netfilter: xtables: move extension arguments into compound structure (4/6)
[linux-2.6/verdex.git] / net / ipv4 / netfilter / ipt_ttl.c
blob297f1cbf4ff547fc6124d819a92e33e8566d7971
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.
8 */
10 #include <linux/ip.h>
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;
26 switch (info->mode) {
27 case IPT_TTL_EQ:
28 return ttl == info->ttl;
29 case IPT_TTL_NE:
30 return ttl != info->ttl;
31 case IPT_TTL_LT:
32 return ttl < info->ttl;
33 case IPT_TTL_GT:
34 return ttl > info->ttl;
35 default:
36 printk(KERN_WARNING "ipt_ttl: unknown mode %d\n",
37 info->mode);
38 return false;
41 return false;
44 static struct xt_match ttl_mt_reg __read_mostly = {
45 .name = "ttl",
46 .family = NFPROTO_IPV4,
47 .match = ttl_mt,
48 .matchsize = sizeof(struct ipt_ttl_info),
49 .me = THIS_MODULE,
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);