From fbe8e66431264990b99873dcb5a5625cef2c0df3 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 2 Apr 2019 17:42:56 +0200 Subject: [PATCH] Make arp swapping more readable, --BUG --- p4src/static-mapping.p4 | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/p4src/static-mapping.p4 b/p4src/static-mapping.p4 index 9b5b267..55311f9 100644 --- a/p4src/static-mapping.p4 +++ b/p4src/static-mapping.p4 @@ -334,18 +334,25 @@ Echo or Echo Reply Message /********************** ARP ***********************************/ action arp_reply(mac_addr_t mac_addr) { - ipv4_addr_t tmp = hdr.arp.src_ipv4_addr; + /* swap */ + ipv4_addr_t ipv4_src = hdr.arp.dst_ipv4_addr; + ipv4_addr_t ipv4_dst = hdr.arp.src_ipv4_addr; + + /* swap/add */ + mac_addr_t mac_src = mac_addr; + mac_addr_t mac_dst = hdr.arp.src_mac_addr; /* fill the ethernet header */ - hdr.ethernet.src_addr = mac_addr; - hdr.ethernet.dst_addr = hdr.arp.src_mac_addr; + hdr.ethernet.dst_addr = mac_dst; + hdr.ethernet.src_addr = mac_src; /* fill the arp header */ - hdr.arp.dst_mac_addr = hdr.arp.src_mac_addr; - hdr.arp.dst_ipv4_addr = tmp; + hdr.arp.dst_mac_addr = mac_dst; + hdr.arp.src_mac_addr = mac_src; - hdr.arp.src_mac_addr = mac_addr; - hdr.arp.src_ipv4_addr = hdr.arp.dst_ipv4_addr; + /* swapping */ + hdr.arp.dst_ipv4_addr = ipv4_src; + hdr.arp.src_ipv4_addr = ipv4_dst; hdr.arp.opcode = ARP_REPLY; }