diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /net/bridge/netfilter/ebt_arpreply.c |
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'net/bridge/netfilter/ebt_arpreply.c')
-rw-r--r-- | net/bridge/netfilter/ebt_arpreply.c | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/net/bridge/netfilter/ebt_arpreply.c b/net/bridge/netfilter/ebt_arpreply.c new file mode 100644 index 00000000000..b934de90f7c --- /dev/null +++ b/net/bridge/netfilter/ebt_arpreply.c | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | * ebt_arpreply | ||
3 | * | ||
4 | * Authors: | ||
5 | * Grzegorz Borowiak <grzes@gnu.univ.gda.pl> | ||
6 | * Bart De Schuymer <bdschuym@pandora.be> | ||
7 | * | ||
8 | * August, 2003 | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | #include <linux/netfilter_bridge/ebtables.h> | ||
13 | #include <linux/netfilter_bridge/ebt_arpreply.h> | ||
14 | #include <linux/if_arp.h> | ||
15 | #include <net/arp.h> | ||
16 | #include <linux/module.h> | ||
17 | |||
18 | static int ebt_target_reply(struct sk_buff **pskb, unsigned int hooknr, | ||
19 | const struct net_device *in, const struct net_device *out, | ||
20 | const void *data, unsigned int datalen) | ||
21 | { | ||
22 | struct ebt_arpreply_info *info = (struct ebt_arpreply_info *)data; | ||
23 | u32 _sip, *siptr, _dip, *diptr; | ||
24 | struct arphdr _ah, *ap; | ||
25 | unsigned char _sha[ETH_ALEN], *shp; | ||
26 | struct sk_buff *skb = *pskb; | ||
27 | |||
28 | ap = skb_header_pointer(skb, 0, sizeof(_ah), &_ah); | ||
29 | if (ap == NULL) | ||
30 | return EBT_DROP; | ||
31 | |||
32 | if (ap->ar_op != htons(ARPOP_REQUEST) || | ||
33 | ap->ar_hln != ETH_ALEN || | ||
34 | ap->ar_pro != htons(ETH_P_IP) || | ||
35 | ap->ar_pln != 4) | ||
36 | return EBT_CONTINUE; | ||
37 | |||
38 | shp = skb_header_pointer(skb, sizeof(_ah), ETH_ALEN, &_sha); | ||
39 | if (shp == NULL) | ||
40 | return EBT_DROP; | ||
41 | |||
42 | siptr = skb_header_pointer(skb, sizeof(_ah) + ETH_ALEN, | ||
43 | sizeof(_sip), &_sip); | ||
44 | if (siptr == NULL) | ||
45 | return EBT_DROP; | ||
46 | |||
47 | diptr = skb_header_pointer(skb, | ||
48 | sizeof(_ah) + 2 * ETH_ALEN + sizeof(_sip), | ||
49 | sizeof(_dip), &_dip); | ||
50 | if (diptr == NULL) | ||
51 | return EBT_DROP; | ||
52 | |||
53 | arp_send(ARPOP_REPLY, ETH_P_ARP, *siptr, (struct net_device *)in, | ||
54 | *diptr, shp, info->mac, shp); | ||
55 | |||
56 | return info->target; | ||
57 | } | ||
58 | |||
59 | static int ebt_target_reply_check(const char *tablename, unsigned int hookmask, | ||
60 | const struct ebt_entry *e, void *data, unsigned int datalen) | ||
61 | { | ||
62 | struct ebt_arpreply_info *info = (struct ebt_arpreply_info *)data; | ||
63 | |||
64 | if (datalen != EBT_ALIGN(sizeof(struct ebt_arpreply_info))) | ||
65 | return -EINVAL; | ||
66 | if (BASE_CHAIN && info->target == EBT_RETURN) | ||
67 | return -EINVAL; | ||
68 | if (e->ethproto != htons(ETH_P_ARP) || | ||
69 | e->invflags & EBT_IPROTO) | ||
70 | return -EINVAL; | ||
71 | CLEAR_BASE_CHAIN_BIT; | ||
72 | if (strcmp(tablename, "nat") || hookmask & ~(1 << NF_BR_PRE_ROUTING)) | ||
73 | return -EINVAL; | ||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | static struct ebt_target reply_target = | ||
78 | { | ||
79 | .name = EBT_ARPREPLY_TARGET, | ||
80 | .target = ebt_target_reply, | ||
81 | .check = ebt_target_reply_check, | ||
82 | .me = THIS_MODULE, | ||
83 | }; | ||
84 | |||
85 | static int __init init(void) | ||
86 | { | ||
87 | return ebt_register_target(&reply_target); | ||
88 | } | ||
89 | |||
90 | static void __exit fini(void) | ||
91 | { | ||
92 | ebt_unregister_target(&reply_target); | ||
93 | } | ||
94 | |||
95 | module_init(init); | ||
96 | module_exit(fini); | ||
97 | MODULE_LICENSE("GPL"); | ||