Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * ebt_mark_m | |
3 | * | |
4 | * Authors: | |
5 | * Bart De Schuymer <bdschuym@pandora.be> | |
6 | * | |
7 | * July, 2002 | |
8 | * | |
9 | */ | |
10 | ||
11 | #include <linux/netfilter_bridge/ebtables.h> | |
12 | #include <linux/netfilter_bridge/ebt_mark_m.h> | |
13 | #include <linux/module.h> | |
14 | ||
15 | static int ebt_filter_mark(const struct sk_buff *skb, | |
16 | const struct net_device *in, const struct net_device *out, const void *data, | |
17 | unsigned int datalen) | |
18 | { | |
19 | struct ebt_mark_m_info *info = (struct ebt_mark_m_info *) data; | |
20 | ||
21 | if (info->bitmask & EBT_MARK_OR) | |
22 | return !(!!(skb->nfmark & info->mask) ^ info->invert); | |
23 | return !(((skb->nfmark & info->mask) == info->mark) ^ info->invert); | |
24 | } | |
25 | ||
26 | static int ebt_mark_check(const char *tablename, unsigned int hookmask, | |
27 | const struct ebt_entry *e, void *data, unsigned int datalen) | |
28 | { | |
29 | struct ebt_mark_m_info *info = (struct ebt_mark_m_info *) data; | |
30 | ||
31 | if (datalen != EBT_ALIGN(sizeof(struct ebt_mark_m_info))) | |
32 | return -EINVAL; | |
33 | if (info->bitmask & ~EBT_MARK_MASK) | |
34 | return -EINVAL; | |
35 | if ((info->bitmask & EBT_MARK_OR) && (info->bitmask & EBT_MARK_AND)) | |
36 | return -EINVAL; | |
37 | if (!info->bitmask) | |
38 | return -EINVAL; | |
39 | return 0; | |
40 | } | |
41 | ||
42 | static struct ebt_match filter_mark = | |
43 | { | |
44 | .name = EBT_MARK_MATCH, | |
45 | .match = ebt_filter_mark, | |
46 | .check = ebt_mark_check, | |
47 | .me = THIS_MODULE, | |
48 | }; | |
49 | ||
65b4b4e8 | 50 | static int __init ebt_mark_m_init(void) |
1da177e4 LT |
51 | { |
52 | return ebt_register_match(&filter_mark); | |
53 | } | |
54 | ||
65b4b4e8 | 55 | static void __exit ebt_mark_m_fini(void) |
1da177e4 LT |
56 | { |
57 | ebt_unregister_match(&filter_mark); | |
58 | } | |
59 | ||
65b4b4e8 AM |
60 | module_init(ebt_mark_m_init); |
61 | module_exit(ebt_mark_m_fini); | |
1da177e4 | 62 | MODULE_LICENSE("GPL"); |