Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / net / ipv4 / netfilter / ipt_pkttype.c
blob8ddb1dc5e5aee4aabd395b4032be6c9f390abfe2
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.
6 */
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,
24 int offset,
25 int *hotdrop)
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,
34 void *matchinfo,
35 unsigned int matchsize,
36 unsigned int hook_mask)
39 if (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");
43 return 0;
46 if (matchsize != IPT_ALIGN(sizeof(struct ipt_pkttype_info)))
47 return 0;
49 return 1;
52 static struct ipt_match pkttype_match = {
53 .name = "pkttype",
54 .match = &match,
55 .checkentry = &checkentry,
56 .me = THIS_MODULE,
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);
69 module_init(init);
70 module_exit(fini);