Added support to display multiple IPv6 addresses 06/167806/1
authorAbhishek Sansanwal <abhishek.s94@samsung.com>
Mon, 22 Jan 2018 06:54:33 +0000 (12:24 +0530)
committerAbhishek Sansanwal <abhishek.s94@samsung.com>
Mon, 22 Jan 2018 06:55:34 +0000 (12:25 +0530)
Signed-off-by: Abhishek Sansanwal <abhishek.s94@samsung.com>
Change-Id: Id1b8b318be5cfd71e68ccac27a0d265d6ae2544e

sources/libraries/Common/common_ip_info.c

index 7caf4d9..1f9bfc1 100755 (executable)
@@ -847,6 +847,29 @@ static Elm_Object_Item* _add_description(Evas_Object* genlist, char* title,
        return det;
 }
 
+static bool __ap_foreach_ipv6_callback(char *ipv6_address, void *user_data)
+{
+       char **buf = NULL;
+       buf = user_data;
+       if (*buf == NULL) {
+               if (!(*buf = (char *)malloc(strlen(ipv6_address) + 1))) {
+                       ERROR_LOG(UG_NAME_ERR, "Failed to allocate memory");
+                       return false;
+               }
+               *buf[0] = '\0';
+               strncpy(*buf, ipv6_address, strlen(ipv6_address) + 1);
+       } else {
+               if (!(*buf = (char *)realloc(*buf, strlen(*buf) + strlen(ipv6_address) + 5))) {
+                       ERROR_LOG(UG_NAME_ERR, "Failed to realloc memory");
+                       return false;
+               }
+               strncat(*buf, "<br>", 5);
+               strncat(*buf, ipv6_address, strlen(ipv6_address) + 1);
+       }
+
+       return true;
+}
+
 static void __ip_info_toggle_item_sel_cb(void* data,
                Evas_Object* obj, void* event_info)
 {
@@ -900,7 +923,7 @@ static void __ip_info_toggle_item_sel_cb(void* data,
                _delete_static_ip_table(ip_info_list_data);
 
                wifi_manager_ap_get_ip_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &ip_addr);
-               wifi_manager_ap_get_ip_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV6, &ipv6_addr);
+               wifi_manager_ap_foreach_ipv6_address(ap, __ap_foreach_ipv6_callback, &ipv6_addr);
 
                /* Dynamic IP Address */
                ip_info_list_data->ip_addr_item = _add_description(
@@ -1204,7 +1227,7 @@ full_ip_info_t *ip_info_append_items(wifi_manager_ap_h ap, const char *pkg_name,
                _create_static_ip_table(ip_data);
        } else if (WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC == type) {
                wifi_manager_ap_get_ip_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &ip_addr);
-               wifi_manager_ap_get_ip_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV6, &ipv6_addr);
+               wifi_manager_ap_foreach_ipv6_address(ap, __ap_foreach_ipv6_callback, &ipv6_addr);
 
                prev_ip_info->ip_addr = g_strdup(ip_addr);