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; }