From 3210aec76f77e83630367d47b888db89baec44c4 Mon Sep 17 00:00:00 2001 From: Niraj Kumar Goit Date: Thu, 4 Jan 2018 14:48:49 +0530 Subject: Modified logic to process each VSIE of all vendors. Modified logic to process each VSIE of all vendors instead of only samsung vendor(OUI: 001632). Received VSIE will be appended in the list and shared with application. Change-Id: I11fee186c04677fdcd7746fcef7fd1dee4a0b02e Signed-off-by: Niraj Kumar Goit --- gsupplicant/gsupplicant.h | 3 +- gsupplicant/supplicant.c | 82 ++++++++++++++++++++++++++++------------------- 2 files changed, 50 insertions(+), 35 deletions(-) (limited to 'gsupplicant') diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h index 612ab5ae..123f3b2f 100755 --- a/gsupplicant/gsupplicant.h +++ b/gsupplicant/gsupplicant.h @@ -377,8 +377,7 @@ const char *g_supplicant_network_get_eap(GSupplicantNetwork *network); const char *g_supplicant_network_get_identity(GSupplicantNetwork *network); const char *g_supplicant_network_get_phase2(GSupplicantNetwork *network); unsigned int g_supplicant_network_get_keymgmt(GSupplicantNetwork *network); -const void *g_supplicant_network_get_wifi_vsie(GSupplicantNetwork *network, - unsigned int *wifi_vsie_len); +void *g_supplicant_network_get_wifi_vsie(GSupplicantNetwork *network); #endif struct _GSupplicantCallbacks { diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c index 9b7e003f..4bfa10e8 100755 --- a/gsupplicant/supplicant.c +++ b/gsupplicant/supplicant.c @@ -211,8 +211,7 @@ struct g_supplicant_bss { #if defined TIZEN_EXT dbus_bool_t ft_psk; dbus_bool_t ft_ieee8021x; - char *wifi_vsie; - unsigned int wifi_vsie_len; + GSList *vsie_list; dbus_bool_t hs20; #endif unsigned int wps_capabilities; @@ -240,8 +239,7 @@ struct _GSupplicantNetwork { char *identity; char *phase2; unsigned int keymgmt; - char *wifi_vsie; - unsigned int wifi_vsie_len; + GSList *vsie_list; #endif }; @@ -671,7 +669,7 @@ static void remove_network(gpointer data) g_free(network->phase2); #endif #if defined TIZEN_EXT - g_free(network->wifi_vsie); + g_slist_free_full(network->vsie_list, g_free); #endif g_free(network); @@ -683,7 +681,7 @@ static void remove_bss(gpointer data) g_free(bss->path); #if defined TIZEN_EXT - g_free(bss->wifi_vsie); + g_slist_free_full(bss->vsie_list, g_free); #endif g_free(bss); } @@ -1381,16 +1379,29 @@ bool g_supplicant_network_get_rsn_mode(GSupplicantNetwork *network) return false; } -const void *g_supplicant_network_get_wifi_vsie(GSupplicantNetwork *network, - unsigned int *wifi_vsie_len) +void *g_supplicant_network_get_wifi_vsie(GSupplicantNetwork *network) { - if (!network) { - *wifi_vsie_len = 0; + GSList *vsie_list = NULL; + + if (!network) return NULL; + + if (g_slist_length(network->vsie_list) > 0) { + GSList *list = NULL; + unsigned char *vsie = NULL; + for (list = network->vsie_list; list; list = list->next) { + unsigned char *ie = (unsigned char *)list->data; + vsie = (unsigned char *)g_try_malloc0(ie[1]+2); // tag number size(1), tag length size(1) + + if (vsie) { + memcpy(vsie, ie, ie[1]+2); + vsie_list = g_slist_append(vsie_list, vsie); + } else + SUPPLICANT_DBG("Failed to allocate memory"); + } } - *wifi_vsie_len = network->wifi_vsie_len; - return network->wifi_vsie; + return vsie_list; } #endif @@ -1687,14 +1698,18 @@ static void add_or_replace_bss_to_network(struct g_supplicant_bss *bss) #if defined TIZEN_EXT network->keymgmt = bss->keymgmt; - if (bss->wifi_vsie_len > 0) { - SUPPLICANT_DBG("vsie len: %d", bss->wifi_vsie_len); - network->wifi_vsie = (char *)g_try_malloc0(bss->wifi_vsie_len); - if(network->wifi_vsie) { - network->wifi_vsie_len = bss->wifi_vsie_len; - memcpy(network->wifi_vsie, bss->wifi_vsie, network->wifi_vsie_len); - } else { - SUPPLICANT_DBG("Failed to allocate memory for wifi_vsie"); + if (g_slist_length(bss->vsie_list) > 0) { + GSList *list = NULL; + unsigned char *vsie = NULL; + for (list = bss->vsie_list; list; list = list->next) { + unsigned char *ie = (unsigned char *)list->data; + vsie = (unsigned char *)g_try_malloc0(ie[1]+2); // tag number size(1), tag length size(1) + + if (vsie) { + memcpy(vsie, ie, ie[1]+2); + network->vsie_list = g_slist_append(network->vsie_list, vsie); + } else + SUPPLICANT_DBG("Failed to allocate memory."); } } @@ -1878,9 +1893,6 @@ static void bss_process_ies(DBusMessageIter *iter, void *user_data) { struct g_supplicant_bss *bss = user_data; const unsigned char WPS_OUI[] = { 0x00, 0x50, 0xf2, 0x04 }; -#if defined TIZEN_EXT - const unsigned char WIFI_OUI[] = {0x00, 0x16, 0x32}; -#endif unsigned char *ie, *ie_end; DBusMessageIter array; unsigned int value; @@ -1912,16 +1924,20 @@ static void bss_process_ies(DBusMessageIter *iter, void *user_data) for (ie_end = ie + ie_len; ie < ie_end && ie + ie[1] + 1 <= ie_end; ie += ie[1] + 2) { #if defined TIZEN_EXT - if((ie[0] == VENDOR_SPECIFIC_INFO) && (memcmp(ie+2, WIFI_OUI, sizeof(WIFI_OUI)) == 0)) { - SUPPLICANT_DBG("IE: match WIFI_OUI"); - bss->wifi_vsie = (char *)g_try_malloc0(ie[1] + 2); // tag number size(1), tag length size(1) - if (bss->wifi_vsie) { - bss->wifi_vsie_len = ie[1] + 2; - memcpy(bss->wifi_vsie, ie, bss->wifi_vsie_len); - } else { - SUPPLICANT_DBG("Failed to allocate memory for wifi_vsie"); - } - continue; + unsigned char *vsie; + int vsie_len = 0; + if(ie[0] == VENDOR_SPECIFIC_INFO && memcmp(ie+2, WPS_OUI, sizeof(WPS_OUI)) != 0) { + SUPPLICANT_DBG("IE: match vendor specific data"); + + vsie_len = ie[1]+2; // tag number size(1), tag length size(1) + vsie = (unsigned char *)g_try_malloc0(vsie_len); + + if (vsie) { + memcpy(vsie, ie, vsie_len); + bss->vsie_list = g_slist_append(bss->vsie_list, vsie); + } else + SUPPLICANT_DBG("Failed to allocate memory"); + continue; } #endif if (ie[0] != WMM_WPA1_WPS_INFO || ie[1] < WPS_INFO_MIN_LEN || -- cgit v1.2.3