From dce2054780e8142aebe5a7d11c4751040437f7ec Mon Sep 17 00:00:00 2001 From: Mayank Haarit Date: Wed, 18 Apr 2018 19:59:49 +0530 Subject: Added logic to get country code of APs It also includes parsing country code from IEs received from the supplicant Change-Id: Iea5f8b2ea7cc8fefe07591cc4d636d27b015d427 Signed-off-by: Mayank Haarit --- gsupplicant/gsupplicant.h | 2 ++ gsupplicant/supplicant.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'gsupplicant') diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h index ead619c4..0a28dbfb 100755 --- a/gsupplicant/gsupplicant.h +++ b/gsupplicant/gsupplicant.h @@ -397,6 +397,8 @@ 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); void *g_supplicant_network_get_wifi_vsie(GSupplicantNetwork *network); +const unsigned char *g_supplicant_network_get_countrycode(GSupplicantNetwork + *network); #endif struct _GSupplicantCallbacks { diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c index 92efbc9c..fbfa6c7f 100644 --- a/gsupplicant/supplicant.c +++ b/gsupplicant/supplicant.c @@ -44,6 +44,10 @@ #define IEEE80211_CAP_IBSS 0x0002 #define IEEE80211_CAP_PRIVACY 0x0010 +#if defined TIZEN_EXT +#define COUNTRY_CODE_LENGTH 2 +#endif + #define BSS_UNKNOWN_STRENGTH -90 static DBusConnection *connection; @@ -223,6 +227,7 @@ struct g_supplicant_bss { dbus_bool_t ft_ieee8021x; GSList *vsie_list; dbus_bool_t hs20; + unsigned char country_code[COUNTRY_CODE_LENGTH]; #endif unsigned int wps_capabilities; }; @@ -250,6 +255,7 @@ struct _GSupplicantNetwork { char *phase2; unsigned int keymgmt; GSList *vsie_list; + unsigned char country_code[COUNTRY_CODE_LENGTH]; #endif }; @@ -1408,6 +1414,15 @@ unsigned int g_supplicant_network_get_keymgmt(GSupplicantNetwork *network) return network->keymgmt; } + +const unsigned char *g_supplicant_network_get_countrycode(GSupplicantNetwork + *network) +{ + if (!network) + return NULL; + + return network->country_code; +} #endif const unsigned char *g_supplicant_peer_get_widi_ies(GSupplicantPeer *peer, @@ -1876,6 +1891,7 @@ static int add_or_replace_bss_to_network(struct g_supplicant_bss *bss) } network->isHS20AP = bss->hs20; + memcpy(network->country_code, bss->country_code, COUNTRY_CODE_LENGTH); #endif SUPPLICANT_DBG("New network %s created", network->name); @@ -2079,6 +2095,7 @@ static void bss_process_ies(DBusMessageIter *iter, void *user_data) #define WPS_CONFIGURED 0x02 #if defined TIZEN_EXT #define VENDOR_SPECIFIC_INFO 0xDD +#define WLAN_EID_COUNTRY 7 #endif dbus_message_iter_recurse(iter, &array); @@ -2089,6 +2106,7 @@ static void bss_process_ies(DBusMessageIter *iter, void *user_data) bss->wps_capabilities = 0; bss->keymgmt = 0; + memset(bss->country_code, 0, COUNTRY_CODE_LENGTH); for (ie_end = ie + ie_len; ie < ie_end && ie + ie[1] + 1 <= ie_end; ie += ie[1] + 2) { @@ -2108,6 +2126,11 @@ static void bss_process_ies(DBusMessageIter *iter, void *user_data) SUPPLICANT_DBG("Failed to allocate memory"); continue; } + + if(ie[0] == WLAN_EID_COUNTRY && ie[1] >= 2) { + memcpy(bss->country_code, ie+2, COUNTRY_CODE_LENGTH); + continue; + } #endif if (ie[0] != WMM_WPA1_WPS_INFO || ie[1] < WPS_INFO_MIN_LEN || memcmp(ie+2, WPS_OUI, sizeof(WPS_OUI)) != 0) -- cgit v1.2.3