2 * IPv6 Hop Limit Target module
3 * Maciej Soltysiak <solt@dns.toxicfilms.tv>
4 * Based on HW's ttl target
5 * This program is distributed under the terms of GNU GPL
9 #include <linux/netfilter_ipv6/ip6t_HL.h>
15 F_HL_SET = 1 << O_HL_SET,
16 F_HL_INC = 1 << O_HL_INC,
17 F_HL_DEC = 1 << O_HL_DEC,
18 F_ANY = F_HL_SET | F_HL_INC | F_HL_DEC,
21 #define s struct ip6t_HL_info
22 static const struct xt_option_entry HL_opts[] = {
23 {.name = "hl-set", .type = XTTYPE_UINT8, .id = O_HL_SET,
24 .excl = F_ANY, .flags = XTOPT_PUT, XTOPT_POINTER(s, hop_limit)},
25 {.name = "hl-dec", .type = XTTYPE_UINT8, .id = O_HL_DEC,
26 .excl = F_ANY, .flags = XTOPT_PUT, XTOPT_POINTER(s, hop_limit),
28 {.name = "hl-inc", .type = XTTYPE_UINT8, .id = O_HL_INC,
29 .excl = F_ANY, .flags = XTOPT_PUT, XTOPT_POINTER(s, hop_limit),
35 static void HL_help(void)
39 " --hl-set value Set HL to <value 0-255>\n"
40 " --hl-dec value Decrement HL by <value 1-255>\n"
41 " --hl-inc value Increment HL by <value 1-255>\n");
44 static void HL_parse(struct xt_option_call *cb)
46 struct ip6t_HL_info *info = cb->data;
48 xtables_option_parse(cb);
49 switch (cb->entry->id) {
51 info->mode = IP6T_HL_SET;
54 info->mode = IP6T_HL_INC;
57 info->mode = IP6T_HL_DEC;
62 static void HL_check(struct xt_fcheck_call *cb)
64 if (!(cb->xflags & F_ANY))
65 xtables_error(PARAMETER_PROBLEM,
66 "HL: You must specify an action");
69 static void HL_save(const void *ip, const struct xt_entry_target *target)
71 const struct ip6t_HL_info *info =
72 (struct ip6t_HL_info *) target->data;
86 printf(" %u", info->hop_limit);
89 static void HL_print(const void *ip, const struct xt_entry_target *target,
92 const struct ip6t_HL_info *info =
93 (struct ip6t_HL_info *) target->data;
101 printf("decrement by");
104 printf("increment by");
107 printf(" %u", info->hop_limit);
110 static struct xtables_target hl_tg6_reg = {
112 .version = XTABLES_VERSION,
113 .family = NFPROTO_IPV6,
114 .size = XT_ALIGN(sizeof(struct ip6t_HL_info)),
115 .userspacesize = XT_ALIGN(sizeof(struct ip6t_HL_info)),
119 .x6_parse = HL_parse,
120 .x6_fcheck = HL_check,
121 .x6_options = HL_opts,
126 xtables_register_target(&hl_tg6_reg);