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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * Hop Limit matching module
3
 * Maciej Soltysiak <solt@dns.toxicfilms.tv>
4
 * Based on HW's ttl module
5
 *
6
 * This software is distributed under the terms  GNU GPL
7
 */
8
 
9
#include <linux/module.h>
10
#include <linux/skbuff.h>
11
 
12
#include <linux/netfilter_ipv6/ip6t_hl.h>
13
#include <linux/netfilter_ipv6/ip6_tables.h>
14
 
15
MODULE_AUTHOR("Maciej Soltysiak <solt@dns.toxicfilms.tv>");
16
MODULE_DESCRIPTION("IP tables Hop Limit matching module");
17
MODULE_LICENSE("GPL");
18
 
19
static int match(const struct sk_buff *skb, const struct net_device *in,
20
                 const struct net_device *out, const void *matchinfo,
21
                 int offset, const void *hdr, u_int16_t datalen,
22
                 int *hotdrop)
23
{
24
        const struct ip6t_hl_info *info = matchinfo;
25
        const struct ipv6hdr *ip6h = skb->nh.ipv6h;
26
 
27
        switch (info->mode) {
28
                case IP6T_HL_EQ:
29
                        return (ip6h->hop_limit == info->hop_limit);
30
                        break;
31
                case IP6T_HL_NE:
32
                        return (!(ip6h->hop_limit == info->hop_limit));
33
                        break;
34
                case IP6T_HL_LT:
35
                        return (ip6h->hop_limit < info->hop_limit);
36
                        break;
37
                case IP6T_HL_GT:
38
                        return (ip6h->hop_limit > info->hop_limit);
39
                        break;
40
                default:
41
                        printk(KERN_WARNING "ip6t_hl: unknown mode %d\n",
42
                                info->mode);
43
                        return 0;
44
        }
45
 
46
        return 0;
47
}
48
 
49
static int checkentry(const char *tablename, const struct ip6t_ip6 *ip,
50
                      void *matchinfo, unsigned int matchsize,
51
                      unsigned int hook_mask)
52
{
53
        if (matchsize != IP6T_ALIGN(sizeof(struct ip6t_hl_info)))
54
                return 0;
55
 
56
        return 1;
57
}
58
 
59
static struct ip6t_match hl_match = { { NULL, NULL }, "hl", &match,
60
                &checkentry, NULL, THIS_MODULE };
61
 
62
static int __init init(void)
63
{
64
        return ip6t_register_match(&hl_match);
65
}
66
 
67
static void __exit fini(void)
68
{
69
        ip6t_unregister_match(&hl_match);
70
 
71
}
72
 
73
module_init(init);
74
module_exit(fini);

powered by: WebSVN 2.1.0

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