/* * NATv6: IPv6-to-IPv6 Network Prefix Translation as * proposed in RFC 6296. * Based on MAP66 (c) 2010 sven-ola()gmx.de * (c) 2011 mschiffer()universe-factory.net "I'm the one to blame for any problems with this version ;P" */ #include "libip6t_NPTV6.h" void NPTV6_help_note(void) { printf( "\n" "Note: you need two ip6tables rules to map an internal network\n" "using ULAs to/from external network with official IPv6 address.\n" "\n" "Example:\n" "\n" "ip6tables -t mangle -I PREROUTING -i eth0 -d 2001:0DB8:0001::/48 -j DNPTV6 --to-destination FD01:0203:0405::/48\n" "ip6tables -t mangle -I POSTROUTING -o eth0 -s FD01:0203:0405::/48 -j SNPTV6 --to-source 2001:0DB8:0001::/48\n"); } static void parse_to(const char *orig_arg, struct ip6t_nptv6_info *info) { char *arg, *slash; arg = strdup(orig_arg); if (arg == NULL) xtables_error(RESOURCE_PROBLEM, "strdup"); slash = strchr(arg, '/'); if (!slash) xtables_error(PARAMETER_PROBLEM, "No prefix length given\n"); info->nptv6_prefix_len = atoi(slash+1); if (info->nptv6_prefix_len <= 0 || info->nptv6_prefix_len > 64) xtables_error(PARAMETER_PROBLEM, "Prefix length `%s' not valid\n", slash+1); *slash = 0; info->nptv6_prefix = *xtables_numeric_to_ip6addr(arg); free(arg); } void NPTV6_parse(struct xt_option_call *cb) { struct ip6t_nptv6_info* info = (struct ip6t_nptv6_info*)cb->data; xtables_option_parse(cb); switch(cb->entry->id) { case 0: parse_to(cb->arg, info); break; } } void NPTV6_print(const void *ip, const struct xt_entry_target *target, int numeric) { const struct ip6t_nptv6_info* info = (struct ip6t_nptv6_info*)target->data; printf(" to: %s/%d", xtables_ip6addr_to_numeric(&info->nptv6_prefix), info->nptv6_prefix_len); }