diff --git a/p4src/static-mapping.p4 b/p4src/static-mapping.p4 index d0bfae8..6f2a259 100644 --- a/p4src/static-mapping.p4 +++ b/p4src/static-mapping.p4 @@ -98,6 +98,16 @@ control MyIngress(inout headers hdr, hdr.ipv6.setInvalid(); } + /* nat64_prefix is the same as the matching key, but without the mask */ + action nat64_static(ipv6_addr_t v6_src, ipv4_addr_t v4_dst, ipv6_addr_t nat64_prefix) { + ipv6_addr_t src_offset = hdr.ipv6.src_addr - v6_src; + ipv4_addr_t src = v4_dst + (ipv4_addr_t) src_offset; + + ipv4_addr_t dst = (ipv4_addr_t) (hdr.ipv6.dst_addr - nat64_prefix); + + nat64_generic(src, dst); + } + /* if replacing actions */ action nat64_icmp6_echo_request(ipv6_addr_t v6_src, ipv4_addr_t v4_dst, ipv6_addr_t nat64_prefix) { nat64_static(v6_src, v4_dst, nat64_prefix); @@ -113,8 +123,6 @@ control MyIngress(inout headers hdr, hdr.icmp.type = ICMP_ECHO_REPLY; } - - /* NAT46: protocol unspecific changes */ action nat46_generic(ipv6_addr_t src, ipv6_addr_t dst) { hdr.ipv6.setValid(); @@ -135,15 +143,6 @@ control MyIngress(inout headers hdr, } - /* nat64_prefix is the same as the matching key, but without the mask */ - action nat64_static(ipv6_addr_t v6_src, ipv4_addr_t v4_dst, ipv6_addr_t nat64_prefix) { - ipv6_addr_t src_offset = hdr.ipv6.src_addr - v6_src; - ipv4_addr_t src = v4_dst + (ipv4_addr_t) src_offset; - - ipv4_addr_t dst = (ipv4_addr_t) (hdr.ipv6.dst_addr - nat64_prefix); - - nat64_generic(src, dst); - } action nat46_icmp_echo_request(ipv6_addr_t v6_src, ipv4_addr_t v4_dst, ipv6_addr_t nat64_prefix) { ; /* TBD */