diff --git a/src/bbl_rx.c b/src/bbl_rx.c index 293bfc47..0fe08b91 100644 --- a/src/bbl_rx.c +++ b/src/bbl_rx.c @@ -495,6 +495,8 @@ bbl_rx_icmpv6(bbl_ethernet_header_t *eth, bbl_ipv6_t *ipv6, bbl_interface_s *int } } else if(icmpv6->type == IPV6_ICMPV6_NEIGHBOR_SOLICITATION) { session->send_requests |= BBL_SEND_ICMPV6_NA; + } else if(icmpv6->type == IPV6_ICMPV6_ECHO_REQUEST) { + bbl_send_icmpv6_echo_reply(interface, session, eth, ipv6, icmpv6); } } @@ -1736,6 +1738,8 @@ bbl_rx_network_icmpv6(bbl_ethernet_header_t *eth, bbl_interface_s *interface) { secondary_ip6 = secondary_ip6->next; } } + } else if(icmpv6->type == IPV6_ICMPV6_ECHO_REQUEST) { + bbl_send_icmpv6_echo_reply(interface, NULL, eth, ipv6, icmpv6); } } diff --git a/src/bbl_send.c b/src/bbl_send.c index 10f213dc..fe741f9d 100644 --- a/src/bbl_send.c +++ b/src/bbl_send.c @@ -188,4 +188,23 @@ bbl_send_icmp_reply(bbl_interface_s *interface, ipv4->ttl = 64; icmp->type = ICMP_TYPE_ECHO_REPLY; return bbl_send_to_buffer(interface, eth); +} + +bbl_send_result_t +bbl_send_icmpv6_echo_reply(bbl_interface_s *interface, + bbl_session_s *session, + bbl_ethernet_header_t *eth, + bbl_ipv6_t *ipv6, + 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; + } + ipv6->ttl = 255; + icmpv6->type = IPV6_ICMPV6_ECHO_REPLY; + return bbl_send_to_buffer(interface, eth); } \ No newline at end of file diff --git a/src/bbl_send.h b/src/bbl_send.h index a243f246..1f637170 100644 --- a/src/bbl_send.h +++ b/src/bbl_send.h @@ -62,4 +62,11 @@ bbl_send_icmp_reply(bbl_interface_s *interface, bbl_ipv4_t *ipv4, bbl_icmp_t *icmp); +bbl_send_result_t +bbl_send_icmpv6_echo_reply(bbl_interface_s *interface, + bbl_session_s *session, + bbl_ethernet_header_t *eth, + bbl_ipv6_t *ipv6, + bbl_icmpv6_t *icmpv6); + #endif \ No newline at end of file