1 /* IP tables module for matching the value of the IPv4 DSCP field
3 * ipt_dscp.c,v 1.3 2002/08/05 19:00:21 laforge Exp
5 * (C) 2002 by Harald Welte <laforge@netfilter.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/module.h>
13 #include <linux/skbuff.h>
15 #include <linux/netfilter_ipv4/ipt_dscp.h>
16 #include <linux/netfilter_ipv4/ip_tables.h>
18 MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
19 MODULE_DESCRIPTION("iptables DSCP matching module");
20 MODULE_LICENSE("GPL");
22 static int match(const struct sk_buff *skb,
23 const struct net_device *in, const struct net_device *out,
24 const struct xt_match *match, const void *matchinfo,
25 int offset, unsigned int protoff, int *hotdrop)
27 const struct ipt_dscp_info *info = matchinfo;
28 const struct iphdr *iph = skb->nh.iph;
30 u_int8_t sh_dscp = ((info->dscp << IPT_DSCP_SHIFT) & IPT_DSCP_MASK);
32 return ((iph->tos&IPT_DSCP_MASK) == sh_dscp) ^ info->invert;
35 static struct ipt_match dscp_match = {
38 .matchsize = sizeof(struct ipt_dscp_info),
42 static int __init ipt_dscp_init(void)
44 return ipt_register_match(&dscp_match);
47 static void __exit ipt_dscp_fini(void)
49 ipt_unregister_match(&dscp_match);
53 module_init(ipt_dscp_init);
54 module_exit(ipt_dscp_fini);