]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/netfilter/nf_nat_snmp_basic.c
[NETFILTER]: nf_conntrack_sip: add seperate SDP header parsing function
[linux-2.6-omap-h63xx.git] / net / ipv4 / netfilter / nf_nat_snmp_basic.c
index 6e88505d61625b7e9939c5f90257bb76ce772135..000e080bac5c49ec35541cee0f8d93ebf4779452 100644 (file)
@@ -50,6 +50,7 @@
 #include <net/udp.h>
 
 #include <net/netfilter/nf_nat.h>
+#include <net/netfilter/nf_conntrack_expect.h>
 #include <net/netfilter/nf_conntrack_helper.h>
 #include <net/netfilter/nf_nat_helper.h>
 
@@ -60,7 +61,7 @@ MODULE_ALIAS("ip_nat_snmp_basic");
 
 #define SNMP_PORT 161
 #define SNMP_TRAP_PORT 162
-#define NOCT1(n) (*(u8 *)n)
+#define NOCT1(n) (*(u8 *)(n))
 
 static int debug;
 static DEFINE_SPINLOCK(snmp_lock);
@@ -260,7 +261,7 @@ static unsigned char asn1_eoc_decode(struct asn1_ctx *ctx, unsigned char *eoc)
 {
        unsigned char ch;
 
-       if (eoc == 0) {
+       if (eoc == NULL) {
                if (!asn1_octet_decode(ctx, &ch))
                        return 0;
 
@@ -1188,9 +1189,9 @@ static int snmp_parse_mangle(unsigned char *msg,
  */
 static int snmp_translate(struct nf_conn *ct,
                          enum ip_conntrack_info ctinfo,
-                         struct sk_buff **pskb)
+                         struct sk_buff *skb)
 {
-       struct iphdr *iph = ip_hdr(*pskb);
+       struct iphdr *iph = ip_hdr(skb);
        struct udphdr *udph = (struct udphdr *)((__be32 *)iph + iph->ihl);
        u_int16_t udplen = ntohs(udph->len);
        u_int16_t paylen = udplen - sizeof(struct udphdr);
@@ -1225,13 +1226,13 @@ static int snmp_translate(struct nf_conn *ct,
 
 /* We don't actually set up expectations, just adjust internal IP
  * addresses if this is being NATted */
-static int help(struct sk_buff **pskb, unsigned int protoff,
+static int help(struct sk_buff *skb, unsigned int protoff,
                struct nf_conn *ct,
                enum ip_conntrack_info ctinfo)
 {
        int dir = CTINFO2DIR(ctinfo);
        unsigned int ret;
-       struct iphdr *iph = ip_hdr(*pskb);
+       struct iphdr *iph = ip_hdr(skb);
        struct udphdr *udph = (struct udphdr *)((u_int32_t *)iph + iph->ihl);
 
        /* SNMP replies and originating SNMP traps get mangled */
@@ -1250,7 +1251,7 @@ static int help(struct sk_buff **pskb, unsigned int protoff,
         * enough room for a UDP header.  Just verify the UDP length field so we
         * can mess around with the payload.
         */
-       if (ntohs(udph->len) != (*pskb)->len - (iph->ihl << 2)) {
+       if (ntohs(udph->len) != skb->len - (iph->ihl << 2)) {
                 if (net_ratelimit())
                         printk(KERN_WARNING "SNMP: dropping malformed packet "
                                "src=%u.%u.%u.%u dst=%u.%u.%u.%u\n",
@@ -1258,41 +1259,38 @@ static int help(struct sk_buff **pskb, unsigned int protoff,
                 return NF_DROP;
        }
 
-       if (!skb_make_writable(pskb, (*pskb)->len))
+       if (!skb_make_writable(skb, skb->len))
                return NF_DROP;
 
        spin_lock_bh(&snmp_lock);
-       ret = snmp_translate(ct, ctinfo, pskb);
+       ret = snmp_translate(ct, ctinfo, skb);
        spin_unlock_bh(&snmp_lock);
        return ret;
 }
 
+static const struct nf_conntrack_expect_policy snmp_exp_policy = {
+       .max_expected   = 0,
+       .timeout        = 180,
+};
+
 static struct nf_conntrack_helper snmp_helper __read_mostly = {
-       .max_expected           = 0,
-       .timeout                = 180,
        .me                     = THIS_MODULE,
        .help                   = help,
+       .expect_policy          = &snmp_exp_policy,
        .name                   = "snmp",
        .tuple.src.l3num        = AF_INET,
        .tuple.src.u.udp.port   = __constant_htons(SNMP_PORT),
        .tuple.dst.protonum     = IPPROTO_UDP,
-       .mask.src.l3num         = 0xFFFF,
-       .mask.src.u.udp.port    = __constant_htons(0xFFFF),
-       .mask.dst.protonum      = 0xFF,
 };
 
 static struct nf_conntrack_helper snmp_trap_helper __read_mostly = {
-       .max_expected           = 0,
-       .timeout                = 180,
        .me                     = THIS_MODULE,
        .help                   = help,
+       .expect_policy          = &snmp_exp_policy,
        .name                   = "snmp_trap",
        .tuple.src.l3num        = AF_INET,
        .tuple.src.u.udp.port   = __constant_htons(SNMP_TRAP_PORT),
        .tuple.dst.protonum     = IPPROTO_UDP,
-       .mask.src.l3num         = 0xFFFF,
-       .mask.src.u.udp.port    = __constant_htons(0xFFFF),
-       .mask.dst.protonum      = 0xFF,
 };
 
 /*****************************************************************************