Deleted Added
full compact
alias_cuseeme.c (190841) alias_cuseeme.c (259858)
1/*-
2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
3 * with the aid of code written by
4 * Junichi SATOH <junichi@astec.co.jp> 1996, 1997.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 13 unchanged lines hidden (view full) ---

22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
3 * with the aid of code written by
4 * Junichi SATOH <junichi@astec.co.jp> 1996, 1997.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 13 unchanged lines hidden (view full) ---

22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/netinet/libalias/alias_cuseeme.c 190841 2009-04-08 11:56:49Z piso $");
30__FBSDID("$FreeBSD: head/sys/netinet/libalias/alias_cuseeme.c 259858 2013-12-25 02:06:57Z glebius $");
31
32#ifdef _KERNEL
33#include <sys/param.h>
34#include <sys/kernel.h>
35#include <sys/module.h>
36#else
37#include <errno.h>
38#include <sys/types.h>

--- 12 unchanged lines hidden (view full) ---

51#else
52#include "alias_local.h"
53#include "alias_mod.h"
54#endif
55
56#define CUSEEME_PORT_NUMBER 7648
57
58static void
31
32#ifdef _KERNEL
33#include <sys/param.h>
34#include <sys/kernel.h>
35#include <sys/module.h>
36#else
37#include <errno.h>
38#include <sys/types.h>

--- 12 unchanged lines hidden (view full) ---

51#else
52#include "alias_local.h"
53#include "alias_mod.h"
54#endif
55
56#define CUSEEME_PORT_NUMBER 7648
57
58static void
59AliasHandleCUSeeMeOut(struct libalias *la, struct ip *pip,
59AliasHandleCUSeeMeOut(struct libalias *la, struct ip *pip,
60 struct alias_link *lnk);
61
62static void
60 struct alias_link *lnk);
61
62static void
63AliasHandleCUSeeMeIn(struct libalias *la, struct ip *pip,
63AliasHandleCUSeeMeIn(struct libalias *la, struct ip *pip,
64 struct in_addr original_addr);
65
64 struct in_addr original_addr);
65
66static int
66static int
67fingerprint(struct libalias *la, struct alias_data *ah)
68{
69
70 if (ah->dport == NULL || ah->oaddr == NULL)
71 return (-1);
72 if (ntohs(*ah->dport) == CUSEEME_PORT_NUMBER)
73 return (0);
74 return (-1);
75}
76
67fingerprint(struct libalias *la, struct alias_data *ah)
68{
69
70 if (ah->dport == NULL || ah->oaddr == NULL)
71 return (-1);
72 if (ntohs(*ah->dport) == CUSEEME_PORT_NUMBER)
73 return (0);
74 return (-1);
75}
76
77static int
77static int
78protohandlerin(struct libalias *la, struct ip *pip, struct alias_data *ah)
79{
80
81 AliasHandleCUSeeMeIn(la, pip, *ah->oaddr);
82 return (0);
83}
84
78protohandlerin(struct libalias *la, struct ip *pip, struct alias_data *ah)
79{
80
81 AliasHandleCUSeeMeIn(la, pip, *ah->oaddr);
82 return (0);
83}
84
85static int
85static int
86protohandlerout(struct libalias *la, struct ip *pip, struct alias_data *ah)
87{
88
89 AliasHandleCUSeeMeOut(la, pip, ah->lnk);
90 return (0);
91}
92
93/* Kernel module definition. */
94struct proto_handler handlers[] = {
86protohandlerout(struct libalias *la, struct ip *pip, struct alias_data *ah)
87{
88
89 AliasHandleCUSeeMeOut(la, pip, ah->lnk);
90 return (0);
91}
92
93/* Kernel module definition. */
94struct proto_handler handlers[] = {
95 {
96 .pri = 120,
97 .dir = OUT,
98 .proto = UDP,
99 .fingerprint = &fingerprint,
95 {
96 .pri = 120,
97 .dir = OUT,
98 .proto = UDP,
99 .fingerprint = &fingerprint,
100 .protohandler = &protohandlerout
100 .protohandler = &protohandlerout
101 },
101 },
102 {
102 {
103 .pri = 120,
104 .dir = IN,
105 .proto = UDP,
106 .fingerprint = &fingerprint,
103 .pri = 120,
104 .dir = IN,
105 .proto = UDP,
106 .fingerprint = &fingerprint,
107 .protohandler = &protohandlerin
107 .protohandler = &protohandlerin
108 },
108 },
109 { EOH }
110};
111
112static int
113mod_handler(module_t mod, int type, void *data)
114{
115 int error;
116

--- 8 unchanged lines hidden (view full) ---

125 break;
126 default:
127 error = EINVAL;
128 }
129 return (error);
130}
131
132#ifdef _KERNEL
109 { EOH }
110};
111
112static int
113mod_handler(module_t mod, int type, void *data)
114{
115 int error;
116

--- 8 unchanged lines hidden (view full) ---

125 break;
126 default:
127 error = EINVAL;
128 }
129 return (error);
130}
131
132#ifdef _KERNEL
133static
133static
134#endif
134#endif
135moduledata_t
135moduledata_t
136alias_mod = {
137 "alias_cuseeme", mod_handler, NULL
138};
139
140#ifdef _KERNEL
141DECLARE_MODULE(alias_cuseeme, alias_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND);
142MODULE_VERSION(alias_cuseeme, 1);
143MODULE_DEPEND(alias_cuseeme, libalias, 1, 1, 1);

--- 85 unchanged lines hidden ---
136alias_mod = {
137 "alias_cuseeme", mod_handler, NULL
138};
139
140#ifdef _KERNEL
141DECLARE_MODULE(alias_cuseeme, alias_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND);
142MODULE_VERSION(alias_cuseeme, 1);
143MODULE_DEPEND(alias_cuseeme, libalias, 1, 1, 1);

--- 85 unchanged lines hidden ---