From: Milind Ramesh Murhekar Date: Fri, 23 Jun 2017 05:40:18 +0000 (+0530) Subject: [wifi-manager] Add new CAPI to get raw ssid X-Git-Tag: submit/tizen/20170706.101920~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0307ae017efb2f3204ea850a245c0cd2795de88a;p=platform%2Fcore%2Fapi%2Fwifi-manager.git [wifi-manager] Add new CAPI to get raw ssid Description: This patch adds the new API to get raw SSID in bytes of an AP. Change-Id: If351a442723f6b71808266cfde0d6a1bde3434a5 Signed-off-by: Milind Ramesh Murhekar --- diff --git a/include/network_interface.h b/include/network_interface.h index 16509cb..8264c1e 100755 --- a/include/network_interface.h +++ b/include/network_interface.h @@ -154,6 +154,8 @@ typedef struct { net_error_state_type_e ProfileErrorState; /** Service error state */ char Favourite; /** Favourite flag */ int disconnect_reason; /** Supplicant Disconnect Reason Code */ + unsigned char raw_ssid[NET_WLAN_RAW_SSID_LEN+1];/** Raw SSID bytes */ + int raw_ssid_len; /** Raw SSID length */ } net_profile_info_s; typedef struct { @@ -170,6 +172,8 @@ typedef struct { typedef struct { char ssid[NET_WLAN_ESSID_LEN + 1]; + unsigned char raw_ssid[NET_WLAN_RAW_SSID_LEN + 1]; /** Raw SSID bytes */ + int raw_ssid_len; /** Raw SSID length */ wlan_security_mode_type_e security; char wps; } net_ssid_scan_bss_info_s; diff --git a/include/network_wlan.h b/include/network_wlan.h index 183a3d8..5bec3ec 100755 --- a/include/network_wlan.h +++ b/include/network_wlan.h @@ -25,10 +25,13 @@ extern "C" { #endif /* __cplusplus */ -/** Length of essid */ +/** Length of raw SSID */ +#define NET_WLAN_RAW_SSID_LEN 32 + +/** Length of ESSID */ #define NET_WLAN_ESSID_LEN 128 -/** Length of bssid */ +/** Length of BSSID */ #define NET_WLAN_BSSID_LEN 17 /** diff --git a/include/wifi-manager.h b/include/wifi-manager.h index 0fdefff..4435d51 100755 --- a/include/wifi-manager.h +++ b/include/wifi-manager.h @@ -1711,6 +1711,21 @@ int wifi_manager_ap_refresh(wifi_manager_ap_h ap); */ int wifi_manager_ap_get_essid(wifi_manager_ap_h ap, char **essid); +/** + * @brief Gets raw SSID (Service Set Identifier). + * @since_tizen 4.0 + * @remarks You must release @a ssid using free(). + * @param[in] ap The access point handle + * @param[out] ssid The raw SSID bytes + * @param[out] ssid_len The raw SSID length + * @return 0 on success, otherwise negative error value + * @retval #WIFI_MANAGER_ERROR_NONE Successful + * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported + */ +int wifi_manager_ap_get_raw_ssid(wifi_manager_ap_h ap, char **ssid, int *ssid_len); + /** * @brief Gets BSSID (Basic Service Set Identifier). * @since_tizen 3.0 diff --git a/src/network_interface.c b/src/network_interface.c index 75d061a..6bea83b 100755 --- a/src/network_interface.c +++ b/src/network_interface.c @@ -908,6 +908,12 @@ static int __net_extract_wifi_info(GVariantIter *array, net_profile_info_s* Prof ProfInfo->PassphraseRequired = TRUE; else ProfInfo->PassphraseRequired = FALSE; + } else if (g_strcmp0(key, "SSID") == 0) { + const gchar *ssid = NULL; + gsize ssid_len; + ssid = g_variant_get_fixed_array(var, &ssid_len, sizeof(guchar)); + memcpy(ProfInfo->raw_ssid, ssid, ssid_len); + ProfInfo->raw_ssid_len = ssid_len; } else if (g_strcmp0(key, "BSSID") == 0) { value = g_variant_get_string(var, NULL); diff --git a/src/network_signal.c b/src/network_signal.c index fb43d1d..dab5e7f 100755 --- a/src/network_signal.c +++ b/src/network_signal.c @@ -177,12 +177,15 @@ static int __net_handle_wifi_specific_scan_rsp(GVariant *param) GVariant *value = NULL; gchar *key = NULL; const gchar *ssid = NULL; + const unsigned char *raw_ssid = NULL; + gsize raw_ssid_len = 0; gint32 security = 0; gboolean wps = FALSE; GSList *bss_info_list = NULL; gboolean ssid_found = FALSE; gboolean sec_found = FALSE; gboolean wps_found = FALSE; + gboolean raw_ssid_found = FALSE; g_variant_get(param, "(a{sv})", &iter); @@ -192,6 +195,12 @@ static int __net_handle_wifi_specific_scan_rsp(GVariant *param) WIFI_LOG(WIFI_INFO, "SSID: %s", ssid); ssid_found = TRUE; } + if (g_strcmp0(key, "raw_ssid") == 0 && raw_ssid_found == FALSE) { + raw_ssid = g_variant_get_fixed_array(value, &raw_ssid_len, sizeof(guchar)); + raw_ssid_found = TRUE; + WIFI_LOG(WIFI_INFO, "raw SSID len: %d", raw_ssid_len); + raw_ssid_found = TRUE; + } if (g_strcmp0(key, "security") == 0 && sec_found == FALSE) { security = g_variant_get_int32(value); WIFI_LOG(WIFI_INFO, "with security: %d", security); @@ -203,7 +212,8 @@ static int __net_handle_wifi_specific_scan_rsp(GVariant *param) wps_found = TRUE; } - if (ssid_found == TRUE && sec_found == TRUE && wps_found == TRUE) { + if (ssid_found == TRUE && raw_ssid_found == TRUE && + sec_found == TRUE && wps_found == TRUE) { net_ssid_scan_bss_info_s *bss = NULL; bss = g_try_new0(net_ssid_scan_bss_info_s, 1); if (bss == NULL) { @@ -216,11 +226,19 @@ static int __net_handle_wifi_specific_scan_rsp(GVariant *param) } g_strlcpy(bss->ssid, ssid, NET_WLAN_ESSID_LEN); + if (raw_ssid != NULL && raw_ssid_len > 0 && + raw_ssid_len < (NET_WLAN_RAW_SSID_LEN+1)) { + memcpy(bss->raw_ssid, raw_ssid, raw_ssid_len); + bss->raw_ssid_len = raw_ssid_len; + } else { + memset(bss->raw_ssid, 0, sizeof(bss->raw_ssid)); + bss->raw_ssid_len = 0; + } bss->security = __net_get_wlan_sec_mode(security); bss->wps = (char)wps; bss_info_list = g_slist_append(bss_info_list, bss); - ssid_found = sec_found = wps_found = FALSE; + ssid_found = sec_found = wps_found = raw_ssid_found = FALSE; } } g_variant_iter_free(iter); diff --git a/src/wifi_ap.c b/src/wifi_ap.c index 790b2e8..ffc3c1e 100755 --- a/src/wifi_ap.c +++ b/src/wifi_ap.c @@ -378,6 +378,27 @@ EXPORT_API int wifi_manager_ap_get_essid(wifi_manager_ap_h ap, char **essid) return WIFI_MANAGER_ERROR_NONE; } +EXPORT_API int wifi_manager_ap_get_raw_ssid(wifi_manager_ap_h ap, char **ssid, int *ssid_len) +{ + CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); + + if (_wifi_check_ap_validity(ap) == false || ssid == NULL || + ssid_len == NULL) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); + return WIFI_MANAGER_ERROR_INVALID_PARAMETER; + } + + net_profile_info_s *profile_info = ap; + *ssid = g_try_malloc0(NET_WLAN_RAW_SSID_LEN + 1); + if (*ssid == NULL) + return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; + + memcpy(*ssid, profile_info->raw_ssid, NET_WLAN_RAW_SSID_LEN); + *ssid_len = profile_info->raw_ssid_len; + + return WIFI_MANAGER_ERROR_NONE; +} + EXPORT_API int wifi_manager_ap_get_bssid(wifi_manager_ap_h ap, char **bssid) { CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); diff --git a/src/wifi_internal.c b/src/wifi_internal.c index 25fbce0..8697bec 100755 --- a/src/wifi_internal.c +++ b/src/wifi_internal.c @@ -317,6 +317,8 @@ static void __update_specific_iterator(GSList *bss_list) return; } g_strlcpy(prof_info->essid, info->ssid, NET_WLAN_ESSID_LEN); + memcpy(prof_info->raw_ssid, info->raw_ssid, info->raw_ssid_len); + prof_info->raw_ssid_len = info->raw_ssid_len; prof_info->security_info.sec_mode = info->security; prof_info->security_info.wps_support = (char)info->wps; specific_profile_iterator = g_slist_append(specific_profile_iterator,