if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
+ if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
*ip_address = __profile_convert_ip_to_string(&net_info->IpAddr6,
address_family);
- else
- *ip_address = __profile_convert_ip_to_string(&net_info->IpAddr,
- address_family);
+ } else {
+ if (net_get_preferred_ipv6_address(net_info->ProfileName, ip_address) != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get preferred ipv6 address");
+ *ip_address = __profile_convert_ip_to_string(&net_info->IpAddr,
+ address_family);
+ }
+ }
if (*ip_address == NULL)
return CONNECTION_ERROR_OUT_OF_MEMORY;