blob: beb24d19a56f7373bee6c535fe329e1b7a1f6ea5 [file] [log] [blame]
Harald Welte2e4e6a12006-01-12 13:30:04 -08001/* 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
YOSHIFUJI Hideaki601e68e2007-02-12 11:15:49 -08006 * it under the terms of the GNU General Public License version 2 as
Harald Welte2e4e6a12006-01-12 13:30:04 -08007 * published by the Free Software Foundation.
YOSHIFUJI Hideaki601e68e2007-02-12 11:15:49 -08008 *
Harald Welte2e4e6a12006-01-12 13:30:04 -08009 */
10
11#include <linux/module.h>
12#include <linux/skbuff.h>
13
14#include <linux/netfilter.h>
15#include <linux/netfilter_arp.h>
16#include <linux/netfilter/x_tables.h>
17#include <linux/netfilter/xt_NFQUEUE.h>
18
19MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
Jan Engelhardt2ae15b62008-01-14 23:42:28 -080020MODULE_DESCRIPTION("Xtables: packet forwarding to netlink");
Harald Welte2e4e6a12006-01-12 13:30:04 -080021MODULE_LICENSE("GPL");
22MODULE_ALIAS("ipt_NFQUEUE");
23MODULE_ALIAS("ip6t_NFQUEUE");
24MODULE_ALIAS("arpt_NFQUEUE");
25
26static unsigned int
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080027nfqueue_tg(struct sk_buff *skb, const struct net_device *in,
28 const struct net_device *out, unsigned int hooknum,
29 const struct xt_target *target, const void *targinfo)
Harald Welte2e4e6a12006-01-12 13:30:04 -080030{
31 const struct xt_NFQ_info *tinfo = targinfo;
32
33 return NF_QUEUE_NR(tinfo->queuenum);
34}
35
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080036static struct xt_target nfqueue_tg_reg[] __read_mostly = {
Patrick McHardy4470bbc2006-08-22 00:34:04 -070037 {
38 .name = "NFQUEUE",
39 .family = AF_INET,
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080040 .target = nfqueue_tg,
Patrick McHardy4470bbc2006-08-22 00:34:04 -070041 .targetsize = sizeof(struct xt_NFQ_info),
42 .me = THIS_MODULE,
43 },
44 {
45 .name = "NFQUEUE",
46 .family = AF_INET6,
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080047 .target = nfqueue_tg,
Patrick McHardy4470bbc2006-08-22 00:34:04 -070048 .targetsize = sizeof(struct xt_NFQ_info),
49 .me = THIS_MODULE,
50 },
51 {
52 .name = "NFQUEUE",
53 .family = NF_ARP,
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080054 .target = nfqueue_tg,
Patrick McHardy4470bbc2006-08-22 00:34:04 -070055 .targetsize = sizeof(struct xt_NFQ_info),
56 .me = THIS_MODULE,
57 },
Harald Welte2e4e6a12006-01-12 13:30:04 -080058};
59
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080060static int __init nfqueue_tg_init(void)
Harald Welte2e4e6a12006-01-12 13:30:04 -080061{
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080062 return xt_register_targets(nfqueue_tg_reg, ARRAY_SIZE(nfqueue_tg_reg));
Harald Welte2e4e6a12006-01-12 13:30:04 -080063}
64
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080065static void __exit nfqueue_tg_exit(void)
Harald Welte2e4e6a12006-01-12 13:30:04 -080066{
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080067 xt_unregister_targets(nfqueue_tg_reg, ARRAY_SIZE(nfqueue_tg_reg));
Harald Welte2e4e6a12006-01-12 13:30:04 -080068}
69
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080070module_init(nfqueue_tg_init);
71module_exit(nfqueue_tg_exit);