3cedc9be88077b09cb43fb731c0df8d718c33db6
[safe/jmp/linux-2.6] / net / ipv4 / netfilter / ipt_NFQUEUE.c
1 /* iptables module for using new netfilter netlink queue
2  *
3  * (C) 2005 by Harald Welte <laforge@netfilter.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as 
7  * published by the Free Software Foundation.
8  * 
9  */
10
11 #include <linux/module.h>
12 #include <linux/skbuff.h>
13
14 #include <linux/netfilter.h>
15 #include <linux/netfilter_ipv4/ip_tables.h>
16 #include <linux/netfilter_ipv4/ipt_NFQUEUE.h>
17
18 MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
19 MODULE_DESCRIPTION("iptables NFQUEUE target");
20 MODULE_LICENSE("GPL");
21
22 static unsigned int
23 target(struct sk_buff **pskb,
24        const struct net_device *in,
25        const struct net_device *out,
26        unsigned int hooknum,
27        const void *targinfo,
28        void *userinfo)
29 {
30         const struct ipt_NFQ_info *tinfo = targinfo;
31
32         return NF_QUEUE_NR(tinfo->queuenum);
33 }
34
35 static int
36 checkentry(const char *tablename,
37            const struct ipt_entry *e,
38            void *targinfo,
39            unsigned int targinfosize,
40            unsigned int hook_mask)
41 {
42         if (targinfosize != IPT_ALIGN(sizeof(struct ipt_NFQ_info))) {
43                 printk(KERN_WARNING "NFQUEUE: targinfosize %u != %Zu\n",
44                        targinfosize,
45                        IPT_ALIGN(sizeof(struct ipt_NFQ_info)));
46                 return 0;
47         }
48
49         return 1;
50 }
51
52 static struct ipt_target ipt_NFQ_reg = {
53         .name           = "NFQUEUE",
54         .target         = target,
55         .checkentry     = checkentry,
56         .me             = THIS_MODULE,
57 };
58
59 static int __init init(void)
60 {
61         return ipt_register_target(&ipt_NFQ_reg);
62 }
63
64 static void __exit fini(void)
65 {
66         ipt_unregister_target(&ipt_NFQ_reg);
67 }
68
69 module_init(init);
70 module_exit(fini);