socket-examples: IPv6 related update for examples to set correct scoped id

The scope id must be present when connecting to IPv6 Local Link
address.
This commit is contained in:
David Cermak
2020-02-04 16:38:23 +01:00
committed by bot
parent 286538e7af
commit 94ded5fb2f
4 changed files with 19 additions and 13 deletions

View File

@@ -54,10 +54,11 @@ static void tcp_client_task(void *pvParameters)
ip_protocol = IPPROTO_IP;
inet_ntoa_r(dest_addr.sin_addr, addr_str, sizeof(addr_str) - 1);
#else // IPV6
struct sockaddr_in6 dest_addr;
struct sockaddr_in6 dest_addr = { 0 };
inet6_aton(HOST_IP_ADDR, &dest_addr.sin6_addr);
dest_addr.sin6_family = AF_INET6;
dest_addr.sin6_port = htons(PORT);
dest_addr.sin6_scope_id = esp_netif_get_netif_impl_index(EXAMPLE_INTERFACE);
addr_family = AF_INET6;
ip_protocol = IPPROTO_IPV6;
inet6_ntoa_r(dest_addr.sin6_addr, addr_str, sizeof(addr_str) - 1);