[TCP]: Fix RFC2465 typo.
[linux-2.6-block.git] / net / bridge / netfilter / ebt_802_3.c
CommitLineData
1da177e4
LT
1/*
2 * 802_3
3 *
4 * Author:
5 * Chris Vitale csv@bluetail.com
6 *
7 * May 2003
8 *
9 */
10
11#include <linux/netfilter_bridge/ebtables.h>
12#include <linux/netfilter_bridge/ebt_802_3.h>
13#include <linux/module.h>
14
15static int ebt_filter_802_3(const struct sk_buff *skb, const struct net_device *in,
16 const struct net_device *out, const void *data, unsigned int datalen)
17{
18 struct ebt_802_3_info *info = (struct ebt_802_3_info *)data;
19 struct ebt_802_3_hdr *hdr = ebt_802_3_hdr(skb);
20 uint16_t type = hdr->llc.ui.ctrl & IS_UI ? hdr->llc.ui.type : hdr->llc.ni.type;
21
22 if (info->bitmask & EBT_802_3_SAP) {
23 if (FWINV(info->sap != hdr->llc.ui.ssap, EBT_802_3_SAP))
24 return EBT_NOMATCH;
25 if (FWINV(info->sap != hdr->llc.ui.dsap, EBT_802_3_SAP))
26 return EBT_NOMATCH;
27 }
28
29 if (info->bitmask & EBT_802_3_TYPE) {
30 if (!(hdr->llc.ui.dsap == CHECK_TYPE && hdr->llc.ui.ssap == CHECK_TYPE))
31 return EBT_NOMATCH;
32 if (FWINV(info->type != type, EBT_802_3_TYPE))
33 return EBT_NOMATCH;
34 }
35
36 return EBT_MATCH;
37}
38
39static struct ebt_match filter_802_3;
40static int ebt_802_3_check(const char *tablename, unsigned int hookmask,
41 const struct ebt_entry *e, void *data, unsigned int datalen)
42{
43 struct ebt_802_3_info *info = (struct ebt_802_3_info *)data;
44
45 if (datalen < sizeof(struct ebt_802_3_info))
46 return -EINVAL;
47 if (info->bitmask & ~EBT_802_3_MASK || info->invflags & ~EBT_802_3_MASK)
48 return -EINVAL;
49
50 return 0;
51}
52
53static struct ebt_match filter_802_3 =
54{
55 .name = EBT_802_3_MATCH,
56 .match = ebt_filter_802_3,
57 .check = ebt_802_3_check,
58 .me = THIS_MODULE,
59};
60
61static int __init init(void)
62{
63 return ebt_register_match(&filter_802_3);
64}
65
66static void __exit fini(void)
67{
68 ebt_unregister_match(&filter_802_3);
69}
70
71module_init(init);
72module_exit(fini);
73MODULE_LICENSE("GPL");