2 * Hop Limit modification target for ip6tables
3 * Maciej Soltysiak <solt@dns.toxicfilms.tv>
4 * Based on HW's TTL module
6 * This software is distributed under the terms of GNU GPL
9 #include <linux/module.h>
10 #include <linux/skbuff.h>
12 #include <linux/ipv6.h>
14 #include <linux/netfilter/x_tables.h>
15 #include <linux/netfilter_ipv6/ip6t_HL.h>
17 MODULE_AUTHOR("Maciej Soltysiak <solt@dns.toxicfilms.tv>");
18 MODULE_DESCRIPTION("IP6 tables Hop Limit modification module");
19 MODULE_LICENSE("GPL");
21 static unsigned int ip6t_hl_target(struct sk_buff **pskb,
22 const struct net_device *in,
23 const struct net_device *out,
25 const struct xt_target *target,
29 const struct ip6t_HL_info *info = targinfo;
32 if (!skb_make_writable(*pskb, (*pskb)->len))
35 ip6h = ipv6_hdr(*pskb);
39 new_hl = info->hop_limit;
42 new_hl = ip6h->hop_limit + info->hop_limit;
47 new_hl = ip6h->hop_limit - info->hop_limit;
52 new_hl = ip6h->hop_limit;
56 ip6h->hop_limit = new_hl;
61 static bool ip6t_hl_checkentry(const char *tablename,
63 const struct xt_target *target,
65 unsigned int hook_mask)
67 const struct ip6t_HL_info *info = targinfo;
69 if (info->mode > IP6T_HL_MAXMODE) {
70 printk(KERN_WARNING "ip6t_HL: invalid or unknown Mode %u\n",
74 if (info->mode != IP6T_HL_SET && info->hop_limit == 0) {
75 printk(KERN_WARNING "ip6t_HL: increment/decrement doesn't "
76 "make sense with value 0\n");
82 static struct xt_target ip6t_HL __read_mostly = {
85 .target = ip6t_hl_target,
86 .targetsize = sizeof(struct ip6t_HL_info),
88 .checkentry = ip6t_hl_checkentry,
92 static int __init ip6t_hl_init(void)
94 return xt_register_target(&ip6t_HL);
97 static void __exit ip6t_hl_fini(void)
99 xt_unregister_target(&ip6t_HL);
102 module_init(ip6t_hl_init);
103 module_exit(ip6t_hl_fini);