wifi-manager: Implemented functionality to get AP's country code 52/176352/7
authorMayank Haarit <mayank.h@samsung.com>
Wed, 18 Apr 2018 15:17:44 +0000 (20:47 +0530)
committerMayank Haarit <mayank.h@samsung.com>
Thu, 19 Apr 2018 14:48:15 +0000 (20:18 +0530)
Change-Id: Id767e0b34753860f283f39bddffd84a2f45b698d
Signed-off-by: Mayank Haarit <mayank.h@samsung.com>
include/network_interface.h
include/network_wlan.h
src/network_interface.c
src/wifi_ap.c
test/wifi_manager_test.c

index 92f55a8..a0a3fd0 100755 (executable)
@@ -170,6 +170,7 @@ typedef struct {
        int raw_ssid_len;                                                               /** Raw SSID length */
        GSList *vsie_list;                      /** List of Vendor Specific Information Element of AP*/
        int assoc_status_code;                                                  /** Supplicant WiFi Association Status Code */
+       char country_code[NET_WLAN_COUNTRY_CODE_LEN];                           /** Country code received from AP */
 } net_profile_info_s;
 
 typedef struct {
index 9b3ca54..9a23bd2 100755 (executable)
@@ -37,6 +37,9 @@ extern "C" {
 /** Length of Frequency */
 #define NET_WLAN_FREQ_LEN                                              5
 
+/** Length of country code */
+#define NET_WLAN_COUNTRY_CODE_LEN                              3
+
 /**
  * Length of WPS PIN code
  * WPS PIN code should be 4 or 8 digits
index 392567d..1fbbf8b 100755 (executable)
@@ -1057,6 +1057,11 @@ static int __net_extract_wifi_info(GVariantIter *array, net_profile_info_s* Prof
 
                } else if (g_strcmp0(key, "Keymgmt") == 0) {
                        ProfInfo->security_info.keymgmt = (unsigned int)g_variant_get_uint32(var);
+               } else if (g_strcmp0(key, "Country") == 0) {
+                       value = g_variant_get_string(var, NULL);
+
+                       if (value != NULL)
+                               g_strlcpy(ProfInfo->country_code, value, NET_WLAN_COUNTRY_CODE_LEN);
                } else
                        Error = __net_extract_common_info(key, var, ProfInfo);
        }
index a3f496b..198fed4 100755 (executable)
@@ -1554,6 +1554,34 @@ EXPORT_API int wifi_manager_ap_set_dns_address(wifi_manager_ap_h ap,
        return WIFI_MANAGER_ERROR_NONE;
 }
 
+EXPORT_API int wifi_manager_ap_get_countrycode(wifi_manager_ap_h ap,
+                                              char **country_code)
+{
+       __NETWORK_CAPI_FUNC_ENTER__;
+
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       if (_wifi_check_ap_validity(ap) == false || country_code == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+               __NETWORK_CAPI_FUNC_EXIT__;
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       net_profile_info_s *profile_info = ap;
+       if (profile_info->country_code[0] != '\0') {
+               *country_code = strdup(profile_info->country_code);
+               if (*country_code == NULL) {
+                       __NETWORK_CAPI_FUNC_EXIT__;
+                       return WIFI_MANAGER_ERROR_OUT_OF_MEMORY;
+               }
+       } else
+               *country_code = NULL;
+
+       __NETWORK_CAPI_FUNC_EXIT__;
+
+       return WIFI_MANAGER_ERROR_NONE;
+}
+
 /* Wi-Fi security information ************************************************/
 EXPORT_API int wifi_manager_ap_get_security_type(wifi_manager_ap_h ap,
                wifi_manager_security_type_e *type)
index 635b966..0d824ac 100755 (executable)
@@ -1243,6 +1243,15 @@ static bool __test_found_print_ap_info_callback(wifi_manager_ap_h ap, void *user
                else
                        printf("Fail to get passpoint state\n");
 
+               if (wifi_manager_ap_get_countrycode(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+                       if (str_value) {
+                               printf("Country Code : %s\n", str_value);
+                               free(str_value);
+                       } else
+                               printf("Country code is NULL\n");
+               } else
+                       printf("Fail to get Country code\n");
+
                if (sec_type != WIFI_MANAGER_SECURITY_TYPE_EAP) {
                        g_free(ap_name);
                        return false;