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("IP tables TTL matching module");
19 MODULE_LICENSE("GPL");
21 static bool match(const struct sk_buff *skb,
22 const struct net_device *in, const struct net_device *out,
23 const struct xt_match *match, const void *matchinfo,
24 int offset, unsigned int protoff, bool *hotdrop)
26 const struct ipt_ttl_info *info = matchinfo;
27 const u8 ttl = ip_hdr(skb)->ttl;
31 return ttl == info->ttl;
33 return ttl != info->ttl;
35 return ttl < info->ttl;
37 return ttl > info->ttl;
39 printk(KERN_WARNING "ipt_ttl: unknown mode %d\n",
47 static struct xt_match ttl_match __read_mostly = {
51 .matchsize = sizeof(struct ipt_ttl_info),
55 static int __init ipt_ttl_init(void)
57 return xt_register_match(&ttl_match);
60 static void __exit ipt_ttl_fini(void)
62 xt_unregister_match(&ttl_match);
65 module_init(ipt_ttl_init);
66 module_exit(ipt_ttl_fini);