[NETFILTER]: x_tables: add xt_{match,target} arguments to match/target functions
[safe/jmp/linux-2.6] / net / netfilter / xt_NOTRACK.c
1 /* This is a module which is used for setting up fake conntracks
2  * on packets so that they are not seen by the conntrack/NAT code.
3  */
4 #include <linux/module.h>
5 #include <linux/skbuff.h>
6
7 #include <linux/netfilter/x_tables.h>
8 #include <net/netfilter/nf_conntrack_compat.h>
9
10 MODULE_LICENSE("GPL");
11 MODULE_ALIAS("ipt_NOTRACK");
12
13 static unsigned int
14 target(struct sk_buff **pskb,
15        const struct net_device *in,
16        const struct net_device *out,
17        unsigned int hooknum,
18        const struct xt_target *target,
19        const void *targinfo,
20        void *userinfo)
21 {
22         /* Previously seen (loopback)? Ignore. */
23         if ((*pskb)->nfct != NULL)
24                 return XT_CONTINUE;
25
26         /* Attach fake conntrack entry. 
27            If there is a real ct entry correspondig to this packet, 
28            it'll hang aroun till timing out. We don't deal with it
29            for performance reasons. JK */
30         nf_ct_untrack(*pskb);
31         (*pskb)->nfctinfo = IP_CT_NEW;
32         nf_conntrack_get((*pskb)->nfct);
33
34         return XT_CONTINUE;
35 }
36
37 static struct xt_target notrack_reg = {
38         .name           = "NOTRACK",
39         .target         = target,
40         .targetsize     = 0,
41         .table          = "raw",
42         .me             = THIS_MODULE,
43 };
44
45 static struct xt_target notrack6_reg = {
46         .name           = "NOTRACK",
47         .target         = target,
48         .targetsize     = 0,
49         .table          = "raw",
50         .me             = THIS_MODULE,
51 };
52
53 static int __init init(void)
54 {
55         int ret;
56
57         ret = xt_register_target(AF_INET, &notrack_reg);
58         if (ret)
59                 return ret;
60
61         ret = xt_register_target(AF_INET6, &notrack6_reg);
62         if (ret)
63                 xt_unregister_target(AF_INET, &notrack_reg);
64
65         return ret;
66 }
67
68 static void __exit fini(void)
69 {
70         xt_unregister_target(AF_INET6, &notrack6_reg);
71         xt_unregister_target(AF_INET, &notrack_reg);
72 }
73
74 module_init(init);
75 module_exit(fini);