blob: 5549c39c78512d63228c04c62362633337c8a5f5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* 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
17MODULE_LICENSE("GPL");
18MODULE_DESCRIPTION("iptables TOS match module");
19
20static int
21match(const struct sk_buff *skb,
22 const struct net_device *in,
23 const struct net_device *out,
Patrick McHardyc4986732006-03-20 18:02:56 -080024 const struct xt_match *match,
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 const void *matchinfo,
26 int offset,
Harald Welte2e4e6a12006-01-12 13:30:04 -080027 unsigned int protoff,
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 int *hotdrop)
29{
30 const struct ipt_tos_info *info = matchinfo;
31
32 return (skb->nh.iph->tos == info->tos) ^ info->invert;
33}
34
Linus Torvalds1da177e2005-04-16 15:20:36 -070035static struct ipt_match tos_match = {
36 .name = "tos",
Patrick McHardy1d5cd902006-03-20 18:01:14 -080037 .match = match,
38 .matchsize = sizeof(struct ipt_tos_info),
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 .me = THIS_MODULE,
40};
41
Andrew Morton65b4b4e2006-03-28 16:37:06 -080042static int __init ipt_multiport_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070043{
44 return ipt_register_match(&tos_match);
45}
46
Andrew Morton65b4b4e2006-03-28 16:37:06 -080047static void __exit ipt_multiport_fini(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070048{
49 ipt_unregister_match(&tos_match);
50}
51
Andrew Morton65b4b4e2006-03-28 16:37:06 -080052module_init(ipt_multiport_init);
53module_exit(ipt_multiport_fini);