1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Fix TCP send to IPv6 link local addresses (#7207)

credit: Simon Arlott @nomis - similar to #6541 for TCP (#7207)
This commit is contained in:
david gauchard 2020-04-11 12:46:07 +02:00 committed by GitHub
parent ee619d367f
commit 4f27ce16b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -127,8 +127,14 @@ public:
} }
} }
int connect(CONST ip_addr_t* addr, uint16_t port) int connect(ip_addr_t* addr, uint16_t port)
{ {
#if LWIP_IPV6
// Set zone so that link local addresses use the default interface
if (IP_IS_V6(addr) && ip6_addr_lacks_zone(ip_2_ip6(addr), IP6_UNKNOWN)) {
ip6_addr_assign_zone(ip_2_ip6(addr), IP6_UNKNOWN, netif_default);
}
#endif
err_t err = tcp_connect(_pcb, addr, port, &ClientContext::_s_connected); err_t err = tcp_connect(_pcb, addr, port, &ClientContext::_s_connected);
if (err != ERR_OK) { if (err != ERR_OK) {
return 0; return 0;

View File

@ -117,7 +117,7 @@ public:
#if LWIP_IPV6 #if LWIP_IPV6
// Set zone so that link local addresses use the default interface // 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)) { 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); ip6_addr_assign_zone(ip_2_ip6(&_pcb->remote_ip), IP6_UNKNOWN, netif_default);
} }
#endif #endif
return true; return true;