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

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [tags/] [linux-2.6/] [linux-2.6.24_or32_unified_v2.3/] [net/] [ipv4/] [netfilter/] [ipt_addrtype.c] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 xianfeng
/*
2
 *  iptables module to match inet_addr_type() of an ip.
3
 *
4
 *  Copyright (c) 2004 Patrick McHardy <kaber@trash.net>
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/kernel.h>
12
#include <linux/module.h>
13
#include <linux/skbuff.h>
14
#include <linux/netdevice.h>
15
#include <linux/ip.h>
16
#include <net/route.h>
17
 
18
#include <linux/netfilter_ipv4/ipt_addrtype.h>
19
#include <linux/netfilter/x_tables.h>
20
 
21
MODULE_LICENSE("GPL");
22
MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
23
MODULE_DESCRIPTION("iptables addrtype match");
24
 
25
static inline bool match_type(__be32 addr, u_int16_t mask)
26
{
27
        return !!(mask & (1 << inet_addr_type(addr)));
28
}
29
 
30
static bool match(const struct sk_buff *skb,
31
                  const struct net_device *in, const struct net_device *out,
32
                  const struct xt_match *match, const void *matchinfo,
33
                  int offset, unsigned int protoff, bool *hotdrop)
34
{
35
        const struct ipt_addrtype_info *info = matchinfo;
36
        const struct iphdr *iph = ip_hdr(skb);
37
        bool ret = true;
38
 
39
        if (info->source)
40
                ret &= match_type(iph->saddr, info->source)^info->invert_source;
41
        if (info->dest)
42
                ret &= match_type(iph->daddr, info->dest)^info->invert_dest;
43
 
44
        return ret;
45
}
46
 
47
static struct xt_match addrtype_match __read_mostly = {
48
        .name           = "addrtype",
49
        .family         = AF_INET,
50
        .match          = match,
51
        .matchsize      = sizeof(struct ipt_addrtype_info),
52
        .me             = THIS_MODULE
53
};
54
 
55
static int __init ipt_addrtype_init(void)
56
{
57
        return xt_register_match(&addrtype_match);
58
}
59
 
60
static void __exit ipt_addrtype_fini(void)
61
{
62
        xt_unregister_match(&addrtype_match);
63
}
64
 
65
module_init(ipt_addrtype_init);
66
module_exit(ipt_addrtype_fini);

powered by: WebSVN 2.1.0

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