From b3acb79484337400dd7cca9dcf56f72e7749e817 Mon Sep 17 00:00:00 2001 From: Abhishek Sansanwal Date: Mon, 22 Jan 2018 12:24:33 +0530 Subject: [PATCH] Added support to display multiple IPv6 addresses Signed-off-by: Abhishek Sansanwal Change-Id: Id1b8b318be5cfd71e68ccac27a0d265d6ae2544e --- sources/libraries/Common/common_ip_info.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/sources/libraries/Common/common_ip_info.c b/sources/libraries/Common/common_ip_info.c index 7caf4d9..1f9bfc1 100755 --- a/sources/libraries/Common/common_ip_info.c +++ b/sources/libraries/Common/common_ip_info.c @@ -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, "
", 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); -- 2.7.4