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>
13 #include <linux/netfilter_ipv6/ip6_tables.h>
14 #include <linux/netfilter_ipv6/ip6t_HL.h>
16 MODULE_AUTHOR("Maciej Soltysiak <solt@dns.toxicfilms.tv>");
17 MODULE_DESCRIPTION("IP tables Hop Limit modification module");
18 MODULE_LICENSE("GPL");
20 static unsigned int ip6t_hl_target(struct sk_buff
**pskb
,
21 const struct net_device
*in
,
22 const struct net_device
*out
,
24 const struct xt_target
*target
,
25 const void *targinfo
, void *userinfo
)
28 const struct ip6t_HL_info
*info
= targinfo
;
32 if (!skb_make_writable(pskb
, (*pskb
)->len
))
35 ip6h
= (*pskb
)->nh
.ipv6h
;
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 if (new_hl
!= ip6h
->hop_limit
) {
57 diffs
[0] = htons(((unsigned)ip6h
->hop_limit
) << 8) ^ 0xFFFF;
58 ip6h
->hop_limit
= new_hl
;
59 diffs
[1] = htons(((unsigned)ip6h
->hop_limit
) << 8);
65 static int ip6t_hl_checkentry(const char *tablename
,
67 const struct xt_target
*target
,
69 unsigned int targinfosize
,
70 unsigned int hook_mask
)
72 struct ip6t_HL_info
*info
= targinfo
;
74 if (info
->mode
> IP6T_HL_MAXMODE
) {
75 printk(KERN_WARNING
"ip6t_HL: invalid or unknown Mode %u\n",
79 if ((info
->mode
!= IP6T_HL_SET
) && (info
->hop_limit
== 0)) {
80 printk(KERN_WARNING
"ip6t_HL: increment/decrement doesn't "
81 "make sense with value 0\n");
87 static struct ip6t_target ip6t_HL
= {
89 .target
= ip6t_hl_target
,
90 .targetsize
= sizeof(struct ip6t_HL_info
),
92 .checkentry
= ip6t_hl_checkentry
,
96 static int __init
init(void)
98 return ip6t_register_target(&ip6t_HL
);
101 static void __exit
fini(void)
103 ip6t_unregister_target(&ip6t_HL
);
This page took 0.068712 seconds and 5 git commands to generate.