]> bbs.cooldavid.org Git - net-next-2.6.git/blame - net/bridge/netfilter/ebt_mark_m.c
[NETFILTER]: ebtables: remove casts, use consts
[net-next-2.6.git] / net / bridge / netfilter / ebt_mark_m.c
CommitLineData
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
15static 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{
abfdf1c4 19 const struct ebt_mark_m_info *info = data;
1da177e4
LT
20
21 if (info->bitmask & EBT_MARK_OR)
82e91ffe
TG
22 return !(!!(skb->mark & info->mask) ^ info->invert);
23 return !(((skb->mark & info->mask) == info->mark) ^ info->invert);
1da177e4
LT
24}
25
26static int ebt_mark_check(const char *tablename, unsigned int hookmask,
27 const struct ebt_entry *e, void *data, unsigned int datalen)
28{
abfdf1c4 29 const struct ebt_mark_m_info *info = data;
1da177e4
LT
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
42static 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 50static int __init ebt_mark_m_init(void)
1da177e4
LT
51{
52 return ebt_register_match(&filter_mark);
53}
54
65b4b4e8 55static void __exit ebt_mark_m_fini(void)
1da177e4
LT
56{
57 ebt_unregister_match(&filter_mark);
58}
59
65b4b4e8
AM
60module_init(ebt_mark_m_init);
61module_exit(ebt_mark_m_fini);
1da177e4 62MODULE_LICENSE("GPL");