Merge "Revise background scan routine" into tizen
authortaesub kim <taesub.kim@samsung.com>
Wed, 8 Nov 2017 00:57:12 +0000 (00:57 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Wed, 8 Nov 2017 00:57:12 +0000 (00:57 +0000)
16 files changed:
CMakeLists.txt
include/netsupplicant.h
include/wifi-ssid-scan.h [deleted file]
interfaces/netconfig-iface-wifi.xml
resources/etc/dbus-1/system.d/net-config.conf
src/dbus/netsupplicant.c
src/signal-handler.c
src/wifi-bssid-scan.c
src/wifi-config.c
src/wifi-extension.c
src/wifi-indicator.c
src/wifi-ssid-scan.c [deleted file]
src/wifi-state.c
src/wifi-tdls.c
src/wifi-wps.c
src/wifi.c

index 87477e0..8546f90 100755 (executable)
@@ -32,7 +32,6 @@ SET(SRCS
        src/wifi-firmware.c
        src/wifi-indicator.c
        src/signal-handler.c
-       src/wifi-ssid-scan.c
        src/utils/emulator.c
        src/wifi-eap-config.c
        src/network-statistics.c
index aa5f495..67ea9ba 100755 (executable)
@@ -40,9 +40,9 @@ struct dbus_input_arguments {
        void *data;
 };
 
-/* Returns Supplicant interface
- * Do not free the returned interface */
-const char *netconfig_wifi_get_supplicant_interface(void);
+/* Returns Supplicant interface.
+ * Need to release interface using g_free */
+char *netconfig_wifi_get_supplicant_interface(void);
 
 GList *setup_input_args(GList *list, struct dbus_input_arguments *items);
 GVariant *netconfig_supplicant_invoke_dbus_method(const char *dest, const char *path,
diff --git a/include/wifi-ssid-scan.h b/include/wifi-ssid-scan.h
deleted file mode 100755 (executable)
index 6398bd2..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Network Configuration Module
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __NETCONFIG_WIFI_SSID_SCAN_H__
-#define __NETCONFIG_WIFI_SSID_SCAN_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "wifi.h"
-
-gboolean       wifi_ssid_scan(const char *ssid);
-gboolean       wifi_ssid_scan_get_state(void);
-void           wifi_ssid_scan_emit_scan_completed(void);
-void           wifi_ssid_scan_add_bss(GVariant *message);
-
-gboolean       handle_request_specific_scan(Wifi *wifi, GDBusMethodInvocation *context, const gchar *ssid);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NETCONFIG_WIFI_SSID_SCAN_H__ */
index 9874bfc..c1d46e6 100755 (executable)
@@ -34,9 +34,6 @@
                <method name="GetAutoscanmode">
                        <arg type="u" name="autoscanmode" direction="out"/>
                </method>
-               <method name="RequestSpecificScan">
-                       <arg type="s" name="SSID" direction="in"/>
-               </method>
                <method name="RequestBssidScan">
                </method>
                <method name="RequestWpsCancel">
index cf85aef..ef94c1d 100755 (executable)
@@ -43,7 +43,6 @@
                <check send_destination="net.netconfig" send_interface="net.netconfig.network_statistics" send_member="ResetWifiTotalTxBytes" privilege="http://tizen.org/privilege/network.set" />
 
                <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="DeleteEapConfig" privilege="http://tizen.org/privilege/network.profile" />
-               <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="RequestSpecificScan" privilege="http://tizen.org/privilege/network.set" />
                <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="RequestBssidScan" privilege="http://tizen.org/privilege/network.set" />
                <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="RequestWpsCancel" privilege="http://tizen.org/privilege/network.set" />
                <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="RequestWpsConnect" privilege="http://tizen.org/privilege/network.set" />
index 0000da9..a1d1445 100755 (executable)
 #include "netdbus.h"
 #include "netsupplicant.h"
 
-#define DBUS_OBJECT_PATH_MAX                   150
-
-const char *netconfig_wifi_get_supplicant_interface(void)
+char *netconfig_wifi_get_supplicant_interface(void)
 {
        GVariant *message = NULL;
        GVariant *params = NULL;
        gchar *path = NULL;
-       static char obj_path[DBUS_OBJECT_PATH_MAX] = { '\0', };
-
-       if (obj_path[0] != '\0')
-               return (const char *)obj_path;
 
        params = g_variant_new("(s)", WIFI_IFNAME);
 
@@ -46,13 +40,9 @@ const char *netconfig_wifi_get_supplicant_interface(void)
 
        g_variant_get(message, "(o)", &path);
 
-       g_strlcpy(obj_path, path, DBUS_OBJECT_PATH_MAX);
-
-       if (path)
-               g_free(path);
        g_variant_unref(message);
 
-       return (const char *)obj_path;
+       return (char *)path;
 }
 
 GVariant *netconfig_supplicant_invoke_dbus_method(const char *dest, const char *path,
@@ -134,7 +124,7 @@ GVariant *netconfig_supplicant_invoke_dbus_interface_property_get(const char *in
 {
        GVariant *params = NULL;
        GVariant *reply = NULL;
-       const char *path;
+       char *path;
 
        ERR("[GDBUS] property_get : %s", key);
 
@@ -152,6 +142,7 @@ GVariant *netconfig_supplicant_invoke_dbus_interface_property_get(const char *in
                        "Get",
                        params);
 
+       g_free(path);
        if (reply == NULL) {
                ERR("netconfig_supplicant_invoke_dbus_method() failed.");
                return NULL;
@@ -166,7 +157,7 @@ gboolean netconfig_supplicant_invoke_dbus_interface_property_set(const char *int
 {
        gboolean result = FALSE;
        GVariant *message = NULL;
-       const char *path;
+       char *path;
 
        DBG("[DBUS] property_set : %s", key);
 
@@ -184,6 +175,7 @@ gboolean netconfig_supplicant_invoke_dbus_interface_property_set(const char *int
                        message,
                        notify_func);
 
+       g_free(path);
        if (result == FALSE) {
                ERR("dbus_connection_send_with_reply() failed");
 
index 116ce50..e3ee51f 100755 (executable)
@@ -36,7 +36,6 @@
 #include "network-state.h"
 #include "cellular-state.h"
 #include "signal-handler.h"
-#include "wifi-ssid-scan.h"
 #include "wifi-background-scan.h"
 #include "wifi-tdls.h"
 
@@ -532,10 +531,7 @@ static void _supplicant_bss_added(GDBusConnection *conn,
                const gchar *sig, GVariant *param, gpointer user_data)
 {
        DBG("BSS added handling!");
-       if (wifi_ssid_scan_get_state() == TRUE)
-               wifi_ssid_scan_add_bss(param);
-       else
-               wifi_state_set_bss_found(TRUE);
+       wifi_state_set_bss_found(TRUE);
 
        return;
 }
@@ -553,12 +549,7 @@ static void _supplicant_scan_done(GDBusConnection *conn,
                        return;
        }
 
-       if (netconfig_wifi_get_bgscan_state() != TRUE) {
-               if (wifi_ssid_scan_get_state() == TRUE)
-                       wifi_ssid_scan_emit_scan_completed();
-               else
-                       wifi_ssid_scan(NULL);
-       } else {
+       if (netconfig_wifi_get_bgscan_state() == TRUE) {
                if (wifi_state_get_technology_state() >=
                                NETCONFIG_WIFI_TECH_POWERED)
                        netconfig_wifi_bgscan_start(FALSE);
index 05ad0c1..2eba2b6 100755 (executable)
@@ -270,7 +270,7 @@ done:
 static int _netconfig_wifi_bssid_get_bss(void)
 {
        gboolean reply = FALSE;
-       const char *if_path = NULL;
+       char *if_path = NULL;
        GVariant *params = NULL;
 
        if_path = netconfig_wifi_get_supplicant_interface();
@@ -284,6 +284,8 @@ static int _netconfig_wifi_bssid_get_bss(void)
        reply = netconfig_invoke_dbus_method_nonblock(SUPPLICANT_SERVICE,
                        if_path, DBUS_INTERFACE_PROPERTIES,
                        "Get", params, __netconfig_wifi_bssid_get_bss_result);
+
+       g_free(if_path);
        if (reply != TRUE) {
                ERR("Fail to method: Get");
 
@@ -323,16 +325,19 @@ void netconfig_wifi_bssid_signal_scanaborted(void)
        __netconfig_set_bssid_scan_mode(FALSE);
 }
 
-static int __netconfig_wifi_bssid_request_scan(const char *if_path)
+static int __netconfig_wifi_bssid_request_scan(char *if_path)
 {
        GDBusConnection *connection = NULL;
        GVariant *message = NULL;
        GVariantBuilder *builder = NULL;
        const char *key1 = "Type";
        const char *val1 = "passive";
+       gboolean is_free_required = FALSE;
 
-       if (if_path == NULL)
+       if (if_path == NULL) {
                if_path = netconfig_wifi_get_supplicant_interface();
+               is_free_required = TRUE;
+       }
 
        if (if_path == NULL) {
                DBG("Fail to get wpa_supplicant DBus path");
@@ -365,6 +370,8 @@ static int __netconfig_wifi_bssid_request_scan(const char *if_path)
 
        netconfig_is_device_scanning = TRUE;
 
+       if (is_free_required)
+               g_free(if_path);
        g_variant_unref(message);
        /* Clear bss_info_list for the next scan result */
        if (bssid_info_list) {
index afa0382..72914a6 100755 (executable)
@@ -716,7 +716,7 @@ gboolean _add_vsie(int frame_id, const char* vsie)
        GVariant *params = NULL;
        GVariant *message = NULL;
        GVariantBuilder *bytearray_builder = NULL;
-       const char *if_path;
+       char *if_path;
        int i = 0;
        size_t vsie_len = 0;
 
@@ -766,6 +766,7 @@ gboolean _add_vsie(int frame_id, const char* vsie)
        message = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE,
                        if_path, SUPPLICANT_INTERFACE ".Interface", "VendorElemAdd", params);
 
+       g_free(if_path);
        if (message == NULL) {
                ERR("Failed to send command to wpa_supplicant");
                g_free(bytearray);
@@ -782,7 +783,7 @@ gboolean _get_vsie(int frame_id, char **vsie)
 {
        GVariant *params = NULL;
        GVariant *message = NULL;
-       const char *if_path;
+       char *if_path;
 
        if (frame_id >= NETCONFIG_VSIE_FRAME_MAX) {
                DBG("Invalid parameter, frame-id: %d", frame_id);
@@ -800,6 +801,7 @@ gboolean _get_vsie(int frame_id, char **vsie)
        message = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE,
                        if_path, SUPPLICANT_INTERFACE ".Interface", "VendorElemGet", params);
 
+       g_free(if_path);
        if (message == NULL) {
                ERR("Failed to send command to wpa_supplicant");
                return FALSE;
@@ -842,7 +844,7 @@ gboolean _remove_vsie(int frame_id, const char *vsie)
        GVariant *params = NULL;
        GVariant *message = NULL;
        GVariantBuilder *bytearray_builder = NULL;
-       const char *if_path;
+       char *if_path;
        int i = 0;
        size_t vsie_len = 0;
 
@@ -891,6 +893,7 @@ gboolean _remove_vsie(int frame_id, const char *vsie)
        message = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE,
                        if_path, SUPPLICANT_INTERFACE ".Interface", "VendorElemRem", params);
 
+       g_free(if_path);
        if (message == NULL) {
                ERR("Failed to send command to wpa_supplicant");
                g_free(bytearray);
index eaf1e75..0261844 100755 (executable)
@@ -40,7 +40,7 @@ gboolean handle_flush_bss(Wifi *wifi, GDBusMethodInvocation *context)
        g_return_val_if_fail(wifi != NULL, FALSE);
 
        GDBusConnection *connection = NULL;
-       const char *if_path = NULL;
+       char *if_path = NULL;
 
        if_path = netconfig_wifi_get_supplicant_interface();
        if (if_path == NULL) {
@@ -53,6 +53,7 @@ gboolean handle_flush_bss(Wifi *wifi, GDBusMethodInvocation *context)
        if (connection == NULL) {
                netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailFlushBss");
                ERR("Failed to get netdbus connection");
+               g_free(if_path);
                return FALSE;
        }
 
@@ -70,6 +71,7 @@ gboolean handle_flush_bss(Wifi *wifi, GDBusMethodInvocation *context)
                        NULL,
                        NULL);
 
+       g_free(if_path);
        wifi_complete_flush_bss(wifi, context);
        return TRUE;
 }
index e788e65..1c99a18 100755 (executable)
@@ -66,7 +66,7 @@ int netconfig_wifi_get_rssi(void)
 
 static int __netconfig_wifi_update_and_get_rssi(void)
 {
-       const char *if_path = NULL;
+       char *if_path = NULL;
        GVariant *message = NULL;
        GVariant *value = NULL;
        gchar *key;
@@ -83,6 +83,8 @@ static int __netconfig_wifi_update_and_get_rssi(void)
 
        message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE, if_path,
                                SUPPLICANT_INTERFACE ".Interface", "SignalPoll", NULL);
+
+       g_free(if_path);
        if (message == NULL) {
                ERR("Fail to get SignalPoll from wpa_supplicant");
                return 0;
diff --git a/src/wifi-ssid-scan.c b/src/wifi-ssid-scan.c
deleted file mode 100755 (executable)
index 620bf6d..0000000
+++ /dev/null
@@ -1,541 +0,0 @@
-/*
- * Network Configuration Module
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-
-#include "log.h"
-#include "util.h"
-#include "neterror.h"
-#include "netdbus.h"
-#include "netsupplicant.h"
-#include "wifi-ssid-scan.h"
-#include "wifi-background-scan.h"
-
-#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
-#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
-
-#define WIFI_KEYMGMT_NONE                      (1 << 0)
-#define WIFI_KEYMGMT_IEEE8021X         (1 << 1)
-#define WIFI_KEYMGMT_WPA_NONE          (1 << 2)
-#define WIFI_KEYMGMT_WPA_PSK           (1 << 3)
-#define WIFI_KEYMGMT_WPA_PSK_256       (1 << 4)
-#define WIFI_KEYMGMT_WPA_FT_PSK                (1 << 5)
-#define WIFI_KEYMGMT_WPA_FT_EAP                (1 << 6)
-#define WIFI_KEYMGMT_WPA_EAP           (1 << 7)
-#define WIFI_KEYMGMT_WPA_EAP_256       (1 << 8)
-#define WIFI_KEYMGMT_WPS                       (1 << 9)
-
-#define WIFI_PAIRWISE_NONE                     (1 << 0)
-#define WIFI_PAIRWISE_TKIP                     (1 << 1)
-#define WIFI_PAIRWISE_CCMP                     (1 << 2)
-
-typedef struct {
-       const char *str;
-       unsigned int val;
-} strval_s;
-
-static strval_s wifi_keymgmt[] = {
-       { "none",                       WIFI_KEYMGMT_NONE },
-       { "ieee8021x",          WIFI_KEYMGMT_IEEE8021X },
-       { "wpa-none",           WIFI_KEYMGMT_WPA_NONE },
-       { "wpa-psk",            WIFI_KEYMGMT_WPA_PSK },
-       { "wpa-psk-sha256",     WIFI_KEYMGMT_WPA_PSK_256 },
-       { "wpa-ft-psk",         WIFI_KEYMGMT_WPA_FT_PSK },
-       { "wpa-ft-eap",         WIFI_KEYMGMT_WPA_FT_EAP },
-       { "wpa-eap",            WIFI_KEYMGMT_WPA_EAP },
-       { "wpa-eap-sha256",     WIFI_KEYMGMT_WPA_EAP_256 },
-       { "wps",                        WIFI_KEYMGMT_WPS },
-       { }
-};
-
-static strval_s wifi_pairwise[] = {
-       { "none",                       WIFI_PAIRWISE_NONE },
-       { "tkip",                       WIFI_PAIRWISE_TKIP },
-       { "ccmp",                       WIFI_PAIRWISE_CCMP },
-       { }
-};
-
-typedef enum {
-       WIFI_SECURITY_UNKNOWN = 0x00,
-       WIFI_SECURITY_NONE,
-       WIFI_SECURITY_WEP,
-       WIFI_SECURITY_PSK,
-       WIFI_SECURITY_PSK2,
-       WIFI_SECURITY_IEEE8021X,
-} wifi_security_e;
-
-typedef struct {
-       unsigned char ssid[33];
-       unsigned char bssid[6];
-       wifi_security_e security;
-       unsigned int wpa_keymgmt;
-       unsigned int wpa_pairwise;
-       unsigned int rsn_keymgmt;
-       unsigned int rsn_pairwise;
-       gboolean rsn_selected;
-       gboolean privacy;
-       gboolean wps;
-       int ssid_len;
-} bss_info_t;
-
-static gboolean g_ssid_scan_state = FALSE;
-static GSList *bss_info_list = NULL;
-static guint ssid_scan_timer = 0;
-static char *g_ssid = NULL;
-
-static void __check_keymgmt(const char *str_keymgmt, unsigned int *key_info)
-{
-       int i;
-
-       for (i = 0; wifi_keymgmt[i].str; i++) {
-               if (g_strcmp0(str_keymgmt, wifi_keymgmt[i].str) == 0) {
-                       INFO("keymgmt : %s", str_keymgmt);
-                       *key_info |= wifi_keymgmt[i].val;
-                       break;
-               }
-       }
-}
-
-static void __check_pairwise(const char *str_pairwise, unsigned int *pairwise_info)
-{
-       int i;
-
-       for (i = 0; wifi_pairwise[i].str; i++) {
-               if (g_strcmp0(str_pairwise, wifi_pairwise[i].str) == 0) {
-                       INFO("pairwise : %s", str_pairwise);
-                       *pairwise_info |= wifi_pairwise[i].val;
-                       break;
-               }
-       }
-}
-
-static wifi_security_e __check_security(bss_info_t *bss_info)
-{
-       gboolean ieee8021x = FALSE;
-       gboolean psk = FALSE;
-       gboolean ft_ieee8021x = FALSE;
-       gboolean ft_psk = FALSE;
-       unsigned int keymgmt = bss_info->rsn_keymgmt | bss_info->wpa_keymgmt;
-
-       if (keymgmt & (WIFI_KEYMGMT_WPA_EAP | WIFI_KEYMGMT_WPA_EAP_256))
-               ieee8021x = TRUE;
-       else if (keymgmt & WIFI_KEYMGMT_WPA_FT_EAP)
-               ft_ieee8021x = TRUE;
-
-       if (keymgmt & (WIFI_KEYMGMT_WPA_PSK | WIFI_KEYMGMT_WPA_PSK_256))
-               psk = TRUE;
-       else if (keymgmt & WIFI_KEYMGMT_WPA_FT_PSK)
-               ft_psk = TRUE;
-
-       if (ieee8021x || ft_ieee8021x)
-               bss_info->security = WIFI_SECURITY_IEEE8021X;
-       else if (psk || ft_psk)
-               bss_info->security = WIFI_SECURITY_PSK;
-       else if (bss_info->privacy)
-               bss_info->security = WIFI_SECURITY_WEP;
-       else
-               bss_info->security = WIFI_SECURITY_NONE;
-
-       if (bss_info->rsn_selected) {
-               unsigned int pairwise = bss_info->rsn_pairwise | bss_info->wpa_pairwise;
-               if ((pairwise & WIFI_PAIRWISE_CCMP) ||
-                       (pairwise & (WIFI_PAIRWISE_CCMP | WIFI_PAIRWISE_TKIP)))
-                       bss_info->security = WIFI_SECURITY_PSK2;
-       }
-
-       return bss_info->security;
-}
-
-static gboolean __ssid_scan_timeout(gpointer data)
-{
-       wifi_ssid_scan_emit_scan_completed();
-
-       return FALSE;
-}
-
-static void _start_ssid_scan_timer(void)
-{
-       INFO("Wi-Fi SSID scan started");
-       g_ssid_scan_state = TRUE;
-
-       netconfig_start_timer_seconds(5, __ssid_scan_timeout, NULL, &ssid_scan_timer);
-}
-
-static void _stop_ssid_scan_timer(void)
-{
-       INFO("Wi-Fi SSID scan finished");
-       g_ssid_scan_state = FALSE;
-
-       netconfig_stop_timer(&ssid_scan_timer);
-}
-
-static void _parse_wpa_message(GVariant *param, bss_info_t *bss_info)
-{
-       GVariantIter *iter1;
-       GVariant *var;
-       gchar *key;
-
-       g_variant_get(param, "a{sv}", &iter1);
-       while (g_variant_iter_loop(iter1, "{sv}", &key, &var)) {
-               if (g_strcmp0(key, "KeyMgmt") == 0) {
-                       GVariantIter *iter2;
-                       g_variant_get(var, "as", &iter2);
-                       char *str;
-                       while (g_variant_iter_loop(iter2, "s", &str)) {
-                               if (str == NULL)
-                                       break;
-                               unsigned int key_info = 0;
-                               __check_keymgmt(str, &key_info);
-                               if (bss_info->rsn_selected)
-                                       bss_info->rsn_keymgmt = key_info;
-                               else
-                                       bss_info->wpa_keymgmt = key_info;
-                       }
-                       g_variant_iter_free(iter2);
-               } else if (g_strcmp0(key, "Pairwise") == 0) {
-                       GVariantIter *iter2;
-                       g_variant_get(var, "as", &iter2);
-                       char *str;
-                       while (g_variant_iter_loop(iter2, "s", &str)) {
-                               if (str == NULL)
-                                       break;
-                               unsigned int pairwise_info = 0;
-                               __check_pairwise(str, &pairwise_info);
-                               if (bss_info->rsn_selected)
-                                       bss_info->rsn_pairwise = pairwise_info;
-                               else
-                                       bss_info->wpa_pairwise = pairwise_info;
-                       }
-                       g_variant_iter_free(iter2);
-               }
-       }
-
-       g_variant_iter_free(iter1);
-
-       return;
-}
-
-static gboolean _request_ssid_scan(const char *object_path, const char *ssid)
-{
-       /* TODO: Revise following code */
-
-       GDBusConnection *connection = NULL;
-       GVariant *reply = NULL;
-       GVariant *params = NULL;
-       GError *error = NULL;
-       GVariantBuilder *builder1 = NULL;
-       GVariantBuilder *builder2 = NULL;
-       GVariantBuilder *builder3 = NULL;
-       const gchar *key1 = "Type";
-       const gchar *val1 = "active";
-       const gchar *key2 = "SSIDs";
-       int i = 0;
-
-       connection = netdbus_get_connection();
-       if (connection == NULL) {
-               DBG("Failed to get GDBusconnection");
-               return FALSE;
-       }
-
-       builder1 = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-       g_variant_builder_add(builder1, "{sv}", key1, g_variant_new_string(val1));
-
-       builder2 = g_variant_builder_new(G_VARIANT_TYPE("aay"));
-       builder3 = g_variant_builder_new(G_VARIANT_TYPE("ay"));
-
-       for (i = 0; i < strlen(ssid); i++)
-               g_variant_builder_add(builder3, "y", ssid[i]);
-
-       g_variant_builder_add(builder2, "@ay", g_variant_builder_end(builder3));
-       g_variant_builder_add(builder1, "{sv}", key2, g_variant_builder_end(builder2));
-
-       params = g_variant_new("(@a{sv})", g_variant_builder_end(builder1));
-
-       g_variant_builder_unref(builder1);
-       g_variant_builder_unref(builder2);
-       g_variant_builder_unref(builder3);
-
-       reply = g_dbus_connection_call_sync(
-                       connection,
-                       SUPPLICANT_SERVICE,
-                       object_path,
-                       SUPPLICANT_INTERFACE ".Interface",
-                       "Scan",
-                       params,
-                       NULL,
-                       G_DBUS_CALL_FLAGS_NONE,
-                       NETCONFIG_DBUS_REPLY_TIMEOUT,
-                       netdbus_get_cancellable(),
-                       &error);
-
-       if (reply == NULL) {
-               if (error != NULL) {
-                       ERR("Error!!! dbus_connection_send_with_reply_and_block() failed. "
-                                       "DBus error [%d: %s]", error->code, error->message);
-                       g_error_free(error);
-               } else
-                       ERR("Error!!! Failed to get properties");
-
-               return FALSE;
-       }
-
-       if (g_ssid != NULL)
-               g_free(g_ssid);
-
-       g_ssid = g_strdup(ssid);
-
-       g_variant_unref(reply);
-
-       return TRUE;
-}
-
-static void _emit_ssid_scan_completed(void)
-{
-       GVariantBuilder *builder = NULL;
-       GSList* list = NULL;
-       const char *prop_ssid = "ssid";
-       const char *prop_bssid = "bssid";
-       char bssid_buf[18] = {0,};
-       char *bssid_str = bssid_buf;
-       const char *prop_security = "security";
-       const char *prop_wps = "wps";
-       GVariantBuilder *rawssid_builder = NULL;
-       const char *prop_raw_ssid = "raw_ssid";
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-       for (list = bss_info_list; list != NULL; list = list->next) {
-               bss_info_t *bss_info = (bss_info_t *)list->data;
-               if (bss_info && g_strcmp0((char *)bss_info->ssid, g_ssid) == 0) {
-                       const gchar *ssid = (char *)bss_info->ssid;
-                       int ssid_len = bss_info->ssid_len;
-                       const gchar *bssid = (gchar *)&bss_info->bssid[0];
-                       int i = 0;
-
-                       wifi_security_e security = __check_security(bss_info);
-                       gboolean wps = bss_info->wps;
-                       DBG("BSS found; SSID:%s security:%d WPS:%d", ssid, security, wps);
-
-                       if (bssid) {
-                               snprintf(bssid_str, sizeof(bssid_buf), MACSTR, MAC2STR(bssid));
-                               DBG("BSSID: %s", bssid_str);
-                       }
-
-                       g_variant_builder_add(builder, "{sv}", prop_ssid, g_variant_new_string(ssid));
-
-                       /* append raw SSID in bytes to the specific
-                          scan completed signal here */
-                       rawssid_builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
-                       for (i = 0; i < ssid_len; i++)
-                               g_variant_builder_add(rawssid_builder, "y", ssid[i]);
-                       g_variant_builder_add(builder, "{sv}", prop_raw_ssid, g_variant_new("ay", rawssid_builder));
-                       g_variant_builder_unref(rawssid_builder);
-
-                       g_variant_builder_add(builder, "{sv}", prop_bssid,
-                                               g_variant_new_string(bssid));
-                       g_variant_builder_add(builder, "{sv}", prop_security, g_variant_new_int32(security));
-                       /* WPS */
-                       g_variant_builder_add(builder, "{sv}", prop_wps, g_variant_new_boolean(wps));
-               }
-       }
-
-       wifi_emit_specific_scan_completed((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
-
-       if (builder)
-               g_variant_builder_unref(builder);
-
-       if (bss_info_list != NULL) {
-               g_slist_free_full(bss_info_list, g_free);
-               bss_info_list = NULL;
-       }
-
-       if (g_ssid != NULL) {
-               g_free(g_ssid);
-               g_ssid = NULL;
-       }
-
-       INFO("SpecificScanCompleted");
-
-       return;
-}
-
-gboolean wifi_ssid_scan(const char *ssid)
-{
-       const char *if_path;
-       static char *scan_ssid = NULL;
-
-       netconfig_wifi_bgscan_stop();
-
-       if (ssid != NULL) {
-               if (scan_ssid != NULL)
-                       g_free(scan_ssid);
-               scan_ssid = g_strdup(ssid);
-       }
-
-       if (scan_ssid == NULL)
-               goto error;
-
-       if_path = netconfig_wifi_get_supplicant_interface();
-       if (if_path == NULL) {
-               DBG("Fail to get wpa_supplicant DBus path");
-               goto error;
-       }
-
-       if (netconfig_wifi_get_scanning() == TRUE) {
-               DBG("Wi-Fi scan in progress, %s scan will be delayed", scan_ssid);
-               return TRUE;
-       }
-
-       if (bss_info_list) {
-               g_slist_free_full(bss_info_list, g_free);
-               bss_info_list = NULL;
-       }
-
-       INFO("Start Wi-Fi scan with %s(%d)", scan_ssid, strlen(scan_ssid));
-       if (_request_ssid_scan(if_path, (const char *)scan_ssid) == TRUE) {
-               _start_ssid_scan_timer();
-               g_free(scan_ssid);
-               scan_ssid = NULL;
-               return TRUE;
-       }
-
-error:
-       if (scan_ssid != NULL) {
-               g_free(scan_ssid);
-               scan_ssid = NULL;
-       }
-
-       netconfig_wifi_bgscan_start(FALSE);
-
-       return FALSE;
-}
-
-gboolean wifi_ssid_scan_get_state(void)
-{
-       return g_ssid_scan_state;
-}
-
-void wifi_ssid_scan_emit_scan_completed(void)
-{
-       if (g_ssid_scan_state != TRUE)
-               return;
-
-       _stop_ssid_scan_timer();
-       _emit_ssid_scan_completed();
-       netconfig_wifi_bgscan_start(FALSE);
-}
-
-void wifi_ssid_scan_add_bss(GVariant *message)
-{
-       GVariantIter *iter;
-       GVariant *value;
-       gchar *path = NULL;
-       gchar *key;
-       bss_info_t *bss_info;
-
-       if (g_ssid_scan_state != TRUE)
-               return;
-
-       INFO("NEW BSS added");
-
-       if (message == NULL) {
-               DBG("Message does not have parameters");
-               return;
-       }
-
-       if (path != NULL)
-               INFO("Object path of BSS added is %s", path);
-
-       bss_info = g_try_new0(bss_info_t, 1);
-       if (bss_info == NULL)
-               return;
-
-       g_variant_get(message, "(oa{sv})", &path, &iter);
-       while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
-               if (g_strcmp0(key, "SSID") == 0) {
-                       const guchar *ssid;
-                       gsize ssid_len;
-                       ssid = g_variant_get_fixed_array(value, &ssid_len, sizeof(guchar));
-                       if (ssid != NULL && ssid_len > 0 && ssid_len < 33) {
-                               memcpy(bss_info->ssid, ssid, ssid_len);
-                               bss_info->ssid_len = ssid_len;
-                       } else {
-                               memset(bss_info->ssid, 0, sizeof(bss_info->ssid));
-                               bss_info->ssid_len = 0;
-                       }
-               } else if (g_strcmp0(key, "Privacy") == 0) {
-                       gboolean privacy = FALSE;
-                       privacy = g_variant_get_boolean(value);
-                       bss_info->privacy = privacy;
-               } else if (g_strcmp0(key, "RSN") == 0) {
-                       bss_info->rsn_selected = TRUE;
-                       _parse_wpa_message(value, bss_info);
-               } else if (g_strcmp0(key, "WPA") == 0) {
-                       bss_info->rsn_selected = FALSE;
-                       _parse_wpa_message(value, bss_info);
-               } else if (g_strcmp0(key, "IEs") == 0) {
-                       const guchar *ie;
-                       gsize ie_len;
-                       ie = g_variant_get_fixed_array(value, &ie_len, sizeof(guchar));
-                       DBG("The IE : %s", ie);
-               } else if (g_strcmp0(key, "BSSID") == 0) {
-                       const guchar *bssid;
-                       gsize bssid_len;
-
-                       bssid = g_variant_get_fixed_array(value, &bssid_len, sizeof(guchar));
-                       if (bssid != NULL && bssid_len == 6)
-                               memcpy(bss_info->bssid, bssid, bssid_len);
-               }
-       }
-
-       g_variant_iter_free(iter);
-       if (path)
-               g_free(path);
-
-       if (bss_info->ssid[0] == '\0') {
-               g_free(bss_info);
-               return;
-       }
-
-       if (bss_info->security == WIFI_SECURITY_UNKNOWN) {
-               if (bss_info->privacy == TRUE)
-                       bss_info->security = WIFI_SECURITY_WEP;
-               else
-                       bss_info->security = WIFI_SECURITY_NONE;
-       }
-
-       bss_info_list = g_slist_append(bss_info_list, bss_info);
-}
-
-gboolean handle_request_specific_scan(Wifi *wifi,
-               GDBusMethodInvocation *context, const gchar *ssid)
-{
-       gboolean result = FALSE;
-
-       g_return_val_if_fail(wifi != NULL, FALSE);
-       g_return_val_if_fail(ssid != NULL, FALSE);
-
-       result = wifi_ssid_scan((const char *)ssid);
-
-       if (result != TRUE)
-               netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailSpecificScan");
-       else
-               wifi_complete_request_specific_scan(wifi, context);
-
-       return result;
-}
index 0bdd05e..5d89458 100755 (executable)
@@ -352,7 +352,7 @@ static void _deregister_network_notification(void)
 static void _set_power_save(gboolean power_save)
 {
        gboolean result;
-       const char *if_path;
+       char *if_path;
        GVariant *input_args = NULL;
        static gboolean old_state = TRUE;
        const gchar *args_disable = "POWERMODE 1";
@@ -383,6 +383,8 @@ static void _set_power_save(gboolean power_save)
        else
                old_state = power_save;
 
+       g_free(if_path);
+
        return;
 }
 
index d9b95e4..319acbc 100755 (executable)
@@ -110,7 +110,7 @@ static gboolean _tdls_timer_discover_event(gpointer user_data)
 static GVariant * __netconfig_wifi_tdls_send_dbus_str(const char* method, const char *str)
 {
        GVariant *message = NULL;
-       const char *if_path = NULL;
+       char *if_path = NULL;
        GVariant *params = NULL;
 
        if_path = netconfig_wifi_get_supplicant_interface();
@@ -124,6 +124,7 @@ static GVariant * __netconfig_wifi_tdls_send_dbus_str(const char* method, const
        message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
                        if_path, SUPPLICANT_INTERFACE ".Interface", method, params);
 
+       g_free(if_path);
        INFO("TDLS Returned from Blocking method for Send DBUS Command");
        return message;
 }
@@ -308,7 +309,7 @@ gboolean handle_tdls_channel_switch(Wifi *wifi, GDBusMethodInvocation *context,
        GVariant *message = NULL;
        GVariantBuilder *builder;
        GVariant *params;
-       const char *if_path = NULL;
+       char *if_path = NULL;
        unsigned char oper_class = 0;
 
        if (peer_mac_Addr == NULL) {
@@ -347,6 +348,7 @@ gboolean handle_tdls_channel_switch(Wifi *wifi, GDBusMethodInvocation *context,
        message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
                                if_path, SUPPLICANT_INTERFACE ".Interface", "TDLSChannelSwitch", params);
 
+       g_free(if_path);
        if (message == NULL) {
                ERR(" TDLS : Fail to Process TDLS Channel Switch Request !!!");
                wifi_complete_tdls_channel_switch(wifi, context,
index 5f09eb7..6cf4262 100755 (executable)
@@ -155,12 +155,10 @@ static void __netconfig_wifi_invoke_wps_connect(GObject *source_object,
        GVariant *message = NULL;
        GVariantBuilder *builder = NULL;
        const char *role = "enrollee", *type, *key;
-       const char *if_path = NULL;
+       char *if_path = NULL;
        gboolean reply = FALSE;
 
-       if (if_path == NULL)
-               if_path = netconfig_wifi_get_supplicant_interface();
-
+       if_path = netconfig_wifi_get_supplicant_interface();
        if (if_path == NULL) {
                DBG("Fail to get wpa_supplicant DBus path");
                return;
@@ -196,13 +194,14 @@ static void __netconfig_wifi_invoke_wps_connect(GObject *source_object,
                        message,
                        (GAsyncReadyCallback) interface_wps_start_result);
 
+       g_free(if_path);
        if (reply != TRUE)
                ERR("Fail to Scan");
 
        return;
 }
 
-static gboolean __netconfig_wifi_invoke_wps_process_credentials(const char *object_path)
+static gboolean __netconfig_wifi_invoke_wps_process_credentials(char *object_path)
 {
        gboolean reply = FALSE;
        GVariant *params = NULL;
@@ -227,7 +226,7 @@ static gboolean __netconfig_wifi_invoke_wps_process_credentials(const char *obje
 
 gboolean netconfig_wifi_wps_connect()
 {
-       const char *if_path = NULL;
+       char *if_path = NULL;
 
        if_path = netconfig_wifi_get_supplicant_interface();
        if (if_path == NULL) {
@@ -237,10 +236,11 @@ gboolean netconfig_wifi_wps_connect()
 
        if (__netconfig_wifi_invoke_wps_process_credentials(if_path) == TRUE) {
                ERR("Wi-Fi WPS Connect started");
-
+               g_free(if_path);
                return TRUE;
        }
 
+       g_free(if_path);
        return FALSE;
 }
 
@@ -273,7 +273,7 @@ static void __interface_wps_cancel_result(GObject *source_object,
 static gboolean __netconfig_wifi_invoke_wps_cancel()
 {
        gboolean reply = FALSE;
-       const char *if_path = NULL;
+       char *if_path = NULL;
 
        if_path = netconfig_wifi_get_supplicant_interface();
        if (if_path == NULL) {
@@ -290,6 +290,7 @@ static gboolean __netconfig_wifi_invoke_wps_cancel()
        if (reply != TRUE)
                ERR("M/W--->WPAS: Interface.WPS.Cancel Method Failed");
 
+       g_free(if_path);
        return reply;
 }
 
index 972fa3d..ef8db47 100755 (executable)
@@ -35,7 +35,6 @@
 #include "wifi-state.h"
 #include "wifi-agent.h"
 #include "wifi-firmware.h"
-#include "wifi-ssid-scan.h"
 #include "wifi-passpoint.h"
 #include "wifi-eap-config.h"
 #include "wifi-background-scan.h"
@@ -162,8 +161,6 @@ void wifi_object_create_and_init(void)
                        G_CALLBACK(handle_get_wifi_state), NULL);
 
        /* WIFI scan */
-       g_signal_connect(wifi_object, "handle-request-specific-scan",
-                       G_CALLBACK(handle_request_specific_scan), NULL);
        g_signal_connect(wifi_object, "handle-request-bssid-scan",
                        G_CALLBACK(handle_request_bssid_scan), NULL);
        g_signal_connect(wifi_object, "handle-get-bssid-list",