diff --git a/p4src/actions_egress.p4 b/p4src/actions_egress.p4 index 7b3301d..4d1bf92 100644 --- a/p4src/actions_egress.p4 +++ b/p4src/actions_egress.p4 @@ -87,6 +87,7 @@ table v4_networks { set_egress_port; set_egress_port_and_mac; controller_debug; + controller_reply; controller_debug_table_id; NoAction; } diff --git a/p4src/minip4_solution.p4 b/p4src/minip4_solution.p4 index 9f47072..3ff4c12 100644 --- a/p4src/minip4_solution.p4 +++ b/p4src/minip4_solution.p4 @@ -105,60 +105,10 @@ control RealMain( apply { bit<17> tmp17 = 0; - bool apply_v4networks = false; - bool apply_v6networks = false; + bool apply_v4networks = true; + bool apply_v6networks = true; - if(hdr.ipv6.isValid()) { - apply_v6networks = true; - - if(nat64.apply().hit) { /* generic / static nat64 done */ - if(hdr.icmp6.isValid()) { - nat64_icmp6_generic(); - - if(hdr.icmp6.type == ICMP6_ECHO_REPLY) { - hdr.icmp.type = ICMP_ECHO_REPLY; - hdr.icmp.code = 0; - } - if(hdr.icmp6.type == ICMP6_ECHO_REQUEST) { - hdr.icmp.type = ICMP_ECHO_REQUEST; - hdr.icmp.code = 0; - } - } - - if(hdr.udp.isValid()) { - delta_udp_from_v6_to_v4 - } - - if(hdr.tcp.isValid()) { - delta_tcp_from_v6_to_v4 - } - apply_v4networks = false; - apply_v6networks = true; - } - } else if(hdr.ipv4.isValid()) { - apply_v4networks = true; - - if(nat46.apply().hit) { - if(hdr.icmp.isValid()) { - nat46_icmp_generic(); - - if(hdr.icmp.type == ICMP_ECHO_REPLY) { - hdr.icmp6.type = ICMP6_ECHO_REPLY; - } - if(hdr.icmp.type == ICMP_ECHO_REQUEST) { - hdr.icmp6.type = ICMP6_ECHO_REQUEST; - } - } - if(hdr.udp.isValid()) { - delta_udp_from_v4_to_v6 - } - if(hdr.tcp.isValid()) { - delta_tcp_from_v4_to_v6 - } - apply_v4networks = true; - apply_v6networks = false; - } - } + // #include "netpfga_nat64.p4" if(apply_v4networks == true) { v4_networks.apply(); @@ -167,8 +117,6 @@ control RealMain( if(apply_v6networks == true) { v6_networks.apply(); } - - lookup_table.apply(); } } diff --git a/p4src/netpfga_nat64.p4 b/p4src/netpfga_nat64.p4 new file mode 100644 index 0000000..34b3348 --- /dev/null +++ b/p4src/netpfga_nat64.p4 @@ -0,0 +1,61 @@ + if(hdr.ipv6.isValid()) { + apply_v6networks = true; + + if(nat64.apply().hit) { /* generic / static nat64 done */ + if(hdr.icmp6.isValid()) { + nat64_icmp6_generic(); + + if(hdr.icmp6.type == ICMP6_ECHO_REPLY) { + hdr.icmp.type = ICMP_ECHO_REPLY; + hdr.icmp.code = 0; + } + if(hdr.icmp6.type == ICMP6_ECHO_REQUEST) { + hdr.icmp.type = ICMP_ECHO_REQUEST; + hdr.icmp.code = 0; + } + } + + if(hdr.udp.isValid()) { + delta_udp_from_v6_to_v4 + } + + if(hdr.tcp.isValid()) { + delta_tcp_from_v6_to_v4 + } + apply_v4networks = false; + apply_v6networks = true; + } + } else if(hdr.ipv4.isValid()) { + apply_v4networks = true; + + if(nat46.apply().hit) { + if(hdr.icmp.isValid()) { + nat46_icmp_generic(); + + if(hdr.icmp.type == ICMP_ECHO_REPLY) { + hdr.icmp6.type = ICMP6_ECHO_REPLY; + } + if(hdr.icmp.type == ICMP_ECHO_REQUEST) { + hdr.icmp6.type = ICMP6_ECHO_REQUEST; + } + } + if(hdr.udp.isValid()) { + delta_udp_from_v4_to_v6 + } + if(hdr.tcp.isValid()) { + delta_tcp_from_v4_to_v6 + } + apply_v4networks = true; + apply_v6networks = false; + } + } + + if(apply_v4networks == true) { + v4_networks.apply(); + } + + if(apply_v6networks == true) { + v6_networks.apply(); + } + + lookup_table.apply();