netfilter: xtables: move extension arguments into compound structure (1/6)
[deliverable/linux.git] / net / bridge / netfilter / ebt_mark_m.c
1 /*
2 * ebt_mark_m
3 *
4 * Authors:
5 * Bart De Schuymer <bdschuym@pandora.be>
6 *
7 * July, 2002
8 *
9 */
10 #include <linux/module.h>
11 #include <linux/netfilter/x_tables.h>
12 #include <linux/netfilter_bridge/ebtables.h>
13 #include <linux/netfilter_bridge/ebt_mark_m.h>
14
15 static bool
16 ebt_mark_mt(const struct sk_buff *skb, const struct xt_match_param *par)
17 {
18 const struct ebt_mark_m_info *info = par->matchinfo;
19
20 if (info->bitmask & EBT_MARK_OR)
21 return !!(skb->mark & info->mask) ^ info->invert;
22 return ((skb->mark & info->mask) == info->mark) ^ info->invert;
23 }
24
25 static bool
26 ebt_mark_mt_check(const char *table, const void *e,
27 const struct xt_match *match, void *data,
28 unsigned int hook_mask)
29 {
30 const struct ebt_mark_m_info *info = data;
31
32 if (info->bitmask & ~EBT_MARK_MASK)
33 return false;
34 if ((info->bitmask & EBT_MARK_OR) && (info->bitmask & EBT_MARK_AND))
35 return false;
36 if (!info->bitmask)
37 return false;
38 return true;
39 }
40
41 static struct xt_match ebt_mark_mt_reg __read_mostly = {
42 .name = "mark_m",
43 .revision = 0,
44 .family = NFPROTO_BRIDGE,
45 .match = ebt_mark_mt,
46 .checkentry = ebt_mark_mt_check,
47 .matchsize = XT_ALIGN(sizeof(struct ebt_mark_m_info)),
48 .me = THIS_MODULE,
49 };
50
51 static int __init ebt_mark_m_init(void)
52 {
53 return xt_register_match(&ebt_mark_mt_reg);
54 }
55
56 static void __exit ebt_mark_m_fini(void)
57 {
58 xt_unregister_match(&ebt_mark_mt_reg);
59 }
60
61 module_init(ebt_mark_m_init);
62 module_exit(ebt_mark_m_fini);
63 MODULE_DESCRIPTION("Ebtables: Packet mark match");
64 MODULE_LICENSE("GPL");
This page took 0.032575 seconds and 5 git commands to generate.