#include "netsupplicant.h"
#include "wifi-background-scan.h"
-#define NETCONFIG_SSID_LEN 32
-#define NETCONFIG_BSSID_LEN 6
-#define NETCONFIG_WPS_DBUS_REPLY_TIMEOUT (10 * 1000)
-
-#define VCONF_WIFI_ALWAYS_ALLOW_SCANNING \
- "file/private/wifi/always_allow_scanning"
-
-static gboolean netconfig_is_wps_enabled = FALSE;
-static gboolean netconfig_is_device_scanning = FALSE;
-static gboolean netconfig_is_bssid_scan_aborted = FALSE;
-static int wps_bss_list_count = 0;
-
-struct bssid_scan_info_t {
- unsigned char ssid[NETCONFIG_SSID_LEN + 1];
- unsigned char bssid[NETCONFIG_BSSID_LEN + 1];
- int ssid_len;
- int rssi;
- int mode;
-};
-
-struct netconfig_wifi_wps {
+typedef struct {
+ char *interface_name;
char *pin;
gboolean pbc;
-};
+} wifi_wps_s;
-static struct netconfig_wifi_wps wifi_wps;
+GSList *g_wifi_wps_list = NULL;
-static GSList *wps_bss_info_list = NULL;
+static void __free_wifi_wps(gpointer data)
+{
+ wifi_wps_s *wifi_wps = data;
+
+ g_free(wifi_wps->interface_name);
+ g_free(wifi_wps->pin);
+ g_free(wifi_wps);
+}
+
+static wifi_wps_s *__get_wifi_wps(const char *interface_name)
+{
+ GSList *list = NULL;
+
+ for (list = g_wifi_wps_list; list; list = list->next) {
+ wifi_wps_s *wifi_wps = list->data;
+ if (g_strcmp0(wifi_wps->interface_name, interface_name) == 0)
+ return wifi_wps;
+ }
+
+ return NULL;
+}
+
+static void __destroy_wifi_wps(const char *interface_name)
+{
+ wifi_wps_s *wifi_wps;
+
+ wifi_wps = __get_wifi_wps(interface_name);
+ if (wifi_wps == NULL)
+ return;
+
+ g_wifi_wps_list = g_slist_remove(g_wifi_wps_list, wifi_wps);
+ __free_wifi_wps(wifi_wps);
+}
+
+static void __create_wifi_wps(const char *interface_name)
+{
+ wifi_wps_s *wifi_wps;
+
+ wifi_wps = g_try_new0(wifi_wps_s, 1);
+ if (wifi_wps == NULL)
+ return;
+
+ wifi_wps->interface_name = g_strdup(interface_name);
+ g_wifi_wps_list = g_slist_append(g_wifi_wps_list, wifi_wps);
+}
-static void __netconfig_wps_set_mode(gboolean enable)
+static void __set_wifi_wps(const char *interface_name, gboolean pbc, char *pin)
{
- if (netconfig_is_wps_enabled == enable)
+ wifi_wps_s *wifi_wps;
+
+ wifi_wps = __get_wifi_wps(interface_name);
+ if (wifi_wps == NULL)
return;
- netconfig_is_wps_enabled = enable;
+ wifi_wps->pbc = pbc;
+ if (pin)
+ wifi_wps->pin = g_strdup(pin);
+}
+
+static gboolean __get_wifi_wps_pbc(const char *interface_name)
+{
+ wifi_wps_s *wifi_wps;
+
+ wifi_wps = __get_wifi_wps(interface_name);
+ if (wifi_wps == NULL)
+ return FALSE;
+
+ return wifi_wps->pbc;
}
-gboolean netconfig_wifi_is_wps_enabled(void)
+static char *__get_wifi_wps_pin(const char *interface_name)
{
- return netconfig_is_wps_enabled;
+ wifi_wps_s *wifi_wps;
+
+ wifi_wps = __get_wifi_wps(interface_name);
+ if (wifi_wps == NULL)
+ return NULL;
+
+ return wifi_wps->pin;
}
-void netconfig_wifi_notify_wps_credentials(const char *ssid, gsize ssid_len, const char *wps_key)
+void netconfig_wifi_notify_wps_credentials(const char *interface_name,
+ const char *ssid, gsize ssid_len, const char *wps_key)
{
GVariantBuilder *builder;
GVariant *params;
g_variant_builder_unref(rawssid_builder);
g_variant_builder_add(builder, "{sv}", prop_key, g_variant_new_string(wps_key));
- params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+ params = g_variant_new("(s@a{sv})", interface_name,
+ g_variant_builder_end(builder));
g_variant_builder_unref(builder);
netconfig_dbus_emit_signal(NULL,
return;
}
-void netconfig_wifi_notify_wps_completed(const char *ssid, gsize ssid_len)
+void netconfig_wifi_notify_wps_completed(const char *interface_name,
+ const char *ssid, gsize ssid_len)
{
GVariantBuilder *builder;
GVariant *params;
g_variant_builder_add(builder, "{sv}", prop_ssid, g_variant_new("ay", rawssid_builder));
g_variant_builder_unref(rawssid_builder);
- params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+ params = g_variant_new("(s@a{sv})", interface_name,
+ g_variant_builder_end(builder));
g_variant_builder_unref(builder);
netconfig_dbus_emit_signal(NULL,
return;
}
-void netconfig_wifi_notify_wps_fail_event(int config_error, int error_indication)
+void netconfig_wifi_notify_wps_fail_event(const char *interface_name,
+ int config_error, int error_indication)
{
GVariantBuilder *builder;
GVariant *params;
g_variant_builder_add(builder, "{sv}", prop_config_error, g_variant_new_int32(config_error));
g_variant_builder_add(builder, "{sv}", prop_error_indication, g_variant_new_int32(error_indication));
- params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+ params = g_variant_new("(s@a{sv})", interface_name,
+ g_variant_builder_end(builder));
g_variant_builder_unref(builder);
netconfig_dbus_emit_signal(NULL,
return;
}
-static void __netconfig_wifi_wps_notify_scan_done(void)
-{
- GVariantBuilder *builder = NULL;
- GVariantBuilder *builder1 = NULL;
- GSList* list = NULL;
- const char *prop_ssid = "ssid";
- const char *prop_bssid = "bssid";
- const char *prop_rssi = "rssi";
- const char *prop_mode = "mode";
-
- builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
- for (list = wps_bss_info_list; list != NULL; list = list->next) {
- struct bssid_scan_info_t *bss_info = (struct bssid_scan_info_t *)list->data;
-
- if (bss_info) {
- gchar bssid_buff[18] = { 0, };
- gchar *bssid_str = bssid_buff;
- unsigned char *ssid = (unsigned char *)bss_info->ssid;
- int ssid_len = (int)bss_info->ssid_len;
- int rssi = (int)bss_info->rssi;
- int mode = (int)bss_info->mode;
- 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);
-
- builder1 = g_variant_builder_new(G_VARIANT_TYPE("ay"));
- for (i = 0; i < ssid_len; i++)
- g_variant_builder_add(builder1, "y", ssid[i]);
- g_variant_builder_add(builder, "{sv}", prop_ssid, g_variant_builder_end(builder1));
- g_variant_builder_unref(builder1);
-
- 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));
- }
- }
-
- wifi_emit_bssid_scan_completed((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
- g_variant_builder_unref(builder);
-
- if (wps_bss_info_list != NULL)
- g_slist_free_full(wps_bss_info_list, g_free);
-
- wps_bss_info_list = NULL;
- wps_bss_list_count = 0;
- INFO("BSSIDScanCompleted");
-
- return;
-}
-
-static void __netconfig_wifi_wps_get_bss_info_result(
- GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
- GVariant *reply = NULL;
- GVariant *value;
- GVariantIter *iter;
- gchar *key;
- struct bssid_scan_info_t *bss_info;
- GDBusConnection *conn = NULL;
- GError *error = NULL;
-
- conn = G_DBUS_CONNECTION(source_object);
- reply = g_dbus_connection_call_finish(conn, res, &error);
-
- if (error != NULL) {
- ERR("Error code: [%d] Error message: [%s]", error->code, error->message);
- g_error_free(error);
- goto done;
- }
-
- bss_info = g_try_new0(struct bssid_scan_info_t, 1);
- if (bss_info == NULL)
- goto done;
-
- g_variant_get(reply, "(a{sv})", &iter);
- while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
- if (key != NULL) {
- 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_len == NETCONFIG_BSSID_LEN)
- memcpy(bss_info->bssid, bssid, bssid_len);
- } else 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 <= NETCONFIG_SSID_LEN) {
- 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, "Mode") == 0) {
- gchar *mode = NULL;
-
- g_variant_get(value, "s", &mode);
- if (mode == NULL)
- bss_info->mode = 0;
- else {
- if (g_strcmp0(mode, "infrastructure") == 0)
- bss_info->mode = 1;
- else if (g_strcmp0(mode, "ad-hoc") == 0)
- bss_info->mode = 2;
- else
- bss_info->mode = 0;
- g_free(mode);
- }
- } else if (g_strcmp0(key, "Signal") == 0) {
- gint16 signal;
-
- signal = g_variant_get_int16(value);
- bss_info->rssi = signal;
- }
- }
- }
-
- if (bss_info->ssid[0] == '\0')
- g_free(bss_info);
- else
- wps_bss_info_list = g_slist_append(wps_bss_info_list, bss_info);
-
- g_variant_iter_free(iter);
-done:
- if (reply)
- g_variant_unref(reply);
-
- netconfig_gdbus_pending_call_unref();
-
- wps_bss_list_count--;
- if (wps_bss_list_count <= 0) {
- __netconfig_wifi_wps_notify_scan_done();
-
- if (netconfig_is_bssid_scan_aborted == FALSE)
- wifi_power_driver_and_supplicant(FALSE);
- }
-}
-
-static void __netconfig_wifi_wps_get_bss_info(const char *path, int index)
-{
- gboolean reply = FALSE;
- GVariant *param = NULL;
-
- param = g_variant_new("(s)", SUPPLICANT_IFACE_BSS);
-
- reply = netconfig_invoke_dbus_method_nonblock(SUPPLICANT_SERVICE,
- path, DBUS_INTERFACE_PROPERTIES,
- "GetAll", param, __netconfig_wifi_wps_get_bss_info_result);
- if (reply != TRUE)
- ERR("Fail to invoke_dbus_method_nonblock GetAll");
-
- return;
-}
-
-static void __netconfig_wifi_wps_get_bsss_result(GObject *source_object,
- GAsyncResult *res, gpointer user_data)
-{
- GVariant *reply = NULL;
- GVariant *value = NULL;
- GVariantIter *iter = NULL;
- GDBusConnection *conn = NULL;
- gchar *path = NULL;
- gboolean counter_flag = FALSE;
- GError *error = NULL;
-
- conn = G_DBUS_CONNECTION(source_object);
- reply = g_dbus_connection_call_finish(conn, res, &error);
- if (error != NULL) {
- ERR("Error code: [%d] Error message: [%s]", error->code, error->message);
- g_error_free(error);
- goto done;
- }
-
- g_variant_get(reply, "(v)", &value);
- if (g_variant_is_of_type(value, G_VARIANT_TYPE_OBJECT_PATH_ARRAY)) {
- g_variant_get(value, "ao", &iter);
- while (g_variant_iter_next(iter, "o", &path)) {
- if (path != NULL && g_strcmp0(path, "/") != 0) {
- __netconfig_wifi_wps_get_bss_info(path, ++wps_bss_list_count);
-
- counter_flag = TRUE;
- }
-
- if (path)
- g_free(path);
- }
- }
-
- if (iter)
- g_variant_iter_free(iter);
-
- if (value)
- g_variant_unref(value);
-
-done:
- if (reply)
- g_variant_unref(reply);
-
- netconfig_gdbus_pending_call_unref();
-
- /* Send BssidScanCompleted signal even when the BSS count is 0 */
- if (wps_bss_list_count <= 0 && counter_flag == FALSE) {
- __netconfig_wifi_wps_notify_scan_done();
-
- if (netconfig_is_bssid_scan_aborted == FALSE)
- wifi_power_driver_and_supplicant(FALSE);
- }
-}
-
-static int _netconfig_wifi_wps_get_bsss(void)
-{
- gboolean reply = FALSE;
- const char *if_path = NULL;
- GVariant *params = NULL;
-
- if_path = netconfig_wifi_get_supplicant_interface();
- if (if_path == NULL) {
- DBG("Fail to get wpa_supplicant DBus path");
- return -ESRCH;
- }
-
- 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_wps_get_bsss_result);
- if (reply != TRUE) {
- ERR("Fail to method: Get");
-
- return -ESRCH;
- }
-
- return 0;
-}
-
-void netconfig_wifi_wps_signal_scandone(void)
-{
- wps_bss_list_count = 0;
- _netconfig_wifi_wps_get_bsss();
-
- netconfig_is_device_scanning = FALSE;
-
- __netconfig_wps_set_mode(FALSE);
-}
-
-void netconfig_wifi_wps_signal_scanaborted(void)
-{
- wps_bss_list_count = 0;
- netconfig_is_bssid_scan_aborted = TRUE;
- _netconfig_wifi_wps_get_bsss();
-
- netconfig_is_device_scanning = FALSE;
-
- __netconfig_wps_set_mode(FALSE);
-}
-
-static int __netconfig_wifi_bssid_request_scan(const 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();
-
- if (if_path == NULL) {
- DBG("Fail to get wpa_supplicant DBus path");
- return -ESRCH;
- }
-
- connection = netdbus_get_connection();
- if (connection == NULL) {
- ERR("Failed to get GDBusconnection");
- return -EIO;
- }
-
- builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
- g_variant_builder_add(builder, "{sv}", key1, g_variant_new_string(val1));
- message = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
- g_variant_builder_unref(builder);
-
- g_dbus_connection_call(connection,
- SUPPLICANT_SERVICE,
- if_path,
- SUPPLICANT_INTERFACE ".Interface",
- "Scan",
- message,
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- NETCONFIG_WPS_DBUS_REPLY_TIMEOUT,
- netdbus_get_cancellable(),
- NULL,
- NULL);
-
- netconfig_is_device_scanning = TRUE;
-
- g_variant_unref(message);
- /* Clear bss_info_list for the next scan result */
- if (wps_bss_info_list) {
- g_slist_free_full(wps_bss_info_list, g_free);
- wps_bss_info_list = NULL;
- }
-
- netconfig_is_bssid_scan_aborted = FALSE;
-
- return 0;
-}
-
-static void __netconfig_wifi_interface_create_result(
- GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
- GVariant *message;
- gchar *path = NULL;
- GDBusConnection *conn = NULL;
- GError *error = NULL;
-
- conn = G_DBUS_CONNECTION(source_object);
-
- message = g_dbus_connection_call_finish(conn, res, &error);
- if (error == NULL) {
- g_variant_get(message, "(o)", &path);
-
- if (path) {
- __netconfig_wifi_bssid_request_scan(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);
- g_free(path);
- } else
- __netconfig_wifi_bssid_request_scan(NULL);
- } else {
- ERR("Failed to create interface, Error: %d[%s]", error->code, error->message);
- __netconfig_wps_set_mode(FALSE);
- wifi_power_driver_and_supplicant(FALSE);
- }
-
- g_variant_unref(message);
-}
-
-static int __netconfig_wifi_wps_create_interface(void)
-{
- 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;
- }
-
- builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
- g_variant_builder_add(builder, "{sv}", key, g_variant_new_string(val));
- message = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
-
- g_dbus_connection_call(connection,
- SUPPLICANT_SERVICE,
- SUPPLICANT_PATH,
- SUPPLICANT_INTERFACE,
- "CreateInterface",
- message,
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- NETCONFIG_WPS_DBUS_REPLY_TIMEOUT,
- netdbus_get_cancellable(),
- (GAsyncReadyCallback) __netconfig_wifi_interface_create_result,
- NULL);
-
- g_variant_unref(message);
-
- return 0;
-}
-
-static int __netconfig_wifi_bssid_scan(void)
-{
- int err = 0;
- wifi_tech_state_e wifi_tech_state;
-
- if (netconfig_is_device_scanning == TRUE)
- return -EINPROGRESS;
-
- wifi_tech_state = wifi_state_get_technology_state();
- if (wifi_tech_state <= NETCONFIG_WIFI_TECH_OFF)
- err = wifi_power_driver_and_supplicant(TRUE);
-
- if (err < 0 && err != -EALREADY)
- return err;
-
- netconfig_is_device_scanning = TRUE;
-
- DBG("BSSID scan requested");
- if (wifi_tech_state >= NETCONFIG_WIFI_TECH_POWERED) {
- if (netconfig_wifi_get_scanning() == TRUE)
- return -EINPROGRESS;
-
- netconfig_wifi_bgscan_start(TRUE);
-
- if (wifi_tech_state == NETCONFIG_WIFI_TECH_CONNECTED)
- __netconfig_wifi_bssid_request_scan(NULL);
- } else {
- err = __netconfig_wifi_wps_create_interface();
- }
-
- return err;
-}
-
-gboolean handle_request_bssid_scan(Wifi *wifi, GDBusMethodInvocation *context)
-{
- int err, enabled = 0;
- wifi_tech_state_e tech_state;
-
- g_return_val_if_fail(wifi != NULL, FALSE);
-
- 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;
- }
-
-#if !defined TIZEN_WEARABLE
- if (netconfig_wifi_is_bgscan_paused()) {
- ERR("Scan is paused");
- netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_NO_SERVICE, "ScanPaused");
- return FALSE;
- }
-#endif
-
- tech_state = wifi_state_get_technology_state();
- if (tech_state <= NETCONFIG_WIFI_TECH_OFF) {
-#if !defined TIZEN_WEARABLE
- enabled = 1;
-#else
- enabled = 0;
-#endif
-
- if (enabled == 0) {
- netconfig_error_permission_denied(context);
- return FALSE;
- }
- }
-
- __netconfig_wps_set_mode(TRUE);
-
- err = __netconfig_wifi_bssid_scan();
- if (err < 0) {
- if (err == -EINPROGRESS)
- netconfig_error_inprogress(context);
- else
- netconfig_error_wifi_driver_failed(context);
-
- return FALSE;
- }
-
- wifi_complete_request_bssid_scan(wifi, context);
- return TRUE;
-}
-
static void interface_wps_start_result(GObject *source_object,
GAsyncResult *res, gpointer user_data)
{
GVariant *message = NULL;
GVariantBuilder *builder = NULL;
const char *role = "enrollee", *type, *key;
- const char *if_path = NULL;
+ char *if_path = NULL;
gboolean reply = FALSE;
+ char *interface_name = user_data;
- if (if_path == 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");
+ g_free(interface_name);
return;
}
key = "Type";
- if (wifi_wps.pbc == TRUE)
+ if (__get_wifi_wps_pbc(interface_name) == TRUE)
type = "pbc";
else
type = "pin";
g_variant_builder_add(builder, "{sv}", key, g_variant_new_string(type));
- if (wifi_wps.pin != NULL) {
+ if (__get_wifi_wps_pin(interface_name) != NULL) {
key = "Pin";
- g_variant_builder_add(builder, "{sv}", key, g_variant_new_string(wifi_wps.pin));
+ g_variant_builder_add(builder, "{sv}", key,
+ g_variant_new_string(__get_wifi_wps_pin(interface_name)));
}
message = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
g_variant_builder_unref(builder);
SUPPLICANT_IFACE_WPS,
"Start",
message,
- (GAsyncReadyCallback) interface_wps_start_result);
+ (GAsyncReadyCallback) interface_wps_start_result,
+ NULL);
if (reply != TRUE)
ERR("Fail to Scan");
+ __destroy_wifi_wps(interface_name);
+ g_free(interface_name);
+ g_free(if_path);
return;
}
-static gboolean __netconfig_wifi_invoke_wps_process_credentials(const char *object_path)
+static gboolean __netconfig_wifi_invoke_wps_process_credentials(char *object_path,
+ const char *interface_name)
{
gboolean reply = FALSE;
GVariant *params = NULL;
const char *interface = SUPPLICANT_IFACE_WPS;
const char *key = "ProcessCredentials";
gboolean credentials = TRUE;
- GVariant *var = NULL;
- var = g_variant_new_boolean(credentials);
- params = g_variant_new("(ssv)", interface, key, var);
+ params = g_variant_new("(ssv)", interface, key, g_variant_new_boolean(credentials));
INFO("[net-config]: TizenMW-->WPAS: .Set");
reply = netconfig_invoke_dbus_method_nonblock(SUPPLICANT_SERVICE,
- object_path, DBUS_INTERFACE_PROPERTIES,
- "Set", params, __netconfig_wifi_invoke_wps_connect);
+ object_path, DBUS_INTERFACE_PROPERTIES, "Set", params,
+ __netconfig_wifi_invoke_wps_connect, g_strdup(interface_name));
if (reply != TRUE)
ERR("M/W--->WPAS: Interface.WPS.Set Method Failed");
return reply;
}
-gboolean netconfig_wifi_wps_connect()
+gboolean netconfig_wifi_wps_connect(const char *interface_name)
{
- const char *if_path = NULL;
+ char *if_path = 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 FALSE;
}
- if (__netconfig_wifi_invoke_wps_process_credentials(if_path) == TRUE) {
+ if (__netconfig_wifi_invoke_wps_process_credentials(if_path, interface_name) == TRUE) {
ERR("Wi-Fi WPS Connect started");
-
+ g_free(if_path);
return TRUE;
}
+ g_free(if_path);
return FALSE;
}
netconfig_gdbus_pending_call_unref();
}
-static gboolean __netconfig_wifi_invoke_wps_cancel()
+static gboolean __netconfig_wifi_invoke_wps_cancel(const char *interface_name)
{
gboolean reply = FALSE;
- const char *if_path = NULL;
+ char *if_path = 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;
DBG("M/W--->WPAS: Interface.WPS.Cancel Method");
reply = netconfig_invoke_dbus_method_nonblock(SUPPLICANT_SERVICE,
- if_path, SUPPLICANT_IFACE_WPS,
- "Cancel", NULL, __interface_wps_cancel_result);
+ if_path, SUPPLICANT_IFACE_WPS, "Cancel", NULL,
+ __interface_wps_cancel_result, NULL);
if (reply != TRUE)
ERR("M/W--->WPAS: Interface.WPS.Cancel Method Failed");
+ g_free(if_path);
return reply;
}
-gboolean netconfig_get_wps_field()
-{
- return wifi_wps.pbc;
-}
-
-gboolean handle_request_wps_cancel(Wifi *wifi, GDBusMethodInvocation *context)
+gboolean handle_request_wps_cancel(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname)
{
INFO("Received WPS PBC Cancel Request");
- g_return_val_if_fail(wifi != NULL, FALSE);
- __netconfig_wifi_invoke_wps_cancel();
+ g_return_val_if_fail(wifi != NULL, TRUE);
+ __netconfig_wifi_invoke_wps_cancel(ifname);
wifi_complete_request_wps_cancel(wifi, context);
return TRUE;
}
-gboolean handle_request_wps_connect(Wifi *wifi, GDBusMethodInvocation *context, gchar *param)
+gboolean handle_request_wps_connect(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, gchar *param)
{
INFO("Received WPS PBC/PIN Connection Request");
- g_return_val_if_fail(wifi != NULL, FALSE);
+ g_return_val_if_fail(wifi != NULL, TRUE);
/* Checking the value of pin if param have a string "PBC"
* in that scenario PBC will trigger otherwise PIN Connection */
+ __create_wifi_wps(ifname);
- if (g_strcmp0(param, "PBC") == 0) {
- wifi_wps.pbc = TRUE;
- wifi_wps.pin = NULL;
- } else {
- wifi_wps.pin = g_strdup(param);
- wifi_wps.pbc = FALSE;
- }
+ if (g_strcmp0(param, "PBC") == 0)
+ __set_wifi_wps(ifname, TRUE, NULL);
+ else
+ __set_wifi_wps(ifname, FALSE, param);
- netconfig_wifi_wps_connect();
+ netconfig_wifi_wps_connect(ifname);
wifi_complete_request_wps_connect(wifi, context);
return TRUE;