Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
[deliverable/linux.git] / net / ipv4 / netfilter / ipt_tos.c
1 /* Kernel module to match TOS values. */
2
3 /* (C) 1999-2001 Paul `Rusty' Russell
4 * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11 #include <linux/module.h>
12 #include <linux/skbuff.h>
13
14 #include <linux/netfilter_ipv4/ipt_tos.h>
15 #include <linux/netfilter_ipv4/ip_tables.h>
16
17 MODULE_LICENSE("GPL");
18 MODULE_DESCRIPTION("iptables TOS match module");
19
20 static int
21 match(const struct sk_buff *skb,
22 const struct net_device *in,
23 const struct net_device *out,
24 const void *matchinfo,
25 int offset,
26 unsigned int protoff,
27 int *hotdrop)
28 {
29 const struct ipt_tos_info *info = matchinfo;
30
31 return (skb->nh.iph->tos == info->tos) ^ info->invert;
32 }
33
34 static int
35 checkentry(const char *tablename,
36 const void *ip,
37 void *matchinfo,
38 unsigned int matchsize,
39 unsigned int hook_mask)
40 {
41 if (matchsize != IPT_ALIGN(sizeof(struct ipt_tos_info)))
42 return 0;
43
44 return 1;
45 }
46
47 static struct ipt_match tos_match = {
48 .name = "tos",
49 .match = &match,
50 .checkentry = &checkentry,
51 .me = THIS_MODULE,
52 };
53
54 static int __init init(void)
55 {
56 return ipt_register_match(&tos_match);
57 }
58
59 static void __exit fini(void)
60 {
61 ipt_unregister_match(&tos_match);
62 }
63
64 module_init(init);
65 module_exit(fini);
This page took 0.033324 seconds and 6 git commands to generate.