From bb883b65d867ad5bcdac9c4ae6479a0fadb067e2 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Tue, 16 Jul 2024 15:05:12 +0300 Subject: [PATCH 1/2] fix(lwip): Filter out V6 packets if V6 is not enabled the ESP might accept and act on some IPv6 packets, even though IPv6 is not enabled for the interface in Arduino. This change makes the ESP ignore all IPv6 packets if IPv6 address is not available. --- libraries/Network/src/NetworkInterface.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libraries/Network/src/NetworkInterface.cpp b/libraries/Network/src/NetworkInterface.cpp index d7813611b65..d8ba922fc85 100644 --- a/libraries/Network/src/NetworkInterface.cpp +++ b/libraries/Network/src/NetworkInterface.cpp @@ -11,6 +11,7 @@ #include "lwip/ip_addr.h" #include "lwip/err.h" #include "lwip/netif.h" +#include "lwip/dns.h" #include "dhcpserver/dhcpserver.h" #include "dhcpserver/dhcpserver_options.h" #include "esp32-hal-log.h" @@ -34,6 +35,17 @@ NetworkInterface *getNetifByID(Network_Interface_ID id) { return NULL; } +#if CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM +extern "C" int lwip_hook_ip6_input(struct pbuf *p, struct netif *inp) { + if (ip6_addr_isany_val(inp->ip6_addr[0].u_addr.ip6)) { + // We don't have an LL address -> eat this packet here, so it won't get accepted on input netif + pbuf_free(p); + return 1; + } + return 0; +} +#endif + static void _ip_event_cb(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) { if (event_base == IP_EVENT) { NetworkInterface *netif = NULL; From 45bc9b1f4d69df45385c5b5fc87e38ac49bdc7f6 Mon Sep 17 00:00:00 2001 From: Me No Dev Date: Tue, 16 Jul 2024 15:32:20 +0300 Subject: [PATCH 2/2] fix(lwip): DNS header is not required --- libraries/Network/src/NetworkInterface.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/Network/src/NetworkInterface.cpp b/libraries/Network/src/NetworkInterface.cpp index d8ba922fc85..4eb2ea03e94 100644 --- a/libraries/Network/src/NetworkInterface.cpp +++ b/libraries/Network/src/NetworkInterface.cpp @@ -11,7 +11,6 @@ #include "lwip/ip_addr.h" #include "lwip/err.h" #include "lwip/netif.h" -#include "lwip/dns.h" #include "dhcpserver/dhcpserver.h" #include "dhcpserver/dhcpserver_options.h" #include "esp32-hal-log.h"