master-thesis/p4src/netpfga_nat64.p4
2019-08-01 12:02:25 +02:00

62 lines
1.5 KiB
Text

bool apply_v6networks = false;
bool apply_v4networks = false;
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 = true;
apply_v6networks = false;
}
} 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 = false;
apply_v6networks = true;
}
}
if(apply_v4networks == true) {
v4_networks.apply();
}
if(apply_v6networks == true) {
v6_networks.apply();
}