diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-11-10 09:29:22 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-11-12 09:25:24 +0100 |
commit | 86a5d1878d33a974289d61bcab5fc5d8d05c9c42 (patch) | |
tree | 09bffa0fa6944682aa4c77b128b19057ce248675 /libip6t_DNPTV6.c | |
parent | 0344f2ec310d317dc5f31e5c066a7a141d504333 (diff) | |
download | NPTv6-86a5d1878d33a974289d61bcab5fc5d8d05c9c42.tar NPTv6-86a5d1878d33a974289d61bcab5fc5d8d05c9c42.zip |
Add support for older kernel and iptables versions
Diffstat (limited to 'libip6t_DNPTV6.c')
-rw-r--r-- | libip6t_DNPTV6.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/libip6t_DNPTV6.c b/libip6t_DNPTV6.c index ad937ae..c12ca4d 100644 --- a/libip6t_DNPTV6.c +++ b/libip6t_DNPTV6.c @@ -16,15 +16,35 @@ static void DNPTV6_help(void) NPTV6_help_note(); } +static int DNPTV6_parse(int c, char **argv, int invert, unsigned int *flags, const void *entry, struct xt_entry_target **target) +{ + struct ip6t_nptv6_info* info = (struct ip6t_nptv6_info*)(*target)->data; + + switch(c) { + case 0: + if (!optarg) { + xtables_error(PARAMETER_PROBLEM, "--to-destination: No prefix given"); + } + if (invert) { + xtables_error(PARAMETER_PROBLEM, "Unexpected `!' after --to-destination"); + } + + NPTV6_parse_to(optarg, info); + return 1; + } + + return 0; +} + static void DNPTV6_save(const void *ip, const struct xt_entry_target *target) { const struct ip6t_nptv6_info* info = (struct ip6t_nptv6_info*)target->data; printf(" --to-destination %s/%d ", xtables_ip6addr_to_numeric(&info->nptv6_prefix), info->nptv6_prefix_len); } -static const struct xt_option_entry DNPTV6_opts[] = { - {.name = "to-destination", .id = 0, .type = XTTYPE_STRING, .flags = XTOPT_MAND}, - XTOPT_TABLEEND, +static const struct option DNPTV6_opts[] = { + {.name = "to-destination", .has_arg = required_argument, .flag = NULL, .val = 0}, + {.name = NULL}, }; static struct xtables_target DNPTV6_tg6_reg = { @@ -34,10 +54,10 @@ static struct xtables_target DNPTV6_tg6_reg = { .size = XT_ALIGN(sizeof(struct ip6t_nptv6_info)), .userspacesize = XT_ALIGN(sizeof(struct ip6t_nptv6_info)), .help = DNPTV6_help, - .x6_parse = NPTV6_parse, + .parse = DNPTV6_parse, .print = NPTV6_print, .save = DNPTV6_save, - .x6_options = DNPTV6_opts, + .extra_opts = DNPTV6_opts, }; void _init(void) |