1 /* (C) 1999-2001 Michal Ludvig <michal@logix.cz>
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 as
5 * published by the Free Software Foundation.
8 #include <linux/module.h>
9 #include <linux/skbuff.h>
10 #include <linux/if_ether.h>
11 #include <linux/if_packet.h>
13 #include <linux/netfilter_ipv4/ipt_pkttype.h>
14 #include <linux/netfilter_ipv4/ip_tables.h>
16 MODULE_LICENSE("GPL");
17 MODULE_AUTHOR("Michal Ludvig <michal@logix.cz>");
18 MODULE_DESCRIPTION("IP tables match to match on linklayer packet type");
20 static int match(const struct sk_buff
*skb
,
21 const struct net_device
*in
,
22 const struct net_device
*out
,
23 const void *matchinfo
,
27 const struct ipt_pkttype_info
*info
= matchinfo
;
29 return (skb
->pkt_type
== info
->pkttype
) ^ info
->invert
;
32 static int checkentry(const char *tablename
,
33 const struct ipt_ip
*ip
,
35 unsigned int matchsize
,
36 unsigned int hook_mask
)
40 & ~((1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_IN)
41 | (1 << NF_IP_FORWARD))) {
42 printk("ipt_pkttype: only valid for PRE_ROUTING, LOCAL_IN or FORWARD.\n");
46 if (matchsize
!= IPT_ALIGN(sizeof(struct ipt_pkttype_info
)))
52 static struct ipt_match pkttype_match
= {
55 .checkentry
= &checkentry
,
59 static int __init
init(void)
61 return ipt_register_match(&pkttype_match
);
64 static void __exit
fini(void)
66 ipt_unregister_match(&pkttype_match
);