OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [net/] [ipv4/] [netfilter/] [ipt_dscp.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/* IP tables module for matching the value of the IPv4 DSCP field
2
 *
3
 * ipt_dscp.c,v 1.3 2002/08/05 19:00:21 laforge Exp
4
 *
5
 * (C) 2002 by Harald Welte <laforge@gnumonks.org>
6
 *
7
 * This software is distributed under the terms  GNU GPL
8
 */
9
 
10
#include <linux/module.h>
11
#include <linux/skbuff.h>
12
 
13
#include <linux/netfilter_ipv4/ipt_dscp.h>
14
#include <linux/netfilter_ipv4/ip_tables.h>
15
 
16
MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
17
MODULE_DESCRIPTION("IP tables DSCP matching module");
18
MODULE_LICENSE("GPL");
19
 
20
static int match(const struct sk_buff *skb, const struct net_device *in,
21
                 const struct net_device *out, const void *matchinfo,
22
                 int offset, const void *hdr, u_int16_t datalen,
23
                 int *hotdrop)
24
{
25
        const struct ipt_dscp_info *info = matchinfo;
26
        const struct iphdr *iph = skb->nh.iph;
27
 
28
        u_int8_t sh_dscp = ((info->dscp << IPT_DSCP_SHIFT) & IPT_DSCP_MASK);
29
 
30
        return ((iph->tos&IPT_DSCP_MASK) == sh_dscp) ^ info->invert;
31
}
32
 
33
static int checkentry(const char *tablename, const struct ipt_ip *ip,
34
                      void *matchinfo, unsigned int matchsize,
35
                      unsigned int hook_mask)
36
{
37
        if (matchsize != IPT_ALIGN(sizeof(struct ipt_dscp_info)))
38
                return 0;
39
 
40
        return 1;
41
}
42
 
43
static struct ipt_match dscp_match = { { NULL, NULL }, "dscp", &match,
44
                &checkentry, NULL, THIS_MODULE };
45
 
46
static int __init init(void)
47
{
48
        return ipt_register_match(&dscp_match);
49
}
50
 
51
static void __exit fini(void)
52
{
53
        ipt_unregister_match(&dscp_match);
54
 
55
}
56
 
57
module_init(init);
58
module_exit(fini);

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.