Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 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_arp.h> |
| 16 | #include <linux/netfilter/x_tables.h> |
| 17 | #include <linux/netfilter/xt_NFQUEUE.h> |
| 18 | |
| 19 | MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); |
| 20 | MODULE_DESCRIPTION("[ip,ip6,arp]_tables NFQUEUE target"); |
| 21 | MODULE_LICENSE("GPL"); |
| 22 | MODULE_ALIAS("ipt_NFQUEUE"); |
| 23 | MODULE_ALIAS("ip6t_NFQUEUE"); |
| 24 | MODULE_ALIAS("arpt_NFQUEUE"); |
| 25 | |
| 26 | static unsigned int |
| 27 | target(struct sk_buff **pskb, |
| 28 | const struct net_device *in, |
| 29 | const struct net_device *out, |
| 30 | unsigned int hooknum, |
Patrick McHardy | c498673 | 2006-03-20 18:02:56 -0800 | [diff] [blame] | 31 | const struct xt_target *target, |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 32 | const void *targinfo, |
| 33 | void *userinfo) |
| 34 | { |
| 35 | const struct xt_NFQ_info *tinfo = targinfo; |
| 36 | |
| 37 | return NF_QUEUE_NR(tinfo->queuenum); |
| 38 | } |
| 39 | |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 40 | static struct xt_target ipt_NFQ_reg = { |
| 41 | .name = "NFQUEUE", |
| 42 | .target = target, |
Patrick McHardy | 5d04bff | 2006-03-20 18:01:58 -0800 | [diff] [blame] | 43 | .targetsize = sizeof(struct xt_NFQ_info), |
Pablo Neira Ayuso | a45049c | 2006-03-22 13:55:40 -0800 | [diff] [blame^] | 44 | .family = AF_INET, |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 45 | .me = THIS_MODULE, |
| 46 | }; |
| 47 | |
| 48 | static struct xt_target ip6t_NFQ_reg = { |
| 49 | .name = "NFQUEUE", |
| 50 | .target = target, |
Patrick McHardy | 5d04bff | 2006-03-20 18:01:58 -0800 | [diff] [blame] | 51 | .targetsize = sizeof(struct xt_NFQ_info), |
Pablo Neira Ayuso | a45049c | 2006-03-22 13:55:40 -0800 | [diff] [blame^] | 52 | .family = AF_INET6, |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 53 | .me = THIS_MODULE, |
| 54 | }; |
| 55 | |
| 56 | static struct xt_target arpt_NFQ_reg = { |
| 57 | .name = "NFQUEUE", |
| 58 | .target = target, |
Patrick McHardy | 5d04bff | 2006-03-20 18:01:58 -0800 | [diff] [blame] | 59 | .targetsize = sizeof(struct xt_NFQ_info), |
Pablo Neira Ayuso | a45049c | 2006-03-22 13:55:40 -0800 | [diff] [blame^] | 60 | .family = NF_ARP, |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 61 | .me = THIS_MODULE, |
| 62 | }; |
| 63 | |
| 64 | static int __init init(void) |
| 65 | { |
| 66 | int ret; |
Pablo Neira Ayuso | a45049c | 2006-03-22 13:55:40 -0800 | [diff] [blame^] | 67 | ret = xt_register_target(&ipt_NFQ_reg); |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 68 | if (ret) |
| 69 | return ret; |
Pablo Neira Ayuso | a45049c | 2006-03-22 13:55:40 -0800 | [diff] [blame^] | 70 | ret = xt_register_target(&ip6t_NFQ_reg); |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 71 | if (ret) |
| 72 | goto out_ip; |
Pablo Neira Ayuso | a45049c | 2006-03-22 13:55:40 -0800 | [diff] [blame^] | 73 | ret = xt_register_target(&arpt_NFQ_reg); |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 74 | if (ret) |
| 75 | goto out_ip6; |
| 76 | |
| 77 | return ret; |
| 78 | out_ip6: |
Pablo Neira Ayuso | a45049c | 2006-03-22 13:55:40 -0800 | [diff] [blame^] | 79 | xt_unregister_target(&ip6t_NFQ_reg); |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 80 | out_ip: |
Pablo Neira Ayuso | a45049c | 2006-03-22 13:55:40 -0800 | [diff] [blame^] | 81 | xt_unregister_target(&ipt_NFQ_reg); |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 82 | |
| 83 | return ret; |
| 84 | } |
| 85 | |
| 86 | static void __exit fini(void) |
| 87 | { |
Pablo Neira Ayuso | a45049c | 2006-03-22 13:55:40 -0800 | [diff] [blame^] | 88 | xt_unregister_target(&arpt_NFQ_reg); |
| 89 | xt_unregister_target(&ip6t_NFQ_reg); |
| 90 | xt_unregister_target(&ipt_NFQ_reg); |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | module_init(init); |
| 94 | module_exit(fini); |