Change ethernet addresses, too

This commit is contained in:
Nico Schottelius 2019-04-03 11:02:07 +02:00
parent 92faaa1852
commit bc2eb7dad1
1 changed files with 11 additions and 3 deletions

View File

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