examples: Fix socket examples to uses IPv6 scoped addresses from tcpip_adapter API

This commit is contained in:
David Cermak 2020-09-29 16:14:25 +02:00 committed by bot
parent d4499598e4
commit def1304b4a
2 changed files with 14 additions and 2 deletions

View File

@ -31,6 +31,12 @@
#define HOST_IP_ADDR CONFIG_EXAMPLE_IPV6_ADDR
#endif
#ifdef CONFIG_EXAMPLE_CONNECT_ETHERNET
#define EXAMPLE_INTERFACE TCPIP_ADAPTER_IF_ETH
#elif CONFIG_EXAMPLE_CONNECT_WIFI
#define EXAMPLE_INTERFACE TCPIP_ADAPTER_IF_STA
#endif
#define PORT CONFIG_EXAMPLE_PORT
static const char *TAG = "example";
@ -59,7 +65,7 @@ static void tcp_client_task(void *pvParameters)
dest_addr.sin6_family = AF_INET6;
dest_addr.sin6_port = htons(PORT);
// Setting scope_id to the connecting interface for correct routing if IPv6 Local Link supplied
dest_addr.sin6_scope_id = esp_netif_get_netif_impl_index(EXAMPLE_INTERFACE);
dest_addr.sin6_scope_id = tcpip_adapter_get_netif_index(EXAMPLE_INTERFACE);
addr_family = AF_INET6;
ip_protocol = IPPROTO_IPV6;
inet6_ntoa_r(dest_addr.sin6_addr, addr_str, sizeof(addr_str) - 1);

View File

@ -31,6 +31,12 @@
#define HOST_IP_ADDR CONFIG_EXAMPLE_IPV6_ADDR
#endif
#ifdef CONFIG_EXAMPLE_CONNECT_ETHERNET
#define EXAMPLE_INTERFACE TCPIP_ADAPTER_IF_ETH
#elif CONFIG_EXAMPLE_CONNECT_WIFI
#define EXAMPLE_INTERFACE TCPIP_ADAPTER_IF_STA
#endif
#define PORT CONFIG_EXAMPLE_PORT
static const char *TAG = "example";
@ -60,7 +66,7 @@ static void udp_client_task(void *pvParameters)
dest_addr.sin6_family = AF_INET6;
dest_addr.sin6_port = htons(PORT);
// Setting scope_id to the connecting interface for correct routing if IPv6 Local Link supplied
dest_addr.sin6_scope_id = esp_netif_get_netif_impl_index(EXAMPLE_INTERFACE);
dest_addr.sin6_scope_id = tcpip_adapter_get_netif_index(EXAMPLE_INTERFACE);
addr_family = AF_INET6;
ip_protocol = IPPROTO_IPV6;
inet6_ntoa_r(dest_addr.sin6_addr, addr_str, sizeof(addr_str) - 1);