Patch: 2.1.82 IP_MASQ no modules patch

Adam Heath (adam@brainiac.egr.msu.edu)
Wed, 28 Jan 1998 13:55:42 -0500 (EST)


This patch allows the ip_masq helper apps to be compiled directly into the
kernel, no longer needing to be modules. Support is there for adding
non-standard ports for each app on the kernel command line. Read the
Configure.help text to find out.

Here is a line I use in lilo for testing this feature.
append="reboot=warm \
ip_masq=+quake,1001 \
ip_masq=+ftp,1002 \
ip_masq=+vdolive,1003 \
ip_masq=+raudio,1004 \
ip_masq=+cuseeme,1005 \
ip_masq=+irc,1006 \
"
This says to add the mentioned ports to the ones already defined for the
app. If the plus wasn't there, then the mentioned port[s] would replace
the ones already defined.

diff -ruN 2.1.82-pure/Documentation/Configure.help 2.1.82/Documentation/Configure.help
--- 2.1.82-pure/Documentation/Configure.help Wed Jan 28 13:26:29 1998
+++ 2.1.82/Documentation/Configure.help Wed Jan 28 13:01:42 1998
@@ -1630,6 +1630,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 2.1.82-pure/include/net/ip_masq_app.h 2.1.82/include/net/ip_masq_app.h
--- 2.1.82-pure/include/net/ip_masq_app.h Wed Dec 31 19:00:00 1969
+++ 2.1.82/include/net/ip_masq_app.h Wed Jan 28 11:09:32 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 2.1.82-pure/include/net/ip_masq_apphelp.h 2.1.82/include/net/ip_masq_apphelp.h
--- 2.1.82-pure/include/net/ip_masq_apphelp.h Wed Dec 31 19:00:00 1969
+++ 2.1.82/include/net/ip_masq_apphelp.h Wed Jan 28 11:56:06 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 2.1.82-pure/init/main.c 2.1.82/init/main.c
--- 2.1.82-pure/init/main.c Wed Jan 28 13:26:33 1998
+++ 2.1.82/init/main.c Tue Jan 27 20:00:52 1998
@@ -277,7 +277,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) || defined(CONFIG_KERNELD)
extern void ipc_init(void);
#endif
@@ -492,6 +494,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 2.1.82-pure/net/ipv4/Config.in 2.1.82/net/ipv4/Config.in
--- 2.1.82-pure/net/ipv4/Config.in Thu Jan 15 17:33:07 1998
+++ 2.1.82/net/ipv4/Config.in Tue Jan 27 20:00:52 1998
@@ -39,9 +39,13 @@
bool 'IP: accounting' CONFIG_IP_ACCT
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 2.1.82-pure/net/ipv4/Makefile 2.1.82/net/ipv4/Makefile
--- 2.1.82-pure/net/ipv4/Makefile Wed Dec 10 12:45:16 1997
+++ 2.1.82/net/ipv4/Makefile Wed Jan 28 11:38:35 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 2.1.82-pure/net/ipv4/ip_masq_app.c 2.1.82/net/ipv4/ip_masq_app.c
--- 2.1.82-pure/net/ipv4/ip_masq_app.c Wed Dec 10 12:45:16 1997
+++ 2.1.82/net/ipv4/ip_masq_app.c Tue Jan 27 20:00:52 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 */
+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 2.1.82-pure/net/ipv4/ip_masq_cuseeme.c 2.1.82/net/ipv4/ip_masq_cuseeme.c
--- 2.1.82-pure/net/ipv4/ip_masq_cuseeme.c Wed Dec 10 12:45:16 1997
+++ 2.1.82/net/ipv4/ip_masq_cuseeme.c Wed Jan 28 11:57:21 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 2.1.82-pure/net/ipv4/ip_masq_ftp.c 2.1.82/net/ipv4/ip_masq_ftp.c
--- 2.1.82-pure/net/ipv4/ip_masq_ftp.c Wed Dec 10 12:45:16 1997
+++ 2.1.82/net/ipv4/ip_masq_ftp.c Wed Jan 28 11:57:01 1998
@@ -48,6 +48,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>
@@ -57,15 +58,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 */
@@ -319,73 +327,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 2.1.82-pure/net/ipv4/ip_masq_irc.c 2.1.82/net/ipv4/ip_masq_irc.c
--- 2.1.82-pure/net/ipv4/ip_masq_irc.c Wed Dec 10 12:45:16 1997
+++ 2.1.82/net/ipv4/ip_masq_irc.c Wed Jan 28 11:58:05 1998
@@ -53,20 +53,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");


@@ -294,75 +304,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 2.1.82-pure/net/ipv4/ip_masq_quake.c 2.1.82/net/ipv4/ip_masq_quake.c
--- 2.1.82-pure/net/ipv4/ip_masq_quake.c Wed Dec 10 12:45:16 1997
+++ 2.1.82/net/ipv4/ip_masq_quake.c Wed Jan 28 11:56:40 1998
@@ -21,7 +21,6 @@
*
*/

-#include <linux/config.h>
#include <linux/module.h>
#include <asm/system.h>
#include <linux/types.h>
@@ -33,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 +47,20 @@
/* Have we seen a client connect message */
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)
@@ -282,42 +296,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 2.1.82-pure/net/ipv4/ip_masq_raudio.c 2.1.82/net/ipv4/ip_masq_raudio.c
--- 2.1.82-pure/net/ipv4/ip_masq_raudio.c Wed Dec 10 12:45:16 1997
+++ 2.1.82/net/ipv4/ip_masq_raudio.c Wed Jan 28 11:57:41 1998
@@ -75,6 +75,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
@@ -105,8 +106,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
@@ -508,69 +516,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 2.1.82-pure/net/ipv4/ip_masq_vdolive.c 2.1.82/net/ipv4/ip_masq_vdolive.c
--- 2.1.82-pure/net/ipv4/ip_masq_vdolive.c Wed Dec 10 12:45:16 1997
+++ 2.1.82/net/ipv4/ip_masq_vdolive.c Wed Jan 28 11:58:44 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 */