gboolean is_hidden;
} net_wifi_connect_service_info_t;
-int _net_dbus_open_connection(const char* profile_name);
-int _net_dbus_close_connection(const char* profile_name);
-int _net_dbus_scan_request(void);
-int _net_dbus_get_scan_state(int *state);
-int _net_dbus_set_bgscan_mode(net_wifi_background_scan_mode_e mode);
-int _net_dbus_set_agent_passphrase_and_connect(
+int _net_dbus_open_connection(network_info_s *network_info,
+ const char* profile_name);
+int _net_dbus_close_connection(network_info_s *network_info,
+ const char* profile_name);
+int _net_dbus_scan_request(network_info_s *network_info);
+int _net_dbus_get_scan_state(network_info_s *network_info, int *state);
+int _net_dbus_set_bgscan_mode(network_info_s *network_info,
+ net_wifi_background_scan_mode_e mode);
+int _net_dbus_set_agent_passphrase_and_connect(network_info_s *network_info,
const char *passphrase, const char *profilename);
-int _net_dbus_get_wps_generated_pin(char **wps_pin);
-int _net_dbus_set_agent_wps_pbc_and_connect(const char *profilename);
-int _net_dbus_set_agent_wps_pin_and_connect(
+int _net_dbus_get_wps_generated_pin(network_info_s *network_info, char **wps_pin);
+int _net_dbus_set_agent_wps_pbc_and_connect(network_info_s *network_info,
+ const char *profilename);
+int _net_dbus_set_agent_wps_pin_and_connect(network_info_s *network_info,
const char *wps_pin, const char *profilename);
-int _net_dbus_get_tech_status(net_tech_info_s* tech_status);
-int _net_dbus_connect_service(const net_wifi_connect_service_info_t* wifi_connection_info);
-int _net_dbus_get_preferred_ipv6_address(const char *profilename, char **address);
-int _net_dbus_set_profile_ipv4(net_profile_info_s* prof_info, char* profile_name);
-int _net_dbus_set_profile_ipv6(net_profile_info_s* prof_info, char* profile_name);
-int _net_dbus_set_profile_dns(net_profile_info_s* prof_info, char* profile_name);
-int _net_dbus_set_proxy(net_profile_info_s* prof_info, char* profile_name);
-int _net_dbus_get_technology_state(network_tech_state_info_s* tech_state);
-GVariant *_net_invoke_dbus_method(const char *dest, const char *path,
- const char *interface_name, const char *method,
- GVariant *params, int *dbus_error);
-int _net_invoke_dbus_method_nonblock(const char *dest, const char *path,
+int _net_dbus_get_tech_status(network_info_s *network_info,
+ net_tech_info_s *tech_status);
+int _net_dbus_connect_service(network_info_s *network_info,
+ const net_wifi_connect_service_info_t *wifi_connection_info);
+int _net_dbus_get_preferred_ipv6_address(network_info_s *network_info,
+ const char *profilename, char **address);
+int _net_dbus_set_profile_ipv4(network_info_s *network_info,
+ net_profile_info_s *prof_info, char *profile_name);
+int _net_dbus_set_profile_ipv6(network_info_s *network_info,
+ net_profile_info_s *prof_info, char *profile_name);
+int _net_dbus_set_profile_dns(network_info_s *network_info,
+ net_profile_info_s *prof_info, char *profile_name);
+int _net_dbus_set_proxy(network_info_s *network_info,
+ net_profile_info_s *prof_info, char *profile_name);
+int _net_dbus_get_technology_state(network_info_s *network_info,
+ network_tech_state_info_s *tech_state);
+GVariant *_net_invoke_dbus_method(network_info_s *network_info,
+ const char *dest, const char *path, const char *interface_name,
+ const char *method, GVariant *params, int *dbus_error);
+int _net_invoke_dbus_method_nonblock(network_info_s *network_info,
+ const char *dest, const char *path,
const char *interface_name, const char *method,
GVariant *params, int timeout,
GAsyncReadyCallback notify_func);
-int _net_dbus_load_wifi_driver(gboolean wifi_picker_test);
-int _net_dbus_remove_wifi_driver(void);
-int _net_dbus_specific_scan_request(const char *ssid);
-int _net_dbus_bssid_scan_request(void);
-int _net_dbus_netlink_scan_request(GSList *nl_scan_list, const char *vsie);
-int _net_dbus_get_passpoint(int *enabled);
-int _net_dbus_set_passpoint(int enable);
-int _net_dbus_multi_scan_request(GSList *multi_scan_list);
-int _net_dbus_get_max_scan_ssids(int *max_scan_ssids);
-
-int _net_dbus_cancel_wps(void);
-int _net_dbus_open_connection_without_ssid();
-int _net_dbus_open_pin_connection_without_ssid(const char *pin);
-
-int _net_dbus_tdls_disconnect(const char* peer_mac_addr);
-int _net_dbus_tdls_connected_peer(char** peer_mac_addr);
-int _net_dbus_tdls_connect(const char *peer_mac_addr);
-int _net_dbus_tdls_discover(const char *peer_mac_addr);
-int _net_dbus_tdls_enable_channel_switch(const char* peer_mac_addr, int freq);
-int _net_dbus_tdls_disable_channel_switch(const char* peer_mac_addr);
-
-int _net_dbus_config_get_id_list(GSList **list);
-int _net_dbus_config_set_field(const gchar *config_id, const gchar *key, const gchar *value);
-int _net_dbus_config_get_passphrase(const gchar *config_id, gchar **passphrase);
-int _net_dbus_config_save_configurations(const gchar *config_id, const gchar *name,
+int _net_dbus_load_wifi_driver(network_info_s *network_info, gboolean wifi_picker_test);
+int _net_dbus_remove_wifi_driver(network_info_s *network_info);
+int _net_dbus_specific_scan_request(network_info_s *network_info, const char *ssid);
+int _net_dbus_bssid_scan_request(network_info_s *network_info);
+int _net_dbus_netlink_scan_request(network_info_s *network_info,
+ GSList *nl_scan_list, const char *vsie);
+int _net_dbus_get_passpoint(network_info_s *network_info, int *enabled);
+int _net_dbus_set_passpoint(network_info_s *network_info, int enable);
+int _net_dbus_multi_scan_request(network_info_s *network_info,
+ GSList *multi_scan_list);
+int _net_dbus_get_max_scan_ssids(network_info_s *network_info, int *max_scan_ssids);
+
+int _net_dbus_cancel_wps(network_info_s *network_info);
+int _net_dbus_open_connection_without_ssid(network_info_s *network_info);
+int _net_dbus_open_pin_connection_without_ssid(network_info_s *network_info,
+ const char *pin);
+
+int _net_dbus_tdls_disconnect(network_info_s *network_info, const char* peer_mac_addr);
+int _net_dbus_tdls_connected_peer(network_info_s *network_info, char** peer_mac_addr);
+int _net_dbus_tdls_connect(network_info_s *network_info, const char *peer_mac_addr);
+int _net_dbus_tdls_discover(network_info_s *network_info, const char *peer_mac_addr);
+int _net_dbus_tdls_enable_channel_switch(network_info_s *network_info,
+ const char* peer_mac_addr, int freq);
+int _net_dbus_tdls_disable_channel_switch(network_info_s *network_info,
+ const char* peer_mac_addr);
+
+int _net_dbus_config_get_id_list(network_info_s *network_info, GSList **list);
+int _net_dbus_config_set_field(network_info_s *network_info,
+ const gchar *config_id, const gchar *key, const gchar *value);
+int _net_dbus_config_get_passphrase(network_info_s *network_info,
+ const gchar *config_id, gchar **passphrase);
+int _net_dbus_config_save_configurations(network_info_s *network_info,
+ const gchar *config_id, const gchar *name,
const gchar *ssid, const gchar *passphrase, const gchar *proxy_address,
net_ip_info_config_s *ip_info, gboolean is_hidden, gboolean is_created);
-int _net_dbus_config_save_eap_configurations(const gchar *config_id,
- const gchar *name, const gchar *ssid, const gchar *passphrase,
+int _net_dbus_config_save_eap_configurations(network_info_s *network_info,
+ const gchar *config_id, const gchar *name, const gchar *ssid, const gchar *passphrase,
const gchar *proxy_address, net_eap_config_s *eap_config, gboolean is_hidden, gboolean is_created);
-int _net_dbus_config_remove_configurations(const gchar *config_id);
-int _net_dbus_config_load_configurations(const gchar *config_id, gchar **name,
- gchar **passphrase, net_wifi_security_type_e *security_type, gchar **proxy_address,
+int _net_dbus_config_remove_configurations(network_info_s *network_info,
+ const gchar *config_id);
+int _net_dbus_config_load_configurations(network_info_s *network_info,
+ const gchar *config_id, gchar **name, gchar **passphrase,
+ net_wifi_security_type_e *security_type, gchar **proxy_address,
gboolean *is_hidden, net_ip_info_config_s **ip_info, void *last_error);
-int _net_dbus_config_load_eap_configurations(const gchar *config_id,
- gchar **name, net_wifi_security_type_e *security_type, gchar **proxy_address,
- gboolean *is_hidden, net_eap_config_s **eap_config, void *last_error);
-
-int _net_dbus_device_policy_get_wifi(int *state);
-int _net_dbus_device_policy_get_wifi_profile(int *state);
-int _net_dbus_resume_bgscan(void);
-int _net_dbus_pause_bgscan(void);
-int _net_dbus_get_autoscanmode(unsigned int *autoscanmode);
-int _net_dbus_get_autoscan(gboolean *autoscan);
-
-
-int _net_dbus_add_vsie(unsigned int frame_id, const char *vsie_str);
-int _net_dbus_get_vsie(unsigned int frame_id, char **vsie_str);
-int _net_dbus_remove_vsie(unsigned int frame_id, const char *vsie_str);
-int _net_dbus_flush_bss(void);
-int _net_dbus_set_bssid(char *bssid);
-int _net_dbus_get_auto_connect_mode(int *connect_mode);
-int _net_dbus_set_auto_connect_mode(int connect_mode);
-int _net_dbus_wifi_set_autoconnect(const char *profile_name, gboolean autoconnect);
-int _net_dbus_wifi_get_autoconnect(const char *profile_name, gboolean *autoconnect);
-int _net_dbus_get_5ghz_support(gboolean *supported);
-int _net_dbus_set_ip_conflict_period(unsigned int initial_time);
-
-int _net_dbus_dpp_enter_peer_uri(guint32 peer_id, guint32 own_id, const char *uri);
-int _net_dbus_dpp_generate_uri(guint32 peer_id, guint32 own_id, gboolean is_initiator, const char *key);
-
-int _net_dbus_dpp_start_configurator_initiator(const gchar *group_id, const gchar *ssid,
+int _net_dbus_config_load_eap_configurations(network_info_s *network_info,
+ const gchar *config_id, gchar **name, net_wifi_security_type_e *security_type,
+ gchar **proxy_address, gboolean *is_hidden, net_eap_config_s **eap_config, void *last_error);
+
+int _net_dbus_device_policy_get_wifi(network_info_s *network_info, int *state);
+int _net_dbus_device_policy_get_wifi_profile(network_info_s *network_info,
+ int *state);
+int _net_dbus_resume_bgscan(network_info_s *network_info);
+int _net_dbus_pause_bgscan(network_info_s *network_info);
+int _net_dbus_get_autoscanmode(network_info_s *network_info,
+ unsigned int *autoscanmode);
+int _net_dbus_get_autoscan(network_info_s *network_info, gboolean *autoscan);
+
+int _net_dbus_add_vsie(network_info_s *network_info,
+ unsigned int frame_id, const char *vsie_str);
+int _net_dbus_get_vsie(network_info_s *network_info,
+ unsigned int frame_id, char **vsie_str);
+int _net_dbus_remove_vsie(network_info_s *network_info,
+ unsigned int frame_id, const char *vsie_str);
+int _net_dbus_flush_bss(network_info_s *network_info);
+int _net_dbus_set_bssid(network_info_s *network_info, char *bssid);
+int _net_dbus_get_auto_connect_mode(network_info_s *network_info,
+ int *connect_mode);
+int _net_dbus_set_auto_connect_mode(network_info_s *network_info,
+ int connect_mode);
+int _net_dbus_wifi_set_autoconnect(network_info_s *network_info,
+ const char *profile_name, gboolean autoconnect);
+int _net_dbus_wifi_get_autoconnect(network_info_s *network_info,
+ const char *profile_name, gboolean *autoconnect);
+int _net_dbus_get_5ghz_support(network_info_s *network_info, gboolean *supported);
+int _net_dbus_set_ip_conflict_period(network_info_s *network_info, unsigned int initial_time);
+
+int _net_dbus_dpp_enter_peer_uri(network_info_s *network_info,
+ guint32 peer_id, guint32 own_id, const char *uri);
+int _net_dbus_dpp_generate_uri(network_info_s *network_info,
+ guint32 peer_id, guint32 own_id, gboolean is_initiator, const char *key);
+
+int _net_dbus_dpp_start_configurator_initiator(network_info_s *network_info,
+ const gchar *group_id, const gchar *ssid,
const gchar *peer_uri, guint32 peer_id, const gchar *net_role,
const gchar *akm, const gchar *configurator_key, const gchar *pass);
-int _net_dbus_dpp_start_enrollee_initiator(const gchar *peer_uri, guint32 peer_id);
-int _net_dbus_dpp_start_configurator_responder(const gchar *group_id,
- const gchar *ssid, const gchar *net_role, const gchar *akm,
+int _net_dbus_dpp_start_enrollee_initiator(network_info_s *network_info,
+ const gchar *peer_uri, guint32 peer_id);
+int _net_dbus_dpp_start_configurator_responder(network_info_s *network_info,
+ const gchar *group_id, const gchar *ssid, const gchar *net_role, const gchar *akm,
const gchar *auth_key, const gchar *configurator_key, const gchar *pass);
-int _net_dbus_dpp_start_enrollee_responder(const gchar *auth_key);
+int _net_dbus_dpp_start_enrollee_responder(network_info_s *network_info,
+ const gchar *auth_key);
-int _net_dbus_dpp_stop(guint32 peer_id, guint32 own_id, gboolean is_initiator);
+int _net_dbus_dpp_stop(network_info_s *network_info,
+ guint32 peer_id, guint32 own_id, gboolean is_initiator);
#ifdef __cplusplus
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 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 __NETWORK_INFO_H__
+#define __NETWORK_INFO_H__
+
+#include <gio/gio.h>
+
+#include "network_error.h"
+#include "network_wlan.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NET_TECH_LENGTH_MAX 64
+
+typedef enum {
+ NET_EVENT_OPEN_RSP,
+ NET_EVENT_CLOSE_RSP,
+ NET_EVENT_OPEN_IND,
+ NET_EVENT_CLOSE_IND,
+ NET_EVENT_NET_STATE_IND,
+ NET_EVENT_WIFI_SCAN_RSP,
+ NET_EVENT_WIFI_SCAN_IND,
+ NET_EVENT_WIFI_SCAN_CHANGED,
+ NET_EVENT_WIFI_MAC_ID_IND, /** This is deprecated Event and maintained only for compatibility */
+ NET_EVENT_WIFI_POWER_RSP,
+ NET_EVENT_WIFI_POWER_IND,
+ NET_EVENT_WIFI_SPECIFIC_SCAN_RSP,
+ NET_EVENT_WIFI_SPECIFIC_SCAN_IND,
+ NET_EVENT_WIFI_MULTI_SCAN_RSP,
+ NET_EVENT_WIFI_MULTI_SCAN_IND,
+ NET_EVENT_WIFI_WPS_RSP,
+ NET_EVENT_WIFI_SCANNING_IND,
+ NET_EVENT_WIFI_BSSID_SCAN_IND,
+ NET_EVENT_WIFI_NETLINK_SCAN_IND,
+ NET_EVENT_WIFI_IP_CONFLICT_IND,
+ NET_EVENT_WIFI_TDLS_DISCOVERED_IND,
+ NET_EVENT_WIFI_TDLS_CONNECTED_IND,
+ NET_EVENT_WIFI_TDLS_DISCONNECTED_IND,
+ NET_EVENT_WIFI_FORGET_AP_IND,
+ NET_EVENT_WIFI_RSSI_CHANGED,
+ NET_EVENT_WIFI_RSSI_LEVEL_CHANGED,
+ NET_EVENT_WIFI_MODULE_STATE_CHANGED,
+ NET_EVENT_WIFI_DPP_URI_GENERATED,
+ NET_EVENT_WIFI_DPP_BOOTSTRAPPED,
+ NET_EVENT_WIFI_DPP_AWAITING,
+ NET_EVENT_WIFI_DPP_AUTHENTICATING,
+ NET_EVENT_WIFI_DPP_AUTH_SUCCESS,
+ NET_EVENT_WIFI_DPP_AUTH_FAILED,
+ NET_EVENT_WIFI_DPP_NOT_COMPATIBLE,
+ NET_EVENT_WIFI_DPP_CONF_FAILED,
+ NET_EVENT_WIFI_DPP_SCAN_PEER_QR,
+ NET_EVENT_WIFI_DPP_NETWORK_ID,
+ NET_EVENT_WIFI_DPP_CONF_SENT,
+ NET_EVENT_WIFI_DPP_CONF_RECEIVED,
+ NET_EVENT_WIFI_DPP_FAILED,
+ NET_EVENT_WIFI_DPP_REMOVED,
+ NET_EVENT_WIFI_DPP_EVENT_IND, /* TODO: Make this in detail */
+} net_event_e;
+
+typedef struct {
+ net_event_e Event; /** CM Asynchronous event */
+ char ProfileName[NET_PROFILE_NAME_LEN_MAX+1]; /** Profile Identifier corresponding to the event */
+ net_err_e Error; /** Event Status */
+ int Datalength; /** Event data length */
+ void *Data; /** Event data: Depending on the event, Event Data will be
+ type-casted to the appropriate event info data structure */
+} net_event_info_s;
+
+typedef void (*net_event_cb)(const net_event_info_s *net_event, void *user_data);
+
+typedef enum {
+ NET_STATE_TYPE_UNKNOWN = 0x00, /** Not defined */
+ NET_STATE_TYPE_IDLE, /** Idle state */
+ NET_STATE_TYPE_FAILURE, /** Failure state */
+ NET_STATE_TYPE_ASSOCIATION, /** Association state */
+ NET_STATE_TYPE_CONFIGURATION, /** Configuration state */
+ NET_STATE_TYPE_READY, /** Ready state */
+ NET_STATE_TYPE_ONLINE, /** Online state */
+ NET_STATE_TYPE_DISCONNECT, /** Login state */
+} net_state_type_e;
+
+typedef enum {
+ WIFI_UNKNOWN = 0x00, /** Unknown state */
+ WIFI_OFF = 0x01, /** Wi-Fi is Off */
+ WIFI_ON = 0x02, /** Wi-Fi is On(idle/failure) */
+ WIFI_ASSOCIATION = 0x03, /** Trying association */
+ WIFI_CONFIGURATION = 0x04, /** Trying configuration */
+ WIFI_CONNECTED = 0x05, /** Wi-Fi is connected */
+ WIFI_DISCONNECTING = 0x06, /** Trying to disconnect */
+} net_wifi_state_e;
+
+typedef enum {
+ NETWORK_REQUEST_TYPE_SCAN = 0x00,
+ NETWORK_REQUEST_TYPE_OPEN_CONNECTION,
+ NETWORK_REQUEST_TYPE_CLOSE_CONNECTION,
+ NETWORK_REQUEST_TYPE_WIFI_POWER,
+ NETWORK_REQUEST_TYPE_ENROLL_WPS,
+ NETWORK_REQUEST_TYPE_SPECIFIC_SCAN,
+ NETWORK_REQUEST_TYPE_BSSID_SCAN,
+ NETWORK_REQUEST_TYPE_NETLINK_SCAN,
+ NETWORK_REQUEST_TYPE_IP_CONFLICT,
+ NETWORK_REQUEST_TYPE_MULTI_SCAN,
+ NETWORK_REQUEST_TYPE_SET_DEFAULT,
+ NETWORK_REQUEST_TYPE_RESET_DEFAULT,
+ NETWORK_REQUEST_TYPE_TDLS_DISCOVERY,
+ NETWORK_REQUEST_TYPE_FORGET_AP,
+ NETWORK_REQUEST_TYPE_MAX
+} network_async_request_type_e;
+
+typedef struct {
+ int flag;
+ char ProfileName[NET_PROFILE_NAME_LEN_MAX + 1];
+ char ssid[NET_WLAN_ESSID_LEN + 1];
+ GSList *multi_scan_list;
+ int multi_scan_type;
+} network_request_table_s;
+
+typedef struct {
+ GDBusConnection *connection;
+ GCancellable *cancellable;
+
+ guint subscribe_id_connman_state;
+ guint subscribe_id_connman_error;
+ guint subscribe_id_connman_scandone;
+ guint subscribe_id_connman_scanstarted;
+ guint subscribe_id_netconfig_wifi;
+ guint subscribe_id_netconfig;
+
+ char interface_name[NET_WLAN_IF_NAME_LEN];
+ char mac_address[WIFI_MAC_ADDR_LEN + 1];
+ net_state_type_e service_state;
+ net_wifi_state_e wifi_state;
+ gboolean scan_pending;
+ int net_service_error;
+ network_request_table_s request_table[NETWORK_REQUEST_TYPE_MAX];
+
+ void *wifi_handle;
+ net_event_cb event_callback;
+ void *user_data;
+} network_info_s;
+
+typedef struct {
+ char technology[NET_TECH_LENGTH_MAX];
+ char AvailableTechnology;
+ char EnabledTechnology;
+ char ConnectedTechnology;
+ char DefaultTechnology;
+ unsigned char Connected;
+ unsigned char Powered;
+} network_tech_state_info_s;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETWORK_INFO_H__ */
#define __NETWORK_INTERFACE_H__
#include <glib.h>
+
+#include "network_info.h"
#include "network_wlan.h"
#include "network_error.h"
} while (0)
typedef enum {
- NET_EVENT_OPEN_RSP,
- NET_EVENT_CLOSE_RSP,
- NET_EVENT_OPEN_IND,
- NET_EVENT_CLOSE_IND,
- NET_EVENT_NET_STATE_IND,
- NET_EVENT_WIFI_SCAN_RSP,
- NET_EVENT_WIFI_SCAN_IND,
- NET_EVENT_WIFI_SCAN_CHANGED,
- NET_EVENT_WIFI_MAC_ID_IND, /** This is deprecated Event and maintained only for compatibility */
- NET_EVENT_WIFI_POWER_RSP,
- NET_EVENT_WIFI_POWER_IND,
- NET_EVENT_WIFI_SPECIFIC_SCAN_RSP,
- NET_EVENT_WIFI_SPECIFIC_SCAN_IND,
- NET_EVENT_WIFI_MULTI_SCAN_RSP,
- NET_EVENT_WIFI_MULTI_SCAN_IND,
- NET_EVENT_WIFI_WPS_RSP,
- NET_EVENT_WIFI_SCANNING_IND,
- NET_EVENT_WIFI_BSSID_SCAN_IND,
- NET_EVENT_WIFI_NETLINK_SCAN_IND,
- NET_EVENT_WIFI_IP_CONFLICT_IND,
- NET_EVENT_WIFI_TDLS_DISCOVERED_IND,
- NET_EVENT_WIFI_TDLS_CONNECTED_IND,
- NET_EVENT_WIFI_TDLS_DISCONNECTED_IND,
- NET_EVENT_WIFI_FORGET_AP_IND,
- NET_EVENT_WIFI_DPP_URI_GENERATED,
- NET_EVENT_WIFI_DPP_BOOTSTRAPPED,
- NET_EVENT_WIFI_DPP_AWAITING,
- NET_EVENT_WIFI_DPP_AUTHENTICATING,
- NET_EVENT_WIFI_DPP_AUTH_SUCCESS,
- NET_EVENT_WIFI_DPP_AUTH_FAILED,
- NET_EVENT_WIFI_DPP_NOT_COMPATIBLE,
- NET_EVENT_WIFI_DPP_CONF_FAILED,
- NET_EVENT_WIFI_DPP_SCAN_PEER_QR,
- NET_EVENT_WIFI_DPP_NETWORK_ID,
- NET_EVENT_WIFI_DPP_CONF_SENT,
- NET_EVENT_WIFI_DPP_CONF_RECEIVED,
- NET_EVENT_WIFI_DPP_FAILED,
- NET_EVENT_WIFI_DPP_REMOVED,
- NET_EVENT_WIFI_DPP_EVENT_IND, /* TODO: Make this in detail */
-} net_event_e;
-
-typedef enum {
WIFI_TECH_UNKNOWN = 0x00,
WIFI_TECH_OFF = 0x01,
WIFI_TECH_WPS_ONLY = 0x02,
} wifi_tech_state_e;
typedef enum {
- WIFI_UNKNOWN = 0x00, /** Unknown state */
- WIFI_OFF = 0x01, /** Wi-Fi is Off */
- WIFI_ON = 0x02, /** Wi-Fi is On(idle/failure) */
- WIFI_ASSOCIATION = 0x03, /** Trying association */
- WIFI_CONFIGURATION = 0x04, /** Trying configuration */
- WIFI_CONNECTED = 0x05, /** Wi-Fi is connected */
- WIFI_DISCONNECTING = 0x06, /** Trying to disconnect */
-} net_wifi_state_e;
-
-typedef enum {
WIFI_BGSCAN_MODE_EXPONENTIAL = 0x00, /** scan cycle : 4, 8, 16, ...128s */
WIFI_BGSCAN_MODE_PERIODIC, /** scan cycle : 10s */
} net_wifi_background_scan_mode_e;
} net_wifi_security_type_e;
typedef enum {
- NET_STATE_TYPE_UNKNOWN = 0x00, /** Not defined */
- NET_STATE_TYPE_IDLE, /** Idle state */
- NET_STATE_TYPE_FAILURE, /** Failure state */
- NET_STATE_TYPE_ASSOCIATION, /** Association state */
- NET_STATE_TYPE_CONFIGURATION, /** Configuration state */
- NET_STATE_TYPE_READY, /** Ready state */
- NET_STATE_TYPE_ONLINE, /** Online state */
- NET_STATE_TYPE_DISCONNECT, /** Login state */
-} net_state_type_e;
-
-typedef enum {
NET_STATE_ERROR_NONE = 0x00,
NET_STATE_ERROR_OUT_OF_RANGE = 0x01,
NET_STATE_ERROR_PIN_MISSING = 0x02,
} net_profile_bssid_list_s;
typedef struct {
- char ProfileName[NET_PROFILE_NAME_LEN_MAX+1]; /** Profile name */
+ char ProfileName[NET_PROFILE_NAME_LEN_MAX + 1]; /** Profile name */
net_state_type_e ProfileState; /** Service state */
- char essid[NET_WLAN_ESSID_LEN+1]; /** ESSID */
- char bssid[WIFI_MAC_ADDR_LEN+1]; /** Basic service set identification */
+ char essid[NET_WLAN_ESSID_LEN + 1]; /** ESSID */
+ char bssid[WIFI_MAC_ADDR_LEN + 1]; /** Basic service set identification */
unsigned char Strength; /** Strength : between 0 and 100 */
unsigned int frequency; /** Frequency band(MHz) */
int max_rate; /** Maximum speed of the line(Mbps) */
net_error_state_type_e ProfileErrorState; /** Service error state */
char Favourite; /** Favourite flag */
int disconnect_reason; /** Supplicant Disconnect Reason Code */
- unsigned char raw_ssid[NET_WLAN_RAW_SSID_LEN+1];/** Raw SSID bytes */
+ unsigned char raw_ssid[NET_WLAN_RAW_SSID_LEN + 1]; /** Raw SSID bytes */
int raw_ssid_len; /** Raw SSID length */
GSList *vsie_list; /** List of Vendor Specific Information Element of AP*/
int assoc_status_code; /** Supplicant WiFi Association Status Code */
char country_code[NET_WLAN_COUNTRY_CODE_LEN]; /** Country code received from AP */
- char operation_mode[NET_MAX_PROTOCOL_LEN+1]; /** WI-FI Network Protocol Type (802.11a/b/g/n/ac/ax) */
+ char operation_mode[NET_MAX_PROTOCOL_LEN + 1]; /** WI-FI Network Protocol Type (802.11a/b/g/n/ac/ax) */
unsigned int connection_mode; /** Connection mode (IEEE 802.11b/g/n/a/ac) */
GSList *bssid_list; /** List if BSSID, strength and frequency of AP **/
gboolean ap_hidden_status; /** Hidden Status of connected AP */
+
+ network_info_s *network_info;
} net_profile_info_s;
typedef struct {
+ char name[NET_WLAN_IF_NAME_LEN];
+ net_wifi_state_e state;
+} net_wifi_interface_info_s;
+
+typedef struct {
net_wifi_wps_type_e type; /** PBC / PIN */
char pin[NET_WLAN_MAX_WPSPIN_LEN + 1]; /** Optional. This pin is needed when the user input PIN code */
} net_wifi_wps_info_s;
typedef struct {
char essid[NET_WLAN_ESSID_LEN + 1]; /** Basic feature */
unsigned char raw_ssid[NET_WLAN_RAW_SSID_LEN + 1]; /** Raw SSID bytes */
- int raw_ssid_len; /** Raw SSID length */
+ int raw_ssid_len; /** Raw SSID length */
wlan_connection_mode_type_e wlan_mode; /** Infrastructure / ad-hoc / auto mode */
wlan_security_info_s security_info; /** Security mode and authentication info */
gboolean is_hidden; /** Hidden network */
} net_netlink_scan_bss_info_s;
typedef struct {
- net_event_e Event; /** CM Asynchronous event */
- char ProfileName[NET_PROFILE_NAME_LEN_MAX+1]; /** Profile Identifier corresponding to the event */
- net_err_e Error; /** Event Status */
- int Datalength; /** Event data length */
- void * Data; /** Event data: Depending on the event, Event Data will be
- type-casted to the appropriate event info data structure */
-} net_event_info_s;
-
-typedef struct {
char powered; /** powered state */
char connected; /** connected state */
} net_tech_info_s;
} net_ip_info_config_s;
typedef struct {
+ char ifname[NET_WLAN_IF_NAME_LEN];
+ int rssi_level;
+} net_rssi_info_s;
+
+typedef struct {
+ char ifname[NET_WLAN_IF_NAME_LEN];
+ int status_uevent;
+} net_module_info_s;
+
+typedef struct {
guint32 peer_id;
guint32 own_id;
char own_uri[MAX_DPP_URI_LEN];
} net_dpp_event_info_s;
-typedef void (*net_event_cb)(const net_event_info_s* net_event, void* user_data);
-
-int net_register_client_ext(net_event_cb event_cb, void *user_data);
-int net_deregister_client_ext(void);
+int net_register_client_ext(network_info_s **network_info,
+ const char *interface_name, net_event_cb event_cb, void *user_data);
+void net_deregister_client_ext(network_info_s *network_info);
-gboolean net_check_ref_count(void);
-void net_set_cs_tid(int tid);
+void net_set_cs_tid(network_info_s *network_info, int tid);
void net_unset_cs_tid(int tid);
-int net_open_connection(const char *profile_name);
-int net_close_connection(const char *profile_name);
-
-int net_get_technology_properties(net_tech_info_s *tech_info);
-
-int net_get_profile_info(const char *profile_name, net_profile_info_s *prof_info);
-int net_get_profile_list(GSList **profile_list);
-
-int net_modify_profile(const char *profile_name, net_profile_info_s *prof_info);
-int net_delete_profile(const char *profile_name);
-int net_delete_profile_async(const char *profile_name);
-void net_forget_ap_finshed(net_err_e Error);
-
-int net_init_profile_info(net_profile_info_s *ProfInfo);
-int net_specific_scan_wifi(const char *ssid);
-int net_get_wps_generated_pin(char **wps_pin);
-int net_bssid_scan_wifi(int activated);
-int net_netlink_scan_wifi(GSList *nl_scan_list, const char *vsie);
-int net_wifi_get_passpoint(int *enable);
-int net_wifi_set_passpoint(int enable);
-int net_wifi_get_scan_state(int *scan_state);
-int net_multi_scan_wifi(GSList *specific_scan_list, gboolean multi_scan_type[]);
-int net_wifi_get_max_scan_ssids(int *max_scan_ssids);
-
-int net_wifi_add_vsie(unsigned int frame_id, const char *vsie_str);
-int net_wifi_get_vsie(unsigned int frame_id, char **vsie_str);
-int net_wifi_remove_vsie(unsigned int frame_id, const char *vsie_str);
-int net_wifi_flush_bss(void);
-int net_wifi_set_bssid(char *bssid);
-int net_wifi_get_auto_connect_mode(int *connect_mode);
-int net_wifi_set_auto_connect_mode(int connect_mode);
-int net_wifi_set_ap_auto_connect(const char *profile_name, gboolean autoconnect);
-int net_wifi_get_ap_auto_connect(const char *profile_name, gboolean *autoconnect);
-
-int net_wifi_cancel_wps(void);
-
-int net_open_connection_with_wifi_info(const net_wifi_connection_info_s *wifi_info);
-int net_scan_wifi(void);
-int net_wifi_power_on(gboolean wifi_picker_test);
-int net_wifi_power_off(void);
-int net_wifi_enroll_wps(const char *profile_name, net_wifi_wps_info_s *wps_info);
-int net_check_get_privilege(void);
-int net_check_profile_privilege(void);
-
-int net_wifi_enroll_wps_without_ssid(net_wifi_wps_info_s *wps_info);
-
-int net_wifi_tdls_disconnect(const char* peer_mac_addr);
-int net_wifi_tdls_connected_peer(char** peer_mac_addr);
-int net_wifi_tdls_connect(const char* peer_mac_addr);
-int net_wifi_tdls_discover(const char* peer_mac_addr);
-int net_wifi_tdls_enable_channel_switch(const char* peer_mac_addr, int freq);
-int net_wifi_tdls_disbale_channel_switch(const char* peer_mac_addr);
-
-int net_get_device_policy_wifi(void);
-int net_get_device_policy_wifi_profile(void);
-int net_wifi_set_autoscan(gboolean autoscan);
-int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_e scan_mode);
-int net_wifi_get_autoscan(gboolean *autoscan);
-int net_wifi_get_autoscanmode(unsigned int *autoscanmode);
-int net_foreach_ipv6_address(GSList **ipv6_address_list);
-int net_get_preferred_ipv6_address(const char *profilename, char **address);
+int net_open_connection(network_info_s *network_info, const char *profile_name);
+int net_close_connection(network_info_s *network_info, const char *profile_name);
+
+int net_get_technology_properties(network_info_s *network_info, net_tech_info_s *tech_info);
+
+int net_get_interface_list(network_info_s *network_info, GSList **interface_list);
+
+int net_get_profile_info(network_info_s *network_info,
+ const char *profile_name, net_profile_info_s *prof_info);
+int net_get_profile_list(network_info_s *network_info, GSList **profile_list);
+
+int net_modify_profile(network_info_s *network_info,
+ const char *profile_name, net_profile_info_s *prof_info);
+int net_delete_profile(network_info_s *network_info, const char *profile_name);
+int net_delete_profile_async(network_info_s *network_info, const char *profile_name);
+void net_forget_ap_finished(network_info_s *network_info, net_err_e Error);
+
+int net_init_profile_info(network_info_s *network_info, net_profile_info_s *ProfInfo);
+int net_specific_scan_wifi(network_info_s *network_info, const char *ssid);
+int net_get_wps_generated_pin(network_info_s *network_info, char **wps_pin);
+int net_bssid_scan_wifi(network_info_s *network_info, int activated);
+int net_netlink_scan_wifi(network_info_s *network_info,
+ GSList *nl_scan_list, const char *vsie);
+int net_wifi_get_passpoint(network_info_s *network_info, int *enable);
+int net_wifi_set_passpoint(network_info_s *network_info, int enable);
+int net_wifi_get_scan_state(network_info_s *network_info, int *scan_state);
+int net_multi_scan_wifi(network_info_s *network_info,
+ GSList *specific_scan_list, gboolean multi_scan_type[]);
+int net_wifi_get_max_scan_ssids(network_info_s *network_info, int *max_scan_ssids);
+
+int net_wifi_add_vsie(network_info_s *network_info, unsigned int frame_id, const char *vsie_str);
+int net_wifi_get_vsie(network_info_s *network_info, unsigned int frame_id, char **vsie_str);
+int net_wifi_remove_vsie(network_info_s *network_info, unsigned int frame_id, const char *vsie_str);
+int net_wifi_flush_bss(network_info_s *network_info);
+int net_wifi_set_bssid(network_info_s *network_info, char *bssid);
+int net_wifi_get_auto_connect_mode(network_info_s *network_info, int *connect_mode);
+int net_wifi_set_auto_connect_mode(network_info_s *network_info, int connect_mode);
+int net_wifi_set_ap_auto_connect(network_info_s *network_info,
+ const char *profile_name, gboolean autoconnect);
+int net_wifi_get_ap_auto_connect(network_info_s *network_info,
+ const char *profile_name, gboolean *autoconnect);
+
+int net_wifi_cancel_wps(network_info_s *network_info);
+
+int net_open_connection_with_wifi_info(network_info_s *network_info,
+ const net_wifi_connection_info_s *wifi_info);
+int net_scan_wifi(network_info_s *network_info);
+int net_wifi_power_on(network_info_s *network_info, gboolean wifi_picker_test);
+int net_wifi_power_off(network_info_s *network_info);
+int net_wifi_enroll_wps(network_info_s *network_info,
+ const char *profile_name, net_wifi_wps_info_s *wps_info);
+int net_check_get_privilege(network_info_s *network_info);
+int net_check_profile_privilege(network_info_s *network_info);
+
+int net_wifi_enroll_wps_without_ssid(network_info_s *network_info,
+ net_wifi_wps_info_s *wps_info);
+
+int net_wifi_tdls_disconnect(network_info_s *network_info, const char* peer_mac_addr);
+int net_wifi_tdls_connected_peer(network_info_s *network_info, char** peer_mac_addr);
+int net_wifi_tdls_connect(network_info_s *network_info, const char* peer_mac_addr);
+int net_wifi_tdls_discover(network_info_s *network_info, const char* peer_mac_addr);
+int net_wifi_tdls_enable_channel_switch(network_info_s *network_info,
+ const char* peer_mac_addr, int freq);
+int net_wifi_tdls_disbale_channel_switch(network_info_s *network_info,
+ const char* peer_mac_addr);
+
+int net_get_device_policy_wifi(network_info_s *network_info);
+int net_get_device_policy_wifi_profile(network_info_s *network_info);
+int net_wifi_set_autoscan(network_info_s *network_info, gboolean autoscan);
+int net_wifi_set_background_scan_mode(network_info_s *network_info,
+ net_wifi_background_scan_mode_e scan_mode);
+int net_wifi_get_autoscan(network_info_s *network_info, gboolean *autoscan);
+int net_wifi_get_autoscanmode(network_info_s *network_info, unsigned int *autoscanmode);
+int net_wifi_get_module_state(network_info_s *network_info, int *module_state);
-int net_config_get_id_list(GSList **list);
-int net_config_set_field(const gchar *config_id, const gchar *key, const gchar *value);
-int net_config_get_passphrase(const gchar *config_id, gchar **passphrase);
-int net_config_save_configurations(const gchar *config_id,
- const gchar *name, const gchar *ssid, const gchar *passphrase,
+int net_foreach_ipv6_address(GSList **ipv6_address_list);
+int net_get_preferred_ipv6_address(network_info_s *network_info,
+ const char *profilename, char **address);
+
+int net_config_get_id_list(network_info_s *network_info, GSList **list);
+int net_config_set_field(network_info_s *network_info,
+ const gchar *config_id, const gchar *key, const gchar *value);
+int net_config_get_passphrase(network_info_s *network_info,
+ const gchar *config_id, gchar **passphrase);
+int net_config_save_configurations(network_info_s *network_info,
+ const gchar *config_id, const gchar *name, const gchar *ssid, const gchar *passphrase,
const gchar *proxy_address, net_ip_info_config_s *ip_info,
gboolean is_hidden, gboolean is_created);
-int net_config_save_eap_configurations(const gchar *config_id,
- const gchar *name, const gchar *ssid, const gchar *passphrase,
+int net_config_save_eap_configurations(network_info_s *network_info,
+ const gchar *config_id, const gchar *name, const gchar *ssid, const gchar *passphrase,
const gchar *proxy_address, void *eap_config, gboolean is_hidden, gboolean is_created);
-int net_config_remove_configurations(const gchar *config_id);
-int net_config_load_configurations(const gchar *config_id, gchar **name,
+int net_config_remove_configurations(network_info_s *network_info,
+ const gchar *config_id);
+int net_config_load_configurations(network_info_s *network_info,
+ const gchar *config_id, gchar **name,
gchar **passphrase, void *security_type, gchar **proxy_address, gboolean *is_hidden,
net_ip_info_config_s **ip_info, void *last_error);
-int net_config_load_eap_configurations(const gchar *config_id,
- gchar **name, void *security_type, gchar **proxy_address,
+int net_config_load_eap_configurations(network_info_s *network_info,
+ const gchar *config_id, gchar **name, void *security_type, gchar **proxy_address,
gboolean *is_hidden, void **eap_config, void *last_error);
-int net_set_ip_conflict_detect_mode(gboolean detect);
-int net_ip_conflict_detect_is_enabled(gboolean *state);
-int net_wifi_set_ip_conflict_period(unsigned int initial_time);
-int net_wifi_get_ip_conflict_state(unsigned int *state);
-int net_wifi_get_ip_conflict_period(unsigned int* initial_time);
-wifi_tech_state_e wifi_state_get_technology_state(void);
-int net_get_service_state();
-int net_wifi_get_5ghz_support(gboolean *supported);
-
-int net_dpp_enter_peer_uri(guint32 peer_id, guint32 own_id, const char *uri);
-int net_dpp_generate_own_uri(guint32 peer_id, guint32 own_id, gboolean is_initiator, const char *key);
-int net_dpp_start(void *dpp_data, const char *auth_key,
+int net_set_ip_conflict_detect_mode(network_info_s *network_info, gboolean detect);
+int net_ip_conflict_detect_is_enabled(network_info_s *network_info, gboolean *state);
+int net_wifi_set_ip_conflict_period(network_info_s *network_info,
+ unsigned int initial_time);
+int net_wifi_get_ip_conflict_state(network_info_s *network_info, unsigned int *state);
+int net_wifi_get_ip_conflict_period(network_info_s *network_info,
+ unsigned int* initial_time);
+wifi_tech_state_e net_get_technology_state(network_info_s *network_info);
+int net_get_service_state(network_info_s *network_info);
+int net_wifi_get_5ghz_support(network_info_s *network_info, gboolean *supported);
+
+int net_dpp_enter_peer_uri(network_info_s *network_info,
+ guint32 peer_id, guint32 own_id, const char *uri);
+int net_dpp_generate_own_uri(network_info_s *network_info,
+ guint32 peer_id, guint32 own_id, gboolean is_initiator, const char *key);
+int net_dpp_start(void *dpp_handle, const char *auth_key,
const char *configurator_key, const char *pass);
-int net_dpp_stop(guint32 peer_id, guint32 own_id, gboolean is_initiator);
+int net_dpp_stop(network_info_s *network_info,
+ guint32 peer_id, guint32 own_id, gboolean is_initiator);
/**
* \}
*/
#include <gio/gio.h>
#include <glib-object.h>
+#include "network_info.h"
#include "network_interface.h"
#ifdef __cplusplus
/** Maximum Profile Count */
#define NET_PROFILE_LIST_MAX 512
-#define NET_TECH_LENGTH_MAX 64
-
#define CONNMAN_MAX_BUFLEN 512
#define CONNMAN_STATE_STRLEN 16
#define CONNMAN_MANAGER_PATH "/"
#define CONNMAN_PATH "/net/connman"
#define CONNMAN_TECHNOLOGY_PATH "/net/connman/technology"
+#define CONNMAN_WIFI_TECHNOLOGY_PATH "/net/connman/technology/wifi"
#define NETCONFIG_SERVICE "net.netconfig"
#define NETCONFIG_NETWORK_INTERFACE NETCONFIG_SERVICE ".network"
#define NETCONFIG_SIGNAL_WIFI_CONNECT_FAIL "WiFiConnectFail"
#define NETCONFIG_SIGNAL_WPS_FAIL_EVENT "WpsFailEvent"
#define NETCONFIG_SIGNAL_IP_CONFLICT_EVENT "IpConflictEvent"
+#define NETCONFIG_SIGNAL_RSSI_CHANGED "RssiChanged"
+#define NETCONFIG_SIGNAL_RSSI_LEVEL_CHANGED "RssiLevelChanged"
+#define NETCONFIG_SIGNAL_MODULE_STATE_CHANGED "ModuleStateChanged"
+
#define NETCONFIG_SIGNAL_DPP_URI_GENERATED "DppUriGenerated"
#define NETCONFIG_SIGNAL_DPP_BOOTSTRAPPED "DppBootstrapped"
#define NETCONFIG_SIGNAL_DPP_AWAITING "DppAwaiting"
#define __NETWORK_CAPI_FUNC_EXIT__ WIFI_LOG(WIFI_INFO, "Quit");
typedef enum {
- NETWORK_REQUEST_TYPE_SCAN = 0x00,
- NETWORK_REQUEST_TYPE_OPEN_CONNECTION,
- NETWORK_REQUEST_TYPE_CLOSE_CONNECTION,
- NETWORK_REQUEST_TYPE_WIFI_POWER,
- NETWORK_REQUEST_TYPE_ENROLL_WPS,
- NETWORK_REQUEST_TYPE_SPECIFIC_SCAN,
- NETWORK_REQUEST_TYPE_BSSID_SCAN,
- NETWORK_REQUEST_TYPE_NETLINK_SCAN,
- NETWORK_REQUEST_TYPE_IP_CONFLICT,
- NETWORK_REQUEST_TYPE_MULTI_SCAN,
- NETWORK_REQUEST_TYPE_SET_DEFAULT,
- NETWORK_REQUEST_TYPE_RESET_DEFAULT,
- NETWORK_REQUEST_TYPE_TDLS_DISCOVERY,
- NETWORK_REQUEST_TYPE_FORGET_AP,
- NETWORK_REQUEST_TYPE_MAX
-} network_async_request_type_e;
-
-typedef enum {
NETWORK_SCAN_TYPE_FULL_CHANNEL = 0x00,
NETWORK_SCAN_TYPE_SPECIFIC_SCAN,
NETWORK_SCAN_TYPE_MULTI_SCAN,
NETWORK_SCAN_TYPE_BSSID_SCAN,
} network_scan_type_e;
-typedef struct {
- int flag;
- char ProfileName[NET_PROFILE_NAME_LEN_MAX+1];
- char ssid[NET_WLAN_ESSID_LEN+1];
- GSList *multi_scan_list;
- int multi_scan_type;
-} network_request_table_s;
-
-typedef struct {
- net_wifi_state_e wifi_state;
- net_event_cb ClientEventCb_wifi;
- void* user_data_wifi;
- int ref_count;
- guint handler_id;
-} network_info_s;
-
-typedef struct {
- char technology[NET_TECH_LENGTH_MAX];
- char AvailableTechnology;
- char EnabledTechnology;
- char ConnectedTechnology;
- char DefaultTechnology;
- unsigned char Connected;
- unsigned char Powered;
-} network_tech_state_info_s;
-
-int _net_get_tech_state(GVariant *iter, network_tech_state_info_s* tech_state);
+int _net_get_tech_state(network_info_s *network_info,
+ GVariant *iter, network_tech_state_info_s* tech_state);
char* _net_print_error(net_err_e error);
-int _net_open_connection_with_wifi_info(const net_wifi_connection_info_s* wifi_info);
+int _net_open_connection_with_wifi_info(network_info_s *network_info,
+ const net_wifi_connection_info_s* wifi_info);
int _net_check_profile_name(const char* ProfileName);
-int _net_get_profile_list(GSList **profile_list);
-void _net_client_callback(net_event_info_s *event_data);
-net_wifi_state_e _net_get_wifi_state(net_err_e *net_error);
-void _net_clear_request_table(void);
-
-guint _net_client_callback_add(GSourceFunc func, gpointer user_data);
-void _net_client_callback_cleanup(void);
-
-gboolean _net_dbus_is_pending_call_used(void);
-void _net_dbus_pending_call_ref(void);
-void _net_dbus_pending_call_unref(void);
-int _net_dbus_create_gdbus_call(void);
-int _net_dbus_close_gdbus_call(void);
-GDBusConnection *_net_dbus_get_gdbus_conn(void);
-GCancellable *_net_dbus_get_gdbus_cancellable(void);
+gboolean _net_check_service_mac_addr(network_info_s *network_info, const char* service);
+int _net_get_interface_list(network_info_s *network_info, GSList **interface_list);
+int _net_get_profile_list(network_info_s *network_info, GSList **profile_list);
+net_err_e _net_get_wifi_state(network_info_s *network_info);
+void _net_clear_request_table(network_info_s *network_info);
+
+int _net_dbus_create_gdbus_call(network_info_s *network_info);
+void _net_dbus_close_gdbus_call(network_info_s *network_info);
#ifdef __cplusplus
}
extern "C" {
#endif
-#define CONNMAN_WIFI_SERVICE_PROFILE_PREFIX \
- CONNMAN_PATH "/service/wifi_"
+#define CONNMAN_WIFI_SERVICE_PROFILE_PREFIX CONNMAN_PATH "/service/wifi_"
-int _net_deregister_signal(void);
-int _net_register_signal(void);
-int _net_init_service_state(void);
+int _net_register_signal(network_info_s *network_info);
+void _net_deregister_signal(network_info_s *network_info);
-void _net_set_cs_tid(int tid);
+int _net_init_service_state(network_info_s *network_info);
+
+void _net_set_cs_tid(network_info_s *network_info, int tid);
void _net_unset_cs_tid(int tid);
-net_state_type_e _net_get_service_state();
#ifdef __cplusplus
}
extern "C" {
#endif /* __cplusplus */
+/** Length of interface name */
+#define NET_WLAN_IF_NAME_LEN 32
+
/** Length of raw SSID */
#define NET_WLAN_RAW_SSID_LEN 32
*/
/**
+ * @brief Called for each found available interface.
+ * @since_tizen 6.0
+ * @param[in] ifname The interface name
+ * @param[in] user_data The user data passed from the request function
+ * @return @c true to continue with the next iteration of the loop, \n
+ * otherwise @c false to break out of the loop
+ * @pre wifi_manager_foreach_available_interface() will invoke this callback.
+ * @see wifi_manager_foreach_available_interface()
+ */
+typedef bool(*wifi_manager_interface_cb)(char *ifname, void *user_data);
+
+/**
+ * @brief Initializes Wi-Fi with interface name.
+ * @since_tizen 6.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @remarks You must release @a wifi using wifi_manager_deinitialize().
+ * @param[out] wifi The Wi-Fi handle
+ * @param[in] ifname The interface name
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_ALREADY_INITIALIZED Already initialized
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_initialize_with_interface_name(wifi_manager_h *wifi,
+ const char *ifname);
+
+/**
+ * @brief Gets a list of available interfaces.
+ * @since_tizen 6.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @param[in] wifi The Wi-Fi handle
+ * @param[in] callback The callback to be called
+ * @param[in] user_data The user data passed to the callback function
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @post This function invokes wifi_manager_found_ap_cb().
+ */
+int wifi_manager_foreach_available_interface(wifi_manager_h wifi,
+ wifi_manager_interface_cb callback, void *user_data);
+
+/**
+ * @brief Gets the result of the scan in all interfaces.
+ * @since_tizen 6.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @param[in] wifi The Wi-Fi handle
+ * @param[in] callback The callback to be called
+ * @param[in] user_data The user data passed to the callback function
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @post This function invokes wifi_manager_found_ap_cb().
+ */
+int wifi_manager_foreach_found_ap_in_all_interfaces(wifi_manager_h wifi,
+ wifi_manager_found_ap_cb callback, void *user_data);
+
+/**
+ * @brief Gets configurations of an access point in all interfaces.
+ * @since_tizen 6.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile
+ *
+ * @param[in] wifi The Wi-Fi handle
+ * @param[in] callback The callback to be called
+ * @param[in] user_data The user data passed to the callback function
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @pre This function needs wifi_manager_initialize() before use.
+ * @post This function invokes wifi_manager_config_list_cb().
+ */
+int wifi_manager_config_foreach_configuration_in_all_interfaces(wifi_manager_h wifi,
+ wifi_manager_config_list_cb callback, void *user_data);
+
+/**
* @brief Enables or disables auto-scanning
* @details If auto-scanning is disabled, then background scan and wps scan don't work.
* By default, the auto-scanning is enabled automatically until disabling auto-scanning.
* @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
* @post This function invokes wifi_manager_netlink_scan_finished_cb().
*/
-int wifi_manager_netlink_scan(wifi_manager_h wifi, wifi_manager_netlink_scan_h netlink_scan,
+int wifi_manager_netlink_scan(wifi_manager_h wifi,
+ wifi_manager_netlink_scan_h netlink_scan,
wifi_manager_netlink_scan_finished_cb callback, void *user_data);
/**
#include "wifi-manager.h"
#include "wifi-manager-extension.h"
+
+#include "network_info.h"
+#include "network_internal.h"
#include "network_interface.h"
#ifdef __cplusplus
}\
} while(0)
-typedef enum {
- WIFI_DEVICE_STATE_CB,
- WIFI_BG_SCAN_CB,
- WIFI_SCAN_REQUEST_CB,
- WIFI_SCAN_CHANGED_CB,
- WIFI_SPECIFIC_SCAN_CB,
- WIFI_BSSID_SCAN_CB,
- WIFI_NETLINK_SCAN_CB,
- WIFI_IP_CONFLICT_CB,
- WIFI_MULTI_SCAN_CB,
- WIFI_MANAGER_CONNECTION_STATE_CB,
- WIFI_ACTIVATED_CB,
- WIFI_DEACTIVATED_CB,
- WIFI_CONNECTED_CB,
- WIFI_DISCONNECTED_CB,
- WIFI_MANAGER_RSSI_LEVEL_CHANGED_CB,
- WIFI_MANAGER_TDLS_STATE_CHANGED_CB,
- WIFI_MANAGER_TDLS_DISCOVERED_CB,
- WIFI_MANAGER_FORGET_AP_CB,
- WIFI_MANAGER_DPP_EVENT_CB,
-} wifi_manager_handle_cb_e;
-
typedef void *wifi_manager_dpp_h;
typedef enum {
} wifi_config_ip_info_s;
typedef struct {
- gchar *name;
- gchar *passphrase;
- wifi_manager_security_type_e security_type;
- gboolean is_created;
- gboolean is_saved;
-
- gboolean is_hidden;
- gchar *proxy_address;
- wifi_manager_address_family_e address_family;
- wifi_eap_config_s *eap_config;
- wifi_config_ip_info_s *ip_info;
- wifi_manager_error_e last_error;
-} wifi_config_s;
-
-typedef struct {
- gchar *group_id;
- gchar *ssid;
- gchar *peer_uri;
- guint32 peer_id;
- gchar *own_uri;
- guint32 own_id;
- gboolean is_initiator;
- wifi_manager_dpp_role_e role;
- wifi_manager_dpp_network_role_e net_role;
- wifi_manager_dpp_akm_e akm;
- wifi_manager_dpp_state_e state;
-} wifi_dpp_s;
-
-typedef struct {
wifi_manager_device_state_changed_cb device_state_cb;
void *device_state_user_data;
wifi_manager_scan_finished_cb bg_scan_cb;
void *scan_request_user_data;
wifi_manager_scan_state_changed_cb scan_changed_cb;
void *scan_changed_user_data;
+ char specific_scan_essid[NET_WLAN_ESSID_LEN + 1];
wifi_manager_scan_finished_cb specific_scan_cb;
void *specific_scan_user_data;
wifi_manager_bssid_scan_finished_cb bssid_scan_cb;
wifi_manager_dpp_event_cb dpp_event_cb;
void *dpp_event_user_data;
+ network_info_s *network_info;
+ char interface_name[NET_WLAN_IF_NAME_LEN];
+ bool is_disconnect_wps_pbc;
+ bool is_disconnect_wps_pin;
+
+ GSList *ap_handle_list;
+ GSList *config_handle_list;
+
+ GSList *interface_iterator;
+ GSList *profile_iterator;
+ GSList *specific_profile_iterator;
+ GSList *bss_profile_iterator;
+ GSList *config_iterator;
} wifi_manager_handle_s;
+typedef struct {
+ gchar *name;
+ gchar *passphrase;
+ wifi_manager_security_type_e security_type;
+ gboolean is_created;
+ gboolean is_saved;
+
+ gboolean is_hidden;
+ gchar *proxy_address;
+ wifi_manager_address_family_e address_family;
+ wifi_eap_config_s *eap_config;
+ wifi_config_ip_info_s *ip_info;
+ wifi_manager_error_e last_error;
+
+ wifi_manager_handle_s *wifi_handle;
+} wifi_config_s;
+
+typedef struct {
+ gchar *group_id;
+ gchar *ssid;
+ gchar *peer_uri;
+ guint32 peer_id;
+ gchar *own_uri;
+ guint32 own_id;
+ gboolean is_initiator;
+ wifi_manager_dpp_role_e role;
+ wifi_manager_dpp_network_role_e net_role;
+ wifi_manager_dpp_akm_e akm;
+ wifi_manager_dpp_state_e state;
+
+ network_info_s *network_info;
+} wifi_dpp_s;
typedef struct {
int type;
} wifi_netlink_scan_s;
/* WIFI Manager */
-int _wifi_init(void);
-bool _wifi_deinit(void);
-void _wifi_set_cs_tid(int tid);
+int _wifi_init(wifi_manager_h wifi, const char *ifname);
+void _wifi_deinit(wifi_manager_h wifi);
+void _wifi_set_cs_tid(wifi_manager_h wifi, int tid);
void _wifi_unset_cs_tid(int tid);
int _wifi_create_handle(wifi_manager_h *wifi);
-int _wifi_add_to_handle_list(wifi_manager_h* wifi);
+void _wifi_add_to_handle_list(wifi_manager_h *wifi);
void _wifi_remove_from_handle_list(wifi_manager_h wifi);
+int _wifi_length_from_handle_list(void);
bool _wifi_find_from_handle_list(wifi_manager_h wifi);
-int _wifi_get_count_from_handle_list(void);
-int _wifi_get_callback_count_from_handle_list(wifi_manager_handle_cb_e e);
+void _wifi_clear_profile_list(void);
int _wifi_activate(wifi_manager_h wifi, wifi_manager_activated_cb callback,
gboolean wifi_picker_test, void *user_data);
int _wifi_deactivate(wifi_manager_h wifi, wifi_manager_deactivated_cb callback, void *user_data);
-bool _wifi_check_ap_validity(wifi_manager_ap_h ap_h);
-void _wifi_add_to_ap_list(wifi_manager_ap_h ap_h);
-void _wifi_remove_from_ap_list(wifi_manager_ap_h ap_h);
+bool _wifi_check_ap_validity(net_profile_info_s *ap_info);
+void _wifi_add_to_ap_list(net_profile_info_s *ap_info);
+void _wifi_remove_from_ap_list(net_profile_info_s *ap_info);
bool _wifi_check_profile_name_validity(const char *profile_name);
bool _wifi_check_essid_validity(const char *essid);
-int _wifi_get_wifi_device_state(wifi_manager_device_state_e *device_state);
-int _wifi_get_wifi_state(wifi_manager_connection_state_e* connection_state);
-int _wifi_get_intf_name(char** name);
+int _wifi_get_mac_address(wifi_manager_h wifi, char **mac_address);
+int _wifi_get_wifi_device_state(wifi_manager_h wifi, wifi_manager_device_state_e *device_state);
+int _wifi_get_wifi_state(wifi_manager_h wifi, wifi_manager_connection_state_e *connection_state);
+void _wifi_get_intf_name(wifi_manager_h wifi, char **name);
int _wifi_scan_request(wifi_manager_h wifi,
wifi_manager_scan_finished_cb callback, void *user_data);
int _wifi_scan_specific_ap(wifi_manager_h wifi, const char *essid,
wifi_manager_scan_finished_cb callback, void *user_data);
-int _wifi_get_scan_state(wifi_manager_scan_state_e *scan_state);
+int _wifi_get_scan_state(wifi_manager_h wifi, wifi_manager_scan_state_e *scan_state);
int _wifi_get_hidden_aps(wifi_manager_h wifi, const char* essid,
wifi_manager_security_type_e sec_type, const char *passphrase,
wifi_manager_connected_cb callback, void* user_data);
-int _wifi_get_connected_profile(wifi_manager_ap_h *ap);
-int _wifi_foreach_found_ap(wifi_manager_found_ap_cb callback, void *user_data);
-int _wifi_foreach_found_specific_ap(wifi_manager_found_ap_cb callback, void *user_data);
-int _wifi_foreach_found_bssid_ap(wifi_manager_found_ap_cb callback, void *user_data);
-int _wifi_foreach_found_netlink_scan_ap(wifi_manager_found_ap_cb callback, void *user_data);
+int _wifi_get_connected_profile(wifi_manager_h wifi, wifi_manager_ap_h *ap);
+
+int _wifi_foreach_available_interface(wifi_manager_h wifi,
+ wifi_manager_interface_cb callback, void *user_data);
+int _wifi_foreach_found_ap(wifi_manager_h wifi,
+ wifi_manager_found_ap_cb callback, void *user_data);
+int _wifi_foreach_found_ap_in_all_interfaces(wifi_manager_h wifi,
+ wifi_manager_found_ap_cb callback, void *user_data);
+int _wifi_foreach_found_specific_ap(wifi_manager_h wifi,
+ wifi_manager_found_ap_cb callback, void *user_data);
+int _wifi_foreach_found_bssid_ap(wifi_manager_h wifi,
+ wifi_manager_found_ap_cb callback, void *user_data);
+int _wifi_foreach_found_netlink_scan_ap(wifi_manager_h wifi,
+ wifi_manager_found_ap_cb callback, void *user_data);
int _wifi_open_profile(wifi_manager_h wifi, wifi_manager_ap_h ap_h,
wifi_manager_connected_cb callback, void *user_data);
wifi_manager_connected_cb callback, void *user_data);
int _wifi_connect_with_wps_pin(wifi_manager_h wifi, wifi_manager_ap_h ap,
const char *pin, wifi_manager_connected_cb callback, void *user_data);
-int _wifi_forget_ap(wifi_manager_ap_h ap);
+int _wifi_forget_ap(wifi_manager_h wifi, wifi_manager_ap_h ap);
int _wifi_forget_ap_async(wifi_manager_h wifi, wifi_manager_ap_h ap,
- wifi_manager_forget_ap_finished_cb callback,
- void* user_data);
+ wifi_manager_forget_ap_finished_cb callback, void* user_data);
int __ap_convert_netmask_to_prefix_len(const char *netmask);
-void _wifi_rssi_level_changed_cb(keynode_t *node, void *user_data);
-
-int _wifi_update_ap_info(net_profile_info_s *ap_info);
+int _wifi_update_ap_info(wifi_manager_h wifi, net_profile_info_s *ap_info);
wifi_manager_connection_state_e _wifi_convert_to_ap_state(net_state_type_e state);
int _wifi_connect_with_wps_pbc_without_ssid(wifi_manager_h wifi,
wifi_manager_connected_cb callback, void *user_data);
int _wifi_connect_with_wps_pin_without_ssid(wifi_manager_h wifi,
const char *pin, wifi_manager_connected_cb callback, void* user_data);
-int _wifi_cancel_wps(void);
+int _wifi_cancel_wps(wifi_manager_h wifi);
int _wifi_bssid_scan_request(wifi_manager_h wifi,
wifi_manager_bssid_scan_finished_cb callback, void *user_data);
int _wifi_start_multi_scan(wifi_manager_h wifi,
wifi_manager_specific_scan_h specific_scan,
wifi_manager_scan_finished_cb callback, void *user_data);
-int _wifi_get_max_scan_ssids(int *max_scan_ssids);
+int _wifi_get_max_scan_ssids(wifi_manager_h wifi, int *max_scan_ssids);
/* WIFI Configuration */
-bool _wifi_check_config_validity(wifi_manager_config_h config_h);
-void _wifi_add_to_config_list(wifi_manager_config_h config_h);
-void _wifi_remove_from_config_list(wifi_manager_config_h config_h);
+bool _wifi_check_config_validity(wifi_config_s *config);
+void _wifi_add_to_config_list(wifi_config_s *config);
+void _wifi_remove_from_config_list(wifi_config_s *config);
gchar * _wifi_config_get_config_id(const gchar *name, wifi_manager_security_type_e security_type);
-int _wifi_config_get_config_id_list(GSList **list);
+int _wifi_config_get_config_id_list(wifi_manager_h wifi, GSList **list);
-int _wifi_save_configuration(const gchar *name, const gchar *passphrase,
+int _wifi_save_configuration(wifi_manager_h wifi,
+ const gchar *name, const gchar *passphrase,
wifi_manager_security_type_e security_type, const gchar *proxy_address,
wifi_config_ip_info_s *ip_info, gboolean is_hidden, gboolean is_created);
-int _wifi_load_configurations(void);
-int _wifi_foreach_configuration(wifi_manager_config_list_cb callback, void *user_data);
-int _wifi_remove_configuration(const gchar *config_id);
-int _wifi_configuration_set_field(const gchar *config_id, const gchar *key, const gchar *value);
-int _wifi_configuration_get_passphrase(const gchar *config_id, gchar **passphrase);
-int _wifi_save_eap_configurations(const gchar *name, const gchar *passphrase,
+int _wifi_load_configurations(wifi_manager_h wifi);
+int _wifi_foreach_configuration(wifi_manager_h wifi,
+ wifi_manager_config_list_cb callback, void *user_data);
+int _wifi_remove_configuration(wifi_manager_h wifi, const gchar *config_id);
+int _wifi_configuration_set_field(wifi_manager_h wifi, const gchar *config_id, const gchar *key, const gchar *value);
+int _wifi_configuration_get_passphrase(wifi_manager_h wifi, const gchar *config_id, gchar **passphrase);
+int _wifi_save_eap_configurations(wifi_manager_h wifi,
+ const gchar *name, const gchar *passphrase,
wifi_manager_security_type_e security_type, const gchar *proxy_address,
wifi_eap_config_s *eap_config, gboolean is_hidden, gboolean is_created);
gchar *_wifi_eap_type_to_string(wifi_manager_eap_type_e eap_type);
gchar *_wifi_eap_auth_type_to_string(wifi_manager_eap_auth_type_e eap_auth_type);
-int _wifi_set_autoscan(bool autoscan);
-int _wifi_set_background_scan_mode(wifi_manager_autoscan_mode_e mode);
-int _wifi_get_autoscan(bool *autoscan);
-int _wifi_get_autoscanmode(wifi_manager_autoscan_mode_e *autoscanmode);
-int _wifi_get_passpoint(int *passpoint);
-int _wifi_set_passpoint(int passpoint);
-int _wifi_get_module_state(wifi_manager_module_state_e *state);
-void _wifi_module_state_changed_cb(keynode_t *node, void *user_data);
-
-int _wifi_add_vsie(wifi_manager_h wifi,
- wifi_manager_vsie_frames_e frame_id, const char *vsie_str);
-int _wifi_get_vsie(wifi_manager_h wifi,
- wifi_manager_vsie_frames_e frame_id, char **vsie_str);
-int _wifi_remove_vsie(wifi_manager_h wifi,
- wifi_manager_vsie_frames_e frame_id, const char *vsie_str);
-
-int _wifi_flush_bss(void);
-int _wifi_set_bssid(char *bssid);
-int _wifi_get_auto_connect(int *connect_mode);
-int _wifi_set_auto_connect(int connect_mode);
+int _wifi_set_autoscan(wifi_manager_h wifi, bool autoscan);
+int _wifi_set_background_scan_mode(wifi_manager_h wifi,
+ wifi_manager_autoscan_mode_e mode);
+int _wifi_get_autoscan(wifi_manager_h wifi, bool *autoscan);
+int _wifi_get_autoscanmode(wifi_manager_h wifi, wifi_manager_autoscan_mode_e *autoscanmode);
+int _wifi_get_passpoint(wifi_manager_h wifi, int *passpoint);
+int _wifi_set_passpoint(wifi_manager_h wifi, int passpoint);
+int _wifi_get_module_state(wifi_manager_h wifi, wifi_manager_module_state_e *state);
+
+int _wifi_add_vsie(wifi_manager_h wifi, wifi_manager_vsie_frames_e frame_id, const char *vsie_str);
+int _wifi_get_vsie(wifi_manager_h wifi, wifi_manager_vsie_frames_e frame_id, char **vsie_str);
+int _wifi_remove_vsie(wifi_manager_h wifi, wifi_manager_vsie_frames_e frame_id, const char *vsie_str);
+
+int _wifi_flush_bss(wifi_manager_h wifi);
+int _wifi_set_bssid(wifi_manager_h wifi, char *bssid);
+int _wifi_get_auto_connect(wifi_manager_h wifi, int *connect_mode);
+int _wifi_set_auto_connect(wifi_manager_h wifi, int connect_mode);
int _wifi_set_ap_auto_connect(wifi_manager_ap_h ap_h, bool autoconnect);
int _wifi_get_ap_auto_connect(wifi_manager_ap_h ap_h, bool *autoconnect);
-int _wifi_ip_conflict_detect_enable_set(bool detect);
-int _wifi_ip_conflict_detect_is_enabled(bool *state);
-int _wifi_set_ip_conflict_period(unsigned int initial_time);
-int _wifi_get_ip_conflict_state(wifi_manager_ip_conflict_state_e *state);
-int _wifi_get_ip_conflict_period(unsigned int* initial_time);
-int _wifi_get_wps_generated_pin(char **wps_pin);
-int _wifi_get_connection_mode(wifi_manager_connection_mode_e *mode);
+int _wifi_ip_conflict_detect_enable_set(wifi_manager_h wifi, bool detect);
+int _wifi_ip_conflict_detect_is_enabled(wifi_manager_h wifi, bool *state);
+int _wifi_set_ip_conflict_period(wifi_manager_h wifi, unsigned int initial_time);
+int _wifi_get_ip_conflict_state(wifi_manager_h wifi, wifi_manager_ip_conflict_state_e *state);
+int _wifi_get_ip_conflict_period(wifi_manager_h wifi, unsigned int* initial_time);
+int _wifi_get_wps_generated_pin(wifi_manager_h wifi, char **wps_pin);
+int _wifi_get_connection_mode(wifi_manager_h wifi, wifi_manager_connection_mode_e *mode);
void __clear_profile_list(GSList **iterator);
+gpointer _wifi_copy_vsie_list(gconstpointer data, gpointer user_data);
+gpointer _wifi_copy_bssid_list(gconstpointer data, gpointer user_data);
+
/* WIFI Privilege Check */
-int _wifi_check_get_privilege();
-int _wifi_check_profile_privilege();
+int _wifi_check_get_privilege(wifi_manager_h wifi);
+int _wifi_check_profile_privilege(wifi_manager_h wifi);
/* WIFI Feature Check */
bool __check_feature_supported(const char *key, wifi_supported_feature_e feature);
} wifi_service_state_e;
extern tizen_profile_t _get_tizen_profile();
-int _wifi_get_service_state();
-int _wifi_get_5ghz_support(bool *supported);
+int _wifi_get_service_state(wifi_manager_handle_s *wifi_handle);
+int _wifi_get_5ghz_support(wifi_manager_h wifi, bool *supported);
/* WIFI DPP */
Name: capi-network-wifi-manager
Summary: Network Wi-Fi library in TIZEN C API
-Version: 1.1.53
+Version: 1.2.0
Release: 1
Group: System/Network
License: Apache-2.0
#define WIFI_SECURITY_OWE "owe"
#define WIFI_SECURITY_DPP "dpp"
-extern __thread network_info_s NetworkInfo;
-extern __thread network_request_table_s request_table[NETWORK_REQUEST_TYPE_MAX];
-__thread gboolean scan_pending = FALSE;
-
//LCOV_EXCL_START
static int __net_error_string_to_enum(const char *error)
{
{
__NETWORK_FUNC_ENTER__;
- net_event_info_s event_data = { 0, };
- net_profile_info_s prof_info;
- network_request_table_s *open_info =
- &request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION];
- network_request_table_s *wps_info =
- &request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS];
GDBusConnection *conn = NULL;
GError *error = NULL;
net_err_e Error = NET_ERR_NONE;
GVariant *reply;
+ net_event_info_s *event_data = NULL;
+ net_profile_info_s prof_info;
+ network_info_s *network_info = (network_info_s *)user_data;
+ network_request_table_s *request_table = network_info->request_table;
+ network_request_table_s *open_info = &request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION];
+ network_request_table_s *wps_info = &request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS];
WIFI_LOG(WIFI_INFO, "__net_open_connection_reply() called");
if (reply)
g_variant_unref(reply);
- if (Error == NET_ERR_NONE)
- goto done;
+ if (Error == NET_ERR_NONE) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
WIFI_LOG(WIFI_ERROR, "Connection open failed[%d]", Error);
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
if (open_info->flag == TRUE) {
- g_strlcpy(event_data.ProfileName, open_info->ProfileName,
+ g_strlcpy(event_data->ProfileName, open_info->ProfileName,
NET_PROFILE_NAME_LEN_MAX + 1);
memset(open_info, 0, sizeof(network_request_table_s));
- event_data.Error = Error;
+ event_data->Error = Error;
if (Error == NET_ERR_ACTIVE_CONNECTION_EXISTS) {
- Error = net_get_profile_info(event_data.ProfileName, &prof_info);
-
+ Error = net_get_profile_info(network_info, event_data->ProfileName, &prof_info);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Fail to get profile info[%s]",
_net_print_error(Error));
- event_data.Datalength = 0;
- event_data.Data = NULL;
+ event_data->Datalength = 0;
+ event_data->Data = NULL;
} else {
- event_data.Datalength = sizeof(net_profile_info_s);
- event_data.Data = &prof_info;
+ event_data->Datalength = sizeof(net_profile_info_s);
+ event_data->Data = &prof_info;
}
}
- event_data.Event = NET_EVENT_OPEN_RSP;
+ event_data->Event = NET_EVENT_OPEN_RSP;
WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_OPEN_RSP Error[%s]",
- _net_print_error(event_data.Error));
+ _net_print_error(event_data->Error));
+
} else if (wps_info->flag == TRUE) {
- g_strlcpy(event_data.ProfileName, wps_info->ProfileName,
+ g_strlcpy(event_data->ProfileName, wps_info->ProfileName,
NET_PROFILE_NAME_LEN_MAX + 1);
memset(wps_info, 0, sizeof(network_request_table_s));
- event_data.Error = Error;
+ event_data->Error = Error;
if (Error == NET_ERR_ACTIVE_CONNECTION_EXISTS) {
- Error = net_get_profile_info(event_data.ProfileName, &prof_info);
+ Error = net_get_profile_info(network_info, event_data->ProfileName, &prof_info);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Fail to get profile info[%s]",
_net_print_error(Error));
- event_data.Datalength = 0;
- event_data.Data = NULL;
+ event_data->Datalength = 0;
+ event_data->Data = NULL;
} else {
- event_data.Datalength = sizeof(net_profile_info_s);
- event_data.Data = &prof_info;
+ event_data->Datalength = sizeof(net_profile_info_s);
+ event_data->Data = &prof_info;
}
}
- event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+ event_data->Event = NET_EVENT_WIFI_WPS_RSP;
WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_WIFI_WPS_RSP Error[%s]",
- _net_print_error(event_data.Error));
- } else {
- _net_dbus_pending_call_unref();
+ _net_print_error(event_data->Error));
+ } else {
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
return;
}
-done:
- _net_dbus_pending_call_unref();
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
- _net_client_callback(&event_data);
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
}
__NETWORK_FUNC_ENTER__;
GVariant *reply;
- net_event_info_s event_data = { 0, };
- network_request_table_s *bssid_scan_info =
- &request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN];
-
GDBusConnection *conn = NULL;
GError *error = NULL;
net_err_e Error = NET_ERR_NONE;
+ net_event_info_s *event_data;
+
+ network_info_s *network_info = (network_info_s *)user_data;
+ network_request_table_s *request_table = network_info->request_table;
+ network_request_table_s *bssid_scan_info = &request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN];
+
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
conn = G_DBUS_CONNECTION(source_object);
reply = g_dbus_connection_call_finish(conn, res, &error);
+
if (error != NULL) {
- WIFI_LOG(WIFI_ERROR, "Scan failed. Error [%s]\n",
+ WIFI_LOG(WIFI_ERROR, "Scan failed. Error [%s]",
error->message);
Error = __net_error_string_to_enum(error->message);
g_error_free(error);
0, sizeof(network_request_table_s));
- event_data.Event = NET_EVENT_WIFI_BSSID_SCAN_IND;
+ event_data->Event = NET_EVENT_WIFI_BSSID_SCAN_IND;
WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_WIFI_BSSID_SCAN_IND[%s]",
- _net_print_error(event_data.Error));
- event_data.Error = NET_ERR_NONE;
- event_data.Datalength = 0;
- event_data.Data = NULL;
+ _net_print_error(event_data->Error));
+ event_data->Error = NET_ERR_NONE;
+ event_data->Datalength = 0;
+ event_data->Data = NULL;
+
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
- _net_client_callback(&event_data);
+ g_free(event_data);
} else if (Error == NET_ERR_IN_PROGRESS) {
/* should retry scan after receiving scan result */
if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
- WIFI_LOG(WIFI_INFO, "Full channel Scan pending\n");
- scan_pending = TRUE;
+ WIFI_LOG(WIFI_INFO, "Full channel Scan pending");
+ network_info->scan_pending = TRUE;
} else if (bssid_scan_info->flag == TRUE) {
- WIFI_LOG(WIFI_INFO, "BSSID Scan pending\n");
- scan_pending = TRUE;
+ WIFI_LOG(WIFI_INFO, "BSSID Scan pending");
+ network_info->scan_pending = TRUE;
}
} else if (Error != NET_ERR_NONE) {
- WIFI_LOG(WIFI_ERROR, "Scan failed. Error [%d]\n", Error);
+ WIFI_LOG(WIFI_ERROR, "Scan failed. Error [%d]", Error);
if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
memset(&request_table[NETWORK_REQUEST_TYPE_SCAN],
0, sizeof(network_request_table_s));
- event_data.Event = NET_EVENT_WIFI_SCAN_RSP;
+ event_data->Event = NET_EVENT_WIFI_SCAN_RSP;
} else if (bssid_scan_info->flag == TRUE) {
memset(&request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN],
0, sizeof(network_request_table_s));
- event_data.Event = NET_EVENT_WIFI_BSSID_SCAN_IND;
+ event_data->Event = NET_EVENT_WIFI_BSSID_SCAN_IND;
}
- if (event_data.Event) {
- event_data.Datalength = 0;
- event_data.Data = NULL;
- event_data.Error = Error;
+ if (event_data->Event) {
+ event_data->Datalength = 0;
+ event_data->Data = NULL;
+ event_data->Error = Error;
+
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
- _net_dbus_pending_call_unref();
- _net_client_callback(&event_data);
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
return;
}
} else
- WIFI_LOG(WIFI_INFO, "Scan Request success\n");
-
- _net_dbus_pending_call_unref();
+ WIFI_LOG(WIFI_INFO, "Scan Request success");
__NETWORK_FUNC_EXIT__;
}
{
__NETWORK_FUNC_ENTER__;
- WIFI_LOG(WIFI_INFO, "__net_close_connection_reply() called");
-
+ GDBusConnection *conn = NULL;
+ GError *error = NULL;
+ net_err_e Error = NET_ERR_NONE;
GVariant *reply;
- net_event_info_s event_data = { 0, };
+ net_event_info_s *event_data = NULL;
+ network_info_s *network_info = (network_info_s *)user_data;
+ network_request_table_s *request_table = network_info->request_table;
network_request_table_s *close_info =
&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION];
- GDBusConnection *conn = NULL;
- GError *error = NULL;
- net_err_e Error = NET_ERR_NONE;
+ WIFI_LOG(WIFI_INFO, "__net_close_connection_reply() called");
+
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
conn = G_DBUS_CONNECTION(source_object);
reply = g_dbus_connection_call_finish(conn, res, &error);
WIFI_LOG(WIFI_ERROR, "Connection close failed[%d]", Error);
if (close_info->flag == TRUE) {
- g_strlcpy(event_data.ProfileName, close_info->ProfileName,
+ g_strlcpy(event_data->ProfileName, close_info->ProfileName,
NET_PROFILE_NAME_LEN_MAX + 1);
memset(close_info, 0, sizeof(network_request_table_s));
- event_data.Error = Error;
- event_data.Datalength = 0;
- event_data.Data = NULL;
- event_data.Event = NET_EVENT_CLOSE_RSP;
+ event_data->Error = Error;
+ event_data->Datalength = 0;
+ event_data->Data = NULL;
+ event_data->Event = NET_EVENT_CLOSE_RSP;
WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_CLOSE_RSP Error[%s]",
- _net_print_error(event_data.Error));
+ _net_print_error(event_data->Error));
} else {
- _net_dbus_pending_call_unref();
-
__NETWORK_FUNC_EXIT__;
return;
}
done:
- _net_dbus_pending_call_unref();
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
- _net_client_callback(&event_data);
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
}
GDBusConnection *conn = NULL;
GError *error = NULL;
net_err_e Error = NET_ERR_NONE;
- net_event_info_s event_data = { 0, };
+ net_event_info_s *event_data = NULL;
GVariant *reply;
+ network_info_s *network_info = (network_info_s *)user_data;
+ network_request_table_s *request_table = network_info->request_table;
WIFI_LOG(WIFI_INFO, "__net_wifi_power_reply() called");
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
conn = G_DBUS_CONNECTION(source_object);
reply = g_dbus_connection_call_finish(conn, res, &error);
if (error != NULL) {
g_variant_unref(reply);
if (Error != NET_ERR_NONE) {
- WIFI_LOG(WIFI_ERROR,
- "Wi-Fi power operation failed. Error [%d]", Error);
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi power operation failed. Error [%d]", Error);
if (Error != NET_ERR_WIFI_DRIVER_LOAD_INPROGRESS) {
if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER],
0, sizeof(network_request_table_s));
- event_data.Event = NET_EVENT_WIFI_POWER_RSP;
+ event_data->Event = NET_EVENT_WIFI_POWER_RSP;
WIFI_LOG(WIFI_INFO,
"Sending NET_EVENT_WIFI_POWER_RSP Wi-Fi: %d Error = %d",
- NetworkInfo.wifi_state, Error);
+ network_info->wifi_state, Error);
- event_data.Datalength = sizeof(net_wifi_state_e);
- event_data.Data = &(NetworkInfo.wifi_state);
- event_data.Error = Error;
+ event_data->Datalength = sizeof(net_wifi_state_e);
+ event_data->Data = &(network_info->wifi_state);
+ event_data->Error = Error;
}
}
} else {
- _net_dbus_pending_call_unref();
-
__NETWORK_FUNC_EXIT__;
return;
}
- _net_dbus_pending_call_unref();
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
- _net_client_callback(&event_data);
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
}
GDBusConnection *conn = NULL;
GError *error = NULL;
- net_err_e Error = NET_ERR_NONE;
- net_event_info_s event_data = { 0, };
GVariant *reply;
+ net_err_e Error = NET_ERR_NONE;
+ net_event_info_s *event_data = NULL;
+ network_info_s *network_info = (network_info_s *)user_data;
+ network_request_table_s *request_table = network_info->request_table;
+
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
conn = G_DBUS_CONNECTION(source_object);
reply = g_dbus_connection_call_finish(conn, res, &error);
memset(&request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN],
0, sizeof(network_request_table_s));
- event_data.Event = NET_EVENT_WIFI_BSSID_SCAN_IND;
- event_data.Datalength = 0;
- event_data.Data = NULL;
- event_data.Error = Error;
-
- _net_dbus_pending_call_unref();
+ event_data->Event = NET_EVENT_WIFI_BSSID_SCAN_IND;
+ event_data->Datalength = 0;
+ event_data->Data = NULL;
+ event_data->Error = Error;
- _net_client_callback(&event_data);
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
return;
}
} else
WIFI_LOG(WIFI_INFO, "bssid scan succeed");
- _net_dbus_pending_call_unref();
-
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
}
GDBusConnection *conn = NULL;
GError *error = NULL;
- net_err_e Error = NET_ERR_NONE;
- net_event_info_s event_data = { 0, };
GVariant *reply;
+ net_err_e Error = NET_ERR_NONE;
+ net_event_info_s *event_data = NULL;
+ network_info_s *network_info = (network_info_s *)user_data;
+ network_request_table_s *request_table = network_info->request_table;
+
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
conn = G_DBUS_CONNECTION(source_object);
reply = g_dbus_connection_call_finish(conn, res, &error);
if (request_table[NETWORK_REQUEST_TYPE_NETLINK_SCAN].flag == TRUE) {
memset(&request_table[NETWORK_REQUEST_TYPE_NETLINK_SCAN],
0, sizeof(network_request_table_s));
- event_data.Event = NET_EVENT_WIFI_NETLINK_SCAN_IND;
+ event_data->Event = NET_EVENT_WIFI_NETLINK_SCAN_IND;
- event_data.Datalength = 0;
- event_data.Data = NULL;
- event_data.Error = Error;
+ event_data->Datalength = 0;
+ event_data->Data = NULL;
+ event_data->Error = Error;
- _net_dbus_pending_call_unref();
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
- _net_client_callback(&event_data);
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
return;
} else
WIFI_LOG(WIFI_INFO, "netlink scan succeed");
- _net_dbus_pending_call_unref();
-
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
}
else
WIFI_LOG(WIFI_INFO, "set passpoint succeeded");
- _net_dbus_pending_call_unref();
-
__NETWORK_FUNC_EXIT__;
}
return buf;
}
-static int __net_dbus_set_agent_field_and_connect(
+static int __net_dbus_set_agent_field_and_connect(network_info_s *network_info,
const char *key, const char *value, const char *profilename)
{
__NETWORK_FUNC_ENTER__;
builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
g_variant_builder_add(builder, "{sv}", key, g_variant_new_string(value));
- params = g_variant_new("(o@a{sv})",
- profilename, g_variant_builder_end(builder));
+ params = g_variant_new("(o@a{sv})", profilename, g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH,
+ Error = _net_invoke_dbus_method_nonblock(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
CONNMAN_AGENT_INTERFACE, "SetField", params,
DBUS_REPLY_TIMEOUT, __net_open_connection_reply);
}
//LCOV_EXCL_STOP
-GVariant *_net_invoke_dbus_method(const char *dest, const char *path,
- const char *interface_name, const char *method,
- GVariant *params, int *dbus_error)
+GVariant *_net_invoke_dbus_method(network_info_s *network_info,
+ const char *dest, const char *path, const char *interface_name,
+ const char *method, GVariant *params, int *dbus_error)
{
__NETWORK_FUNC_ENTER__;
GError *error = NULL;
GVariant *reply = NULL;
*dbus_error = NET_ERR_NONE;
- GDBusConnection *connection;
-
- connection = _net_dbus_get_gdbus_conn();
- if (connection == NULL) {
- WIFI_LOG(WIFI_ERROR, "GDBusconnection is NULL"); //LCOV_EXCL_LINE
- *dbus_error = NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
- return reply; //LCOV_EXCL_LINE
+ GDBusConnection *connection = NULL;
+ gboolean created = FALSE;
+
+ if (network_info == NULL || network_info->connection == NULL) {
+ connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (connection == NULL) {
+ /* LCOV_EXCL_START */
+ if (error != NULL) {
+ WIFI_LOG(WIFI_ERROR,
+ "Failed to connect to the D-BUS daemon [%s]", error->message);
+ g_error_free(error);
+ }
+ /* LCOV_EXCL_STOP */
+ return NULL;
+ }
+ created = TRUE;
+ } else {
+ connection = network_info->connection;
+ created = FALSE;
}
- reply = g_dbus_connection_call_sync(connection,
+ reply = g_dbus_connection_call_sync(network_info->connection,
dest,
path,
interface_name,
NULL,
G_DBUS_CALL_FLAGS_NONE,
DBUS_REPLY_TIMEOUT_SYNC,
- _net_dbus_get_gdbus_cancellable(),
+ network_info->cancellable,
&error);
if (reply == NULL) {
if (error != NULL) {
return NULL;
}
+ if (created)
+ g_object_unref(connection);
+
__NETWORK_FUNC_EXIT__;
return reply;
}
-int _net_invoke_dbus_method_nonblock(const char *dest, const char *path,
+int _net_invoke_dbus_method_nonblock(network_info_s *network_info,
+ const char *dest, const char *path,
const char *interface_name, const char *method,
GVariant *params, int timeout,
GAsyncReadyCallback notify_func)
{
__NETWORK_FUNC_ENTER__;
- GDBusConnection *connection;
-
- connection = _net_dbus_get_gdbus_conn();
- if (connection == NULL) {
- WIFI_LOG(WIFI_ERROR, "GDBusconnection is NULL"); //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
- }
-
- g_dbus_connection_call(connection,
+ g_dbus_connection_call(network_info->connection,
dest,
path,
interface_name,
NULL,
G_DBUS_CALL_FLAGS_NONE,
timeout,
- _net_dbus_get_gdbus_cancellable(),
+ network_info->cancellable,
(GAsyncReadyCallback) notify_func,
- NULL);
-
- if (notify_func != NULL)
- _net_dbus_pending_call_ref();
+ network_info);
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-int _net_dbus_open_connection(const char* profile_name)
+int _net_dbus_open_connection(network_info_s *network_info,
+ const char* profile_name)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
/* use DBus signal than reply pending because of performance reason */
- Error = _net_invoke_dbus_method_nonblock(CONNMAN_SERVICE, profile_name,
+ Error = _net_invoke_dbus_method_nonblock(network_info,
+ CONNMAN_SERVICE, profile_name,
CONNMAN_SERVICE_INTERFACE, "Connect", NULL,
DBUS_REPLY_TIMEOUT, __net_open_connection_reply);
return Error;
}
-int _net_dbus_close_connection(const char* profile_name)
+int _net_dbus_close_connection(network_info_s *network_info,
+ const char* profile_name)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
/* use DBus signal than reply pending because of performance reason */
- Error = _net_invoke_dbus_method_nonblock(CONNMAN_SERVICE, profile_name,
+ Error = _net_invoke_dbus_method_nonblock(network_info,
+ CONNMAN_SERVICE, profile_name,
CONNMAN_SERVICE_INTERFACE, "Disconnect", NULL,
DBUS_REPLY_TIMEOUT, __net_close_connection_reply);
return Error;
}
-int _net_dbus_scan_request(void)
+int _net_dbus_scan_request(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
+ GVariant *params = NULL;
+
+ params = g_variant_new("(s)", network_info->interface_name);
/* use DBus signal than reply pending because of performance reason */
- Error = _net_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
- CONNMAN_WIFI_TECHNOLOGY_PREFIX,
- CONNMAN_TECHNOLOGY_INTERFACE, "Scan", NULL,
+ Error = _net_invoke_dbus_method_nonblock(network_info,
+ CONNMAN_SERVICE, CONNMAN_WIFI_TECHNOLOGY_PREFIX,
+ CONNMAN_TECHNOLOGY_INTERFACE, "ScanDevice", params,
DBUS_REPLY_TIMEOUT, __net_scan_reply);
if (Error == NET_ERR_IN_PROGRESS)
return Error;
}
-int _net_dbus_get_scan_state(int *scanstate)
+int _net_dbus_get_scan_state(network_info_s *network_info, int *scanstate)
{
__NETWORK_FUNC_ENTER__;
GVariant *value = NULL;
GVariantIter *iter;
gchar *key;
+ GVariant *params = NULL;
const char *method = "GetScanState";
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
CONNMAN_SERVICE, CONNMAN_WIFI_TECHNOLOGY_PREFIX,
- CONNMAN_TECHNOLOGY_INTERFACE, method, NULL, &Error);
+ CONNMAN_TECHNOLOGY_INTERFACE, method, params, &Error);
if (message == NULL) {
- WIFI_LOG(WIFI_ERROR, "Failed to get scan state\n"); //LCOV_EXCL_LINE
+ WIFI_LOG(WIFI_ERROR, "Failed to get scan state"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__;
return Error;
}
g_variant_get(message, "(a{sv})", &iter);
while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
if (g_variant_is_of_type(value, G_VARIANT_TYPE_BOOLEAN)) {
- if (g_strcmp0(key, "Scanstate") == 0)
+ if (g_strcmp0(key, network_info->interface_name) == 0)
*scanstate = g_variant_get_boolean(value);
}
}
g_variant_iter_free(iter);
g_variant_unref(message);
- WIFI_LOG(WIFI_INFO, "scan state: %d\n", *scanstate);
+ WIFI_LOG(WIFI_INFO, "scan state: %d", *scanstate);
__NETWORK_FUNC_EXIT__;
return Error;
}
//LCOV_EXCL_START
-int _net_dbus_set_bgscan_mode(net_wifi_background_scan_mode_e mode)
+int _net_dbus_set_bgscan_mode(network_info_s *network_info,
+ net_wifi_background_scan_mode_e mode)
{
__NETWORK_FUNC_ENTER__;
GVariant *message = NULL;
GVariant *params;
- params = g_variant_new("(u)", mode);
+ params = g_variant_new("(su)", network_info->interface_name, mode);
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, "SetBgscan", params, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "SetBgscan",
+ params, &Error);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "_net_invoke_dbus_method failed"); //LCOV_EXCL_LINE
return Error;
}
-int _net_dbus_set_ip_conflict_period(unsigned int initial_time)
+int _net_dbus_set_ip_conflict_period(network_info_s *network_info, unsigned int initial_time)
{
__NETWORK_FUNC_ENTER__;
GVariant *message = NULL;
GVariant *params;
- params = g_variant_new("(u)", initial_time);
+ params = g_variant_new("(su)", network_info->interface_name, initial_time);
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, "SetIpConflictPeriod", params, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "SetIpConflictPeriod",
+ params, &Error);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "_net_invoke_dbus_method failed"); //LCOV_EXCL_LINE
}
//LCOV_EXCL_STOP
-int _net_dbus_get_technology_state(network_tech_state_info_s *tech_state)
+int _net_dbus_get_technology_state(network_info_s *network_info,
+ network_tech_state_info_s *tech_state)
{
__NETWORK_FUNC_ENTER__;
return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
}
- message = _net_invoke_dbus_method(CONNMAN_SERVICE,
- CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
- "GetTechnologies", NULL, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE, "GetTechnologies",
+ NULL, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to get technology info"); //LCOV_EXCL_LINE
goto done; //LCOV_EXCL_LINE
}
- Error = _net_get_tech_state(message, tech_state);
+ Error = _net_get_tech_state(network_info, message, tech_state);
g_variant_unref(message);
return Error;
}
-int _net_dbus_get_tech_status(net_tech_info_s *tech_status)
+int _net_dbus_get_tech_status(network_info_s *network_info,
+ net_tech_info_s *tech_status)
{
__NETWORK_FUNC_ENTER__;
g_strlcpy(tech_state.technology, "wifi", NET_TECH_LENGTH_MAX);
- Error = _net_dbus_get_technology_state(&tech_state);
+ Error = _net_dbus_get_technology_state(network_info, &tech_state);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"_net_dbus_get_technology_state() failed. Error [%s]",
}
//LCOV_EXCL_START
-int _net_dbus_set_eap_config_fields_and_connect(
+static int _net_dbus_set_eap_config_fields_and_connect(network_info_s *network_info,
const net_wifi_connect_service_info_t *wifi_info,
const char *profilename)
{
CONNMAN_CONFIG_FIELD_PVT_KEY_PASSPHRASE,
wifi_info->private_key_password);
- params = g_variant_new("(o@a{ss})",
- profilename, g_variant_builder_end(builder));
+ params = g_variant_new("(o@a{ss})", profilename, g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH,
+ Error = _net_invoke_dbus_method_nonblock(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
NETCONFIG_WIFI_INTERFACE, "CreateEapConfig", params,
DBUS_REPLY_TIMEOUT, __net_open_connection_reply);
}
//LCOV_EXCL_STOP
-int _net_dbus_set_agent_passphrase_and_connect(
+int _net_dbus_set_agent_passphrase_and_connect(network_info_s *network_info,
const char *passphrase, const char *profilename)
{
__NETWORK_FUNC_ENTER__;
return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
}
- Error = __net_dbus_set_agent_field_and_connect(
- NETCONFIG_AGENT_FIELD_PASSPHRASE,
- passphrase,
- profilename);
+ Error = __net_dbus_set_agent_field_and_connect(network_info,
+ NETCONFIG_AGENT_FIELD_PASSPHRASE, passphrase, profilename);
if (NET_ERR_NONE != Error) {
WIFI_LOG(WIFI_ERROR, "Configuration failed(%d)", Error); //LCOV_EXCL_LINE
return Error; //LCOV_EXCL_LINE
}
//LCOV_EXCL_START
-int _net_dbus_set_agent_fields_and_connect(const char *ssid,
- const char *passphrase, const char *profilename)
+static int _net_dbus_set_agent_fields_and_connect(network_info_s *network_info,
+ const char *ssid, const char *passphrase, const char *profilename)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
+ GVariant *params = NULL;
+ GVariantBuilder *builder;
/* If OPEN network, passphrase can be NULL */
if (NULL == ssid || strlen(ssid) <= 0 || NULL == profilename) {
return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
}
- GVariant *params = NULL;
- GVariantBuilder *builder;
-
builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_SSID,
g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, ssid,
g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_PASSPHRASE,
g_variant_new_string(passphrase));
- params = g_variant_new("(o@a{sv})",
- profilename, g_variant_builder_end(builder));
+ params = g_variant_new("(o@a{sv})", profilename, g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH,
+ Error = _net_invoke_dbus_method_nonblock(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
CONNMAN_AGENT_INTERFACE, "SetField", params,
DBUS_REPLY_TIMEOUT, __net_open_connection_reply);
if (NET_ERR_NONE != Error) {
return Error;
}
-int _net_dbus_get_wps_generated_pin(char **wps_pin)
+int _net_dbus_get_wps_generated_pin(network_info_s *network_info, char **wps_pin)
{
__NETWORK_FUNC_ENTER__;
net_err_e error = NET_ERR_NONE;
const gchar *value = NULL;
const gchar *path = NULL;
- params = g_variant_new("(s)", "wlan0");
- reply = _net_invoke_dbus_method(SUPPLICANT_SERVICE, SUPPLICANT_PATH,
- SUPPLICANT_INTERFACE, "GetInterface", params, &error);
+ params = g_variant_new("(s)", network_info->interface_name);
+
+ reply = _net_invoke_dbus_method(network_info,
+ SUPPLICANT_SERVICE, SUPPLICANT_PATH,
+ SUPPLICANT_INTERFACE, "GetInterface",
+ params, &error);
if (reply == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi interface");
return error;
}
g_variant_get(reply, "(&o)", &path);
- reply = _net_invoke_dbus_method(SUPPLICANT_SERVICE, path,
- SUPPLICANT_INTERFACE ".Interface.WPS", "GeneratePin", NULL, &error);
+ reply = _net_invoke_dbus_method(network_info,
+ SUPPLICANT_SERVICE, path,
+ SUPPLICANT_INTERFACE ".Interface.WPS",
+ "GeneratePin", NULL, &error);
if (reply == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to get wps pin");
return error;
return error;
}
-int _net_dbus_set_agent_wps_pbc_and_connect(const char *profilename)
+int _net_dbus_set_agent_wps_pbc_and_connect(network_info_s *network_info,
+ const char *profilename)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- Error = __net_dbus_set_agent_field_and_connect(
- NETCONFIG_AGENT_FIELD_WPS_PBC,
- "enable",
- profilename);
+ Error = __net_dbus_set_agent_field_and_connect(network_info,
+ NETCONFIG_AGENT_FIELD_WPS_PBC, "enable", profilename);
if (NET_ERR_NONE != Error) {
WIFI_LOG(WIFI_ERROR, "PBC configuration failed(%d)", Error);
return Error;
return Error;
}
-int _net_dbus_set_agent_wps_pin_and_connect(
+int _net_dbus_set_agent_wps_pin_and_connect(network_info_s *network_info,
const char *wps_pin, const char *profilename)
{
__NETWORK_FUNC_ENTER__;
return NET_ERR_INVALID_PARAM;
}
- Error = __net_dbus_set_agent_field_and_connect(
- NETCONFIG_AGENT_FIELD_WPS_PIN,
- wps_pin,
- profilename);
+ Error = __net_dbus_set_agent_field_and_connect(network_info,
+ NETCONFIG_AGENT_FIELD_WPS_PIN, wps_pin, profilename);
if (NET_ERR_NONE != Error) {
WIFI_LOG(WIFI_ERROR, "PIN configuration failed(%d)", Error);
return Error;
}
//LCOV_EXCL_STOP
-int _net_dbus_connect_service(const net_wifi_connect_service_info_t *wifi_connection_info)
+int _net_dbus_connect_service(network_info_s *network_info,
+ const net_wifi_connect_service_info_t *wifi_connection_info)
{
__NETWORK_FUNC_ENTER__;
/* Get group name with prefix 'ssid' in hex */
grp_name = __net_make_group_name(wifi_connection_info->is_hidden == TRUE ?
- NULL : wifi_connection_info->raw_ssid,
- wifi_connection_info->raw_ssid_len,
- wifi_connection_info->mode,
- wifi_connection_info->security);
+ NULL : wifi_connection_info->raw_ssid,
+ wifi_connection_info->raw_ssid_len,
+ wifi_connection_info->mode,
+ wifi_connection_info->security);
if (NULL == grp_name) {
WIFI_LOG(WIFI_ERROR, "Failed to make a group name"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_UNKNOWN; //LCOV_EXCL_LINE
}
- Error = _net_get_profile_list(&profile_list);
+ Error = _net_get_profile_list(network_info, &profile_list);
if (NET_ERR_NONE != Error) {
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"_net_get_profile_list fail. Error [%s]",
wifi_connection_info->security);
WIFI_LOG(WIFI_INFO, "Hidden target name %s", target_name);
- g_strlcpy(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
+ g_strlcpy(network_info->request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
target_name, NET_PROFILE_NAME_LEN_MAX+1);
g_free(target_name);
//LCOV_EXCL_STOP
} else {
- g_strlcpy(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
+ g_strlcpy(network_info->request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
prof_info->ProfileName, NET_PROFILE_NAME_LEN_MAX+1);
}
//LCOV_EXCL_START
if (g_strcmp0(wifi_connection_info->security, "ieee8021x") == 0) {
/* Create the EAP config file */
- Error = _net_dbus_set_eap_config_fields_and_connect(
+ Error = _net_dbus_set_eap_config_fields_and_connect(network_info,
wifi_connection_info, prof_info->ProfileName);
if (NET_ERR_NONE != Error) {
WIFI_LOG(WIFI_ERROR, "Fail to create eap_config");
goto error;
}
} else if (wifi_connection_info->is_hidden == TRUE) {
- Error = _net_dbus_set_agent_fields_and_connect(
+ Error = _net_dbus_set_agent_fields_and_connect(network_info,
wifi_connection_info->ssid,
wifi_connection_info->passphrase,
prof_info->ProfileName);
} else if (g_strcmp0(wifi_connection_info->security, "none") != 0 &&
g_strcmp0(wifi_connection_info->security, "owe") != 0) {
- Error = _net_dbus_set_agent_passphrase_and_connect(
+ Error = _net_dbus_set_agent_passphrase_and_connect(network_info,
wifi_connection_info->passphrase, prof_info->ProfileName);
if (NET_ERR_NONE != Error) {
WIFI_LOG(WIFI_ERROR, "Fail to set agent_passphrase");
goto error;
}
} else {
- Error = _net_dbus_open_connection(prof_info->ProfileName);
+ Error = _net_dbus_open_connection(network_info, prof_info->ProfileName);
//LCOV_EXCL_STOP
}
"Failed to request open connection, Error [%s]",
_net_print_error(Error));
- memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], //LCOV_EXCL_LINE
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION]), //LCOV_EXCL_LINE
0, sizeof(network_request_table_s));
}
}
//LCOV_EXCL_START
-int _net_dbus_get_preferred_ipv6_address(const char *profilename, char **address)
+int _net_dbus_get_preferred_ipv6_address(network_info_s *network_info,
+ const char *profilename, char **address)
{
__NETWORK_FUNC_ENTER__;
GVariant *params = NULL;
if (address == NULL) {
- WIFI_LOG(WIFI_ERROR, "Invalid Parameter\n");
+ WIFI_LOG(WIFI_ERROR, "Invalid Parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
params = g_variant_new("(s)", profilename);
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_NETWORK_PATH,
- NETCONFIG_NETWORK_INTERFACE, "PreferredIpv6Address", params, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_NETWORK_PATH,
+ NETCONFIG_NETWORK_INTERFACE, "PreferredIpv6Address",
+ params, &Error);
if (message == NULL) {
- WIFI_LOG(WIFI_ERROR, "Failed to get preferred IPv6 address\n");
+ WIFI_LOG(WIFI_ERROR, "Failed to get preferred IPv6 address");
__NETWORK_FUNC_EXIT__;
return Error;
}
g_variant_get(message, "(s)", address);
- WIFI_LOG(WIFI_INFO, "Preferred IPv6 Address [%s]\n", *address);
+ WIFI_LOG(WIFI_INFO, "Preferred IPv6 Address [%s]", *address);
g_variant_unref(message);
return Error;
}
-int _net_dbus_set_profile_ipv4(net_profile_info_s* prof_info, char* profile_name)
+int _net_dbus_set_profile_ipv4(network_info_s *network_info,
+ net_profile_info_s *prof_info, char *profile_name)
{
__NETWORK_FUNC_ENTER__;
prop_ipv4_configuration, g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- message = _net_invoke_dbus_method(CONNMAN_SERVICE, profile_name,
- CONNMAN_SERVICE_INTERFACE, "SetProperty", params,
- &Error);
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, profile_name,
+ CONNMAN_SERVICE_INTERFACE, "SetProperty",
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to set IPv4 Property"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
}
g_variant_unref(message);
- WIFI_LOG(WIFI_INFO, "Successfully configured IPv4.Configuration\n");
+ WIFI_LOG(WIFI_INFO, "Successfully configured IPv4.Configuration");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_set_profile_ipv6(net_profile_info_s* prof_info, char* profile_name)
+int _net_dbus_set_profile_ipv6(network_info_s *network_info,
+ net_profile_info_s* prof_info, char* profile_name)
{
__NETWORK_FUNC_ENTER__;
net_dev_info_s *profile_net_info = NULL;
if ((prof_info == NULL) || (profile_name == NULL) || (strlen(profile_name) == 0)) {
- WIFI_LOG(WIFI_ERROR, "Error!!! Invalid argument\n");
+ WIFI_LOG(WIFI_ERROR, "Error!!! Invalid argument");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
INET6_ADDRSTRLEN);
prefix_length = profile_net_info->PrefixLen6;
- WIFI_LOG(WIFI_INFO, "ipaddress : %s, prefix_len : %d, gateway :"
- " %s\n", ip6_ptr, prefix_length, gw6_ptr);
+ WIFI_LOG(WIFI_INFO, "ipaddress : %s, prefix_len : %d, gateway : %s",
+ ip6_ptr, prefix_length, gw6_ptr);
builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
g_variant_builder_add(builder, "{sv}", prop_method,
g_variant_new_string(off_method));
- WIFI_LOG(WIFI_INFO, "DBus Message 2/2: %s %s\n",
+ WIFI_LOG(WIFI_INFO, "DBus Message 2/2: %s %s",
prop_method, off_method);
} else if (profile_net_info->IpConfigType6 == NET_IP_CONFIG_TYPE_STATIC) {
g_variant_builder_add(builder, "{sv}", prop_gateway,
g_variant_new_string(gw6_ptr));
}
- WIFI_LOG(WIFI_INFO, "DBus Message 2/2: %s %s %s %s %s %d"
- " %s %s\n", prop_method, manual_method,
+ WIFI_LOG(WIFI_INFO, "DBus Message 2/2: %s %s %s %s %s %d %s %s",
+ prop_method, manual_method,
prop_address, ipaddr6, prop_prefixlen,
prefix_length, prop_gateway, gwaddr6);
} else {
- WIFI_LOG(WIFI_ERROR, "Invalid argument\n");
+ WIFI_LOG(WIFI_ERROR, "Invalid argument");
g_variant_builder_unref(builder);
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- message = _net_invoke_dbus_method(CONNMAN_SERVICE, profile_name,
- CONNMAN_SERVICE_INTERFACE, "SetProperty", params,
- &Error);
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, profile_name,
+ CONNMAN_SERVICE_INTERFACE, "SetProperty",
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to set IPv6 Property");
__NETWORK_FUNC_EXIT__;
}
g_variant_unref(message);
- WIFI_LOG(WIFI_INFO, "Successfully configured IPv6.Configuration\n");
+ WIFI_LOG(WIFI_INFO, "Successfully configured IPv6.Configuration");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_set_profile_dns(net_profile_info_s* prof_info, char* profile_name)
+int _net_dbus_set_profile_dns(network_info_s *network_info,
+ net_profile_info_s* prof_info, char* profile_name)
{
__NETWORK_FUNC_ENTER__;
profile_net_info = &(prof_info->net_info);
if (profile_net_info->DnsCount > NET_DNS_ADDR_MAX) {
- WIFI_LOG(WIFI_ERROR, "Invalid parameter\n");
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
profile_net_info->DnsConfigType6 == NET_DNS_CONFIG_TYPE_DYNAMIC) {
builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
- WIFI_LOG(WIFI_INFO, "IPv4 DnsConfigType: %d\n", profile_net_info->DnsConfigType);
+ WIFI_LOG(WIFI_INFO, "IPv4 DnsConfigType: %d", profile_net_info->DnsConfigType);
if (profile_net_info->DnsConfigType ==
NET_DNS_CONFIG_TYPE_STATIC ||
profile_net_info->DnsConfigType6 ==
g_variant_builder_add(builder, "s",
dhcp_method);
- WIFI_LOG(WIFI_INFO, "IPv6 DnsConfigType: %d\n", profile_net_info->DnsConfigType6);
+ WIFI_LOG(WIFI_INFO, "IPv6 DnsConfigType: %d", profile_net_info->DnsConfigType6);
if (profile_net_info->DnsConfigType6 ==
NET_DNS_CONFIG_TYPE_STATIC)
g_variant_builder_add(builder, "s",
g_variant_builder_add(builder, "s",
dns_address[i]);
}
- WIFI_LOG(WIFI_INFO, "IPv4 DNS Address added in g_variant: %s\n", dns_address[i]);
+ WIFI_LOG(WIFI_INFO, "IPv4 DNS Address added in g_variant: %s", dns_address[i]);
}
for (i = 0; i < profile_net_info->DnsCount6; i++) {
g_variant_builder_add(builder, "s",
ipv6_dns_address[i]);
}
- WIFI_LOG(WIFI_INFO, "IPv6 DNS Address added in g_variant: %s\n", ipv6_dns_address[i]);
+ WIFI_LOG(WIFI_INFO, "IPv6 DNS Address added in g_variant: %s", ipv6_dns_address[i]);
}
params = g_variant_new("(sv)", prop_nameserver_configuration, g_variant_builder_end(builder));
g_variant_builder_unref(builder);
}
- message = _net_invoke_dbus_method(CONNMAN_SERVICE, profile_name,
- CONNMAN_SERVICE_INTERFACE, "SetProperty", params,
- &Error);
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, profile_name,
+ CONNMAN_SERVICE_INTERFACE, "SetProperty",
+ params, &Error);
if (message == NULL) {
__NETWORK_FUNC_EXIT__;
return Error;
}
- WIFI_LOG(WIFI_INFO, "Successfully configured Nameservers.Configuration\n");
+ WIFI_LOG(WIFI_INFO, "Successfully configured Nameservers.Configuration");
g_variant_unref(message);
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_set_proxy(net_profile_info_s* prof_info, char* profile_name)
+int _net_dbus_set_proxy(network_info_s *network_info,
+ net_profile_info_s* prof_info, char* profile_name)
{
__NETWORK_FUNC_ENTER__;
params = g_variant_new("(sv)", prop_proxy_configuration, g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- message = _net_invoke_dbus_method(CONNMAN_SERVICE, profile_name,
- CONNMAN_SERVICE_INTERFACE, "SetProperty", params,
- &Error);
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, profile_name,
+ CONNMAN_SERVICE_INTERFACE, "SetProperty",
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to set Proxy Configuration");
__NETWORK_FUNC_EXIT__;
return Error;
}
- WIFI_LOG(WIFI_INFO, "Successfully configured Proxy.Configuration\n");
+ WIFI_LOG(WIFI_INFO, "Successfully configured Proxy.Configuration");
g_variant_unref(message);
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_load_wifi_driver(gboolean wifi_picker_test)
+int _net_dbus_load_wifi_driver(network_info_s *network_info, gboolean wifi_picker_test)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
GVariant *params;
- params = g_variant_new("(b)", wifi_picker_test);
+ params = g_variant_new("(sb)", network_info->interface_name, wifi_picker_test);
/* use DBus signal than reply pending because of performance reason */
- Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
- "LoadDriver", params, DBUS_REPLY_TIMEOUT,
+ Error = _net_invoke_dbus_method_nonblock(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "LoadDriver",
+ params, DBUS_REPLY_TIMEOUT,
__net_wifi_power_reply);
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_remove_wifi_driver(void)
+int _net_dbus_remove_wifi_driver(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
+ GVariant *params = NULL;
+
+ params = g_variant_new("(s)", network_info->interface_name);
/* use DBus signal than reply pending because of performance reason */
- Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
- "RemoveDriver", NULL, DBUS_REPLY_TIMEOUT,
+ Error = _net_invoke_dbus_method_nonblock(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "RemoveDriver",
+ params, DBUS_REPLY_TIMEOUT,
__net_wifi_power_reply);
__NETWORK_FUNC_EXIT__;
GDBusConnection *conn = NULL;
GError *error = NULL;
net_err_e Error = NET_ERR_NONE;
- net_event_info_s event_data = { 0, };
+ net_event_info_s *event_data = NULL;
GVariant *reply;
+ network_info_s *network_info = (network_info_s *)user_data;
+ network_request_table_s *request_table = network_info->request_table;
+
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
conn = G_DBUS_CONNECTION(source_object);
reply = g_dbus_connection_call_finish(conn, res, &error);
if (error != NULL) {
- WIFI_LOG(WIFI_ERROR, "Scan failed. Error [%s]\n",
+ WIFI_LOG(WIFI_ERROR, "Scan failed. Error [%s]",
error->message);
Error = __net_error_string_to_enum(error->message);
g_error_free(error);
if (Error == NET_ERR_IN_PROGRESS) {
/* should retry scan after receiving scan result */
if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
- WIFI_LOG(WIFI_INFO, "Specific Scan pending\n");
- scan_pending = TRUE;
+ WIFI_LOG(WIFI_INFO, "Specific Scan pending");
+ network_info->scan_pending = TRUE;
}
} else if (Error != NET_ERR_NONE) {
- WIFI_LOG(WIFI_ERROR, "Specific Scan failed. Error [%d]\n", Error);
+ WIFI_LOG(WIFI_ERROR, "Specific Scan failed. Error [%d]", Error);
if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
memset(&request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN],
0, sizeof(network_request_table_s));
- event_data.Event = NET_EVENT_WIFI_SPECIFIC_SCAN_RSP;
- event_data.Datalength = 0;
- event_data.Data = NULL;
- event_data.Error = Error;
+ event_data->Event = NET_EVENT_WIFI_SPECIFIC_SCAN_RSP;
+ event_data->Datalength = 0;
+ event_data->Data = NULL;
+ event_data->Error = Error;
+
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
- _net_dbus_pending_call_unref();
- _net_client_callback(&event_data);
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
return;
}
} else
- WIFI_LOG(WIFI_INFO, "Specific Scan Request success\n");
-
- _net_dbus_pending_call_unref();
+ WIFI_LOG(WIFI_INFO, "Specific Scan Request success");
__NETWORK_FUNC_EXIT__;
}
-int _net_dbus_specific_scan_request(const char *ssid)
+int _net_dbus_specific_scan_request(network_info_s *network_info, const char *ssid)
{
__NETWORK_FUNC_ENTER__;
- WIFI_LOG(WIFI_ERROR, "specific scan ssid : %s", ssid);
-
GVariant *params = NULL;
GVariantBuilder *builder;
net_err_e Error = NET_ERR_NONE;
+ WIFI_LOG(WIFI_ERROR, "specific scan ssid : %s", ssid);
+
builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
g_variant_builder_add(builder, "{sv}", "SSID", g_variant_new_string(ssid));
- params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+ params = g_variant_new("(s@a{sv})", network_info->interface_name,
+ g_variant_builder_end(builder));
g_variant_builder_unref(builder);
/* use DBus signal than reply pending because of performance reason */
- Error = _net_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
- CONNMAN_WIFI_TECHNOLOGY_PREFIX,
+ Error = _net_invoke_dbus_method_nonblock(network_info,
+ CONNMAN_SERVICE, CONNMAN_WIFI_TECHNOLOGY_PREFIX,
CONNMAN_TECHNOLOGY_INTERFACE, "SpecificScan", params,
DBUS_REPLY_TIMEOUT, __net_specific_scan_request_reply);
return Error;
}
-int _net_dbus_bssid_scan_request(void)
+int _net_dbus_bssid_scan_request(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
+ GVariant *params = NULL;
+
+ params = g_variant_new("(s)", network_info->interface_name);
- Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
- "RequestBssidScan", NULL, 6 * DBUS_REPLY_TIMEOUT,
+ Error = _net_invoke_dbus_method_nonblock(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "RequestBssidScan",
+ params, 6 * DBUS_REPLY_TIMEOUT,
__net_bssid_scan_wifi_reply);
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_netlink_scan_request(GSList *nl_scan_list, const char *vsie)
+int _net_dbus_netlink_scan_request(network_info_s *network_info,
+ GSList *nl_scan_list, const char *vsie)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
g_variant_builder_add(builder, "{sv}", "VSIE", g_variant_new_string(vsie));
}
- params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+ params = g_variant_new("(s@a{sv})", network_info->interface_name, g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
- "NetlinkScan", params, 6 * DBUS_REPLY_TIMEOUT,
+ Error = _net_invoke_dbus_method_nonblock(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "NetlinkScan",
+ params, 6 * DBUS_REPLY_TIMEOUT,
__net_netlink_scan_wifi_reply);
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_get_passpoint(int *enabled)
+int _net_dbus_get_passpoint(network_info_s *network_info, int *enabled)
{
__NETWORK_FUNC_ENTER__;
+ GVariant *params = NULL;
GVariant *message = NULL;
net_err_e Error = NET_ERR_NONE;
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
- "GetPasspoint", NULL, &Error);
+ params = g_variant_new("(s)", network_info->interface_name);
+
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "GetPasspoint",
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to Get Passpoint");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_set_passpoint(int enable)
+int _net_dbus_set_passpoint(network_info_s *network_info, int enable)
{
__NETWORK_FUNC_ENTER__;
GVariant *params;
net_err_e Error = NET_ERR_NONE;
- params = g_variant_new("(i)", enable);
+ params = g_variant_new("(si)", network_info->interface_name, enable);
- Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
- "SetPasspoint", params, 6 * DBUS_REPLY_TIMEOUT,
+ Error = _net_invoke_dbus_method_nonblock(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "SetPasspoint",
+ params, 6 * DBUS_REPLY_TIMEOUT,
__net_set_passpoint_reply);
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_add_vsie(unsigned int frame_id, const char *vsie_str)
+int _net_dbus_add_vsie(network_info_s *network_info,
+ unsigned int frame_id, const char *vsie_str)
{
__NETWORK_FUNC_ENTER__;
GVariant *params = NULL;
net_err_e Error = NET_ERR_NONE;
- params = g_variant_new("(is)", frame_id, vsie_str);
+ params = g_variant_new("(sis)", network_info->interface_name, frame_id, vsie_str);
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, "AddVsie", params,
- &Error);
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "AddVsie",
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to add vsie");
}
g_variant_unref(message);
- WIFI_LOG(WIFI_INFO, "Successfully Added VSIE\n");
+ WIFI_LOG(WIFI_INFO, "Successfully Added VSIE");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_get_vsie(unsigned int frame_id, char **vsie_str)
+int _net_dbus_get_vsie(network_info_s *network_info,
+ unsigned int frame_id, char **vsie_str)
{
__NETWORK_FUNC_ENTER__;
const char *val = NULL;
net_err_e Error = NET_ERR_NONE;
- params = g_variant_new("(i)", frame_id);
+ params = g_variant_new("(si)", network_info->interface_name, frame_id);
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, "GetVsie", params,
- &Error);
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "GetVsie",
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to get vsie");
return Error;
}
-int _net_dbus_remove_vsie(unsigned int frame_id, const char *vsie_str)
+int _net_dbus_remove_vsie(network_info_s *network_info,
+ unsigned int frame_id, const char *vsie_str)
{
__NETWORK_FUNC_ENTER__;
GVariant *params = NULL;
net_err_e Error = NET_ERR_NONE;
- params = g_variant_new("(is)", frame_id, vsie_str);
+ params = g_variant_new("(sis)", network_info->interface_name, frame_id, vsie_str);
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, "RemoveVsie", params,
- &Error);
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "RemoveVsie",
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to remove vsie");
}
g_variant_unref(message);
- WIFI_LOG(WIFI_INFO, "Successfully Added VSIE\n");
+ WIFI_LOG(WIFI_INFO, "Successfully Added VSIE");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_flush_bss(void)
+int _net_dbus_flush_bss(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
+ GVariant *params = NULL;
GVariant *message = NULL;
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, "FlushBss", NULL, &Error);
+ params = g_variant_new("(s)", network_info->interface_name);
+
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "FlushBss",
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to flush bss");
}
g_variant_unref(message);
- WIFI_LOG(WIFI_INFO, "Successfully flush bss\n");
+ WIFI_LOG(WIFI_INFO, "Successfully flush bss");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_set_bssid(char *bssid)
+int _net_dbus_set_bssid(network_info_s *network_info, char *bssid)
{
__NETWORK_FUNC_ENTER__;
WIFI_LOG(WIFI_INFO, "SetBSSID [%s]", bssid);
- params = g_variant_new("(sv)", prop_key, g_variant_new_string(bssid));
+ params = g_variant_new("(ssv)", network_info->interface_name,
+ prop_key, g_variant_new_string(bssid));
- message = _net_invoke_dbus_method(CONNMAN_SERVICE,
- CONNMAN_WIFI_TECHNOLOGY_PREFIX,
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, CONNMAN_WIFI_TECHNOLOGY_PREFIX,
CONNMAN_TECHNOLOGY_INTERFACE,
method, params, &Error);
return Error;
}
-int _net_dbus_get_5ghz_support(gboolean *supported)
+int _net_dbus_get_5ghz_support(network_info_s *network_info, gboolean *supported)
{
__NETWORK_FUNC_ENTER__;
gchar *key = NULL;
gboolean is_5ghz_supported = FALSE;
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
CONNMAN_SERVICE, CONNMAN_WIFI_TECHNOLOGY_PREFIX,
- CONNMAN_TECHNOLOGY_INTERFACE, "Get5GhzSupported", NULL, &Error);
+ CONNMAN_TECHNOLOGY_INTERFACE, "Get5GhzSupported",
+ NULL, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to get technology properties");
return Error;
}
-int _net_dbus_get_auto_connect_mode(int *connect_mode)
+int _net_dbus_get_auto_connect_mode(network_info_s *network_info,
+ int *connect_mode)
{
__NETWORK_FUNC_ENTER__;
gchar *key = NULL;
gboolean status = TRUE;
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
- CONNMAN_MANAGER_INTERFACE, "GetProperties", NULL, &Error);
+ CONNMAN_MANAGER_INTERFACE, "GetProperties",
+ NULL, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to get service properties");
}
-int _net_dbus_set_auto_connect_mode(int connect_mode)
+int _net_dbus_set_auto_connect_mode(network_info_s *network_info, int connect_mode)
{
__NETWORK_FUNC_ENTER__;
params = g_variant_new("(sv)", key, (connect_mode == 1) ?
g_variant_new_boolean(value_enable) : g_variant_new_boolean(value_disable));
- message = _net_invoke_dbus_method(CONNMAN_SERVICE,
- CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
- "SetProperty", params, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE, "SetProperty",
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to Set AutoConnect");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_wifi_set_autoconnect(const char *profile_name, gboolean autoconnect)
+int _net_dbus_wifi_set_autoconnect(network_info_s *network_info,
+ const char *profile_name, gboolean autoconnect)
{
__NETWORK_FUNC_ENTER__;
params = g_variant_new("(sv)", "AutoConnect", g_variant_new_boolean(autoconnect));
- message = _net_invoke_dbus_method(CONNMAN_SERVICE,
- profile_name, CONNMAN_SERVICE_INTERFACE,
- "SetProperty", params, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, profile_name,
+ CONNMAN_SERVICE_INTERFACE, "SetProperty",
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to Set AutoConnect");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_wifi_get_autoconnect(const char *profile_name, gboolean *autoconnect)
+int _net_dbus_wifi_get_autoconnect(network_info_s *network_info,
+ const char *profile_name, gboolean *autoconnect)
{
__NETWORK_FUNC_ENTER__;
GVariantIter *iter = NULL;
gchar *key = NULL;
- message = _net_invoke_dbus_method(CONNMAN_SERVICE,
- profile_name, CONNMAN_SERVICE_INTERFACE,
- "GetProperties", NULL, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, profile_name,
+ CONNMAN_SERVICE_INTERFACE, "GetProperties",
+ NULL, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to get service properties");
__NETWORK_FUNC_EXIT__;
{
__NETWORK_FUNC_ENTER__;
- WIFI_LOG(WIFI_INFO, "__net_wps_cancel_wifi_reply() called\n");
+ WIFI_LOG(WIFI_INFO, "__net_wps_cancel_wifi_reply() called");
GDBusConnection *conn = NULL;
GVariant *dbus_result = NULL;
dbus_result = g_dbus_connection_call_finish(conn, res, &error);
if (error != NULL) {
- WIFI_LOG(WIFI_ERROR, "error msg - [%s]\n", error->message);
+ WIFI_LOG(WIFI_ERROR, "error msg - [%s]", error->message);
g_error_free(error);
}
if (dbus_result)
g_variant_unref(dbus_result);
- _net_dbus_pending_call_unref();
-
__NETWORK_FUNC_EXIT__;
}
-int _net_dbus_cancel_wps(void)
+int _net_dbus_cancel_wps(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
+ GVariant *params = NULL;
net_err_e Error = NET_ERR_NONE;
- Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
- "RequestWpsCancel", NULL, DBUS_REPLY_TIMEOUT,
+ params = g_variant_new("(s)", network_info->interface_name);
+
+ Error = _net_invoke_dbus_method_nonblock(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "RequestWpsCancel",
+ params, DBUS_REPLY_TIMEOUT,
__net_wps_cancel_reply);
__NETWORK_FUNC_EXIT__;
{
__NETWORK_FUNC_ENTER__;
- int callback_flag = FALSE;
GDBusConnection *conn = NULL;
GError *error = NULL;
GVariant *dbus_result = NULL;
- net_event_info_s event_data;
+ net_event_info_s *event_data = NULL;
net_err_e Error = NET_ERR_NONE;
- network_request_table_s *wps_info =
- &request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS];
- memset(&event_data, 0, sizeof(event_data));
+ network_info_s *network_info = (network_info_s *)user_data;
+ network_request_table_s *request_table = network_info->request_table;
+ network_request_table_s *wps_info = &request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS];
+
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
conn = G_DBUS_CONNECTION(source_object);
dbus_result = g_dbus_connection_call_finish(conn, res, &error);
if (error != NULL) {
- WIFI_LOG(WIFI_INFO, "error msg - [%s]\n", error->message);
+ WIFI_LOG(WIFI_INFO, "error msg - [%s]", error->message);
Error = __net_error_string_to_enum(error->message);
g_error_free(error);
} else
- WIFI_LOG(WIFI_INFO, "error msg is NULL\n");
+ WIFI_LOG(WIFI_INFO, "error msg is NULL");
if (dbus_result)
g_variant_unref(dbus_result);
- if (Error == NET_ERR_NONE)
- goto done;
+ if (Error == NET_ERR_NONE) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
- WIFI_LOG(WIFI_ERROR, "Connection open failed. Error [%d]\n", Error);
+ WIFI_LOG(WIFI_ERROR, "Connection open failed. Error [%d]", Error);
memset(wps_info, 0, sizeof(network_request_table_s));
- event_data.Error = Error;
- event_data.Event = NET_EVENT_WIFI_WPS_RSP;
-
- WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_WIFI_WPS_RSP Error = %s\n",
- _net_print_error(event_data.Error));
+ event_data->Error = Error;
+ event_data->Event = NET_EVENT_WIFI_WPS_RSP;
- callback_flag = TRUE;
+ WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_WIFI_WPS_RSP Error = %s",
+ _net_print_error(event_data->Error));
-done:
- _net_dbus_pending_call_unref();
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
- if (callback_flag)
- _net_client_callback(&event_data);
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
}
-int _net_dbus_open_connection_without_ssid()
+int _net_dbus_open_connection_without_ssid(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
GVariant *params = NULL;
- params = g_variant_new("(s)", "PBC");
- WIFI_LOG(WIFI_ERROR, "Invoke wps connection without ssid");
+ params = g_variant_new("(ss)", network_info->interface_name, "PBC");
+ WIFI_LOG(WIFI_INFO, "Invoke wps connection without ssid");
- Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
- "RequestWpsConnect", params, DBUS_REPLY_TIMEOUT,
+ Error = _net_invoke_dbus_method_nonblock(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "RequestWpsConnect",
+ params, DBUS_REPLY_TIMEOUT,
__net_wps_connect_wifi_reply);
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_open_pin_connection_without_ssid(const char *pin)
+int _net_dbus_open_pin_connection_without_ssid(network_info_s *network_info,
+ const char *pin)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
GVariant *params = NULL;
- params = g_variant_new("(s)", pin);
+ params = g_variant_new("(ss)", network_info->interface_name, pin);
- Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
- "RequestWpsConnect", params, DBUS_REPLY_TIMEOUT,
+ Error = _net_invoke_dbus_method_nonblock(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "RequestWpsConnect",
+ params, DBUS_REPLY_TIMEOUT,
__net_wps_connect_wifi_reply);
return Error;
}
-int _net_dbus_dpp_enter_peer_uri(guint32 peer_id, guint32 own_id, const char *uri)
+int _net_dbus_dpp_enter_peer_uri(network_info_s *network_info,
+ guint32 peer_id, guint32 own_id, const char *uri)
{
__NETWORK_FUNC_ENTER__;
params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
"DppEnterPeerUri", params, &Error);
if (message == NULL) {
}
g_variant_unref(message);
- WIFI_LOG(WIFI_INFO, "Successfully DppEnterPeerUri\n");
+ WIFI_LOG(WIFI_INFO, "Successfully DppEnterPeerUri");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_dpp_generate_uri(guint32 peer_id, guint32 own_id, gboolean is_initiator, const char *key)
+int _net_dbus_dpp_generate_uri(network_info_s *network_info,
+ guint32 peer_id, guint32 own_id, gboolean is_initiator, const char *key)
{
__NETWORK_FUNC_ENTER__;
params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
"DppGenerateUri", params, &Error);
if (message == NULL) {
}
g_variant_unref(message);
- WIFI_LOG(WIFI_INFO, "Successfully DppGenerateUri\n");
+ WIFI_LOG(WIFI_INFO, "Successfully DppGenerateUri");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_dpp_start_configurator_initiator(const gchar *group_id, const gchar *ssid,
+int _net_dbus_dpp_start_configurator_initiator(network_info_s *network_info,
+ const gchar *group_id, const gchar *ssid,
const gchar *peer_uri, guint32 peer_id, const gchar *net_role,
const gchar *akm, const gchar *configurator_key, const gchar *pass)
{
params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
"DppStartConfiguratorInitiator", params, &Error);
if (message == NULL) {
}
g_variant_unref(message);
- WIFI_LOG(WIFI_INFO, "Successfully DppStartConfiguratorInitiator\n");
+ WIFI_LOG(WIFI_INFO, "Successfully DppStartConfiguratorInitiator");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_dpp_start_enrollee_initiator(const gchar *peer_uri, guint32 peer_id)
+int _net_dbus_dpp_start_enrollee_initiator(network_info_s *network_info,
+ const gchar *peer_uri, guint32 peer_id)
{
__NETWORK_FUNC_ENTER__;
GVariant *params = NULL;
params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
"DppStartEnrolleeInitiator", params, &Error);
if (message == NULL) {
}
g_variant_unref(message);
- WIFI_LOG(WIFI_INFO, "Successfully DppStartEnrolleeInitiator\n");
+ WIFI_LOG(WIFI_INFO, "Successfully DppStartEnrolleeInitiator");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_dpp_start_configurator_responder(const gchar *group_id,
- const gchar *ssid, const gchar *net_role, const gchar *akm,
+int _net_dbus_dpp_start_configurator_responder(network_info_s *network_info,
+ const gchar *group_id, const gchar *ssid, const gchar *net_role, const gchar *akm,
const gchar *auth_key, const gchar *configurator_key, const gchar *pass)
{
__NETWORK_FUNC_ENTER__;
params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
"DppStartConfiguratorResponder", params, &Error);
if (message == NULL) {
}
g_variant_unref(message);
- WIFI_LOG(WIFI_INFO, "Successfully DppStartConfiguratorResponder\n");
+ WIFI_LOG(WIFI_INFO, "Successfully DppStartConfiguratorResponder");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_dpp_start_enrollee_responder(const gchar *auth_key)
+int _net_dbus_dpp_start_enrollee_responder(network_info_s *network_info,
+ const gchar *auth_key)
{
__NETWORK_FUNC_ENTER__;
GVariant *params = NULL;
params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
"DppStartEnrolleeResponder", params, &Error);
if (message == NULL) {
}
g_variant_unref(message);
- WIFI_LOG(WIFI_INFO, "Successfully DppStartEnrolleeResponder\n");
+ WIFI_LOG(WIFI_INFO, "Successfully DppStartEnrolleeResponder");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_dpp_stop(guint32 peer_id, guint32 own_id, gboolean is_initiator)
+int _net_dbus_dpp_stop(network_info_s *network_info,
+ guint32 peer_id, guint32 own_id, gboolean is_initiator)
{
__NETWORK_FUNC_ENTER__;
GVariant *params = NULL;
params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
"DppStop", params, &Error);
if (message == NULL) {
}
g_variant_unref(message);
- WIFI_LOG(WIFI_INFO, "Successfully stop DPP\n");
+ WIFI_LOG(WIFI_INFO, "Successfully stop DPP");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_tdls_disconnect(const char* peer_mac_addr)
+int _net_dbus_tdls_disconnect(network_info_s *network_info, const char* peer_mac_addr)
{
__NETWORK_FUNC_ENTER__;
params = g_variant_new("(s)", peer_mac_addr);
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, method, params, &Error);
+ NETCONFIG_WIFI_INTERFACE, method,
+ params, &Error);
if (message == NULL) {
- WIFI_LOG(WIFI_ERROR, "Failed to TDLS Disconnect Request\n");
+ WIFI_LOG(WIFI_ERROR, "Failed to TDLS Disconnect Request");
__NETWORK_FUNC_EXIT__;
return Error;
}
g_variant_get(message, "(i)", &ret);
WIFI_LOG(WIFI_INFO, "[%s] success", method);
- WIFI_LOG(WIFI_INFO, ", status [%d]\n", ret);
+ WIFI_LOG(WIFI_INFO, ", status [%d]", ret);
if (ret)
Error = NET_ERR_NONE;
return Error;
}
-int _net_dbus_tdls_connected_peer(char** peer_mac_addr)
+int _net_dbus_tdls_connected_peer(network_info_s *network_info,
+ char** peer_mac_addr)
{
__NETWORK_FUNC_ENTER__;
const char *method = "TdlsConnectedPeer";
if (NULL == peer_mac_addr) {
- WIFI_LOG(WIFI_ERROR, "Invalid Parameter\n");
+ WIFI_LOG(WIFI_ERROR, "Invalid Parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, method, NULL, &Error);
+ NETCONFIG_WIFI_INTERFACE, method,
+ NULL, &Error);
if (message == NULL) {
- WIFI_LOG(WIFI_ERROR, "Failed to Get Peer Connected Mac address\n");
+ WIFI_LOG(WIFI_ERROR, "Failed to Get Peer Connected Mac address");
__NETWORK_FUNC_EXIT__;
return Error;
}
g_variant_get(message, "(s)", peer_mac_addr);
WIFI_LOG(WIFI_INFO, "[%s] success", method);
- WIFI_LOG(WIFI_INFO, "TDLS Peer Mac address [%s]\n", *peer_mac_addr);
+ WIFI_LOG(WIFI_INFO, "TDLS Peer Mac address [%s]", *peer_mac_addr);
g_variant_unref(message);
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_tdls_connect(const char *peer_mac_addr)
+int _net_dbus_tdls_connect(network_info_s *network_info, const char *peer_mac_addr)
{
__NETWORK_FUNC_ENTER__;
params = g_variant_new("(s)", peer_mac_addr);
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, method, params, &Error);
+ NETCONFIG_WIFI_INTERFACE, method,
+ params, &Error);
if (message == NULL) {
- WIFI_LOG(WIFI_ERROR, "Failed to TDLS Connect Request\n");
+ WIFI_LOG(WIFI_ERROR, "Failed to TDLS Connect Request");
__NETWORK_FUNC_EXIT__;
return Error;
}
g_variant_get(message, "(i)", &ret);
WIFI_LOG(WIFI_INFO, "[%s] success", method);
- WIFI_LOG(WIFI_INFO, ", status [%d]\n", ret);
+ WIFI_LOG(WIFI_INFO, ", status [%d]", ret);
if (ret)
Error = NET_ERR_NONE;
return Error;
}
-int _net_dbus_tdls_discover(const char *peer_mac_addr)
+int _net_dbus_tdls_discover(network_info_s *network_info, const char *peer_mac_addr)
{
__NETWORK_FUNC_ENTER__;
params = g_variant_new("(s)", peer_mac_addr);
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, method, params, &Error);
+ NETCONFIG_WIFI_INTERFACE, method,
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to request TDLS discover : Error [%d]", Error);
g_variant_get(message, "(i)", &ret);
WIFI_LOG(WIFI_INFO, "[%s] success", method);
- WIFI_LOG(WIFI_INFO, ", status [%d]\n", ret);
+ WIFI_LOG(WIFI_INFO, ", status [%d]", ret);
if (ret == 0x00)
Error = NET_ERR_NONE;
return Error;
}
-int _net_dbus_tdls_enable_channel_switch(const char* peer_mac_addr, int freq)
+int _net_dbus_tdls_enable_channel_switch(network_info_s *network_info,
+ const char* peer_mac_addr, int freq)
{
__NETWORK_FUNC_ENTER__;
params = g_variant_new("(si)", peer_mac_addr, freq);
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, "TdlsChannelSwitch", params, &Error);
+ NETCONFIG_WIFI_INTERFACE, "TdlsChannelSwitch",
+ params, &Error);
if (message == NULL) {
- WIFI_LOG(WIFI_ERROR, "Failed to Enable TDLS Channel Switch Request\n");
+ WIFI_LOG(WIFI_ERROR, "Failed to Enable TDLS Channel Switch Request");
__NETWORK_FUNC_EXIT__;
return Error;
}
g_variant_get(message, "(i)", &ret);
- WIFI_LOG(WIFI_INFO, "Status [%d]\n", ret);
+ WIFI_LOG(WIFI_INFO, "Status [%d]", ret);
if (ret == 0)
Error = NET_ERR_NONE;
return Error;
}
-int _net_dbus_tdls_disable_channel_switch(const char* peer_mac_addr)
+int _net_dbus_tdls_disable_channel_switch(network_info_s *network_info,
+ const char* peer_mac_addr)
{
__NETWORK_FUNC_ENTER__;
params = g_variant_new("(s)", peer_mac_addr);
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, "TdlsCancelChannelSwitch", params, &Error);
+ NETCONFIG_WIFI_INTERFACE, "TdlsCancelChannelSwitch",
+ params, &Error);
if (message == NULL) {
- WIFI_LOG(WIFI_ERROR, "Failed to Disable TDLS Channel Switch Request\n");
+ WIFI_LOG(WIFI_ERROR, "Failed to Disable TDLS Channel Switch Request");
__NETWORK_FUNC_EXIT__;
return Error;
}
g_variant_get(message, "(i)", &ret);
- WIFI_LOG(WIFI_INFO, "Status [%d]\n", ret);
+ WIFI_LOG(WIFI_INFO, "Status [%d]", ret);
if (ret == 0)
Error = NET_ERR_NONE;
-int _net_dbus_config_get_id_list(GSList **list)
+int _net_dbus_config_get_id_list(network_info_s *network_info, GSList **list)
{
__NETWORK_FUNC_ENTER__;
GVariantIter *iter = NULL;
gchar *config_id = NULL;
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
NETCONFIG_WIFI_INTERFACE, "GetConfigIds",
- g_variant_new("()"), &Error);
+ g_variant_new("(s)", network_info->interface_name), &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to GetConfigIds");
return Error;
}
-int _net_dbus_config_set_field(const gchar *config_id, const gchar *key, const gchar *value)
+int _net_dbus_config_set_field(network_info_s *network_info,
+ const gchar *config_id, const gchar *key, const gchar *value)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
GVariant *message = NULL;
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
NETCONFIG_WIFI_INTERFACE, "SetConfigField",
g_variant_new("(sss)", config_id, key, value), &Error);
return Error;
}
-int _net_dbus_config_get_passphrase(const gchar *config_id, gchar **passphrase)
+int _net_dbus_config_get_passphrase(network_info_s *network_info,
+ const gchar *config_id, gchar **passphrase)
{
__NETWORK_FUNC_ENTER__;
GVariant *message = NULL;
gchar *val = NULL;
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
NETCONFIG_WIFI_INTERFACE, "GetConfigPassphrase",
g_variant_new("(s)", config_id), &Error);
return Error;
}
-int _net_dbus_config_save_configurations(const gchar *config_id, const gchar *name,
+int _net_dbus_config_save_configurations(network_info_s *network_info,
+ const gchar *config_id, const gchar *name,
const gchar *ssid, const gchar *passphrase, const gchar *proxy_address,
net_ip_info_config_s *ip_info, gboolean is_hidden, gboolean is_created)
{
break;
}
- params = g_variant_new("(s@a{sv})", config_id, g_variant_builder_end(b));
+ params = g_variant_new("(ss@a{sv})", network_info->interface_name,
+ config_id, g_variant_builder_end(b));
g_variant_builder_unref(b);
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
NETCONFIG_WIFI_INTERFACE, "SaveConfiguration",
params, &Error);
return Error;
}
-int _net_dbus_config_save_eap_configurations(const gchar *config_id,
- const gchar *name, const gchar *ssid, const gchar *passphrase,
+int _net_dbus_config_save_eap_configurations(network_info_s *network_info,
+ const gchar *config_id, const gchar *name, const gchar *ssid, const gchar *passphrase,
const gchar *proxy_address, net_eap_config_s *eap_config, gboolean is_hidden, gboolean is_created)
{
__NETWORK_FUNC_ENTER__;
g_free(eap_type);
}
- params = g_variant_new("(s@a{sv})", config_id, g_variant_builder_end(b));
+ params = g_variant_new("(ss@a{sv})", network_info->interface_name,
+ config_id, g_variant_builder_end(b));
g_variant_builder_unref(b);
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
NETCONFIG_WIFI_INTERFACE, "SaveEapConfiguration",
params, &Error);
return Error;
}
-int _net_dbus_config_remove_configurations(const gchar *config_id)
+int _net_dbus_config_remove_configurations(network_info_s *network_info,
+ const gchar *config_id)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
GVariant *message = NULL;
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
NETCONFIG_WIFI_INTERFACE, "RemoveConfiguration",
- g_variant_new("(s)", config_id), &Error);
+ g_variant_new("(ss)", network_info->interface_name, config_id),
+ &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to RemoveConfiguration");
return Error;
}
-int _net_dbus_config_load_configurations(const gchar *config_id, gchar **name,
- gchar **passphrase, net_wifi_security_type_e *security_type, gchar **proxy_address,
+int _net_dbus_config_load_configurations(network_info_s *network_info,
+ const gchar *config_id, gchar **name, gchar **passphrase,
+ net_wifi_security_type_e *security_type, gchar **proxy_address,
gboolean *is_hidden, net_ip_info_config_s **ip_info, void *last_error)
{
__NETWORK_FUNC_ENTER__;
int *wifi_last_error = (int *)last_error;
int order = 0;
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
NETCONFIG_WIFI_INTERFACE, "LoadConfiguration",
- g_variant_new("(s)", config_id), &Error);
+ g_variant_new("(ss)", network_info->interface_name, config_id),
+ &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to LoadConfiguration");
return Error;
}
-int _net_dbus_config_load_eap_configurations(const gchar *config_id,
- gchar **name, net_wifi_security_type_e *security_type, gchar **proxy_address,
- gboolean *is_hidden, net_eap_config_s **eap_config, void *last_error)
+int _net_dbus_config_load_eap_configurations(network_info_s *network_info,
+ const gchar *config_id, gchar **name, net_wifi_security_type_e *security_type,
+ gchar **proxy_address, gboolean *is_hidden, net_eap_config_s **eap_config, void *last_error)
{
__NETWORK_FUNC_ENTER__;
GVariant *value;
int *wifi_last_error = (int *)last_error;
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
NETCONFIG_WIFI_INTERFACE, "LoadEapConfiguration",
- g_variant_new("(s)", config_id), &Error);
+ g_variant_new("(ss)", network_info->interface_name, config_id),
+ &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to LoadEapConfiguration");
return Error;
}
-int _net_dbus_device_policy_get_wifi(int *state)
+int _net_dbus_device_policy_get_wifi(network_info_s *network_info, int *state)
{
__NETWORK_FUNC_ENTER__;
GVariant *message = NULL;
if (state == NULL) {
- WIFI_LOG(WIFI_ERROR, "Invalid Parameter\n");
+ WIFI_LOG(WIFI_ERROR, "Invalid Parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_NETWORK_PATH,
- NETCONFIG_NETWORK_INTERFACE, "DevicePolicyGetWifi", NULL, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_NETWORK_PATH,
+ NETCONFIG_NETWORK_INTERFACE, "DevicePolicyGetWifi",
+ NULL, &Error);
if (message == NULL) {
- WIFI_LOG(WIFI_ERROR, "Failed to get wifi device policy\n");
+ WIFI_LOG(WIFI_ERROR, "Failed to get wifi device policy");
return Error;
}
g_variant_get(message, "(i)", state);
- WIFI_LOG(WIFI_INFO, "Wifi device policy state [%d]\n", *state);
+ WIFI_LOG(WIFI_INFO, "Wifi device policy state [%d]", *state);
g_variant_unref(message);
return Error;
}
-int _net_dbus_device_policy_get_wifi_profile(int *state)
+int _net_dbus_device_policy_get_wifi_profile(network_info_s *network_info,
+ int *state)
{
__NETWORK_FUNC_ENTER__;
GVariant *message = NULL;
if (state == NULL) {
- WIFI_LOG(WIFI_ERROR, "Invalid Parameter\n");
+ WIFI_LOG(WIFI_ERROR, "Invalid Parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_NETWORK_PATH,
- NETCONFIG_NETWORK_INTERFACE, "DevicePolicyGetWifiProfile", NULL, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_NETWORK_PATH,
+ NETCONFIG_NETWORK_INTERFACE, "DevicePolicyGetWifiProfile",
+ NULL, &Error);
if (message == NULL) {
- WIFI_LOG(WIFI_ERROR, "Failed to get wifi device policy\n");
+ WIFI_LOG(WIFI_ERROR, "Failed to get wifi device policy");
return Error;
}
g_variant_get(message, "(i)", state);
- WIFI_LOG(WIFI_INFO, "Wifi profile device policy state [%d]\n", *state);
+ WIFI_LOG(WIFI_INFO, "Wifi profile device policy state [%d]", *state);
g_variant_unref(message);
return Error;
}
-int _net_dbus_resume_bgscan(void)
+int _net_dbus_resume_bgscan(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
+ GVariant *params = NULL;
GVariant *message = NULL;
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, "ResumeBgscan", NULL, &Error);
+ params = g_variant_new("(s)", network_info->interface_name);
+
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "ResumeBgscan",
+ params, &Error);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "_net_invoke_dbus_method failed");
return Error;
}
-int _net_dbus_pause_bgscan(void)
+int _net_dbus_pause_bgscan(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
+ GVariant *params = NULL;
GVariant *message = NULL;
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, "PauseBgscan", NULL, &Error);
+ params = g_variant_new("(s)", network_info->interface_name);
+
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "PauseBgscan",
+ params, &Error);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "_net_invoke_dbus_method failed");
return Error;
}
-int _net_dbus_get_autoscan(gboolean *autoscan)
+int _net_dbus_get_autoscan(network_info_s *network_info, gboolean *autoscan)
{
__NETWORK_FUNC_ENTER__;
+ GVariant *params = NULL;
GVariant *message = NULL;
net_err_e Error = NET_ERR_NONE;
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
- "GetAutoscan", NULL, &Error);
+ params = g_variant_new("(s)", network_info->interface_name);
+
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "GetAutoscan",
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to Get Passpoint");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_get_autoscanmode(unsigned int *autoscanmode)
+int _net_dbus_get_autoscanmode(network_info_s *network_info,
+ unsigned int *autoscanmode)
{
__NETWORK_FUNC_ENTER__;
+ GVariant *params = NULL;
GVariant *message = NULL;
net_err_e Error = NET_ERR_NONE;
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
- "GetAutoscanmode", NULL, &Error);
+ params = g_variant_new("(s)", network_info->interface_name);
+
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "GetAutoscanmode",
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to Get Passpoint");
__NETWORK_FUNC_EXIT__;
GDBusConnection *conn = NULL;
GError *error = NULL;
- net_err_e Error = NET_ERR_NONE;
- net_event_info_s event_data = { 0, };
GVariant *reply;
+ net_err_e Error = NET_ERR_NONE;
+ net_event_info_s *event_data = NULL;
+ network_info_s *network_info = (network_info_s *)user_data;
+ network_request_table_s *request_table = network_info->request_table;
+
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
conn = G_DBUS_CONNECTION(source_object);
reply = g_dbus_connection_call_finish(conn, res, &error);
if (error != NULL) {
- WIFI_LOG(WIFI_ERROR, "Scan failed. Error [%s]\n",
+ WIFI_LOG(WIFI_ERROR, "Scan failed. Error [%s]",
error->message);
Error = __net_error_string_to_enum(error->message);
g_error_free(error);
if (Error == NET_ERR_IN_PROGRESS) {
/* should retry scan after receiving scan result */
if (request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].flag == TRUE) {
- WIFI_LOG(WIFI_INFO, "Multi Scan pending\n");
- scan_pending = TRUE;
+ WIFI_LOG(WIFI_INFO, "Multi Scan pending");
+ network_info->scan_pending = TRUE;
}
} else if (Error != NET_ERR_NONE) {
- WIFI_LOG(WIFI_ERROR, "Multi Scan failed. Error [%d]\n", Error);
+ WIFI_LOG(WIFI_ERROR, "Multi Scan failed. Error [%d]", Error);
g_slist_free_full(request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_list, g_free);
if (request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].flag == TRUE) {
memset(&request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN],
0, sizeof(network_request_table_s));
- event_data.Event = NET_EVENT_WIFI_MULTI_SCAN_RSP;
- event_data.Datalength = 0;
- event_data.Data = NULL;
- event_data.Error = Error;
+ event_data->Event = NET_EVENT_WIFI_MULTI_SCAN_RSP;
+ event_data->Datalength = 0;
+ event_data->Data = NULL;
+ event_data->Error = Error;
+
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
- _net_dbus_pending_call_unref();
- _net_client_callback(&event_data);
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
return;
}
} else
- WIFI_LOG(WIFI_INFO, "Multi Scan Request success\n");
-
- _net_dbus_pending_call_unref();
+ WIFI_LOG(WIFI_INFO, "Multi Scan Request success");
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
}
-int _net_dbus_multi_scan_request(GSList *multi_scan_list)
+int _net_dbus_multi_scan_request(network_info_s *network_info,
+ GSList *multi_scan_list)
{
__NETWORK_FUNC_ENTER__;
char freq[NET_WLAN_FREQ_LEN] = {0, };
WIFI_LOG(WIFI_INFO, "multi_scan_type:%d, Number of elements in a list:%d",
- request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_type,
+ network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_type,
g_slist_length(multi_scan_list));
builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
- if (request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_type == WIFI_MULTI_SCAN_SSID) {
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_type == WIFI_MULTI_SCAN_SSID) {
for (list = multi_scan_list; list; list = list->next) {
WIFI_LOG(WIFI_INFO, "AP name: %s", ((wifi_manager_multi_scan_ap_s *)list->data)->str);
g_strlcpy(ssid, ((wifi_manager_multi_scan_ap_s *)list->data)->str, NET_WLAN_ESSID_LEN + 1);
g_variant_builder_add(builder, "{sv}", "SSID", g_variant_new_string(ssid));
}
- } else if (request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_type == WIFI_MULTI_SCAN_FREQ) {
+ } else if (network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_type == WIFI_MULTI_SCAN_FREQ) {
for (list = multi_scan_list; list; list = list->next) {
WIFI_LOG(WIFI_INFO, "Freq: %s", ((wifi_manager_multi_scan_ap_s *)list->data)->str);
g_strlcpy(freq, ((wifi_manager_multi_scan_ap_s *)list->data)->str, NET_WLAN_FREQ_LEN);
params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- Error = _net_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
- CONNMAN_WIFI_TECHNOLOGY_PREFIX,
- CONNMAN_TECHNOLOGY_INTERFACE, "SpecificScan", params,
- DBUS_REPLY_TIMEOUT, __net_multi_scan_request_reply);
+ Error = _net_invoke_dbus_method_nonblock(network_info,
+ CONNMAN_SERVICE, CONNMAN_WIFI_TECHNOLOGY_PREFIX,
+ CONNMAN_TECHNOLOGY_INTERFACE, "SpecificScan",
+ params, DBUS_REPLY_TIMEOUT,
+ __net_multi_scan_request_reply);
if (Error == NET_ERR_IN_PROGRESS)
Error = NET_ERR_NONE; //LCOV_EXCL_LINE
return Error;
}
-int _net_dbus_get_max_scan_ssids(int *max_scan_ssids)
+int _net_dbus_get_max_scan_ssids(network_info_s *network_info, int *max_scan_ssids)
{
__NETWORK_FUNC_ENTER__;
GVariantIter *iter = NULL;
gchar *key = NULL;
- message = _net_invoke_dbus_method(
+ message = _net_invoke_dbus_method(network_info,
CONNMAN_SERVICE, CONNMAN_WIFI_TECHNOLOGY_PREFIX,
- CONNMAN_TECHNOLOGY_INTERFACE, "GetMaxScanSsid", NULL, &Error);
+ CONNMAN_TECHNOLOGY_INTERFACE, "GetMaxScanSsid",
+ NULL, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to get Max scan SSIDs.");
*max_scan_ssids = 0;
#define DBUS_OBJECT_PATH_MAX 150
-__thread network_info_s NetworkInfo = { 0, };
-extern __thread network_request_table_s request_table[NETWORK_REQUEST_TYPE_MAX];
-static wifi_tech_state_e g_tech_state = WIFI_TECH_UNKNOWN;
-
//LCOV_EXCL_START
-static int __net_check_get_privilege()
+static int __net_check_get_privilege(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
GVariant *message = NULL;
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_NETWORK_PATH,
- NETCONFIG_NETWORK_INTERFACE, "CheckGetPrivilege", NULL, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_NETWORK_PATH,
+ NETCONFIG_NETWORK_INTERFACE, "CheckGetPrivilege",
+ NULL, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to check get privilege"); //LCOV_EXCL_LINE
return Error; //LCOV_EXCL_LINE
return Error;
}
-static int __net_set_ip_conflict_detect_mode(bool detect)
+static int __net_set_ip_conflict_detect_mode(network_info_s *network_info, bool detect)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
GVariant *message = NULL;
GVariant *params;
- params = g_variant_new("(b)", detect);
+ params = g_variant_new("(sb)", network_info->interface_name, detect);
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, "IpConflictSetEnable", params, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "IpConflictSetEnable",
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to set conflict detect enable mode"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__;
return Error;
}
-static int __net_ip_conflict_detect_is_enabled(gboolean *state)
+static int __net_ip_conflict_detect_is_enabled(network_info_s *network_info,
+ gboolean *state)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
+ GVariant *params = NULL;
GVariant *message = NULL;
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, "IsIpConflictDetectEnabled", NULL, &Error);
+ params = g_variant_new("(s)", network_info->interface_name);
+
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "IsIpConflictDetectEnabled",
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to get conflict detect enable mode"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__;
}
-static int __net_check_profile_privilege()
+static int __net_check_profile_privilege(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
GVariant *message = NULL;
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_NETWORK_PATH,
- NETCONFIG_NETWORK_INTERFACE, "CheckProfilePrivilege", NULL, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_NETWORK_PATH,
+ NETCONFIG_NETWORK_INTERFACE, "CheckProfilePrivilege",
+ NULL, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to check profile privilege"); //LCOV_EXCL_LINE
return Error; //LCOV_EXCL_LINE
return WLAN_SEC_EAP_AUTH_NONE;
}
-static int __net_wifi_modify_profile(const char* ProfileName,
- net_profile_info_s* ProfInfo, net_profile_info_s* exProfInfo)
+static int __net_wifi_modify_profile(network_info_s *network_info,
+ const char* ProfileName, net_profile_info_s* ProfInfo,
+ net_profile_info_s* exProfInfo)
{
__NETWORK_FUNC_ENTER__;
if (ex_security_info->sec_mode == WLAN_SEC_MODE_WEP) {
if (g_strcmp0(security_info->authentication.wep.wepKey,
ex_security_info->authentication.wep.wepKey) != 0) {
- Error = _net_dbus_set_agent_passphrase_and_connect(
+ Error = _net_dbus_set_agent_passphrase_and_connect(network_info,
security_info->authentication.wep.wepKey, ProfileName);
if (NET_ERR_NONE != Error) {
ex_security_info->sec_mode == WLAN_SEC_MODE_WPA2_PSK) {
if (g_strcmp0(security_info->authentication.psk.pskKey,
ex_security_info->authentication.psk.pskKey) != 0) {
- Error = _net_dbus_set_agent_passphrase_and_connect(
+ Error = _net_dbus_set_agent_passphrase_and_connect(network_info,
security_info->authentication.psk.pskKey, ProfileName);
if (NET_ERR_NONE != Error) {
if ((ex_net_info->ProxyMethod != net_info->ProxyMethod) ||
(g_strcmp0(ex_net_info->ProxyAddr, net_info->ProxyAddr) != 0)) {
- Error = _net_dbus_set_proxy(ProfInfo, profilePath);
-
+ Error = _net_dbus_set_proxy(network_info, ProfInfo, profilePath);
if (Error != NET_ERR_NONE) {
__NETWORK_FUNC_EXIT__;
return Error;
(net_info->IpAddr.Data.Ipv4.s_addr != ex_net_info->IpAddr.Data.Ipv4.s_addr ||
net_info->SubnetMask.Data.Ipv4.s_addr != ex_net_info->SubnetMask.Data.Ipv4.s_addr ||
net_info->GatewayAddr.Data.Ipv4.s_addr != ex_net_info->GatewayAddr.Data.Ipv4.s_addr))) {
- Error = _net_dbus_set_profile_ipv4(ProfInfo, profilePath);
+
+ Error = _net_dbus_set_profile_ipv4(network_info, ProfInfo, profilePath);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to set IPv4");
net_info->PrefixLen6 != ex_net_info->PrefixLen6 ||
net_info->GatewayAddr6.Data.Ipv6.s6_addr != ex_net_info->GatewayAddr6.Data.Ipv6.s6_addr))) {
- Error = _net_dbus_set_profile_ipv6(ProfInfo, profilePath);
+ Error = _net_dbus_set_profile_ipv6(network_info, ProfInfo, profilePath);
if (Error != NET_ERR_NONE) {
- WIFI_LOG(WIFI_ERROR, "Error!!! Can't set IPv6\n");
+ WIFI_LOG(WIFI_ERROR, "Error!!! Can't set IPv6");
__NETWORK_FUNC_EXIT__;
return Error;
if (i < net_info->DnsCount ||
ex_net_info->DnsConfigType != net_info->DnsConfigType ||
ex_net_info->DnsConfigType6 != net_info->DnsConfigType6) {
- Error = _net_dbus_set_profile_dns(ProfInfo, profilePath);
+
+ Error = _net_dbus_set_profile_dns(network_info, ProfInfo, profilePath);
if (Error != NET_ERR_NONE) {
- WIFI_LOG(WIFI_ERROR, "Failed to set DNS\n");
+ WIFI_LOG(WIFI_ERROR, "Failed to set DNS");
__NETWORK_FUNC_EXIT__;
return Error;
return NET_ERR_NONE;
}
-static int __net_wifi_delete_profile(net_profile_name_s* WifiProfName,
- wlan_security_mode_type_e sec_mode, gboolean passpoint)
+static int __net_wifi_delete_profile(network_info_s *network_info,
+ net_profile_name_s* WifiProfName, wlan_security_mode_type_e sec_mode,
+ gboolean passpoint)
{
__NETWORK_FUNC_ENTER__;
GVariant *params;
if (passpoint == TRUE && WLAN_SEC_MODE_IEEE8021X == sec_mode) {
- message = _net_invoke_dbus_method(CONNMAN_SERVICE,
- WifiProfName->ProfileName,
- CONNMAN_SERVICE_INTERFACE, "Remove", NULL,
- &Error);
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, WifiProfName->ProfileName,
+ CONNMAN_SERVICE_INTERFACE, "Remove",
+ NULL, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to Remove service(profile)");
WifiProfName->ProfileName);
params = g_variant_new("(s)", param0);
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
- "DeleteEapConfig", params, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "DeleteEapConfig",
+ params, &Error);
} else if (passpoint == TRUE || WLAN_SEC_MODE_IEEE8021X != sec_mode) {
- message = _net_invoke_dbus_method(CONNMAN_SERVICE,
- WifiProfName->ProfileName,
- CONNMAN_SERVICE_INTERFACE, "Remove", NULL,
- &Error);
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, WifiProfName->ProfileName,
+ CONNMAN_SERVICE_INTERFACE, "Remove",
+ NULL, &Error);
} else {
g_snprintf(param0, NET_PROFILE_NAME_LEN_MAX + 8, "string:%s",
WifiProfName->ProfileName);
params = g_variant_new("(s)", param0);
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
- "DeleteEapConfig", params, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "DeleteEapConfig",
+ params, &Error);
}
if (message == NULL) {
return Error;
}
-static int __net_extract_service_info(
+static int __net_extract_service_info(network_info_s *network_info,
const char* ProfileName, GVariantIter *iter,
net_profile_info_s* ProfInfo)
{
}
if (isProf) {
- if ((Error = net_init_profile_info(ProfInfo)) != NET_ERR_NONE) {
+ if ((Error = net_init_profile_info(network_info, ProfInfo)) != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to init profile");
__NETWORK_FUNC_EXIT__;
return Error;
return Error;
}
-static int __net_extract_all_services(GVariantIter *array,
- const char *service_prefix, GSList **profile_list)
+static int __net_extract_all_services(network_info_s *network_info,
+ GVariantIter *array, const char *service_prefix, GSList **profile_list)
{
net_profile_info_s *ProfInfo = NULL;
net_err_e Error = NET_ERR_NONE;
if (obj == NULL)
continue;
+ if (_net_check_service_mac_addr(network_info, obj) != TRUE)
+ continue;
+
if (g_str_has_prefix(obj, service_prefix) == TRUE) {
ProfInfo = g_try_malloc0(sizeof(net_profile_info_s));
if (ProfInfo == NULL)
goto error;
- if ((Error = net_init_profile_info(ProfInfo)) != NET_ERR_NONE) {
+ if ((Error = net_init_profile_info(network_info, ProfInfo)) != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to init profile");
goto error;
}
return Error;
}
-static int __net_extract_services(GVariantIter *message, GSList **profile_list)
+static int __net_extract_services(network_info_s *network_info,
+ GVariantIter *message, GSList **profile_list)
{
__NETWORK_FUNC_ENTER__;
service_prefix = CONNMAN_WIFI_SERVICE_PROFILE_PREFIX;
- Error = __net_extract_all_services(message, service_prefix, profile_list);
+ Error = __net_extract_all_services(network_info,
+ message, service_prefix, profile_list);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to extract services from received message");
__NETWORK_FUNC_EXIT__;
return Error;
}
-static int __net_get_profile_info(
- const char* ProfileName, net_profile_info_s* ProfInfo)
+static int __net_get_profile_info(network_info_s *network_info,
+ const char *ProfileName, net_profile_info_s *ProfInfo)
{
__NETWORK_FUNC_ENTER__;
GVariantIter *service = NULL;
gchar *path = NULL;
- message = _net_invoke_dbus_method(CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
- CONNMAN_MANAGER_INTERFACE, "GetServices", NULL, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE, "GetServices",
+ NULL, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to get profile");
goto done;
g_variant_get(message, "(a(oa{sv}))", &iter);
while (g_variant_iter_loop(iter, "(oa{sv})", &path, &service)) {
if (g_strcmp0(ProfileName, path) == 0) {
- Error = __net_extract_service_info(ProfileName, service, ProfInfo);
+ Error = __net_extract_service_info(network_info,
+ ProfileName, service, ProfInfo);
g_variant_iter_free(service);
g_free(path);
break;
return Error;
}
-static gboolean __net_is_connecting(const char *profile_name)
+static net_err_e __net_get_wifi_state(network_info_s *network_info)
{
- __NETWORK_FUNC_ENTER__;
+ net_err_e err = NET_ERR_NONE;
- char *svc_name1 = request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
- char *svc_name2 = request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
-
- if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
- g_strcmp0(profile_name, svc_name1) == 0) {
- __NETWORK_FUNC_EXIT__;
- return TRUE;
- } else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
- g_strcmp0(profile_name, svc_name2) == 0) {
- __NETWORK_FUNC_EXIT__;
- return TRUE;
+ if (network_info->wifi_state == WIFI_UNKNOWN ||
+ network_info->wifi_state == WIFI_OFF) {
+ err = _net_get_wifi_state(network_info);
}
- __NETWORK_FUNC_EXIT__;
- return FALSE;
+ return err;
}
-static void __net_abort_open_connection(const char *profile_name)
+void net_forget_ap_finished(network_info_s *network_info, net_err_e Error)
{
__NETWORK_FUNC_ENTER__;
- net_event_info_s event_data;
+ net_event_info_s *event_data = NULL;
char event_string[64];
- char *svc_name1 = request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
- char *svc_name2 = request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
-
- if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
- g_strcmp0(profile_name, svc_name1) == 0) {
- memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
- sizeof(network_request_table_s));
-
- event_data.Event = NET_EVENT_OPEN_RSP;
- g_strlcpy(event_string, "Sending NET_EVENT_OPEN_RSP", 64);
-
- _net_dbus_pending_call_unref();
- } else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
- g_strcmp0(profile_name, svc_name2) == 0) {
- memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
- sizeof(network_request_table_s));
-
- event_data.Event = NET_EVENT_WIFI_WPS_RSP;
- g_strlcpy(event_string, "Sending NET_EVENT_WIFI_WPS_RSP", 64);
-
- _net_dbus_pending_call_unref();
- } else {
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_FORGET_AP].flag == FALSE) {
__NETWORK_FUNC_EXIT__;
return;
}
- g_strlcpy(event_data.ProfileName, profile_name, NET_PROFILE_NAME_LEN_MAX+1);
- event_data.Error = NET_ERR_OPERATION_ABORTED;
- event_data.Datalength = 0;
- event_data.Data = NULL;
-
- WIFI_LOG(WIFI_INFO, "%s, Error: %d", event_string, event_data.Error);
- _net_client_callback(&event_data);
-
- __NETWORK_FUNC_EXIT__;
-}
-
-void net_forget_ap_finshed(net_err_e Error)
-{
- __NETWORK_FUNC_ENTER__;
-
- net_event_info_s event_data;
- char event_string[64];
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_FORGET_AP]), 0,
+ sizeof(network_request_table_s));
- if (request_table[NETWORK_REQUEST_TYPE_FORGET_AP].flag == FALSE) {
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
__NETWORK_FUNC_EXIT__;
return;
}
- memset(&request_table[NETWORK_REQUEST_TYPE_FORGET_AP], 0,
- sizeof(network_request_table_s));
-
- event_data.Event = NET_EVENT_WIFI_FORGET_AP_IND;
+ event_data->Event = NET_EVENT_WIFI_FORGET_AP_IND;
g_strlcpy(event_string, "Sending NET_EVENT_WIFI_FORGET_AP_IND", 64);
- event_data.Error = Error;
- event_data.Datalength = 0;
- event_data.Data = NULL;
+ event_data->Error = Error;
+ event_data->Datalength = 0;
+ event_data->Data = NULL;
+
+ WIFI_LOG(WIFI_INFO, "%s, Error: %d", event_string, event_data->Error);
- WIFI_LOG(WIFI_INFO, "%s, Error: %d", event_string, event_data.Error);
- _net_client_callback(&event_data);
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
}
return NET_ERR_NONE;
}
-int _net_get_profile_list(GSList **profile_list)
+gboolean _net_check_service_mac_addr(network_info_s *network_info, const char* service)
+{
+ __NETWORK_FUNC_ENTER__;
+ const char *service_header = CONNMAN_WIFI_SERVICE_PROFILE_PREFIX;
+ const char *org = NULL;
+ const char *dst = NULL;
+ int service_index = 0;
+ int mac_index = 0;
+ int i = 0;
+
+ service_index = strlen(service_header);
+ for (i = 0; i < 6; i++) {
+ org = &service[service_index];
+ dst = &network_info->mac_address[mac_index];
+
+ if (g_ascii_strncasecmp(org, dst, 2) != 0)
+ return FALSE;
+
+ service_index += 2;
+ mac_index += 3;
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return TRUE;
+}
+
+int _net_get_interface_list(network_info_s *network_info, GSList **interface_list)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message;
+ GVariantIter *iter;
+ gchar *interface_name = NULL;
+
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, CONNMAN_WIFI_TECHNOLOGY_PATH,
+ CONNMAN_TECHNOLOGY_INTERFACE, "GetInterfaces",
+ NULL, &Error);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get interface list"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ g_variant_get(message, "(as)", &iter);
+ while (g_variant_iter_loop(iter, "s", &interface_name)) {
+ WIFI_LOG(WIFI_INFO, "Ifname [%s]", interface_name);
+ *interface_list = g_slist_append(*interface_list, g_strdup(interface_name));
+ }
+
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_get_profile_list(network_info_s *network_info, GSList **profile_list)
{
__NETWORK_FUNC_ENTER__;
GVariant *message;
GVariantIter *iter;
- message = _net_invoke_dbus_method(CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
- CONNMAN_MANAGER_INTERFACE, "GetServices", NULL, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE, "GetServices",
+ NULL, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to get service(profile) list"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
}
g_variant_get(message, "(a(oa{sv}))", &iter);
- Error = __net_extract_services(iter, profile_list);
+ Error = __net_extract_services(network_info, iter, profile_list);
if (iter != NULL)
g_variant_iter_free(iter);
return Error;
}
-int net_init_profile_info(net_profile_info_s *ProfInfo)
+int net_init_profile_info(network_info_s *network_info, net_profile_info_s *ProfInfo)
{
int i = 0;
net_dev_info_s *net_info = NULL;
if (ProfInfo == NULL) {
- WIFI_LOG(WIFI_ERROR, "Invalid Parameter\n"); //LCOV_EXCL_LINE
+ WIFI_LOG(WIFI_ERROR, "Invalid Parameter"); //LCOV_EXCL_LINE
return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
}
ProfInfo->security_info.wps_support = FALSE;
ProfInfo->disconnect_reason = WIFI_REASON_UNSPECIFIED;
ProfInfo->assoc_status_code = 0;
+
+ ProfInfo->network_info = network_info;
+
net_info = &(ProfInfo->net_info);
net_info->DnsCount = 0;
return NET_ERR_NONE;
}
-int net_specific_scan_wifi(const char *ssid)
+int net_specific_scan_wifi(network_info_s *network_info, const char *ssid)
{
__NETWORK_FUNC_ENTER__;
return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
}
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ Error = __net_get_wifi_state(network_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
}
- if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
- WIFI_LOG(WIFI_ERROR, "Find hidden AP request in progress"); //LCOV_EXCL_LINE
+ if (network_info->wifi_state == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
- }
-
- if (NetworkInfo.wifi_state == WIFI_OFF) {
- if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
- }
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- if (_net_dbus_is_pending_call_used() == TRUE) {
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_NETLINK_SCAN].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].flag == TRUE) {
WIFI_LOG(WIFI_ERROR, "pending call in progress"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag = TRUE;
- g_strlcpy(request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].ssid, ssid, NET_WLAN_ESSID_LEN + 1);
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Specific scan request in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
+ }
+
+ network_info->request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag = TRUE;
+ g_strlcpy(network_info->request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].ssid,
+ ssid, NET_WLAN_ESSID_LEN + 1);
- Error = _net_dbus_specific_scan_request(ssid);
+ Error = _net_dbus_specific_scan_request(network_info, ssid);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"_net_dbus_specific_scan_request() failed. Error [%s]",
_net_print_error(Error));
- memset(&request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN], 0, //LCOV_EXCL_LINE
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN]), 0, //LCOV_EXCL_LINE
sizeof(network_request_table_s));
}
}
//LCOV_EXCL_START
-int net_bssid_scan_wifi(int activated)
+int net_bssid_scan_wifi(network_info_s *network_info, int activated)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_NETLINK_SCAN].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "pending call in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- if (_net_dbus_is_pending_call_used() == TRUE) {
- if (request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN].flag == TRUE)
- return NET_ERR_IN_PROGRESS;
-
- WIFI_LOG(WIFI_ERROR, "pending call in progress");
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "BSSID scan request in progress");
__NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
+ return NET_ERR_IN_PROGRESS;
}
- request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN].flag = TRUE;
+ network_info->request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN].flag = TRUE;
if (activated == 0)
- Error = _net_dbus_bssid_scan_request();
+ Error = _net_dbus_bssid_scan_request(network_info);
else
- Error = _net_dbus_scan_request();
+ Error = _net_dbus_scan_request(network_info);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
"_net_dbus_bssid_scan_request() failed. Error [%s]",
_net_print_error(Error));
- memset(&request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN], 0,
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN]), 0,
sizeof(network_request_table_s));
}
return Error;
}
-int net_netlink_scan_wifi(GSList *nl_scan_list, const char *vsie)
+int net_netlink_scan_wifi(network_info_s *network_info, GSList *nl_scan_list, const char *vsie)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "pending call in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- if (_net_dbus_is_pending_call_used() == TRUE) {
- if (request_table[NETWORK_REQUEST_TYPE_NETLINK_SCAN].flag == TRUE)
- return NET_ERR_IN_PROGRESS;
-
- WIFI_LOG(WIFI_ERROR, "pending call in progress");
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_NETLINK_SCAN].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Netlink scan request in progress");
__NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
+ return NET_ERR_IN_PROGRESS;
}
- request_table[NETWORK_REQUEST_TYPE_NETLINK_SCAN].flag = TRUE;
- Error = _net_dbus_netlink_scan_request(nl_scan_list, vsie);
+ network_info->request_table[NETWORK_REQUEST_TYPE_NETLINK_SCAN].flag = TRUE;
+ Error = _net_dbus_netlink_scan_request(network_info, nl_scan_list, vsie);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
"netlink dbus request failed. Error [%s]",
_net_print_error(Error));
- memset(&request_table[NETWORK_REQUEST_TYPE_NETLINK_SCAN], 0,
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_NETLINK_SCAN]), 0,
sizeof(network_request_table_s));
}
return Error;
}
-int net_multi_scan_wifi(GSList *multi_scan_list, gboolean multi_scan_type[])
+int net_multi_scan_wifi(network_info_s *network_info,
+ GSList *multi_scan_list, gboolean multi_scan_type[])
{
__NETWORK_FUNC_ENTER__;
return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
}
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ Error = __net_get_wifi_state(network_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
}
- if (request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].flag == TRUE) {
- WIFI_LOG(WIFI_ERROR, "Multi Scan request in progress"); //LCOV_EXCL_LINE
+ if (network_info->wifi_state == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
- }
-
- if (NetworkInfo.wifi_state == WIFI_OFF) {
- if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
- }
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- if (_net_dbus_is_pending_call_used() == TRUE) {
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_NETLINK_SCAN].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
WIFI_LOG(WIFI_ERROR, "pending call in progress"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].flag = TRUE;
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Multi Scan request in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
+ }
+
+ network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].flag = TRUE;
if (multi_scan_type[WIFI_MULTI_SCAN_SSID] == true &&
multi_scan_type[WIFI_MULTI_SCAN_FREQ] == true)
- request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_type = WIFI_MULTI_SCAN_SSID_FREQ;
+ network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_type = WIFI_MULTI_SCAN_SSID_FREQ;
else if (multi_scan_type[WIFI_MULTI_SCAN_SSID] == true)
- request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_type = WIFI_MULTI_SCAN_SSID;
+ network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_type = WIFI_MULTI_SCAN_SSID;
else if (multi_scan_type[WIFI_MULTI_SCAN_FREQ] == true)
- request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_type = WIFI_MULTI_SCAN_FREQ;
+ network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_type = WIFI_MULTI_SCAN_FREQ;
wifi_manager_multi_scan_ap_s *temp = NULL;
for (GSList *list = multi_scan_list; list; list = list->next) {
g_strlcpy(temp->str, ((wifi_manager_multi_scan_ap_s *)list->data)->str, NET_WLAN_ESSID_LEN + 1);
temp->flag = ((wifi_manager_multi_scan_ap_s *)list->data)->flag;
- request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_list = g_slist_append(
- request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_list, temp);
+ network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_list = g_slist_append(
+ network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_list, temp);
}
- Error = _net_dbus_multi_scan_request(multi_scan_list);
+ Error = _net_dbus_multi_scan_request(network_info, multi_scan_list);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"_net_dbus_multi_scan_request() failed. Error [%s]",
_net_print_error(Error));
- g_slist_free_full(request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_list, g_free);
- memset(&request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN], 0, //LCOV_EXCL_LINE
+ g_slist_free_full(network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_list, g_free);
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN]), 0, //LCOV_EXCL_LINE
sizeof(network_request_table_s));
}
return Error;
}
-int net_get_wps_generated_pin(char **wps_pin)
+int net_get_wps_generated_pin(network_info_s *network_info, char **wps_pin)
{
net_err_e error = NET_ERR_NONE;
- error = _net_dbus_get_wps_generated_pin(wps_pin);
+ error = _net_dbus_get_wps_generated_pin(network_info, wps_pin);
if (error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to get wps pin : %d", error);
return error;
}
-int net_wifi_get_passpoint(int *enabled)
+int net_wifi_get_passpoint(network_info_s *network_info, int *enabled)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- if (NetworkInfo.wifi_state == WIFI_OFF) {
- if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
- }
+ Error = __net_get_wifi_state(network_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
}
- if (_net_dbus_is_pending_call_used() == TRUE) {
- WIFI_LOG(WIFI_ERROR, "pending call in progress");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
+ if (network_info->wifi_state == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- Error = _net_dbus_get_passpoint(enabled);
+ Error = _net_dbus_get_passpoint(network_info, enabled);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
"_net_dbus_get_passpoint() failed. Error [%s]",
return Error;
}
-int net_wifi_set_passpoint(int enable)
+int net_wifi_set_passpoint(network_info_s *network_info, int enable)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- if (NetworkInfo.wifi_state == WIFI_OFF) {
- if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
- }
+ Error = __net_get_wifi_state(network_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
}
- if (_net_dbus_is_pending_call_used() == TRUE) {
- WIFI_LOG(WIFI_ERROR, "pending call in progress");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
+ if (network_info->wifi_state == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- Error = _net_dbus_set_passpoint(enable);
+ Error = _net_dbus_set_passpoint(network_info, enable);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
"_net_dbus_set_passpoint() failed. Error [%s]",
return Error;
}
-int net_wifi_add_vsie(unsigned int frame_id, const char *vsie_str)
+int net_wifi_add_vsie(network_info_s *network_info, unsigned int frame_id, const char *vsie_str)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- if (NetworkInfo.wifi_state == WIFI_OFF) {
- if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
- }
+ Error = __net_get_wifi_state(network_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
}
- if (_net_dbus_is_pending_call_used() == TRUE) {
- WIFI_LOG(WIFI_ERROR, "pending call in progress");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
+ if (network_info->wifi_state == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- Error = _net_dbus_add_vsie(frame_id, vsie_str);
+ Error = _net_dbus_add_vsie(network_info, frame_id, vsie_str);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
"_net_dbus_add_vsie() failed. Error [%s]",
return Error;
}
-int net_wifi_get_vsie(unsigned int frame_id, char **vsie_str)
+int net_wifi_get_vsie(network_info_s *network_info, unsigned int frame_id, char **vsie_str)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- if (NetworkInfo.wifi_state == WIFI_OFF) {
- if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
- }
+ Error = __net_get_wifi_state(network_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
}
- if (_net_dbus_is_pending_call_used() == TRUE) {
- WIFI_LOG(WIFI_ERROR, "pending call in progress");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
+ if (network_info->wifi_state == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- Error = _net_dbus_get_vsie(frame_id, vsie_str);
+ Error = _net_dbus_get_vsie(network_info, frame_id, vsie_str);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
"_net_dbus_get_vsie() failed. Error [%s]",
return Error;
}
-int net_wifi_remove_vsie(unsigned int frame_id, const char *vsie_str)
+int net_wifi_remove_vsie(network_info_s *network_info, unsigned int frame_id, const char *vsie_str)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- if (NetworkInfo.wifi_state == WIFI_OFF) {
- if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
- }
+ Error = __net_get_wifi_state(network_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
}
- if (_net_dbus_is_pending_call_used() == TRUE) {
- WIFI_LOG(WIFI_ERROR, "pending call in progress");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
+ if (network_info->wifi_state == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- Error = _net_dbus_remove_vsie(frame_id, vsie_str);
+ Error = _net_dbus_remove_vsie(network_info, frame_id, vsie_str);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
"_net_dbus_remove_vsie() failed. Error [%s]",
return Error;
}
-EXPORT_API int net_wifi_flush_bss(void)
+EXPORT_API int net_wifi_flush_bss(network_info_s *network_info)
{
__NETWORK_CAPI_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_CAPI_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- Error = _net_dbus_flush_bss();
+ Error = _net_dbus_flush_bss(network_info);
if (Error != NET_ERR_NONE) {
- WIFI_LOG(WIFI_ERROR, "Failed to flush bss. Error [%s]\n",
+ WIFI_LOG(WIFI_ERROR, "Failed to flush bss. Error [%s]",
_net_print_error(Error));
__NETWORK_CAPI_FUNC_EXIT__;
return Error;
return NET_ERR_NONE;
}
-int net_wifi_set_bssid(char *bssid)
+int net_wifi_set_bssid(network_info_s *network_info, char *bssid)
{
__NETWORK_CAPI_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_CAPI_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- Error = _net_dbus_set_bssid(bssid);
+ Error = _net_dbus_set_bssid(network_info, bssid);
if (Error != NET_ERR_NONE) {
- WIFI_LOG(WIFI_ERROR, "Failed to set bssid. Error [%s]\n",
+ WIFI_LOG(WIFI_ERROR, "Failed to set bssid. Error [%s]",
_net_print_error(Error));
__NETWORK_CAPI_FUNC_EXIT__;
return Error;
return NET_ERR_NONE;
}
-EXPORT_API int net_wifi_set_auto_connect_mode(int connect_mode)
+EXPORT_API int net_wifi_set_auto_connect_mode(network_info_s *network_info,
+ int connect_mode)
{
__NETWORK_CAPI_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_CAPI_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- if ((Error = _net_dbus_set_auto_connect_mode(connect_mode)) != NET_ERR_NONE) {
+ if ((Error = _net_dbus_set_auto_connect_mode(network_info, connect_mode)) != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
"Failed to set auto connect mode. Error [%s]",
_net_print_error(Error));
return NET_ERR_NONE;
}
-EXPORT_API int net_wifi_get_5ghz_support(gboolean *supported)
+EXPORT_API int net_wifi_get_5ghz_support(network_info_s *network_info, gboolean *supported)
{
__NETWORK_CAPI_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_CAPI_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- if ((Error = _net_dbus_get_5ghz_support(supported)) != NET_ERR_NONE) {
+ if ((Error = _net_dbus_get_5ghz_support(network_info, supported)) != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
"Failed to get 5 Ghz supported. Error [%s]",
_net_print_error(Error));
return NET_ERR_NONE;
}
-EXPORT_API int net_wifi_get_auto_connect_mode(int *connect_mode)
+EXPORT_API int net_wifi_get_auto_connect_mode(network_info_s *network_info,
+ int *connect_mode)
{
__NETWORK_CAPI_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_CAPI_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- if ((Error = _net_dbus_get_auto_connect_mode(connect_mode)) != NET_ERR_NONE) {
+ if ((Error = _net_dbus_get_auto_connect_mode(network_info, connect_mode)) != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
"Failed to set auto connect mode. Error [%s]",
_net_print_error(Error));
return NET_ERR_NONE;
}
-EXPORT_API int net_wifi_set_ap_auto_connect(const char *profile_name, gboolean autoconnect)
+EXPORT_API int net_wifi_set_ap_auto_connect(network_info_s *network_info,
+ const char *profile_name, gboolean autoconnect)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Invalid profile name");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- Error = _net_dbus_wifi_set_autoconnect(profile_name, autoconnect);
+ Error = _net_dbus_wifi_set_autoconnect(network_info, profile_name, autoconnect);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to set autoconnect(%d), Error[%s]",
autoconnect, _net_print_error(Error));
return Error;
}
-EXPORT_API int net_wifi_get_ap_auto_connect(const char *profile_name, gboolean *autoconnect)
+EXPORT_API int net_wifi_get_ap_auto_connect(network_info_s *network_info,
+ const char *profile_name, gboolean *autoconnect)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Invalid profile name");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- Error = _net_dbus_wifi_get_autoconnect(profile_name, autoconnect);
+ Error = _net_dbus_wifi_get_autoconnect(network_info, profile_name, autoconnect);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to get autoconnect, Error[%s]",
_net_print_error(Error));
}
//LCOV_EXCL_STOP
-int net_open_connection_with_wifi_info(const net_wifi_connection_info_s *wifi_info)
+int net_open_connection_with_wifi_info(network_info_s *network_info,
+ const net_wifi_connection_info_s *wifi_info)
{
__NETWORK_FUNC_ENTER__;
return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
}
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ Error = __net_get_wifi_state(network_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
}
- if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
- WIFI_LOG(WIFI_ERROR, "Connection open request in progress"); //LCOV_EXCL_LINE
+ if (network_info->wifi_state == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
- }
-
- if (NetworkInfo.wifi_state == WIFI_OFF) {
- if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
- }
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- if (_net_dbus_is_pending_call_used() == TRUE) {
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_FORGET_AP].flag == TRUE) {
WIFI_LOG(WIFI_ERROR, "pending call in progress"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag = TRUE;
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Connection open request in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
+ }
+
+ network_info->request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag = TRUE;
- Error = _net_open_connection_with_wifi_info(wifi_info);
+ Error = _net_open_connection_with_wifi_info(network_info, wifi_info);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"net_open_connection_with_wifi_info() failed. Error [%s]",
_net_print_error(Error));
- if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag != 0)
- memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0, //LCOV_EXCL_LINE
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag != 0)
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION]), 0, //LCOV_EXCL_LINE
sizeof(network_request_table_s));
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_NONE;
}
-int net_wifi_power_on(gboolean wifi_picker_test)
+int net_wifi_power_on(network_info_s *network_info, gboolean wifi_picker_test)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
int hotspot_state = 0;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
- }
-
- if (!net_get_device_policy_wifi()) {
+ if (!net_get_device_policy_wifi(network_info)) {
WIFI_LOG(WIFI_ERROR, "Wifi profile device policy restricts"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_SECURITY_RESTRICTED; //LCOV_EXCL_LINE
}
+ /* TODO */
if (vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_state) != 0) {
WIFI_LOG(WIFI_ERROR, "Failed to get vconf key of hotspot mode"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- if (NetworkInfo.wifi_state != WIFI_OFF) {
- if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_ON) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered on already!"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_ALREADY_EXISTS; //LCOV_EXCL_LINE
- } else if (Error != NET_ERR_NONE) {
- WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return Error; //LCOV_EXCL_LINE
- }
+ Error = __net_get_wifi_state(network_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ if (network_info->wifi_state == WIFI_ON) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered on already!"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_ALREADY_EXISTS; //LCOV_EXCL_LINE
}
- if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
WIFI_LOG(WIFI_ERROR, "Request in progress"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
}
- _net_dbus_pending_call_unref();
- memset(request_table, 0, sizeof(request_table));
+ memset(network_info->request_table, 0, sizeof(network_info->request_table));
- request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag = TRUE;
+ network_info->request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag = TRUE;
- Error = _net_dbus_load_wifi_driver(wifi_picker_test);
+ Error = _net_dbus_load_wifi_driver(network_info, wifi_picker_test);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"Failed to request Wi-Fi power on/off. Error [%s]",
_net_print_error(Error));
- memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER], 0, //LCOV_EXCL_LINE
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_WIFI_POWER]), 0, //LCOV_EXCL_LINE
sizeof(network_request_table_s));
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_NONE;
}
-int net_wifi_power_off(void)
+int net_wifi_power_off(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ Error = __net_get_wifi_state(network_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ if (network_info->wifi_state == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off already!"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ return NET_ERR_ALREADY_EXISTS; //LCOV_EXCL_LINE
}
- if (NetworkInfo.wifi_state == WIFI_OFF) {
- if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off already!"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_ALREADY_EXISTS; //LCOV_EXCL_LINE
- }
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_NETLINK_SCAN].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "pending call in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
WIFI_LOG(WIFI_ERROR, "Request in progress"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
}
- //LCOV_EXCL_START
- if (_net_dbus_is_pending_call_used() == TRUE) {
- if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
- _net_dbus_pending_call_unref();
-
- memset(&request_table[NETWORK_REQUEST_TYPE_SCAN],
- 0, sizeof(network_request_table_s));
- }
-
- if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
- _net_dbus_pending_call_unref();
-
- memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION],
- 0, sizeof(network_request_table_s));
- }
-
- if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE) {
- _net_dbus_pending_call_unref();
-
- memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS],
- 0, sizeof(network_request_table_s));
- }
-
- if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE) {
- _net_dbus_pending_call_unref();
-
- memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION],
- 0, sizeof(network_request_table_s));
- }
-
- if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
- _net_dbus_pending_call_unref();
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE)
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_SCAN]),
+ 0, sizeof(network_request_table_s));
- memset(&request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN],
- 0, sizeof(network_request_table_s));
- }
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE)
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION]),
+ 0, sizeof(network_request_table_s));
- if (request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN].flag == TRUE) {
- _net_dbus_pending_call_unref();
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE)
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS]),
+ 0, sizeof(network_request_table_s));
- memset(&request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN],
- 0, sizeof(network_request_table_s));
- }
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE)
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION]),
+ 0, sizeof(network_request_table_s));
- if (_net_dbus_is_pending_call_used() == TRUE) {
- WIFI_LOG(WIFI_ERROR, "pending call in progress");
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE)
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN]),
+ 0, sizeof(network_request_table_s));
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
- }
- }
- //LCOV_EXCL_STOP
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN].flag == TRUE)
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN]),
+ 0, sizeof(network_request_table_s));
- request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag = TRUE;
+ network_info->request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag = TRUE;
- Error = _net_dbus_remove_wifi_driver();
+ Error = _net_dbus_remove_wifi_driver(network_info);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"Failed to request Wi-Fi power on/off. Error [%s]",
_net_print_error(Error));
- memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER], //LCOV_EXCL_LINE
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_WIFI_POWER]), //LCOV_EXCL_LINE
0, sizeof(network_request_table_s));
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_NONE;
}
-int net_scan_wifi(void)
+int net_scan_wifi(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ Error = __net_get_wifi_state(network_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
}
- if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
- WIFI_LOG(WIFI_ERROR, "Request in progress"); //LCOV_EXCL_LINE
+ if (network_info->wifi_state == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- if (NetworkInfo.wifi_state == WIFI_OFF) {
- if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
- }
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_NETLINK_SCAN].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "pending call in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- if (_net_dbus_is_pending_call_used() == TRUE) {
- if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
- } else {
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
- }
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Scan request in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
}
- request_table[NETWORK_REQUEST_TYPE_SCAN].flag = TRUE;
+ network_info->request_table[NETWORK_REQUEST_TYPE_SCAN].flag = TRUE;
- Error = _net_dbus_scan_request();
+ Error = _net_dbus_scan_request(network_info);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to request scan. Error [%s]", //LCOV_EXCL_LINE
_net_print_error(Error));
- memset(&request_table[NETWORK_REQUEST_TYPE_SCAN], 0, //LCOV_EXCL_LINE
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_SCAN]), 0, //LCOV_EXCL_LINE
sizeof(network_request_table_s));
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_NONE;
}
-int net_wifi_get_scan_state(int *scanstate)
+int net_wifi_get_scan_state(network_info_s *network_info, int *scanstate)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ Error = __net_get_wifi_state(network_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
}
- if (NetworkInfo.wifi_state == WIFI_OFF) {
- if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
- }
+ if (network_info->wifi_state == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
- WIFI_LOG(WIFI_ERROR, "Request in progress"); //LCOV_EXCL_LINE
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Scan request in progress"); //LCOV_EXCL_LINE
*scanstate = 1; //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE; //LCOV_EXCL_LINE
}
- Error = _net_dbus_get_scan_state(scanstate);
+ Error = _net_dbus_get_scan_state(network_info, scanstate);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to get scan state. Error [%s]", //LCOV_EXCL_LINE
_net_print_error(Error));
}
//LCOV_EXCL_START
-int net_wifi_enroll_wps(const char *profile_name, net_wifi_wps_info_s *wps_info)
+int net_wifi_enroll_wps(network_info_s *network_info,
+ const char *profile_name, net_wifi_wps_info_s *wps_info)
{
__NETWORK_FUNC_ENTER__;
return NET_ERR_INVALID_PARAM;
}
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
+ Error = __net_get_wifi_state(network_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state");
__NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
+ return Error;
}
- if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE) {
- WIFI_LOG(WIFI_ERROR, "Request in progress");
+ if (network_info->wifi_state == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!");
__NETWORK_FUNC_EXIT__;
- return NET_ERR_IN_PROGRESS;
+ return NET_ERR_INVALID_OPERATION;
}
- if (NetworkInfo.wifi_state == WIFI_OFF) {
- if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
- }
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_FORGET_AP].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "pending call in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- if (_net_dbus_is_pending_call_used() == TRUE) {
- WIFI_LOG(WIFI_ERROR, "pending call in progress");
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Request in progress");
__NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
+ return NET_ERR_IN_PROGRESS;
}
- request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag = TRUE;
- g_strlcpy(request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName,
+ network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag = TRUE;
+ g_strlcpy(network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName,
profile_name, NET_PROFILE_NAME_LEN_MAX+1);
if (wps_info->type == WIFI_WPS_PBC)
- Error = _net_dbus_set_agent_wps_pbc_and_connect(profile_name);
+ Error = _net_dbus_set_agent_wps_pbc_and_connect(network_info, profile_name);
else if (wps_info->type == WIFI_WPS_PIN)
- Error = _net_dbus_set_agent_wps_pin_and_connect(wps_info->pin, profile_name);
+ Error = _net_dbus_set_agent_wps_pin_and_connect(network_info, wps_info->pin, profile_name);
else
Error = NET_ERR_INVALID_PARAM;
if (NET_ERR_NONE != Error) {
- WIFI_LOG(WIFI_ERROR,
- "WPS configuration failed(%s)", _net_print_error(Error));
+ WIFI_LOG(WIFI_ERROR, "WPS configuration failed(%s)", _net_print_error(Error));
- memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS]), 0,
sizeof(network_request_table_s));
}
return Error;
}
-int net_wifi_cancel_wps(void)
+int net_wifi_cancel_wps(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- WIFI_LOG(WIFI_ERROR, "net_wifi_wps_cancel called\n");
- if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
+ WIFI_LOG(WIFI_INFO, "net_wifi_wps_cancel called");
- if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == FALSE) {
- WIFI_LOG(WIFI_ERROR, "No pending call in progress\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
+ Error = __net_get_wifi_state(network_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
}
- if (_net_get_wifi_state(&Error) != WIFI_ON) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
+ if (network_info->wifi_state != WIFI_ON) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- if (_net_dbus_is_pending_call_used() == TRUE) {
- WIFI_LOG(WIFI_ERROR, "pending call in progress\n");
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == FALSE) {
+ WIFI_LOG(WIFI_ERROR, "No pending call in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_OPERATION;
}
- if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName[0] != '\0')
- net_delete_profile(request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName);
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName[0] != '\0')
+ net_delete_profile(network_info, network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName);
- Error = _net_dbus_cancel_wps();
+ Error = _net_dbus_cancel_wps(network_info);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
- "Failed to request cancel WPS, Error [%s]\n",
+ "Failed to request cancel WPS, Error [%s]",
_net_print_error(Error));
}
- memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS]), 0,
sizeof(network_request_table_s));
__NETWORK_FUNC_EXIT__;
return Error;
}
-wifi_tech_state_e wifi_state_get_technology_state(void)
+wifi_tech_state_e net_get_technology_state(network_info_s *network_info)
{
GVariant *message = NULL, *variant;
GVariantIter *iter, *next;
- wifi_tech_state_e ret = WIFI_TECH_OFF;
+ wifi_tech_state_e tech_state = WIFI_TECH_OFF;
gboolean wifi_tech_powered = FALSE;
gboolean wifi_tech_connected = FALSE;
const char *path;
gchar *key;
net_err_e Error = NET_ERR_NONE;
- message = _net_invoke_dbus_method(CONNMAN_SERVICE,
- CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
- "GetTechnologies", NULL, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE, "GetTechnologies",
+ NULL, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to get_technology_state");
continue;
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);
- WIFI_LOG(WIFI_INFO, "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);
- WIFI_LOG(WIFI_INFO, "%s", sdata);
+ if (g_strcmp0(key, "Device.List") == 0) {
+ GVariantIter *list_iter = NULL;
+ gchar *dev_key = NULL;
+ GVariant *dev_var = NULL;
+ const gchar *sdata = NULL;
+ gboolean bdata = FALSE;
+ gboolean find = FALSE;
+
+ 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)) {
+ sdata = g_variant_get_string(dev_var, NULL);
+ WIFI_LOG(WIFI_INFO, "%s [%s]", dev_key, sdata);
+
+ if (g_strcmp0(dev_key, "Ifname") == 0) {
+ find = g_strcmp0(sdata, network_info->interface_name) == 0 ? TRUE : FALSE;
+ }
+ } else if (g_variant_is_of_type(dev_var, G_VARIANT_TYPE_BOOLEAN)) {
+ bdata = g_variant_get_boolean(dev_var);
+ WIFI_LOG(WIFI_INFO, "%s [%s]", dev_key, bdata ? "True" : "False");
+
+ if (find && g_strcmp0(dev_key, "Powered") == 0) {
+ wifi_tech_powered = bdata;
+ } else if (find && g_strcmp0(dev_key, "Connected") == 0) {
+ wifi_tech_connected = bdata;
+ }
+ }
+ }
+ g_variant_iter_free(list_iter);
}
}
}
g_variant_iter_free(iter);
if (wifi_tech_powered == TRUE)
- ret = WIFI_TECH_POWERED;
+ tech_state = WIFI_TECH_POWERED;
if (wifi_tech_connected == TRUE)
- ret = WIFI_TECH_CONNECTED;
-
- g_tech_state = ret;
+ tech_state = WIFI_TECH_CONNECTED;
- return g_tech_state;
+ return tech_state;
}
-int net_get_wifi_power_state(net_wifi_state_e *current_state)
+int net_check_get_privilege(network_info_s *network_info)
{
- __NETWORK_FUNC_ENTER__;
-
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- *current_state = _net_get_wifi_state(&Error);
-
- __NETWORK_FUNC_EXIT__;
- return Error;
-}
-
-int net_check_get_privilege()
-{
- net_err_e Error = NET_ERR_NONE;
-
- Error = __net_check_get_privilege();
+ Error = __net_check_get_privilege(network_info);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to check get privilege. Error [%s]", //LCOV_EXCL_LINE
- _net_print_error(Error));
-
- return Error; //LCOV_EXCL_LINE
+ _net_print_error(Error)); //LCOV_EXCL_LINE
}
return Error;
}
-int net_set_ip_conflict_detect_mode(gboolean detect)
+int net_set_ip_conflict_detect_mode(network_info_s *network_info, gboolean detect)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- Error = __net_set_ip_conflict_detect_mode(detect);
+ Error = __net_set_ip_conflict_detect_mode(network_info, detect);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to set ip conflict detection enable, Error [%s]", //LCOV_EXCL_LINE
_net_print_error(Error));
return Error;
}
-int net_ip_conflict_detect_is_enabled(gboolean *state)
+int net_ip_conflict_detect_is_enabled(network_info_s *network_info, gboolean *state)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- Error = __net_ip_conflict_detect_is_enabled(state);
+ Error = __net_ip_conflict_detect_is_enabled(network_info, state);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to get ip conflict detection mode, Error [%s]", //LCOV_EXCL_LINE
_net_print_error(Error));
return Error;
}
-int net_check_profile_privilege()
+int net_check_profile_privilege(network_info_s *network_info)
{
net_err_e Error = NET_ERR_NONE;
- Error = __net_check_profile_privilege();
+ Error = __net_check_profile_privilege(network_info);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to check profile privilege. Error [%s]", //LCOV_EXCL_LINE
- _net_print_error(Error));
-
- return Error; //LCOV_EXCL_LINE
+ _net_print_error(Error)); //LCOV_EXCL_LINE
}
return Error;
}
-int net_wifi_enroll_wps_without_ssid(net_wifi_wps_info_s *wps_info)
+int net_wifi_enroll_wps_without_ssid(network_info_s *network_info,
+ net_wifi_wps_info_s *wps_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
+ Error = __net_get_wifi_state(network_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
}
- if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE) {
- WIFI_LOG(WIFI_ERROR, "Request in progress\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_IN_PROGRESS;
+ if (network_info->wifi_state != WIFI_ON) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- if (_net_get_wifi_state(&Error) != WIFI_ON) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_FORGET_AP].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "pending call in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- if (_net_dbus_is_pending_call_used() == TRUE) {
- WIFI_LOG(WIFI_ERROR, "pending call in progress\n");
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Request in progress");
__NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
+ return NET_ERR_IN_PROGRESS;
}
- memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS]), 0,
sizeof(network_request_table_s));
- request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag = TRUE;
+ network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag = TRUE;
if (wps_info->type == WIFI_WPS_PBC) {
- Error = _net_dbus_open_connection_without_ssid();
+ Error = _net_dbus_open_connection_without_ssid(network_info);
} else if (wps_info->type == WIFI_WPS_PIN) {
- Error = _net_dbus_open_pin_connection_without_ssid(wps_info->pin);
+ Error = _net_dbus_open_pin_connection_without_ssid(network_info, wps_info->pin);
} else{
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
- "Failed to request open connection, Error [%s]\n",
+ "Failed to request open connection, Error [%s]",
_net_print_error(Error));
- memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS]), 0,
sizeof(network_request_table_s));
}
return Error;
}
-int net_wifi_tdls_disconnect(const char* peer_mac_addr)
+int net_wifi_tdls_disconnect(network_info_s *network_info, const char* peer_mac_addr)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
if (peer_mac_addr == NULL) {
- WIFI_LOG(WIFI_ERROR, "invalid parameter\n");
+ WIFI_LOG(WIFI_ERROR, "invalid parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- Error = _net_dbus_tdls_disconnect(peer_mac_addr);
+ Error = _net_dbus_tdls_disconnect(network_info, peer_mac_addr);
if (Error != NET_ERR_NONE)
- WIFI_LOG(WIFI_ERROR, "_net_dbus_tdls_set_device_type failed\n");
+ WIFI_LOG(WIFI_ERROR, "_net_dbus_tdls_set_device_type failed");
__NETWORK_FUNC_EXIT__;
}
-int net_wifi_tdls_connected_peer(char** peer_mac_addr)
+int net_wifi_tdls_connected_peer(network_info_s *network_info, char** peer_mac_addr)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
if (peer_mac_addr == NULL) {
- WIFI_LOG(WIFI_ERROR, "invalid parameter\n");
+ WIFI_LOG(WIFI_ERROR, "invalid parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- Error = _net_dbus_tdls_connected_peer(peer_mac_addr);
+ Error = _net_dbus_tdls_connected_peer(network_info, peer_mac_addr);
if (Error != NET_ERR_NONE)
- WIFI_LOG(WIFI_ERROR, "net_wifi_tdls_connected_peer failed\n");
+ WIFI_LOG(WIFI_ERROR, "net_wifi_tdls_connected_peer failed");
__NETWORK_FUNC_EXIT__;
}
-int net_wifi_tdls_enable_channel_switch(const char* peer_mac_addr, int freq)
+int net_wifi_tdls_enable_channel_switch(network_info_s *network_info,
+ const char* peer_mac_addr, int freq)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
if (peer_mac_addr == NULL || freq < 0) {
- WIFI_LOG(WIFI_ERROR, "invalid parameter\n");
+ WIFI_LOG(WIFI_ERROR, "invalid parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- Error = _net_dbus_tdls_enable_channel_switch(peer_mac_addr, freq);
+ Error = _net_dbus_tdls_enable_channel_switch(network_info, peer_mac_addr, freq);
if (Error != NET_ERR_NONE)
- WIFI_LOG(WIFI_ERROR, "net_wifi_tdls_enable_channel_switch failed\n");
+ WIFI_LOG(WIFI_ERROR, "net_wifi_tdls_enable_channel_switch failed");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int net_wifi_tdls_disbale_channel_switch(const char* peer_mac_addr)
+int net_wifi_tdls_disbale_channel_switch(network_info_s *network_info,
+ const char* peer_mac_addr)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
if (peer_mac_addr == NULL) {
- WIFI_LOG(WIFI_ERROR, "invalid parameter\n");
+ WIFI_LOG(WIFI_ERROR, "invalid parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- Error = _net_dbus_tdls_disable_channel_switch(peer_mac_addr);
-
+ Error = _net_dbus_tdls_disable_channel_switch(network_info, peer_mac_addr);
if (Error != NET_ERR_NONE)
- WIFI_LOG(WIFI_ERROR, "net_wifi_tdls_disbale_channel_switch failed\n");
+ WIFI_LOG(WIFI_ERROR, "net_wifi_tdls_disbale_channel_switch failed");
__NETWORK_FUNC_EXIT__;
}
-int net_wifi_tdls_connect(const char* peer_mac_addr)
+int net_wifi_tdls_connect(network_info_s *network_info, const char* peer_mac_addr)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
if (peer_mac_addr == NULL) {
- WIFI_LOG(WIFI_ERROR, "invalid parameter\n");
+ WIFI_LOG(WIFI_ERROR, "invalid parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- Error = _net_dbus_tdls_connect(peer_mac_addr);
-
+ Error = _net_dbus_tdls_connect(network_info, peer_mac_addr);
if (Error != NET_ERR_NONE)
- WIFI_LOG(WIFI_ERROR, "_net_dbus_tdls_connect failed\n");
+ WIFI_LOG(WIFI_ERROR, "_net_dbus_tdls_connect failed");
__NETWORK_FUNC_EXIT__;
}
-int net_wifi_tdls_discover(const char* peer_mac_addr)
+int net_wifi_tdls_discover(network_info_s *network_info, const char* peer_mac_addr)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
if (peer_mac_addr == NULL) {
- WIFI_LOG(WIFI_ERROR, "invalid parameter\n");
+ WIFI_LOG(WIFI_ERROR, "invalid parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
-
- if (request_table[NETWORK_REQUEST_TYPE_TDLS_DISCOVERY].flag == TRUE) {
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_TDLS_DISCOVERY].flag == TRUE) {
WIFI_LOG(WIFI_ERROR, "TDLS Discovery Request in progress"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
}
- request_table[NETWORK_REQUEST_TYPE_TDLS_DISCOVERY].flag = TRUE;
-
- Error = _net_dbus_tdls_discover(peer_mac_addr);
+ network_info->request_table[NETWORK_REQUEST_TYPE_TDLS_DISCOVERY].flag = TRUE;
+ Error = _net_dbus_tdls_discover(network_info, peer_mac_addr);
if (Error != NET_ERR_NONE) {
- WIFI_LOG(WIFI_ERROR, "_net_dbus_tdls_discover failed\n");
+ WIFI_LOG(WIFI_ERROR, "_net_dbus_tdls_discover failed");
- memset(&request_table[NETWORK_REQUEST_TYPE_TDLS_DISCOVERY], 0, //LCOV_EXCL_LINE
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_TDLS_DISCOVERY]), 0, //LCOV_EXCL_LINE
sizeof(network_request_table_s));
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__;
return Error;
}
-int net_get_device_policy_wifi(void)
+int net_get_device_policy_wifi(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
int state = -1;
- net_err_e Error = _net_dbus_device_policy_get_wifi(&state);
+ net_err_e Error = _net_dbus_device_policy_get_wifi(network_info, &state);
if (Error != NET_ERR_NONE) {
- WIFI_LOG(WIFI_ERROR, "_net_dbus_device_policy_get_wifi failed\n");
+ WIFI_LOG(WIFI_ERROR, "_net_dbus_device_policy_get_wifi failed");
state = TRUE;
}
- WIFI_LOG(WIFI_INFO, "Wifi device policy state [%d]\n", state);
+ WIFI_LOG(WIFI_INFO, "Wifi device policy state [%d]", state);
__NETWORK_FUNC_EXIT__;
return state;
}
-int net_get_device_policy_wifi_profile(void)
+int net_get_device_policy_wifi_profile(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
int state = -1;
- net_err_e Error = _net_dbus_device_policy_get_wifi_profile(&state);
+ net_err_e Error = _net_dbus_device_policy_get_wifi_profile(network_info, &state);
if (Error != NET_ERR_NONE) {
- WIFI_LOG(WIFI_ERROR, "_net_dbus_device_policy_get_wifi_profile failed\n");
+ WIFI_LOG(WIFI_ERROR, "_net_dbus_device_policy_get_wifi_profile failed");
state = TRUE;
}
- WIFI_LOG(WIFI_INFO, "Wifi profile policy state [%d]\n", state);
+ WIFI_LOG(WIFI_INFO, "Wifi profile policy state [%d]", state);
__NETWORK_FUNC_EXIT__;
return state;
}
//LCOV_EXCL_STOP
-int net_register_client_ext(net_event_cb event_cb, void *user_data)
+int net_register_client_ext(network_info_s **network_info,
+ const char *interface_name, net_event_cb event_cb, void *user_data)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
+ network_info_s *net_info = NULL;
+ GSList *list = NULL;
+ GSList *interface_list = NULL;
if (event_cb == NULL) {
WIFI_LOG(WIFI_ERROR, "Invalid EventCb parameter"); //LCOV_EXCL_LINE
return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
}
- if (NetworkInfo.ClientEventCb_wifi != NULL) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi EventCb Already registered"); //LCOV_EXCL_LINE
+ net_info = g_try_malloc0(sizeof(network_info_s));
+ if (net_info == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to allocate memory"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_ALREADY_REGISTERED; //LCOV_EXCL_LINE
+ return NET_ERR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
}
- if (NetworkInfo.ref_count < 1) {
- Error = _net_register_signal();
- if (Error != NET_ERR_NONE && Error != NET_ERR_APP_ALREADY_REGISTERED) {
- WIFI_LOG(WIFI_ERROR, "Failed to register DBus signal [%s]", //LCOV_EXCL_LINE
- _net_print_error(Error));
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return Error; //LCOV_EXCL_LINE
- }
-
- Error = _net_init_service_state();
- if (Error != NET_ERR_NONE) {
- WIFI_LOG(WIFI_ERROR, "Failed to init service state [%s]", //LCOV_EXCL_LINE
- _net_print_error(Error));
- _net_deregister_signal();
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return Error; //LCOV_EXCL_LINE
- }
+ Error = _net_dbus_create_gdbus_call(net_info);
+ if (Error != NET_ERR_NONE) {
+ g_free(net_info); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
}
- NetworkInfo.ClientEventCb_wifi = event_cb;
- NetworkInfo.user_data_wifi = user_data;
-
- __sync_fetch_and_add(&NetworkInfo.ref_count, 1);
+ Error = _net_get_interface_list(net_info, &interface_list);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get interface list. Error [%s]", //LCOV_EXCL_LINE
+ _net_print_error(Error));
+ _net_dbus_close_gdbus_call(net_info); //LCOV_EXCL_LINE
+ g_free(net_info); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_NONE;
-}
+ for (list = interface_list; list; list = list->next) {
+ const char *ifname = list->data;
+ if (interface_name == NULL || !g_strcmp0(interface_name, ifname)) {
+ g_strlcpy(net_info->interface_name, ifname, NET_WLAN_IF_NAME_LEN + 1);
+ WIFI_LOG(WIFI_INFO, "Set interface name [%s]", ifname);
+ break;
+ }
+ }
-int net_deregister_client_ext()
-{
- __NETWORK_FUNC_ENTER__;
+ if (list == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to find interface [%s]", interface_name); //LCOV_EXCL_LINE
+ _net_dbus_close_gdbus_call(net_info); //LCOV_EXCL_LINE
+ g_free(net_info); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
+ }
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ Error = _net_register_signal(net_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to register DBus signal [%s]", //LCOV_EXCL_LINE
+ _net_print_error(Error));
+ _net_dbus_close_gdbus_call(net_info); //LCOV_EXCL_LINE
+ g_free(net_info); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
}
- if (NetworkInfo.ClientEventCb_wifi == NULL) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi EventCb was not registered"); //LCOV_EXCL_LINE
+ Error = _net_init_service_state(net_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to init service state [%s]", //LCOV_EXCL_LINE
+ _net_print_error(Error));
+ _net_deregister_signal(net_info); //LCOV_EXCL_LINE
+ _net_dbus_close_gdbus_call(net_info); //LCOV_EXCL_LINE
+ g_free(net_info); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
}
- NetworkInfo.ClientEventCb_wifi = NULL;
- NetworkInfo.user_data_wifi = NULL;
+ net_info->event_callback = event_cb;
+ net_info->user_data = user_data;
- if (__sync_sub_and_fetch(&NetworkInfo.ref_count, 1) < 1) {
- _net_deregister_signal();
- _net_clear_request_table();
- _net_client_callback_cleanup();
- }
+ *network_info = net_info;
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-gboolean net_check_ref_count(void)
+void net_deregister_client_ext(network_info_s *network_info)
{
- if (NetworkInfo.ref_count > 0)
- return TRUE;
+ __NETWORK_FUNC_ENTER__;
+
+ if (network_info) {
+ network_info->event_callback = NULL;
+ network_info->user_data = NULL;
- return FALSE; //LCOV_EXCL_LINE
+ _net_deregister_signal(network_info);
+ _net_dbus_close_gdbus_call(network_info);
+ _net_clear_request_table(network_info);
+
+ g_free(network_info);
+ }
+
+ __NETWORK_FUNC_EXIT__;
}
//LCOV_EXCL_START
-void net_set_cs_tid(int tid)
+void net_set_cs_tid(network_info_s *network_info, int tid)
{
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- return;
- }
-
- _net_set_cs_tid(tid);
+ _net_set_cs_tid(network_info, tid);
}
void net_unset_cs_tid(int tid)
}
//LCOV_EXCL_STOP
-int net_open_connection(const char *profile_name)
+int net_open_connection(network_info_s *network_info, const char *profile_name)
{
__NETWORK_FUNC_ENTER__;
return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
}
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE ||
+ network_info->request_table[NETWORK_REQUEST_TYPE_FORGET_AP].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "pending call in progress"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
WIFI_LOG(WIFI_ERROR, "Request in progress"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
}
- if (_net_dbus_is_pending_call_used() == TRUE) {
- WIFI_LOG(WIFI_ERROR, "Pending call in progress"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
- }
-
- request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag = TRUE;
- g_strlcpy(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
+ network_info->request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag = TRUE;
+ g_strlcpy(network_info->request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
profile_name, NET_PROFILE_NAME_LEN_MAX+1);
- Error = _net_dbus_open_connection(profile_name);
+ Error = _net_dbus_open_connection(network_info, profile_name);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"Failed to request open connection, Error [%s]",
_net_print_error(Error));
- memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], //LCOV_EXCL_LINE
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION]), //LCOV_EXCL_LINE
0, sizeof(network_request_table_s));
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_NONE;
}
-int net_close_connection(const char *profile_name)
+int net_close_connection(network_info_s *network_info, const char *profile_name)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- gboolean is_connecting = FALSE;
WIFI_LOG(WIFI_INFO, "ProfileName [%s] passed", profile_name);
return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
}
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
- }
-
- if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE) {
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE) {
WIFI_LOG(WIFI_ERROR, "Request in progress"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
}
- if (_net_dbus_is_pending_call_used() == TRUE) {
- is_connecting = __net_is_connecting(profile_name); //LCOV_EXCL_LINE
- if (is_connecting == FALSE) { //LCOV_EXCL_LINE
- WIFI_LOG(WIFI_ERROR, "pending call in progress"); //LCOV_EXCL_LINE
-
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
- }
- }
-
- request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag = TRUE;
- g_strlcpy(request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName,
+ network_info->request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag = TRUE;
+ g_strlcpy(network_info->request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName,
profile_name, NET_PROFILE_NAME_LEN_MAX+1);
- Error = _net_dbus_close_connection(profile_name);
+ Error = _net_dbus_close_connection(network_info, profile_name);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"Failed to request close connection, Error [%s]",
_net_print_error(Error));
- memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION], //LCOV_EXCL_LINE
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION]), //LCOV_EXCL_LINE
0, sizeof(network_request_table_s));
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return Error; //LCOV_EXCL_LINE
}
- if (is_connecting == TRUE)
- __net_abort_open_connection(profile_name); //LCOV_EXCL_LINE
-
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-int net_delete_profile(const char* profile_name)
+int net_delete_profile(network_info_s *network_info, const char* profile_name)
{
__NETWORK_FUNC_ENTER__;
net_profile_name_s wifi_prof_name;
net_profile_info_s prof_info;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
- }
-
WIFI_LOG(WIFI_INFO, "Delete Profile [%s]", profile_name);
if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
}
- Error = __net_get_profile_info(profile_name, &prof_info);
+ Error = __net_get_profile_info(network_info, profile_name, &prof_info);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"Failed to get service(profile) information. Error [%s]",
g_strlcpy(wifi_prof_name.ProfileName, profile_name, NET_PROFILE_NAME_LEN_MAX + 1);
- Error = __net_wifi_delete_profile(&wifi_prof_name,
+ Error = __net_wifi_delete_profile(network_info,
+ &wifi_prof_name,
prof_info.security_info.sec_mode,
prof_info.passpoint);
if (Error != NET_ERR_NONE) {
}
static void _net_delete_profile_async_reply(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
+ GAsyncResult *res, gpointer user_data)
{
__NETWORK_FUNC_ENTER__;
gchar *path = NULL;
net_profile_name_s wifi_prof_name;
net_profile_info_s prof_info;
+ network_info_s *network_info = (network_info_s *)user_data;
+ network_request_table_s *request_table = network_info->request_table;
conn = G_DBUS_CONNECTION(source_object);
message = g_dbus_connection_call_finish(conn, res, &error);
if (message == NULL && error != NULL) {
- WIFI_LOG(WIFI_ERROR, "Delete profile, error [%s]\n", error->message);
+ WIFI_LOG(WIFI_ERROR, "Delete profile, error [%s]", error->message);
Error = NET_ERR_UNKNOWN;
g_error_free(error);
goto error;
while (g_variant_iter_loop(iter, "(oa{sv})", &path, &service)) {
if (g_strcmp0(request_table[NETWORK_REQUEST_TYPE_FORGET_AP].ProfileName, path) == 0) {
- Error = __net_extract_service_info(path, service,
- &prof_info);
+ Error = __net_extract_service_info(network_info,
+ path, service, &prof_info);
g_variant_iter_free(service);
g_free(path);
break;
request_table[NETWORK_REQUEST_TYPE_FORGET_AP].ProfileName,
NET_PROFILE_NAME_LEN_MAX + 1);
- Error = __net_wifi_delete_profile(&wifi_prof_name,
- prof_info.security_info.sec_mode,
- prof_info.passpoint);
+ Error = __net_wifi_delete_profile(network_info, &wifi_prof_name,
+ prof_info.security_info.sec_mode, prof_info.passpoint);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"Failed to delete service(profile). Error [%s]",
prof_info.ProfileState != NET_STATE_TYPE_READY &&
prof_info.ProfileState != NET_STATE_TYPE_ASSOCIATION &&
prof_info.ProfileState != NET_STATE_TYPE_CONFIGURATION)
- net_forget_ap_finshed(Error);
+ net_forget_ap_finished(network_info, Error);
- _net_dbus_pending_call_unref();
__NETWORK_FUNC_EXIT__;
return;
error:
- net_forget_ap_finshed(Error);
- _net_dbus_pending_call_unref();
+ net_forget_ap_finished(network_info, Error);
__NETWORK_FUNC_EXIT__;
}
-int net_delete_profile_async(const char* profile_name)
+int net_delete_profile_async(network_info_s *network_info, const char* profile_name)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
- }
-
WIFI_LOG(WIFI_INFO, "Delete Profile [%s]", profile_name);
if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
}
/* Get service details */
- request_table[NETWORK_REQUEST_TYPE_FORGET_AP].flag = TRUE;
- g_strlcpy(request_table[NETWORK_REQUEST_TYPE_FORGET_AP].ProfileName,
+ network_info->request_table[NETWORK_REQUEST_TYPE_FORGET_AP].flag = TRUE;
+ g_strlcpy(network_info->request_table[NETWORK_REQUEST_TYPE_FORGET_AP].ProfileName,
profile_name, NET_PROFILE_NAME_LEN_MAX+1);
- Error = _net_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
- CONNMAN_MANAGER_PATH,
- CONNMAN_MANAGER_INTERFACE,
- "GetServices", NULL,
- DBUS_REPLY_TIMEOUT,
- _net_delete_profile_async_reply);
+ Error = _net_invoke_dbus_method_nonblock(network_info,
+ CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE, "GetServices",
+ NULL, DBUS_REPLY_TIMEOUT,
+ _net_delete_profile_async_reply);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"Failed to get service(profile) information. Error [%s]",
_net_print_error(Error));
- request_table[NETWORK_REQUEST_TYPE_FORGET_AP].flag = FALSE;
+ network_info->request_table[NETWORK_REQUEST_TYPE_FORGET_AP].flag = FALSE;
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return Error; //LCOV_EXCL_LINE
}
return NET_ERR_NONE;
}
-int net_modify_profile(const char* profile_name, net_profile_info_s* prof_info)
+int net_modify_profile(network_info_s *network_info,
+ const char* profile_name, net_profile_info_s* prof_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
net_profile_info_s exProfInfo;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
- }
-
- if (!net_get_device_policy_wifi()) {
+ if (!net_get_device_policy_wifi(network_info)) {
WIFI_LOG(WIFI_ERROR, "Wifi device policy restricts"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_SECURITY_RESTRICTED; //LCOV_EXCL_LINE
}
- if (!net_get_device_policy_wifi_profile()) {
+ if (!net_get_device_policy_wifi_profile(network_info)) {
WIFI_LOG(WIFI_ERROR, "Wifi profile device policy restricts"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_SECURITY_RESTRICTED; //LCOV_EXCL_LINE
}
- Error = net_get_profile_info(profile_name, &exProfInfo);
+ Error = net_get_profile_info(network_info, profile_name, &exProfInfo);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"Failed to get service(profile) information. Error [%s]",
}
if (prof_info == NULL) {
- WIFI_LOG(WIFI_ERROR, "Invalid Parameter\n"); //LCOV_EXCL_LINE
+ WIFI_LOG(WIFI_ERROR, "Invalid Parameter"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
}
- Error = __net_wifi_modify_profile(profile_name, prof_info, &exProfInfo);
+ Error = __net_wifi_modify_profile(network_info, profile_name, prof_info, &exProfInfo);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
return NET_ERR_NONE;
}
-int net_get_profile_info(const char *profile_name, net_profile_info_s *prof_info)
+int net_get_profile_info(network_info_s *network_info,
+ const char *profile_name, net_profile_info_s *prof_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
- }
-
if (prof_info == NULL ||
_net_check_profile_name(profile_name) != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Invalid Parameter"); //LCOV_EXCL_LINE
return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
}
- Error = __net_get_profile_info(profile_name, prof_info);
+ Error = __net_get_profile_info(network_info, profile_name, prof_info);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"Failed to get service(profile) information. Error [%s]",
return Error;
}
-int net_get_profile_list(GSList **profile_list)
+int net_get_interface_list(network_info_s *network_info, GSList **interface_list)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ Error = _net_get_interface_list(network_info, interface_list);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "Failed to get interface list. Error [%s]",
+ _net_print_error(Error));
}
- Error = _net_get_profile_list(profile_list);
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int net_get_profile_list(network_info_s *network_info, GSList **profile_list)
+{
+ __NETWORK_FUNC_ENTER__;
+ net_err_e Error = NET_ERR_NONE;
+
+ Error = _net_get_profile_list(network_info, profile_list);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"Failed to get service(profile) list. Error [%s]",
_net_print_error(Error));
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return Error; //LCOV_EXCL_LINE
}
__NETWORK_FUNC_EXIT__;
- return NET_ERR_NONE;
+ return Error;
}
-int net_get_technology_properties(net_tech_info_s *tech_info)
+int net_get_technology_properties(network_info_s *network_info, net_tech_info_s *tech_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
- }
-
- if ((Error = _net_dbus_get_tech_status(tech_info)) != NET_ERR_NONE) {
+ if ((Error = _net_dbus_get_tech_status(network_info, tech_info)) != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to get technology status. Error [%s]", //LCOV_EXCL_LINE
_net_print_error(Error));
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_NONE;
}
-int net_config_get_id_list(GSList **list)
+int net_config_get_id_list(network_info_s *network_info, GSList **list)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
- }
-
- Error = _net_dbus_config_get_id_list(list);
+ Error = _net_dbus_config_get_id_list(network_info, list);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"Failed to get config id list. Error [%s]",
return Error;
}
-int net_config_set_field(const gchar *config_id, const gchar *key, const gchar *value)
+int net_config_set_field(network_info_s *network_info,
+ const gchar *config_id, const gchar *key, const gchar *value)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
- }
-
- Error = _net_dbus_config_set_field(config_id, key, value);
+ Error = _net_dbus_config_set_field(network_info, config_id, key, value);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"Failed to set field. Error [%s]",
return Error;
}
-int net_config_get_passphrase(const gchar *config_id, gchar **passphrase)
+int net_config_get_passphrase(network_info_s *network_info,
+ const gchar *config_id, gchar **passphrase)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
- }
-
- Error = _net_dbus_config_get_passphrase(config_id, passphrase);
+ Error = _net_dbus_config_get_passphrase(network_info, config_id, passphrase);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"Failed to get config id list. Error [%s]",
return Error;
}
-int net_config_save_configurations(const gchar *config_id, const gchar *name,
- const gchar *ssid, const gchar *passphrase, const gchar *proxy_address,
- net_ip_info_config_s *ip_info, gboolean is_hidden, gboolean is_created)
+int net_config_save_configurations(network_info_s *network_info,
+ const gchar *config_id, const gchar *name, const gchar *ssid, const gchar *passphrase,
+ const gchar *proxy_address, net_ip_info_config_s *ip_info,
+ gboolean is_hidden, gboolean is_created)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
- }
-
- Error = _net_dbus_config_save_configurations(config_id, name, ssid,
- passphrase, proxy_address, ip_info, is_hidden, is_created);
+ Error = _net_dbus_config_save_configurations(network_info,
+ config_id, name, ssid, passphrase, proxy_address,
+ ip_info, is_hidden, is_created);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"Failed to save configurations. Error [%s]",
}
//LCOV_EXCL_START
-int net_config_save_eap_configurations(const gchar *config_id,
- const gchar *name, const gchar *ssid, const gchar *passphrase,
+int net_config_save_eap_configurations(network_info_s *network_info,
+ const gchar *config_id, const gchar *name, const gchar *ssid, const gchar *passphrase,
const gchar *proxy_address, void *eap_config, gboolean is_hidden, gboolean is_created)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
net_eap_config_s *net_eap_config = (net_eap_config_s *)eap_config;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- Error = _net_dbus_config_save_eap_configurations(config_id, name, ssid, passphrase,
+ Error = _net_dbus_config_save_eap_configurations(network_info,
+ config_id, name, ssid, passphrase,
proxy_address, net_eap_config, is_hidden, is_created);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR,
}
//LCOV_EXCL_STOP
-int net_config_remove_configurations(const gchar *config_id)
+int net_config_remove_configurations(network_info_s *network_info,
+ const gchar *config_id)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
- }
-
- Error = _net_dbus_config_remove_configurations(config_id);
+ Error = _net_dbus_config_remove_configurations(network_info, config_id);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"Failed to remove configurations. Error [%s]",
return Error;
}
-int net_config_load_configurations(const gchar *config_id, gchar **name,
+int net_config_load_configurations(network_info_s *network_info,
+ const gchar *config_id, gchar **name,
gchar **passphrase, void *security_type, gchar **proxy_address, gboolean *is_hidden,
net_ip_info_config_s **ip_info, void *last_error)
{
net_err_e Error = NET_ERR_NONE;
net_wifi_security_type_e *sec_type = (net_wifi_security_type_e *)security_type;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
- }
-
- Error = _net_dbus_config_load_configurations(config_id, name, passphrase,
- sec_type, proxy_address, is_hidden, ip_info, last_error);
+ Error = _net_dbus_config_load_configurations(network_info,
+ config_id, name, passphrase, sec_type, proxy_address,
+ is_hidden, ip_info, last_error);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"Failed to load configurations. Error [%s]",
}
//LCOV_EXCL_START
-int net_config_load_eap_configurations(const gchar *config_id,
- gchar **name, void *security_type, gchar **proxy_address,
+int net_config_load_eap_configurations(network_info_s *network_info,
+ const gchar *config_id, gchar **name, void *security_type, gchar **proxy_address,
gboolean *is_hidden, void **eap_config, void *last_error)
{
__NETWORK_FUNC_ENTER__;
net_eap_config_s **net_eap_config = (net_eap_config_s **)eap_config;
net_wifi_security_type_e *sec_type = (net_wifi_security_type_e *)security_type;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- Error = _net_dbus_config_load_eap_configurations(config_id, name, sec_type,
- proxy_address, is_hidden, net_eap_config, last_error);
+ Error = _net_dbus_config_load_eap_configurations(network_info,
+ config_id, name, sec_type, proxy_address, is_hidden,
+ net_eap_config, last_error);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR,
"Failed to load eap configurations. Error [%s]",
return Error;
}
-int net_wifi_set_autoscan(gboolean autoscan)
+int net_wifi_set_autoscan(network_info_s *network_info, gboolean autoscan)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
WIFI_LOG(WIFI_INFO, "[%s] auto scan", autoscan ? "enable" : "disable");
if (autoscan)
- Error = _net_dbus_resume_bgscan();
+ Error = _net_dbus_resume_bgscan(network_info);
else
- Error = _net_dbus_pause_bgscan();
+ Error = _net_dbus_pause_bgscan(network_info);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
return NET_ERR_NONE;
}
-int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_e scan_mode)
+int net_wifi_set_background_scan_mode(network_info_s *network_info,
+ net_wifi_background_scan_mode_e scan_mode)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
+ Error = __net_get_wifi_state(network_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
}
- if (NetworkInfo.wifi_state == WIFI_OFF) {
- if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
- }
+ if (network_info->wifi_state == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- if ((Error = _net_dbus_set_bgscan_mode(scan_mode)) != NET_ERR_NONE) {
+ if ((Error = _net_dbus_set_bgscan_mode(network_info, scan_mode)) != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
"Failed to set bgscan mode. Error [%s]",
_net_print_error(Error));
return NET_ERR_NONE;
}
-int net_wifi_set_ip_conflict_period(unsigned int initial_time)
+int net_wifi_set_ip_conflict_period(network_info_s *network_info,
+ unsigned int initial_time)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if ((Error = _net_dbus_set_ip_conflict_period(initial_time)) != NET_ERR_NONE) {
+ if ((Error = _net_dbus_set_ip_conflict_period(network_info, initial_time)) != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
"Failed to set ip conflict detect period. Error [%s]",
_net_print_error(Error));
return NET_ERR_NONE;
}
-int net_wifi_get_ip_conflict_period(unsigned int* initial_time)
+int net_wifi_get_ip_conflict_period(network_info_s *network_info,
+ unsigned int* initial_time)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
+ GVariant *params = NULL;
GVariant *message = NULL;
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, "GetIpConflictPeriod", NULL, &Error);
+ params = g_variant_new("(s)", network_info->interface_name);
+
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "GetIpConflictPeriod",
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to get IP conflict detection period"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__;
return Error;
}
-int net_wifi_get_ip_conflict_state(unsigned int *state)
+int net_wifi_get_ip_conflict_state(network_info_s *network_info, unsigned int *state)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
+ GVariant *params = NULL;
GVariant *message = NULL;
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, "GetIpConflictState", NULL, &Error);
+ params = g_variant_new("(s)", network_info->interface_name);
+
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "GetIpConflictState",
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to get IP conflict state"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__;
return Error;
}
-int net_wifi_get_autoscan(gboolean *autoscan)
+int net_wifi_get_autoscan(network_info_s *network_info, gboolean *autoscan)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- if (_net_dbus_is_pending_call_used() == TRUE) {
- WIFI_LOG(WIFI_ERROR, "pending call in progress");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
- }
-
- Error = _net_dbus_get_autoscan(autoscan);
+ Error = _net_dbus_get_autoscan(network_info, autoscan);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
"_net_dbus_get_autoscan() failed. Error [%s]",
return Error;
}
-int net_wifi_get_autoscanmode(unsigned int *autoscanmode)
+int net_wifi_get_autoscanmode(network_info_s *network_info, unsigned int *autoscanmode)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- if (_net_dbus_is_pending_call_used() == TRUE) {
- WIFI_LOG(WIFI_ERROR, "pending call in progress");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
- }
-
- Error = _net_dbus_get_autoscanmode(autoscanmode);
+ Error = _net_dbus_get_autoscanmode(network_info, autoscanmode);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
"_net_dbus_get_autoscanmode() failed. Error [%s]",
return Error;
}
+int net_wifi_get_module_state(network_info_s *network_info, int *module_state)
+{
+ GVariant *message = NULL, *variant;
+ GVariantIter *iter, *next;
+ const char *path;
+ gchar *key;
+ net_err_e Error = NET_ERR_NONE;
+
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE, "GetTechnologies",
+ NULL, &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get_technology_state");
+ return Error;
+ }
+
+ *module_state = 0;
+
+ 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 = NULL;
+ gchar *dev_key = NULL;
+ GVariant *dev_var = NULL;
+ const gchar *sdata = 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)) {
+ sdata = g_variant_get_string(dev_var, NULL);
+ WIFI_LOG(WIFI_INFO, "%s [%s]", dev_key, sdata);
+
+ if (g_strcmp0(dev_key, "Ifname") == 0) {
+ if (g_strcmp0(sdata, network_info->interface_name) == 0)
+ *module_state = 1;
+ }
+ }
+ }
+ g_variant_iter_free(list_iter);
+ }
+ }
+ }
+
+ g_variant_unref(message);
+ g_variant_iter_free(iter);
+
+ return NET_ERR_NONE;
+}
+
static int __net_convert_string_to_ipv6_string(char *str, char **ip_address)
{
int i = 1;
*ip_address = (char *)malloc(INET6_ADDRSTRLEN);
if (NULL == *ip_address) {
- WIFI_LOG(WIFI_ERROR, "Malloc Failed\n");
+ WIFI_LOG(WIFI_ERROR, "Malloc Failed");
return NET_ERR_INVALID_OPERATION;
}
return Error;
}
-int net_get_preferred_ipv6_address(const char *profilename, char **address)
+int net_get_preferred_ipv6_address(network_info_s *network_info,
+ const char *profilename, char **address)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- Error = _net_dbus_get_preferred_ipv6_address(profilename, address);
+ Error = _net_dbus_get_preferred_ipv6_address(network_info, profilename, address);
if (Error != NET_ERR_NONE)
- WIFI_LOG(WIFI_ERROR, "_net_dbus_get_preferred_ipv6_address failed\n");
+ WIFI_LOG(WIFI_ERROR, "_net_dbus_get_preferred_ipv6_address failed");
__NETWORK_FUNC_EXIT__;
return Error;
}
-int net_get_service_state()
+int net_get_service_state(network_info_s *network_info)
{
- __NETWORK_FUNC_ENTER__;
- return _net_get_service_state();
+ return network_info->service_state;
}
-int net_wifi_get_max_scan_ssids(int *max_scan_ssids)
+int net_wifi_get_max_scan_ssids(network_info_s *network_info, int *max_scan_ssids)
{
__NETWORK_CAPI_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered");
- __NETWORK_CAPI_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
- }
-
- Error = _net_dbus_get_max_scan_ssids(max_scan_ssids);
+ Error = _net_dbus_get_max_scan_ssids(network_info, max_scan_ssids);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
"Failed to get Max scan SSIDs. Error [%s]",
return NET_ERR_NONE;
}
-static net_err_e __check_preconditions()
+static net_err_e __check_preconditions(network_info_s *network_info)
{
- net_err_e rv = NET_ERR_NONE;
+ net_err_e Error = NET_ERR_NONE;
- if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_NOT_REGISTERED;
+ Error = __net_get_wifi_state(network_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
}
- if (NetworkInfo.wifi_state == WIFI_OFF) {
- if ((NetworkInfo.wifi_state = _net_get_wifi_state(&rv)) == WIFI_OFF) {
- WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
- }
+ if (network_info->wifi_state == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- return rv;
+ return Error;
}
-int net_dpp_enter_peer_uri(guint32 peer_id, guint32 own_id, const char *uri)
+int net_dpp_enter_peer_uri(network_info_s *network_info,
+ guint32 peer_id, guint32 own_id, const char *uri)
{
net_err_e Error = NET_ERR_NONE;
- Error = __check_preconditions();
+ Error = __check_preconditions(network_info);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to enter peer uri : %d", Error);
/* TODO generate args, set request table value, handle return values*/
- Error = _net_dbus_dpp_enter_peer_uri(peer_id, own_id, uri);
+ Error = _net_dbus_dpp_enter_peer_uri(network_info, peer_id, own_id, uri);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
return Error;
}
-int net_dpp_generate_own_uri(guint32 peer_id, guint32 own_id, gboolean is_initiator, const char *key)
+int net_dpp_generate_own_uri(network_info_s *network_info,
+ guint32 peer_id, guint32 own_id, gboolean is_initiator, const char *key)
{
net_err_e Error = NET_ERR_NONE;
- Error = __check_preconditions();
+ Error = __check_preconditions(network_info);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to generate uri : %d", Error);
/* TODO generate args, set request table value, handle return values*/
- Error = _net_dbus_dpp_generate_uri(peer_id, own_id, is_initiator, key);
+ Error = _net_dbus_dpp_generate_uri(network_info, peer_id, own_id, is_initiator, key);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
gboolean is_configurator = (p_dpp->role == WIFI_MANAGER_DPP_ROLE_CONFIGURATOR);
if (p_dpp->is_initiator && is_configurator)
- rv = _net_dbus_dpp_start_configurator_initiator(p_dpp->group_id, p_dpp->ssid,
+ rv = _net_dbus_dpp_start_configurator_initiator(p_dpp->network_info,
+ p_dpp->group_id, p_dpp->ssid,
p_dpp->peer_uri, p_dpp->peer_id,
__dpp_network_role_to_string(p_dpp->net_role),
__dpp_akm_to_string(p_dpp->akm),
configurator_key, pass);
else if (p_dpp->is_initiator && !is_configurator)
- rv = _net_dbus_dpp_start_enrollee_initiator(p_dpp->peer_uri, p_dpp->peer_id);
+ rv = _net_dbus_dpp_start_enrollee_initiator(p_dpp->network_info,
+ p_dpp->peer_uri, p_dpp->peer_id);
else if (!p_dpp->is_initiator && is_configurator)
- rv = _net_dbus_dpp_start_configurator_responder(p_dpp->group_id, p_dpp->ssid,
+ rv = _net_dbus_dpp_start_configurator_responder(p_dpp->network_info,
+ p_dpp->group_id, p_dpp->ssid,
__dpp_network_role_to_string(p_dpp->net_role),
__dpp_akm_to_string(p_dpp->akm),
auth_key, configurator_key, pass);
else
- rv = _net_dbus_dpp_start_enrollee_responder(auth_key);
+ rv = _net_dbus_dpp_start_enrollee_responder(p_dpp->network_info, auth_key);
return rv;
}
-int net_dpp_start(void *dpp_data, const char *auth_key,
+int net_dpp_start(void *dpp_handle, const char *auth_key,
const char *configurator_key, const char *pass)
{
net_err_e Error = NET_ERR_NONE;
+ wifi_dpp_s *dpp_data = (wifi_dpp_s *)dpp_handle;
- Error = __check_preconditions();
+ Error = __check_preconditions(dpp_data->network_info);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to start dpp uri : %d", Error);
/* TODO generate args, set request table value, handle return values*/
- Error = __net_dpp_start_each((wifi_dpp_s *)dpp_data, auth_key, configurator_key, pass);
+ Error = __net_dpp_start_each(dpp_data, auth_key, configurator_key, pass);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
return Error;
}
-int net_dpp_stop(guint32 peer_id, guint32 own_id, gboolean is_initiator)
+int net_dpp_stop(network_info_s *network_info,
+ guint32 peer_id, guint32 own_id, gboolean is_initiator)
{
net_err_e Error = NET_ERR_NONE;
- Error = __check_preconditions();
+ Error = __check_preconditions(network_info);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to stop dpp : %d", Error);
/* TODO generate args, set request table value, handle return values*/
- Error = _net_dbus_dpp_stop(peer_id, own_id, is_initiator);
+ Error = _net_dbus_dpp_stop(network_info, peer_id, own_id, is_initiator);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
#include "network_internal.h"
#include "network_dbus.h"
-typedef struct {
- GDBusConnection *connection;
- int conn_ref_count;
- GCancellable *cancellable;
- void *handle_libnetwork;
-} gdbus_connection_data_s;
-
-typedef struct {
- GSourceFunc func;
- gpointer user_data;
- guint id;
-} managed_idle_data_s;
-
-extern __thread network_info_s NetworkInfo;
-__thread network_request_table_s request_table[NETWORK_REQUEST_TYPE_MAX] = { { 0, }, };
-
-static __thread gdbus_connection_data_s gdbus_conn = { NULL, 0, NULL, NULL };
-static __thread GSList *managed_idler_list = NULL;
-
//LCOV_EXCL_START
static char *__convert_eap_type_to_string(gchar eap_type)
{
}
}
-int _net_get_tech_state(GVariant *msg, network_tech_state_info_s* tech_state)
+int _net_get_tech_state(network_info_s *network_info,
+ GVariant *msg, network_tech_state_info_s* tech_state)
{
__NETWORK_FUNC_ENTER__;
gchar *tech_prefix;
gchar *path = NULL;
gchar *key = NULL;
- gboolean data;
tech_prefix = CONNMAN_WIFI_TECHNOLOGY_PREFIX;
continue;
while (g_variant_iter_loop(var, "{sv}", &key, &value)) {
- if (g_strcmp0(key, "Powered") == 0) {
- data = g_variant_get_boolean(value);
-
- if (data)
- tech_state->Powered = TRUE;
- else
- tech_state->Powered = FALSE;
- } else if (g_strcmp0(key, "Connected") == 0) {
- data = g_variant_get_boolean(value);
-
- if (data)
- tech_state->Connected = TRUE;
- else
- tech_state->Connected = FALSE;
- } else if (g_strcmp0(key, "Tethering") == 0) {
- /* For further use */
+ if (g_strcmp0(key, "Device.List") == 0) {
+ GVariantIter *list_iter = NULL;
+ gchar *dev_key = NULL;
+ GVariant *dev_var = NULL;
+ const gchar *sdata = NULL;
+ gboolean bdata = FALSE;
+ gboolean find = FALSE;
+
+ g_variant_get(value, "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)) {
+ sdata = g_variant_get_string(dev_var, NULL);
+ WIFI_LOG(WIFI_INFO, "%s [%s]", dev_key, sdata);
+
+ if (g_strcmp0(dev_key, "Ifname") == 0) {
+ find = g_strcmp0(sdata, network_info->interface_name) == 0 ? TRUE : FALSE;
+ }
+ } else if (g_variant_is_of_type(dev_var, G_VARIANT_TYPE_BOOLEAN)) {
+ bdata = g_variant_get_boolean(dev_var);
+ WIFI_LOG(WIFI_INFO, "%s [%s]", dev_key, bdata ? "True" : "False");
+
+ if (find && g_strcmp0(dev_key, "Powered") == 0) {
+ tech_state->Powered = bdata;
+ } else if (find && g_strcmp0(dev_key, "Connected") == 0) {
+ tech_state->Connected = bdata;
+ }
+ }
+ }
+ g_variant_iter_free(list_iter);
}
}
}
}
/** This function is used only to open Wi-Fi connection with hidden APs */
-int _net_open_connection_with_wifi_info(const net_wifi_connection_info_s* wifi_info)
+int _net_open_connection_with_wifi_info(network_info_s *network_info,
+ const net_wifi_connection_info_s* wifi_info)
{
__NETWORK_FUNC_ENTER__;
return NET_ERR_INVALID_PARAM;
}
- Error = _net_dbus_connect_service(&wifi_connection_info);
+ Error = _net_dbus_connect_service(network_info, &wifi_connection_info);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to request connect service. Error [%s]",
_net_print_error(Error));
return Error;
}
-static void __net_client_clear_cb_data(net_event_info_s *client)
-{
- if (client && client->Datalength > 0) {
- if (client->Event == NET_EVENT_WIFI_SPECIFIC_SCAN_IND ||
- client->Event == NET_EVENT_WIFI_BSSID_SCAN_IND ||
- client->Event == NET_EVENT_WIFI_NETLINK_SCAN_IND) {
- GSList *bss_info_list = client->Data;
-
- if (bss_info_list != NULL) {
- g_slist_free_full(bss_info_list, g_free);
- client->Data = NULL;
- }
- }
- g_free(client->Data);
- client->Data = NULL;
- }
- g_free(client);
-}
-
-static gboolean __net_client_cb_wifi_idle(gpointer data)
-{
- net_event_info_s *event_data = (net_event_info_s *)data;
-
- if (NetworkInfo.ClientEventCb_wifi != NULL)
- NetworkInfo.ClientEventCb_wifi(event_data, NetworkInfo.user_data_wifi);
-
- __net_client_clear_cb_data(event_data);
-
- return FALSE;
-}
-
-void _net_client_callback(net_event_info_s *event_data)
-{
- guint id;
-
- __NETWORK_FUNC_ENTER__;
-
- if (NetworkInfo.ref_count < 1) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered. "
- "If multi-threaded, thread integrity be broken.");
- __NETWORK_FUNC_EXIT__;
- return;
- }
-
- if (NetworkInfo.ClientEventCb_wifi != NULL) {
- net_event_info_s *client = g_try_new0(net_event_info_s, 1);
- if (client == NULL) {
- __NETWORK_FUNC_EXIT__;
- return;
- }
-
- memcpy(client, event_data, sizeof(net_event_info_s));
- if (event_data->Datalength > 0) {
- if (event_data->Event == NET_EVENT_WIFI_SPECIFIC_SCAN_IND ||
- event_data->Event == NET_EVENT_WIFI_BSSID_SCAN_IND ||
- event_data->Event == NET_EVENT_WIFI_NETLINK_SCAN_IND) {
- client->Data = event_data->Data;
- } else {
- client->Data = g_try_malloc0(event_data->Datalength);
- if (client->Data == NULL) {
- g_free(client);
- __NETWORK_FUNC_EXIT__;
- return;
- }
-
- memcpy(client->Data, event_data->Data, event_data->Datalength);
- }
- } else {
- client->Datalength = 0;
- client->Data = NULL;
- }
-
- id = _net_client_callback_add(__net_client_cb_wifi_idle, (gpointer)client);
- if (!id)
- __net_client_clear_cb_data(client);
- }
-
- __NETWORK_FUNC_EXIT__;
-}
-
-net_wifi_state_e _net_get_wifi_state(net_err_e *net_error)
+net_err_e _net_get_wifi_state(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
network_tech_state_info_s tech_state = { { 0, }, };
- net_wifi_state_e wifi_state = WIFI_UNKNOWN;
g_strlcpy(tech_state.technology, "wifi", NET_TECH_LENGTH_MAX);
- Error = _net_dbus_get_technology_state(&tech_state);
+ Error = _net_dbus_get_technology_state(network_info, &tech_state);
if (Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR,
"_net_dbus_get_technology_state() failed. Error [%s]",
_net_print_error(Error));
- *net_error = Error;
goto state_done;
}
if (tech_state.Powered == TRUE)
- wifi_state = WIFI_ON;
+ network_info->wifi_state = WIFI_ON;
else
- wifi_state = WIFI_OFF;
+ network_info->wifi_state = WIFI_OFF;
state_done:
__NETWORK_FUNC_EXIT__;
- return wifi_state;
-}
-
-static void __net_client_idle_destroy_cb(gpointer data)
-{
- __NETWORK_FUNC_ENTER__;
-
- if (!data) {
- __NETWORK_FUNC_EXIT__;
- return;
- }
-
- managed_idler_list = g_slist_remove(managed_idler_list, data);
- g_free(data);
-
- __NETWORK_FUNC_EXIT__;
-}
-
-static gboolean __net_client_idle_cb(gpointer user_data)
-{
- __NETWORK_FUNC_ENTER__;
-
- managed_idle_data_s *data = (managed_idle_data_s *)user_data;
-
- if (!data) {
- __NETWORK_FUNC_EXIT__;
- return FALSE;
- }
-
- __NETWORK_FUNC_EXIT__;
- return data->func(data->user_data);
-}
-
-guint _net_client_callback_add(GSourceFunc func, gpointer user_data)
-{
- __NETWORK_FUNC_ENTER__;
-
- guint id;
- managed_idle_data_s *data;
- GMainContext *context;
- GSource *src;
-
- if (!func) {
- __NETWORK_FUNC_EXIT__;
- return 0;
- }
-
- data = g_try_new0(managed_idle_data_s, 1);
- if (!data) {
- __NETWORK_FUNC_EXIT__;
- return 0;
- }
-
- data->func = func;
- data->user_data = user_data;
-
- context = g_main_context_get_thread_default();
- src = g_idle_source_new();
- g_source_set_callback(src, __net_client_idle_cb, data,
- __net_client_idle_destroy_cb);
- id = g_source_attach(src, context);
- g_source_unref(src);
- if (!id) {
- g_free(data);
- __NETWORK_FUNC_EXIT__;
- return id;
- }
-
- data->id = id;
-
- managed_idler_list = g_slist_append(managed_idler_list, data);
-
- __NETWORK_FUNC_EXIT__;
- return id;
-}
-
-void _net_client_callback_cleanup(void)
-{
- __NETWORK_FUNC_ENTER__;
-
- GSList *cur = managed_idler_list;
- GSource *src;
- managed_idle_data_s *data;
-
- while (cur) {
- GSList *next = cur->next;
- data = (managed_idle_data_s *)cur->data;
-
- src = g_main_context_find_source_by_id(g_main_context_default(), data->id);
- if (src) {
- __net_client_clear_cb_data((net_event_info_s *)data->user_data);
- g_source_destroy(src);
- cur = managed_idler_list;
- } else
- cur = next;
- }
-
- g_slist_free(managed_idler_list);
- managed_idler_list = NULL;
-
- __NETWORK_FUNC_EXIT__;
+ return Error;
}
-void _net_clear_request_table(void)
+void _net_clear_request_table(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
int i;
for (i = 0; i < NETWORK_REQUEST_TYPE_MAX; i++)
- memset(&request_table[i], 0, sizeof(network_request_table_s));
+ memset(&(network_info->request_table[i]), 0, sizeof(network_request_table_s));
__NETWORK_FUNC_EXIT__;
}
-gboolean _net_dbus_is_pending_call_used(void)
-{
- if (gdbus_conn.conn_ref_count > 0)
- return TRUE;
-
- return FALSE;
-}
-
-void _net_dbus_pending_call_ref(void)
-{
- g_object_ref(gdbus_conn.connection);
-
- __sync_fetch_and_add(&gdbus_conn.conn_ref_count, 1);
-}
-
-void _net_dbus_pending_call_unref(void)
-{
- if (gdbus_conn.conn_ref_count < 1)
- return;
-
- if (gdbus_conn.connection)
- g_object_unref(gdbus_conn.connection);
-
- if (__sync_sub_and_fetch(&gdbus_conn.conn_ref_count, 1) < 1 &&
- gdbus_conn.handle_libnetwork != NULL) {
- WIFI_LOG(WIFI_ERROR, "A handle of libnetwork is not NULL");
-
- if (NetworkInfo.ref_count < 1)
- gdbus_conn.connection = NULL;
- }
-}
-
-int _net_dbus_create_gdbus_call(void)
+int _net_dbus_create_gdbus_call(network_info_s *network_info)
{
GError *error = NULL;
- if (gdbus_conn.connection != NULL) {
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_APP_ALREADY_REGISTERED;
- }
-
#if !GLIB_CHECK_VERSION(2, 36, 0)
g_type_init();
#endif
- gdbus_conn.connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (gdbus_conn.connection == NULL) {
+ if (network_info == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ network_info->connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (network_info->connection == NULL) {
if (error != NULL) {
WIFI_LOG(WIFI_ERROR,
"Failed to connect to the D-BUS daemon [%s]", error->message);
return NET_ERR_UNKNOWN;
}
- gdbus_conn.cancellable = g_cancellable_new();
-
- if (gdbus_conn.handle_libnetwork != NULL) {
- WIFI_LOG(WIFI_ERROR,
- "A handle of libnetwork is not NULL and should be released");
-
- dlclose(gdbus_conn.handle_libnetwork);
- gdbus_conn.handle_libnetwork = NULL;
- }
+ network_info->cancellable = g_cancellable_new();
return NET_ERR_NONE;
}
-int _net_dbus_close_gdbus_call(void)
+void _net_dbus_close_gdbus_call(network_info_s *network_info)
{
- g_cancellable_cancel(gdbus_conn.cancellable);
- g_object_unref(gdbus_conn.cancellable);
- gdbus_conn.cancellable = NULL;
-
- if (gdbus_conn.conn_ref_count < 1) {
- WIFI_LOG(WIFI_INFO, "There is no pending call");
- } else {
- WIFI_LOG(WIFI_ERROR,
- "There are %d pending calls, waiting to be cleared",
- gdbus_conn.conn_ref_count);
+ if (network_info) {
+ g_cancellable_cancel(network_info->cancellable);
+ g_object_unref(network_info->cancellable);
+ network_info->cancellable = NULL;
- if (gdbus_conn.handle_libnetwork != NULL)
- WIFI_LOG(WIFI_ERROR, "A handle of libnetwork is not NULL");
-
- gdbus_conn.handle_libnetwork = dlopen("/usr/lib/libnetwork.so", RTLD_LAZY);
- g_object_unref(gdbus_conn.connection);
+ g_object_unref(network_info->connection);
+ network_info->connection = NULL;
}
-
- if (G_IS_OBJECT(gdbus_conn.connection))
- g_clear_object(&gdbus_conn.connection);
- else
- gdbus_conn.connection = NULL;
-
- return NET_ERR_NONE;
-}
-
-GDBusConnection *_net_dbus_get_gdbus_conn(void)
-{
- return gdbus_conn.connection;
-}
-
-GCancellable *_net_dbus_get_gdbus_cancellable(void)
-{
- return gdbus_conn.cancellable;
}
//LCOV_EXCL_STOP
#define NET_WPS_EI_OPERATION_FAILED 1
#define NET_WPS_EI_SECURITY_WEP_PROHIBITED 2
-extern __thread network_info_s NetworkInfo;
-extern __thread network_request_table_s request_table[NETWORK_REQUEST_TYPE_MAX];
-extern __thread gboolean scan_pending;
-
-static __thread net_state_type_e service_state = NET_STATE_TYPE_UNKNOWN;
-static __thread int net_service_error = NET_ERR_NONE;
-static __thread guint gdbus_conn_subscribe_id_connman_state = 0;
-static __thread guint gdbus_conn_subscribe_id_connman_error = 0;
-static __thread guint gdbus_conn_subscribe_id_connman_scandone = 0;
-static __thread guint gdbus_conn_subscribe_id_connman_scanstarted = 0;
-static __thread guint gdbus_conn_subscribe_id_netconfig_wifi = 0;
-static __thread guint gdbus_conn_subscribe_id_netconfig = 0;
-
struct cs_tid_info {
int tid;
guint subscribe_id_connman_state;
return "Invalid parameter";
}
-static int __net_handle_wifi_power_rsp(gboolean value)
+static int __net_handle_wifi_power_rsp(network_info_s *network_info,
+ GVariant *param, gboolean value)
{
__NETWORK_FUNC_ENTER__;
- net_event_info_s event_data = { 0, };
+ net_event_info_s *event_data = NULL;
+ char *interface_name = NULL;
+
+ g_variant_get(param, "(s)", &interface_name);
+ if (g_strcmp0(interface_name, network_info->interface_name) != 0) {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+ }
+
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_OUT_OF_MEMORY;
+ }
if (value == TRUE) {
- NetworkInfo.wifi_state = WIFI_ON;
- event_data.Error = NET_ERR_NONE;
+ network_info->wifi_state = WIFI_ON;
+ event_data->Error = NET_ERR_NONE;
WIFI_LOG(WIFI_INFO, "wifi state: WIFI_ON");
} else {
- NetworkInfo.wifi_state = WIFI_OFF;
- event_data.Error = NET_ERR_NONE;
+ network_info->wifi_state = WIFI_OFF;
+ event_data->Error = NET_ERR_NONE;
WIFI_LOG(WIFI_INFO, "wifi state: WIFI_OFF");
- if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE)
- memset(&request_table[NETWORK_REQUEST_TYPE_SCAN],
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE)
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_SCAN]),
0, sizeof(network_request_table_s));
}
- if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
- memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER],
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_WIFI_POWER]),
0, sizeof(network_request_table_s));
- event_data.Event = NET_EVENT_WIFI_POWER_RSP;
+ event_data->Event = NET_EVENT_WIFI_POWER_RSP;
WIFI_LOG(WIFI_INFO, "NET_EVENT_WIFI_POWER_RSP");
-
- _net_dbus_pending_call_unref();
} else {
- event_data.Event = NET_EVENT_WIFI_POWER_IND;
+ event_data->Event = NET_EVENT_WIFI_POWER_IND;
WIFI_LOG(WIFI_INFO, "NET_EVENT_WIFI_POWER_IND");
}
- event_data.Datalength = sizeof(net_wifi_state_e);
- event_data.Data = &(NetworkInfo.wifi_state);
+ event_data->Datalength = sizeof(net_wifi_state_e);
+ event_data->Data = &(network_info->wifi_state);
- _net_client_callback(&event_data);
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
}
-static int __net_handle_specific_scan_resp(GSList *bss_info_list)
+static int __net_handle_specific_scan_resp(network_info_s *network_info,
+ GSList *bss_info_list)
{
__NETWORK_FUNC_ENTER__;
int count = 0;;
- net_event_info_s event_data = { 0, };
+ net_event_info_s *event_data = NULL;
- if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
- memset(&request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN],
- 0, sizeof(network_request_table_s));
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ g_slist_free_full(bss_info_list, g_free);
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_OUT_OF_MEMORY;
+ }
- _net_dbus_pending_call_unref();
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN]),
+ 0, sizeof(network_request_table_s));
count = (int)g_slist_length(bss_info_list);
WIFI_LOG(WIFI_INFO,
NETCONFIG_SIGNAL_SPECIFIC_SCAN_DONE,
count);
- event_data.Event = NET_EVENT_WIFI_SPECIFIC_SCAN_IND;
- event_data.Datalength = count;
- event_data.Data = bss_info_list;
+ event_data->Event = NET_EVENT_WIFI_SPECIFIC_SCAN_IND;
+ event_data->Datalength = count;
+ event_data->Data = bss_info_list;
- _net_client_callback(&event_data);
- } else
- g_slist_free_full(bss_info_list, g_free);
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+ }
+ g_slist_free_full(bss_info_list, g_free);
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-static int __net_handle_wifi_specific_scan_rsp(GVariant *param)
+static int __net_handle_wifi_specific_scan_rsp(network_info_s *network_info,
+ GVariant *param)
{
GVariantIter *iter = NULL;
GVariant *value = NULL;
}
g_variant_iter_free(iter);
- __net_handle_specific_scan_resp(bss_info_list);
-
- /* To enhance performance,
- * BSS list should be release in a delayed manner in _net_client_callback */
+ __net_handle_specific_scan_resp(network_info, bss_info_list);
return NET_ERR_NONE;
}
-static int __net_handle_bssid_scan_resp(GSList *bss_info_list)
+static int __net_handle_bssid_scan_resp(network_info_s *network_info,
+ GSList *bss_info_list)
{
__NETWORK_FUNC_ENTER__;
int count = 0;;
- net_event_info_s event_data = { 0, };
+ net_event_info_s *event_data = NULL;
- if (request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN].flag == TRUE) {
- memset(&request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN],
- 0, sizeof(network_request_table_s));
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ g_slist_free_full(bss_info_list, g_free);
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_OUT_OF_MEMORY;
+ }
- _net_dbus_pending_call_unref();
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN].flag == TRUE) {
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN]),
+ 0, sizeof(network_request_table_s));
count = (int)g_slist_length(bss_info_list);
WIFI_LOG(WIFI_INFO,
NETCONFIG_SIGNAL_BSSID_SCAN_DONE,
count);
- event_data.Event = NET_EVENT_WIFI_BSSID_SCAN_IND;
- event_data.Datalength = count;
- event_data.Data = bss_info_list;
+ event_data->Event = NET_EVENT_WIFI_BSSID_SCAN_IND;
+ event_data->Datalength = count;
+ event_data->Data = bss_info_list;
- _net_client_callback(&event_data);
- } else
- g_slist_free_full(bss_info_list, g_free);
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+ }
+ g_slist_free_full(bss_info_list, g_free);
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-static int __net_handle_wifi_bssid_scan_rsp(GVariant *param)
+static int __net_handle_wifi_bssid_scan_rsp(network_info_s *network_info,
+ GVariant *param)
{
GVariantIter *iter = NULL;
GVariant *value = NULL;
gboolean bssid_found = FALSE;
gboolean rssi_found = FALSE;
gboolean mode_found = FALSE;
+ char *interface_name = NULL;
- g_variant_get(param, "(a{sv})", &iter);
+ g_variant_get(param, "(sa{sv})", &interface_name, &iter);
+
+ if (g_strcmp0(interface_name, network_info->interface_name) != 0)
+ return NET_ERR_NONE;
while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
if (g_strcmp0(key, "ssid") == 0) {
}
g_variant_iter_free(iter);
- __net_handle_bssid_scan_resp(bss_info_list);
+ __net_handle_bssid_scan_resp(network_info, bss_info_list);
return NET_ERR_NONE;
}
-static int __net_handle_netlink_scan_resp(GSList *bss_info_list)
+static int __net_handle_netlink_scan_resp(network_info_s *network_info,
+ GSList *bss_info_list)
{
__NETWORK_FUNC_ENTER__;
int count = 0;;
- net_event_info_s event_data = { 0, };
+ net_event_info_s *event_data = NULL;
- if (request_table[NETWORK_REQUEST_TYPE_NETLINK_SCAN].flag == TRUE) {
- memset(&request_table[NETWORK_REQUEST_TYPE_NETLINK_SCAN],
- 0, sizeof(network_request_table_s));
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ g_slist_free_full(bss_info_list, g_free);
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_OUT_OF_MEMORY;
+ }
- _net_dbus_pending_call_unref();
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_NETLINK_SCAN].flag == TRUE) {
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_NETLINK_SCAN]),
+ 0, sizeof(network_request_table_s));
count = (int)g_slist_length(bss_info_list);
WIFI_LOG(WIFI_INFO,
NETCONFIG_SIGNAL_NETLINK_SCAN_DONE,
count);
- event_data.Event = NET_EVENT_WIFI_NETLINK_SCAN_IND;
- event_data.Datalength = count;
- event_data.Data = bss_info_list;
+ event_data->Event = NET_EVENT_WIFI_NETLINK_SCAN_IND;
+ event_data->Datalength = count;
+ event_data->Data = bss_info_list;
- _net_client_callback(&event_data);
- } else
- g_slist_free_full(bss_info_list, g_free);
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+ }
+ g_slist_free_full(bss_info_list, g_free);
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-static int __net_handle_wifi_netlink_scan_rsp(GVariant *param)
+static int __net_handle_wifi_netlink_scan_rsp(network_info_s *network_info,
+ GVariant *param)
{
GVariantIter *iter = NULL;
GVariant *value = NULL;
gboolean freq_found = FALSE;
gboolean rssi_found = FALSE;
gboolean vsie_found = FALSE;
+ char *interface_name = NULL;
- g_variant_get(param, "(a{sv})", &iter);
+ g_variant_get(param, "(sa{sv})", &interface_name, &iter);
+
+ if (g_strcmp0(interface_name, network_info->interface_name) != 0)
+ return NET_ERR_NONE;
while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
if (g_strcmp0(key, "ssid") == 0) {
return NET_ERR_UNKNOWN;
}
- g_strlcpy(bss->ssid, ssid, strlen(ssid)+1);
+ g_strlcpy(bss->ssid, ssid, strlen(ssid) + 1);
g_strlcpy(bss->bssid, bssid, WIFI_MAC_ADDR_LEN + 1);
bss->freq = freq;
bss->rssi = rssi;
}
}
g_variant_iter_free(iter);
- __net_handle_netlink_scan_resp(bss_info_list);
+
+ __net_handle_netlink_scan_resp(network_info, bss_info_list);
return NET_ERR_NONE;
}
-static void __net_handle_state_ind(const char *profile_name,
- net_state_type_e profile_state)
+static void __net_handle_state_ind(network_info_s *network_info,
+ const char *profile_name, net_state_type_e profile_state)
{
__NETWORK_FUNC_ENTER__;
- net_event_info_s event_data = { 0, };
+ net_event_info_s *event_data = NULL;
- event_data.Error = NET_ERR_NONE;
- event_data.Event = NET_EVENT_NET_STATE_IND;
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
- g_strlcpy(event_data.ProfileName, profile_name, sizeof(event_data.ProfileName));
+ event_data->Error = NET_ERR_NONE;
+ event_data->Event = NET_EVENT_NET_STATE_IND;
- event_data.Datalength = sizeof(net_state_type_e);
- event_data.Data = &profile_state;
+ g_strlcpy(event_data->ProfileName, profile_name, sizeof(event_data->ProfileName));
+
+ event_data->Datalength = sizeof(net_state_type_e);
+ event_data->Data = &profile_state;
WIFI_LOG(WIFI_INFO,
"Sending NET_EVENT_NET_STATE_IND, state: %d, profile name: %s",
- profile_state, event_data.ProfileName);
+ profile_state, event_data->ProfileName);
+
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
- _net_client_callback(&event_data);
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
}
-static void __net_handle_failure_ind(const char *profile_name)
+static void __net_handle_failure_ind(network_info_s *network_info,
+ const char *profile_name)
{
__NETWORK_FUNC_ENTER__;
- net_event_info_s event_data = { 0, };
+ net_event_info_s *event_data = NULL;
- const char *svc_name1 =
- request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
- const char *svc_name2 =
- request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
- const char *svc_name3 =
- request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName;
+ network_request_table_s *request_table = network_info->request_table;
+ const char *svc_name1 = request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
+ const char *svc_name2 = request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
+ const char *svc_name3 = request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName;
+
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
strstr(profile_name, svc_name1) != NULL) {
memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
sizeof(network_request_table_s));
- event_data.Event = NET_EVENT_OPEN_RSP;
-
- _net_dbus_pending_call_unref();
+ event_data->Event = NET_EVENT_OPEN_RSP;
} else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
g_strcmp0(profile_name, svc_name2) == 0) {
memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
sizeof(network_request_table_s));
- event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+ event_data->Event = NET_EVENT_WIFI_WPS_RSP;
memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION], 0,
sizeof(network_request_table_s));
-
- _net_dbus_pending_call_unref();
} else if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE &&
g_strcmp0(profile_name, svc_name3) == 0) {
memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION], 0,
sizeof(network_request_table_s));
- event_data.Event = NET_EVENT_CLOSE_RSP;
-
- _net_dbus_pending_call_unref();
+ event_data->Event = NET_EVENT_CLOSE_RSP;
} else {
- __net_handle_state_ind(profile_name, NET_STATE_TYPE_FAILURE);
+ __net_handle_state_ind(network_info, profile_name, NET_STATE_TYPE_FAILURE);
__NETWORK_FUNC_EXIT__;
return;
}
- g_strlcpy(event_data.ProfileName,
+ g_strlcpy(event_data->ProfileName,
profile_name, NET_PROFILE_NAME_LEN_MAX+1);
- if (net_service_error != NET_ERR_NONE)
- event_data.Error = net_service_error;
+ if (network_info->net_service_error != NET_ERR_NONE)
+ event_data->Error = network_info->net_service_error;
else {
- event_data.Error = NET_ERR_CONNECTION_CONNECT_FAILED;
- WIFI_LOG(WIFI_ERROR, "Event error defined %d", event_data.Error);
+ event_data->Error = NET_ERR_CONNECTION_CONNECT_FAILED;
+ WIFI_LOG(WIFI_ERROR, "Event error defined %d", event_data->Error);
}
- event_data.Datalength = 0;
- event_data.Data = NULL;
+ event_data->Datalength = 0;
+ event_data->Data = NULL;
- net_service_error = NET_ERR_NONE;
+ network_info->net_service_error = NET_ERR_NONE;
- WIFI_LOG(WIFI_ERROR, "State failure %d", event_data.Error);
- _net_client_callback(&event_data);
+ WIFI_LOG(WIFI_ERROR, "State failure %d", event_data->Error);
/* Reseting the state back in case of failure state */
- service_state = NET_STATE_TYPE_IDLE;
+ network_info->service_state = NET_STATE_TYPE_IDLE;
+
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
}
-static void __net_handle_disconnect_ind(const char *profile_name)
+static void __net_handle_disconnect_ind(network_info_s *network_info,
+ const char *profile_name)
{
__NETWORK_FUNC_ENTER__;
- net_event_info_s event_data = { 0, };
+ net_event_info_s *event_data = NULL;
+ network_request_table_s *request_table = network_info->request_table;
+ const char *svc_name1 = request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName;
+ const char *svc_name2 = request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
+ const char *svc_name3 = request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
- const char *svc_name1 =
- request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName;
- const char *svc_name2 =
- request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
- const char *svc_name3 =
- request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
strstr(profile_name, svc_name2) != NULL) {
sizeof(network_request_table_s));
/** Send Open Resp */
- event_data.Error = NET_ERR_OPERATION_ABORTED;
- event_data.Event = NET_EVENT_OPEN_RSP;
- g_strlcpy(event_data.ProfileName, profile_name, NET_PROFILE_NAME_LEN_MAX+1);
+ event_data->Error = NET_ERR_OPERATION_ABORTED;
+ event_data->Event = NET_EVENT_OPEN_RSP;
+ g_strlcpy(event_data->ProfileName, profile_name, NET_PROFILE_NAME_LEN_MAX+1);
WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_OPEN_RSP");
- _net_dbus_pending_call_unref();
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
- _net_client_callback(&event_data);
- goto out;
+ g_free(event_data);
+ __NETWORK_FUNC_EXIT__;
+ return;
}
if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
sizeof(network_request_table_s));
/** Send WPS Resp */
- event_data.Error = NET_ERR_OPERATION_ABORTED;
- event_data.Event = NET_EVENT_WIFI_WPS_RSP;
- g_strlcpy(event_data.ProfileName, profile_name, NET_PROFILE_NAME_LEN_MAX+1);
+ event_data->Error = NET_ERR_OPERATION_ABORTED;
+ event_data->Event = NET_EVENT_WIFI_WPS_RSP;
+ g_strlcpy(event_data->ProfileName, profile_name, NET_PROFILE_NAME_LEN_MAX+1);
WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_WIFI_WPS_RSP");
- _net_dbus_pending_call_unref();
- _net_client_callback(&event_data);
- goto out;
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+
+ g_free(event_data);
+ __NETWORK_FUNC_EXIT__;
+ return;
}
if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE &&
sizeof(network_request_table_s));
/** Send Close Resp */
- event_data.Error = NET_ERR_NONE;
- event_data.Event = NET_EVENT_CLOSE_RSP;
- g_strlcpy(event_data.ProfileName, profile_name, NET_PROFILE_NAME_LEN_MAX+1);
+ event_data->Error = NET_ERR_NONE;
+ event_data->Event = NET_EVENT_CLOSE_RSP;
+ g_strlcpy(event_data->ProfileName, profile_name, NET_PROFILE_NAME_LEN_MAX+1);
WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_CLOSE_RSP");
- _net_dbus_pending_call_unref();
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
- _net_client_callback(&event_data);
- goto out;
+ g_free(event_data);
+ __NETWORK_FUNC_EXIT__;
+ return;
}
/** Send Close Ind */
- event_data.Error = NET_ERR_NONE;
- event_data.Event = NET_EVENT_CLOSE_IND;
- g_strlcpy(event_data.ProfileName, profile_name, NET_PROFILE_NAME_LEN_MAX+1);
+ event_data->Error = NET_ERR_NONE;
+ event_data->Event = NET_EVENT_CLOSE_IND;
+ g_strlcpy(event_data->ProfileName, profile_name, NET_PROFILE_NAME_LEN_MAX+1);
WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_CLOSE_IND");
- _net_client_callback(&event_data);
- net_forget_ap_finshed(NET_ERR_NONE);
-out:
- __NETWORK_FUNC_EXIT__;
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+
+ g_free(event_data);
+
+ net_forget_ap_finished(network_info, NET_ERR_NONE);
}
-static int __net_handle_service_state_changed(const gchar *sig_path,
- const char *key, const char *state)
+static int __net_handle_service_state_changed(network_info_s *network_info,
+ const gchar *sig_path, const char *key, const char *state)
{
net_err_e Error = NET_ERR_NONE;
net_state_type_e old_state, new_state;
-
- net_event_info_s event_data = { 0, };
+ net_event_info_s *event_data = NULL;
+ network_request_table_s *request_table = network_info->request_table;
if (sig_path == NULL)
return Error;
WIFI_LOG(WIFI_INFO, "profile name: %s", sig_path);
- if (NetworkInfo.wifi_state == WIFI_OFF) {
+ if (_net_check_service_mac_addr(network_info, sig_path) == FALSE)
+ return Error;
+
+ if (network_info->wifi_state == WIFI_OFF) {
WIFI_LOG(WIFI_INFO, "Wi-Fi is off");
return Error;
}
- old_state = service_state;
+ old_state = network_info->service_state;
new_state = string2state(state);
WIFI_LOG(WIFI_INFO, "old state [%s], new state [%s]",
_convert_net_state_to_string(old_state), _convert_net_state_to_string(new_state));
if (old_state == new_state)
return Error;
- service_state = new_state;
+ network_info->service_state = new_state;
switch (new_state) {
case NET_STATE_TYPE_IDLE:
- if (NetworkInfo.wifi_state == WIFI_CONNECTED)
- NetworkInfo.wifi_state = WIFI_ON;
+ if (network_info->wifi_state == WIFI_CONNECTED)
+ network_info->wifi_state = WIFI_ON;
if (old_state == NET_STATE_TYPE_DISCONNECT) {
break;
} else if (old_state != NET_STATE_TYPE_FAILURE) {
- __net_handle_disconnect_ind(sig_path);
+ __net_handle_disconnect_ind(network_info, sig_path);
break;
}
case NET_STATE_TYPE_ASSOCIATION:
case NET_STATE_TYPE_CONFIGURATION:
- __net_handle_state_ind(sig_path, new_state);
+ __net_handle_state_ind(network_info, sig_path, new_state);
break;
case NET_STATE_TYPE_READY:
case NET_STATE_TYPE_ONLINE:
{
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL)
+ break;
+
if (old_state != NET_STATE_TYPE_READY &&
old_state != NET_STATE_TYPE_ONLINE) {
- const char *svc_name1 =
- request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
+ const char *svc_name1 = request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
strstr(sig_path, svc_name1) != NULL) {
memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
sizeof(network_request_table_s));
- event_data.Event = NET_EVENT_OPEN_RSP;
+ event_data->Event = NET_EVENT_OPEN_RSP;
WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_OPEN_RSP");
-
- _net_dbus_pending_call_unref();
} else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE) {
const char *svc_name2 =
request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
sizeof(network_request_table_s));
- event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+ event_data->Event = NET_EVENT_WIFI_WPS_RSP;
WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_WIFI_WPS_RSP");
-
- _net_dbus_pending_call_unref();
} else {
- event_data.Event = NET_EVENT_OPEN_IND;
+ event_data->Event = NET_EVENT_OPEN_IND;
WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_OPEN_IND");
}
net_profile_info_s prof_info;
- if ((Error = net_get_profile_info(sig_path, &prof_info)) != NET_ERR_NONE) {
+ if ((Error = net_get_profile_info(network_info, sig_path, &prof_info)) != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "net_get_profile_info() failed [%s]",
_net_print_error(Error));
- event_data.Datalength = 0;
- event_data.Data = NULL;
+ event_data->Datalength = 0;
+ event_data->Data = NULL;
} else {
- event_data.Datalength = sizeof(net_profile_info_s);
- event_data.Data = &prof_info;
+ event_data->Datalength = sizeof(net_profile_info_s);
+ event_data->Data = &prof_info;
}
- event_data.Error = Error;
- g_strlcpy(event_data.ProfileName, sig_path, NET_PROFILE_NAME_LEN_MAX+1);
+ event_data->Error = Error;
+ g_strlcpy(event_data->ProfileName, sig_path, NET_PROFILE_NAME_LEN_MAX+1);
- _net_client_callback(&event_data);
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
}
+ g_free(event_data);
break;
}
case NET_STATE_TYPE_DISCONNECT:
{
- __net_handle_disconnect_ind(sig_path);
+ __net_handle_disconnect_ind(network_info, sig_path);
break;
}
case NET_STATE_TYPE_FAILURE:
- __net_handle_failure_ind(sig_path);
+ __net_handle_failure_ind(network_info, sig_path);
break;
default:
return Error;
}
-static int __net_handle_service_set_error(const char *key, const char *error)
+static int __net_handle_service_set_error(network_info_s *network_info,
+ const char *key, const char *error)
{
if (error == NULL || *error == '\0')
return NET_ERR_NONE;
WIFI_LOG(WIFI_ERROR, "[%s] %s", key, error);
- net_service_error = string2error(error);
+ network_info->net_service_error = string2error(error);
return NET_ERR_NONE;
}
-static int __net_handle_scan_changed(GVariant *param)
+static int __net_handle_scan_changed(network_info_s *network_info, GVariant *param)
{
__NETWORK_FUNC_ENTER__;
- const char *key = NULL;
- gboolean value = false;
GVariant *var;
- net_event_info_s event_data = { 0, };
+ gboolean value = false;
+ net_event_info_s *event_data = NULL;
+ char *interface_name = NULL;
+
+ g_variant_get(param, "(sv)", &interface_name, &var);
+
+ if (g_strcmp0(interface_name, network_info->interface_name) != 0) {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+ }
- g_variant_get(param, "(sv)", &key, &var);
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_OUT_OF_MEMORY;
+ }
- if (g_strcmp0(key, "scan_started") == 0)
- value = true;
- else if (g_strcmp0(key, "scan_done") == 0)
- value = false;
+ value = g_variant_get_boolean(var);
- WIFI_LOG(WIFI_INFO, "Key:[%s] value:[%d]", key, value);
+ WIFI_LOG(WIFI_INFO, "%s [%d]", interface_name, value);
- event_data.Event = NET_EVENT_WIFI_SCAN_CHANGED;
- event_data.Error = NET_ERR_NONE;
- event_data.Datalength = sizeof(gboolean);
- event_data.Data = &value;
+ event_data->Event = NET_EVENT_WIFI_SCAN_CHANGED;
+ event_data->Error = NET_ERR_NONE;
+ event_data->Datalength = sizeof(gboolean);
+ event_data->Data = &value;
- _net_client_callback(&event_data);
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
- g_free((gchar *)key);
- if (NULL != var)
- g_variant_unref(var);
+ g_free(event_data);
+
+ g_variant_unref(var);
WIFI_LOG(WIFI_INFO, "Exit Function");
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-static int __net_handle_scan_done(GVariant *param)
+static int __net_handle_scan_done(network_info_s *network_info, GVariant *param)
{
- net_event_info_s event_data = { 0, };
-
- const char *key = NULL;
GVariant *value;
+ net_event_info_s *event_data = NULL;
int last_scan_type = -1;
+ char *interface_name = NULL;
- WIFI_LOG(WIFI_INFO, "param type: %s", g_variant_get_type_string(param));
+ g_variant_get(param, "(sv)", &interface_name, &value);
- if (g_variant_is_of_type(param, ((const GVariantType *)"(sv)"))) {
- g_variant_get(param, "(sv)", &key, &value);
- WIFI_LOG(WIFI_INFO, "key: %s", key);
- if (g_strcmp0(key, "Scantype") == 0) {
- if (g_variant_is_of_type(value, G_VARIANT_TYPE_INT32)) {
- last_scan_type = g_variant_get_int32(value);
- WIFI_LOG(WIFI_INFO, "last scan type: %d (0:full,1:specific,2:multi)", last_scan_type);
- }
- }
+ if (g_strcmp0(interface_name, network_info->interface_name) != 0)
+ return NET_ERR_NONE;
- g_free((gchar *)key);
- if (NULL != value)
- g_variant_unref(value);
- }
+ last_scan_type = g_variant_get_int32(value);
+ WIFI_LOG(WIFI_INFO, "%s last scan type: %d (0:full,1:specific,2:multi)",
+ interface_name, last_scan_type);
+
+ g_variant_unref(value);
/* Check if any scan request is pending, if scan request is pending then
* do not send scan-done signal to application and invoke pending scan request. */
- WIFI_LOG(WIFI_INFO, "scan_pending: %d", scan_pending);
- if (scan_pending == TRUE) {
+ WIFI_LOG(WIFI_INFO, "scan_pending: %d", network_info->scan_pending);
+ if (network_info->scan_pending == TRUE) {
net_err_e Error = NET_ERR_NONE;
- scan_pending = FALSE;
+ network_info->scan_pending = FALSE;
int current_scan_type = -1;
- if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE)
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE)
current_scan_type = NETWORK_SCAN_TYPE_FULL_CHANNEL;
- else if (request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN].flag == TRUE)
+ else if (network_info->request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN].flag == TRUE)
current_scan_type = NETWORK_SCAN_TYPE_BSSID_SCAN;
- else if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE)
+ else if (network_info->request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE)
current_scan_type = NETWORK_SCAN_TYPE_SPECIFIC_SCAN;
- else if (request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].flag == TRUE)
+ else if (network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].flag == TRUE)
current_scan_type = NETWORK_SCAN_TYPE_MULTI_SCAN;
WIFI_LOG(WIFI_INFO, "Request scan type: %d (0:full,1:specific,2:multi)", current_scan_type);
goto out;
} else if (current_scan_type == NETWORK_SCAN_TYPE_FULL_CHANNEL) {
- Error = _net_dbus_scan_request();
+ Error = _net_dbus_scan_request(network_info);
return Error;
} else if (current_scan_type == NETWORK_SCAN_TYPE_BSSID_SCAN &&
last_scan_type != NETWORK_SCAN_TYPE_FULL_CHANNEL) {
- Error = _net_dbus_scan_request();
+ Error = _net_dbus_scan_request(network_info);
return Error;
} else if (current_scan_type == NETWORK_SCAN_TYPE_SPECIFIC_SCAN) {
- Error = _net_dbus_specific_scan_request(request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].ssid);
+ Error = _net_dbus_specific_scan_request(network_info,
+ network_info->request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].ssid);
return Error;
} else if (current_scan_type == NETWORK_SCAN_TYPE_MULTI_SCAN) {
- GSList *list = request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_list;
+ GSList *list = network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_list;
- Error = _net_dbus_multi_scan_request(list);
+ Error = _net_dbus_multi_scan_request(network_info, list);
return Error;
}
}
out:
- if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
- memset(&request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN],
- 0, sizeof(network_request_table_s));
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL)
+ return NET_ERR_OUT_OF_MEMORY;
- _net_dbus_pending_call_unref();
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN]),
+ 0, sizeof(network_request_table_s));
WIFI_LOG(WIFI_INFO, "Specific scan completed");
- event_data.Event = NET_EVENT_WIFI_SPECIFIC_SCAN_IND;
+ event_data->Event = NET_EVENT_WIFI_SPECIFIC_SCAN_IND;
- } else if (request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].flag == TRUE) {
+ } else if (network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].flag == TRUE) {
WIFI_LOG(WIFI_INFO, "Multi scan completed");
- g_slist_free_full(request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_list, g_free);
+ g_slist_free_full(network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_list, g_free);
- memset(&request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN], 0,
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN]), 0,
sizeof(network_request_table_s));
- _net_dbus_pending_call_unref();
- event_data.Event = NET_EVENT_WIFI_MULTI_SCAN_IND;
+ event_data->Event = NET_EVENT_WIFI_MULTI_SCAN_IND;
- } else if (request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN].flag == TRUE) {
-
- _net_dbus_pending_call_unref();
+ } else if (network_info->request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN].flag == TRUE) {
WIFI_LOG(WIFI_INFO, "BSSID Scan Completed");
- __net_dbus_get_bssid_list();
+ __net_dbus_get_bssid_list(network_info);
+ g_free(event_data);
return NET_ERR_NONE;
- } else if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
- memset(&request_table[NETWORK_REQUEST_TYPE_SCAN], 0,
+ } else if (network_info->request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_SCAN]), 0,
sizeof(network_request_table_s));
- event_data.Event = NET_EVENT_WIFI_SCAN_RSP;
-
- _net_dbus_pending_call_unref();
+ event_data->Event = NET_EVENT_WIFI_SCAN_RSP;
} else {
- event_data.Event = NET_EVENT_WIFI_SCAN_IND;
+ event_data->Event = NET_EVENT_WIFI_SCAN_IND;
}
- event_data.Error = NET_ERR_NONE;
- event_data.Datalength = 0;
- event_data.Data = NULL;
+ event_data->Error = NET_ERR_NONE;
+ event_data->Datalength = 0;
+ event_data->Data = NULL;
- _net_client_callback(&event_data);
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+
+ g_free(event_data);
return NET_ERR_NONE;
}
const char *key = NULL;
const char *value = NULL;
GVariant *var;
+ network_info_s *network_info = (network_info_s *)user_data;
if (g_strcmp0(sig, SIGNAL_PROPERTY_CHANGED) == 0) {
g_variant_get(param, "(sv)", &key, &var);
if (g_strcmp0(key, "State") == 0) {
g_variant_get(var, "s", &value);
- __net_handle_service_state_changed(path, key, value);
+ __net_handle_service_state_changed(network_info, path, key, value);
} else if (g_strcmp0(key, "Error") == 0) {
g_variant_get(var, "s", &value);
- __net_handle_service_set_error(key, value);
+ __net_handle_service_set_error(network_info, key, value);
}
}
__NETWORK_FUNC_EXIT__;
}
-static int __net_handle_wifi_tdls_discover_event(GVariant *param)
+static int __net_handle_wifi_tdls_discover_event(network_info_s *network_info,
+ GVariant *param)
{
__NETWORK_FUNC_ENTER__;
const char *key = NULL;
const gchar *sig_value = NULL;
net_tdls_discover_s discover_info = { 0, "" };
+ net_event_info_s *event_data = NULL;
+ char *interface_name = NULL;
+ g_variant_get(param, "(sa{sv})", &interface_name, &iter);
- g_variant_get(param, "(a{sv})", &iter);
+ if (g_strcmp0(interface_name, network_info->interface_name) != 0) {
+ __NETWORK_FUNC_EXIT__
+ return NET_ERR_NONE;
+ }
while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
if (g_strcmp0(key, "peermac") == 0) {
if (discover_info.type == 0
|| NULL != strstr("00:00:00:00:00:00", discover_info.mac_add)) {
WIFI_LOG(WIFI_INFO, "Clear the Discovery Flag");
- if (request_table[NETWORK_REQUEST_TYPE_TDLS_DISCOVERY].flag == TRUE) {
- memset(&request_table[NETWORK_REQUEST_TYPE_TDLS_DISCOVERY], 0,
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_TDLS_DISCOVERY].flag == TRUE) {
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_TDLS_DISCOVERY]), 0,
sizeof(network_request_table_s));
}
}
- net_event_info_s event_data;
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_OUT_OF_MEMORY;
+ }
- memset(&event_data, 0, sizeof(event_data));
- event_data.Error = NET_ERR_NONE;
- event_data.Event = NET_EVENT_WIFI_TDLS_DISCOVERED_IND;
+ event_data->Error = NET_ERR_NONE;
+ event_data->Event = NET_EVENT_WIFI_TDLS_DISCOVERED_IND;
- event_data.Data = &discover_info;
+ event_data->Data = &discover_info;
- if (event_data.Data)
- event_data.Datalength = sizeof(net_tdls_discover_s);
+ if (event_data->Data)
+ event_data->Datalength = sizeof(net_tdls_discover_s);
else
- event_data.Datalength = 0;
+ event_data->Datalength = 0;
WIFI_LOG(WIFI_ERROR, "Sending NET_EVENT_TDLS_DISCOVER_IND, Discover Type [%d]", discover_info.type);
- _net_client_callback(&event_data);
-
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-static int __net_handle_wifi_tdls_connected_event(GVariant *param)
+static int __net_handle_wifi_tdls_connected_event(network_info_s *network_info,
+ GVariant *param)
{
__NETWORK_FUNC_ENTER__;
GVariant *value = NULL;
const char *key = NULL;
const gchar *sig_value = NULL;
+ net_event_info_s *event_data = NULL;
+ char *interface_name = NULL;
- g_variant_get(param, "(a{sv})", &iter);
+ g_variant_get(param, "(sa{sv})", &interface_name, &iter);
+
+ if (g_strcmp0(interface_name, network_info->interface_name) != 0) {
+ __NETWORK_FUNC_EXIT__
+ return NET_ERR_NONE;
+ }
while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
if (g_strcmp0(key, "peermac") == 0) {
}
g_variant_iter_free(iter);
- net_event_info_s event_data;
- memset(&event_data, 0, sizeof(event_data));
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_OUT_OF_MEMORY;
+ }
- event_data.Error = NET_ERR_NONE;
- event_data.Event = NET_EVENT_WIFI_TDLS_CONNECTED_IND;
- event_data.Data = g_strdup(sig_value);
+ event_data->Error = NET_ERR_NONE;
+ event_data->Event = NET_EVENT_WIFI_TDLS_CONNECTED_IND;
+ event_data->Data = g_strdup(sig_value);
- if (event_data.Data)
- event_data.Datalength = strlen(event_data.Data);
+ if (event_data->Data)
+ event_data->Datalength = strlen(event_data->Data);
else
- event_data.Datalength = 0;
+ event_data->Datalength = 0;
WIFI_LOG(WIFI_ERROR, "Sending NET_EVENT_TDLS_CONNECTED_IND");
- _net_client_callback(&event_data);
- g_free(event_data.Data);
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+
+ g_free(event_data->Data);
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-static int __net_handle_wifi_tdls_disconnected_event(GVariant *param)
+static int __net_handle_wifi_tdls_disconnected_event(network_info_s *network_info,
+ GVariant *param)
{
__NETWORK_FUNC_ENTER__;
GVariant *value = NULL;
const char *key = NULL;
const gchar *sig_value = NULL;
+ net_event_info_s *event_data = NULL;
+ char *interface_name = NULL;
- g_variant_get(param, "(a{sv})", &iter);
+ g_variant_get(param, "(a{sv})", &interface_name, &iter);
+
+ if (g_strcmp0(interface_name, network_info->interface_name) != 0) {
+ __NETWORK_FUNC_EXIT__
+ return NET_ERR_NONE;
+ }
while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
if (g_strcmp0(key, "peermac") == 0) {
}
g_variant_iter_free(iter);
- net_event_info_s event_data;
- memset(&event_data, 0, sizeof(event_data));
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_OUT_OF_MEMORY;
+ }
- event_data.Error = NET_ERR_NONE;
- event_data.Event = NET_EVENT_WIFI_TDLS_DISCONNECTED_IND;
- event_data.Data = g_strdup(sig_value);
+ event_data->Error = NET_ERR_NONE;
+ event_data->Event = NET_EVENT_WIFI_TDLS_DISCONNECTED_IND;
+ event_data->Data = g_strdup(sig_value);
- if (event_data.Data)
- event_data.Datalength = strlen(event_data.Data);
+ if (event_data->Data)
+ event_data->Datalength = strlen(event_data->Data);
else
- event_data.Datalength = 0;
+ event_data->Datalength = 0;
WIFI_LOG(WIFI_ERROR, "Sending NET_EVENT_TDLS_DISCONNECTED_IND");
- _net_client_callback(&event_data);
- g_free(event_data.Data);
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+
+ g_free(event_data->Data);
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-static int __net_handle_wifi_connect_fail_event(GVariant *param)
+static int __net_handle_wifi_connect_fail_event(network_info_s *network_info,
+ GVariant *param)
{
__NETWORK_FUNC_ENTER__;
- net_event_info_s event_data = { 0, };
+ net_event_info_s *event_data = NULL;
+ char *interface_name = NULL;
network_request_table_s *open_info =
- &request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION];
+ &(network_info->request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION]);
network_request_table_s *wps_info =
- &request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS];
+ &(network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS]);
+
+ g_variant_get(param, "(s)", &interface_name);
+ if (g_strcmp0(interface_name, network_info->interface_name) != 0) {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+ }
+
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_OUT_OF_MEMORY;
+ }
- event_data.Datalength = 0;
- event_data.Data = NULL;
+ event_data->Datalength = 0;
+ event_data->Data = NULL;
WIFI_LOG(WIFI_ERROR, "Failed to connect WiFi");
if (open_info->flag == TRUE) {
memset(open_info, 0, sizeof(network_request_table_s));
- event_data.Error = NET_ERR_INVALID_OPERATION;
- event_data.Event = NET_EVENT_OPEN_RSP;
+ event_data->Error = NET_ERR_INVALID_OPERATION;
+ event_data->Event = NET_EVENT_OPEN_RSP;
WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_OPEN_RSP");
} else if (wps_info->flag == TRUE) {
memset(wps_info, 0, sizeof(network_request_table_s));
- event_data.Error = NET_ERR_INVALID_OPERATION;
- event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+ event_data->Error = NET_ERR_INVALID_OPERATION;
+ event_data->Event = NET_EVENT_WIFI_WPS_RSP;
WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_WIFI_WPS_RSP");
} else {
WIFI_LOG(WIFI_WARN, "WiFi Connection flag not set");
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
- _net_client_callback(&event_data);
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+
+ g_free(event_data);
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-static int __net_handle_wifi_wps_fail_event_rsp(GVariant *param)
+static int __net_handle_wifi_wps_fail_event_rsp(network_info_s *network_info,
+ GVariant *param)
{
GVariantIter *iter = NULL;
GVariant *value = NULL;
const char *key = NULL;
gint32 config_error = 0;
gint32 error_indication = 0;
+ net_event_info_s *event_data = NULL;
+ char *interface_name = NULL;
- g_variant_get(param, "(a{sv})", &iter);
+ g_variant_get(param, "(a{sv})", &interface_name, &iter);
+
+ if (g_strcmp0(interface_name, network_info->interface_name) != 0) {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+ }
while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
if (g_strcmp0(key, "config_error") == 0) {
}
g_variant_iter_free(iter);
- net_event_info_s event_data;
- memset(&event_data, 0, sizeof(event_data));
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_OUT_OF_MEMORY;
+ }
- if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag ==
- TRUE)
- memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+ if (network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE)
+ memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS]), 0,
sizeof(network_request_table_s));
- event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+ event_data->Event = NET_EVENT_WIFI_WPS_RSP;
if (config_error == NET_WPS_CFG_MSG_TIMEOUT &&
error_indication == NET_WPS_EI_NO_ERROR)
- event_data.Error = NET_ERR_CONNECTION_WPS_TIMEOUT;
+ event_data->Error = NET_ERR_CONNECTION_WPS_TIMEOUT;
else if (config_error == NET_WPS_CFG_NO_ERROR &&
error_indication == NET_WPS_EI_OPERATION_FAILED)
- event_data.Error = NET_ERR_CONNECTION_CONNECT_FAILED;
+ event_data->Error = NET_ERR_CONNECTION_CONNECT_FAILED;
else if (config_error == NET_WPS_CFG_MULTIPLE_PBC_DETECTED &&
error_indication == NET_WPS_EI_NO_ERROR)
- event_data.Error = NET_ERR_CONNECTION_WPS_OVERLAP;
+ event_data->Error = NET_ERR_CONNECTION_WPS_OVERLAP;
else if (config_error == NET_WPS_CFG_NO_ERROR &&
error_indication == NET_WPS_EI_SECURITY_WEP_PROHIBITED)
- event_data.Error = NET_ERR_CONNECTION_WPS_WEP_PROHIBITED;
+ event_data->Error = NET_ERR_CONNECTION_WPS_WEP_PROHIBITED;
- event_data.Datalength = 0;
- event_data.Data = NULL;
+ event_data->Datalength = 0;
+ event_data->Data = NULL;
- _net_client_callback(&event_data);
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+ g_free(event_data);
return NET_ERR_NONE;
}
-static int __net_handle_ip_conflict_rsp(GVariant *param)
+static int __net_handle_ip_conflict_rsp(network_info_s *network_info,
+ GVariant *param)
{
GVariantIter *iter = NULL;
GVariant *value = NULL;
net_ip_conflict_info_s conflict_info;
conflict_info.state = NULL;
conflict_info.mac = NULL;
- net_event_info_s event_data;
- memset(&event_data, 0, sizeof(event_data));
+ net_event_info_s *event_data = NULL;
+ char *interface_name = NULL;
- g_variant_get(param, "(a{sv})", &iter);
+ g_variant_get(param, "(sa{sv})", &interface_name, &iter);
+
+ if (g_strcmp0(interface_name, network_info->interface_name) != 0)
+ return NET_ERR_NONE;
while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
if (g_strcmp0(key, "state") == 0) {
}
g_variant_iter_free(iter);
-
WIFI_LOG(WIFI_INFO,
"Received the signal: %s",
NETCONFIG_SIGNAL_IP_CONFLICT_EVENT);
- event_data.Error = NET_ERR_NONE;
- event_data.Event = NET_EVENT_WIFI_IP_CONFLICT_IND;
- event_data.Datalength = sizeof(net_ip_conflict_info_s);
- event_data.Data = &conflict_info;
- _net_client_callback(&event_data);
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL)
+ return NET_ERR_OUT_OF_MEMORY;
+
+ event_data->Error = NET_ERR_NONE;
+ event_data->Event = NET_EVENT_WIFI_IP_CONFLICT_IND;
+ event_data->Datalength = sizeof(net_ip_conflict_info_s);
+ event_data->Data = &conflict_info;
+
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+
+ g_free(event_data);
+ return NET_ERR_NONE;
+}
+
+static int __net_handle_rssi_changed(network_info_s *network_info,
+ GVariant *param)
+{
+ net_rssi_info_s rssi_info = { 0, };
+ net_event_info_s *event_data = NULL;
+ char *interface_name = NULL;
+
+ g_variant_get(param, "(si)", &interface_name, &(rssi_info.rssi_level));
+
+ if (g_strcmp0(interface_name, network_info->interface_name) != 0)
+ return NET_ERR_NONE;
+
+ g_strlcpy(rssi_info.ifname, interface_name, strlen(interface_name) + 1);
+
+ WIFI_LOG(WIFI_INFO, "Rssi changed [%s:%d]",
+ rssi_info.ifname, rssi_info.rssi_level);
+
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL)
+ return NET_ERR_OUT_OF_MEMORY;
+
+ event_data->Error = NET_ERR_NONE;
+ event_data->Event = NET_EVENT_WIFI_RSSI_CHANGED;
+ event_data->Datalength = sizeof(net_rssi_info_s);
+ event_data->Data = &rssi_info;
+
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+
+ g_free(event_data);
+ return NET_ERR_NONE;
+}
+
+static int __net_handle_rssi_level_changed(network_info_s *network_info,
+ GVariant *param)
+{
+ GVariantIter *iter = NULL;
+ GVariant *value = NULL;
+ const char *key = NULL;
+ const gchar *ifname = NULL;
+ net_rssi_info_s rssi_info = {0,};
+ net_event_info_s *event_data = NULL;
+
+ g_variant_get(param, "(a{sv})", &iter);
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ if (g_strcmp0(key, "ifname") == 0) {
+ ifname = g_variant_get_string(value, NULL);
+ if (ifname && strlen(ifname) > 0)
+ g_strlcpy(rssi_info.ifname, ifname, strlen(ifname) + 1);
+ } else if (g_strcmp0(key, "rssi_level") == 0) {
+ rssi_info.rssi_level = g_variant_get_uint32(value);
+ }
+ }
+ g_variant_iter_free(iter);
+
+ WIFI_LOG(WIFI_INFO, "Rssi level changed [%s:%d]",
+ rssi_info.ifname, rssi_info.rssi_level);
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL)
+ return NET_ERR_OUT_OF_MEMORY;
+
+ event_data->Error = NET_ERR_NONE;
+ event_data->Event = NET_EVENT_WIFI_RSSI_LEVEL_CHANGED;
+ event_data->Datalength = sizeof(net_rssi_info_s);
+ event_data->Data = &rssi_info;
+
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+
+ g_free(event_data);
return NET_ERR_NONE;
}
-static int __net_handle_dpp_uri_generated(GVariant *param)
+static int __net_handle_module_state_changed(network_info_s *network_info,
+ GVariant *param)
+{
+ GVariantIter *iter = NULL;
+ GVariant *value = NULL;
+ const char *key = NULL;
+ const gchar *ifname = NULL;
+ net_module_info_s module_info = {0,};
+ net_event_info_s *event_data = NULL;
+
+ g_variant_get(param, "(a{sv})", &iter);
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ if (g_strcmp0(key, "ifname") == 0) {
+ ifname = g_variant_get_string(value, NULL);
+ if (ifname && strlen(ifname) > 0)
+ g_strlcpy(module_info.ifname, ifname, strlen(ifname) + 1);
+ } else if (g_strcmp0(key, "status_uevent") == 0) {
+ module_info.status_uevent = g_variant_get_uint32(value);
+ }
+ }
+ g_variant_iter_free(iter);
+
+ WIFI_LOG(WIFI_INFO, "Module state changed [%s:%d]",
+ module_info.ifname, module_info.status_uevent);
+
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL)
+ return NET_ERR_OUT_OF_MEMORY;
+
+ event_data->Error = NET_ERR_NONE;
+ event_data->Event = NET_EVENT_WIFI_MODULE_STATE_CHANGED;
+ event_data->Datalength = sizeof(net_module_info_s);
+ event_data->Data = &module_info;
+
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+
+ g_free(event_data);
+ return NET_ERR_NONE;
+}
+
+static int __net_handle_dpp_uri_generated(network_info_s *network_info,
+ GVariant *param)
{
GVariantIter *iter = NULL;
GVariant *value = NULL;
gchar *key = NULL;
const gchar *uri_str = NULL;
net_dpp_event_info_s dpp_event_info = {0,};
- net_event_info_s event_data;
- memset(&event_data, 0, sizeof(event_data));
+ net_event_info_s *event_data = NULL;
g_variant_get(param, "(a{sv})", &iter);
"Received the signal: %s",
NETCONFIG_SIGNAL_DPP_URI_GENERATED);
- event_data.Error = NET_ERR_NONE;
- event_data.Event = NET_EVENT_WIFI_DPP_URI_GENERATED;
- event_data.Datalength = sizeof(net_dpp_event_info_s);
- event_data.Data = &dpp_event_info;
- _net_client_callback(&event_data);
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL)
+ return NET_ERR_OUT_OF_MEMORY;
+
+ event_data->Error = NET_ERR_NONE;
+ event_data->Event = NET_EVENT_WIFI_DPP_URI_GENERATED;
+ event_data->Datalength = sizeof(net_dpp_event_info_s);
+ event_data->Data = &dpp_event_info;
+
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+ g_free(event_data);
return NET_ERR_NONE;
}
-static int __net_handle_dpp_bootstrapped(GVariant *param)
+static int __net_handle_dpp_bootstrapped(network_info_s *network_info,
+ GVariant *param)
{
GVariantIter *iter = NULL;
GVariant *value = NULL;
gchar *key = NULL;
net_dpp_event_info_s dpp_event_info;
dpp_event_info.peer_id = 0;
- net_event_info_s event_data;
- memset(&event_data, 0, sizeof(event_data));
+ net_event_info_s *event_data = NULL;
g_variant_get(param, "(a{sv})", &iter);
"Received the signal: %s",
NETCONFIG_SIGNAL_DPP_BOOTSTRAPPED);
- event_data.Error = NET_ERR_NONE;
- event_data.Event = NET_EVENT_WIFI_DPP_BOOTSTRAPPED;
- event_data.Datalength = sizeof(net_dpp_event_info_s);
- event_data.Data = &dpp_event_info;
- _net_client_callback(&event_data);
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL)
+ return NET_ERR_OUT_OF_MEMORY;
+ event_data->Error = NET_ERR_NONE;
+ event_data->Event = NET_EVENT_WIFI_DPP_BOOTSTRAPPED;
+ event_data->Datalength = sizeof(net_dpp_event_info_s);
+ event_data->Data = &dpp_event_info;
+
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+
+ g_free(event_data);
return NET_ERR_NONE;
}
-static int __net_handle_dpp_awaiting(GVariant *param)
+static int __net_handle_dpp_awaiting(network_info_s *network_info,
+ GVariant *param)
{
GVariantIter *iter = NULL;
GVariant *value = NULL;
gchar *key = NULL;
net_dpp_event_info_s dpp_event_info;
dpp_event_info.own_id = 0;
- net_event_info_s event_data;
- memset(&event_data, 0, sizeof(event_data));
+ net_event_info_s *event_data = NULL;
g_variant_get(param, "(a{sv})", &iter);
"Received the signal: %s",
NETCONFIG_SIGNAL_DPP_AWAITING);
- event_data.Error = NET_ERR_NONE;
- event_data.Event = NET_EVENT_WIFI_DPP_AWAITING;
- event_data.Datalength = sizeof(net_dpp_event_info_s);
- event_data.Data = &dpp_event_info;
- _net_client_callback(&event_data);
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL)
+ return NET_ERR_OUT_OF_MEMORY;
+
+ event_data->Error = NET_ERR_NONE;
+ event_data->Event = NET_EVENT_WIFI_DPP_AWAITING;
+ event_data->Datalength = sizeof(net_dpp_event_info_s);
+ event_data->Data = &dpp_event_info;
+
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+ g_free(event_data);
return NET_ERR_NONE;
}
-static int __net_handle_dpp_events(GVariant *param, net_event_e event)
+static int __net_handle_dpp_events(network_info_s *network_info,
+ GVariant *param, net_event_e event)
{
GVariantIter *iter = NULL;
GVariant *value = NULL;
gchar *key = NULL;
net_dpp_event_info_s dpp_event_info;
dpp_event_info.peer_id = 0;
- net_event_info_s event_data;
- memset(&event_data, 0, sizeof(event_data));
+ net_event_info_s *event_data = NULL;
g_variant_get(param, "(a{sv})", &iter);
}
g_variant_iter_free(iter);
- event_data.Error = NET_ERR_NONE;
- event_data.Event = event;
- event_data.Datalength = sizeof(net_dpp_event_info_s);
- event_data.Data = &dpp_event_info;
- _net_client_callback(&event_data);
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL)
+ return NET_ERR_OUT_OF_MEMORY;
+ event_data->Error = NET_ERR_NONE;
+ event_data->Event = event;
+ event_data->Datalength = sizeof(net_dpp_event_info_s);
+ event_data->Data = &dpp_event_info;
+
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+
+ g_free(event_data);
return NET_ERR_NONE;
}
-static int __net_handle_dpp_failed(GVariant *param)
+static int __net_handle_dpp_failed(network_info_s *network_info,
+ GVariant *param)
{
- net_event_info_s event_data;
- memset(&event_data, 0, sizeof(event_data));
+ net_event_info_s *event_data = NULL;
WIFI_LOG(WIFI_INFO,
"Received the signal: %s",
NETCONFIG_SIGNAL_DPP_FAILED);
- event_data.Error = NET_ERR_NONE;
- event_data.Event = NET_EVENT_WIFI_DPP_FAILED;
- _net_client_callback(&event_data);
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_OUT_OF_MEMORY;
+ }
+
+ event_data->Error = NET_ERR_NONE;
+ event_data->Event = NET_EVENT_WIFI_DPP_FAILED;
+
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+
+ g_free(event_data);
return NET_ERR_NONE;
}
-static int __net_handle_dpp_removed(GVariant *param)
+static int __net_handle_dpp_removed(network_info_s *network_info,
+ GVariant *param)
{
GVariantIter *iter = NULL;
GVariant *value = NULL;
net_dpp_event_info_s dpp_event_info;
dpp_event_info.peer_id = 0;
dpp_event_info.own_id = 0;
- net_event_info_s event_data;
- memset(&event_data, 0, sizeof(event_data));
+ net_event_info_s *event_data = NULL;
g_variant_get(param, "(a{sv})", &iter);
"Received the signal: %s",
NETCONFIG_SIGNAL_DPP_REMOVED);
- event_data.Error = NET_ERR_NONE;
- event_data.Event = NET_EVENT_WIFI_DPP_REMOVED;
- event_data.Datalength = sizeof(net_dpp_event_info_s);
- event_data.Data = &dpp_event_info;
- _net_client_callback(&event_data);
+ event_data = g_try_malloc0(sizeof(net_event_info_s));
+ if (event_data == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_OUT_OF_MEMORY;
+ }
+ event_data->Error = NET_ERR_NONE;
+ event_data->Event = NET_EVENT_WIFI_DPP_REMOVED;
+ event_data->Datalength = sizeof(net_dpp_event_info_s);
+ event_data->Data = &dpp_event_info;
+
+ if (network_info->event_callback)
+ network_info->event_callback(event_data, network_info->user_data);
+
+ g_free(event_data);
return NET_ERR_NONE;
}
-
static void __net_connman_manager_signal_filter(GDBusConnection *conn,
const gchar *name, const gchar *path, const gchar *interface,
const gchar *sig, GVariant *param, gpointer user_data)
{
+ network_info_s *network_info = (network_info_s *)user_data;
+
if (g_strcmp0(sig, SIGNAL_SCAN_CHANGED) == 0)
- __net_handle_scan_changed(param);
+ __net_handle_scan_changed(network_info, param);
else if (g_strcmp0(sig, SIGNAL_SCAN_DONE) == 0)
- __net_handle_scan_done(param);
+ __net_handle_scan_done(network_info, param);
}
static void __net_netconfig_signal_filter(GDBusConnection *conn,
const gchar *name, const gchar *path, const gchar *interface,
const gchar *sig, GVariant *param, gpointer user_data)
{
+ network_info_s *network_info = (network_info_s *)user_data;
+
if (g_strcmp0(sig, NETCONFIG_SIGNAL_POWERON_COMPLETED) == 0)
- __net_handle_wifi_power_rsp(TRUE);
+ __net_handle_wifi_power_rsp(network_info, param, TRUE);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_POWEROFF_COMPLETED) == 0)
- __net_handle_wifi_power_rsp(FALSE);
+ __net_handle_wifi_power_rsp(network_info, param, FALSE);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_SPECIFIC_SCAN_DONE) == 0)
- __net_handle_wifi_specific_scan_rsp(param);
+ __net_handle_wifi_specific_scan_rsp(network_info, param);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_BSSID_SCAN_DONE) == 0)
- __net_handle_wifi_bssid_scan_rsp(param);
+ __net_handle_wifi_bssid_scan_rsp(network_info, param);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_NETLINK_SCAN_DONE) == 0)
- __net_handle_wifi_netlink_scan_rsp(param);
+ __net_handle_wifi_netlink_scan_rsp(network_info, param);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_TDLS_PEER_FOUND) == 0)
- __net_handle_wifi_tdls_discover_event(param);
+ __net_handle_wifi_tdls_discover_event(network_info, param);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_TDLS_CONNECTED) == 0)
- __net_handle_wifi_tdls_connected_event(param);
+ __net_handle_wifi_tdls_connected_event(network_info, param);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_TDLS_DISCONNECTED) == 0)
- __net_handle_wifi_tdls_disconnected_event(param);
+ __net_handle_wifi_tdls_disconnected_event(network_info, param);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_WIFI_CONNECT_FAIL) == 0)
- __net_handle_wifi_connect_fail_event(param);
+ __net_handle_wifi_connect_fail_event(network_info, param);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_WPS_FAIL_EVENT) == 0)
- __net_handle_wifi_wps_fail_event_rsp(param);
+ __net_handle_wifi_wps_fail_event_rsp(network_info, param);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_IP_CONFLICT_EVENT) == 0)
- __net_handle_ip_conflict_rsp(param);
+ __net_handle_ip_conflict_rsp(network_info, param);
+ else if (g_strcmp0(sig, NETCONFIG_SIGNAL_RSSI_CHANGED) == 0)
+ __net_handle_rssi_changed(network_info, param);
+ else if (g_strcmp0(sig, NETCONFIG_SIGNAL_RSSI_LEVEL_CHANGED) == 0)
+ __net_handle_rssi_level_changed(network_info, param);
+ else if (g_strcmp0(sig, NETCONFIG_SIGNAL_MODULE_STATE_CHANGED) == 0)
+ __net_handle_module_state_changed(network_info, param);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_DPP_URI_GENERATED) == 0)
- __net_handle_dpp_uri_generated(param);
+ __net_handle_dpp_uri_generated(network_info, param);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_DPP_BOOTSTRAPPED) == 0)
- __net_handle_dpp_bootstrapped(param);
+ __net_handle_dpp_bootstrapped(network_info, param);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_DPP_AWAITING) == 0)
- __net_handle_dpp_awaiting(param);
+ __net_handle_dpp_awaiting(network_info, param);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_DPP_AUTHENTICATING) == 0)
- __net_handle_dpp_events(param, NET_EVENT_WIFI_DPP_AUTHENTICATING);
+ __net_handle_dpp_events(network_info, param, NET_EVENT_WIFI_DPP_AUTHENTICATING);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_DPP_AUTH_SUCCESS) == 0)
- __net_handle_dpp_events(param, NET_EVENT_WIFI_DPP_AUTH_SUCCESS);
+ __net_handle_dpp_events(network_info, param, NET_EVENT_WIFI_DPP_AUTH_SUCCESS);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_DPP_AUTH_FAILED) == 0)
- __net_handle_dpp_events(param, NET_EVENT_WIFI_DPP_AUTH_FAILED);
+ __net_handle_dpp_events(network_info, param, NET_EVENT_WIFI_DPP_AUTH_FAILED);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_DPP_NOT_COMPATIBLE) == 0)
- __net_handle_dpp_events(param, NET_EVENT_WIFI_DPP_NOT_COMPATIBLE);
+ __net_handle_dpp_events(network_info, param, NET_EVENT_WIFI_DPP_NOT_COMPATIBLE);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_DPP_CONF_FAILED) == 0)
- __net_handle_dpp_events(param, NET_EVENT_WIFI_DPP_CONF_FAILED);
+ __net_handle_dpp_events(network_info, param, NET_EVENT_WIFI_DPP_CONF_FAILED);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_DPP_SCAN_PEER_QR) == 0)
- __net_handle_dpp_events(param, NET_EVENT_WIFI_DPP_SCAN_PEER_QR);
+ __net_handle_dpp_events(network_info, param, NET_EVENT_WIFI_DPP_SCAN_PEER_QR);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_DPP_NETWORK_ID) == 0)
- __net_handle_dpp_events(param, NET_EVENT_WIFI_DPP_NETWORK_ID);
+ __net_handle_dpp_events(network_info, param, NET_EVENT_WIFI_DPP_NETWORK_ID);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_DPP_CONF_SENT) == 0)
- __net_handle_dpp_events(param, NET_EVENT_WIFI_DPP_CONF_SENT);
+ __net_handle_dpp_events(network_info, param, NET_EVENT_WIFI_DPP_CONF_SENT);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_DPP_CONF_RECEIVED) == 0)
- __net_handle_dpp_events(param, NET_EVENT_WIFI_DPP_CONF_RECEIVED);
+ __net_handle_dpp_events(network_info, param, NET_EVENT_WIFI_DPP_CONF_RECEIVED);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_DPP_FAILED) == 0)
- __net_handle_dpp_failed(param);
+ __net_handle_dpp_failed(network_info, param);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_DPP_REMOVED) == 0)
- __net_handle_dpp_removed(param);
+ __net_handle_dpp_removed(network_info, param);
}
static void __net_netconfig_network_signal_filter(GDBusConnection *conn,
return;
}
-static int __net_get_tech_states(GVariant *message, net_state_type_e *state)
+static int __net_get_tech_states(network_info_s *network_info, GVariant *message)
{
__NETWORK_FUNC_ENTER__;
gchar *path = NULL;
gchar *key = NULL;
- if (NetworkInfo.wifi_state == WIFI_UNKNOWN)
- NetworkInfo.wifi_state = WIFI_OFF;
+ if (network_info->wifi_state == WIFI_UNKNOWN)
+ network_info->wifi_state = WIFI_OFF;
g_variant_get(message, "(a(oa{sv}))", &iter);
while (g_variant_iter_loop(iter, "(oa{sv})", &path, &next)) {
continue;
while (g_variant_iter_loop(next, "{sv}", &key, &variant)) {
- gboolean data;
-
- if (g_variant_is_of_type(variant, G_VARIANT_TYPE_BOOLEAN)) {
- data = g_variant_get_boolean(variant);
- WIFI_LOG(WIFI_INFO, "key-[%s] - %s", key, data ? "True" : "False");
-
- if (strcmp(key, "Powered") == 0) {
- if (data == FALSE)
- NetworkInfo.wifi_state = WIFI_OFF;
- else if (data == TRUE && NetworkInfo.wifi_state < WIFI_ON)
- NetworkInfo.wifi_state = WIFI_ON;
- } else if (strcmp(key, "Connected") == 0 && data) {
- *(state) = NET_STATE_TYPE_READY;
- NetworkInfo.wifi_state = WIFI_CONNECTED;
+ if (g_strcmp0(key, "Device.List") == 0) {
+ GVariantIter *list_iter = NULL;
+ gchar *dev_key = NULL;
+ GVariant *dev_var = NULL;
+ const gchar *sdata = NULL;
+ gboolean bdata = FALSE;
+ gboolean find = FALSE;
+
+ 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)) {
+ sdata = g_variant_get_string(dev_var, NULL);
+ WIFI_LOG(WIFI_INFO, "%s [%s]", dev_key, sdata);
+
+ if (g_strcmp0(dev_key, "Ifname") == 0) {
+ find = g_strcmp0(sdata, network_info->interface_name) == 0 ? TRUE : FALSE;
+ } else if (find && g_strcmp0(dev_key, "MAC.Address") == 0) {
+ g_strlcpy(network_info->mac_address, sdata, WIFI_MAC_ADDR_LEN + 1);
+ }
+ } else if (g_variant_is_of_type(dev_var, G_VARIANT_TYPE_BOOLEAN)) {
+ bdata = g_variant_get_boolean(dev_var);
+ WIFI_LOG(WIFI_INFO, "%s [%s]", dev_key, bdata ? "True" : "False");
+
+ if (find && g_strcmp0(dev_key, "Powered") == 0) {
+ if (bdata == FALSE)
+ network_info->wifi_state = WIFI_OFF;
+ else if (network_info->wifi_state < WIFI_ON)
+ network_info->wifi_state = WIFI_ON;
+ } else if (find && g_strcmp0(dev_key, "Connected") == 0) {
+ if (bdata == TRUE) {
+ network_info->service_state = NET_STATE_TYPE_READY;
+ network_info->wifi_state = WIFI_CONNECTED;
+ }
+ }
+ }
}
- /* For further use
- else if (strcmp(key, "Tethering") == 0 && data) {
- } */
+ g_variant_iter_free(list_iter);
}
}
}
return Error;
}
-static int __net_dbus_get_bssid_list()
+static int __net_dbus_get_bssid_list(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
+ GVariant *params = NULL;
GVariant *message = NULL;
- message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
- "GetBssidList", NULL, &Error);
+ params = g_variant_new("(s)", network_info->interface_name);
+
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "GetBssidList",
+ params, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to get bssid list");
goto done;
return Error;
}
-static int __net_dbus_get_technology_states(net_state_type_e *state)
+static int __net_dbus_get_technology_states(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
GVariant *message = NULL;
- if (state == NULL) {
- WIFI_LOG(WIFI_ERROR, "Invalid parameter");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_PARAM;
- }
+ network_info->service_state = NET_STATE_TYPE_UNKNOWN;
- message = _net_invoke_dbus_method(CONNMAN_SERVICE,
- CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
- "GetTechnologies", NULL, &Error);
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE, "GetTechnologies",
+ NULL, &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to get technology info");
goto done;
}
- Error = __net_get_tech_states(message, state);
+ Error = __net_get_tech_states(network_info, message);
g_variant_unref(message);
return Error;
}
-void _net_set_cs_tid(int tid)
+void _net_set_cs_tid(network_info_s *network_info, int tid)
{
GSList *list;
struct cs_tid_info *tid_info = NULL;
cs_tid_list = g_slist_prepend(cs_tid_list, tid_info);
}
- tid_info->subscribe_id_connman_state = gdbus_conn_subscribe_id_connman_state;
- tid_info->subscribe_id_connman_error = gdbus_conn_subscribe_id_connman_error;
- tid_info->subscribe_id_connman_scandone = gdbus_conn_subscribe_id_connman_scandone;
- tid_info->subscribe_id_connman_scanstarted = gdbus_conn_subscribe_id_connman_scanstarted;
- tid_info->subscribe_id_netconfig_wifi = gdbus_conn_subscribe_id_netconfig_wifi;
- tid_info->subscribe_id_netconfig = gdbus_conn_subscribe_id_netconfig;
+ tid_info->subscribe_id_connman_state = network_info->subscribe_id_connman_state;
+ tid_info->subscribe_id_connman_error = network_info->subscribe_id_connman_error;
+ tid_info->subscribe_id_connman_scandone = network_info->subscribe_id_connman_scandone;
+ tid_info->subscribe_id_connman_scanstarted = network_info->subscribe_id_connman_scanstarted;
+ tid_info->subscribe_id_netconfig_wifi = network_info->subscribe_id_netconfig_wifi;
+ tid_info->subscribe_id_netconfig = network_info->subscribe_id_netconfig;
WIFI_LOG(WIFI_INFO, "tid %d, tid_info %p", tid, tid_info);
}
}
//LCOV_EXCL_STOP
-int _net_deregister_signal(void)
+int _net_register_signal(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
- GDBusConnection *connection;
net_err_e Error = NET_ERR_NONE;
- connection = _net_dbus_get_gdbus_conn();
- if (connection == NULL) {
- WIFI_LOG(WIFI_ERROR, "Already de-registered"); //LCOV_EXCL_LINE
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
- }
-
- g_dbus_connection_signal_unsubscribe(connection,
- gdbus_conn_subscribe_id_connman_state);
- g_dbus_connection_signal_unsubscribe(connection,
- gdbus_conn_subscribe_id_connman_error);
- g_dbus_connection_signal_unsubscribe(connection,
- gdbus_conn_subscribe_id_connman_scandone);
- g_dbus_connection_signal_unsubscribe(connection,
- gdbus_conn_subscribe_id_connman_scanstarted);
- g_dbus_connection_signal_unsubscribe(connection,
- gdbus_conn_subscribe_id_netconfig_wifi);
- g_dbus_connection_signal_unsubscribe(connection,
- gdbus_conn_subscribe_id_netconfig);
-
- Error = _net_dbus_close_gdbus_call();
- if (Error != NET_ERR_NONE) {
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return Error; //LCOV_EXCL_LINE
- }
-
- __NETWORK_FUNC_EXIT__;
- return Error;
-}
-
-int _net_register_signal(void)
-{
- __NETWORK_FUNC_ENTER__;
-
- GDBusConnection *connection;
- net_err_e Error = NET_ERR_NONE;
-
- Error = _net_dbus_create_gdbus_call();
- if (Error != NET_ERR_NONE) {
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return Error; //LCOV_EXCL_LINE
- }
-
- connection = _net_dbus_get_gdbus_conn();
- if (connection == NULL) {
- __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
- return NET_ERR_UNKNOWN; //LCOV_EXCL_LINE
+ if (network_info == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
}
/* Create connman service state connection */
- gdbus_conn_subscribe_id_connman_state = g_dbus_connection_signal_subscribe(
- connection,
+ network_info->subscribe_id_connman_state = g_dbus_connection_signal_subscribe(
+ network_info->connection,
CONNMAN_SERVICE,
CONNMAN_SERVICE_INTERFACE,
SIGNAL_PROPERTY_CHANGED,
"State",
G_DBUS_SIGNAL_FLAGS_NONE,
__net_connman_service_signal_filter,
- NULL,
+ network_info,
NULL);
/* Create connman service error connection */
- gdbus_conn_subscribe_id_connman_error = g_dbus_connection_signal_subscribe(
- connection,
+ network_info->subscribe_id_connman_error = g_dbus_connection_signal_subscribe(
+ network_info->connection,
CONNMAN_SERVICE,
CONNMAN_SERVICE_INTERFACE,
SIGNAL_PROPERTY_CHANGED,
"Error",
G_DBUS_SIGNAL_FLAGS_NONE,
__net_connman_service_signal_filter,
- NULL,
+ network_info,
NULL);
/* Create net-config service connection for network */
- gdbus_conn_subscribe_id_netconfig = g_dbus_connection_signal_subscribe(
- connection,
+ network_info->subscribe_id_netconfig = g_dbus_connection_signal_subscribe(
+ network_info->connection,
NETCONFIG_SERVICE,
NETCONFIG_NETWORK_INTERFACE,
NULL,
NULL,
G_DBUS_SIGNAL_FLAGS_NONE,
__net_netconfig_network_signal_filter,
- NULL,
+ network_info,
NULL);
/* Create connman service scandone connection */
- gdbus_conn_subscribe_id_connman_scandone = g_dbus_connection_signal_subscribe(
- connection,
+ network_info->subscribe_id_connman_scandone = g_dbus_connection_signal_subscribe(
+ network_info->connection,
CONNMAN_SERVICE,
CONNMAN_MANAGER_INTERFACE,
"ScanDone",
NULL,
G_DBUS_SIGNAL_FLAGS_NONE,
__net_connman_manager_signal_filter,
- NULL,
+ network_info,
NULL);
/* Create connman service scanstarted connection */
- gdbus_conn_subscribe_id_connman_scanstarted = g_dbus_connection_signal_subscribe(
- connection,
+ network_info->subscribe_id_connman_scanstarted = g_dbus_connection_signal_subscribe(
+ network_info->connection,
CONNMAN_SERVICE,
CONNMAN_MANAGER_INTERFACE,
SIGNAL_SCAN_CHANGED,
NULL,
G_DBUS_SIGNAL_FLAGS_NONE,
__net_connman_manager_signal_filter,
- NULL,
+ network_info,
NULL);
/* Create net-config service connection */
- gdbus_conn_subscribe_id_netconfig_wifi = g_dbus_connection_signal_subscribe(
- connection,
+ network_info->subscribe_id_netconfig_wifi = g_dbus_connection_signal_subscribe(
+ network_info->connection,
NETCONFIG_SERVICE,
NETCONFIG_WIFI_INTERFACE,
NULL,
NULL,
G_DBUS_SIGNAL_FLAGS_NONE,
__net_netconfig_signal_filter,
- NULL,
+ network_info,
NULL);
+ /* LCOV_EXCL_START */
+ if (network_info->subscribe_id_connman_state == 0 ||
+ network_info->subscribe_id_connman_error == 0 ||
+ network_info->subscribe_id_connman_scandone == 0 ||
+ network_info->subscribe_id_connman_scanstarted == 0 ||
+ network_info->subscribe_id_netconfig_wifi == 0) {
+ WIFI_LOG(WIFI_ERROR, "Failed register signals "
+ "connman_state(%d), connman_error(%d), connman_scandone(%d), "
+ "connman_scanstarted(%d), netconfig_wifi(%d)",
+ network_info->subscribe_id_connman_state,
+ network_info->subscribe_id_connman_error,
+ network_info->subscribe_id_connman_scandone,
+ network_info->subscribe_id_connman_scanstarted,
+ network_info->subscribe_id_netconfig_wifi);
+ _net_deregister_signal(network_info);
+ Error = NET_ERR_INVALID_OPERATION;
+ }
+ /* LCOV_EXCL_STOP */
+
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_init_service_state(void)
+void _net_deregister_signal(network_info_s *network_info)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ if (network_info) {
+ g_dbus_connection_signal_unsubscribe(network_info->connection,
+ network_info->subscribe_id_connman_state);
+ g_dbus_connection_signal_unsubscribe(network_info->connection,
+ network_info->subscribe_id_connman_error);
+ g_dbus_connection_signal_unsubscribe(network_info->connection,
+ network_info->subscribe_id_connman_scandone);
+ g_dbus_connection_signal_unsubscribe(network_info->connection,
+ network_info->subscribe_id_connman_scanstarted);
+ g_dbus_connection_signal_unsubscribe(network_info->connection,
+ network_info->subscribe_id_netconfig_wifi);
+ g_dbus_connection_signal_unsubscribe(network_info->connection,
+ network_info->subscribe_id_netconfig);
+ }
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+int _net_init_service_state(network_info_s *network_info)
{
__NETWORK_FUNC_ENTER__;
net_err_e Error = NET_ERR_NONE;
- service_state = NET_STATE_TYPE_UNKNOWN;
- Error = __net_dbus_get_technology_states(&service_state);
+ Error = __net_dbus_get_technology_states(network_info);
if (Error != NET_ERR_NONE) {
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return Error; //LCOV_EXCL_LINE
}
WIFI_LOG(WIFI_INFO, "init service state, wifi:%s",
- _convert_net_state_to_string(service_state));
+ _convert_net_state_to_string(network_info->service_state));
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-
-net_state_type_e _net_get_service_state()
-{
- return service_state;
-}
return ipstr;
}
-static void __wifi_init_ap(net_profile_info_s *profile_info, const char *essid)
+static void __wifi_init_ap(wifi_manager_handle_s *wifi_handle,
+ net_profile_info_s *profile_info, const char *essid)
{
profile_info->ProfileState = NET_STATE_TYPE_IDLE;
profile_info->net_info.IpConfigType = NET_IP_CONFIG_TYPE_OFF;
profile_info->security_info.sec_mode = WLAN_SEC_MODE_NONE;
profile_info->security_info.enc_mode = WLAN_ENC_MODE_NONE;
g_strlcpy(profile_info->essid, essid, NET_WLAN_ESSID_LEN+1);
+
+ profile_info->network_info = wifi_handle->network_info;
}
static char *__wifi_create_profile_name(const char *ssid,
return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
}
- __wifi_init_ap(ap_info, essid);
+ __wifi_init_ap(wifi, ap_info, essid);
- _wifi_add_to_ap_list((wifi_manager_ap_h)ap_info);
+ _wifi_add_to_ap_list(ap_info);
*ap = (wifi_manager_ap_h)ap_info;
__NETWORK_CAPI_FUNC_EXIT__;
return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
}
- __wifi_init_ap(ap_info, essid);
+ __wifi_init_ap(wifi, ap_info, essid);
ap_info->is_hidden = TRUE;
- _wifi_add_to_ap_list((wifi_manager_ap_h)ap_info);
+ _wifi_add_to_ap_list(ap_info);
*ap = (wifi_manager_ap_h)ap_info;
__NETWORK_CAPI_FUNC_EXIT__;
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ net_profile_info_s *origin_info = origin;
net_profile_info_s *ap_info = g_try_malloc0(sizeof(net_profile_info_s));
if (ap_info == NULL) {
/* __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE */
}
memcpy(ap_info, origin, sizeof(net_profile_info_s));
+ ap_info->vsie_list = g_slist_copy_deep(origin_info->vsie_list,
+ _wifi_copy_vsie_list, NULL);
+ ap_info->bssid_list = g_slist_copy_deep(origin_info->bssid_list,
+ _wifi_copy_bssid_list, NULL);
- _wifi_add_to_ap_list((wifi_manager_ap_h)ap_info);
+ _wifi_add_to_ap_list(ap_info);
*cloned_ap = (wifi_manager_ap_h)ap_info;
/* __NETWORK_CAPI_FUNC_EXIT__; */
}
int rv = NET_ERR_NONE;
- rv = net_get_profile_info(ap_info->ProfileName, &ap_info_local);
+ rv = net_get_profile_info(ap_info->network_info, ap_info->ProfileName, &ap_info_local);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
__NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NO_CONNECTION; //LCOV_EXCL_LINE
}
} else if (address_family == WIFI_MANAGER_ADDRESS_FAMILY_IPV6) {
- if (net_get_preferred_ipv6_address(profile_info->ProfileName, ip_address) != NET_ERR_NONE) {
+ if (net_get_preferred_ipv6_address(profile_info->network_info,
+ profile_info->ProfileName, ip_address) != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to get preferred ipv6 address");
*ip_address = __ap_convert_ip_to_string(
&profile_info->net_info.IpAddr6,
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ wifi_manager_handle_s *wifi_handle = wifi;
wifi_config_s *h = NULL;
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
h->eap_config->eap_auth_type = WIFI_MANAGER_EAP_AUTH_TYPE_NONE;
}
- _wifi_add_to_config_list((wifi_manager_config_h)h);
- *config = (wifi_manager_config_h)h;
+ h->wifi_handle = wifi_handle;
+ _wifi_add_to_config_list(h);
+ *config = h;
__NETWORK_CAPI_FUNC_EXIT__;
h->eap_config->eap_auth_type = config->eap_config->eap_auth_type;
}
- _wifi_add_to_config_list((wifi_manager_config_h)h);
- *cloned_config = (wifi_manager_config_h)h;
+ h->wifi_handle = config->wifi_handle;
+ _wifi_add_to_config_list(h);
+ *cloned_config = h;
__NETWORK_CAPI_FUNC_EXIT__;
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ _wifi_remove_from_config_list(config);
+
g_free(h->name);
g_free(h->passphrase);
g_free(h->proxy_address);
g_free(h->eap_config);
}
- _wifi_remove_from_config_list(config);
+ g_free(h);
__NETWORK_CAPI_FUNC_EXIT__;
}
if (h->security_type == WIFI_MANAGER_SECURITY_TYPE_EAP) {
- ret = _wifi_save_eap_configurations(h->name, h->passphrase, h->security_type,
+ ret = _wifi_save_eap_configurations(wifi, h->name, h->passphrase, h->security_type,
h->proxy_address, h->eap_config, h->is_hidden, h->is_created);
if (ret != WIFI_MANAGER_ERROR_NONE)
WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_eap_configurations"); //LCOV_EXCL_LINE
} else {
- ret = _wifi_save_configuration(h->name, h->passphrase, h->security_type,
+ ret = _wifi_save_configuration(wifi, h->name, h->passphrase, h->security_type,
h->proxy_address, h->ip_info, h->is_hidden, h->is_created);
if (ret != WIFI_MANAGER_ERROR_NONE)
WIFI_LOG(WIFI_ERROR, "Fail to save configurations [%d]", ret); //LCOV_EXCL_LINE
config_id = _wifi_config_get_config_id(h->name, h->security_type);
- ret = _wifi_remove_configuration(config_id);
+ ret = _wifi_remove_configuration(wifi, config_id);
if (ret != WIFI_MANAGER_ERROR_NONE)
WIFI_LOG(WIFI_ERROR, "Fail to remove configurations [%d]", ret);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- ret = _wifi_load_configurations();
+ ret = _wifi_load_configurations(wifi);
if (ret != WIFI_MANAGER_ERROR_NONE) {
WIFI_LOG(WIFI_ERROR, "Fail to load configurations [%d]", ret); //LCOV_EXCL_LINE
__NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
return ret; //LCOV_EXCL_LINE
}
+ ret = _wifi_foreach_configuration(wifi, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
+ return ret;
+}
+
+EXPORT_API int wifi_manager_config_foreach_configuration_in_all_interfaces(wifi_manager_h wifi,
+ wifi_manager_config_list_cb callback, void *user_data)
+{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ int ret = WIFI_MANAGER_ERROR_NONE;
+
+ RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
- return _wifi_foreach_configuration(callback, user_data);
+ if (callback == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ ret = _wifi_load_configurations(wifi);
+ if (ret != WIFI_MANAGER_ERROR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Fail to load configurations [%d]", ret); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return ret; //LCOV_EXCL_LINE
+ }
+
+ ret = _wifi_foreach_configuration(wifi, callback, user_data);
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+ return ret;
}
EXPORT_API int wifi_manager_config_get_name(wifi_manager_config_h config, char **name)
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
wifi_dpp_s *p_dpp = NULL;
+ wifi_manager_handle_s *wifi_handle = wifi;
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
}
p_dpp->is_initiator = is_initiator;
+ p_dpp->network_info = wifi_handle->network_info;
_wifi_add_to_dpp_list((wifi_manager_dpp_h)p_dpp);
*handle = (wifi_manager_dpp_h)p_dpp;
return WIFI_MANAGER_ERROR_NONE;
}
-static int __wifi_set_dpp_event_cb(wifi_manager_h wifi,
+static void __wifi_set_dpp_event_cb(wifi_manager_handle_s *wifi_handle,
void *callback, void *user_data)
{
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
-
- local_handle->dpp_event_cb = callback;
- local_handle->dpp_event_user_data = user_data;
-
- return WIFI_MANAGER_ERROR_NONE;
+ wifi_handle->dpp_event_cb = callback;
+ wifi_handle->dpp_event_user_data = user_data;
}
EXPORT_API int wifi_manager_dpp_set_event_cb(wifi_manager_h wifi,
return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
}
+ __wifi_set_dpp_event_cb(wifi, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return __wifi_set_dpp_event_cb(wifi, callback, user_data);
+ return WIFI_MANAGER_ERROR_NONE;
}
EXPORT_API int wifi_manager_dpp_unset_event_cb(wifi_manager_h wifi)
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
+ __wifi_set_dpp_event_cb(wifi, NULL, NULL);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return __wifi_set_dpp_event_cb(wifi, NULL, NULL);
+ return WIFI_MANAGER_ERROR_NONE;
}
EXPORT_API int wifi_manager_dpp_is_initiator(wifi_manager_dpp_h handle,
#include "wifi_internal.h"
-bool is_disconnect_wps_pbc = false;
-bool is_disconnect_wps_pin = false;
-static gboolean multi_scan_type[WIFI_MULTI_SCAN_MAX] = {0, };
-
#define WIFI_SECURITY_NONE "none"
#define WIFI_SECURITY_WEP "wep"
#define WIFI_SECURITY_WPA_PSK "psk"
#define WIFI_SECURITY_DPP "dpp"
#define WIFI_SECURITY_EAP "ieee8021x"
+#define WIFI_MAC_ADDR_PATH_LEN 32
+#define WIFI_MAC_ADDR_PATH "/sys/class/net/%s/address"
/* DPP related DBus calls are sync method.
* If DPP is not allowed to start from net-config, there's no g_p_dpp_current for lib.
* So, we should take care about changing DPP DBus call mechanism
*/
-static __thread wifi_dpp_s *g_p_dpp_current = NULL;
-
-static __thread GSList *wifi_manager_handle_list = NULL;
-static __thread GSList *ap_handle_list = NULL;
-static __thread GSList *config_handle_list = NULL;
-static __thread GSList *multi_scan_handle_list = NULL;
-static __thread GSList *netlink_scan_handle_list = NULL;
-static __thread GSList *dpp_handle_list = NULL;
-
-static __thread GSList *profile_iterator = NULL;
-static __thread GSList *specific_profile_iterator = NULL;
-static __thread GSList *bss_profile_iterator = NULL;
-static __thread GSList *config_iterator = NULL;
-static __thread char specific_profile_essid[NET_WLAN_ESSID_LEN + 1] = { 0, };
-static __thread bool wifi_is_feature_checked[WIFI_SUPPORTED_FEATURE_MAX] = {0, };
-static __thread bool wifi_feature_supported[WIFI_SUPPORTED_FEATURE_MAX] = {0, };
+static wifi_dpp_s *g_p_dpp_current = NULL;
+
+static GSList *wifi_manager_handle_list = NULL;
+static GSList *multi_scan_handle_list = NULL;
+static GSList *netlink_scan_handle_list = NULL;
+static GSList *dpp_handle_list = NULL;
+
+static gboolean multi_scan_type[WIFI_MULTI_SCAN_MAX] = {0, };
+
+static bool wifi_is_feature_checked[WIFI_SUPPORTED_FEATURE_MAX] = {0, };
+static bool wifi_feature_supported[WIFI_SUPPORTED_FEATURE_MAX] = {0, };
//LCOV_EXCL_START
static wifi_manager_error_e __convert_to_ap_error_type(net_err_e err_type)
return type;
}
-static void __clear_profile_internal_list(GSList **iterator)
+static void __clear_profile_internal_list(GSList *iterator)
{
GSList *list;
- for (list = *iterator; list; list = list->next) {
+ for (list = iterator; list; list = list->next) {
net_profile_info_s *prof_info = (net_profile_info_s *)list->data;
if (prof_info->vsie_list) {
//LCOV_EXCL_STOP
+void __clear_interface_list(GSList **iterator)
+{
+ if (*iterator) {
+ *iterator = g_slist_nth(*iterator, 0);
+ g_slist_free_full(*iterator, g_free);
+ *iterator = NULL;
+ }
+}
+
void __clear_profile_list(GSList **iterator)
{
if (*iterator) {
*iterator = g_slist_nth(*iterator, 0);
- __clear_profile_internal_list(iterator);
+ __clear_profile_internal_list(*iterator);
g_slist_free_full(*iterator, g_free);
*iterator = NULL;
}
}
-static int __update_profile_iterator(void)
+gpointer _wifi_copy_vsie_list(gconstpointer data, gpointer user_data)
+{
+ return g_strdup(data);
+}
+
+gpointer _wifi_copy_bssid_list(gconstpointer data, gpointer user_data)
+{
+ net_profile_bssid_list_s *org_data, *dst_data;
+
+ org_data = (net_profile_bssid_list_s *)data;
+ dst_data = g_try_malloc0(sizeof(net_profile_bssid_list_s));
+ if (dst_data) {
+ g_strlcpy(dst_data->bssid, org_data->bssid, 18);
+ dst_data->strength = org_data->strength;
+ dst_data->frequency = org_data->frequency;
+ }
+
+ return dst_data;
+}
+
+static int __update_profile_iterator(wifi_manager_handle_s *wifi_handle)
{
int rv;
- __clear_profile_list(&profile_iterator);
+ __clear_profile_list(&(wifi_handle->profile_iterator));
- rv = net_get_profile_list(&profile_iterator);
+ rv = net_get_profile_list(wifi_handle->network_info,
+ &(wifi_handle->profile_iterator));
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NONE;
}
-static void __update_specific_iterator(GSList *bss_list)
+static int __update_interface_iterator(wifi_manager_handle_s *wifi_handle)
+{
+ int rv;
+
+ __clear_interface_list(&(wifi_handle->interface_iterator));
+
+ rv = net_get_interface_list(wifi_handle->network_info,
+ &(wifi_handle->interface_iterator));
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+static void __update_specific_iterator(wifi_manager_handle_s *wifi_handle, GSList *bss_list)
{
int i, count = 0;
GSList *list = bss_list;
WIFI_LOG(WIFI_ERROR, "Failed to alloc profile"); //LCOV_EXCL_LINE
return; //LCOV_EXCL_LINE
}
- if (net_init_profile_info(prof_info) != NET_ERR_NONE) {
+
+ if (net_init_profile_info(wifi_handle->network_info, prof_info) != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to init profile"); //LCOV_EXCL_LINE
g_free(prof_info); //LCOV_EXCL_LINE
return; //LCOV_EXCL_LINE
}
+
g_strlcpy(prof_info->essid, info->ssid, NET_WLAN_ESSID_LEN);
memcpy(prof_info->raw_ssid, info->raw_ssid, info->raw_ssid_len);
prof_info->raw_ssid_len = info->raw_ssid_len;
prof_info->security_info.sec_mode = info->security;
prof_info->security_info.wps_support = (char)info->wps;
- specific_profile_iterator = g_slist_append(specific_profile_iterator,
- (net_profile_info_s *)prof_info);
+
+ wifi_handle->specific_profile_iterator =
+ g_slist_append(wifi_handle->specific_profile_iterator,
+ (net_profile_info_s *)prof_info);
}
}
-static void __update_bss_profile_iterator(GSList *bss_list)
+static void __update_bss_profile_iterator(wifi_manager_handle_s *wifi_handle,
+ GSList *bss_list)
{
int count = 0;
GSList *list = bss_list;
return; //LCOV_EXCL_LINE
}
- if (net_init_profile_info(profile) != NET_ERR_NONE) {
+ if (net_init_profile_info(wifi_handle->network_info, profile) != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to init profile"); //LCOV_EXCL_LINE
g_free(profile); //LCOV_EXCL_LINE
return; //LCOV_EXCL_LINE
}
- g_strlcpy(profile->essid, (char *)ap->ssid, NET_WLAN_ESSID_LEN+1);
+ g_strlcpy(profile->essid, (char *)ap->ssid, NET_WLAN_ESSID_LEN + 1);
g_strlcpy(profile->bssid, ap->bssid, WIFI_MAC_ADDR_LEN + 1);
profile->wlan_mode = ap->mode;
* so modify the rssi value in same manner as done in connman. */
profile->Strength = 120 + ap->rssi;
- bss_profile_iterator = g_slist_append(bss_profile_iterator,
- (net_profile_info_s *)profile);
+ wifi_handle->bss_profile_iterator =
+ g_slist_append(wifi_handle->bss_profile_iterator,
+ (net_profile_info_s *)profile);
}
}
//LCOV_EXCL_START
-static void __update_netlink_scan_profile_iterator(GSList *bss_list)
+static void __update_netlink_scan_profile_iterator(wifi_manager_handle_s *wifi_handle,
+ GSList *bss_list)
{
int count = 0;
GSList *list = bss_list;
return;
}
- if (net_init_profile_info(profile) != NET_ERR_NONE) {
+ if (net_init_profile_info(wifi_handle->network_info, profile) != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to init profile");
g_free(profile);
return;
break;
}
- bss_profile_iterator = g_slist_append(bss_profile_iterator,
+ wifi_handle->bss_profile_iterator = g_slist_append(wifi_handle->bss_profile_iterator,
(net_profile_info_s *)profile);
}
}
wifi_info->is_hidden = ap_info->is_hidden;
}
-static int __connect_with_wifi_info(net_profile_info_s *ap_info)
+static int __connect_with_wifi_info(wifi_manager_handle_s *wifi_handle,
+ net_profile_info_s *ap_info)
{
net_wifi_connection_info_s wifi_info;
+
memset(&wifi_info, 0, sizeof(net_wifi_connection_info_s));
__convert_profile_info_to_wifi_info(&wifi_info, ap_info);
- return net_open_connection_with_wifi_info(&wifi_info);
+ return net_open_connection_with_wifi_info(wifi_handle->network_info, &wifi_info);
}
-static int __load_configurations(const gchar *config_id, gchar **name,
+static int __load_configurations(wifi_manager_handle_s *wifi_handle,
+ const gchar *config_id, gchar **name,
gchar **passphrase, wifi_manager_security_type_e *security_type, gchar **proxy_address,
gboolean *is_hidden, wifi_config_ip_info_s **ip_info,
wifi_manager_error_e *last_error)
{
int rv;
- rv = net_config_load_configurations(config_id, name, passphrase, security_type,
+ rv = net_config_load_configurations(wifi_handle->network_info,
+ config_id, name, passphrase, security_type,
proxy_address, is_hidden, (net_ip_info_config_s **)ip_info,
last_error);
if (rv == NET_ERR_ACCESS_DENIED) {
return WIFI_MANAGER_ERROR_NONE;
}
-static int __load_eap_configurations(const gchar *config_id, gchar **name,
+static int __load_eap_configurations(wifi_manager_handle_s *wifi_handle,
+ const gchar *config_id, gchar **name,
wifi_manager_security_type_e *security_type, gchar **proxy_address, gboolean *is_hidden,
wifi_eap_config_s **eap_config, wifi_manager_error_e *last_error)
{
int rv;
- rv = net_config_load_eap_configurations(config_id, name, security_type,
+ rv = net_config_load_eap_configurations(wifi_handle->network_info,
+ config_id, name, security_type,
proxy_address, is_hidden, (void **)eap_config, last_error);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
}
//LCOV_EXCL_START
-static void __state_changed_cb(char *profile_name,
+static void __state_changed_cb(wifi_manager_handle_s *wifi_handle, char *profile_name,
net_profile_info_s *profile_info, wifi_manager_connection_state_e state)
{
- GSList *list;
net_profile_info_s *ap_info = NULL;
if (profile_name == NULL)
WIFI_LOG(WIFI_INFO, "%s state changed : %s", profile_name, __convert_ap_state_to_string(state));
- if (_wifi_get_callback_count_from_handle_list(WIFI_MANAGER_CONNECTION_STATE_CB)) {
+ if (wifi_handle->connection_state_cb) {
ap_info = g_try_malloc0(sizeof(net_profile_info_s));
if (ap_info == NULL) {
WIFI_LOG(WIFI_ERROR, "Memory allocation error");
if (profile_info)
memcpy(ap_info, profile_info, sizeof(net_profile_info_s));
+ else
+ ap_info->network_info = wifi_handle->network_info;
WIFI_LOG(WIFI_INFO, "[Ap info] profile name(%s) essid(%s) bssid(%s)",
ap_info->ProfileName, ap_info->essid, ap_info->bssid);
_wifi_add_to_ap_list(ap_info);
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (local_handle->connection_state_cb)
- local_handle->connection_state_cb(state, ap_info,
- local_handle->connection_state_user_data);
- }
+ wifi_handle->connection_state_cb(state, ap_info,
+ wifi_handle->connection_state_user_data);
_wifi_remove_from_ap_list(ap_info);
+ g_free(ap_info);
}
}
-static void __set_activated_cb(wifi_manager_h wifi,
+static void __set_activated_cb(wifi_manager_handle_s *wifi_handle,
wifi_manager_activated_cb user_cb, void *user_data)
{
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
-
- if (user_cb != NULL) {
- local_handle->activated_cb = user_cb;
- local_handle->activated_user_data = user_data;
- }
+ wifi_handle->activated_cb = user_cb;
+ wifi_handle->activated_user_data = user_data;
}
-static void __set_deactivated_cb(wifi_manager_h wifi,
+static void __set_deactivated_cb(wifi_manager_handle_s *wifi_handle,
wifi_manager_deactivated_cb user_cb, void *user_data)
{
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
-
- if (user_cb != NULL) {
- local_handle->deactivated_cb = user_cb;
- local_handle->deactivated_user_data = user_data;
- }
+ wifi_handle->deactivated_cb = user_cb;
+ wifi_handle->deactivated_user_data = user_data;
}
-static void __power_on_off_cb(net_event_info_s *event_cb, bool is_requested)
+static void __power_on_off_cb(wifi_manager_handle_s *wifi_handle,
+ net_event_info_s *event_cb, bool is_requested)
{
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
- if (!_wifi_get_callback_count_from_handle_list(WIFI_ACTIVATED_CB) &&
- !_wifi_get_callback_count_from_handle_list(WIFI_DEACTIVATED_CB) &&
- !_wifi_get_callback_count_from_handle_list(WIFI_DEVICE_STATE_CB))
- return;
-
- GSList *list;
wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE;
wifi_manager_device_state_e state = WIFI_MANAGER_DEVICE_STATE_DEACTIVATED;
net_wifi_state_e *wifi_state = (net_wifi_state_e *)event_cb->Data;
+ if (wifi_handle->activated_cb == NULL &&
+ wifi_handle->deactivated_cb == NULL &&
+ wifi_handle->device_state_cb == NULL)
+ return;
+
if (event_cb->Error == NET_ERR_NONE &&
event_cb->Datalength == sizeof(net_wifi_state_e)) {
if (*wifi_state == WIFI_ON) {
} else if (*wifi_state == WIFI_OFF) {
WIFI_LOG(WIFI_INFO, "Wi-Fi power off");
state = WIFI_MANAGER_DEVICE_STATE_DEACTIVATED;
- __clear_profile_list(&profile_iterator);
- __clear_profile_list(&specific_profile_iterator);
- __clear_profile_list(&bss_profile_iterator);
+ __clear_profile_list(&(wifi_handle->profile_iterator));
+ __clear_profile_list(&(wifi_handle->specific_profile_iterator));
+ __clear_profile_list(&(wifi_handle->bss_profile_iterator));
} else {
WIFI_LOG(WIFI_ERROR, "Error Wi-Fi state %d", *wifi_state);
error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED;
state = WIFI_MANAGER_DEVICE_STATE_DEACTIVATED;
}
- if (_wifi_get_callback_count_from_handle_list(WIFI_ACTIVATED_CB)) {
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (local_handle->activated_cb)
- local_handle->activated_cb(error_code, local_handle->activated_user_data);
+ if (wifi_handle->activated_cb)
+ wifi_handle->activated_cb(error_code, wifi_handle->activated_user_data);
- local_handle->activated_cb = NULL;
- local_handle->activated_user_data = NULL;
- }
- }
+ wifi_handle->activated_cb = NULL;
+ wifi_handle->activated_user_data = NULL;
- if (_wifi_get_callback_count_from_handle_list(WIFI_DEACTIVATED_CB)) {
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (local_handle->deactivated_cb != NULL)
- local_handle->deactivated_cb(error_code, local_handle->deactivated_user_data);
+ if (wifi_handle->deactivated_cb)
+ wifi_handle->deactivated_cb(error_code, wifi_handle->deactivated_user_data);
- local_handle->deactivated_cb = NULL;
- local_handle->deactivated_user_data = NULL;
- }
- }
+ wifi_handle->deactivated_cb = NULL;
+ wifi_handle->deactivated_user_data = NULL;
- if (_wifi_get_callback_count_from_handle_list(WIFI_DEVICE_STATE_CB)) {
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (local_handle->device_state_cb)
- local_handle->device_state_cb(state, local_handle->device_state_user_data);
- }
+ if (error_code == WIFI_MANAGER_ERROR_NONE) {
+ if (wifi_handle->device_state_cb)
+ wifi_handle->device_state_cb(state, wifi_handle->device_state_user_data);
}
}
-static void __set_scan_cb(wifi_manager_h wifi,
+static void __set_scan_cb(wifi_manager_handle_s *wifi_handle,
wifi_manager_scan_finished_cb user_cb, void *user_data)
{
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
-
- if (user_cb) {
- local_handle->scan_request_cb = user_cb;
- local_handle->scan_request_user_data = user_data;
- }
+ wifi_handle->scan_request_cb = user_cb;
+ wifi_handle->scan_request_user_data = user_data;
}
-static void __set_specific_scan_cb(wifi_manager_h wifi,
+static void __set_specific_scan_cb(wifi_manager_handle_s *wifi_handle,
wifi_manager_scan_finished_cb user_cb, void *user_data)
{
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
-
- if (user_cb) {
- local_handle->specific_scan_cb = user_cb;
- local_handle->specific_scan_user_data = user_data;
- }
+ wifi_handle->specific_scan_cb = user_cb;
+ wifi_handle->specific_scan_user_data = user_data;
}
-static void __set_bssid_scan_cb(wifi_manager_h wifi,
+static void __set_bssid_scan_cb(wifi_manager_handle_s *wifi_handle,
wifi_manager_bssid_scan_finished_cb user_cb, void *user_data)
{
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
-
- if (user_cb) {
- local_handle->bssid_scan_cb = user_cb;
- local_handle->bssid_scan_user_data = user_data;
- }
+ wifi_handle->bssid_scan_cb = user_cb;
+ wifi_handle->bssid_scan_user_data = user_data;
}
-static void __set_netlink_scan_cb(wifi_manager_h wifi,
+static void __set_netlink_scan_cb(wifi_manager_handle_s *wifi_handle,
wifi_manager_netlink_scan_finished_cb user_cb, void *user_data)
{
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
-
- if (user_cb) {
- local_handle->netlink_scan_cb = user_cb;
- local_handle->netlink_scan_user_data = user_data;
- }
+ wifi_handle->netlink_scan_cb = user_cb;
+ wifi_handle->netlink_scan_user_data = user_data;
}
-static void __set_multi_scan_cb(wifi_manager_h wifi,
+static void __set_multi_scan_cb(wifi_manager_handle_s *wifi_handle,
wifi_manager_scan_finished_cb user_cb, void *user_data)
{
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
-
- if (user_cb) {
- local_handle->multi_scan_cb = user_cb;
- local_handle->multi_scan_user_data = user_data;
- }
+ wifi_handle->multi_scan_cb = user_cb;
+ wifi_handle->multi_scan_user_data = user_data;
}
-static void __scan_cb(net_event_info_s *event_cb, bool is_requested)
+static void __scan_cb(wifi_manager_handle_s *wifi_handle,
+ net_event_info_s *event_cb, bool is_requested)
{
- GSList *list;
wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE;
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
if (event_cb->Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Scan failed[%d]", event_cb->Error);
error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED;
}
- if (_wifi_get_callback_count_from_handle_list(WIFI_SCAN_REQUEST_CB)) {
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- wifi_manager_scan_finished_cb cb = local_handle->scan_request_cb;
- void* user_data = local_handle->scan_request_user_data;
- local_handle->scan_request_cb = NULL;
- local_handle->scan_request_user_data = NULL;
+ if (wifi_handle->scan_request_cb) {
+ wifi_handle->scan_request_cb(error_code, wifi_handle->scan_request_user_data);
- if (cb)
- cb(error_code, user_data);
+ wifi_handle->scan_request_cb = NULL;
+ wifi_handle->scan_request_user_data = NULL;
- }
return;
}
- if (_wifi_get_callback_count_from_handle_list(WIFI_BG_SCAN_CB)) {
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (local_handle->bg_scan_cb)
- local_handle->bg_scan_cb(error_code, local_handle->bg_scan_user_data);
- }
- }
+ if (wifi_handle->bg_scan_cb)
+ wifi_handle->bg_scan_cb(error_code, wifi_handle->bg_scan_user_data);
}
-static void __scan_changed_cb(wifi_manager_scan_state_e scan_state)
+static void __scan_changed_cb(wifi_manager_handle_s *wifi_handle, wifi_manager_scan_state_e scan_state)
{
- GSList *list;
-
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
if (scan_state == 1)
WIFI_LOG(WIFI_INFO, "scan state: Scan is in progress");
else
WIFI_LOG(WIFI_INFO, "scan state: Scan is not running");
- if (_wifi_get_callback_count_from_handle_list(WIFI_SCAN_CHANGED_CB)) {
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (local_handle->scan_changed_cb)
- local_handle->scan_changed_cb(scan_state, local_handle->scan_changed_user_data);
- }
- }
+ if (wifi_handle->scan_changed_cb)
+ wifi_handle->scan_changed_cb(scan_state, wifi_handle->scan_changed_user_data);
}
-static void __specific_scan_cb(net_event_info_s *event_cb)
+static void __specific_scan_cb(wifi_manager_handle_s *wifi_handle, net_event_info_s *event_cb)
{
- GSList *list;
wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE;
- __clear_profile_list(&specific_profile_iterator);
+ __clear_profile_list(&(wifi_handle->specific_profile_iterator));
if (event_cb->Error != NET_ERR_NONE) {
- WIFI_LOG(WIFI_ERROR, "Specific scan failed!, Error [%d]\n", event_cb->Error);
+ WIFI_LOG(WIFI_ERROR, "Specific scan failed!, Error [%d]", event_cb->Error);
error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED;
} else if (event_cb->Data) {
- __update_specific_iterator((GSList *)event_cb->Data);
- WIFI_LOG(WIFI_INFO, "Specific AP count : %d\n",
- (int)g_slist_length(specific_profile_iterator));
+ __update_specific_iterator(wifi_handle, (GSList *)event_cb->Data);
+ WIFI_LOG(WIFI_INFO, "Specific AP count : %d",
+ (int)g_slist_length(wifi_handle->specific_profile_iterator));
}
- if (_wifi_get_callback_count_from_handle_list(WIFI_SPECIFIC_SCAN_CB)) {
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (local_handle->specific_scan_cb)
- local_handle->specific_scan_cb(error_code, local_handle->specific_scan_user_data);
+ if (wifi_handle->specific_scan_cb)
+ wifi_handle->specific_scan_cb(error_code, wifi_handle->specific_scan_user_data);
- local_handle->specific_scan_cb = NULL;
- local_handle->specific_scan_user_data = NULL;
- }
- }
+ wifi_handle->specific_scan_cb = NULL;
+ wifi_handle->specific_scan_user_data = NULL;
}
-static void __bssid_scan_cb(net_event_info_s *event_cb)
+static void __bssid_scan_cb(wifi_manager_handle_s *wifi_handle, net_event_info_s *event_cb)
{
- GSList *list;
wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE;
- __clear_profile_list(&bss_profile_iterator);
+ __clear_profile_list(&(wifi_handle->bss_profile_iterator));
if (event_cb->Error != NET_ERR_NONE) {
- WIFI_LOG(WIFI_ERROR, "BSSID scan failed!, Error [%d]\n",
+ WIFI_LOG(WIFI_ERROR, "BSSID scan failed!, Error [%d]",
event_cb->Error);
error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED;
} else if (event_cb->Data) {
- __update_bss_profile_iterator((GSList *)event_cb->Data);
- WIFI_LOG(WIFI_INFO, "BSS AP count : %d\n",
- (int)g_slist_length(bss_profile_iterator));
+ __update_bss_profile_iterator(wifi_handle, (GSList *)event_cb->Data);
+ WIFI_LOG(WIFI_INFO, "BSS AP count : %d",
+ (int)g_slist_length(wifi_handle->bss_profile_iterator));
}
- if (_wifi_get_callback_count_from_handle_list(WIFI_BSSID_SCAN_CB)) {
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (local_handle->bssid_scan_cb)
- local_handle->bssid_scan_cb(error_code, local_handle->bssid_scan_user_data);
+ if (wifi_handle->bssid_scan_cb)
+ wifi_handle->bssid_scan_cb(error_code, wifi_handle->bssid_scan_user_data);
- local_handle->bssid_scan_cb = NULL;
- local_handle->bssid_scan_user_data = NULL;
- }
- }
+ wifi_handle->bssid_scan_cb = NULL;
+ wifi_handle->bssid_scan_user_data = NULL;
}
-static void __ip_conflict_cb(net_event_info_s *event_cb)
+static void __ip_conflict_cb(wifi_manager_handle_s *wifi_handle, net_event_info_s *event_cb)
{
- GSList *list;
char *mac = NULL;
char *state = NULL;
net_ip_conflict_info_s *conflict_info = NULL;
wifi_manager_ip_conflict_state_e conflict_state = WIFI_MANAGER_IP_CONFLICT_STATE_UNKNOWN;
- __clear_profile_list(&bss_profile_iterator);
+ __clear_profile_list(&(wifi_handle->bss_profile_iterator));
if (event_cb->Data) {
conflict_info = (net_ip_conflict_info_s *)event_cb->Data;
}
}
- if (_wifi_get_callback_count_from_handle_list(WIFI_IP_CONFLICT_CB)) {
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (local_handle->ip_conflict_cb)
- local_handle->ip_conflict_cb(mac, conflict_state,
- local_handle->ip_conflict_user_data);
-
- }
- }
+ if (wifi_handle->ip_conflict_cb)
+ wifi_handle->ip_conflict_cb(mac, conflict_state, wifi_handle->ip_conflict_user_data);
if (conflict_info) {
g_free(conflict_info->mac);
}
}
-static void __netlink_scan_cb(net_event_info_s *event_cb)
+static void __netlink_scan_cb(wifi_manager_handle_s *wifi_handle, net_event_info_s *event_cb)
{
- GSList *list;
wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE;
- __clear_profile_list(&bss_profile_iterator);
+ __clear_profile_list(&(wifi_handle->bss_profile_iterator));
if (event_cb->Error != NET_ERR_NONE) {
- WIFI_LOG(WIFI_ERROR, "NETLINK scan failed!, Error [%d]\n",
+ WIFI_LOG(WIFI_ERROR, "NETLINK scan failed!, Error [%d]",
event_cb->Error);
error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED;
} else if (event_cb->Data) {
- __update_netlink_scan_profile_iterator((GSList *)event_cb->Data);
- WIFI_LOG(WIFI_INFO, "BSS AP count : %d\n",
- (int)g_slist_length(bss_profile_iterator));
+ __update_netlink_scan_profile_iterator(wifi_handle, (GSList *)event_cb->Data);
+ WIFI_LOG(WIFI_INFO, "BSS AP count : %d",
+ (int)g_slist_length(wifi_handle->bss_profile_iterator));
}
- if (_wifi_get_callback_count_from_handle_list(WIFI_NETLINK_SCAN_CB)) {
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (local_handle->netlink_scan_cb)
- local_handle->netlink_scan_cb(error_code, local_handle->netlink_scan_user_data);
+ if (wifi_handle->netlink_scan_cb)
+ wifi_handle->netlink_scan_cb(error_code, wifi_handle->netlink_scan_user_data);
- local_handle->netlink_scan_cb = NULL;
- local_handle->netlink_scan_user_data = NULL;
- }
- }
+ wifi_handle->netlink_scan_cb = NULL;
+ wifi_handle->netlink_scan_user_data = NULL;
}
-static void __multi_scan_cb(net_event_info_s *event_cb)
+static void __multi_scan_cb(wifi_manager_handle_s *wifi_handle, net_event_info_s *event_cb)
{
- GSList *list;
wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE;
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
if (event_cb->Error != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Multi Scan failed[%d]", event_cb->Error);
error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED;
}
- if (_wifi_get_callback_count_from_handle_list(WIFI_MULTI_SCAN_CB)) {
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (local_handle->multi_scan_cb)
- local_handle->multi_scan_cb(error_code, local_handle->multi_scan_user_data);
+ if (wifi_handle->multi_scan_cb)
+ wifi_handle->multi_scan_cb(error_code, wifi_handle->multi_scan_user_data);
- local_handle->multi_scan_cb = NULL;
- local_handle->multi_scan_user_data = NULL;
- }
- return;
- }
+ wifi_handle->multi_scan_cb = NULL;
+ wifi_handle->multi_scan_user_data = NULL;
}
-static void __set_connected_cb(wifi_manager_h wifi,
+static void __set_connected_cb(wifi_manager_handle_s *wifi_handle,
wifi_manager_connected_cb user_cb, void *user_data)
{
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
-
- if (user_cb != NULL) {
- local_handle->connected_cb = user_cb;
- local_handle->connected_user_data = user_data;
- }
+ wifi_handle->connected_cb = user_cb;
+ wifi_handle->connected_user_data = user_data;
}
-static void __connected_cb(wifi_manager_error_e result)
+static void __connected_cb(wifi_manager_handle_s *wifi_handle, wifi_manager_error_e result)
{
- GSList *list;
+ if (wifi_handle->connected_cb)
+ wifi_handle->connected_cb(result, wifi_handle->connected_user_data);
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
- if (_wifi_get_callback_count_from_handle_list(WIFI_CONNECTED_CB)) {
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (local_handle->connected_cb != NULL)
- local_handle->connected_cb(result, local_handle->connected_user_data);
-
- local_handle->connected_cb = NULL;
- local_handle->connected_user_data = NULL;
- }
- }
+ wifi_handle->connected_cb = NULL;
+ wifi_handle->connected_user_data = NULL;
}
-static void __set_disconnected_cb(wifi_manager_h wifi,
+static void __set_disconnected_cb(wifi_manager_handle_s *wifi_handle,
wifi_manager_disconnected_cb user_cb, void *user_data)
{
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
-
- if (user_cb != NULL) {
- local_handle->disconnected_cb = user_cb;
- local_handle->disconnected_user_data = user_data;
- }
+ wifi_handle->disconnected_cb = user_cb;
+ wifi_handle->disconnected_user_data = user_data;
}
-static void __disconnected_cb(wifi_manager_error_e result)
+static void __disconnected_cb(wifi_manager_handle_s *wifi_handle,
+ wifi_manager_error_e result)
{
- GSList *list;
-
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
+ if (wifi_handle->disconnected_cb)
+ wifi_handle->disconnected_cb(result, wifi_handle->disconnected_user_data);
- if (_wifi_get_callback_count_from_handle_list(WIFI_DISCONNECTED_CB)) {
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (local_handle->disconnected_cb != NULL)
- local_handle->disconnected_cb(result, local_handle->disconnected_user_data);
-
- local_handle->disconnected_cb = NULL;
- local_handle->disconnected_user_data = NULL;
- }
- }
+ wifi_handle->disconnected_cb = NULL;
+ wifi_handle->disconnected_user_data = NULL;
}
-static void __tdls_discovered_cb(net_event_info_s *event_cb)
+static void __tdls_discovered_cb(wifi_manager_handle_s *wifi_handle,
+ net_event_info_s *event_cb)
{
- GSList *list;
char *peer_mac_add = NULL;
net_tdls_discover_s *discover_info;
-
wifi_manager_tdls_discovery_state_e state;
discover_info = (net_tdls_discover_s*)event_cb->Data;
peer_mac_add = discover_info->mac_add;
-
- WIFI_LOG(WIFI_INFO, "Peer Mac Add %s , Type[%d] \n", peer_mac_add, discover_info->type);
+ WIFI_LOG(WIFI_INFO, "Peer Mac Add %s , Type[%d] ", peer_mac_add, discover_info->type);
if (discover_info->type == 0) //TDLS Discovery : Unicast
state = WIFI_MANAGER_TDLS_DISCOVERY_STATE_FINISHED;
} else
state = WIFI_MANAGER_TDLS_DISCOVERY_STATE_ONGOING;
- if (_wifi_get_callback_count_from_handle_list(WIFI_MANAGER_TDLS_DISCOVERED_CB)) {
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (local_handle->tdls_discovered_cb)
- local_handle->tdls_discovered_cb(state, peer_mac_add,
- local_handle->tdls_discovered_user_data);
- }
- }
+ if (wifi_handle->tdls_discovered_cb)
+ wifi_handle->tdls_discovered_cb(state, peer_mac_add,
+ wifi_handle->tdls_discovered_user_data);
}
-static void __tdls_state_changed_cb(wifi_manager_tdls_state_e state,
- net_event_info_s *event_cb)
+static void __tdls_state_changed_cb(wifi_manager_handle_s *wifi_handle,
+ wifi_manager_tdls_state_e state, net_event_info_s *event_cb)
{
- GSList *list;
char *peer_mac_add = NULL;
peer_mac_add = (char*)event_cb->Data;
- WIFI_LOG(WIFI_INFO, "Peer Mac Add %s \n", peer_mac_add);
+ WIFI_LOG(WIFI_INFO, "Peer Mac Add %s ", peer_mac_add);
- if (_wifi_get_callback_count_from_handle_list(WIFI_MANAGER_TDLS_STATE_CHANGED_CB)) {
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (local_handle->tdls_state_changed_cb)
- local_handle->tdls_state_changed_cb(state, peer_mac_add,
- local_handle->tdls_state_changed_user_data);
- }
- }
+ if (wifi_handle->tdls_state_changed_cb)
+ wifi_handle->tdls_state_changed_cb(state, peer_mac_add,
+ wifi_handle->tdls_state_changed_user_data);
}
//LCOV_EXCL_STOP
-static void __set_forget_ap_cb(wifi_manager_h wifi,
+static void __set_forget_ap_cb(wifi_manager_handle_s *wifi_handle,
wifi_manager_forget_ap_finished_cb user_cb, void *user_data)
{
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
-
- if (user_cb != NULL) {
- local_handle->forget_ap_cb = user_cb;
- local_handle->forget_ap_user_data = user_data;
- }
+ wifi_handle->forget_ap_cb = user_cb;
+ wifi_handle->forget_ap_user_data = user_data;
}
-static void __forget_ap_cb(wifi_manager_error_e result)
+static void __forget_ap_cb(wifi_manager_handle_s *wifi_handle, wifi_manager_error_e result)
{
- GSList *list;
+ if (wifi_handle->forget_ap_cb)
+ wifi_handle->forget_ap_cb(result, wifi_handle->forget_ap_user_data);
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
- if (_wifi_get_callback_count_from_handle_list(WIFI_MANAGER_FORGET_AP_CB)) {
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (local_handle->forget_ap_cb != NULL)
- local_handle->forget_ap_cb(result,
- local_handle->forget_ap_user_data);
+ wifi_handle->forget_ap_cb = NULL;
+ wifi_handle->forget_ap_user_data = NULL;
+}
- local_handle->forget_ap_cb = NULL;
- local_handle->forget_ap_user_data = NULL;
- }
+static void __rssi_level_changed_cb(wifi_manager_handle_s *wifi_handle,
+ net_rssi_info_s *rssi_info)
+{
+ if (wifi_handle->rssi_level_changed_cb) {
+ if (!g_strcmp0(wifi_handle->interface_name, rssi_info->ifname))
+ wifi_handle->rssi_level_changed_cb(rssi_info->rssi_level,
+ wifi_handle->rssi_level_changed_user_data);
}
}
-static void __raise_dpp_event_callback(wifi_manager_dpp_event_e event,
- wifi_manager_dpp_state_e state)
+static void __module_state_changed_cb(wifi_manager_handle_s *wifi_handle,
+ net_module_info_s *module_info)
{
- GSList *list;
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (!local_handle->dpp_event_cb)
- continue;
- local_handle->dpp_event_cb(event,
- state,
- g_p_dpp_current,
- local_handle->dpp_event_user_data);
+ if (wifi_handle->module_state_changed_cb) {
+ if (!g_strcmp0(wifi_handle->interface_name, module_info->ifname))
+ wifi_handle->module_state_changed_cb(module_info->status_uevent,
+ wifi_handle->module_state_changed_user_data);
}
}
-static void __dpp_uri_generated_cb(net_dpp_event_info_s *dpp_event_info)
+static void __raise_dpp_event_callback(wifi_manager_handle_s *wifi_handle,
+ wifi_manager_dpp_event_e event, wifi_manager_dpp_state_e state)
{
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
+ if (wifi_handle->dpp_event_cb)
+ wifi_handle->dpp_event_cb(event, state, g_p_dpp_current,
+ wifi_handle->dpp_event_user_data);
+}
+static void __dpp_uri_generated_cb(wifi_manager_handle_s *wifi_handle,
+ net_dpp_event_info_s *dpp_event_info)
+{
if (g_p_dpp_current) {
g_p_dpp_current->own_uri = g_strdup(dpp_event_info->own_uri);
g_p_dpp_current->own_id = dpp_event_info->own_id;
}
- __raise_dpp_event_callback(WIFI_MANAGER_DPP_EVENT_URI_GENERATED,
+ __raise_dpp_event_callback(wifi_handle, WIFI_MANAGER_DPP_EVENT_URI_GENERATED,
WIFI_MANAGER_DPP_STATE_NONE);
}
-static void __dpp_bootstrapped_cb(net_dpp_event_info_s *dpp_event_info)
+static void __dpp_bootstrapped_cb(wifi_manager_handle_s *wifi_handle,
+ net_dpp_event_info_s *dpp_event_info)
{
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
if (g_p_dpp_current) {
g_p_dpp_current->peer_id = dpp_event_info->peer_id;
g_p_dpp_current->state = WIFI_MANAGER_DPP_STATE_BOOTSTRAPPED;
}
- __raise_dpp_event_callback(WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
+ __raise_dpp_event_callback(wifi_handle, WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
WIFI_MANAGER_DPP_STATE_BOOTSTRAPPED);
}
-static void __dpp_awaiting_cb(net_dpp_event_info_s *dpp_event_info)
+static void __dpp_awaiting_cb(wifi_manager_handle_s *wifi_handle,
+ net_dpp_event_info_s *dpp_event_info)
{
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
if (g_p_dpp_current)
g_p_dpp_current->state = WIFI_MANAGER_DPP_STATE_AWAITING;
- __raise_dpp_event_callback(WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
+ __raise_dpp_event_callback(wifi_handle, WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
WIFI_MANAGER_DPP_STATE_AWAITING);
}
-static void __dpp_authenticating_cb(net_dpp_event_info_s *dpp_event_info)
+static void __dpp_authenticating_cb(wifi_manager_handle_s *wifi_handle,
+ net_dpp_event_info_s *dpp_event_info)
{
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
if (g_p_dpp_current)
g_p_dpp_current->state = WIFI_MANAGER_DPP_STATE_AUTHENTICATING;
- __raise_dpp_event_callback(WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
+ __raise_dpp_event_callback(wifi_handle, WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
WIFI_MANAGER_DPP_STATE_AUTHENTICATING);
}
-static void __dpp_auth_success_cb(net_dpp_event_info_s *dpp_event_info)
+static void __dpp_auth_success_cb(wifi_manager_handle_s *wifi_handle,
+ net_dpp_event_info_s *dpp_event_info)
{
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
if (g_p_dpp_current)
g_p_dpp_current->state = WIFI_MANAGER_DPP_STATE_AUTHENTICATED;
- __raise_dpp_event_callback(WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
+ __raise_dpp_event_callback(wifi_handle, WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
WIFI_MANAGER_DPP_STATE_AUTHENTICATED);
}
-static void __dpp_auth_failed_cb(net_dpp_event_info_s *dpp_event_info)
+static void __dpp_auth_failed_cb(wifi_manager_handle_s *wifi_handle,
+ net_dpp_event_info_s *dpp_event_info)
{
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
- __raise_dpp_event_callback(WIFI_MANAGER_DPP_EVENT_AUTH_FAILED,
+ __raise_dpp_event_callback(wifi_handle, WIFI_MANAGER_DPP_EVENT_AUTH_FAILED,
WIFI_MANAGER_DPP_STATE_NONE);
}
-static void __dpp_not_compatible_cb(net_dpp_event_info_s *dpp_event_info)
+static void __dpp_not_compatible_cb(wifi_manager_handle_s *wifi_handle,
+ net_dpp_event_info_s *dpp_event_info)
{
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
- __raise_dpp_event_callback(WIFI_MANAGER_DPP_EVENT_NOT_COMPATIBLE,
+ __raise_dpp_event_callback(wifi_handle, WIFI_MANAGER_DPP_EVENT_NOT_COMPATIBLE,
WIFI_MANAGER_DPP_STATE_NONE);
}
-static void __dpp_conf_failed_cb(net_dpp_event_info_s *dpp_event_info)
+static void __dpp_conf_failed_cb(wifi_manager_handle_s *wifi_handle,
+ net_dpp_event_info_s *dpp_event_info)
{
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
- __raise_dpp_event_callback(WIFI_MANAGER_DPP_EVENT_CONF_FAILED,
+ __raise_dpp_event_callback(wifi_handle, WIFI_MANAGER_DPP_EVENT_CONF_FAILED,
WIFI_MANAGER_DPP_STATE_NONE);
}
-static void __dpp_scan_peer_qr_cb(net_dpp_event_info_s *dpp_event_info)
+static void __dpp_scan_peer_qr_cb(wifi_manager_handle_s *wifi_handle,
+ net_dpp_event_info_s *dpp_event_info)
{
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
if (g_p_dpp_current)
g_p_dpp_current->state = WIFI_MANAGER_DPP_STATE_URI_REQUESTED;
- __raise_dpp_event_callback(WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
+ __raise_dpp_event_callback(wifi_handle, WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
WIFI_MANAGER_DPP_STATE_URI_REQUESTED);
}
-static void __dpp_network_id_cb(net_dpp_event_info_s *dpp_event_info)
+static void __dpp_network_id_cb(wifi_manager_handle_s *wifi_handle,
+ net_dpp_event_info_s *dpp_event_info)
{
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
if (g_p_dpp_current)
g_p_dpp_current->state = WIFI_MANAGER_DPP_STATE_CONFIGURED;
- __raise_dpp_event_callback(WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
+ __raise_dpp_event_callback(wifi_handle, WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
WIFI_MANAGER_DPP_STATE_CONFIGURED);
}
-static void __dpp_conf_sent_cb(net_dpp_event_info_s *dpp_event_info)
+static void __dpp_conf_sent_cb(wifi_manager_handle_s *wifi_handle,
+ net_dpp_event_info_s *dpp_event_info)
{
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
if (g_p_dpp_current)
g_p_dpp_current->state = WIFI_MANAGER_DPP_STATE_CONFIGURING;
- __raise_dpp_event_callback(WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
+ __raise_dpp_event_callback(wifi_handle, WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
WIFI_MANAGER_DPP_STATE_CONFIGURING);
}
-static void __dpp_conf_received_cb(net_dpp_event_info_s *dpp_event_info)
+static void __dpp_conf_received_cb(wifi_manager_handle_s *wifi_handle,
+ net_dpp_event_info_s *dpp_event_info)
{
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
if (g_p_dpp_current)
g_p_dpp_current->state = WIFI_MANAGER_DPP_STATE_CONFIGURED;
- __raise_dpp_event_callback(WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
+ __raise_dpp_event_callback(wifi_handle, WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
WIFI_MANAGER_DPP_STATE_CONFIGURED);
}
-static void __dpp_failed_cb(net_dpp_event_info_s *dpp_event_info)
+static void __dpp_failed_cb(wifi_manager_handle_s *wifi_handle,
+ net_dpp_event_info_s *dpp_event_info)
{
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
if (g_p_dpp_current) {
g_p_dpp_current->peer_id = 0;
g_p_dpp_current->own_id = 0;
g_p_dpp_current->state = WIFI_MANAGER_DPP_STATE_NONE;
}
- __raise_dpp_event_callback(WIFI_MANAGER_DPP_EVENT_REQUEST_FAILED,
+ __raise_dpp_event_callback(wifi_handle, WIFI_MANAGER_DPP_EVENT_REQUEST_FAILED,
WIFI_MANAGER_DPP_STATE_NONE);
g_p_dpp_current = NULL;
}
-static void __dpp_removed_cb(net_dpp_event_info_s *dpp_event_info)
+static void __dpp_removed_cb(wifi_manager_handle_s *wifi_handle,
+ net_dpp_event_info_s *dpp_event_info)
{
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
if (g_p_dpp_current) {
g_p_dpp_current->peer_id = 0;
g_p_dpp_current->own_id = 0;
g_p_dpp_current->state = WIFI_MANAGER_DPP_STATE_NONE;
}
- __raise_dpp_event_callback(WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
+ __raise_dpp_event_callback(wifi_handle, WIFI_MANAGER_DPP_EVENT_STATE_CHANGED,
WIFI_MANAGER_DPP_STATE_NONE);
g_p_dpp_current = NULL;
wifi_manager_error_e result = WIFI_MANAGER_ERROR_NONE;
bool is_profile_exists = false;
GSList *list = NULL;
+ wifi_manager_handle_s *wifi_handle = user_data;
switch (event_cb->Event) {
case NET_EVENT_OPEN_RSP:
__convert_ap_error_type_to_string(result));
if (is_requested)
- __connected_cb(result);
+ __connected_cb(wifi_handle, result);
switch (event_cb->Error) {
case NET_ERR_NONE:
if (event_cb->Datalength == sizeof(net_profile_info_s))
prof_info_p = (net_profile_info_s *)event_cb->Data;
- __state_changed_cb(event_cb->ProfileName, prof_info_p,
+ __state_changed_cb(wifi_handle, event_cb->ProfileName, prof_info_p,
WIFI_MANAGER_CONNECTION_STATE_CONNECTED);
return;
case NET_ERR_ACTIVE_CONNECTION_EXISTS:
break;
}
- if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE) {
- __state_changed_cb(event_cb->ProfileName, &prof_info,
+ if (net_get_profile_info(wifi_handle->network_info,
+ event_cb->ProfileName, &prof_info) == NET_ERR_NONE) {
+ __state_changed_cb(wifi_handle, event_cb->ProfileName, &prof_info,
WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED);
/* Free internal GSList */
prof_info.bssid_list = NULL;
}
} else
- __state_changed_cb(event_cb->ProfileName, NULL,
+ __state_changed_cb(wifi_handle, event_cb->ProfileName, NULL,
WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED);
break;
__convert_ap_error_type_to_string(result));
if (is_requested)
- __disconnected_cb(result);
+ __disconnected_cb(wifi_handle, result);
switch (event_cb->Error) {
case NET_ERR_NONE:
- if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE) {
- __state_changed_cb(event_cb->ProfileName, &prof_info,
+ if (net_get_profile_info(wifi_handle->network_info,
+ event_cb->ProfileName, &prof_info) == NET_ERR_NONE) {
+ __state_changed_cb(wifi_handle, event_cb->ProfileName, &prof_info,
WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED);
/* Free internal GSList */
prof_info.bssid_list = NULL;
}
} else
- __state_changed_cb(event_cb->ProfileName, NULL,
+ __state_changed_cb(wifi_handle, event_cb->ProfileName, NULL,
WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED);
- WIFI_LOG(WIFI_INFO, "Connection close succeeded!\n");
+ WIFI_LOG(WIFI_INFO, "Connection close succeeded!");
/* Checking if disconnection request was sent when WPS PBC connection
* was requested, if true then start WPS PBC connection request */
- if (is_disconnect_wps_pbc) {
+ if (wifi_handle->is_disconnect_wps_pbc) {
net_wifi_wps_info_s wps_info;
memset(&wps_info, 0, sizeof(net_wifi_wps_info_s));
wps_info.type = WIFI_WPS_PBC;
- if (net_wifi_enroll_wps_without_ssid(&wps_info) != NET_ERR_NONE)
- __connected_cb(WIFI_MANAGER_ERROR_OPERATION_FAILED);
- is_disconnect_wps_pbc = false;
+ if (net_wifi_enroll_wps_without_ssid(wifi_handle->network_info, &wps_info) != NET_ERR_NONE)
+ __connected_cb(wifi_handle, WIFI_MANAGER_ERROR_OPERATION_FAILED);
+ wifi_handle->is_disconnect_wps_pbc = false;
}
/* Checking if disconnection request was sent when WPS PIN connection
* was requested, if true then start WPS PBC connection request */
- else if (is_disconnect_wps_pin) {
+ else if (wifi_handle->is_disconnect_wps_pin) {
net_wifi_wps_info_s wps_info;
memset(&wps_info, 0, sizeof(net_wifi_wps_info_s));
wps_info.type = WIFI_WPS_PIN;
- if (net_wifi_enroll_wps_without_ssid(&wps_info) != NET_ERR_NONE)
- __connected_cb(WIFI_MANAGER_ERROR_OPERATION_FAILED);
- is_disconnect_wps_pin = false;
+ if (net_wifi_enroll_wps_without_ssid(wifi_handle->network_info, &wps_info) != NET_ERR_NONE)
+ __connected_cb(wifi_handle, WIFI_MANAGER_ERROR_OPERATION_FAILED);
+ wifi_handle->is_disconnect_wps_pin = false;
}
return;
WIFI_LOG(WIFI_INFO, "state: %s", __convert_ap_state_to_string(ap_state));
WIFI_LOG(WIFI_INFO, "profile name: %s", event_cb->ProfileName);
- if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE) {
- __state_changed_cb(event_cb->ProfileName, &prof_info, ap_state);
+ if (net_get_profile_info(wifi_handle->network_info,
+ event_cb->ProfileName, &prof_info) == NET_ERR_NONE) {
+ __state_changed_cb(wifi_handle, event_cb->ProfileName, &prof_info, ap_state);
/* Free internal GSList */
if (prof_info.vsie_list) {
}
} else if (ap_state == WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED) {
net_profile_info_s *profile = NULL;
- for (list = profile_iterator; list; list = list->next) {
+ for (list = wifi_handle->profile_iterator; list; list = list->next) {
profile = (net_profile_info_s *)list->data;
if (!g_strcmp0(event_cb->ProfileName, profile->ProfileName)) {
is_profile_exists = true;
if (is_profile_exists == true) {
profile->ProfileState = *profile_state;
- __state_changed_cb(event_cb->ProfileName, profile, ap_state);
+ __state_changed_cb(wifi_handle, event_cb->ProfileName, profile, ap_state);
} else
- __state_changed_cb(event_cb->ProfileName,
- NULL, ap_state);
+ __state_changed_cb(wifi_handle, event_cb->ProfileName, NULL, ap_state);
} else
- __state_changed_cb(event_cb->ProfileName, NULL, ap_state);
+ __state_changed_cb(wifi_handle, event_cb->ProfileName, NULL, ap_state);
break;
case NET_EVENT_WIFI_SCAN_RSP:
case NET_EVENT_WIFI_SCAN_IND:
- __scan_cb(event_cb, is_requested);
+ __scan_cb(wifi_handle, event_cb, is_requested);
break;
case NET_EVENT_WIFI_SPECIFIC_SCAN_RSP:
- WIFI_LOG(WIFI_INFO, "Got Wi-Fi specific scan RSP\n");
- __specific_scan_cb(event_cb);
+ WIFI_LOG(WIFI_INFO, "Got Wi-Fi specific scan RSP");
+ __specific_scan_cb(wifi_handle, event_cb);
break;
case NET_EVENT_WIFI_SPECIFIC_SCAN_IND:
- WIFI_LOG(WIFI_INFO, "Got Wi-Fi specific scan IND\n");
- __specific_scan_cb(event_cb);
+ WIFI_LOG(WIFI_INFO, "Got Wi-Fi specific scan IND");
+ __specific_scan_cb(wifi_handle, event_cb);
break;
case NET_EVENT_WIFI_BSSID_SCAN_IND:
- WIFI_LOG(WIFI_INFO, "Got BSSID scan done IND\n");
- __bssid_scan_cb(event_cb);
+ WIFI_LOG(WIFI_INFO, "Got BSSID scan done IND");
+ __bssid_scan_cb(wifi_handle, event_cb);
break;
case NET_EVENT_WIFI_IP_CONFLICT_IND:
- WIFI_LOG(WIFI_INFO, "Got ip conflict event IND\n"); //LCOV_EXCL_LINE
- __ip_conflict_cb(event_cb); //LCOV_EXCL_LINE
+ WIFI_LOG(WIFI_INFO, "Got ip conflict event IND"); //LCOV_EXCL_LINE
+ __ip_conflict_cb(wifi_handle, event_cb); //LCOV_EXCL_LINE
break;
case NET_EVENT_WIFI_NETLINK_SCAN_IND:
- WIFI_LOG(WIFI_INFO, "Got NETLINK scan done IND\n"); //LCOV_EXCL_LINE
- __netlink_scan_cb(event_cb); //LCOV_EXCL_LINE
+ WIFI_LOG(WIFI_INFO, "Got NETLINK scan done IND"); //LCOV_EXCL_LINE
+ __netlink_scan_cb(wifi_handle, event_cb); //LCOV_EXCL_LINE
break;
case NET_EVENT_WIFI_SCAN_CHANGED:
- WIFI_LOG(WIFI_INFO, "Got Wi-Fi ScanChanged event\n");
+ WIFI_LOG(WIFI_INFO, "Got Wi-Fi ScanChanged event");
wifi_manager_scan_state_e *scan_state = (wifi_manager_scan_state_e *)event_cb->Data;
- __scan_changed_cb(*scan_state);
+ __scan_changed_cb(wifi_handle, *scan_state);
break;
case NET_EVENT_WIFI_POWER_RSP:
is_requested = true;
/* fall through */
case NET_EVENT_WIFI_POWER_IND:
- __power_on_off_cb(event_cb, is_requested);
+ __power_on_off_cb(wifi_handle, event_cb, is_requested);
break;
case NET_EVENT_WIFI_TDLS_DISCOVERED_IND:
WIFI_LOG(WIFI_INFO, "Received TDLS Discover Ind"); //LCOV_EXCL_LINE
- __tdls_discovered_cb(event_cb); //LCOV_EXCL_LINE
+ __tdls_discovered_cb(wifi_handle, event_cb); //LCOV_EXCL_LINE
break;
case NET_EVENT_WIFI_TDLS_CONNECTED_IND:
WIFI_LOG(WIFI_INFO, "Received TDLS Connected Ind"); //LCOV_EXCL_LINE
- __tdls_state_changed_cb(WIFI_MANAGER_TDLS_STATE_CONNECTED, event_cb); //LCOV_EXCL_LINE
+ __tdls_state_changed_cb(wifi_handle, WIFI_MANAGER_TDLS_STATE_CONNECTED, event_cb); //LCOV_EXCL_LINE
break;
case NET_EVENT_WIFI_TDLS_DISCONNECTED_IND:
WIFI_LOG(WIFI_INFO, "Received TDLS Disconnected Ind"); //LCOV_EXCL_LINE
- __tdls_state_changed_cb(WIFI_MANAGER_TDLS_STATE_DISCONNECTED, event_cb); //LCOV_EXCL_LINE
+ __tdls_state_changed_cb(wifi_handle, WIFI_MANAGER_TDLS_STATE_DISCONNECTED, event_cb); //LCOV_EXCL_LINE
break;
case NET_EVENT_WIFI_MULTI_SCAN_RSP:
- WIFI_LOG(WIFI_INFO, "Got Wi-Fi multi scan RSP\n"); //LCOV_EXCL_LINE
- __multi_scan_cb(event_cb); //LCOV_EXCL_LINE
+ WIFI_LOG(WIFI_INFO, "Got Wi-Fi multi scan RSP"); //LCOV_EXCL_LINE
+ __multi_scan_cb(wifi_handle, event_cb); //LCOV_EXCL_LINE
break;
case NET_EVENT_WIFI_MULTI_SCAN_IND:
- WIFI_LOG(WIFI_INFO, "Got Wi-Fi multi scan IND\n"); //LCOV_EXCL_LINE
- __multi_scan_cb(event_cb); //LCOV_EXCL_LINE
+ WIFI_LOG(WIFI_INFO, "Got Wi-Fi multi scan IND"); //LCOV_EXCL_LINE
+ __multi_scan_cb(wifi_handle, event_cb); //LCOV_EXCL_LINE
break;
case NET_EVENT_WIFI_FORGET_AP_IND:
- WIFI_LOG(WIFI_INFO, "Got Wi-Fi forget AP IND\n"); //LCOV_EXCL_LINE
- __forget_ap_cb(event_cb->Error); //LCOV_EXCL_LINE
+ WIFI_LOG(WIFI_INFO, "Got Wi-Fi forget AP IND"); //LCOV_EXCL_LINE
+ __forget_ap_cb(wifi_handle, event_cb->Error); //LCOV_EXCL_LINE
+ break;
+ case NET_EVENT_WIFI_RSSI_CHANGED:
+ case NET_EVENT_WIFI_RSSI_LEVEL_CHANGED:
+ __rssi_level_changed_cb(wifi_handle, (net_rssi_info_s *)event_cb->Data);
+ break;
+ case NET_EVENT_WIFI_MODULE_STATE_CHANGED:
+ __module_state_changed_cb(wifi_handle, (net_module_info_s *)event_cb->Data);
break;
case NET_EVENT_WIFI_DPP_URI_GENERATED:
- __dpp_uri_generated_cb((net_dpp_event_info_s *)event_cb->Data);
+ __dpp_uri_generated_cb(wifi_handle, (net_dpp_event_info_s *)event_cb->Data);
break;
case NET_EVENT_WIFI_DPP_BOOTSTRAPPED:
- __dpp_bootstrapped_cb((net_dpp_event_info_s *)event_cb->Data);
+ __dpp_bootstrapped_cb(wifi_handle, (net_dpp_event_info_s *)event_cb->Data);
break;
case NET_EVENT_WIFI_DPP_AWAITING:
- __dpp_awaiting_cb((net_dpp_event_info_s *)event_cb->Data);
+ __dpp_awaiting_cb(wifi_handle, (net_dpp_event_info_s *)event_cb->Data);
break;
case NET_EVENT_WIFI_DPP_AUTHENTICATING:
- __dpp_authenticating_cb((net_dpp_event_info_s *)event_cb->Data);
+ __dpp_authenticating_cb(wifi_handle, (net_dpp_event_info_s *)event_cb->Data);
break;
case NET_EVENT_WIFI_DPP_AUTH_SUCCESS:
- __dpp_auth_success_cb((net_dpp_event_info_s *)event_cb->Data);
+ __dpp_auth_success_cb(wifi_handle, (net_dpp_event_info_s *)event_cb->Data);
break;
case NET_EVENT_WIFI_DPP_AUTH_FAILED:
- __dpp_auth_failed_cb((net_dpp_event_info_s *)event_cb->Data);
+ __dpp_auth_failed_cb(wifi_handle, (net_dpp_event_info_s *)event_cb->Data);
break;
case NET_EVENT_WIFI_DPP_NOT_COMPATIBLE:
- __dpp_not_compatible_cb((net_dpp_event_info_s *)event_cb->Data);
+ __dpp_not_compatible_cb(wifi_handle, (net_dpp_event_info_s *)event_cb->Data);
break;
case NET_EVENT_WIFI_DPP_CONF_FAILED:
- __dpp_conf_failed_cb((net_dpp_event_info_s *)event_cb->Data);
+ __dpp_conf_failed_cb(wifi_handle, (net_dpp_event_info_s *)event_cb->Data);
break;
case NET_EVENT_WIFI_DPP_SCAN_PEER_QR:
- __dpp_scan_peer_qr_cb((net_dpp_event_info_s *)event_cb->Data);
+ __dpp_scan_peer_qr_cb(wifi_handle, (net_dpp_event_info_s *)event_cb->Data);
break;
case NET_EVENT_WIFI_DPP_NETWORK_ID:
- __dpp_network_id_cb((net_dpp_event_info_s *)event_cb->Data);
+ __dpp_network_id_cb(wifi_handle, (net_dpp_event_info_s *)event_cb->Data);
break;
case NET_EVENT_WIFI_DPP_CONF_SENT:
- __dpp_conf_sent_cb((net_dpp_event_info_s *)event_cb->Data);
+ __dpp_conf_sent_cb(wifi_handle, (net_dpp_event_info_s *)event_cb->Data);
break;
case NET_EVENT_WIFI_DPP_CONF_RECEIVED:
- __dpp_conf_received_cb((net_dpp_event_info_s *)event_cb->Data);
+ __dpp_conf_received_cb(wifi_handle, (net_dpp_event_info_s *)event_cb->Data);
break;
case NET_EVENT_WIFI_DPP_FAILED:
- __dpp_failed_cb((net_dpp_event_info_s *)event_cb->Data);
+ __dpp_failed_cb(wifi_handle, (net_dpp_event_info_s *)event_cb->Data);
break;
case NET_EVENT_WIFI_DPP_REMOVED:
- __dpp_removed_cb((net_dpp_event_info_s *)event_cb->Data);
+ __dpp_removed_cb(wifi_handle, (net_dpp_event_info_s *)event_cb->Data);
break;
default:
break;
}
}
-int _wifi_init(void)
+int _wifi_init(wifi_manager_h wifi, const char *ifname)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_register_client_ext((net_event_cb)_wifi_evt_cb, NULL);
+ rv = net_register_client_ext(&(wifi_handle->network_info),
+ ifname, (net_event_cb)_wifi_evt_cb, wifi);
if (rv != NET_ERR_NONE && rv != NET_ERR_APP_ALREADY_REGISTERED) {
WIFI_LOG(WIFI_ERROR, "Failed to register client [%d]", rv); //LCOV_EXCL_LINE
return rv; //LCOV_EXCL_LINE
}
- return NET_ERR_NONE;
+ g_strlcpy(wifi_handle->interface_name,
+ wifi_handle->network_info->interface_name, NET_WLAN_IF_NAME_LEN + 1);
+ wifi_handle->network_info->wifi_handle = wifi_handle;
+
+ return WIFI_MANAGER_ERROR_NONE;
}
int _wifi_create_handle(wifi_manager_h *wifi)
{
- *wifi = g_try_malloc0(sizeof(wifi_manager_handle_s));
-
- if (*wifi != NULL)
- WIFI_LOG(WIFI_INFO, "New handle create[%p]", *wifi);
- else {
+ wifi_manager_handle_s *wifi_handle = g_try_malloc0(sizeof(wifi_manager_handle_s));
+ if (wifi_handle == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to create wifi handle"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
}
+ *wifi = wifi_handle;
+
+ WIFI_LOG(WIFI_INFO, "New handle create[%p]", *wifi);
+
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_add_to_handle_list(wifi_manager_h *wifi)
+void _wifi_add_to_handle_list(wifi_manager_h *wifi)
{
wifi_manager_handle_list = g_slist_append(wifi_manager_handle_list, *wifi);
- return WIFI_MANAGER_ERROR_NONE;
}
void _wifi_remove_from_handle_list(wifi_manager_h wifi)
wifi = NULL;
}
+int _wifi_length_from_handle_list(void)
+{
+ return g_slist_length(wifi_manager_handle_list);
+}
+
bool _wifi_find_from_handle_list(wifi_manager_h wifi)
{
if (g_slist_find(wifi_manager_handle_list, wifi) != NULL)
return false;
}
-int _wifi_get_count_from_handle_list(void)
-{
- return ((int)g_slist_length(wifi_manager_handle_list));
-}
-
-int _wifi_get_callback_count_from_handle_list(wifi_manager_handle_cb_e e)
-{
- GSList *list;
- int count = 0;
-
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- switch (e) {
- case WIFI_DEVICE_STATE_CB:
- if (local_handle->device_state_cb)
- ++count;
- break;
- case WIFI_BG_SCAN_CB:
- if (local_handle->bg_scan_cb)
- ++count;
- break;
- case WIFI_SCAN_CHANGED_CB:
- if (local_handle->scan_changed_cb)
- ++count;
- break;
- case WIFI_SCAN_REQUEST_CB:
- if (local_handle->scan_request_cb)
- ++count;
- break;
- case WIFI_SPECIFIC_SCAN_CB:
- if (local_handle->specific_scan_cb)
- ++count;
- break;
- case WIFI_MANAGER_CONNECTION_STATE_CB:
- if (local_handle->connection_state_cb)
- ++count;
- break;
- case WIFI_ACTIVATED_CB:
- if (local_handle->activated_cb)
- ++count;
- break;
- case WIFI_DEACTIVATED_CB:
- if (local_handle->deactivated_cb)
- ++count;
- break;
- case WIFI_CONNECTED_CB:
- if (local_handle->connected_cb)
- ++count;
- break;
- case WIFI_DISCONNECTED_CB:
- if (local_handle->disconnected_cb)
- ++count;
- break;
- case WIFI_MANAGER_RSSI_LEVEL_CHANGED_CB:
- if (local_handle->rssi_level_changed_cb)
- ++count;
- break;
- case WIFI_MANAGER_TDLS_STATE_CHANGED_CB:
- if (local_handle->tdls_state_changed_cb)
- ++count;
- break;
- case WIFI_MANAGER_TDLS_DISCOVERED_CB:
- if (local_handle->tdls_discovered_cb)
- ++count;
- break;
- case WIFI_BSSID_SCAN_CB:
- if (local_handle->bssid_scan_cb)
- ++count;
- break;
- case WIFI_IP_CONFLICT_CB:
- if (local_handle->ip_conflict_cb)
- ++count;
- break;
- case WIFI_MULTI_SCAN_CB:
- if (local_handle->multi_scan_cb)
- ++count;
- break;
- case WIFI_NETLINK_SCAN_CB:
- if (local_handle->netlink_scan_cb)
- ++count;
- break;
- case WIFI_MANAGER_FORGET_AP_CB:
- if (local_handle->forget_ap_cb)
- ++count;
- break;
- case WIFI_MANAGER_DPP_EVENT_CB:
- if (local_handle->dpp_event_cb)
- ++count;
- break;
- default:
- break;
- }
- }
-
- return count;
-}
-
void config_free(gpointer data)
{
wifi_config_s *h = (wifi_config_s *)data;
g_free(p_dpp);
}
-bool _wifi_deinit(void)
+void _wifi_deinit(wifi_manager_h wifi)
{
- int rv = net_deregister_client_ext();
- if (rv != NET_ERR_NONE && rv != NET_ERR_APP_NOT_REGISTERED)
- return false;
+ wifi_manager_handle_s *wifi_handle = wifi;
- __clear_profile_list(&profile_iterator);
- __clear_profile_list(&specific_profile_iterator);
- __clear_profile_list(&bss_profile_iterator);
+ net_deregister_client_ext(wifi_handle->network_info);
- g_slist_free_full(ap_handle_list, g_free);
- ap_handle_list = NULL;
+ __clear_profile_list(&(wifi_handle->ap_handle_list));
+ __clear_profile_list(&(wifi_handle->profile_iterator));
+ __clear_profile_list(&(wifi_handle->specific_profile_iterator));
+ __clear_profile_list(&(wifi_handle->bss_profile_iterator));
- g_slist_free_full(config_handle_list, g_free);
- config_handle_list = NULL;
-
- __clear_config_list(&config_iterator);
+ __clear_config_list(&(wifi_handle->config_handle_list));
+ __clear_config_list(&(wifi_handle->config_iterator));
+}
+void _wifi_clear_profile_list(void)
+{
g_slist_free_full(dpp_handle_list, __free_dpp);
g_p_dpp_current = NULL;
-
- return true;
}
//LCOV_EXCL_START
-void _wifi_set_cs_tid(int tid)
+void _wifi_set_cs_tid(wifi_manager_h wifi, int tid)
{
- net_set_cs_tid(tid);
+ wifi_manager_handle_s *wifi_handle = wifi;
+
+ net_set_cs_tid(wifi_handle->network_info, tid);
}
void _wifi_unset_cs_tid(int tid)
gboolean wifi_picker_test, void *user_data)
{
int rv = NET_ERR_NONE;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_power_on(wifi_picker_test);
+ rv = net_wifi_power_on(wifi_handle->network_info, wifi_picker_test);
rv = __convert_to_ap_error_type(rv);
if (rv == WIFI_MANAGER_ERROR_NONE)
- __set_activated_cb(wifi, callback, user_data);
+ __set_activated_cb(wifi_handle, callback, user_data);
+
return rv;
}
int _wifi_deactivate(wifi_manager_h wifi, wifi_manager_deactivated_cb callback, void *user_data)
{
int rv = NET_ERR_NONE;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_power_off();
+ rv = net_wifi_power_off(wifi_handle->network_info);
rv = __convert_to_ap_error_type(rv);
if (rv == WIFI_MANAGER_ERROR_NONE)
- __set_deactivated_cb(wifi, callback, user_data);
+ __set_deactivated_cb(wifi_handle, callback, user_data);
return rv;
}
+int _wifi_get_mac_address(wifi_manager_h wifi, char **mac_address)
+{
+ FILE *fp = NULL;
+ char mac_path[WIFI_MAC_ADDR_PATH_LEN];
+ char buf[WIFI_MAC_ADDR_LEN + 1];
+ wifi_manager_handle_s *wifi_handle = wifi;
+
+ g_snprintf(mac_path, WIFI_MAC_ADDR_PATH_LEN, WIFI_MAC_ADDR_PATH, wifi_handle->interface_name);
+
+ if (access(mac_path, F_OK) == 0)
+ fp = fopen(mac_path, "r");
+
+ if (fp) {
+ if (fgets(buf, sizeof(buf), fp) == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get MAC info from %s", mac_path); //LCOV_EXCL_LINE
+ fclose(fp); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ WIFI_LOG(WIFI_INFO, "%s : %s", mac_path, buf);
+
+ *mac_address = g_strdup(buf);
+ fclose(fp);
+ } else {
+ *mac_address = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
+
+ if (*mac_address == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get vconf" //LCOV_EXCL_LINE
+ " from %s", VCONFKEY_WIFI_BSSID_ADDRESS);
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ if (strlen(*mac_address) == 0) {
+ WIFI_LOG(WIFI_ERROR, "Mac address is invalid" //LCOV_EXCL_LINE
+ " from %s", VCONFKEY_WIFI_BSSID_ADDRESS);
+ g_free(*mac_address); //LCOV_EXCL_LINE
+ *mac_address = NULL; //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
-int _wifi_ip_conflict_detect_enable_set(bool detect)
+int _wifi_ip_conflict_detect_enable_set(wifi_manager_h wifi, bool detect)
{
int rv = NET_ERR_NONE;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_set_ip_conflict_detect_mode(detect);
+ rv = net_set_ip_conflict_detect_mode(wifi_handle->network_info, detect);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
-bool _wifi_check_ap_validity(wifi_manager_ap_h ap_h)
+bool _wifi_check_ap_validity(net_profile_info_s *ap_info)
{
- GSList *list = NULL;
+ wifi_manager_handle_s *wifi_handle;
+ network_info_s *network_info;
- if (ap_h == NULL)
+ if (ap_info == NULL)
return false;
- for (list = ap_handle_list; list; list = list->next)
- if (ap_h == list->data) return true;
+ network_info = ap_info->network_info;
+ if (network_info == NULL)
+ return false;
- for (list = profile_iterator; list; list = list->next)
- if (ap_h == list->data) return true;
+ wifi_handle = network_info->wifi_handle;
+ if (wifi_handle == NULL)
+ return false;
- for (list = specific_profile_iterator; list; list = list->next)
- if (ap_h == list->data) return true;
+ if (_wifi_find_from_handle_list(wifi_handle) == false)
+ return false;
- for (list = bss_profile_iterator; list; list = list->next)
- if (ap_h == list->data) return true;
+ if (g_slist_find(wifi_handle->ap_handle_list, ap_info) != NULL)
+ return true;
+
+ if (g_slist_find(wifi_handle->profile_iterator, ap_info) != NULL)
+ return true;
+
+ if (g_slist_find(wifi_handle->specific_profile_iterator, ap_info) != NULL)
+ return true;
+
+ if (g_slist_find(wifi_handle->bss_profile_iterator, ap_info) != NULL)
+ return true;
return false;
}
-void _wifi_add_to_ap_list(wifi_manager_ap_h ap_h)
+void _wifi_add_to_ap_list(net_profile_info_s *ap_info)
{
- ap_handle_list = g_slist_append(ap_handle_list, ap_h);
+ network_info_s *network_info;
+ wifi_manager_handle_s *wifi_handle;
+
+ network_info = ap_info->network_info;
+ if (network_info == NULL)
+ return;
+
+ wifi_handle = network_info->wifi_handle;
+ if (wifi_handle) {
+ wifi_handle->ap_handle_list =
+ g_slist_append(wifi_handle->ap_handle_list, ap_info);
+ }
}
-void _wifi_remove_from_ap_list(wifi_manager_ap_h ap_h)
+void _wifi_remove_from_ap_list(net_profile_info_s *ap_info)
{
- ap_handle_list = g_slist_remove(ap_handle_list, ap_h);
- g_free(ap_h);
+ network_info_s *network_info;
+ wifi_manager_handle_s *wifi_handle;
+
+ network_info = ap_info->network_info;
+ if (network_info == NULL)
+ return;
+
+ wifi_handle = network_info->wifi_handle;
+ if (wifi_handle) {
+ wifi_handle->ap_handle_list =
+ g_slist_remove(wifi_handle->ap_handle_list, ap_info);
+ }
}
bool _wifi_check_profile_name_validity(const char *profile_name)
return true;
}
-int _wifi_get_wifi_device_state(wifi_manager_device_state_e *device_state)
+int _wifi_get_wifi_device_state(wifi_manager_h wifi, wifi_manager_device_state_e *device_state)
{
net_tech_info_s tech_info;
+ wifi_manager_handle_s *wifi_handle = wifi;
int rv = NET_ERR_NONE;
- rv = net_get_technology_properties(&tech_info);
+ rv = net_get_technology_properties(wifi_handle->network_info, &tech_info);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_get_wifi_state(wifi_manager_connection_state_e *connection_state)
+int _wifi_get_wifi_state(wifi_manager_h wifi, wifi_manager_connection_state_e *connection_state)
{
+ wifi_manager_handle_s *wifi_handle = wifi;
wifi_tech_state_e tech_state = WIFI_TECH_UNKNOWN;
wifi_service_state_e service_state = WIFI_SERVICE_STATE_UNKNOWN;
- tech_state = wifi_state_get_technology_state();
- service_state = _wifi_get_service_state();
+ tech_state = net_get_technology_state(wifi_handle->network_info);
+ service_state = _wifi_get_service_state(wifi_handle);
/* LCOV_EXCL_START */
if (tech_state == WIFI_TECH_UNKNOWN)
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_get_intf_name(char** name)
+void _wifi_get_intf_name(wifi_manager_h wifi, char **name)
{
- int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- if ((int)g_slist_length(profile_iterator) == 0) {
- rv = __update_profile_iterator();
- if (rv == NET_ERR_ACCESS_DENIED) {
- WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
- return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
- }
- }
-
- if ((int)g_slist_length(profile_iterator) == 0) {
- WIFI_LOG(WIFI_ERROR, "There is no AP"); //LCOV_EXCL_LINE
- return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
- }
-
- net_profile_info_s *profile = (net_profile_info_s *)profile_iterator->data;
- *name = strdup(profile->net_info.DevName);
- if (*name == NULL)
- return WIFI_MANAGER_ERROR_OUT_OF_MEMORY;
-
- return WIFI_MANAGER_ERROR_NONE;
+ *name = g_strdup(wifi_handle->interface_name);
}
-int _wifi_ip_conflict_detect_is_enabled(bool *state)
+int _wifi_ip_conflict_detect_is_enabled(wifi_manager_h wifi, bool *state)
{
int rv;
gboolean is_enabled = FALSE;
- rv = net_ip_conflict_detect_is_enabled(&is_enabled);
+ wifi_manager_handle_s *wifi_handle = wifi;
+
+ rv = net_ip_conflict_detect_is_enabled(wifi_handle->network_info, &is_enabled);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
wifi_manager_scan_finished_cb callback, void *user_data)
{
int rv;
- rv = net_scan_wifi();
+ wifi_manager_handle_s *wifi_handle = wifi;
+ rv = net_scan_wifi(wifi_handle->network_info);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
} else if (rv == NET_ERR_INVALID_OPERATION) {
return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
} else if (rv == NET_ERR_NONE) {
- __set_scan_cb(wifi, callback, user_data);
+ __set_scan_cb(wifi_handle, callback, user_data);
return WIFI_MANAGER_ERROR_NONE;
}
return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
-int _wifi_get_scan_state(wifi_manager_scan_state_e *scan_state)
+int _wifi_get_scan_state(wifi_manager_h wifi, wifi_manager_scan_state_e *scan_state)
{
int rv;
int state = 0;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_get_scan_state(&state);
-
+ rv = net_wifi_get_scan_state(wifi_handle->network_info, &state);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
wifi_manager_scan_finished_cb callback, void *user_data)
{
int rv;
- rv = net_specific_scan_wifi(essid);
+ wifi_manager_handle_s *wifi_handle = wifi;
+ rv = net_specific_scan_wifi(wifi_handle->network_info, essid);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
} else if (rv == NET_ERR_INVALID_OPERATION) {
return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
} else if (rv == NET_ERR_NONE) {
- g_strlcpy(specific_profile_essid, essid, NET_WLAN_ESSID_LEN+1);
- __set_specific_scan_cb(wifi, callback, user_data);
+ g_strlcpy(wifi_handle->specific_scan_essid, essid, NET_WLAN_ESSID_LEN + 1);
+ __set_specific_scan_cb(wifi_handle, callback, user_data);
return WIFI_MANAGER_ERROR_NONE;
}
bool is_available = false;
wifi_manager_security_type_e type = 0;
net_profile_info_s *profile_info = NULL;
+ wifi_manager_handle_s *wifi_handle = wifi;
GSList *list;
- rv = __update_profile_iterator();
+ rv = __update_profile_iterator(wifi_handle);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
}
- if ((int)g_slist_length(profile_iterator) == 0) {
+ if ((int)g_slist_length(wifi_handle->profile_iterator) == 0) {
WIFI_LOG(WIFI_WARN, "There is no AP"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NONE; //LCOV_EXCL_LINE
}
- for (list = profile_iterator; list; list = list->next) {
+ for (list = wifi_handle->profile_iterator; list; list = list->next) {
net_profile_info_s *prof_info = (net_profile_info_s *)list->data;
switch (prof_info->security_info.sec_mode) {
case WLAN_SEC_MODE_NONE:
is_available = true;
profile_info = (wifi_manager_ap_h)prof_info;
}
- } else if (!g_strcmp0(prof_info->essid,
- essid) && type == sec_type) {
+ } else if (!g_strcmp0(prof_info->essid, essid) && type == sec_type) {
WIFI_LOG(WIFI_INFO, "AP %s not hidden", essid);
rv = wifi_manager_ap_set_passphrase((wifi_manager_ap_h)prof_info,
passphrase);
{
int rv;
wifi_manager_device_state_e device_state;
+ wifi_manager_handle_s *wifi_handle = wifi;
int activated = -1;
int flight_mode = -1;
return WIFI_MANAGER_ERROR_OPERATION_FAILED;
}
- rv = _wifi_get_wifi_device_state(&device_state);
+ rv = _wifi_get_wifi_device_state(wifi, &device_state);
if (rv == WIFI_MANAGER_ERROR_NONE) {
if (WIFI_MANAGER_DEVICE_STATE_DEACTIVATED == device_state)
activated = 0;
return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
}
- rv = net_bssid_scan_wifi(activated);
+ rv = net_bssid_scan_wifi(wifi_handle->network_info, activated);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
} else if (rv == NET_ERR_INVALID_OPERATION) {
return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
} else if (rv == NET_ERR_NONE) {
- __set_bssid_scan_cb(wifi, callback, user_data);
+ __set_bssid_scan_cb(wifi_handle, callback, user_data);
return WIFI_MANAGER_ERROR_NONE;
}
bool enable;
int is_on = 0;
int vconf_type = VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI_AP;
+ wifi_manager_handle_s *wifi_handle = wifi;
wifi_netlink_scan_s *nl_scan = (wifi_netlink_scan_s *)netlink_scan;
/** When softap mode is enabled wifi device is in deactivated state,
return WIFI_MANAGER_ERROR_INVALID_OPERATION;
}
- rv = net_netlink_scan_wifi(nl_scan->ssids, nl_scan->vsie);
-
+ rv = net_netlink_scan_wifi(wifi_handle->network_info, nl_scan->ssids, nl_scan->vsie);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied");
return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
} else if (rv == NET_ERR_INVALID_OPERATION) {
return WIFI_MANAGER_ERROR_INVALID_OPERATION;
} else if (rv == NET_ERR_NONE) {
- __set_netlink_scan_cb(wifi, callback, user_data);
+ __set_netlink_scan_cb(wifi_handle, callback, user_data);
return WIFI_MANAGER_ERROR_NONE;
}
return WIFI_MANAGER_ERROR_OPERATION_FAILED;
}
-int _wifi_add_vsie(wifi_manager_h wifi,
- wifi_manager_vsie_frames_e frame_id, const char *vsie_str)
+int _wifi_add_vsie(wifi_manager_h wifi, wifi_manager_vsie_frames_e frame_id, const char *vsie_str)
{
int rv;
net_vsie_frames_e f_id;
+ wifi_manager_handle_s *wifi_handle = wifi;
switch (frame_id) {
case WIFI_MANAGER_VSIE_FRAME_ASSOC_REQ:
WIFI_LOG(WIFI_ERROR, "Frame ID: [%d] not supported.", frame_id);
return WIFI_MANAGER_ERROR_NOT_SUPPORTED;
}
- rv = net_wifi_add_vsie(f_id, vsie_str);
+ rv = net_wifi_add_vsie(wifi_handle->network_info, f_id, vsie_str);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied");
return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
return WIFI_MANAGER_ERROR_OPERATION_FAILED;
}
-int _wifi_get_vsie(wifi_manager_h wifi,
- wifi_manager_vsie_frames_e frame_id, char **vsie_str)
+int _wifi_get_vsie(wifi_manager_h wifi, wifi_manager_vsie_frames_e frame_id, char **vsie_str)
{
int rv;
net_vsie_frames_e f_id;
+ wifi_manager_handle_s *wifi_handle = wifi;
switch (frame_id) {
case WIFI_MANAGER_VSIE_FRAME_ASSOC_REQ:
WIFI_LOG(WIFI_ERROR, "Frame ID: [%d] not supported.", frame_id);
return WIFI_MANAGER_ERROR_NOT_SUPPORTED;
}
- rv = net_wifi_get_vsie(f_id, vsie_str);
+ rv = net_wifi_get_vsie(wifi_handle->network_info, f_id, vsie_str);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied");
return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
return WIFI_MANAGER_ERROR_OPERATION_FAILED;
}
-int _wifi_remove_vsie(wifi_manager_h wifi,
- wifi_manager_vsie_frames_e frame_id, const char *vsie_str)
+int _wifi_remove_vsie(wifi_manager_h wifi, wifi_manager_vsie_frames_e frame_id, const char *vsie_str)
{
int rv;
net_vsie_frames_e f_id;
+ wifi_manager_handle_s *wifi_handle = wifi;
switch (frame_id) {
case WIFI_MANAGER_VSIE_FRAME_ASSOC_REQ:
WIFI_LOG(WIFI_ERROR, "Frame ID: [%d] not supported.", frame_id);
return WIFI_MANAGER_ERROR_NOT_SUPPORTED;
}
- rv = net_wifi_remove_vsie(f_id, vsie_str);
+ rv = net_wifi_remove_vsie(wifi_handle->network_info, f_id, vsie_str);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied");
return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
return WIFI_MANAGER_ERROR_OPERATION_FAILED;
}
-int _wifi_flush_bss(void)
+int _wifi_flush_bss(wifi_manager_h wifi)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_flush_bss();
-
+ rv = net_wifi_flush_bss(wifi_handle->network_info);
if (rv != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to flush bss");
return WIFI_MANAGER_ERROR_OPERATION_FAILED;
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_set_bssid(char *bssid)
+int _wifi_set_bssid(wifi_manager_h wifi, char *bssid)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_set_bssid(bssid);
-
+ rv = net_wifi_set_bssid(wifi_handle->network_info, bssid);
if (rv != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to set bssid");
return WIFI_MANAGER_ERROR_OPERATION_FAILED;
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_set_auto_connect(int connect_mode)
+int _wifi_set_auto_connect(wifi_manager_h wifi, int connect_mode)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_set_auto_connect_mode(connect_mode);
+ rv = net_wifi_set_auto_connect_mode(wifi_handle->network_info, connect_mode);
if (rv != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to set auto connection mode");
return rv;
}
-int _wifi_get_auto_connect(int *connect_mode)
+int _wifi_get_auto_connect(wifi_manager_h wifi, int *connect_mode)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_get_auto_connect_mode(connect_mode);
+ rv = net_wifi_get_auto_connect_mode(wifi_handle->network_info, connect_mode);
if (rv != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to get auto connection mode");
return rv;
}
-int _wifi_get_5ghz_support(bool *supported)
+int _wifi_get_5ghz_support(wifi_manager_h wifi, bool *supported)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
gboolean is_supported = FALSE;
- rv = net_wifi_get_5ghz_support(&is_supported);
+ rv = net_wifi_get_5ghz_support(wifi_handle->network_info, &is_supported);
if (rv != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to get 5 Ghz supported");
int rv = 0;
net_profile_info_s *ap_info = ap;
- rv = net_wifi_set_ap_auto_connect(ap_info->ProfileName, autoconnect);
+ rv = net_wifi_set_ap_auto_connect(ap_info->network_info,
+ ap_info->ProfileName, autoconnect);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied");
return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
gboolean auto_connect = FALSE;
net_profile_info_s *ap_info = ap;
- rv = net_wifi_get_ap_auto_connect(ap_info->ProfileName, &auto_connect);
+ rv = net_wifi_get_ap_auto_connect(ap_info->network_info,
+ ap_info->ProfileName, &auto_connect);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied");
return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
}
//LCOV_EXCL_STOP
-int _wifi_get_connected_profile(wifi_manager_ap_h *ap)
+int _wifi_get_connected_profile(wifi_manager_h wifi, wifi_manager_ap_h *ap)
{
int rv;
- wifi_manager_ap_h ap_h = NULL;
+ wifi_manager_handle_s *wifi_handle = wifi;
+ net_profile_info_s *ap_info = NULL;
+ net_profile_info_s *connected_ap = NULL;
GSList *list;
- rv = __update_profile_iterator();
+ rv = __update_profile_iterator(wifi_handle);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
}
- for (list = profile_iterator; list; list = list->next) {
+ for (list = wifi_handle->profile_iterator; list; list = list->next) {
net_profile_info_s *prof_info = (net_profile_info_s *)list->data;
- if (prof_info->ProfileState == NET_STATE_TYPE_ONLINE ||
- prof_info->ProfileState == NET_STATE_TYPE_READY) {
- ap_h = (wifi_manager_ap_h)prof_info;
- break;
+ if (!g_strcmp0(prof_info->net_info.DevName, wifi_handle->interface_name)) {
+ if (prof_info->ProfileState == NET_STATE_TYPE_ONLINE ||
+ prof_info->ProfileState == NET_STATE_TYPE_READY) {
+ connected_ap = prof_info;
+ break;
+ }
}
}
- if (ap_h == NULL) {
+ if (connected_ap == NULL) {
WIFI_LOG(WIFI_ERROR, "There is no connected AP"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NO_CONNECTION; //LCOV_EXCL_LINE
}
- *ap = g_try_malloc0(sizeof(net_profile_info_s));
- if (*ap == NULL)
+ ap_info = g_try_malloc0(sizeof(net_profile_info_s));
+ if (ap_info == NULL)
return WIFI_MANAGER_ERROR_OUT_OF_MEMORY;
- memcpy(*ap, ap_h, sizeof(net_profile_info_s));
+ memcpy(ap_info, connected_ap, sizeof(net_profile_info_s));
+ ap_info->vsie_list = g_slist_copy_deep(connected_ap->vsie_list,
+ _wifi_copy_vsie_list, NULL);
+ ap_info->bssid_list = g_slist_copy_deep(connected_ap->bssid_list,
+ _wifi_copy_bssid_list, NULL);
+
+ _wifi_add_to_ap_list(ap_info);
+ *ap = (wifi_manager_ap_h)ap_info;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_foreach_available_interface(wifi_manager_h wifi,
+ wifi_manager_interface_cb callback, void *user_data)
+{
+ int rv;
+ GSList *list;
+ wifi_manager_handle_s *wifi_handle = wifi;
+
+ rv = __update_interface_iterator(wifi_handle);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ }
- _wifi_add_to_ap_list(*ap);
+ if ((int)g_slist_length(wifi_handle->interface_iterator) == 0) {
+ WIFI_LOG(WIFI_WARN, "There is no interface"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_NONE; //LCOV_EXCL_LINE
+ }
+
+ for (list = wifi_handle->interface_iterator; list; list = list->next) {
+ char *interface_name = (char *)list->data;
+ rv = callback(interface_name, user_data);
+ if (rv == false) break;
+ }
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_foreach_found_ap(wifi_manager_found_ap_cb callback, void *user_data)
+int _wifi_foreach_found_ap(wifi_manager_h wifi,
+ wifi_manager_found_ap_cb callback, void *user_data)
{
int rv;
GSList *list;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = __update_profile_iterator();
+ rv = __update_profile_iterator(wifi_handle);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
}
- if ((int)g_slist_length(profile_iterator) == 0) {
+ if ((int)g_slist_length(wifi_handle->profile_iterator) == 0) {
WIFI_LOG(WIFI_WARN, "There is no AP"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NONE; //LCOV_EXCL_LINE
}
- for (list = profile_iterator; list; list = list->next) {
+ for (list = wifi_handle->profile_iterator; list; list = list->next) {
+ net_profile_info_s *prof_info = (net_profile_info_s *)list->data;
+ if (!g_strcmp0(prof_info->net_info.DevName, wifi_handle->interface_name)) {
+ if (prof_info->is_hidden == TRUE)
+ continue;
+
+ rv = callback((wifi_manager_ap_h)prof_info, user_data);
+ if (rv == false) break;
+ }
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_foreach_found_ap_in_all_interfaces(wifi_manager_h wifi,
+ wifi_manager_found_ap_cb callback, void *user_data)
+{
+ int rv;
+ GSList *list;
+ wifi_manager_handle_s *wifi_handle = wifi;
+
+ rv = __update_profile_iterator(wifi_handle);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ }
+
+ if ((int)g_slist_length(wifi_handle->profile_iterator) == 0) {
+ WIFI_LOG(WIFI_WARN, "There is no AP"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_NONE; //LCOV_EXCL_LINE
+ }
+
+ for (list = wifi_handle->profile_iterator; list; list = list->next) {
net_profile_info_s *prof_info = (net_profile_info_s *)list->data;
if (prof_info->is_hidden == TRUE)
continue;
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_foreach_found_specific_ap(wifi_manager_found_ap_cb callback, void *user_data)
+int _wifi_foreach_found_specific_ap(wifi_manager_h wifi,
+ wifi_manager_found_ap_cb callback, void *user_data)
{
int rv;
GSList *list;
+ wifi_manager_handle_s *wifi_handle = wifi;
- if ((int)g_slist_length(specific_profile_iterator) == 0) {
+ if ((int)g_slist_length(wifi_handle->specific_profile_iterator) == 0) {
WIFI_LOG(WIFI_WARN, "There is no specific APs");
- rv = __update_profile_iterator();
+ rv = __update_profile_iterator(wifi_handle);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
}
- if ((int)g_slist_length(profile_iterator) == 0) {
+ if ((int)g_slist_length(wifi_handle->profile_iterator) == 0) {
WIFI_LOG(WIFI_WARN, "There is no APs"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NONE; //LCOV_EXCL_LINE
}
- for (list = profile_iterator; list; list = list->next) {
+ for (list = wifi_handle->profile_iterator; list; list = list->next) {
net_profile_info_s *prof_info = (net_profile_info_s *)list->data;
- if (!g_strcmp0(specific_profile_essid, prof_info->essid)) {
+ if (!g_strcmp0(wifi_handle->specific_scan_essid, prof_info->essid)) {
rv = callback((wifi_manager_ap_h)prof_info, user_data);
if (rv == false) break;
}
return WIFI_MANAGER_ERROR_NONE;
}
- for (list = specific_profile_iterator; list; list = list->next) {
+ for (list = wifi_handle->specific_profile_iterator; list; list = list->next) {
net_profile_info_s *prof_info = (net_profile_info_s *)list->data;
rv = callback((wifi_manager_ap_h)prof_info, user_data);
if (rv == false) break;
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_foreach_found_bssid_ap(wifi_manager_found_ap_cb callback, void *user_data)
+int _wifi_foreach_found_bssid_ap(wifi_manager_h wifi,
+ wifi_manager_found_ap_cb callback, void *user_data)
{
int rv;
GSList *list;
+ wifi_manager_handle_s *wifi_handle = wifi;
- for (list = bss_profile_iterator; list; list = list->next) {
+ for (list = wifi_handle->bss_profile_iterator; list; list = list->next) {
net_profile_info_s *prof_info = (net_profile_info_s *)list->data;
rv = callback((wifi_manager_ap_h)prof_info, user_data);
if (rv == false) break;
}
//LCOV_EXCL_START
-int _wifi_foreach_found_netlink_scan_ap(wifi_manager_found_ap_cb callback, void *user_data)
+int _wifi_foreach_found_netlink_scan_ap(wifi_manager_h wifi,
+ wifi_manager_found_ap_cb callback, void *user_data)
{
int rv;
GSList *list;
+ wifi_manager_handle_s *wifi_handle = wifi;
- if (bss_profile_iterator == NULL) {
+ if (wifi_handle->bss_profile_iterator == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to search APs");
return WIFI_MANAGER_ERROR_OPERATION_FAILED;
}
- for (list = bss_profile_iterator; list; list = list->next) {
+ for (list = wifi_handle->bss_profile_iterator; list; list = list->next) {
net_profile_info_s *prof_info = (net_profile_info_s *)list->data;
rv = callback((wifi_manager_ap_h)prof_info, user_data);
if (rv == false) break;
}
- __clear_profile_list(&bss_profile_iterator);
+ __clear_profile_list(&(wifi_handle->bss_profile_iterator));
+
return WIFI_MANAGER_ERROR_NONE;
}
//LCOV_EXCL_STOP
int rv;
bool valid_profile;
net_profile_info_s *ap_info = ap_h;
+ wifi_manager_handle_s *wifi_handle = wifi;
- valid_profile =
- _wifi_check_profile_name_validity(ap_info->ProfileName);
-
+ valid_profile = _wifi_check_profile_name_validity(ap_info->ProfileName);
if (valid_profile == true && ap_info->Favourite)
- rv = net_open_connection(ap_info->ProfileName);
+ rv = net_open_connection(wifi_handle->network_info, ap_info->ProfileName);
else if (valid_profile == true &&
ap_info->is_hidden != TRUE &&
ap_info->security_info.sec_mode == WLAN_SEC_MODE_NONE)
- rv = net_open_connection(ap_info->ProfileName);
+ rv = net_open_connection(wifi_handle->network_info, ap_info->ProfileName);
else
- rv = __connect_with_wifi_info(ap_info);
+ rv = __connect_with_wifi_info(wifi_handle, ap_info);
rv = __convert_to_ap_error_type(rv);
if (rv == WIFI_MANAGER_ERROR_NONE)
- __set_connected_cb(wifi, callback, user_data);
+ __set_connected_cb(wifi_handle, callback, user_data);
return rv;
}
{
int rv;
net_profile_info_s *ap_info = ap_h;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_close_connection(ap_info->ProfileName);
+ rv = net_close_connection(wifi_handle->network_info, ap_info->ProfileName);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
- __set_disconnected_cb(wifi, callback, user_data);
+ __set_disconnected_cb(wifi_handle, callback, user_data);
return WIFI_MANAGER_ERROR_NONE;
}
wifi_manager_connected_cb callback, void *user_data)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
net_profile_info_s *ap_info = ap_h;
net_wifi_wps_info_s wps_info;
memset(&wps_info, 0, sizeof(net_wifi_wps_info_s));
wps_info.type = WIFI_WPS_PBC;
- rv = net_wifi_enroll_wps(ap_info->ProfileName, &wps_info);
+ rv = net_wifi_enroll_wps(wifi_handle->network_info, ap_info->ProfileName, &wps_info);
if (rv != NET_ERR_NONE)
return __convert_to_ap_error_type(rv);
- __set_connected_cb(wifi, callback, user_data);
+ __set_connected_cb(wifi_handle, callback, user_data);
return WIFI_MANAGER_ERROR_NONE;
}
const char *pin, wifi_manager_connected_cb callback, void *user_data)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
net_profile_info_s *ap_info = ap_h;
net_wifi_wps_info_s wps_info;
wps_info.type = WIFI_WPS_PIN;
g_strlcpy(wps_info.pin, pin, NET_WLAN_MAX_WPSPIN_LEN + 1);
- rv = net_wifi_enroll_wps(ap_info->ProfileName, &wps_info);
+ rv = net_wifi_enroll_wps(wifi_handle->network_info, ap_info->ProfileName, &wps_info);
if (rv != NET_ERR_NONE)
return __convert_to_ap_error_type(rv);
- __set_connected_cb(wifi, callback, user_data);
+ __set_connected_cb(wifi_handle, callback, user_data);
return WIFI_MANAGER_ERROR_NONE;
}
//LCOV_EXCL_STOP
-int _wifi_forget_ap(wifi_manager_ap_h ap)
+int _wifi_forget_ap(wifi_manager_h wifi, wifi_manager_ap_h ap)
{
int rv = 0;
+ wifi_manager_handle_s *wifi_handle = wifi;
net_profile_info_s *ap_info = ap;
if (ap_info == NULL) {
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- rv = net_delete_profile(ap_info->ProfileName);
+ rv = net_delete_profile(wifi_handle->network_info, ap_info->ProfileName);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
}
int _wifi_forget_ap_async(wifi_manager_h wifi, wifi_manager_ap_h ap,
- wifi_manager_forget_ap_finished_cb callback,
- void* user_data)
+ wifi_manager_forget_ap_finished_cb callback, void* user_data)
{
int rv = 0;
- GSList *list;
+ wifi_manager_handle_s *wifi_handle = wifi;
net_profile_info_s *ap_info = ap;
if (ap_info == NULL) {
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- if (_wifi_get_callback_count_from_handle_list(WIFI_MANAGER_FORGET_AP_CB)) {
- for (list = wifi_manager_handle_list; list; list = list->next) {
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
- if (local_handle->forget_ap_cb != NULL) {
- WIFI_LOG(WIFI_ERROR, "Already in progress"); //LCOV_EXCL_LINE
- return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
- }
- }
- }
-
- rv = net_delete_profile_async(ap_info->ProfileName);
+ rv = net_delete_profile_async(wifi_handle->network_info, ap_info->ProfileName);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
}
ap_info->Favourite = (char)FALSE;
- __set_forget_ap_cb(wifi, callback, user_data);
+ __set_forget_ap_cb(wifi_handle, callback, user_data);
return WIFI_MANAGER_ERROR_NONE;
}
//LCOV_EXCL_START
-void _wifi_rssi_level_changed_cb(keynode_t *node, void *user_data)
-{
- GSList *list;
- wifi_manager_handle_s *handle;
- int rssi_level = 0;
-
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
- for (list = wifi_manager_handle_list; list; list = list->next) {
- handle = (wifi_manager_handle_s *)list->data;
-
- if (__wifi_check_handle_validity((wifi_manager_h)handle) != true)
- return;
-
- if (vconf_get_int(VCONFKEY_WIFI_STRENGTH, &rssi_level) != 0)
- return;
-
- if (handle->rssi_level_changed_cb)
- handle->rssi_level_changed_cb(rssi_level,
- handle->rssi_level_changed_user_data);
- }
-}
-
-int _wifi_update_ap_info(net_profile_info_s *ap_info)
+int _wifi_update_ap_info(wifi_manager_h wifi, net_profile_info_s *ap_info)
{
int rv = NET_ERR_NONE;
- rv = net_modify_profile(ap_info->ProfileName, ap_info);
+ wifi_manager_handle_s *wifi_handle = wifi;
+ rv = net_modify_profile(wifi_handle->network_info, ap_info->ProfileName, ap_info);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
wifi_manager_connected_cb callback, void *user_data)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
net_wifi_wps_info_s wps_info;
net_profile_info_s *profile = NULL;
GSList *list;
wps_info.type = WIFI_WPS_PBC;
- WIFI_LOG(WIFI_INFO, "start\n");
+ WIFI_LOG(WIFI_INFO, "start");
/* Disconnect if already connected to an AP */
- __update_profile_iterator();
+ __update_profile_iterator(wifi_handle);
- for (list = profile_iterator; list; list = list->next) {
+ for (list = wifi_handle->profile_iterator; list; list = list->next) {
profile = (net_profile_info_s *)list->data;
if (profile->ProfileState == NET_STATE_TYPE_ASSOCIATION ||
profile->ProfileState == NET_STATE_TYPE_CONFIGURATION ||
profile->ProfileState == NET_STATE_TYPE_READY ||
profile->ProfileState == NET_STATE_TYPE_ONLINE) {
- rv = net_close_connection(profile->ProfileName);
+ rv = net_close_connection(wifi_handle->network_info, profile->ProfileName);
if (rv != NET_ERR_NONE)
return __convert_to_ap_error_type(rv);
- is_disconnect_wps_pbc = true;
+
+ wifi_handle->is_disconnect_wps_pbc = true;
}
}
- if (!is_disconnect_wps_pbc) {
- rv = net_wifi_enroll_wps_without_ssid(&wps_info);
+ if (!wifi_handle->is_disconnect_wps_pbc) {
+ rv = net_wifi_enroll_wps_without_ssid(wifi_handle->network_info, &wps_info);
if (rv != NET_ERR_NONE)
return __convert_to_ap_error_type(rv);
}
- __set_connected_cb(wifi, callback, user_data);
+ __set_connected_cb(wifi_handle, callback, user_data);
return WIFI_MANAGER_ERROR_NONE;
}
wifi_manager_connected_cb callback, void* user_data)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
net_wifi_wps_info_s wps_info;
net_profile_info_s *profile = NULL;
GSList *list;
wps_info.type = WIFI_WPS_PIN;
g_strlcpy(wps_info.pin, pin, NET_WLAN_MAX_WPSPIN_LEN + 1);
- WIFI_LOG(WIFI_INFO, "pin: %s\n", pin);
+ WIFI_LOG(WIFI_INFO, "pin: %s", pin);
/* Disconnect if already connected to an AP */
- __update_profile_iterator();
-
+ __update_profile_iterator(wifi_handle);
- for (list = profile_iterator; list; list = list->next) {
+ for (list = wifi_handle->profile_iterator; list; list = list->next) {
profile = (net_profile_info_s *)list->data;
if (profile->ProfileState == NET_STATE_TYPE_ASSOCIATION ||
profile->ProfileState == NET_STATE_TYPE_CONFIGURATION ||
profile->ProfileState == NET_STATE_TYPE_READY ||
profile->ProfileState == NET_STATE_TYPE_ONLINE) {
- rv = net_close_connection(profile->ProfileName);
+ rv = net_close_connection(wifi_handle->network_info, profile->ProfileName);
if (rv != NET_ERR_NONE)
return __convert_to_ap_error_type(rv);
- is_disconnect_wps_pin = true;
+ wifi_handle->is_disconnect_wps_pin = true;
}
}
- if (!is_disconnect_wps_pin) {
- rv = net_wifi_enroll_wps_without_ssid(&wps_info);
+ if (!wifi_handle->is_disconnect_wps_pin) {
+ rv = net_wifi_enroll_wps_without_ssid(wifi_handle->network_info, &wps_info);
if (rv != NET_ERR_NONE)
return __convert_to_ap_error_type(rv);
}
- __set_connected_cb(wifi, callback, user_data);
+ __set_connected_cb(wifi_handle, callback, user_data);
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_cancel_wps(void)
+int _wifi_cancel_wps(wifi_manager_h wifi)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_cancel_wps();
-
+ rv = net_wifi_cancel_wps(wifi_handle->network_info);
if (rv != NET_ERR_NONE)
return WIFI_MANAGER_ERROR_OPERATION_FAILED;
- __connected_cb(WIFI_MANAGER_ERROR_OPERATION_ABORTED);
+ __connected_cb(wifi_handle, WIFI_MANAGER_ERROR_OPERATION_ABORTED);
+
return WIFI_MANAGER_ERROR_NONE;
}
//LCOV_EXCL_STOP
-bool _wifi_check_config_validity(wifi_manager_config_h config_h)
+bool _wifi_check_config_validity(wifi_config_s *config)
{
- GSList *list = NULL;
+ wifi_manager_handle_s *wifi_handle;
- if (config_h == NULL)
+ if (config == NULL)
return false;
- for (list = config_handle_list; list; list = list->next)
- if (config_h == list->data) return true;
+ wifi_handle = config->wifi_handle;
+ if (wifi_handle == NULL)
+ return false;
- for (list = config_iterator; list; list = list->next)
- if (config_h == list->data) return true;
+ if (_wifi_find_from_handle_list(wifi_handle) == false)
+ return false;
+
+ if (g_slist_find(wifi_handle->config_handle_list, config) != NULL)
+ return true;
+
+ if (g_slist_find(wifi_handle->config_iterator, config) != NULL)
+ return true;
return false;
}
-void _wifi_add_to_config_list(wifi_manager_config_h config_h)
+void _wifi_add_to_config_list(wifi_config_s *config)
{
- config_handle_list = g_slist_append(config_handle_list, config_h);
+ wifi_manager_handle_s *wifi_handle = config->wifi_handle;
+
+ if (wifi_handle) {
+ wifi_handle->config_handle_list =
+ g_slist_append(wifi_handle->config_handle_list, config);
+ }
}
-void _wifi_remove_from_config_list(wifi_manager_config_h config_h)
+void _wifi_remove_from_config_list(wifi_config_s *config)
{
- config_handle_list = g_slist_remove(config_handle_list, config_h);
- g_free(config_h);
+ wifi_manager_handle_s *wifi_handle = config->wifi_handle;
+
+ if (wifi_handle) {
+ wifi_handle->config_handle_list =
+ g_slist_remove(wifi_handle->config_handle_list, config);
+ }
}
gchar *_wifi_config_get_config_id(const gchar *name, wifi_manager_security_type_e security_type)
return config_id;
}
-int _wifi_config_get_config_id_list(GSList **list)
+int _wifi_config_get_config_id_list(wifi_manager_h wifi, GSList **list)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_config_get_id_list(list);
+ rv = net_config_get_id_list(wifi_handle->network_info, list);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_save_configuration(const gchar *name, const gchar *passphrase,
+int _wifi_save_configuration(wifi_manager_h wifi,
+ const gchar *name, const gchar *passphrase,
wifi_manager_security_type_e security_type, const gchar *proxy_address,
wifi_config_ip_info_s *ip_info, gboolean is_hidden, gboolean is_created)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
gchar *config_id = NULL;
gchar *ssid = NULL;
config_id = _wifi_config_get_config_id(name, security_type);
ssid = __wifi_change_name_to_hexadecimal(name);
- rv = net_config_save_configurations(config_id, name, ssid, passphrase,
+ rv = net_config_save_configurations(wifi_handle->network_info,
+ config_id, name, ssid, passphrase,
proxy_address, (void *)ip_info, is_hidden, is_created);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_load_configurations(void)
+int _wifi_load_configurations(wifi_manager_h wifi)
{
int rv;
- GSList *config_ids = NULL;
int i;
+ wifi_manager_handle_s *wifi_handle = wifi;
+ GSList *config_ids = NULL;
- __clear_config_list(&config_iterator);
+ __clear_config_list(&(wifi_handle->config_iterator));
- rv = _wifi_config_get_config_id_list(&config_ids);
+ rv = _wifi_config_get_config_id_list(wifi, &config_ids);
if (rv != WIFI_MANAGER_ERROR_NONE) {
WIFI_LOG(WIFI_ERROR, "Fail to load configurations [%d]", rv); //LCOV_EXCL_LINE
return rv; //LCOV_EXCL_LINE
if (h == NULL)
break;
+ h->wifi_handle = wifi_handle;
+
if (g_str_has_suffix(id, "ieee8021x") == TRUE) {
h->eap_config = g_new0(wifi_eap_config_s, 1);
if (h->eap_config == NULL) {
g_free(h);//LCOV_EXCL_LINE
break;//LCOV_EXCL_LINE
}
- rv = __load_eap_configurations(id, &h->name,
+ rv = __load_eap_configurations(wifi_handle, id, &h->name,
&h->security_type, &h->proxy_address, &h->is_hidden, &h->eap_config, &h->last_error);
} else {
h->ip_info = g_new0(wifi_config_ip_info_s, 1);
g_free(h);//LCOV_EXCL_LINE
break;//LCOV_EXCL_LINE
}
- rv = __load_configurations(id, &h->name, &h->passphrase, &h->security_type,
+ rv = __load_configurations(wifi_handle, id, &h->name, &h->passphrase, &h->security_type,
&h->proxy_address, &h->is_hidden, &h->ip_info,
&h->last_error);
}
h->address_family = WIFI_MANAGER_ADDRESS_FAMILY_IPV4;
h->is_saved = TRUE;
- config_iterator = g_slist_append(config_iterator, (wifi_manager_config_h)h);
+ wifi_handle->config_iterator = g_slist_append(wifi_handle->config_iterator,
+ (wifi_manager_config_h)h);
}
config_ids = config_ids->next;
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_foreach_configuration(wifi_manager_config_list_cb callback, void *user_data)
+int _wifi_foreach_configuration(wifi_manager_h wifi,
+ wifi_manager_config_list_cb callback, void *user_data)
{
int rv;
GSList *list;
+ wifi_manager_handle_s *wifi_handle = wifi;
- for (list = config_iterator; list; list = list->next) {
+ for (list = wifi_handle->config_iterator; list; list = list->next) {
rv = callback((wifi_manager_config_h)list->data, user_data);
if (rv == false)
break;
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_remove_configuration(const gchar *config_id)
+int _wifi_remove_configuration(wifi_manager_h wifi, const gchar *config_id)
{
int rv;
GSList *list;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_config_remove_configurations(config_id);
+ rv = net_config_remove_configurations(wifi_handle->network_info, config_id);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
} else if (rv != NET_ERR_NONE)
return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
- rv = __update_profile_iterator();
+ rv = __update_profile_iterator(wifi_handle);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
}
- if ((int)g_slist_length(profile_iterator) == 0) {
+ if ((int)g_slist_length(wifi_handle->profile_iterator) == 0) {
WIFI_LOG(WIFI_WARN, "There is no AP"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NONE; //LCOV_EXCL_LINE
}
- for (list = profile_iterator; list; list = list->next) {
+ for (list = wifi_handle->profile_iterator; list; list = list->next) {
net_profile_info_s *prof_info = (net_profile_info_s *)list->data;
if (g_str_has_suffix((gchar*)(prof_info->ProfileName), config_id) == TRUE) {
- rv = net_delete_profile(prof_info->ProfileName); //LCOV_EXCL_LINE
+ rv = net_delete_profile(wifi_handle->network_info, prof_info->ProfileName); //LCOV_EXCL_LINE
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
}
//LCOV_EXCL_START
-int _wifi_save_eap_configurations(const gchar *name, const gchar *passphrase,
+int _wifi_save_eap_configurations(wifi_manager_h wifi,
+ const gchar *name, const gchar *passphrase,
wifi_manager_security_type_e security_type, const gchar *proxy_address,
wifi_eap_config_s *eap_config, gboolean is_hidden, gboolean is_created)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
gchar *config_id = NULL;
gchar *ssid = NULL;
config_id = _wifi_config_get_config_id(name, security_type);
ssid = __wifi_change_name_to_hexadecimal(name);
-
- rv = net_config_save_eap_configurations(config_id, name, ssid, passphrase,
+ rv = net_config_save_eap_configurations(wifi_handle->network_info,
+ config_id, name, ssid, passphrase,
proxy_address, (void *)eap_config, is_hidden, is_created);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_configuration_set_field(const gchar *config_id, const gchar *key, const gchar *value)
+int _wifi_configuration_set_field(wifi_manager_h wifi,
+ const gchar *config_id, const gchar *key, const gchar *value)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_config_set_field(config_id, key, value);
+ rv = net_config_set_field(wifi_handle->network_info, config_id, key, value);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_configuration_get_passphrase(const gchar *config_id, gchar **passphrase)
+int _wifi_configuration_get_passphrase(wifi_manager_h wifi,
+ const gchar *config_id, gchar **passphrase)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_config_get_passphrase(config_id, passphrase);
+ rv = net_config_get_passphrase(wifi_handle->network_info, config_id, passphrase);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_check_get_privilege()
+int _wifi_check_get_privilege(wifi_manager_h wifi)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_check_get_privilege();
+ rv = net_check_get_privilege(wifi_handle->network_info);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_check_profile_privilege()
+int _wifi_check_profile_privilege(wifi_manager_h wifi)
{
- int rv = net_check_profile_privilege();
+ int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
+
+ rv = net_check_profile_privilege(wifi_handle->network_info);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
}
//LCOV_EXCL_START
-int _wifi_set_autoscan(bool autoscan)
+int _wifi_set_autoscan(wifi_manager_h wifi, bool autoscan)
{
int rv = 0;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_set_autoscan(autoscan);
+ rv = net_wifi_set_autoscan(wifi_handle->network_info, autoscan);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied");
return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_set_background_scan_mode(wifi_manager_autoscan_mode_e mode)
+int _wifi_set_background_scan_mode(wifi_manager_h wifi,
+ wifi_manager_autoscan_mode_e mode)
{
int rv = 0;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_set_background_scan_mode(mode);
+ rv = net_wifi_set_background_scan_mode(wifi_handle->network_info, mode);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied");
return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_set_ip_conflict_period(unsigned int initial_time)
+int _wifi_set_ip_conflict_period(wifi_manager_h wifi, unsigned int initial_time)
{
int rv = 0;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_set_ip_conflict_period(initial_time);
+ rv = net_wifi_set_ip_conflict_period(wifi_handle->network_info, initial_time);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied");
return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_get_autoscan(bool *autoscan)
+int _wifi_get_autoscan(wifi_manager_h wifi, bool *autoscan)
{
int rv;
gboolean auto_scan = 0;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_get_autoscan(&auto_scan);
+ rv = net_wifi_get_autoscan(wifi_handle->network_info, &auto_scan);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_get_autoscanmode(wifi_manager_autoscan_mode_e *autoscanmode)
+int _wifi_get_autoscanmode(wifi_manager_h wifi, wifi_manager_autoscan_mode_e *autoscanmode)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_get_autoscanmode(autoscanmode);
+ rv = net_wifi_get_autoscanmode(wifi_handle->network_info, autoscanmode);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_set_passpoint(int passpoint)
+int _wifi_set_passpoint(wifi_manager_h wifi, int passpoint)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_set_passpoint(passpoint);
-
+ rv = net_wifi_set_passpoint(wifi_handle->network_info, passpoint);
if (rv != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to set passpoint");
return rv;
}
-int _wifi_get_passpoint(int *passpoint)
+int _wifi_get_passpoint(wifi_manager_h wifi, int *passpoint)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_get_passpoint(passpoint);
-
+ rv = net_wifi_get_passpoint(wifi_handle->network_info, passpoint);
if (rv != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to get passpoint state");
return rv;
}
-int _wifi_get_ip_conflict_period(unsigned int* initial_time)
+int _wifi_get_ip_conflict_period(wifi_manager_h wifi, unsigned int* initial_time)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_get_ip_conflict_period(initial_time);
+ rv = net_wifi_get_ip_conflict_period(wifi_handle->network_info, initial_time);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_get_ip_conflict_state(wifi_manager_ip_conflict_state_e *state)
+int _wifi_get_ip_conflict_state(wifi_manager_h wifi, wifi_manager_ip_conflict_state_e *state)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_get_ip_conflict_state(state);
+ rv = net_wifi_get_ip_conflict_state(wifi_handle->network_info, state);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_get_wps_generated_pin(char **wps_pin)
+int _wifi_get_wps_generated_pin(wifi_manager_h wifi, char **wps_pin)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_get_wps_generated_pin(wps_pin);
-
+ rv = net_get_wps_generated_pin(wifi_handle->network_info, wps_pin);
if (rv != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to get WPS PIN");
return rv;
}
-int _wifi_get_module_state(wifi_manager_module_state_e *state)
+int _wifi_get_module_state(wifi_manager_h wifi, wifi_manager_module_state_e *state)
{
int rv = 0;
int wifi_device_status = 0;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = vconf_get_int(VCONFKEY_WIFI_DEVICE_STATUS_UEVENT, &wifi_device_status);
-
- if (rv < 0) {
- WIFI_LOG(WIFI_ERROR, "Failed to get vconf value [%s]\n",
- VCONFKEY_WIFI_DEVICE_STATUS_UEVENT);
- return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ rv = net_wifi_get_module_state(wifi_handle->network_info, &wifi_device_status);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get module state"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
if (wifi_device_status == 0) {
return WIFI_MANAGER_ERROR_NONE;
}
-
-void _wifi_module_state_changed_cb(keynode_t *node, void *user_data)
-{
- GSList *list;
- wifi_manager_handle_s *handle;
- int wifi_device_status = 0;
-
- if (net_check_ref_count() != true) {
- WIFI_LOG(WIFI_ERROR, "Application is not registered"
- "If multi-threaded, thread integrity be broken.");
- return;
- }
-
- for (list = wifi_manager_handle_list; list; list = list->next) {
- handle = (wifi_manager_handle_s *)list->data;
-
- if (__wifi_check_handle_validity((wifi_manager_h)handle) != true)
- return;
-
- if (vconf_get_int(VCONFKEY_WIFI_DEVICE_STATUS_UEVENT, &wifi_device_status) < 0) {
- WIFI_LOG(WIFI_ERROR, "Unable to read status from vconf key\n");
- return;
- }
-
- WIFI_LOG(WIFI_ERROR, "Wi-Fi Module State [%d]\n", wifi_device_status);
-
- if (handle->module_state_changed_cb)
- handle->module_state_changed_cb(wifi_device_status,
- handle->module_state_changed_user_data);
- }
-}
-
//LCOV_EXCL_STOP
bool _wifi_check_multi_scan_validity(wifi_manager_specific_scan_h specific_scan)
wifi_manager_scan_finished_cb callback, void *user_data)
{
int rv = -1;
-
+ wifi_manager_handle_s *wifi_handle = wifi;
GSList *multi_scan_list = (GSList *)specific_scan;
- rv = net_multi_scan_wifi(multi_scan_list->next, multi_scan_type);
+ rv = net_multi_scan_wifi(wifi_handle->network_info, multi_scan_list->next, multi_scan_type);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
} else if (rv == NET_ERR_OUT_OF_MEMORY) {
return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
} else if (rv == NET_ERR_NONE) {
- __set_multi_scan_cb(wifi, callback, user_data);
+ __set_multi_scan_cb(wifi_handle, callback, user_data);
return WIFI_MANAGER_ERROR_NONE;
}
return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
-int _wifi_get_connection_mode(wifi_manager_connection_mode_e *mode)
+int _wifi_get_connection_mode(wifi_manager_h wifi, wifi_manager_connection_mode_e *mode)
{
int rv;
GSList *list;
+ wifi_manager_handle_s *wifi_handle = wifi;
net_profile_info_s *prof_info = NULL;
- rv = __update_profile_iterator();
+ rv = __update_profile_iterator(wifi_handle);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied");
return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
}
- for (list = profile_iterator; list; list = list->next) {
+ for (list = wifi_handle->profile_iterator; list; list = list->next) {
prof_info = (net_profile_info_s *)list->data;
if (prof_info->ProfileState == NET_STATE_TYPE_ONLINE ||
prof_info->ProfileState == NET_STATE_TYPE_READY)
return WIFI_MANAGER_ERROR_NONE;
}
-int _wifi_get_service_state()
+int _wifi_get_service_state(wifi_manager_handle_s *wifi_handle)
{
wifi_service_state_e ret = WIFI_SERVICE_STATE_UNKNOWN;
- net_state_type_e service_state = net_get_service_state();
+ net_state_type_e service_state = net_get_service_state(wifi_handle->network_info);
switch (service_state) {
case NET_STATE_TYPE_UNKNOWN:
return ret;
}
-int _wifi_get_max_scan_ssids(int *max_scan_ssids)
+int _wifi_get_max_scan_ssids(wifi_manager_h wifi, int *max_scan_ssids)
{
int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
- rv = net_wifi_get_max_scan_ssids(max_scan_ssids);
-
+ rv = net_wifi_get_max_scan_ssids(wifi_handle->network_info, max_scan_ssids);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
if(g_p_dpp_current != p_dpp)
return WIFI_MANAGER_ERROR_NOW_IN_PROGRESS;
- rv = net_dpp_enter_peer_uri(p_dpp->peer_id, p_dpp->own_id, uri);
+ rv = net_dpp_enter_peer_uri(p_dpp->network_info, p_dpp->peer_id, p_dpp->own_id, uri);
if (rv != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to enter peer URI");
if(g_p_dpp_current != p_dpp)
return WIFI_MANAGER_ERROR_NOW_IN_PROGRESS;
- rv = net_dpp_generate_own_uri(p_dpp->peer_id, p_dpp->own_id, p_dpp->is_initiator, key);
+ rv = net_dpp_generate_own_uri(p_dpp->network_info,
+ p_dpp->peer_id, p_dpp->own_id, p_dpp->is_initiator, key);
if (rv != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to generate own URI");
if(g_p_dpp_current != p_dpp)
return WIFI_MANAGER_ERROR_NOW_IN_PROGRESS;
- rv = net_dpp_stop(p_dpp->peer_id, p_dpp->own_id, p_dpp->is_initiator);
+ rv = net_dpp_stop(p_dpp->network_info,
+ p_dpp->peer_id, p_dpp->own_id, p_dpp->is_initiator);
if (rv != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to stop");
#include "network_internal.h"
#include "wifi_internal.h"
-#define WIFI_MAC_ADDR_PATH "/sys/class/net/wlan0/address"
-
//LCOV_EXCL_START
bool __wifi_check_handle_validity(wifi_manager_h wifi)
{
return _wifi_find_from_handle_list(wifi);
}
-static int __wifi_set_device_state_changed_cb(wifi_manager_h wifi,
+static void __wifi_set_device_state_changed_cb(wifi_manager_handle_s *wifi_handle,
void *callback, void *user_data)
{
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
-
- local_handle->device_state_cb = callback;
- local_handle->device_state_user_data = user_data;
-
- return WIFI_MANAGER_ERROR_NONE;
+ wifi_handle->device_state_cb = callback;
+ wifi_handle->device_state_user_data = user_data;
}
-static int __wifi_set_background_scan_cb(wifi_manager_h wifi,
+static void __wifi_set_background_scan_cb(wifi_manager_handle_s *wifi_handle,
void *callback, void *user_data)
{
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
-
- local_handle->bg_scan_cb = callback;
- local_handle->bg_scan_user_data = user_data;
-
- return WIFI_MANAGER_ERROR_NONE;
+ wifi_handle->bg_scan_cb = callback;
+ wifi_handle->bg_scan_user_data = user_data;
}
-static int __wifi_set_scan_state_changed_cb(wifi_manager_h wifi,
+static void __wifi_set_scan_state_changed_cb(wifi_manager_handle_s *wifi_handle,
void *callback, void *user_data)
{
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
-
- local_handle->scan_changed_cb = callback;
- local_handle->scan_changed_user_data = user_data;
-
- return WIFI_MANAGER_ERROR_NONE;
+ wifi_handle->scan_changed_cb = callback;
+ wifi_handle->scan_changed_user_data = user_data;
}
-static int __wifi_set_connection_state_changed_cb(wifi_manager_h wifi,
+static void __wifi_set_connection_state_changed_cb(wifi_manager_handle_s *wifi_handle,
void *callback, void *user_data)
{
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
-
- local_handle->connection_state_cb = callback;
- local_handle->connection_state_user_data = user_data;
-
- return WIFI_MANAGER_ERROR_NONE;
+ wifi_handle->connection_state_cb = callback;
+ wifi_handle->connection_state_user_data = user_data;
}
-static int __wifi_set_ip_conflict_cb(wifi_manager_h wifi,
+static void __wifi_set_ip_conflict_cb(wifi_manager_handle_s *wifi_handle,
void *callback, void *user_data)
{
- wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
-
- local_handle->ip_conflict_cb = callback;
- local_handle->ip_conflict_user_data = user_data;
-
- return WIFI_MANAGER_ERROR_NONE;
+ wifi_handle->ip_conflict_cb = callback;
+ wifi_handle->ip_conflict_user_data = user_data;
}
-static int __wifi_set_rssi_level_changed_cb(wifi_manager_h wifi,
+static void __wifi_set_rssi_level_changed_cb(wifi_manager_handle_s *wifi_handle,
void *callback, void *user_data)
{
- static __thread gint refcount = 0;
- wifi_manager_handle_s *local_handle;
-
- local_handle = (wifi_manager_handle_s *)wifi;
-
- if (callback) {
- if (refcount == 0)
- vconf_notify_key_changed(VCONFKEY_WIFI_STRENGTH,
- _wifi_rssi_level_changed_cb, NULL);
-
- refcount++;
- WIFI_LOG(WIFI_INFO, "Successfully registered(%d)", refcount);
- } else {
- if (refcount > 0 && local_handle->rssi_level_changed_cb) {
- if (--refcount == 0) {
- if (vconf_ignore_key_changed(VCONFKEY_WIFI_STRENGTH,
- _wifi_rssi_level_changed_cb) < 0) {
- WIFI_LOG(WIFI_ERROR, "Error to de-register vconf callback(%d)", refcount);
- } else {
- WIFI_LOG(WIFI_INFO, "Successfully de-registered(%d)", refcount);
- }
- }
- }
- }
-
- local_handle->rssi_level_changed_cb = callback;
- local_handle->rssi_level_changed_user_data = user_data;
-
- return WIFI_MANAGER_ERROR_NONE;
-}
-
-static int __wifi_get_handle_count(void)
-{
- return _wifi_get_count_from_handle_list();
+ wifi_handle->rssi_level_changed_cb = callback;
+ wifi_handle->rssi_level_changed_user_data = user_data;
}
-static int __wifi_set_module_state_changed_cb(wifi_manager_h wifi,
+static void __wifi_set_module_state_changed_cb(wifi_manager_handle_s *wifi_handle,
void *callback, void *user_data)
{
- static __thread gint refcount = 0;
- wifi_manager_handle_s *local_handle;
-
- local_handle = (wifi_manager_handle_s *)wifi;
-
- if (callback) {
- if (refcount == 0)
- vconf_notify_key_changed(VCONFKEY_WIFI_DEVICE_STATUS_UEVENT,
- _wifi_module_state_changed_cb, NULL);
-
- refcount++;
- WIFI_LOG(WIFI_INFO, "Successfully registered(%d)", refcount);
- } else {
- if (refcount > 0 && local_handle->module_state_changed_cb) {
- if (--refcount == 0) {
- if (vconf_ignore_key_changed(VCONFKEY_WIFI_DEVICE_STATUS_UEVENT,
- _wifi_module_state_changed_cb) < 0) {
- WIFI_LOG(WIFI_ERROR, "Error to de-register vconf callback(%d)", refcount);
- } else {
- WIFI_LOG(WIFI_INFO, "Successfully de-registered(%d)", refcount);
- }
- }
- }
- }
-
- local_handle->module_state_changed_cb = callback;
- local_handle->module_state_changed_user_data = user_data;
-
- return WIFI_MANAGER_ERROR_NONE;
+ wifi_handle->module_state_changed_cb = callback;
+ wifi_handle->module_state_changed_user_data = user_data;
}
//LCOV_EXCL_STOP
return WIFI_MANAGER_ERROR_ALREADY_INITIALIZED; //LCOV_EXCL_LINE
}
- rv = _wifi_init();
+ rv = _wifi_create_handle(wifi);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Init failed[%d]", rv); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+
+ rv = _wifi_init(*wifi, NULL);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ _wifi_deinit(*wifi); //LCOV_EXCL_LINE
__NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
} else if (rv != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Init failed[%d]", rv); //LCOV_EXCL_LINE
+ _wifi_deinit(*wifi); //LCOV_EXCL_LINE
__NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
+ _wifi_add_to_handle_list(wifi);
+ WIFI_LOG(WIFI_INFO, "Wi-Fi successfully initialized");
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_initialize_with_interface_name(wifi_manager_h *wifi,
+ const char *ifname)
+{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ int rv;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (wifi == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (ifname == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (__wifi_check_handle_validity(*wifi)) {
+ WIFI_LOG(WIFI_ERROR, "Already initialized"); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_ALREADY_INITIALIZED; //LCOV_EXCL_LINE
+ }
+
rv = _wifi_create_handle(wifi);
if (rv != WIFI_MANAGER_ERROR_NONE) {
WIFI_LOG(WIFI_ERROR, "Init failed[%d]", rv); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
}
+ rv = _wifi_init(*wifi, ifname);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ _wifi_deinit(*wifi); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Init failed[%d]", rv); //LCOV_EXCL_LINE
+ _wifi_deinit(*wifi); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
_wifi_add_to_handle_list(wifi);
- WIFI_LOG(WIFI_INFO, "Wi-Fi successfully initialized");
+ WIFI_LOG(WIFI_INFO, "Wi-Fi successfully initialized with interface name [%s]", ifname);
__NETWORK_CAPI_FUNC_EXIT__;
return WIFI_MANAGER_ERROR_NONE;
WIFI_LOG(WIFI_INFO, "Destroy handle: %p", wifi);
+ _wifi_deinit(wifi);
_wifi_remove_from_handle_list(wifi);
- if (__wifi_get_handle_count() == 0) {
- if (_wifi_deinit() == false) {
- WIFI_LOG(WIFI_ERROR, "Deinit failed"); //LCOV_EXCL_LINE
- __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
- return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
- }
- }
+ if (_wifi_length_from_handle_list() == 0)
+ _wifi_clear_profile_list();
WIFI_LOG(WIFI_INFO, "Wi-Fi successfully de-initialized");
int rv;
rv = wifi_manager_initialize(wifi);
-
if (rv == WIFI_MANAGER_ERROR_NONE)
- _wifi_set_cs_tid(tid);
+ _wifi_set_cs_tid(*wifi, tid);
__NETWORK_CAPI_FUNC_EXIT__;
return rv;
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- rv = _wifi_get_5ghz_support(supported);
+ rv = _wifi_get_5ghz_support(wifi, supported);
__NETWORK_CAPI_FUNC_EXIT__;
return rv;
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- rv = _wifi_get_wifi_device_state(&device_state);
+ rv = _wifi_get_wifi_device_state(wifi, &device_state);
if (rv == WIFI_MANAGER_ERROR_NONE) {
if (WIFI_MANAGER_DEVICE_STATE_DEACTIVATED == device_state)
*activated = false;
{
__NETWORK_CAPI_FUNC_ENTER__;
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- if (_get_tizen_profile() == TIZEN_PROFILE_TV) {
- //LCOV_EXCL_START
- FILE *fp = NULL;
- char buf[WIFI_MAC_ADDR_LEN + 1];
- if (0 == access(WIFI_MAC_ADDR_PATH, F_OK))
- fp = fopen(WIFI_MAC_ADDR_PATH, "r");
-
- if (fp == NULL) {
- WIFI_LOG(WIFI_ERROR, "Failed to open file"
- " %s\n", WIFI_MAC_ADDR_PATH);
- __NETWORK_CAPI_FUNC_EXIT__;
- return WIFI_MANAGER_ERROR_OPERATION_FAILED;
- }
-
- if (fgets(buf, sizeof(buf), fp) == NULL) {
- WIFI_LOG(WIFI_ERROR, "Failed to get MAC"
- " info from %s\n", WIFI_MAC_ADDR_PATH);
- fclose(fp);
- __NETWORK_CAPI_FUNC_EXIT__;
- return WIFI_MANAGER_ERROR_OPERATION_FAILED;
- }
-
- WIFI_LOG(WIFI_INFO, "%s : %s\n", WIFI_MAC_ADDR_PATH, buf);
-
- *mac_address = strndup(buf, WIFI_MAC_ADDR_LEN + 1);
- if (*mac_address == NULL) {
- WIFI_LOG(WIFI_ERROR, "strndup() failed");
- fclose(fp);
- __NETWORK_CAPI_FUNC_EXIT__;
- return WIFI_MANAGER_ERROR_OUT_OF_MEMORY;
- }
-
- fclose(fp);
- //LCOV_EXCL_STOP
- } else {
- *mac_address = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
-
- if (*mac_address == NULL) {
- WIFI_LOG(WIFI_ERROR, "Failed to get vconf" //LCOV_EXCL_LINE
- " from %s", VCONFKEY_WIFI_BSSID_ADDRESS);
- __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
- return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
- }
-
- if (strlen(*mac_address) == 0) {
- WIFI_LOG(WIFI_ERROR, "Mac address is invalid" //LCOV_EXCL_LINE
- " from %s", VCONFKEY_WIFI_BSSID_ADDRESS);
- g_free(*mac_address); //LCOV_EXCL_LINE
- *mac_address = NULL; //LCOV_EXCL_LINE
- __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
- return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
- }
- }
+ rv = _wifi_get_mac_address(wifi, mac_address);
__NETWORK_CAPI_FUNC_EXIT__;
- return WIFI_MANAGER_ERROR_NONE;
+ return rv;
}
EXPORT_API int wifi_manager_get_network_interface_name(wifi_manager_h wifi, char **name)
{
- __NETWORK_CAPI_FUNC_ENTER__
+ __NETWORK_CAPI_FUNC_ENTER__;
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ _wifi_get_intf_name(wifi, name);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_get_intf_name(name);
+ return WIFI_MANAGER_ERROR_NONE;
}
EXPORT_API int wifi_manager_scan(wifi_manager_h wifi,
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- rv = _wifi_get_scan_state(scan_state);
+ rv = _wifi_get_scan_state(wifi, scan_state);
if (rv != WIFI_MANAGER_ERROR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi scan state"); //LCOV_EXCL_LINE
__NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
rv = _wifi_scan_specific_ap(wifi, essid, callback, user_data);
if (rv != WIFI_MANAGER_ERROR_NONE)
- WIFI_LOG(WIFI_ERROR, "Wi-Fi hidden scan failed.\n"); //LCOV_EXCL_LINE
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi hidden scan failed."); //LCOV_EXCL_LINE
__NETWORK_CAPI_FUNC_EXIT__;
return rv;
{
__NETWORK_CAPI_FUNC_ENTER__;
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_get_hidden_aps(wifi, essid, sec_type, passphrase, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_get_hidden_aps(wifi, essid, sec_type, passphrase, callback,
- user_data);
+ return rv;
}
EXPORT_API int wifi_manager_get_connected_ap(wifi_manager_h wifi, wifi_manager_ap_h *ap)
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- rv = _wifi_get_connected_profile(ap);
+ rv = _wifi_get_connected_profile(wifi, ap);
WIFI_LOG(WIFI_INFO, "Connected AP %p, rv %d", *ap, rv);
__NETWORK_CAPI_FUNC_EXIT__;
return rv;
}
+EXPORT_API int wifi_manager_foreach_available_interface(wifi_manager_h wifi,
+ wifi_manager_interface_cb callback, void *user_data)
+{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ int rv;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
+
+ if (callback == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = _wifi_foreach_available_interface(wifi, callback, user_data);
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+ return rv;
+}
+
EXPORT_API int wifi_manager_foreach_found_ap(wifi_manager_h wifi,
wifi_manager_found_ap_cb callback, void *user_data)
{
__NETWORK_CAPI_FUNC_ENTER__;
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_foreach_found_ap(wifi, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_foreach_found_ap(callback, user_data);
+ return rv;
+}
+
+EXPORT_API int wifi_manager_foreach_found_ap_in_all_interfaces(wifi_manager_h wifi,
+ wifi_manager_found_ap_cb callback, void *user_data)
+{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ int rv;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
+
+ if (callback == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = _wifi_foreach_found_ap_in_all_interfaces(wifi, callback, user_data);
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+ return rv;
}
EXPORT_API int wifi_manager_foreach_found_specific_ap(wifi_manager_h wifi,
{
__NETWORK_CAPI_FUNC_ENTER__;
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_foreach_found_specific_ap(wifi, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_foreach_found_specific_ap(callback, user_data);
+ return rv;
}
EXPORT_API int wifi_manager_foreach_found_bssid_ap(wifi_manager_h wifi,
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- rv = _wifi_check_get_privilege();
+ rv = _wifi_check_get_privilege(wifi);
if (rv != WIFI_MANAGER_ERROR_NONE) {
WIFI_LOG(WIFI_ERROR, "Fail to check the privilege"); //LCOV_EXCL_LINE
__NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
return rv; //LCOV_EXCL_LINE
}
+ rv = _wifi_foreach_found_bssid_ap(wifi, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_foreach_found_bssid_ap(callback, user_data);
+ return rv;
}
EXPORT_API int wifi_manager_foreach_found_netlink_scan_ap(wifi_manager_h wifi,
{
__NETWORK_CAPI_FUNC_ENTER__;
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_foreach_found_netlink_scan_ap(wifi, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_foreach_found_netlink_scan_ap(callback, user_data);
+ return rv;
}
EXPORT_API int wifi_manager_connect(wifi_manager_h wifi,
{
__NETWORK_CAPI_FUNC_ENTER__;
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_open_profile(wifi, ap, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_open_profile(wifi, ap, callback, user_data);
+ return rv;
}
EXPORT_API int wifi_manager_disconnect(wifi_manager_h wifi,
{
__NETWORK_CAPI_FUNC_ENTER__;
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_close_profile(wifi, ap, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_close_profile(wifi, ap, callback, user_data);
+ return rv;
}
//LCOV_EXCL_START
{
__NETWORK_CAPI_FUNC_ENTER__;
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_connect_with_wps_pbc(wifi, ap, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_connect_with_wps_pbc(wifi, ap, callback, user_data);
+ return rv;
}
EXPORT_API int wifi_manager_connect_by_wps_pin(wifi_manager_h wifi,
{
__NETWORK_CAPI_FUNC_ENTER__;
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_connect_with_wps_pin(wifi, ap, pin, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_connect_with_wps_pin(wifi, ap, pin, callback, user_data);
+ return rv;
}
//LCOV_EXCL_STOP
{
__NETWORK_CAPI_FUNC_ENTER__;
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_forget_ap(wifi, ap);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_forget_ap(ap);
+ return rv;
}
EXPORT_API int wifi_manager_forget_ap_async(wifi_manager_h wifi, wifi_manager_ap_h ap,
{
__NETWORK_CAPI_FUNC_ENTER__;
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_forget_ap_async(wifi, ap, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_forget_ap_async(wifi, ap, callback, user_data);
+ return rv;
}
EXPORT_API int wifi_manager_update_ap(wifi_manager_h wifi, wifi_manager_ap_h ap)
{
__NETWORK_CAPI_FUNC_ENTER__;
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_NONE;
}
+ rv = _wifi_update_ap_info(wifi, profile_info);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_update_ap_info(profile_info);
+ return rv;
}
EXPORT_API int wifi_manager_get_connection_state(wifi_manager_h wifi,
{
__NETWORK_CAPI_FUNC_ENTER__;
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_get_wifi_state(wifi, connection_state);
+
__NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
- return _wifi_get_wifi_state(connection_state);
+ return rv;
}
EXPORT_API int wifi_manager_set_device_state_changed_cb(wifi_manager_h wifi,
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ __wifi_set_device_state_changed_cb(wifi, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return __wifi_set_device_state_changed_cb(wifi, callback, user_data);
+ return WIFI_MANAGER_ERROR_NONE;
}
EXPORT_API int wifi_manager_unset_device_state_changed_cb(wifi_manager_h wifi)
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
+ __wifi_set_device_state_changed_cb(wifi, NULL, NULL);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return __wifi_set_device_state_changed_cb(wifi, NULL, NULL);
+ return WIFI_MANAGER_ERROR_NONE;
}
EXPORT_API int wifi_manager_set_background_scan_cb(wifi_manager_h wifi,
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ __wifi_set_background_scan_cb(wifi, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return __wifi_set_background_scan_cb(wifi, callback, user_data);
+ return WIFI_MANAGER_ERROR_NONE;
}
EXPORT_API int wifi_manager_unset_background_scan_cb(wifi_manager_h wifi)
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
+ __wifi_set_background_scan_cb(wifi, NULL, NULL);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return __wifi_set_background_scan_cb(wifi, NULL, NULL);
+ return WIFI_MANAGER_ERROR_NONE;
}
EXPORT_API int wifi_manager_set_scan_state_changed_cb(wifi_manager_h wifi,
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ __wifi_set_scan_state_changed_cb(wifi, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return __wifi_set_scan_state_changed_cb(wifi, callback, user_data);
+ return WIFI_MANAGER_ERROR_NONE;
}
EXPORT_API int wifi_manager_unset_scan_state_changed_cb(wifi_manager_h wifi)
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
+ __wifi_set_scan_state_changed_cb(wifi, NULL, NULL);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return __wifi_set_scan_state_changed_cb(wifi, NULL, NULL);
+ return WIFI_MANAGER_ERROR_NONE;
}
EXPORT_API int wifi_manager_set_connection_state_changed_cb(wifi_manager_h wifi,
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ __wifi_set_connection_state_changed_cb(wifi, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return __wifi_set_connection_state_changed_cb(wifi, callback, user_data);
+ return WIFI_MANAGER_ERROR_NONE;
}
EXPORT_API int wifi_manager_unset_connection_state_changed_cb(wifi_manager_h wifi)
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
+ __wifi_set_connection_state_changed_cb(wifi, NULL, NULL);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return __wifi_set_connection_state_changed_cb(wifi, NULL, NULL);
+ return WIFI_MANAGER_ERROR_NONE;
}
EXPORT_API int wifi_manager_set_ip_conflict_cb(wifi_manager_h wifi,
wifi_manager_ip_conflict_cb callback, void *user_data)
{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- return __wifi_set_ip_conflict_cb(wifi, callback, user_data);
+ __wifi_set_ip_conflict_cb(wifi, callback, user_data);
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+ return WIFI_MANAGER_ERROR_NONE;
}
EXPORT_API int wifi_manager_unset_ip_conflict_cb(wifi_manager_h wifi)
{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
- return __wifi_set_ip_conflict_cb(wifi, NULL, NULL);
+
+ __wifi_set_ip_conflict_cb(wifi, NULL, NULL);
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+ return WIFI_MANAGER_ERROR_NONE;
}
EXPORT_API int wifi_manager_set_ip_conflict_detect_enable(wifi_manager_h wifi,
bool detect)
{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
int rv;
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
- rv = _wifi_ip_conflict_detect_enable_set(detect);
+ rv = _wifi_ip_conflict_detect_enable_set(wifi, detect);
if (rv != WIFI_MANAGER_ERROR_NONE)
WIFI_LOG(WIFI_ERROR, "Failed to change ip conflict detect mode"); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__;
return rv;
}
EXPORT_API int wifi_manager_ip_conflict_detect_is_enabled(wifi_manager_h wifi, bool *state)
{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- return _wifi_ip_conflict_detect_is_enabled(state);
+ rv = _wifi_ip_conflict_detect_is_enabled(wifi, state);
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+ return rv;
}
//LCOV_EXCL_START
EXPORT_API int wifi_manager_set_ip_conflict_period(wifi_manager_h wifi,
unsigned int initial_time)
{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
- return _wifi_set_ip_conflict_period(initial_time);
+
+ rv = _wifi_set_ip_conflict_period(wifi, initial_time);
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+ return rv;
}
EXPORT_API int wifi_manager_get_ip_conflict_period(wifi_manager_h wifi,
unsigned int *initial_time)
{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
}
- return _wifi_get_ip_conflict_period(initial_time);
+ rv = _wifi_get_ip_conflict_period(wifi, initial_time);
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+ return rv;
}
//LCOV_EXCL_STOP
EXPORT_API int wifi_manager_get_ip_conflict_state(wifi_manager_h wifi,
wifi_manager_ip_conflict_state_e *state)
{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- return _wifi_get_ip_conflict_state(state);
+ rv = _wifi_get_ip_conflict_state(wifi, state);
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+ return rv;
}
EXPORT_API int wifi_manager_set_rssi_level_changed_cb(wifi_manager_h wifi,
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ __wifi_set_rssi_level_changed_cb(wifi, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return __wifi_set_rssi_level_changed_cb(wifi, callback, user_data);
+ return WIFI_MANAGER_ERROR_NONE;
}
EXPORT_API int wifi_manager_unset_rssi_level_changed_cb(wifi_manager_h wifi)
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
+ __wifi_set_rssi_level_changed_cb(wifi, NULL, NULL);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return __wifi_set_rssi_level_changed_cb(wifi, NULL, NULL);
+ return WIFI_MANAGER_ERROR_NONE;
}
EXPORT_API int wifi_manager_connect_by_wps_pbc_without_ssid(wifi_manager_h wifi,
{
__NETWORK_CAPI_FUNC_ENTER__;
- CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ int rv;
- WIFI_LOG(WIFI_INFO, "[App-->TizenMW] WiFi Connect by WPS_PBC without SSID\n");
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
+ WIFI_LOG(WIFI_INFO, "[App-->TizenMW] WiFi Connect by WPS_PBC without SSID");
+
if (callback == NULL) { //LCOV_EXCL_LINE
- WIFI_LOG(WIFI_ERROR, "[App<--TizenMW] Wrong Parameter Passed\n"); //LCOV_EXCL_LINE
+ WIFI_LOG(WIFI_ERROR, "[App<--TizenMW] Wrong Parameter Passed"); //LCOV_EXCL_LINE
__NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_connect_with_wps_pbc_without_ssid(wifi, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_connect_with_wps_pbc_without_ssid(wifi, callback, user_data);
+ return rv;
}
EXPORT_API int wifi_manager_connect_by_wps_pin_without_ssid(wifi_manager_h wifi, const char *pin,
{
__NETWORK_CAPI_FUNC_ENTER__;
- CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ int rv;
- WIFI_LOG(WIFI_INFO, "[App-->TizenMW] WiFi Connect by WPS_PIN without SSID\n");
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
+ WIFI_LOG(WIFI_INFO, "[App-->TizenMW] WiFi Connect by WPS_PIN without SSID");
+
if (callback == NULL) { //LCOV_EXCL_LINE
- WIFI_LOG(WIFI_ERROR, "[App<--TizenMW] Wrong Parameter Passed\n"); //LCOV_EXCL_LINE
+ WIFI_LOG(WIFI_ERROR, "[App<--TizenMW] Wrong Parameter Passed"); //LCOV_EXCL_LINE
__NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
if ((NULL == pin) || ((strlen(pin) != 4) &&
(strlen(pin) != NET_WLAN_MAX_WPSPIN_LEN))) {
- WIFI_LOG(WIFI_ERROR, "[App<--TizenMW] Wrong Parameter Passed\n"); //LCOV_EXCL_LINE
+ WIFI_LOG(WIFI_ERROR, "[App<--TizenMW] Wrong Parameter Passed"); //LCOV_EXCL_LINE
__NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_connect_with_wps_pin_without_ssid(wifi, pin, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_connect_with_wps_pin_without_ssid(wifi, pin, callback, user_data);
+ return rv;
}
EXPORT_API int wifi_manager_cancel_wps(wifi_manager_h wifi)
{
__NETWORK_CAPI_FUNC_ENTER__;
- CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
- WIFI_LOG(WIFI_INFO, "[App-->TizenMW] cancel wps request\n");
-
int rv;
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
- rv = _wifi_cancel_wps();
+ WIFI_LOG(WIFI_INFO, "[App-->TizenMW] cancel wps request");
+
+ rv = _wifi_cancel_wps(wifi);
if (rv != WIFI_MANAGER_ERROR_NONE)
- WIFI_LOG(WIFI_ERROR, "[App<--TizenMW] Error!! WPS Cancel Request failed. rv[%d]\n", rv); //LCOV_EXCL_LINE
+ WIFI_LOG(WIFI_ERROR, "[App<--TizenMW] Error!! WPS Cancel Request failed. rv[%d]", rv); //LCOV_EXCL_LINE
__NETWORK_CAPI_FUNC_EXIT__;
return rv;
EXPORT_API int wifi_manager_get_wps_generated_pin(wifi_manager_h wifi, char **wps_pin)
{
- CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ __NETWORK_CAPI_FUNC_ENTER__;
+
int rv;
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
- rv = _wifi_get_wps_generated_pin(wps_pin);
+
+ rv = _wifi_get_wps_generated_pin(wifi, wps_pin);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
__NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
+ __NETWORK_CAPI_FUNC_EXIT__;
return rv;
}
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_set_autoscan(autoscan);
+ return _wifi_set_autoscan(wifi, autoscan);
}
-EXPORT_API int wifi_manager_set_autoscan_mode(wifi_manager_h wifi, wifi_manager_autoscan_mode_e mode)
+EXPORT_API int wifi_manager_set_autoscan_mode(wifi_manager_h wifi,
+ wifi_manager_autoscan_mode_e mode)
{
+ int rv;
+
__NETWORK_CAPI_FUNC_ENTER__;
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
- int rv;
-
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- rv = _wifi_set_background_scan_mode(mode);
+ rv = _wifi_set_background_scan_mode(wifi, mode);
if (rv != WIFI_MANAGER_ERROR_NONE)
WIFI_LOG(WIFI_ERROR, "Set background scan mode failed");
EXPORT_API int wifi_manager_get_autoscan(wifi_manager_h wifi,
bool *autoscan)
{
+ int rv;
+
__NETWORK_CAPI_FUNC_ENTER__;
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_get_autoscan(wifi, autoscan);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_get_autoscan(autoscan);
+ return rv;
}
EXPORT_API int wifi_manager_get_autoscan_mode(wifi_manager_h wifi,
wifi_manager_autoscan_mode_e *mode)
{
+ int rv;
+
__NETWORK_CAPI_FUNC_ENTER__;
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_get_autoscanmode(wifi, mode);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_get_autoscanmode(mode);
+ return rv;
}
EXPORT_API int wifi_manager_set_passpoint(wifi_manager_h wifi, int passpoint)
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
- rv = _wifi_set_passpoint(passpoint);
+ rv = _wifi_set_passpoint(wifi, passpoint);
__NETWORK_CAPI_FUNC_EXIT__;
return rv;
return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
}
- rv = _wifi_get_passpoint(passpoint);
+ rv = _wifi_get_passpoint(wifi, passpoint);
__NETWORK_CAPI_FUNC_EXIT__;
return rv;
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ __wifi_set_module_state_changed_cb(wifi, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return __wifi_set_module_state_changed_cb(wifi, callback, user_data);
+ return WIFI_MANAGER_ERROR_NONE;
}
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
+ __wifi_set_module_state_changed_cb(wifi, NULL, NULL);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return __wifi_set_module_state_changed_cb(wifi, NULL, NULL);
+ return WIFI_MANAGER_ERROR_NONE;
}
EXPORT_API int wifi_manager_get_module_state(wifi_manager_h wifi,
{
__NETWORK_CAPI_FUNC_ENTER__;
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_get_module_state(wifi, state);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_get_module_state(state);
+ return rv;
}
}
//LCOV_EXCL_START
-EXPORT_API int wifi_manager_netlink_scan(wifi_manager_h wifi, wifi_manager_netlink_scan_h netlink_scan,
- wifi_manager_netlink_scan_finished_cb callback, void *user_data)
+EXPORT_API int wifi_manager_netlink_scan(wifi_manager_h wifi,
+ wifi_manager_netlink_scan_h netlink_scan,
+ wifi_manager_netlink_scan_finished_cb callback, void *user_data)
{
__NETWORK_CAPI_FUNC_ENTER__;
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
- rv = _wifi_flush_bss();
-
+ rv = _wifi_flush_bss(wifi);
if (rv != WIFI_MANAGER_ERROR_NONE)
- WIFI_LOG(WIFI_ERROR, "[App-->TizenMW] Error!! bss flush Request failed. rv[%d]\n", rv);
+ WIFI_LOG(WIFI_ERROR, "[App-->TizenMW] Error!! bss flush Request failed. rv[%d]", rv);
__NETWORK_CAPI_FUNC_EXIT__;
return rv;
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
- rv = _wifi_set_bssid(bssid);
-
+ rv = _wifi_set_bssid(wifi, bssid);
if (rv != WIFI_MANAGER_ERROR_NONE) {
WIFI_LOG(WIFI_ERROR, "Error!! wifi set bssid failed.[%d]", rv);
__NETWORK_CAPI_FUNC_EXIT__;
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
- rv = _wifi_get_auto_connect(connect_mode);
+ rv = _wifi_get_auto_connect(wifi, connect_mode);
__NETWORK_CAPI_FUNC_EXIT__;
return rv;
int rv;
- rv = _wifi_set_auto_connect(connect_mode);
+ rv = _wifi_set_auto_connect(wifi, connect_mode);
__NETWORK_CAPI_FUNC_EXIT__;
return rv;
{
__NETWORK_CAPI_FUNC_ENTER__;
- CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
int rv;
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
if (max_scan_ssids == NULL) {
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- rv = _wifi_get_max_scan_ssids(max_scan_ssids);
+ rv = _wifi_get_max_scan_ssids(wifi, max_scan_ssids);
__NETWORK_CAPI_FUNC_EXIT__;
return rv;
{
__NETWORK_CAPI_FUNC_ENTER__;
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
if (!(_wifi_check_multi_scan_validity(specific_scan)) ||
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_specific_scan_set_ssid(specific_scan, essid);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_specific_scan_set_ssid(specific_scan, essid);
+ return rv;
}
EXPORT_API int wifi_manager_specific_scan_set_freq(wifi_manager_specific_scan_h specific_scan,
{
__NETWORK_CAPI_FUNC_ENTER__;
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
if (!_wifi_check_multi_scan_validity(specific_scan)) {
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_specific_scan_set_freq(specific_scan, freq);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_specific_scan_set_freq(specific_scan, freq);
+ return rv;
}
EXPORT_API int wifi_manager_specific_ap_start_multi_scan(wifi_manager_h wifi,
{
__NETWORK_CAPI_FUNC_ENTER__;
+ int rv;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
WIFI_LOG(WIFI_ERROR, "specific scan handle %p", specific_scan);
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ rv = _wifi_start_multi_scan(wifi, specific_scan, callback, user_data);
+
__NETWORK_CAPI_FUNC_EXIT__;
- return _wifi_start_multi_scan(wifi, specific_scan, callback, user_data);
+ return rv;
}
EXPORT_API int wifi_manager_get_connection_mode(wifi_manager_h wifi,
return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
}
- rv = _wifi_get_connection_mode(mode);
+ rv = _wifi_get_connection_mode(wifi, mode);
WIFI_LOG(WIFI_INFO, "Connection mode %d", *mode);
__NETWORK_CAPI_FUNC_EXIT__;
{
__NETWORK_CAPI_FUNC_ENTER__;
+ wifi_manager_handle_s *wifi_handle = wifi;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE);
WIFI_LOG(WIFI_INFO, "WiFi TDLS Discover Request");
}
int rv = 0;
- rv = net_wifi_tdls_discover(peer_mac_addr);
+ rv = net_wifi_tdls_discover(wifi_handle->network_info, peer_mac_addr);
if (rv == NET_ERR_IN_PROGRESS) {
WIFI_LOG(WIFI_ERROR, "In Progress"); //LCOV_EXCL_LINE
{
__NETWORK_CAPI_FUNC_ENTER__;
+ wifi_manager_handle_s *wifi_handle = wifi;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE);
WIFI_LOG(WIFI_INFO, "[App-->TizenMW] WiFi TDLS Connect Request");
}
int rv = 0;
- rv = net_wifi_tdls_connect(peer_mac_addr);
+ rv = net_wifi_tdls_connect(wifi_handle->network_info, peer_mac_addr);
if (rv != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "[App<--TizenMW] WIFI_MANAGER_ERROR_OPERATION_FAILED\n");
{
__NETWORK_CAPI_FUNC_ENTER__;
+ wifi_manager_handle_s *wifi_handle = wifi;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE);
}
int rv = 0;
- rv = net_wifi_tdls_disconnect(peer_mac_addr);
+ rv = net_wifi_tdls_disconnect(wifi_handle->network_info, peer_mac_addr);
if (rv != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to disconnect tdls");
{
__NETWORK_CAPI_FUNC_ENTER__;
+ wifi_manager_handle_s *wifi_handle = wifi;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE);
}
int rv = 0;
- rv = net_wifi_tdls_connected_peer(peer_mac_addr);
+ rv = net_wifi_tdls_connected_peer(wifi_handle->network_info, peer_mac_addr);
if (rv != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to get connected peer");
{
__NETWORK_CAPI_FUNC_ENTER__;
+ wifi_manager_handle_s *wifi_handle = wifi;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE);
}
int rv = 0;
- rv = net_wifi_tdls_enable_channel_switch(peer_mac_addr, freq);
+ rv = net_wifi_tdls_enable_channel_switch(wifi_handle->network_info, peer_mac_addr, freq);
if (rv != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to enable TDLS Channel Switching Request");
{
__NETWORK_CAPI_FUNC_ENTER__;
+ wifi_manager_handle_s *wifi_handle = wifi;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE);
int rv = 0;
- rv = net_wifi_tdls_disbale_channel_switch(peer_mac_addr);
+ rv = net_wifi_tdls_disbale_channel_switch(wifi_handle->network_info, peer_mac_addr);
if (rv != NET_ERR_NONE) {
WIFI_LOG(WIFI_ERROR, "Failed to disable TDLS channel switching request");
__NETWORK_CAPI_FUNC_EXIT__;
msg(HR_SINGLE);
if (ret == WIFI_MANAGER_ERROR_NONE)
- msg(LOG_GREEN "Load config list finished" LOG_END);
+ msg(LOG_GREEN "Remove config list finished" LOG_END);
else
- msg("Fail to load config list " LOG_RED "[%s]" LOG_END,
+ msg("Fail to remove config list " LOG_RED "[%s]" LOG_END,
test_wifi_mgr_convert_error_to_string(ret));
msg(HR_SINGLE);
wifi_manager_device_state_e g_device_state = WIFI_MANAGER_DEVICE_STATE_DEACTIVATED;
static int cs_tid = 0;
+static char g_ifname[MENU_DATA_SIZE] = "wlan1";
+
extern struct menu_data menu_public[];
extern struct menu_data menu_extension[];
static void __test_device_state_cb(wifi_manager_device_state_e state, void *user_data)
{
+ wifi_manager_h wifi_h = NULL;
+ char *if_name = NULL;
+
g_device_state = state;
- msg("[%s] Device state changed callback, State [%s]",
- (char *)user_data, test_wifi_mgr_device_state_to_string(g_device_state));
+ wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
+ wifi_manager_get_network_interface_name(wifi_h, &if_name);
+
+ msg("[%d:%s] Device state changed callback, State [%s]",
+ GPOINTER_TO_INT(user_data), if_name, test_wifi_mgr_device_state_to_string(g_device_state));
+
+ FREE(if_name);
}
static void __test_scan_changed_cb(wifi_manager_scan_state_e state, void* user_data)
{
- msg("[%s] Scan changed, Scan state [%s]", (char *)user_data,
- test_wifi_mgr_scan_state_to_string(state));
+ wifi_manager_h wifi_h = NULL;
+ char *if_name = NULL;
+
+ wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
+ wifi_manager_get_network_interface_name(wifi_h, &if_name);
+
+ msg("[%d:%s] Scan changed, Scan state [%s]", GPOINTER_TO_INT(user_data),
+ if_name, test_wifi_mgr_scan_state_to_string(state));
+
+ FREE(if_name);
}
static void __test_connection_state_cb(wifi_manager_connection_state_e state,
wifi_manager_ap_h ap, void* user_data)
{
int ret = WIFI_MANAGER_ERROR_NONE;
+ wifi_manager_h wifi_h = NULL;
+ char *if_name = NULL;
char *ap_name = NULL;
- msgn("[%s] Connection state changed callback, State [%s]",
- (char *)user_data, test_wifi_mgr_conn_state_to_string(state));
+ wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
+ wifi_manager_get_network_interface_name(wifi_h, &if_name);
+
+ msgn("[%d:%s] Connection state changed callback, State [%s]",
+ GPOINTER_TO_INT(user_data), if_name, test_wifi_mgr_conn_state_to_string(state));
ret = wifi_manager_ap_get_essid(ap, &ap_name);
if (ret != WIFI_MANAGER_ERROR_NONE) {
msg(", AP name " LOG_CYAN "[%s]" LOG_END, ap_name);
FREE(ap_name);
}
+
+ FREE(if_name);
}
static void __test_rssi_level_cb(wifi_manager_rssi_level_e rssi_level, void* user_data)
{
- msg("[%s] RSSI level changed callback, level [%d]", (char *)user_data, rssi_level);
+ wifi_manager_h wifi_h = NULL;
+ char *if_name = NULL;
+
+ wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
+ wifi_manager_get_network_interface_name(wifi_h, &if_name);
+
+ msg("[%d:%s] RSSI level changed callback, level [%d]",
+ GPOINTER_TO_INT(user_data), if_name, rssi_level);
+
+ FREE(if_name);
}
static void __test_bg_scan_completed_cb(wifi_manager_error_e error_code, void* user_data)
{
- msg("[%s] Background scan completed, error code [%s]",
- (char *)user_data, test_wifi_mgr_convert_error_to_string(error_code));
+ wifi_manager_h wifi_h = NULL;
+ char *if_name = NULL;
+
+ wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
+ wifi_manager_get_network_interface_name(wifi_h, &if_name);
+
+ msg("[%d:%s] Background scan completed, error code [%s]",
+ GPOINTER_TO_INT(user_data), if_name, test_wifi_mgr_convert_error_to_string(error_code));
+
+ FREE(if_name);
}
static void __test_ip_conflict_cb(char *mac, wifi_manager_ip_conflict_state_e state, void *user_data)
{
- msgn("[%s] Ip conflict", (char *)user_data);
+ wifi_manager_h wifi_h = NULL;
+ char *if_name = NULL;
+
+ wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
+ wifi_manager_get_network_interface_name(wifi_h, &if_name);
+
+ msgn("[%d:%s] Ip conflict", GPOINTER_TO_INT(user_data), if_name);
if (state == WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_DETECTED)
msg(" detected [%s]", mac);
msg(" removed");
else
msg(" state unknown");
+
+ FREE(if_name);
}
static void __test_get_wifi_module_state_cb(wifi_manager_module_state_e state, void *user_data)
{
- msgn("[%s] Wi-Fi module state changed callback", (char *)user_data);
+ wifi_manager_h wifi_h = NULL;
+ char *if_name = NULL;
+
+ wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
+ wifi_manager_get_network_interface_name(wifi_h, &if_name);
+
+ msgn("[%d%s] Wi-Fi module state changed callback", GPOINTER_TO_INT(user_data), if_name);
msg(", Wi-Fi module [%s]", test_wifi_mgr_module_state_to_string(state));
+
+ FREE(if_name);
}
static void __test_tdls_state_cb(wifi_manager_tdls_state_e state, char *peer_mac_add, void *user_data)
{
- msgn("[%s] TDLS state changed callback", (char *)user_data);
+ wifi_manager_h wifi_h = NULL;
+ char *if_name = NULL;
+
+ wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
+ wifi_manager_get_network_interface_name(wifi_h, &if_name);
+
+ msgn("[%d:%s] TDLS state changed callback", GPOINTER_TO_INT(user_data), if_name);
if (state == WIFI_MANAGER_TDLS_STATE_CONNECTED)
msg(", state : TDLS connected, Peer MAC address [%s]", peer_mac_add);
else
msg(", state : TDLS disconnected, Peer MAC address [%s]", peer_mac_add);
+
+ FREE(if_name);
}
static void __test_tdls_discover_cb(wifi_manager_tdls_discovery_state_e state,
char *peer_mac_add, void *user_data)
{
- msgn("[%s] TDLS discover callback", (char *)user_data);
+ wifi_manager_h wifi_h = NULL;
+ char *if_name = NULL;
+
+ wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
+ wifi_manager_get_network_interface_name(wifi_h, &if_name);
+
+ msgn("[%d:%s] TDLS discover callback", GPOINTER_TO_INT(user_data), if_name);
msgn(", Peer MAC address [%s], state [%d]", peer_mac_add, state);
if (state == WIFI_MANAGER_TDLS_DISCOVERY_STATE_ONGOING)
msg(", Discovery is ongoing");
else
msg(", Discovery is finished");
+
+ FREE(if_name);
}
static void __test_dpp_event_cb(wifi_manager_dpp_event_e event,
wifi_manager_dpp_state_e state, wifi_manager_dpp_h handle, void *user_data)
{
- msgn("[%s] DPP event callback", (char *)user_data);
+ wifi_manager_h wifi_h = NULL;
+ char *if_name = NULL;
+
+ wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
+ wifi_manager_get_network_interface_name(wifi_h, &if_name);
+
+ msgn("[%d:%s] DPP event callback", GPOINTER_TO_INT(user_data), if_name);
msg(", event [%s]", test_wifi_mgr_dpp_event_to_string(event));
if (event == WIFI_MANAGER_DPP_EVENT_STATE_CHANGED)
msg("state [%s]", test_wifi_mgr_dpp_state_to_string(state));
+
+ FREE(if_name);
}
static int _test_wifi_mgr_initialize(MManager *mm, struct menu_data *menu)
{
int ret = WIFI_MANAGER_ERROR_NONE;
bool state = FALSE;
+ char *if_name = NULL;
- if (!g_wifi_h) {
- ret = wifi_manager_initialize(&g_wifi_h);
- if (ret == WIFI_MANAGER_ERROR_NONE) {
- wifi_manager_set_device_state_changed_cb(g_wifi_h, __test_device_state_cb, "1");
- wifi_manager_set_scan_state_changed_cb(g_wifi_h, __test_scan_changed_cb, "1");
- wifi_manager_set_connection_state_changed_cb(g_wifi_h, __test_connection_state_cb, "1");
- wifi_manager_set_rssi_level_changed_cb(g_wifi_h, __test_rssi_level_cb, "1");
- wifi_manager_set_background_scan_cb(g_wifi_h, __test_bg_scan_completed_cb, "1");
- wifi_manager_set_ip_conflict_cb(g_wifi_h, __test_ip_conflict_cb, "1");
- wifi_manager_set_module_state_changed_cb(g_wifi_h, __test_get_wifi_module_state_cb, "1");
+ if (g_wifi_h) {
+ wifi_manager_deinitialize(g_wifi_h);
+ g_wifi_h = NULL;
+ }
- wifi_manager_tdls_set_state_changed_cb(g_wifi_h, __test_tdls_state_cb, "1");
- wifi_manager_tdls_set_discovered_cb(g_wifi_h, __test_tdls_discover_cb, "1");
+ if (g_wifi2_h) {
+ wifi_manager_deinitialize(g_wifi2_h);
+ g_wifi2_h = NULL;
+ }
- wifi_manager_dpp_set_event_cb(g_wifi_h, __test_dpp_event_cb, "1");
+ ret = wifi_manager_initialize(&g_wifi_h);
+ if (ret == WIFI_MANAGER_ERROR_NONE) {
+ wifi_manager_set_device_state_changed_cb(g_wifi_h, __test_device_state_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_scan_state_changed_cb(g_wifi_h, __test_scan_changed_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_connection_state_changed_cb(g_wifi_h, __test_connection_state_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_rssi_level_changed_cb(g_wifi_h, __test_rssi_level_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_background_scan_cb(g_wifi_h, __test_bg_scan_completed_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_ip_conflict_cb(g_wifi_h, __test_ip_conflict_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_module_state_changed_cb(g_wifi_h, __test_get_wifi_module_state_cb, GINT_TO_POINTER(1));
+
+ wifi_manager_tdls_set_state_changed_cb(g_wifi_h, __test_tdls_state_cb, GINT_TO_POINTER(1));
+ wifi_manager_tdls_set_discovered_cb(g_wifi_h, __test_tdls_discover_cb, GINT_TO_POINTER(1));
+
+ wifi_manager_dpp_set_event_cb(g_wifi_h, __test_dpp_event_cb, GINT_TO_POINTER(1));
+
+ wifi_manager_get_network_interface_name(g_wifi_h, &if_name);
+ msg(LOG_GREEN "[1:%s] Success to initialize wifi handle [%p]" LOG_END, if_name, g_wifi_h);
+ FREE(if_name);
+ } else {
+ msg("[1] Failed to initialize wifi handle " LOG_RED "[%s]" LOG_END,
+ test_wifi_mgr_convert_error_to_string(ret));
+ }
- msg(LOG_GREEN "Success to initialize wifi [1] handle [%p]" LOG_END, g_wifi_h);
- } else {
- msg("Failed to initialize wifi handle " LOG_RED "[%s]" LOG_END,
- test_wifi_mgr_convert_error_to_string(ret));
- }
+ ret = wifi_manager_initialize(&g_wifi2_h);
+ if (ret == WIFI_MANAGER_ERROR_NONE) {
+ wifi_manager_set_device_state_changed_cb(g_wifi2_h, __test_device_state_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_scan_state_changed_cb(g_wifi2_h, __test_scan_changed_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_connection_state_changed_cb(g_wifi2_h, __test_connection_state_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_rssi_level_changed_cb(g_wifi2_h, __test_rssi_level_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_background_scan_cb(g_wifi2_h, __test_bg_scan_completed_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_ip_conflict_cb(g_wifi2_h, __test_ip_conflict_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_module_state_changed_cb(g_wifi2_h, __test_get_wifi_module_state_cb, GINT_TO_POINTER(2));
+
+ wifi_manager_tdls_set_state_changed_cb(g_wifi2_h, __test_tdls_state_cb, GINT_TO_POINTER(2));
+ wifi_manager_tdls_set_discovered_cb(g_wifi2_h, __test_tdls_discover_cb, GINT_TO_POINTER(2));
+
+ wifi_manager_dpp_set_event_cb(g_wifi2_h, __test_dpp_event_cb, GINT_TO_POINTER(2));
+
+ wifi_manager_get_network_interface_name(g_wifi2_h, &if_name);
+ msg(LOG_GREEN "[2:%s] Success to initialize wifi handle [%p]" LOG_END, if_name, g_wifi2_h);
+ FREE(if_name);
+ } else {
+ msg("[2] Failed to initialize wifi handle " LOG_RED "[%s]" LOG_END,
+ test_wifi_mgr_convert_error_to_string(ret));
}
- if (!g_wifi2_h) {
- ret = wifi_manager_initialize(&g_wifi2_h);
+ if (ret == WIFI_MANAGER_ERROR_NONE) {
+ ret = wifi_manager_is_activated(g_wifi_h, &state);
+ wifi_manager_get_network_interface_name(g_wifi_h, &if_name);
if (ret == WIFI_MANAGER_ERROR_NONE) {
- wifi_manager_set_device_state_changed_cb(g_wifi2_h, __test_device_state_cb, "2");
- wifi_manager_set_scan_state_changed_cb(g_wifi2_h, __test_scan_changed_cb, "2");
- wifi_manager_set_connection_state_changed_cb(g_wifi2_h, __test_connection_state_cb, "2");
- wifi_manager_set_rssi_level_changed_cb(g_wifi2_h, __test_rssi_level_cb, "2");
- wifi_manager_set_background_scan_cb(g_wifi2_h, __test_bg_scan_completed_cb, "2");
- wifi_manager_set_ip_conflict_cb(g_wifi2_h, __test_ip_conflict_cb, "2");
- wifi_manager_set_module_state_changed_cb(g_wifi2_h, __test_get_wifi_module_state_cb, "2");
-
- wifi_manager_tdls_set_state_changed_cb(g_wifi2_h, __test_tdls_state_cb, "2");
- wifi_manager_tdls_set_discovered_cb(g_wifi2_h, __test_tdls_discover_cb, "2");
-
- wifi_manager_dpp_set_event_cb(g_wifi2_h, __test_dpp_event_cb, "2");
-
- msg(LOG_GREEN "Success to initialize wifi [2] handle [%p]" LOG_END, g_wifi2_h);
+ g_device_state = state;
+ msg("[1:%s] Wi-Fi device state " LOG_CYAN "[%s]" LOG_END, if_name,
+ test_wifi_mgr_device_state_to_string(g_device_state));
} else {
- msg("Failed to initialize wifi [2] handle " LOG_RED "[%s]" LOG_END,
+ msg("[1] Failed to get Wi-Fi device state " LOG_RED "[%s]" LOG_END,
test_wifi_mgr_convert_error_to_string(ret));
}
- }
-
- ret = wifi_manager_is_activated(g_wifi_h, &state);
- if (ret == WIFI_MANAGER_ERROR_NONE) {
- g_device_state = state;
- msg("Wi-Fi device state " LOG_CYAN "[%s]" LOG_END,
- test_wifi_mgr_device_state_to_string(g_device_state));
- } else {
- msg("Failed to get Wi-Fi device state " LOG_RED "[%s]" LOG_END,
- test_wifi_mgr_convert_error_to_string(ret));
+ FREE(if_name);
}
return ret;
{
int ret = WIFI_MANAGER_ERROR_NONE;
bool state = FALSE;
+ char *if_name = NULL;
cs_tid = get_tid();
- if (!g_wifi_h) {
- ret = wifi_manager_initialize_cs(cs_tid, &g_wifi_h);
- if (ret == WIFI_MANAGER_ERROR_NONE) {
- wifi_manager_set_device_state_changed_cb(g_wifi_h, __test_device_state_cb, "1");
- wifi_manager_set_scan_state_changed_cb(g_wifi_h, __test_scan_changed_cb, "1");
- wifi_manager_set_connection_state_changed_cb(g_wifi_h, __test_connection_state_cb, "1");
- wifi_manager_set_rssi_level_changed_cb(g_wifi_h, __test_rssi_level_cb, "1");
- wifi_manager_set_background_scan_cb(g_wifi_h, __test_bg_scan_completed_cb, "1");
- wifi_manager_set_ip_conflict_cb(g_wifi_h, __test_ip_conflict_cb, "1");
- wifi_manager_set_module_state_changed_cb(g_wifi_h, __test_get_wifi_module_state_cb, "1");
+ if (g_wifi_h) {
+ wifi_manager_deinitialize(g_wifi_h);
+ g_wifi_h = NULL;
+ }
- wifi_manager_tdls_set_state_changed_cb(g_wifi_h, __test_tdls_state_cb, "1");
- wifi_manager_tdls_set_discovered_cb(g_wifi_h, __test_tdls_discover_cb, "1");
+ if (g_wifi2_h) {
+ wifi_manager_deinitialize(g_wifi2_h);
+ g_wifi2_h = NULL;
+ }
- wifi_manager_dpp_set_event_cb(g_wifi_h, __test_dpp_event_cb, "1");
+ ret = wifi_manager_initialize_cs(cs_tid, &g_wifi_h);
+ if (ret == WIFI_MANAGER_ERROR_NONE) {
+ wifi_manager_set_device_state_changed_cb(g_wifi_h, __test_device_state_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_scan_state_changed_cb(g_wifi_h, __test_scan_changed_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_connection_state_changed_cb(g_wifi_h, __test_connection_state_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_rssi_level_changed_cb(g_wifi_h, __test_rssi_level_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_background_scan_cb(g_wifi_h, __test_bg_scan_completed_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_ip_conflict_cb(g_wifi_h, __test_ip_conflict_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_module_state_changed_cb(g_wifi_h, __test_get_wifi_module_state_cb, GINT_TO_POINTER(1));
+
+ wifi_manager_tdls_set_state_changed_cb(g_wifi_h, __test_tdls_state_cb, GINT_TO_POINTER(1));
+ wifi_manager_tdls_set_discovered_cb(g_wifi_h, __test_tdls_discover_cb, GINT_TO_POINTER(1));
+
+ wifi_manager_dpp_set_event_cb(g_wifi_h, __test_dpp_event_cb, GINT_TO_POINTER(1));
+
+ wifi_manager_get_network_interface_name(g_wifi_h, &if_name);
+ msg(LOG_GREEN "[1:%s] Success to initialize wifi handle [%p]" LOG_END, if_name, g_wifi_h);
+ FREE(if_name);
+ } else {
+ msg("[1] Failed to initialize wifi handle " LOG_RED "[%s]" LOG_END,
+ test_wifi_mgr_convert_error_to_string(ret));
+ }
- msg(LOG_GREEN "Success to initialize wifi [1] handle [%p]" LOG_END, g_wifi_h);
+ ret = wifi_manager_initialize_cs(cs_tid, &g_wifi2_h);
+ if (ret == WIFI_MANAGER_ERROR_NONE) {
+ wifi_manager_set_device_state_changed_cb(g_wifi2_h, __test_device_state_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_scan_state_changed_cb(g_wifi2_h, __test_scan_changed_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_connection_state_changed_cb(g_wifi2_h, __test_connection_state_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_rssi_level_changed_cb(g_wifi2_h, __test_rssi_level_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_background_scan_cb(g_wifi2_h, __test_bg_scan_completed_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_ip_conflict_cb(g_wifi2_h, __test_ip_conflict_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_module_state_changed_cb(g_wifi2_h, __test_get_wifi_module_state_cb, GINT_TO_POINTER(2));
+
+ wifi_manager_tdls_set_state_changed_cb(g_wifi2_h, __test_tdls_state_cb, GINT_TO_POINTER(2));
+ wifi_manager_tdls_set_discovered_cb(g_wifi2_h, __test_tdls_discover_cb, GINT_TO_POINTER(2));
+
+ wifi_manager_dpp_set_event_cb(g_wifi2_h, __test_dpp_event_cb, GINT_TO_POINTER(2));
+
+ wifi_manager_get_network_interface_name(g_wifi2_h, &if_name);
+ msg(LOG_GREEN "[2:%s] Success to initialize wifi handle [%p]" LOG_END, if_name, g_wifi2_h);
+ FREE(if_name);
+ } else {
+ msg("[2] Failed to initialize wifi handle " LOG_RED "[%s]" LOG_END,
+ test_wifi_mgr_convert_error_to_string(ret));
+ }
+
+ if (ret == WIFI_MANAGER_ERROR_NONE) {
+ ret = wifi_manager_is_activated(g_wifi_h, &state);
+ wifi_manager_get_network_interface_name(g_wifi_h, &if_name);
+ if (ret == WIFI_MANAGER_ERROR_NONE) {
+ g_device_state = state;
+ msg("[1:%s] Wi-Fi device state " LOG_CYAN "[%s]" LOG_END, if_name,
+ test_wifi_mgr_device_state_to_string(g_device_state));
} else {
- msg("Failed to initialize wifi handle " LOG_RED "[%s]" LOG_END,
+ msg("[1] Failed to get Wi-Fi device state " LOG_RED "[%s]" LOG_END,
test_wifi_mgr_convert_error_to_string(ret));
}
+ FREE(if_name);
}
- if (!g_wifi2_h) {
- ret = wifi_manager_initialize_cs(cs_tid, &g_wifi2_h);
- if (ret == WIFI_MANAGER_ERROR_NONE) {
- wifi_manager_set_device_state_changed_cb(g_wifi2_h, __test_device_state_cb, "2");
- wifi_manager_set_scan_state_changed_cb(g_wifi2_h, __test_scan_changed_cb, "2");
- wifi_manager_set_connection_state_changed_cb(g_wifi2_h, __test_connection_state_cb, "2");
- wifi_manager_set_rssi_level_changed_cb(g_wifi2_h, __test_rssi_level_cb, "2");
- wifi_manager_set_background_scan_cb(g_wifi2_h, __test_bg_scan_completed_cb, "2");
- wifi_manager_set_ip_conflict_cb(g_wifi2_h, __test_ip_conflict_cb, "2");
- wifi_manager_set_module_state_changed_cb(g_wifi2_h, __test_get_wifi_module_state_cb, "2");
+ return ret;
+}
+
+static int _test_wifi_mgr_initialize_with_ifname(MManager *mm, struct menu_data *menu)
+{
+ int ret = WIFI_MANAGER_ERROR_NONE;
+ bool state = FALSE;
+ char *if_name = NULL;
- wifi_manager_tdls_set_state_changed_cb(g_wifi2_h, __test_tdls_state_cb, "2");
- wifi_manager_tdls_set_discovered_cb(g_wifi2_h, __test_tdls_discover_cb, "2");
+ if (g_wifi_h) {
+ wifi_manager_deinitialize(g_wifi_h);
+ g_wifi_h = NULL;
+ }
- wifi_manager_dpp_set_event_cb(g_wifi2_h, __test_dpp_event_cb, "2");
+ if (g_wifi2_h) {
+ wifi_manager_deinitialize(g_wifi2_h);
+ g_wifi2_h = NULL;
+ }
- msg(LOG_GREEN "Success to initialize wifi [2] handle [%p]" LOG_END, g_wifi2_h);
- } else {
- msg("Failed to initialize wifi [2] handle " LOG_RED "[%s]" LOG_END,
- test_wifi_mgr_convert_error_to_string(ret));
- }
+ ret = wifi_manager_initialize_with_interface_name(&g_wifi_h, g_ifname);
+ if (ret == WIFI_MANAGER_ERROR_NONE) {
+ wifi_manager_set_device_state_changed_cb(g_wifi_h, __test_device_state_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_scan_state_changed_cb(g_wifi_h, __test_scan_changed_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_connection_state_changed_cb(g_wifi_h, __test_connection_state_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_rssi_level_changed_cb(g_wifi_h, __test_rssi_level_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_background_scan_cb(g_wifi_h, __test_bg_scan_completed_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_ip_conflict_cb(g_wifi_h, __test_ip_conflict_cb, GINT_TO_POINTER(1));
+ wifi_manager_set_module_state_changed_cb(g_wifi_h, __test_get_wifi_module_state_cb, GINT_TO_POINTER(1));
+
+ wifi_manager_tdls_set_state_changed_cb(g_wifi_h, __test_tdls_state_cb, GINT_TO_POINTER(1));
+ wifi_manager_tdls_set_discovered_cb(g_wifi_h, __test_tdls_discover_cb, GINT_TO_POINTER(1));
+
+ wifi_manager_dpp_set_event_cb(g_wifi_h, __test_dpp_event_cb, GINT_TO_POINTER(1));
+
+ wifi_manager_get_network_interface_name(g_wifi_h, &if_name);
+ msg(LOG_GREEN "[1:%s] Success to initialize wifi handle [%p]" LOG_END, if_name, g_wifi_h);
+ FREE(if_name);
+ } else {
+ msg("[1] Failed to initialize wifi handle " LOG_RED "[%s]" LOG_END,
+ test_wifi_mgr_convert_error_to_string(ret));
}
- ret = wifi_manager_is_activated(g_wifi_h, &state);
+ ret = wifi_manager_initialize_with_interface_name(&g_wifi2_h, g_ifname);
if (ret == WIFI_MANAGER_ERROR_NONE) {
- g_device_state = state;
- msg("Wi-Fi device state " LOG_CYAN "[%s]" LOG_END,
- test_wifi_mgr_device_state_to_string(g_device_state));
+ wifi_manager_set_device_state_changed_cb(g_wifi2_h, __test_device_state_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_scan_state_changed_cb(g_wifi2_h, __test_scan_changed_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_connection_state_changed_cb(g_wifi2_h, __test_connection_state_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_rssi_level_changed_cb(g_wifi2_h, __test_rssi_level_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_background_scan_cb(g_wifi2_h, __test_bg_scan_completed_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_ip_conflict_cb(g_wifi2_h, __test_ip_conflict_cb, GINT_TO_POINTER(2));
+ wifi_manager_set_module_state_changed_cb(g_wifi2_h, __test_get_wifi_module_state_cb, GINT_TO_POINTER(2));
+
+ wifi_manager_tdls_set_state_changed_cb(g_wifi2_h, __test_tdls_state_cb, GINT_TO_POINTER(2));
+ wifi_manager_tdls_set_discovered_cb(g_wifi2_h, __test_tdls_discover_cb, GINT_TO_POINTER(2));
+
+ wifi_manager_dpp_set_event_cb(g_wifi2_h, __test_dpp_event_cb, GINT_TO_POINTER(2));
+
+ wifi_manager_get_network_interface_name(g_wifi2_h, &if_name);
+ msg(LOG_GREEN "[2:%s] Success to initialize wifi handle [%p]" LOG_END, if_name, g_wifi2_h);
+ FREE(if_name);
} else {
- msg("Failed to get Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+ msg("[2] Failed to initialize wifi handle " LOG_RED "[%s]" LOG_END,
test_wifi_mgr_convert_error_to_string(ret));
}
+ if (ret == WIFI_MANAGER_ERROR_NONE) {
+ ret = wifi_manager_is_activated(g_wifi_h, &state);
+ wifi_manager_get_network_interface_name(g_wifi_h, &if_name);
+ if (ret == WIFI_MANAGER_ERROR_NONE) {
+ g_device_state = state;
+ msg("[1:%s] Wi-Fi device state " LOG_CYAN "[%s]" LOG_END, if_name,
+ test_wifi_mgr_device_state_to_string(g_device_state));
+ } else {
+ msg("[1] Failed to get Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+ test_wifi_mgr_convert_error_to_string(ret));
+ }
+ FREE(if_name);
+ }
+
return ret;
}
static int _test_wifi_mgr_deinitialize(void)
{
int ret = WIFI_MANAGER_ERROR_NONE;
+ char *if_name = NULL;
if (g_wifi_h) {
if (cs_tid)
else
ret = wifi_manager_deinitialize(g_wifi_h);
- if (ret == WIFI_MANAGER_ERROR_NONE)
- msg(LOG_GREEN "Succeeded to deinitialize wifi handle" LOG_END);
- else
- msg("Failed to deinitialize wifi [1] handle " LOG_RED "[%s]" LOG_END,
+ if (ret == WIFI_MANAGER_ERROR_NONE) {
+ wifi_manager_get_network_interface_name(g_wifi_h, &if_name);
+ msg(LOG_GREEN "[1:%s] Succeeded to deinitialize wifi handle" LOG_END, if_name);
+ FREE(if_name);
+ } else
+ msg("[1] Failed to deinitialize wifi handle " LOG_RED "[%s]" LOG_END,
test_wifi_mgr_convert_error_to_string(ret));
}
else
ret = wifi_manager_deinitialize(g_wifi2_h);
- if (ret == WIFI_MANAGER_ERROR_NONE)
- msg(LOG_GREEN "Succeeded to deinitialize wifi2 handle" LOG_END);
- else
- msg("Failed to deinitialize wifi [2] handle " LOG_RED "[%s]" LOG_END,
+ if (ret == WIFI_MANAGER_ERROR_NONE) {
+ wifi_manager_get_network_interface_name(g_wifi_h, &if_name);
+ msg(LOG_GREEN "[2:%s] Succeeded to deinitialize wifi handle" LOG_END, if_name);
+ FREE(if_name);
+ } else
+ msg("[2] Failed to deinitialize wifi handle " LOG_RED "[%s]" LOG_END,
test_wifi_mgr_convert_error_to_string(ret));
}
return ret;
}
-static gboolean _test_wifi_mgr_create_init_menu(struct menu_data init_menu[2])
+static gboolean _test_wifi_mgr_create_init_menu(struct menu_data init_menu[5])
{
- init_menu[0].key = "1";
- init_menu[0].title = LOG_YELLOW "Wifi Mgr Init" LOG_END;
- init_menu[0].sub_menu = menu_main;
- init_menu[0].callback = _test_wifi_mgr_initialize;
- init_menu[0].data = NULL;
+ init_menu[0].key = "0";
+ init_menu[0].title = LOG_LIGHTGREEN "[Interface Name]" LOG_END;
+ init_menu[0].sub_menu = NULL;
+ init_menu[0].callback = NULL;
+ init_menu[0].data = g_ifname;
- init_menu[1].key = "2";
- init_menu[1].title = LOG_YELLOW "Wifi Mgr Init for C#" LOG_END;
+ init_menu[1].key = "1";
+ init_menu[1].title = LOG_YELLOW "Wifi Mgr Init" LOG_END;
init_menu[1].sub_menu = menu_main;
- init_menu[1].callback = _test_wifi_mgr_initialize_cs;
+ init_menu[1].callback = _test_wifi_mgr_initialize;
init_menu[1].data = NULL;
+ init_menu[2].key = "2";
+ init_menu[2].title = LOG_YELLOW "Wifi Mgr Init for C#" LOG_END;
+ init_menu[2].sub_menu = menu_main;
+ init_menu[2].callback = _test_wifi_mgr_initialize_cs;
+ init_menu[2].data = NULL;
+
+ init_menu[3].key = "3";
+ init_menu[3].title = LOG_YELLOW "Wifi Mgr Init with ifname" LOG_END;
+ init_menu[3].sub_menu = menu_main;
+ init_menu[3].callback = _test_wifi_mgr_initialize_with_ifname;
+ init_menu[3].data = NULL;
+
return TRUE;
}
GMainLoop *mainloop = NULL;
GIOChannel *channel = g_io_channel_unix_new(STDIN_FILENO);
MManager *manager;
- struct menu_data init_menu[2+1] = { {NULL, NULL, NULL, } };
+ struct menu_data init_menu[5] = { {NULL, NULL, NULL, } };
#if !GLIB_CHECK_VERSION(2, 35, 0)
g_type_init();