Fixed a bug that wrong IP information is used in comp_compare_ip_and_ifname()
authorsaerome.kim <saerome.kim@samsung.com>
Wed, 11 Apr 2018 11:35:17 +0000 (20:35 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:50 +0000 (19:38 +0900)
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
capi/src/companion.c
capi/src/companion_dbus.c
src/companion-manager/src/comp_util.c

index bc1c57b..e7a1d2c 100644 (file)
@@ -382,7 +382,7 @@ EXPORT_API int companion_device_get_found_devices(companion_h handle,
                while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
                        char *deviceid = NULL;
                        char *addr = NULL;
-                       int device_type = COMPANION_DEVICE_TYPE_REMOTE;
+                       int device_type = COMPANION_DEVICE_TYPE_ERROR;
                        int port;
                        int sec_port;
                        companion_device_s *device = NULL;
@@ -446,7 +446,7 @@ EXPORT_API int companion_device_get_found_mowned_devices(
                while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
                        char *deviceid = NULL;
                        char *addr = NULL;
-                       int device_type = COMPANION_DEVICE_TYPE_REMOTE;
+                       int device_type = COMPANION_DEVICE_TYPE_ERROR;
                        int port;
                        int sec_port;
                        companion_device_s *device = NULL;
@@ -503,7 +503,7 @@ EXPORT_API int companion_device_information_get_my_device(companion_h handle,
        GVariant *key_value = NULL;
        char *deviceid = NULL;
        char *addr = NULL;
-       int device_type = COMPANION_DEVICE_TYPE_REMOTE;
+       int device_type = COMPANION_DEVICE_TYPE_ERROR;
        int port = -1;
        int sec_port = -1;
 
index 0286cc4..28109d3 100644 (file)
@@ -106,7 +106,7 @@ static void __device_found_cb(Group *object, gint count, GVariant *va,
        while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
                char *device_id = NULL;
                char *ip = NULL;
-               int device_type = COMPANION_DEVICE_TYPE_REMOTE;
+               int device_type = COMPANION_DEVICE_TYPE_ERROR;
                int port = -1;
                int sec_port = -1;
 
@@ -162,7 +162,7 @@ static void __mowned_device_found_cb(Group *object, gint count, GVariant *va,
        while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
                char *device_id = NULL;
                char *ip = NULL;
-               int device_type = 0;
+               int device_type = COMPANION_DEVICE_TYPE_ERROR;
                int port = -1;
                int sec_port = -1;
 
index 491641c..7f756e0 100644 (file)
@@ -300,20 +300,18 @@ int comp_compare_ip_and_ifname(char *ipdata)
                iter = g_list_first(g_ip_info.ipv4_list);
                while (NULL != iter) {
                        ipv4info = iter->data;
-                       if (ipv4info && ipv4info->ip && !strncmp(ipv4info->ip, ip, INET_ADDRSTRLEN)) {
+                       if (ipv4info && ipv4info->ip && !strncmp(ipv4info->ip, ip, INET_ADDRSTRLEN))
                                return LOCAL_IP;
-                       }
                        iter = g_list_next(iter);
                }
        } else {
                /* In case IPv4 ip = fe80::7edd:90ff:feb1:1b57, ifname = wlan0 */
                ipv6_info_s *ipv6info = NULL;
-               iter = g_list_first(g_ip_info.ipv4_list);
+               iter = g_list_first(g_ip_info.ipv6_list);
                while (NULL != iter) {
                        ipv6info = iter->data;
-                       if (ipv6info && ipv6info->ip && !strncmp(ipv6info->ip, ip, INET6_ADDRSTRLEN)) {
+                       if (ipv6info && ipv6info->ip && !strncmp(ipv6info->ip, ip, INET6_ADDRSTRLEN))
                                return LOCAL_IP;
-                       }
                        iter = g_list_next(iter);
                }
        }