]> git.karo-electronics.de Git - mv-sheeva.git/blob - net/bridge/netfilter/ebt_pkttype.c
06393452ef91cbca6b7c9b2eee75dbbf03a6ce1c
[mv-sheeva.git] / net / bridge / netfilter / ebt_pkttype.c
1 /*
2  *  ebt_pkttype
3  *
4  *      Authors:
5  *      Bart De Schuymer <bdschuym@pandora.be>
6  *
7  *  April, 2003
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_pkttype.h>
14
15 static bool
16 ebt_pkttype_mt(const struct sk_buff *skb, const struct net_device *in,
17                const struct net_device *out, const struct xt_match *match,
18                const void *data, int offset, unsigned int protoff,
19                bool *hotdrop)
20 {
21         const struct ebt_pkttype_info *info = data;
22
23         return (skb->pkt_type == info->pkt_type) ^ info->invert;
24 }
25
26 static bool
27 ebt_pkttype_mt_check(const char *table, const void *e,
28                      const struct xt_match *match, void *data,
29                      unsigned int hook_mask)
30 {
31         const struct ebt_pkttype_info *info = data;
32
33         if (info->invert != 0 && info->invert != 1)
34                 return false;
35         /* Allow any pkt_type value */
36         return true;
37 }
38
39 static struct ebt_match filter_pkttype __read_mostly = {
40         .name           = EBT_PKTTYPE_MATCH,
41         .revision       = 0,
42         .family         = NFPROTO_BRIDGE,
43         .match          = ebt_pkttype_mt,
44         .checkentry     = ebt_pkttype_mt_check,
45         .matchsize      = XT_ALIGN(sizeof(struct ebt_pkttype_info)),
46         .me             = THIS_MODULE,
47 };
48
49 static int __init ebt_pkttype_init(void)
50 {
51         return ebt_register_match(&filter_pkttype);
52 }
53
54 static void __exit ebt_pkttype_fini(void)
55 {
56         ebt_unregister_match(&filter_pkttype);
57 }
58
59 module_init(ebt_pkttype_init);
60 module_exit(ebt_pkttype_fini);
61 MODULE_DESCRIPTION("Ebtables: Link layer packet type match");
62 MODULE_LICENSE("GPL");