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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [net/] [ipv4/] [netfilter/] [ipt_ttl.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 TTL
2
 *
3
 * ipt_ttl.c,v 1.5 2000/11/13 11:16:08 laforge Exp
4
 *
5
 * (C) 2000,2001 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_ttl.h>
14
#include <linux/netfilter_ipv4/ip_tables.h>
15
 
16
MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
17
MODULE_DESCRIPTION("IP tables TTL 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_ttl_info *info = matchinfo;
26
        const struct iphdr *iph = skb->nh.iph;
27
 
28
        switch (info->mode) {
29
                case IPT_TTL_EQ:
30
                        return (iph->ttl == info->ttl);
31
                        break;
32
                case IPT_TTL_NE:
33
                        return (!(iph->ttl == info->ttl));
34
                        break;
35
                case IPT_TTL_LT:
36
                        return (iph->ttl < info->ttl);
37
                        break;
38
                case IPT_TTL_GT:
39
                        return (iph->ttl > info->ttl);
40
                        break;
41
                default:
42
                        printk(KERN_WARNING "ipt_ttl: unknown mode %d\n",
43
                                info->mode);
44
                        return 0;
45
        }
46
 
47
        return 0;
48
}
49
 
50
static int checkentry(const char *tablename, const struct ipt_ip *ip,
51
                      void *matchinfo, unsigned int matchsize,
52
                      unsigned int hook_mask)
53
{
54
        if (matchsize != IPT_ALIGN(sizeof(struct ipt_ttl_info)))
55
                return 0;
56
 
57
        return 1;
58
}
59
 
60
static struct ipt_match ttl_match = { { NULL, NULL }, "ttl", &match,
61
                &checkentry, NULL, THIS_MODULE };
62
 
63
static int __init init(void)
64
{
65
        return ipt_register_match(&ttl_match);
66
}
67
 
68
static void __exit fini(void)
69
{
70
        ipt_unregister_match(&ttl_match);
71
 
72
}
73
 
74
module_init(init);
75
module_exit(fini);

powered by: WebSVN 2.1.0

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