From 3aeb851ea781645a6c3ee7f34f06892db315dbc6 Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Fri, 20 Sep 2019 21:29:44 +0100 Subject: [PATCH] Fix UDP send to IPv6 link local addresses lwIP's tcp/udp_connect() and tcp/udp_bind() functions automatically set the zone if it is required but missing, but udp_connect() is not used so this doesn't happen. Explicitly set the zone to the default network interface if it is required for the type of address being used. Otherwise there is no zone set and packets to a link local destination don't go anywhere. --- libraries/ESP8266WiFi/src/include/UdpContext.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/ESP8266WiFi/src/include/UdpContext.h b/libraries/ESP8266WiFi/src/include/UdpContext.h index 8ad074eeec..e11efdd5ae 100644 --- a/libraries/ESP8266WiFi/src/include/UdpContext.h +++ b/libraries/ESP8266WiFi/src/include/UdpContext.h @@ -112,6 +112,12 @@ class UdpContext { _pcb->remote_ip = addr; _pcb->remote_port = port; +#if LWIP_IPV6 + // Set zone so that link local addresses use the default interface + if (IP_IS_V6(&_pcb->remote_ip) && ip6_addr_lacks_zone(ip_2_ip6(&_pcb->remote_ip), IP6_UNKNOWN)) { + ip6_addr_assign_zone(ip_2_ip6(&_pcb->remote_ip),IP6_UNKNOWN, netif_default); + } +#endif return true; }