All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Sverker Abrahamsson" <sverker@abrahamsson.com>
To: <netfilter-devel@lists.netfilter.org>, <tmarshall@real.com>
Subject: Patch for ip_nat_rtsp.c
Date: Sun, 9 Oct 2005 14:59:44 +0200	[thread overview]
Message-ID: <02e201c5ccd1$5235dce0$3c01010a@Fiona> (raw)

[-- Attachment #1: Type: text/plain, Size: 567 bytes --]

Hi
I was trying to get the RTSP nat module to work by applying the patches in patch-o-matic but ip_nat_rtsp.c continued to give compiler errors. I patched as far as I could but got stuck in help_out where it uses seq field of struct ip_conntrack_expect, which I believe was removed in 2.6.11. I haven't been able to figure out the exact functionality and I see on other nat modules that they were simplified a lot after the 2.6.11 API change.

Maybe someone on the list can understand the functionality better, or can hint me on what should be changed.
/Sverker

[-- Attachment #2: ip_nat_rtsp.patch --]
[-- Type: application/octet-stream, Size: 4997 bytes --]

--- linux-2.6.13.3.orig/include/linux/netfilter_ipv4/ip_conntrack_rtsp.h	2005-10-09 14:46:59.000000000 +0200
+++ linux-2.6.13.3/include/linux/netfilter_ipv4/ip_conntrack_rtsp.h	2005-10-08 20:47:26.000000000 +0200
@@ -47,6 +47,13 @@
 #endif
 };
 
+/* For NAT to hook in when we find a packet which describes what other
+ * connection we should expect. */
+extern unsigned int (*ip_nat_rtsp_hook)(struct sk_buff **pskb,
+				 enum ip_conntrack_info ctinfo,
+				 struct ip_ct_rtsp_expect *expinfo,
+				 struct ip_conntrack_expect *exp);
+
 #ifdef __KERNEL__
 
 #define RTSP_PORT   554
--- linux-2.6.13.3.orig/net/ipv4/netfilter/ip_nat_rtsp.c	2005-10-09 14:43:50.000000000 +0200
+++ linux-2.6.13.3/net/ipv4/netfilter/ip_nat_rtsp.c	2005-10-08 19:52:05.000000000 +0200
@@ -69,6 +69,7 @@
 static int       num_ports = 0;
 static u_int32_t extip = 0;
 static int       dstact = 0;
+static DEFINE_SPINLOCK(ip_rtsp_lock);
 
 MODULE_AUTHOR("Tom Marshall <tmarshall@real.com>");
 MODULE_DESCRIPTION("RTSP network address translation module");
@@ -163,8 +164,8 @@
     case pb_single:
         for (loport = prtspexp->loport; loport != 0; loport++) /* XXX: improper wrap? */
         {
-            t.dst.u.udp.port = htons(loport);
-            if (ip_conntrack_change_expect(exp, &t) == 0)
+            exp->tuple.dst.u.udp.port = htons(loport);
+            if (ip_conntrack_expect_related(exp) == 0)
             {
                 DEBUGP("using port %hu\n", loport);
                 break;
@@ -179,8 +180,8 @@
     case pb_range:
         for (loport = prtspexp->loport; loport != 0; loport += 2) /* XXX: improper wrap? */
         {
-            t.dst.u.udp.port = htons(loport);
-            if (ip_conntrack_change_expect(exp, &t) == 0)
+            exp->tuple.dst.u.udp.port = htons(loport);
+            if (ip_conntrack_expect_related(exp) == 0)
             {
                 hiport = loport + ~exp->mask.dst.u.udp.port;
                 DEBUGP("using ports %hu-%hu\n", loport, hiport);
@@ -196,8 +197,8 @@
     case pb_discon:
         for (loport = prtspexp->loport; loport != 0; loport++) /* XXX: improper wrap? */
         {
-            t.dst.u.udp.port = htons(loport);
-            if (ip_conntrack_change_expect(exp, &t) == 0)
+            exp->tuple.dst.u.udp.port = htons(loport);
+            if (ip_conntrack_expect_related(exp) == 0)
             {
                 DEBUGP("using port %hu (1 of 2)\n", loport);
                 break;
@@ -205,8 +206,8 @@
         }
         for (hiport = prtspexp->hiport; hiport != 0; hiport++) /* XXX: improper wrap? */
         {
-            t.dst.u.udp.port = htons(hiport);
-            if (ip_conntrack_change_expect(exp, &t) == 0)
+            exp->tuple.dst.u.udp.port = htons(hiport);
+            if (ip_conntrack_expect_related(exp) == 0)
             {
                 DEBUGP("using port %hu (2 of 2)\n", hiport);
                 break;
@@ -365,7 +366,7 @@
 static unsigned int
 expected(struct sk_buff **pskb, uint hooknum, struct ip_conntrack* ct, struct ip_nat_info* info)
 {
-    struct ip_nat_multi_range mr;
+    struct ip_nat_range mr;
     u_int32_t newdstip, newsrcip, newip;
 
     struct ip_conntrack *master = master_ct(ct);
@@ -382,10 +383,9 @@
     DEBUGP("newsrcip=%u.%u.%u.%u, newdstip=%u.%u.%u.%u, newip=%u.%u.%u.%u\n",
            NIPQUAD(newsrcip), NIPQUAD(newdstip), NIPQUAD(newip));
 
-    mr.rangesize = 1;
     /* We don't want to manip the per-protocol, just the IPs. */
-    mr.range[0].flags = IP_NAT_RANGE_MAP_IPS;
-    mr.range[0].min_ip = mr.range[0].max_ip = newip;
+    mr.flags = IP_NAT_RANGE_MAP_IPS;
+    mr.min_ip = mr.max_ip = newip;
 
     return ip_nat_setup_info(ct, &mr, hooknum);
 }
@@ -428,7 +428,7 @@
         if (nf_strncasecmp(ptcp+lineoff, "Transport:", 10) == 0)
         {
             uint oldtcplen = tcplen;
-            if (!rtsp_mangle_tran(ct, ctinfo, exp, prtspexp, pskb, lineoff, linelen))
+            if (!rtsp_mangle_tran(ctinfo, exp, prtspexp, pskb, lineoff, linelen))
             {
                 break;
             }
@@ -445,9 +445,9 @@
 }
 
 static int
-help(struct sk_buff **pskb
+help(struct sk_buff **pskb,
      enum ip_conntrack_info ctinfo,
-     struct ip_ct_rtsp_expect *ct_rtsp_info;
+     struct ip_ct_rtsp_expect *ct_rtsp_info,
      struct ip_conntrack_expect* exp)
 {
     struct iphdr*  iph  = (struct iphdr*)(*pskb)->nh.iph;
@@ -456,17 +456,18 @@
     int dir = CTINFO2DIR(ctinfo);
     int rc = NF_ACCEPT;
 
+    spin_lock_bh(&ip_rtsp_lock);
     switch (dir)
     {
     case IP_CT_DIR_ORIGINAL:
-        rc = help_out(pskb, ctinfo, ct_rtsp_info, exp, pskb);
+        rc = help_out(pskb, ctinfo, ct_rtsp_info, exp);
         break;
     case IP_CT_DIR_REPLY:
     	/* XXX: unmangle */
 	rc = NF_ACCEPT;
         break;
     }
-    UNLOCK_BH(&ip_rtsp_lock);
+    spin_unlock_bh(&ip_rtsp_lock);
 
     return rc;
 }

                 reply	other threads:[~2005-10-09 12:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='02e201c5ccd1$5235dce0$3c01010a@Fiona' \
    --to=sverker@abrahamsson.com \
    --cc=netfilter-devel@lists.netfilter.org \
    --cc=tmarshall@real.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.