summaryrefslogtreecommitdiff
path: root/gsupplicant/supplicant.c
diff options
context:
space:
mode:
authorNiraj Kumar Goit <niraj.g@samsung.com>2018-01-04 14:48:49 +0530
committerSeonah Moon <seonah1.moon@samsung.com>2018-01-23 16:59:24 +0900
commit0e3dff67b594543b0488007bc913b3939ffe0fe6 (patch)
tree861e7b40e81acacf63951cc79cc7191893aec420 /gsupplicant/supplicant.c
parent1e0637575d1d1250baa8551dde46bb7bab02bc38 (diff)
downloadconnman-0e3dff67b594543b0488007bc913b3939ffe0fe6.tar.gz
connman-0e3dff67b594543b0488007bc913b3939ffe0fe6.tar.bz2
connman-0e3dff67b594543b0488007bc913b3939ffe0fe6.zip
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: Ifbb0159f40a8949a6f117416e5d436d5c2299b49
Diffstat (limited to 'gsupplicant/supplicant.c')
-rw-r--r--gsupplicant/supplicant.c82
1 files changed, 49 insertions, 33 deletions
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 28c95eae..724520e0 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -221,8 +221,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;
@@ -250,8 +249,7 @@ struct _GSupplicantNetwork {
char *identity;
char *phase2;
unsigned int keymgmt;
- char *wifi_vsie;
- unsigned int wifi_vsie_len;
+ GSList *vsie_list;
#endif
};
@@ -808,7 +806,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);
@@ -820,7 +818,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);
}
@@ -1558,16 +1556,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
@@ -1849,14 +1860,18 @@ static int 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.");
}
}
@@ -2047,9 +2062,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;
@@ -2081,16 +2093,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 ||