From e079f8ba981d7a6d1c69976f96bb1f4c2cf43acc Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Wed, 7 Sep 2022 09:41:32 +0530 Subject: [PATCH] mdns: fix IPV4 only build and also update CI configuration Earlier commit 48c157bc469d15c24d85eaaf0fd2bce004b87d45 had typo regarding variable name. This was not caught in CI because IPV6 was not really getting disabled due to an indirect dependency of `CONFIG_EXAMPLE_CONNECT_IPV6`. This commit fixes both the problems. --- components/mdns/examples/main/mdns_example_main.c | 13 +++++++++---- components/mdns/examples/sdkconfig.ci.eth_no_ipv6 | 1 + components/mdns/mdns_networking_lwip.c | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) 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 = {