diff --git a/p4src/static-mapping.p4 b/p4src/static-mapping.p4 index 3567398..979f7f3 100644 --- a/p4src/static-mapping.p4 +++ b/p4src/static-mapping.p4 @@ -302,11 +302,19 @@ Echo or Echo Reply Message } action icmp_echo_reply() { - ipv4_addr_t tmp = hdr.ipv4.src_addr; + mac_addr_t mac_tmp = hdr.ethernet.dst_addr; + ipv4_addr_t ipv4_tmp = hdr.ipv4.src_addr; - hdr.icmp.type = ICMP_ECHO_REPLY; + /* swap ethernet addresses */ + hdr.ethernet.dst_addr = hdr.ethernet.src_addr; + hdr.ethernet.src_addr = mac_tmp; + + /* swap ipv4 addresses */ hdr.ipv4.src_addr = hdr.ipv4.dst_addr; - hdr.ipv4.dst_addr = tmp; + hdr.ipv4.dst_addr = ipv4_tmp; + + /* set correct type */ + hdr.icmp.type = ICMP_ECHO_REPLY; meta.chk_icmp = 1; }