Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * ebt_pkttype |
| 3 | * |
| 4 | * Authors: |
| 5 | * Bart De Schuymer <bdschuym@pandora.be> |
| 6 | * |
| 7 | * April, 2003 |
| 8 | * |
| 9 | */ |
| 10 | |
| 11 | #include <linux/netfilter_bridge/ebtables.h> |
| 12 | #include <linux/netfilter_bridge/ebt_pkttype.h> |
| 13 | #include <linux/module.h> |
| 14 | |
| 15 | static 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 | { |
| 21 | struct ebt_pkttype_info *info = (struct ebt_pkttype_info *)data; |
| 22 | |
| 23 | return (skb->pkt_type != info->pkt_type) ^ info->invert; |
| 24 | } |
| 25 | |
| 26 | static int ebt_pkttype_check(const char *tablename, unsigned int hookmask, |
| 27 | const struct ebt_entry *e, void *data, unsigned int datalen) |
| 28 | { |
| 29 | struct ebt_pkttype_info *info = (struct ebt_pkttype_info *)data; |
| 30 | |
| 31 | if (datalen != EBT_ALIGN(sizeof(struct ebt_pkttype_info))) |
| 32 | return -EINVAL; |
| 33 | if (info->invert != 0 && info->invert != 1) |
| 34 | return -EINVAL; |
| 35 | /* Allow any pkt_type value */ |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | static struct ebt_match filter_pkttype = |
| 40 | { |
| 41 | .name = EBT_PKTTYPE_MATCH, |
| 42 | .match = ebt_filter_pkttype, |
| 43 | .check = ebt_pkttype_check, |
| 44 | .me = THIS_MODULE, |
| 45 | }; |
| 46 | |
Andrew Morton | 65b4b4e | 2006-03-28 16:37:06 -0800 | [diff] [blame] | 47 | static int __init ebt_pkttype_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | { |
| 49 | return ebt_register_match(&filter_pkttype); |
| 50 | } |
| 51 | |
Andrew Morton | 65b4b4e | 2006-03-28 16:37:06 -0800 | [diff] [blame] | 52 | static void __exit ebt_pkttype_fini(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | { |
| 54 | ebt_unregister_match(&filter_pkttype); |
| 55 | } |
| 56 | |
Andrew Morton | 65b4b4e | 2006-03-28 16:37:06 -0800 | [diff] [blame] | 57 | module_init(ebt_pkttype_init); |
| 58 | module_exit(ebt_pkttype_fini); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | MODULE_LICENSE("GPL"); |