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;
29 const u8 ttl = ip_hdr(skb)->ttl;
33 return (ttl == info->ttl);
36 return (!(ttl == info->ttl));
39 return (ttl < info->ttl);
42 return (ttl > info->ttl);
45 printk(KERN_WARNING "ipt_ttl: unknown mode %d\n",
53 static struct xt_match ttl_match = {
57 .matchsize = sizeof(struct ipt_ttl_info),
61 static int __init ipt_ttl_init(void)
63 return xt_register_match(&ttl_match);
66 static void __exit ipt_ttl_fini(void)
68 xt_unregister_match(&ttl_match);
71 module_init(ipt_ttl_init);
72 module_exit(ipt_ttl_fini);