wifi-manager: To get vsie list of APs 60/179260/3
authorMayank Haarit <mayank.h@samsung.com>
Wed, 16 May 2018 16:04:10 +0000 (21:34 +0530)
committerMayank Haarit <mayank.h@samsung.com>
Thu, 17 May 2018 14:54:08 +0000 (20:24 +0530)
This patch add the funtionality :
1) To get the vsie list of APs during netlink scan results.
2) Added common function to clear internal GSList of net_profile_info_s.

Change-Id: Iac37300311cb8069a6b459107a9f8afd729ae250
Signed-off-by: Mayank Haarit <mayank.h@samsung.com>
include/network_interface.h
src/network_signal.c
src/wifi_ap.c
src/wifi_internal.c
test/wifi_manager_test.c

index ad86ba851763297aa6822c3cb535d2d86ae5bbc6..8acf82e955dfe954f1bff138d463772b743ac7fa 100755 (executable)
@@ -215,7 +215,7 @@ typedef struct {
 typedef struct {
        char ssid[NET_WLAN_ESSID_LEN + 1];
        char bssid[NET_WLAN_BSSID_LEN + 1];
-       char vsie[NET_WLAN_MAX_VSIE_LEN + 1];
+       GSList *vsie_list;
        int freq;
        int rssi;
        int security_type;
index b4c3faf762ce4ed88253bf729af280149d3bf600..2078a400f3041d8007352824cc5682df30ce0595 100755 (executable)
@@ -426,7 +426,7 @@ static int __net_handle_wifi_netlink_scan_rsp(GVariant *param)
        GSList *bss_info_list = NULL;
        const gchar *ssid = NULL;
        const gchar *bssid = NULL;
-       const gchar *vsie = NULL;
+       GSList *vsie_list = NULL;
        int freq = 0;
        int rssi = 0;
        int sec_type = 0;
@@ -460,8 +460,31 @@ static int __net_handle_wifi_netlink_scan_rsp(GVariant *param)
                } else if (g_strcmp0(key, "encryption") == 0) {
                        enc_type = g_variant_get_int32(value);
                        encryption_found = TRUE;
-               } else if (g_strcmp0(key, "vsie") == 0) {
-                       vsie = g_variant_get_string(value, NULL);
+               } else if (g_strcmp0(key, "vsie_list") == 0) {
+                       GVariantIter *iter_sub = NULL;
+                       const unsigned char *vsie_bytes = NULL;
+                       unsigned char *vsie = NULL;
+                       GVariant *value_sub;
+                       gchar *key_sub = NULL;
+                       gsize size;
+                       g_variant_get(value, "a{sv}", &iter_sub);
+                       vsie_list = NULL;
+
+                       while (g_variant_iter_loop(iter_sub, "{sv}", &key_sub, &value_sub)) {
+                               vsie_bytes = g_variant_get_fixed_array(value_sub, &size, sizeof(guchar));
+
+                               if (vsie_bytes) {
+                                       vsie = (unsigned char *)g_try_malloc0(size);
+
+                                       if (vsie) {
+                                               memcpy(vsie, vsie_bytes, size);
+                                               vsie_list = g_slist_append(vsie_list, vsie);
+                                       } else
+                                               WIFI_LOG(WIFI_ERROR, "Failed to allocate memory.");
+                               }
+                       }
+
+                       g_variant_iter_free(iter_sub);
                        vsie_found = TRUE;
                }
 
@@ -470,8 +493,20 @@ static int __net_handle_wifi_netlink_scan_rsp(GVariant *param)
                        freq_found == TRUE && rssi_found == TRUE && vsie_found == TRUE) {
                        net_netlink_scan_bss_info_s *bss = NULL;
                        bss = g_try_new0(net_netlink_scan_bss_info_s, 1);
+
                        if (bss == NULL) {
                                WIFI_LOG(WIFI_ERROR, "Memory allocation error");
+                               GSList *list_sub = bss_info_list;
+                               g_slist_free_full(vsie_list, g_free);
+
+                               for (list_sub = bss_info_list; list_sub; list_sub = list_sub->next) {
+                                       net_netlink_scan_bss_info_s *ap_sub = (net_netlink_scan_bss_info_s *)list_sub->data;
+
+                                       if (ap_sub->vsie_list) {
+                                               g_slist_free_full(ap_sub->vsie_list, g_free);
+                                               ap_sub->vsie_list = NULL;
+                                       }
+                               }
 
                                g_slist_free_full(bss_info_list, g_free);
                                g_variant_unref(value);
@@ -491,11 +526,7 @@ static int __net_handle_wifi_netlink_scan_rsp(GVariant *param)
                                        "Security type : %d, Encryption type: %d", bssid, freq, rssi, ssid,
                                        sec_type, enc_type);
 
-                       if (strncmp(vsie, "dd", 2) == 0) {
-                               WIFI_LOG(WIFI_INFO, "vsie: %s", vsie);
-                               g_strlcpy(bss->vsie, vsie, strlen(vsie)+1);
-                       }
-
+                       bss->vsie_list = vsie_list;
                        bss_info_list = g_slist_append(bss_info_list, bss);
 
                        ssid_found = bssid_found = freq_found = rssi_found = vsie_found = FALSE;
index 0761873c6f17f082ba0ecd9459469414889e6100..7aea86fdc293dbc980f5487287ada1d69b67ba9b 100755 (executable)
@@ -580,8 +580,6 @@ EXPORT_API int wifi_manager_ap_foreach_vsie(wifi_manager_ap_h ap,
                if (rv == false)
                        break;
        }
-       g_slist_free_full(profile_info->vsie_list, g_free);
-       profile_info->vsie_list = NULL;
 
        __NETWORK_CAPI_FUNC_EXIT__;
        return WIFI_MANAGER_ERROR_NONE;
@@ -1606,8 +1604,6 @@ EXPORT_API int wifi_manager_foreach_found_bssid(wifi_manager_ap_h ap,
                if (rv == false)
                        break;
        }
-       g_slist_free_full(profile_info->bssid_list, g_free);
-       profile_info->bssid_list = NULL;
 
        __NETWORK_CAPI_FUNC_EXIT__;
        return WIFI_MANAGER_ERROR_NONE;
index a1a07c269d088feb82273e7682744b12d4db7b57..85c0e94c41e9311079ff37f145659926b497b990 100755 (executable)
@@ -279,12 +279,33 @@ gchar *_wifi_eap_auth_type_to_string(wifi_manager_eap_auth_type_e eap_auth_type)
        }
        return type;
 }
+
+static void __clear_profile_internal_list(GSList **iterator)
+{
+       GSList *list;
+
+       for (list = *iterator; list; list = list->next) {
+               net_profile_info_s *prof_info = (net_profile_info_s *)list->data;
+
+               if (prof_info->vsie_list) {
+                       g_slist_free_full(prof_info->vsie_list, g_free);
+                       prof_info->vsie_list = NULL;
+               }
+
+               if (prof_info->bssid_list) {
+                       g_slist_free_full(prof_info->bssid_list, g_free);
+                       prof_info->bssid_list = NULL;
+               }
+       }
+}
+
 //LCOV_EXCL_STOP
 
 static void __clear_profile_list(GSList **iterator)
 {
        if (*iterator) {
                *iterator = g_slist_nth(*iterator, 0);
+               __clear_profile_internal_list(iterator);
                g_slist_free_full(*iterator, g_free);
                *iterator = NULL;
        }
@@ -408,6 +429,26 @@ static void __update_netlink_scan_profile_iterator(GSList *bss_list)
 
                g_strlcpy(profile->essid, ap->ssid, NET_WLAN_ESSID_LEN+1);
                g_strlcpy(profile->bssid, ap->bssid, NET_MAX_MAC_ADDR_LEN+1);
+
+               if (ap->vsie_list) {
+                       GSList *list;
+
+                       for (list = ap->vsie_list; list; list = list->next) {
+                               unsigned char *str = (unsigned char *)list->data;
+                               unsigned char *vsie;
+                               vsie = g_try_malloc0(str[1]+2);
+
+                               if (vsie) {
+                                       memcpy(vsie, str, str[1]+2);
+                                       profile->vsie_list = g_slist_append(profile->vsie_list, vsie);
+                               } else
+                                       WIFI_LOG(WIFI_ERROR, "Failed to allocate memory.");
+                       }
+
+                       g_slist_free_full(ap->vsie_list, g_free);
+                       ap->vsie_list = NULL;
+               }
+
                profile->frequency = (unsigned int)ap->freq;
                profile->Strength = 120 + ap->rssi;
 
index fdb42f84cb40ab4609cc9c15f797659353adc58a..0252d6ec496f8109e7f907be49069627a25efe6f 100755 (executable)
@@ -2682,6 +2682,9 @@ static bool __test_get_netlink_scan_list(wifi_manager_ap_h ap, void *user_data)
                break;
        }
 
+       if (wifi_manager_ap_foreach_vsie(ap, __test_vendor_specific_callback, NULL) != WIFI_MANAGER_ERROR_NONE)
+               printf("Fail to get vsie\n");
+
        g_free(bssid);
        g_free(essid);
        return true;