www.usr.com/support/gpl/USR9107_release.1.4.tar.gz
[bcm963xx.git] / kernel / linux / net / ipv4 / netfilter / ip_nat_rtsp.c
index ef82f1b..a40c73d 100755 (executable)
@@ -192,19 +192,8 @@ rtsp_mangle_tran(struct ip_conntrack* ct, enum ip_conntrack_info ctinfo,
     switch (prtspexp->pbtype)
     {
     case pb_single:
-        for (loport = prtspexp->loport; loport != 0; loport++) /* XXX: improper wrap? */
-        {
-            DEBUGP("Original UDP PORT value is %hu exp loport %hu hiport %hu\n", t.dst.u.udp.port,
-                    prtspexp->loport, prtspexp->hiport);
-            // Do not transpose the ports yet. If you do, you better register a helper
-            // to mangle them correctly when you receive packets on those ports.
-            //t.dst.u.udp.port = htons(loport);
-            if (ip_conntrack_change_expect(exp, &t) == 0)
-            {
-                DEBUGP("using port %hu\n", loport);
-                break;
-            }
-        }
+        loport = prtspexp->loport;
+        DEBUGP("PB_SINGLE: LO_PORT %hu\n", loport);
         if (loport != 0)
         {
             rbuf1len = sprintf(rbuf1, "%hu", loport);
@@ -213,6 +202,7 @@ rtsp_mangle_tran(struct ip_conntrack* ct, enum ip_conntrack_info ctinfo,
         break;
     case pb_range:
         loport = prtspexp->loport;
+        DEBUGP("PB_RANGE: LO_PORT %hu\n", loport);
         if (loport != 0)
         {
             rbuf1len = sprintf(rbuf1, "%hu", loport);
@@ -222,6 +212,7 @@ rtsp_mangle_tran(struct ip_conntrack* ct, enum ip_conntrack_info ctinfo,
         }
         break;
     case pb_discon:
+        DEBUGP("PB_DISCON:n");
         for (loport = prtspexp->loport; loport != 0; loport++) /* XXX: improper wrap? */
         {
             DEBUGP("Original UDP PORT value is %hu exp loport %hu hiport %hu\n", t.dst.u.udp.port,
@@ -403,8 +394,6 @@ static unsigned int
 expected(struct sk_buff** pskb, uint hooknum,
                 struct ip_conntrack* ct, struct ip_nat_info* info)
 {
-    struct iphdr* iph = (struct iphdr*)(*pskb)->nh.iph;
-    struct udphdr *udph = (void *)iph + iph->ihl * 4;
     struct ip_nat_multi_range mr;
     u_int32_t newdstip, newsrcip, newip;
 
@@ -426,12 +415,6 @@ expected(struct sk_buff** pskb, uint hooknum,
     DUMP_TUPLE(&master->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
     DUMP_TUPLE(&master->tuplehash[IP_CT_DIR_REPLY].tuple);
 
-    /*
-     * Ignore the UDP checksum for now.
-     */
-    udph->dest = ct->nat.rtsp_info.orig_port;
-    udph->check = 0;
-
     mr.rangesize = 1;
     /*
      * We don't want to manip the per-protocol, just the IPs. Actually we
@@ -439,6 +422,8 @@ expected(struct sk_buff** pskb, uint hooknum,
      */
     mr.range[0].flags = IP_NAT_RANGE_MAP_IPS;
     mr.range[0].min_ip = mr.range[0].max_ip = newip;
+    mr.range[0].flags |= IP_NAT_RANGE_PROTO_SPECIFIED;
+    mr.range[0].min.udp.port = mr.range[0].max.udp.port = ct->nat.rtsp_info.orig_port;
 
     return ip_nat_setup_info(ct, &mr, hooknum);
 }
@@ -517,9 +502,12 @@ help_in(struct ip_conntrack* ct, enum ip_conntrack_info ctinfo,
 }
 
 static uint
-help(struct ip_conntrack* ct, struct ip_conntrack_expect* exp,
-                struct ip_nat_info* info, enum ip_conntrack_info ctinfo,
-                unsigned int hooknum, struct sk_buff** pskb)
+help(struct ip_conntrack* ct,
+     struct ip_conntrack_expect* exp,
+     struct ip_nat_info* info,
+     enum ip_conntrack_info ctinfo,
+     unsigned int hooknum,
+     struct sk_buff** pskb)
 {
     struct iphdr*  iph  = (struct iphdr*)(*pskb)->nh.iph;
     struct tcphdr* tcph = (struct tcphdr*)((char*)iph + iph->ihl * 4);
@@ -559,19 +547,6 @@ help(struct ip_conntrack* ct, struct ip_conntrack_expect* exp,
     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)
     {
@@ -631,13 +606,8 @@ init(void)
         hlpr->mask.src.u.tcp.port = 0xFFFF;
         hlpr->mask.dst.protonum = 0xFFFF;
         hlpr->help = help;
-#ifdef CONFIG_MIPS_BRCM
-        //hlpr->flags = 0;
-        //hlpr->me = THIS_MODULE;
-#else
         hlpr->flags = 0;
         hlpr->me = THIS_MODULE;
-#endif
         hlpr->expect = expected;
 
         tmpname = &rtsp_names[i][0];