From 86a37509e336f5475ffc226b4d25db89b545f968 Mon Sep 17 00:00:00 2001 From: Christian Giese Date: Thu, 13 Jan 2022 10:02:59 +0100 Subject: [PATCH] fix ICMPv6 echo response --- src/bbl_send.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/bbl_send.c b/src/bbl_send.c index be4811e4..9c0ca608 100644 --- a/src/bbl_send.c +++ b/src/bbl_send.c @@ -115,6 +115,14 @@ swap_ipv4_src_dst(bbl_ipv4_t *ipv4) ipv4->src = dst; } +static void +swap_ipv6_src_dst(bbl_ipv6_t *ipv6) +{ + uint8_t *dst = ipv6->dst; + ipv6->dst = ipv6->src; + ipv6->src = dst; +} + static void update_eth(bbl_interface_s *interface, bbl_session_s *session, @@ -198,12 +206,7 @@ bbl_send_icmpv6_echo_reply(bbl_interface_s *interface, bbl_icmpv6_t *icmpv6) { update_eth(interface, session, eth); - ipv6->dst = ipv6->src; - if(session) { - ipv6->src = session->ipv6_address; - } else { - ipv6->src = interface->ip6.address; - } + swap_ipv6_src_dst(ipv6); ipv6->ttl = 255; icmpv6->type = IPV6_ICMPV6_ECHO_REPLY; return bbl_send_to_buffer(interface, eth);