Skip to content

Commit 3aeb851

Browse files
committed
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.
1 parent 69f3e81 commit 3aeb851

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

libraries/ESP8266WiFi/src/include/UdpContext.h

+6
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ class UdpContext
112112
{
113113
_pcb->remote_ip = addr;
114114
_pcb->remote_port = port;
115+
#if LWIP_IPV6
116+
// Set zone so that link local addresses use the default interface
117+
if (IP_IS_V6(&_pcb->remote_ip) && ip6_addr_lacks_zone(ip_2_ip6(&_pcb->remote_ip), IP6_UNKNOWN)) {
118+
ip6_addr_assign_zone(ip_2_ip6(&_pcb->remote_ip),IP6_UNKNOWN, netif_default);
119+
}
120+
#endif
115121
return true;
116122
}
117123

0 commit comments

Comments
 (0)