]> bbs.cooldavid.org Git - net-next-2.6.git/blame - net/bridge/netfilter/ebt_pkttype.c
netfilter: ebtables: do centralized size checking
[net-next-2.6.git] / net / bridge / netfilter / ebt_pkttype.c
CommitLineData
1da177e4
LT
1/*
2 * ebt_pkttype
3 *
4 * Authors:
5 * Bart De Schuymer <bdschuym@pandora.be>
6 *
7 * April, 2003
8 *
9 */
18219d3f
JE
10#include <linux/module.h>
11#include <linux/netfilter/x_tables.h>
1da177e4
LT
12#include <linux/netfilter_bridge/ebtables.h>
13#include <linux/netfilter_bridge/ebt_pkttype.h>
1da177e4
LT
14
15static int ebt_filter_pkttype(const struct sk_buff *skb,
16 const struct net_device *in,
17 const struct net_device *out,
18 const void *data,
19 unsigned int datalen)
20{
abfdf1c4 21 const struct ebt_pkttype_info *info = data;
1da177e4
LT
22
23 return (skb->pkt_type != info->pkt_type) ^ info->invert;
24}
25
26static int ebt_pkttype_check(const char *tablename, unsigned int hookmask,
27 const struct ebt_entry *e, void *data, unsigned int datalen)
28{
abfdf1c4 29 const struct ebt_pkttype_info *info = data;
1da177e4 30
1da177e4
LT
31 if (info->invert != 0 && info->invert != 1)
32 return -EINVAL;
33 /* Allow any pkt_type value */
34 return 0;
35}
36
30083c95 37static struct ebt_match filter_pkttype __read_mostly = {
1da177e4
LT
38 .name = EBT_PKTTYPE_MATCH,
39 .match = ebt_filter_pkttype,
40 .check = ebt_pkttype_check,
18219d3f 41 .matchsize = XT_ALIGN(sizeof(struct ebt_pkttype_info)),
1da177e4
LT
42 .me = THIS_MODULE,
43};
44
65b4b4e8 45static int __init ebt_pkttype_init(void)
1da177e4
LT
46{
47 return ebt_register_match(&filter_pkttype);
48}
49
65b4b4e8 50static void __exit ebt_pkttype_fini(void)
1da177e4
LT
51{
52 ebt_unregister_match(&filter_pkttype);
53}
54
65b4b4e8
AM
55module_init(ebt_pkttype_init);
56module_exit(ebt_pkttype_fini);
f776c4cd 57MODULE_DESCRIPTION("Ebtables: Link layer packet type match");
1da177e4 58MODULE_LICENSE("GPL");