]>
Commit | Line | Data |
---|---|---|
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 | |
18 | MODULE_AUTHOR("Maciej Soltysiak <solt@dns.toxicfilms.tv>"); | |
19 | MODULE_DESCRIPTION("IP tables Hop Limit matching module"); | |
20 | MODULE_LICENSE("GPL"); | |
21 | ||
1d93a9cb JE |
22 | static bool match(const struct sk_buff *skb, |
23 | const struct net_device *in, const struct net_device *out, | |
24 | const struct xt_match *match, const void *matchinfo, | |
25 | int offset, unsigned int protoff, bool *hotdrop) | |
1da177e4 LT |
26 | { |
27 | const struct ip6t_hl_info *info = matchinfo; | |
0660e03f | 28 | const struct ipv6hdr *ip6h = ipv6_hdr(skb); |
1da177e4 LT |
29 | |
30 | switch (info->mode) { | |
31 | case IP6T_HL_EQ: | |
7c4e36bc | 32 | return ip6h->hop_limit == info->hop_limit; |
1da177e4 LT |
33 | break; |
34 | case IP6T_HL_NE: | |
7c4e36bc | 35 | return ip6h->hop_limit != info->hop_limit; |
1da177e4 LT |
36 | break; |
37 | case IP6T_HL_LT: | |
7c4e36bc | 38 | return ip6h->hop_limit < info->hop_limit; |
1da177e4 LT |
39 | break; |
40 | case IP6T_HL_GT: | |
7c4e36bc | 41 | return ip6h->hop_limit > info->hop_limit; |
1da177e4 LT |
42 | break; |
43 | default: | |
1ab1457c | 44 | printk(KERN_WARNING "ip6t_hl: unknown mode %d\n", |
1da177e4 | 45 | info->mode); |
1d93a9cb | 46 | return false; |
1da177e4 LT |
47 | } |
48 | ||
1d93a9cb | 49 | return false; |
1da177e4 LT |
50 | } |
51 | ||
9f15c530 | 52 | static struct xt_match hl_match __read_mostly = { |
1da177e4 | 53 | .name = "hl", |
6709dbbb | 54 | .family = AF_INET6, |
7f939713 PM |
55 | .match = match, |
56 | .matchsize = sizeof(struct ip6t_hl_info), | |
1da177e4 LT |
57 | .me = THIS_MODULE, |
58 | }; | |
59 | ||
65b4b4e8 | 60 | static int __init ip6t_hl_init(void) |
1da177e4 | 61 | { |
6709dbbb | 62 | return xt_register_match(&hl_match); |
1da177e4 LT |
63 | } |
64 | ||
65b4b4e8 | 65 | static void __exit ip6t_hl_fini(void) |
1da177e4 | 66 | { |
6709dbbb | 67 | xt_unregister_match(&hl_match); |
1da177e4 LT |
68 | } |
69 | ||
65b4b4e8 AM |
70 | module_init(ip6t_hl_init); |
71 | module_exit(ip6t_hl_fini); |