From bc2eb7dad1555442589cd955e95e05c00e3fa382 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 3 Apr 2019 11:02:07 +0200 Subject: [PATCH] Change ethernet addresses, too --- p4src/static-mapping.p4 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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; }