netfilter: xtables: move extension arguments into compound structure (1/6)
[deliverable/linux.git] / net / ipv6 / netfilter / ip6t_hl.c
CommitLineData
1da177e4
LT
1/* Hop Limit matching module */
2
3/* (C) 2001-2002 Maciej Soltysiak <solt@dns.toxicfilms.tv>
4 * Based on HW's ttl module
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
6709dbbb 11#include <linux/ipv6.h>
1da177e4
LT
12#include <linux/module.h>
13#include <linux/skbuff.h>
14
15#include <linux/netfilter_ipv6/ip6t_hl.h>
6709dbbb 16#include <linux/netfilter/x_tables.h>
1da177e4
LT
17
18MODULE_AUTHOR("Maciej Soltysiak <solt@dns.toxicfilms.tv>");
2ae15b64 19MODULE_DESCRIPTION("Xtables: IPv6 Hop Limit field match");
1da177e4
LT
20MODULE_LICENSE("GPL");
21
f7108a20 22static bool hl_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
1da177e4 23{
f7108a20 24 const struct ip6t_hl_info *info = par->matchinfo;
0660e03f 25 const struct ipv6hdr *ip6h = ipv6_hdr(skb);
1da177e4
LT
26
27 switch (info->mode) {
28 case IP6T_HL_EQ:
7c4e36bc 29 return ip6h->hop_limit == info->hop_limit;
1da177e4
LT
30 break;
31 case IP6T_HL_NE:
7c4e36bc 32 return ip6h->hop_limit != info->hop_limit;
1da177e4
LT
33 break;
34 case IP6T_HL_LT:
7c4e36bc 35 return ip6h->hop_limit < info->hop_limit;
1da177e4
LT
36 break;
37 case IP6T_HL_GT:
7c4e36bc 38 return ip6h->hop_limit > info->hop_limit;
1da177e4
LT
39 break;
40 default:
1ab1457c 41 printk(KERN_WARNING "ip6t_hl: unknown mode %d\n",
1da177e4 42 info->mode);
1d93a9cb 43 return false;
1da177e4
LT
44 }
45
1d93a9cb 46 return false;
1da177e4
LT
47}
48
d3c5ee6d 49static struct xt_match hl_mt6_reg __read_mostly = {
1da177e4 50 .name = "hl",
ee999d8b 51 .family = NFPROTO_IPV6,
d3c5ee6d 52 .match = hl_mt6,
7f939713 53 .matchsize = sizeof(struct ip6t_hl_info),
1da177e4
LT
54 .me = THIS_MODULE,
55};
56
d3c5ee6d 57static int __init hl_mt6_init(void)
1da177e4 58{
d3c5ee6d 59 return xt_register_match(&hl_mt6_reg);
1da177e4
LT
60}
61
d3c5ee6d 62static void __exit hl_mt6_exit(void)
1da177e4 63{
d3c5ee6d 64 xt_unregister_match(&hl_mt6_reg);
1da177e4
LT
65}
66
d3c5ee6d
JE
67module_init(hl_mt6_init);
68module_exit(hl_mt6_exit);
This page took 0.398399 seconds and 5 git commands to generate.