2 * Filtering ARP tables module.
4 * Copyright (C) 2002 David S. Miller (davem@redhat.com)
8 #include <linux/module.h>
9 #include <linux/netfilter_arp/arp_tables.h>
11 MODULE_LICENSE("GPL");
12 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
13 MODULE_DESCRIPTION("arptables filter table");
15 #define FILTER_VALID_HOOKS ((1 << NF_ARP_IN) | (1 << NF_ARP_OUT) | \
16 (1 << NF_ARP_FORWARD))
21 struct arpt_entry entry;
22 struct arpt_standard_target target;
25 struct arpt_error_target
27 struct arpt_entry_target target;
28 char errorname[ARPT_FUNCTION_MAXNAMELEN];
33 struct arpt_entry entry;
34 struct arpt_error_target target;
39 struct arpt_replace repl;
40 struct arpt_standard entries[3];
41 struct arpt_error term;
42 } initial_table __initdata
43 = { { "filter", FILTER_VALID_HOOKS, 4,
44 sizeof(struct arpt_standard) * 3 + sizeof(struct arpt_error),
46 [NF_ARP_OUT] = sizeof(struct arpt_standard),
47 [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard), },
49 [NF_ARP_OUT] = sizeof(struct arpt_standard),
50 [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard), },
57 { 0 }, { 0 }, { 0 }, { 0 },
67 sizeof(struct arpt_entry),
68 sizeof(struct arpt_standard),
71 { { { { ARPT_ALIGN(sizeof(struct arpt_standard_target)), "" } }, { } },
78 { 0 }, { 0 }, { 0 }, { 0 },
88 sizeof(struct arpt_entry),
89 sizeof(struct arpt_standard),
92 { { { { ARPT_ALIGN(sizeof(struct arpt_standard_target)), "" } }, { } },
99 { 0 }, { 0 }, { 0 }, { 0 },
106 "", "", { 0 }, { 0 },
109 sizeof(struct arpt_entry),
110 sizeof(struct arpt_standard),
113 { { { { ARPT_ALIGN(sizeof(struct arpt_standard_target)), "" } }, { } },
121 { 0 }, { 0 }, { 0 }, { 0 },
128 "", "", { 0 }, { 0 },
131 sizeof(struct arpt_entry),
132 sizeof(struct arpt_error),
135 { { { { ARPT_ALIGN(sizeof(struct arpt_error_target)), ARPT_ERROR_TARGET } },
142 static struct arpt_table packet_filter = {
144 .valid_hooks = FILTER_VALID_HOOKS,
145 .lock = RW_LOCK_UNLOCKED,
151 /* The work comes in here from netfilter.c */
152 static unsigned int arpt_hook(unsigned int hook,
153 struct sk_buff **pskb,
154 const struct net_device *in,
155 const struct net_device *out,
156 int (*okfn)(struct sk_buff *))
158 return arpt_do_table(pskb, hook, in, out, &packet_filter, NULL);
161 static struct nf_hook_ops arpt_ops[] = {
164 .owner = THIS_MODULE,
166 .hooknum = NF_ARP_IN,
170 .owner = THIS_MODULE,
172 .hooknum = NF_ARP_OUT,
176 .owner = THIS_MODULE,
178 .hooknum = NF_ARP_FORWARD,
182 static int __init arptable_filter_init(void)
187 ret = arpt_register_table(&packet_filter, &initial_table.repl);
191 ret = nf_register_hooks(arpt_ops, ARRAY_SIZE(arpt_ops));
197 arpt_unregister_table(&packet_filter);
201 static void __exit arptable_filter_fini(void)
203 nf_unregister_hooks(arpt_ops, ARRAY_SIZE(arpt_ops));
204 arpt_unregister_table(&packet_filter);
207 module_init(arptable_filter_init);
208 module_exit(arptable_filter_fini);