Skip to content

Commit ee619d3

Browse files
authored
Fix UDP send to IPv6 link local addresses (#6541)
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 5511180 commit ee619d3

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
@@ -114,6 +114,12 @@ class UdpContext
114114
{
115115
_pcb->remote_ip = addr;
116116
_pcb->remote_port = port;
117+
#if LWIP_IPV6
118+
// Set zone so that link local addresses use the default interface
119+
if (IP_IS_V6(&_pcb->remote_ip) && ip6_addr_lacks_zone(ip_2_ip6(&_pcb->remote_ip), IP6_UNKNOWN)) {
120+
ip6_addr_assign_zone(ip_2_ip6(&_pcb->remote_ip),IP6_UNKNOWN, netif_default);
121+
}
122+
#endif
117123
return true;
118124
}
119125

0 commit comments

Comments
 (0)