diff options
author | Mayank Haarit <mayank.h@samsung.com> | 2018-04-18 19:59:49 +0530 |
---|---|---|
committer | Mayank Haarit <mayank.h@samsung.com> | 2018-04-20 19:34:29 +0530 |
commit | dce2054780e8142aebe5a7d11c4751040437f7ec (patch) | |
tree | cbbe0c26f6956b267d8192e409e13c66b966505a /src | |
parent | f08451dc1450406af7f5db6d3cd2f49e1da33836 (diff) | |
download | connman-dce2054780e8142aebe5a7d11c4751040437f7ec.tar.gz connman-dce2054780e8142aebe5a7d11c4751040437f7ec.tar.bz2 connman-dce2054780e8142aebe5a7d11c4751040437f7ec.zip |
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 <mayank.h@samsung.com>
Diffstat (limited to 'src')
-rwxr-xr-x | src/connman.h | 3 | ||||
-rwxr-xr-x | src/network.c | 24 | ||||
-rwxr-xr-x | src/service.c | 10 |
3 files changed, 37 insertions, 0 deletions
diff --git a/src/connman.h b/src/connman.h index a5977b88..d1069b93 100755 --- a/src/connman.h +++ b/src/connman.h @@ -24,6 +24,9 @@ #include <glib.h> #define CONNMAN_API_SUBJECT_TO_CHANGE +#if defined TIZEN_EXT +#define WIFI_COUNTRY_CODE_LEN 2 +#endif #include <connman/dbus.h> diff --git a/src/network.c b/src/network.c index 0e3d4b34..eb2d0391 100755 --- a/src/network.c +++ b/src/network.c @@ -119,6 +119,7 @@ struct connman_network { * Only for EAP-FAST */ char *phase1; + unsigned char country_code[WIFI_COUNTRY_CODE_LEN]; #endif } wifi; @@ -2076,6 +2077,29 @@ int connman_network_get_assoc_status_code(struct connman_network *network) return network->wifi.assoc_status_code; } + +int connman_network_set_countrycode(struct connman_network *network, + const unsigned char *country_code) +{ + int i = 0; + + if (country_code == NULL) + return -EINVAL; + + DBG("network %p Country Code %02x:%02x",network, + country_code[0],country_code[1]); + + for (; i < WIFI_COUNTRY_CODE_LEN; i++) + network->wifi.country_code[i] = country_code[i]; + + return 0; +} + +unsigned char *connman_network_get_countrycode(struct connman_network *network) +{ + return (unsigned char *)network->wifi.country_code; +} + #endif int connman_network_set_nameservers(struct connman_network *network, diff --git a/src/service.c b/src/service.c index c3bdc0e5..b533dcd0 100755 --- a/src/service.c +++ b/src/service.c @@ -3230,6 +3230,9 @@ static void append_wifi_ext_info(DBusMessageIter *dict, const char *enc_mode; const char *str; gboolean passpoint; + char country_code_buff[WIFI_COUNTRY_CODE_LEN + 1] = {0,}; + char *country_code_str = country_code_buff; + unsigned char *country_code; ssid = connman_network_get_blob(network, "WiFi.SSID", &ssid_len); bssid = connman_network_get_bssid(network); @@ -3238,11 +3241,16 @@ static void append_wifi_ext_info(DBusMessageIter *dict, enc_mode = connman_network_get_enc_mode(network); passpoint = connman_network_get_bool(network, "WiFi.HS20AP"); keymgmt = connman_network_get_keymgmt(network); + country_code = connman_network_get_countrycode(network); snprintf(bssid_str, WIFI_BSSID_STR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); + snprintf(country_code_str, (WIFI_COUNTRY_CODE_LEN + 1), "%c%c", + country_code[0], country_code[1]); + + connman_dbus_dict_append_fixed_array(dict, "SSID", DBUS_TYPE_BYTE, &ssid, ssid_len); connman_dbus_dict_append_basic(dict, "BSSID", @@ -3257,6 +3265,8 @@ static void append_wifi_ext_info(DBusMessageIter *dict, DBUS_TYPE_BOOLEAN, &passpoint); connman_dbus_dict_append_basic(dict, "Keymgmt", DBUS_TYPE_UINT32, &keymgmt); + connman_dbus_dict_append_basic(dict, "Country", DBUS_TYPE_STRING, + &country_code_str); str = connman_network_get_string(network, "WiFi.Security"); if (str != NULL && g_str_equal(str, "ieee8021x") == TRUE) { |