Date: Mon, 5 Sep 2005 15:35:45 GMT From: soc-pisati <soc-pisati@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 83130 for review Message-ID: <200509051535.j85FZj7j089307@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=83130 Change 83130 by soc-pisati@soc-pisati_longino on 2005/09/05 15:35:43 Cosmetic fixes: -renamed layer to proto in struct proto_handler -word aligned struct proto_handler moving dir and proto from int8_t to int16_t -removed useless names of fingerprint and protocol handler functions from struct proto_handler -rename [attach|detach]_handler to [attach|detach]_handlers -updated readme.txt to reflect changes -fixed fix_base.sh -and something else that i probably forgot now.. :P Affected files ... .. //depot/projects/soc2005/libalias/Makefile#4 edit .. //depot/projects/soc2005/libalias/fix-base.sh#2 edit .. //depot/projects/soc2005/libalias/ipfw2-4/Makefile#2 edit .. //depot/projects/soc2005/libalias/ipfw2-4/kld/Makefile#2 edit .. //depot/projects/soc2005/libalias/ipfw2-4/kld/in.h#2 edit .. //depot/projects/soc2005/libalias/ipfw2-4/kld/ip_fw.c#2 edit .. //depot/projects/soc2005/libalias/ipfw2-4/kld/ip_fw.h#2 edit .. //depot/projects/soc2005/libalias/ipfw2-4/kld/ip_fw2.c#2 edit .. //depot/projects/soc2005/libalias/ipfw2-4/kld/ip_fw2.h#2 edit .. //depot/projects/soc2005/libalias/ipfw2-4/kld/raw_ip.c#2 edit .. //depot/projects/soc2005/libalias/ipfw2-4/sbin/Makefile#2 edit .. //depot/projects/soc2005/libalias/ipfw2-4/sbin/ipfw.8#2 edit .. //depot/projects/soc2005/libalias/ipfw2-4/sbin/ipfw.c#2 edit .. //depot/projects/soc2005/libalias/ipfw2-4/sbin/ipfw2.c#2 edit .. //depot/projects/soc2005/libalias/ipfw2-5/Makefile#2 edit .. //depot/projects/soc2005/libalias/ipfw2-5/kld/Makefile#2 edit .. //depot/projects/soc2005/libalias/ipfw2-5/kld/in.h#2 edit .. //depot/projects/soc2005/libalias/ipfw2-5/kld/ip_fw.h#2 edit .. //depot/projects/soc2005/libalias/ipfw2-5/kld/ip_fw2.c#2 edit .. //depot/projects/soc2005/libalias/ipfw2-5/kld/ip_fw_pfil.c#2 edit .. //depot/projects/soc2005/libalias/ipfw2-5/kld/raw_ip.c#2 edit .. //depot/projects/soc2005/libalias/ipfw2-5/sbin/Makefile#2 edit .. //depot/projects/soc2005/libalias/ipfw2-5/sbin/ipfw.8#2 edit .. //depot/projects/soc2005/libalias/ipfw2-5/sbin/ipfw2.c#2 edit .. //depot/projects/soc2005/libalias/ipfw2-6/Makefile#2 edit .. //depot/projects/soc2005/libalias/ipfw2-6/kld/Makefile#2 edit .. //depot/projects/soc2005/libalias/ipfw2-6/kld/in.h#2 edit .. //depot/projects/soc2005/libalias/ipfw2-6/kld/ip_fw.h#2 edit .. //depot/projects/soc2005/libalias/ipfw2-6/kld/ip_fw2.c#2 edit .. //depot/projects/soc2005/libalias/ipfw2-6/kld/ip_fw_pfil.c#2 edit .. //depot/projects/soc2005/libalias/ipfw2-6/kld/raw_ip.c#2 edit .. //depot/projects/soc2005/libalias/ipfw2-6/sbin/Makefile#2 edit .. //depot/projects/soc2005/libalias/ipfw2-6/sbin/ipfw.8#2 edit .. //depot/projects/soc2005/libalias/ipfw2-6/sbin/ipfw2.c#2 edit .. //depot/projects/soc2005/libalias/libalias/HISTORY#2 edit .. //depot/projects/soc2005/libalias/libalias/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/alias.c#2 edit .. //depot/projects/soc2005/libalias/libalias/alias.h#2 edit .. //depot/projects/soc2005/libalias/libalias/alias_cuseeme.c#2 edit .. //depot/projects/soc2005/libalias/libalias/alias_db.c#2 edit .. //depot/projects/soc2005/libalias/libalias/alias_dummy.c#2 edit .. //depot/projects/soc2005/libalias/libalias/alias_ftp.c#2 edit .. //depot/projects/soc2005/libalias/libalias/alias_irc.c#2 edit .. //depot/projects/soc2005/libalias/libalias/alias_local.h#2 edit .. //depot/projects/soc2005/libalias/libalias/alias_mod.c#2 edit .. //depot/projects/soc2005/libalias/libalias/alias_mod.h#2 edit .. //depot/projects/soc2005/libalias/libalias/alias_nbt.c#2 edit .. //depot/projects/soc2005/libalias/libalias/alias_old.c#2 edit .. //depot/projects/soc2005/libalias/libalias/alias_pptp.c#2 edit .. //depot/projects/soc2005/libalias/libalias/alias_proxy.c#2 edit .. //depot/projects/soc2005/libalias/libalias/alias_skinny.c#2 edit .. //depot/projects/soc2005/libalias/libalias/alias_smedia.c#2 edit .. //depot/projects/soc2005/libalias/libalias/alias_util.c#2 edit .. //depot/projects/soc2005/libalias/libalias/kld-cuseeme/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/kld-dummy/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/kld-ftp/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/kld-irc/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/kld-libalias/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/kld-nbt/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/kld-pptp/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/kld-skinny/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/kld-smedia/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/lib-cuseeme/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/lib-dummy/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/lib-ftp/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/lib-irc/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/lib-libalias/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/lib-nbt/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/lib-pptp/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/lib-skinny/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/lib-smedia/Makefile#2 edit .. //depot/projects/soc2005/libalias/libalias/libalias.3#2 edit .. //depot/projects/soc2005/libalias/libalias/libalias.conf#2 edit .. //depot/projects/soc2005/libalias/ng_nat/Makefile#2 edit .. //depot/projects/soc2005/libalias/ng_nat/ng_nat.c#2 edit .. //depot/projects/soc2005/libalias/ng_nat/ng_nat.h#2 edit .. //depot/projects/soc2005/libalias/patch/strsep.c#2 edit .. //depot/projects/soc2005/libalias/patch/strspn.c#2 edit .. //depot/projects/soc2005/libalias/readme.txt#2 edit .. //depot/projects/soc2005/libalias/test/setup_test_env.sh#2 edit .. //depot/projects/soc2005/libalias/test/test_ipfw_nat.sh#2 edit .. //depot/projects/soc2005/libalias/test/test_ng_nat.sh#2 edit Differences ... ==== //depot/projects/soc2005/libalias/Makefile#4 (text+ko) ==== ==== //depot/projects/soc2005/libalias/fix-base.sh#2 (text+ko) ==== @@ -18,8 +18,8 @@ # patch libkern (4.x and 5.x only) patch_libkern() { # check if libkern was already applied... - grep strspn /usr/src/sys/sys/libkern.h - [ $? -eq 1 ] && return + grep strspn ${PREF}/sys/sys/libkern.h + [ $? -ne 1 ] && return cat ${PREF}/sys/sys/libkern.h | awk -v l=${LIBKERN} '{print} /^char*.\*strncpy/ {print l}' > ${PREF}/sys/sys/libkern.h.tmp cat ${PREF}/sys/conf/files | awk -v f=${FILES} '{print} /^libkern\/strncpy\.c/ {print f}' > ${PREF}/sys/conf/files.tmp @@ -49,7 +49,7 @@ patch_libkern ;; 4) -LIBKERN="char\t\*strsep(char\*\*,const\tchar\t\*delim);\nsize_t\tstrspn(const\tchar*\,const\tchar\*);" +LIBKERN="char\t\*strsep(char\*\*,const\tchar\t\*);\nsize_t\tstrspn(const\tchar*\,const\tchar\*);" FILES="libkern\/strsep\.c\tstandard\nlibkern\/strspn\.c\tstandard" install_lib_ng_nat ==== //depot/projects/soc2005/libalias/ipfw2-4/Makefile#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-4/kld/Makefile#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-4/kld/in.h#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-4/kld/ip_fw.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-4/kld/ip_fw.h#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-4/kld/ip_fw2.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-4/kld/ip_fw2.h#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-4/kld/raw_ip.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-4/sbin/Makefile#2 (text+ko) ==== @@ -8,4 +8,8 @@ CFLAGS+= -DIPFW2 .endif +# XXX - dunno why i need these... +DESTDIR=/ +BINDIR=sbin + .include <bsd.prog.mk> ==== //depot/projects/soc2005/libalias/ipfw2-4/sbin/ipfw.8#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-4/sbin/ipfw.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-4/sbin/ipfw2.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-5/Makefile#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-5/kld/Makefile#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-5/kld/in.h#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-5/kld/ip_fw.h#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-5/kld/ip_fw2.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-5/kld/ip_fw_pfil.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-5/kld/raw_ip.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-5/sbin/Makefile#2 (text+ko) ==== @@ -5,4 +5,8 @@ WARNS?= 0 MAN= ipfw.8 +# XXX - dunno why i need these... +DESTDIR=/ +BINDIR=sbin + .include <bsd.prog.mk> ==== //depot/projects/soc2005/libalias/ipfw2-5/sbin/ipfw.8#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-5/sbin/ipfw2.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-6/Makefile#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-6/kld/Makefile#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-6/kld/in.h#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-6/kld/ip_fw.h#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-6/kld/ip_fw2.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-6/kld/ip_fw_pfil.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-6/kld/raw_ip.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-6/sbin/Makefile#2 (text+ko) ==== @@ -6,4 +6,8 @@ MAN= ipfw.8 CFLAGS+=-g +# XXX - dunno why i need these... +DESTDIR=/ +BINDIR=sbin + .include <bsd.prog.mk> ==== //depot/projects/soc2005/libalias/ipfw2-6/sbin/ipfw.8#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ipfw2-6/sbin/ipfw2.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/libalias/HISTORY#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/libalias/Makefile#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/libalias/alias.c#2 (text+ko) ==== @@ -1539,7 +1539,6 @@ void *handle; struct proto_handler *m; const char *error; - int i, *n; moduledata_t *p; handle = dlopen (path, RTLD_LAZY); @@ -1571,26 +1570,7 @@ return (NOK); } - n = dlsym(handle, "entries"); - if ((error = dlerror()) != NULL) { - fputs(error, stderr); - return (NOK); - } - - for (i=0; i<*n; i++) { - m[i].fingerprint = dlsym(t->handle, m[i].fingername); - if ((error = dlerror()) != NULL) { - fputs(error, stderr); - return (NOK); - } - m[i].protohandler = dlsym(t->handle, m[i].protohname); - if ((error = dlerror()) != NULL) { - fputs(error, stderr); - return (NOK); - } - attach_handler(&m[i], 1); - } - printf("num of proto_handler: %u\n", i); + attach_handlers(m); return (OK); } @@ -1601,7 +1581,7 @@ /* unload all modules then reload everything */ while ((p = first_handler()) != NULL) { - detach_handler(p, 1); + detach_handler(p); } while ((t = walk_dll_chain()) != NULL) { dlclose(t->handle); ==== //depot/projects/soc2005/libalias/libalias/alias.h#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/libalias/alias_cuseeme.c#2 (text+ko) ==== @@ -103,13 +103,9 @@ } /* Kernel module definition. */ -struct proto_handler handlers[] = {{120, OUT, UDP, "fingerprint", &fingerprint, - "protohandlerout", &protohandlerout}, - {120, IN, UDP, "fingerprint", &fingerprint, - "protohandlerin", &protohandlerin}}; +struct proto_handler handlers[] = {{120, OUT, UDP, &fingerprint, &protohandlerout}, + {120, IN, UDP, &fingerprint, &protohandlerin}, {EOH}}; -int entries = sizeof (handlers) / sizeof (struct proto_handler); - static int mod_handler(module_t mod, int type, void *data) { @@ -118,11 +114,11 @@ switch (type) { case MOD_LOAD: error = 0; - attach_handler(handlers, entries); + attach_handlers(handlers); break; case MOD_UNLOAD: error = 0; - detach_handler(handlers, entries); + detach_handlers(handlers); break; default: error = EINVAL; ==== //depot/projects/soc2005/libalias/libalias/alias_db.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/libalias/alias_dummy.c#2 (text+ko) ==== @@ -114,10 +114,8 @@ * THEIR EXACT NAMES: handlers and entries. */ -struct proto_handler handlers [] = {{666, IN|OUT, UDP|TCP, "fingerprint", &fingerprint, - "protohandler", &protohandler}}; - -int entries = sizeof (handlers) / sizeof (struct proto_handler); +struct proto_handler handlers [] = {{666, IN|OUT, UDP|TCP, &fingerprint, + &protohandler}, {EOH}}; static int mod_handler(module_t mod, int type, void *data) @@ -127,11 +125,11 @@ switch (type) { case MOD_LOAD: error = 0; - attach_handler(handlers, entries); + attach_handlers(handlers); break; case MOD_UNLOAD: error = 0; - detach_handler(handlers, entries); + detach_handlers(handlers); break; default: error = EINVAL; ==== //depot/projects/soc2005/libalias/libalias/alias_ftp.c#2 (text+ko) ==== @@ -132,10 +132,8 @@ return (OK); } -struct proto_handler handlers[] = {{80, OUT, TCP, "fingerprint", &fingerprint, - "protohandler", &protohandler}}; - -int entries = sizeof (handlers) / sizeof (struct proto_handler); +struct proto_handler handlers[] = {{80, OUT, TCP, &fingerprint, + &protohandler}, {EOH}}; static int mod_handler(module_t mod, int type, void *data) @@ -145,11 +143,11 @@ switch (type) { case MOD_LOAD: error = 0; - attach_handler(handlers, entries); + attach_handlers(handlers); break; case MOD_UNLOAD: error = 0; - detach_handler(handlers, entries); + detach_handlers(handlers); break; default: error = EINVAL; ==== //depot/projects/soc2005/libalias/libalias/alias_irc.c#2 (text+ko) ==== @@ -121,10 +121,8 @@ return (OK); } -struct proto_handler handlers[] = {{90, OUT, TCP, "fingerprint", &fingerprint, - "protohandler", &protohandler}}; - -int entries = sizeof (handlers) / sizeof (struct proto_handler); +struct proto_handler handlers[] = {{90, OUT, TCP, &fingerprint, + &protohandler}, {EOH}}; static int mod_handler(module_t mod, int type, void *data) { @@ -133,11 +131,11 @@ switch (type) { case MOD_LOAD: error = 0; - attach_handler(handlers, entries); + attach_handlers(handlers); break; case MOD_UNLOAD: error = 0; - detach_handler(handlers, entries); + detach_handlers(handlers); break; default: error = EINVAL; ==== //depot/projects/soc2005/libalias/libalias/alias_local.h#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/libalias/alias_mod.c#2 (text+ko) ==== @@ -239,7 +239,7 @@ p->next = NULL; /* i'm paranoid... */ for(; *b != NULL; b = &((*b)->next), i++) { if (((*b)->pri == p->pri) && ((*b)->dir == p->dir) && - ((*b)->layer == p->layer)) + ((*b)->proto == p->proto)) return (EHDCON); /* priority conflict */ if ((*b)->pri > p->pri) { p->next = *b; break; @@ -264,11 +264,12 @@ } int -attach_handler(struct proto_handler *_p, int s) { +attach_handlers(struct proto_handler *_p) { int i, res = NOK; LIBALIAS_WLOCK(&handler_chain); - for (i=0; i<s; i++) { + for (i=0; 1; i++) { + if (*((int *)&_p[i]) == EOH) break; res = _attach_handler(&handler_chain, &_p[i]); if (res != OK) break; } @@ -277,11 +278,12 @@ } int -detach_handler(struct proto_handler *_p, int s) { +detach_handlers(struct proto_handler *_p) { int i, res = NOK; LIBALIAS_WLOCK(&handler_chain); - for (i=0; i<s; i++) { + for (i=0; 1; i++) { + if (*((int *)&_p[i]) == EOH) break; res = _detach_handler(&handler_chain, &_p[i]); if (res != OK) break; } @@ -290,13 +292,23 @@ } int -find_handler(int8_t dir, int8_t layer, struct libalias *la, struct ip *pip, struct alias_data *ad) { +detach_handler(struct proto_handler *_p) { + int res = NOK; + + LIBALIAS_WLOCK(&handler_chain); + res = _detach_handler(&handler_chain, _p); + LIBALIAS_WUNLOCK(&handler_chain); + return (res); +} + +int +find_handler(int8_t dir, int8_t proto, struct libalias *la, struct ip *pip, struct alias_data *ad) { struct proto_handler *p; int err; LIBALIAS_RLOCK(&handler_chain); for (p = handler_chain.chain, err = EHDNOF; p != NULL; p = p->next) - if ((p->dir & dir) && (p->layer & layer)) + if ((p->dir & dir) && (p->proto & proto)) if (p->fingerprint(la, pip, ad) == OK) { err = p->protohandler(la, pip, ad); break; ==== //depot/projects/soc2005/libalias/libalias/alias_mod.h#2 (text+ko) ==== @@ -38,7 +38,7 @@ #define IN 1 #define OUT 2 -/* working layer */ +/* working protocol */ #define IP 1 #define TCP 2 #define UDP 4 @@ -67,14 +67,12 @@ struct proto_handler { - int pri; /* handler priority */ - int8_t dir:2, /* flow direction */ - layer:6; /* layer handler */ - char fingername[32]; /* name of fingerprint function */ - int (*fingerprint)(struct libalias *la, /* fingerprint * function */ + u_int pri; /* handler priority */ + int16_t dir; /* flow direction */ + int16_t proto; /* working protocol */ + int (*fingerprint)(struct libalias *la, /* fingerprint * function */ struct ip *pip, struct alias_data *ah); - char protohname[32]; /* name of aliasing function */ - int (*protohandler)(struct libalias *la, /* aliasing * function */ + int (*protohandler)(struct libalias *la, /* aliasing * function */ struct ip *pip, struct alias_data *ah); struct proto_handler *next; }; @@ -119,8 +117,9 @@ void handler_chain_init(void); void handler_chain_destroy(void); -int attach_handler(struct proto_handler *, int); -int detach_handler(struct proto_handler *, int); +int attach_handlers(struct proto_handler *); +int detach_handlers(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); @@ -137,10 +136,13 @@ #define OK 1 #define NOK -1 +/* end of handlers */ +#define EOH -1 + /* * handler/dll conflict - tried to attach a protocol handleror a dll, * but found another one with same priority, direction and working - * layer(proto handler) or name (dll) already in chain + * protocol(proto handler) or name (dll) already in chain */ #define EHDCON 2 ==== //depot/projects/soc2005/libalias/libalias/alias_nbt.c#2 (text+ko) ==== @@ -137,11 +137,8 @@ } /* Kernel module definition. */ -struct proto_handler handlers[] = {{130, IN|OUT, UDP, "fingerprint1", &fingerprint1, - "protohandler1", &protohandler1}, - {140, IN|OUT, UDP, "fingerprint2", &fingerprint2, - "protohandler1", &protohandler2}}; -int entries = sizeof (handlers) / sizeof (struct proto_handler); +struct proto_handler handlers[] = {{130, IN|OUT, UDP, &fingerprint1, &protohandler1}, + {140, IN|OUT, UDP, &fingerprint2, &protohandler2}, {EOH}}; static int mod_handler(module_t mod, int type, void *data) @@ -151,11 +148,11 @@ switch (type) { case MOD_LOAD: error = 0; - attach_handler(handlers, entries); + attach_handlers(handlers); break; case MOD_UNLOAD: error = 0; - detach_handler(handlers, entries); + detach_handlers(handlers); break; default: error = EINVAL; ==== //depot/projects/soc2005/libalias/libalias/alias_old.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/libalias/alias_pptp.c#2 (text+ko) ==== @@ -155,21 +155,15 @@ } /* Kernel module definition. */ -struct proto_handler handlers[] = {{200, IN, TCP, "fingerprint", &fingerprint, - "protohandlerin", &protohandlerin}, - {210, OUT, TCP, "fingerprint", &fingerprint, - "protohandlerout", &protohandlerout}, +struct proto_handler handlers[] = {{200, IN, TCP, &fingerprint, &protohandlerin}, + {210, OUT, TCP, &fingerprint, &protohandlerout}, /* * 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. */ - {INT_MAX, IN, IP, "fingerprintgre", &fingerprintgre, - "protohandlergrein", &protohandlergrein}, - {INT_MAX, OUT, IP, "fingerprintgre", &fingerprintgre, - "protohandlergreout", &protohandlergreout}}; -int entries = sizeof (handlers) / sizeof (struct proto_handler); - + {INT_MAX, IN, IP, &fingerprintgre, &protohandlergrein}, + {INT_MAX, OUT, IP, &fingerprintgre, &protohandlergreout}, {EOH}}; static int mod_handler(module_t mod, int type, void *data) { @@ -178,11 +172,11 @@ switch (type) { case MOD_LOAD: error = 0; - attach_handler(handlers, entries); + attach_handlers(handlers); break; case MOD_UNLOAD: error = 0; - detach_handler(handlers, entries); + detach_handlers(handlers); break; default: error = EINVAL; ==== //depot/projects/soc2005/libalias/libalias/alias_proxy.c#2 (text+ko) ==== @@ -71,9 +71,9 @@ #include <ctype.h> #include <stdio.h> #include <stdlib.h> -#include <string.h> #include <netdb.h> #include <arpa/inet.h> +#include <string.h> #endif /* BSD IPV4 includes */ ==== //depot/projects/soc2005/libalias/libalias/alias_skinny.c#2 (text+ko) ==== @@ -92,9 +92,8 @@ return (OK); } -struct proto_handler handlers[] = {{110, IN|OUT, TCP, "fingerprint", &fingerprint, - "protohandler", &protohandler}}; -int entries = sizeof (handlers) / sizeof (struct proto_handler); +struct proto_handler handlers[] = {{110, IN|OUT, TCP, &fingerprint, + &protohandler}, {EOH}}; static int mod_handler(module_t mod, int type, void *data) @@ -104,11 +103,11 @@ switch (type) { case MOD_LOAD: error = 0; - attach_handler(handlers, entries); + attach_handlers(handlers); break; case MOD_UNLOAD: error = 0; - detach_handler(handlers, entries); + detach_handlers(handlers); break; default: error = EINVAL; ==== //depot/projects/soc2005/libalias/libalias/alias_smedia.c#2 (text+ko) ==== @@ -167,9 +167,8 @@ return (OK); } -struct proto_handler handlers[] = {{100, OUT, TCP|UDP, "fingerprint", &fingerprint, - "protohandler", &protohandler}}; -int entries = sizeof (handlers) / sizeof (struct proto_handler); +struct proto_handler handlers[] = {{100, OUT, TCP|UDP, &fingerprint, + &protohandler}, {EOH}}; static int mod_handler(module_t mod, int type, void *data) @@ -179,11 +178,11 @@ switch (type) { case MOD_LOAD: error = 0; - attach_handler(handlers, entries); + attach_handlers(handlers); break; case MOD_UNLOAD: error = 0; - detach_handler(handlers, entries); + detach_handlers(handlers); break; default: error = EINVAL; ==== //depot/projects/soc2005/libalias/libalias/alias_util.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/libalias/kld-cuseeme/Makefile#2 (text+ko) ==== @@ -4,4 +4,6 @@ SRCS= alias_cuseeme.c INCS= alias.h +CFLAGS+= -Werror + .include <bsd.kmod.mk> ==== //depot/projects/soc2005/libalias/libalias/kld-dummy/Makefile#2 (text+ko) ==== @@ -4,4 +4,6 @@ SRCS= alias_dummy.c INCS= alias.h +CFLAGS+= -Werror + .include <bsd.kmod.mk> ==== //depot/projects/soc2005/libalias/libalias/kld-ftp/Makefile#2 (text+ko) ==== @@ -4,4 +4,6 @@ SRCS= alias_ftp.c INCS= alias.h +CFLAGS+= -Werror + .include <bsd.kmod.mk> ==== //depot/projects/soc2005/libalias/libalias/kld-irc/Makefile#2 (text+ko) ==== @@ -4,4 +4,6 @@ SRCS= alias_irc.c INCS= alias.h +CFLAGS+= -Werror + .include <bsd.kmod.mk> ==== //depot/projects/soc2005/libalias/libalias/kld-libalias/Makefile#2 (text+ko) ==== @@ -30,4 +30,6 @@ attach_handler \ detach_handler +CFLAGS+= -Werror + .include <bsd.kmod.mk> ==== //depot/projects/soc2005/libalias/libalias/kld-nbt/Makefile#2 (text+ko) ==== @@ -4,4 +4,6 @@ SRCS= alias_nbt.c INCS= alias.h +CFLAGS+= -Werror + .include <bsd.kmod.mk> ==== //depot/projects/soc2005/libalias/libalias/kld-pptp/Makefile#2 (text+ko) ==== @@ -4,4 +4,6 @@ SRCS= alias_pptp.c INCS= alias.h +CFLAGS+= -Werror + .include <bsd.kmod.mk> ==== //depot/projects/soc2005/libalias/libalias/kld-skinny/Makefile#2 (text+ko) ==== @@ -4,4 +4,6 @@ SRCS= alias_skinny.c INCS= alias.h +CFLAGS+= -Werror + .include <bsd.kmod.mk> ==== //depot/projects/soc2005/libalias/libalias/kld-smedia/Makefile#2 (text+ko) ==== @@ -4,4 +4,6 @@ SRCS= alias_smedia.c INCS= alias.h +CFLAGS+= -Werror + .include <bsd.kmod.mk> ==== //depot/projects/soc2005/libalias/libalias/lib-cuseeme/Makefile#2 (text+ko) ==== @@ -6,4 +6,6 @@ SRCS= alias_cuseeme.c INCS= alias_mod.h +CFLAGS+= -Werror + .include <bsd.lib.mk> ==== //depot/projects/soc2005/libalias/libalias/lib-dummy/Makefile#2 (text+ko) ==== @@ -6,4 +6,6 @@ SRCS= alias_dummy.c INCS= alias_mod.h +CFLAGS+= -Werror + .include <bsd.lib.mk> ==== //depot/projects/soc2005/libalias/libalias/lib-ftp/Makefile#2 (text+ko) ==== @@ -6,4 +6,6 @@ SRCS= alias_ftp.c INCS= alias_mod.h +CFLAGS+= -Werror + .include <bsd.lib.mk> ==== //depot/projects/soc2005/libalias/libalias/lib-irc/Makefile#2 (text+ko) ==== @@ -6,4 +6,6 @@ SRCS= alias_irc.c INCS= alias_mod.h +CFLAGS+= -Werror + .include <bsd.lib.mk> ==== //depot/projects/soc2005/libalias/libalias/lib-libalias/Makefile#2 (text+ko) ==== @@ -7,4 +7,6 @@ SRCS= alias.c alias_db.c alias_proxy.c alias_util.c alias_old.c alias_mod.c INCS= alias.h alias_mod.h +CFLAGS+= -Werror + .include <bsd.lib.mk> ==== //depot/projects/soc2005/libalias/libalias/lib-nbt/Makefile#2 (text+ko) ==== @@ -6,4 +6,6 @@ SRCS= alias_nbt.c INCS= alias_mod.h +CFLAGS+= -Werror + .include <bsd.lib.mk> ==== //depot/projects/soc2005/libalias/libalias/lib-pptp/Makefile#2 (text+ko) ==== @@ -6,4 +6,6 @@ SRCS= alias_pptp.c INCS= alias_mod.h +CFLAGS+= -Werror + .include <bsd.lib.mk> ==== //depot/projects/soc2005/libalias/libalias/lib-skinny/Makefile#2 (text+ko) ==== @@ -6,4 +6,6 @@ SRCS= alias_skinny.c INCS= alias_mod.h +CFLAGS+= -Werror + .include <bsd.lib.mk> ==== //depot/projects/soc2005/libalias/libalias/lib-smedia/Makefile#2 (text+ko) ==== @@ -6,4 +6,6 @@ SRCS= alias_smedia.c INCS= alias_mod.h +CFLAGS+= -Werror + .include <bsd.lib.mk> ==== //depot/projects/soc2005/libalias/libalias/libalias.3#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/libalias/libalias.conf#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ng_nat/Makefile#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ng_nat/ng_nat.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/ng_nat/ng_nat.h#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/patch/strsep.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/patch/strspn.c#2 (text+ko) ==== ==== //depot/projects/soc2005/libalias/readme.txt#2 (text+ko) ==== @@ -256,12 +256,10 @@ struct proto_handler { int pri; /* handler priority */ - int8_t dir:2, /* flow direction */ - layer:6; /* layer handler */ - char fingername[32]; /* name of fingerprint function */ + int16_t dir; /* flow direction */ + int16_t proto; /* working protocol */ int (*fingerprint)(struct libalias *la, /* fingerprint * function */ struct ip *pip, struct alias_data *ah); - char protohname[32]; /* name of aliasing function */ int (*protohandler)(struct libalias *la, /* aliasing * function */ struct ip *pip, struct alias_data *ah); struct proto_handler *next; @@ -274,12 +272,9 @@ dir is the direction of packets: ingoing or outgoing. -layer says at which layer this packet belongs: IP, TCP or UDP +proto says at which protocol this packet belongs: IP, TCP or UDP -fingername and protohname are the names (yes the name!) of the -functions doing (respectively) fingerprinting and protocol handling. - -fingerprint points to the fingerprint function while protohname points +fingerprint points to the fingerprint function while protohandler points to the protocol handler function. The fingerprint function has the double of scope of checking if the @@ -291,7 +286,7 @@ When a packet enters libalias, if it meets a module hook, libalias scan handler_chain to see if there's an handler that match -this type of packet (it checks layer and direction of packet), then if +this type of packet (it checks protocol and direction of packet), then if more then one handler is found, it starts with the module with a lower priority number: it calls fingerprints and read the result. @@ -325,7 +320,7 @@ IN: direction -UDP: operating layer +UDP: working protocol la: pointer to this instance of libalias @@ -380,24 +375,22 @@ [from alias_dummy.c] -struct proto_handler handlers [] = {{666, IN|OUT, UDP|TCP, "fingerprint", &fingerprint, - "protohandler", &protohandler}}; +struct proto_handler handlers [] = {{666, IN|OUT, UDP|TCP, + &fingerprint, &protohandler}}; -int entries = sizeof (handlers) / sizeof (struct proto_handler); - -These two variables are the 'most important things' in your module, -cause they describe the handlers present and let the outside world use +The variable 'handlers' is the 'most important thing' in your module, +cause it describes the handlers present and let the outside world use it in an opaque way. -They must ALWAYS be present in every module, and they MUST retain -their names (handlers and entries), else if you'll try to load +It must ALWAYS be present in every module, and it MUST retain +the name 'handlers', else if you'll try to load this module in userland, it will complain about missing symbols: for more info about module load/unload, please refer to LibAliasRefreshModules, LibAliasLoadModule and LibAliasUnloadModule in alias.c handlers[] contains all the proto_handler structures present in a -module, while entries counts them. +module. static int mod_handler(module_t mod, int type, void *data) @@ -407,11 +400,11 @@ switch (type) { case MOD_LOAD: >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200509051535.j85FZj7j089307>