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("Xtables: IPv6 Hop Limit field modification target");
19 MODULE_LICENSE("GPL");
22 hl_tg6(struct sk_buff *skb, const struct net_device *in,
23 const struct net_device *out, unsigned int hooknum,
24 const struct xt_target *target, const void *targinfo)
27 const struct ip6t_HL_info *info = targinfo;
30 if (!skb_make_writable(skb, skb->len))
37 new_hl = info->hop_limit;
40 new_hl = ip6h->hop_limit + info->hop_limit;
45 new_hl = ip6h->hop_limit - info->hop_limit;
50 new_hl = ip6h->hop_limit;
54 ip6h->hop_limit = new_hl;
60 hl_tg6_check(const char *tablename, const void *entry,
61 const struct xt_target *target, void *targinfo,
62 unsigned int hook_mask)
64 const struct ip6t_HL_info *info = targinfo;
66 if (info->mode > IP6T_HL_MAXMODE) {
67 printk(KERN_WARNING "ip6t_HL: invalid or unknown Mode %u\n",
71 if (info->mode != IP6T_HL_SET && info->hop_limit == 0) {
72 printk(KERN_WARNING "ip6t_HL: increment/decrement doesn't "
73 "make sense with value 0\n");
79 static struct xt_target hl_tg6_reg __read_mostly = {
83 .targetsize = sizeof(struct ip6t_HL_info),
85 .checkentry = hl_tg6_check,
89 static int __init hl_tg6_init(void)
91 return xt_register_target(&hl_tg6_reg);
94 static void __exit hl_tg6_exit(void)
96 xt_unregister_target(&hl_tg6_reg);
99 module_init(hl_tg6_init);
100 module_exit(hl_tg6_exit);