diff --git a/components/mdns/examples/main/mdns_example_main.c b/components/mdns/examples/main/mdns_example_main.c index da0cbe53b..a3f2cb272 100644 --- a/components/mdns/examples/main/mdns_example_main.c +++ b/components/mdns/examples/main/mdns_example_main.c @@ -332,10 +332,15 @@ static void query_mdns_host_with_getaddrinfo(char * host) if (!getaddrinfo(host, NULL, &hints, &res)) { while (res) { - ESP_LOGI(TAG, "getaddrinfo: %s resolved to: %s", host, - res->ai_family == AF_INET? - inet_ntoa(((struct sockaddr_in *) res->ai_addr)->sin_addr): - inet_ntoa(((struct sockaddr_in6 *) res->ai_addr)->sin6_addr)); + char *resolved_addr; +#if CONFIG_LWIP_IPV6 + resolved_addr = res->ai_family == AF_INET ? + inet_ntoa(((struct sockaddr_in *) res->ai_addr)->sin_addr) : + inet_ntoa(((struct sockaddr_in6 *) res->ai_addr)->sin6_addr); +#else + resolved_addr = inet_ntoa(((struct sockaddr_in *) res->ai_addr)->sin_addr); +#endif // CONFIG_LWIP_IPV6 + ESP_LOGI(TAG, "getaddrinfo: %s resolved to: %s", host, resolved_addr); res = res->ai_next; } } diff --git a/components/mdns/examples/sdkconfig.ci.eth_no_ipv6 b/components/mdns/examples/sdkconfig.ci.eth_no_ipv6 index 42f26f6ba..d669ec075 100644 --- a/components/mdns/examples/sdkconfig.ci.eth_no_ipv6 +++ b/components/mdns/examples/sdkconfig.ci.eth_no_ipv6 @@ -4,6 +4,7 @@ CONFIG_MDNS_ADD_MAC_TO_HOSTNAME=y CONFIG_MDNS_PUBLISH_DELEGATE_HOST=y CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y CONFIG_LWIP_IPV6=n +CONFIG_EXAMPLE_CONNECT_IPV6=n CONFIG_EXAMPLE_CONNECT_ETHERNET=y CONFIG_EXAMPLE_CONNECT_WIFI=n CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y diff --git a/components/mdns/mdns_networking_lwip.c b/components/mdns/mdns_networking_lwip.c index f600ada25..dbbc11bb9 100644 --- a/components/mdns/mdns_networking_lwip.c +++ b/components/mdns/mdns_networking_lwip.c @@ -343,7 +343,7 @@ size_t _mdns_udp_pcb_write(mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol, c ip_add_copy.type = ip->type; memcpy(&(ip_add_copy.u_addr), &(ip->u_addr), sizeof(ip_add_copy.u_addr)); #else - memcpy(&(ip_add_copy.addr), &(ip->u_addr), sizeof(ip_addr_copy.addr)); + memcpy(&(ip_add_copy.addr), &(ip->u_addr), sizeof(ip_add_copy.addr)); #endif // CONFIG_LWIP_IPV6 mdns_api_call_t msg = {