]> err.no Git - linux-2.6/blobdiff - net/ipv4/netfilter/nf_nat_h323.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
[linux-2.6] / net / ipv4 / netfilter / nf_nat_h323.c
index c1b059a737088bbad8ba3d3785e41522c8ce13d0..ee47bf28c82547463629288cc16249bcceb1e20c 100644 (file)
 #include <linux/netfilter/nf_conntrack_h323.h>
 
 /****************************************************************************/
-static int set_addr(struct sk_buff **pskb,
+static int set_addr(struct sk_buff *skb,
                    unsigned char **data, int dataoff,
                    unsigned int addroff, __be32 ip, __be16 port)
 {
        enum ip_conntrack_info ctinfo;
-       struct nf_conn *ct = nf_ct_get(*pskb, &ctinfo);
+       struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
        struct {
                __be32 ip;
                __be16 port;
        } __attribute__ ((__packed__)) buf;
-       struct tcphdr _tcph, *th;
+       const struct tcphdr *th;
+       struct tcphdr _tcph;
 
        buf.ip = ip;
        buf.port = port;
        addroff += dataoff;
 
-       if (ip_hdr(*pskb)->protocol == IPPROTO_TCP) {
-               if (!nf_nat_mangle_tcp_packet(pskb, ct, ctinfo,
+       if (ip_hdr(skb)->protocol == IPPROTO_TCP) {
+               if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
                                              addroff, sizeof(buf),
                                              (char *) &buf, sizeof(buf))) {
                        if (net_ratelimit())
@@ -49,14 +50,13 @@ static int set_addr(struct sk_buff **pskb,
                }
 
                /* Relocate data pointer */
-               th = skb_header_pointer(*pskb, ip_hdrlen(*pskb),
+               th = skb_header_pointer(skb, ip_hdrlen(skb),
                                        sizeof(_tcph), &_tcph);
                if (th == NULL)
                        return -1;
-               *data = (*pskb)->data + ip_hdrlen(*pskb) +
-                   th->doff * 4 + dataoff;
+               *data = skb->data + ip_hdrlen(skb) + th->doff * 4 + dataoff;
        } else {
-               if (!nf_nat_mangle_udp_packet(pskb, ct, ctinfo,
+               if (!nf_nat_mangle_udp_packet(skb, ct, ctinfo,
                                              addroff, sizeof(buf),
                                              (char *) &buf, sizeof(buf))) {
                        if (net_ratelimit())
@@ -67,45 +67,44 @@ static int set_addr(struct sk_buff **pskb,
                /* nf_nat_mangle_udp_packet uses skb_make_writable() to copy
                 * or pull everything in a linear buffer, so we can safely
                 * use the skb pointers now */
-               *data = ((*pskb)->data + ip_hdrlen(*pskb) +
-                        sizeof(struct udphdr));
+               *data = skb->data + ip_hdrlen(skb) + sizeof(struct udphdr);
        }
 
        return 0;
 }
 
 /****************************************************************************/
-static int set_h225_addr(struct sk_buff **pskb,
+static int set_h225_addr(struct sk_buff *skb,
                         unsigned char **data, int dataoff,
                         TransportAddress *taddr,
-                        union nf_conntrack_address *addr, __be16 port)
+                        union nf_inet_addr *addr, __be16 port)
 {
-       return set_addr(pskb, data, dataoff, taddr->ipAddress.ip,
+       return set_addr(skb, data, dataoff, taddr->ipAddress.ip,
                        addr->ip, port);
 }
 
 /****************************************************************************/
-static int set_h245_addr(struct sk_buff **pskb,
+static int set_h245_addr(struct sk_buff *skb,
                         unsigned char **data, int dataoff,
                         H245_TransportAddress *taddr,
-                        union nf_conntrack_address *addr, __be16 port)
+                        union nf_inet_addr *addr, __be16 port)
 {
-       return set_addr(pskb, data, dataoff,
+       return set_addr(skb, data, dataoff,
                        taddr->unicastAddress.iPAddress.network,
                        addr->ip, port);
 }
 
 /****************************************************************************/
-static int set_sig_addr(struct sk_buff **pskb, struct nf_conn *ct,
+static int set_sig_addr(struct sk_buff *skb, struct nf_conn *ct,
                        enum ip_conntrack_info ctinfo,
                        unsigned char **data,
                        TransportAddress *taddr, int count)
 {
-       struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
+       const struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
        int dir = CTINFO2DIR(ctinfo);
        int i;
        __be16 port;
-       union nf_conntrack_address addr;
+       union nf_inet_addr addr;
 
        for (i = 0; i < count; i++) {
                if (get_h225_addr(ct, *data, &taddr[i], &addr, &port)) {
@@ -125,7 +124,7 @@ static int set_sig_addr(struct sk_buff **pskb, struct nf_conn *ct,
                                         NIPQUAD(addr.ip), port,
                                         NIPQUAD(ct->tuplehash[!dir].tuple.dst.u3.ip),
                                         info->sig_port[!dir]);
-                               return set_h225_addr(pskb, data, 0, &taddr[i],
+                               return set_h225_addr(skb, data, 0, &taddr[i],
                                                     &ct->tuplehash[!dir].
                                                     tuple.dst.u3,
                                                     info->sig_port[!dir]);
@@ -137,7 +136,7 @@ static int set_sig_addr(struct sk_buff **pskb, struct nf_conn *ct,
                                         NIPQUAD(addr.ip), port,
                                         NIPQUAD(ct->tuplehash[!dir].tuple.src.u3.ip),
                                         info->sig_port[!dir]);
-                               return set_h225_addr(pskb, data, 0, &taddr[i],
+                               return set_h225_addr(skb, data, 0, &taddr[i],
                                                     &ct->tuplehash[!dir].
                                                     tuple.src.u3,
                                                     info->sig_port[!dir]);
@@ -149,7 +148,7 @@ static int set_sig_addr(struct sk_buff **pskb, struct nf_conn *ct,
 }
 
 /****************************************************************************/
-static int set_ras_addr(struct sk_buff **pskb, struct nf_conn *ct,
+static int set_ras_addr(struct sk_buff *skb, struct nf_conn *ct,
                        enum ip_conntrack_info ctinfo,
                        unsigned char **data,
                        TransportAddress *taddr, int count)
@@ -157,7 +156,7 @@ static int set_ras_addr(struct sk_buff **pskb, struct nf_conn *ct,
        int dir = CTINFO2DIR(ctinfo);
        int i;
        __be16 port;
-       union nf_conntrack_address addr;
+       union nf_inet_addr addr;
 
        for (i = 0; i < count; i++) {
                if (get_h225_addr(ct, *data, &taddr[i], &addr, &port) &&
@@ -168,7 +167,7 @@ static int set_ras_addr(struct sk_buff **pskb, struct nf_conn *ct,
                                 NIPQUAD(addr.ip), ntohs(port),
                                 NIPQUAD(ct->tuplehash[!dir].tuple.dst.u3.ip),
                                 ntohs(ct->tuplehash[!dir].tuple.dst.u.udp.port));
-                       return set_h225_addr(pskb, data, 0, &taddr[i],
+                       return set_h225_addr(skb, data, 0, &taddr[i],
                                             &ct->tuplehash[!dir].tuple.dst.u3,
                                             ct->tuplehash[!dir].tuple.
                                                                dst.u.udp.port);
@@ -179,7 +178,7 @@ static int set_ras_addr(struct sk_buff **pskb, struct nf_conn *ct,
 }
 
 /****************************************************************************/
-static int nat_rtp_rtcp(struct sk_buff **pskb, struct nf_conn *ct,
+static int nat_rtp_rtcp(struct sk_buff *skb, struct nf_conn *ct,
                        enum ip_conntrack_info ctinfo,
                        unsigned char **data, int dataoff,
                        H245_TransportAddress *taddr,
@@ -244,7 +243,7 @@ static int nat_rtp_rtcp(struct sk_buff **pskb, struct nf_conn *ct,
        }
 
        /* Modify signal */
-       if (set_h245_addr(pskb, data, dataoff, taddr,
+       if (set_h245_addr(skb, data, dataoff, taddr,
                          &ct->tuplehash[!dir].tuple.dst.u3,
                          htons((port & htons(1)) ? nated_port + 1 :
                                                    nated_port)) == 0) {
@@ -273,7 +272,7 @@ static int nat_rtp_rtcp(struct sk_buff **pskb, struct nf_conn *ct,
 }
 
 /****************************************************************************/
-static int nat_t120(struct sk_buff **pskb, struct nf_conn *ct,
+static int nat_t120(struct sk_buff *skb, struct nf_conn *ct,
                    enum ip_conntrack_info ctinfo,
                    unsigned char **data, int dataoff,
                    H245_TransportAddress *taddr, __be16 port,
@@ -301,7 +300,7 @@ static int nat_t120(struct sk_buff **pskb, struct nf_conn *ct,
        }
 
        /* Modify signal */
-       if (set_h245_addr(pskb, data, dataoff, taddr,
+       if (set_h245_addr(skb, data, dataoff, taddr,
                          &ct->tuplehash[!dir].tuple.dst.u3,
                          htons(nated_port)) < 0) {
                nf_ct_unexpect_related(exp);
@@ -318,7 +317,7 @@ static int nat_t120(struct sk_buff **pskb, struct nf_conn *ct,
 }
 
 /****************************************************************************/
-static int nat_h245(struct sk_buff **pskb, struct nf_conn *ct,
+static int nat_h245(struct sk_buff *skb, struct nf_conn *ct,
                    enum ip_conntrack_info ctinfo,
                    unsigned char **data, int dataoff,
                    TransportAddress *taddr, __be16 port,
@@ -351,7 +350,7 @@ static int nat_h245(struct sk_buff **pskb, struct nf_conn *ct,
        }
 
        /* Modify signal */
-       if (set_h225_addr(pskb, data, dataoff, taddr,
+       if (set_h225_addr(skb, data, dataoff, taddr,
                          &ct->tuplehash[!dir].tuple.dst.u3,
                          htons(nated_port)) == 0) {
                /* Save ports */
@@ -391,22 +390,18 @@ static void ip_nat_q931_expect(struct nf_conn *new,
        /* Change src to where master sends to */
        range.flags = IP_NAT_RANGE_MAP_IPS;
        range.min_ip = range.max_ip = new->tuplehash[!this->dir].tuple.src.u3.ip;
-
-       /* hook doesn't matter, but it has to do source manip */
-       nf_nat_setup_info(new, &range, NF_IP_POST_ROUTING);
+       nf_nat_setup_info(new, &range, IP_NAT_MANIP_SRC);
 
        /* For DST manip, map port here to where it's expected. */
        range.flags = (IP_NAT_RANGE_MAP_IPS | IP_NAT_RANGE_PROTO_SPECIFIED);
        range.min = range.max = this->saved_proto;
        range.min_ip = range.max_ip =
            new->master->tuplehash[!this->dir].tuple.src.u3.ip;
-
-       /* hook doesn't matter, but it has to do destination manip */
-       nf_nat_setup_info(new, &range, NF_IP_PRE_ROUTING);
+       nf_nat_setup_info(new, &range, IP_NAT_MANIP_DST);
 }
 
 /****************************************************************************/
-static int nat_q931(struct sk_buff **pskb, struct nf_conn *ct,
+static int nat_q931(struct sk_buff *skb, struct nf_conn *ct,
                    enum ip_conntrack_info ctinfo,
                    unsigned char **data, TransportAddress *taddr, int idx,
                    __be16 port, struct nf_conntrack_expect *exp)
@@ -414,7 +409,7 @@ static int nat_q931(struct sk_buff **pskb, struct nf_conn *ct,
        struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
        int dir = CTINFO2DIR(ctinfo);
        u_int16_t nated_port = ntohs(port);
-       union nf_conntrack_address addr;
+       union nf_inet_addr addr;
 
        /* Set expectations for NAT */
        exp->saved_proto.tcp.port = exp->tuple.dst.u.tcp.port;
@@ -439,7 +434,7 @@ static int nat_q931(struct sk_buff **pskb, struct nf_conn *ct,
        }
 
        /* Modify signal */
-       if (set_h225_addr(pskb, data, 0, &taddr[idx],
+       if (set_h225_addr(skb, data, 0, &taddr[idx],
                          &ct->tuplehash[!dir].tuple.dst.u3,
                          htons(nated_port)) == 0) {
                /* Save ports */
@@ -450,7 +445,7 @@ static int nat_q931(struct sk_buff **pskb, struct nf_conn *ct,
                if (idx > 0 &&
                    get_h225_addr(ct, *data, &taddr[0], &addr, &port) &&
                    (ntohl(addr.ip) & 0xff000000) == 0x7f000000) {
-                       set_h225_addr(pskb, data, 0, &taddr[0],
+                       set_h225_addr(skb, data, 0, &taddr[0],
                                      &ct->tuplehash[!dir].tuple.dst.u3,
                                      info->sig_port[!dir]);
                }
@@ -481,21 +476,17 @@ static void ip_nat_callforwarding_expect(struct nf_conn *new,
        /* Change src to where master sends to */
        range.flags = IP_NAT_RANGE_MAP_IPS;
        range.min_ip = range.max_ip = new->tuplehash[!this->dir].tuple.src.u3.ip;
-
-       /* hook doesn't matter, but it has to do source manip */
-       nf_nat_setup_info(new, &range, NF_IP_POST_ROUTING);
+       nf_nat_setup_info(new, &range, IP_NAT_MANIP_SRC);
 
        /* For DST manip, map port here to where it's expected. */
        range.flags = (IP_NAT_RANGE_MAP_IPS | IP_NAT_RANGE_PROTO_SPECIFIED);
        range.min = range.max = this->saved_proto;
        range.min_ip = range.max_ip = this->saved_ip;
-
-       /* hook doesn't matter, but it has to do destination manip */
-       nf_nat_setup_info(new, &range, NF_IP_PRE_ROUTING);
+       nf_nat_setup_info(new, &range, IP_NAT_MANIP_DST);
 }
 
 /****************************************************************************/
-static int nat_callforwarding(struct sk_buff **pskb, struct nf_conn *ct,
+static int nat_callforwarding(struct sk_buff *skb, struct nf_conn *ct,
                              enum ip_conntrack_info ctinfo,
                              unsigned char **data, int dataoff,
                              TransportAddress *taddr, __be16 port,
@@ -525,7 +516,7 @@ static int nat_callforwarding(struct sk_buff **pskb, struct nf_conn *ct,
        }
 
        /* Modify signal */
-       if (!set_h225_addr(pskb, data, dataoff, taddr,
+       if (!set_h225_addr(skb, data, dataoff, taddr,
                           &ct->tuplehash[!dir].tuple.dst.u3,
                           htons(nated_port)) == 0) {
                nf_ct_unexpect_related(exp);
@@ -546,15 +537,15 @@ static int nat_callforwarding(struct sk_buff **pskb, struct nf_conn *ct,
 /****************************************************************************/
 static int __init init(void)
 {
-       BUG_ON(rcu_dereference(set_h245_addr_hook) != NULL);
-       BUG_ON(rcu_dereference(set_h225_addr_hook) != NULL);
-       BUG_ON(rcu_dereference(set_sig_addr_hook) != NULL);
-       BUG_ON(rcu_dereference(set_ras_addr_hook) != NULL);
-       BUG_ON(rcu_dereference(nat_rtp_rtcp_hook) != NULL);
-       BUG_ON(rcu_dereference(nat_t120_hook) != NULL);
-       BUG_ON(rcu_dereference(nat_h245_hook) != NULL);
-       BUG_ON(rcu_dereference(nat_callforwarding_hook) != NULL);
-       BUG_ON(rcu_dereference(nat_q931_hook) != NULL);
+       BUG_ON(set_h245_addr_hook != NULL);
+       BUG_ON(set_h225_addr_hook != NULL);
+       BUG_ON(set_sig_addr_hook != NULL);
+       BUG_ON(set_ras_addr_hook != NULL);
+       BUG_ON(nat_rtp_rtcp_hook != NULL);
+       BUG_ON(nat_t120_hook != NULL);
+       BUG_ON(nat_h245_hook != NULL);
+       BUG_ON(nat_callforwarding_hook != NULL);
+       BUG_ON(nat_q931_hook != NULL);
 
        rcu_assign_pointer(set_h245_addr_hook, set_h245_addr);
        rcu_assign_pointer(set_h225_addr_hook, set_h225_addr);