]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - net/bridge/netfilter/ebt_pkttype.c
netfilter: move Ebtables to use Xtables
[mirror_ubuntu-zesty-kernel.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 14
2d06d4a5
JE
15static bool
16ebt_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)
1da177e4 20{
abfdf1c4 21 const struct ebt_pkttype_info *info = data;
1da177e4 22
8cc784ee 23 return (skb->pkt_type == info->pkt_type) ^ info->invert;
1da177e4
LT
24}
25
2d06d4a5
JE
26static bool
27ebt_pkttype_mt_check(const char *table, const void *e,
28 const struct xt_match *match, void *data,
29 unsigned int hook_mask)
1da177e4 30{
abfdf1c4 31 const struct ebt_pkttype_info *info = data;
1da177e4 32
1da177e4 33 if (info->invert != 0 && info->invert != 1)
19eda879 34 return false;
1da177e4 35 /* Allow any pkt_type value */
19eda879 36 return true;
1da177e4
LT
37}
38
043ef46c
JE
39static struct xt_match ebt_pkttype_mt_reg __read_mostly = {
40 .name = "pkttype",
001a18d3
JE
41 .revision = 0,
42 .family = NFPROTO_BRIDGE,
2d06d4a5
JE
43 .match = ebt_pkttype_mt,
44 .checkentry = ebt_pkttype_mt_check,
18219d3f 45 .matchsize = XT_ALIGN(sizeof(struct ebt_pkttype_info)),
1da177e4
LT
46 .me = THIS_MODULE,
47};
48
65b4b4e8 49static int __init ebt_pkttype_init(void)
1da177e4 50{
043ef46c 51 return xt_register_match(&ebt_pkttype_mt_reg);
1da177e4
LT
52}
53
65b4b4e8 54static void __exit ebt_pkttype_fini(void)
1da177e4 55{
043ef46c 56 xt_unregister_match(&ebt_pkttype_mt_reg);
1da177e4
LT
57}
58
65b4b4e8
AM
59module_init(ebt_pkttype_init);
60module_exit(ebt_pkttype_fini);
f776c4cd 61MODULE_DESCRIPTION("Ebtables: Link layer packet type match");
1da177e4 62MODULE_LICENSE("GPL");