diff options
Diffstat (limited to 'freebsd/sys/netinet/libalias')
-rw-r--r-- | freebsd/sys/netinet/libalias/alias.c | 32 | ||||
-rw-r--r-- | freebsd/sys/netinet/libalias/alias_cuseeme.c | 36 | ||||
-rw-r--r-- | freebsd/sys/netinet/libalias/alias_db.c | 21 | ||||
-rw-r--r-- | freebsd/sys/netinet/libalias/alias_dummy.c | 42 | ||||
-rw-r--r-- | freebsd/sys/netinet/libalias/alias_irc.c | 24 | ||||
-rw-r--r-- | freebsd/sys/netinet/libalias/alias_local.h | 2 | ||||
-rw-r--r-- | freebsd/sys/netinet/libalias/alias_mod.c | 192 | ||||
-rw-r--r-- | freebsd/sys/netinet/libalias/alias_mod.h | 138 | ||||
-rw-r--r-- | freebsd/sys/netinet/libalias/alias_nbt.c | 54 | ||||
-rw-r--r-- | freebsd/sys/netinet/libalias/alias_pptp.c | 60 | ||||
-rw-r--r-- | freebsd/sys/netinet/libalias/alias_sctp.h | 1 | ||||
-rw-r--r-- | freebsd/sys/netinet/libalias/alias_skinny.c | 20 | ||||
-rw-r--r-- | freebsd/sys/netinet/libalias/alias_smedia.c | 22 |
13 files changed, 245 insertions, 399 deletions
diff --git a/freebsd/sys/netinet/libalias/alias.c b/freebsd/sys/netinet/libalias/alias.c index 9e975122..a2cd987c 100644 --- a/freebsd/sys/netinet/libalias/alias.c +++ b/freebsd/sys/netinet/libalias/alias.c @@ -1724,7 +1724,7 @@ LibAliasUnLoadAllModule(void) /* Unload all modules then reload everything. */ while ((p = first_handler()) != NULL) { - detach_handler(p); + LibAliasDetachHandlers(p); } while ((t = walk_dll_chain()) != NULL) { dlclose(t->handle); @@ -1751,40 +1751,22 @@ LibAliasUnLoadAllModule(void) struct mbuf * m_megapullup(struct mbuf *m, int len) { struct mbuf *mcl; - + if (len > m->m_pkthdr.len) goto bad; - - /* Do not reallocate packet if it is sequentional, - * writable and has some extra space for expansion. - * XXX: Constant 100bytes is completely empirical. */ -#define RESERVE 100 - if (m->m_next == NULL && M_WRITABLE(m) && M_TRAILINGSPACE(m) >= RESERVE) + + if (m->m_next == NULL && M_WRITABLE(m)) return (m); - if (len <= MCLBYTES - RESERVE) { - mcl = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); - } else if (len < MJUM16BYTES) { - int size; - if (len <= MJUMPAGESIZE - RESERVE) { - size = MJUMPAGESIZE; - } else if (len <= MJUM9BYTES - RESERVE) { - size = MJUM9BYTES; - } else { - size = MJUM16BYTES; - }; - mcl = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, size); - } else { - goto bad; - } + mcl = m_get2(len, M_NOWAIT, MT_DATA, M_PKTHDR); if (mcl == NULL) goto bad; - + m_align(mcl, len); m_move_pkthdr(mcl, m); m_copydata(m, 0, len, mtod(mcl, caddr_t)); mcl->m_len = mcl->m_pkthdr.len = len; m_freem(m); - + return (mcl); bad: m_freem(m); diff --git a/freebsd/sys/netinet/libalias/alias_cuseeme.c b/freebsd/sys/netinet/libalias/alias_cuseeme.c index 1bdb7c4a..d6c9520c 100644 --- a/freebsd/sys/netinet/libalias/alias_cuseeme.c +++ b/freebsd/sys/netinet/libalias/alias_cuseeme.c @@ -58,14 +58,14 @@ __FBSDID("$FreeBSD$"); #define CUSEEME_PORT_NUMBER 7648 static void -AliasHandleCUSeeMeOut(struct libalias *la, struct ip *pip, +AliasHandleCUSeeMeOut(struct libalias *la, struct ip *pip, struct alias_link *lnk); static void -AliasHandleCUSeeMeIn(struct libalias *la, struct ip *pip, +AliasHandleCUSeeMeIn(struct libalias *la, struct ip *pip, struct in_addr original_addr); -static int +static int fingerprint(struct libalias *la, struct alias_data *ah) { @@ -76,7 +76,7 @@ fingerprint(struct libalias *la, struct alias_data *ah) return (-1); } -static int +static int protohandlerin(struct libalias *la, struct ip *pip, struct alias_data *ah) { @@ -84,7 +84,7 @@ protohandlerin(struct libalias *la, struct ip *pip, struct alias_data *ah) return (0); } -static int +static int protohandlerout(struct libalias *la, struct ip *pip, struct alias_data *ah) { @@ -94,20 +94,20 @@ protohandlerout(struct libalias *la, struct ip *pip, struct alias_data *ah) /* Kernel module definition. */ struct proto_handler handlers[] = { - { - .pri = 120, - .dir = OUT, - .proto = UDP, - .fingerprint = &fingerprint, + { + .pri = 120, + .dir = OUT, + .proto = UDP, + .fingerprint = &fingerprint, .protohandler = &protohandlerout - }, + }, { - .pri = 120, - .dir = IN, - .proto = UDP, - .fingerprint = &fingerprint, + .pri = 120, + .dir = IN, + .proto = UDP, + .fingerprint = &fingerprint, .protohandler = &protohandlerin - }, + }, { EOH } }; @@ -132,9 +132,9 @@ mod_handler(module_t mod, int type, void *data) } #ifdef _KERNEL -static +static #endif -moduledata_t +moduledata_t alias_mod = { "alias_cuseeme", mod_handler, NULL }; diff --git a/freebsd/sys/netinet/libalias/alias_db.c b/freebsd/sys/netinet/libalias/alias_db.c index fabe586e..219d5d34 100644 --- a/freebsd/sys/netinet/libalias/alias_db.c +++ b/freebsd/sys/netinet/libalias/alias_db.c @@ -148,6 +148,7 @@ __FBSDID("$FreeBSD$"); #include <machine/stdarg.h> #include <rtems/bsd/sys/param.h> #include <sys/kernel.h> +#include <sys/systm.h> #include <rtems/bsd/sys/lock.h> #include <sys/module.h> #include <sys/rwlock.h> @@ -350,24 +351,16 @@ MODULE_VERSION(libalias, 1); static int alias_mod_handler(module_t mod, int type, void *data) { - int error; switch (type) { - case MOD_LOAD: - error = 0; - handler_chain_init(); - break; case MOD_QUIESCE: case MOD_UNLOAD: - handler_chain_destroy(); finishoff(); - error = 0; - break; + case MOD_LOAD: + return (0); default: - error = EINVAL; + return (EINVAL); } - - return (error); } static moduledata_t alias_mod = { @@ -793,9 +786,9 @@ FindNewPortGroup(struct libalias *la, struct alias_link *search_result; for (j = 0; j < port_count; j++) - if (0 != (search_result = FindLinkIn(la, dst_addr, alias_addr, - dst_port, htons(port_sys + j), - link_type, 0))) + if ((search_result = FindLinkIn(la, dst_addr, + alias_addr, dst_port, htons(port_sys + j), + link_type, 0)) != NULL) break; /* Found a good range, return base */ diff --git a/freebsd/sys/netinet/libalias/alias_dummy.c b/freebsd/sys/netinet/libalias/alias_dummy.c index eacfac86..b4c00c20 100644 --- a/freebsd/sys/netinet/libalias/alias_dummy.c +++ b/freebsd/sys/netinet/libalias/alias_dummy.c @@ -29,7 +29,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -/* +/* * Alias_dummy is just an empty skeleton used to demostrate how to write * a module for libalias, that will run unalterated in userland or in * kernel land. @@ -61,19 +61,19 @@ __FBSDID("$FreeBSD$"); static void AliasHandleDummy(struct libalias *la, struct ip *ip, struct alias_data *ah); -static int +static int fingerprint(struct libalias *la, struct alias_data *ah) { - /* - * Check here all the data that will be used later, if any field + /* + * Check here all the data that will be used later, if any field * is empy/NULL, return a -1 value. */ - if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL || + if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL || ah->maxpktsize == 0) return (-1); - /* - * Fingerprint the incoming packet, if it matches any conditions + /* + * Fingerprint the incoming packet, if it matches any conditions * return an OK value. */ if (ntohs(*ah->dport) == 123 @@ -82,12 +82,12 @@ fingerprint(struct libalias *la, struct alias_data *ah) return (-1); /* I don't recognize this packet. */ } -/* - * Wrap in this general purpose function, the real function used to alias the +/* + * Wrap in this general purpose function, the real function used to alias the * packets. */ -static int +static int protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) { @@ -95,22 +95,22 @@ protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) return (0); } -/* - * NOTA BENE: the next variable MUST NOT be renamed in any case if you want - * your module to work in userland, cause it's used to find and use all +/* + * NOTA BENE: the next variable MUST NOT be renamed in any case if you want + * your module to work in userland, cause it's used to find and use all * the protocol handlers present in every module. - * So WATCH OUT, your module needs this variables and it needs it with + * So WATCH OUT, your module needs this variables and it needs it with * ITS EXACT NAME: handlers. */ struct proto_handler handlers [] = { - { - .pri = 666, - .dir = IN|OUT, - .proto = UDP|TCP, - .fingerprint = &fingerprint, + { + .pri = 666, + .dir = IN|OUT, + .proto = UDP|TCP, + .fingerprint = &fingerprint, .protohandler = &protohandler - }, + }, { EOH } }; @@ -119,7 +119,7 @@ mod_handler(module_t mod, int type, void *data) { int error; - switch (type) { + switch (type) { case MOD_LOAD: error = 0; LibAliasAttachHandlers(handlers); diff --git a/freebsd/sys/netinet/libalias/alias_irc.c b/freebsd/sys/netinet/libalias/alias_irc.c index 880d897e..44ff6d92 100644 --- a/freebsd/sys/netinet/libalias/alias_irc.c +++ b/freebsd/sys/netinet/libalias/alias_irc.c @@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$"); Version 2.1: May, 1997 (cjm) Very minor changes to conform with local/global/function naming conventions - withing the packet alising module. + within the packet alising module. */ /* Includes */ @@ -94,11 +94,11 @@ static void AliasHandleIrcOut(struct libalias *, struct ip *, struct alias_link *, int maxpacketsize); -static int +static int fingerprint(struct libalias *la, struct alias_data *ah) { - if (ah->dport == NULL || ah->dport == NULL || ah->lnk == NULL || + if (ah->dport == NULL || ah->dport == NULL || ah->lnk == NULL || ah->maxpktsize == 0) return (-1); if (ntohs(*ah->dport) == IRC_CONTROL_PORT_NUMBER_1 @@ -107,7 +107,7 @@ fingerprint(struct libalias *la, struct alias_data *ah) return (-1); } -static int +static int protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) { @@ -120,13 +120,13 @@ protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) } struct proto_handler handlers[] = { - { - .pri = 90, - .dir = OUT, - .proto = TCP, - .fingerprint = &fingerprint, + { + .pri = 90, + .dir = OUT, + .proto = TCP, + .fingerprint = &fingerprint, .protohandler = &protohandler - }, + }, { EOH } }; @@ -151,7 +151,7 @@ mod_handler(module_t mod, int type, void *data) } #ifdef _KERNEL -static +static #endif moduledata_t alias_mod = { "alias_irc", mod_handler, NULL @@ -484,7 +484,7 @@ lPACKET_DONE: which will generate a type-error on all but 32-bit machines. [Note 2] This routine really ought to be replaced with one that - creates a transparent proxy on the aliasing host, to allow arbitary + creates a transparent proxy on the aliasing host, to allow arbitrary changes in the TCP stream. This should not be too difficult given this base; I (ee) will try to do this some time later. */ diff --git a/freebsd/sys/netinet/libalias/alias_local.h b/freebsd/sys/netinet/libalias/alias_local.h index a7b3fe19..3010be84 100644 --- a/freebsd/sys/netinet/libalias/alias_local.h +++ b/freebsd/sys/netinet/libalias/alias_local.h @@ -357,7 +357,7 @@ void PunchFWHole(struct alias_link *_lnk); /* Housekeeping function */ void HouseKeeping(struct libalias *); -/* Tcp specfic routines */ +/* Tcp specific routines */ /* lint -save -library Suppress flexelint warnings */ /* Transparent proxy routines */ diff --git a/freebsd/sys/netinet/libalias/alias_mod.c b/freebsd/sys/netinet/libalias/alias_mod.c index 0e0bd56a..6acbbee6 100644 --- a/freebsd/sys/netinet/libalias/alias_mod.c +++ b/freebsd/sys/netinet/libalias/alias_mod.c @@ -54,201 +54,82 @@ __FBSDID("$FreeBSD$"); #endif /* Protocol and userland module handlers chains. */ -LIST_HEAD(handler_chain, proto_handler) handler_chain = LIST_HEAD_INITIALIZER(handler_chain); -#ifdef _KERNEL -struct rwlock handler_rw; -#endif -SLIST_HEAD(dll_chain, dll) dll_chain = SLIST_HEAD_INITIALIZER(dll_chain); - -#ifdef _KERNEL - -#define LIBALIAS_RWLOCK_INIT() \ - rw_init(&handler_rw, "Libalias_modules_rwlock") -#define LIBALIAS_RWLOCK_DESTROY() rw_destroy(&handler_rw) -#define LIBALIAS_WLOCK_ASSERT() \ - rw_assert(&handler_rw, RA_WLOCKED) - -static __inline void -LIBALIAS_RLOCK(void) -{ - rw_rlock(&handler_rw); -} - -static __inline void -LIBALIAS_RUNLOCK(void) -{ - rw_runlock(&handler_rw); -} - -static __inline void -LIBALIAS_WLOCK(void) -{ - rw_wlock(&handler_rw); -} - -static __inline void -LIBALIAS_WUNLOCK(void) -{ - rw_wunlock(&handler_rw); -} - -static void -_handler_chain_init(void) -{ - - if (!rw_initialized(&handler_rw)) - LIBALIAS_RWLOCK_INIT(); -} - -static void -_handler_chain_destroy(void) -{ - - if (rw_initialized(&handler_rw)) - LIBALIAS_RWLOCK_DESTROY(); -} - -#else -#define LIBALIAS_RWLOCK_INIT() ; -#define LIBALIAS_RWLOCK_DESTROY() ; -#define LIBALIAS_WLOCK_ASSERT() ; -#define LIBALIAS_RLOCK() ; -#define LIBALIAS_RUNLOCK() ; -#define LIBALIAS_WLOCK() ; -#define LIBALIAS_WUNLOCK() ; -#define _handler_chain_init() ; -#define _handler_chain_destroy() ; -#endif - -void -handler_chain_init(void) -{ - _handler_chain_init(); -} - -void -handler_chain_destroy(void) -{ - _handler_chain_destroy(); -} +static TAILQ_HEAD(handler_chain, proto_handler) handler_chain = + TAILQ_HEAD_INITIALIZER(handler_chain); static int -_attach_handler(struct proto_handler *p) +attach_handler(struct proto_handler *p) { struct proto_handler *b; - LIBALIAS_WLOCK_ASSERT(); - b = NULL; - LIST_FOREACH(b, &handler_chain, entries) { - if ((b->pri == p->pri) && + TAILQ_FOREACH(b, &handler_chain, link) { + if ((b->pri == p->pri) && (b->dir == p->dir) && (b->proto == p->proto)) - return (EEXIST); /* Priority conflict. */ + return (EEXIST); if (b->pri > p->pri) { - LIST_INSERT_BEFORE(b, p, entries); + TAILQ_INSERT_BEFORE(b, p, link); return (0); } } - /* End of list or found right position, inserts here. */ - if (b) - LIST_INSERT_AFTER(b, p, entries); - else - LIST_INSERT_HEAD(&handler_chain, p, entries); - return (0); -} -static int -_detach_handler(struct proto_handler *p) -{ - struct proto_handler *b, *b_tmp; + TAILQ_INSERT_TAIL(&handler_chain, p, link); - LIBALIAS_WLOCK_ASSERT(); - LIST_FOREACH_SAFE(b, &handler_chain, entries, b_tmp) { - if (b == p) { - LIST_REMOVE(b, entries); - return (0); - } - } - return (ENOENT); /* Handler not found. */ + return (0); } int -LibAliasAttachHandlers(struct proto_handler *_p) +LibAliasAttachHandlers(struct proto_handler *p) { - int i, error; + int error; - LIBALIAS_WLOCK(); - error = -1; - for (i = 0; 1; i++) { - if (*((int *)&_p[i]) == EOH) - break; - error = _attach_handler(&_p[i]); - if (error != 0) - break; + while (p->dir != NODIR) { + error = attach_handler(p); + if (error) + return (error); + p++; } - LIBALIAS_WUNLOCK(); - return (error); + + return (0); } +/* XXXGL: should be void, but no good reason to break ABI */ int -LibAliasDetachHandlers(struct proto_handler *_p) +LibAliasDetachHandlers(struct proto_handler *p) { - int i, error; - LIBALIAS_WLOCK(); - error = -1; - for (i = 0; 1; i++) { - if (*((int *)&_p[i]) == EOH) - break; - error = _detach_handler(&_p[i]); - if (error != 0) - break; + while (p->dir != NODIR) { + TAILQ_REMOVE(&handler_chain, p, link); + p++; } - LIBALIAS_WUNLOCK(); - return (error); -} - -int -detach_handler(struct proto_handler *_p) -{ - int error; - LIBALIAS_WLOCK(); - error = -1; - error = _detach_handler(_p); - LIBALIAS_WUNLOCK(); - return (error); + return (0); } int -find_handler(int8_t dir, int8_t proto, struct libalias *la, __unused struct ip *pip, +find_handler(int8_t dir, int8_t proto, struct libalias *la, struct ip *ip, struct alias_data *ad) { struct proto_handler *p; - int error; - LIBALIAS_RLOCK(); - error = ENOENT; - LIST_FOREACH(p, &handler_chain, entries) { - if ((p->dir & dir) && (p->proto & proto)) - if (p->fingerprint(la, ad) == 0) { - error = p->protohandler(la, pip, ad); - break; - } - } - LIBALIAS_RUNLOCK(); - return (error); + TAILQ_FOREACH(p, &handler_chain, link) + if ((p->dir & dir) && (p->proto & proto) && + p->fingerprint(la, ad) == 0) + return (p->protohandler(la, ip, ad)); + + return (ENOENT); } struct proto_handler * first_handler(void) { - - return (LIST_FIRST(&handler_chain)); + + return (TAILQ_FIRST(&handler_chain)); } +#ifndef _KERNEL /* Dll manipulation code - this code is not thread safe... */ - +SLIST_HEAD(dll_chain, dll) dll_chain = SLIST_HEAD_INITIALIZER(dll_chain); int attach_dll(struct dll *p) { @@ -272,7 +153,7 @@ detach_dll(char *p) error = NULL; SLIST_FOREACH_SAFE(b, &dll_chain, next, b_tmp) if (!strncmp(b->name, p, DLL_LEN)) { - SLIST_REMOVE(&dll_chain, b, dll, next); + SLIST_REMOVE(&dll_chain, b, dll, next); error = b; break; } @@ -290,3 +171,4 @@ walk_dll_chain(void) SLIST_REMOVE_HEAD(&dll_chain, next); return (t); } +#endif /* !_KERNEL */ diff --git a/freebsd/sys/netinet/libalias/alias_mod.h b/freebsd/sys/netinet/libalias/alias_mod.h index 727df8e6..fd020c46 100644 --- a/freebsd/sys/netinet/libalias/alias_mod.h +++ b/freebsd/sys/netinet/libalias/alias_mod.h @@ -54,102 +54,92 @@ MALLOC_DECLARE(M_ALIAS); #endif #endif -/* Protocol handlers struct & function. */ +/* Packet flow direction flags. */ +#define IN 0x0001 +#define OUT 0x0002 +#define NODIR 0x4000 -/* Packet flow direction. */ -#define IN 1 -#define OUT 2 +/* Working protocol flags. */ +#define IP 0x01 +#define TCP 0x02 +#define UDP 0x04 -/* Working protocol. */ -#define IP 1 -#define TCP 2 -#define UDP 4 - -/* +/* * Data passed to protocol handler module, it must be filled * right before calling find_handler() to determine which * module is elegible to be called. */ +struct alias_data { + struct alias_link *lnk; + struct in_addr *oaddr; /* Original address. */ + struct in_addr *aaddr; /* Alias address. */ + uint16_t *aport; /* Alias port. */ + uint16_t *sport, *dport; /* Source & destination port */ + uint16_t maxpktsize; /* Max packet size. */ +}; -struct alias_data { - struct alias_link *lnk; - struct in_addr *oaddr; /* Original address. */ - struct in_addr *aaddr; /* Alias address. */ - uint16_t *aport; /* Alias port. */ - uint16_t *sport, *dport; /* Source & destination port */ - uint16_t maxpktsize; /* Max packet size. */ -}; - -/* +/* * This structure contains all the information necessary to make * a protocol handler correctly work. */ - struct proto_handler { - u_int pri; /* Handler priority. */ - int16_t dir; /* Flow direction. */ - uint8_t proto; /* Working protocol. */ - int (*fingerprint)(struct libalias *, /* Fingerprint * function. */ - struct alias_data *); - int (*protohandler)(struct libalias *, /* Aliasing * function. */ - struct ip *, struct alias_data *); - LIST_ENTRY(proto_handler) entries; + u_int pri; /* Handler priority. */ + int16_t dir; /* Flow direction. */ + uint8_t proto; /* Working protocol. */ + /* Fingerprint * function. */ + int (*fingerprint)(struct libalias *, struct alias_data *); + /* Aliasing * function. */ + int (*protohandler)(struct libalias *, struct ip *, + struct alias_data *); + TAILQ_ENTRY(proto_handler) link; }; +/* End of handlers. */ +#define EOH .dir = NODIR -/* +/* Functions used with protocol handlers. */ +int LibAliasAttachHandlers(struct proto_handler *); +int LibAliasDetachHandlers(struct proto_handler *); +int find_handler(int8_t, int8_t, struct libalias *, struct ip *, + struct alias_data *); +struct proto_handler *first_handler(void); + +#ifndef _KERNEL +/* * Used only in userland when libalias needs to keep track of all * module loaded. In kernel land (kld mode) we don't need to care * care about libalias modules cause it's kld to do it for us. */ - -#define DLL_LEN 32 -struct dll { - char name[DLL_LEN]; /* Name of module. */ - void *handle; /* - * Ptr to shared obj obtained through - * dlopen() - use this ptr to get access - * to any symbols from a loaded module - * via dlsym(). - */ - SLIST_ENTRY(dll) next; +#define DLL_LEN 32 +struct dll { + char name[DLL_LEN]; /* Name of module. */ + void *handle; /* + * Ptr to shared obj obtained through + * dlopen() - use this ptr to get access + * to any symbols from a loaded module + * via dlsym(). + */ + SLIST_ENTRY(dll) next; }; -/* Functions used with protocol handlers. */ - -void handler_chain_init(void); -void handler_chain_destroy(void); -int LibAliasAttachHandlers(struct proto_handler *); -int LibAliasDetachHandlers(struct proto_handler *); -int detach_handler(struct proto_handler *); -int find_handler(int8_t, int8_t, struct libalias *, - struct ip *, struct alias_data *); -struct proto_handler *first_handler(void); - /* Functions used with dll module. */ +void dll_chain_init(void); +void dll_chain_destroy(void); +int attach_dll(struct dll *); +void *detach_dll(char *); +struct dll *walk_dll_chain(void); -void dll_chain_init(void); -void dll_chain_destroy(void); -int attach_dll(struct dll *); -void *detach_dll(char *); -struct dll *walk_dll_chain(void); - -/* End of handlers. */ -#define EOH -1 - -/* +/* * Some defines borrowed from sys/module.h used to compile a kld * in userland as a shared lib. */ - -#ifndef _KERNEL typedef enum modeventtype { - MOD_LOAD, - MOD_UNLOAD, - MOD_SHUTDOWN, - MOD_QUIESCE + MOD_LOAD, + MOD_UNLOAD, + MOD_SHUTDOWN, + MOD_QUIESCE } modeventtype_t; - + typedef struct module *module_t; typedef int (*modeventhand_t)(module_t, int /* modeventtype_t */, void *); @@ -157,10 +147,10 @@ typedef int (*modeventhand_t)(module_t, int /* modeventtype_t */, void *); * Struct for registering modules statically via SYSINIT. */ typedef struct moduledata { - const char *name; /* module name */ - modeventhand_t evhand; /* event handler */ - void *priv; /* extra data */ + const char *name; /* module name */ + modeventhand_t evhand; /* event handler */ + void *priv; /* extra data */ } moduledata_t; -#endif +#endif /* !_KERNEL */ -#endif /* !_ALIAS_MOD_H_ */ +#endif /* !_ALIAS_MOD_H_ */ diff --git a/freebsd/sys/netinet/libalias/alias_nbt.c b/freebsd/sys/netinet/libalias/alias_nbt.c index 5a917872..c10f9b48 100644 --- a/freebsd/sys/netinet/libalias/alias_nbt.c +++ b/freebsd/sys/netinet/libalias/alias_nbt.c @@ -72,17 +72,17 @@ __FBSDID("$FreeBSD$"); #define NETBIOS_DGM_PORT_NUMBER 138 static int -AliasHandleUdpNbt(struct libalias *, struct ip *, struct alias_link *, +AliasHandleUdpNbt(struct libalias *, struct ip *, struct alias_link *, struct in_addr *, u_short); static int AliasHandleUdpNbtNS(struct libalias *, struct ip *, struct alias_link *, struct in_addr *, u_short *, struct in_addr *, u_short *); -static int +static int fingerprint1(struct libalias *la, struct alias_data *ah) { - if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL || + if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL || ah->aaddr == NULL || ah->aport == NULL) return (-1); if (ntohs(*ah->dport) == NETBIOS_DGM_PORT_NUMBER @@ -91,18 +91,18 @@ fingerprint1(struct libalias *la, struct alias_data *ah) return (-1); } -static int +static int protohandler1(struct libalias *la, struct ip *pip, struct alias_data *ah) { return (AliasHandleUdpNbt(la, pip, ah->lnk, ah->aaddr, *ah->aport)); } -static int +static int fingerprint2(struct libalias *la, struct alias_data *ah) { - if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL || + if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL || ah->aaddr == NULL || ah->aport == NULL) return (-1); if (ntohs(*ah->dport) == NETBIOS_NS_PORT_NUMBER @@ -111,7 +111,7 @@ fingerprint2(struct libalias *la, struct alias_data *ah) return (-1); } -static int +static int protohandler2in(struct libalias *la, struct ip *pip, struct alias_data *ah) { @@ -120,7 +120,7 @@ protohandler2in(struct libalias *la, struct ip *pip, struct alias_data *ah) return (0); } -static int +static int protohandler2out(struct libalias *la, struct ip *pip, struct alias_data *ah) { @@ -130,27 +130,27 @@ protohandler2out(struct libalias *la, struct ip *pip, struct alias_data *ah) /* Kernel module definition. */ struct proto_handler handlers[] = { - { - .pri = 130, - .dir = IN|OUT, - .proto = UDP, - .fingerprint = &fingerprint1, + { + .pri = 130, + .dir = IN|OUT, + .proto = UDP, + .fingerprint = &fingerprint1, .protohandler = &protohandler1 - }, - { - .pri = 140, - .dir = IN, - .proto = UDP, - .fingerprint = &fingerprint2, + }, + { + .pri = 140, + .dir = IN, + .proto = UDP, + .fingerprint = &fingerprint2, .protohandler = &protohandler2in - }, - { - .pri = 140, - .dir = OUT, - .proto = UDP, - .fingerprint = &fingerprint2, + }, + { + .pri = 140, + .dir = OUT, + .proto = UDP, + .fingerprint = &fingerprint2, .protohandler = &protohandler2out - }, + }, { EOH } }; @@ -175,7 +175,7 @@ mod_handler(module_t mod, int type, void *data) } #ifdef _KERNEL -static +static #endif moduledata_t alias_mod = { "alias_nbt", mod_handler, NULL diff --git a/freebsd/sys/netinet/libalias/alias_pptp.c b/freebsd/sys/netinet/libalias/alias_pptp.c index e8205db0..39861c5c 100644 --- a/freebsd/sys/netinet/libalias/alias_pptp.c +++ b/freebsd/sys/netinet/libalias/alias_pptp.c @@ -80,7 +80,7 @@ AliasHandlePptpGreOut(struct libalias *, struct ip *); static int AliasHandlePptpGreIn(struct libalias *, struct ip *); -static int +static int fingerprint(struct libalias *la, struct alias_data *ah) { @@ -92,14 +92,14 @@ fingerprint(struct libalias *la, struct alias_data *ah) return (-1); } -static int +static int fingerprintgre(struct libalias *la, struct alias_data *ah) { return (0); } -static int +static int protohandlerin(struct libalias *la, struct ip *pip, struct alias_data *ah) { @@ -107,7 +107,7 @@ protohandlerin(struct libalias *la, struct ip *pip, struct alias_data *ah) return (0); } -static int +static int protohandlerout(struct libalias *la, struct ip *pip, struct alias_data *ah) { @@ -115,7 +115,7 @@ protohandlerout(struct libalias *la, struct ip *pip, struct alias_data *ah) return (0); } -static int +static int protohandlergrein(struct libalias *la, struct ip *pip, struct alias_data *ah) { @@ -125,7 +125,7 @@ protohandlergrein(struct libalias *la, struct ip *pip, struct alias_data *ah) return (-1); } -static int +static int protohandlergreout(struct libalias *la, struct ip *pip, struct alias_data *ah) { @@ -136,39 +136,39 @@ protohandlergreout(struct libalias *la, struct ip *pip, struct alias_data *ah) /* Kernel module definition. */ struct proto_handler handlers[] = { - { - .pri = 200, - .dir = IN, - .proto = TCP, - .fingerprint = &fingerprint, + { + .pri = 200, + .dir = IN, + .proto = TCP, + .fingerprint = &fingerprint, .protohandler = &protohandlerin }, - { - .pri = 210, - .dir = OUT, - .proto = TCP, - .fingerprint = &fingerprint, + { + .pri = 210, + .dir = OUT, + .proto = TCP, + .fingerprint = &fingerprint, .protohandler = &protohandlerout }, -/* - * WATCH OUT!!! these 2 handlers NEED a priority of INT_MAX (highest possible) +/* + * WATCH OUT!!! these 2 handlers NEED a priority of INT_MAX (highest possible) * cause they will ALWAYS process packets, so they must be the last one * in chain: look fingerprintgre() above. */ - { - .pri = INT_MAX, - .dir = IN, - .proto = IP, - .fingerprint = &fingerprintgre, + { + .pri = INT_MAX, + .dir = IN, + .proto = IP, + .fingerprint = &fingerprintgre, .protohandler = &protohandlergrein }, - { - .pri = INT_MAX, - .dir = OUT, - .proto = IP, - .fingerprint = &fingerprintgre, + { + .pri = INT_MAX, + .dir = OUT, + .proto = IP, + .fingerprint = &fingerprintgre, .protohandler = &protohandlergreout - }, + }, { EOH } }; static int @@ -192,7 +192,7 @@ mod_handler(module_t mod, int type, void *data) } #ifdef _KERNEL -static +static #endif moduledata_t alias_mod = { "alias_pptp", mod_handler, NULL diff --git a/freebsd/sys/netinet/libalias/alias_sctp.h b/freebsd/sys/netinet/libalias/alias_sctp.h index 840917ad..99cceee4 100644 --- a/freebsd/sys/netinet/libalias/alias_sctp.h +++ b/freebsd/sys/netinet/libalias/alias_sctp.h @@ -92,7 +92,6 @@ #ifndef _KERNEL #include <stdlib.h> #include <stdio.h> -#include <curses.h> #endif //#ifdef _KERNEL diff --git a/freebsd/sys/netinet/libalias/alias_skinny.c b/freebsd/sys/netinet/libalias/alias_skinny.c index 9f292916..b1f8f8c7 100644 --- a/freebsd/sys/netinet/libalias/alias_skinny.c +++ b/freebsd/sys/netinet/libalias/alias_skinny.c @@ -58,7 +58,7 @@ static void AliasHandleSkinny(struct libalias *, struct ip *, struct alias_link *); -static int +static int fingerprint(struct libalias *la, struct alias_data *ah) { @@ -70,7 +70,7 @@ fingerprint(struct libalias *la, struct alias_data *ah) return (-1); } -static int +static int protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) { @@ -79,13 +79,13 @@ protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) } struct proto_handler handlers[] = { - { - .pri = 110, - .dir = IN|OUT, - .proto = TCP, - .fingerprint = &fingerprint, + { + .pri = 110, + .dir = IN|OUT, + .proto = TCP, + .fingerprint = &fingerprint, .protohandler = &protohandler - }, + }, { EOH } }; @@ -110,7 +110,7 @@ mod_handler(module_t mod, int type, void *data) } #ifdef _KERNEL -static +static #endif moduledata_t alias_mod = { "alias_skinny", mod_handler, NULL @@ -342,7 +342,7 @@ AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *lnk) * through the packet using len to determine message boundaries. * This comes into play big time with port messages being in the * same packet as register messages. Also, open receive channel - * acks are usually buried in a pakcet some 400 bytes long. + * acks are usually buried in a packet some 400 bytes long. */ while (dlen >= skinny_hdr_len) { len = (sd->len); diff --git a/freebsd/sys/netinet/libalias/alias_smedia.c b/freebsd/sys/netinet/libalias/alias_smedia.c index 47ae2748..9578a4af 100644 --- a/freebsd/sys/netinet/libalias/alias_smedia.c +++ b/freebsd/sys/netinet/libalias/alias_smedia.c @@ -133,14 +133,14 @@ __FBSDID("$FreeBSD$"); static void AliasHandleRtspOut(struct libalias *, struct ip *, struct alias_link *, int maxpacketsize); -static int +static int fingerprint(struct libalias *la, struct alias_data *ah) { if (ah->dport != NULL && ah->aport != NULL && ah->sport != NULL && ntohs(*ah->dport) == TFTP_PORT_NUMBER) return (0); - if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL || + if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL || ah->maxpktsize == 0) return (-1); if (ntohs(*ah->dport) == RTSP_CONTROL_PORT_NUMBER_1 @@ -151,7 +151,7 @@ fingerprint(struct libalias *la, struct alias_data *ah) return (-1); } -static int +static int protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) { @@ -163,13 +163,13 @@ protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) } struct proto_handler handlers[] = { - { - .pri = 100, - .dir = OUT, + { + .pri = 100, + .dir = OUT, .proto = TCP|UDP, - .fingerprint = &fingerprint, + .fingerprint = &fingerprint, .protohandler = &protohandler - }, + }, { EOH } }; @@ -194,7 +194,7 @@ mod_handler(module_t mod, int type, void *data) } #ifdef _KERNEL -static +static #endif moduledata_t alias_mod = { "alias_smedia", mod_handler, NULL @@ -408,7 +408,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip, SetAckModified(lnk); tc = (struct tcphdr *)ip_next(pip); delta = GetDeltaSeqOut(tc->th_seq, lnk); - AddSeq(lnk, delta + new_dlen - dlen, pip->ip_hl, pip->ip_len, + AddSeq(lnk, delta + new_dlen - dlen, pip->ip_hl, pip->ip_len, tc->th_seq, tc->th_off); new_len = htons(hlen + new_dlen); @@ -520,7 +520,7 @@ AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *lnk, /* * When aliasing a server, check for the 200 reply - * Accomodate varying number of blanks between 200 & OK + * Accommodate varying number of blanks between 200 & OK */ if (dlen >= (int)strlen(str200)) { |