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 #define FILTER_VALID_HOOKS ((1 << NF_ARP_IN) | (1 << NF_ARP_OUT))
16 struct arpt_entry entry;
17 struct arpt_standard_target target;
20 struct arpt_error_target
22 struct arpt_entry_target target;
23 char errorname[ARPT_FUNCTION_MAXNAMELEN];
28 struct arpt_entry entry;
29 struct arpt_error_target target;
34 struct arpt_replace repl;
35 struct arpt_standard entries[2];
36 struct arpt_error term;
37 } initial_table __initdata
38 = { { "filter", FILTER_VALID_HOOKS, 3,
39 sizeof(struct arpt_standard) * 2 + sizeof(struct arpt_error),
41 [NF_ARP_OUT] sizeof(struct arpt_standard) },
43 [NF_ARP_OUT] sizeof(struct arpt_standard), },
50 { 0 }, { 0 }, { 0 }, { 0 },
60 sizeof(struct arpt_entry),
61 sizeof(struct arpt_standard),
64 { { { { ARPT_ALIGN(sizeof(struct arpt_standard_target)), "" } }, { } },
71 { 0 }, { 0 }, { 0 }, { 0 },
81 sizeof(struct arpt_entry),
82 sizeof(struct arpt_standard),
85 { { { { ARPT_ALIGN(sizeof(struct arpt_standard_target)), "" } }, { } },
93 { 0 }, { 0 }, { 0 }, { 0 },
100 "", "", { 0 }, { 0 },
103 sizeof(struct arpt_entry),
104 sizeof(struct arpt_error),
107 { { { { ARPT_ALIGN(sizeof(struct arpt_error_target)), ARPT_ERROR_TARGET } },
114 static struct arpt_table packet_filter
115 = { { NULL, NULL }, "filter", &initial_table.repl,
116 FILTER_VALID_HOOKS, RW_LOCK_UNLOCKED, NULL, THIS_MODULE };
118 /* The work comes in here from netfilter.c */
119 static unsigned int arpt_hook(unsigned int hook,
120 struct sk_buff **pskb,
121 const struct net_device *in,
122 const struct net_device *out,
123 int (*okfn)(struct sk_buff *))
125 return arpt_do_table(pskb, hook, in, out, &packet_filter, NULL);
128 static struct nf_hook_ops arpt_ops[]
129 = { { { NULL, NULL }, arpt_hook, NF_ARP, NF_ARP_IN, 0 },
130 { { NULL, NULL }, arpt_hook, NF_ARP, NF_ARP_OUT, 0 }
133 static int __init init(void)
138 ret = arpt_register_table(&packet_filter);
143 ret = nf_register_hook(&arpt_ops[0]);
147 ret = nf_register_hook(&arpt_ops[1]);
154 nf_unregister_hook(&arpt_ops[0]);
157 arpt_unregister_table(&packet_filter);
162 static void __exit fini(void)
166 for (i = 0; i < sizeof(arpt_ops)/sizeof(struct nf_hook_ops); i++)
167 nf_unregister_hook(&arpt_ops[i]);
169 arpt_unregister_table(&packet_filter);
174 MODULE_LICENSE("GPL");