mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-11-04 06:11:06 +00:00 
			
		
		
		
	examples: Fix socket examples to uses IPv6 scoped addresses from tcpip_adapter API
This commit is contained in:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user