new VNET
[linux-2.6.git] / net / netfilter / xt_SETXID.c
1 #include <linux/module.h>
2 #include <linux/skbuff.h>
3 #include <linux/ip.h>
4 #include <net/checksum.h>
5 #include <linux/vs_network.h>
6
7 #include <linux/netfilter/x_tables.h>
8 #include <linux/netfilter/xt_SETXID.h>
9
10 MODULE_LICENSE("GPL");
11 MODULE_AUTHOR("");
12 MODULE_DESCRIPTION("");
13 MODULE_ALIAS("ipt_SETXID");
14
15 static unsigned int
16 target_v1(struct sk_buff **pskb,
17           const struct net_device *in,
18           const struct net_device *out,
19           unsigned int hooknum,
20           const struct xt_target *target,
21           const void *targinfo)
22 {
23         const struct xt_setxid_target_info_v1 *setxidinfo = targinfo;
24
25         switch (setxidinfo->mode) {
26         case XT_SET_PACKET_XID:
27                  (*pskb)->skb_tag = setxidinfo->mark;
28                 break;
29         }
30         return XT_CONTINUE;
31 }
32
33
34 static int
35 checkentry_v1(const char *tablename,
36               const void *entry,
37               const struct xt_target *target,
38               void *targinfo,
39               unsigned int hook_mask)
40 {
41         struct xt_setxid_target_info_v1 *setxidinfo = targinfo;
42
43         if (setxidinfo->mode != XT_SET_PACKET_XID) {
44                 printk(KERN_WARNING "SETXID: unknown mode %u\n",
45                        setxidinfo->mode);
46                 return 0;
47         }
48
49         return 1;
50 }
51
52 static struct xt_target xt_setxid_target[] = {
53         {
54                 .name           = "SETXID",
55                 .family         = AF_INET,
56                 .revision       = 1,
57                 .checkentry     = checkentry_v1,
58                 .target         = target_v1,
59                 .targetsize     = sizeof(struct xt_setxid_target_info_v1),
60                 .table          = "mangle",
61                 .me             = THIS_MODULE,
62         }
63 };
64
65 static int __init init(void)
66 {
67         int err;
68
69         err = xt_register_targets(xt_setxid_target, ARRAY_SIZE(xt_setxid_target));
70         return err;
71 }
72
73 static void __exit fini(void)
74 {
75         xt_unregister_targets(xt_setxid_target, ARRAY_SIZE(xt_setxid_target));
76 }
77
78 module_init(init);
79 module_exit(fini);