Reordering actions...

This commit is contained in:
Nico Schottelius 2019-03-27 20:15:31 +01:00
parent b87b7b72f6
commit 432965eb4f

View file

@ -98,6 +98,16 @@ control MyIngress(inout headers hdr,
hdr.ipv6.setInvalid(); 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 */ /* if replacing actions */
action nat64_icmp6_echo_request(ipv6_addr_t v6_src, ipv4_addr_t v4_dst, ipv6_addr_t nat64_prefix) { 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); nat64_static(v6_src, v4_dst, nat64_prefix);
@ -113,8 +123,6 @@ control MyIngress(inout headers hdr,
hdr.icmp.type = ICMP_ECHO_REPLY; hdr.icmp.type = ICMP_ECHO_REPLY;
} }
/* NAT46: protocol unspecific changes */ /* NAT46: protocol unspecific changes */
action nat46_generic(ipv6_addr_t src, ipv6_addr_t dst) { action nat46_generic(ipv6_addr_t src, ipv6_addr_t dst) {
hdr.ipv6.setValid(); 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) { action nat46_icmp_echo_request(ipv6_addr_t v6_src, ipv4_addr_t v4_dst, ipv6_addr_t nat64_prefix) {
; /* TBD */ ; /* TBD */