1 /* IP tables module for matching the value of the TTL
3 * ipt_ttl.c,v 1.5 2000/11/13 11:16:08 laforge Exp
5 * (C) 2000,2001 by Harald Welte <laforge@netfilter.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
13 #include <linux/module.h>
14 #include <linux/skbuff.h>
16 #include <linux/netfilter_ipv4/ipt_ttl.h>
17 #include <linux/netfilter/x_tables.h>
19 MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
20 MODULE_DESCRIPTION("IP tables TTL matching module");
21 MODULE_LICENSE("GPL");
23 static int match(const struct sk_buff *skb,
24 const struct net_device *in, const struct net_device *out,
25 const struct xt_match *match, const void *matchinfo,
26 int offset, unsigned int protoff, int *hotdrop)
28 const struct ipt_ttl_info *info = matchinfo;
32 return (skb->nh.iph->ttl == info->ttl);
35 return (!(skb->nh.iph->ttl == info->ttl));
38 return (skb->nh.iph->ttl < info->ttl);
41 return (skb->nh.iph->ttl > info->ttl);
44 printk(KERN_WARNING "ipt_ttl: unknown mode %d\n",
52 static struct xt_match ttl_match = {
56 .matchsize = sizeof(struct ipt_ttl_info),
60 static int __init ipt_ttl_init(void)
62 return xt_register_match(&ttl_match);
65 static void __exit ipt_ttl_fini(void)
67 xt_unregister_match(&ttl_match);
70 module_init(ipt_ttl_init);
71 module_exit(ipt_ttl_fini);