Merge "Add dbus method for getting wifi passphrase" into tizen
[platform/core/connectivity/net-config.git] / src / wifi-bssid-scan.c
old mode 100644 (file)
new mode 100755 (executable)
index 05ad0c1..1773752
@@ -25,6 +25,7 @@
 #include "util.h"
 #include "wifi-power.h"
 #include "wifi-state.h"
+#include "wifi-scan.h"
 #include "wifi-background-scan.h"
 
 #define NETCONFIG_SSID_LEN                                             32
 #define VCONF_WIFI_ALWAYS_ALLOW_SCANNING \
        "file/private/wifi/always_allow_scanning"
 
-static gboolean netconfig_is_bssid_scan_started = FALSE;
-static gboolean netconfig_is_device_scanning = FALSE;
-static gboolean netconfig_is_bssid_scan_aborted = FALSE;
-static int bssid_list_count = 0;
-static GSList *bssid_info_list = NULL;
-
-struct bssid_scan_info_t {
+typedef struct {
        unsigned char ssid[NETCONFIG_SSID_LEN + 1];
        unsigned char bssid[NETCONFIG_BSSID_LEN + 1];
        int ssid_len;
        int rssi;
        int mode;
-};
+       unsigned int frequency;
+} bssid_scan_info_s;
+
+typedef struct {
+       char *interface_name;
+       int scan_info_count;
+       GSList *scan_info_list;
+} bssid_scan_data_s;
+
+static GSList *g_bssid_scan_list = NULL;
+
+static void __free_bssid_scan_data(gpointer data)
+{
+       bssid_scan_data_s *scan_data = data;
+
+       g_slist_free_full(scan_data->scan_info_list, g_free);
+       g_free(scan_data->interface_name);
+       g_free(scan_data);
+}
 
-gboolean netconfig_wifi_is_bssid_scan_started(void)
+static bssid_scan_data_s *__create_bssid_scan_data(const char *interface_name)
 {
-       return netconfig_is_bssid_scan_started;
+       bssid_scan_data_s *scan_data;
+
+       scan_data = g_try_new0(bssid_scan_data_s, 1);
+       if (scan_data == NULL)
+               return NULL;
+
+       scan_data->interface_name = g_strdup(interface_name);
+
+       g_bssid_scan_list = g_slist_append(g_bssid_scan_list, scan_data);
+
+       return scan_data;
 }
 
-static void __netconfig_wifi_bssid_notify_scan_done(void)
+static bssid_scan_data_s *__get_bssid_scan_data(const char *interface_name)
+{
+       GSList *list = NULL;
+       bssid_scan_data_s *scan_data = NULL;
+
+       for (list = g_bssid_scan_list; list; list = list->next) {
+               scan_data = list->data;
+               if (g_strcmp0(scan_data->interface_name, interface_name) == 0)
+                       return scan_data;
+       }
+
+       scan_data = __create_bssid_scan_data(interface_name);
+       return scan_data;
+}
+
+static void __update_bssid_scan_info_count(const char *interface_name,
+               int mode)
+{
+       bssid_scan_data_s *scan_data;
+
+       scan_data = __get_bssid_scan_data(interface_name);
+       if (scan_data == NULL)
+               return;
+
+       if (mode == 0)
+               scan_data->scan_info_count--;
+       else
+               scan_data->scan_info_count++;
+}
+
+static int __get_bssid_scan_info_count(const char *interface_name)
+{
+       bssid_scan_data_s *scan_data;
+
+       scan_data = __get_bssid_scan_data(interface_name);
+       if (scan_data == NULL)
+               return 0;
+
+       return scan_data->scan_info_count;
+}
+
+static void __append_bssid_scan_info(const char *interface_name,
+               bssid_scan_info_s *scan_info)
+{
+       bssid_scan_data_s *scan_data;
+
+       scan_data = __get_bssid_scan_data(interface_name);
+       if (scan_data == NULL)
+               return;
+
+       scan_data->scan_info_list = g_slist_append(scan_data->scan_info_list, scan_info);
+}
+
+static void __destroy_bssid_scan_data(const char *interface_name)
+{
+       bssid_scan_data_s *scan_data;
+
+       scan_data = __get_bssid_scan_data(interface_name);
+       if (scan_data == NULL)
+               return;
+
+       g_bssid_scan_list = g_slist_remove(g_bssid_scan_list, scan_data);
+       __free_bssid_scan_data(scan_data);
+}
+
+static void __netconfig_wifi_bssid_notify_scan_done(const char *interface_name)
 {
        GVariantBuilder *builder = NULL;
        GVariantBuilder *builder1 = NULL;
@@ -61,10 +149,17 @@ static void __netconfig_wifi_bssid_notify_scan_done(void)
        const char *prop_bssid = "bssid";
        const char *prop_rssi = "rssi";
        const char *prop_mode = "mode";
+       const char *prop_freq = "frequency";
+       bssid_scan_data_s *scan_data = NULL;
 
        builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-       for (list = bssid_info_list; list != NULL; list = list->next) {
-               struct bssid_scan_info_t *bss_info = (struct bssid_scan_info_t *)list->data;
+
+       scan_data = __get_bssid_scan_data(interface_name);
+       if (scan_data == NULL)
+               goto done;
+
+       for (list = scan_data->scan_info_list; list != NULL; list = list->next) {
+               bssid_scan_info_s *bss_info = (bssid_scan_info_s *)list->data;
 
                if (bss_info) {
                        gchar bssid_buff[18] = { 0, };
@@ -73,12 +168,14 @@ static void __netconfig_wifi_bssid_notify_scan_done(void)
                        int ssid_len = (int)bss_info->ssid_len;
                        int rssi = (int)bss_info->rssi;
                        int mode = (int)bss_info->mode;
+                       guint32 frequency = (guint32)bss_info->frequency;
                        int i = 0;
                        g_snprintf(bssid_buff, 18, "%02x:%02x:%02x:%02x:%02x:%02x",
                                        bss_info->bssid[0], bss_info->bssid[1], bss_info->bssid[2],
                                        bss_info->bssid[3], bss_info->bssid[4], bss_info->bssid[5]);
 
-                       DBG("BSS found; SSID %s, BSSID %s, RSSI %d MODE %d", ssid, bssid_str, rssi, mode);
+                       SECURE_LOGD("BSS found; SSID %s, BSSID %s, RSSI %d MODE %d, Frequency %d",
+                                       ssid, bssid_str, rssi, mode, frequency);
 
                        builder1 = g_variant_builder_new(G_VARIANT_TYPE("ay"));
                        for (i = 0; i < ssid_len; i++)
@@ -89,17 +186,17 @@ static void __netconfig_wifi_bssid_notify_scan_done(void)
                        g_variant_builder_add(builder, "{sv}", prop_bssid, g_variant_new_string(bssid_str));
                        g_variant_builder_add(builder, "{sv}", prop_rssi, g_variant_new_int32(rssi));
                        g_variant_builder_add(builder, "{sv}", prop_mode, g_variant_new_int32(mode));
+                       g_variant_builder_add(builder, "{sv}", prop_freq, g_variant_new_uint32(frequency));
                }
        }
 
-       wifi_emit_bssid_scan_completed((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
+done:
+       wifi_emit_bssid_scan_completed((Wifi *)get_wifi_object(),
+               interface_name, g_variant_builder_end(builder));
        g_variant_builder_unref(builder);
 
-       if (bssid_info_list != NULL)
-               g_slist_free_full(bssid_info_list, g_free);
+       __destroy_bssid_scan_data(interface_name);
 
-       bssid_info_list = NULL;
-       bssid_list_count = 0;
        INFO("BSSIDScanCompleted");
 
        return;
@@ -112,9 +209,10 @@ static void __netconfig_wifi_bssid_get_bss_info_result(
        GVariant *value;
        GVariantIter *iter;
        gchar *key;
-       struct bssid_scan_info_t *bss_info;
+       bssid_scan_info_s *bss_info;
        GDBusConnection *conn = NULL;
        GError *error = NULL;
+       char *interface_name = user_data;
 
        conn = G_DBUS_CONNECTION(source_object);
        reply = g_dbus_connection_call_finish(conn, res, &error);
@@ -125,7 +223,7 @@ static void __netconfig_wifi_bssid_get_bss_info_result(
                goto done;
        }
 
-       bss_info = g_try_new0(struct bssid_scan_info_t, 1);
+       bss_info = g_try_new0(bssid_scan_info_s, 1);
        if (bss_info == NULL)
                goto done;
 
@@ -137,7 +235,7 @@ static void __netconfig_wifi_bssid_get_bss_info_result(
                                gsize bssid_len;
 
                                bssid = g_variant_get_fixed_array(value, &bssid_len, sizeof(guchar));
-                               if (bssid_len == NETCONFIG_BSSID_LEN)
+                               if (bssid != NULL && bssid_len == NETCONFIG_BSSID_LEN)
                                        memcpy(bss_info->bssid, bssid, bssid_len);
                        } else if (g_strcmp0(key, "SSID") == 0) {
                                const guchar *ssid;
@@ -171,6 +269,11 @@ static void __netconfig_wifi_bssid_get_bss_info_result(
 
                                signal = g_variant_get_int16(value);
                                bss_info->rssi = signal;
+                       } else if (g_strcmp0(key, "Frequency") == 0) {
+                               gint16 frequency;
+
+                               frequency = g_variant_get_uint16(value);
+                               bss_info->frequency = (unsigned int)frequency;
                        }
                }
        }
@@ -178,7 +281,7 @@ static void __netconfig_wifi_bssid_get_bss_info_result(
        if (bss_info->ssid[0] == '\0')
                g_free(bss_info);
        else
-               bssid_info_list = g_slist_append(bssid_info_list, bss_info);
+               __append_bssid_scan_info(interface_name, bss_info);
 
        g_variant_iter_free(iter);
 done:
@@ -187,16 +290,19 @@ done:
 
        netconfig_gdbus_pending_call_unref();
 
-       bssid_list_count--;
-       if (bssid_list_count <= 0) {
-               __netconfig_wifi_bssid_notify_scan_done();
+       __update_bssid_scan_info_count(interface_name, 0);
+       if (__get_bssid_scan_info_count(interface_name) <= 0) {
+               __netconfig_wifi_bssid_notify_scan_done(interface_name);
 
-               if (netconfig_is_bssid_scan_aborted == FALSE)
-                       wifi_power_driver_and_supplicant(FALSE);
+               if (netconfig_wifi_bssidscan_get_aborted(interface_name) == FALSE)
+                       wifi_power_driver_and_supplicant(interface_name, FALSE);
        }
+
+       g_free(interface_name);
 }
 
-static void __netconfig_wifi_bssid_get_bss_info(const char *path, int index)
+static void __netconfig_wifi_bssid_get_bss_info(const char *interface_name,
+               const char *path)
 {
        gboolean reply = FALSE;
        GVariant *param = NULL;
@@ -204,8 +310,9 @@ static void __netconfig_wifi_bssid_get_bss_info(const char *path, int index)
        param = g_variant_new("(s)", SUPPLICANT_IFACE_BSS);
 
        reply = netconfig_invoke_dbus_method_nonblock(SUPPLICANT_SERVICE,
-                       path, DBUS_INTERFACE_PROPERTIES,
-                       "GetAll", param, __netconfig_wifi_bssid_get_bss_info_result);
+                       path, DBUS_INTERFACE_PROPERTIES, "GetAll", param,
+                       __netconfig_wifi_bssid_get_bss_info_result,
+                       g_strdup(interface_name));
        if (reply != TRUE)
                ERR("Fail to invoke_dbus_method_nonblock GetAll");
 
@@ -222,6 +329,7 @@ static void __netconfig_wifi_bssid_get_bss_result(GObject *source_object,
        gchar *path = NULL;
        gboolean counter_flag = FALSE;
        GError *error = NULL;
+       char *interface_name = user_data;
 
        conn = G_DBUS_CONNECTION(source_object);
        reply = g_dbus_connection_call_finish(conn, res, &error);
@@ -236,7 +344,8 @@ static void __netconfig_wifi_bssid_get_bss_result(GObject *source_object,
                g_variant_get(value, "ao", &iter);
                while (g_variant_iter_next(iter, "o", &path)) {
                        if (path != NULL && g_strcmp0(path, "/") != 0) {
-                               __netconfig_wifi_bssid_get_bss_info(path, ++bssid_list_count);
+                               __update_bssid_scan_info_count(interface_name, 1);
+                               __netconfig_wifi_bssid_get_bss_info(interface_name, path);
 
                                counter_flag = TRUE;
                        }
@@ -259,21 +368,23 @@ done:
        netconfig_gdbus_pending_call_unref();
 
        /* Send BssidScanCompleted signal even when the BSS count is 0 */
-       if (bssid_list_count <= 0 && counter_flag == FALSE) {
-               __netconfig_wifi_bssid_notify_scan_done();
+       if (__get_bssid_scan_info_count(interface_name) <= 0 && counter_flag == FALSE) {
+               __netconfig_wifi_bssid_notify_scan_done(interface_name);
 
-               if (netconfig_is_bssid_scan_aborted == FALSE)
-                       wifi_power_driver_and_supplicant(FALSE);
+               if (netconfig_wifi_bssidscan_get_aborted(interface_name) == FALSE)
+                       wifi_power_driver_and_supplicant(interface_name, FALSE);
        }
+
+       g_free(interface_name);
 }
 
-static int _netconfig_wifi_bssid_get_bss(void)
+static int _netconfig_wifi_bssid_get_bss(const char *interface_name)
 {
        gboolean reply = FALSE;
-       const char *if_path = NULL;
+       char *if_path = NULL;
        GVariant *params = NULL;
 
-       if_path = netconfig_wifi_get_supplicant_interface();
+       if_path = netconfig_wifi_get_supplicant_interface_path(interface_name);
        if (if_path == NULL) {
                DBG("Fail to get wpa_supplicant DBus path");
                return -ESRCH;
@@ -282,8 +393,11 @@ static int _netconfig_wifi_bssid_get_bss(void)
        params = g_variant_new("(ss)", SUPPLICANT_IFACE_INTERFACE, "BSSs");
 
        reply = netconfig_invoke_dbus_method_nonblock(SUPPLICANT_SERVICE,
-                       if_path, DBUS_INTERFACE_PROPERTIES,
-                       "Get", params, __netconfig_wifi_bssid_get_bss_result);
+                       if_path, DBUS_INTERFACE_PROPERTIES, "Get", params,
+                       __netconfig_wifi_bssid_get_bss_result,
+                       g_strdup(interface_name));
+
+       g_free(if_path);
        if (reply != TRUE) {
                ERR("Fail to method: Get");
 
@@ -293,56 +407,65 @@ static int _netconfig_wifi_bssid_get_bss(void)
        return 0;
 }
 
-
-static void __netconfig_set_bssid_scan_mode(gboolean enable)
+void netconfig_wifi_bssid_signal_scandone(const char *interface_name)
 {
-       if (netconfig_is_bssid_scan_started == enable)
-               return;
+       _netconfig_wifi_bssid_get_bss(interface_name);
 
-       netconfig_is_bssid_scan_started = enable;
+       netconfig_wifi_bssidscan_set_scanning(interface_name, FALSE);
+       netconfig_wifi_bssidscan_set_mode(interface_name, FALSE);
 }
 
-void netconfig_wifi_bssid_signal_scandone(void)
+void netconfig_wifi_bssid_signal_scanaborted(const char *interface_name)
 {
-       bssid_list_count = 0;
-       _netconfig_wifi_bssid_get_bss();
+       netconfig_wifi_bssidscan_set_aborted(interface_name, TRUE);
+       _netconfig_wifi_bssid_get_bss(interface_name);
 
-       netconfig_is_device_scanning = FALSE;
-
-       __netconfig_set_bssid_scan_mode(FALSE);
+       netconfig_wifi_bssidscan_set_scanning(interface_name, FALSE);
+       netconfig_wifi_bssidscan_set_mode(interface_name, FALSE);
 }
 
-void netconfig_wifi_bssid_signal_scanaborted(void)
+static void __netconfig_wifi_bssid_scan_request_reply(GObject *source_object,
+               GAsyncResult *res, gpointer user_data)
 {
-       bssid_list_count = 0;
-       netconfig_is_bssid_scan_aborted = TRUE;
-       _netconfig_wifi_bssid_get_bss();
+       GVariant *message;
+       GDBusConnection *conn = NULL;
+       GError *error = NULL;
 
-       netconfig_is_device_scanning = FALSE;
+       conn = G_DBUS_CONNECTION(source_object);
+       message = g_dbus_connection_call_finish(conn, res, &error);
+
+       if (message == NULL) {
+               if (error != NULL) {
+                       ERR("Fail to request status [%d: %s]", error->code, error->message);
+                       g_error_free(error);
+               } else {
+                       ERR("Fail to request bssid scan");
+               }
+       } else {
+               DBG("Successfully requested bssid scan");
+               g_variant_unref(message);
+       }
 
-       __netconfig_set_bssid_scan_mode(FALSE);
+       netconfig_gdbus_pending_call_unref();
 }
 
-static int __netconfig_wifi_bssid_request_scan(const char *if_path)
+static int __netconfig_wifi_bssid_request_scan(const char *interface_name, char *if_path)
 {
-       GDBusConnection *connection = NULL;
        GVariant *message = NULL;
        GVariantBuilder *builder = NULL;
        const char *key1 = "Type";
        const char *val1 = "passive";
-
-       if (if_path == NULL)
-               if_path = netconfig_wifi_get_supplicant_interface();
+       gboolean is_free_required = FALSE;
+       gboolean reply = FALSE;
 
        if (if_path == NULL) {
-               DBG("Fail to get wpa_supplicant DBus path");
-               return -ESRCH;
+               if_path = netconfig_wifi_get_supplicant_interface_path(interface_name);
+               is_free_required = TRUE;
        }
 
-       connection = netdbus_get_connection();
-       if (connection == NULL) {
-               ERR("Failed to get GDBusconnection");
-               return -EIO;
+       if (if_path == NULL) {
+               DBG("Fail to get wpa_supplicant DBus path");
+               goto out;
        }
 
        builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
@@ -350,29 +473,31 @@ static int __netconfig_wifi_bssid_request_scan(const char *if_path)
        message = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
        g_variant_builder_unref(builder);
 
-       g_dbus_connection_call(connection,
+       DBG("[net-config]: TizenMW-->WPAS: .Interface.Scan");
+       reply = netconfig_supplicant_invoke_dbus_method_nonblock(
                        SUPPLICANT_SERVICE,
                        if_path,
                        SUPPLICANT_INTERFACE ".Interface",
                        "Scan",
                        message,
-                       NULL,
-                       G_DBUS_CALL_FLAGS_NONE,
-                       NETCONFIG_DBUS_REPLY_TIMEOUT,
-                       netdbus_get_cancellable(),
-                       NULL,
+                       (GAsyncReadyCallback) __netconfig_wifi_bssid_scan_request_reply,
                        NULL);
 
-       netconfig_is_device_scanning = TRUE;
+       if (reply != TRUE) {
+               ERR("Fail to Scan");
+               goto out;
+       }
+
+       netconfig_wifi_bssidscan_set_scanning(interface_name, TRUE);
+
+out:
+       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) {
-               g_slist_free_full(bssid_info_list, g_free);
-               bssid_info_list = NULL;
-       }
+       __destroy_bssid_scan_data(interface_name);
 
-       netconfig_is_bssid_scan_aborted = FALSE;
+       netconfig_wifi_bssidscan_set_aborted(interface_name, FALSE);
 
        return 0;
 }
@@ -380,10 +505,11 @@ static int __netconfig_wifi_bssid_request_scan(const char *if_path)
 static void __netconfig_wifi_interface_create_result(
                GObject *source_object, GAsyncResult *res, gpointer user_data)
 {
-       GVariant *message;
+       GVariant *message = NULL;
        gchar *path = NULL;
        GDBusConnection *conn = NULL;
        GError *error = NULL;
+       char *interface_name = user_data;
 
        conn = G_DBUS_CONNECTION(source_object);
 
@@ -392,117 +518,115 @@ static void __netconfig_wifi_interface_create_result(
                g_variant_get(message, "(o)", &path);
 
                if (path) {
-                       __netconfig_wifi_bssid_request_scan(path);
+                       __netconfig_wifi_bssid_request_scan(interface_name, path);
                        g_free(path);
                }
        } else if (NULL != strstr(error->message, ".InterfaceExists")) {
                INFO("Error Message %s %s", error->message, path);
                g_variant_get(message, "(o)", &path);
                if (path) {
-                       __netconfig_wifi_bssid_request_scan(path);
+                       __netconfig_wifi_bssid_request_scan(interface_name, path);
                        g_free(path);
                } else
-                       __netconfig_wifi_bssid_request_scan(NULL);
+                       __netconfig_wifi_bssid_request_scan(interface_name, NULL);
+
+               g_error_free(error);
        } else {
                ERR("Failed to create interface, Error: %d[%s]", error->code, error->message);
-               __netconfig_set_bssid_scan_mode(FALSE);
-               wifi_power_driver_and_supplicant(FALSE);
+               netconfig_wifi_bssidscan_set_mode(interface_name, FALSE);
+               wifi_power_driver_and_supplicant(interface_name, FALSE);
+               g_error_free(error);
        }
 
        g_variant_unref(message);
+       g_free(interface_name);
+       netconfig_gdbus_pending_call_unref();
 }
 
-static int  __netconfig_wifi_bssid_create_interface(void)
+static int  __netconfig_wifi_bssid_create_interface(const char *interface_name)
 {
-       GDBusConnection *connection = NULL;
        GVariant *message = NULL;
        GVariantBuilder *builder = NULL;
        const char *key = "Ifname";
-       const char *val = WIFI_IFNAME;
-
-       connection = netdbus_get_connection();
-       if (connection == NULL) {
-               DBG("Failed to get GDBusconnection");
-               return -EIO;
-       }
+       gboolean reply = FALSE;
 
        builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-       g_variant_builder_add(builder, "{sv}", key, g_variant_new_string(val));
+       g_variant_builder_add(builder, "{sv}", key, g_variant_new_string(interface_name));
        message = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
 
-       g_dbus_connection_call(connection,
+       DBG("[net-config]: TizenMW-->WPAS: CreateInterface");
+       reply = netconfig_supplicant_invoke_dbus_method_nonblock(
                        SUPPLICANT_SERVICE,
                        SUPPLICANT_PATH,
                        SUPPLICANT_INTERFACE,
                        "CreateInterface",
                        message,
-                       NULL,
-                       G_DBUS_CALL_FLAGS_NONE,
-                       NETCONFIG_DBUS_REPLY_TIMEOUT,
-                       netdbus_get_cancellable(),
                        (GAsyncReadyCallback) __netconfig_wifi_interface_create_result,
-                       NULL);
+                       g_strdup(interface_name));
 
-       g_variant_unref(message);
+       if (reply != TRUE)
+               ERR("Fail to CreateInterface");
 
        return 0;
 }
 
-static int __netconfig_wifi_bssid_scan(void)
+static int __netconfig_wifi_bssid_scan(const char *interface_name)
 {
        int err = 0;
        wifi_tech_state_e wifi_tech_state;
 
-       if (netconfig_is_device_scanning == TRUE)
+       if (netconfig_wifi_bssidscan_get_scanning(interface_name) == TRUE)
                return -EINPROGRESS;
 
-       wifi_tech_state = wifi_state_get_technology_state();
+       wifi_tech_state = wifi_state_get_technology_state(interface_name);
        if (wifi_tech_state <= NETCONFIG_WIFI_TECH_OFF)
-               err = wifi_power_driver_and_supplicant(TRUE);
+               err = wifi_power_driver_and_supplicant(interface_name, TRUE);
 
        if (err < 0 && err != -EALREADY)
                return err;
 
-       netconfig_is_device_scanning = TRUE;
+       netconfig_wifi_bssidscan_set_scanning(interface_name, TRUE);
 
        DBG("BSSID scan requested");
        if (wifi_tech_state >= NETCONFIG_WIFI_TECH_POWERED) {
-               if (netconfig_wifi_get_scanning() == TRUE)
+               if (netconfig_wifi_scan_get_scanning(interface_name) == TRUE)
                        return -EINPROGRESS;
 
-               netconfig_wifi_bgscan_start(TRUE);
+               netconfig_wifi_bgscan_start(interface_name, TRUE);
 
                if (wifi_tech_state == NETCONFIG_WIFI_TECH_CONNECTED)
-                       __netconfig_wifi_bssid_request_scan(NULL);
+                       __netconfig_wifi_bssid_request_scan(interface_name, NULL);
        } else {
-               err = __netconfig_wifi_bssid_create_interface();
+               err = __netconfig_wifi_bssid_create_interface(interface_name);
        }
 
        return err;
 }
 
-gboolean handle_request_bssid_scan(Wifi *wifi, GDBusMethodInvocation *context)
+gboolean handle_request_bssid_scan(Wifi *wifi, GDBusMethodInvocation *context,
+               const gchar *ifname)
 {
        int err, enabled = 0;
        wifi_tech_state_e tech_state;
 
-       g_return_val_if_fail(wifi != NULL, FALSE);
+       g_return_val_if_fail(wifi != NULL, TRUE);
 
        if (netconfig_is_wifi_tethering_on() == TRUE) {
                ERR("Wi-Fi Tethering is enabled");
                netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_NO_SERVICE, "TetheringEnabled");
-               return -EBUSY;
+               return TRUE;
        }
 
 #if !defined TIZEN_WEARABLE
-       if (netconfig_wifi_is_bgscan_paused()) {
+       if (netconfig_wifi_bgscan_is_paused(ifname)) {
                ERR("Scan is paused");
                netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_NO_SERVICE, "ScanPaused");
-               return FALSE;
+               return TRUE;
        }
 #endif
 
-       tech_state = wifi_state_get_technology_state();
+       tech_state = wifi_state_get_technology_state(ifname);
        if (tech_state <= NETCONFIG_WIFI_TECH_OFF) {
 #if !defined TIZEN_WEARABLE
                enabled = 1;
@@ -512,29 +636,32 @@ gboolean handle_request_bssid_scan(Wifi *wifi, GDBusMethodInvocation *context)
 
                if (enabled == 0) {
                        netconfig_error_permission_denied(context);
-                       return FALSE;
+                       return TRUE;
                }
        }
 
-       __netconfig_set_bssid_scan_mode(TRUE);
+       netconfig_wifi_bssidscan_set_mode(ifname, TRUE);
 
-       err = __netconfig_wifi_bssid_scan();
+       err = __netconfig_wifi_bssid_scan(ifname);
        if (err < 0) {
                if (err == -EINPROGRESS)
                        netconfig_error_inprogress(context);
                else
                        netconfig_error_wifi_driver_failed(context);
 
-               return FALSE;
+               return TRUE;
        }
 
        wifi_complete_request_bssid_scan(wifi, context);
        return TRUE;
 }
 
-gboolean handle_get_bssid_list(Wifi *wifi, GDBusMethodInvocation *context)
+gboolean handle_get_bssid_list(Wifi *wifi, GDBusMethodInvocation *context,
+               const gchar *ifname)
 {
-       _netconfig_wifi_bssid_get_bss();
+       __create_bssid_scan_data(ifname);
+       _netconfig_wifi_bssid_get_bss(ifname);
+
        wifi_complete_get_bssid_list(wifi, context);
        return TRUE;
 }