src/neterror.c
src/wifi-eap.c
src/wifi-wps.c
+ src/wifi-scan.c
src/wifi-bssid-scan.c
src/wifi-netlink-scan.c
src/wifi-agent.c
src/wifi-passpoint.c
src/utils/log.c
src/utils/util.c
+ src/utils/setting.c
src/vpnsvc.c
src/vpnsvc-internal.c
src/mptcp.c
struct sock_data * start_ip_conflict_mon(void);
void stop_ip_conflict_mon();
gboolean handle_ip_conflict_set_enable(Wifi *wifi, GDBusMethodInvocation *context,
- bool detect);
-gboolean handle_is_ip_conflict_detect_enabled(Wifi *wifi, GDBusMethodInvocation *context);
+ const gchar *ifname, bool detect);
+gboolean handle_is_ip_conflict_detect_enabled(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname);
gboolean handle_set_ip_conflict_period(Wifi *wifi, GDBusMethodInvocation *context,
- guint initial_time);
-gboolean handle_get_ip_conflict_state(Wifi *wifi, GDBusMethodInvocation
- *context);
-gboolean handle_get_ip_conflict_period(Wifi *wifi, GDBusMethodInvocation *context);
+ const gchar *ifname, guint initial_time);
+gboolean handle_get_ip_conflict_state(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname);
+gboolean handle_get_ip_conflict_period(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname);
#ifdef __cplusplus
gboolean netconfig_invoke_dbus_method_nonblock(const char *dest, const char *path,
const char *interface_name, const char *method, GVariant *params,
- GAsyncReadyCallback notify_func);
+ GAsyncReadyCallback notify_func, void *user_data);
GVariant *netconfig_invoke_dbus_method(const char *dest, const char *path,
const char *interface_name, const char *method,
GVariant *params);
/* Returns Supplicant interface.
* Need to release interface using g_free */
-char *netconfig_wifi_get_supplicant_interface(void);
+char *netconfig_wifi_get_supplicant_interface_path(const char *interface_name);
/* Adhoc solution to use P2P interface */
char *netconfig_wifi_get_supplicant_p2p_interface(void);
gboolean netconfig_supplicant_invoke_dbus_method_nonblock(const char *dest,
const char *path, const char *interface_name,
const char *method, GVariant *params,
- GAsyncReadyCallback notify_func);
-GVariant *netconfig_supplicant_invoke_dbus_interface_property_get(const char *interface,
+ GAsyncReadyCallback notify_func, void *user_data);
+GVariant *netconfig_supplicant_invoke_dbus_interface_property_get(const char *interface_name,
const char *key);
-gboolean netconfig_supplicant_invoke_dbus_interface_property_set(const char *interface,
+gboolean netconfig_supplicant_invoke_dbus_interface_property_set(const char *interface_name,
const char *key, GVariant *message,
GAsyncReadyCallback notify_func);
const char *netconfig_wifi_get_connected_essid(const char *default_profile);
gboolean netconfig_get_default_is_metered(void);
+void netconfig_set_default_ipaddress(const char *ipaddr);
+void netconfig_set_default_ipaddress6(const char *ipaddr);
+void netconfig_set_default_proxy(const char *proxy);
+
void netconfig_update_default(void);
-void netconfig_update_default_profile(const char *profile);
-char *netconfig_get_ifname(const char *profile);
+void netconfig_update_default_profile(void);
+const char *netconfig_get_ifname(const char *profile);
void state_object_create_and_init(void);
void state_object_deinit(void);
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2020 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_SETTING_H__
+#define __NETCONFIG_SETTING_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+#include <stdbool.h>
+
+#define NETCONFIG_SETTINGS_PATH "/var/lib/net-config/settings"
+#define SETTINGS_WIFI_GROUP_NAME "Wifi"
+
+void netconfig_setting_init(void);
+void netconfig_setting_deinit(void);
+
+int netconfig_setting_save(void);
+int netconfig_setting_load(void);
+
+void netconfig_setting_update_interface_for_last_powered(const char *interface_name,
+ bool mode);
+GSList *netconfig_setting_get_interfaces_for_last_powered(void);
+
+void netconfig_setting_update_interface_off_for_airplane(const char *interface_name,
+ bool mode);
+GSList *netconfig_setting_get_interfaces_off_by_airplane(void);
+
+void netconfig_setting_update_interface_off_for_restricted(const char *interface_name,
+ bool mode);
+GSList *netconfig_setting_get_interfaces_off_by_restricted(void);
+
+void netconfig_setting_update_interface_off_for_emergency(const char *interface_name,
+ bool mode);
+GSList *netconfig_setting_get_interfaces_off_by_emergency(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_SETTING_H__ */
#include "wifi.h"
#include "plugin.h"
+#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
+
#define NETCONFIG_TIZEN_SYSTEM_ENV "/run/tizen-system-env"
+#define MAC_ADDRESS_MAX_LEN 18
#define MAX_SIZE_ERROR_BUFFER 256
#define ETHERNET_FEATURE "http://tizen.org/feature/network.ethernet"
bool netconfig_check_feature_supported(netconfig_supported_feature_e feature);
+gboolean netconfig_check_mac_address(const char *service, const char *mac_address);
gboolean netconfig_check_passphrase(const gchar *service, const char *passphrase);
+
GKeyFile *netconfig_keyfile_load(const char *pathname);
void netconfig_keyfile_save(GKeyFile *keyfile, const char *pathname);
gboolean connman_register_agent(void);
gboolean connman_unregister_agent(void);
-gboolean netconfig_wifi_set_agent_field_for_eap_network(
+gboolean netconfig_wifi_set_agent_field_for_eap_network(const char *interface_name,
const char *name, const char *identity, const char *passphrase);
gboolean handle_set_field(NetConnmanAgent *connman_agent,
#include "wifi.h"
-#if defined TIZEN_WEARABLE
-#define SCAN_PERIODIC_DELAY 15
-#define SCAN_EXPONENTIAL_MIN 5
-#define SCAN_EXPONENTIAL_MAX 320
-#else
-#define SCAN_PERIODIC_DELAY 10
-#define SCAN_EXPONENTIAL_MIN 4
-#define SCAN_EXPONENTIAL_MAX 128
-#endif
-
-enum {
- WIFI_BGSCAN_MODE_EXPONENTIAL = 0x00,
- WIFI_BGSCAN_MODE_PERIODIC,
- WIFI_BGSCAN_MODE_MAX,
-};
-
-void netconfig_wifi_bgscan_start(gboolean immediate_scan);
-void netconfig_wifi_bgscan_stop(void);
-gboolean netconfig_wifi_get_bgscan_state(void);
-guint netconfig_wifi_bgscan_get_mode(void);
-
-gboolean netconfig_wifi_get_scanning(void);
-void netconfig_wifi_set_scanning(gboolean scanning);
-
-gboolean netconfig_wifi_block_bgscan(int status);
-void netconfig_wifi_set_bgscan_pause(gboolean pause);
-gboolean netconfig_wifi_bgscan_set_interval(guint interval);
-void netconfig_wifi_bgscan_get_interval(guint *interval);
-gboolean netconfig_wifi_is_bgscan_paused(void);
-
-gboolean handle_set_bgscan(Wifi *wifi, GDBusMethodInvocation *context, guint scan_mode);
-gboolean handle_resume_bgscan(Wifi *wifi, GDBusMethodInvocation *context);
-gboolean handle_pause_bgscan(Wifi *wifi, GDBusMethodInvocation *context);
-gboolean handle_reset_bgscan_interval(Wifi *wifi, GDBusMethodInvocation *context);
-
-gboolean handle_get_autoscan(Wifi *wifi, GDBusMethodInvocation *context);
-gboolean handle_get_autoscanmode(Wifi *wifi, GDBusMethodInvocation *context);
+void netconfig_wifi_bgscan_start(const char *interface_name, gboolean immediate_scan);
+void netconfig_wifi_bgscan_stop(const char *interface_name);
+
+gboolean handle_set_bgscan(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, guint scan_mode);
+gboolean handle_resume_bgscan(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname);
+gboolean handle_pause_bgscan(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname);
+gboolean handle_reset_bgscan_interval(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname);
+
+gboolean handle_get_autoscan(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname);
+gboolean handle_get_autoscanmode(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname);
#include "wifi.h"
-gboolean netconfig_wifi_is_bssid_scan_started(void);
+void netconfig_wifi_bssid_signal_scandone(const char *interface_name);
+void netconfig_wifi_bssid_signal_scanaborted(const char *interface_name);
-void netconfig_wifi_bssid_signal_scandone(void);
-void netconfig_wifi_bssid_signal_scanaborted(void);
-
-gboolean handle_request_bssid_scan(Wifi *wifi, GDBusMethodInvocation *context);
-gboolean handle_get_bssid_list(Wifi *wifi, GDBusMethodInvocation *context);
+gboolean handle_request_bssid_scan(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname);
+gboolean handle_get_bssid_list(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname);
#ifdef __cplusplus
}
NETCONFIG_VSIE_FRAME_MAX
} netconfig_vsie_frames_e;
-gboolean wifi_config_get_config_id(const gchar *service_profile, gchar **config_id);
-gboolean wifi_config_remove_configuration(const gchar *config_id);
-gboolean wifi_config_save_configuration(const gchar *config_id, GKeyFile *keyfile);
-gboolean wifi_config_get_group_name(const gchar *prefix, const gchar *config_id, gchar **group_name);
+gboolean wifi_config_get_config_id(const gchar *service_profile, gchar **config_id);
+gboolean wifi_config_remove_configuration(const gchar *interface_name,
+ const gchar *config_id);
+gboolean wifi_config_save_configuration(const gchar *interface_name,
+ const gchar *config_id, GKeyFile *keyfile);
+gboolean wifi_config_get_group_name(const gchar *prefix,
+ const gchar *interface_name, const gchar *config_id, gchar **group_name);
int __netconfig_hex_str_to_bin(const char *hex, unsigned char *buf, size_t len);
int __netconfig_hex_to_byte(const char *hex);
int __netconfig_hex_char_to_num(char c);
-gboolean handle_get_config_ids(Wifi *wifi, GDBusMethodInvocation *context);
-gboolean handle_load_configuration(Wifi *wifi, GDBusMethodInvocation *context, const gchar *config_id);
-gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context, const gchar *config_id, GVariant *configuration);
-gboolean handle_load_eap_configuration(Wifi *wifi, GDBusMethodInvocation *context, const gchar *config_id);
-gboolean handle_save_eap_configuration(Wifi *wifi, GDBusMethodInvocation *context, const gchar *config_id, GVariant *configuration);
-gboolean handle_remove_configuration(Wifi *wifi, GDBusMethodInvocation *context, const gchar *config_id);
-gboolean handle_set_config_field(Wifi *wifi, GDBusMethodInvocation *context, const gchar *config_id, const gchar *key, const gchar *value);
-gboolean handle_get_config_passphrase(Wifi *wifi, GDBusMethodInvocation *context, const gchar *config_id);
+gboolean handle_get_config_ids(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname);
+gboolean handle_load_configuration(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, const gchar *config_id);
+gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, const gchar *config_id, GVariant *configuration);
+gboolean handle_load_eap_configuration(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, const gchar *config_id);
+gboolean handle_save_eap_configuration(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, const gchar *config_id, GVariant *configuration);
+gboolean handle_remove_configuration(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, const gchar *config_id);
+gboolean handle_set_config_field(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, const gchar *config_id, const gchar *key, const gchar *value);
+gboolean handle_get_config_passphrase(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, const gchar *config_id);
-gboolean handle_add_vsie(Wifi *wifi, GDBusMethodInvocation *context, int frame_id, const gchar *vsie);
-gboolean handle_get_vsie(Wifi *wifi, GDBusMethodInvocation *context, int frame_id);
-gboolean handle_remove_vsie(Wifi *wifi, GDBusMethodInvocation *context, int frame_id, const gchar *vsie);
+gboolean handle_add_vsie(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, int frame_id, const gchar *vsie);
+gboolean handle_get_vsie(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, int frame_id);
+gboolean handle_remove_vsie(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, int frame_id, const gchar *vsie);
#ifdef __cplusplus
}
void netconfig_wifi_dpp_network_id_event(GVariant *message);
void netconfig_wifi_dpp_conf_sent_event(GVariant *message);
void netconfig_wifi_dpp_conf_received_event(GVariant *message);
-void netconfig_wifi_dpp_conf_obj_event(GVariant *message);
+void netconfig_wifi_dpp_conf_obj_event(const char *interface_name, GVariant *message);
gboolean handle_dpp_enter_peer_uri(Wifi *wifi, GDBusMethodInvocation *context, GVariant *dpp_info);
gboolean handle_dpp_generate_uri(Wifi *wifi, GDBusMethodInvocation *context, GVariant *dpp_info);
extern "C" {
#endif
-gboolean handle_flush_bss(Wifi *wifi, GDBusMethodInvocation *context);
+gboolean handle_flush_bss(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname);
#ifdef __cplusplus
}
NETCONFIG_WIFI_SOFTAP = 0x03,
};
-int netconfig_wifi_firmware(enum netconfig_wifi_firmware type, gboolean enable);
+int netconfig_wifi_firmware(enum netconfig_wifi_firmware type,
+ const char *interface_name, gboolean enable);
-gboolean handle_start(WifiFirmware *firmware, GDBusMethodInvocation *context, const gchar *device);
-gboolean handle_stop(WifiFirmware *firmware, GDBusMethodInvocation *context, const gchar *device);
+gboolean handle_start(WifiFirmware *firmware, GDBusMethodInvocation *context,
+ const gchar *device, const gchar *ifname);
+gboolean handle_stop(WifiFirmware *firmware, GDBusMethodInvocation *context,
+ const gchar *device, const gchar *ifname);
#ifdef __cplusplus
}
unsigned int netconfig_wifi_get_freq(void);
int netconfig_wifi_rssi_level(const int rssi_dbm);
-void netconfig_wifi_indicator_start(void);
-void netconfig_wifi_indicator_stop(void);
+void netconfig_wifi_indicator_start(const char *interface_name);
+void netconfig_wifi_indicator_stop(const char *interface_name);
#ifdef __cplusplus
}
struct nl_msg *msg;
} netconfig_nl_global;
-void __netconfig_notify_netlink_scan_done(void);
-int handle_netlink_scan(Wifi *wifi, GDBusMethodInvocation *context, GVariant *params);
+void __netconfig_notify_netlink_scan_done(const char *interface_name);
+int handle_netlink_scan(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, GVariant *params);
#ifdef __cplusplus
}
#include "wifi.h"
-gboolean handle_get_passpoint(Wifi *wifi, GDBusMethodInvocation *context);
-gboolean handle_set_passpoint(Wifi *wifi, GDBusMethodInvocation *context, gint enable);
+gboolean handle_get_passpoint(Wifi *wifi, GDBusMethodInvocation *context, const gchar *ifname);
+gboolean handle_set_passpoint(Wifi *wifi, GDBusMethodInvocation *context, const gchar *ifname, gint enable);
#ifdef __cplusplus
}
void wifi_power_initialize(void);
void wifi_power_deinitialize(void);
-int wifi_power_on(void);
-int wifi_power_off(void);
-void wifi_set_early_suspend(gboolean);
+int wifi_power_on(const char *interface_name);
+int wifi_power_off(const char *interface_name);
+void wifi_set_early_suspend(const char *interface_name, gboolean value);
#if defined TIZEN_WEARABLE
-int wifi_power_on_wearable(gboolean device_picker_test);
+int wifi_power_on_wearable(const char *interface_name, gboolean device_picker_test);
#endif
-int wifi_power_driver_and_supplicant(gboolean enable);
-void wifi_power_disable_technology_state_by_only_connman_signal(void);
-void wifi_power_recover_firmware(void);
+int wifi_power_driver_and_supplicant(const char *interface_name, gboolean enable);
+void wifi_power_recover_firmware(const char *interface_name);
-gboolean handle_load_driver(Wifi *wifi, GDBusMethodInvocation *context, gboolean device_picker_test);
-gboolean handle_remove_driver(Wifi *wifi, GDBusMethodInvocation *context);
+gboolean handle_load_driver(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, gboolean device_picker_test);
+gboolean handle_remove_driver(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname);
gboolean handle_load_p2p_driver(Wifi *wifi, GDBusMethodInvocation *context);
gboolean handle_remove_p2p_driver(Wifi *wifi, GDBusMethodInvocation *context);
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2020 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_SCAN_H__
+#define __NETCONFIG_SCAN_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "wifi.h"
+
+#if defined TIZEN_WEARABLE
+#define SCAN_PERIODIC_DELAY 15
+#define SCAN_EXPONENTIAL_MIN 5
+#define SCAN_EXPONENTIAL_MAX 320
+#else
+#define SCAN_PERIODIC_DELAY 10
+#define SCAN_EXPONENTIAL_MIN 4
+#define SCAN_EXPONENTIAL_MAX 128
+#endif
+
+enum {
+ WIFI_BGSCAN_MODE_EXPONENTIAL = 0x00,
+ WIFI_BGSCAN_MODE_PERIODIC,
+ WIFI_BGSCAN_MODE_MAX,
+};
+
+void netconfig_wifi_scan_set_scanning(const char *interface_name, gboolean scanning);
+guint netconfig_wifi_scan_get_scanning(const char *interface_name);
+
+gboolean netconfig_wifi_bgscan_set_mode(const char *interface_name, guint mode);
+guint netconfig_wifi_bgscan_get_mode(const char *interface_name);
+void netconfig_wifi_bgscan_set_timer_id(const char *interface_name, guint timer_id);
+guint netconfig_wifi_bgscan_get_timer_id(const char *interface_name);
+gboolean netconfig_wifi_bgscan_set_interval(const char *interface_name, guint interval);
+guint netconfig_wifi_bgscan_get_interval(const char *interface_name);
+void netconfig_wifi_bgscan_set_pause(const char *interface_name, gboolean pause);
+gboolean netconfig_wifi_bgscan_is_paused(const char *interface_name);
+void netconfig_wifi_bgscan_start_timer(const char *interface_name, gboolean immediate_scan);
+void netconfig_wifi_bgscan_stop_timer(const char *interface_name);
+
+void netconfig_wifi_bssidscan_set_mode(const char *interface_name, gboolean enable);
+gboolean netconfig_wifi_bssidscan_get_mode(const char *interface_name);
+void netconfig_wifi_bssidscan_set_aborted(const char *interface_name, gboolean abort);
+gboolean netconfig_wifi_bssidscan_get_aborted(const char *interface_name);
+void netconfig_wifi_bssidscan_set_scanning(const char *interface_name, gboolean scanning);
+guint netconfig_wifi_bssidscan_get_scanning(const char *interface_name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_SCAN_H__ */
NETCONFIG_WIFI_TECH_TETHERED = 0x05,
} wifi_tech_state_e;
-typedef struct {
- void (*wifi_state_changed)(wifi_service_state_e, void *user_data);
+typedef struct wifi_state_notifier{
+ struct wifi_state_notifier *notifier;
+ char *service;
+ void (*wifi_state_changed)(struct wifi_state_notifier *,
+ char *, wifi_service_state_e, void *);
void *user_data;
-} wifi_state_notifier;
+} wifi_state_notifier_s;
+
+typedef struct {
+ char *interface_name;
+ char *mac_address;
+ gboolean powered;
+ gboolean connected;
+ wifi_tech_state_e tech_state;
+ wifi_service_state_e service_state;
+} wifi_device_data_s;
+
+char *_convert_wifi_technology_state_to_string(wifi_tech_state_e wifi_tech_state_type);
+char *_convert_wifi_service_state_to_string(wifi_service_state_e wifi_service_state_type);
+
+void wifi_state_update_power_state(const char *interface_name, gboolean powered);
+void wifi_state_emit_power_completed(const char *interface_name, gboolean power_on);
+void wifi_state_emit_power_failed(const char *interface_name);
+
+char *wifi_get_favorite_service(void);
+void wifi_start_timer_network_notification(const char *interface_name);
-#define VCONF_WIFI_LAST_POWER_STATE "file/private/wifi/last_power_state"
+void wifi_state_notifier_register(wifi_state_notifier_s *notifier);
+void wifi_state_notifier_unregister(wifi_state_notifier_s *notifier);
+void wifi_state_notifier_cleanup(void);
-void wifi_state_update_power_state(gboolean powered);
-void wifi_state_emit_power_completed(gboolean power_on);
-void wifi_state_emit_power_failed(void);
+void wifi_state_set_bss_found(gboolean found);
+gboolean wifi_state_is_bss_found(void);
-char *wifi_get_favorite_service(void);
-void wifi_start_timer_network_notification(void);
+gboolean wifi_state_update_device_list(void);
+GSList *wifi_state_get_device_list(void);
-void wifi_state_notifier_register(wifi_state_notifier *notifier);
-void wifi_state_notifier_unregister(wifi_state_notifier *notifier);
-void wifi_state_notifier_cleanup(void);
+void wifi_state_set_service_state(const char *interface_name, wifi_service_state_e new_state);
+wifi_service_state_e wifi_state_get_service_state(const char *interface_name);
-void wifi_state_set_bss_found(gboolean found);
-gboolean wifi_state_is_bss_found(void);
+void wifi_state_set_technology_state(const char *interface_name, wifi_tech_state_e new_state);
+wifi_tech_state_e wifi_state_get_technology_state(const char *interface_name);
-void wifi_state_set_service_state(wifi_service_state_e new_state);
-wifi_service_state_e wifi_state_get_service_state(void);
+void wifi_state_set_powered(const char *interface_name, gboolean powered);
+gboolean wifi_state_get_powered(const char *interface_name);
-void wifi_state_set_tech_state(wifi_tech_state_e new_state);
-wifi_tech_state_e wifi_state_get_technology_state(bool mode);
-gboolean wifi_state_is_technology_available(void);
+void wifi_state_set_connected(const char *interface_name, gboolean connected);
+gboolean wifi_state_get_connected(const char *interface_name);
-void wifi_state_set_connected_essid(void);
-void wifi_state_get_connected_essid(gchar **essid);
+gboolean wifi_state_is_existed(const char *interface_name);
+const char *wifi_state_get_interface_name(const char *mac_address);
+const char *wifi_state_get_mac_address(const char *interface_name);
-gboolean handle_get_wifi_state(Wifi *wifi, GDBusMethodInvocation *context);
+void wifi_state_set_connected_essid(void);
+void wifi_state_get_connected_essid(gchar **essid);
-char *_convert_wifi_technology_state_to_string(wifi_tech_state_e wifi_tech_state_type);
-char *_convert_wifi_service_state_to_string(wifi_service_state_e wifi_service_state_type);
+void wifi_state_initialize(void);
+void wifi_state_deinitialize(void);
#ifdef __cplusplus
NETCONFIG_ERROR_TDLS_FAIL_CHANNEL_SWITCH = 0x05,
} netconfig_tdls_error_e;
-void netconfig_wifi_tdls_peer_found_event(GVariant *message);
-void netconfig_wifi_tdls_connected_event(GVariant *message);
-void netconfig_wifi_tdls_disconnected_event(GVariant *message);
+void netconfig_wifi_tdls_connected_event(const char *interface_name, GVariant *message);
+void netconfig_wifi_tdls_disconnected_event(const char *interface_name, GVariant *message);
+void netconfig_wifi_tdls_peer_found_event(const char *interface_name, GVariant *message);
+
void __netconfig_wifi_notify_tdls_connected_event(const char *peer_mac);
-gboolean handle_tdls_disconnect(Wifi *wifi, GDBusMethodInvocation *context, gchar *peer_mac_addr);
-gboolean handle_tdls_connected_peer(Wifi *wifi, GDBusMethodInvocation *context);
-gboolean handle_tdls_connect(Wifi *wifi, GDBusMethodInvocation *context, gchar *peer_mac_Addr);
-gboolean handle_tdls_discover(Wifi *wifi, GDBusMethodInvocation *context, gchar *peer_mac_Addr);
+gboolean handle_tdls_disconnect(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, gchar *peer_mac_addr);
+gboolean handle_tdls_connected_peer(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname);
+gboolean handle_tdls_connect(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, gchar *peer_mac_Addr);
+gboolean handle_tdls_discover(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, gchar *peer_mac_Addr);
gboolean handle_tdls_channel_switch(Wifi *wifi, GDBusMethodInvocation *context,
- gchar *peer_mac_Addr, int freq);
+ const gchar *ifname, gchar *peer_mac_Addr, int freq);
gboolean handle_tdls_cancel_channel_switch(Wifi *wifi, GDBusMethodInvocation *context,
- gchar *peer_mac_Addr);
+ const gchar *ifname, gchar *peer_mac_Addr);
#define WPS_EI_NO_ERROR 0
#define WPS_EI_OPERATION_FAILED 1
-gboolean handle_request_wps_connect(Wifi *wifi, GDBusMethodInvocation *context, gchar *param);
-gboolean handle_request_wps_cancel(Wifi *wifi, GDBusMethodInvocation *context);
-void netconfig_wifi_notify_wps_completed(const char *ssid, gsize ssid_len);
-void netconfig_wifi_notify_wps_fail_event(int config_error, int error_indication);
-void netconfig_wifi_notify_wps_credentials(const char *ssid, gsize ssid_len, const char *wps_key);
-gboolean netconfig_get_wps_field();
+gboolean handle_request_wps_connect(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, gchar *param);
+gboolean handle_request_wps_cancel(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname);
+void netconfig_wifi_notify_wps_completed(const char *interface_name,
+ const char *ssid, gsize ssid_len);
+void netconfig_wifi_notify_wps_fail_event(const char *interface_name,
+ int config_error, int error_indication);
+void netconfig_wifi_notify_wps_credentials(const char *interface_name,
+ const char *ssid, gsize ssid_len, const char *wps_key);
gboolean netconfig_wifi_wps_connect();
#ifdef __cplusplus
<node name="/net/netconfig/wifi">
<interface name="net.netconfig.wifi">
<method name="LoadDriver">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="b" name="DevicePickerTest" direction="in"/>
</method>
<method name="RemoveDriver">
+ <arg type="s" name="ifname" direction="in"/>
</method>
<method name="GetBssidList">
+ <arg type="s" name="ifname" direction="in"/>
</method>
<method name="LaunchDirect">
</method>
<arg type="s" name="state" direction="out"/>
</method>
<method name="IsIpConflictDetectEnabled">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="b" name="state" direction="out"/>
</method>
<method name="SetBgscan">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="u" name="ScanMode" direction="in"/>
</method>
<method name="ResumeBgscan">
+ <arg type="s" name="ifname" direction="in"/>
</method>
<method name="PauseBgscan">
+ <arg type="s" name="ifname" direction="in"/>
</method>
<method name="ResetBgscanInterval">
</method>
<method name="FlushBss">
+ <arg type="s" name="ifname" direction="in"/>
</method>
<method name="GetAutoscan">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="b" name="autoscan" direction="out"/>
</method>
<method name="GetIpConflictState">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="u" name="state" direction="out"/>
</method>
<method name="GetIpConflictPeriod">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="u" name="initial_time" direction="out"/>
</method>
<method name="GetAutoscanmode">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="u" name="autoscanmode" direction="out"/>
</method>
<method name="RequestBssidScan">
+ <arg type="s" name="ifname" direction="in"/>
</method>
<method name="NetlinkScan">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="a{sv}" name="ssids" direction="in"/>
</method>
<method name="RequestWpsCancel">
+ <arg type="s" name="ifname" direction="in"/>
</method>
<method name="RequestWpsConnect">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="s" name="param" direction="in"/>
</method>
<method name="GetPasspoint">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="i" name="enable" direction="out"/>
</method>
<method name="SetPasspoint">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="i" name="enable" direction="in"/>
</method>
<method name="GetConfigIds">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="as" name="config_ids" direction="out"/>
</method>
<method name="SaveConfiguration">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="s" name="config_id" direction="in"/>
<arg type="a{sv}" name="Configuration" direction="in"/>
</method>
<method name="SaveEapConfiguration">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="s" name="config_id" direction="in"/>
<arg type="a{sv}" name="Configuration" direction="in"/>
</method>
<method name="SetIpConflictPeriod">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="u" name="initial_time" direction="in"/>
</method>
<method name="RemoveConfiguration">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="s" name="config_id" direction="in"/>
</method>
<method name="LoadConfiguration">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="s" name="config_id" direction="in"/>
<arg type="a{sv}" name="Configuration" direction="out"/>
</method>
<method name="LoadEapConfiguration">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="s" name="config_id" direction="in"/>
<arg type="a{sv}" name="Configuration" direction="out"/>
</method>
<arg type="s" name="Profile" direction="in"/>
</method>
<method name="IpConflictSetEnable">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="b" name="detect" direction="in"/>
</method>
<method name="GetSimImsi">
<arg type="b" name="allowed" direction="out"/>
</method>
<method name="TdlsDisconnect">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="s" name="peer_mac_addr" direction="in"/>
- <arg type="i" name="result" direction="out" />
+ <arg type="i" name="result" direction="out" />
</method>
<method name="TdlsConnectedPeer">
- <arg type="s" name="peer_mac_addr" direction="out" />
+ <arg type="s" name="ifname" direction="in"/>
+ <arg type="s" name="peer_mac_addr" direction="out" />
</method>
<method name="TdlsConnect">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="s" name="peer_mac_addr" direction="in"/>
- <arg type="i" name="result" direction="out" />
+ <arg type="i" name="result" direction="out" />
</method>
<method name="TdlsDiscover">
+ <arg type="s" name="ifname" direction="in"/>
<arg type="s" name="peer_mac_addr" direction="in"/>
- <arg type="i" name="result" direction="out" />
+ <arg type="i" name="result" direction="out" />
</method>
<method name="TdlsChannelSwitch">
- <arg type="s" name="peer_mac_addr" direction="in" />
- <arg type="i" name="freq" direction="in" />
- <arg type="i" name="result" direction="out" />
+ <arg type="s" name="ifname" direction="in"/>
+ <arg type="s" name="peer_mac_addr" direction="in" />
+ <arg type="i" name="freq" direction="in" />
+ <arg type="i" name="result" direction="out" />
</method>
<method name="TdlsCancelChannelSwitch">
- <arg type="s" name="peer_mac_addr" direction="in" />
- <arg type="i" name="result" direction="out" />
+ <arg type="s" name="ifname" direction="in"/>
+ <arg type="s" name="peer_mac_addr" direction="in" />
+ <arg type="i" name="result" direction="out" />
</method>
<method name='AddVsie'>
+ <arg type="s" name="ifname" direction="in"/>
<arg type='i' name='frame_id' direction='in'/>
<arg type='s' name='vsie' direction='in'/>
</method>
<method name='GetVsie'>
+ <arg type="s" name="ifname" direction="in"/>
<arg type='i' name='frame_id' direction='in'/>
<arg type='s' name='vsie' direction='out'/>
</method>
<method name='RemoveVsie'>
+ <arg type="s" name="ifname" direction="in"/>
<arg type='i' name='frame_id' direction='in'/>
<arg type='s' name='vsie' direction='in'/>
</method>
<arg type="a{sv}" name="dpp_info" direction="in"/>
</method>
- <signal name="PowerOnCompleted"></signal>
- <signal name="PowerOffCompleted"></signal>
- <signal name="PowerOperationFailed"></signal>
+ <signal name="PowerOnCompleted">
+ <arg type="s" name="ifname" direction="out"/>
+ </signal>
+ <signal name="PowerOffCompleted">
+ <arg type="s" name="ifname" direction="out"/>
+ </signal>
+ <signal name="PowerOperationFailed">
+ <arg type="s" name="ifname" direction="out"/>
+ </signal>
<signal name="SpecificScanCompleted">
<arg type="a{sv}" name="Fields" direction="out"/>
</signal>
<signal name="BssidScanCompleted">
+ <arg type="s" name="ifname" direction="out"/>
<arg type="a{sv}" name="Fields" direction="out"/>
</signal>
<signal name="NetlinkScanCompleted">
+ <arg type="s" name="ifname" direction="out"/>
<arg type="a{sv}" name="Fields" direction="out"/>
</signal>
<signal name="IpConflictEvent">
+ <arg type="s" name="ifname" direction="out"/>
<arg type="a{sv}" name="Fields" direction="out"/>
</signal>
+ <signal name="RssiChanged">
+ <arg type="s" name="ifname" direction="out"/>
+ <arg type="i" name="rssi_level" direction="out"/>
+ </signal>
<signal name="DppUriGenerated">
<arg type="a{sv}" name="Fields" direction="out"/>
</signal>
Name: net-config
Summary: TIZEN Network Configuration service
-Version: 1.1.155
+Version: 1.2.0
Release: 3
Group: System/Network
License: Apache-2.0
%install
%make_install
+#Settings file
+mkdir -p %{buildroot}/%{_localstatedir}/lib/net-config
+cp resources/var/lib/net-config/settings %{buildroot}/%{_localstatedir}/lib/net-config/settings
+
#Systemd service file
mkdir -p %{buildroot}%{_unitdir}
%attr(644,root,root) /usr/lib/tmpfiles.d/security-network-config.conf
%attr(644,root,root) %{_unitdir}/net-config.service
%attr(644,root,root) %{_unitdir}/multi-user.target.wants/net-config.service
+%attr(644,root,root) /var/lib/net-config/settings
%license LICENSE
%attr(750,network_fw,network_fw) /opt/etc/dump.d/module.d/network_dump.sh
%attr(750,network_fw,network_fw) /opt/var/lib/net-config/network_dump.sh
--- /dev/null
+[Wifi]
+LastPoweredInterfaces=
+WifiOffByAirplaneInterfaces=
+WifiOffByRestrictedInterfaces=
+WifiOffByEmergencyInterfaces=
g_variant_builder_unref(builder);
rv = netconfig_invoke_dbus_method_nonblock(CLATD_SERVICE, CLATD_PATH,
- CLATD_INTERFACE, "Start", g_variant_new("(@a{is})", params), __netconfig_clatd_async_callback);
+ CLATD_INTERFACE, "Start", g_variant_new("(@a{is})", params),
+ __netconfig_clatd_async_callback, NULL);
if (!rv) {
DBG("Failed to dbus call");
}
rv = netconfig_invoke_dbus_method_nonblock(CLATD_SERVICE, CLATD_PATH,
- CLATD_INTERFACE, "Stop", NULL, NULL);
+ CLATD_INTERFACE, "Stop", NULL, NULL, NULL);
g_is_running = FALSE;
DBG("clatd disabled[%d]", g_is_running);
if (!rv) {
gboolean netconfig_invoke_dbus_method_nonblock(const char *dest, const char *path,
const char *interface_name, const char *method, GVariant *params,
- GAsyncReadyCallback notify_func)
+ GAsyncReadyCallback notify_func, void *user_data)
{
GDBusConnection *connection = NULL;
NETCONFIG_DBUS_REPLY_TIMEOUT,
netdbus_get_cancellable(),
(GAsyncReadyCallback) notify_func,
- NULL);
+ user_data);
if (notify_func)
netconfig_gdbus_pending_call_ref();
return (char *)path;
}
-char *netconfig_wifi_get_supplicant_interface(void)
+char *netconfig_wifi_get_supplicant_interface_path(const char *interface_name)
{
- return netconfig_get_supplicant_interface(WIFI_IFNAME);
+ const char *ifname = interface_name ? interface_name : WIFI_IFNAME;
+ return netconfig_get_supplicant_interface(ifname);
}
char *netconfig_wifi_get_supplicant_p2p_interface(void)
GVariant *reply = NULL;
GDBusConnection *connection = NULL;
- INFO("[DBUS Sync] %s %s %s", interface_name, method, path);
+ if (g_strcmp0(method, "GetInterface") != 0)
+ INFO("[DBUS Sync] %s %s %s", interface_name, method, path);
connection = netdbus_get_connection();
if (connection == NULL) {
gboolean netconfig_supplicant_invoke_dbus_method_nonblock(const char *dest,
const char *path, const char *interface_name,
const char *method, GVariant *params,
- GAsyncReadyCallback notify_func)
+ GAsyncReadyCallback notify_func, void *user_data)
{
GDBusConnection *connection = NULL;
NETCONFIG_DBUS_REPLY_TIMEOUT,
netdbus_get_cancellable(),
(GAsyncReadyCallback) notify_func,
- NULL);
+ user_data);
if (notify_func)
netconfig_gdbus_pending_call_ref();
return TRUE;
}
-GVariant *netconfig_supplicant_invoke_dbus_interface_property_get(const char *interface,
+GVariant *netconfig_supplicant_invoke_dbus_interface_property_get(const char *interface_name,
const char *key)
{
GVariant *params = NULL;
ERR("[GDBUS] property_get : %s", key);
- path = netconfig_wifi_get_supplicant_interface();
+ path = netconfig_wifi_get_supplicant_interface_path(interface_name);
if (path == NULL) {
DBG("Failed to get wpa_supplicant DBus path");
return NULL;
}
- params = g_variant_new("(ss)", interface, key);
+ params = g_variant_new("(ss)", SUPPLICANT_IFACE_INTERFACE, key);
reply = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE,
path,
return reply;
}
-gboolean netconfig_supplicant_invoke_dbus_interface_property_set(const char *interface,
+gboolean netconfig_supplicant_invoke_dbus_interface_property_set(const char *interface_name,
const char *key, GVariant *var,
GAsyncReadyCallback notify_func)
{
DBG("[DBUS] property_set : %s", key);
- path = netconfig_wifi_get_supplicant_interface();
+ path = netconfig_wifi_get_supplicant_interface_path(interface_name);
if (path == NULL) {
ERR("Failed to get wpa_supplicant DBus path");
return result;
}
- message = g_variant_new("(ssv)", interface, key, var);
+ message = g_variant_new("(ssv)", SUPPLICANT_IFACE_INTERFACE, key, var);
result = netconfig_invoke_dbus_method_nonblock(SUPPLICANT_SERVICE,
path,
DBUS_INTERFACE_PROPERTIES,
"Set",
message,
- notify_func);
+ notify_func,
+ NULL);
g_free(path);
if (result == FALSE) {
#include <unistd.h>
#include <stdbool.h>
+#include "netdbus.h"
#include "ip-conflict-detect.h"
#include "network-state.h"
#include "log.h"
int ioctl_sock;
static bool initial_bursts = true;
bool is_ip_conflict_detect_enabled = false;
+bool is_ip_conflict_detect_running = false;
static gboolean send_arp(gpointer data);
-static void __netconfig_wifi_notify_ip_conflict(char *state, char *mac);
+static void __netconfig_wifi_notify_ip_conflict(const char *interface_name,
+ char *state, char *mac);
ip_conflict_state_e conflict_state = NETCONFIG_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED;
struct sock_data *sd;
sd->iteration == CONFLICT_REMOVE_ITERATION_LIMIT) {
sd->iteration = 0;
conflict_state = NETCONFIG_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED;
- __netconfig_wifi_notify_ip_conflict("resolved", GRATUITOUS_ARP_MAC_ADDR);
+ __netconfig_wifi_notify_ip_conflict(netconfig_get_default_ifname(),
+ "resolved", GRATUITOUS_ARP_MAC_ADDR);
initial_bursts = true;
}
int zero_mac = strcmp(tbuf , GRATUITOUS_ARP_MAC_ADDR);
if (zero_mac == 0) {
- DBG("Broadcast packet.\n");
+ DBG("Broadcast packet.");
goto skip;
}
DBG("our mac= %s source mac= %s target mac= %s", netconfig_get_default_mac_address(), sbuf, tbuf);
mac_cmp = strcmp(tbuf , netconfig_get_default_mac_address());
if (mac_cmp != 0) {
- INFO("Packet not intended to us.\n");
+ INFO("Packet not intended to us.");
goto out;
}
skip:
if ((mac_cmp != 0) && (__convert_uchar_to_uint(arp_recv.s_IPaddr) == target_ip)) {
sd->iteration = 0;
if (conflict_state != NETCONFIG_IP_CONFLICT_STATE_CONFLICT_DETECTED) {
- INFO("ip conflict is detected !\n");
+ INFO("ip conflict is detected !");
conflict_state = NETCONFIG_IP_CONFLICT_STATE_CONFLICT_DETECTED;
- __netconfig_wifi_notify_ip_conflict("conflict", sbuf);
+ __netconfig_wifi_notify_ip_conflict(
+ netconfig_get_default_ifname(),
+ "conflict", sbuf);
sd->timeout = BURST_ARP_SEND_TIME;
}
return -1;
if ((sd->chk_conflict_sd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ARP))) == -1) {
- INFO("socket Failed.\n");
+ INFO("socket Failed.");
return -1;
}
}
if (ioctl(sd->chk_conflict_sd, SIOCGIFINDEX, &net_ifr) == -1) {
- INFO("ioctl Failed. Error..... = %s\n",
+ INFO("ioctl Failed. Error..... = %s",
strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
goto err;
}
if (sendto(sd->chk_conflict_sd, &arp, sizeof(arp), 0,
(struct sockaddr*)&addr, sizeof(addr)) < 0) {
- INFO("Sending ARP Packet Failed. Error. = %s\n",
+ INFO("Sending ARP Packet Failed. Error. = %s",
strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
__close_channel_and_sock(sd);
if (__open_channel_and_sock(sd) == -1)
INFO("__open_channel_and_sock failed");
goto err;
} else {
- DBG("Sent ARP Packet \n");
+ /* DBG("Sent ARP Packet"); */
}
if (sd->timer_id) {
struct sock_data * start_ip_conflict_mon(void)
{
- if (is_ip_conflict_detect_enabled == true) {
+ if (is_ip_conflict_detect_enabled == false) {
+ INFO("ip_conflict_detect is disabled");
+ return NULL;
+ }
+
+ if (is_ip_conflict_detect_running == true) {
INFO("detection mode is set to true");
return NULL;
}
sd->timeout = td.initial_time;
send_arp(sd);
- is_ip_conflict_detect_enabled = true;
+ is_ip_conflict_detect_running = true;
conflict_state = NETCONFIG_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED;
return sd;
}
g_free(sd);
sd = NULL;
- is_ip_conflict_detect_enabled = false;
+ is_ip_conflict_detect_running = false;
conflict_state = NETCONFIG_IP_CONFLICT_STATE_UNKNOWN;
INFO("Monitoring stopped");
}
-static void __netconfig_wifi_notify_ip_conflict(char *state, char *mac)
+static void __netconfig_wifi_notify_ip_conflict(const char *interface_name,
+ char *state, char *mac)
{
GVariantBuilder *builder = NULL;
g_variant_builder_add(builder, "{sv}", "state", g_variant_new_string(state));
g_variant_builder_add(builder, "{sv}", "mac", g_variant_new_string(mac));
- wifi_emit_ip_conflict_event((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
+ wifi_emit_ip_conflict_event((Wifi *)get_wifi_object(),
+ interface_name, g_variant_builder_end(builder));
g_variant_builder_unref(builder);
/* send notification using net-popup */
}
gboolean handle_ip_conflict_set_enable(Wifi *wifi, GDBusMethodInvocation *context,
- bool detect)
+ const gchar *ifname, bool detect)
{
g_return_val_if_fail(wifi != NULL, TRUE);
if (detect == false) {
- if (sd != NULL)
+ if (is_ip_conflict_detect_enabled == true) {
stop_ip_conflict_mon();
- else {
+ is_ip_conflict_detect_enabled = false;
+ } else {
netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "AlreadyExists");
return TRUE;
}
} else {
- if (sd == NULL) {
- if (start_ip_conflict_mon() == NULL) {
- INFO("Failed to start IP conflict monitoring");
- netconfig_error_dbus_method_return(context,
- NETCONFIG_ERROR_INTERNAL, "Failed");
- return TRUE;
+ if (is_ip_conflict_detect_enabled == false) {
+ is_ip_conflict_detect_enabled = true;
+ const char *def_profile = netconfig_get_default_profile();
+ if (netconfig_is_wifi_profile(def_profile) ||
+ netconfig_is_ethernet_profile(def_profile)) {
+ if (start_ip_conflict_mon() == NULL) {
+ INFO("Failed to start IP conflict monitoring");
+ netconfig_error_dbus_method_return(context,
+ NETCONFIG_ERROR_INTERNAL, "Failed");
+ return TRUE;
+ }
}
} else {
netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "AlreadyExists");
return TRUE;
}
-gboolean handle_is_ip_conflict_detect_enabled(Wifi *wifi, GDBusMethodInvocation *context)
+gboolean handle_is_ip_conflict_detect_enabled(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname)
{
g_return_val_if_fail(wifi != NULL, TRUE);
GVariant *param = NULL;
return TRUE;
}
-gboolean handle_set_ip_conflict_period(Wifi *wifi, GDBusMethodInvocation *context, guint initial_time)
+gboolean handle_set_ip_conflict_period(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, guint initial_time)
{
g_return_val_if_fail(wifi != NULL, TRUE);
INFO("%d", initial_time);
return TRUE;
}
-gboolean handle_get_ip_conflict_state(Wifi *wifi, GDBusMethodInvocation *context)
+gboolean handle_get_ip_conflict_state(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname)
{
g_return_val_if_fail(wifi != NULL, TRUE);
GVariant *param = NULL;
return TRUE;
}
-gboolean handle_get_ip_conflict_period(Wifi *wifi, GDBusMethodInvocation *context)
+gboolean handle_get_ip_conflict_period(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname)
{
g_return_val_if_fail(wifi != NULL, TRUE);
GVariant *param = NULL;
#include "log.h"
#include "util.h"
#include "wifi.h"
+#include "setting.h"
#include "netdbus.h"
#include "emulator.h"
#include "neterror.h"
return 0;
}
+ netconfig_setting_init();
+
netconfig_error_init();
if (TIZEN_NTP_ENABLE)
netconfig_dpm_deinit();
+ netconfig_setting_deinit();
+
if (TIZEN_NTP_ENABLE)
netconfig_clock_deinit();
#include "util.h"
#include "netdbus.h"
#include "wifi-power.h"
+#include "wifi-state.h"
#include "network-dpm.h"
#include "network-state.h"
int netconfig_dpm_update_from_wifi(void)
{
+ GSList *list = wifi_state_get_device_list();
+
INFO("DPM update from wifi [%d]", dpm_policy_wifi);
if (!dpm_policy_wifi) {
- int wifi_state = 0;
- vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
- if (wifi_state != VCONFKEY_WIFI_OFF) {
- int err = wifi_power_off();
- if (err < 0) {
- if (err == -EINPROGRESS)
- ERR("wifi power off : InProgress");
- else if (err == -EALREADY)
- ERR("wifi power off : AlreadyExists");
- else if (err == -EPERM)
- ERR("wifi power off : PermissionDenied");
- else
- ERR("wifi power off : WifiDriverFailed");
- } else
- DBG("wifi power off : ErrorNone");
-
- netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_OFF_BY_AIRPLANE, 0);
- netconfig_send_restriction_to_net_popup("Wi-Fi unavailable",
- "toast_popup", "wifi");
+ for ( ; list; list = list->next) {
+ wifi_device_data_s *device_data = list->data;
+ if (device_data->powered == TRUE) {
+ int err = wifi_power_off(device_data->interface_name);
+ if (err < 0) {
+ if (err == -EINPROGRESS)
+ ERR("wifi power off : InProgress");
+ else if (err == -EALREADY)
+ ERR("wifi power off : AlreadyExists");
+ else if (err == -EPERM)
+ ERR("wifi power off : PermissionDenied");
+ else
+ ERR("wifi power off : WifiDriverFailed");
+ } else
+ DBG("wifi power off : ErrorNone");
+ }
}
+
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_OFF_BY_AIRPLANE, 0);
+ netconfig_send_restriction_to_net_popup("Wi-Fi unavailable", "toast_popup", "wifi");
}
return dpm_policy_wifi;
return is_connected;
}
-static char *__netconfig_get_default_profile(void)
-{
- GVariant *message = NULL;
- GVariantIter *iter;
- GVariantIter *next;
- gchar *default_profile = NULL;
- gchar *object_path;
-
- message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
- CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
- "GetServices", NULL);
- if (message == NULL) {
- ERR("Failed to get profiles");
- return NULL;
- }
-
- g_variant_get(message, "(a(oa{sv}))", &iter);
- while (g_variant_iter_loop(iter, "(oa{sv})", &object_path, &next)) {
- if (object_path == NULL)
- continue;
-
- if (netconfig_is_cellular_profile(object_path) && !netconfig_is_cellular_internet_profile(object_path))
- continue;
-
- if (__netconfig_is_connected(next) == TRUE) {
- default_profile = g_strdup(object_path);
- g_free(object_path);
- g_variant_iter_free(next);
- break;
- }
- }
- g_variant_iter_free(iter);
- g_variant_unref(message);
-
- return default_profile;
-}
-
static int __netconfig_telephony_get_modem_object_path(GSList **modem_path_list)
{
GVariant *result;
return ret;
}
-static void __netconfig_get_default_connection_info(const char *profile)
+static int __netconfig_reset_ipv4_socket(const char *interface_name)
+{
+ int ret;
+ int fd;
+ struct ifreq ifr;
+ struct sockaddr_in sai;
+ const char *ipaddr = netconfig_get_default_ipaddress();
+ DBG("ipaddr-[%s]", ipaddr);
+
+ if (!ipaddr)
+ return -1;
+
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (fd < 0)
+ return -1;
+
+ memset(&sai, 0, sizeof(struct sockaddr_in));
+ sai.sin_family = AF_INET;
+ sai.sin_port = 0;
+ if (!inet_aton(ipaddr, &sai.sin_addr)) {
+ DBG("fail to inet_aton()");
+ close(fd);
+ return -1;
+ }
+
+ memset(&ifr, 0, sizeof(struct ifreq));
+ memcpy(&ifr.ifr_addr, &sai, sizeof(sai));
+ g_strlcpy((char *)ifr.ifr_name, interface_name, IFNAMSIZ);
+
+#ifndef SIOCKILLADDR
+#define SIOCKILLADDR 0x8939
+#endif
+
+ ret = ioctl(fd, SIOCKILLADDR, &ifr);
+ if (ret < 0) {
+ DBG("fail to ioctl[SIOCKILLADDR]");
+ close(fd);
+ return -1;
+ }
+
+ close(fd);
+ return 0;
+}
+
+static void __netconfig_clear_default_connection_info(void)
+{
+ static char *old_profile = NULL;
+
+ if (netconfig_default_connection_info.profile != NULL) {
+
+ if (netconfig_is_wifi_profile(netconfig_default_connection_info.profile))
+ __netconfig_reset_ipv4_socket(netconfig_default_connection_info.ifname);
+
+ g_free(old_profile);
+ old_profile = strdup(netconfig_default_connection_info.profile);
+
+ g_free(netconfig_default_connection_info.profile);
+ netconfig_default_connection_info.profile = NULL;
+
+ g_free(netconfig_default_connection_info.ifname);
+ netconfig_default_connection_info.ifname = NULL;
+
+ g_free(netconfig_default_connection_info.ipaddress);
+ netconfig_default_connection_info.ipaddress = NULL;
+
+ g_free(netconfig_default_connection_info.ipaddress6);
+ netconfig_default_connection_info.ipaddress6 = NULL;
+
+ g_free(netconfig_default_connection_info.proxy);
+ netconfig_default_connection_info.proxy = NULL;
+
+ g_free(netconfig_default_connection_info.mac_address);
+ netconfig_default_connection_info.mac_address = NULL;
+
+ netconfig_default_connection_info.freq = 0;
+ netconfig_default_connection_info.is_metered = FALSE;
+
+ g_free(netconfig_default_connection_info.essid);
+ netconfig_default_connection_info.essid = NULL;
+ }
+}
+
+static gboolean __netconfig_get_default_connection_info(void)
{
GVariant *message = NULL, *variant = NULL, *variant2 = NULL;
- GVariantIter *iter = NULL, *iter1 = NULL, *service = NULL;
- GVariant *next = NULL;
+ GVariantIter *iter = NULL, *iter1 = NULL;
+ GVariant *var = NULL;
gchar *obj_path;
gchar *key = NULL;
gchar *key1 = NULL;
gchar *key2 = NULL;
- gboolean found_profile = 0;
message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
- "GetServices", NULL);
+ "GetDefaultService", NULL);
if (message == NULL) {
ERR("Failed to get services informations");
- goto done;
+ return FALSE;
}
- g_variant_get(message, "(a(oa{sv}))", &service);
- if (service == NULL) {
- ERR("Failed to get services iter");
- goto done;
+ if (!g_variant_is_of_type(message, G_VARIANT_TYPE("(oa{sv})"))) {
+ DBG("There is no default service");
+ g_variant_unref(message);
+ return FALSE;
}
- while (g_variant_iter_loop(service, "(oa{sv})", &obj_path, &iter)) {
- if (g_strcmp0(obj_path, profile) == 0) {
- g_free(obj_path);
- found_profile = 1;
- break;
- }
- }
+ g_variant_get(message, "(oa{sv})", &obj_path, &iter);
- if (iter == NULL || found_profile == 0) {
- ERR("Profile %s doesn't exist", profile);
- goto done;
+ if (g_strcmp0(obj_path, netconfig_default_connection_info.profile) == 0) {
+ g_variant_unref(message);
+ g_variant_iter_free(iter);
+ return FALSE;
}
- while (g_variant_iter_loop(iter, "{sv}", &key, &next)) {
+ __netconfig_clear_default_connection_info();
+
+ netconfig_default_connection_info.profile = g_strdup(obj_path);
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
const gchar *value = NULL;
guint16 freq = 0;
if (g_strcmp0(key, "Name") == 0 &&
- netconfig_is_wifi_profile(profile) == TRUE) {
- if (g_variant_is_of_type(next, G_VARIANT_TYPE_STRING)) {
- value = g_variant_get_string(next, NULL);
+ netconfig_is_wifi_profile(obj_path) == TRUE) {
+ if (g_variant_is_of_type(var, G_VARIANT_TYPE_STRING)) {
+ value = g_variant_get_string(var, NULL);
netconfig_default_connection_info.essid = g_strdup(value);
}
} else if (g_strcmp0(key, "Ethernet") == 0) {
- g_variant_get(next, "a{sv}", &iter1);
+ g_variant_get(var, "a{sv}", &iter1);
if (iter1 == NULL)
continue;
while (g_variant_iter_loop(iter1, "{sv}", &key1, &variant)) {
}
g_variant_iter_free(iter1);
} else if (g_strcmp0(key, "IPv4") == 0) {
- g_variant_get(next, "a{sv}", &iter1);
+ g_variant_get(var, "a{sv}", &iter1);
if (iter1 == NULL)
continue;
while (g_variant_iter_loop(iter1, "{sv}", &key1, &variant)) {
}
g_variant_iter_free(iter1);
} else if (g_strcmp0(key, "IPv6") == 0) {
- g_variant_get(next, "a{sv}", &iter1);
+ g_variant_get(var, "a{sv}", &iter1);
if (iter1 == NULL)
continue;
while (g_variant_iter_loop(iter1, "{sv}", &key1, &variant)) {
g_variant_iter_free(iter1);
} else if (g_strcmp0(key, "Proxy") == 0) {
- g_variant_get(next, "a{sv}", &iter1);
+ g_variant_get(var, "a{sv}", &iter1);
if (iter1 == NULL)
continue;
while (g_variant_iter_loop(iter1, "{sv}", &key2, &variant2)) {
}
g_variant_iter_free(iter1);
} else if (g_strcmp0(key, "Frequency") == 0) {
- if (g_variant_is_of_type(next, G_VARIANT_TYPE_UINT16)) {
- freq = g_variant_get_uint16(next);
+ if (g_variant_is_of_type(var, G_VARIANT_TYPE_UINT16)) {
+ freq = g_variant_get_uint16(var);
netconfig_default_connection_info.freq = freq;
}
}
}
- if (netconfig_is_cellular_profile(profile) == TRUE) {
+ if (netconfig_is_cellular_profile(obj_path) == TRUE) {
net_profile_name_t pdp_name;
int ret;
- ret = __netconfig_telephony_search_pdp_profile(profile, &pdp_name);
+ ret = __netconfig_telephony_search_pdp_profile(obj_path, &pdp_name);
if (ret >= 0 && strlen(pdp_name.profile_name) > 0)
if (__netconfig_telephony_get_metered_info(&pdp_name))
netconfig_default_connection_info.is_metered = TRUE;
}
-done:
- if (message)
- g_variant_unref(message);
-
- if (iter)
- g_variant_iter_free(iter);
-
- if (service)
- g_variant_iter_free(service);
+ g_variant_unref(message);
+ g_variant_iter_free(iter);
- return;
+ return TRUE;
}
static char *__netconfig_get_preferred_ipv6_address(char *profile)
return ret;
}
-static void __netconfig_update_if_service_connected(void)
-{
- GVariant *message = NULL, *var;
- GVariantIter *iter, *next;
- gchar *path;
- gchar *key;
-
- message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
- CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
- "GetServices", NULL);
-
- if (message == NULL) {
- ERR("Failed to get services");
- return;
- }
-
- g_variant_get(message, "(a(oa{sv}))", &iter);
- while (g_variant_iter_loop(iter, "(oa{sv})", &path, &next)) {
- if (path == NULL)
- continue;
-
- if (g_str_has_prefix(path,
- CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE) {
- if (g_strrstr(path + strlen(CONNMAN_WIFI_SERVICE_PROFILE_PREFIX),
- "hidden") != NULL) {
- /* skip hidden profiles */
- continue;
- }
- /* Process this */
- } else if (g_str_has_prefix(path,
- CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX) == TRUE) {
- /* Process this */
- } else if (g_str_has_prefix(path,
- CONNMAN_ETHERNET_SERVICE_PROFILE_PREFIX) == TRUE) {
- /* Process this */
- } else {
- continue;
- }
-
- while (g_variant_iter_loop(next, "{sv}", &key, &var)) {
- if (g_strcmp0(key, "State") == 0) {
- const gchar *sdata = NULL;
- sdata = g_variant_get_string(var, NULL);
- DBG("%s [%s: %s]", path, key, sdata);
-
- if (g_strcmp0(sdata, "online") == 0 || g_strcmp0(sdata, "ready") == 0) {
-
- /* Found a connected WiFi / 3G service.
- * Lets update the default profile info.
- */
- netconfig_update_default_profile((const gchar*)path);
- g_free(key);
- g_free(path);
- g_variant_unref(var);
- g_variant_iter_free(next);
- goto done;
- }
- }
- }
- }
-done:
- g_variant_iter_free(iter);
- g_variant_unref(message);
-
- return;
-}
-
static void __netconfig_network_notify_result(const char *sig_name, const char *key)
{
GVariantBuilder *builder;
return;
}
+static char *__netconfig_get_mac_address(const char *profile)
+{
+ char mac_str[MAC_ADDRESS_MAX_LEN] = { 0, };
+ const char *orgin = NULL;
+ int org_index, dst_index;
+ int i;
+
+ org_index = strlen(CONNMAN_WIFI_SERVICE_PROFILE_PREFIX);
+ dst_index = 0;
+
+ for (i = 0; i < 6; i++) {
+ orgin = &profile[org_index];
+
+ memcpy(&mac_str[dst_index], orgin, 2);
+ if (i < 5)
+ mac_str[dst_index + 2] = ':';
+ else
+ mac_str[dst_index + 2] = '\0';
+
+ org_index += 2;
+ dst_index += 3;
+ }
+
+ return g_strdup(mac_str);
+}
+
const char *netconfig_get_default_profile(void)
{
return netconfig_default_connection_info.profile;
return netconfig_default_connection_info.ipaddress;
}
+
const char *netconfig_get_default_ipaddress6(void)
{
return netconfig_default_connection_info.ipaddress6;
return netconfig_default_connection_info.is_metered;
}
-static int __netconfig_reset_ipv4_socket(void)
+void netconfig_set_default_ipaddress(const char *ipaddr)
{
- int ret;
- int fd;
- struct ifreq ifr;
- struct sockaddr_in sai;
- const char *ipaddr = netconfig_get_default_ipaddress();
- DBG("ipaddr-[%s]", ipaddr);
-
- if (!ipaddr)
- return -1;
-
- fd = socket(AF_INET, SOCK_DGRAM, 0);
- if (fd < 0)
- return -1;
-
- memset(&sai, 0, sizeof(struct sockaddr_in));
- sai.sin_family = AF_INET;
- sai.sin_port = 0;
- if (!inet_aton(ipaddr, &sai.sin_addr)) {
- DBG("fail to inet_aton()");
- close(fd);
- return -1;
- }
-
- memset(&ifr, 0, sizeof(struct ifreq));
- memcpy(&ifr.ifr_addr, &sai, sizeof(sai));
- g_strlcpy((char *)ifr.ifr_name, WIFI_IFNAME, IFNAMSIZ);
-
-#ifndef SIOCKILLADDR
-#define SIOCKILLADDR 0x8939
-#endif
-
- ret = ioctl(fd, SIOCKILLADDR, &ifr);
- if (ret < 0) {
- DBG("fail to ioctl[SIOCKILLADDR]");
- close(fd);
- return -1;
- }
-
- close(fd);
- return 0;
+ netconfig_default_connection_info.ipaddress = g_strdup(ipaddr);
}
-void netconfig_update_default_profile(const char *profile)
+void netconfig_set_default_ipaddress6(const char *ipaddr)
{
- static char *old_profile = NULL;
-
- /* It's automatically updated by signal-handler
- * DO NOT update manually
- *
- * It is going to update default connection information
- */
-
- if (netconfig_default_connection_info.profile != NULL) {
-
- if (netconfig_is_wifi_profile(netconfig_default_connection_info.profile))
- __netconfig_reset_ipv4_socket();
-
- g_free(old_profile);
- old_profile = strdup(netconfig_default_connection_info.profile);
-
- g_free(netconfig_default_connection_info.profile);
- netconfig_default_connection_info.profile = NULL;
-
- g_free(netconfig_default_connection_info.ifname);
- netconfig_default_connection_info.ifname = NULL;
-
- g_free(netconfig_default_connection_info.ipaddress);
- netconfig_default_connection_info.ipaddress = NULL;
-
- g_free(netconfig_default_connection_info.ipaddress6);
- netconfig_default_connection_info.ipaddress6 = NULL;
-
- g_free(netconfig_default_connection_info.proxy);
- netconfig_default_connection_info.proxy = NULL;
-
- g_free(netconfig_default_connection_info.mac_address);
- netconfig_default_connection_info.mac_address = NULL;
-
- netconfig_default_connection_info.freq = 0;
- netconfig_default_connection_info.is_metered = FALSE;
-
- g_free(netconfig_default_connection_info.essid);
- netconfig_default_connection_info.essid = NULL;
- }
-
- /* default profile is NULL and new connected profile is NULL */
- if (!profile) {
- char *tmp_profile = __netconfig_get_default_profile();
-
- if (tmp_profile && netconfig_is_cellular_profile(tmp_profile) &&
- !netconfig_is_cellular_internet_profile(tmp_profile)) {
- DBG("not a default cellular profile");
- g_free(tmp_profile);
- tmp_profile = NULL;
- }
+ netconfig_default_connection_info.ipaddress6 = g_strdup(ipaddr);
+}
- if (!tmp_profile) {
- __netconfig_update_default_connection_info();
- return;
- }
+void netconfig_set_default_proxy(const char *proxy)
+{
+ netconfig_default_connection_info.proxy = g_strdup(proxy);
+}
- netconfig_default_connection_info.profile = g_strdup(tmp_profile);
- __netconfig_get_default_connection_info(tmp_profile);
+void netconfig_update_default_profile(void)
+{
+ if (__netconfig_get_default_connection_info())
__netconfig_update_default_connection_info();
- g_free(tmp_profile);
- return;
- }
-
- netconfig_default_connection_info.profile = g_strdup(profile);
- __netconfig_get_default_connection_info(profile);
- __netconfig_update_default_connection_info();
}
void netconfig_update_default(void)
{
if (__netconfig_is_tech_state_connected() == TRUE)
- __netconfig_update_if_service_connected();
+ netconfig_update_default_profile();
else
__netconfig_adjust_tcp_buffer_size();
}
-char *netconfig_get_ifname(const char *profile)
+const char *netconfig_get_ifname(const char *profile)
{
- GVariant *message = NULL, *variant;
- GVariantIter *iter, *next, *service;
- gchar *obj_path;
- gchar *key;
- gchar *key1;
- const gchar *value = NULL;
- gchar *ifname = NULL;
- gboolean found_profile = 0;
-
- if (profile == NULL)
- return NULL;
-
- message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
- CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
- "GetServices", NULL);
- if (message == NULL) {
- ERR("Failed to get services informations");
- return NULL;
- }
-
- g_variant_get(message, "(a(oa{sv}))", &service);
- while (g_variant_iter_loop(service, "(oa{sv})", &obj_path, &iter)) {
- if (g_strcmp0(obj_path, profile) == 0) {
- g_free(obj_path);
- found_profile = 1;
- break;
- }
- }
-
- if (found_profile == 0) {
- ERR("Profile %s doesn't exist", profile);
- g_variant_iter_free(service);
- g_variant_unref(message);
- return NULL;
- }
-
- while (g_variant_iter_loop(iter, "{sv}", &key, &next)) {
- if (g_strcmp0(key, "Ethernet") == 0) {
- while (g_variant_iter_loop(next, "{sv}", &key1, &variant)) {
- if (g_strcmp0(key1, "Interface") == 0) {
- value = g_variant_get_string(variant, NULL);
- if (!ifname)
- ifname = g_strdup(value);
- g_free(key1);
- g_variant_unref(variant);
- break;
- }
- }
- }
- }
+ const char *ifname = NULL;
+ char *mac_addr = NULL;
- g_variant_unref(message);
-
- g_variant_iter_free(service);
- g_variant_iter_free(iter);
+ mac_addr = __netconfig_get_mac_address(profile);
+ ifname = wifi_state_get_interface_name(mac_addr);
+ g_free(mac_addr);
return ifname;
}
#include "log.h"
#include "util.h"
#include "netsupplicant.h"
+#include "network-state.h"
#include "network-statistics.h"
#include "generated-code.h"
static Network_statistics *netconfigstatistics = NULL;
+static gboolean __find_wifi_interface_name(const char *interface_name)
+{
+ GSList *list = wifi_state_get_device_list();
+
+ for ( ; list; list = list->next) {
+ wifi_device_data_s *device_data = list->data;
+ if (g_strcmp0(device_data->interface_name, interface_name) == 0)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
gboolean netconfig_wifi_get_bytes_statistics(guint64 *tx, guint64 *rx)
{
gboolean ret = FALSE;
if (p_entry != NULL) {
*p_entry++ = '\0';
- if (g_strcmp0(p_ifname, WIFI_IFNAME) != 0)
+ if (__find_wifi_interface_name(p_ifname) == FALSE)
continue;
/* read interface statistics */
netconfig_vconf_get_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, &val);
tx_bytes = (guint64)val;
- if (wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED) {
+ if (wifi_state_get_service_state(netconfig_get_default_ifname()) != NETCONFIG_WIFI_CONNECTED) {
last_bytes = tx_bytes;
network_statistics_complete_get_wifi_last_tx_bytes(object, context, last_bytes);
return TRUE;
netconfig_vconf_get_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, &val);
rx_bytes = (guint64)val;
- if (wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED) {
+ if (wifi_state_get_service_state(netconfig_get_default_ifname()) != NETCONFIG_WIFI_CONNECTED) {
last_bytes = rx_bytes;
network_statistics_complete_get_wifi_last_rx_bytes(object, context, last_bytes);
return TRUE;
{
guint64 tx = 0, rx = 0;
- if (wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED) {
+ if (wifi_state_get_service_state(netconfig_get_default_ifname()) != NETCONFIG_WIFI_CONNECTED) {
netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, 0);
network_statistics_complete_reset_wifi_last_tx_bytes(object, context);
return TRUE;
{
guint64 tx = 0, rx = 0;
- if (wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED) {
+ if (wifi_state_get_service_state(netconfig_get_default_ifname()) != NETCONFIG_WIFI_CONNECTED) {
netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, 0);
network_statistics_complete_reset_wifi_last_rx_bytes(object, context);
return TRUE;
netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_RCV, (int)total_rx);
}
-static void wifi_statistics_update_state(wifi_service_state_e state, void *user_data)
+static void wifi_statistics_update_state(wifi_state_notifier_s *notifier,
+ char *service, wifi_service_state_e state, void *user_data)
{
guint64 tx = 0, rx = 0;
guint64 last_tx = 0, last_rx = 0;
prev_state = state;
}
-static wifi_state_notifier state_notifier = {
+static wifi_state_notifier_s state_notifier = {
+ .notifier = NULL,
+ .service = NULL,
.wifi_state_changed = wifi_statistics_update_state,
.user_data = NULL,
};
ERR("Export with path failed");
}
- wifi_statistics_update_state(NETCONFIG_WIFI_IDLE, NULL);
+ wifi_statistics_update_state(&state_notifier, NULL, NETCONFIG_WIFI_IDLE, NULL);
wifi_state_notifier_register(&state_notifier);
return;
#include "netdbus.h"
#include "neterror.h"
#include "wifi-wps.h"
-#include "wifi-bssid-scan.h"
#include "wifi-agent.h"
#include "wifi-power.h"
#include "wifi-state.h"
+#include "wifi-scan.h"
+#include "wifi-bssid-scan.h"
+#include "wifi-background-scan.h"
#include "netsupplicant.h"
#include "network-state.h"
#include "cellular-state.h"
#include "signal-handler.h"
-#include "wifi-background-scan.h"
#include "wifi-tdls.h"
#include "wifi-dpp.h"
#include "ip-conflict-detect.h"
#define CONNMAN_SIGNAL_SERVICES_CHANGED "ServicesChanged"
#define CONNMAN_SIGNAL_PROPERTY_CHANGED "PropertyChanged"
+#define CONNMAN_SIGNAL_DEVICE_CHANGED "DeviceChanged"
+#define CONNMAN_SIGNAL_DEVICE_DETECTED "DeviceDetected"
#define SIGNAL_NAME_OWNER_CHANGED "NameOwnerChanged"
#define MAX_SIG_LEN 64
builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
if (value != NULL) {
+ netconfig_set_default_ipaddress(value);
vconf_set_str(VCONFKEY_NETWORK_IP, value);
g_variant_builder_add(builder, "{sv}", "IPv4Address",
g_variant_new_string(value));
builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
if (value != NULL) {
+ netconfig_set_default_ipaddress6(value);
vconf_set_str(VCONFKEY_NETWORK_IP6, value);
g_variant_builder_add(builder, "{sv}", "IPv6Address",
g_variant_new_string(value));
}
#endif
+static char *__supplicant_get_interface_name(const gchar *path, const gchar *interface)
+{
+ GVariant *params = NULL;
+ GVariant *reply = NULL, *var = NULL;;
+ char *interface_name = NULL;
+
+ params = g_variant_new("(ss)", interface, "Ifname");
+
+ reply = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE,
+ path, DBUS_INTERFACE_PROPERTIES, "Get", params);
+ if (reply == NULL) {
+ ERR("Failed to get interface name");
+ return NULL;
+ }
+
+ g_variant_get(reply, "(v)", &var);
+
+ if (g_variant_is_of_type(var, G_VARIANT_TYPE_STRING)) {
+ interface_name = g_variant_dup_string(var, NULL);
+ DBG("%s [%s]", path, interface_name);
+ }
+
+ g_variant_unref(var);
+ g_variant_unref(reply);
+
+ return interface_name;
+}
+
static void _technology_signal_cb(GDBusConnection *conn,
const gchar *name, const gchar *path, const gchar *interface,
const gchar *sig, GVariant *param, gpointer user_data)
{
gchar *key = NULL;
- gboolean value = FALSE;
GVariant *var = NULL;
+ GVariantIter *iter = NULL;
+ const gchar *svalue = NULL;
+ gboolean bvalue = FALSE;
+
+ DBG("%s %s", path, sig);
if (param == NULL)
return;
- if (g_str_has_prefix(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == TRUE) {
- g_variant_get(param, "(sv)", &key, &var);
- if (g_strcmp0(key, "Powered") == 0) {
- /* Power state */
- value = g_variant_get_boolean(var);
- if (value == TRUE)
- wifi_state_update_power_state(TRUE);
- else
- wifi_state_update_power_state(FALSE);
- } else if (g_strcmp0(key, "Connected") == 0) {
- /* Connection state */
- value = g_variant_get_boolean(var);
- if (value == TRUE)
- wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_CONNECTED);
- else
- wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_POWERED);
- } else if (g_strcmp0(key, "Tethering") == 0) {
- /* Tethering state */
- wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_TETHERED);
+ if (g_str_has_prefix(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) != TRUE)
+ return;
+
+ if (g_strcmp0(sig, CONNMAN_SIGNAL_DEVICE_CHANGED) == 0) {
+ g_variant_get(param, "(a{sv})", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+ if (g_strcmp0(key, "Ifname") == 0) {
+ svalue = g_variant_get_string(var, NULL);
+ DBG("Ifname [%s]", svalue);
+ } else if (g_strcmp0(key, "Powered") == 0) {
+ bvalue = g_variant_get_boolean(var);
+ DBG("Powered [%d]", bvalue);
+ wifi_state_update_power_state(svalue, bvalue);
+ } else if (g_strcmp0(key, "Connected") == 0) {
+ bvalue = g_variant_get_boolean(var);
+ DBG("Connected [%d]", bvalue);
+ wifi_state_set_connected(svalue, bvalue);
+ if (bvalue == TRUE)
+ wifi_state_set_technology_state(svalue, NETCONFIG_WIFI_TECH_CONNECTED);
+ else
+ wifi_state_set_technology_state(svalue, NETCONFIG_WIFI_TECH_POWERED);
+ }
}
- g_free(key);
- g_variant_unref(var);
+ g_variant_iter_free(iter);
+ } else if (g_strcmp0(sig, CONNMAN_SIGNAL_DEVICE_DETECTED) == 0) {
+ wifi_state_update_device_list();
}
}
struct sock_data *sd = NULL;
gchar *pf = NULL;
int idx = 0;
+ const char *interface_name = NULL;
if (path == NULL || param == NULL)
goto done;
if (g_strcmp0(sig, CONNMAN_SIGNAL_PROPERTY_CHANGED) != 0)
goto done;
+ interface_name = netconfig_get_ifname(path);
+
if (g_strcmp0(sigvalue, "State") == 0) {
g_variant_get(variant, "s", &property);
}
if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
- if (wifi_state >= VCONFKEY_WIFI_CONNECTED) {
- g_free(property);
- goto done;
- }
-
- netconfig_update_default_profile(path);
+ netconfig_update_default_profile();
- wifi_state_set_service_state(NETCONFIG_WIFI_CONNECTED);
+ wifi_state_set_service_state(interface_name, NETCONFIG_WIFI_CONNECTED);
- } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
- if (netconfig_get_default_profile() == NULL ||
- netconfig_is_wifi_profile(netconfig_get_default_profile())
- != TRUE) {
- if (g_strcmp0(property, "failure") == 0)
- wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE);
- else
- wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
- g_free(property);
- goto done;
- }
+ } else if (g_strcmp0(property, "failure") == 0 ||
+ g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
+ if (g_strcmp0(property, "failure") == 0)
+ wifi_state_set_service_state(interface_name, NETCONFIG_WIFI_FAILURE);
+ else
+ wifi_state_set_service_state(interface_name, NETCONFIG_WIFI_IDLE);
if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
g_free(property);
goto done;
}
- netconfig_update_default_profile(NULL);
-
- if (g_strcmp0(property, "failure") == 0)
- wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE);
- else
- wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
+ netconfig_update_default_profile();
} else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
- if (netconfig_get_default_profile() == NULL ||
- netconfig_is_wifi_profile(netconfig_get_default_profile()) != TRUE) {
- if (g_strcmp0(property, "association") == 0)
- wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION);
- else
- wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION);
- g_free(property);
- goto done;
- }
+ if (g_strcmp0(property, "association") == 0)
+ wifi_state_set_service_state(interface_name, NETCONFIG_WIFI_ASSOCIATION);
+ else
+ wifi_state_set_service_state(interface_name, NETCONFIG_WIFI_CONFIGURATION);
if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
g_free(property);
goto done;
}
- netconfig_update_default_profile(NULL);
-
- if (g_strcmp0(property, "association") == 0)
- wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION);
- else
- wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION);
+ netconfig_update_default_profile();
}
} else {
if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
- if (netconfig_get_default_profile() == NULL) {
- if (!netconfig_is_cellular_profile(path)) {
- netconfig_update_default_profile(path);
- } else {
- if (netconfig_is_cellular_internet_profile(path)) {
- netconfig_update_default_profile(path);
- }
- }
- } else {
+ netconfig_update_default_profile();
+
+ if (netconfig_is_cellular_profile(netconfig_get_default_profile())) {
pf = netconfig_get_connected_cellular_internet_ipv6only_profile(NULL);
- if (pf)
- {
+ if (pf) {
g_free(pf);
/* Enable clatd if it is not in running state */
if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
cellular_state_set_service_state(NETCONFIG_CELLULAR_ONLINE);
- } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
+ } else if (g_strcmp0(property, "failure") == 0 ||
+ g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
if (netconfig_get_default_profile() == NULL) {
g_free(property);
goto done;
goto done;
}
- netconfig_update_default_profile(NULL);
+ netconfig_update_default_profile();
} else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
if (netconfig_get_default_profile() == NULL) {
g_free(property);
goto done;
}
- netconfig_update_default_profile(NULL);
+ netconfig_update_default_profile();
}
}
g_free(property);
} else if (g_strcmp0(sigvalue, "Proxy") == 0) {
- if (netconfig_is_wifi_profile(path) != TRUE || g_strcmp0(path, netconfig_get_default_profile()) != 0)
+ if (g_strcmp0(path, netconfig_get_default_profile()) != 0)
goto done;
if (!g_variant_is_of_type(variant, G_VARIANT_TYPE_ARRAY))
if (g_strcmp0(property, "Servers") == 0) {
GVariantIter *iter_sub = NULL;
- builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-
g_variant_get(var, "as", &iter_sub);
g_variant_iter_loop(iter_sub, "s", &value);
g_variant_iter_free(iter_sub);
DBG("Proxy - [%s]", value);
- vconf_set_str(VCONFKEY_NETWORK_PROXY, value);
+ if (g_strcmp0(value, netconfig_get_default_proxy()) != 0) {
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
- g_variant_builder_add(builder, "{sv}", "ProxyAddress",
- g_variant_new_string(value));
+ netconfig_set_default_proxy(value);
+ vconf_set_str(VCONFKEY_NETWORK_PROXY, value);
- sig_params = g_variant_new("(@a{sv})",
- g_variant_builder_end(builder));
- g_variant_builder_unref(builder);
+ g_variant_builder_add(builder, "{sv}", "ProxyAddress",
+ g_variant_new_string(value));
- netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH,
- NETCONFIG_NETWORK_INTERFACE, "NetworkConfigChanged",
- sig_params);
+ sig_params = g_variant_new("(@a{sv})",
+ g_variant_builder_end(builder));
+ g_variant_builder_unref(builder);
+
+ netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH,
+ NETCONFIG_NETWORK_INTERFACE, "NetworkConfigChanged",
+ sig_params);
+ }
g_free(property);
g_variant_unref(var);
DBG("Method - [%s]", value);
if (g_strcmp0(value, "direct") == 0) {
- builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ if (g_strcmp0("", netconfig_get_default_proxy()) != 0) {
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
- vconf_set_str(VCONFKEY_NETWORK_PROXY, "");
- g_variant_builder_add(builder, "{sv}", "ProxyAddress",
- g_variant_new_string(""));
+ netconfig_set_default_proxy("");
+ vconf_set_str(VCONFKEY_NETWORK_PROXY, "");
- sig_params = g_variant_new("(@a{sv})",
- g_variant_builder_end(builder));
- g_variant_builder_unref(builder);
+ g_variant_builder_add(builder, "{sv}", "ProxyAddress",
+ g_variant_new_string(""));
- netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH,
- NETCONFIG_NETWORK_INTERFACE,
- "NetworkConfigChanged", sig_params);
+ sig_params = g_variant_new("(@a{sv})",
+ g_variant_builder_end(builder));
+ g_variant_builder_unref(builder);
+
+ netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH,
+ NETCONFIG_NETWORK_INTERFACE,
+ "NetworkConfigChanged", sig_params);
+ }
}
g_free(property);
g_variant_iter_free(iter);
} else if (g_strcmp0(sigvalue, "IPv4") == 0) {
+ if (g_strcmp0(path, netconfig_get_default_profile()) != 0)
+ goto done;
+
__netconfig_extract_ipv4_signal_data(variant, path);
} else if (g_strcmp0(sigvalue, "IPv6") == 0) {
+ if (g_strcmp0(path, netconfig_get_default_profile()) != 0)
+ goto done;
+
__netconfig_extract_ipv6_signal_data(variant, path);
} else if (g_strcmp0(sigvalue, "Error") == 0) {
g_variant_get(variant, "s", &property);
return;
}
-static void _services_changed_cb(GDBusConnection *conn, const gchar *name,
- const gchar *path, const gchar *interface, const gchar *sig,
- GVariant *param, gpointer user_data)
-{
- gchar *property, *value;
- gchar *service_path;
- GVariant *variant = NULL;
- GVariantIter *added = NULL, *removed = NULL, *next = NULL;
-
- if (path == NULL || param == NULL)
- return;
-
- if (g_strcmp0(sig, CONNMAN_SIGNAL_SERVICES_CHANGED) != 0)
- return;
-
- if (netconfig_get_default_profile() != NULL)
- return;
-
- g_variant_get(param, "(a(oa{sv})ao)", &added, &removed);
-
- while (g_variant_iter_loop(added, "(oa{sv})", &service_path, &next)) {
- gboolean is_wifi_prof, is_cell_prof, is_cell_internet_prof;
- is_wifi_prof = netconfig_is_wifi_profile(service_path);
- is_cell_prof = netconfig_is_cellular_profile(service_path);
- is_cell_internet_prof = netconfig_is_cellular_internet_profile(
- service_path);
- if (service_path != NULL) {
- while (next && g_variant_iter_loop(next, "{sv}", &property,
- &variant)) {
- if (g_strcmp0(property, "State") == 0) {
- g_variant_get(variant, "s", &value);
- DBG("Profile %s State %s", service_path,
- value);
- if (g_strcmp0(value, "ready") != 0 &&
- g_strcmp0(value,
- "online") != 0) {
- g_free(property);
- g_free(value);
- g_variant_unref(variant);
- break;
- }
-
- if (!is_cell_prof)
- netconfig_update_default_profile(
- service_path);
- else if (is_cell_internet_prof) {
- netconfig_update_default_profile(
- service_path);
- }
- if (is_wifi_prof)
- wifi_state_set_service_state(
- NETCONFIG_WIFI_CONNECTED);
- else if (is_cell_prof &&
- is_cell_internet_prof)
- cellular_state_set_service_state(
- NETCONFIG_CELLULAR_ONLINE);
- g_free(property);
- g_free(value);
- g_variant_unref(variant);
- break;
- }
- }
- }
- }
-
- g_variant_iter_free(added);
-
- if (next)
- g_variant_iter_free(next);
-
- if (removed)
- g_variant_iter_free(removed);
-
- return;
-}
-
static void _scan_changed_cb(GDBusConnection *conn,
const gchar *name, const gchar *path, const gchar *interface,
const gchar *sig, GVariant *param, gpointer user_data)
const gchar *name, const gchar *path, const gchar *interface,
const gchar *sig, GVariant *param, gpointer user_data)
{
+ char *interface_name = NULL;
+
DBG("Interface removed handling!");
- if (netconfig_wifi_is_bssid_scan_started() == TRUE)
- netconfig_wifi_bssid_signal_scanaborted();
+ interface_name = __supplicant_get_interface_name(path, interface);
+ if (interface_name == NULL)
+ return;
+
+ if (netconfig_wifi_bssidscan_get_mode(interface_name) == TRUE)
+ netconfig_wifi_bssid_signal_scanaborted(interface_name);
+
+ g_free(interface_name);
return;
}
GVariantIter *iter = NULL;
GVariant *variant = NULL;
gboolean scanning = FALSE;
+ char *interface_name = NULL;
if (param == NULL)
return;
+ interface_name = __supplicant_get_interface_name(path, interface);
+ if (interface_name == NULL)
+ return;
+
g_variant_get(param, "(a{sv})", &iter);
while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
if (g_strcmp0(key, "Scanning") == 0) {
scanning = g_variant_get_boolean(variant);
DBG("setting scanning %s", scanning ? "TRUE" : "FALSE");
if (scanning == TRUE)
- netconfig_wifi_set_scanning(TRUE);
+ netconfig_wifi_scan_set_scanning(interface_name, TRUE);
else
- netconfig_wifi_set_scanning(FALSE);
+ netconfig_wifi_scan_set_scanning(interface_name, FALSE);
g_variant_unref(variant);
g_free(key);
} else if (g_strcmp0(key, "State") == 0) {
state = g_variant_get_string(variant, NULL);
if (state != NULL)
- ERR("Supplicant state : %s", state);
+ DBG("Supplicant state : %s", state);
g_variant_unref(variant);
g_free(key);
break;
} else if (g_strcmp0(key, "DisconnectReason") == 0) {
int reason = g_variant_get_int32(variant);
- ERR("Supplicant DisconnReason : %d", reason);
+ DBG("Supplicant DisconnReason : %d", reason);
g_variant_unref(variant);
g_free(key);
}
g_variant_iter_free(iter);
-
+ g_free(interface_name);
return;
}
const gchar *name, const gchar *path, const gchar *interface,
const gchar *sig, GVariant *param, gpointer user_data)
{
+ char *interface_name = NULL;
+
DBG("Scan Done handling!");
- netconfig_wifi_set_scanning(FALSE);
- if (netconfig_wifi_is_bssid_scan_started() == TRUE) {
- netconfig_wifi_bssid_signal_scandone();
- if (wifi_state_get_technology_state(FALSE) < NETCONFIG_WIFI_TECH_POWERED)
+ interface_name = __supplicant_get_interface_name(path, interface);
+ if (interface_name == NULL)
+ return;
+
+ netconfig_wifi_scan_set_scanning(interface_name, FALSE);
+
+ if (netconfig_wifi_bssidscan_get_mode(interface_name) == TRUE) {
+ DBG("%s bssid scan done!", interface_name);
+ netconfig_wifi_bssid_signal_scandone(interface_name);
+ if (wifi_state_get_technology_state(interface_name)
+ < NETCONFIG_WIFI_TECH_POWERED) {
+ g_free(interface_name);
return;
+ }
}
- if (netconfig_wifi_get_bgscan_state() == TRUE) {
- if (wifi_state_get_technology_state(FALSE) >=
- NETCONFIG_WIFI_TECH_POWERED)
- netconfig_wifi_bgscan_start(FALSE);
+ if (netconfig_wifi_bgscan_get_mode(interface_name) == TRUE) {
+ DBG("%s bgscan done!", interface_name);
+ if (wifi_state_get_technology_state(interface_name)
+ >= NETCONFIG_WIFI_TECH_POWERED) {
+ netconfig_wifi_bgscan_start(interface_name, FALSE);
+ }
- wifi_start_timer_network_notification();
+ wifi_start_timer_network_notification(interface_name);
}
+ g_free(interface_name);
return;
}
const gchar *name, const gchar *path, const gchar *interface,
const gchar *sig, GVariant *param, gpointer user_data)
{
+ char *interface_name = NULL;
+
DBG("Driver Hanged handling!");
ERR("Critical. Wi-Fi firmware crashed");
netconfig_send_message_to_net_popup("Wi-Fi Error",
"Wi-Fi Driver Hanged. Please get log dump and report", "popup", NULL);
#endif
- wifi_power_recover_firmware();
+ interface_name = __supplicant_get_interface_name(path, interface);
+ if (interface_name == NULL)
+ return;
+
+ wifi_power_recover_firmware(interface_name);
+
+ g_free(interface_name);
return;
}
const gchar *name, const gchar *path, const gchar *interface,
const gchar *sig, GVariant *param, gpointer user_data)
{
+ char *interface_name = NULL;
+
DBG("Received TDLS Connected Signal");
- netconfig_wifi_tdls_connected_event(param);
+ interface_name = __supplicant_get_interface_name(path, interface);
+ if (interface_name == NULL)
+ return;
+
+ netconfig_wifi_tdls_connected_event(interface_name, param);
+
+ g_free(interface_name);
return;
}
const gchar *name, const gchar *path, const gchar *interface,
const gchar *sig, GVariant *param, gpointer user_data)
{
+ char *interface_name = NULL;
+
DBG("Received TDLS Disconnected Signal");
- netconfig_wifi_tdls_disconnected_event(param);
+ interface_name = __supplicant_get_interface_name(path, interface);
+ if (interface_name == NULL)
+ return;
+
+ netconfig_wifi_tdls_disconnected_event(interface_name, param);
+
+ g_free(interface_name);
return;
}
const gchar *name, const gchar *path, const gchar *interface,
const gchar *sig, GVariant *param, gpointer user_data)
{
+ char *interface_name = NULL;
+
DBG("Received TDLS Peer Found Signal");
- netconfig_wifi_tdls_peer_found_event(param);
+
+ interface_name = __supplicant_get_interface_name(path, interface);
+ if (interface_name == NULL)
+ return;
+
+ netconfig_wifi_tdls_peer_found_event(interface_name, param);
+
+ g_free(interface_name);
return;
}
const gchar *name, const gchar *path, const gchar *interface,
const gchar *sig, GVariant *param, gpointer user_data)
{
+ char *interface_name = NULL;
+
DBG("Received DPP Conf Obj Signal");
- netconfig_wifi_dpp_conf_obj_event(param);
+
+ interface_name = __supplicant_get_interface_name(path, interface);
+ if (interface_name == NULL)
+ return;
+
+ netconfig_wifi_dpp_conf_obj_event(interface_name, param);
+
+ g_free(interface_name);
return;
}
-static void _supplicant_wifi_wps_connected(GVariant *param)
+static void _supplicant_wifi_wps_connected(const char *interface_name, GVariant *param)
{
gchar *key;
char ssid[32] = {0, };
ssid_len = 0;
}
INFO("WPS PBC Connection completed with AP %s", ssid);
- netconfig_wifi_notify_wps_completed(ssid, ssid_len);
+ netconfig_wifi_notify_wps_completed(interface_name,
+ ssid, ssid_len);
}
}
error_indication = WPS_EI_OPERATION_FAILED;
config_error = WPS_CFG_NO_ERROR;
ERR("Error Occured! Notifying Fail Event");
- netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
+ netconfig_wifi_notify_wps_fail_event(interface_name,
+ config_error, error_indication);
}
-static void _supplicant_wifi_wps_event(GVariant *param)
+static void _supplicant_wifi_wps_event(const char *interface_name, GVariant *param)
{
gchar *key;
gchar *name;
ERR("Error Indication %d", error_indication);
}
}
- netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
+ netconfig_wifi_notify_wps_fail_event(interface_name,
+ config_error, error_indication);
}
g_variant_iter_free(iter);
error_indication = WPS_EI_OPERATION_FAILED;
config_error = WPS_CFG_NO_ERROR;
ERR("Error Occured! Notifying Fail Event");
- netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
+ netconfig_wifi_notify_wps_fail_event(interface_name,
+ config_error, error_indication);
}
static void _find_service_and_set_passphrase(char *ssid, char *key)
return;
}
-static void _supplicant_wifi_wps_credentials(GVariant *param)
+static void _supplicant_wifi_wps_credentials(const char *interface_name, GVariant *param)
{
gchar *key;
char ssid[32] = {0, };
if (g_strcmp0(key_mgmt, "psk") == 0)
_find_service_and_set_passphrase(ssid, wps_key);
-#if 0
- /*
- * Notify WPS Credentials only when requested through WPS PBC
- * In case of WPS PIN connman will take care of notification
- */
- if (netconfig_get_wps_field() == TRUE)
-#endif
- netconfig_wifi_notify_wps_credentials(ssid, ssid_len, wps_key);
+ netconfig_wifi_notify_wps_credentials(interface_name, ssid, ssid_len, wps_key);
return;
error:
error_indication = WPS_EI_OPERATION_FAILED;
config_error = WPS_CFG_NO_ERROR;
ERR("Error Occured! Notifying Fail Event");
- netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
+ netconfig_wifi_notify_wps_fail_event(interface_name, config_error, error_indication);
}
static void __netconfig_wps_signal_filter_handler(GDBusConnection *conn,
const gchar *name, const gchar *path, const gchar *interface,
const gchar *sig, GVariant *param, gpointer user_data)
{
+ char *interface_name = NULL;
+
+ interface_name = __supplicant_get_interface_name(path, interface);
+ if (interface_name == NULL)
+ return;
+
if (g_strcmp0(sig, SIGNAL_WPS_CREDENTIALS) == 0) {
INFO("Received wps CREDENTIALS Signal from Supplicant");
- _supplicant_wifi_wps_credentials(param);
+ _supplicant_wifi_wps_credentials(interface_name, param);
} else if (g_strcmp0(sig, SIGNAL_WPS_EVENT) == 0) {
INFO("Received wps EVENT Signal from Supplicant");
- _supplicant_wifi_wps_event(param);
+ _supplicant_wifi_wps_event(interface_name, param);
} else if (g_strcmp0(sig, SIGNAL_WPS_CONNECTED) == 0) {
INFO("Received WPSConnected Signal from Supplicant");
- _supplicant_wifi_wps_connected(param);
+ _supplicant_wifi_wps_connected(interface_name, param);
}
+ g_free(interface_name);
return;
}
connection,
CONNMAN_SERVICE,
CONNMAN_MANAGER_INTERFACE,
- CONNMAN_SIGNAL_SERVICES_CHANGED,
- NULL,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- _services_changed_cb,
- NULL,
- NULL);
-
- conn_subscription_ids[4] = g_dbus_connection_signal_subscribe(
- connection,
- CONNMAN_SERVICE,
- CONNMAN_MANAGER_INTERFACE,
SIGNAL_SCAN_CHANGED,
CONNMAN_MANAGER_PATH,
NULL,
INFO("Successfully register connman DBus signal filters");
- conn_subscription_ids[5] = g_dbus_connection_signal_subscribe(
+ conn_subscription_ids[4] = g_dbus_connection_signal_subscribe(
connection,
SUPPLICANT_SERVICE,
SUPPLICANT_INTERFACE ".Interface.WPS",
GIOFlags flags;
struct sockaddr_in addr;
GIOChannel *channel = NULL;
+ const char *ifname = NULL;
int sock;
if (net_params == NULL || net_params->addr == NULL)
if (sock < 0)
goto cleanup;
+ ifname = netconfig_get_default_ifname();
if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE,
- WIFI_IFNAME, strlen(WIFI_IFNAME) + 1) < 0) {
+ ifname, strlen(ifname) + 1) < 0) {
ERR("Bind to device error");
close(sock);
goto cleanup;
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2020 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 "setting.h"
+#include "util.h"
+#include "log.h"
+
+typedef enum {
+ SETTING_TYPE_LAST_POWER,
+ SETTING_TYPE_WIFI_OFF_BY_AIRPLANE,
+ SETTING_TYPE_WIFI_OFF_BY_RESTRICTED,
+ SETTING_TYPE_WIFI_OFF_BY_EMERGENCY,
+} netconfig_setting_type_e;
+
+typedef struct {
+ const char *key;
+ GSList *string_list;
+} netconfig_setting_data_s;
+
+netconfig_setting_data_s netconfig_setting_data[] = {
+ { "LastPoweredInterfaces", NULL },
+ { "WifiOffByAirplaneInterfaces", NULL },
+ { "WifiOffByRestrictedInterfaces", NULL },
+ { "WifiOffByEmergencyInterfaces", NULL },
+};
+
+void netconfig_setting_init(void)
+{
+ netconfig_setting_load();
+
+ INFO("setting is initialized");
+
+ return;
+}
+
+void netconfig_setting_deinit(void)
+{
+ int i, size;
+
+ netconfig_setting_save();
+
+ size = ARRAY_SIZE(netconfig_setting_data);
+ for (i = 0; i < size; i++)
+ g_slist_free_full(netconfig_setting_data[i].string_list, g_free);
+
+ INFO("setting is deinitialized");
+
+ return;
+}
+
+static void __setting_set_string_list(GKeyFile *keyfile, netconfig_setting_type_e type)
+{
+ GString *string_str = NULL;
+ char **string_list = NULL;
+ GSList *list = NULL;
+ guint length;
+
+ string_str = g_string_new(NULL);
+ if (string_str) {
+ list = netconfig_setting_data[type].string_list;
+ for (; list; list = list->next) {
+ if (string_str->len > 0)
+ g_string_append_printf(string_str, " %s", (char *)list->data);
+ else
+ g_string_append(string_str, list->data);
+ }
+
+ if (string_str->len > 0) {
+ string_list = g_strsplit_set(string_str->str, " ", 0);
+ length = g_strv_length(string_list);
+ g_key_file_set_string_list(keyfile, SETTINGS_WIFI_GROUP_NAME,
+ netconfig_setting_data[type].key,
+ (const gchar **)string_list, length);
+ } else {
+ g_key_file_remove_key(keyfile, SETTINGS_WIFI_GROUP_NAME,
+ netconfig_setting_data[type].key, NULL);
+ }
+
+ g_string_free(string_str, TRUE);
+ }
+}
+
+static void __setting_get_string_list(GKeyFile *keyfile, netconfig_setting_type_e type)
+{
+ char **string_list = NULL;
+ gsize length;
+ int i;
+
+ INFO("Key [%s]", netconfig_setting_data[type].key);
+
+ string_list = g_key_file_get_string_list(keyfile, SETTINGS_WIFI_GROUP_NAME,
+ netconfig_setting_data[type].key, &length, NULL);
+ if (string_list && length != 0) {
+ for (i = 0; string_list[i]; i++) {
+ netconfig_setting_data[type].string_list = g_slist_append(
+ netconfig_setting_data[type].string_list,
+ g_strdup(string_list[i]));
+
+ INFO("%s", string_list[i]);
+ }
+ }
+
+ g_strfreev(string_list);
+}
+
+int netconfig_setting_save(void)
+{
+ GKeyFile *keyfile = NULL;
+
+ INFO("Save setting [%s]", NETCONFIG_SETTINGS_PATH);
+
+ keyfile = netconfig_keyfile_load(NETCONFIG_SETTINGS_PATH);
+ if (keyfile == NULL) {
+ ERR("Fail to get settings keyfile");
+ return -EIO;
+ }
+
+ __setting_set_string_list(keyfile, SETTING_TYPE_LAST_POWER);
+ __setting_set_string_list(keyfile, SETTING_TYPE_WIFI_OFF_BY_AIRPLANE);
+ __setting_set_string_list(keyfile, SETTING_TYPE_WIFI_OFF_BY_RESTRICTED);
+ __setting_set_string_list(keyfile, SETTING_TYPE_WIFI_OFF_BY_EMERGENCY);
+
+ netconfig_keyfile_save(keyfile, NETCONFIG_SETTINGS_PATH);
+
+ g_key_file_free(keyfile);
+ return 0;
+}
+
+int netconfig_setting_load(void)
+{
+ GKeyFile *keyfile = NULL;
+
+ INFO("Load setting [%s]", NETCONFIG_SETTINGS_PATH);
+
+ keyfile = netconfig_keyfile_load(NETCONFIG_SETTINGS_PATH);
+ if (keyfile == NULL) {
+ ERR("Fail to get settings keyfile");
+ return -EIO;
+ }
+
+ __setting_get_string_list(keyfile, SETTING_TYPE_LAST_POWER);
+ __setting_get_string_list(keyfile, SETTING_TYPE_WIFI_OFF_BY_AIRPLANE);
+ __setting_get_string_list(keyfile, SETTING_TYPE_WIFI_OFF_BY_RESTRICTED);
+ __setting_get_string_list(keyfile, SETTING_TYPE_WIFI_OFF_BY_EMERGENCY);
+
+ return 0;
+}
+
+void netconfig_setting_update_interface_for_last_powered(const char *interface_name,
+ bool mode)
+{
+ GSList *list = netconfig_setting_data[SETTING_TYPE_LAST_POWER].string_list;
+ bool find = FALSE;
+
+ for ( ; list; list = list->next) {
+ const char *ifname = list->data;
+ if (g_strcmp0(ifname, interface_name) == 0) {
+ if (mode == FALSE)
+ netconfig_setting_data[SETTING_TYPE_LAST_POWER].string_list = g_slist_remove(
+ netconfig_setting_data[SETTING_TYPE_LAST_POWER].string_list, ifname);
+
+ find = TRUE;
+ break;
+ }
+ }
+
+ if (mode == TRUE && find == FALSE)
+ netconfig_setting_data[SETTING_TYPE_LAST_POWER].string_list = g_slist_append(
+ netconfig_setting_data[SETTING_TYPE_LAST_POWER].string_list, g_strdup(interface_name));
+
+ netconfig_setting_save();
+}
+
+GSList *netconfig_setting_get_interfaces_for_last_powered(void)
+{
+ return netconfig_setting_data[SETTING_TYPE_LAST_POWER].string_list;
+}
+
+void netconfig_setting_update_interface_off_for_airplane(const char *interface_name,
+ bool mode)
+{
+ GSList *list = netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_AIRPLANE].string_list;
+ bool find = FALSE;
+
+ for ( ; list; list = list->next) {
+ const char *ifname = list->data;
+ if (g_strcmp0(ifname, interface_name) == 0) {
+ if (mode == FALSE)
+ netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_AIRPLANE].string_list = g_slist_remove(
+ netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_AIRPLANE].string_list, ifname);
+
+ find = TRUE;
+ break;
+ }
+ }
+
+ if (mode == TRUE && find == FALSE)
+ netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_AIRPLANE].string_list = g_slist_append(
+ netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_AIRPLANE].string_list, g_strdup(interface_name));
+
+ netconfig_setting_save();
+}
+
+GSList *netconfig_setting_get_interfaces_off_by_airplane(void)
+{
+ return netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_AIRPLANE].string_list;
+}
+
+void netconfig_setting_update_interface_off_for_restricted(const char *interface_name,
+ bool mode)
+{
+ GSList *list = netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_RESTRICTED].string_list;
+ bool find = FALSE;
+
+ for ( ; list; list = list->next) {
+ const char *ifname = list->data;
+ if (g_strcmp0(ifname, interface_name) == 0) {
+ if (mode == FALSE)
+ netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_RESTRICTED].string_list = g_slist_remove(
+ netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_RESTRICTED].string_list, ifname);
+
+ find = TRUE;
+ break;
+ }
+ }
+
+ if (mode == TRUE && find == FALSE)
+ netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_RESTRICTED].string_list = g_slist_append(
+ netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_RESTRICTED].string_list, g_strdup(interface_name));
+
+ netconfig_setting_save();
+}
+
+GSList *netconfig_setting_get_interfaces_off_by_restricted(void)
+{
+ return netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_RESTRICTED].string_list;
+}
+
+void netconfig_setting_update_interface_off_for_emergency(const char *interface_name,
+ bool mode)
+{
+ GSList *list = netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_EMERGENCY].string_list;
+ bool find = FALSE;
+
+ for ( ; list; list = list->next) {
+ const char *ifname = list->data;
+ if (g_strcmp0(ifname, interface_name) == 0) {
+ if (mode == FALSE)
+ netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_EMERGENCY].string_list = g_slist_remove(
+ netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_EMERGENCY].string_list, ifname);
+
+ find = TRUE;
+ break;
+ }
+ }
+
+ if (mode == TRUE && find == FALSE)
+ netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_EMERGENCY].string_list = g_slist_append(
+ netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_EMERGENCY].string_list, g_strdup(interface_name));
+
+ netconfig_setting_save();
+}
+
+GSList *netconfig_setting_get_interfaces_off_by_emergency(void)
+{
+ return netconfig_setting_data[SETTING_TYPE_WIFI_OFF_BY_EMERGENCY].string_list;
+}
#define DBUS_INTERFACE_DBUS "org.freedesktop.DBus"
#define MAC_INFO_FILEPATH tzplatform_mkpath(TZ_SYS_ETC, "/.mac.info")
#define MAC_ADDRESS_FILEPATH "/sys/class/net/wlan0/address"
-#define MAC_ADDRESS_MAX_LEN 18
#define HEADED_PLUGIN_FILEPATH "/usr/lib/net-config-plugin-headed.so"
#define TELEPHONY_PLUGIN_FILEPATH "/usr/lib/net-config-plugin-telephony.so"
#define STC_PLUGIN_FILEPATH "/usr/lib/net-config-plugin-stc.so"
static bool is_feature_checked[NETCONFIG_SUPPORTED_FEATURE_MAX] = {0, };
static bool feature_supported[NETCONFIG_SUPPORTED_FEATURE_MAX] = {0, };
+gboolean netconfig_check_mac_address(const char *service, const char *mac_address)
+{
+ int service_index = 0;
+ int mac_index = 0;
+ const char *org = NULL;
+ const char *dst = NULL;
+ int i = 0;
+
+ if (g_str_has_prefix(service, "wifi_") == FALSE)
+ return FALSE;
+
+ service_index = strlen("wifi_");
+ for (i = 0; i < 6; i++) {
+ org = &service[service_index];
+ dst = &mac_address[mac_index];
+
+ if (g_ascii_strncasecmp(org, dst, 2) != 0)
+ return FALSE;
+
+ service_index += 2;
+ mac_index += 3;
+ }
+
+ return TRUE;
+}
+
gboolean netconfig_check_passphrase(const gchar *service, const char *passphrase)
{
gsize length;
{
int ret = 0;
- DBG("[%s: %d]", key, value);
+ if (g_strcmp0(key, VCONFKEY_WIFI_TRANSFER_STATE) != 0)
+ DBG("[%s: %d]", key, value);
ret = vconf_set_int(key, value);
if (ret != VCONF_OK)
#define NETCONFIG_AGENT_ERR_CONNECT_FAILED "connect-failed"
-struct netconfig_wifi_agent {
+typedef struct {
+ char *interface_name;
GByteArray *ssid;
char *name;
char *identity;
char *password;
#endif
gboolean wps_pbc;
-};
+} netconfig_wifi_agent_s;
-static struct netconfig_wifi_agent agent;
+static GSList *g_agent_list = NULL;
-static void __netconfig_agent_clear_fields(void)
+static void __agent_clear_fields(netconfig_wifi_agent_s *agent)
{
- if (agent.ssid)
- g_byte_array_free(agent.ssid, TRUE);
- g_free(agent.name);
- g_free(agent.identity);
- g_free(agent.passphrase);
- g_free(agent.wps_pin);
+ if (!agent)
+ return;
+
+ g_free(agent->interface_name);
+ if (agent->ssid)
+ g_byte_array_free(agent->ssid, TRUE);
+ g_free(agent->name);
+ g_free(agent->identity);
+ g_free(agent->passphrase);
+ g_free(agent->wps_pin);
#if defined TIZEN_CAPTIVE_PORTAL
- g_free(agent.username);
- g_free(agent.password);
+ g_free(agent->username);
+ g_free(agent->password);
#endif
- agent.ssid = NULL;
- agent.name = NULL;
- agent.identity = NULL;
- agent.passphrase = NULL;
- agent.wps_pin = NULL;
+ agent->interface_name = NULL;
+ agent->ssid = NULL;
+ agent->name = NULL;
+ agent->identity = NULL;
+ agent->passphrase = NULL;
+ agent->wps_pin = NULL;
#if defined TIZEN_CAPTIVE_PORTAL
- agent.username = NULL;
- agent.password = NULL;
+ agent->username = NULL;
+ agent->password = NULL;
#endif
- agent.wps_pbc = FALSE;
+ agent->wps_pbc = FALSE;
+}
+
+static void __agent_free_data(gpointer data)
+{
+ netconfig_wifi_agent_s *agent = data;
+
+ __agent_clear_fields(agent);
+ g_free(agent);
+}
+
+static netconfig_wifi_agent_s *__agent_get_data(const char *interface_name)
+{
+ GSList *list = NULL;
+
+ for (list = g_agent_list; list; list = list->next) {
+ netconfig_wifi_agent_s *wifi_agent = list->data;
+ if (g_strcmp0(wifi_agent->interface_name, interface_name) == 0)
+ return wifi_agent;
+ }
+
+ return NULL;
}
int connman_register_agent(void)
reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
- "UnregisterAgent", param, NULL);
+ "UnregisterAgent", param, NULL, NULL);
if (reply != TRUE)
ERR("Fail to unregister agent");
/* Clearing the agent fields */
- __netconfig_agent_clear_fields();
+ g_slist_free_full(g_agent_list, __agent_free_data);
return reply;
}
-gboolean netconfig_wifi_set_agent_field_for_eap_network(
- const char *name, const char *identity, const char *passphrase)
+gboolean netconfig_wifi_set_agent_field_for_eap_network(const char *interface_name,
+ const char *name, const char *identity, const char *passphrase)
{
int name_len;
+ netconfig_wifi_agent_s *wifi_agent = NULL;
if (name == NULL)
return FALSE;
- __netconfig_agent_clear_fields();
+ wifi_agent = __agent_get_data(interface_name);
+ if (wifi_agent == NULL)
+ return FALSE;
+
+ __agent_clear_fields(wifi_agent);
name_len = strlen(name);
- agent.ssid = g_byte_array_sized_new(name_len);
- agent.ssid->len = name_len;
- memcpy(agent.ssid->data, name, name_len + 1);
+ wifi_agent->ssid = g_byte_array_sized_new(name_len);
+ wifi_agent->ssid->len = name_len;
+ memcpy(wifi_agent->ssid->data, name, name_len + 1);
if (identity)
- agent.identity = g_strdup(identity);
+ wifi_agent->identity = g_strdup(identity);
if (passphrase)
- agent.passphrase = g_strdup(passphrase);
+ wifi_agent->passphrase = g_strdup(passphrase);
gchar *enc_data = NULL;
- enc_data = _netconfig_encrypt_passphrase(agent.passphrase);
+ enc_data = _netconfig_encrypt_passphrase(wifi_agent->passphrase);
if (!enc_data) {
ERR("Failed to encrypt the passphrase");
} else {
- g_free(agent.passphrase);
- agent.passphrase = enc_data;
+ g_free(wifi_agent->passphrase);
+ wifi_agent->passphrase = enc_data;
}
DBG("Successfully configured for EAP network");
GVariant *value;
gboolean updated = FALSE;
gboolean reply = FALSE;
+ const char *interface_name = NULL;
+ netconfig_wifi_agent_s *wifi_agent = NULL;
g_return_val_if_fail(connman_agent != NULL, TRUE);
return TRUE;
}
- __netconfig_agent_clear_fields();
+ interface_name = netconfig_get_ifname(service);
+ if (interface_name == NULL) {
+ error = g_error_new(G_DBUS_ERROR,
+ G_DBUS_ERROR_AUTH_FAILED,
+ CONNMAN_ERROR_INTERFACE ".InvalidService");
+
+ g_dbus_method_invocation_return_gerror(context, error);
+ g_clear_error(&error);
+
+ return TRUE;
+ }
+
+ wifi_agent = __agent_get_data(interface_name);
+ if (wifi_agent == NULL) {
+ wifi_agent = g_try_malloc0(sizeof(netconfig_wifi_agent_s));
+ if (wifi_agent == NULL) {
+ error = g_error_new(G_DBUS_ERROR,
+ G_DBUS_ERROR_AUTH_FAILED,
+ CONNMAN_ERROR_INTERFACE ".OutOfMemory");
+
+ g_dbus_method_invocation_return_gerror(context, error);
+ g_clear_error(&error);
+
+ return TRUE;
+ }
+
+ g_agent_list = g_slist_append(g_agent_list, wifi_agent);
+ }
+
+ __agent_clear_fields(wifi_agent);
+ wifi_agent->interface_name = g_strdup(interface_name);
+
g_variant_get(fields, "a{sv}", &iter);
while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_PASSPHRASE) == 0) {
if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
- agent.passphrase = g_strdup(g_variant_get_string(value, NULL));
+ wifi_agent->passphrase = g_strdup(g_variant_get_string(value, NULL));
updated = TRUE;
DBG("Field [%s] - []", (gchar *)field);
- if (agent.passphrase == NULL)
+ if (wifi_agent->passphrase == NULL)
continue;
- if (netconfig_check_passphrase(service, agent.passphrase) == FALSE) {
+ if (netconfig_check_passphrase(service, wifi_agent->passphrase) == FALSE) {
ERR("Invalid passphrase");
- g_free(agent.passphrase);
- agent.passphrase = NULL;
+ g_free(wifi_agent->passphrase);
+ wifi_agent->passphrase = NULL;
updated = FALSE;
continue;
}
gchar *enc_data = NULL;
- enc_data = _netconfig_encrypt_passphrase(agent.passphrase);
+ enc_data = _netconfig_encrypt_passphrase(wifi_agent->passphrase);
if (!enc_data) {
ERR("Failed to encrypt the passphrase");
continue;
}
- g_free(agent.passphrase);
- agent.passphrase = enc_data;
+ g_free(wifi_agent->passphrase);
+ wifi_agent->passphrase = enc_data;
}
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_WPS_PBC) == 0) {
if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING) &&
g_strcmp0(g_variant_get_string(value, NULL), "enable") == 0) {
- agent.wps_pbc = TRUE;
+ wifi_agent->wps_pbc = TRUE;
updated = TRUE;
- DBG("Field [%s] - [%d]", (gchar *)field, agent.wps_pbc);
+ DBG("Field [%s] - [%d]", (gchar *)field, wifi_agent->wps_pbc);
}
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_WPS_PIN) == 0) {
if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
- agent.wps_pin = g_strdup(g_variant_get_string(value, NULL));
+ wifi_agent->wps_pin = g_strdup(g_variant_get_string(value, NULL));
updated = TRUE;
- DBG("Field [%s] - [%s]", (gchar *)field, agent.wps_pin);
+ DBG("Field [%s] - [%s]", (gchar *)field, wifi_agent->wps_pin);
}
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_NAME) == 0) {
if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
- agent.name = g_strdup(g_variant_get_string(value, NULL));
+ wifi_agent->name = g_strdup(g_variant_get_string(value, NULL));
updated = TRUE;
- DBG("Field [%s] - [%s]", (gchar *)field, agent.name);
+ DBG("Field [%s] - [%s]", (gchar *)field, wifi_agent->name);
}
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_SSID) == 0) {
- if (agent.ssid != NULL) {
- g_byte_array_free(agent.ssid, TRUE);
- agent.ssid = NULL;
+ if (wifi_agent->ssid != NULL) {
+ g_byte_array_free(wifi_agent->ssid, TRUE);
+ wifi_agent->ssid = NULL;
}
if (g_variant_is_of_type(value, G_VARIANT_TYPE_BYTESTRING)) {
g_byte_array_append(array, &char_value, 1);
g_variant_iter_free(iter1);
if (array != NULL && (array->len > 0)) {
- agent.ssid = g_byte_array_sized_new(array->len);
- agent.ssid->len = array->len;
- memcpy(agent.ssid->data, array->data, array->len);
+ wifi_agent->ssid = g_byte_array_sized_new(array->len);
+ wifi_agent->ssid->len = array->len;
+ memcpy(wifi_agent->ssid->data, array->data, array->len);
updated = TRUE;
DBG("Field [%s] - []", (gchar *)field);
}
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_IDENTITY) == 0) {
if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
- agent.identity = g_strdup(g_variant_get_string(value, NULL));
+ wifi_agent->identity = g_strdup(g_variant_get_string(value, NULL));
updated = TRUE;
- DBG("Field [%s] - [%s]", (gchar *)field, agent.identity);
+ DBG("Field [%s] - [%s]", (gchar *)field, wifi_agent->identity);
}
#if defined TIZEN_CAPTIVE_PORTAL
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_USERNAME) == 0) {
if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
- agent.username = g_strdup(g_variant_get_string(value, NULL));
+ wifi_agent->username = g_strdup(g_variant_get_string(value, NULL));
updated = TRUE;
- DBG("Field [%s] - [%s]", (gchar *)field, agent.username);
+ DBG("Field [%s] - [%s]", (gchar *)field, wifi_agent->username);
}
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_PASSWORD) == 0) {
if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
- agent.password = g_strdup(g_variant_get_string(value, NULL));
+ wifi_agent->password = g_strdup(g_variant_get_string(value, NULL));
updated = TRUE;
- DBG("Field [%s] - [%s]", (gchar *)field, agent.password);
+ DBG("Field [%s] - [%s]", (gchar *)field, wifi_agent->password);
}
#endif
}
if (updated == TRUE) {
reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
service, CONNMAN_SERVICE_INTERFACE, "Connect",
- NULL, __netconfig_wifi_connect_reply);
+ NULL, __netconfig_wifi_connect_reply,
+ g_strdup(interface_name));
if (reply != TRUE) {
ERR("Fail to connect Wi-Fi");
- __netconfig_agent_clear_fields();
+ __agent_clear_fields(wifi_agent);
error = g_error_new(G_DBUS_ERROR,
G_DBUS_ERROR_AUTH_FAILED,
CONNMAN_ERROR_INTERFACE ".InvalidArguments");
}
} else {
ERR("Fail to connect Wi-Fi");
- __netconfig_agent_clear_fields();
+ __agent_clear_fields(wifi_agent);
error = g_error_new(G_DBUS_ERROR,
G_DBUS_ERROR_AUTH_FAILED,
GVariant *out_table = NULL;
gboolean updated = FALSE;
GVariantBuilder *builder = NULL;
+ GError *error = NULL;
+ const char *interface_name = NULL;
+ netconfig_wifi_agent_s *wifi_agent = NULL;
g_return_val_if_fail(connman_agent != NULL, TRUE);
DBG("Agent fields requested for service: %s", service);
+ interface_name = netconfig_get_ifname(service);
+ if (interface_name == NULL) {
+ error = g_error_new(G_DBUS_ERROR,
+ G_DBUS_ERROR_AUTH_FAILED,
+ CONNMAN_ERROR_INTERFACE ".InvalidService");
+
+ g_dbus_method_invocation_return_gerror(context, error);
+ g_clear_error(&error);
+
+ return TRUE;
+ }
+
+ wifi_agent = __agent_get_data(interface_name);
+ if (wifi_agent == NULL) {
+ error = g_error_new(G_DBUS_ERROR,
+ G_DBUS_ERROR_AUTH_FAILED,
+ CONNMAN_ERROR_INTERFACE ".InvalidService");
+
+ g_dbus_method_invocation_return_gerror(context, error);
+ g_clear_error(&error);
+
+ return TRUE;
+ }
+
builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
g_variant_get(fields, "a{sv}", &iter);
while (g_variant_iter_loop(iter, "{sv}", &field, &r_value)) {
if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_PASSPHRASE) == 0 &&
- agent.passphrase != NULL) {
+ wifi_agent->passphrase != NULL) {
g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_PASSPHRASE,
- g_variant_new_string(agent.passphrase));
+ g_variant_new_string(wifi_agent->passphrase));
updated = TRUE;
- DBG("Setting [%s] - [%s]", field, agent.passphrase);
+ DBG("Setting [%s] - [%s]", field, wifi_agent->passphrase);
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_WPS) == 0 &&
- (agent.wps_pbc == TRUE || agent.wps_pin != NULL)) {
- if (agent.wps_pbc == TRUE) {
+ (wifi_agent->wps_pbc == TRUE || wifi_agent->wps_pin != NULL)) {
+ if (wifi_agent->wps_pbc == TRUE) {
/* Sending empty string for WPS push button method */
- g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_WPS, g_variant_new_string(""));
+ g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_WPS,
+ g_variant_new_string(""));
updated = TRUE;
DBG("Setting empty string for [%s]", field);
- } else if (agent.wps_pin != NULL) {
- g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_WPS, g_variant_new_string(agent.wps_pin));
+ } else if (wifi_agent->wps_pin != NULL) {
+ g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_WPS,
+ g_variant_new_string(wifi_agent->wps_pin));
updated = TRUE;
- DBG("Setting string [%s] - [%s]", field, agent.wps_pin);
+ DBG("Setting string [%s] - [%s]", field, wifi_agent->wps_pin);
}
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_NAME) == 0 &&
- agent.name != NULL) {
- g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_NAME, g_variant_new_string(agent.name));
+ wifi_agent->name != NULL) {
+ g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_NAME,
+ g_variant_new_string(wifi_agent->name));
updated = TRUE;
- DBG("Settings [%s] - [%s]", field, agent.name);
+ DBG("Settings [%s] - [%s]", field, wifi_agent->name);
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_SSID) == 0 &&
- agent.ssid != NULL) {
+ wifi_agent->ssid != NULL) {
int i = 0;
GVariantBuilder *builder1 = NULL;
builder1 = g_variant_builder_new(G_VARIANT_TYPE("ay"));
- for (i = 0; i < (agent.ssid->len); i++)
- g_variant_builder_add(builder1, "y", agent.ssid->data[i]);
+ for (i = 0; i < (wifi_agent->ssid->len); i++)
+ g_variant_builder_add(builder1, "y", wifi_agent->ssid->data[i]);
- g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_SSID, g_variant_builder_end(builder1));
+ g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_SSID,
+ g_variant_builder_end(builder1));
if (builder1 != NULL)
g_variant_builder_unref(builder1);
updated = TRUE;
DBG("Settings [%s] - []", field);
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_IDENTITY) == 0 &&
- agent.identity != NULL) {
- g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_IDENTITY, g_variant_new_string(agent.identity));
+ wifi_agent->identity != NULL) {
+ g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_IDENTITY,
+ g_variant_new_string(wifi_agent->identity));
updated = TRUE;
- DBG("Settings [%s] - [%s]", field, agent.identity);
+ DBG("Settings [%s] - [%s]", field, wifi_agent->identity);
#if defined TIZEN_CAPTIVE_PORTAL
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_USERNAME) == 0 &&
- agent.username != NULL) {
- g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_USERNAME, g_variant_new_string(agent.username));
+ wifi_agent->username != NULL) {
+ g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_USERNAME,
+ g_variant_new_string(wifi_agent->username));
updated = TRUE;
- DBG("Settings [%s] - [%s]", field, agent.username);
+ DBG("Settings [%s] - [%s]", field, wifi_agent->username);
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_PASSWORD) == 0 &&
- agent.password != NULL) {
- g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_PASSWORD, g_variant_new_string(agent.password));
+ wifi_agent->password != NULL) {
+ g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_PASSWORD,
+ g_variant_new_string(wifi_agent->password));
updated = TRUE;
- DBG("Settings [%s] - [%s]", field, agent.password);
+ DBG("Settings [%s] - [%s]", field, wifi_agent->password);
#endif
}
}
g_clear_error(&error);
}
- __netconfig_agent_clear_fields();
+ __agent_clear_fields(wifi_agent);
return TRUE;
}
return FALSE;
}
-static void __wifi_state_monitor(wifi_service_state_e state,
- void *user_data);
+static void __wifi_state_monitor(wifi_state_notifier_s *notifier,
+ char *service, wifi_service_state_e state, void *user_data);
-static wifi_state_notifier wifi_state_monitor_notifier = {
+static wifi_state_notifier_s wifi_state_monitor_notifier = {
+ .notifier = NULL,
+ .service = NULL,
.wifi_state_changed = __wifi_state_monitor,
.user_data = NULL,
};
-static void __wifi_state_monitor(wifi_service_state_e state,
- void *user_data)
+static void __wifi_state_monitor(wifi_state_notifier_s *notifier,
+ char *service, wifi_service_state_e state, void *user_data)
{
DBG("Wi-Fi state: %x", state);
}
/* Disconnect and forget the AP */
- service_profile = (char*) netconfig_get_default_profile();
+ service_profile = (char *)netconfig_get_default_profile();
if (service_profile && netconfig_is_wifi_profile(service_profile)) {
/* Now forget the AP*/
reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
ERR("Failed to forget the AP ");
}
} else {
- if (NETCONFIG_WIFI_CONNECTED ==
- wifi_state_get_service_state()) {
+ if (wifi_state_get_service_state(netconfig_get_default_ifname())
+ == NETCONFIG_WIFI_CONNECTED) {
/* check Internet availability by sending and receiving data*/
netconfig_check_internet_accessibility();
/* Returning TRUE itself is enough to restart the timer */
#include "util.h"
#include "netdbus.h"
#include "wifi-state.h"
+#include "wifi-scan.h"
#include "wifi-background-scan.h"
-struct bgscan_data {
- guint time;
- guint mode;
- guint timer_id;
- gboolean paused;
-};
-
-static gboolean netconfig_wifi_scanning = FALSE;
-
-static gboolean __netconfig_wifi_bgscan_next_scan(gpointer data);
-
-static struct bgscan_data *__netconfig_wifi_bgscan_get_data(void)
-{
- static struct bgscan_data data = {
- SCAN_EXPONENTIAL_MIN, WIFI_BGSCAN_MODE_EXPONENTIAL, 0, FALSE};
-
- return &data;
-}
-
-static gboolean __netconfig_wifi_bgscan_set_mode(guint mode)
-{
- if (mode != WIFI_BGSCAN_MODE_EXPONENTIAL && mode != WIFI_BGSCAN_MODE_PERIODIC) {
- ERR("Invalid scan mode [%d]", mode);
- return FALSE;
- }
-
- struct bgscan_data *data = __netconfig_wifi_bgscan_get_data();
- data->mode = mode;
-
- return TRUE;
-}
-
-static gboolean _set_scan_reset_interval(guint interval)
-{
- if ((interval < SCAN_EXPONENTIAL_MIN) || (interval > SCAN_EXPONENTIAL_MAX)) {
- ERR("Invalid interval [%d]", interval);
- return FALSE;
- }
-
- struct bgscan_data *data = __netconfig_wifi_bgscan_get_data();
- data->time = interval;
- return TRUE;
-}
-
-static guint _get_scan_reset_interval(void)
-{
- struct bgscan_data *data = __netconfig_wifi_bgscan_get_data();
-
- return data->time;;
-}
-
-static void __netconfig_wifi_scan_request_reply(GObject *source_object,
- GAsyncResult *res, gpointer user_data)
-{
- GVariant *reply;
- GDBusConnection *conn = NULL;
- GError *error = NULL;
-
- conn = G_DBUS_CONNECTION(source_object);
- reply = g_dbus_connection_call_finish(conn, res, &error);
-
- if (reply == NULL) {
- if (error != NULL) {
- ERR("Fail to request status [%d: %s]", error->code, error->message);
- netconfig_wifi_set_scanning(FALSE);
- g_error_free(error);
- } else {
- ERR("Fail to request scan");
- netconfig_wifi_set_scanning(FALSE);
- }
- } else {
- DBG("Successfully requested");
- g_variant_unref(reply);
- }
-
- netconfig_gdbus_pending_call_unref();
-}
-
-static gboolean __netconfig_wifi_bgscan_request_connman_scan(int retries)
-{
- gboolean reply = FALSE;
-
- netconfig_wifi_set_scanning(TRUE);
-
- reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
- CONNMAN_WIFI_TECHNOLOGY_PREFIX,
- CONNMAN_TECHNOLOGY_INTERFACE, "Scan", NULL, __netconfig_wifi_scan_request_reply);
- if (reply != TRUE) {
- ERR("Failed to send Scan request to connman");
- netconfig_wifi_set_scanning(FALSE);
- }
-
- return reply;
-}
-
-static gboolean __netconfig_wifi_bgscan_immediate_scan(gpointer data)
-{
- static int retries = 0;
- guint state = wifi_state_get_service_state();
-
-#if !defined TIZEN_WEARABLE
- if (netconfig_wifi_is_bgscan_paused()) {
- return FALSE;
- }
-#endif
- if (netconfig_wifi_block_bgscan(-1))
- return FALSE;
-
- if (state == NETCONFIG_WIFI_CONNECTED) {
- if (netconfig_wifi_bgscan_get_mode() == WIFI_BGSCAN_MODE_EXPONENTIAL) {
- DBG("Wi-Fi state is connected, scan is paused");
- return FALSE;
- }
- } else if (state == NETCONFIG_WIFI_ASSOCIATION || state == NETCONFIG_WIFI_CONFIGURATION) {
- /* During WIFI connecting, WIFI can be disappeared.
- * After 1 sec, try scan even if connecting state */
- if (retries < 2) {
- retries++;
- return TRUE;
- }
- }
-
- if (__netconfig_wifi_bgscan_request_connman_scan(retries) == TRUE) {
- retries = 0;
- return FALSE;
- } else if (retries > 2) {
- retries = 0;
- return FALSE;
- }
-
- retries++;
-
- return TRUE;
-}
-
-static void __netconfig_wifi_bgscan_start_timer(gboolean immediate_scan)
-{
- struct bgscan_data *data = __netconfig_wifi_bgscan_get_data();
-
- netconfig_stop_timer(&(data->timer_id));
-
- switch (data->mode) {
- case WIFI_BGSCAN_MODE_EXPONENTIAL:
- if (data->time < SCAN_EXPONENTIAL_MIN ||
- data->time == SCAN_PERIODIC_DELAY)
- data->time = SCAN_EXPONENTIAL_MIN;
- break;
- case WIFI_BGSCAN_MODE_PERIODIC:
- data->time = SCAN_PERIODIC_DELAY;
- break;
- default:
- DBG("Invalid Wi-Fi background scan mode[%d]", data->mode);
- return;
- }
-
- if (immediate_scan)
- DBG("Scan immediately[%d], mode[%d](0 exponential / 1 periodic)", immediate_scan, data->mode);
- else
- DBG("Scan immediately[%d], mode[%d](0 exponential / 1 periodic), next[%d]", immediate_scan, data->mode, data->time);
-
- if (immediate_scan)
- g_timeout_add(500, __netconfig_wifi_bgscan_immediate_scan, NULL);
-
- netconfig_start_timer_seconds(data->time,
- __netconfig_wifi_bgscan_next_scan, data, &(data->timer_id));
- if (data->mode == WIFI_BGSCAN_MODE_EXPONENTIAL && immediate_scan) {
- data->time = data->time * 2;
- if (data->time > SCAN_EXPONENTIAL_MAX)
- data->time = SCAN_EXPONENTIAL_MAX;
- }
-
- //DBG("Scan immediately[%d], mode[%d](0 exponential / 1 periodic), next[%d]", immediate_scan, data->mode, data->time);
-}
-
-static void __netconfig_wifi_bgscan_stop_timer(struct bgscan_data *data)
-{
- if (data == NULL)
- return;
-
- netconfig_stop_timer(&(data->timer_id));
-}
-
-static gboolean __netconfig_wifi_bgscan_next_scan(gpointer data)
-{
- int pm_state = VCONFKEY_PM_STATE_NORMAL;
-
- /* In case of LCD off, we don't need Wi-Fi scan */
- netconfig_vconf_get_int(VCONFKEY_PM_STATE, &pm_state);
- if (pm_state >= VCONFKEY_PM_STATE_LCDOFF)
- return TRUE;
-
- __netconfig_wifi_bgscan_start_timer(TRUE);
-
- return FALSE;
-}
-
-gboolean netconfig_wifi_block_bgscan(int status)
-{
- static gboolean blocked = FALSE;
-
- if (status == 1)
- blocked = TRUE;
- else if (status == 0)
- blocked = FALSE;
-
- return blocked;
-}
-
-void netconfig_wifi_set_bgscan_pause(gboolean pause)
-{
- struct bgscan_data *data = __netconfig_wifi_bgscan_get_data();
- DBG("[%s] Wi-Fi background scan", pause ? "Pause" : "Resume");
- data->paused = pause;
-}
-
-gboolean netconfig_wifi_is_bgscan_paused(void)
-{
- struct bgscan_data *data = __netconfig_wifi_bgscan_get_data();
- DBG("Wi-Fi background scan is [%s]", data->paused ? "Paused" : "Runable");
- return data->paused;
-}
-
-void netconfig_wifi_bgscan_start(gboolean immediate_scan)
+void netconfig_wifi_bgscan_start(const char *interface_name, gboolean immediate_scan)
{
wifi_tech_state_e wifi_tech_state;
wifi_service_state_e wifi_service_state;
- struct bgscan_data *data =
- __netconfig_wifi_bgscan_get_data();
-
- if (data == NULL)
- return;
- if (data->timer_id > 0)
- __netconfig_wifi_bgscan_stop_timer(data);
+ if (netconfig_wifi_bgscan_get_timer_id(interface_name) > 0)
+ netconfig_wifi_bgscan_stop_timer(interface_name);
- wifi_tech_state = wifi_state_get_technology_state(FALSE);
- wifi_service_state = wifi_state_get_service_state();
- DBG("wifi tech state [%s] service state [%s]",
+ wifi_tech_state = wifi_state_get_technology_state(interface_name);
+ wifi_service_state = wifi_state_get_service_state(interface_name);
+ DBG("[%s] Wi-Fi tech state [%s] service state [%s]", interface_name,
_convert_wifi_technology_state_to_string(wifi_tech_state),
_convert_wifi_service_state_to_string(wifi_service_state));
if (wifi_tech_state < NETCONFIG_WIFI_TECH_POWERED)
return;
- if (data->mode == WIFI_BGSCAN_MODE_EXPONENTIAL &&
+ if (netconfig_wifi_bgscan_get_mode(interface_name) == WIFI_BGSCAN_MODE_EXPONENTIAL &&
wifi_service_state == NETCONFIG_WIFI_CONNECTED)
return;
- DBG("Wi-Fi background scan started or re-started(%d)", immediate_scan);
- __netconfig_wifi_bgscan_start_timer(immediate_scan);
-}
-
-void netconfig_wifi_bgscan_stop(void)
-{
- struct bgscan_data *data =
- __netconfig_wifi_bgscan_get_data();
-
- if (data == NULL)
- return;
+ DBG("[%s] Wi-Fi background scan started or re-started(%d)",
+ interface_name, immediate_scan);
- DBG("Wi-Fi background scan stop [mode:%d]", data->mode);
-
- data->time = 0;
-
- __netconfig_wifi_bgscan_stop_timer(data);
+ netconfig_wifi_bgscan_start_timer(interface_name, immediate_scan);
}
-gboolean netconfig_wifi_get_bgscan_state(void)
+void netconfig_wifi_bgscan_stop(const char *interface_name)
{
- struct bgscan_data *data =
- __netconfig_wifi_bgscan_get_data();
- return ((data->timer_id > (guint)0) ? TRUE : FALSE);
+ netconfig_wifi_bgscan_stop_timer(interface_name);
}
-guint netconfig_wifi_bgscan_get_mode(void)
-{
- struct bgscan_data *data = __netconfig_wifi_bgscan_get_data();
-
- return data->mode;
-}
-
-gboolean netconfig_wifi_bgscan_set_interval(guint interval)
-{
- gboolean ret = FALSE;
-
- ret = _set_scan_reset_interval(interval);
-
- return ret;
-}
-
-void netconfig_wifi_bgscan_get_interval(guint *interval)
-{
- *interval = _get_scan_reset_interval();
-}
-
-gboolean netconfig_wifi_get_scanning(void)
-{
- return netconfig_wifi_scanning;
-}
-
-void netconfig_wifi_set_scanning(gboolean scanning)
-{
- if (netconfig_wifi_scanning != scanning)
- netconfig_wifi_scanning = scanning;
-}
-
-gboolean handle_set_bgscan(Wifi *wifi, GDBusMethodInvocation *context, guint scan_mode)
+gboolean handle_set_bgscan(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, guint scan_mode)
{
gint old_mode = 0;
int pm_state = VCONFKEY_PM_STATE_NORMAL;
- old_mode = netconfig_wifi_bgscan_get_mode();
+ old_mode = netconfig_wifi_bgscan_get_mode(ifname);
if (old_mode == scan_mode) {
wifi_complete_set_bgscan(wifi, context);
return TRUE;
}
- if (__netconfig_wifi_bgscan_set_mode(scan_mode) != TRUE) {
+ if (netconfig_wifi_bgscan_set_mode(ifname, scan_mode) != TRUE) {
ERR("Invalid mode [%d]", scan_mode);
netconfig_error_invalid_parameter(context);
return TRUE;
}
- INFO("scan mode is changed [%d]", scan_mode);
+ INFO("[%s] Wi-Fi scan mode is changed [%d]", ifname, scan_mode);
/* In case of LCD off, we don't need Wi-Fi scan right now */
netconfig_vconf_get_int(VCONFKEY_PM_STATE, &pm_state);
if (pm_state >= VCONFKEY_PM_STATE_LCDOFF)
- netconfig_wifi_bgscan_start(FALSE);
+ netconfig_wifi_bgscan_start(ifname, FALSE);
else
- netconfig_wifi_bgscan_start(TRUE);
+ netconfig_wifi_bgscan_start(ifname, TRUE);
wifi_complete_set_bgscan(wifi, context);
return TRUE;
}
-gboolean handle_resume_bgscan(Wifi *wifi, GDBusMethodInvocation *context)
+gboolean handle_resume_bgscan(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname)
{
- netconfig_wifi_set_bgscan_pause(FALSE);
+ netconfig_wifi_bgscan_set_pause(ifname, FALSE);
wifi_complete_resume_bgscan(wifi, context);
return TRUE;
}
-gboolean handle_pause_bgscan(Wifi *wifi, GDBusMethodInvocation *context)
+gboolean handle_pause_bgscan(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname)
{
- netconfig_wifi_set_bgscan_pause(TRUE);
+ netconfig_wifi_bgscan_set_pause(ifname, TRUE);
wifi_complete_pause_bgscan(wifi, context);
return TRUE;
}
-gboolean handle_reset_bgscan_interval(Wifi *wifi, GDBusMethodInvocation *context)
+gboolean handle_reset_bgscan_interval(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname)
{
-
- _set_scan_reset_interval(SCAN_EXPONENTIAL_MIN);
+ netconfig_wifi_bgscan_set_interval(ifname, SCAN_EXPONENTIAL_MIN);
wifi_complete_reset_bgscan_interval(wifi, context);
return TRUE;
}
-gboolean handle_get_autoscan(Wifi *wifi, GDBusMethodInvocation *context)
+gboolean handle_get_autoscan(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname)
{
gboolean autoscan = 0;
- autoscan = netconfig_wifi_is_bgscan_paused();
+ autoscan = netconfig_wifi_bgscan_is_paused(ifname);
wifi_complete_get_autoscan(wifi, context, autoscan);
return TRUE;
}
-gboolean handle_get_autoscanmode(Wifi *wifi, GDBusMethodInvocation *context)
+gboolean handle_get_autoscanmode(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname)
{
guint autoscanmode = 0;
- autoscanmode = netconfig_wifi_bgscan_get_mode();
+ autoscanmode = netconfig_wifi_bgscan_get_mode(ifname);
wifi_complete_get_autoscanmode(wifi, context, autoscanmode);
return TRUE;
#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;
-};
+} 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);
+}
+
+static bssid_scan_data_s *__create_bssid_scan_data(const char *interface_name)
+{
+ 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 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;
-gboolean netconfig_wifi_is_bssid_scan_started(void)
+ 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)
{
- return netconfig_is_bssid_scan_started;
+ bssid_scan_data_s *scan_data;
+
+ scan_data = __get_bssid_scan_data(interface_name);
+ if (scan_data == NULL) {
+ scan_data = g_try_new0(bssid_scan_data_s, 1);
+ if (scan_data == NULL)
+ return;
+
+ scan_data->interface_name = g_strdup(interface_name);
+ }
+
+ scan_data->scan_info_list = g_slist_append(scan_data->scan_info_list, scan_info);
}
-static void __netconfig_wifi_bssid_notify_scan_done(void)
+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;
const char *prop_bssid = "bssid";
const char *prop_rssi = "rssi";
const char *prop_mode = "mode";
+ 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, };
}
}
- 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;
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);
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;
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:
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;
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");
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);
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;
}
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;
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;
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) {
return 0;
}
-
-static void __netconfig_set_bssid_scan_mode(gboolean enable)
-{
- if (netconfig_is_bssid_scan_started == enable)
- return;
-
- netconfig_is_bssid_scan_started = enable;
-}
-
-void netconfig_wifi_bssid_signal_scandone(void)
+void netconfig_wifi_bssid_signal_scandone(const char *interface_name)
{
- bssid_list_count = 0;
- _netconfig_wifi_bssid_get_bss();
-
- netconfig_is_device_scanning = FALSE;
+ _netconfig_wifi_bssid_get_bss(interface_name);
- __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)
+void netconfig_wifi_bssid_signal_scanaborted(const char *interface_name)
{
- bssid_list_count = 0;
- netconfig_is_bssid_scan_aborted = TRUE;
- _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);
}
static void __netconfig_wifi_bssid_scan_request_reply(GObject *source_object,
netconfig_gdbus_pending_call_unref();
}
-static int __netconfig_wifi_bssid_request_scan(char *if_path)
+static int __netconfig_wifi_bssid_request_scan(const char *interface_name, char *if_path)
{
GVariant *message = NULL;
GVariantBuilder *builder = NULL;
gboolean reply = FALSE;
if (if_path == NULL) {
- if_path = netconfig_wifi_get_supplicant_interface();
+ if_path = netconfig_wifi_get_supplicant_interface_path(interface_name);
is_free_required = TRUE;
}
SUPPLICANT_INTERFACE ".Interface",
"Scan",
message,
- (GAsyncReadyCallback) __netconfig_wifi_bssid_scan_request_reply);
+ (GAsyncReadyCallback) __netconfig_wifi_bssid_scan_request_reply,
+ NULL);
if (reply != TRUE) {
ERR("Fail to Scan");
goto out;
}
- netconfig_is_device_scanning = TRUE;
+ netconfig_wifi_bssidscan_set_scanning(interface_name, TRUE);
out:
if (is_free_required)
g_free(if_path);
/* 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;
}
gchar *path = NULL;
GDBusConnection *conn = NULL;
GError *error = NULL;
+ char *interface_name = user_data;
conn = G_DBUS_CONNECTION(source_object);
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)
{
GVariant *message = NULL;
GVariantBuilder *builder = NULL;
const char *key = "Ifname";
- const char *val = WIFI_IFNAME;
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);
SUPPLICANT_INTERFACE,
"CreateInterface",
message,
- (GAsyncReadyCallback) __netconfig_wifi_interface_create_result);
+ (GAsyncReadyCallback) __netconfig_wifi_interface_create_result,
+ g_strdup(interface_name));
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(FALSE);
+ 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;
}
#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 TRUE;
}
#endif
- tech_state = wifi_state_get_technology_state(FALSE);
+ tech_state = wifi_state_get_technology_state(ifname);
if (tech_state <= NETCONFIG_WIFI_TECH_OFF) {
#if !defined TIZEN_WEARABLE
enabled = 1;
}
}
- __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);
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;
}
#include "util.h"
#include "neterror.h"
#include "wifi-config.h"
+#include "wifi-state.h"
#include "netsupplicant.h"
#include "wifi-key-encryption.h"
#define WIFI_PREFIX_LENGTH MAC_ADDRESS_LENGTH + 6 /* wifi_485a3f2f506a_ */
#define PROFILE_PREFIX_LENGTH WIFI_PREFIX_LENGTH + 21 /* /net/connman/service/wifi_485a3f2f506a_ */
-#define WIFI_MAC_ADD_LENGTH 17
-#define WIFI_MAC_ADD_PATH "/sys/class/net/wlan0/address"
+#define WIFI_MAC_PATH_LENGTH 64
+#define WIFI_MAC_ADDR_LENGTH 17
+#define WIFI_MAC_ADDR_PATH "/sys/class/net/%s/address"
#define NET_DNS_ADDR_MAX 2
g_free(conf);
}
-static gboolean __get_mac_address(gchar **mac_address)
+static gboolean __get_mac_address(const gchar *interface_name, gchar **mac_address)
{
+ FILE *fp = NULL;
+ char buf[WIFI_MAC_ADDR_LENGTH + 1];
+ char path[WIFI_MAC_PATH_LENGTH];
gchar *tmp_mac = NULL;
gchar *tmp = NULL;
gchar mac[13] = { 0, };
gint i = 0, j = 0;
- if (TIZEN_TV) {
- FILE *fp = NULL;
- char buf[WIFI_MAC_ADD_LENGTH + 1];
- if (0 == access(WIFI_MAC_ADD_PATH, F_OK))
- fp = fopen(WIFI_MAC_ADD_PATH, "r");
+ snprintf(path, WIFI_MAC_PATH_LENGTH, WIFI_MAC_ADDR_PATH, interface_name);
- if (fp == NULL) {
- ERR("Failed to open file %s\n", WIFI_MAC_ADD_PATH);
- *mac_address = NULL;
- return FALSE;
- }
+ if (0 == access(path, F_OK))
+ fp = fopen(path, "r");
+ if (fp) {
if (fgets(buf, sizeof(buf), fp) == NULL) {
- ERR("Failed to get MAC info from %s\n", WIFI_MAC_ADD_PATH);
+ ERR("Failed to get MAC info from %s\n", path);
*mac_address = NULL;
fclose(fp);
return FALSE;
}
- tmp_mac = (gchar *)malloc(WIFI_MAC_ADD_LENGTH + 1);
+ tmp_mac = (gchar *)malloc(WIFI_MAC_ADDR_LENGTH + 1);
if (tmp_mac == NULL) {
ERR("malloc() failed");
*mac_address = NULL;
fclose(fp);
return FALSE;
}
- memset(tmp_mac, 0, WIFI_MAC_ADD_LENGTH + 1);
- g_strlcpy(tmp_mac, buf, WIFI_MAC_ADD_LENGTH + 1);
+ memset(tmp_mac, 0, WIFI_MAC_ADDR_LENGTH + 1);
+ g_strlcpy(tmp_mac, buf, WIFI_MAC_ADDR_LENGTH + 1);
fclose(fp);
} else {
+ ERR("Failed to open file %s\n", path);
+
tmp_mac = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
if (tmp_mac == NULL) {
ERR("vconf_get_str(WIFI_BSSID_ADDRESS) Failed");
return FALSE;
}
}
+
tmp = g_ascii_strdown(tmp_mac, (gssize)strlen(tmp_mac));
free(tmp_mac);
while (tmp && tmp[i]) {
return TRUE;
}
-gboolean wifi_config_get_group_name(const gchar *prefix, const gchar *config_id, gchar **group_name)
+gboolean wifi_config_get_group_name(const gchar *prefix,
+ const gchar *interface_name, const gchar *config_id, gchar **group_name)
{
gchar *mac_address = NULL;
gchar *g_name = NULL;
gboolean ret = FALSE;
- ret = __get_mac_address(&mac_address);
+ ret = __get_mac_address(interface_name, &mac_address);
if ((ret != TRUE) || (strlen(mac_address) == 0)) {
ERR("Cannot get WIFI MAC address");
g_free(mac_address);
return TRUE;
}
-static gboolean _load_configuration(const gchar *config_id, struct wifi_config *config)
+static gboolean _load_configuration(const gchar *interface_name,
+ const gchar *config_id, struct wifi_config *config)
{
GKeyFile *keyfile;
gchar *group_name;
gboolean hidden = FALSE;
gboolean ret = FALSE;
- ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
+ ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX,
+ interface_name, config_id, &group_name);
if (ret != TRUE) {
ERR("Fail to get_wifi_config_group_name");
return FALSE;
return TRUE;
}
-gboolean wifi_config_save_configuration(const gchar *config_id, GKeyFile *keyfile)
+gboolean wifi_config_save_configuration(const gchar *interface_name,
+ const gchar *config_id, GKeyFile *keyfile)
{
gchar *dir;
gchar *path;
gchar *group_name;
gboolean ret = FALSE;
- ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
+ ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX,
+ interface_name, config_id, &group_name);
if (ret != TRUE) {
ERR("Fail to get_wifi_config_group_name");
return FALSE;
return TRUE;
}
-static gboolean _remove_configuration(const gchar *config_id)
+static gboolean _remove_configuration(const gchar *interface_name, const gchar *config_id)
{
gboolean ret = FALSE;
gchar *dir;
gchar *group_name;
- ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
+ ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX,
+ interface_name, config_id, &group_name);
if (ret != TRUE) {
ERR("Fail to get_wifi_config_group_name");
return FALSE;
}
-static gboolean _set_field(const gchar *config_id, const gchar *key, const gchar *value)
+static gboolean _set_field(const gchar *interface_name,
+ const gchar *config_id, const gchar *key, const gchar *value)
{
gboolean ret = TRUE;
GKeyFile *keyfile;
gchar *group_name;
- ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
+ ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX,
+ interface_name, config_id, &group_name);
if (ret != TRUE) {
ERR("Fail to get_wifi_config_group_name");
return FALSE;
ret = FALSE;
}
- wifi_config_save_configuration(config_id, keyfile);
+ wifi_config_save_configuration(interface_name, config_id, keyfile);
g_key_file_free(keyfile);
g_free(group_name);
return ret;
}
-static gboolean _get_field(const gchar *config_id, const gchar *key, gchar **value)
+static gboolean _get_field(const gchar *interface_name,
+ const gchar *config_id, const gchar *key, gchar **value)
{
GKeyFile *keyfile;
gchar *group_name;
gboolean hidden = FALSE;
gboolean ret = FALSE;
- ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
+ ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX,
+ interface_name, config_id, &group_name);
if (ret != TRUE) {
ERR("Fail to get_wifi_config_group_name");
return FALSE;
return TRUE;
}
-static GSList *_get_list(void)
+static GSList *_get_list(const char *mac_addr)
{
GSList *list = NULL;
struct dirent *dp = NULL;
strncmp(dp->d_name, WIFI_CONFIG_PREFIX, strlen(WIFI_CONFIG_PREFIX)) != 0) {
continue;
}
- gchar *config_id = g_strdup(dp->d_name + WIFI_PREFIX_LENGTH);
- list = g_slist_append(list, g_strdup(config_id));
- g_free(config_id);
+
+ DBG("%s", dp->d_name);
+
+ if (netconfig_check_mac_address(dp->d_name, mac_addr)) {
+ gchar *config_id = g_strdup(dp->d_name + WIFI_PREFIX_LENGTH);
+ DBG("%s", config_id);
+ list = g_slist_append(list, g_strdup(config_id));
+ g_free(config_id);
+ }
}
closedir(dir);
return ret;
}
-gboolean wifi_config_remove_configuration(const gchar *config_id)
+gboolean wifi_config_remove_configuration(const gchar *interface_name,
+ const gchar *config_id)
{
gboolean ret = FALSE;
- ret = _remove_configuration(config_id);
+ ret = _remove_configuration(interface_name, config_id);
return ret;
}
return length;
}
-gboolean _add_vsie(int frame_id, const char* vsie)
+gboolean _add_vsie(const char *interface_name, int frame_id, const char* vsie)
{
GVariant *params = NULL;
GVariant *message = NULL;
params = g_variant_new("(iay)", frame_id, bytearray_builder);
g_variant_builder_unref(bytearray_builder);
- if_path = netconfig_wifi_get_supplicant_interface();
-
+ if_path = netconfig_wifi_get_supplicant_interface_path(interface_name);
if (if_path == NULL) {
ERR("Fail to get wpa_supplicant DBus path");
g_free(bytearray);
return TRUE;
}
-gboolean _get_vsie(int frame_id, char **vsie)
+gboolean _get_vsie(const char *interface_name, int frame_id, char **vsie)
{
GVariant *params = NULL;
GVariant *message = NULL;
return FALSE;
}
- if_path = netconfig_wifi_get_supplicant_interface();
+ if_path = netconfig_wifi_get_supplicant_interface_path(interface_name);
if (if_path == NULL) {
ERR("Fail to get wpa_supplicant DBus path");
return FALSE;
}
-gboolean _remove_vsie(int frame_id, const char *vsie)
+gboolean _remove_vsie(const char *interface_name, int frame_id, const char *vsie)
{
GVariant *params = NULL;
GVariant *message = NULL;
params = g_variant_new("(iay)", frame_id, bytearray_builder);
g_variant_builder_unref(bytearray_builder);
- if_path = netconfig_wifi_get_supplicant_interface();
+ if_path = netconfig_wifi_get_supplicant_interface_path(interface_name);
if (if_path == NULL) {
ERR("Fail to get wpa_supplicant DBus path");
g_free(bytearray);
}
/* dbus method */
-gboolean handle_get_config_ids(Wifi *wifi, GDBusMethodInvocation *context)
+gboolean handle_get_config_ids(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname)
{
guint i = 0;
GSList *config_ids = NULL;
guint length;
gchar **result = NULL;
+ const gchar *mac_addr = NULL;
g_return_val_if_fail(wifi != NULL, TRUE);
- config_ids = _get_list();
+ mac_addr = wifi_state_get_mac_address(ifname);
+ DBG("%s", mac_addr);
+ config_ids = _get_list(mac_addr);
if (config_ids == NULL) {
ERR("Fail to get config list");
netconfig_error_no_profile(context);
}
gboolean handle_load_configuration(Wifi *wifi, GDBusMethodInvocation *context,
- const gchar *config_id)
+ const gchar *ifname, const gchar *config_id)
{
gboolean ret = FALSE;
GVariantBuilder *b = NULL;
conf = g_new0(struct wifi_config, 1);
conf->ip_info = g_new0(wifi_ip_info_s, 1);
- ret = _load_configuration(config_id, conf);
+ ret = _load_configuration(ifname, config_id, conf);
if (ret != TRUE) {
g_free(conf->ip_info);
g_free(conf);
__free_wifi_configuration(conf);
+ INFO("Success to load configuration [%s:%s]", ifname, config_id);
+
wifi_complete_load_configuration(wifi, context, g_variant_builder_end(b));
g_variant_builder_unref(b);
return TRUE;
}
gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context,
- const gchar *config_id, GVariant *configuration)
+ const gchar *ifname, const gchar *config_id, GVariant *configuration)
{
gboolean ret = FALSE;
struct wifi_config *conf = NULL;
conf->favorite = TRUE;
conf->autoconnect = TRUE;
- ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
+ ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX,
+ ifname, config_id, &group_name);
if (ret != TRUE) {
__free_wifi_configuration(conf);
ERR("Fail to get_wifi_config_group_name");
i += 1;
}
- ret = wifi_config_save_configuration(config_id, keyfile);
+ ret = wifi_config_save_configuration(ifname, config_id, keyfile);
if (ret == TRUE) {
INFO("Success to save configuration [%s]", config_id);
wifi_complete_save_configuration(wifi, context);
}
gboolean handle_load_eap_configuration(Wifi *wifi, GDBusMethodInvocation *context,
- const gchar *config_id)
+ const gchar *ifname, const gchar *config_id)
{
gboolean ret = FALSE;
GVariantBuilder *b = NULL;
conf->eap_config = g_new0(struct wifi_eap_config, 1);
conf->ip_info = g_new0(wifi_ip_info_s, 1);
- ret = _load_configuration(config_id, conf);
+ ret = _load_configuration(ifname, config_id, conf);
if (ret != TRUE) {
g_free(conf->eap_config);
g_free(conf->ip_info);
}
gboolean handle_save_eap_configuration(Wifi *wifi, GDBusMethodInvocation *context,
- const gchar *config_id, GVariant *configuration)
+ const gchar *ifname, const gchar *config_id, GVariant *configuration)
{
gboolean ret = FALSE;
struct wifi_config *conf = NULL;
conf->favorite = TRUE;
conf->autoconnect = TRUE;
- ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
+ ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX,
+ ifname, config_id, &group_name);
if (ret != TRUE) {
__free_wifi_configuration(conf);
ERR("Fail to get_wifi_config_group_name");
g_key_file_set_string(keyfile, group_name,
WIFI_CONFIG_EAP_SUBJECT_MATCH, conf->eap_config->subject_match);
- ret = wifi_config_save_configuration(config_id, keyfile);
+ ret = wifi_config_save_configuration(ifname, config_id, keyfile);
if (ret == TRUE) {
INFO("Success to save eap configuration [%s]", config_id);
wifi_complete_save_eap_configuration(wifi, context);
return TRUE;
}
-gboolean handle_remove_configuration(Wifi *wifi, GDBusMethodInvocation *context, const gchar *config_id)
+gboolean handle_remove_configuration(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, const gchar *config_id)
{
gboolean ret = FALSE;
return TRUE;
}
- ret = _remove_configuration(config_id);
+ ret = _remove_configuration(ifname, config_id);
if (ret != TRUE) {
/* no configuration or error */
ERR("No [%s] configuration", config_id);
* Proxy.Servers=trst.com:8888; (O)
*/
gboolean handle_set_config_field(Wifi *wifi, GDBusMethodInvocation *context,
- const gchar *config_id, const gchar *key, const gchar *value)
+ const gchar *ifname, const gchar *config_id, const gchar *key, const gchar *value)
{
gboolean ret = FALSE;
gchar *keyfile_key = NULL;
DBG("Key[%s] Value[%s]", key, value);
if (g_strcmp0(key, WIFI_CONFIG_PROXYADDRESS) == 0) {
- ret = _set_field(config_id, WIFI_CONFIG_PROXY_METHOD, "manual");
+ ret = _set_field(ifname, config_id, WIFI_CONFIG_PROXY_METHOD, "manual");
if (!ret) {
ERR("Fail to [%s]set_wifi_config_field(%s/manual)", config_id, WIFI_CONFIG_PROXY_METHOD);
netconfig_error_invalid_parameter(context);
return TRUE;
}
- ret = _set_field(config_id, keyfile_key, (const gchar *)value);
+ ret = _set_field(ifname, config_id, keyfile_key, (const gchar *)value);
if (!ret) {
ERR("Fail to [%s]set_wifi_config_field(%s/%s)", config_id, key, value);
}
return TRUE;
}
-gboolean handle_get_config_passphrase(Wifi *wifi, GDBusMethodInvocation *context, const gchar *config_id)
+gboolean handle_get_config_passphrase(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, const gchar *config_id)
{
gboolean ret = FALSE;
gchar *passphrase = NULL;
return TRUE;
}
- ret = _get_field(config_id, WIFI_CONFIG_PASSPHRASE, &passphrase);
+ ret = _get_field(ifname, config_id, WIFI_CONFIG_PASSPHRASE, &passphrase);
if (!ret) {
ERR("Fail to [%s] _get_field(%s)", config_id, WIFI_CONFIG_PASSPHRASE);
netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "OperationFailed");
}
gboolean handle_add_vsie(Wifi *wifi, GDBusMethodInvocation *context,
- int frame_id, const gchar *vsie)
+ const gchar *ifname, int frame_id, const gchar *vsie)
{
DBG("Frame ID: [%d] VSIE: [%s]", frame_id, vsie);
gboolean ret = FALSE;
- ret = _add_vsie(frame_id, vsie);
+ ret = _add_vsie(ifname, frame_id, vsie);
if (!ret) {
DBG("Failed to add vsie: %s", vsie);
netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "OperationFailed");
}
gboolean handle_get_vsie(Wifi *wifi, GDBusMethodInvocation *context,
- int frame_id)
+ const gchar *ifname, int frame_id)
{
DBG("Frame ID: [%d]", frame_id);
gboolean ret = FALSE;
gchar *vsie = NULL;
- ret = _get_vsie(frame_id, &vsie);
+ ret = _get_vsie(ifname, frame_id, &vsie);
if (!ret) {
DBG("Failed to get vsie for frame:[%d]", frame_id);
netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "OperationFailed");
}
gboolean handle_remove_vsie(Wifi *wifi, GDBusMethodInvocation *context,
- int frame_id, const gchar *vsie)
+ const gchar *ifname, int frame_id, const gchar *vsie)
{
DBG("Frame ID: [%d] VSIE: [%s]", frame_id, vsie);
gboolean ret = FALSE;
- ret = _remove_vsie(frame_id, vsie);
+ ret = _remove_vsie(ifname, frame_id, vsie);
if (!ret) {
DBG("Failed to remove vsie: %s", vsie);
netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "OperationFailed");
if (if_path)
return if_path;
- if_path = netconfig_wifi_get_supplicant_interface();
+ if_path = netconfig_wifi_get_supplicant_interface_path(NULL);
return if_path;
}
return netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
CONNMAN_WIFI_TECHNOLOGY_PREFIX,
CONNMAN_TECHNOLOGY_INTERFACE, "Scan", NULL,
- __wifi_dpp_connman_scan_request_reply);
+ __wifi_dpp_connman_scan_request_reply, NULL);
}
DBG("[TizenMW-->WPAS]: Wi-Fi Flush BSS Request: ");
- if_path = netconfig_wifi_get_supplicant_interface();
+ if_path = netconfig_wifi_get_supplicant_interface_path(NULL);
if (if_path == NULL) {
ERR("Fail to get wpa_supplicant DBus path");
return FALSE;
}
-static gboolean __save_configuration_object(wifi_dpp_conf_obj *conf_obj)
+static gboolean __save_configuration_object(const char *interface_name,
+ wifi_dpp_conf_obj *conf_obj)
{
gchar ssid_hex[65] = {0,};
gchar *config_id = NULL;
netconfig_convert_bytes_to_hexstr(conf_obj->ssid, strlen(conf_obj->ssid), ssid_hex);
config_id = g_strdup_printf("%s_managed_%s", ssid_hex, conf_obj->akm);
- ret = wifi_config_get_group_name("wifi_", config_id, &group_name);
+ ret = wifi_config_get_group_name("wifi_", interface_name, config_id, &group_name);
if (!ret) {
ERR("Failed to get Wi-Fi config group name");
g_free(config_id);
g_key_file_set_boolean(keyfile, group_name, "Favorite", TRUE);
g_key_file_set_boolean(keyfile, group_name, "AutoConnect", TRUE);
- ret = wifi_config_save_configuration(config_id, keyfile);
+ ret = wifi_config_save_configuration(interface_name, config_id, keyfile);
if (ret == TRUE)
INFO("Success to save configuration [%s]", config_id);
else
}
-void netconfig_wifi_dpp_conf_obj_event(GVariant *message)
+void netconfig_wifi_dpp_conf_obj_event(const char *interface_name, GVariant *message)
{
GVariantIter *iter = NULL;
gchar *key = NULL;
g_variant_get(value, "&s", &conf_obj.net_access_key);
}
- if (!__save_configuration_object(&conf_obj) || !__netconfig_wifi_invoke_flush_bss()) {
+ if (!__save_configuration_object(interface_name, &conf_obj) || !__netconfig_wifi_invoke_flush_bss()) {
g_variant_iter_free(iter);
__netconfig_wifi_dpp_notify_dpp_failed(p_dpp_info);
return;
#include "wifi-state.h"
#include "wifi-config.h"
#include "wifi-eap-config.h"
+#include "network-state.h"
#include "neterror.h"
#define CONNMAN_CONFIG_FIELD_TYPE "Type"
return updated;
}
-static gboolean _delete_configuration(const gchar *profile)
+static gboolean _delete_configuration(const char *interface_name, const char *profile)
{
gboolean ret = FALSE;
gchar *config_id = NULL;
}
ERR("get config_id [%s] from [%s]", config_id, profile);
- ret = wifi_config_remove_configuration(config_id);
+ ret = wifi_config_remove_configuration(interface_name, config_id);
if (ret != TRUE)
ERR("Fail to wifi_config_remove_configuration [%s]", config_id);
char *ssid = NULL;
int ssid_len = 0;
int err = 0;
+ const char *interface_name = NULL;
if (NULL == profile) {
ERR("Invalid profile name");
return FALSE;
}
- if (_delete_configuration(profile) != TRUE)
+ interface_name = netconfig_get_ifname(profile);
+ if (interface_name == NULL) {
+ ERR("Invalid profile name");
+ return FALSE;
+ }
+
+ if (_delete_configuration(interface_name, profile) != TRUE)
ERR("Fail to delete configuration [%s]", profile);
wifi_ident = strstr(profile, "wifi_");
return TRUE;
}
-static void __netconfig_eap_state(
- wifi_service_state_e state, void *user_data);
-
-static wifi_state_notifier netconfig_eap_notifier = {
- .wifi_state_changed = __netconfig_eap_state,
- .user_data = NULL,
-};
-
-static void __netconfig_eap_state(
- wifi_service_state_e state, void *user_data)
+static void __netconfig_eap_state(wifi_state_notifier_s *notifier,
+ char *service, wifi_service_state_e state, void *user_data)
{
- const char *wifi_profile = (const char *)user_data;
+ if (notifier == NULL)
+ return;
- if (wifi_profile == NULL) {
- wifi_state_notifier_unregister(&netconfig_eap_notifier);
+ if (service == NULL) {
+ wifi_state_notifier_unregister(notifier);
+ g_free(notifier->service);
+ g_free(notifier->user_data);
+ g_free(notifier);
return;
}
return;
if (state == NETCONFIG_WIFI_FAILURE)
- __netconfig_delete_config(wifi_profile);
-
- g_free(netconfig_eap_notifier.user_data);
- netconfig_eap_notifier.user_data = NULL;
+ __netconfig_delete_config(service);
- wifi_state_notifier_unregister(&netconfig_eap_notifier);
+ wifi_state_notifier_unregister(notifier);
+ g_free(notifier->service);
+ g_free(notifier->user_data);
+ g_free(notifier->service);
}
gboolean handle_create_eap_config(Wifi *wifi, GDBusMethodInvocation *context,
{
gboolean updated = FALSE;
gboolean result = FALSE;
+ wifi_state_notifier_s *state_notifier = NULL;
+ const char *interface_name = NULL;
g_return_val_if_fail(wifi != NULL, TRUE);
DBG("Set agent fields for %s", service);
if (netconfig_is_wifi_profile(service) != TRUE) {
- netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_WRONG_PROFILE, "InvalidService");
+ netconfig_error_dbus_method_return(context,
+ NETCONFIG_ERROR_WRONG_PROFILE, "InvalidService");
+ return TRUE;
+ }
+
+ interface_name = netconfig_get_ifname(service);
+ if (interface_name == NULL) {
+ netconfig_error_dbus_method_return(context,
+ NETCONFIG_ERROR_WRONG_PROFILE, "InvalidService");
return TRUE;
}
passphrase = (const char *)value;
}
- netconfig_wifi_set_agent_field_for_eap_network(
- name, identity, passphrase);
+ netconfig_wifi_set_agent_field_for_eap_network(interface_name,
+ name, identity, passphrase);
g_variant_iter_free(iter);
}
result = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
service, CONNMAN_SERVICE_INTERFACE, "Connect",
- NULL, __netconfig_wifi_connect_reply);
-
- if (netconfig_eap_notifier.user_data != NULL) {
- g_free(netconfig_eap_notifier.user_data);
- netconfig_eap_notifier.user_data = NULL;
-
- wifi_state_notifier_unregister(&netconfig_eap_notifier);
+ NULL, __netconfig_wifi_connect_reply,
+ g_strdup(interface_name));
+
+ state_notifier = g_try_malloc0(sizeof(wifi_state_notifier_s));
+ if (state_notifier) {
+ state_notifier->notifier = state_notifier;
+ state_notifier->service = g_strdup(service);
+ state_notifier->wifi_state_changed = __netconfig_eap_state;
+ wifi_state_notifier_register(state_notifier);
}
-
- netconfig_eap_notifier.user_data = g_strdup(service);
- wifi_state_notifier_register(&netconfig_eap_notifier);
} else {
netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INVALID_PARAMETER, "InvalidArguments");
}
{
g_return_val_if_fail(wifi != NULL, TRUE);
- wifi_complete_delete_eap_config(wifi, context);
+ __netconfig_delete_config(profile);
- __netconfig_delete_config((const char *)profile);
+ wifi_complete_delete_eap_config(wifi, context);
return TRUE;
}
EXPORT_SYM void netconfig_wifi_power_on()
{
#if defined TIZEN_WEARABLE
- wifi_power_on_wearable(TRUE);
+ wifi_power_on_wearable(NULL, TRUE);
#else
- wifi_power_on();
+ wifi_power_on(NULL);
#endif
}
#include "wifi-extension.h"
-gboolean handle_flush_bss(Wifi *wifi, GDBusMethodInvocation *context)
+gboolean handle_flush_bss(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname)
{
DBG("Wi-Fi flush bss");
GDBusConnection *connection = NULL;
char *if_path = NULL;
- if_path = netconfig_wifi_get_supplicant_interface();
+ if_path = netconfig_wifi_get_supplicant_interface_path(ifname);
if (if_path == NULL) {
netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailFlushBss");
DBG("Fail to get wpa_supplicant DBus path");
#include "network-statistics.h"
#define WLAN_DRIVER_SCRIPT "/usr/bin/wlan.sh"
-#define WLAN_IFACE_NAME "wlan0"
-#define WLAN_P2P_IFACE_NAME_TV "p2p0"
-#define WLAN_P2P_IFACE_NAME_COMMON "wlan0"
-#define WLAN_P2P_IFACE_NAME ((TIZEN_TV) ? (WLAN_P2P_IFACE_NAME_TV) : (WLAN_P2P_IFACE_NAME_COMMON))
#define QUAD_CPUS_COUNT 4
#define TEMP_BUFFER_LEN 100
#define WIFI_MAC_ADD_PATH "/sys/class/net/wlan0/address"
-static int __netconfig_sta_firmware_start(void)
+static int __netconfig_sta_firmware_start(const char *interface_name)
{
int rv = 0;
const char *path = WLAN_DRIVER_SCRIPT;
- char *const args[] = { "/usr/bin/wlan.sh", "start", NULL };
+ char *const args[] = { "/usr/bin/wlan.sh", "start", (char *)interface_name, NULL };
char *const envs[] = { NULL };
rv = netconfig_execute_file(path, args, envs);
if (rv < 0)
return -EIO;
- rv = netconfig_interface_up(WLAN_IFACE_NAME);
+ rv = netconfig_interface_up(interface_name);
if (rv != TRUE)
return -EIO;
return 0;
}
-static int __netconfig_sta_firmware_stop(void)
+static int __netconfig_sta_firmware_stop(const char *interface_name)
{
int rv = 0;
const char *path = WLAN_DRIVER_SCRIPT;
- char *const args[] = { "/usr/bin/wlan.sh", "stop", NULL };
+ char *const args[] = { "/usr/bin/wlan.sh", "stop", (char *)interface_name, NULL };
char *const envs[] = { NULL };
/* Update statistics before driver remove */
netconfig_wifi_statistics_update_powered_off();
- rv = netconfig_interface_down(WLAN_IFACE_NAME);
+ rv = netconfig_interface_down(interface_name);
if (rv != TRUE)
return -EIO;
return 0;
}
-static int __netconfig_p2p_firmware_start(void)
+static int __netconfig_p2p_firmware_start(const char *interface_name)
{
if (!netconfig_check_feature_supported(NETCONFIG_SUPPORTED_FEATURE_WIFI_DIRECT))
return -ENODEV;
int rv = 0;
const char *path = WLAN_DRIVER_SCRIPT;
- char *const args[] = { "/usr/bin/wlan.sh", "p2p", NULL };
+ char *const args[] = { "/usr/bin/wlan.sh", "p2p", (char *)interface_name, NULL };
char *const envs[] = { NULL };
rv = netconfig_execute_file(path, args, envs);
return -EIO;
#if defined TIZEN_WLAN_USE_P2P_INTERFACE
- rv = netconfig_interface_up(WLAN_P2P_IFACE_NAME);
+ rv = netconfig_interface_up(interface_name);
if (rv != TRUE)
return -EIO;
#endif
return 0;
}
-static int __netconfig_p2p_firmware_stop(void)
+static int __netconfig_p2p_firmware_stop(const char *interface_name)
{
if (!netconfig_check_feature_supported(NETCONFIG_SUPPORTED_FEATURE_WIFI_DIRECT))
return -ENODEV;
int rv = 0;
const char *path = WLAN_DRIVER_SCRIPT;
- char *const args[] = { "/usr/bin/wlan.sh", "stop", NULL };
+ char *const args[] = { "/usr/bin/wlan.sh", "stop", (char *)interface_name, NULL };
char *const envs[] = { NULL };
- rv = netconfig_interface_down(WLAN_IFACE_NAME);
+ rv = netconfig_interface_down(interface_name);
if (rv != TRUE)
return -EIO;
return 0;
}
-static int __netconfig_softap_firmware_start(void)
+static int __netconfig_softap_firmware_start(const char *interface_name)
{
if (!netconfig_check_feature_supported(NETCONFIG_SUPPORTED_FEATURE_TETHERING)
&& !netconfig_check_feature_supported(NETCONFIG_SUPPORTED_FEATURE_WIFI_SOFTAP))
int rv = 0;
const char *path = WLAN_DRIVER_SCRIPT;
- char *const args[] = { "/usr/bin/wlan.sh", "softap", NULL };
+ char *const args[] = { "/usr/bin/wlan.sh", "softap", (char *)interface_name, NULL };
char *const envs[] = { NULL };
rv = netconfig_execute_file(path, args, envs);
if (rv < 0)
return -EIO;
- if (netconfig_interface_up(WLAN_IFACE_NAME) == FALSE)
+ if (netconfig_interface_up(interface_name) == FALSE)
return -EIO;
DBG("Successfully loaded softap device driver");
return 0;
}
-static int __netconfig_softap_firmware_stop(void)
+static int __netconfig_softap_firmware_stop(const char *interface_name)
{
if (!netconfig_check_feature_supported(NETCONFIG_SUPPORTED_FEATURE_TETHERING)
&& !netconfig_check_feature_supported(NETCONFIG_SUPPORTED_FEATURE_WIFI_SOFTAP))
int rv = 0;
const char *path = WLAN_DRIVER_SCRIPT;
- char *const args[] = { "/usr/bin/wlan.sh", "stop", NULL };
+ char *const args[] = { "/usr/bin/wlan.sh", "stop", (char *)interface_name, NULL };
char *const envs[] = { NULL };
- rv = netconfig_interface_down(WLAN_IFACE_NAME);
+ rv = netconfig_interface_down(interface_name);
if (rv != TRUE)
return -EIO;
return 0;
}
-static int __netconfig_wifi_firmware_start(enum netconfig_wifi_firmware type)
+static int __netconfig_wifi_firmware_start(enum netconfig_wifi_firmware type,
+ const char *interface_name)
{
if (emulator_is_emulated() == TRUE)
return -EIO;
switch (type) {
case NETCONFIG_WIFI_STA:
- return __netconfig_sta_firmware_start();
+ return __netconfig_sta_firmware_start(interface_name);
case NETCONFIG_WIFI_P2P:
- return __netconfig_p2p_firmware_start();
+ return __netconfig_p2p_firmware_start(interface_name);
case NETCONFIG_WIFI_SOFTAP:
- return __netconfig_softap_firmware_start();
+ return __netconfig_softap_firmware_start(interface_name);
default:
break;
}
return -ENXIO;
}
-static int __netconfig_wifi_firmware_stop(enum netconfig_wifi_firmware type)
+static int __netconfig_wifi_firmware_stop(enum netconfig_wifi_firmware type,
+ const char *interface_name)
{
if (emulator_is_emulated() == TRUE)
return -EIO;
switch (type) {
case NETCONFIG_WIFI_STA:
- return __netconfig_sta_firmware_stop();
+ return __netconfig_sta_firmware_stop(interface_name);
case NETCONFIG_WIFI_P2P:
- return __netconfig_p2p_firmware_stop();
+ return __netconfig_p2p_firmware_stop(interface_name);
case NETCONFIG_WIFI_SOFTAP:
- return __netconfig_softap_firmware_stop();
+ return __netconfig_softap_firmware_stop(interface_name);
default:
break;
}
return -ENXIO;
}
-static int __netconfig_set_rps_cpus(void)
+static int __netconfig_set_rps_cpus(const char *interface_name)
{
int fd, curr;
ssize_t count;
DBG("WiFi driver loaded... ");
}
- snprintf(t_buf, TEMP_BUFFER_LEN, "/sys/class/net/wlan0/queues/rx-0/rps_cpus");
+ snprintf(t_buf, TEMP_BUFFER_LEN,
+ "/sys/class/net/%s/queues/rx-0/rps_cpus",
+ interface_name);
DBG("Command : [%s]", t_buf);
curr = 0;
if (r_buf[0] == 'e') {
close(fd);
DBG("e is already written");
- snprintf(t_buf, TEMP_BUFFER_LEN, "/sys/class/net/wlan0/queues/rx-%d/rps_cpus", curr);
+ snprintf(t_buf, TEMP_BUFFER_LEN,
+ "/sys/class/net/%s/queues/rx-%d/rps_cpus",
+ interface_name, curr);
DBG("Command : [%s]", t_buf);
continue;
} else {
}
close(fd);
- snprintf(t_buf, TEMP_BUFFER_LEN, "/sys/class/net/wlan0/queues/rx-%d/rps_cpus", curr);
+ snprintf(t_buf, TEMP_BUFFER_LEN,
+ "/sys/class/net/%s/queues/rx-%d/rps_cpus",
+ interface_name, curr);
DBG("Command : [%s]", t_buf);
}
return 0;
}
-int netconfig_wifi_firmware(enum netconfig_wifi_firmware type, gboolean enable)
+int netconfig_wifi_firmware(enum netconfig_wifi_firmware type,
+ const char *interface_name, gboolean enable)
{
int err;
static enum netconfig_wifi_firmware current_driver = NETCONFIG_WIFI_OFF;
return -EALREADY;
} else if (current_driver == alias) {
- err = __netconfig_wifi_firmware_stop(type);
+ err = __netconfig_wifi_firmware_stop(type, interface_name);
if (err < 0 && err != -EALREADY)
return err;
return -EIO;
}
- err = __netconfig_wifi_firmware_start(type);
+ err = __netconfig_wifi_firmware_start(type, interface_name);
if (err < 0)
DBG("Failed to execute script file");
else
current_driver = alias;
- if (__netconfig_set_rps_cpus() < 0)
+ if (__netconfig_set_rps_cpus(interface_name) < 0)
DBG("Failed to set rps_cpus");
return err;
}
-gboolean handle_start(WifiFirmware *firmware, GDBusMethodInvocation *context, const gchar *device)
+gboolean handle_start(WifiFirmware *firmware, GDBusMethodInvocation *context,
+ const gchar *device, const gchar *ifname)
{
int err;
DBG("Wi-Fi firmware start %s", device != NULL ? device : "null");
if (g_strcmp0("p2p", device) == 0)
- err = netconfig_wifi_firmware(NETCONFIG_WIFI_P2P, TRUE);
+ err = netconfig_wifi_firmware(NETCONFIG_WIFI_P2P, ifname, TRUE);
else if (g_strcmp0("softap", device) == 0)
- err = netconfig_wifi_firmware(NETCONFIG_WIFI_SOFTAP, TRUE);
+ err = netconfig_wifi_firmware(NETCONFIG_WIFI_SOFTAP, ifname, TRUE);
else
err = -EINVAL;
if (err < 0) {
if (err == -EALREADY)
netconfig_error_already_exists(context);
- else if (g_strcmp0("softap", device) == 0 && err == -EIO && netconfig_is_wifi_direct_on() == FALSE) {
- if (netconfig_wifi_firmware(NETCONFIG_WIFI_P2P, FALSE) == 0 && netconfig_wifi_firmware(NETCONFIG_WIFI_SOFTAP, TRUE) == 0) {
+ else if (g_strcmp0("softap", device) == 0 &&
+ err == -EIO && netconfig_is_wifi_direct_on() == FALSE) {
+ if (netconfig_wifi_firmware(NETCONFIG_WIFI_P2P, ifname, FALSE) == 0 &&
+ netconfig_wifi_firmware(NETCONFIG_WIFI_SOFTAP, ifname, TRUE) == 0) {
wifi_firmware_complete_start(firmware, context);
return TRUE;
} else
return TRUE;
}
-gboolean handle_stop(WifiFirmware *firmware, GDBusMethodInvocation *context, const gchar *device)
+gboolean handle_stop(WifiFirmware *firmware, GDBusMethodInvocation *context,
+ const gchar *device, const gchar *ifname)
{
int err;
DBG("Wi-Fi firmware stop %s", device != NULL ? device : "null");
if (g_strcmp0("p2p", device) == 0)
- err = netconfig_wifi_firmware(NETCONFIG_WIFI_P2P, FALSE);
+ err = netconfig_wifi_firmware(NETCONFIG_WIFI_P2P, ifname, FALSE);
else if (g_strcmp0("softap", device) == 0)
- err = netconfig_wifi_firmware(NETCONFIG_WIFI_SOFTAP, FALSE);
+ err = netconfig_wifi_firmware(NETCONFIG_WIFI_SOFTAP, ifname, FALSE);
else
err = -EINVAL;
#endif
#define NETCONFIG_PROCWIRELESS "/proc/net/wireless"
+typedef struct {
+ char *interface_name;
+ int last_snr_level;
+} rssi_data_s;
+
static int netconfig_wifi_rssi = VCONFKEY_WIFI_SNR_MIN;
static guint32 netconfig_wifi_freq = 0;
static guint netconfig_wifi_indicator_timer = 0;
+static GSList *g_rssi_list = NULL;
+
+static rssi_data_s *__create_rssi_data(const char *interface_name)
+{
+ rssi_data_s *rssi_data = g_try_malloc0(sizeof(rssi_data_s));
+ if (!rssi_data) {
+ ERR("Memory allocation failed");
+ return NULL;
+ }
+
+ rssi_data->interface_name = g_strdup(interface_name);
+
+ g_rssi_list = g_slist_append(g_rssi_list, rssi_data);
+
+ return rssi_data;
+}
+
+static rssi_data_s *__get_rssi_data(const char *interface_name)
+{
+ GSList *list;
+ rssi_data_s *rssi_data = NULL;
+
+ for (list = g_rssi_list; list; list = list->next) {
+ rssi_data = list->data;
+ if (g_strcmp0(rssi_data->interface_name, interface_name) == 0)
+ return rssi_data;
+ }
+
+ return rssi_data;
+}
+
+static void __destroy_rssi_data(const char *interface_name)
+{
+ rssi_data_s *rssi_data = __get_rssi_data(interface_name);
+
+ if (!rssi_data)
+ return;
+
+ g_rssi_list = g_slist_remove(g_rssi_list, rssi_data);
+ g_free(rssi_data->interface_name);
+ g_free(rssi_data);
+}
int netconfig_wifi_get_rssi(void)
{
return netconfig_wifi_freq;
}
-static int __netconfig_wifi_update_and_get_rssi(void)
+static int __netconfig_wifi_update_and_get_rssi(const char *interface_name)
{
char *if_path = NULL;
GVariant *message = NULL;
gint32 key_value;
int rssi_dbm = VCONFKEY_WIFI_SNR_MIN;
- if_path = netconfig_wifi_get_supplicant_interface();
+ if_path = netconfig_wifi_get_supplicant_interface_path(interface_name);
if (if_path == NULL) {
ERR("Fail to get wpa_supplicant DBus path");
return 0;
if (g_strcmp0(key, "rssi") == 0) {
key_value = g_variant_get_int32(variant);
rssi_dbm = (int)key_value;
- DBG("Currently signal dbm value [%d]", rssi_dbm);
+ /* DBG("Currently signal dbm value [%d]", rssi_dbm); */
} else if (g_strcmp0(key, "frequency") == 0) {
netconfig_wifi_freq = g_variant_get_uint32(variant);
- DBG("Currently frequency [%u]", netconfig_wifi_freq);
+ /* DBG("Currently frequency [%u]", netconfig_wifi_freq); */
}
}
return snr_level;
}
-static void __netconfig_wifi_set_rssi_level(const int snr_level)
+static void __netconfig_wifi_set_rssi_level(const char *interface_name,
+ const int snr_level)
{
- static int last_snr_level = 0;
+ rssi_data_s *rssi_data = NULL;
+ const char *default_ifname = NULL;
+
+ rssi_data = __get_rssi_data(interface_name);
+ if (rssi_data == NULL)
+ return;
+
+ if (snr_level != rssi_data->last_snr_level) {
+ wifi_emit_rssi_changed((Wifi *)get_wifi_object(), interface_name, snr_level);
+
+ default_ifname = netconfig_get_default_ifname();
+ if (g_strcmp0(default_ifname, interface_name) == 0)
+ netconfig_set_vconf_int(VCONFKEY_WIFI_STRENGTH, snr_level);
- if (snr_level != last_snr_level) {
- netconfig_set_vconf_int(VCONFKEY_WIFI_STRENGTH, snr_level);
netconfig_battery_update_wifi_rssi(snr_level);
- last_snr_level = snr_level;
+
+ rssi_data->last_snr_level = snr_level;
}
}
"org.tizen.system.deviced.PmQos",
"WifiThroughput",
params,
+ NULL,
NULL);
if (reply != TRUE)
return;
"org.tizen.system.deviced.PmQos",
"WifiThroughput",
params,
+ NULL,
NULL);
if (reply != TRUE)
return;
int rssi_dbm = 0;
int snr_level = 0;
int pm_state = VCONFKEY_PM_STATE_NORMAL;
+ char *interface_name = data;
- if (wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED)
+ if (wifi_state_get_service_state(interface_name) != NETCONFIG_WIFI_CONNECTED) {
+ g_free(interface_name);
return FALSE;
+ }
/* In case of LCD off, we don't need to update Wi-Fi indicator */
netconfig_vconf_get_int(VCONFKEY_PM_STATE, &pm_state);
if (pm_state >= VCONFKEY_PM_STATE_LCDOFF)
return TRUE;
- rssi_dbm = __netconfig_wifi_update_and_get_rssi();
- /* INFO("%d dbm", rssi_dbm); */
+ rssi_dbm = __netconfig_wifi_update_and_get_rssi(interface_name);
snr_level = netconfig_wifi_rssi_level(rssi_dbm);
- __netconfig_wifi_set_rssi_level(snr_level);
+ __netconfig_wifi_set_rssi_level(interface_name, snr_level);
__netconfig_wifi_update_indicator();
return TRUE;
}
-void netconfig_wifi_indicator_start(void)
+void netconfig_wifi_indicator_start(const char *interface_name)
{
+ const char *default_ifname = NULL;
+
INFO("Start Wi-Fi indicator");
- netconfig_set_vconf_int(VCONFKEY_WIFI_STRENGTH, VCONFKEY_WIFI_STRENGTH_MAX);
- __wifi_indicator_monitor(&netconfig_wifi_indicator_timer);
+ __create_rssi_data(interface_name);
+
+ wifi_emit_rssi_changed((Wifi *)get_wifi_object(),
+ interface_name, VCONFKEY_WIFI_STRENGTH_MAX);
+
+ default_ifname = netconfig_get_default_ifname();
+ if (g_strcmp0(default_ifname, interface_name) == 0)
+ netconfig_set_vconf_int(VCONFKEY_WIFI_STRENGTH, VCONFKEY_WIFI_STRENGTH_MAX);
+
+ netconfig_start_timer_seconds(WIFI_INDICATOR_INTERVAL,
+ __wifi_indicator_monitor, g_strdup(interface_name),
+ &netconfig_wifi_indicator_timer);
+
netconfig_battery_update_wifi_rssi(VCONFKEY_WIFI_STRENGTH_MAX);
- netconfig_start_timer_seconds(WIFI_INDICATOR_INTERVAL, __wifi_indicator_monitor, NULL, &netconfig_wifi_indicator_timer);
}
-void netconfig_wifi_indicator_stop(void)
+void netconfig_wifi_indicator_stop(const char *interface_name)
{
INFO("Stop Wi-Fi indicator");
netconfig_wifi_rssi = VCONFKEY_WIFI_SNR_MIN;
netconfig_wifi_freq = 0;
+
+ __destroy_rssi_data(interface_name);
}
return 0;
}
-void __netconfig_notify_netlink_scan_done(void)
+void __netconfig_notify_netlink_scan_done(const char *interface_name)
{
GVariantBuilder *builder = NULL;
GVariantBuilder *builder1 = NULL;
}
}
- wifi_emit_netlink_scan_completed((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
+ wifi_emit_netlink_scan_completed((Wifi *)get_wifi_object(),
+ interface_name, g_variant_builder_end(builder));
g_variant_builder_unref(builder);
if (bss_info_list != NULL)
return ret;
}
-static int __netconfig_initialize_nl80211(netconfig_nl_global *global)
+static int __netconfig_initialize_nl80211(netconfig_nl_global *global,
+ const char *interface_name)
{
int err = 0;
- global->if_index = __netconfig_get_interface_index(WIFI_IFNAME);
+ global->if_index = __netconfig_get_interface_index(interface_name);
if (global->if_index < 0) {
DBG("Failed to get interface index");
return -1;
return 0;
}
-int handle_netlink_scan(Wifi *wifi, GDBusMethodInvocation *context, GVariant *params)
+int handle_netlink_scan(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname, GVariant *params)
{
DBG("");
netconfig_nl_global global = {
};
/** Initialize netlink socket */
- int ret = __netconfig_initialize_nl80211(&global);
+ int ret = __netconfig_initialize_nl80211(&global, ifname);
if (ret < 0) {
DBG("__netconfig_initialize_nl80211() failed, error %d", ret);
netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "AccessDenied");
}
wifi_complete_netlink_scan(wifi, context);
- __netconfig_notify_netlink_scan_done();
+ __netconfig_notify_netlink_scan_done(ifname);
__netconfig_deinitialize_nl80211(&global);
return TRUE;
#include "wifi-passpoint.h"
#if defined TIZEN_WLAN_PASSPOINT
-static gboolean netconfig_wifi_get_passpoint(gint32 *enabled)
+static gboolean netconfig_wifi_get_passpoint(const char *interface_name, gint32 *enabled)
{
GVariant *reply, *var = NULL;
gboolean value;
gboolean result = FALSE;
- reply = netconfig_supplicant_invoke_dbus_interface_property_get(SUPPLICANT_IFACE_INTERFACE,
- "Passpoint");
+ reply = netconfig_supplicant_invoke_dbus_interface_property_get(interface_name, "Passpoint");
if (reply == NULL) {
ERR("Error!!! Failed to get passpoint property");
return FALSE;
return result;
}
-static gboolean netconfig_wifi_set_passpoint(gint32 enable)
+static gboolean netconfig_wifi_set_passpoint(const char *interface_name, gint32 enable)
{
gint32 value = enable ? 1 : 0;
gboolean result = FALSE;
- result = netconfig_supplicant_invoke_dbus_interface_property_set(
- SUPPLICANT_IFACE_INTERFACE, "Passpoint",
- g_variant_new_int32(value), NULL);
+ result = netconfig_supplicant_invoke_dbus_interface_property_set(interface_name,
+ "Passpoint", g_variant_new_int32(value), NULL);
if (result == FALSE)
ERR("Fail to set passpoint enable[%d]", enable);
}
#endif
-gboolean handle_get_passpoint(Wifi *wifi, GDBusMethodInvocation *context)
+gboolean handle_get_passpoint(Wifi *wifi, GDBusMethodInvocation *context,
+ const char *ifname)
{
gint32 enable = 0;
g_return_val_if_fail(wifi != NULL, TRUE);
#if defined TIZEN_WLAN_PASSPOINT
- netconfig_wifi_get_passpoint(&enable);;
+ netconfig_wifi_get_passpoint(ifname, &enable);;
#else
enable = 0;
#endif
return TRUE;
}
-gboolean handle_set_passpoint(Wifi *wifi, GDBusMethodInvocation *context, gint enable)
+gboolean handle_set_passpoint(Wifi *wifi, GDBusMethodInvocation *context,
+ const char *ifname, gint enable)
{
g_return_val_if_fail(wifi != NULL, TRUE);
#if defined TIZEN_WLAN_PASSPOINT
- netconfig_wifi_set_passpoint(enable);
+ netconfig_wifi_set_passpoint(ifname, enable);
#endif
wifi_complete_set_passpoint(wifi, context);
return TRUE;
#include "log.h"
#include "util.h"
+#include "setting.h"
#include "netdbus.h"
#include "neterror.h"
#include "wifi-wps.h"
+#include "wifi-scan.h"
#include "wifi-bssid-scan.h"
#include "wifi-power.h"
#include "wifi-state.h"
#include "wifi-firmware.h"
#include "wifi-background-scan.h"
-
#define WLAN_SUPPLICANT_SCRIPT "/usr/bin/wpa_supp.sh"
#define P2P_SUPPLICANT_SCRIPT "/usr/bin/p2p_supp.sh"
#define VCONFKEY_SETAPPL_NETWORK_PERMIT_WITH_LCD_OFF_LIMIT "db/setting/network_with_lcd_off_limit"
#endif
-#define WLAN_MAC_ADDRESS_FILEPATH "/sys/class/net/wlan0/address"
-#define WLAN_MAC_ADDR_MAX 20
-#define VCONF_WIFI_BSSID_ADDRESS "db/wifi/bssid_address"
-
+#define WLAN_MAC_ADDR_MAX 20
#define ETH_MAC_ADDR_SIZE 6
#define VCONF_ETH_MAC_ADDRESS "db/dnet/mac_address"
#define NET_EXEC_PATH "/sbin/ifconfig"
#define MAX_DRV_CMD_SIZE 248
#define WLAN_IOCTL_SUSPEND (SIOCDEVPRIVATE + 1)
-static gboolean connman_wifi_technology_state = FALSE;
-static gboolean wifi_firmware_recovery_mode = FALSE;
-static int airplane_mode = 0;
-
typedef struct {
char *buf;
int used_len;
int total_len;
} netconfig_wifi_priv_cmd;
+static gboolean wifi_firmware_recovery_mode = FALSE;
+static int airplane_mode = 0;
+
static gboolean __is_wifi_restricted(void)
{
#if defined TIZEN_WEARABLE
GVariant *reply;
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);
if (error != NULL) {
if (g_strstr_len(error->message, strlen(error->message),
CONNMAN_ERROR_INTERFACE ".AlreadyEnabled") != NULL) {
- wifi_state_update_power_state(TRUE);
+ wifi_state_update_power_state(interface_name, TRUE);
} else if (g_strstr_len(error->message, strlen(error->message),
CONNMAN_ERROR_INTERFACE ".AlreadyDisabled") != NULL) {
- wifi_state_update_power_state(FALSE);
+ wifi_state_update_power_state(interface_name, FALSE);
} else {
ERR("Fail to request status [%d: %s]", error->code, error->message);
- wifi_state_update_power_state(FALSE);
+ wifi_state_update_power_state(interface_name, FALSE);
}
g_error_free(error);
} else {
ERR("Fail to request status");
- wifi_state_update_power_state(FALSE);
+ wifi_state_update_power_state(interface_name, FALSE);
}
} else {
DBG("Successfully requested");
}
netconfig_gdbus_pending_call_unref();
+ g_free(interface_name);
}
int __execute_supplicant(gboolean enable)
return 0;
}
-void netconfig_wifi_recover_firmware(void)
-{
- wifi_firmware_recovery_mode = TRUE;
-
- netconfig_wifi_bgscan_stop();
-
- wifi_power_off();
-}
-
-static int _load_driver_and_supplicant(void)
+static int _load_driver_and_supplicant(const char *interface_name)
{
int err = 0;
wifi_tech_state_e tech_state;
- tech_state = wifi_state_get_technology_state(FALSE);
+ tech_state = wifi_state_get_technology_state(interface_name);
if (tech_state > NETCONFIG_WIFI_TECH_OFF)
return -EALREADY;
if (err < 0 && err != -EALREADY)
return err;
- err = netconfig_wifi_firmware(NETCONFIG_WIFI_STA, TRUE);
+ err = netconfig_wifi_firmware(NETCONFIG_WIFI_STA, interface_name, TRUE);
if (err < 0 && err != -EALREADY) {
__execute_supplicant(FALSE);
return err;
}
- wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_WPS_ONLY);
+ wifi_state_set_technology_state(interface_name, NETCONFIG_WIFI_TECH_WPS_ONLY);
return 0;
}
-static int _remove_driver_and_supplicant(void)
+static int _remove_driver_and_supplicant(const char *interface_name)
{
int err = 0;
DBG("remove driver and supplicant");
if (wifi_firmware_recovery_mode != TRUE &&
- netconfig_wifi_is_bssid_scan_started() == TRUE) {
+ netconfig_wifi_bssidscan_get_mode(interface_name) == TRUE) {
DBG("Wi-Fi WPS mode");
return 0;
}
- err = netconfig_wifi_firmware(NETCONFIG_WIFI_STA, FALSE);
+ err = netconfig_wifi_firmware(NETCONFIG_WIFI_STA, interface_name, FALSE);
if (err < 0 && err != -EALREADY)
return err;
if (err < 0 && err != -EALREADY)
return err;
- wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_OFF);
+ wifi_state_set_technology_state(interface_name, NETCONFIG_WIFI_TECH_OFF);
// reset service state
- wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
+ wifi_state_set_service_state(interface_name, NETCONFIG_WIFI_IDLE);
if (wifi_firmware_recovery_mode == TRUE) {
- if (wifi_power_on() < 0)
+ if (wifi_power_on(interface_name) < 0)
ERR("Failed to recover Wi-Fi firmware");
wifi_firmware_recovery_mode = FALSE;
static gboolean __check_and_set_technology_enable(gpointer data)
{
static int retry_count = NETCONFIG_TECH_WAITING_COUNT;
+ wifi_tech_state_e tech_state = NETCONFIG_WIFI_TECH_UNKNOWN;
gboolean value_enable = TRUE;
gboolean reply = FALSE;
GVariant *params = NULL;
- char key[] = "Powered";
+ char *interface_name = data;
- if (wifi_state_is_technology_available() == FALSE) {
+ tech_state = wifi_state_get_technology_state(interface_name);
+ if (tech_state == NETCONFIG_WIFI_TECH_UNKNOWN) {
retry_count--;
if (retry_count > 0)
return TRUE;
}
- params = g_variant_new("(sv)", key, g_variant_new_boolean(value_enable));
+ params = g_variant_new("(sb)", interface_name, value_enable);
reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
CONNMAN_WIFI_TECHNOLOGY_PREFIX,
CONNMAN_TECHNOLOGY_INTERFACE,
- "SetProperty", params, __technology_reply);
+ "SetDevicePower", params,
+ __technology_reply,
+ g_strdup(interface_name));
if (reply != TRUE) {
ERR("Fail to set technology enable");
- wifi_state_update_power_state(FALSE);
+ wifi_state_update_power_state(interface_name, FALSE);
retry_count = NETCONFIG_TECH_WAITING_COUNT;
+ g_free(interface_name);
return FALSE;
}
retry_count = NETCONFIG_TECH_WAITING_COUNT;
+ g_free(interface_name);
return FALSE;
}
-static int _set_connman_technology_power(gboolean enable)
+static int _set_connman_technology_power(const char *interface_name, gboolean enable)
{
gboolean reply = FALSE;
GVariant *params = NULL;
- char key[] = "Powered";
gboolean value_enable = TRUE;
gboolean value_disable = FALSE;
+ gboolean powered = FALSE;
+ wifi_tech_state_e tech_state = NETCONFIG_WIFI_TECH_UNKNOWN;
- if (connman_wifi_technology_state == enable)
+ DBG("Set %s technology [%s]", interface_name, enable == TRUE ? "enable" : "disable");
+
+ powered = wifi_state_get_powered(interface_name);
+ if (powered == enable) {
+ DBG("Already %s", enable ? "enabled" : "disabled");
return -EALREADY;
+ }
- if (enable && wifi_state_is_technology_available() == FALSE) {
- netconfig_start_timer(NETCONFIG_TECH_WAITING_INTERVAL,
- __check_and_set_technology_enable, NULL, NULL);
- connman_wifi_technology_state = enable;
- return 0;
+ if (enable == TRUE) {
+ tech_state = wifi_state_get_technology_state(interface_name);
+ if (tech_state == NETCONFIG_WIFI_TECH_UNKNOWN) {
+ netconfig_start_timer(NETCONFIG_TECH_WAITING_INTERVAL,
+ __check_and_set_technology_enable, g_strdup(interface_name), NULL);
+ wifi_state_set_powered(interface_name, enable);
+ return 0;
+ }
}
- params = g_variant_new("(sv)", key, (enable == TRUE) ?
- g_variant_new_boolean(value_enable) : g_variant_new_boolean(value_disable));
+ params = g_variant_new("(sb)", interface_name, (enable == TRUE) ? value_enable : value_disable);
reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
- CONNMAN_WIFI_TECHNOLOGY_PREFIX, CONNMAN_TECHNOLOGY_INTERFACE,
- "SetProperty", params, __technology_reply);
+ CONNMAN_WIFI_TECHNOLOGY_PREFIX, CONNMAN_TECHNOLOGY_INTERFACE,
+ "SetDevicePower", params, __technology_reply, g_strdup(interface_name));
if (reply != TRUE) {
ERR("Fail to set technology %s", enable == TRUE ? "enable" : "disable");
return -ESRCH;
}
- /* If Wi-Fi powered off,
- * Do not remove Wi-Fi driver until ConnMan technology state updated
- */
- if (enable == TRUE)
- connman_wifi_technology_state = enable;
-
/* To be keep safe, early disable Wi-Fi tech state */
if (enable != TRUE)
- wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_WPS_ONLY);
+ wifi_state_set_technology_state(interface_name, NETCONFIG_WIFI_TECH_WPS_ONLY);
return 0;
}
-static void __netconfig_set_wifi_bssid(void)
-{
- int rv = 0;
- char bssid[WLAN_MAC_ADDR_MAX];
-
- FILE *fp = fopen(WLAN_MAC_ADDRESS_FILEPATH, "r");
-
- if (fp == NULL) {
- ERR("Fail to open %s", WLAN_MAC_ADDRESS_FILEPATH);
- return;
- }
-
- rv = fseek(fp, 0L, SEEK_SET);
- if (rv != 0) {
- ERR("Fail to seek file");
- fclose(fp);
- return;
- }
-
- rv = fscanf(fp, "%17s", bssid);
- if (rv < 0) {
- ERR("Fail to read bssid");
- fclose(fp);
- return;
- }
-
- netconfig_set_vconf_str(VCONF_WIFI_BSSID_ADDRESS, bssid);
-
- fclose(fp);
-}
-
-void netconfig_wifi_disable_technology_state_by_only_connman_signal(void)
-{
- /* Important: it's only done by ConnMan technology signal update */
- connman_wifi_technology_state = FALSE;
-}
-
-#if defined TIZEN_WEARABLE
-int netconfig_wifi_on_wearable(gboolean device_picker_test)
-{
- int err = 0;
- int ps_mode;
-
- if (netconfig_vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &ps_mode) < 0) {
- ERR("Fail to get VCONFKEY_SETAPPL_PSMODE");
- return -EIO;
- }
-
- if (ps_mode > SETTING_PSMODE_NORMAL) {
- WARN("ps mode is on(%d), Not turn on Wi-Fi", ps_mode);
- return -EPERM;
- }
-
- err = wifi_power_driver_and_supplicant(TRUE);
- if (err < 0 && err != -EALREADY)
- return err;
-
- err = _set_connman_technology_power(TRUE);
-
- if (device_picker_test == TRUE)
- netconfig_wifi_enable_device_picker_test();
-
- return err;
-}
-#else
+#if !defined TIZEN_WEARABLE
static void __netconfig_wifi_restrict_mode(keynode_t *node, void *user_data)
{
int wifi_state = 0, restricted = 0;
- int wifi_off_by_restricted = 0;
-
- netconfig_vconf_get_int(VCONF_WIFI_OFF_STATE_BY_RESTRICTED, &wifi_off_by_restricted);
+ GSList *list = NULL;
netconfig_vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
netconfig_vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, &restricted);
DBG("network restricted mode %s", restricted > 0 ? "ON" : "OFF");
- DBG("Wi-Fi state %d, Wi-Fi was off by restricted mode %s", wifi_state,
- wifi_off_by_restricted ? "Yes" : "No");
+ DBG("wifi state: %d (0 off / 1 on / 2 connected)", wifi_state);
if (restricted > 0) {
/* network restricted on */
+ GSList *device_list = NULL;
+
if (wifi_state == VCONFKEY_WIFI_OFF)
return;
- wifi_power_off();
+ device_list = wifi_state_get_device_list();
+ for (list = device_list; list; list = list->next) {
+ wifi_device_data_s *device_data = list->data;
+ wifi_power_off(device_data->interface_name);
+ netconfig_setting_update_interface_off_for_restricted(device_data->interface_name, TRUE);
+ }
netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_RESTRICTED, 1);
} else {
/* network restricted off */
- if (!wifi_off_by_restricted)
- return;
+ GSList *ifname_list = NULL;
netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_RESTRICTED, 0);
- if (wifi_state > VCONFKEY_WIFI_OFF)
- return;
+ ifname_list = netconfig_setting_get_interfaces_off_by_restricted();
+ for (list = ifname_list; list; list = list->next) {
+ char *interface_name = list->data;
- wifi_power_on();
+ if (wifi_state_get_technology_state(interface_name) > NETCONFIG_WIFI_TECH_OFF)
+ continue;
+
+ netconfig_setting_update_interface_off_for_restricted(interface_name, FALSE);
+ wifi_power_on(interface_name);
+ }
}
}
#endif
static void __netconfig_wifi_airplane_mode(keynode_t *node, void *user_data)
{
int wifi_state = 0, airplane_state = 0;
- int wifi_off_by_airplane = 0;
+ GSList *list = NULL;
- netconfig_vconf_get_int(VCONF_WIFI_OFF_STATE_BY_AIRPLANE, &wifi_off_by_airplane);
netconfig_vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
if (node != NULL)
netconfig_vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &airplane_state);
DBG("airplane mode %s (prev:%d)", airplane_state > 0 ? "ON" : "OFF", airplane_mode);
- DBG("Wi-Fi state(or use) %d, Wi-Fi was off by flight mode %s", wifi_state,
- wifi_off_by_airplane ? "Yes" : "No");
+ DBG("wifi state: %d (0 off / 1 on / 2 connected)", wifi_state);
if (airplane_mode == airplane_state)
- return ;
+ return;
airplane_mode = airplane_state;
if (airplane_state > 0) {
/* airplane mode on */
+ GSList *device_list = NULL;
+
if (wifi_state == VCONFKEY_WIFI_OFF)
return;
- wifi_power_off();
+ device_list = wifi_state_get_device_list();
+ for (list = device_list; list; list = list->next) {
+ wifi_device_data_s *device_data = list->data;
+ if (device_data->tech_state > NETCONFIG_WIFI_TECH_OFF) {
+ wifi_power_off(device_data->interface_name);
+ netconfig_setting_update_interface_off_for_airplane(device_data->interface_name, TRUE);
+ }
+ }
netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_AIRPLANE, 1);
} else {
/* airplane mode off */
- if (!wifi_off_by_airplane)
- return;
+ GSList *ifname_list = NULL;
netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_AIRPLANE, 0);
- if (wifi_state > VCONFKEY_WIFI_OFF)
- return;
- wifi_power_on();
+ ifname_list = netconfig_setting_get_interfaces_off_by_airplane();
+ for (list = ifname_list; list; list = list->next) {
+ char *interface_name = list->data;
+
+ if (wifi_state_get_technology_state(interface_name) > NETCONFIG_WIFI_TECH_OFF)
+ continue;
+
+ netconfig_setting_update_interface_off_for_airplane(interface_name, FALSE);
+ wifi_power_on(interface_name);
+ }
}
}
static void __emergency_mode_changed_cb(keynode_t *node, void *user_data)
{
int wifi_state = 0, emergency = 0;
- int wifi_off_by_emergency = 0;
+ GSList *list = NULL;
#if !defined TIZEN_WEARABLE
int emergency_by_fmm = 0;
#endif
- netconfig_vconf_get_int(VCONF_WIFI_OFF_STATE_BY_EMERGENCY, &wifi_off_by_emergency);
+
netconfig_vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
#if !defined TIZEN_WEARABLE
netconfig_vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &emergency);
DBG("emergency mode %s", emergency > SETTING_PSMODE_POWERFUL ? "ON" : "OFF");
- DBG("Wi-Fi state %d, Wi-Fi was off by emergency mode %s", wifi_state, wifi_off_by_emergency ? "Yes" : "No");
+ DBG("wifi state: %d (0 off / 1 on / 2 connected)", wifi_state);
#if defined TIZEN_WEARABLE
if (emergency == SETTING_PSMODE_WEARABLE) {
/* basic power saving mode on */
} else if (emergency == SETTING_PSMODE_WEARABLE_ENHANCED) {
/* enhanced power saving mode on */
+ GSList *device_list = NULL;
+
if (wifi_state == VCONFKEY_WIFI_OFF)
return;
- wifi_power_off();
+ device_list = wifi_state_get_device_list();
+ for (list = device_list; list; list = list->next) {
+ wifi_device_data_s *device_data = list->data;
+ wifi_power_off(device_data->interface_name);
+ netconfig_setting_update_interface_off_for_emergency(device_data->interface_name, TRUE);
+ }
+
netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_EMERGENCY, 1);
} else {
/* power saving mode off */
- if (!wifi_off_by_emergency)
- return;
+ GSList *ifname_list = NULL;
netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_EMERGENCY, 0);
- if (wifi_state > VCONFKEY_WIFI_OFF)
- return;
+ ifname_list = netconfig_setting_get_interfaces_off_by_emergency();
+ for (list = ifname_list; list; list = list->next) {
+ char *interface_name = list->data;
+
+ if (wifi_state_get_technology_state(interface_name) > NETCONFIG_WIFI_TECH_OFF)
+ continue;
- wifi_power_on_wearable(TRUE);
+ netconfig_setting_update_interface_off_for_emergency(interface_name, FALSE);
+ wifi_power_on_wearable(interface_name, TRUE);
+ }
}
#else
if (emergency > SETTING_PSMODE_POWERFUL) {
/* emergency mode on */
+ GSList *device_list = NULL;
+
if (wifi_state == VCONFKEY_WIFI_OFF)
return;
- wifi_power_off();
+ device_list = wifi_state_get_device_list();
+ for (list = device_list; list; list = list->next) {
+ wifi_device_data_s *device_data = list->data;
+ wifi_power_off(device_data->interface_name);
+ netconfig_setting_update_interface_off_for_emergency(device_data->interface_name, TRUE);
+ }
netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_EMERGENCY, 1);
} else {
/* emergency mode off */
- if (!wifi_off_by_emergency)
- return;
+ GSList *ifname_list = NULL;
netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_EMERGENCY, 0);
- if (wifi_state > VCONFKEY_WIFI_OFF)
- return;
+ ifname_list = netconfig_setting_get_interfaces_off_by_emergency();
+ for (list = ifname_list; list; list = list->next) {
+ char *interface_name = list->data;
+
+ if (wifi_state_get_technology_state(interface_name) > NETCONFIG_WIFI_TECH_OFF)
+ continue;
- wifi_power_on();
+ netconfig_setting_update_interface_off_for_emergency(interface_name, FALSE);
+ wifi_power_on(interface_name);
+ }
}
#endif
}
-void wifi_set_early_suspend(gboolean value)
+void wifi_set_early_suspend(const char *interface_name, gboolean value)
{
static gboolean old_state = FALSE;
struct ifreq ifr;
if (netconfig_vconf_get_int(VCONFKEY_PM_STATE, &pm_state) < 0)
ERR("Fail to get VCONFKEY_PM_STATE");
- wifi_state = wifi_state_get_service_state();
+ wifi_state = wifi_state_get_service_state(interface_name);
if (value == TRUE &&
(pm_state < VCONFKEY_PM_STATE_LCDOFF ||
snprintf(buf, sizeof(buf), "SETSUSPENDMODE %d", value);
memset(&ifr, 0, sizeof(struct ifreq));
- g_strlcpy((char *)ifr.ifr_name, WIFI_IFNAME, IFNAMSIZ);
+ g_strlcpy((char *)ifr.ifr_name, interface_name, IFNAMSIZ);
DBG("Early suspend command: [%s]", buf);
int new_state = -1;
int wifi_state = 0;
static int prev_state = VCONFKEY_PM_STATE_NORMAL;
+ GSList *list = NULL, *device_list = NULL;
if (netconfig_vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state) < 0) {
ERR("Fail to get VCONFKEY_WIFI_STATE");
if ((new_state == VCONFKEY_PM_STATE_NORMAL) && (prev_state >= VCONFKEY_PM_STATE_LCDOFF)) {
/* Send early suspend mode based on LCD state and disallow early suspend count */
- if (wifi_state != VCONFKEY_WIFI_OFF) {
- wifi_set_early_suspend(FALSE);
- DBG("Unset early suspend");
+ device_list = wifi_state_get_device_list();
+ for (list = device_list; list; list = list->next) {
+ wifi_device_data_s *device_data = list->data;
+ if (device_data->powered == TRUE) {
+ wifi_set_early_suspend(device_data->interface_name, FALSE);
+ DBG("Unset early suspend [%s]", device_data->interface_name);
+ }
+ netconfig_wifi_bgscan_stop(device_data->interface_name);
+ netconfig_wifi_bgscan_set_interval(device_data->interface_name, SCAN_EXPONENTIAL_MIN);
+ netconfig_wifi_bgscan_start(device_data->interface_name, TRUE);
}
-
- netconfig_wifi_bgscan_stop();
- netconfig_wifi_bgscan_set_interval(SCAN_EXPONENTIAL_MIN);
- netconfig_wifi_bgscan_start(TRUE);
} else if ((new_state == VCONFKEY_PM_STATE_LCDOFF) && (prev_state < VCONFKEY_PM_STATE_LCDOFF) && (wifi_state != VCONFKEY_WIFI_OFF)) {
- wifi_set_early_suspend(TRUE);
- DBG("Set early suspend");
+ device_list = wifi_state_get_device_list();
+ for (list = device_list; list; list = list->next) {
+ wifi_device_data_s *device_data = list->data;
+ wifi_set_early_suspend(device_data->interface_name, TRUE);
+ DBG("Set early suspend [%s]", device_data->interface_name);
+ }
}
prev_state = new_state;
}
-static void __doze_level_changed_cb(keynode_t* node, void* user_data)
-{
- int doze_level = -1;
-
- if (node != NULL)
- doze_level = vconf_keynode_get_int(node);
- else
- netconfig_vconf_get_int(VCONFKEY_SYSMAN_DOZE_MODE_LEVEL, &doze_level);
-
- if (doze_level < 0) {
- DBG("Invalid Doze Level: %d", doze_level);
- return;
- }
-
- DBG("Doze Level: %d", doze_level);
-
- if (doze_level >= 1) {
- netconfig_wifi_block_bgscan(1);
- DBG("Block BG scan!");
- } else {
- netconfig_wifi_block_bgscan(0);
- DBG("Unblock BG scan!");
- }
-}
-
-static void __netconfig_telephony_ready_changed_cb(keynode_t * node, void *data)
+static void __netconfig_telephony_ready_changed_cb(keynode_t *node, void *data)
{
int telephony_ready = 0;
+ char *interface_name = data;
if (node != NULL)
telephony_ready = vconf_keynode_get_bool(node);
DBG("Turn Wi-Fi on automatically");
#if defined TIZEN_WEARABLE
- wifi_power_on_wearable(TRUE);
+ wifi_power_on_wearable(interface_name, TRUE);
#else
- wifi_power_on();
+ wifi_power_on(interface_name);
#endif
done:
vconf_ignore_key_changed(VCONFKEY_TELEPHONY_READY, __netconfig_telephony_ready_changed_cb);
+ g_free(interface_name);
}
-int wifi_power_driver_and_supplicant(gboolean enable)
+int wifi_power_driver_and_supplicant(const char *interface_name, gboolean enable)
{
/* There are 3 thumb rules for Wi-Fi power management
* 1. Do not make exposed API to control wpa_supplicant and driver directly.
* 3. Final the best rule: make it as simple as possible.
* Simple code enables easy maintenance and reduces logical errors.
*/
+
if (enable == TRUE) {
- return _load_driver_and_supplicant();
+ return _load_driver_and_supplicant(interface_name);
} else {
- if (connman_wifi_technology_state == TRUE)
+ if (wifi_state_get_powered(interface_name) == TRUE)
return -ENOSYS;
- return _remove_driver_and_supplicant();
+ return _remove_driver_and_supplicant(interface_name);
}
}
-void wifi_power_disable_technology_state_by_only_connman_signal(void)
-{
- /* Important: it's only done by ConnMan technology signal update */
- connman_wifi_technology_state = FALSE;
-}
-
-void wifi_power_recover_firmware(void)
+void wifi_power_recover_firmware(const char *interface_name)
{
wifi_firmware_recovery_mode = TRUE;
- netconfig_wifi_bgscan_stop();
+ netconfig_wifi_bgscan_stop(interface_name);
- wifi_power_off();
+ wifi_power_off(interface_name);
}
-int wifi_power_on(void)
+int wifi_power_on(const char *interface_name)
{
int err = 0;
wifi_tech_state_e tech_state;
- tech_state = wifi_state_get_technology_state(TRUE);
+ tech_state = wifi_state_get_technology_state(interface_name);
if (tech_state >= NETCONFIG_WIFI_TECH_POWERED) {
- /* There can be a scenario where wifi is automatically *
- * activated by connman if wifi was powered in last boot. *
- * So we should update connman_wifi_technology_state variable *
- * if it is found that wifi_tech_state variable is *
- * NETCONFIG_WIFI_TECH_POWERED and connman_wifi_technology_state *
- * variable is FALSE. Earlier connman_wifi_technology_state *
- * variable was only updated when wifi was Powered on from *
- * net-config resulting in variable not getting updated. *
- * This caused wifi to not get deactivated after reboot if *
- * last power state was activated */
- ERR("Net-Config WiFi connman technology state %d",
- connman_wifi_technology_state);
- if (connman_wifi_technology_state == FALSE)
- connman_wifi_technology_state = TRUE;
+ INFO("Net-Config WiFi connman technology state %d", tech_state);
return -EALREADY;
}
return -EBUSY;
}
- err = wifi_power_driver_and_supplicant(TRUE);
+ err = wifi_power_driver_and_supplicant(interface_name, TRUE);
if (err < 0 && err != -EALREADY)
return err;
- err = _set_connman_technology_power(TRUE);
+ err = _set_connman_technology_power(interface_name, TRUE);
return err;
}
-int wifi_power_off(void)
+int wifi_power_off(const char *interface_name)
{
int err;
- err = _set_connman_technology_power(FALSE);
+ err = _set_connman_technology_power(interface_name, FALSE);
if (err == -EALREADY)
- wifi_state_update_power_state(FALSE);
+ wifi_state_update_power_state(interface_name, FALSE);
- return 0;
+ return err;
}
#if defined TIZEN_WEARABLE
-int wifi_power_on_wearable(gboolean device_picker_test)
+int wifi_power_on_wearable(const char *interface_name, gboolean device_picker_test)
{
int err = 0;
wifi_tech_state_e tech_state;
- tech_state = wifi_state_get_technology_state(TRUE);
+ tech_state = wifi_state_get_technology_state(interface_name);
if (tech_state >= NETCONFIG_WIFI_TECH_POWERED)
return -EALREADY;
- err = wifi_power_driver_and_supplicant(TRUE);
+ err = wifi_power_driver_and_supplicant(interface_name, TRUE);
if (err < 0 && err != -EALREADY)
return err;
- err = _set_connman_technology_power(TRUE);
+ err = _set_connman_technology_power(interface_name, TRUE);
if (device_picker_test == TRUE)
netconfig_wifi_enable_device_picker_test();
void wifi_power_initialize(void)
{
- int wifi_last_power_state = 0;
+ GSList *interface_list = NULL;
/* Initialize Airplane mode */
netconfig_vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &airplane_mode);
DBG("Airplane[%s]", airplane_mode > 0 ? "ON" : "OFF");
/* Update the last Wi-Fi power state */
- netconfig_vconf_get_int(VCONF_WIFI_LAST_POWER_STATE, &wifi_last_power_state);
- if (wifi_last_power_state > VCONFKEY_WIFI_OFF) {
+ interface_list = netconfig_setting_get_interfaces_for_last_powered();
+ for (; interface_list; interface_list = interface_list->next) {
+ const char *interface_name = interface_list->data;
+
if (TIZEN_TELEPHONY_ENABLE) {
int telephony_ready = 0;
netconfig_vconf_get_bool(VCONFKEY_TELEPHONY_READY, &telephony_ready);
if (telephony_ready == 0) {
DBG("Telephony API is not initialized yet");
vconf_notify_key_changed(VCONFKEY_TELEPHONY_READY,
- __netconfig_telephony_ready_changed_cb, NULL);
+ __netconfig_telephony_ready_changed_cb,
+ g_strdup(interface_name));
} else {
if (netconfig_tapi_check_sim_state() == FALSE)
DBG("SIM is not initialized yet");
}
DBG("Turn Wi-Fi on automatically");
#if defined TIZEN_WEARABLE
- wifi_power_on_wearable(TRUE);
+ wifi_power_on_wearable(interface_name, TRUE);
#else
- wifi_power_on();
+ wifi_power_on(interface_name);
#endif
}
__netconfig_wifi_airplane_mode, NULL);
#endif
- vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE, __emergency_mode_changed_cb, NULL);
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE,
+ __emergency_mode_changed_cb, NULL);
vconf_notify_key_changed(VCONFKEY_PM_STATE, __pm_state_changed_cb, NULL);
- vconf_notify_key_changed(VCONFKEY_SYSMAN_DOZE_MODE_LEVEL, __doze_level_changed_cb, NULL);
- __doze_level_changed_cb(NULL, NULL);
}
void wifi_power_deinitialize(void)
{
- vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE, __emergency_mode_changed_cb);
- vconf_ignore_key_changed(VCONFKEY_PM_STATE, __pm_state_changed_cb);
- vconf_ignore_key_changed(VCONFKEY_SYSMAN_DOZE_MODE_LEVEL, __doze_level_changed_cb);
}
gboolean handle_load_driver(Wifi *wifi,
- GDBusMethodInvocation *context, gboolean device_picker_test)
+ GDBusMethodInvocation *context,
+ const gchar *ifname, gboolean device_picker_test)
{
int err;
- DBG("Wi-Fi power on requested");
+ DBG("Wi-Fi power on requested [%s]", ifname);
g_return_val_if_fail(wifi != NULL, TRUE);
wifi_firmware_download();
#if defined TIZEN_WEARABLE
- err = wifi_power_on_wearable(device_picker_test);
+ err = wifi_power_on_wearable(ifname, device_picker_test);
#else
- err = wifi_power_on();
+ err = wifi_power_on(ifname);
if (device_picker_test == TRUE)
netconfig_wifi_enable_device_picker_test();
netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_AIRPLANE, 0);
- __netconfig_set_wifi_bssid();
wifi_complete_load_driver(wifi, context);
return TRUE;
}
-gboolean handle_remove_driver(Wifi *wifi, GDBusMethodInvocation *context)
+gboolean handle_remove_driver(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname)
{
int err;
- DBG("Wi-Fi power off requested");
+ DBG("Wi-Fi power off requested [%s]", ifname);
g_return_val_if_fail(wifi != NULL, TRUE);
- err = wifi_power_off();
+ err = wifi_power_off(ifname);
if (err < 0) {
if (err == -EINPROGRESS)
netconfig_error_inprogress(context);
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2020 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 <glib.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include "log.h"
+#include "util.h"
+#include "netdbus.h"
+#include "wifi-state.h"
+#include "wifi-scan.h"
+
+typedef struct {
+ const char *interface_name;
+
+ /* background scan */
+ guint bg_interval;
+ guint bg_mode;
+ guint bg_timer_id;
+ gboolean bg_paused;
+
+ /* bssid scan*/
+ gboolean bssid_enabled;
+ gboolean bssid_aborted;
+ gboolean bssid_scanning;
+
+ /* scan */
+ gboolean scanning;
+} scan_data_s;
+
+static GSList *g_scan_list = NULL;
+
+static scan_data_s *__wifi_scan_create_data(const char *interface_name)
+{
+ scan_data_s *scan_data = g_try_malloc0(sizeof(scan_data_s));
+ if (!scan_data) {
+ ERR("Memory allocation failed");
+ return NULL;
+ }
+
+ scan_data->interface_name = g_strdup(interface_name);
+
+ scan_data->scanning = FALSE;
+
+ scan_data->bg_interval = SCAN_EXPONENTIAL_MIN;
+ scan_data->bg_mode = WIFI_BGSCAN_MODE_EXPONENTIAL;
+ scan_data->bg_timer_id = 0;
+ scan_data->bg_paused = FALSE;
+
+ scan_data->bssid_enabled = FALSE;
+ scan_data->bssid_aborted = FALSE;
+ scan_data->bssid_scanning = FALSE;
+
+ g_scan_list = g_slist_append(g_scan_list, scan_data);
+
+ return scan_data;
+}
+
+static scan_data_s *__wifi_scan_get_data(const char *interface_name)
+{
+ GSList *list;
+ scan_data_s *scan_data;
+
+ for (list = g_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 = __wifi_scan_create_data(interface_name);
+ return scan_data;
+}
+
+void netconfig_wifi_scan_set_scanning(const char *interface_name, gboolean scanning)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+
+ if (!scan_data)
+ return;
+
+ scan_data->scanning = scanning;
+}
+
+guint netconfig_wifi_scan_get_scanning(const char *interface_name)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+
+ if (!scan_data)
+ return FALSE;
+
+ return scan_data->scanning;;
+}
+
+gboolean netconfig_wifi_bgscan_set_mode(const char *interface_name, guint mode)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+
+ if (!scan_data)
+ return FALSE;
+
+ if (mode != WIFI_BGSCAN_MODE_EXPONENTIAL && mode != WIFI_BGSCAN_MODE_PERIODIC) {
+ ERR("Invalid scan mode [%d]", mode);
+ return FALSE;
+ }
+
+ scan_data->bg_mode = mode;
+
+ return TRUE;
+}
+
+guint netconfig_wifi_bgscan_get_mode(const char *interface_name)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+
+ if (!scan_data)
+ return 0;
+
+ return scan_data->bg_mode;
+}
+
+void netconfig_wifi_bgscan_set_timer_id(const char *interface_name, guint timer_id)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+
+ if (!scan_data)
+ return;
+
+ scan_data->bg_timer_id = timer_id;
+}
+
+guint netconfig_wifi_bgscan_get_timer_id(const char *interface_name)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+
+ if (!scan_data)
+ return 0;
+
+ return scan_data->bg_timer_id;
+}
+
+gboolean netconfig_wifi_bgscan_set_interval(const char *interface_name, guint interval)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+
+ if (!scan_data)
+ return FALSE;
+
+ if ((interval < SCAN_EXPONENTIAL_MIN) || (interval > SCAN_EXPONENTIAL_MAX)) {
+ ERR("Invalid interval [%d]", interval);
+ return FALSE;
+ }
+
+ scan_data->bg_interval = interval;
+
+ return TRUE;
+}
+
+guint netconfig_wifi_bgscan_get_interval(const char *interface_name)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+
+ if (!scan_data)
+ return SCAN_EXPONENTIAL_MIN;
+
+ return scan_data->bg_interval;
+}
+
+void netconfig_wifi_bgscan_set_pause(const char *interface_name, gboolean pause)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+ if (!scan_data)
+ return;
+
+ scan_data->bg_paused = pause;
+
+ DBG("[%s] Wi-Fi background scan [%s]", interface_name,
+ pause ? "Pause" : "Resume");
+}
+
+gboolean netconfig_wifi_bgscan_is_paused(const char *interface_name)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+ if (!scan_data)
+ return FALSE;
+
+ DBG("[%s] Wi-Fi background scan is [%s]", interface_name,
+ scan_data->bg_paused ? "Paused" : "Runnable");
+
+ return scan_data->bg_paused;
+}
+
+static void __wifi_scan_request_reply(GObject *source_object,
+ GAsyncResult *res, gpointer user_data)
+{
+ GVariant *reply;
+ 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);
+
+ if (reply == NULL) {
+ if (error != NULL) {
+ ERR("Fail to request status [%d: %s]", error->code, error->message);
+ netconfig_wifi_scan_set_scanning(interface_name, FALSE);
+ g_error_free(error);
+ } else {
+ ERR("Fail to request scan");
+ netconfig_wifi_scan_set_scanning(interface_name, FALSE);
+ }
+ } else {
+ DBG("Successfully requested");
+ g_variant_unref(reply);
+ }
+
+ netconfig_gdbus_pending_call_unref();
+ g_free(interface_name);
+}
+
+static gboolean __wifi_scan_request_connman_scan(const char *interface_name)
+{
+ GVariant *params = NULL;
+ gboolean reply = FALSE;
+
+ netconfig_wifi_scan_set_scanning(interface_name, TRUE);
+
+ params = g_variant_new("(s)", interface_name);
+
+ reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
+ CONNMAN_WIFI_TECHNOLOGY_PREFIX,
+ CONNMAN_TECHNOLOGY_INTERFACE, "ScanDevice", params,
+ __wifi_scan_request_reply, g_strdup(interface_name));
+ if (reply != TRUE) {
+ ERR("Failed to send Scan request to connman");
+ netconfig_wifi_scan_set_scanning(interface_name, FALSE);
+ }
+
+ return reply;
+}
+
+static gboolean __wifi_bgscan_immediate_scan(gpointer data)
+{
+ static int retries = 0;
+ scan_data_s *scan_data = data;
+ guint state = 0;
+
+ if (!scan_data)
+ return FALSE;
+
+ state = wifi_state_get_service_state(scan_data->interface_name);
+
+#if !defined TIZEN_WEARABLE
+ if (netconfig_wifi_bgscan_is_paused(scan_data->interface_name)) {
+ return FALSE;
+ }
+#endif
+
+ if (state == NETCONFIG_WIFI_CONNECTED) {
+ if (netconfig_wifi_bgscan_get_mode(scan_data->interface_name) == WIFI_BGSCAN_MODE_EXPONENTIAL) {
+ DBG("[%s] Wi-Fi state is connected, scan is paused", scan_data->interface_name);
+ return FALSE;
+ }
+ } else if (state == NETCONFIG_WIFI_ASSOCIATION || state == NETCONFIG_WIFI_CONFIGURATION) {
+ /* During WIFI connecting, WIFI can be disappeared.
+ * After 1 sec, try scan even if connecting state */
+ if (retries < 2) {
+ retries++;
+ return TRUE;
+ }
+ }
+
+ if (__wifi_scan_request_connman_scan(scan_data->interface_name) == TRUE) {
+ retries = 0;
+ return FALSE;
+ } else if (retries > 2) {
+ retries = 0;
+ return FALSE;
+ }
+
+ retries++;
+
+ return TRUE;
+}
+
+static gboolean __wifi_bgscan_next_scan(gpointer data)
+{
+ int pm_state = VCONFKEY_PM_STATE_NORMAL;
+ scan_data_s *scan_data = data;
+
+ if (!scan_data)
+ return FALSE;
+
+ /* In case of LCD off, we don't need Wi-Fi scan */
+ netconfig_vconf_get_int(VCONFKEY_PM_STATE, &pm_state);
+ if (pm_state >= VCONFKEY_PM_STATE_LCDOFF)
+ return TRUE;
+
+ netconfig_wifi_bgscan_start_timer(scan_data->interface_name, TRUE);
+
+ return FALSE;
+}
+
+void netconfig_wifi_bgscan_start_timer(const char *interface_name, gboolean immediate_scan)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+
+ if (!scan_data)
+ return;
+
+ netconfig_stop_timer(&(scan_data->bg_timer_id));
+
+ switch (scan_data->bg_mode) {
+ case WIFI_BGSCAN_MODE_EXPONENTIAL:
+ if (scan_data->bg_interval < SCAN_EXPONENTIAL_MIN ||
+ scan_data->bg_interval == SCAN_PERIODIC_DELAY)
+ scan_data->bg_interval = SCAN_EXPONENTIAL_MIN;
+ break;
+ case WIFI_BGSCAN_MODE_PERIODIC:
+ scan_data->bg_interval = SCAN_PERIODIC_DELAY;
+ break;
+ default:
+ DBG("Invalid Wi-Fi background scan mode[%d]", scan_data->bg_mode);
+ return;
+ }
+
+ if (immediate_scan)
+ DBG("[%s] Scan immediately[%d], mode[%d](0 exponential / 1 periodic)",
+ interface_name, immediate_scan, scan_data->bg_mode);
+ else
+ DBG("[%s] Scan immediately[%d], mode[%d](0 exponential / 1 periodic), next[%d]",
+ interface_name, immediate_scan, scan_data->bg_mode, scan_data->bg_interval);
+
+ if (immediate_scan)
+ g_timeout_add(500, __wifi_bgscan_immediate_scan, scan_data);
+
+ netconfig_start_timer_seconds(scan_data->bg_interval,
+ __wifi_bgscan_next_scan, scan_data, &(scan_data->bg_timer_id));
+
+ if (scan_data->bg_mode == WIFI_BGSCAN_MODE_EXPONENTIAL && immediate_scan) {
+ scan_data->bg_interval = scan_data->bg_interval * 2;
+ if (scan_data->bg_interval > SCAN_EXPONENTIAL_MAX)
+ scan_data->bg_interval = SCAN_EXPONENTIAL_MAX;
+ }
+}
+
+void netconfig_wifi_bgscan_stop_timer(const char *interface_name)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+
+ if (scan_data)
+ return;
+
+ netconfig_stop_timer(&(scan_data->bg_timer_id));
+}
+
+void netconfig_wifi_bssidscan_set_mode(const char *interface_name, gboolean enable)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+ if (!scan_data)
+ return;
+
+ scan_data->bssid_enabled = enable;
+}
+
+gboolean netconfig_wifi_bssidscan_get_mode(const char *interface_name)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+ if (!scan_data)
+ return FALSE;
+
+ return scan_data->bssid_enabled;
+}
+
+void netconfig_wifi_bssidscan_set_aborted(const char *interface_name, gboolean abort)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+ if (!scan_data)
+ return;
+
+ scan_data->bssid_aborted = abort;
+}
+
+gboolean netconfig_wifi_bssidscan_get_aborted(const char *interface_name)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+ if (!scan_data)
+ return FALSE;
+
+ return scan_data->bssid_aborted;
+}
+
+void netconfig_wifi_bssidscan_set_scanning(const char *interface_name, gboolean scanning)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+
+ if (!scan_data)
+ return;
+
+ scan_data->bssid_scanning = scanning;
+}
+
+guint netconfig_wifi_bssidscan_get_scanning(const char *interface_name)
+{
+ scan_data_s *scan_data = __wifi_scan_get_data(interface_name);
+
+ if (!scan_data)
+ return FALSE;
+
+ return scan_data->bssid_scanning;;
+}
#include "log.h"
#include "util.h"
#include "netdbus.h"
+#include "setting.h"
#include "wifi-state.h"
#include "wifi-power.h"
+#include "wifi-scan.h"
#include "netsupplicant.h"
#include "network-state.h"
#include "wifi-indicator.h"
#include "network-statistics.h"
#include "wifi-background-scan.h"
+#define NETCONFIG_UPDATE_DEVICE_LIST_TIMEOUT 1 * 1000
#define NETCONFIG_NETWORK_NOTIFICATION_TIMEOUT 15 * 1000
static gboolean new_bss_found = FALSE;
-static guint network_noti_timer_id = 0;
-static wifi_service_state_e g_service_state = NETCONFIG_WIFI_UNKNOWN;
-static wifi_tech_state_e g_tech_state = NETCONFIG_WIFI_TECH_UNKNOWN;
+static guint network_update_timer_id = 0;
+static guint network_noti_timer_id = 0;
-static GSList *notifier_list = NULL;
+static GSList *g_device_list = NULL;
+static GSList *g_notifier_list = NULL;
static guint network_connected_popup_timer_id = 0;
static gboolean block_network_connected_popup = FALSE;
+static void __device_free_data(gpointer data)
+{
+ wifi_device_data_s *device_data = data;
+
+ g_free(device_data->interface_name);
+ g_free(device_data->mac_address);
+ g_free(device_data);
+
+}
+
+static wifi_device_data_s *__device_get_data(const char *interface_name)
+{
+ GSList *list = NULL;
+
+ for (list = g_device_list; list; list = list->next) {
+ wifi_device_data_s *device_data = list->data;
+ if (g_strcmp0(device_data->interface_name, interface_name) == 0)
+ return device_data;
+ }
+
+ return NULL;
+}
+
+static wifi_device_data_s *__device_get_data_by_macaddr(const char *macaddr)
+{
+ GSList *list = NULL;
+
+ for (list = g_device_list; list; list = list->next) {
+ wifi_device_data_s *device_data = list->data;
+ if (g_ascii_strncasecmp(device_data->mac_address,
+ macaddr, MAC_ADDRESS_MAX_LEN) == 0)
+ return device_data;
+ }
+
+ return NULL;
+}
+
char *_convert_wifi_service_state_to_string(wifi_service_state_e wifi_service_state_type)
{
switch (wifi_service_state_type) {
{
const char *essid_name = NULL;
const char *wifi_profile = netconfig_get_default_profile();
+ const char *wifi_ifname = netconfig_get_default_ifname();
- if (wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED)
+ if (wifi_state_get_service_state(wifi_ifname) != NETCONFIG_WIFI_CONNECTED)
return;
if (wifi_profile == NULL ||
static const char *__get_wifi_connected_essid(void)
{
const char *essid_name = NULL;
- const char *wifi_profile = NULL;
+ const char *wifi_profile = netconfig_get_default_profile();
+ const char *wifi_ifname = netconfig_get_default_ifname();
- if (wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED)
+ if (wifi_state_get_service_state(wifi_ifname) != NETCONFIG_WIFI_CONNECTED)
return NULL;
- wifi_profile = netconfig_get_default_profile();
-
if (wifi_profile == NULL || netconfig_is_wifi_profile(wifi_profile) != TRUE) {
ERR("Can't get Wi-Fi profile");
return NULL;
/* Add activation of services when Wi-Fi is connected */
}
-static void _wifi_state_changed(wifi_service_state_e state)
+static void _wifi_state_changed(const char *interface_name,
+ wifi_service_state_e state)
{
GSList *list;
+ const char *ifname;
- for (list = notifier_list; list; list = list->next) {
- wifi_state_notifier *notifier = list->data;
+ for (list = g_notifier_list; list; ) {
+ wifi_state_notifier_s *notifier = list->data;
+ list = list->next;
+
+ if (notifier->service) {
+ ifname = netconfig_get_ifname(notifier->service);
+ if (g_strcmp0(ifname, interface_name) != 0)
+ continue;
+ }
if (notifier->wifi_state_changed != NULL)
- notifier->wifi_state_changed(state, notifier->user_data);
+ notifier->wifi_state_changed(notifier->notifier,
+ notifier->service, state, notifier->user_data);
}
}
wifi_tech_state_e tech_state;
wifi_service_state_e service_state;
+ char *interface_name = data;
- tech_state = wifi_state_get_technology_state(FALSE);
+ tech_state = wifi_state_get_technology_state(interface_name);
if (tech_state < NETCONFIG_WIFI_TECH_POWERED) {
DBG("Wi-Fi off or WPS only supported[%d]", tech_state);
goto cleanup;
}
- service_state = wifi_state_get_service_state();
+ service_state = wifi_state_get_service_state(interface_name);
if (service_state == NETCONFIG_WIFI_CONNECTED) {
DBG("Service state is connected");
goto cleanup;
return;
}
-void wifi_state_emit_power_completed(gboolean power_on)
+void wifi_state_emit_power_completed(const char *interface_name, gboolean power_on)
{
if (power_on)
- wifi_emit_power_on_completed((Wifi *)get_wifi_object());
+ wifi_emit_power_on_completed((Wifi *)get_wifi_object(), interface_name);
else
- wifi_emit_power_off_completed((Wifi *)get_wifi_object());
+ wifi_emit_power_off_completed((Wifi *)get_wifi_object(), interface_name);
+
+ DBG("Successfully sent signal [%s %s]",
+ interface_name, (power_on) ? "powerOn" : "powerOff");
+}
+
+void wifi_state_emit_power_failed(const char *interface_name)
+{
+ wifi_emit_power_operation_failed((Wifi *)get_wifi_object(), interface_name);
- DBG("Successfully sent signal [%s]", (power_on) ? "powerOn" : "powerOff");
+ DBG("Successfully sent signal [%s PowerOperationFailed]", interface_name);
}
-void wifi_state_emit_power_failed(void)
+static void __update_wifi_state(void)
{
- wifi_emit_power_operation_failed((Wifi *)get_wifi_object());
+ int wifi_state = VCONFKEY_WIFI_OFF;
+ int network_wifi_state = VCONFKEY_NETWORK_WIFI_OFF;
+ GSList *list = NULL;
- DBG("Successfully sent signal [PowerOperationFailed]");
+ for (list = g_device_list; list; list = list->next) {
+ wifi_device_data_s *device_data = list->data;
+ if (device_data->powered) {
+ if (wifi_state < VCONFKEY_WIFI_UNCONNECTED)
+ wifi_state = VCONFKEY_WIFI_UNCONNECTED;
+ if (network_wifi_state < VCONFKEY_NETWORK_WIFI_NOT_CONNECTED)
+ network_wifi_state = VCONFKEY_NETWORK_WIFI_NOT_CONNECTED;
+ }
+ if (device_data->connected) {
+ wifi_state = VCONFKEY_WIFI_CONNECTED;
+ network_wifi_state = VCONFKEY_NETWORK_WIFI_CONNECTED;
+ }
+ }
+
+ netconfig_set_vconf_int(VCONFKEY_WIFI_STATE, wifi_state);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_STATE, network_wifi_state);
}
-void wifi_state_update_power_state(gboolean powered)
+void wifi_state_update_power_state(const char *interface_name, gboolean powered)
{
wifi_tech_state_e tech_state;
* DO NOT update manually
* It includes Wi-Fi state configuration
*/
- tech_state = wifi_state_get_technology_state(FALSE);
+ tech_state = wifi_state_get_technology_state(interface_name);
if (powered == TRUE) {
if (tech_state < NETCONFIG_WIFI_TECH_POWERED && netconfig_is_wifi_tethering_on() != TRUE) {
DBG("Wi-Fi turned on or waken up from power-save mode");
- wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_POWERED);
+ wifi_state_set_powered(interface_name, TRUE);
+ wifi_state_set_technology_state(interface_name, NETCONFIG_WIFI_TECH_POWERED);
- wifi_state_emit_power_completed(TRUE);
+ wifi_state_emit_power_completed(interface_name, TRUE);
netconfig_battery_start_wifi();
netconfig_wifi_device_picker_service_start();
- netconfig_set_vconf_int(VCONF_WIFI_LAST_POWER_STATE, VCONFKEY_WIFI_UNCONNECTED);
- netconfig_set_vconf_int(VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_UNCONNECTED);
- netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_STATE, VCONFKEY_NETWORK_WIFI_NOT_CONNECTED);
+ __update_wifi_state();
netconfig_set_system_event(SYS_EVT_WIFI_STATE, EKEY_WIFI_STATE, EVAL_WIFI_ON);
- netconfig_wifi_bgscan_stop();
- netconfig_wifi_bgscan_set_interval(SCAN_EXPONENTIAL_MIN);
- netconfig_wifi_bgscan_start(TRUE);
+ netconfig_wifi_bgscan_stop(interface_name);
+ netconfig_wifi_bgscan_set_interval(interface_name, SCAN_EXPONENTIAL_MIN);
+ netconfig_wifi_bgscan_start(interface_name, TRUE);
/* Add callback to track change in notification setting */
_register_network_notification();
+
+ netconfig_setting_update_interface_for_last_powered(interface_name, TRUE);
}
} else if (tech_state > NETCONFIG_WIFI_TECH_OFF) {
DBG("Wi-Fi turned off or in power-save mode");
- wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_WPS_ONLY);
+ wifi_state_set_powered(interface_name, FALSE);
+ wifi_state_set_technology_state(interface_name, NETCONFIG_WIFI_TECH_WPS_ONLY);
netconfig_wifi_device_picker_service_stop();
- wifi_power_disable_technology_state_by_only_connman_signal();
- wifi_power_driver_and_supplicant(FALSE);
+ wifi_power_driver_and_supplicant(interface_name, FALSE);
- wifi_state_emit_power_completed(FALSE);
+ wifi_state_emit_power_completed(interface_name, FALSE);
netconfig_battery_end_wifi();
- netconfig_set_vconf_int(VCONF_WIFI_LAST_POWER_STATE, VCONFKEY_WIFI_OFF);
- netconfig_set_vconf_int(VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_OFF);
- netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_STATE, VCONFKEY_NETWORK_WIFI_OFF);
+ __update_wifi_state();
netconfig_set_system_event(SYS_EVT_WIFI_STATE, EKEY_WIFI_STATE, EVAL_WIFI_OFF);
- netconfig_wifi_bgscan_stop();
+ netconfig_wifi_bgscan_stop(interface_name);
+ netconfig_wifi_scan_set_scanning(interface_name, FALSE);
_set_bss_found(FALSE);
netconfig_send_notification_to_net_popup(NETCONFIG_DEL_IP_CONFLICT_NOTI, NULL);
_deregister_network_notification();
+
+ netconfig_setting_update_interface_for_last_powered(interface_name, FALSE);
}
}
return _get_connman_favorite_service();
}
-void wifi_start_timer_network_notification(void)
+void wifi_start_timer_network_notification(const char *interface_name)
{
#if defined TIZEN_WEARABLE
/* In case of wearable device, no need to notify available Wi-Fi APs */
- return ;
+ return;
#endif
- netconfig_start_timer(NETCONFIG_NETWORK_NOTIFICATION_TIMEOUT, _check_network_notification, NULL, &network_noti_timer_id);
+ netconfig_start_timer(NETCONFIG_NETWORK_NOTIFICATION_TIMEOUT,
+ _check_network_notification, g_strdup(interface_name), &network_noti_timer_id);
}
-void wifi_state_notifier_register(wifi_state_notifier *notifier)
+void wifi_state_notifier_register(wifi_state_notifier_s *notifier)
{
DBG("register notifier");
- notifier_list = g_slist_append(notifier_list, notifier);
+ g_notifier_list = g_slist_append(g_notifier_list, notifier);
}
-void wifi_state_notifier_unregister(wifi_state_notifier *notifier)
+void wifi_state_notifier_unregister(wifi_state_notifier_s *notifier)
{
DBG("un-register notifier");
- notifier_list = g_slist_remove_all(notifier_list, notifier);
+ g_notifier_list = g_slist_remove_all(g_notifier_list, notifier);
}
void wifi_state_notifier_cleanup(void)
{
- g_slist_free_full(notifier_list, NULL);
+ g_slist_free_full(g_notifier_list, NULL);
}
void wifi_state_set_bss_found(gboolean found)
return new_bss_found;
}
-void wifi_state_set_service_state(wifi_service_state_e new_state)
+gboolean wifi_state_update_device_list(void)
+{
+ GVariant *message = NULL, *variant;
+ GVariantIter *iter, *next;
+ const char *path;
+ gchar *key;
+ gboolean updated = FALSE;
+
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "GetTechnologies", NULL);
+ if (message == NULL) {
+ ERR("Failed to get technologies");
+ return updated;
+ }
+
+ g_slist_free_full(g_device_list, __device_free_data);
+ g_device_list = NULL;
+
+ g_variant_get(message, "(a(oa{sv}))", &iter);
+ while (g_variant_iter_loop(iter, "(oa{sv})", &path, &next)) {
+ if (path == NULL || g_strcmp0(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) != 0)
+ continue;
+
+ while (g_variant_iter_loop(next, "{sv}", &key, &variant)) {
+ if (g_strcmp0(key, "Device.List") == 0) {
+ GVariantIter *list_iter;
+ gchar *dev_key;
+ GVariant *dev_var;
+ const gchar *sdata;
+ wifi_device_data_s *device_data = NULL;
+
+ g_variant_get(variant, "a{sv}", &list_iter);
+ while(g_variant_iter_loop(list_iter, "{sv}", &dev_key, &dev_var)) {
+ if (g_variant_is_of_type(dev_var, G_VARIANT_TYPE_STRING)) {
+ if (g_strcmp0(dev_key, "Ifname") == 0) {
+ device_data = g_try_malloc0(sizeof(wifi_device_data_s));
+ if (!device_data) {
+ g_variant_unref(dev_var);
+ break;
+ }
+
+ sdata = g_variant_get_string(dev_var, NULL);
+ device_data->interface_name = g_strdup(sdata);
+ g_device_list = g_slist_append(g_device_list, device_data);
+
+ updated = TRUE;
+
+ } else if (g_strcmp0(dev_key, "MAC.Address") == 0) {
+ if (device_data) {
+ sdata = g_variant_get_string(dev_var, NULL);
+ device_data->mac_address = g_strdup(sdata);
+
+ DBG("Ifname[%s] MAC[%s] Powered[%d] Connected[%d]",
+ device_data->interface_name, device_data->mac_address,
+ device_data->powered, device_data->connected);
+ }
+ }
+ } else if (g_variant_is_of_type(dev_var, G_VARIANT_TYPE_BOOLEAN)) {
+ if (g_strcmp0(dev_key, "Powered") == 0) {
+ if (device_data) {
+ device_data->powered = g_variant_get_boolean(dev_var);
+ if (device_data->powered == TRUE)
+ device_data->tech_state = NETCONFIG_WIFI_TECH_POWERED;
+ else
+ device_data->tech_state = NETCONFIG_WIFI_TECH_OFF;
+ }
+ } else if (g_strcmp0(dev_key, "Connected") == 0) {
+ if (device_data) {
+ device_data->connected = g_variant_get_boolean(dev_var);
+ if (device_data->connected == TRUE)
+ device_data->tech_state = NETCONFIG_WIFI_TECH_CONNECTED;
+ }
+ }
+ }
+ }
+
+ g_variant_iter_free(list_iter);
+ }
+ }
+ }
+
+ g_variant_unref(message);
+
+ g_variant_iter_free(iter);
+
+ return updated;
+}
+
+GSList *wifi_state_get_device_list(void)
+{
+ return g_device_list;
+}
+
+static gboolean __state_update_device_list(gpointer data)
+{
+ if (wifi_state_update_device_list() == FALSE)
+ return TRUE;
+
+ netconfig_stop_timer(&network_update_timer_id);
+ return FALSE;
+}
+
+void wifi_state_set_service_state(const char *interface_name, wifi_service_state_e new_state)
{
static gboolean dhcp_stage = FALSE;
- wifi_service_state_e old_state = g_service_state;
+ wifi_device_data_s *device_data = NULL;
+ wifi_service_state_e old_state = NETCONFIG_WIFI_UNKNOWN;
+
+ device_data = __device_get_data(interface_name);
+ if (!device_data)
+ return;
+ old_state = device_data->service_state;
if (old_state == new_state)
return;
- g_service_state = new_state;
+ device_data->service_state = new_state;
DBG("Wi-Fi service state, old state[%s] ==> new state[%s]",
_convert_wifi_service_state_to_string(old_state), _convert_wifi_service_state_to_string(new_state));
/* From association, temporarily disable Wi-Fi power saving */
if ((old_state < NETCONFIG_WIFI_ASSOCIATION || old_state == NETCONFIG_WIFI_FAILURE) && new_state == NETCONFIG_WIFI_ASSOCIATION) {
_set_power_lock(TRUE);
- wifi_set_early_suspend(FALSE);
+ wifi_set_early_suspend(interface_name, FALSE);
dhcp_stage = TRUE;
} else if (dhcp_stage == TRUE && new_state != NETCONFIG_WIFI_CONFIGURATION) {
_set_power_lock(FALSE);
- wifi_set_early_suspend(TRUE);
+ wifi_set_early_suspend(interface_name, TRUE);
dhcp_stage = FALSE;
}
if (new_state == NETCONFIG_WIFI_CONNECTED) {
netconfig_send_notification_to_net_popup(NETCONFIG_DEL_FOUND_AP_NOTI, NULL);
- netconfig_set_vconf_int(VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_CONNECTED);
- netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_STATE, VCONFKEY_NETWORK_WIFI_CONNECTED);
+ __update_wifi_state();
netconfig_set_system_event(SYS_EVT_WIFI_STATE, EKEY_WIFI_STATE, EVAL_WIFI_CONNECTED);
__set_wifi_connected_essid();
- netconfig_wifi_indicator_start();
+ netconfig_wifi_indicator_start(interface_name);
} else if (old_state == NETCONFIG_WIFI_CONNECTED) {
netconfig_send_notification_to_net_popup(NETCONFIG_DEL_PORTAL_NOTI, NULL);
__unset_wifi_connected_essid();
- netconfig_set_vconf_int (VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_UNCONNECTED);
- netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_STATE, VCONFKEY_NETWORK_WIFI_NOT_CONNECTED);
+ __update_wifi_state();
netconfig_set_system_event(SYS_EVT_WIFI_STATE, EKEY_WIFI_STATE, EVAL_WIFI_ON);
- netconfig_wifi_indicator_stop();
+ netconfig_wifi_indicator_stop(interface_name);
- netconfig_wifi_bgscan_stop();
- netconfig_wifi_bgscan_set_interval(SCAN_EXPONENTIAL_MIN);
- netconfig_wifi_bgscan_start(TRUE);
+ netconfig_wifi_bgscan_stop(interface_name);
+ netconfig_wifi_bgscan_set_interval(interface_name, SCAN_EXPONENTIAL_MIN);
+ netconfig_wifi_bgscan_start(interface_name, TRUE);
} else if ((old_state > NETCONFIG_WIFI_IDLE && old_state < NETCONFIG_WIFI_CONNECTED) && new_state == NETCONFIG_WIFI_IDLE) {
/* in ipv6 case disconnect/association -> association */
DBG("reset the bg scan period");
- netconfig_wifi_bgscan_stop();
- netconfig_wifi_bgscan_start(TRUE);
+ netconfig_wifi_bgscan_stop(interface_name);
+ netconfig_wifi_bgscan_start(interface_name, TRUE);
}
- _wifi_state_changed(new_state);
+ _wifi_state_changed(interface_name, new_state);
if (new_state == NETCONFIG_WIFI_CONNECTED)
_wifi_state_connected_activation();
}
-wifi_service_state_e wifi_state_get_service_state(void)
+wifi_service_state_e wifi_state_get_service_state(const char *interface_name)
{
- return g_service_state;
+ wifi_device_data_s *device_data = __device_get_data(interface_name);
+ if (!device_data)
+ return NETCONFIG_WIFI_UNKNOWN;
+
+ return device_data->service_state;
}
-void wifi_state_set_tech_state(wifi_tech_state_e new_state)
+void wifi_state_set_technology_state(const char *interface_name, wifi_tech_state_e new_state)
{
- wifi_tech_state_e old_state = g_tech_state;
+ wifi_device_data_s *device_data = NULL;
- if (old_state == new_state)
- return;
+ device_data = __device_get_data(interface_name);
+ if (device_data) {
+ if (device_data->tech_state == new_state)
+ return;
- g_tech_state = new_state;
+ DBG("Wi-Fi %s technology state, old state[%s] ==> new state[%s]", interface_name,
+ _convert_wifi_technology_state_to_string(device_data->tech_state),
+ _convert_wifi_technology_state_to_string(new_state));
- DBG("Wi-Fi technology state, old state[%s] ==> new state[%s]",
- _convert_wifi_technology_state_to_string(old_state), _convert_wifi_technology_state_to_string(new_state));
+ device_data->tech_state = new_state;
+ }
}
-wifi_tech_state_e wifi_state_get_technology_state(bool mode)
+wifi_tech_state_e wifi_state_get_technology_state(const char *interface_name)
{
- GVariant *message = NULL, *variant;
- GVariantIter *iter, *next;
- wifi_tech_state_e ret = NETCONFIG_WIFI_TECH_OFF;
- gboolean wifi_tech_powered = FALSE;
- gboolean wifi_tech_connected = FALSE;
- const char *path;
- gchar *key;
+ wifi_device_data_s *device_data = NULL;
- if (!mode && g_tech_state > NETCONFIG_WIFI_TECH_UNKNOWN)
- return g_tech_state;
+ device_data = __device_get_data(interface_name);
+ if (device_data) {
+ DBG("Wi-Fi %s technology state [%s]", interface_name,
+ _convert_wifi_technology_state_to_string(device_data->tech_state));
- message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
- CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
- "GetTechnologies", NULL);
- if (message == NULL) {
- ERR("Failed to get_technology_state");
- return NETCONFIG_WIFI_TECH_UNKNOWN;
+ return device_data->tech_state;
}
- g_variant_get(message, "(a(oa{sv}))", &iter);
- while (g_variant_iter_loop(iter, "(oa{sv})", &path, &next)) {
- if (path == NULL || g_strcmp0(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) != 0)
- continue;
+ return NETCONFIG_WIFI_TECH_UNKNOWN;
+}
- while (g_variant_iter_loop(next, "{sv}", &key, &variant)) {
- const gchar *sdata = NULL;
- gboolean data;
-
- if (g_variant_is_of_type(variant, G_VARIANT_TYPE_BOOLEAN)) {
- data = g_variant_get_boolean(variant);
- DBG("key-[%s] - %s", key, data ? "True" : "False");
-
- if (strcmp(key, "Powered") == 0 && data)
- wifi_tech_powered = TRUE;
- else if (strcmp(key, "Connected") == 0 && data)
- wifi_tech_connected = TRUE;
- /* For further use
- else if (strcmp(key, "Tethering") == 0 && data) {
- } */
- } else if (g_variant_is_of_type(variant, G_VARIANT_TYPE_STRING)) {
- sdata = g_variant_get_string(variant, NULL);
- DBG("%s", sdata);
- }
- }
+void wifi_state_set_powered(const char *interface_name, gboolean powered)
+{
+ wifi_device_data_s *device_data = __device_get_data(interface_name);
+
+ if (device_data) {
+ device_data->powered = powered;
+ DBG("Wi-Fi %s [%s]", interface_name, powered ? "enabled" : "disabled");
}
+}
- g_variant_unref(message);
+gboolean wifi_state_get_powered(const char *interface_name)
+{
+ wifi_device_data_s *device_data = __device_get_data(interface_name);
+ if (!device_data)
+ return FALSE;
- g_variant_iter_free(iter);
+ return device_data->powered;
+}
- if (wifi_tech_powered == TRUE)
- ret = NETCONFIG_WIFI_TECH_POWERED;
+void wifi_state_set_connected(const char *interface_name, gboolean connected)
+{
+ wifi_device_data_s *device_data = __device_get_data(interface_name);
- if (wifi_tech_connected == TRUE)
- ret = NETCONFIG_WIFI_TECH_CONNECTED;
+ if (device_data) {
+ device_data->connected = connected;
+ DBG("Wi-Fi %s [%s]", interface_name, connected ? "connected" : "disconnected");
+ }
+}
- g_tech_state = ret;
+gboolean wifi_state_get_connected(const char *interface_name)
+{
+ wifi_device_data_s *device_data = __device_get_data(interface_name);
+ if (!device_data)
+ return FALSE;
- return g_tech_state;
+ return device_data->connected;
}
-gboolean wifi_state_is_technology_available(void)
+gboolean wifi_state_is_existed(const char *interface_name)
{
- GVariant *message = NULL;
- GVariantIter *iter, *next;
- const char *path;
- gboolean ret = FALSE;
-
- message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
- CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
- "GetTechnologies", NULL);
- if (message == NULL) {
- ERR("Failed to get_technology_state");
+ wifi_device_data_s *device_data = __device_get_data(interface_name);
+ if (!device_data)
return FALSE;
- }
- g_variant_get(message, "(a(oa{sv}))", &iter);
- while (g_variant_iter_loop(iter, "(oa{sv})", &path, &next)) {
- if (path != NULL && g_strcmp0(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == 0)
- ret = TRUE;
- }
+ return TRUE;
+}
- g_variant_unref(message);
- g_variant_iter_free(iter);
+const char *wifi_state_get_interface_name(const char *mac_address)
+{
+ wifi_device_data_s *device_data = __device_get_data_by_macaddr(mac_address);
+ if (!device_data)
+ return NULL;
+
+ return device_data->interface_name;
+}
- DBG("Wi-Fi technology is %s", ret ? "available" : "unavailable");
- return ret;
+const char *wifi_state_get_mac_address(const char *interface_name)
+{
+ wifi_device_data_s *device_data = __device_get_data(interface_name);
+ if (!device_data)
+ return NULL;
+
+ return device_data->mac_address;
}
void wifi_state_set_connected_essid(void)
*essid = g_strdup(__get_wifi_connected_essid());
}
-/* wifi_connection_state_e in CAPI
- *
- * WIFI_CONNECTION_STATE_FAILURE = -1
- * WIFI_CONNECTION_STATE_DISCONNECTED = 0
- * WIFI_CONNECTION_STATE_ASSOCIATION = 1
- * WIFI_CONNECTION_STATE_CONFIGURATION = 2
- * WIFI_CONNECTION_STATE_CONNECTED = 3
- */
-/* connection_wifi_state_e in CAPI
- *
- * CONNECTION_WIFI_STATE_DEACTIVATED = 0
- * CONNECTION_WIFI_STATE_DISCONNECTED = 1
- * CONNECTION_WIFI_STATE_CONNECTED = 2
- */
-gboolean handle_get_wifi_state(Wifi *wifi, GDBusMethodInvocation *context)
-{
- g_return_val_if_fail(wifi != NULL, TRUE);
- GVariant *param = NULL;
- wifi_tech_state_e tech_state = NETCONFIG_WIFI_TECH_UNKNOWN;
- wifi_service_state_e service_state = NETCONFIG_WIFI_UNKNOWN;
- tech_state = wifi_state_get_technology_state(FALSE);
- service_state = wifi_state_get_service_state();
-
- if (tech_state == NETCONFIG_WIFI_TECH_UNKNOWN)
- param = g_variant_new("(s)", "unknown");
- else if (tech_state == NETCONFIG_WIFI_TECH_OFF ||
- tech_state == NETCONFIG_WIFI_TECH_WPS_ONLY)
- param = g_variant_new("(s)", "deactivated");
- else if (tech_state == NETCONFIG_WIFI_TECH_CONNECTED)
- param = g_variant_new("(s)", "connected");
- else {
- switch (service_state) {
- case NETCONFIG_WIFI_FAILURE:
- param = g_variant_new("(s)", "failure");
- break;
- case NETCONFIG_WIFI_ASSOCIATION:
- param = g_variant_new("(s)", "association");
- break;
- case NETCONFIG_WIFI_CONFIGURATION:
- param = g_variant_new("(s)", "configuration");
- break;
- case NETCONFIG_WIFI_CONNECTED:
- param = g_variant_new("(s)", "connected");
- break;
- case NETCONFIG_WIFI_UNKNOWN:
- case NETCONFIG_WIFI_IDLE:
- default:
- param = g_variant_new("(s)", "disconnected");
- }
- }
-
- g_dbus_method_invocation_return_value(context, param);
+void wifi_state_initialize(void)
+{
+ if (wifi_state_update_device_list() == FALSE)
+ netconfig_start_timer(NETCONFIG_UPDATE_DEVICE_LIST_TIMEOUT,
+ __state_update_device_list, NULL, &network_update_timer_id);
+}
- return TRUE;
+void wifi_state_deinitialize(void)
+{
+ g_slist_free_full(g_device_list, __device_free_data);
}
}
}
-void __netconfig_wifi_notify_tdls_event(const char *sig_name, const char *peer_mac)
+void __netconfig_wifi_notify_tdls_event(const char *interface_name,
+ const char *sig_name, const char *peer_mac)
{
GVariantBuilder *builder;
GVariant *params;
+
builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
g_variant_builder_add(builder, "{sv}", "peermac", g_variant_new_string(peer_mac));
-
- 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,
INFO("Sent signal (%s) Peer Mac (%s)", sig_name, peer_mac);
}
-void __netconfig_wifi_notify_tdls_discover_event(const char *peer_mac, int discover_type)
+void __netconfig_wifi_notify_tdls_discover_event(const char *interface_name,
+ const char *peer_mac, int discover_type)
{
GVariantBuilder *builder;
GVariant *params;
+
builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
g_variant_builder_add(builder, "{sv}", "peermac", g_variant_new_string(peer_mac));
g_variant_builder_add(builder, "{sv}", "discover_type", g_variant_new_int32(discover_type));
-
- 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,
static gboolean _tdls_timer_discover_event(gpointer user_data)
{
+ char *interface_name = user_data;
- if (tdls_timer_id == 0)
+ if (tdls_timer_id == 0) {
+ g_free(interface_name);
return FALSE;
+ }
INFO("[TDLS Discover Timer Expired");
- __netconfig_wifi_notify_tdls_discover_event("00:00:00:00:00:00", is_discover_broadcast);
+ __netconfig_wifi_notify_tdls_discover_event(interface_name,
+ "00:00:00:00:00:00", is_discover_broadcast);
is_discover_broadcast = 0;
stop_tdls_timer();
is_timer_expired = 1;
+ g_free(interface_name);
return FALSE;
}
-static GVariant * __netconfig_wifi_tdls_send_dbus_str(const char* method, const char *str)
+static GVariant * __netconfig_wifi_tdls_send_dbus_str(const char *interface_name,
+ const char *method, const char *str)
{
GVariant *message = 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) {
ERR("Fail to get wpa_supplicant DBus path");
return NULL;
}
gboolean handle_tdls_connect(Wifi *wifi, GDBusMethodInvocation *context,
- gchar *peer_mac_Addr)
+ const gchar *ifname, gchar *peer_mac_Addr)
{
DBG("[TizenMW-->WPAS]: TDLS Setup Request: [%s]", peer_mac_Addr);
ERR(" Already TDLS Connection !!!");
} else {
GVariant *message = NULL;
- message = __netconfig_wifi_tdls_send_dbus_str("TDLSSetup", (const char*)peer_mac_Addr);
+ message = __netconfig_wifi_tdls_send_dbus_str(ifname, "TDLSSetup", (const char*)peer_mac_Addr);
if (message == NULL) {
ERR(" TDLS : failed to connect !!!");
}
gboolean handle_tdls_discover(Wifi *wifi, GDBusMethodInvocation *context,
- gchar *peer_mac_Addr)
+ const gchar *ifname, gchar *peer_mac_Addr)
{
DBG("TDLS Discover Request: [%s]", peer_mac_Addr);
int discover_timeout = 0;
return TRUE;
}
- message = __netconfig_wifi_tdls_send_dbus_str("TDLSDiscover", (const char*)peer_mac_Addr);
+ message = __netconfig_wifi_tdls_send_dbus_str(ifname, "TDLSDiscover", (const char*)peer_mac_Addr);
if (message == NULL) {
ERR(" TDLS : failed to discover !!!");
is_timer_expired = 0;
tdls_timer_id = g_timeout_add_seconds(discover_timeout,
- _tdls_timer_discover_event, NULL);
+ _tdls_timer_discover_event, g_strdup(ifname));
wifi_complete_tdls_discover(wifi, context, NETCONFIG_ERROR_TDLS_NO_ERROR);
return TRUE;
}
gboolean handle_tdls_disconnect(Wifi *wifi, GDBusMethodInvocation *context,
- gchar *peer_mac_Addr)
+ const gchar *ifname, gchar *peer_mac_Addr)
{
DBG("[TizenMW-->WPAS]: TDLS Teardown Request: [%s]", peer_mac_Addr);
wifi_complete_tdls_disconnect(wifi, context, NETCONFIG_ERROR_TDLS_ALREADY_DONE);
} else {
GVariant *message = NULL;
- message = __netconfig_wifi_tdls_send_dbus_str("TDLSTeardown", (const char*)peer_mac_Addr);
+ message = __netconfig_wifi_tdls_send_dbus_str(ifname, "TDLSTeardown", (const char*)peer_mac_Addr);
if (message == NULL) {
ERR(" TDLS : failed to disconnect !!!");
return TRUE;
}
-gboolean handle_tdls_connected_peer(Wifi *wifi, GDBusMethodInvocation *context)
+gboolean handle_tdls_connected_peer(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *ifname)
{
DBG("[TizenMW-->WPAS]: TDLS Connected Peer Request: ");
wifi_complete_tdls_connected_peer(wifi, context, "00.00.00.00.00.00");
return TRUE;
}
- message = __netconfig_wifi_tdls_send_dbus_str("TDLSStatus", (const char*)peer_mac);
+ message = __netconfig_wifi_tdls_send_dbus_str(ifname, "TDLSStatus", (const char*)peer_mac);
if (message == NULL) {
ERR(" TDLS : No active TDLS Link Setup !!!");
wifi_complete_tdls_connected_peer(wifi, context, "00.00.00.00.00.00");
}
gboolean handle_tdls_channel_switch(Wifi *wifi, GDBusMethodInvocation *context,
- gchar *peer_mac_Addr, int freq)
+ const gchar *ifname, gchar *peer_mac_Addr, int freq)
{
GVariant *message = NULL;
GVariantBuilder *builder;
params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- if_path = netconfig_wifi_get_supplicant_interface();
+ if_path = netconfig_wifi_get_supplicant_interface_path(ifname);
if (if_path == NULL) {
ERR("Fail to get wpa_supplicant DBus path");
}
message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
- if_path, SUPPLICANT_INTERFACE ".Interface", "TDLSChannelSwitch", params);
+ if_path, SUPPLICANT_INTERFACE ".Interface",
+ "TDLSChannelSwitch", params);
g_free(if_path);
if (message == NULL) {
gboolean handle_tdls_cancel_channel_switch(Wifi *wifi, GDBusMethodInvocation *context,
- gchar *peer_mac_Addr)
+ const gchar *ifname, gchar *peer_mac_Addr)
{
GVariant *message = NULL;
wifi_complete_tdls_cancel_channel_switch(wifi, context, NETCONFIG_ERROR_TDLS_FAIL_CHANNEL_SWITCH);
return TRUE;
}
- message = __netconfig_wifi_tdls_send_dbus_str("TDLSCancelChannelSwitch", (const char*)peer_mac_Addr);
+ message = __netconfig_wifi_tdls_send_dbus_str(ifname,
+ "TDLSCancelChannelSwitch", (const char*)peer_mac_Addr);
if (message == NULL) {
ERR(" TDLS : Fail to TDLS Cancel Channel Swicth Request !!!");
wifi_complete_tdls_cancel_channel_switch(wifi, context, NETCONFIG_ERROR_TDLS_FAIL_CHANNEL_SWITCH);
return TRUE;
}
-void netconfig_wifi_tdls_connected_event(GVariant *message)
+void netconfig_wifi_tdls_connected_event(const char *interface_name, GVariant *message)
{
DBG("WiFi TDLS Connected EVENT");
INFO("Peer Mac Address: [%s]", peer_mac);
is_connected = 1;
- __netconfig_wifi_notify_tdls_event("TDLSConnect", peer_mac);
+ __netconfig_wifi_notify_tdls_event(interface_name, "TDLSConnect", peer_mac);
}
-void netconfig_wifi_tdls_disconnected_event(GVariant *message)
+void netconfig_wifi_tdls_disconnected_event(const char *interface_name, GVariant *message)
{
DBG("WiFi TDLS Disconnected EVENT");
const gchar *peer_mac_addr = NULL;
if (g_strcmp0(peer_mac, peer_mac_addr) == 0) {
INFO("TDLS Peer Disconnected Mac Address: [%s]", peer_mac);
is_connected = 0;
- __netconfig_wifi_notify_tdls_event("TDLSDisconnect", peer_mac);
+ __netconfig_wifi_notify_tdls_event(interface_name, "TDLSDisconnect", peer_mac);
} else
INFO("TDLS Peer Disconnected peer_mac(%s) != peer_mac_address(%s)", peer_mac, peer_mac_addr);
}
-void netconfig_wifi_tdls_peer_found_event(GVariant *message)
+void netconfig_wifi_tdls_peer_found_event(const char *interface_name, GVariant *message)
{
DBG("WiFi TDLS Discovery EVENT Received !!");
const gchar *peer_mac_addr = NULL;
if (is_discover_broadcast == 0)
stop_tdls_timer();
- __netconfig_wifi_notify_tdls_discover_event(peer_mac_addr, is_discover_broadcast);
+ __netconfig_wifi_notify_tdls_discover_event(interface_name, peer_mac_addr, is_discover_broadcast);
} else
DBG("Timer expired: Do not process the TDLS Discovery Event");
}
#include "netsupplicant.h"
#include "wifi-background-scan.h"
-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;
-void netconfig_wifi_notify_wps_credentials(const char *ssid, gsize ssid_len, const char *wps_key)
+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 __set_wifi_wps(const char *interface_name, gboolean pbc, char *pin)
+{
+ wifi_wps_s *wifi_wps;
+
+ wifi_wps = __get_wifi_wps(interface_name);
+ if (wifi_wps == NULL)
+ return;
+
+ 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;
+}
+
+static char *__get_wifi_wps_pin(const char *interface_name)
+{
+ 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 *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,
const char *role = "enrollee", *type, *key;
char *if_path = NULL;
gboolean reply = FALSE;
+ char *interface_name = user_data;
- 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);
- g_free(if_path);
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(char *object_path)
+static gboolean __netconfig_wifi_invoke_wps_process_credentials(char *object_path,
+ const char *interface_name)
{
gboolean reply = FALSE;
GVariant *params = NULL;
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)
{
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;
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;
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");
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, TRUE);
- __netconfig_wifi_invoke_wps_cancel();
+ __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");
/* 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;
{
GDBusConnection *conn = NULL;
GError *error = NULL;
+ GVariant *params = NULL;
+ char *interface_name = user_data;
DBG("WiFi Connection Reply");
g_error_free(error);
DBG("WiFi Connection in Progress");
netconfig_gdbus_pending_call_unref();
+ g_free(interface_name);
return;
}
g_error_free(error);
+
+ params = g_variant_new("(s)", interface_name);
if (netconfig_dbus_emit_signal(NULL, NETCONFIG_WIFI_PATH,
NETCONFIG_WIFI_INTERFACE, "WiFiConnectFail",
- NULL) == FALSE)
+ params) == FALSE)
ERR("Failed to emit WiFiConnectFail signal");
else
DBG("Successfully sent WiFiConnectFail signal");
DBG("WiFi Connection has been initiated successfully");
netconfig_gdbus_pending_call_unref();
+ g_free(interface_name);
return;
}
g_signal_connect(wifi_object, "handle-remove-p2p-driver",
G_CALLBACK(handle_remove_p2p_driver), NULL);
- /* WIFI state */
- g_signal_connect(wifi_object, "handle-get-wifi-state",
- G_CALLBACK(handle_get_wifi_state), NULL);
-
/* WIFI scan */
g_signal_connect(wifi_object, "handle-request-bssid-scan",
G_CALLBACK(handle_request_bssid_scan), NULL);
_set_wifi_mac_address();
+ wifi_state_initialize();
wifi_power_initialize();
return;
g_object_unref(wififirmware_object);
wifi_power_deinitialize();
+ wifi_state_deinitialize();
}