From 5320577817b6d8c2e3543a5b50c8fa8aec30e59a Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Fri, 17 Dec 2021 13:36:14 +0900 Subject: [PATCH] [Tizen] Add address type check logic (#13102) --- src/platform/Tizen/DnssdImpl.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/platform/Tizen/DnssdImpl.cpp b/src/platform/Tizen/DnssdImpl.cpp index 8792ce52d95c34..7eaaeb409e6f30 100644 --- a/src/platform/Tizen/DnssdImpl.cpp +++ b/src/platform/Tizen/DnssdImpl.cpp @@ -445,15 +445,17 @@ void OnResolve(dnssd_error_e result, dnssd_service_h service, void * data) // If both IPv4 and IPv6 are set, IPv6 address has higher priority. if (ipv6 != nullptr) { - validIP = chip::Inet::IPAddress::FromString(ipv6, ipStr); + validIP = (chip::Inet::IPAddress::FromString(ipv6, ipStr) && ipStr.Type() == chip::Inet::IPAddressType::kIPv6); } #if INET_CONFIG_ENABLE_IPV4 else if (ipv4 != nullptr) { - validIP = chip::Inet::IPAddress::FromString(ipv4, ipStr); + validIP = (chip::Inet::IPAddress::FromString(ipv4, ipStr) && ipStr.Type() == chip::Inet::IPAddressType::kIPv4); } #endif + ChipLogDetail(DeviceLayer, "Dnssd: %s ipv4: %s, ipv6: %s, valid: %d", __func__, ipv4, ipv6, validIP); + if (validIP) { mdnsService.mAddress.SetValue(ipStr);