Make arp swapping more readable, --BUG
This commit is contained in:
parent
ec55663cfc
commit
fbe8e66431
1 changed files with 14 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue