Messages in this thread Patch in this message | | | Date | Tue, 31 Mar 1998 03:21:33 -0500 (EST) | From | Adam Heath <> | Subject | Patch: 2.1.92pre2: ipmasq_nomodules |
| |
This patch allows the ip_masq_{ftp,irc,vdolive,quake,raudio,cuseeme} helper modules be statically linked into the kernel. The is one of the last remaining hurdles for firewall systems to remove module support.
Adam diff -ruN linux/Documentation/Configure.help 2.1.92/Documentation/Configure.help --- linux/Documentation/Configure.help Mon Mar 30 15:29:21 1998 +++ 2.1.92/Documentation/Configure.help Mon Mar 30 15:35:41 1998 @@ -1699,6 +1699,54 @@ tracert program. If you want this, say Y. +IP: masquerading +CONFIG_IP_MASQUERADE_FTP + This enables support for masquerading FTP connections. If compiled + as a module, then ports are specified with insmod as "ports=port, + port,...". Otherwise, they are specified on the kernel command + line, as "ip_masq=[+]ftp,port,port,..." If "+" is given, then + "port,port,..." is added to current list of ports. + +IP: masquerading +CONFIG_IP_MASQUERADE_IRC + This enables support for masquerading IRC connections. If compiled + as a module, then ports are specified with insmod as "ports=port, + port,...". Otherwise, they are specified on the kernel command + line, as "ip_masq=[+]irc,port,port,..." If "+" is given, then + "port,port,..." is added to current list of ports. + +IP: masquerading +CONFIG_IP_MASQUERADE_QUAKE + This enables support for masquerading Quake connections. If compiled + as a module, then ports are specified with insmod as "ports=port, + port,...". Otherwise, they are specified on the kernel command + line, as "ip_masq=[+]quake,port,port,..." If "+" is given, then + "port,port,..." is added to current list of ports. + +IP: masquerading +CONFIG_IP_MASQUERADE_VDOLIVE + This enables support for masquerading VDOLIVE connections. If compiled + as a module, then ports are specified with insmod as "ports=port, + port,...". Otherwise, they are specified on the kernel command + line, as "ip_masq=[+]vdolive,port,port,..." If "+" is given, then + "port,port,..." is added to current list of ports. + +IP: masquerading +CONFIG_IP_MASQUERADE_RAUDIO + This enables support for masquerading RAUDIO connections. If compiled + as a module, then ports are specified with insmod as "ports=port, + port,...". Otherwise, they are specified on the kernel command + line, as "ip_masq=[+]raudio,port,port,..." If "+" is given, then + "port,port,..." is added to current list of ports. + +IP: masquerading +CONFIG_IP_MASQUERADE_CUSEEME + This enables support for masquerading CUSEEME connections. If compiled + as a module, then ports are specified with insmod as "ports=port, + port,...". Otherwise, they are specified on the kernel command + line, as "ip_masq=[+]cuseeme,port,port,..." If "+" is given, then + "port,port,..." is added to current list of ports. + IP: ipautofw masquerade support CONFIG_IP_MASQUERADE_IPAUTOFW (Experimental) ipautofw is a program by Richard Lynch allowing additional support diff -ruN linux/include/net/ip_masq_app.h 2.1.92/include/net/ip_masq_app.h --- linux/include/net/ip_masq_app.h Wed Dec 31 19:00:00 1969 +++ 2.1.92/include/net/ip_masq_app.h Mon Mar 30 15:35:41 1998 @@ -0,0 +1,10 @@ +#ifndef _IP_MASQ_APP_H +#define _IP_MASQ_APP_H + +struct ip_masq_app_setup { + const char * appname; + int * array; + int (*init) (void); +}; + +#endif _IP_MASQ_APP_H_ diff -ruN linux/include/net/ip_masq_apphelp.h 2.1.92/include/net/ip_masq_apphelp.h --- linux/include/net/ip_masq_apphelp.h Wed Dec 31 19:00:00 1969 +++ 2.1.92/include/net/ip_masq_apphelp.h Mon Mar 30 15:35:41 1998 @@ -0,0 +1,58 @@ +#ifdef MODULE + EXPORT_NO_SYMBOLS; + #define IPM_INIT_MODULE_HEADER(name) int init_module(void) + #define IPM_INIT_MODULE_RET return j ? -EIO : 0 + #define IPM_END_MODULE_HEADER(name) void cleanup_module(void) + #define IPM_END_MODULE_RET \ + if (k) IP_MASQ_DEBUG(1-debug, "text: can't remove module"); +#else + #define IPM_INIT_MODULE_HEADER(name) __initfunc(int ip_masq_ ## name ## _init(void)) + #define IPM_INIT_MODULE_RET return j + #define IPM_END_MODULE_HEADER(name) int ip_masq_ ## name ## _done(void) + #define IPM_END_MODULE_RET return k; +#endif + +#define IPM_INIT_MODULE(name,proto,text) \ +IPM_INIT_MODULE_HEADER(name)\ +{\ + int i, j=0;\ + for (i=0; (i<MAX_MASQ_APP_PORTS); i++) {\ + if (PORTS[i]) {\ + if ((INCARNATIONS[i] = kmalloc(sizeof(struct ip_masq_app),\ + GFP_KERNEL)) == NULL) {\ + j = -ENOMEM;\ + break;\ + }\ + memcpy(INCARNATIONS[i], &ip_masq_ ## name, sizeof(struct ip_masq_app));\ + if ((j = register_ip_masq_app(INCARNATIONS[i],\ + proto,\ + PORTS[i])))\ + break;\ + IP_MASQ_DEBUG(1-debug, "text: loaded support on port[%d] = %d\n",\ + i, PORTS[i]);\ + } else {\ + /* To be safe, force the incarnation table entry to NULL */\ + INCARNATIONS[i] = NULL;\ + }\ + }\ + IPM_INIT_MODULE_RET;\ +} +#define IPM_END_MODULE(name,text) \ +IPM_END_MODULE_HEADER(name)\ +{\ + int i, j, k;\ + k=0;\ + for (i=0; (i<MAX_MASQ_APP_PORTS); i++) {\ + if (INCARNATIONS[i]) {\ + if ((j = unregister_ip_masq_app(INCARNATIONS[i]))) {\ + k = j;\ + } else {\ + kfree(INCARNATIONS[i]);\ + INCARNATIONS[i] = NULL;\ + IP_MASQ_DEBUG(1-debug, "Ftp: unloaded support on port[%d] = %d\n",\ + i, PORTS[i]);\ + }\ + }\ + }\ + IPM_END_MODULE_RET;\ +} diff -ruN linux/init/main.c 2.1.92/init/main.c --- linux/init/main.c Mon Mar 30 15:29:09 1998 +++ 2.1.92/init/main.c Mon Mar 30 15:36:41 1998 @@ -275,6 +275,9 @@ #ifdef CONFIG_FTAPE extern void ftape_setup(char *str, int *ints); #endif +#ifdef CONFIG_IP_MASQUERADE +extern void ip_masq_app_setup(char *str, int *ints); +#endif #if defined(CONFIG_SYSVIPC) extern void ipc_init(void); @@ -500,6 +503,9 @@ #endif #ifdef CONFIG_INET { "ether=", eth_setup }, +#endif +#ifdef CONFIG_IP_MASQUERADE + { "ip_masq=", ip_masq_app_setup }, #endif #ifdef CONFIG_ARCNET_COM20020 { "com20020=", com20020_setup }, diff -ruN linux/net/ipv4/Config.in 2.1.92/net/ipv4/Config.in --- linux/net/ipv4/Config.in Mon Mar 30 15:28:39 1998 +++ 2.1.92/net/ipv4/Config.in Mon Mar 30 15:37:42 1998 @@ -40,9 +40,14 @@ if [ "$CONFIG_IP_FIREWALL" = "y" ]; then bool 'IP: masquerading' CONFIG_IP_MASQUERADE if [ "$CONFIG_IP_MASQUERADE" != "n" ]; then - comment 'Protocol-specific masquerading support will be built as modules.' + dep_tristate 'IP_MASQ: FTP protocol support' CONFIG_IP_MASQUERADE_FTP $CONFIG_IP_MASQUERADE + dep_tristate 'IP_MASQ: Internet Relay Chat protocol support' CONFIG_IP_MASQUERADE_IRC $CONFIG_IP_MASQUERADE + dep_tristate 'IP_MASQ: Real Audio protocol support' CONFIG_IP_MASQUERADE_RAUDIO $CONFIG_IP_MASQUERADE + dep_tristate 'IP_MASQ: CuSeeMe protocol support' CONFIG_IP_MASQUERADE_CUSEEME $CONFIG_IP_MASQUERADE + dep_tristate 'IP_MASQ: VdoLive protocol support' CONFIG_IP_MASQUERADE_VDOLIVE $CONFIG_IP_MASQUERADE + dep_tristate 'IP_MASQ: Quake protocol support' CONFIG_IP_MASQUERADE_QUAKE $CONFIG_IP_MASQUERADE bool 'IP: ICMP masquerading' CONFIG_IP_MASQUERADE_ICMP - comment 'Protocol-specific masquerading support will be built as modules.' + if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then tristate 'IP: ipautofw masq support (EXPERIMENTAL)' CONFIG_IP_MASQUERADE_IPAUTOFW tristate 'IP: ipportfw masq support (EXPERIMENTAL)' CONFIG_IP_MASQUERADE_IPPORTFW diff -ruN linux/net/ipv4/Makefile 2.1.92/net/ipv4/Makefile --- linux/net/ipv4/Makefile Wed Dec 10 12:45:16 1997 +++ 2.1.92/net/ipv4/Makefile Mon Mar 30 15:35:41 1998 @@ -56,7 +56,55 @@ endif ifeq ($(CONFIG_IP_MASQUERADE),y) -IPV4X_OBJS += ip_masq.o ip_masq_mod.o ip_masq_app.o + + IPV4X_OBJS += ip_masq.o ip_masq_mod.o ip_masq_app.o + ifeq ($(CONFIG_IP_MASQUERADE_FTP),y) + IPV4X_OBJS += ip_masq_ftp.o + else + ifeq ($(CONFIG_IP_MASQUERADE_FTP),m) + M_OBJS += ip_masq_ftp.o + endif + endif + + ifeq ($(CONFIG_IP_MASQUERADE_IRC),y) + IPV4X_OBJS += ip_masq_irc.o + else + ifeq ($(CONFIG_IP_MASQUERADE_IRC),m) + M_OBJS += ip_masq_irc.o + endif + endif + + ifeq ($(CONFIG_IP_MASQUERADE_RAUDIO),y) + IPV4X_OBJS += ip_masq_raudio.o + else + ifeq ($(CONFIG_IP_MASQUERADE_RAUDIO),m) + M_OBJS += ip_masq_raudio.o + endif + endif + + ifeq ($(CONFIG_IP_MASQUERADE_CUSEEME),y) + IPV4X_OBJS += ip_masq_cuseeme.o + else + ifeq ($(CONFIG_IP_MASQUERADE_CUSEEME),m) + M_OBJS += ip_masq_cuseeme.o + endif + endif + + ifeq ($(CONFIG_IP_MASQUERADE_VDOLIVE),y) + IPV4X_OBJS += ip_masq_vdolive.o + else + ifeq ($(CONFIG_IP_MASQUERADE_VDOLIVE),m) + M_OBJS += ip_masq_vdolive.o + endif + endif + + ifeq ($(CONFIG_IP_MASQUERADE_QUAKE),y) + IPV4X_OBJS += ip_masq_quake.o + else + ifeq ($(CONFIG_IP_MASQUERADE_QUAKE),m) + M_OBJS += ip_masq_quake.o + endif + endif ifeq ($(CONFIG_IP_MASQUERADE_IPAUTOFW),y) IPV4_OBJS += ip_masq_autofw.o @@ -74,8 +122,6 @@ endif endif -M_OBJS += ip_masq_ftp.o ip_masq_irc.o ip_masq_raudio.o ip_masq_quake.o -M_OBJS += ip_masq_vdolive.o ip_masq_cuseeme.o endif ifeq ($(CONFIG_SYN_COOKIES),y) diff -ruN linux/net/ipv4/ip_masq_app.c 2.1.92/net/ipv4/ip_masq_app.c --- linux/net/ipv4/ip_masq_app.c Mon Mar 30 15:28:16 1998 +++ 2.1.92/net/ipv4/ip_masq_app.c Mon Mar 30 16:03:17 1998 @@ -31,6 +31,7 @@ #include <linux/in.h> #include <linux/ip.h> #include <linux/init.h> +#include <linux/ctype.h> #include <net/protocol.h> #include <net/tcp.h> #include <net/udp.h> @@ -38,6 +39,7 @@ #include <linux/stat.h> #include <linux/proc_fs.h> #include <net/ip_masq.h> +#include <net/ip_masq_app.h> #define IP_MASQ_APP_TAB_SIZE 16 /* must be power of 2 */ @@ -57,6 +59,69 @@ struct ip_masq_app *ip_masq_app_base[IP_MASQ_APP_TAB_SIZE]; +#ifdef CONFIG_IP_MASQUERADE_FTP + extern int ip_masq_ftp_ports[MAX_MASQ_APP_PORTS]; + extern int ip_masq_ftp_init(void); +#endif +#ifdef CONFIG_IP_MASQUERADE_IRC + extern int ip_masq_irc_ports[MAX_MASQ_APP_PORTS]; + extern int ip_masq_irc_init(void); +#endif +#ifdef CONFIG_IP_MASQUERADE_QUAKE + extern int ip_masq_quake_ports[MAX_MASQ_APP_PORTS]; + extern int ip_masq_quake_init(void); +#endif +#ifdef CONFIG_IP_MASQUERADE_CUSEEME + extern int ip_masq_cuseeme_ports[MAX_MASQ_APP_PORTS]; + extern int ip_masq_cuseeme_init(void); +#endif +#ifdef CONFIG_IP_MASQUERADE_VDOLIVE + extern int ip_masq_vdolive_ports[MAX_MASQ_APP_PORTS]; + extern int ip_masq_vdolive_init(void); +#endif +#ifdef CONFIG_IP_MASQUERADE_RAUDIO + extern int ip_masq_raudio_ports[MAX_MASQ_APP_PORTS]; + extern int ip_masq_raudio_init(void); +#endif + +struct ip_masq_app_setup ip_masq_app_info[] = { + +#ifdef CONFIG_IP_MASQUERADE_FTP + { "ftp", ip_masq_ftp_ports, + ip_masq_ftp_init, + }, +#endif +#ifdef CONFIG_IP_MASQUERADE_IRC + { "irc", ip_masq_irc_ports, + ip_masq_irc_init, + }, +#endif +#ifdef CONFIG_IP_MASQUERADE_QUAKE + { "quake", ip_masq_quake_ports, + ip_masq_quake_init, + }, +#endif +#ifdef CONFIG_IP_MASQUERADE_CUSEEME + { "cuseeme", ip_masq_cuseeme_ports, + ip_masq_cuseeme_init, + }, +#endif +#ifdef CONFIG_IP_MASQUERADE_RAUDIO + { "raudio", ip_masq_raudio_ports, + ip_masq_raudio_init, + }, +#endif +#ifdef CONFIG_IP_MASQUERADE_VDOLIVE + { "vdolive", ip_masq_vdolive_ports, + ip_masq_vdolive_init, +}, +#endif + + { NULL, NULL, NULL } +}; + + + /* * ip_masq_app registration routine * port: host byte order. @@ -487,6 +552,9 @@ __initfunc(int ip_masq_app_init(void)) { + int p; + for (p=0;ip_masq_app_info[p].init;p++) + ip_masq_app_info[p].init(); #ifdef CONFIG_PROC_FS proc_net_register(&proc_net_ip_masq_app); #endif @@ -602,3 +670,39 @@ } return n_skb; } + + +#ifndef MODULE /* MODULE */ +__initfunc(void ip_masq_app_setup(char *str, int *ints)) +{ + int p=0,i=0; + char *app=str,*sptr=NULL; + + if((sptr=strchr(str,','))) + *sptr='\0',str=sptr+1; + + if(!strncmp(app,"+",1)) + app++,i=1; + + for(p=0;ip_masq_app_info[p].appname;p++) + if(!strcmp(app,ip_masq_app_info[p].appname)){ + char *cur; + int *pts=NULL; + + pts=ip_masq_app_info[p].array; + if(i) for(i=0;pts[i];i++); + + cur=str; + while (cur && isdigit(*cur) && i <= MAX_MASQ_APP_PORTS) { + pts[i++]=simple_strtoul(cur,NULL,0); + if ((cur = strchr(cur,',')) != NULL) cur++; + } + while (i <= MAX_MASQ_APP_PORTS) + pts[i++]=0; + + break; + } + return; +} + +#endif /* MODULE */ diff -ruN linux/net/ipv4/ip_masq_cuseeme.c 2.1.92/net/ipv4/ip_masq_cuseeme.c --- linux/net/ipv4/ip_masq_cuseeme.c Wed Dec 10 12:45:16 1997 +++ 2.1.92/net/ipv4/ip_masq_cuseeme.c Mon Mar 30 15:35:41 1998 @@ -49,6 +49,7 @@ #include <linux/init.h> #include <net/protocol.h> #include <net/udp.h> +#include <net/ip_masq_apphelp.h> /* #define IP_MASQ_NDEBUG */ #include <net/ip_masq.h> @@ -88,15 +89,22 @@ * List of ports (up to MAX_MASQ_APP_PORTS) to be handled by helper * First port is set to the default port. */ -static int ports[MAX_MASQ_APP_PORTS] = {7648}; /* I rely on the trailing items being set to zero */ -struct ip_masq_app *masq_incarnations[MAX_MASQ_APP_PORTS]; +#ifdef MODULE + #define PORTS ports + #define INCARNATIONS incarnations +#else + #define PORTS ip_masq_cuseeme_ports + #define INCARNATIONS ip_masq_cuseeme_incarnations +#endif +int PORTS[MAX_MASQ_APP_PORTS]={7648}; /* I rely on the trailing items being set to zero */ +struct ip_masq_app *INCARNATIONS[MAX_MASQ_APP_PORTS]; /* * Debug level */ static int debug=0; -MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_MASQ_APP_PORTS) "i"); +MODULE_PARM(PORTS, "1-" __MODULE_STRING(MAX_MASQ_APP_PORTS) "i"); MODULE_PARM(debug, "i"); static int @@ -188,74 +196,5 @@ }; -/* - * ip_masq_cuseeme initialization - */ - -__initfunc(int ip_masq_cuseeme_init(void)) -{ - int i, j; - - for (i=0; (i<MAX_MASQ_APP_PORTS); i++) { - if (ports[i]) { - if ((masq_incarnations[i] = kmalloc(sizeof(struct ip_masq_app), - GFP_KERNEL)) == NULL) - return -ENOMEM; - memcpy(masq_incarnations[i], &ip_masq_cuseeme, sizeof(struct ip_masq_app)); - if ((j = register_ip_masq_app(masq_incarnations[i], - IPPROTO_UDP, - ports[i]))) { - return j; - } -#if DEBUG_CONFIG_IP_MASQ_CUSEEME - IP_MASQ_DEBUG(1-debug, "CuSeeMe: loaded support on port[%d] = %d\n", - i, ports[i]); -#endif - } else { - /* To be safe, force the incarnation table entry to NULL */ - masq_incarnations[i] = NULL; - } - } - return 0; -} - -/* - * ip_masq_cuseeme fin. - */ - -int ip_masq_cuseeme_done(void) -{ - int i, j, k; - - k=0; - for (i=0; (i<MAX_MASQ_APP_PORTS); i++) { - if (masq_incarnations[i]) { - if ((j = unregister_ip_masq_app(masq_incarnations[i]))) { - k = j; - } else { - kfree(masq_incarnations[i]); - masq_incarnations[i] = NULL; - IP_MASQ_DEBUG(1-debug, "CuSeeMe: unloaded support on port[%d] = %d\n", i, ports[i]); - } - } - } - return k; -} - -#ifdef MODULE -EXPORT_NO_SYMBOLS; - -int init_module(void) -{ - if (ip_masq_cuseeme_init() != 0) - return -EIO; - return 0; -} - -void cleanup_module(void) -{ - if (ip_masq_cuseeme_done() != 0) - IP_MASQ_DEBUG(1-debug, "ip_masq_cuseeme: can't remove module"); -} - -#endif /* MODULE */ +IPM_INIT_MODULE(cuseeme,IPPROTO_UDP,CuSeeMe); +IPM_END_MODULE(cuseeme,ip_masq_cuseeme); diff -ruN linux/net/ipv4/ip_masq_ftp.c 2.1.92/net/ipv4/ip_masq_ftp.c --- linux/net/ipv4/ip_masq_ftp.c Mon Mar 30 15:28:40 1998 +++ 2.1.92/net/ipv4/ip_masq_ftp.c Mon Mar 30 15:41:20 1998 @@ -47,6 +47,7 @@ #include <linux/init.h> #include <net/protocol.h> #include <net/tcp.h> +#include <net/ip_masq_apphelp.h> /* #define IP_MASQ_NDEBUG */ #include <net/ip_masq.h> @@ -56,15 +57,22 @@ * List of ports (up to MAX_MASQ_APP_PORTS) to be handled by helper * First port is set to the default port. */ -static int ports[MAX_MASQ_APP_PORTS] = {21}; /* I rely on the trailing items being set to zero */ -struct ip_masq_app *masq_incarnations[MAX_MASQ_APP_PORTS]; +#ifdef MODULE + #define PORTS ports + #define INCARNATIONS incarnations +#else + #define PORTS ip_masq_ftp_ports + #define INCARNATIONS ip_masq_ftp_incarnations +#endif +int PORTS[MAX_MASQ_APP_PORTS]={21}; /* I rely on the trailing items being set to zero */ +struct ip_masq_app *INCARNATIONS[MAX_MASQ_APP_PORTS]; /* * Debug level */ static int debug=0; -MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_MASQ_APP_PORTS) "i"); +MODULE_PARM(PORTS, "1-" __MODULE_STRING(MAX_MASQ_APP_PORTS) "i"); MODULE_PARM(debug, "i"); /* Dummy variable */ @@ -318,73 +326,6 @@ masq_ftp_in, /* pkt_in */ }; -/* - * ip_masq_ftp initialization - */ - -__initfunc(int ip_masq_ftp_init(void)) -{ - int i, j; - - for (i=0; (i<MAX_MASQ_APP_PORTS); i++) { - if (ports[i]) { - if ((masq_incarnations[i] = kmalloc(sizeof(struct ip_masq_app), - GFP_KERNEL)) == NULL) - return -ENOMEM; - memcpy(masq_incarnations[i], &ip_masq_ftp, sizeof(struct ip_masq_app)); - if ((j = register_ip_masq_app(masq_incarnations[i], - IPPROTO_TCP, - ports[i]))) { - return j; - } - IP_MASQ_DEBUG(1-debug, "Ftp: loaded support on port[%d] = %d\n", - i, ports[i]); - } else { - /* To be safe, force the incarnation table entry to NULL */ - masq_incarnations[i] = NULL; - } - } - return 0; -} - -/* - * ip_masq_ftp fin. - */ - -int ip_masq_ftp_done(void) -{ - int i, j, k; - - k=0; - for (i=0; (i<MAX_MASQ_APP_PORTS); i++) { - if (masq_incarnations[i]) { - if ((j = unregister_ip_masq_app(masq_incarnations[i]))) { - k = j; - } else { - kfree(masq_incarnations[i]); - masq_incarnations[i] = NULL; - IP_MASQ_DEBUG(1-debug, "Ftp: unloaded support on port[%d] = %d\n", - i, ports[i]); - } - } - } - return k; -} - -#ifdef MODULE -EXPORT_NO_SYMBOLS; - -int init_module(void) -{ - if (ip_masq_ftp_init() != 0) - return -EIO; - return 0; -} - -void cleanup_module(void) -{ - if (ip_masq_ftp_done() != 0) - printk(KERN_INFO "ip_masq_ftp: can't remove module"); -} -#endif /* MODULE */ +IPM_INIT_MODULE(ftp,IPPROTO_TCP,File Transfer Protocol); +IPM_END_MODULE(ftp,ip_masq_ftp); diff -ruN linux/net/ipv4/ip_masq_irc.c 2.1.92/net/ipv4/ip_masq_irc.c --- linux/net/ipv4/ip_masq_irc.c Mon Mar 30 15:28:40 1998 +++ 2.1.92/net/ipv4/ip_masq_irc.c Mon Mar 30 15:35:41 1998 @@ -52,20 +52,30 @@ #include <net/protocol.h> #include <net/tcp.h> #include <net/ip_masq.h> +#include <net/ip_masq_apphelp.h> /* * List of ports (up to MAX_MASQ_APP_PORTS) to be handled by helper * First port is set to the default port. */ -int ports[MAX_MASQ_APP_PORTS] = {6667}; /* I rely on the trailing items being set to zero */ -struct ip_masq_app *masq_incarnations[MAX_MASQ_APP_PORTS]; +#ifdef MODULE + #define PORTS ports + #define INCARNATIONS incarnations +#else + #define PORTS ip_masq_irc_ports + #define INCARNATIONS ip_masq_irc_incarnations +#endif +int PORTS[MAX_MASQ_APP_PORTS]={6667}; /* I rely on the trailing items being set to zero */ +struct ip_masq_app *INCARNATIONS[MAX_MASQ_APP_PORTS]; + + /* * Debug level */ static int debug=0; -MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_MASQ_APP_PORTS) "i"); +MODULE_PARM(PORTS, "1-" __MODULE_STRING(MAX_MASQ_APP_PORTS) "i"); MODULE_PARM(debug, "i"); @@ -293,75 +303,5 @@ NULL /* pkt_in */ }; -/* - * ip_masq_irc initialization - */ - -__initfunc(int ip_masq_irc_init(void)) -{ - int i, j; - - for (i=0; (i<MAX_MASQ_APP_PORTS); i++) { - if (ports[i]) { - if ((masq_incarnations[i] = kmalloc(sizeof(struct ip_masq_app), - GFP_KERNEL)) == NULL) - return -ENOMEM; - memcpy(masq_incarnations[i], &ip_masq_irc, sizeof(struct ip_masq_app)); - if ((j = register_ip_masq_app(masq_incarnations[i], - IPPROTO_TCP, - ports[i]))) { - return j; - } - IP_MASQ_DEBUG(1-debug, - "Irc: loaded support on port[%d] = %d\n", - i, ports[i]); - } else { - /* To be safe, force the incarnation table entry to NULL */ - masq_incarnations[i] = NULL; - } - } - return 0; -} - -/* - * ip_masq_irc fin. - */ - -int ip_masq_irc_done(void) -{ - int i, j, k; - - k=0; - for (i=0; (i<MAX_MASQ_APP_PORTS); i++) { - if (masq_incarnations[i]) { - if ((j = unregister_ip_masq_app(masq_incarnations[i]))) { - k = j; - } else { - kfree(masq_incarnations[i]); - masq_incarnations[i] = NULL; - IP_MASQ_DEBUG(1-debug, "Irc: unloaded support on port[%d] = %d\n", - i, ports[i]); - } - } - } - return k; -} - - -#ifdef MODULE -EXPORT_NO_SYMBOLS; - -int init_module(void) -{ - if (ip_masq_irc_init() != 0) - return -EIO; - return 0; -} - -void cleanup_module(void) -{ - if (ip_masq_irc_done() != 0) - printk(KERN_INFO "ip_masq_irc: can't remove module"); -} - -#endif /* MODULE */ +IPM_INIT_MODULE(irc,IPPROTO_TCP,Internet Relay Chat); +IPM_END_MODULE(irc,ip_masq_irc); diff -ruN linux/net/ipv4/ip_masq_quake.c 2.1.92/net/ipv4/ip_masq_quake.c --- linux/net/ipv4/ip_masq_quake.c Mon Mar 30 15:28:40 1998 +++ 2.1.92/net/ipv4/ip_masq_quake.c Mon Mar 30 15:41:08 1998 @@ -32,6 +32,7 @@ #include <net/protocol.h> #include <net/udp.h> #include <net/ip_masq.h> +#include <net/ip_masq_apphelp.h> #define DEBUG_CONFIG_IP_MASQ_QUAKE 0 @@ -47,6 +48,21 @@ char cl_connect; }; +#ifdef MODULE + #define PORTS ports + #define INCARNATIONS incarnations +#else + #define PORTS ip_masq_quake_ports + #define INCARNATIONS ip_masq_quake_incarnations +#endif +int PORTS[MAX_MASQ_APP_PORTS]={26000,27000}; /* I rely on the trailing items being set to zero */ +struct ip_masq_app *INCARNATIONS[MAX_MASQ_APP_PORTS]; + +static int debug=0; + +MODULE_PARM(PORTS, "1-" __MODULE_STRING(MAX_MASQ_APP_PORTS) "i"); +MODULE_PARM(debug, "i"); + static int masq_quake_init_1 (struct ip_masq_app *mapp, struct ip_masq *ms) { @@ -281,42 +297,6 @@ masq_quake_in /* pkt_in */ }; -/* - * ip_masq_quake initialization - */ - -__initfunc(int ip_masq_quake_init(void)) -{ - return (register_ip_masq_app(&ip_masq_quake, IPPROTO_UDP, 26000) + - register_ip_masq_app(&ip_masq_quakenew, IPPROTO_UDP, 27000)); -} - -/* - * ip_masq_quake fin. - */ - -int ip_masq_quake_done(void) -{ - return (unregister_ip_masq_app(&ip_masq_quake) + - unregister_ip_masq_app(&ip_masq_quakenew)); -} - -#ifdef MODULE -EXPORT_NO_SYMBOLS; - -int init_module(void) -{ - if (ip_masq_quake_init() != 0) - return -EIO; - return 0; -} - -void cleanup_module(void) -{ - if (ip_masq_quake_done() != 0) - printk("ip_masq_quake: can't remove module"); -} - -#endif /* MODULE */ - +IPM_INIT_MODULE(quake,IPPROTO_UDP,Quake); +IPM_END_MODULE(quake,ip_masq_quake); diff -ruN linux/net/ipv4/ip_masq_raudio.c 2.1.92/net/ipv4/ip_masq_raudio.c --- linux/net/ipv4/ip_masq_raudio.c Mon Mar 30 15:29:11 1998 +++ 2.1.92/net/ipv4/ip_masq_raudio.c Mon Mar 30 15:35:54 1998 @@ -74,6 +74,7 @@ #include <net/protocol.h> #include <net/tcp.h> #include <net/ip_masq.h> +#include <net/ip_masq_apphelp.h> /* #ifndef DEBUG_CONFIG_IP_MASQ_RAUDIO @@ -104,8 +105,15 @@ * List of ports (up to MAX_MASQ_APP_PORTS) to be handled by helper * First port is set to the default port. */ -int ports[MAX_MASQ_APP_PORTS] = {554, 7070, 0}; /* I rely on the trailing items being set to zero */ -struct ip_masq_app *masq_incarnations[MAX_MASQ_APP_PORTS]; +#ifdef MODULE + #define PORTS ports + #define INCARNATIONS incarnations +#else + #define PORTS ip_masq_raudio_ports + #define INCARNATIONS ip_masq_raudio_incarnations +#endif +int PORTS[MAX_MASQ_APP_PORTS]={554,7070}; /* I rely on the trailing items being set to zero */ +struct ip_masq_app *INCARNATIONS[MAX_MASQ_APP_PORTS]; /* * Debug level @@ -507,69 +515,5 @@ * ip_masq_raudio initialization */ -__initfunc(int ip_masq_raudio_init(void)) -{ - int i, j; - - for (i=0; (i<MAX_MASQ_APP_PORTS); i++) { - if (ports[i]) { - if ((masq_incarnations[i] = kmalloc(sizeof(struct ip_masq_app), - GFP_KERNEL)) == NULL) - return -ENOMEM; - memcpy(masq_incarnations[i], &ip_masq_raudio, sizeof(struct ip_masq_app)); - if ((j = register_ip_masq_app(masq_incarnations[i], - IPPROTO_TCP, - ports[i]))) { - return j; - } - IP_MASQ_DEBUG(1-debug, "RealAudio: loaded support on port[%d] = %d\n", - i, ports[i]); - } else { - /* To be safe, force the incarnation table entry to NULL */ - masq_incarnations[i] = NULL; - } - } - return 0; -} - -/* - * ip_masq_raudio fin. - */ - -int ip_masq_raudio_done(void) -{ - int i, j, k; - - k=0; - for (i=0; (i<MAX_MASQ_APP_PORTS); i++) { - if (masq_incarnations[i]) { - if ((j = unregister_ip_masq_app(masq_incarnations[i]))) { - k = j; - } else { - kfree(masq_incarnations[i]); - masq_incarnations[i] = NULL; - IP_MASQ_DEBUG(1-debug, "RealAudio: unloaded support on port[%d] = %d\n", - i, ports[i]); - } - } - } - return k; -} - -#ifdef MODULE -EXPORT_NO_SYMBOLS; - -int init_module(void) -{ - if (ip_masq_raudio_init() != 0) - return -EIO; - return 0; -} - -void cleanup_module(void) -{ - if (ip_masq_raudio_done() != 0) - printk(KERN_INFO "ip_masq_raudio: can't remove module"); -} - -#endif /* MODULE */ +IPM_INIT_MODULE(raudio,IPPROTO_TCP,Real Audio); +IPM_END_MODULE(raudio,ip_masq_raudio); diff -ruN linux/net/ipv4/ip_masq_vdolive.c 2.1.92/net/ipv4/ip_masq_vdolive.c --- linux/net/ipv4/ip_masq_vdolive.c Wed Dec 10 12:45:16 1997 +++ 2.1.92/net/ipv4/ip_masq_vdolive.c Mon Mar 30 15:35:54 1998 @@ -33,6 +33,7 @@ #include <net/protocol.h> #include <net/tcp.h> #include <net/ip_masq.h> +#include <net/ip_masq_apphelp.h> struct vdolive_priv_data { /* Ports used */ @@ -46,15 +47,23 @@ * List of ports (up to MAX_MASQ_APP_PORTS) to be handled by helper * First port is set to the default port. */ -static int ports[MAX_MASQ_APP_PORTS] = {7000}; /* I rely on the trailing items being set to zero */ -struct ip_masq_app *masq_incarnations[MAX_MASQ_APP_PORTS]; +#ifdef MODULE + #define PORTS ports + #define INCARNATIONS incarnations +#else + #define PORTS ip_masq_vdolive_ports + #define INCARNATIONS ip_masq_vdolive_incarnations +#endif +int PORTS[MAX_MASQ_APP_PORTS]={7000}; /* I rely on the trailing items being set to zero */ +struct ip_masq_app *INCARNATIONS[MAX_MASQ_APP_PORTS]; + /* * Debug level */ static int debug=0; -MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_MASQ_APP_PORTS) "i"); +MODULE_PARM(PORTS, "1-" __MODULE_STRING(MAX_MASQ_APP_PORTS) "i"); MODULE_PARM(debug, "i"); static int @@ -220,72 +229,6 @@ NULL /* pkt_in */ }; -/* - * ip_masq_vdolive initialization - */ - -__initfunc(int ip_masq_vdolive_init(void)) -{ - int i, j; - - for (i=0; (i<MAX_MASQ_APP_PORTS); i++) { - if (ports[i]) { - if ((masq_incarnations[i] = kmalloc(sizeof(struct ip_masq_app), - GFP_KERNEL)) == NULL) - return -ENOMEM; - memcpy(masq_incarnations[i], &ip_masq_vdolive, sizeof(struct ip_masq_app)); - if ((j = register_ip_masq_app(masq_incarnations[i], - IPPROTO_TCP, - ports[i]))) { - return j; - } - IP_MASQ_DEBUG(1-debug, "RealAudio: loaded support on port[%d] = %d\n", i, ports[i]); - } else { - /* To be safe, force the incarnation table entry to NULL */ - masq_incarnations[i] = NULL; - } - } - return 0; -} - -/* - * ip_masq_vdolive fin. - */ - -int ip_masq_vdolive_done(void) -{ - int i, j, k; - - k=0; - for (i=0; (i<MAX_MASQ_APP_PORTS); i++) { - if (masq_incarnations[i]) { - if ((j = unregister_ip_masq_app(masq_incarnations[i]))) { - k = j; - } else { - kfree(masq_incarnations[i]); - masq_incarnations[i] = NULL; - IP_MASQ_DEBUG(1-debug,"VDOlive: unloaded support on port[%d] = %d\n", i, ports[i]); - } - } - } - return k; -} - - -#ifdef MODULE -EXPORT_NO_SYMBOLS; - -int init_module(void) -{ - if (ip_masq_vdolive_init() != 0) - return -EIO; - return 0; -} - -void cleanup_module(void) -{ - if (ip_masq_vdolive_done() != 0) - IP_MASQ_DEBUG(1-debug, "ip_masq_vdolive: can't remove module"); -} +IPM_INIT_MODULE(vdolive,IPPROTO_TCP,RealAudio); +IPM_END_MODULE(vdolive,ip_masq_vdolive); -#endif /* MODULE */ | |