1 /* IP tables module for matching the value of the TTL
3 * (C) 2000,2001 by Harald Welte <laforge@netfilter.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
11 #include <linux/module.h>
12 #include <linux/skbuff.h>
14 #include <linux/netfilter_ipv4/ipt_ttl.h>
15 #include <linux/netfilter/x_tables.h>
17 MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
18 MODULE_DESCRIPTION("Xtables: IPv4 TTL field match");
19 MODULE_LICENSE("GPL");
21 static bool ttl_mt(const struct sk_buff
*skb
, const struct xt_match_param
*par
)
23 const struct ipt_ttl_info
*info
= par
->matchinfo
;
24 const u8 ttl
= ip_hdr(skb
)->ttl
;
28 return ttl
== info
->ttl
;
30 return ttl
!= info
->ttl
;
32 return ttl
< info
->ttl
;
34 return ttl
> info
->ttl
;
36 printk(KERN_WARNING
"ipt_ttl: unknown mode %d\n",
44 static struct xt_match ttl_mt_reg __read_mostly
= {
46 .family
= NFPROTO_IPV4
,
48 .matchsize
= sizeof(struct ipt_ttl_info
),
52 static int __init
ttl_mt_init(void)
54 return xt_register_match(&ttl_mt_reg
);
57 static void __exit
ttl_mt_exit(void)
59 xt_unregister_match(&ttl_mt_reg
);
62 module_init(ttl_mt_init
);
63 module_exit(ttl_mt_exit
);