Skip to content

Commit bb883b6

Browse files
committed
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.
1 parent e850afb commit bb883b6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: libraries/Network/src/NetworkInterface.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "lwip/ip_addr.h"
1212
#include "lwip/err.h"
1313
#include "lwip/netif.h"
14+
#include "lwip/dns.h"
1415
#include "dhcpserver/dhcpserver.h"
1516
#include "dhcpserver/dhcpserver_options.h"
1617
#include "esp32-hal-log.h"
@@ -34,6 +35,17 @@ NetworkInterface *getNetifByID(Network_Interface_ID id) {
3435
return NULL;
3536
}
3637

38+
#if CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM
39+
extern "C" int lwip_hook_ip6_input(struct pbuf *p, struct netif *inp) {
40+
if (ip6_addr_isany_val(inp->ip6_addr[0].u_addr.ip6)) {
41+
// We don't have an LL address -> eat this packet here, so it won't get accepted on input netif
42+
pbuf_free(p);
43+
return 1;
44+
}
45+
return 0;
46+
}
47+
#endif
48+
3749
static void _ip_event_cb(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) {
3850
if (event_base == IP_EVENT) {
3951
NetworkInterface *netif = NULL;

0 commit comments

Comments
 (0)