Commit | Line | Data |
---|---|---|
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 | ||
15 | static 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 | ||
39 | static struct ebt_match filter_802_3; | |
40 | static 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 | ||
53 | static 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 | ||
65b4b4e8 | 61 | static int __init ebt_802_3_init(void) |
1da177e4 LT |
62 | { |
63 | return ebt_register_match(&filter_802_3); | |
64 | } | |
65 | ||
65b4b4e8 | 66 | static void __exit ebt_802_3_fini(void) |
1da177e4 LT |
67 | { |
68 | ebt_unregister_match(&filter_802_3); | |
69 | } | |
70 | ||
65b4b4e8 AM |
71 | module_init(ebt_802_3_init); |
72 | module_exit(ebt_802_3_fini); | |
1da177e4 | 73 | MODULE_LICENSE("GPL"); |