Bug fix: connection_profile_get_ip_address()
[platform/core/api/connection.git] / src / connection_profile.c
index 2779923..d5e3bd8 100755 (executable)
@@ -572,12 +572,16 @@ EXPORT_API int connection_profile_get_ip_address(connection_profile_h profile,
        if (net_info == NULL)
                return CONNECTION_ERROR_OPERATION_FAILED;
 
-       if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
-               *ip_address = __profile_convert_ip_to_string(&net_info->IpAddr6,
-                               address_family);
-       else
+       if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) {
                *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;