[wifi-manager] Add new CAPI to get raw ssid 57/135557/9
authorMilind Ramesh Murhekar <m.murhekar@samsung.com>
Fri, 23 Jun 2017 05:40:18 +0000 (11:10 +0530)
committerMilind Ramesh Murhekar <m.murhekar@samsung.com>
Thu, 29 Jun 2017 08:42:05 +0000 (14:12 +0530)
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 <m.murhekar@samsung.com>
include/network_interface.h
include/network_wlan.h
include/wifi-manager.h
src/network_interface.c
src/network_signal.c
src/wifi_ap.c
src/wifi_internal.c

index 16509cb02caa3ff31c901b82ec4a03d94f896e24..8264c1e6b0d132944e950a8053f40c8e44d30b6b 100755 (executable)
@@ -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;
index 183a3d8fa2a83763c7f9efe5f810266493776815..5bec3ecff9ab06119700c81a47da6b78fba92b00 100755 (executable)
 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
 
 /**
index 0fdefff864d37678f55452c11a6aeeece3ec88e4..4435d51a9984c163fa8b9a67c547ea928c8b09e4 100755 (executable)
@@ -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
index 75d061acd7e36c3ddbb160e9d68223e474628596..6bea83b754c27f7b0ee38d53d636776879901f4e 100755 (executable)
@@ -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);
 
index fb43d1dbf8c81df388d89919e2e41ba419d3316d..dab5e7fe4fdb2653b692f757388dd6a47f9bc07d 100755 (executable)
@@ -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);
index 790b2e87d181a5fc805c9535afdca563e8022773..ffc3c1edf46c1e0a0654399f141bfe82023b6b2c 100755 (executable)
@@ -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);
index 25fbce0b3c5c4d0a37a8897006489a8689e111ed..8697bec679a45fbdaf27821e61ce80b12b18830c 100755 (executable)
@@ -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,