[netfilter-cvslog] r3755 - in trunk/patch-o-matic-ng/rtsp-conntrack: . linux-2.6.11 linux-2.6.11/include/linux/netfilter_ipv4 linux-2.6.11/net/ipv4/netfilter

laforge at netfilter.org laforge at netfilter.org
Wed Mar 2 13:02:47 CET 2005


Author: laforge at netfilter.org
Date: 2005-03-02 13:02:47 +0100 (Wed, 02 Mar 2005)
New Revision: 3755

Added:
   trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11/
Removed:
   trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11/Documentation/
   trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11/net/ipv4/netfilter/Config.in.ladd
   trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11/net/ipv4/netfilter/Config.in.ladd_2
Modified:
   trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11/include/linux/netfilter_ipv4/ip_conntrack_rtsp.h
   trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11/net/ipv4/netfilter/ip_conntrack_rtsp.c
   trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11/net/ipv4/netfilter/ip_nat_rtsp.c
Log:
add incomplete 2.6.11 branch


Copied: trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11 (from rev 3749, trunk/patch-o-matic-ng/rtsp-conntrack/linux)

Modified: trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11/include/linux/netfilter_ipv4/ip_conntrack_rtsp.h
===================================================================
--- trunk/patch-o-matic-ng/rtsp-conntrack/linux/include/linux/netfilter_ipv4/ip_conntrack_rtsp.h	2005-03-01 20:30:53 UTC (rev 3749)
+++ trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11/include/linux/netfilter_ipv4/ip_conntrack_rtsp.h	2005-03-02 12:02:47 UTC (rev 3755)
@@ -12,7 +12,7 @@
 #define _IP_CONNTRACK_RTSP_H
 
 /* #define IP_NF_RTSP_DEBUG */
-#define IP_NF_RTSP_VERSION "0.01"
+#define IP_NF_RTSP_VERSION "0.6.21"
 
 /* port block types */
 typedef enum {
@@ -47,22 +47,12 @@
 #endif
 };
 
-/* This structure exists only once per master */
-struct ip_ct_rtsp_master
-{
-    /* Empty (?) */
-};
-
-
 #ifdef __KERNEL__
 
 #include <linux/netfilter_ipv4/lockhelp.h>
 
 #define RTSP_PORT   554
 
-/* Protects rtsp part of conntracks */
-DECLARE_LOCK_EXTERN(ip_rtsp_lock);
-
 #endif /* __KERNEL__ */
 
 #endif /* _IP_CONNTRACK_RTSP_H */

Deleted: trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11/net/ipv4/netfilter/Config.in.ladd
===================================================================
--- trunk/patch-o-matic-ng/rtsp-conntrack/linux/net/ipv4/netfilter/Config.in.ladd	2005-03-01 20:30:53 UTC (rev 3749)
+++ trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11/net/ipv4/netfilter/Config.in.ladd	2005-03-02 12:02:47 UTC (rev 3755)
@@ -1,8 +0,0 @@
-        dep_tristate '    Basic SNMP-ALG support (EXPERIMENTAL)' CONFIG_IP_NF_NAT_SNMP_BASIC $CONFIG_IP_NF_NAT
-        if [ "$CONFIG_IP_NF_RTSP" = "m" ]; then
-          define_tristate CONFIG_IP_NF_NAT_RTSP m
-        else
-          if [ "$CONFIG_IP_NF_RTSP" = "y" ]; then
-            define_tristate CONFIG_IP_NF_NAT_RTSP $CONFIG_IP_NF_NAT
-          fi
-        fi

Deleted: trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11/net/ipv4/netfilter/Config.in.ladd_2
===================================================================
--- trunk/patch-o-matic-ng/rtsp-conntrack/linux/net/ipv4/netfilter/Config.in.ladd_2	2005-03-01 20:30:53 UTC (rev 3749)
+++ trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11/net/ipv4/netfilter/Config.in.ladd_2	2005-03-02 12:02:47 UTC (rev 3755)
@@ -1,2 +0,0 @@
-  dep_tristate '  IRC protocol support' CONFIG_IP_NF_IRC $CONFIG_IP_NF_CONNTRACK
-  dep_tristate '  RTSP protocol support' CONFIG_IP_NF_RTSP $CONFIG_IP_NF_CONNTRACK

Modified: trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11/net/ipv4/netfilter/ip_conntrack_rtsp.c
===================================================================
--- trunk/patch-o-matic-ng/rtsp-conntrack/linux/net/ipv4/netfilter/ip_conntrack_rtsp.c	2005-03-01 20:30:53 UTC (rev 3749)
+++ trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11/net/ipv4/netfilter/ip_conntrack_rtsp.c	2005-03-02 12:02:47 UTC (rev 3755)
@@ -18,6 +18,10 @@
  * answered SETUP requests per RTSP session (default 8).
  * With setup_timeout you can specify how long the system waits for
  * an expected data channel (default 300 seconds).
+ *
+ * 2005-02-13: Harald Welte <laforge at netfilter.org>
+ * 	- port to 2.6
+ * 	- update to recent post-2.6.11 api changes
  */
 
 #include <linux/config.h>
@@ -58,18 +62,23 @@
 MODULE_AUTHOR("Tom Marshall <tmarshall at real.com>");
 MODULE_DESCRIPTION("RTSP connection tracking module");
 MODULE_LICENSE("GPL");
-#ifdef MODULE_PARM
-MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i");
+module_param_array(ports, int, &ports_c, 0400);
 MODULE_PARM_DESC(ports, "port numbers of RTSP servers");
-MODULE_PARM(max_outstanding, "i");
+module_param(max_outstanding, int, 0400);
 MODULE_PARM_DESC(max_outstanding, "max number of outstanding SETUP requests per RTSP session");
-MODULE_PARM(setup_timeout, "i");
+module_param(setup_timeout, int, 0400);
 MODULE_PARM_DESC(setup_timeout, "timeout on for unestablished data channels");
-#endif
 
-DECLARE_LOCK(ip_rtsp_lock);
-struct module* ip_conntrack_rtsp = THIS_MODULE;
+static char rtsp_buffer[65536];
+static DECLARE_LOCK(rtsp_buffer_lock);
 
+unsigned int (*ip_nat_rtsp_hook)(struct sk_buff **pskb,
+				 enum ip_conntrack_info ctinfo,
+				 unsigned int matchoff,
+				 unsigned int matchlen,
+				 struct ip_conntrack_expect *exp);
+EXPORT_SYMBOL_GPL(ip_nat_rtsp_hook);
+
 /*
  * Max mappings we will allow for one RTSP connection (for RTP, the number
  * of allocated ports is twice this value).  Note that SMIL burns a lot of
@@ -258,19 +267,23 @@
 /*** conntrack functions ***/
 
 /* outbound packet: client->server */
-static int
-help_out(const struct iphdr* iph, size_t pktlen,
+static inline int
+help_out(struct sk_buff **pskb, unsigned char *rb_ptr, unsigned int datalen,
                 struct ip_conntrack* ct, enum ip_conntrack_info ctinfo)
 {
+    struct ip_ct_rtsp_expect expinfo;
     int dir = CTINFO2DIR(ctinfo);   /* = IP_CT_DIR_ORIGINAL */
-    struct  tcphdr* tcph = (void*)iph + iph->ihl * 4;
-    uint    tcplen = pktlen - iph->ihl * 4;
-    char*   pdata = (char*)tcph + tcph->doff * 4;
-    uint    datalen = tcplen - tcph->doff * 4;
+    //struct  tcphdr* tcph = (void*)iph + iph->ihl * 4;
+    //uint    tcplen = pktlen - iph->ihl * 4;
+    char*   pdata = rb_ptr;
+    //uint    datalen = tcplen - tcph->doff * 4;
     uint    dataoff = 0;
+    int ret = NF_ACCEPT;
 
-    struct ip_conntrack_expect exp;
+    struct ip_conntrack_expect *exp;
 
+    memset(&expinfo, 0, sizeof(expinfo));
+
     while (dataoff < datalen)
     {
         uint    cmdoff = dataoff;
@@ -296,8 +309,6 @@
         }
         DEBUGP("found a setup message\n");
 
-        memset(&exp, 0, sizeof(exp));
-
         off = 0;
         while (nf_mime_nextline(pdata+hdrsoff, hdrslen, &off,
                                 &lineoff, &linelen))
@@ -314,87 +325,104 @@
 
             if (nf_strncasecmp(pdata+hdrsoff+lineoff, "Transport:", 10) == 0)
             {
-                rtsp_parse_transport(pdata+hdrsoff+lineoff, linelen,
-                                     &exp.help.exp_rtsp_info);
+                rtsp_parse_transport(pdata+hdrsoff+lineoff, linelen, &expinfo);
             }
         }
 
-        if (exp.help.exp_rtsp_info.loport == 0)
+        if (expinfo.loport == 0)
         {
             DEBUGP("no udp transports found\n");
             continue;   /* no udp transports found */
         }
 
         DEBUGP("udp transport found, ports=(%d,%hu,%hu)\n",
-              (int)exp.help.exp_rtsp_info.pbtype,
-              exp.help.exp_rtsp_info.loport,
-              exp.help.exp_rtsp_info.hiport);
+              (int)expinfo.pbtype,
+              expinfo.loport,
+              expinfo.hiport);
 
-        LOCK_BH(&ip_rtsp_lock);
-        exp.seq = ntohl(tcph->seq) + hdrsoff; /* mark all the headers */
-        exp.help.exp_rtsp_info.len = hdrslen;
+	exp = ip_conntrack_expect_alloc();
+	if (!exp)
+		ret = NF_DROP;
+		goto out;
+	}
 
-        exp.tuple.src.ip = ct->tuplehash[!dir].tuple.src.ip;
-        exp.mask.src.ip  = 0xffffffff;
-        exp.tuple.dst.ip = ct->tuplehash[dir].tuple.src.ip;
-        exp.mask.dst.ip  = 0xffffffff;
-        exp.tuple.dst.u.udp.port = exp.help.exp_rtsp_info.loport;
-        exp.mask.dst.u.udp.port  = (exp.help.exp_rtsp_info.pbtype == pb_range) ? 0xfffe : 0xffff;
-        exp.tuple.dst.protonum = IPPROTO_UDP;
-        exp.mask.dst.protonum  = 0xffff;
+        //exp->seq = ntohl(tcph->seq) + hdrsoff; /* mark all the headers */
+	exp->master = ct;
+        //exp.help.exp_rtsp_info.len = hdrslen;
 
+        exp->tuple.src.ip = ct->tuplehash[!dir].tuple.src.ip;
+        exp->mask.src.ip  = 0xffffffff;
+        exp->tuple.dst.ip = ct->tuplehash[dir].tuple.src.ip;
+        exp->mask.dst.ip  = 0xffffffff;
+        exp->tuple.dst.u.udp.port = expinfo.loport;
+        exp->mask.dst.u.udp.port  = 
+		(expinfo.pbtype == pb_range) ? 0xfffe : 0xffff;
+        exp->tuple.dst.protonum = IPPROTO_UDP;
+        exp->mask.dst.protonum  = 0xff;
+
         DEBUGP("expect_related %u.%u.%u.%u:%u-%u.%u.%u.%u:%u\n",
-                NIPQUAD(exp.tuple.src.ip),
-                ntohs(exp.tuple.src.u.tcp.port),
-                NIPQUAD(exp.tuple.dst.ip),
-                ntohs(exp.tuple.dst.u.tcp.port));
+                NIPQUAD(exp->tuple.src.ip),
+                ntohs(exp->tuple.src.u.tcp.port),
+                NIPQUAD(exp->tuple.dst.ip),
+                ntohs(exp->tuple.dst.u.tcp.port));
 
-        /* pass the request off to the nat helper */
-        rc = ip_conntrack_expect_related(ct, &exp);
-        UNLOCK_BH(&ip_rtsp_lock);
-        if (rc == 0)
-        {
-            DEBUGP("ip_conntrack_expect_related succeeded\n");
-        }
-        else
-        {
-            INFOP("ip_conntrack_expect_related failed (%d)\n", rc);
-        }
+	if (ip_nat_rtsp_hook)
+        	/* pass the request off to the nat helper */
+		ret = ip_nat_rtsp_hook(pskb, ctinfo, hooknum, &expinfo, exp);
+	else if (ip_conntrack_expect_related(exp) != 0) {
+  		INFOP("ip_conntrack_expect_related failed\n", rc);
+		ip_conntrack_expect_free(exp);
+		ret  = NF_DROP;
+	}
+	goto out;
     }
+out:
 
-    return NF_ACCEPT;
+    return ret;
 }
 
 /* inbound packet: server->client */
-static int
-help_in(const struct iphdr* iph, size_t pktlen,
+static inline int
+help_in(struct sk_buff **pskb, size_t pktlen,
                 struct ip_conntrack* ct, enum ip_conntrack_info ctinfo)
 {
     return NF_ACCEPT;
 }
 
-static int
-help(const struct iphdr* iph, size_t pktlen,
-                struct ip_conntrack* ct, enum ip_conntrack_info ctinfo)
+static int help(struct sk_buff **pskb, struct ip_conntrack* ct, enum
+		ip_conntrack_info ctinfo) 
 {
-    /* tcplen not negative guarenteed by ip_conntrack_tcp.c */
-    struct tcphdr* tcph = (void*)iph + iph->ihl * 4;
-    u_int32_t tcplen = pktlen - iph->ihl * 4;
+    struct tcphdr _tcph, *th;
+    unsigned int dataoff, datalen;
+    char *rb_ptr;
+    int ret;
 
     /* Until there's been traffic both ways, don't look in packets. */
-    if (ctinfo != IP_CT_ESTABLISHED && ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY)
+    if (ctinfo != IP_CT_ESTABLISHED && 
+	ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY)
     {
         DEBUGP("conntrackinfo = %u\n", ctinfo);
         return NF_ACCEPT;
     }
 
     /* Not whole TCP header? */
-    if (tcplen < sizeof(struct tcphdr) || tcplen < tcph->doff * 4)
-    {
-        DEBUGP("tcplen = %u\n", (unsigned)tcplen);
-        return NF_ACCEPT;
-    }
+    th = skb_header_pointer(*pskb, (*pskb)->nh.iph->ihl*4,
+		    	    sizeof(_tcph), &_tcph);
+    if (!th)
+	    return NF_ACCEPT;
+   
+    /* No data ? */
+    dataoff = (*pskb)->nh.iph->ihl*4 + th->doff*4;
+    datalen = (*pskb)->len - dataoff;
+    if (dataoff >= (*pskb)->len)
+	    return NF_ACCEPT;
 
+    LOCK_BH(&rtsp_buffer_lock);
+    rb_ptr = skb_header_pointer(*pskb, dataoff,
+		    		(*pskb)->len - dataoff, rtsp_buffer);
+    BUG_ON(rb_ptr == NULL);
+
+#if 0
     /* Checksum invalid?  Ignore. */
     /* FIXME: Source route IP option packets --RR */
     if (tcp_v4_check(tcph, tcplen, iph->saddr, iph->daddr,
@@ -404,18 +432,21 @@
                tcph, tcplen, NIPQUAD(iph->saddr), NIPQUAD(iph->daddr));
         return NF_ACCEPT;
     }
+#endif
 
     switch (CTINFO2DIR(ctinfo))
     {
     case IP_CT_DIR_ORIGINAL:
-        help_out(iph, pktlen, ct, ctinfo);
+        ret = help_out(*pskb, rb_ptr, datalen, ct, ctinfo);
         break;
     case IP_CT_DIR_REPLY:
-        help_in(iph, pktlen, ct, ctinfo);
+        ret = help_in(*pskb, rb_ptr, datalen, ct, ctinfo);
         break;
     }
 
-    return NF_ACCEPT;
+    UNLOCK_BH(&rtsp_buffer_lock);
+
+    return ret;
 }
 
 static struct ip_conntrack_helper rtsp_helpers[MAX_PORTS];
@@ -466,7 +497,7 @@
         hlpr->tuple.src.u.tcp.port = htons(ports[i]);
         hlpr->tuple.dst.protonum = IPPROTO_TCP;
         hlpr->mask.src.u.tcp.port = 0xFFFF;
-        hlpr->mask.dst.protonum = 0xFFFF;
+        hlpr->mask.dst.protonum = 0xFF;
         hlpr->max_expected = max_outstanding;
         hlpr->timeout = setup_timeout;
         hlpr->flags = IP_CT_HELPER_F_REUSE_EXPECT;

Modified: trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11/net/ipv4/netfilter/ip_nat_rtsp.c
===================================================================
--- trunk/patch-o-matic-ng/rtsp-conntrack/linux/net/ipv4/netfilter/ip_nat_rtsp.c	2005-03-01 20:30:53 UTC (rev 3749)
+++ trunk/patch-o-matic-ng/rtsp-conntrack/linux-2.6.11/net/ipv4/netfilter/ip_nat_rtsp.c	2005-03-02 12:02:47 UTC (rev 3755)
@@ -73,18 +73,11 @@
 MODULE_AUTHOR("Tom Marshall <tmarshall at real.com>");
 MODULE_DESCRIPTION("RTSP network address translation module");
 MODULE_LICENSE("GPL");
-#ifdef MODULE_PARM
-MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i");
-MODULE_PARM_DESC(ports, "port numbers of RTSP servers");
-MODULE_PARM(stunaddr, "s");
+module_param(stunaddr, "s");
 MODULE_PARM_DESC(stunaddr, "Address for detecting STUN");
-MODULE_PARM(destaction, "s");
+module_param(destaction, "s");
 MODULE_PARM_DESC(destaction, "Action for destination parameter (auto/strip/none)");
-#endif
 
-/* protects rtsp part of conntracks */
-DECLARE_LOCK_EXTERN(ip_rtsp_lock);
-
 #define SKIP_WSPACE(ptr,len,off) while(off < len && isspace(*(ptr+off))) { off++; }
 
 /*** helper functions ***/
@@ -119,7 +112,7 @@
  * Assumes that a complete transport header is present, ending with CR or LF
  */
 static int
-rtsp_mangle_tran(struct ip_conntrack* ct, enum ip_conntrack_info ctinfo,
+rtsp_mangle_tran(enum ip_conntrack_info ctinfo,
                  struct ip_conntrack_expect* exp,
                  struct sk_buff** pskb, uint tranoff, uint tranlen)
 {
@@ -135,6 +128,7 @@
     uint        off = 0;
     uint        diff;           /* Number of bytes we removed */
 
+    struct ip_conntrack *ct = exp->master;
     struct ip_ct_rtsp_expect* prtspexp = &exp->help.exp_rtsp_info;
     struct ip_conntrack_tuple t;
 
@@ -278,6 +272,7 @@
                                                          off, diff, NULL, 0))
                     {
                         /* mangle failed, all we can do is bail */
+			ip_conntrack_unexpect_related(exp);
                         return 0;
                     }
                     get_skb_tcpdata(*pskb, &ptcp, &tcplen);
@@ -347,6 +342,7 @@
                                               origoff, origlen, rbuf, rbuflen))
                     {
                         /* mangle failed, all we can do is bail */
+			ip_conntrack_unexpect_related(exp);
                         return 0;
                     }
                     get_skb_tcpdata(*pskb, &ptcp, &tcplen);
@@ -395,8 +391,9 @@
 }
 
 static uint
-help_out(struct ip_conntrack* ct, enum ip_conntrack_info ctinfo,
-         struct ip_conntrack_expect* exp, struct sk_buff** pskb)
+help_out(struct sk_buff **pskb, enum ip_conntrack_info ctinfo,
+	 struct ip_ct_rtsp_expect *prtspexp,
+         struct ip_conntrack_expect* exp)
 {
     char*   ptcp;
     uint    tcplen;
@@ -409,8 +406,6 @@
     struct iphdr* iph = (struct iphdr*)(*pskb)->nh.iph;
     struct tcphdr* tcph = (struct tcphdr*)((void*)iph + iph->ihl*4);
 
-    struct ip_ct_rtsp_expect* prtspexp = &exp->help.exp_rtsp_info;
-
     get_skb_tcpdata(*pskb, &ptcp, &tcplen);
 
     hdrsoff = exp->seq - ntohl(tcph->seq);
@@ -449,78 +444,27 @@
     return NF_ACCEPT;
 }
 
-static uint
-help_in(struct ip_conntrack* ct, enum ip_conntrack_info ctinfo,
-         struct ip_conntrack_expect* exp, struct sk_buff** pskb)
-{
-    /* XXX: unmangle */
-    return NF_ACCEPT;
-}
-
-static uint
-help(struct ip_conntrack* ct,
-     struct ip_conntrack_expect* exp,
-     struct ip_nat_info* info,
+static int
+help(struct sk_buff **pskb
      enum ip_conntrack_info ctinfo,
      unsigned int hooknum,
-     struct sk_buff** pskb)
+     struct ip_ct_rtsp_expect *ct_rtsp_info;
+     struct ip_conntrack_expect* exp)
 {
     struct iphdr*  iph  = (struct iphdr*)(*pskb)->nh.iph;
     struct tcphdr* tcph = (struct tcphdr*)((char*)iph + iph->ihl * 4);
     uint datalen;
-    int dir;
-    struct ip_ct_rtsp_expect* ct_rtsp_info;
+    int dir = CTINFO2DIR(ctinfo);
     int rc = NF_ACCEPT;
 
-    if (ct == NULL || exp == NULL || info == NULL || pskb == NULL)
-    {
-        DEBUGP("!! null ptr (%p,%p,%p,%p) !!\n", ct, exp, info, pskb);
-        return NF_ACCEPT;
-    }
-
-    ct_rtsp_info = &exp->help.exp_rtsp_info;
-
-    /*
-     * Only mangle things once: original direction in POST_ROUTING
-     * and reply direction on PRE_ROUTING.
-     */
-    dir = CTINFO2DIR(ctinfo);
-    if (!((hooknum == NF_IP_POST_ROUTING && dir == IP_CT_DIR_ORIGINAL)
-          || (hooknum == NF_IP_PRE_ROUTING && dir == IP_CT_DIR_REPLY)))
-    {
-        DEBUGP("Not touching dir %s at hook %s\n",
-               dir == IP_CT_DIR_ORIGINAL ? "ORIG" : "REPLY",
-               hooknum == NF_IP_POST_ROUTING ? "POSTROUTING"
-               : hooknum == NF_IP_PRE_ROUTING ? "PREROUTING"
-               : hooknum == NF_IP_LOCAL_OUT ? "OUTPUT" : "???");
-        return NF_ACCEPT;
-    }
-    DEBUGP("got beyond not touching\n");
-
-    datalen = (*pskb)->len - iph->ihl * 4 - tcph->doff * 4;
-
-    LOCK_BH(&ip_rtsp_lock);
-    /* Ensure the packet contains all of the marked data */
-    if (!between(exp->seq + ct_rtsp_info->len,
-                 ntohl(tcph->seq), ntohl(tcph->seq) + datalen))
-    {
-        /* Partial retransmission?  Probably a hacker. */
-        if (net_ratelimit())
-        {
-            INFOP("partial packet %u/%u in %u/%u\n",
-                   exp->seq, ct_rtsp_info->len, ntohl(tcph->seq), ntohl(tcph->seq) + datalen);
-        }
-        UNLOCK_BH(&ip_rtsp_lock);
-        return NF_DROP;
-    }
-
     switch (dir)
     {
     case IP_CT_DIR_ORIGINAL:
-        rc = help_out(ct, ctinfo, exp, pskb);
+        rc = help_out(pskb, ctinfo, ct_rtsp_info, exp, pskb);
         break;
     case IP_CT_DIR_REPLY:
-        rc = help_in(ct, ctinfo, exp, pskb);
+    	/* XXX: unmangle */
+	rc = NF_ACCEPT;
         break;
     }
     UNLOCK_BH(&ip_rtsp_lock);
@@ -528,93 +472,33 @@
     return rc;
 }
 
-static struct ip_nat_helper ip_nat_rtsp_helpers[MAX_PORTS];
-static char rtsp_names[MAX_PORTS][10];
-
-/* This function is intentionally _NOT_ defined as  __exit */
-static void
-fini(void)
+static void __exit fini(void)
 {
-    int i;
-
-    for (i = 0; i < num_ports; i++)
-    {
-        DEBUGP("unregistering helper for port %d\n", ports[i]);
-        ip_nat_helper_unregister(&ip_nat_rtsp_helpers[i]);
-    }
+	ip_nat_rtsp_hook = NULL;
+	synchronize_net();
 }
 
-static int __init
-init(void)
+static int __init init(void)
 {
-    int ret = 0;
-    int i;
-    struct ip_nat_helper* hlpr;
-    char* tmpname;
+	printk("ip_nat_rtsp v" IP_NF_RTSP_VERSION " loading\n");
 
-    printk("ip_nat_rtsp v" IP_NF_RTSP_VERSION " loading\n");
+	BUG_ON(ip_nat_rtsp_hook);
+	ip_nat_rtsp_hook = help;
 
-    if (ports[0] == 0)
-    {
-        ports[0] = RTSP_PORT;
-    }
+	if (stunaddr != NULL)
+		extip = in_aton(stunaddr);
 
-    for (i = 0; (i < MAX_PORTS) && ports[i] != 0; i++)
-    {
-        hlpr = &ip_nat_rtsp_helpers[i];
-        memset(hlpr, 0, sizeof(struct ip_nat_helper));
+	if (destaction != NULL) {
+	        if (strcmp(destaction, "auto") == 0)
+			dstact = DSTACT_AUTO;
 
-        hlpr->tuple.dst.protonum = IPPROTO_TCP;
-        hlpr->tuple.src.u.tcp.port = htons(ports[i]);
-        hlpr->mask.src.u.tcp.port = 0xFFFF;
-        hlpr->mask.dst.protonum = 0xFFFF;
-        hlpr->help = help;
-        hlpr->flags = 0;
-        hlpr->me = THIS_MODULE;
-        hlpr->expect = expected;
+		if (strcmp(destaction, "strip") == 0)
+			dstact = DSTACT_STRIP;
 
-        tmpname = &rtsp_names[i][0];
-        if (ports[i] == RTSP_PORT)
-        {
-                sprintf(tmpname, "rtsp");
-        }
-        else
-        {
-                sprintf(tmpname, "rtsp-%d", i);
-        }
-        hlpr->name = tmpname;
-
-        DEBUGP("registering helper for port %d: name %s\n", ports[i], hlpr->name);
-        ret = ip_nat_helper_register(hlpr);
-
-        if (ret)
-        {
-            printk("ip_nat_rtsp: error registering helper for port %d\n", ports[i]);
-            fini();
-            return 1;
-        }
-        num_ports++;
-    }
-    if (stunaddr != NULL)
-    {
-        extip = in_aton(stunaddr);
-    }
-    if (destaction != NULL)
-    {
-        if (strcmp(destaction, "auto") == 0)
-        {
-            dstact = DSTACT_AUTO;
-        }
-        if (strcmp(destaction, "strip") == 0)
-        {
-            dstact = DSTACT_STRIP;
-        }
-        if (strcmp(destaction, "none") == 0)
-        {
-            dstact = DSTACT_NONE;
-        }
-    }
-    return ret;
+		if (strcmp(destaction, "none") == 0)
+			dstact = DSTACT_NONE;
+	}
+	return 0;
 }
 
 module_init(init);




More information about the netfilter-cvslog mailing list