[NETFILTER]: Replace sk_buff ** with sk_buff *
[deliverable/linux.git] / net / bridge / netfilter / ebt_arpreply.c
CommitLineData
1da177e4
LT
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
3db05fea 18static int ebt_target_reply(struct sk_buff *skb, unsigned int hooknr,
1da177e4
LT
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;
ed9bad06 23 __be32 _sip, *siptr, _dip, *diptr;
1da177e4
LT
24 struct arphdr _ah, *ap;
25 unsigned char _sha[ETH_ALEN], *shp;
1da177e4
LT
26
27 ap = skb_header_pointer(skb, 0, sizeof(_ah), &_ah);
28 if (ap == NULL)
29 return EBT_DROP;
30
31 if (ap->ar_op != htons(ARPOP_REQUEST) ||
32 ap->ar_hln != ETH_ALEN ||
33 ap->ar_pro != htons(ETH_P_IP) ||
34 ap->ar_pln != 4)
35 return EBT_CONTINUE;
36
37 shp = skb_header_pointer(skb, sizeof(_ah), ETH_ALEN, &_sha);
38 if (shp == NULL)
39 return EBT_DROP;
40
41 siptr = skb_header_pointer(skb, sizeof(_ah) + ETH_ALEN,
42 sizeof(_sip), &_sip);
43 if (siptr == NULL)
44 return EBT_DROP;
45
46 diptr = skb_header_pointer(skb,
47 sizeof(_ah) + 2 * ETH_ALEN + sizeof(_sip),
48 sizeof(_dip), &_dip);
49 if (diptr == NULL)
50 return EBT_DROP;
51
52 arp_send(ARPOP_REPLY, ETH_P_ARP, *siptr, (struct net_device *)in,
9d6f229f 53 *diptr, shp, info->mac, shp);
1da177e4
LT
54
55 return info->target;
56}
57
58static int ebt_target_reply_check(const char *tablename, unsigned int hookmask,
59 const struct ebt_entry *e, void *data, unsigned int datalen)
60{
61 struct ebt_arpreply_info *info = (struct ebt_arpreply_info *)data;
62
63 if (datalen != EBT_ALIGN(sizeof(struct ebt_arpreply_info)))
64 return -EINVAL;
65 if (BASE_CHAIN && info->target == EBT_RETURN)
66 return -EINVAL;
67 if (e->ethproto != htons(ETH_P_ARP) ||
68 e->invflags & EBT_IPROTO)
69 return -EINVAL;
70 CLEAR_BASE_CHAIN_BIT;
71 if (strcmp(tablename, "nat") || hookmask & ~(1 << NF_BR_PRE_ROUTING))
72 return -EINVAL;
73 return 0;
74}
75
76static struct ebt_target reply_target =
77{
78 .name = EBT_ARPREPLY_TARGET,
79 .target = ebt_target_reply,
80 .check = ebt_target_reply_check,
81 .me = THIS_MODULE,
82};
83
65b4b4e8 84static int __init ebt_arpreply_init(void)
1da177e4
LT
85{
86 return ebt_register_target(&reply_target);
87}
88
65b4b4e8 89static void __exit ebt_arpreply_fini(void)
1da177e4
LT
90{
91 ebt_unregister_target(&reply_target);
92}
93
65b4b4e8
AM
94module_init(ebt_arpreply_init);
95module_exit(ebt_arpreply_fini);
1da177e4 96MODULE_LICENSE("GPL");
This page took 0.487835 seconds and 5 git commands to generate.