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.
12 #include <linux/module.h>
13 #include <linux/skbuff.h>
15 #include <linux/netfilter_ipv4/ipt_ttl.h>
16 #include <linux/netfilter_ipv4/ip_tables.h>
18 MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
19 MODULE_DESCRIPTION("IP tables TTL matching module");
20 MODULE_LICENSE("GPL");
22 static int match(const struct sk_buff *skb, const struct net_device *in,
23 const struct net_device *out, const void *matchinfo,
24 int offset, unsigned int protoff, int *hotdrop)
26 const struct ipt_ttl_info *info = matchinfo;
30 return (skb->nh.iph->ttl == info->ttl);
33 return (!(skb->nh.iph->ttl == info->ttl));
36 return (skb->nh.iph->ttl < info->ttl);
39 return (skb->nh.iph->ttl > info->ttl);
42 printk(KERN_WARNING "ipt_ttl: unknown mode %d\n",
50 static struct ipt_match ttl_match = {
53 .matchsize = sizeof(struct ipt_ttl_info),
57 static int __init init(void)
59 return ipt_register_match(&ttl_match);
62 static void __exit fini(void)
64 ipt_unregister_match(&ttl_match);