Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ebt_pkttype.c
Go to the documentation of this file.
1 /*
2  * ebt_pkttype
3  *
4  * Authors:
5  * Bart De Schuymer <[email protected]>
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>
14 
15 static bool
16 ebt_pkttype_mt(const struct sk_buff *skb, struct xt_action_param *par)
17 {
18  const struct ebt_pkttype_info *info = par->matchinfo;
19 
20  return (skb->pkt_type == info->pkt_type) ^ info->invert;
21 }
22 
23 static int ebt_pkttype_mt_check(const struct xt_mtchk_param *par)
24 {
25  const struct ebt_pkttype_info *info = par->matchinfo;
26 
27  if (info->invert != 0 && info->invert != 1)
28  return -EINVAL;
29  /* Allow any pkt_type value */
30  return 0;
31 }
32 
33 static struct xt_match ebt_pkttype_mt_reg __read_mostly = {
34  .name = "pkttype",
35  .revision = 0,
36  .family = NFPROTO_BRIDGE,
37  .match = ebt_pkttype_mt,
38  .checkentry = ebt_pkttype_mt_check,
39  .matchsize = sizeof(struct ebt_pkttype_info),
40  .me = THIS_MODULE,
41 };
42 
43 static int __init ebt_pkttype_init(void)
44 {
45  return xt_register_match(&ebt_pkttype_mt_reg);
46 }
47 
48 static void __exit ebt_pkttype_fini(void)
49 {
50  xt_unregister_match(&ebt_pkttype_mt_reg);
51 }
52 
53 module_init(ebt_pkttype_init);
54 module_exit(ebt_pkttype_fini);
55 MODULE_DESCRIPTION("Ebtables: Link layer packet type match");
56 MODULE_LICENSE("GPL");