Refactoring
authorChengyi Zhao <chengyi1.zhao@archermind.com>
Wed, 18 Jun 2014 07:34:01 +0000 (15:34 +0800)
committerZhang zhengguang <zhengguang.zhang@intel.com>
Thu, 26 Jun 2014 06:16:16 +0000 (14:16 +0800)
12 files changed:
CMakeLists.txt
include/net_wifi_private.h [deleted file]
include/wifi.h
src/include/common.h [new file with mode: 0644]
src/include/wifi-internal.h [new file with mode: 0644]
src/libnetwork.c [deleted file]
src/net_wifi.c [deleted file]
src/net_wifi_ap.c [deleted file]
src/wifi-ap.c [new file with mode: 0755]
src/wifi-internal.c [new file with mode: 0755]
src/wifi.c [new file with mode: 0755]
test/wifi_test.c

index abadd9ba0865fa7ae2af3e664739f035fcd62897..9a072fa1e42842179241fd3596cffd55e6f2e19b 100644 (file)
@@ -7,7 +7,9 @@ SET(CMAKE_INSTALL_PREFIX /usr)
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
 SET(INC_DIR include)
-INCLUDE_DIRECTORIES(${INC_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/${INC_DIR}/)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/include/)
+
 
 SET(dependents "dlog vconf capi-base-common glib-2.0 winet-lib connman-lib")
 SET(pc_dependents "capi-base-common")
diff --git a/include/net_wifi_private.h b/include/net_wifi_private.h
deleted file mode 100644 (file)
index ce7a1fe..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * 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 __NET_CONNECTION_PRIVATE_H__
-#define __NET_CONNECTION_PRIVATE_H__
-
-#include <dlog.h>
-
-#include <connman-lib.h>
-#include <connman-manager.h>
-#include <connman-technology.h>
-#include <connman-service.h>
-
-#include "wifi.h"
-#include "common_private.h"
-
-#undef LOG_TAG
-#define LOG_TAG "CAPI_NETWORK_WIFI"
-
-#define WIFI_INFO      1
-#define WIFI_ERROR     2
-#define WIFI_WARN      3
-
-#define WIFI_LOG(log_level, format, args...) \
-       do { \
-               switch (log_level) { \
-               case WIFI_ERROR: \
-                       LOGE(format, ## args); \
-                       break; \
-               case WIFI_WARN: \
-                       LOGW(format, ## args); \
-                       break; \
-               default: \
-                       LOGI(format, ## args); \
-               } \
-       } while(0)
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/*****************************************************************************
- *     Global Structures
- *****************************************************************************/
-/**
- * This is the structure to connect with WPS network.
- */
-typedef struct {
-       /** PBC / PIN */
-       net_wifi_wps_type_t type;
-
-       /** Optional. This pin is needed when the user input PIN code */
-       char pin[NET_WLAN_MAX_WPSPIN_LEN + 1];
-} net_wifi_wps_info_t;
-
-/**
- * This is the profile structure to connect hidden WiFi network.
- */
-typedef struct {
-       /** Basic feature */
-       char essid[NET_WLAN_ESSID_LEN + 1];
-
-       /** Infrastructure / ad-hoc / auto mode */
-       wlan_connection_mode_type_t wlan_mode;
-
-       /** Security mode and authentication info */
-       wlan_security_info_t security_info;
-} net_wifi_connection_info_t;
-
-/**
- * This is the profile structure exposed to applications.
- */
-typedef struct
-{
-       /** Profile name */
-       char *essid;
-} net_profile_info_t;
-
-
-bool _wifi_libnet_init(void);
-bool _wifi_libnet_deinit(void);
-int _wifi_activate(wifi_activated_cb callback, void *user_data);
-int _wifi_deactivate(wifi_deactivated_cb callback, void *user_data);
-
-bool _wifi_libnet_check_ap_validity(wifi_ap_h ap_h);
-void _wifi_libnet_add_to_ap_list(wifi_ap_h ap_h);
-void _wifi_libnet_remove_from_ap_list(wifi_ap_h ap_h);
-bool _wifi_libnet_check_profile_name_validity(const char *profile_name);
-
-bool _wifi_libnet_get_wifi_device_state(wifi_device_state_e *device_state);
-bool _wifi_libnet_get_wifi_state(wifi_connection_state_e* connection_state);
-int _wifi_libnet_get_intf_name(char** name);
-int _wifi_libnet_scan_request(wifi_scan_finished_cb callback, void *user_data);
-int _wifi_libnet_scan_hidden_ap(const char *essid,
-                                       wifi_scan_finished_cb callback, void *user_data);
-int _wifi_libnet_get_connected_profile(wifi_ap_h *ap);
-bool _wifi_libnet_foreach_found_aps(wifi_found_ap_cb callback, void *user_data);
-bool _wifi_libnet_foreach_found_hidden_aps(wifi_found_ap_cb callback, void *user_data);
-
-int _wifi_libnet_open_profile(wifi_ap_h ap_h, wifi_connected_cb callback, void *user_data);
-int _wifi_libnet_close_profile(wifi_ap_h ap_h, wifi_disconnected_cb callback, void *user_data);
-int _wifi_libnet_connect_with_wps(wifi_ap_h ap, wifi_connected_cb callback, void *user_data);
-int _wifi_libnet_forget_ap(wifi_ap_h ap);
-
-int _wifi_set_power_on_off_cb(wifi_device_state_changed_cb callback, void *user_data);
-int _wifi_unset_power_on_off_cb(void);
-int _wifi_set_background_scan_cb(wifi_scan_finished_cb callback, void *user_data);
-int _wifi_unset_background_scan_cb(void);
-int _wifi_set_connection_state_cb(wifi_connection_state_changed_cb callback, void *user_data);
-int _wifi_unset_connection_state_cb();
-
-/*int _wifi_update_ap_info(net_profile_info_t *ap_info);*/
-wifi_connection_state_e _wifi_convert_to_ap_state(
-                                       net_state_type_t state);
-
-net_state_type_t _get_service_state_type(const char *state);
-
-/*For connection which CAPI send some message to WiNet daemon*/
-void _set_wifi_conn_info(net_wifi_connection_info_t *wifi_conn_info);
-net_wifi_connection_info_t *_get_wifi_conn_info(void);
-
-const char *_get_ip_config_str(net_ip_config_type_t ip_config_type);
-net_ip_config_type_t _get_ip_config_type(const char *config);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif
index fcf3add37685ba5979edcafadf20c0340c9ca84f..18d041356dd7dae37ce5b407ebb004fb427bcad5 100644 (file)
@@ -807,7 +807,7 @@ int wifi_ap_get_connection_state(wifi_ap_h ap, wifi_connection_state_e* state);
 * @retval #WIFI_ERROR_OPERATION_FAILED  Operation failed
 * @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED  Address family not supported
 */
-int wifi_ap_get_ip_config_type(wifi_ap_h ap, wifi_address_family_e address_family, wifi_ip_config_type_e* type);
+int wifi_ap_wifi_get_ip_config_type(wifi_ap_h ap, wifi_address_family_e address_family, wifi_ip_config_type_e* type);
 
 /**
 * @brief Sets the config type of IP.
diff --git a/src/include/common.h b/src/include/common.h
new file mode 100644 (file)
index 0000000..3b35052
--- /dev/null
@@ -0,0 +1,558 @@
+/*
+* Network Wi-Fi library
+*
+* Copyright (c) 2014-2015 Intel Corporation. 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_PM_WLAN_H__
+#define __NETWORK_PM_WLAN_H__
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+/**  \file network-pm-wlan.h
+     \brief This file contains constants, enums, tructs, and function prototypes that are used by Wlan related sources internally. This File defines the WLAN exported Data Structures.
+
+*/
+
+/**
+ * \addtogroup  profile_managing
+ * \{
+*/
+
+/*
+==================================================================================================
+                                           CONSTANTS
+==================================================================================================
+*/
+
+/** Maximum length of MAC address  */
+#define        NET_MAX_MAC_ADDR_LEN 32   /*ADDED:*/
+
+/** Length of essid */
+#define NET_WLAN_ESSID_LEN      128
+
+/**
+ * Length of WPS PIN code
+ * WPS PIN code should be 4 or 8 digits
+ */
+#define NET_WLAN_MAX_WPSPIN_LEN                8
+
+/**
+ * Passphrase length should be between 8..63,
+ * If we plan to use encrypted key(hex value generated by wpa_passphrase),
+ * then we have to set this value to some higher number
+ *
+ */
+#define NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN 65
+
+/**
+ * Length of WEP Key
+ * Max of 10 Hex digits allowed in case of 64 bit encryption
+ * Max of 26 Hex digits allowed in case of 128 bit encryption
+ */
+#define NETPM_WLAN_MAX_WEP_KEY_LEN        26
+
+/**
+ * These lengths depends on authentication server being used,
+ * In case of freeradius server Max allowed length for username/password is 255
+ * Let us restrict this value to some optimal value say 50.
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NETPM_WLAN_USERNAME_LEN               50
+
+/**
+ * These lengths depends on authentication server being used,
+ * In case of freeradius server Max allowed length for username/password is 255
+ * Let us restrict this value to some optimal value say 50.
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NETPM_WLAN_PASSWORD_LEN               50
+
+/**
+ * length of CA Cert file name
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NETPM_WLAN_CA_CERT_FILENAME_LEN       50
+
+/**
+ * length of Client Cert file name
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NETPM_WLAN_CLIENT_CERT_FILENAME_LEN   50
+
+/**
+ * length of private key file name
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NETPM_WLAN_PRIVATE_KEY_FILENAME_LEN   50
+
+/**
+ * length of Private key password
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NETPM_WLAN_PRIVATE_KEY_PASSWD_LEN     50
+
+/*==================================================================================================
+                                             ENUMS
+==================================================================================================*/
+/*
+ * Added:Begin
+ */
+typedef enum {
+       /** No error */
+       NET_ERR_NONE = 0x00,
+
+       /* Common Error value */
+
+       /** Error unknown */
+       NET_ERR_UNKNOWN = -999,
+
+       /* Client Register related Errors used in API return */
+
+       /** Application is already registered */
+       NET_ERR_APP_ALREADY_REGISTERED = -990,
+       /** Application is not registered */
+       NET_ERR_APP_NOT_REGISTERED = -989,
+
+       /* Connection Related Error */
+
+       /** No active connection exists for the given profile name */
+       NET_ERR_NO_ACTIVE_CONNECTIONS = -899,
+       /** Active connection already exists for the given profile name  */
+       NET_ERR_ACTIVE_CONNECTION_EXISTS = -898,
+
+       /** Connection failure : out of range */
+       NET_ERR_CONNECTION_OUT_OF_RANGE = -897,
+       /** Connection failure : pin missing */
+       NET_ERR_CONNECTION_PIN_MISSING = -896,
+       /** Connection failure : dhcp failed */
+       NET_ERR_CONNECTION_DHCP_FAILED = -895,
+       /** Connection failure */
+       NET_ERR_CONNECTION_CONNECT_FAILED = -894,
+       /** Connection failure : login failed */
+       NET_ERR_CONNECTION_LOGIN_FAILED = -893,
+       /** Connection failure : authentication failed */
+       NET_ERR_CONNECTION_AUTH_FAILED = -892,
+       /** Connection failure : invalid key */
+       NET_ERR_CONNECTION_INVALID_KEY = -891,
+
+       /* Other Error */
+
+       /** Access(permission) denied */
+       NET_ERR_ACCESS_DENIED = -799,
+       /** Operation is in progress */
+       NET_ERR_IN_PROGRESS = -798,
+       /** Operation was aborted by client or network*/
+       NET_ERR_OPERATION_ABORTED = -797,
+       /** Invalid value of API parameter */
+       NET_ERR_INVALID_PARAM = -796,
+       /** Invalid operation depending on current state */
+       NET_ERR_INVALID_OPERATION = -795,
+
+       /** Feature not supported */
+       NET_ERR_NOT_SUPPORTED = -794,
+       /** TimeOut Error */
+       NET_ERR_TIME_OUT = -793,
+       /** Network service is not available */
+       NET_ERR_NO_SERVICE = -792,
+       /** DBus can't find appropriate method */
+       NET_ERR_UNKNOWN_METHOD = -791,
+       /** Operation is restricted */
+       NET_ERR_SECURITY_RESTRICTED = -790,
+       /** Already exists */
+       NET_ERR_ALREADY_EXISTS = -789,
+
+       /** WiFi driver on/off failed */
+       NET_ERR_WIFI_DRIVER_FAILURE = -699,
+       NET_ERR_WIFI_DRIVER_LOAD_INPROGRESS = -698,
+} net_err_t;
+
+/**
+* @enum net_wifi_state_t
+* This enum indicates wifi state
+*/
+typedef enum {
+       /** Unknown state */
+       WIFI_UNKNOWN = 0x00,
+       /** Wi-Fi is Off */
+       WIFI_OFF,
+       /** Wi-Fi is On(idle/failure) */
+       WIFI_ON,
+       /** Trying to connect(association/configuration) */
+       WIFI_CONNECTING,
+       /** Wi-Fi is connected to an AP(ready/online) */
+       WIFI_CONNECTED,
+       /** Trying to disconnect(connected, but disconnecting process is on going) */
+       WIFI_DISCONNECTING,
+} net_wifi_state_t;
+
+/**
+*@enum net_wifi_background_scan_mode_t
+* This enum indicates background scanning mode.
+*/
+typedef enum {
+       /** scan cycle : 4, 8, 16, ...128s */
+       WIFI_BGSCAN_MODE_EXPONENTIAL = 0x00,
+       /** scan cycle : 10s */
+       WIFI_BGSCAN_MODE_PERIODIC,
+} net_wifi_background_scan_mode_t;
+
+/**
+*@enum net_wifi_wps_type_t
+* This enum indicates WPS type.
+*/
+typedef enum
+{
+       /** WPS type is PBC */
+       WIFI_WPS_PBC = 0x00,
+       /** WPS type is PIN */
+       WIFI_WPS_PIN
+} net_wifi_wps_type_t;
+
+/**
+ * @enum net_proxy_type_t
+ * This enumeration defines the proxy method type.
+ */
+typedef enum
+{
+       /** Not defined */
+       NET_PROXY_TYPE_UNKNOWN  = 0x00,
+       /** Direct connection */
+       NET_PROXY_TYPE_DIRECT = 0x01,
+       /** Auto configuration(Use PAC file)
+        *  If URL property is not set, DHCP/WPAD auto-discover will be tried */
+       NET_PROXY_TYPE_AUTO = 0x02,
+       /** Manual configuration */
+       NET_PROXY_TYPE_MANUAL= 0x03,
+} net_proxy_type_t;
+
+/**
+ * @enum net_ip_config_type_t
+ * Net IP configuration Type
+ */
+typedef enum
+{
+       /** Manual IP configuration */
+       NET_IP_CONFIG_TYPE_STATIC = 0x01,
+
+       /** Config ip using DHCP client*/
+       NET_IP_CONFIG_TYPE_DYNAMIC,
+
+       /** Config IP from Auto IP pool (169.254/16)
+        * Later with DHCP client, if available */
+       NET_IP_CONFIG_TYPE_AUTO_IP,
+
+       /** Indicates an IP address that can not be modified */
+       NET_IP_CONFIG_TYPE_FIXED,
+
+       /** Don't use any method */
+       NET_IP_CONFIG_TYPE_OFF,
+} net_ip_config_type_t;
+
+/**
+ * @enum net_state_type_t
+ * This enumeration defines the service state type.
+ */
+typedef enum
+{
+       /** Not defined */
+       NET_STATE_TYPE_UNKNOWN  = 0x00,
+       /** Idle state */
+       NET_STATE_TYPE_IDLE,
+       /** Failure state */
+       NET_STATE_TYPE_FAILURE,
+       /** Association state */
+       NET_STATE_TYPE_ASSOCIATION,
+       /** Configuration state */
+       NET_STATE_TYPE_CONFIGURATION,
+       /** Ready state */
+       NET_STATE_TYPE_READY,
+       /** Online state */
+       NET_STATE_TYPE_ONLINE,
+       /** Login state */
+       NET_STATE_TYPE_DISCONNECT,
+} net_state_type_t;
+
+/**
+ * @enum connman_service_state_type
+ * This enumeration defines the service state type for adaptering CAPI
+ */
+enum connman_service_state_type
+{
+       /** Not defined */
+       SERVICE_STATE_UNKNOWN   = 0x00,
+       /** Idle state */
+       SERVICE_STATE_IDLE,
+       /** Failure state */
+       SERVICE_STATE_FAILURE,
+       /** Association state */
+       SERVICE_STATE_ASSOCIATION,
+       /** Configuration state */
+       SERVICE_STATE_CONFIGURATION,
+       /** Ready state */
+       SERVICE_STATE_READY,
+       /** Online state */
+       SERVICE_STATE_ONLINE,
+       /** Login state */
+       SERVICE_STATE_DISCONNECT,
+};
+/*
+ * Added:End
+ */
+
+/**
+ * @enum wlan_security_mode_type_t
+ * Below security modes are used in infrastructure and ad-hoc mode
+ * For now all EAP security mechanisms are provided only in infrastructure mode
+ */
+typedef enum
+{
+       /** Security disabled */
+       WLAN_SEC_MODE_NONE = 0x01,
+       /** WEP */
+       WLAN_SEC_MODE_WEP,
+       /** EAP */
+       WLAN_SEC_MODE_IEEE8021X,
+       /** WPA-PSK */
+       WLAN_SEC_MODE_WPA_PSK,
+       /** WPA2-PSK */
+       WLAN_SEC_MODE_WPA2_PSK,
+} wlan_security_mode_type_t;
+
+/**
+ * @enum wlan_encryption_mode_type_t
+ * Below encryption modes are used in infrastructure and ad-hoc mode
+ */
+typedef enum
+{
+       /** Encryption disabled */
+       WLAN_ENC_MODE_NONE = 0x01,
+       /** WEP */
+       WLAN_ENC_MODE_WEP,
+       /** TKIP */
+       WLAN_ENC_MODE_TKIP,
+       /** AES */
+       WLAN_ENC_MODE_AES,
+       /** TKIP and AES are both supported */
+       WLAN_ENC_MODE_TKIP_AES_MIXED,
+} wlan_encryption_mode_type_t;
+
+/**
+ * @enum wlan_connection_mode_type_t
+ * WLAN Operation Mode
+ * @see net_pm_wlan_profile_info_t
+ */
+typedef enum
+{
+       /** auto connection mode */
+       NETPM_WLAN_CONNMODE_AUTO = 0x01,
+       /** Connection mode Adhoc  */
+       NETPM_WLAN_CONNMODE_ADHOC,
+       /** Infra connection mode */
+       NETPM_WLAN_CONNMODE_INFRA,
+} wlan_connection_mode_type_t;
+
+
+/**
+ * @enum wlan_eap_type_t
+ * EAP type
+ * @see wlan_eap_info_t
+ */
+typedef enum {
+       /** EAP PEAP type */
+       WLAN_SEC_EAP_TYPE_PEAP = 0x01,
+       /** EAP TLS type */
+       WLAN_SEC_EAP_TYPE_TLS,
+       /** EAP TTLS type */
+       WLAN_SEC_EAP_TYPE_TTLS,
+       /** EAP SIM type */
+       WLAN_SEC_EAP_TYPE_SIM,
+       /** EAP AKA type */
+       WLAN_SEC_EAP_TYPE_AKA,
+} wlan_eap_type_t;
+
+/**
+ * @enum wlan_eap_auth_type_t
+ * EAP phase2 authentication type
+ * @see wlan_eap_info_t
+ */
+typedef enum {
+       /** EAP phase2 authentication none */
+       WLAN_SEC_EAP_AUTH_NONE = 0x01,
+       /** EAP phase2 authentication PAP */
+       WLAN_SEC_EAP_AUTH_PAP,
+       /** EAP phase2 authentication MSCHAP */
+       WLAN_SEC_EAP_AUTH_MSCHAP,
+       /** EAP phase2 authentication MSCHAPv2 */
+       WLAN_SEC_EAP_AUTH_MSCHAPV2,
+       /** EAP phase2 authentication GTC */
+       WLAN_SEC_EAP_AUTH_GTC,
+       /** EAP phase2 authentication MD5 */
+       WLAN_SEC_EAP_AUTH_MD5,
+} wlan_eap_auth_type_t;
+
+/*
+==================================================================================================
+                                            MACROS
+==================================================================================================
+*/
+
+
+/*==================================================================================================
+                                 STRUCTURES AND OTHER TYPEDEFS
+==================================================================================================*/
+
+/**
+ * Below structure is used to export essid
+ */
+typedef struct
+{
+       /** ESSID */
+       char essid[NET_WLAN_ESSID_LEN+1];
+} net_essid_t;
+
+/**
+ * Below structure is used by WPA-PSK or WPA2-PSK
+ * @remark To see the maximum length of PSK passphrase key.
+ * @see wlan_auth_info_t
+ */
+typedef struct
+{
+       /** key value for WPA-PSK or WPA2-PSK */
+       char pskKey[NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN + 1];
+} wlan_psk_info_t;
+
+/**
+ * Below structure is used by WEP
+ * @remark To see the maximum length of WEP key.
+ * @see wlan_auth_info_t
+ */
+typedef struct
+{
+       /** key value for WEP */
+       char wepKey[NETPM_WLAN_MAX_WEP_KEY_LEN + 1];
+} wlan_wep_info_t;
+
+/**
+ * Below structure is used by EAP
+ * @see wlan_auth_info_t
+ */
+typedef struct
+{
+       /** User name */
+       char username[NETPM_WLAN_USERNAME_LEN+1];
+       /** Password */
+       char password[NETPM_WLAN_PASSWORD_LEN+1];
+
+       /**
+        * Following fields are mandatory for EAP-TLS,
+        * Optional for EAP-TTLS and EAP-PEAP
+        */
+       /**
+        * For EAP-TTLS and EAP-PEAP only ca_cert_filename[] can also be provided
+        */
+       /* Used to authenticate server */
+       char ca_cert_filename[NETPM_WLAN_CA_CERT_FILENAME_LEN+1];
+       /** client certificate file name */
+       char client_cert_filename[NETPM_WLAN_CLIENT_CERT_FILENAME_LEN+1];
+       /** private key file name */
+       char private_key_filename[NETPM_WLAN_PRIVATE_KEY_FILENAME_LEN+1];
+       /** private key password */
+       char private_key_passwd[NETPM_WLAN_PRIVATE_KEY_PASSWD_LEN+1];
+
+       /** eap type */
+       wlan_eap_type_t eap_type;
+       /** eap phase2 authentication type */
+       wlan_eap_auth_type_t eap_auth;
+} wlan_eap_info_t;
+
+/**
+ * At any point of time only one security mechanism is supported
+ * @see wlan_security_info_t
+ */
+typedef union
+{
+       /** Wep Authentication */
+       wlan_wep_info_t wep;
+       /** psk Authentication */
+       wlan_psk_info_t psk;
+       /** eap Authentication */
+       wlan_eap_info_t eap;
+} wlan_auth_info_t;
+
+/**
+ * This is main security information structure
+ * @see net_pm_wlan_profile_info_t
+ */
+typedef struct
+{
+       /** security mode type */
+       wlan_security_mode_type_t sec_mode;
+       /** encryption mode type */
+       wlan_encryption_mode_type_t enc_mode;
+       /** authentication information */
+       wlan_auth_info_t authentication;
+       /** If WPS is supported, then this property will be set to TRUE */
+       char wps_support;
+} wlan_security_info_t;
+
+/**
+ * This is the structure to connect with WPS network.
+ */
+typedef struct {
+       /** PBC / PIN */
+       net_wifi_wps_type_t type;
+
+       /** Optional. This pin is needed when the user input PIN code */
+       char pin[NET_WLAN_MAX_WPSPIN_LEN + 1];
+} net_wifi_wps_info_t;
+
+/**
+ * This is the profile structure to connect hidden WiFi network.
+ */
+typedef struct {
+       /** Basic feature */
+       char essid[NET_WLAN_ESSID_LEN + 1];
+
+       /** Infrastructure / ad-hoc / auto mode */
+       wlan_connection_mode_type_t wlan_mode;
+
+       /** Security mode and authentication info */
+       wlan_security_info_t security_info;
+} net_wifi_connection_info_t;
+
+/**
+ * This is the profile structure exposed to applications.
+ */
+typedef struct
+{
+       /** Profile name */
+       char *essid;
+} net_profile_info_t;
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NETPM_WLAN_H__ */
diff --git a/src/include/wifi-internal.h b/src/include/wifi-internal.h
new file mode 100644 (file)
index 0000000..ffa74e5
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+* Network Wi-Fi library
+*
+* Copyright (c) 2014-2015 Intel Corporation. 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 __NET_CONNECTION_PRIVATE_H__
+#define __NET_CONNECTION_PRIVATE_H__
+
+#include "wifi.h"
+#include "common.h"
+
+#define LOGI(fmt, arg...) printf("%s:%d %s() " fmt "\n",  \
+                               __FILE__, __LINE__, __func__, ## arg)
+#define LOGW(fmt, arg...) printf("warning %s:%d %s() " fmt "\n", \
+                               __FILE__, __LINE__, __func__, ## arg)
+#define LOGE(fmt, arg...) printf("error %s:%d %s() " fmt "\n", \
+                               __FILE__, __LINE__, __func__, ## arg)
+
+#undef LOG_TAG
+#define LOG_TAG "CAPI_NETWORK_WIFI"
+
+#define WIFI_INFO      1
+#define WIFI_ERROR     2
+#define WIFI_WARN      3
+
+#define WIFI_LOG(log_level, format, args...) \
+       do { \
+               switch (log_level) { \
+               case WIFI_ERROR: \
+                       LOGE(format, ## args); \
+                       break; \
+               case WIFI_WARN: \
+                       LOGW(format, ## args); \
+                       break; \
+               default: \
+                       LOGI(format, ## args); \
+               } \
+       } while(0)
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+bool _wifi_libnet_init(void);
+bool _wifi_libnet_deinit(void);
+int _wifi_activate(wifi_activated_cb callback, void *user_data);
+int _wifi_deactivate(wifi_deactivated_cb callback, void *user_data);
+
+bool _wifi_libnet_check_ap_validity(wifi_ap_h ap_h);
+void _wifi_libnet_add_to_ap_list(wifi_ap_h ap_h);
+void _wifi_libnet_remove_from_ap_list(wifi_ap_h ap_h);
+bool _wifi_libnet_check_profile_name_validity(const char *profile_name);
+
+bool _wifi_libnet_get_wifi_device_state(wifi_device_state_e *device_state);
+bool _wifi_libnet_get_wifi_state(wifi_connection_state_e* connection_state);
+int _wifi_libnet_get_intf_name(char** name);
+int _wifi_libnet_scan_request(wifi_scan_finished_cb callback, void *user_data);
+int _wifi_libnet_scan_hidden_ap(const char *essid,
+                                       wifi_scan_finished_cb callback, void *user_data);
+int _wifi_libnet_get_connected_profile(wifi_ap_h *ap);
+bool _wifi_libnet_foreach_found_aps(wifi_found_ap_cb callback, void *user_data);
+bool _wifi_libnet_foreach_found_hidden_aps(wifi_found_ap_cb callback, void *user_data);
+
+int _wifi_libnet_open_profile(wifi_ap_h ap_h, wifi_connected_cb callback, void *user_data);
+int _wifi_libnet_close_profile(wifi_ap_h ap_h, wifi_disconnected_cb callback, void *user_data);
+int _wifi_libnet_connect_with_wps(wifi_ap_h ap, wifi_connected_cb callback, void *user_data);
+int _wifi_libnet_forget_ap(wifi_ap_h ap);
+
+int _wifi_set_power_on_off_cb(wifi_device_state_changed_cb callback, void *user_data);
+int _wifi_unset_power_on_off_cb(void);
+int _wifi_set_background_scan_cb(wifi_scan_finished_cb callback, void *user_data);
+int _wifi_unset_background_scan_cb(void);
+int _wifi_set_connection_state_cb(wifi_connection_state_changed_cb callback, void *user_data);
+int _wifi_unset_connection_state_cb();
+
+wifi_connection_state_e _wifi_convert_to_ap_state(
+                                       net_state_type_t state);
+net_state_type_t _wifi_get_service_state_type(const char *state);
+
+/*For connection which CAPI send some message to WiNet daemon*/
+void _wifi_set_conn_info(net_wifi_connection_info_t *wifi_conn_info);
+net_wifi_connection_info_t *_wifi_get_conn_info(void);
+
+char *_wifi_get_ip_config_str(net_ip_config_type_t ip_config_type);
+net_ip_config_type_t _wifi_get_ip_config_type(const char *config);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
diff --git a/src/libnetwork.c b/src/libnetwork.c
deleted file mode 100755 (executable)
index 5344a2b..0000000
+++ /dev/null
@@ -1,1767 +0,0 @@
-/*
- * 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.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <glib.h>
-#include "net_wifi_private.h"
-
-#include <winet-wifi.h>
-
-static GSList *ap_handle_list = NULL;
-
-typedef struct {
-       char *type;
-       char *mode;
-       char *ssid;
-       char *security;
-       char *passphrase;
-       char *eap_type;
-       char *eap_auth;
-       char *identity;
-       char *password;
-       char *ca_cert_file;
-       char *client_cert_file;
-       char *private_key_file;
-       char *private_key_password;
-} net_wifi_connect_service_info_t;
-
-struct _wifi_cb_s {
-       wifi_device_state_changed_cb device_state_cb;
-       void *device_state_user_data;
-       wifi_scan_finished_cb bg_scan_cb;
-       void *bg_scan_user_data;
-       wifi_scan_finished_cb scan_request_cb;
-       void *scan_request_user_data;
-       wifi_scan_finished_cb scan_hidden_ap_cb;
-       void *scan_hidden_ap_user_data;
-       wifi_connection_state_changed_cb connection_state_cb;
-       void *connection_state_user_data;
-       wifi_activated_cb activated_cb;
-       void *activated_user_data;
-       wifi_deactivated_cb deactivated_cb;
-       void *deactivated_user_data;
-       wifi_connected_cb connected_cb;
-       void *connected_user_data;
-       wifi_disconnected_cb disconnected_cb;
-       void *disconnected_user_data;
-};
-
-struct _profile_list_s {
-       int count;
-       char *profiles;
-};
-
-static struct _wifi_cb_s wifi_callbacks = {0,};
-static struct _profile_list_s profile_iterator = {0, NULL};
-static struct _profile_list_s hidden_profile_iterator = {0, NULL};
-
-/*For connection which CAPI send some message to WiNet daemon*/
-static net_wifi_connection_info_t net_wifi_conn_info;
-
-/*For connection which CAPI send some message to WiNet daemon*/
-void _set_wifi_conn_info(net_wifi_connection_info_t *wifi_conn_info)
-{
-       g_strlcpy(net_wifi_conn_info.essid, wifi_conn_info->essid,
-                                       NET_WLAN_ESSID_LEN+1);
-       net_wifi_conn_info.wlan_mode = wifi_conn_info->wlan_mode;
-       memcpy(&net_wifi_conn_info.security_info,
-                                       &wifi_conn_info->security_info,
-                                       sizeof(wlan_security_info_t));
-}
-
-/*For connection which CAPI send some message to WiNet daemon*/
-net_wifi_connection_info_t *_get_wifi_conn_info(void)
-{
-       return &net_wifi_conn_info;
-}
-
-net_state_type_t _get_service_state_type(const char *state)
-{
-       if (!g_strcmp0(state, "idle"))
-               return NET_STATE_TYPE_IDLE;
-       else if (!g_strcmp0(state, "association"))
-               return NET_STATE_TYPE_ASSOCIATION;
-       else if (!g_strcmp0(state, "configuration"))
-               return NET_STATE_TYPE_CONFIGURATION;
-       else if (!g_strcmp0(state, "ready"))
-               return NET_STATE_TYPE_READY;
-       else if (!g_strcmp0(state, "online"))
-               return NET_STATE_TYPE_ONLINE;
-       else if (!g_strcmp0(state, "disconnect"))
-               return NET_STATE_TYPE_DISCONNECT;
-       else if (!g_strcmp0(state, "failure"))
-               return NET_STATE_TYPE_FAILURE;
-       else
-               return NET_STATE_TYPE_UNKNOWN;
-}
-
-net_ip_config_type_t _get_ip_config_type(const char *config)
-{
-       net_ip_config_type_t config_type;
-
-       if (!g_strcmp0(config, "manual"))
-               config_type = NET_IP_CONFIG_TYPE_STATIC;
-       else if (!g_strcmp0(config, "dhcp"))
-               config_type = NET_IP_CONFIG_TYPE_AUTO_IP;
-       else if (!g_strcmp0(config, "fixed"))
-               config_type = NET_IP_CONFIG_TYPE_FIXED;
-       else if (!g_strcmp0(config, "off"))
-               config_type = NET_IP_CONFIG_TYPE_OFF;
-       else
-               config_type = NET_IP_CONFIG_TYPE_DYNAMIC;
-
-       return config_type;
-}
-
-const char *_get_ip_config_str(net_ip_config_type_t ip_config_type)
-{
-       switch (ip_config_type) {
-       case NET_IP_CONFIG_TYPE_STATIC:
-               return "manual";
-       case NET_IP_CONFIG_TYPE_DYNAMIC:
-               return "dhcp";
-       case NET_IP_CONFIG_TYPE_AUTO_IP:
-               return "dhcp";
-       case NET_IP_CONFIG_TYPE_FIXED:
-               return "fixed";
-       case NET_IP_CONFIG_TYPE_OFF:
-               return "off";
-       }
-
-       return NULL;
-}
-
-/*static wifi_error_e __libnet_convert_to_ap_error_type(net_err_t err_type)
-{
-       switch (err_type) {
-       case NET_ERR_NONE:
-               return WIFI_ERROR_NONE;
-       case NET_ERR_APP_ALREADY_REGISTERED:
-               return WIFI_ERROR_INVALID_OPERATION;
-       case NET_ERR_APP_NOT_REGISTERED:
-               return WIFI_ERROR_INVALID_OPERATION;
-       case NET_ERR_NO_ACTIVE_CONNECTIONS:
-               return WIFI_ERROR_NO_CONNECTION;
-       case NET_ERR_ACTIVE_CONNECTION_EXISTS:
-               return WIFI_ERROR_ALREADY_EXISTS;
-       case NET_ERR_CONNECTION_DHCP_FAILED:
-               return WIFI_ERROR_DHCP_FAILED;
-       case NET_ERR_CONNECTION_INVALID_KEY:
-               return WIFI_ERROR_INVALID_KEY;
-       case NET_ERR_IN_PROGRESS:
-               return WIFI_ERROR_NOW_IN_PROGRESS;
-       case NET_ERR_OPERATION_ABORTED:
-               return WIFI_ERROR_OPERATION_ABORTED;
-       case NET_ERR_TIME_OUT:
-               return WIFI_ERROR_NO_REPLY;
-       default:
-               return WIFI_ERROR_OPERATION_FAILED;
-       }
-}
-
-static const char *__libnet_convert_ap_error_type_to_string(wifi_error_e err_type)
-{
-       switch (err_type) {
-       case WIFI_ERROR_NONE:
-               return "NONE";
-       case WIFI_ERROR_INVALID_PARAMETER:
-               return "INVALID_PARAMETER";
-       case WIFI_ERROR_OUT_OF_MEMORY:
-               return "OUT_OF_MEMORY";
-       case WIFI_ERROR_INVALID_OPERATION:
-               return "INVALID_OPERATION";
-       case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
-               return "ADDRESS_FAMILY_NOT_SUPPORTED";
-       case WIFI_ERROR_OPERATION_FAILED:
-               return "OPERATION_FAILED";
-       case WIFI_ERROR_NO_CONNECTION:
-               return "NO_CONNECTION";
-       case WIFI_ERROR_NOW_IN_PROGRESS:
-               return "NOW_IN_PROGRESS";
-       case WIFI_ERROR_ALREADY_EXISTS:
-               return "ALREADY_EXISTS";
-       case WIFI_ERROR_OPERATION_ABORTED:
-               return "OPERATION_ABORTED";
-       case WIFI_ERROR_DHCP_FAILED:
-               return "DHCP_FAILED";
-       case WIFI_ERROR_INVALID_KEY:
-               return "INVALID_KEY";
-       case WIFI_ERROR_NO_REPLY:
-               return "NO_REPLY";
-       case WIFI_ERROR_SECURITY_RESTRICTED:
-               return "SECURITY_RESTRICTED";
-       }
-
-       return "UNKNOWN";
-}
-
-static const char *__libnet_convert_ap_state_to_string(wifi_connection_state_e state)
-{
-       switch (state) {
-       case WIFI_CONNECTION_STATE_DISCONNECTED:
-               return "DISCONNECTED";
-       case WIFI_CONNECTION_STATE_ASSOCIATION:
-               return "ASSOCIATION";
-       case WIFI_CONNECTION_STATE_CONFIGURATION:
-               return "CONFIGURATION";
-       case WIFI_CONNECTION_STATE_CONNECTED:
-               return "CONNECTED";
-       default:
-               return "UNKNOWN";
-       }
-}*/
-
-static void __libnet_clear_profile_list(struct _profile_list_s *profile_list)
-{
-       if (profile_list->count > 0)
-               g_free(profile_list->profiles);
-
-       profile_list->count = 0;
-       profile_list->profiles = NULL;
-}
-
-static void __libnet_update_profile_iterator(void)
-{
-       struct _profile_list_s wifi_profiles = {0, NULL};
-
-       __libnet_clear_profile_list(&profile_iterator);
-
-       // DELETE: net_get_profile_list(NET_DEVICE_WIFI, &wifi_profiles.profiles, &wifi_profiles.count);
-       WIFI_LOG(WIFI_INFO, "Wifi profile count : %d\n", wifi_profiles.count);
-
-       if (wifi_profiles.count == 0)
-               return;
-
-       profile_iterator.count = wifi_profiles.count;
-       profile_iterator.profiles = wifi_profiles.profiles;
-}
-
-/*static void __libnet_update_hidden_profile_iterator(GSList *ap_list)
-{
-       int count;
-       GSList *list = ap_list;
-
-       for (count = 0; list; list = list->next)
-               count++;
-
-       if (count == 0) {
-               WIFI_LOG(WIFI_INFO, "No hidden AP found\n");
-               return;
-       }
-
-       hidden_profile_iterator.count = count;
-       hidden_profile_iterator.profiles = g_try_new0(net_profile_info_t, count);
-
-       list = ap_list;
-       for (count = 0; list; list = list->next) {
-               net_wifi_connection_info_t *ap = list->data;
-               net_profile_info_t *profile = &hidden_profile_iterator.profiles[count];
-
-               g_strlcpy(profile->ProfileInfo.Wlan.essid, ap->essid, NET_WLAN_ESSID_LEN+1);
-               profile->ProfileInfo.Wlan.security_info.sec_mode = ap->security_info.sec_mode;
-               count++;
-       }
-
-       WIFI_LOG(WIFI_INFO, "Hidden AP count : %d\n", count);
-}*/
-
-/*static void __libnet_convert_profile_info_to_wifi_info(net_wifi_connection_info_t *wifi_info,
-                                                               net_profile_info_t *ap_info)
-{
-       g_strlcpy(wifi_info->essid, ap_info->ProfileInfo.Wlan.essid, NET_WLAN_ESSID_LEN+1);
-       wifi_info->wlan_mode = ap_info->ProfileInfo.Wlan.wlan_mode;
-       memcpy(&wifi_info->security_info, &ap_info->ProfileInfo.Wlan.security_info, sizeof(wlan_security_info_t));
-}*/
-
-/**
- * Added
- */
-static char *__convert_eap_type_to_string(gchar eap_type)
-{
-       switch (eap_type) {
-       case WLAN_SEC_EAP_TYPE_PEAP:
-               return "peap";
-
-       case WLAN_SEC_EAP_TYPE_TLS:
-               return "tls";
-
-       case WLAN_SEC_EAP_TYPE_TTLS:
-               return "ttls";
-
-       case WLAN_SEC_EAP_TYPE_SIM:
-               return "sim";
-
-       case WLAN_SEC_EAP_TYPE_AKA:
-               return "aka";
-
-       default:
-               return NULL;
-       }
-}
-
-static char *__convert_eap_auth_to_string(gchar eap_auth)
-{
-       switch (eap_auth) {
-       case WLAN_SEC_EAP_AUTH_NONE:
-               return "NONE";
-
-       case WLAN_SEC_EAP_AUTH_PAP:
-               return "PAP";
-
-       case WLAN_SEC_EAP_AUTH_MSCHAP:
-               return "MSCHAP";
-
-       case WLAN_SEC_EAP_AUTH_MSCHAPV2:
-               return "MSCHAPV2";
-
-       case WLAN_SEC_EAP_AUTH_GTC:
-               return "GTC";
-
-       case WLAN_SEC_EAP_AUTH_MD5:
-               return "MD5";
-
-       default:
-               return NULL;
-       }
-}
-
-char* _net_print_error(net_err_t error)
-{
-       switch (error) {
-               /** No error */
-       case NET_ERR_NONE:
-               return "NET_ERR_NONE";
-
-               /* Common Error value */
-
-               /** Error unknown */
-       case NET_ERR_UNKNOWN:
-               return "NET_ERR_UNKNOWN";
-
-               /* Client Register related Errors used in API return */
-
-               /** Application is already registered */
-       case NET_ERR_APP_ALREADY_REGISTERED:
-               return "NET_ERR_APP_ALREADY_REGISTERED";
-               /** Application is not registered */
-       case NET_ERR_APP_NOT_REGISTERED:
-               return "NET_ERR_APP_NOT_REGISTERED";
-
-               /* Connection Related Error */
-
-               /** No active connection exists for the given profile name */
-       case NET_ERR_NO_ACTIVE_CONNECTIONS:
-               return "NET_ERR_NO_ACTIVE_CONNECTIONS";
-               /** Active connection already exists for the given profile name  */
-       case NET_ERR_ACTIVE_CONNECTION_EXISTS:
-               return "NET_ERR_ACTIVE_CONNECTION_EXISTS";
-
-               /** Connection failure : out of range */
-       case NET_ERR_CONNECTION_OUT_OF_RANGE:
-               return "NET_ERR_CONNECTION_OUT_OF_RANGE";
-               /** Connection failure : pin missing */
-       case NET_ERR_CONNECTION_PIN_MISSING:
-               return "NET_ERR_CONNECTION_PIN_MISSING";
-               /** Connection failure : dhcp failed */
-       case NET_ERR_CONNECTION_DHCP_FAILED:
-               return "NET_ERR_CONNECTION_DHCP_FAILED";
-               /** Connection failure */
-       case NET_ERR_CONNECTION_CONNECT_FAILED:
-               return "NET_ERR_CONNECTION_CONNECT_FAILED";
-               /** Connection failure : login failed */
-       case NET_ERR_CONNECTION_LOGIN_FAILED:
-               return "NET_ERR_CONNECTION_LOGIN_FAILED";
-               /** Connection failure : authentication failed */
-       case NET_ERR_CONNECTION_AUTH_FAILED:
-               return "NET_ERR_CONNECTION_AUTH_FAILED";
-               /** Connection failure : invalid key */
-       case NET_ERR_CONNECTION_INVALID_KEY:
-               return "NET_ERR_CONNECTION_INVALID_KEY";
-
-               /* Other Error */
-
-               /** Access is denied */
-       case NET_ERR_ACCESS_DENIED:
-               return "NET_ERR_ACCESS_DENIED";
-               /** Operation is in progress */
-       case NET_ERR_IN_PROGRESS:
-               return "NET_ERR_IN_PROGRESS";
-               /** Operation was aborted by client or network*/
-       case NET_ERR_OPERATION_ABORTED:
-               return "NET_ERR_OPERATION_ABORTED";
-               /** Invalid value of API parameter */
-       case NET_ERR_INVALID_PARAM:
-               return "NET_ERR_INVALID_PARAM";
-               /** invalid operation depending on current state */
-       case NET_ERR_INVALID_OPERATION:
-               return "NET_ERR_INVALID_OPERATION";
-
-               /** Feature not supported */
-       case NET_ERR_NOT_SUPPORTED:
-               return "NET_ERR_NOT_SUPPORTED";
-               /** TimeOut Error */
-       case NET_ERR_TIME_OUT:
-               return "NET_ERR_TIME_OUT";
-               /** Network service is not available*/
-       case NET_ERR_NO_SERVICE:
-               return "NET_ERR_NO_SERVICE";
-               /** DBus can't find appropriate method */
-       case NET_ERR_UNKNOWN_METHOD:
-               return "NET_ERR_UNKNOWN_METHOD";
-               /** Operation is restricted */
-       case NET_ERR_SECURITY_RESTRICTED:
-               return "NET_ERR_SECURITY_RESTRICTED";
-               /** WiFi driver on/off failed */
-       case NET_ERR_WIFI_DRIVER_FAILURE:
-               return "NET_ERR_WIFI_DRIVER_FAILURE";
-       default:
-               return "INVALID";
-       }
-}
-
-static void __libnet_set_connected_cb(wifi_connected_cb user_cb, void *user_data)
-{
-       if (user_cb) {
-               wifi_callbacks.connected_cb = user_cb;
-               wifi_callbacks.connected_user_data = user_data;
-       }
-}
-
-static void __libnet_connected_cb(wifi_error_e result)
-{
-       if (wifi_callbacks.connected_cb)
-               wifi_callbacks.connected_cb(result, wifi_callbacks.connected_user_data);
-
-       wifi_callbacks.connected_cb = NULL;
-       wifi_callbacks.connected_user_data = NULL;
-}
-
-static void __libnet_set_disconnected_cb(wifi_disconnected_cb user_cb, void *user_data)
-{
-       if (user_cb) {
-               wifi_callbacks.disconnected_cb = user_cb;
-               wifi_callbacks.disconnected_user_data = user_data;
-       }
-}
-
-static void __libnet_disconnected_cb(wifi_error_e result)
-{
-       if (wifi_callbacks.disconnected_cb)
-               wifi_callbacks.disconnected_cb(result, wifi_callbacks.disconnected_user_data);
-
-       wifi_callbacks.disconnected_cb = NULL;
-       wifi_callbacks.disconnected_user_data = NULL;
-}
-
-wifi_error_e connman_lib2capi_result(enum connman_lib_err_e result)
-{
-       /*
-        * TODO:
-        */
-       wifi_error_e tmp = WIFI_ERROR_NONE;
-       return tmp;
-}
-
-static void connman_service_connect_cb(
-                                       enum connman_lib_err_e result,
-                                       void *user_data)
-{
-       WIFI_LOG(WIFI_INFO, "callback: %d\n", result);
-
-       __libnet_connected_cb(connman_lib2capi_result(result));
-}
-
-static void connman_service_disconnect_cb(
-                                       enum connman_lib_err_e result,
-                                       void *user_data)
-{
-       WIFI_LOG(WIFI_INFO, "callback: %d\n", result);
-
-       __libnet_disconnected_cb(connman_lib2capi_result(result));
-}
-
-static int __net_dbus_set_agent_passphrase(const char *path,
-                                                const char *passphrase)
-{
-       int ret_val;
-       char *service_id;
-
-       if (NULL == passphrase || strlen(passphrase) <= 0) {
-               WIFI_LOG(WIFI_ERROR, "Invalid param \n");
-               return NET_ERR_INVALID_PARAM;
-       }
-
-       service_id = g_strrstr(path, "/") + 1;
-       ret_val = winet_wifi_update_agent_passphrase(service_id, passphrase);
-       if (NET_ERR_NONE != ret_val) {
-               WIFI_LOG(WIFI_ERROR,
-                       "__net_dbus_set_agent_field failed. Error = %d \n",
-                       ret_val);
-               return ret_val;
-       }
-
-       WIFI_LOG(WIFI_ERROR, "Successfully sent passphrase\n");
-
-       return NET_ERR_NONE;
-}
-
-static int __net_dbus_connect_service(wifi_ap_h ap_h,
-               const net_wifi_connect_service_info_t *wifi_connection_info)
-{
-       net_err_t Error = NET_ERR_NONE;
-
-       struct connman_service *service = ap_h;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       if (g_strcmp0(wifi_connection_info->security, "ieee8021x") == 0) {
-               /* Create the EAP config file
-                * TODO:
-                */
-               /*Error = _net_dbus_set_eap_config_fields(wifi_connection_info);*/
-               if (NET_ERR_NONE != Error) {
-                       WIFI_LOG(WIFI_ERROR, "Fail to create eap_config\n");
-
-                       goto done;
-               }
-       } else if (g_strcmp0(wifi_connection_info->security, "none") != 0) {
-               Error = __net_dbus_set_agent_passphrase(
-                               connman_service_get_path(service),
-                               wifi_connection_info->passphrase);
-               if (NET_ERR_NONE != Error) {
-                       WIFI_LOG(WIFI_ERROR, "Fail to set agent_passphrase\n");
-
-                       goto done;
-               }
-       }
-
-       connman_service_connect(service, connman_service_connect_cb, NULL);
-
-done:
-       return Error;
-}
-
-/** This function is used only to open Wi-Fi connection with hidden APs */
-static int __net_open_connection_with_wifi_info(wifi_ap_h ap_h, const net_wifi_connection_info_t* wifi_info)
-{
-       net_err_t Error = NET_ERR_NONE;
-
-       net_wifi_connect_service_info_t wifi_connection_info;
-       memset(&wifi_connection_info, 0, sizeof(net_wifi_connect_service_info_t));
-
-       wifi_connection_info.type = g_strdup("wifi");
-
-       if (wifi_info->wlan_mode == NETPM_WLAN_CONNMODE_ADHOC)
-               wifi_connection_info.mode = g_strdup("adhoc");
-       else
-               wifi_connection_info.mode = g_strdup("managed");
-
-       wifi_connection_info.ssid = g_strdup(wifi_info->essid);
-
-       switch (wifi_info->security_info.sec_mode) {
-       case WLAN_SEC_MODE_NONE:
-               wifi_connection_info.security = g_strdup("none");
-               break;
-
-       case WLAN_SEC_MODE_WEP:
-               wifi_connection_info.security = g_strdup("wep");
-               wifi_connection_info.passphrase =
-                               g_strdup(wifi_info->security_info.authentication.wep.wepKey);
-               break;
-
-       /** WPA-PSK(equivalent to WPA-NONE in case of Ad-Hoc) */
-       case WLAN_SEC_MODE_WPA_PSK:
-               wifi_connection_info.security = g_strdup("psk");
-               wifi_connection_info.passphrase =
-                               g_strdup(wifi_info->security_info.authentication.psk.pskKey);
-               break;
-
-       /** WPA2-PSK */
-       /** WPA-PSK / WPA2-PSK supported */
-       case WLAN_SEC_MODE_WPA2_PSK:
-               wifi_connection_info.security = g_strdup("rsn");
-               wifi_connection_info.passphrase =
-                               g_strdup(wifi_info->security_info.authentication.psk.pskKey);
-               break;
-
-       case WLAN_SEC_MODE_IEEE8021X:
-               wifi_connection_info.security = g_strdup("ieee8021x");
-
-               wifi_connection_info.eap_type = g_strdup(
-                               __convert_eap_type_to_string(
-                                               wifi_info->security_info.authentication.eap.eap_type));
-               wifi_connection_info.eap_auth = g_strdup(
-                               __convert_eap_auth_to_string(
-                                               wifi_info->security_info.authentication.eap.eap_auth));
-
-               if (wifi_info->security_info.authentication.eap.username[0] != '\0')
-                       wifi_connection_info.identity =
-                                       g_strdup(wifi_info->security_info.authentication.eap.username);
-
-               if (wifi_info->security_info.authentication.eap.password[0] != '\0')
-                       wifi_connection_info.password =
-                                       g_strdup(wifi_info->security_info.authentication.eap.password);
-
-               if (wifi_info->security_info.authentication.eap.ca_cert_filename[0] != '\0')
-                       wifi_connection_info.ca_cert_file =
-                                       g_strdup(wifi_info->security_info.authentication.eap.ca_cert_filename);
-
-               if (wifi_info->security_info.authentication.eap.client_cert_filename[0] != '\0')
-                       wifi_connection_info.client_cert_file =
-                                       g_strdup(wifi_info->security_info.authentication.eap.client_cert_filename);
-
-               if (wifi_info->security_info.authentication.eap.private_key_filename[0] != '\0')
-                       wifi_connection_info.private_key_file =
-                                       g_strdup(wifi_info->security_info.authentication.eap.private_key_filename);
-
-               if (wifi_info->security_info.authentication.eap.private_key_passwd[0] != '\0')
-                       wifi_connection_info.private_key_password =
-                                       g_strdup(wifi_info->security_info.authentication.eap.private_key_passwd);
-
-               break;
-       default:
-               WIFI_LOG(WIFI_ERROR, "Invalid security type\n");
-
-               return NET_ERR_INVALID_PARAM;
-       }
-
-       Error = __net_dbus_connect_service(ap_h, &wifi_connection_info);
-       if (Error != NET_ERR_NONE)
-               WIFI_LOG(WIFI_ERROR, "Failed to request connect service. Error [%s]\n",
-                               _net_print_error(Error));
-       else
-               WIFI_LOG(WIFI_ERROR, "Successfully requested to connect service\n");
-
-       g_free(wifi_connection_info.type);
-       g_free(wifi_connection_info.mode);
-       g_free(wifi_connection_info.ssid);
-       g_free(wifi_connection_info.security);
-       g_free(wifi_connection_info.passphrase);
-       g_free(wifi_connection_info.eap_type);
-       g_free(wifi_connection_info.eap_auth);
-       g_free(wifi_connection_info.identity);
-       g_free(wifi_connection_info.password);
-       g_free(wifi_connection_info.ca_cert_file);
-       g_free(wifi_connection_info.client_cert_file);
-       g_free(wifi_connection_info.private_key_file);
-       g_free(wifi_connection_info.private_key_password);
-
-       return Error;
-}
-
-static int __libnet_connect_with_wifi_info(wifi_ap_h ap_h, wifi_connected_cb callback, void *user_data)
-{
-       net_wifi_connection_info_t *wifi_info;
-
-       wifi_info = _get_wifi_conn_info();
-
-       if (__net_open_connection_with_wifi_info(ap_h, wifi_info) != NET_ERR_NONE)
-               return WIFI_ERROR_OPERATION_FAILED;
-
-       return WIFI_ERROR_NONE;
-}
-
-/*static void __libnet_state_changed_cb(char *profile_name, net_profile_info_t *profile_info,
-                                                       wifi_connection_state_e state)
-{
-       if (profile_name == NULL)
-               return;
-
-       if (profile_info == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Error!! Profile info not found! : %s\n", profile_name);
-               return;
-       }
-
-       ap_handle_list = g_slist_append(ap_handle_list, (wifi_ap_h)profile_info);
-
-       if (wifi_callbacks.connection_state_cb)
-               wifi_callbacks.connection_state_cb(state, (wifi_ap_h)profile_info,
-                                       wifi_callbacks.connection_state_user_data);
-
-       ap_handle_list = g_slist_remove(ap_handle_list, (wifi_ap_h)profile_info);
-}*/
-
-static void __libnet_set_activated_cb(wifi_activated_cb user_cb, void *user_data)
-{
-       if (user_cb) {
-               wifi_callbacks.activated_cb = user_cb;
-               wifi_callbacks.activated_user_data = user_data;
-       }
-}
-
-static void __libnet_activated_cb(wifi_error_e result)
-{
-       if (wifi_callbacks.activated_cb)
-               wifi_callbacks.activated_cb(result, wifi_callbacks.activated_user_data);
-
-       wifi_callbacks.activated_cb = NULL;
-       wifi_callbacks.activated_user_data = NULL;
-}
-
-static void __libnet_set_deactivated_cb(wifi_disconnected_cb user_cb, void *user_data)
-{
-       if (user_cb) {
-               wifi_callbacks.deactivated_cb = user_cb;
-               wifi_callbacks.deactivated_user_data = user_data;
-       }
-}
-
-static void __libnet_deactivated_cb(wifi_error_e result)
-{
-       if (wifi_callbacks.deactivated_cb)
-               wifi_callbacks.deactivated_cb(result, wifi_callbacks.deactivated_user_data);
-
-       wifi_callbacks.deactivated_cb = NULL;
-       wifi_callbacks.deactivated_user_data = NULL;
-}
-
-static void __libnet_set_scan_request_cb(wifi_disconnected_cb user_cb, void *user_data)
-{
-       if (user_cb) {
-               wifi_callbacks.scan_request_cb = user_cb;
-               wifi_callbacks.scan_request_user_data = user_data;
-       }
-}
-
-/*static void __libnet_scan_request_cb(wifi_error_e result)
-{
-       if (wifi_callbacks.scan_request_cb)
-               wifi_callbacks.scan_request_cb(result, wifi_callbacks.scan_request_user_data);
-
-       wifi_callbacks.scan_request_cb = NULL;
-       wifi_callbacks.scan_request_user_data = NULL;
-}*/
-
-/*static void __libnet_power_on_off_cb(net_event_info_t *event_cb, bool is_requested)
-{
-       if (wifi_callbacks.device_state_cb == NULL &&
-           wifi_callbacks.activated_cb == NULL &&
-           wifi_callbacks.deactivated_cb == NULL)
-               return;
-
-       wifi_error_e error_code = WIFI_ERROR_NONE;
-       wifi_device_state_e state;
-       net_wifi_state_t *wifi_state = (net_wifi_state_t*)event_cb->Data;
-
-       if (event_cb->Error == NET_ERR_NONE &&
-           event_cb->Datalength == sizeof(net_wifi_state_t)) {
-
-               if (*wifi_state == WIFI_ON) {
-                       WIFI_LOG(WIFI_INFO, "Wi-Fi State : Power ON\n");
-                       state = WIFI_DEVICE_STATE_ACTIVATED;
-               } else if (*wifi_state == WIFI_OFF) {
-                       WIFI_LOG(WIFI_INFO, "Wi-Fi State : Power OFF\n");
-                       state = WIFI_DEVICE_STATE_DEACTIVATED;
-                       __libnet_clear_profile_list(&profile_iterator);
-                       __libnet_clear_profile_list(&hidden_profile_iterator);
-               } else {
-                       WIFI_LOG(WIFI_INFO, "Wi-Fi State : Unknown\n");
-                       error_code = WIFI_ERROR_OPERATION_FAILED;
-                       state = WIFI_DEVICE_STATE_DEACTIVATED;
-               }
-       } else {
-               WIFI_LOG(WIFI_ERROR, "Wi-Fi Power on/off request failed! Error [%d]\n", event_cb->Error);
-               error_code = WIFI_ERROR_OPERATION_FAILED;
-               state = WIFI_DEVICE_STATE_DEACTIVATED;
-       }
-
-       __libnet_activated_cb(error_code);
-       __libnet_deactivated_cb(error_code);
-
-       if (wifi_callbacks.device_state_cb)
-               wifi_callbacks.device_state_cb(state, wifi_callbacks.device_state_user_data);
-}
-
-static void __libnet_scan_cb(net_event_info_t *event_cb)
-{
-       wifi_error_e error_code = WIFI_ERROR_NONE;
-
-       if (event_cb->Error != NET_ERR_NONE) {
-               WIFI_LOG(WIFI_ERROR, "Scan failed!, Error [%d]\n", event_cb->Error);
-               error_code = WIFI_ERROR_OPERATION_FAILED;
-       }
-
-       if (wifi_callbacks.scan_request_cb) {
-               wifi_callbacks.scan_request_cb(error_code, wifi_callbacks.scan_request_user_data);
-               wifi_callbacks.scan_request_cb = NULL;
-               wifi_callbacks.scan_request_user_data = NULL;
-               return;
-       }
-
-       if (wifi_callbacks.bg_scan_cb != NULL)
-               wifi_callbacks.bg_scan_cb(error_code, wifi_callbacks.bg_scan_user_data);
-}
-
-static void __libnet_hidden_scan_cb(net_event_info_t *event_cb)
-{
-       wifi_error_e error_code = WIFI_ERROR_NONE;
-
-       __libnet_clear_profile_list(&hidden_profile_iterator);
-
-       if (event_cb->Error != NET_ERR_NONE) {
-               WIFI_LOG(WIFI_ERROR, "Hidden scan failed!, Error [%d]\n", event_cb->Error);
-               error_code = WIFI_ERROR_OPERATION_FAILED;
-       } else if (event_cb->Data) {
-               GSList *ap_list = event_cb->Data;
-               __libnet_update_hidden_profile_iterator(ap_list);
-       }
-
-       if (wifi_callbacks.scan_hidden_ap_cb) {
-               wifi_callbacks.scan_hidden_ap_cb(error_code, wifi_callbacks.scan_hidden_ap_user_data);
-               wifi_callbacks.scan_hidden_ap_cb = NULL;
-               wifi_callbacks.scan_hidden_ap_user_data = NULL;
-       }
-}*/
-
-/*static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
-{
-       bool is_requested = false;
-       net_profile_info_t *prof_info_p = NULL;
-       net_profile_info_t prof_info;
-       wifi_error_e result = WIFI_ERROR_NONE;
-
-       switch (event_cb->Event) {
-       case NET_EVENT_OPEN_RSP:
-       case NET_EVENT_WIFI_WPS_RSP:
-               is_requested = true;
-                fall through
-       case NET_EVENT_OPEN_IND:
-               if (_wifi_libnet_check_profile_name_validity(event_cb->ProfileName) != true)
-                       return;
-
-               result = __libnet_convert_to_ap_error_type(event_cb->Error);
-               WIFI_LOG(WIFI_INFO, "Got Open RSP/IND : %s\n",
-                       __libnet_convert_ap_error_type_to_string(result));
-
-               if (is_requested)
-                       __libnet_connected_cb(result);
-
-               switch (event_cb->Error) {
-               case NET_ERR_NONE:
-                       WIFI_LOG(WIFI_INFO, "Connection open succeeded\n");
-
-                       if (event_cb->Datalength == sizeof(net_profile_info_t))
-                               prof_info_p = (net_profile_info_t*)event_cb->Data;
-
-                       __libnet_state_changed_cb(event_cb->ProfileName, prof_info_p,
-                                                       WIFI_CONNECTION_STATE_CONNECTED);
-                       return;
-               case NET_ERR_ACTIVE_CONNECTION_EXISTS:
-                       WIFI_LOG(WIFI_INFO, "Connection already existed\n");
-                       return;
-               default :
-                       WIFI_LOG(WIFI_ERROR, "Connection open failed!\n");
-                       break;
-               }
-
-               //DELETE:
-
-               if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE)
-                       __libnet_state_changed_cb(event_cb->ProfileName, &prof_info,
-                                               WIFI_CONNECTION_STATE_DISCONNECTED);
-               else
-                       __libnet_state_changed_cb(event_cb->ProfileName, NULL,
-                                               WIFI_CONNECTION_STATE_DISCONNECTED);
-
-               break;
-       case NET_EVENT_CLOSE_RSP:
-               is_requested = true;
-                fall through
-       case NET_EVENT_CLOSE_IND:
-               if (_wifi_libnet_check_profile_name_validity(event_cb->ProfileName) != true)
-                       return;
-
-               result = __libnet_convert_to_ap_error_type(event_cb->Error);
-               WIFI_LOG(WIFI_INFO, "Got Close RSP/IND : %s\n",
-                       __libnet_convert_ap_error_type_to_string(result));
-
-               if (is_requested)
-                       __libnet_disconnected_cb(result);
-
-               switch (event_cb->Error) {
-               case NET_ERR_NONE:
-                       WIFI_LOG(WIFI_INFO, "Connection close succeeded!\n");
-                       //DELETE:
-                       if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE)
-                               __libnet_state_changed_cb(event_cb->ProfileName, &prof_info,
-                                                       WIFI_CONNECTION_STATE_DISCONNECTED);
-                       else
-                               __libnet_state_changed_cb(event_cb->ProfileName, NULL,
-                                                       WIFI_CONNECTION_STATE_DISCONNECTED);
-                       return;
-               default:
-                       WIFI_LOG(WIFI_ERROR, "Connection close failed!\n");
-                       break;
-               }
-
-               break;
-       case NET_EVENT_NET_STATE_IND:
-               if (_wifi_libnet_check_profile_name_validity(event_cb->ProfileName) != true)
-                       return;
-
-               WIFI_LOG(WIFI_INFO, "Got State changed IND\n");
-
-               if (event_cb->Datalength != sizeof(net_state_type_t))
-                       return;
-
-               net_state_type_t *profile_state = (net_state_type_t*)event_cb->Data;
-               wifi_connection_state_e ap_state = _wifi_convert_to_ap_state(*profile_state);
-
-               WIFI_LOG(WIFI_INFO,
-                       "Profile State : %s, profile name : %s\n",
-                       __libnet_convert_ap_state_to_string(ap_state),
-                       event_cb->ProfileName);
-
-               //DELETE:
-               if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE)
-                       __libnet_state_changed_cb(event_cb->ProfileName, &prof_info, ap_state);
-               else
-                       __libnet_state_changed_cb(event_cb->ProfileName, NULL, ap_state);
-
-
-               break;
-       case NET_EVENT_WIFI_SCAN_RSP:
-       case NET_EVENT_WIFI_SCAN_IND:
-               WIFI_LOG(WIFI_INFO, "Got Wi-Fi scan IND\n");
-               __libnet_scan_cb(event_cb);
-               break;
-       case NET_EVENT_SPECIFIC_SCAN_RSP:
-               WIFI_LOG(WIFI_INFO, "Got Wi-Fi hidden scan RSP\n");
-               break;
-       case NET_EVENT_SPECIFIC_SCAN_IND:
-               WIFI_LOG(WIFI_INFO, "Got Wi-Fi hidden scan IND\n");
-               __libnet_hidden_scan_cb(event_cb);
-               break;
-       case NET_EVENT_WIFI_POWER_RSP:
-               is_requested = true;
-                fall through
-       case NET_EVENT_WIFI_POWER_IND:
-               WIFI_LOG(WIFI_INFO, "Got Wi-Fi power IND\n");
-               __libnet_power_on_off_cb(event_cb, is_requested);
-               break;
-       default :
-               WIFI_LOG(WIFI_ERROR, "Error! Unknown Event\n\n");
-       }
-}*/
-
-wifi_connection_state_e connection_state_string2type(const char *str)
-{
-       if (strcmp(str, "idle") == 0)
-               return WIFI_CONNECTION_STATE_DISCONNECTED;
-       if (strcmp(str, "association") == 0)
-               return WIFI_CONNECTION_STATE_ASSOCIATION;
-       if (strcmp(str, "configuration") == 0)
-               return WIFI_CONNECTION_STATE_CONFIGURATION;
-       if (strcmp(str, "ready") == 0)
-               return WIFI_CONNECTION_STATE_CONNECTED;
-       if (strcmp(str, "online") == 0)
-               return WIFI_CONNECTION_STATE_CONNECTED;
-       if (strcmp(str, "disconnect") == 0)
-               return WIFI_CONNECTION_STATE_DISCONNECTED;
-       if (strcmp(str, "failure") == 0)
-               return WIFI_CONNECTION_STATE_DISCONNECTED;
-
-       return -1;
-}
-
-static void service_state_changed(struct connman_service *service,
-                                                       void *user_data)
-{
-       const char *name = connman_service_get_name(service);
-       const char *new_state = connman_service_get_state(service);
-
-
-       WIFI_LOG(WIFI_INFO, "name %s, state, %s", name, new_state);
-
-       if (wifi_callbacks.connection_state_cb) {
-               GSList *list;
-               net_profile_info_t *info = NULL;
-               net_profile_info_t *profile_info = NULL;
-               wifi_connection_state_e state =
-                               connection_state_string2type(new_state);
-
-               for (list = ap_handle_list; list; list = list->next) {
-
-                       if (list == NULL)
-                               break;
-
-                       info = (net_profile_info_t *)list->data;
-                       if (strcmp(info->essid, name) == 0) {
-                               profile_info = info;
-                               break;
-                       }
-               }
-
-               wifi_callbacks.connection_state_cb(state,
-                               (wifi_ap_h)profile_info,
-                               wifi_callbacks.connection_state_user_data);
-       }
-}
-
-static void service_strength_changed(struct connman_service *service,
-                                                       void *user_data)
-{
-       const char *name = connman_service_get_name(service);
-       int strength = connman_service_get_strength(service);
-
-       WIFI_LOG(WIFI_INFO, "name %s, strength, %d", name, strength);
-}
-
-static void register_service_monitor(gpointer data, gpointer user_data)
-{
-       struct connman_service *service = data;
-
-       const char *path = connman_service_get_path(service);
-       const char *type = connman_service_get_type(service);
-
-       WIFI_LOG(WIFI_INFO, "path %s, type %s", path, type);
-
-       if (strcmp(type, "wifi") != 0)
-               return;
-
-       connman_service_set_property_changed_cb(service, SERVICE_PROP_STATE,
-                                       service_state_changed, user_data);
-
-       connman_service_set_property_changed_cb(service, SERVICE_PROP_STRENGTH,
-                                       service_strength_changed, user_data);
-}
-
-static void service_changed_callback(struct connman_manager *manager,
-                                                       void *user_data)
-{
-       GList *services;
-
-       WIFI_LOG(WIFI_INFO, "service changed");
-
-       services = connman_get_services();
-
-       g_list_foreach(services, register_service_monitor, NULL);
-}
-
-static void technology_powered_changed(struct connman_technology *technology,
-                                                       void *user_data)
-{
-       gboolean powered = connman_get_technology_powered(technology);
-       enum connman_technology_type type =
-                               connman_get_technology_type(technology);
-
-       WIFI_LOG(WIFI_INFO, "technology %d powered %d", type, powered);
-
-       if (wifi_callbacks.device_state_cb) {
-               wifi_device_state_e state;
-
-               state = powered ? WIFI_DEVICE_STATE_ACTIVATED :
-                                               WIFI_DEVICE_STATE_DEACTIVATED;
-               wifi_callbacks.device_state_cb(state,
-                                       wifi_callbacks.device_state_user_data);
-       }
-}
-
-static void technology_added_callback(struct connman_technology *technology,
-                                                       void *user_data)
-{
-       enum connman_technology_type type =
-                               connman_get_technology_type(technology);
-
-       WIFI_LOG(WIFI_INFO, "technology %d added", type);
-
-       if (type == TECH_TYPE_WIFI)
-               connman_technology_set_property_changed_cb(technology,
-                                               TECH_PROP_POWERED,
-                                               technology_powered_changed,
-                                               user_data);
-}
-
-bool _wifi_libnet_init(void)
-{
-       struct connman_technology *technology;
-       int rv = NET_ERR_NONE;
-       /*rv = net_register_client_ext((net_event_cb_t)__libnet_evt_cb, NET_DEVICE_WIFI, NULL);*/
-/*     net_register_client_ext((net_event_cb_t)__libnet_evt_cb, NET_DEVICE_WIFI, NULL);
-       rv = initialize_wifi_ls2_calls();*/
-       connman_lib_init();
-       if (rv != NET_ERR_NONE)
-               return false;
-
-       connman_set_services_changed_cb(service_changed_callback, NULL);
-
-       connman_set_technology_added_cb(technology_added_callback, NULL);
-
-       technology = connman_get_technology(TECH_TYPE_WIFI);
-       if (technology)
-               connman_technology_set_property_changed_cb(technology,
-                                               TECH_PROP_POWERED,
-                                               technology_powered_changed,
-                                               NULL);
-
-       return true;
-}
-
-bool _wifi_libnet_deinit(void)
-{
-       //DELETE:
-/*     if (net_deregister_client_ext(NET_DEVICE_WIFI) != NET_ERR_NONE)
-               return false;*/
-
-       __libnet_clear_profile_list(&profile_iterator);
-       __libnet_clear_profile_list(&hidden_profile_iterator);
-       g_slist_free_full(ap_handle_list, g_free);
-       ap_handle_list = NULL;
-       memset(&wifi_callbacks, 0, sizeof(struct _wifi_cb_s));
-       connman_lib_deinit();
-       return true;
-}
-
-static void __connman_technology_powered_on_cb(
-                                       enum connman_lib_err_e result,
-                                       void *user_data)
-{
-       WIFI_LOG(WIFI_INFO, "callback: %d\n", result);
-
-       __libnet_activated_cb(connman_lib2capi_result(result));
-}
-
-static void __connman_technology_powered_off_cb(
-                                       enum connman_lib_err_e result,
-                                       void *user_data)
-{
-       WIFI_LOG(WIFI_INFO, "callback: %d\n", result);
-
-       __libnet_deactivated_cb(connman_lib2capi_result(result));
-}
-
-int _wifi_activate(wifi_activated_cb callback, void *user_data)
-{
-       /*int rv;
-
-       rv = net_wifi_power_on();
-       if (rv == NET_ERR_NONE) {
-               __libnet_set_activated_cb(callback, user_data);
-               return WIFI_ERROR_NONE;
-       } else if (rv == NET_ERR_INVALID_OPERATION)
-               return WIFI_ERROR_INVALID_OPERATION;
-       else if (rv == NET_ERR_ALREADY_EXISTS)
-               return WIFI_ERROR_ALREADY_EXISTS;
-
-       return WIFI_ERROR_OPERATION_FAILED;*/
-
-       /*
-        * New capi
-        */
-       if (winet_wifi_set_work_mode(WIFI_WORK_MODE_STATION) < 0)
-               return WIFI_ERROR_OPERATION_FAILED;
-
-       struct connman_technology *technology =
-                                       connman_get_technology(TECH_TYPE_WIFI);
-       if (!technology)
-               return WIFI_ERROR_OPERATION_FAILED;
-
-       __libnet_set_activated_cb(callback, user_data);
-
-       connman_enable_technology(technology,
-                                       __connman_technology_powered_on_cb,
-                                       NULL);
-
-       return WIFI_ERROR_NONE;
-}
-
-int _wifi_deactivate(wifi_deactivated_cb callback, void *user_data)
-{
-       /*int rv;
-
-       rv = net_wifi_power_off();
-       if (rv == NET_ERR_NONE) {
-               __libnet_set_deactivated_cb(callback, user_data);
-               return WIFI_ERROR_NONE;
-       } else if (rv == NET_ERR_INVALID_OPERATION)
-               return WIFI_ERROR_INVALID_OPERATION;
-       else if (rv == NET_ERR_ALREADY_EXISTS)
-               return WIFI_ERROR_ALREADY_EXISTS;
-
-       return WIFI_ERROR_OPERATION_FAILED;*/
-
-       /*
-        * New capi
-        */
-       struct connman_technology *technology =
-                                       connman_get_technology(TECH_TYPE_WIFI);
-       if (!technology)
-               return WIFI_ERROR_OPERATION_FAILED;
-
-       __libnet_set_deactivated_cb(callback, user_data);
-
-       connman_disable_technology(technology,
-                                       __connman_technology_powered_off_cb,
-                                       NULL);
-
-       if (winet_wifi_set_work_mode(WIFI_WORK_MODE_OFF) < 0)
-               return WIFI_ERROR_OPERATION_FAILED;
-
-       return WIFI_ERROR_NONE;
-}
-
-bool _wifi_libnet_check_ap_validity(wifi_ap_h ap_h)
-{
-       struct connman_service *service = ap_h;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       const char *name = connman_service_get_name(service);
-
-       if (!name)
-               return false;
-
-       return true;
-}
-
-void _wifi_libnet_add_to_ap_list(wifi_ap_h ap_h)
-{
-       ap_handle_list = g_slist_append(ap_handle_list, ap_h);
-}
-
-void _wifi_libnet_remove_from_ap_list(wifi_ap_h ap_h)
-{
-       net_profile_info_t *ap_info = ap_h;
-       ap_handle_list = g_slist_remove(ap_handle_list, ap_info);
-       g_free(ap_info->essid);
-       g_free(ap_h);
-}
-
-bool _wifi_libnet_check_profile_name_validity(const char *profile_name)
-{
-       const char *profile_prefix = "/net/connman/service/wifi_";
-       int i = 0;
-
-       if (profile_name == NULL ||
-                       g_str_has_prefix(profile_name, profile_prefix) != TRUE) {
-               WIFI_LOG(WIFI_ERROR, "Error!!! Profile name is invalid\n");
-               return false;
-       }
-
-       while (profile_name[i] != '\0') {
-               if (isgraph(profile_name[i]) == 0) {
-                       WIFI_LOG(WIFI_ERROR, "Error!!! Profile name is invalid\n");
-                       return false;
-               }
-               i++;
-       }
-
-       return true;
-}
-
-bool _wifi_libnet_get_wifi_device_state(wifi_device_state_e *device_state)
-{
-       struct connman_technology *technology;
-       bool powered = false;
-
-       technology = connman_get_technology(TECH_TYPE_WIFI);
-
-       if (technology)
-               powered = connman_get_technology_powered(technology);
-
-       if (powered)
-               *device_state = WIFI_DEVICE_STATE_ACTIVATED;
-       else
-               *device_state = WIFI_DEVICE_STATE_DEACTIVATED;
-
-       WIFI_LOG(WIFI_ERROR, "Wi-Fi device state: %d", *device_state);
-
-       return true;
-}
-
-/* Only for test
-static void test_service(gpointer data, gpointer user_data)
-{
-       struct connman_service *service = data;
-       const char *type = connman_service_get_type(service);
-       const char *name = connman_service_get_name(service);
-
-       WIFI_LOG(WIFI_INFO, "type: %s, state %s", name,  type);
-}*/
-
-bool _wifi_libnet_get_wifi_state(wifi_connection_state_e* connection_state)
-{
-       /*net_wifi_state_t wlan_state = 0;*/
-       struct connman_technology *technology;
-       gboolean wifi_powered;
-       GList *services;
-       GList *list;
-
-
-       // DELETE:
-       /*net_profile_name_t profile_name;
-       if (net_get_wifi_state(&wlan_state, &profile_name) != NET_ERR_NONE) {
-               WIFI_LOG(WIFI_ERROR, "Error!! net_get_wifi_state() failed.\n");
-               return false;
-       }*/
-
-       technology = connman_get_technology(TECH_TYPE_WIFI);
-       wifi_powered = connman_get_technology_powered(technology);
-
-       if (!wifi_powered) {
-               *connection_state = WIFI_CONNECTION_STATE_DISCONNECTED;
-               return true;
-       }
-
-       services = connman_get_services();
-       if (services == NULL) {
-               *connection_state = WIFI_CONNECTION_STATE_DISCONNECTED;
-               return true;
-       }
-
-//     g_list_foreach(services, test_service, NULL);
-
-//     list = g_list_next(services);
-       list = services;
-
-       WIFI_LOG(WIFI_INFO, "list: %p", list);
-       WIFI_LOG(WIFI_INFO, "services: %p", services);
-
-       while (list != NULL) {
-               wifi_connection_state_e state;
-               struct connman_service *service;
-               const char *str;
-               const char *type;
-
-               service = list->data;
-               str = connman_service_get_state(service);
-               state = connection_state_string2type(str);
-               type = connman_service_get_type(service);
-
-               WIFI_LOG(WIFI_INFO, "type: %s, state %s", type, str);
-
-               if (state > WIFI_CONNECTION_STATE_DISCONNECTED &&
-                       strcmp(type, "wifi") == 0) {
-                       *connection_state = state;
-                       return true;
-               }
-
-               list = g_list_next(list);
-               WIFI_LOG(WIFI_INFO, "list: %p, services %p", list, services);
-       }
-
-       *connection_state = WIFI_CONNECTION_STATE_DISCONNECTED;
-       return true;
-/*
-       switch (wlan_state) {
-       case WIFI_OFF:
-       case WIFI_ON:
-               *connection_state = WIFI_CONNECTION_STATE_DISCONNECTED;
-               break;
-       case WIFI_CONNECTING:
-               *connection_state = WIFI_CONNECTION_STATE_ASSOCIATION;
-               break;
-       case WIFI_CONNECTED:
-               *connection_state = WIFI_CONNECTION_STATE_CONNECTED;
-               break;
-       case WIFI_DISCONNECTING:
-               *connection_state = WIFI_CONNECTION_STATE_CONNECTED;
-               break;
-       default :
-               WIFI_LOG(WIFI_ERROR, "Error!! Unknown state\n");
-               return false;
-       }
-
-       return true;*/
-}
-
-int _wifi_libnet_get_intf_name(char** name)
-{
-       if (profile_iterator.count == 0)
-               __libnet_update_profile_iterator();
-
-       if (profile_iterator.count == 0) {
-               WIFI_LOG(WIFI_ERROR, "Error!! There is no AP\n");
-               return WIFI_ERROR_OPERATION_FAILED;
-       }
-
-       /**name = g_strdup(profile_iterator.profiles->ProfileInfo.Wlan.net_info.DevName);*/
-       if (*name == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;
-
-       return WIFI_ERROR_NONE;
-}
-
-int _wifi_libnet_scan_request(wifi_scan_finished_cb callback, void *user_data)
-{
-       int rv = NET_ERR_NONE;
-       struct connman_technology *technology =
-                               connman_get_technology(TECH_TYPE_WIFI);
-
-       __libnet_set_scan_request_cb(callback, user_data);
-
-       rv = connman_scan_technology(technology);
-
-       if (rv == NET_ERR_NONE) {
-               return WIFI_ERROR_NONE;
-       } else if (rv == NET_ERR_INVALID_OPERATION)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       return WIFI_ERROR_OPERATION_FAILED;
-}
-
-int _wifi_libnet_scan_hidden_ap(const char *essid,
-                                       wifi_scan_finished_cb callback, void *user_data)
-{
-       int rv = NET_ERR_NONE;
-       // DELETE:
-       /*rv = net_specific_scan_wifi(essid)*/;
-
-       if (rv == NET_ERR_NONE) {
-               wifi_callbacks.scan_hidden_ap_cb = callback;
-               wifi_callbacks.scan_hidden_ap_user_data = user_data;
-               return WIFI_ERROR_NONE;
-       } else if (rv == NET_ERR_INVALID_OPERATION)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       return WIFI_ERROR_OPERATION_FAILED;
-}
-
-int _wifi_libnet_get_connected_profile(wifi_ap_h *ap)
-{
-       wifi_ap_h ap_h = NULL;
-       GList *iter;
-       GList *connman_services_list = NULL;
-       const char *state;
-       net_state_type_t state_type;
-       /*
-        * update service TODO
-        */
-
-       /*
-        * Filter the service
-        */
-       connman_services_list = connman_get_services();
-
-       for (iter = connman_services_list; iter != NULL; iter = iter->next) {
-               struct connman_service *service =
-                   (struct connman_service *)(iter->data);
-
-               state = connman_service_get_state(service);
-               state_type = _get_service_state_type(state);
-               if (( state_type == NET_STATE_TYPE_ONLINE) ||
-                                       (state_type == NET_STATE_TYPE_READY))
-                       ap_h = (wifi_ap_h)service;
-       }
-
-       if (!ap_h) {
-               WIFI_LOG(WIFI_ERROR, "Error!! There is no connected AP.\n");
-               return WIFI_ERROR_NO_CONNECTION;
-       }
-
-       *ap = g_try_malloc0(sizeof(net_profile_info_t));
-       if (*ap == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;
-
-       ((net_profile_info_t *) (*ap))->essid =
-                               g_strdup(connman_service_get_name(ap_h));
-
-       _wifi_libnet_add_to_ap_list(*ap);
-
-       return WIFI_ERROR_NONE;
-}
-
-bool _wifi_libnet_foreach_found_aps(wifi_found_ap_cb callback, void *user_data)
-{
-       bool rv = true;
-       GList *iter;
-       GList *connman_services_list = NULL;
-
-       /*
-        * update all services TODO
-        */
-
-       connman_services_list = connman_get_services();
-
-       if (g_list_length(connman_services_list) == 0) {
-               WIFI_LOG(WIFI_INFO, "There is no APs.\n");
-               return true;
-       }
-
-       for (iter = connman_services_list; iter != NULL; iter = iter->next) {
-               rv = callback((wifi_ap_h)(iter->data), user_data);
-               if (rv == false) break;
-       }
-
-       return true;
-}
-
-bool _wifi_libnet_foreach_found_hidden_aps(wifi_found_ap_cb callback, void *user_data)
-{
-       int i = 0;
-       bool rv = true;
-
-       if (hidden_profile_iterator.count == 0) {
-               WIFI_LOG(WIFI_INFO, "There is no hidden APs.\n");
-               return true;
-       }
-
-       for (;i < hidden_profile_iterator.count;i++) {
-               rv = callback((wifi_ap_h)(&hidden_profile_iterator.profiles[i]), user_data);
-               if (rv == false) break;
-       }
-
-       return true;
-}
-
-int _wifi_libnet_open_profile(wifi_ap_h ap_h, wifi_connected_cb callback, void *user_data)
-{
-        /*int rv = NET_ERR_NONE;
-
-               bool valid_profile;
-        *      net_profile_info_t *ap_info = ap_h;
-        * g_strlcpy(profile_name.ProfileName, ap_info->ProfileName, NET_PROFILE_NAME_LEN_MAX+1);*/
-
-       /*valid_profile =
-                       _wifi_libnet_check_profile_name_validity(profile_name.ProfileName);*/
-
-       // DELETE:
-/*     if (valid_profile == true && ap_info->Favourite)
-               rv = net_open_connection_with_profile(profile_name.ProfileName);
-       else if (valid_profile == true &&
-                       ap_info->ProfileInfo.Wlan.security_info.sec_mode == WLAN_SEC_MODE_NONE)
-               rv = net_open_connection_with_profile(profile_name.ProfileName);
-       else
-               rv = __libnet_connect_with_wifi_info(ap_info);*/
-
-/*     if (rv != NET_ERR_NONE)
-               return WIFI_ERROR_OPERATION_FAILED;
-
-       __libnet_set_connected_cb(callback, user_data);
-
-       return WIFI_ERROR_NONE;*/
-
-       int rv = NET_ERR_NONE;
-       struct connman_service* service = ap_h;
-
-       __libnet_set_connected_cb(callback, user_data);
-
-       if (connman_service_get_favorite(service))
-               connman_service_connect(service, connman_service_connect_cb, NULL);
-       else
-               rv = __libnet_connect_with_wifi_info(ap_h, callback, user_data);
-
-       if (rv != NET_ERR_NONE)
-               return WIFI_ERROR_OPERATION_FAILED;
-
-       return WIFI_ERROR_NONE;
-
-}
-
-int _wifi_libnet_close_profile(wifi_ap_h ap_h, wifi_disconnected_cb callback, void *user_data)
-{
-/*     net_profile_info_t *ap_info = ap_h;
-       net_profile_name_t profile_name;
-
-       g_strlcpy(profile_name.ProfileName, ap_info->ProfileName, NET_PROFILE_NAME_LEN_MAX+1);
-
-       //DELETE:
-       if (net_close_connection(profile_name.ProfileName) != NET_ERR_NONE)
-               return WIFI_ERROR_OPERATION_FAILED;
-
-       __libnet_set_disconnected_cb(callback, user_data);*/
-
-       struct connman_service *service = ap_h;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       __libnet_set_disconnected_cb(callback, user_data);
-       connman_service_disconnect(service, connman_service_disconnect_cb, NULL);
-
-       return WIFI_ERROR_NONE;
-}
-
-int _wifi_libnet_connect_with_wps(wifi_ap_h ap_h, wifi_connected_cb callback, void *user_data)
-{
-/*     net_profile_info_t *ap_info = ap_h;
-       net_wifi_wps_info_t wps_info;
-       net_profile_name_t profile_name;
-
-       memset(&wps_info, 0 , sizeof(net_wifi_wps_info_t));
-       g_strlcpy(profile_name.ProfileName, ap_info->ProfileName, NET_PROFILE_NAME_LEN_MAX+1);
-
-       wps_info.type = WIFI_WPS_PBC;
-
-       // DELETE:
-
-       if (net_wifi_enroll_wps(profile_name.ProfileName, &wps_info) != NET_ERR_NONE)
-               return WIFI_ERROR_OPERATION_FAILED;
-
-       __libnet_set_connected_cb(callback, user_data);*/
-
-       int rv = NET_ERR_NONE;
-       struct connman_service *service = ap_h;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       __libnet_set_connected_cb(callback, user_data);
-
-       if (connman_service_get_favorite(service))
-               connman_service_connect(service, connman_service_connect_cb, NULL);
-       else
-               rv = __libnet_connect_with_wifi_info(ap_h, callback, user_data);
-
-       if (rv != NET_ERR_NONE)
-               return WIFI_ERROR_OPERATION_FAILED;
-
-       return WIFI_ERROR_NONE;
-}
-
-int _wifi_libnet_forget_ap(wifi_ap_h ap)
-{
-/*     int rv = 0;
-       net_profile_name_t profile_name;
-       net_profile_info_t *ap_info = ap;
-
-       g_strlcpy(profile_name.ProfileName, ap_info->ProfileName, NET_PROFILE_NAME_LEN_MAX+1);
-
-       // DELETE:
-       rv = net_delete_profile(profile_name.ProfileName);
-       if (rv != NET_ERR_NONE)
-               return WIFI_ERROR_OPERATION_FAILED;*/
-
-       int rv = NET_ERR_NONE;
-       struct connman_service *service = ap;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       connman_service_remove(service);
-
-       if (rv != NET_ERR_NONE)
-               return WIFI_ERROR_OPERATION_FAILED;
-
-       return WIFI_ERROR_NONE;
-}
-
-/*
-void connman_technology_set_device_state_changed_cb(
-                               struct connman_technology *technology,
-                               void *user_data)
-{
-       struct common_reply_data *reply_data;
-       bool powered;
-
-       reply_data = user_data;
-       if (!reply_data)
-               return;
-
-       if (!technology)
-               return;
-
-       powered = connman_get_technology_powered(technology);
-
-       if (reply_data->cb) {
-               wifi_device_state_e state;
-               state = powered ? WIFI_DEVICE_STATE_ACTIVATED :
-                                               WIFI_DEVICE_STATE_DEACTIVATED;
-               wifi_device_state_changed_cb cb = reply_data->cb;
-               cb(state, reply_data->data);
-       }
-}*/
-
-int _wifi_set_power_on_off_cb(wifi_device_state_changed_cb callback, void *user_data)
-{
-       if (wifi_callbacks.device_state_cb)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       wifi_callbacks.device_state_cb = callback;
-       wifi_callbacks.device_state_user_data = user_data;
-
-       return WIFI_ERROR_NONE;
-
-       /*
-        * New capi
-        */
-/*     struct common_reply_data *reply_data;
-
-       reply_data =
-           common_reply_data_new(callback, user_data, NULL, TRUE);
-
-
-       connman_technology_set_property_changed_cb(
-                       connman_get_technology(TECH_TYPE_WIFI),
-                       TECH_PROP_POWERED,
-                       connman_technology_set_device_state_changed_cb,
-                       user_data);
-
-       return WIFI_ERROR_NONE;*/
-}
-
-int _wifi_unset_power_on_off_cb(void)
-{
-       if (wifi_callbacks.device_state_cb == NULL)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       wifi_callbacks.device_state_cb = NULL;
-       wifi_callbacks.device_state_user_data = NULL;
-
-       return WIFI_ERROR_NONE;
-}
-
-int _wifi_set_background_scan_cb(wifi_scan_finished_cb callback, void *user_data)
-{
-       if (wifi_callbacks.bg_scan_cb)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       wifi_callbacks.bg_scan_cb = callback;
-       wifi_callbacks.bg_scan_user_data = user_data;
-
-       return WIFI_ERROR_NONE;
-}
-
-int _wifi_unset_background_scan_cb(void)
-{
-       if (wifi_callbacks.bg_scan_cb == NULL)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       wifi_callbacks.bg_scan_cb = NULL;
-       wifi_callbacks.bg_scan_user_data = NULL;
-
-       return WIFI_ERROR_NONE;
-}
-
-int _wifi_set_connection_state_cb(wifi_connection_state_changed_cb callback, void *user_data)
-{
-       if (wifi_callbacks.connection_state_cb)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       wifi_callbacks.connection_state_cb = callback;
-       wifi_callbacks.connection_state_user_data = user_data;
-
-       return WIFI_ERROR_NONE;
-}
-
-int _wifi_unset_connection_state_cb()
-{
-       if (wifi_callbacks.connection_state_cb == NULL)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       wifi_callbacks.connection_state_cb = NULL;
-       wifi_callbacks.connection_state_user_data = NULL;
-
-       return WIFI_ERROR_NONE;
-}
-
-/*int _wifi_update_ap_info(net_profile_info_t *ap_info)
-{
-       // DELETE:
-       if (net_modify_profile(ap_info->ProfileName, ap_info) != NET_ERR_NONE)
-               return WIFI_ERROR_OPERATION_FAILED;
-
-       return WIFI_ERROR_NONE;
-}*/
diff --git a/src/net_wifi.c b/src/net_wifi.c
deleted file mode 100755 (executable)
index 71b7037..0000000
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * 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.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <glib.h>
-#include <vconf/vconf.h>
-
-#include "net_wifi_private.h"
-
-static bool is_init = false;
-static wifi_rssi_level_changed_cb rssi_level_changed_cb = NULL;
-static void *rssi_level_changed_user_data = NULL;
-
-static void __rssi_level_changed_cb(keynode_t *node, void *user_data)
-{
-       int rssi_level = vconf_keynode_get_int(node);
-       rssi_level_changed_cb(rssi_level, rssi_level_changed_user_data);
-}
-
-EXPORT_API int wifi_initialize(void)
-{
-       if (is_init) {
-               WIFI_LOG(WIFI_ERROR, "Already initialized\n");
-               return WIFI_ERROR_INVALID_OPERATION;
-       }
-
-       if (_wifi_libnet_init() == false) {
-               WIFI_LOG(WIFI_ERROR, "Init failed!\n");
-               return WIFI_ERROR_OPERATION_FAILED;
-       }
-
-       is_init = true;
-
-       WIFI_LOG(WIFI_INFO, "Wi-Fi successfully initialized!\n");
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_deinitialize(void)
-{
-       if (is_init == false) {
-               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
-               return WIFI_ERROR_INVALID_OPERATION;
-       }
-
-       if (_wifi_libnet_deinit() == false) {
-               WIFI_LOG(WIFI_ERROR, "Deinit failed!\n");
-               return WIFI_ERROR_OPERATION_FAILED;
-       }
-
-       is_init = false;
-       wifi_unset_rssi_level_changed_cb();
-
-       WIFI_LOG(WIFI_INFO, "Wi-Fi successfully de-initialized!\n");
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_activate(wifi_activated_cb callback, void* user_data)
-{
-       int rv;
-
-       if (is_init == false) {
-               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
-               return WIFI_ERROR_INVALID_OPERATION;
-       }
-
-       rv = _wifi_activate(callback, user_data);
-
-       /*rv = connman_technology_set_powered_on_wifi(callback, user_data);*/
-       if (rv != WIFI_ERROR_NONE)
-               WIFI_LOG(WIFI_ERROR, "Error!! Wi-Fi Activation failed.\n");
-
-       return rv;
-}
-
-EXPORT_API int wifi_deactivate(wifi_deactivated_cb callback, void* user_data)
-{
-       int rv;
-
-       if (is_init == false) {
-               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
-               return WIFI_ERROR_INVALID_OPERATION;
-       }
-
-       rv = _wifi_deactivate(callback, user_data);
-
-       /*rv = connman_technology_set_powered_off_wifi(callback, user_data);*/
-       if (rv != WIFI_ERROR_NONE)
-               WIFI_LOG(WIFI_ERROR, "Error!! Wi-Fi Deactivation failed.\n");
-
-       return rv;
-}
-
-EXPORT_API int wifi_is_activated(bool* activated)
-{
-       wifi_device_state_e device_state;
-
-       if (activated == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (_wifi_libnet_get_wifi_device_state(&device_state) == false) {
-               return WIFI_ERROR_OPERATION_FAILED;
-       } else {
-               WIFI_LOG(WIFI_INFO, "WiFi = %d\n", device_state);
-               if (WIFI_DEVICE_STATE_DEACTIVATED == device_state)
-                       *activated = false;
-               else
-                       *activated = true;
-       }
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_get_connection_state(wifi_connection_state_e* connection_state)
-{
-       if (connection_state == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (_wifi_libnet_get_wifi_state(connection_state) == false)
-               return WIFI_ERROR_OPERATION_FAILED;
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_get_mac_address(char** mac_address)
-{
-       if (mac_address == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       *mac_address = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
-
-       if (*mac_address == NULL) {
-               WIFI_LOG(WIFI_ERROR, "vconf_get_str Failed\n");
-               return WIFI_ERROR_OPERATION_FAILED;
-       }
-
-       WIFI_LOG(WIFI_INFO, "MAC Address %s\n", *mac_address);
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_get_network_interface_name(char** name)
-{
-       if (name == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       return _wifi_libnet_get_intf_name(name);
-}
-
-EXPORT_API int wifi_scan(wifi_scan_finished_cb callback, void* user_data)
-{
-       int rv;
-
-       if (callback == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (is_init == false) {
-               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
-               return WIFI_ERROR_INVALID_OPERATION;
-       }
-
-       rv = _wifi_libnet_scan_request(callback, user_data);
-       if (rv != WIFI_ERROR_NONE)
-               WIFI_LOG(WIFI_ERROR, "Error!! Wi-Fi scan failed.\n");
-
-       return rv;
-}
-
-EXPORT_API int wifi_scan_hidden_ap(const char* essid, wifi_scan_finished_cb callback, void* user_data)
-{
-       int rv;
-
-       if (callback == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (is_init == false) {
-               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
-               return WIFI_ERROR_INVALID_OPERATION;
-       }
-
-       rv = _wifi_libnet_scan_hidden_ap(essid, callback, user_data);
-       if (rv != WIFI_ERROR_NONE)
-               WIFI_LOG(WIFI_ERROR, "Error!! Wi-Fi hidden scan failed.\n");
-
-       return rv;
-}
-
-EXPORT_API int wifi_get_connected_ap(wifi_ap_h* ap)
-{
-       int rv;
-
-       if (ap == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       rv = _wifi_libnet_get_connected_profile(ap);
-       WIFI_LOG(WIFI_INFO, "Connected AP %p, rv %d\n", *ap, rv);
-
-       return rv;
-}
-
-EXPORT_API int wifi_foreach_found_aps(wifi_found_ap_cb callback, void* user_data)
-{
-       if (callback == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (_wifi_libnet_foreach_found_aps(callback, user_data) == false)
-               return WIFI_ERROR_OPERATION_FAILED;
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_foreach_found_hidden_aps(wifi_found_ap_cb callback, void* user_data)
-{
-       if (callback == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (_wifi_libnet_foreach_found_hidden_aps(callback, user_data) == false)
-               return WIFI_ERROR_OPERATION_FAILED;
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_connect(wifi_ap_h ap, wifi_connected_cb callback, void* user_data)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (is_init == false) {
-               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
-               return WIFI_ERROR_INVALID_OPERATION;
-       }
-
-       return _wifi_libnet_open_profile(ap, callback, user_data);
-}
-
-EXPORT_API int wifi_disconnect(wifi_ap_h ap, wifi_disconnected_cb callback, void* user_data)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (is_init == false) {
-               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
-               return WIFI_ERROR_INVALID_OPERATION;
-       }
-
-       return _wifi_libnet_close_profile(ap, callback, user_data);
-}
-
-EXPORT_API int wifi_connect_by_wps_pbc(wifi_ap_h ap, wifi_connected_cb callback, void* user_data)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (is_init == false) {
-               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
-               return WIFI_ERROR_INVALID_OPERATION;
-       }
-
-       return _wifi_libnet_connect_with_wps(ap, callback, user_data);
-}
-
-EXPORT_API int wifi_forget_ap(wifi_ap_h ap)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (is_init == false) {
-               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
-               return WIFI_ERROR_INVALID_OPERATION;
-       }
-
-       return _wifi_libnet_forget_ap(ap);
-}
-
-EXPORT_API int wifi_set_device_state_changed_cb(wifi_device_state_changed_cb callback, void* user_data)
-{
-       if (callback == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (is_init == false) {
-               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
-               return WIFI_ERROR_INVALID_OPERATION;
-       }
-
-       return _wifi_set_power_on_off_cb(callback, user_data);
-
-       /*return wifi_set_power_on_off_cb(callback, user_data);*/
-}
-
-EXPORT_API int wifi_unset_device_state_changed_cb(void)
-{
-       return _wifi_unset_power_on_off_cb();
-}
-
-EXPORT_API int wifi_set_background_scan_cb(wifi_scan_finished_cb callback, void* user_data)
-{
-       if (callback == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (is_init == false) {
-               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
-               return WIFI_ERROR_INVALID_OPERATION;
-       }
-
-       return _wifi_set_background_scan_cb(callback, user_data);
-}
-
-EXPORT_API int wifi_unset_background_scan_cb(void)
-{
-       return _wifi_unset_background_scan_cb();
-}
-
-EXPORT_API int wifi_set_connection_state_changed_cb(wifi_connection_state_changed_cb callback, void* user_data)
-{
-       if (callback == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (is_init == false) {
-               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
-               return WIFI_ERROR_INVALID_OPERATION;
-       }
-
-       return _wifi_set_connection_state_cb(callback, user_data);
-}
-
-EXPORT_API int wifi_unset_connection_state_changed_cb(void)
-{
-       return _wifi_unset_connection_state_cb();
-}
-
-EXPORT_API int wifi_set_rssi_level_changed_cb(wifi_rssi_level_changed_cb callback, void* user_data)
-{
-       if (callback == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (rssi_level_changed_cb == NULL)
-               vconf_notify_key_changed(VCONFKEY_WIFI_STRENGTH, __rssi_level_changed_cb, NULL);
-       else
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       rssi_level_changed_cb = callback;
-       rssi_level_changed_user_data = user_data;
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_unset_rssi_level_changed_cb(void)
-{
-       if (rssi_level_changed_cb != NULL)
-               vconf_ignore_key_changed(VCONFKEY_WIFI_STRENGTH, __rssi_level_changed_cb);
-       else
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       rssi_level_changed_cb = NULL;
-       rssi_level_changed_user_data = NULL;
-
-       return WIFI_ERROR_NONE;
-}
diff --git a/src/net_wifi_ap.c b/src/net_wifi_ap.c
deleted file mode 100755 (executable)
index c6925b1..0000000
+++ /dev/null
@@ -1,1367 +0,0 @@
-/*
- * 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.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <arpa/inet.h>
-#include <glib.h>
-#include "net_wifi_private.h"
-
-static void convert_wifi_security(wlan_security_info_t *security_info, char **security)
-{
-       while (*security) {
-               if (g_strcmp0(*security, "none") == 0 &&
-                   security_info->sec_mode < WLAN_SEC_MODE_NONE)
-                       security_info->sec_mode = WLAN_SEC_MODE_NONE;
-               else if (!g_strcmp0(*security, "wep"))
-                       security_info->sec_mode = WLAN_SEC_MODE_WEP;
-               else if (!g_strcmp0(*security, "psk"))
-                       security_info->sec_mode = WLAN_SEC_MODE_WPA_PSK;
-               else if (!g_strcmp0(*security, "ieee8021x"))
-                       security_info->sec_mode = WLAN_SEC_MODE_IEEE8021X;
-               else if (!g_strcmp0(*security, "wpa"))
-                       security_info->sec_mode = WLAN_SEC_MODE_WPA_PSK;
-               else if (!g_strcmp0(*security, "rsn"))
-                       security_info->sec_mode = WLAN_SEC_MODE_WPA2_PSK;
-               else if (!g_strcmp0(*security, "wps"))
-                       security_info->wps_support = TRUE;
-               else
-                       security_info->sec_mode = WLAN_SEC_MODE_NONE;
-
-               security++;
-       }
-
-}
-
-/*static char* __ap_convert_ip_to_string(net_addr_t *ip_addr)
-{
-       unsigned char *ipaddr = (unsigned char *)&ip_addr->Data.Ipv4.s_addr;
-
-       char *ipstr = g_try_malloc0(16);
-       if (ipstr == NULL)
-               return NULL;
-
-       g_snprintf(ipstr, 16, "%d.%d.%d.%d", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]);
-
-       return ipstr;
-}*/
-
-static void __wifi_init_ap(net_profile_info_t *profile_info, const char *essid)
-{
-/*     profile_info->profile_type = NET_DEVICE_WIFI;
-       profile_info->ProfileState = NET_STATE_TYPE_IDLE;
-       profile_info->ProfileInfo.Wlan.net_info.IpConfigType = NET_IP_CONFIG_TYPE_OFF;
-       profile_info->ProfileInfo.Wlan.net_info.ProxyMethod = NET_PROXY_TYPE_DIRECT;
-       profile_info->ProfileInfo.Wlan.wlan_mode = NETPM_WLAN_CONNMODE_AUTO;
-       profile_info->ProfileInfo.Wlan.security_info.sec_mode = WLAN_SEC_MODE_NONE;
-       profile_info->ProfileInfo.Wlan.security_info.enc_mode = WLAN_ENC_MODE_NONE;*/
-       profile_info->essid = g_strdup(essid);
-}
-
-wifi_connection_state_e _wifi_convert_to_ap_state(
-                               net_state_type_t state)
-{
-       wifi_connection_state_e ap_state;
-
-       switch (state) {
-       case NET_STATE_TYPE_ONLINE:
-       case NET_STATE_TYPE_READY:
-               ap_state = WIFI_CONNECTION_STATE_CONNECTED;
-               break;
-       case NET_STATE_TYPE_IDLE:
-       case NET_STATE_TYPE_FAILURE:
-       case NET_STATE_TYPE_DISCONNECT:
-               ap_state = WIFI_CONNECTION_STATE_DISCONNECTED;
-               break;
-       case NET_STATE_TYPE_ASSOCIATION:
-               ap_state = WIFI_CONNECTION_STATE_ASSOCIATION;
-               break;
-       case NET_STATE_TYPE_CONFIGURATION:
-               ap_state = WIFI_CONNECTION_STATE_CONFIGURATION;
-               break;
-       default:
-               ap_state = -1;
-               break;
-       }
-
-       return ap_state;
-}
-
-/* Wi-Fi AP ******************************************************************/
-EXPORT_API int wifi_ap_create(const char* essid, wifi_ap_h* ap)
-{
-       if (essid == NULL || ap == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       net_profile_info_t *ap_info = g_try_malloc0(sizeof(net_profile_info_t));
-       if (ap_info == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;
-
-       __wifi_init_ap(ap_info, essid);
-
-       _wifi_libnet_add_to_ap_list((wifi_ap_h)ap_info);
-       *ap = (wifi_ap_h)ap_info;
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_destroy(wifi_ap_h ap)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       _wifi_libnet_remove_from_ap_list(ap);
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_clone(wifi_ap_h* cloned_ap, wifi_ap_h origin)
-{
-       if (_wifi_libnet_check_ap_validity(origin) == false || cloned_ap == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       net_profile_info_t *ap_info = g_try_malloc0(sizeof(net_profile_info_t));
-       if (ap_info == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;
-
-       memcpy(ap_info, origin, sizeof(net_profile_info_t));
-
-       _wifi_libnet_add_to_ap_list((wifi_ap_h)ap_info);
-       *cloned_ap = (wifi_ap_h)ap_info;
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_refresh(wifi_ap_h ap)
-{
-       /*net_profile_info_t ap_info_local;*/
-
-
-       // DELETE:
-/*net_profile_info_t *ap_info = ap;
- * if (net_get_profile_info(ap_info->ProfileName, &ap_info_local) != NET_ERR_NONE) {
-               WIFI_LOG(WIFI_ERROR, "Error!!! net_get_profile_info() failed\n");
-               return WIFI_ERROR_OPERATION_FAILED;
-       }*/
-
-       /*memcpy(ap, &ap_info_local, sizeof(net_profile_info_t));*/
-
-       return WIFI_ERROR_NONE;
-}
-
-/* Wi-Fi network information *************************************************/
-EXPORT_API int wifi_ap_get_essid(wifi_ap_h ap, char** essid)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || essid == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       struct connman_service *service = ap;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       *essid = g_strdup(connman_service_get_name(service));
-       if (*essid == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_get_bssid(wifi_ap_h ap, char** bssid)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || bssid == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       *bssid = g_strdup(profile_info->ProfileInfo.Wlan.bssid);
-       if (*bssid == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;*/
-
-       struct connman_service *service = ap;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       *bssid = g_strdup(connman_service_get_bssid(service));
-       if (*bssid == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_get_rssi(wifi_ap_h ap, int* rssi)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || rssi == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       *rssi = (int)profile_info->ProfileInfo.Wlan.Strength;*/
-
-       struct connman_service *service = ap;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       *rssi = connman_service_get_strength(service);
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_get_frequency(wifi_ap_h ap, int* frequency)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || frequency == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       *frequency = (int)profile_info->ProfileInfo.Wlan.frequency;*/
-
-       struct connman_service *service = ap;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       *frequency = connman_service_get_frequency(service);
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_get_max_speed(wifi_ap_h ap, int* max_speed)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || max_speed == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       *max_speed = (int)profile_info->ProfileInfo.Wlan.max_rate / 1000000;*/
-
-       struct connman_service *service = ap;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       *max_speed = connman_service_get_max_rate(service);
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_is_favorite(wifi_ap_h ap, bool* favorite)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || favorite == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-
-       if (profile_info->Favourite)
-               *favorite = true;
-       else
-               *favorite = false;*/
-
-       struct connman_service *service = ap;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       *favorite = connman_service_get_favorite(service);
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_get_connection_state(wifi_ap_h ap, wifi_connection_state_e* state)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || state == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       enum connman_service_state_type state_type;
-
-       struct connman_service *service = ap;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       state_type = _get_service_state_type(
-                                       connman_service_get_state(service));
-
-       *state = _wifi_convert_to_ap_state(state_type);
-
-       if (*state < 0)
-               return WIFI_ERROR_OPERATION_FAILED;
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_get_ip_config_type(wifi_ap_h ap, wifi_address_family_e address_family, wifi_ip_config_type_e* type)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false ||
-           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
-            address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
-           type == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
-               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
-               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-
-       switch (profile_info->ProfileInfo.Wlan.net_info.IpConfigType) {
-       case NET_IP_CONFIG_TYPE_STATIC:
-               *type = WIFI_IP_CONFIG_TYPE_STATIC;
-               break;
-       case NET_IP_CONFIG_TYPE_DYNAMIC:
-               *type = WIFI_IP_CONFIG_TYPE_DYNAMIC;
-               break;
-       case NET_IP_CONFIG_TYPE_AUTO_IP:
-               *type = WIFI_IP_CONFIG_TYPE_AUTO;
-               break;
-       case NET_IP_CONFIG_TYPE_FIXED:
-               *type = WIFI_IP_CONFIG_TYPE_FIXED;
-               break;
-       case NET_IP_CONFIG_TYPE_OFF:
-               *type = WIFI_IP_CONFIG_TYPE_NONE;
-               break;
-       default:
-               return WIFI_ERROR_OPERATION_FAILED;
-       }*/
-
-       const struct service_ipv4 *ipv4_config;
-       struct connman_service *service = ap;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       ipv4_config = connman_service_get_ipv4_config(service);
-
-       switch (_get_ip_config_type(ipv4_config->method)) {
-       case NET_IP_CONFIG_TYPE_STATIC:
-               *type = WIFI_IP_CONFIG_TYPE_STATIC;
-               break;
-       case NET_IP_CONFIG_TYPE_DYNAMIC:
-               *type = WIFI_IP_CONFIG_TYPE_DYNAMIC;
-               break;
-       case NET_IP_CONFIG_TYPE_AUTO_IP:
-               *type = WIFI_IP_CONFIG_TYPE_AUTO;
-               break;
-       case NET_IP_CONFIG_TYPE_FIXED:
-               *type = WIFI_IP_CONFIG_TYPE_FIXED;
-               break;
-       case NET_IP_CONFIG_TYPE_OFF:
-               *type = WIFI_IP_CONFIG_TYPE_NONE;
-               break;
-       default:
-               return WIFI_ERROR_OPERATION_FAILED;
-       }
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_set_ip_config_type(wifi_ap_h ap, wifi_address_family_e address_family, wifi_ip_config_type_e type)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false ||
-           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
-            address_family != WIFI_ADDRESS_FAMILY_IPV6)) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
-               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
-               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-       }
-
-       net_ip_config_type_t ip_config_type;
-
-       struct connman_service *service = ap;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       switch (type) {
-       case WIFI_IP_CONFIG_TYPE_STATIC:
-               ip_config_type = NET_IP_CONFIG_TYPE_STATIC;
-               break;
-       case WIFI_IP_CONFIG_TYPE_DYNAMIC:
-               ip_config_type = NET_IP_CONFIG_TYPE_DYNAMIC;
-               break;
-       case WIFI_IP_CONFIG_TYPE_AUTO:
-               ip_config_type = NET_IP_CONFIG_TYPE_AUTO_IP;
-               break;
-       case WIFI_IP_CONFIG_TYPE_FIXED:
-               ip_config_type = NET_IP_CONFIG_TYPE_FIXED;
-               break;
-       case WIFI_IP_CONFIG_TYPE_NONE:
-               ip_config_type = NET_IP_CONFIG_TYPE_OFF;
-               break;
-       default:
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       connman_service_set_ipv4_config(service,
-                       _get_ip_config_str(ip_config_type),
-                       IP_INFO_METHOD);
-
-       return WIFI_ERROR_NONE;
-
-       /*if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false)
-               return WIFI_ERROR_NONE;*/
-
-       /*return _wifi_update_ap_info(profile_info)*/;
-}
-
-EXPORT_API int wifi_ap_get_ip_address(wifi_ap_h ap, wifi_address_family_e address_family, char** ip_address)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false ||
-           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
-            address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
-           ip_address == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
-               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
-               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       *ip_address = __ap_convert_ip_to_string(&profile_info->ProfileInfo.Wlan.net_info.IpAddr);
-       if (*ip_address == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;*/
-       const struct service_ipv4 *ipv4;
-       struct connman_service *service = ap;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       ipv4 = connman_service_get_ipv4_info(service);
-       *ip_address = ipv4->address;
-       if (*ip_address == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_set_ip_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* ip_address)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false ||
-           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
-            address_family != WIFI_ADDRESS_FAMILY_IPV6)) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
-               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
-               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-
-       if (ip_address == NULL)
-               profile_info->ProfileInfo.Wlan.net_info.IpAddr.Data.Ipv4.s_addr = 0;
-       else if (inet_aton(ip_address, &(profile_info->ProfileInfo.Wlan.net_info.IpAddr.Data.Ipv4)) == 0)
-               return WIFI_ERROR_INVALID_PARAMETER;
-
-       if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false)
-               return WIFI_ERROR_NONE;*/
-
-       /*return _wifi_update_ap_info(profile_info)*/;
-
-       struct connman_service *service = ap;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       connman_service_set_ipv4_config(service, ip_address, IP_INFO_ADDRESS);
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_get_subnet_mask(wifi_ap_h ap, wifi_address_family_e address_family, char** subnet_mask)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false ||
-           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
-            address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
-           subnet_mask == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
-               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
-               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       *subnet_mask = __ap_convert_ip_to_string(&profile_info->ProfileInfo.Wlan.net_info.SubnetMask);
-       if (*subnet_mask == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;*/
-
-       const struct service_ipv4 *ipv4;
-       struct connman_service *service = ap;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       ipv4 = connman_service_get_ipv4_info(service);
-       *subnet_mask = ipv4->netmask;
-       if (*subnet_mask == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_set_subnet_mask(wifi_ap_h ap, wifi_address_family_e address_family, const char* subnet_mask)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false ||
-           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
-            address_family != WIFI_ADDRESS_FAMILY_IPV6)) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
-               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
-               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-
-       if (subnet_mask == NULL)
-               profile_info->ProfileInfo.Wlan.net_info.SubnetMask.Data.Ipv4.s_addr = 0;
-       else if (inet_aton(subnet_mask, &(profile_info->ProfileInfo.Wlan.net_info.SubnetMask.Data.Ipv4)) == 0)
-               return WIFI_ERROR_INVALID_PARAMETER;
-
-       if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false)
-               return WIFI_ERROR_NONE;*/
-
-       /*return WIFI_ERROR_NONE _wifi_update_ap_info(profile_info)*/
-
-       struct connman_service *service = ap;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       connman_service_set_ipv4_config(service, subnet_mask, IP_INFO_NETMASK);
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_get_gateway_address(wifi_ap_h ap, wifi_address_family_e address_family, char** gateway_address)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false ||
-           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
-            address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
-           gateway_address == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
-               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
-               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       *gateway_address = __ap_convert_ip_to_string(&profile_info->ProfileInfo.Wlan.net_info.GatewayAddr);
-       if (*gateway_address == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;*/
-
-       const struct service_ipv4 *ipv4;
-       struct connman_service *service = ap;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       ipv4 = connman_service_get_ipv4_info(service);
-       *gateway_address = ipv4->gateway;
-       if (*gateway_address == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_set_gateway_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* gateway_address)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false ||
-           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
-            address_family != WIFI_ADDRESS_FAMILY_IPV6)) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
-               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
-               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-       }
-
-/*
-       net_profile_info_t *profile_info = ap;
-
-       if (gateway_address == NULL)
-               profile_info->ProfileInfo.Wlan.net_info.GatewayAddr.Data.Ipv4.s_addr = 0;
-       else if (inet_aton(gateway_address, &(profile_info->ProfileInfo.Wlan.net_info.GatewayAddr.Data.Ipv4)) == 0)
-               return WIFI_ERROR_INVALID_PARAMETER;
-
-       if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false)
-               return WIFI_ERROR_NONE;
-*/
-
-       /*return WIFI_ERROR_NONE _wifi_update_ap_info(profile_info)*/
-
-       struct connman_service *service = ap;
-       if (!service)
-               return NET_ERR_INVALID_PARAM;
-
-       connman_service_set_ipv4_config(service, gateway_address,
-                                                       IP_INFO_GATEWAY);
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_get_proxy_address(wifi_ap_h ap, wifi_address_family_e address_family, char** proxy_address)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false ||
-           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
-            address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
-           proxy_address == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
-               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
-               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       *proxy_address = g_strdup(profile_info->ProfileInfo.Wlan.net_info.ProxyAddr);
-       if (*proxy_address == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;*/
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_set_proxy_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* proxy_address)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false ||
-           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
-            address_family != WIFI_ADDRESS_FAMILY_IPV6)) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
-               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
-               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-       }
-
-/*
-       net_profile_info_t *profile_info = ap;
-
-       if (proxy_address == NULL)
-               profile_info->ProfileInfo.Wlan.net_info.ProxyAddr[0] = '\0';
-       else
-               g_strlcpy(profile_info->ProfileInfo.Wlan.net_info.ProxyAddr,
-                               proxy_address, NET_PROXY_LEN_MAX+1);
-
-       if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false)
-               return WIFI_ERROR_NONE;
-*/
-
-       /*return WIFI_ERROR_NONE_wifi_update_ap_info(profile_info)*/
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_get_proxy_type(wifi_ap_h ap, wifi_proxy_type_e* type)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || type == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-
-       switch (profile_info->ProfileInfo.Wlan.net_info.ProxyMethod) {
-       case NET_PROXY_TYPE_DIRECT:
-               *type = WIFI_PROXY_TYPE_DIRECT;
-               break;
-       case NET_PROXY_TYPE_AUTO:
-               *type = WIFI_PROXY_TYPE_AUTO;
-               break;
-       case NET_PROXY_TYPE_MANUAL:
-               *type = WIFI_PROXY_TYPE_MANUAL;
-               break;
-       case NET_PROXY_TYPE_UNKNOWN:
-               *type = WIFI_PROXY_TYPE_DIRECT;
-               break;
-       default:
-               return WIFI_ERROR_OPERATION_FAILED;
-       }*/
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_set_proxy_type(wifi_ap_h ap, wifi_proxy_type_e proxy_type)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-/*
-       net_profile_info_t *profile_info = ap;
-       int rv;
-
-       switch (proxy_type) {
-       case WIFI_PROXY_TYPE_DIRECT:
-               profile_info->ProfileInfo.Wlan.net_info.ProxyMethod = NET_PROXY_TYPE_DIRECT;
-               break;
-       case WIFI_PROXY_TYPE_AUTO:
-               profile_info->ProfileInfo.Wlan.net_info.ProxyAddr[0] = '\0';
-               profile_info->ProfileInfo.Wlan.net_info.ProxyMethod = NET_PROXY_TYPE_AUTO;
-               break;
-       case WIFI_PROXY_TYPE_MANUAL:
-               profile_info->ProfileInfo.Wlan.net_info.ProxyAddr[0] = '\0';
-               profile_info->ProfileInfo.Wlan.net_info.ProxyMethod = NET_PROXY_TYPE_MANUAL;
-               break;
-       default:
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }*/
-/*
-       if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false)
-               return WIFI_ERROR_NONE;
-
-       rv = WIFI_ERROR_NONE;_wifi_update_ap_info(profile_info);
-       if (rv != NET_ERR_NONE && proxy_type == WIFI_PROXY_TYPE_MANUAL) {
-               g_strlcpy(profile_info->ProfileInfo.Wlan.net_info.ProxyAddr, "0.0.0.0:8080", 15);
-               rv = _wifi_update_ap_info(profile_info);
-       }*/
-
-       return 0;
-}
-
-EXPORT_API int wifi_ap_get_dns_address(wifi_ap_h ap, int order, wifi_address_family_e address_family, char** dns_address)
-{
-/*     if (_wifi_libnet_check_ap_validity(ap) == false ||
-           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
-            address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
-           dns_address == NULL ||
-           order <= 0 ||
-           order > NET_DNS_ADDR_MAX) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
-               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
-               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-       }*/
-
-/*     net_profile_info_t *profile_info = ap;
-
-       *dns_address = __ap_convert_ip_to_string(&profile_info->ProfileInfo.Wlan.net_info.DnsAddr[order-1]);
-       if (*dns_address == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;*/
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_set_dns_address(wifi_ap_h ap, int order, wifi_address_family_e address_family, const char* dns_address)
-{
-/*     if (_wifi_libnet_check_ap_validity(ap) == false ||
-           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
-            address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
-           order <= 0 ||
-           order > NET_DNS_ADDR_MAX) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
-               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
-               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-       }*/
-
-/*     net_profile_info_t *profile_info = ap;
-
-       if (dns_address == NULL)
-               profile_info->ProfileInfo.Wlan.net_info.DnsAddr[order-1].Data.Ipv4.s_addr = 0;
-       else if (inet_aton(dns_address, &(profile_info->ProfileInfo.Wlan.net_info.DnsAddr[order-1].Data.Ipv4)) == 0)
-               return WIFI_ERROR_INVALID_PARAMETER;
-
-       if (profile_info->ProfileInfo.Wlan.net_info.DnsCount < order)
-               profile_info->ProfileInfo.Wlan.net_info.DnsCount = order;
-
-       if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false)
-               return WIFI_ERROR_NONE;*/
-
-       return WIFI_ERROR_NONE/*_wifi_update_ap_info(profile_info)*/;
-}
-
-/* Wi-Fi security information ************************************************/
-EXPORT_API int wifi_ap_get_security_type(wifi_ap_h ap, wifi_security_type_e* type)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || type == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-
-       switch (profile_info->ProfileInfo.Wlan.security_info.sec_mode) {
-       case WLAN_SEC_MODE_NONE:
-               *type = WIFI_SECURITY_TYPE_NONE;
-               break;
-       case WLAN_SEC_MODE_WEP:
-               *type = WIFI_SECURITY_TYPE_WEP;
-               break;
-       case WLAN_SEC_MODE_IEEE8021X:
-               *type = WIFI_SECURITY_TYPE_EAP;
-               break;
-       case WLAN_SEC_MODE_WPA_PSK:
-               *type = WIFI_SECURITY_TYPE_WPA_PSK;
-               break;
-       case WLAN_SEC_MODE_WPA2_PSK:
-               *type = WIFI_SECURITY_TYPE_WPA2_PSK;
-               break;
-       default:
-               return WIFI_ERROR_OPERATION_FAILED;
-       }*/
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_set_security_type(wifi_ap_h ap, wifi_security_type_e type)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-
-       switch (type) {
-       case WIFI_SECURITY_TYPE_NONE:
-               profile_info->ProfileInfo.Wlan.security_info.sec_mode = WLAN_SEC_MODE_NONE;
-               break;
-       case WIFI_SECURITY_TYPE_WEP:
-               profile_info->ProfileInfo.Wlan.security_info.sec_mode = WLAN_SEC_MODE_WEP;
-               break;
-       case WIFI_SECURITY_TYPE_EAP:
-               profile_info->ProfileInfo.Wlan.security_info.sec_mode = WLAN_SEC_MODE_IEEE8021X;
-               break;
-       case WIFI_SECURITY_TYPE_WPA_PSK:
-               profile_info->ProfileInfo.Wlan.security_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
-               break;
-       case WIFI_SECURITY_TYPE_WPA2_PSK:
-               profile_info->ProfileInfo.Wlan.security_info.sec_mode = WLAN_SEC_MODE_WPA2_PSK;
-               break;
-       default:
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }*/
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_get_encryption_type(wifi_ap_h ap, wifi_encryption_type_e* type)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || type == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       /*
-       net_profile_info_t *profile_info = ap;
-
-       switch (profile_info->ProfileInfo.Wlan.security_info.enc_mode) {
-       case WLAN_ENC_MODE_NONE:
-               *type = WIFI_ENCRYPTION_TYPE_NONE;
-               break;
-       case WLAN_ENC_MODE_WEP:
-               *type = WIFI_ENCRYPTION_TYPE_WEP;
-               break;
-       case WLAN_ENC_MODE_TKIP:
-               *type = WIFI_ENCRYPTION_TYPE_TKIP;
-               break;
-       case WLAN_ENC_MODE_AES:
-               *type = WIFI_ENCRYPTION_TYPE_AES;
-               break;
-       case WLAN_ENC_MODE_TKIP_AES_MIXED:
-               *type = WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED;
-               break;
-       default:
-               return WIFI_ERROR_OPERATION_FAILED;
-       }
-       */
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_set_encryption_type(wifi_ap_h ap, wifi_encryption_type_e type)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-
-       switch (type) {
-       case WIFI_ENCRYPTION_TYPE_NONE:
-               profile_info->ProfileInfo.Wlan.security_info.enc_mode = WLAN_ENC_MODE_NONE;
-               break;
-       case WIFI_ENCRYPTION_TYPE_WEP:
-               profile_info->ProfileInfo.Wlan.security_info.enc_mode = WLAN_ENC_MODE_WEP;
-               break;
-       case WIFI_ENCRYPTION_TYPE_TKIP:
-               profile_info->ProfileInfo.Wlan.security_info.enc_mode = WLAN_ENC_MODE_TKIP;
-               break;
-       case WIFI_ENCRYPTION_TYPE_AES:
-               profile_info->ProfileInfo.Wlan.security_info.enc_mode = WLAN_ENC_MODE_AES;
-               break;
-       case WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED:
-               profile_info->ProfileInfo.Wlan.security_info.enc_mode = WLAN_ENC_MODE_TKIP_AES_MIXED;
-               break;
-       default:
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }*/
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_is_passphrase_required(wifi_ap_h ap, bool* required)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || required == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-       struct connman_service *service = ap;
-
-       if (connman_service_get_favorite(service)) {
-               *required = false;
-               return WIFI_ERROR_NONE;
-       }
-
-       wlan_security_info_t sec_info;
-       convert_wifi_security(&sec_info, connman_service_get_security(service));
-
-       switch (sec_info.sec_mode) {
-       case WLAN_SEC_MODE_NONE:
-               *required = false;
-               break;
-       case WLAN_SEC_MODE_WEP:
-       case WLAN_SEC_MODE_IEEE8021X:
-       case WLAN_SEC_MODE_WPA_PSK:
-       case WLAN_SEC_MODE_WPA2_PSK:
-               *required = true;
-               break;
-       default:
-               return WIFI_ERROR_OPERATION_FAILED;
-       }
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_set_passphrase(wifi_ap_h ap, const char* passphrase)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || passphrase == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-
-       switch (profile_info->ProfileInfo.Wlan.security_info.sec_mode) {
-       case WLAN_SEC_MODE_WEP:
-               g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.wep.wepKey,
-                               passphrase, NETPM_WLAN_MAX_WEP_KEY_LEN+1);
-               break;
-       case WLAN_SEC_MODE_WPA_PSK:
-       case WLAN_SEC_MODE_WPA2_PSK:
-               g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.psk.pskKey,
-                               passphrase, NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN+1);
-               break;
-       case WLAN_SEC_MODE_NONE:
-       case WLAN_SEC_MODE_IEEE8021X:
-       default:
-               return WIFI_ERROR_OPERATION_FAILED;
-       }*/
-
-       struct connman_service* service = ap;
-       net_wifi_connection_info_t wifi_conn_info;
-       memset(&wifi_conn_info, 0, sizeof(net_wifi_connection_info_t));
-
-       wifi_conn_info.wlan_mode = NETPM_WLAN_CONNMODE_AUTO;
-
-       wlan_security_info_t sec_info;
-       convert_wifi_security(&sec_info, connman_service_get_security(service));
-
-       switch (sec_info.sec_mode) {
-       case WLAN_SEC_MODE_WEP:
-               g_strlcpy(
-                       wifi_conn_info.security_info.authentication.wep.wepKey,
-                       passphrase,
-                       NETPM_WLAN_MAX_WEP_KEY_LEN+1);
-               break;
-       case WLAN_SEC_MODE_WPA_PSK:
-       case WLAN_SEC_MODE_WPA2_PSK:
-               g_strlcpy(
-                       wifi_conn_info.security_info.authentication.psk.pskKey,
-                       passphrase,
-                       NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN+1);
-               break;
-       case WLAN_SEC_MODE_NONE:
-       case WLAN_SEC_MODE_IEEE8021X:
-       default:
-               return WIFI_ERROR_OPERATION_FAILED;
-       }
-
-       g_strlcpy(
-               wifi_conn_info.essid,
-               connman_service_get_name(service),
-               NET_WLAN_ESSID_LEN + 1);
-
-       wifi_conn_info.security_info.sec_mode = sec_info.sec_mode;
-
-       _set_wifi_conn_info(&wifi_conn_info);
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_is_wps_supported(wifi_ap_h ap, bool* supported)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || supported == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-
-       if (profile_info->ProfileInfo.Wlan.security_info.wps_support)
-               *supported = true;
-       else
-               *supported = false;*/
-
-       return WIFI_ERROR_NONE;
-}
-
-/* Wi-Fi EAP *****************************************************************/
-EXPORT_API int wifi_ap_set_eap_passphrase(wifi_ap_h ap, const char* user_name, const char* password)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || (user_name == NULL && password == NULL)) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       if (user_name)
-               g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.username,
-                               user_name, NETPM_WLAN_USERNAME_LEN+1);
-
-       if (password)
-               g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.password,
-                               password, NETPM_WLAN_PASSWORD_LEN+1);*/
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_get_eap_passphrase(wifi_ap_h ap, char** user_name, bool* is_password_set)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false ||user_name == NULL || is_password_set == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       *user_name = g_strdup(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.username);
-       if (*user_name == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;
-
-       if (strlen(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.password) > 0)
-               *is_password_set = true;
-       else
-               *is_password_set = false;*/
-
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_get_eap_ca_cert_file(wifi_ap_h ap, char** file)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       *file = g_strdup(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.ca_cert_filename);
-       if (*file == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;*/
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_set_eap_ca_cert_file(wifi_ap_h ap, const char* file)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.ca_cert_filename,
-                       file, NETPM_WLAN_CA_CERT_FILENAME_LEN+1);*/
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_get_eap_client_cert_file(wifi_ap_h ap, char** file)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       *file = g_strdup(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.client_cert_filename);
-       if (*file == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;*/
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_set_eap_client_cert_file(wifi_ap_h ap, const char* file)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.client_cert_filename,
-                       file, NETPM_WLAN_CLIENT_CERT_FILENAME_LEN+1);*/
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_get_eap_private_key_file(wifi_ap_h ap, char** file)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       *file = g_strdup(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.private_key_filename);
-       if (*file == NULL)
-               return WIFI_ERROR_OUT_OF_MEMORY;*/
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_set_eap_private_key_info(wifi_ap_h ap, const char* file, const char* password)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.private_key_filename,
-                       file, NETPM_WLAN_PRIVATE_KEY_FILENAME_LEN+1);
-
-       if (password) {
-               g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.private_key_passwd,
-                               password, NETPM_WLAN_PRIVATE_KEY_PASSWD_LEN+1);
-       }*/
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_get_eap_type(wifi_ap_h ap, wifi_eap_type_e* type)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || type == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       switch (profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_type) {
-       case WLAN_SEC_EAP_TYPE_PEAP:
-               *type = WIFI_EAP_TYPE_PEAP;
-               break;
-       case WLAN_SEC_EAP_TYPE_TLS:
-               *type = WIFI_EAP_TYPE_TLS;
-               break;
-       case WLAN_SEC_EAP_TYPE_TTLS:
-               *type = WIFI_EAP_TYPE_TTLS;
-               break;
-       case WLAN_SEC_EAP_TYPE_SIM:
-               *type = WIFI_EAP_TYPE_SIM;
-               break;
-       case WLAN_SEC_EAP_TYPE_AKA:
-               *type = WIFI_EAP_TYPE_AKA;
-               break;
-       default:
-               return WIFI_ERROR_OPERATION_FAILED;
-       }*/
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_set_eap_type(wifi_ap_h ap, wifi_eap_type_e type)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       switch (type) {
-       case WIFI_EAP_TYPE_PEAP:
-               profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_type = WLAN_SEC_EAP_TYPE_PEAP;
-               break;
-       case WIFI_EAP_TYPE_TLS:
-               profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_type = WLAN_SEC_EAP_TYPE_TLS;
-               break;
-       case WIFI_EAP_TYPE_TTLS:
-               profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_type = WLAN_SEC_EAP_TYPE_TTLS;
-               break;
-       case WIFI_EAP_TYPE_SIM:
-               profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_type = WLAN_SEC_EAP_TYPE_SIM;
-               break;
-       case WIFI_EAP_TYPE_AKA:
-               profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_type = WLAN_SEC_EAP_TYPE_AKA;
-               break;
-       default:
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }*/
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_get_eap_auth_type(wifi_ap_h ap, wifi_eap_auth_type_e* type)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false || type == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       switch (profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_auth) {
-       case WLAN_SEC_EAP_AUTH_NONE:
-               *type = WIFI_EAP_AUTH_TYPE_NONE;
-               break;
-       case WLAN_SEC_EAP_AUTH_PAP:
-               *type = WIFI_EAP_AUTH_TYPE_PAP;
-               break;
-       case WLAN_SEC_EAP_AUTH_MSCHAP:
-               *type = WIFI_EAP_AUTH_TYPE_MSCHAP;
-               break;
-       case WLAN_SEC_EAP_AUTH_MSCHAPV2:
-               *type = WIFI_EAP_AUTH_TYPE_MSCHAPV2;
-               break;
-       case WLAN_SEC_EAP_AUTH_GTC:
-               *type = WIFI_EAP_AUTH_TYPE_GTC;
-               break;
-       case WLAN_SEC_EAP_AUTH_MD5:
-               *type = WIFI_EAP_AUTH_TYPE_MD5;
-               break;
-       default:
-               return WIFI_ERROR_OPERATION_FAILED;
-       }*/
-
-       return WIFI_ERROR_NONE;
-}
-
-EXPORT_API int wifi_ap_set_eap_auth_type(wifi_ap_h ap, wifi_eap_auth_type_e type)
-{
-       if (_wifi_libnet_check_ap_validity(ap) == false) {
-               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }
-
-/*     net_profile_info_t *profile_info = ap;
-       if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
-               return WIFI_ERROR_INVALID_OPERATION;
-
-       switch (type) {
-       case WIFI_EAP_AUTH_TYPE_NONE:
-               profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_NONE;
-               break;
-       case WIFI_EAP_AUTH_TYPE_PAP:
-               profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_PAP;
-               break;
-       case WIFI_EAP_AUTH_TYPE_MSCHAP:
-               profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_MSCHAP;
-               break;
-       case WIFI_EAP_AUTH_TYPE_MSCHAPV2:
-               profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_MSCHAPV2;
-               break;
-       case WIFI_EAP_AUTH_TYPE_GTC:
-               profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_GTC;
-               break;
-       case WIFI_EAP_AUTH_TYPE_MD5:
-               profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_MD5;
-               break;
-       default:
-               return WIFI_ERROR_INVALID_PARAMETER;
-       }*/
-
-       return WIFI_ERROR_NONE;
-}
diff --git a/src/wifi-ap.c b/src/wifi-ap.c
new file mode 100755 (executable)
index 0000000..e6b4c02
--- /dev/null
@@ -0,0 +1,900 @@
+/*
+* Network Wi-Fi library
+*
+* Copyright (c) 2014-2015 Intel Corporation. All rights reserved.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*              http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+#include <stdio.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <glib.h>
+
+#include <connman-service.h>
+
+#include "wifi-internal.h"
+
+static void convert_wifi_security(wlan_security_info_t *security_info,
+                                                       char **security)
+{
+       while (*security) {
+               if (g_strcmp0(*security, "none") == 0 &&
+                   security_info->sec_mode < WLAN_SEC_MODE_NONE)
+                       security_info->sec_mode = WLAN_SEC_MODE_NONE;
+               else if (!g_strcmp0(*security, "wep"))
+                       security_info->sec_mode = WLAN_SEC_MODE_WEP;
+               else if (!g_strcmp0(*security, "psk"))
+                       security_info->sec_mode = WLAN_SEC_MODE_WPA_PSK;
+               else if (!g_strcmp0(*security, "ieee8021x"))
+                       security_info->sec_mode = WLAN_SEC_MODE_IEEE8021X;
+               else if (!g_strcmp0(*security, "wpa"))
+                       security_info->sec_mode = WLAN_SEC_MODE_WPA_PSK;
+               else if (!g_strcmp0(*security, "rsn"))
+                       security_info->sec_mode = WLAN_SEC_MODE_WPA2_PSK;
+               else if (!g_strcmp0(*security, "wps"))
+                       security_info->wps_support = TRUE;
+               else
+                       security_info->sec_mode = WLAN_SEC_MODE_NONE;
+
+               security++;
+       }
+
+}
+
+static void __wifi_init_ap(net_profile_info_t *profile_info,
+                                                       const char *essid)
+{
+       profile_info->essid = g_strdup(essid);
+}
+
+wifi_connection_state_e _wifi_convert_to_ap_state(
+                               net_state_type_t state)
+{
+       wifi_connection_state_e ap_state;
+
+       switch (state) {
+       case NET_STATE_TYPE_ONLINE:
+       case NET_STATE_TYPE_READY:
+               ap_state = WIFI_CONNECTION_STATE_CONNECTED;
+               break;
+       case NET_STATE_TYPE_IDLE:
+       case NET_STATE_TYPE_FAILURE:
+       case NET_STATE_TYPE_DISCONNECT:
+               ap_state = WIFI_CONNECTION_STATE_DISCONNECTED;
+               break;
+       case NET_STATE_TYPE_ASSOCIATION:
+               ap_state = WIFI_CONNECTION_STATE_ASSOCIATION;
+               break;
+       case NET_STATE_TYPE_CONFIGURATION:
+               ap_state = WIFI_CONNECTION_STATE_CONFIGURATION;
+               break;
+       default:
+               ap_state = -1;
+               break;
+       }
+
+       return ap_state;
+}
+
+/* Wi-Fi AP ******************************************************************/
+EXPORT_API int wifi_ap_create(const char* essid, wifi_ap_h* ap)
+{
+       if (essid == NULL || ap == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       net_profile_info_t *ap_info =
+                               g_try_malloc0(sizeof(net_profile_info_t));
+       if (ap_info == NULL)
+               return WIFI_ERROR_OUT_OF_MEMORY;
+
+       __wifi_init_ap(ap_info, essid);
+
+       _wifi_libnet_add_to_ap_list((wifi_ap_h)ap_info);
+       *ap = (wifi_ap_h)ap_info;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_destroy(wifi_ap_h ap)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       _wifi_libnet_remove_from_ap_list(ap);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_clone(wifi_ap_h* cloned_ap, wifi_ap_h origin)
+{
+       if (_wifi_libnet_check_ap_validity(origin) == false ||
+                                               cloned_ap == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       net_profile_info_t *ap_info =
+                               g_try_malloc0(sizeof(net_profile_info_t));
+       if (ap_info == NULL)
+               return WIFI_ERROR_OUT_OF_MEMORY;
+
+       memcpy(ap_info, origin, sizeof(net_profile_info_t));
+
+       _wifi_libnet_add_to_ap_list((wifi_ap_h)ap_info);
+       *cloned_ap = (wifi_ap_h)ap_info;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_refresh(wifi_ap_h ap)
+{
+       return WIFI_ERROR_NONE;
+}
+
+/* Wi-Fi network information *************************************************/
+EXPORT_API int wifi_ap_get_essid(wifi_ap_h ap, char** essid)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || essid == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       struct connman_service *service = ap;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       *essid = g_strdup(connman_service_get_name(service));
+       if (*essid == NULL)
+               return WIFI_ERROR_OUT_OF_MEMORY;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_bssid(wifi_ap_h ap, char** bssid)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || bssid == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       struct connman_service *service = ap;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       *bssid = g_strdup(connman_service_get_bssid(service));
+       if (*bssid == NULL)
+               return WIFI_ERROR_OUT_OF_MEMORY;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_rssi(wifi_ap_h ap, int* rssi)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || rssi == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       struct connman_service *service = ap;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       *rssi = connman_service_get_strength(service);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_frequency(wifi_ap_h ap, int* frequency)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || frequency == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       struct connman_service *service = ap;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       *frequency = connman_service_get_frequency(service);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_max_speed(wifi_ap_h ap, int* max_speed)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || max_speed == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       struct connman_service *service = ap;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       *max_speed = connman_service_get_max_rate(service);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_is_favorite(wifi_ap_h ap, bool* favorite)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || favorite == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       struct connman_service *service = ap;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       *favorite = connman_service_get_favorite(service);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_connection_state(wifi_ap_h ap,
+                                       wifi_connection_state_e* state)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || state == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       enum connman_service_state_type state_type;
+
+       struct connman_service *service = ap;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       state_type = _wifi_get_service_state_type(
+                                       connman_service_get_state(service));
+
+       *state = _wifi_convert_to_ap_state(state_type);
+
+       if (*state < 0)
+               return WIFI_ERROR_OPERATION_FAILED;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_wifi_get_ip_config_type(wifi_ap_h ap,
+                               wifi_address_family_e address_family,
+                               wifi_ip_config_type_e* type)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false ||
+           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
+            address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
+           type == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
+               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
+               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+       }
+
+       const struct service_ipv4 *ipv4_config;
+       struct connman_service *service = ap;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       ipv4_config = connman_service_get_ipv4_config(service);
+
+       switch (_wifi_get_ip_config_type(ipv4_config->method)) {
+       case NET_IP_CONFIG_TYPE_STATIC:
+               *type = WIFI_IP_CONFIG_TYPE_STATIC;
+               break;
+       case NET_IP_CONFIG_TYPE_DYNAMIC:
+               *type = WIFI_IP_CONFIG_TYPE_DYNAMIC;
+               break;
+       case NET_IP_CONFIG_TYPE_AUTO_IP:
+               *type = WIFI_IP_CONFIG_TYPE_AUTO;
+               break;
+       case NET_IP_CONFIG_TYPE_FIXED:
+               *type = WIFI_IP_CONFIG_TYPE_FIXED;
+               break;
+       case NET_IP_CONFIG_TYPE_OFF:
+               *type = WIFI_IP_CONFIG_TYPE_NONE;
+               break;
+       default:
+               return WIFI_ERROR_OPERATION_FAILED;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_set_ip_config_type(wifi_ap_h ap,
+                               wifi_address_family_e address_family,
+                               wifi_ip_config_type_e type)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false ||
+           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
+            address_family != WIFI_ADDRESS_FAMILY_IPV6)) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
+               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
+               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+       }
+
+       net_ip_config_type_t ip_config_type;
+
+       struct connman_service *service = ap;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       switch (type) {
+       case WIFI_IP_CONFIG_TYPE_STATIC:
+               ip_config_type = NET_IP_CONFIG_TYPE_STATIC;
+               break;
+       case WIFI_IP_CONFIG_TYPE_DYNAMIC:
+               ip_config_type = NET_IP_CONFIG_TYPE_DYNAMIC;
+               break;
+       case WIFI_IP_CONFIG_TYPE_AUTO:
+               ip_config_type = NET_IP_CONFIG_TYPE_AUTO_IP;
+               break;
+       case WIFI_IP_CONFIG_TYPE_FIXED:
+               ip_config_type = NET_IP_CONFIG_TYPE_FIXED;
+               break;
+       case WIFI_IP_CONFIG_TYPE_NONE:
+               ip_config_type = NET_IP_CONFIG_TYPE_OFF;
+               break;
+       default:
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       struct service_ipv4 ipv4_config;
+       memset(&ipv4_config, 0, sizeof(struct service_ipv4));
+       ipv4_config.method = _wifi_get_ip_config_str(ip_config_type);
+
+       connman_service_set_ipv4_config(service,
+                       &ipv4_config);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_ip_address(wifi_ap_h ap,
+                               wifi_address_family_e address_family,
+                               char** ip_address)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false ||
+           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
+            address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
+           ip_address == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
+               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
+               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+       }
+
+       const struct service_ipv4 *ipv4;
+       struct connman_service *service = ap;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       ipv4 = connman_service_get_ipv4_info(service);
+       *ip_address = ipv4->address;
+       if (*ip_address == NULL)
+               return WIFI_ERROR_OUT_OF_MEMORY;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_set_ip_address(wifi_ap_h ap,
+                               wifi_address_family_e address_family,
+                               const char* ip_address)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false ||
+           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
+            address_family != WIFI_ADDRESS_FAMILY_IPV6)) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
+               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
+               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+       }
+
+       struct connman_service *service = ap;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       struct service_ipv4 ipv4_config;
+       memset(&ipv4_config, 0, sizeof(struct service_ipv4));
+       ipv4_config.method = "manual";
+       ipv4_config.address = g_strdup(ip_address);
+
+       connman_service_set_ipv4_config(service, &ipv4_config);
+
+       g_free(ipv4_config.address);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_subnet_mask(wifi_ap_h ap,
+                               wifi_address_family_e address_family,
+                               char** subnet_mask)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false ||
+           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
+            address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
+           subnet_mask == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
+               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
+               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+       }
+
+       const struct service_ipv4 *ipv4;
+       struct connman_service *service = ap;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       ipv4 = connman_service_get_ipv4_info(service);
+       *subnet_mask = ipv4->netmask;
+       if (*subnet_mask == NULL)
+               return WIFI_ERROR_OUT_OF_MEMORY;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_set_subnet_mask(wifi_ap_h ap,
+                               wifi_address_family_e address_family,
+                               const char* subnet_mask)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false ||
+           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
+            address_family != WIFI_ADDRESS_FAMILY_IPV6)) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
+               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
+               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+       }
+
+       struct connman_service *service = ap;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       struct service_ipv4 ipv4_config;
+       memset(&ipv4_config, 0, sizeof(struct service_ipv4));
+       ipv4_config.method = "manual";
+       ipv4_config.netmask = g_strdup(subnet_mask);
+
+       connman_service_set_ipv4_config(service, &ipv4_config);
+
+       g_free(ipv4_config.netmask);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_gateway_address(wifi_ap_h ap,
+                               wifi_address_family_e address_family,
+                               char** gateway_address)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false ||
+           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
+            address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
+           gateway_address == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
+               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
+               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+       }
+
+       const struct service_ipv4 *ipv4;
+       struct connman_service *service = ap;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       ipv4 = connman_service_get_ipv4_info(service);
+       *gateway_address = ipv4->gateway;
+       if (*gateway_address == NULL)
+               return WIFI_ERROR_OUT_OF_MEMORY;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_set_gateway_address(wifi_ap_h ap,
+                               wifi_address_family_e address_family,
+                               const char* gateway_address)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false ||
+           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
+            address_family != WIFI_ADDRESS_FAMILY_IPV6)) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
+               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
+               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+       }
+
+       struct connman_service *service = ap;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       struct service_ipv4 ipv4_config;
+       memset(&ipv4_config, 0, sizeof(struct service_ipv4));
+       ipv4_config.method = "manual";
+       ipv4_config.gateway = g_strdup(gateway_address);
+
+       connman_service_set_ipv4_config(service, &ipv4_config);
+
+       g_free(ipv4_config.gateway);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_proxy_address(wifi_ap_h ap,
+                               wifi_address_family_e address_family,
+                               char** proxy_address)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false ||
+           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
+            address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
+           proxy_address == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
+               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
+               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_set_proxy_address(wifi_ap_h ap,
+                               wifi_address_family_e address_family,
+                               const char* proxy_address)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false ||
+           (address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
+            address_family != WIFI_ADDRESS_FAMILY_IPV6)) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
+               WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
+               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_proxy_type(wifi_ap_h ap, wifi_proxy_type_e* type)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || type == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_set_proxy_type(wifi_ap_h ap,
+                                       wifi_proxy_type_e proxy_type)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return 0;
+}
+
+EXPORT_API int wifi_ap_get_dns_address(wifi_ap_h ap, int order,
+                               wifi_address_family_e address_family,
+                               char** dns_address)
+{
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_set_dns_address(wifi_ap_h ap, int order,
+                               wifi_address_family_e address_family,
+                               const char* dns_address)
+{
+       return WIFI_ERROR_NONE;
+}
+
+/* Wi-Fi security information ************************************************/
+EXPORT_API int wifi_ap_get_security_type(wifi_ap_h ap,
+                                               wifi_security_type_e* type)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || type == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_set_security_type(wifi_ap_h ap,
+                                               wifi_security_type_e type)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_encryption_type(wifi_ap_h ap,
+                                               wifi_encryption_type_e* type)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || type == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_set_encryption_type(wifi_ap_h ap,
+                                               wifi_encryption_type_e type)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_is_passphrase_required(wifi_ap_h ap, bool* required)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || required == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       struct connman_service *service = ap;
+
+       if (connman_service_get_favorite(service)) {
+               *required = false;
+               return WIFI_ERROR_NONE;
+       }
+
+       wlan_security_info_t sec_info;
+       convert_wifi_security(&sec_info, connman_service_get_security(service));
+
+       switch (sec_info.sec_mode) {
+       case WLAN_SEC_MODE_NONE:
+               *required = false;
+               break;
+       case WLAN_SEC_MODE_WEP:
+       case WLAN_SEC_MODE_IEEE8021X:
+       case WLAN_SEC_MODE_WPA_PSK:
+       case WLAN_SEC_MODE_WPA2_PSK:
+               *required = true;
+               break;
+       default:
+               return WIFI_ERROR_OPERATION_FAILED;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_set_passphrase(wifi_ap_h ap, const char* passphrase)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false ||
+                                                       passphrase == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       struct connman_service* service = ap;
+       net_wifi_connection_info_t wifi_conn_info;
+       memset(&wifi_conn_info, 0, sizeof(net_wifi_connection_info_t));
+
+       wifi_conn_info.wlan_mode = NETPM_WLAN_CONNMODE_AUTO;
+
+       wlan_security_info_t sec_info;
+       convert_wifi_security(&sec_info, connman_service_get_security(service));
+
+       switch (sec_info.sec_mode) {
+       case WLAN_SEC_MODE_WEP:
+               g_strlcpy(
+                       wifi_conn_info.security_info.authentication.wep.wepKey,
+                       passphrase,
+                       NETPM_WLAN_MAX_WEP_KEY_LEN+1);
+               break;
+       case WLAN_SEC_MODE_WPA_PSK:
+       case WLAN_SEC_MODE_WPA2_PSK:
+               g_strlcpy(
+                       wifi_conn_info.security_info.authentication.psk.pskKey,
+                       passphrase,
+                       NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN+1);
+               break;
+       case WLAN_SEC_MODE_NONE:
+       case WLAN_SEC_MODE_IEEE8021X:
+       default:
+               return WIFI_ERROR_OPERATION_FAILED;
+       }
+
+       g_strlcpy(
+               wifi_conn_info.essid,
+               connman_service_get_name(service),
+               NET_WLAN_ESSID_LEN + 1);
+
+       wifi_conn_info.security_info.sec_mode = sec_info.sec_mode;
+
+       _wifi_set_conn_info(&wifi_conn_info);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_is_wps_supported(wifi_ap_h ap, bool* supported)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || supported == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+/* Wi-Fi EAP *****************************************************************/
+EXPORT_API int wifi_ap_set_eap_passphrase(wifi_ap_h ap,
+                               const char* user_name, const char* password)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false ||
+                               (user_name == NULL && password == NULL)) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_eap_passphrase(wifi_ap_h ap, char** user_name,
+                                               bool* is_password_set)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false ||user_name == NULL ||
+                                       is_password_set == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_eap_ca_cert_file(wifi_ap_h ap, char** file)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_set_eap_ca_cert_file(wifi_ap_h ap, const char* file)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_eap_client_cert_file(wifi_ap_h ap, char** file)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_set_eap_client_cert_file(wifi_ap_h ap,
+                                                       const char* file)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_eap_private_key_file(wifi_ap_h ap, char** file)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_set_eap_private_key_info(wifi_ap_h ap,
+                               const char* file, const char* password)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_eap_type(wifi_ap_h ap, wifi_eap_type_e* type)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || type == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_set_eap_type(wifi_ap_h ap, wifi_eap_type_e type)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_eap_auth_type(wifi_ap_h ap,
+                                               wifi_eap_auth_type_e* type)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false || type == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_set_eap_auth_type(wifi_ap_h ap,
+                                               wifi_eap_auth_type_e type)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIFI_ERROR_NONE;
+}
diff --git a/src/wifi-internal.c b/src/wifi-internal.c
new file mode 100755 (executable)
index 0000000..c9c3262
--- /dev/null
@@ -0,0 +1,1199 @@
+/*
+* Network Wi-Fi library
+*
+* Copyright (c) 2014-2015 Intel Corporation. All rights reserved.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*              http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <glib.h>
+
+#include <winet-wifi.h>
+
+#include <connman-lib.h>
+#include <connman-manager.h>
+#include <connman-technology.h>
+#include <connman-service.h>
+
+#include "wifi-internal.h"
+
+static GSList *ap_handle_list = NULL;
+
+typedef struct {
+       char *type;
+       char *mode;
+       char *ssid;
+       char *security;
+       char *passphrase;
+       char *eap_type;
+       char *eap_auth;
+       char *identity;
+       char *password;
+       char *ca_cert_file;
+       char *client_cert_file;
+       char *private_key_file;
+       char *private_key_password;
+} net_wifi_connect_service_info_t;
+
+struct _wifi_cb_s {
+       wifi_device_state_changed_cb device_state_cb;
+       void *device_state_user_data;
+       wifi_scan_finished_cb bg_scan_cb;
+       void *bg_scan_user_data;
+       wifi_scan_finished_cb scan_request_cb;
+       void *scan_request_user_data;
+       wifi_scan_finished_cb scan_hidden_ap_cb;
+       void *scan_hidden_ap_user_data;
+       wifi_connection_state_changed_cb connection_state_cb;
+       void *connection_state_user_data;
+       wifi_activated_cb activated_cb;
+       void *activated_user_data;
+       wifi_deactivated_cb deactivated_cb;
+       void *deactivated_user_data;
+       wifi_connected_cb connected_cb;
+       void *connected_user_data;
+       wifi_disconnected_cb disconnected_cb;
+       void *disconnected_user_data;
+};
+
+static struct _wifi_cb_s wifi_callbacks = {0,};
+
+/*For connection which CAPI send some message to WiNet daemon*/
+static net_wifi_connection_info_t net_wifi_conn_info;
+
+/*For connection which CAPI send some message to WiNet daemon*/
+void _wifi_set_conn_info(net_wifi_connection_info_t *wifi_conn_info)
+{
+       g_strlcpy(net_wifi_conn_info.essid, wifi_conn_info->essid,
+                                       NET_WLAN_ESSID_LEN+1);
+       net_wifi_conn_info.wlan_mode = wifi_conn_info->wlan_mode;
+       memcpy(&net_wifi_conn_info.security_info,
+                                       &wifi_conn_info->security_info,
+                                       sizeof(wlan_security_info_t));
+}
+
+/*For connection which CAPI send some message to WiNet daemon*/
+net_wifi_connection_info_t *_wifi_get_conn_info(void)
+{
+       return &net_wifi_conn_info;
+}
+
+net_state_type_t _wifi_get_service_state_type(const char *state)
+{
+       if (!g_strcmp0(state, "idle"))
+               return NET_STATE_TYPE_IDLE;
+       else if (!g_strcmp0(state, "association"))
+               return NET_STATE_TYPE_ASSOCIATION;
+       else if (!g_strcmp0(state, "configuration"))
+               return NET_STATE_TYPE_CONFIGURATION;
+       else if (!g_strcmp0(state, "ready"))
+               return NET_STATE_TYPE_READY;
+       else if (!g_strcmp0(state, "online"))
+               return NET_STATE_TYPE_ONLINE;
+       else if (!g_strcmp0(state, "disconnect"))
+               return NET_STATE_TYPE_DISCONNECT;
+       else if (!g_strcmp0(state, "failure"))
+               return NET_STATE_TYPE_FAILURE;
+       else
+               return NET_STATE_TYPE_UNKNOWN;
+}
+
+net_ip_config_type_t _wifi_get_ip_config_type(const char *config)
+{
+       net_ip_config_type_t config_type;
+
+       if (!g_strcmp0(config, "manual"))
+               config_type = NET_IP_CONFIG_TYPE_STATIC;
+       else if (!g_strcmp0(config, "dhcp"))
+               config_type = NET_IP_CONFIG_TYPE_AUTO_IP;
+       else if (!g_strcmp0(config, "fixed"))
+               config_type = NET_IP_CONFIG_TYPE_FIXED;
+       else if (!g_strcmp0(config, "off"))
+               config_type = NET_IP_CONFIG_TYPE_OFF;
+       else
+               config_type = NET_IP_CONFIG_TYPE_DYNAMIC;
+
+       return config_type;
+}
+
+char *_wifi_get_ip_config_str(net_ip_config_type_t ip_config_type)
+{
+       switch (ip_config_type) {
+       case NET_IP_CONFIG_TYPE_STATIC:
+               return "manual";
+       case NET_IP_CONFIG_TYPE_DYNAMIC:
+               return "dhcp";
+       case NET_IP_CONFIG_TYPE_AUTO_IP:
+               return "dhcp";
+       case NET_IP_CONFIG_TYPE_FIXED:
+               return "fixed";
+       case NET_IP_CONFIG_TYPE_OFF:
+               return "off";
+       }
+
+       return NULL;
+}
+
+static char *__convert_eap_type_to_string(gchar eap_type)
+{
+       switch (eap_type) {
+       case WLAN_SEC_EAP_TYPE_PEAP:
+               return "peap";
+
+       case WLAN_SEC_EAP_TYPE_TLS:
+               return "tls";
+
+       case WLAN_SEC_EAP_TYPE_TTLS:
+               return "ttls";
+
+       case WLAN_SEC_EAP_TYPE_SIM:
+               return "sim";
+
+       case WLAN_SEC_EAP_TYPE_AKA:
+               return "aka";
+
+       default:
+               return NULL;
+       }
+}
+
+static char *__convert_eap_auth_to_string(gchar eap_auth)
+{
+       switch (eap_auth) {
+       case WLAN_SEC_EAP_AUTH_NONE:
+               return "NONE";
+
+       case WLAN_SEC_EAP_AUTH_PAP:
+               return "PAP";
+
+       case WLAN_SEC_EAP_AUTH_MSCHAP:
+               return "MSCHAP";
+
+       case WLAN_SEC_EAP_AUTH_MSCHAPV2:
+               return "MSCHAPV2";
+
+       case WLAN_SEC_EAP_AUTH_GTC:
+               return "GTC";
+
+       case WLAN_SEC_EAP_AUTH_MD5:
+               return "MD5";
+
+       default:
+               return NULL;
+       }
+}
+
+char* _net_print_error(net_err_t error)
+{
+       switch (error) {
+               /** No error */
+       case NET_ERR_NONE:
+               return "NET_ERR_NONE";
+
+               /* Common Error value */
+
+               /** Error unknown */
+       case NET_ERR_UNKNOWN:
+               return "NET_ERR_UNKNOWN";
+
+               /* Client Register related Errors used in API return */
+
+               /** Application is already registered */
+       case NET_ERR_APP_ALREADY_REGISTERED:
+               return "NET_ERR_APP_ALREADY_REGISTERED";
+               /** Application is not registered */
+       case NET_ERR_APP_NOT_REGISTERED:
+               return "NET_ERR_APP_NOT_REGISTERED";
+
+               /* Connection Related Error */
+
+               /** No active connection exists for the given profile name */
+       case NET_ERR_NO_ACTIVE_CONNECTIONS:
+               return "NET_ERR_NO_ACTIVE_CONNECTIONS";
+               /** Active connection already exists for
+                *  the given profile name
+                */
+       case NET_ERR_ACTIVE_CONNECTION_EXISTS:
+               return "NET_ERR_ACTIVE_CONNECTION_EXISTS";
+
+               /** Connection failure : out of range */
+       case NET_ERR_CONNECTION_OUT_OF_RANGE:
+               return "NET_ERR_CONNECTION_OUT_OF_RANGE";
+               /** Connection failure : pin missing */
+       case NET_ERR_CONNECTION_PIN_MISSING:
+               return "NET_ERR_CONNECTION_PIN_MISSING";
+               /** Connection failure : dhcp failed */
+       case NET_ERR_CONNECTION_DHCP_FAILED:
+               return "NET_ERR_CONNECTION_DHCP_FAILED";
+               /** Connection failure */
+       case NET_ERR_CONNECTION_CONNECT_FAILED:
+               return "NET_ERR_CONNECTION_CONNECT_FAILED";
+               /** Connection failure : login failed */
+       case NET_ERR_CONNECTION_LOGIN_FAILED:
+               return "NET_ERR_CONNECTION_LOGIN_FAILED";
+               /** Connection failure : authentication failed */
+       case NET_ERR_CONNECTION_AUTH_FAILED:
+               return "NET_ERR_CONNECTION_AUTH_FAILED";
+               /** Connection failure : invalid key */
+       case NET_ERR_CONNECTION_INVALID_KEY:
+               return "NET_ERR_CONNECTION_INVALID_KEY";
+
+               /* Other Error */
+
+               /** Access is denied */
+       case NET_ERR_ACCESS_DENIED:
+               return "NET_ERR_ACCESS_DENIED";
+               /** Operation is in progress */
+       case NET_ERR_IN_PROGRESS:
+               return "NET_ERR_IN_PROGRESS";
+               /** Operation was aborted by client or network*/
+       case NET_ERR_OPERATION_ABORTED:
+               return "NET_ERR_OPERATION_ABORTED";
+               /** Invalid value of API parameter */
+       case NET_ERR_INVALID_PARAM:
+               return "NET_ERR_INVALID_PARAM";
+               /** invalid operation depending on current state */
+       case NET_ERR_INVALID_OPERATION:
+               return "NET_ERR_INVALID_OPERATION";
+
+               /** Feature not supported */
+       case NET_ERR_NOT_SUPPORTED:
+               return "NET_ERR_NOT_SUPPORTED";
+               /** TimeOut Error */
+       case NET_ERR_TIME_OUT:
+               return "NET_ERR_TIME_OUT";
+               /** Network service is not available*/
+       case NET_ERR_NO_SERVICE:
+               return "NET_ERR_NO_SERVICE";
+               /** DBus can't find appropriate method */
+       case NET_ERR_UNKNOWN_METHOD:
+               return "NET_ERR_UNKNOWN_METHOD";
+               /** Operation is restricted */
+       case NET_ERR_SECURITY_RESTRICTED:
+               return "NET_ERR_SECURITY_RESTRICTED";
+               /** WiFi driver on/off failed */
+       case NET_ERR_WIFI_DRIVER_FAILURE:
+               return "NET_ERR_WIFI_DRIVER_FAILURE";
+       default:
+               return "INVALID";
+       }
+}
+
+static void __libnet_set_connected_cb(wifi_connected_cb user_cb,
+                                               void *user_data)
+{
+       if (user_cb) {
+               wifi_callbacks.connected_cb = user_cb;
+               wifi_callbacks.connected_user_data = user_data;
+       }
+}
+
+static void __libnet_connected_cb(wifi_error_e result)
+{
+       if (wifi_callbacks.connected_cb)
+               wifi_callbacks.connected_cb(result,
+                               wifi_callbacks.connected_user_data);
+
+       wifi_callbacks.connected_cb = NULL;
+       wifi_callbacks.connected_user_data = NULL;
+}
+
+static void __libnet_set_disconnected_cb(wifi_disconnected_cb user_cb,
+                                                       void *user_data)
+{
+       if (user_cb) {
+               wifi_callbacks.disconnected_cb = user_cb;
+               wifi_callbacks.disconnected_user_data = user_data;
+       }
+}
+
+static void __libnet_disconnected_cb(wifi_error_e result)
+{
+       if (wifi_callbacks.disconnected_cb)
+               wifi_callbacks.disconnected_cb(result,
+                               wifi_callbacks.disconnected_user_data);
+
+       wifi_callbacks.disconnected_cb = NULL;
+       wifi_callbacks.disconnected_user_data = NULL;
+}
+
+wifi_error_e connman_lib2capi_result(enum connman_lib_err_e result)
+{
+       /*
+        * TODO:
+        */
+       wifi_error_e tmp = WIFI_ERROR_NONE;
+       return tmp;
+}
+
+static void connman_service_connect_cb(
+                                       enum connman_lib_err_e result,
+                                       void *user_data)
+{
+       WIFI_LOG(WIFI_INFO, "callback: %d\n", result);
+
+       __libnet_connected_cb(connman_lib2capi_result(result));
+}
+
+static void connman_service_disconnect_cb(
+                                       enum connman_lib_err_e result,
+                                       void *user_data)
+{
+       WIFI_LOG(WIFI_INFO, "callback: %d\n", result);
+
+       __libnet_disconnected_cb(connman_lib2capi_result(result));
+}
+
+static int __net_dbus_set_agent_passphrase(const char *path,
+                                                const char *passphrase)
+{
+       int ret_val;
+       char *service_id;
+
+       if (NULL == passphrase || strlen(passphrase) <= 0) {
+               WIFI_LOG(WIFI_ERROR, "Invalid param \n");
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       service_id = g_strrstr(path, "/") + 1;
+       ret_val = winet_wifi_update_agent_passphrase(service_id, passphrase);
+       if (NET_ERR_NONE != ret_val) {
+               WIFI_LOG(WIFI_ERROR,
+                       "__net_dbus_set_agent_field failed. Error = %d \n",
+                       ret_val);
+               return ret_val;
+       }
+
+       WIFI_LOG(WIFI_ERROR, "Successfully sent passphrase\n");
+
+       return NET_ERR_NONE;
+}
+
+static int __net_dbus_connect_service(wifi_ap_h ap_h,
+               const net_wifi_connect_service_info_t *wifi_connection_info)
+{
+       net_err_t Error = NET_ERR_NONE;
+
+       struct connman_service *service = ap_h;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       if (g_strcmp0(wifi_connection_info->security, "ieee8021x") == 0) {
+               /* Create the EAP config file
+                * TODO:
+                */
+               /*_net_dbus_set_eap_config_fields(wifi_connection_info);*/
+               if (NET_ERR_NONE != Error) {
+                       WIFI_LOG(WIFI_ERROR, "Fail to create eap_config\n");
+
+                       goto done;
+               }
+       } else if (g_strcmp0(wifi_connection_info->security, "none") != 0) {
+               Error = __net_dbus_set_agent_passphrase(
+                               connman_service_get_path(service),
+                               wifi_connection_info->passphrase);
+               if (NET_ERR_NONE != Error) {
+                       WIFI_LOG(WIFI_ERROR, "Fail to set agent_passphrase\n");
+
+                       goto done;
+               }
+       }
+
+       connman_service_connect(service, connman_service_connect_cb, NULL);
+
+done:
+       return Error;
+}
+
+/** This function is used only to open Wi-Fi connection with hidden APs */
+static int __net_open_connection_with_wifi_info(wifi_ap_h ap_h,
+                               const net_wifi_connection_info_t* wifi_info)
+{
+       net_err_t Error = NET_ERR_NONE;
+
+       net_wifi_connect_service_info_t wifi_connection_info;
+       memset(&wifi_connection_info, 0,
+                       sizeof(net_wifi_connect_service_info_t));
+
+       wifi_connection_info.type = g_strdup("wifi");
+
+       if (wifi_info->wlan_mode == NETPM_WLAN_CONNMODE_ADHOC)
+               wifi_connection_info.mode = g_strdup("adhoc");
+       else
+               wifi_connection_info.mode = g_strdup("managed");
+
+       wifi_connection_info.ssid = g_strdup(wifi_info->essid);
+
+       switch (wifi_info->security_info.sec_mode) {
+       case WLAN_SEC_MODE_NONE:
+               wifi_connection_info.security = g_strdup("none");
+               break;
+
+       case WLAN_SEC_MODE_WEP:
+               wifi_connection_info.security = g_strdup("wep");
+               wifi_connection_info.passphrase =
+                               g_strdup(wifi_info->
+                               security_info.authentication.wep.wepKey);
+               break;
+
+       /** WPA-PSK(equivalent to WPA-NONE in case of Ad-Hoc) */
+       case WLAN_SEC_MODE_WPA_PSK:
+               wifi_connection_info.security = g_strdup("psk");
+               wifi_connection_info.passphrase =
+                               g_strdup(wifi_info->
+                               security_info.authentication.psk.pskKey);
+               break;
+
+       /** WPA2-PSK */
+       /** WPA-PSK / WPA2-PSK supported */
+       case WLAN_SEC_MODE_WPA2_PSK:
+               wifi_connection_info.security = g_strdup("rsn");
+               wifi_connection_info.passphrase =
+                               g_strdup(wifi_info->
+                               security_info.authentication.psk.pskKey);
+               break;
+
+       case WLAN_SEC_MODE_IEEE8021X:
+               wifi_connection_info.security = g_strdup("ieee8021x");
+
+               wifi_connection_info.eap_type = g_strdup(
+                               __convert_eap_type_to_string(
+                                               wifi_info->security_info.authentication.eap.eap_type));
+               wifi_connection_info.eap_auth = g_strdup(
+                               __convert_eap_auth_to_string(
+                                               wifi_info->security_info.authentication.eap.eap_auth));
+
+               if (wifi_info->security_info.authentication.eap.username[0] != '\0')
+                       wifi_connection_info.identity =
+                                       g_strdup(wifi_info->security_info.authentication.eap.username);
+
+               if (wifi_info->security_info.authentication.eap.password[0] != '\0')
+                       wifi_connection_info.password =
+                                       g_strdup(wifi_info->security_info.authentication.eap.password);
+
+               if (wifi_info->security_info.authentication.eap.ca_cert_filename[0] != '\0')
+                       wifi_connection_info.ca_cert_file =
+                                       g_strdup(wifi_info->security_info.authentication.eap.ca_cert_filename);
+
+               if (wifi_info->security_info.authentication.eap.client_cert_filename[0] != '\0')
+                       wifi_connection_info.client_cert_file =
+                                       g_strdup(wifi_info->security_info.authentication.eap.client_cert_filename);
+
+               if (wifi_info->security_info.authentication.eap.private_key_filename[0] != '\0')
+                       wifi_connection_info.private_key_file =
+                                       g_strdup(wifi_info->security_info.authentication.eap.private_key_filename);
+
+               if (wifi_info->security_info.authentication.eap.private_key_passwd[0] != '\0')
+                       wifi_connection_info.private_key_password =
+                                       g_strdup(wifi_info->security_info.authentication.eap.private_key_passwd);
+
+               break;
+       default:
+               WIFI_LOG(WIFI_ERROR, "Invalid security type\n");
+
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       Error = __net_dbus_connect_service(ap_h, &wifi_connection_info);
+       if (Error != NET_ERR_NONE)
+               WIFI_LOG(WIFI_ERROR,
+                       "Failed to request connect service. Error [%s]\n",
+                               _net_print_error(Error));
+       else
+               WIFI_LOG(WIFI_ERROR,
+                               "Successfully requested to connect service\n");
+
+       g_free(wifi_connection_info.type);
+       g_free(wifi_connection_info.mode);
+       g_free(wifi_connection_info.ssid);
+       g_free(wifi_connection_info.security);
+       g_free(wifi_connection_info.passphrase);
+       g_free(wifi_connection_info.eap_type);
+       g_free(wifi_connection_info.eap_auth);
+       g_free(wifi_connection_info.identity);
+       g_free(wifi_connection_info.password);
+       g_free(wifi_connection_info.ca_cert_file);
+       g_free(wifi_connection_info.client_cert_file);
+       g_free(wifi_connection_info.private_key_file);
+       g_free(wifi_connection_info.private_key_password);
+
+       return Error;
+}
+
+static int __libnet_connect_with_wifi_info(wifi_ap_h ap_h,
+                               wifi_connected_cb callback, void *user_data)
+{
+       net_wifi_connection_info_t *wifi_info;
+
+       wifi_info = _wifi_get_conn_info();
+
+       if (__net_open_connection_with_wifi_info(ap_h,
+                                               wifi_info) != NET_ERR_NONE)
+               return WIFI_ERROR_OPERATION_FAILED;
+
+       return WIFI_ERROR_NONE;
+}
+
+static void __libnet_set_activated_cb(wifi_activated_cb user_cb,
+                                                       void *user_data)
+{
+       if (user_cb) {
+               wifi_callbacks.activated_cb = user_cb;
+               wifi_callbacks.activated_user_data = user_data;
+       }
+}
+
+static void __libnet_activated_cb(wifi_error_e result)
+{
+       if (wifi_callbacks.activated_cb)
+               wifi_callbacks.activated_cb(result,
+                               wifi_callbacks.activated_user_data);
+
+       wifi_callbacks.activated_cb = NULL;
+       wifi_callbacks.activated_user_data = NULL;
+}
+
+static void __libnet_set_deactivated_cb(wifi_disconnected_cb user_cb,
+                                                       void *user_data)
+{
+       if (user_cb) {
+               wifi_callbacks.deactivated_cb = user_cb;
+               wifi_callbacks.deactivated_user_data = user_data;
+       }
+}
+
+static void __libnet_deactivated_cb(wifi_error_e result)
+{
+       if (wifi_callbacks.deactivated_cb)
+               wifi_callbacks.deactivated_cb(result,
+                               wifi_callbacks.deactivated_user_data);
+
+       wifi_callbacks.deactivated_cb = NULL;
+       wifi_callbacks.deactivated_user_data = NULL;
+}
+
+static void __libnet_set_scan_request_cb(wifi_disconnected_cb user_cb,
+                                                       void *user_data)
+{
+       if (user_cb) {
+               wifi_callbacks.scan_request_cb = user_cb;
+               wifi_callbacks.scan_request_user_data = user_data;
+       }
+}
+
+/*static void __libnet_scan_request_cb(wifi_error_e result)
+{
+       if (wifi_callbacks.scan_request_cb)
+               wifi_callbacks.scan_request_cb(result, wifi_callbacks.scan_request_user_data);
+
+       wifi_callbacks.scan_request_cb = NULL;
+       wifi_callbacks.scan_request_user_data = NULL;
+}*/
+
+wifi_connection_state_e connection_state_string2type(const char *str)
+{
+       if (strcmp(str, "idle") == 0)
+               return WIFI_CONNECTION_STATE_DISCONNECTED;
+       if (strcmp(str, "association") == 0)
+               return WIFI_CONNECTION_STATE_ASSOCIATION;
+       if (strcmp(str, "configuration") == 0)
+               return WIFI_CONNECTION_STATE_CONFIGURATION;
+       if (strcmp(str, "ready") == 0)
+               return WIFI_CONNECTION_STATE_CONNECTED;
+       if (strcmp(str, "online") == 0)
+               return WIFI_CONNECTION_STATE_CONNECTED;
+       if (strcmp(str, "disconnect") == 0)
+               return WIFI_CONNECTION_STATE_DISCONNECTED;
+       if (strcmp(str, "failure") == 0)
+               return WIFI_CONNECTION_STATE_DISCONNECTED;
+
+       return -1;
+}
+
+static void service_state_changed(struct connman_service *service,
+                                                       void *user_data)
+{
+       const char *name = connman_service_get_name(service);
+       const char *new_state = connman_service_get_state(service);
+
+
+       WIFI_LOG(WIFI_INFO, "name %s, state, %s", name, new_state);
+
+       if (wifi_callbacks.connection_state_cb) {
+               GSList *list;
+               net_profile_info_t *info = NULL;
+               net_profile_info_t *profile_info = NULL;
+               wifi_connection_state_e state =
+                               connection_state_string2type(new_state);
+
+               for (list = ap_handle_list; list; list = list->next) {
+
+                       if (list == NULL)
+                               break;
+
+                       info = (net_profile_info_t *)list->data;
+                       if (strcmp(info->essid, name) == 0) {
+                               profile_info = info;
+                               break;
+                       }
+               }
+
+               wifi_callbacks.connection_state_cb(state,
+                               (wifi_ap_h)profile_info,
+                               wifi_callbacks.connection_state_user_data);
+       }
+}
+
+static void service_strength_changed(struct connman_service *service,
+                                                       void *user_data)
+{
+       const char *name = connman_service_get_name(service);
+       int strength = connman_service_get_strength(service);
+
+       WIFI_LOG(WIFI_INFO, "name %s, strength, %d", name, strength);
+}
+
+static void register_service_monitor(gpointer data, gpointer user_data)
+{
+       struct connman_service *service = data;
+
+       const char *path = connman_service_get_path(service);
+       const char *type = connman_service_get_type(service);
+
+       WIFI_LOG(WIFI_INFO, "path %s, type %s", path, type);
+
+       if (strcmp(type, "wifi") != 0)
+               return;
+
+       connman_service_set_property_changed_cb(service, SERVICE_PROP_STATE,
+                                       service_state_changed, user_data);
+
+       connman_service_set_property_changed_cb(service, SERVICE_PROP_STRENGTH,
+                                       service_strength_changed, user_data);
+}
+
+static void service_changed_callback(struct connman_manager *manager,
+                                                       void *user_data)
+{
+       GList *services;
+
+       WIFI_LOG(WIFI_INFO, "service changed");
+
+       services = connman_get_services();
+
+       g_list_foreach(services, register_service_monitor, NULL);
+}
+
+static void technology_powered_changed(struct connman_technology *technology,
+                                                       void *user_data)
+{
+       gboolean powered = connman_get_technology_powered(technology);
+       enum connman_technology_type type =
+                               connman_get_technology_type(technology);
+
+       WIFI_LOG(WIFI_INFO, "technology %d powered %d", type, powered);
+
+       if (wifi_callbacks.device_state_cb) {
+               wifi_device_state_e state;
+
+               state = powered ? WIFI_DEVICE_STATE_ACTIVATED :
+                                               WIFI_DEVICE_STATE_DEACTIVATED;
+               wifi_callbacks.device_state_cb(state,
+                                       wifi_callbacks.device_state_user_data);
+       }
+}
+
+static void technology_added_callback(struct connman_technology *technology,
+                                                       void *user_data)
+{
+       enum connman_technology_type type =
+                               connman_get_technology_type(technology);
+
+       WIFI_LOG(WIFI_INFO, "technology %d added", type);
+
+       if (type == TECH_TYPE_WIFI)
+               connman_technology_set_property_changed_cb(technology,
+                                               TECH_PROP_POWERED,
+                                               technology_powered_changed,
+                                               user_data);
+}
+
+bool _wifi_libnet_init(void)
+{
+       struct connman_technology *technology;
+       int rv = NET_ERR_NONE;
+
+       connman_lib_init();
+
+       if (rv != NET_ERR_NONE)
+               return false;
+
+       connman_set_services_changed_cb(service_changed_callback, NULL);
+
+       connman_set_technology_added_cb(technology_added_callback, NULL);
+
+       technology = connman_get_technology(TECH_TYPE_WIFI);
+       if (technology)
+               connman_technology_set_property_changed_cb(technology,
+                                               TECH_PROP_POWERED,
+                                               technology_powered_changed,
+                                               NULL);
+
+       return true;
+}
+
+bool _wifi_libnet_deinit(void)
+{
+       g_slist_free_full(ap_handle_list, g_free);
+       ap_handle_list = NULL;
+       memset(&wifi_callbacks, 0, sizeof(struct _wifi_cb_s));
+       connman_lib_deinit();
+       return true;
+}
+
+static void __connman_technology_powered_on_cb(
+                                       enum connman_lib_err_e result,
+                                       void *user_data)
+{
+       WIFI_LOG(WIFI_INFO, "callback: %d\n", result);
+
+       __libnet_activated_cb(connman_lib2capi_result(result));
+}
+
+static void __connman_technology_powered_off_cb(
+                                       enum connman_lib_err_e result,
+                                       void *user_data)
+{
+       WIFI_LOG(WIFI_INFO, "callback: %d\n", result);
+
+       __libnet_deactivated_cb(connman_lib2capi_result(result));
+}
+
+int _wifi_activate(wifi_activated_cb callback, void *user_data)
+{
+       if (winet_wifi_set_work_mode(WIFI_WORK_MODE_STATION) < 0)
+               return WIFI_ERROR_OPERATION_FAILED;
+
+       struct connman_technology *technology =
+                                       connman_get_technology(TECH_TYPE_WIFI);
+       if (!technology)
+               return WIFI_ERROR_OPERATION_FAILED;
+
+       __libnet_set_activated_cb(callback, user_data);
+
+       connman_enable_technology(technology,
+                                       __connman_technology_powered_on_cb,
+                                       NULL);
+
+       return WIFI_ERROR_NONE;
+}
+
+int _wifi_deactivate(wifi_deactivated_cb callback, void *user_data)
+{
+       struct connman_technology *technology =
+                                       connman_get_technology(TECH_TYPE_WIFI);
+       if (!technology)
+               return WIFI_ERROR_OPERATION_FAILED;
+
+       __libnet_set_deactivated_cb(callback, user_data);
+
+       connman_disable_technology(technology,
+                                       __connman_technology_powered_off_cb,
+                                       NULL);
+
+       if (winet_wifi_set_work_mode(WIFI_WORK_MODE_OFF) < 0)
+               return WIFI_ERROR_OPERATION_FAILED;
+
+       return WIFI_ERROR_NONE;
+}
+
+bool _wifi_libnet_check_ap_validity(wifi_ap_h ap_h)
+{
+       struct connman_service *service = ap_h;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       const char *name = connman_service_get_name(service);
+
+       if (!name)
+               return false;
+
+       return true;
+}
+
+void _wifi_libnet_add_to_ap_list(wifi_ap_h ap_h)
+{
+       ap_handle_list = g_slist_append(ap_handle_list, ap_h);
+}
+
+void _wifi_libnet_remove_from_ap_list(wifi_ap_h ap_h)
+{
+       net_profile_info_t *ap_info = ap_h;
+       ap_handle_list = g_slist_remove(ap_handle_list, ap_info);
+       g_free(ap_info->essid);
+       g_free(ap_h);
+}
+
+bool _wifi_libnet_check_profile_name_validity(const char *profile_name)
+{
+       const char *profile_prefix = "/net/connman/service/wifi_";
+       int i = 0;
+
+       if (profile_name == NULL ||
+                       g_str_has_prefix(profile_name, profile_prefix) != TRUE) {
+               WIFI_LOG(WIFI_ERROR, "Error!!! Profile name is invalid\n");
+               return false;
+       }
+
+       while (profile_name[i] != '\0') {
+               if (isgraph(profile_name[i]) == 0) {
+                       WIFI_LOG(WIFI_ERROR, "Error!!! Profile name is invalid\n");
+                       return false;
+               }
+               i++;
+       }
+
+       return true;
+}
+
+bool _wifi_libnet_get_wifi_device_state(wifi_device_state_e *device_state)
+{
+       struct connman_technology *technology;
+       bool powered = false;
+
+       technology = connman_get_technology(TECH_TYPE_WIFI);
+
+       if (technology)
+               powered = connman_get_technology_powered(technology);
+
+       if (powered)
+               *device_state = WIFI_DEVICE_STATE_ACTIVATED;
+       else
+               *device_state = WIFI_DEVICE_STATE_DEACTIVATED;
+
+       WIFI_LOG(WIFI_ERROR, "Wi-Fi device state: %d", *device_state);
+
+       return true;
+}
+
+bool _wifi_libnet_get_wifi_state(wifi_connection_state_e* connection_state)
+{
+       struct connman_technology *technology;
+       gboolean wifi_powered;
+       GList *services;
+       GList *list;
+
+       technology = connman_get_technology(TECH_TYPE_WIFI);
+       wifi_powered = connman_get_technology_powered(technology);
+
+       if (!wifi_powered) {
+               *connection_state = WIFI_CONNECTION_STATE_DISCONNECTED;
+               return true;
+       }
+
+       services = connman_get_services();
+       if (services == NULL) {
+               *connection_state = WIFI_CONNECTION_STATE_DISCONNECTED;
+               return true;
+       }
+
+       list = services;
+
+       WIFI_LOG(WIFI_INFO, "list: %p", list);
+       WIFI_LOG(WIFI_INFO, "services: %p", services);
+
+       while (list != NULL) {
+               wifi_connection_state_e state;
+               struct connman_service *service;
+               const char *str;
+               const char *type;
+
+               service = list->data;
+               str = connman_service_get_state(service);
+               state = connection_state_string2type(str);
+               type = connman_service_get_type(service);
+
+               WIFI_LOG(WIFI_INFO, "type: %s, state %s", type, str);
+
+               if (state > WIFI_CONNECTION_STATE_DISCONNECTED &&
+                       strcmp(type, "wifi") == 0) {
+                       *connection_state = state;
+                       return true;
+               }
+
+               list = g_list_next(list);
+               WIFI_LOG(WIFI_INFO, "list: %p, services %p", list, services);
+       }
+
+       *connection_state = WIFI_CONNECTION_STATE_DISCONNECTED;
+       return true;
+}
+
+int _wifi_libnet_get_intf_name(char** name)
+{
+       return WIFI_ERROR_NONE;
+}
+
+int _wifi_libnet_scan_request(wifi_scan_finished_cb callback, void *user_data)
+{
+       int rv = NET_ERR_NONE;
+       struct connman_technology *technology =
+                               connman_get_technology(TECH_TYPE_WIFI);
+
+       __libnet_set_scan_request_cb(callback, user_data);
+
+       rv = connman_scan_technology(technology);
+
+       if (rv == NET_ERR_NONE) {
+               return WIFI_ERROR_NONE;
+       } else if (rv == NET_ERR_INVALID_OPERATION)
+               return WIFI_ERROR_INVALID_OPERATION;
+
+       return WIFI_ERROR_OPERATION_FAILED;
+}
+
+int _wifi_libnet_scan_hidden_ap(const char *essid,
+                                       wifi_scan_finished_cb callback, void *user_data)
+{
+       int rv = NET_ERR_NONE;
+
+       if (rv == NET_ERR_NONE) {
+               wifi_callbacks.scan_hidden_ap_cb = callback;
+               wifi_callbacks.scan_hidden_ap_user_data = user_data;
+               return WIFI_ERROR_NONE;
+       } else if (rv == NET_ERR_INVALID_OPERATION)
+               return WIFI_ERROR_INVALID_OPERATION;
+
+       return WIFI_ERROR_OPERATION_FAILED;
+}
+
+int _wifi_libnet_get_connected_profile(wifi_ap_h *ap)
+{
+       wifi_ap_h ap_h = NULL;
+       GList *iter;
+       GList *connman_services_list = NULL;
+       const char *state;
+       net_state_type_t state_type;
+       /*
+        * update service TODO
+        */
+
+       /*
+        * Filter the service
+        */
+       connman_services_list = connman_get_services();
+
+       for (iter = connman_services_list; iter != NULL; iter = iter->next) {
+               struct connman_service *service =
+                   (struct connman_service *)(iter->data);
+
+               state = connman_service_get_state(service);
+               state_type = _wifi_get_service_state_type(state);
+               if (( state_type == NET_STATE_TYPE_ONLINE) ||
+                                       (state_type == NET_STATE_TYPE_READY))
+                       ap_h = (wifi_ap_h)service;
+       }
+
+       if (!ap_h) {
+               WIFI_LOG(WIFI_ERROR, "Error!! There is no connected AP.\n");
+               return WIFI_ERROR_NO_CONNECTION;
+       }
+
+       *ap = g_try_malloc0(sizeof(net_profile_info_t));
+       if (*ap == NULL)
+               return WIFI_ERROR_OUT_OF_MEMORY;
+
+       ((net_profile_info_t *) (*ap))->essid =
+                               g_strdup(connman_service_get_name(ap_h));
+
+       _wifi_libnet_add_to_ap_list(*ap);
+
+       return WIFI_ERROR_NONE;
+}
+
+bool _wifi_libnet_foreach_found_aps(wifi_found_ap_cb callback, void *user_data)
+{
+       bool rv = true;
+       GList *iter;
+       GList *connman_services_list = NULL;
+
+       /*
+        * update all services TODO
+        */
+
+       connman_services_list = connman_get_services();
+
+       if (g_list_length(connman_services_list) == 0) {
+               WIFI_LOG(WIFI_INFO, "There is no APs.\n");
+               return true;
+       }
+
+       for (iter = connman_services_list; iter != NULL; iter = iter->next) {
+               rv = callback((wifi_ap_h)(iter->data), user_data);
+               if (rv == false) break;
+       }
+
+       return true;
+}
+
+bool _wifi_libnet_foreach_found_hidden_aps(wifi_found_ap_cb callback,
+                                               void *user_data)
+{
+       return true;
+}
+
+int _wifi_libnet_open_profile(wifi_ap_h ap_h, wifi_connected_cb callback,
+                                                       void *user_data)
+{
+       int rv = NET_ERR_NONE;
+       struct connman_service* service = ap_h;
+
+       __libnet_set_connected_cb(callback, user_data);
+
+       if (connman_service_get_favorite(service))
+               connman_service_connect(service,
+                               connman_service_connect_cb, NULL);
+       else
+               rv = __libnet_connect_with_wifi_info(ap_h, callback, user_data);
+
+       if (rv != NET_ERR_NONE)
+               return WIFI_ERROR_OPERATION_FAILED;
+
+       return WIFI_ERROR_NONE;
+
+}
+
+int _wifi_libnet_close_profile(wifi_ap_h ap_h,
+                       wifi_disconnected_cb callback, void *user_data)
+{
+       struct connman_service *service = ap_h;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       __libnet_set_disconnected_cb(callback, user_data);
+       connman_service_disconnect(service,
+                               connman_service_disconnect_cb, NULL);
+
+       return WIFI_ERROR_NONE;
+}
+
+int _wifi_libnet_connect_with_wps(wifi_ap_h ap_h,
+                               wifi_connected_cb callback, void *user_data)
+{
+       int rv = NET_ERR_NONE;
+       struct connman_service *service = ap_h;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       __libnet_set_connected_cb(callback, user_data);
+
+       if (connman_service_get_favorite(service))
+               connman_service_connect(service,
+                               connman_service_connect_cb, NULL);
+       else
+               rv = __libnet_connect_with_wifi_info(ap_h, callback, user_data);
+
+       if (rv != NET_ERR_NONE)
+               return WIFI_ERROR_OPERATION_FAILED;
+
+       return WIFI_ERROR_NONE;
+}
+
+int _wifi_libnet_forget_ap(wifi_ap_h ap)
+{
+
+       int rv = NET_ERR_NONE;
+       struct connman_service *service = ap;
+       if (!service)
+               return NET_ERR_INVALID_PARAM;
+
+       connman_service_remove(service);
+
+       if (rv != NET_ERR_NONE)
+               return WIFI_ERROR_OPERATION_FAILED;
+
+       return WIFI_ERROR_NONE;
+}
+
+int _wifi_set_power_on_off_cb(wifi_device_state_changed_cb callback,
+                                                       void *user_data)
+{
+       if (wifi_callbacks.device_state_cb)
+               return WIFI_ERROR_INVALID_OPERATION;
+
+       wifi_callbacks.device_state_cb = callback;
+       wifi_callbacks.device_state_user_data = user_data;
+
+       return WIFI_ERROR_NONE;
+}
+
+int _wifi_unset_power_on_off_cb(void)
+{
+       if (wifi_callbacks.device_state_cb == NULL)
+               return WIFI_ERROR_INVALID_OPERATION;
+
+       wifi_callbacks.device_state_cb = NULL;
+       wifi_callbacks.device_state_user_data = NULL;
+
+       return WIFI_ERROR_NONE;
+}
+
+int _wifi_set_background_scan_cb(wifi_scan_finished_cb callback,
+                                                       void *user_data)
+{
+       if (wifi_callbacks.bg_scan_cb)
+               return WIFI_ERROR_INVALID_OPERATION;
+
+       wifi_callbacks.bg_scan_cb = callback;
+       wifi_callbacks.bg_scan_user_data = user_data;
+
+       return WIFI_ERROR_NONE;
+}
+
+int _wifi_unset_background_scan_cb(void)
+{
+       if (wifi_callbacks.bg_scan_cb == NULL)
+               return WIFI_ERROR_INVALID_OPERATION;
+
+       wifi_callbacks.bg_scan_cb = NULL;
+       wifi_callbacks.bg_scan_user_data = NULL;
+
+       return WIFI_ERROR_NONE;
+}
+
+int _wifi_set_connection_state_cb(
+               wifi_connection_state_changed_cb callback, void *user_data)
+{
+       if (wifi_callbacks.connection_state_cb)
+               return WIFI_ERROR_INVALID_OPERATION;
+
+       wifi_callbacks.connection_state_cb = callback;
+       wifi_callbacks.connection_state_user_data = user_data;
+
+       return WIFI_ERROR_NONE;
+}
+
+int _wifi_unset_connection_state_cb()
+{
+       if (wifi_callbacks.connection_state_cb == NULL)
+               return WIFI_ERROR_INVALID_OPERATION;
+
+       wifi_callbacks.connection_state_cb = NULL;
+       wifi_callbacks.connection_state_user_data = NULL;
+
+       return WIFI_ERROR_NONE;
+}
diff --git a/src/wifi.c b/src/wifi.c
new file mode 100755 (executable)
index 0000000..1183244
--- /dev/null
@@ -0,0 +1,427 @@
+/*
+* Network Wi-Fi library
+*
+* Copyright (c) 2014-2015 Intel Corporation. All rights reserved.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*              http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <vconf/vconf.h>
+
+#include "wifi-internal.h"
+
+static bool is_init = false;
+static wifi_rssi_level_changed_cb rssi_level_changed_cb = NULL;
+static void *rssi_level_changed_user_data = NULL;
+
+static void __rssi_level_changed_cb(keynode_t *node, void *user_data)
+{
+       int rssi_level = vconf_keynode_get_int(node);
+       rssi_level_changed_cb(rssi_level, rssi_level_changed_user_data);
+}
+
+EXPORT_API int wifi_initialize(void)
+{
+       if (is_init) {
+               WIFI_LOG(WIFI_ERROR, "Already initialized\n");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       if (_wifi_libnet_init() == false) {
+               WIFI_LOG(WIFI_ERROR, "Init failed!\n");
+               return WIFI_ERROR_OPERATION_FAILED;
+       }
+
+       is_init = true;
+
+       WIFI_LOG(WIFI_INFO, "Wi-Fi successfully initialized!\n");
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_deinitialize(void)
+{
+       if (is_init == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       if (_wifi_libnet_deinit() == false) {
+               WIFI_LOG(WIFI_ERROR, "Deinit failed!\n");
+               return WIFI_ERROR_OPERATION_FAILED;
+       }
+
+       is_init = false;
+       wifi_unset_rssi_level_changed_cb();
+
+       WIFI_LOG(WIFI_INFO, "Wi-Fi successfully de-initialized!\n");
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_activate(wifi_activated_cb callback, void* user_data)
+{
+       int rv;
+
+       if (is_init == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       rv = _wifi_activate(callback, user_data);
+
+       /*rv = connman_technology_set_powered_on_wifi(callback, user_data);*/
+       if (rv != WIFI_ERROR_NONE)
+               WIFI_LOG(WIFI_ERROR, "Error!! Wi-Fi Activation failed.\n");
+
+       return rv;
+}
+
+EXPORT_API int wifi_deactivate(wifi_deactivated_cb callback, void* user_data)
+{
+       int rv;
+
+       if (is_init == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       rv = _wifi_deactivate(callback, user_data);
+
+       /*rv = connman_technology_set_powered_off_wifi(callback, user_data);*/
+       if (rv != WIFI_ERROR_NONE)
+               WIFI_LOG(WIFI_ERROR, "Error!! Wi-Fi Deactivation failed.\n");
+
+       return rv;
+}
+
+EXPORT_API int wifi_is_activated(bool* activated)
+{
+       wifi_device_state_e device_state;
+
+       if (activated == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (_wifi_libnet_get_wifi_device_state(&device_state) == false) {
+               return WIFI_ERROR_OPERATION_FAILED;
+       } else {
+               WIFI_LOG(WIFI_INFO, "WiFi = %d\n", device_state);
+               if (WIFI_DEVICE_STATE_DEACTIVATED == device_state)
+                       *activated = false;
+               else
+                       *activated = true;
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_get_connection_state(
+                               wifi_connection_state_e* connection_state)
+{
+       if (connection_state == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (_wifi_libnet_get_wifi_state(connection_state) == false)
+               return WIFI_ERROR_OPERATION_FAILED;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_get_mac_address(char** mac_address)
+{
+       if (mac_address == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       *mac_address = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
+
+       if (*mac_address == NULL) {
+               WIFI_LOG(WIFI_ERROR, "vconf_get_str Failed\n");
+               return WIFI_ERROR_OPERATION_FAILED;
+       }
+
+       WIFI_LOG(WIFI_INFO, "MAC Address %s\n", *mac_address);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_get_network_interface_name(char** name)
+{
+       if (name == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return _wifi_libnet_get_intf_name(name);
+}
+
+EXPORT_API int wifi_scan(wifi_scan_finished_cb callback, void* user_data)
+{
+       int rv;
+
+       if (callback == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (is_init == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       rv = _wifi_libnet_scan_request(callback, user_data);
+       if (rv != WIFI_ERROR_NONE)
+               WIFI_LOG(WIFI_ERROR, "Error!! Wi-Fi scan failed.\n");
+
+       return rv;
+}
+
+EXPORT_API int wifi_scan_hidden_ap(const char* essid,
+                                       wifi_scan_finished_cb callback,
+                                       void* user_data)
+{
+       int rv;
+
+       if (callback == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (is_init == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       rv = _wifi_libnet_scan_hidden_ap(essid, callback, user_data);
+       if (rv != WIFI_ERROR_NONE)
+               WIFI_LOG(WIFI_ERROR, "Error!! Wi-Fi hidden scan failed.\n");
+
+       return rv;
+}
+
+EXPORT_API int wifi_get_connected_ap(wifi_ap_h* ap)
+{
+       int rv;
+
+       if (ap == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       rv = _wifi_libnet_get_connected_profile(ap);
+       WIFI_LOG(WIFI_INFO, "Connected AP %p, rv %d\n", *ap, rv);
+
+       return rv;
+}
+
+EXPORT_API int wifi_foreach_found_aps(wifi_found_ap_cb callback,
+                                        void* user_data)
+{
+       if (callback == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (_wifi_libnet_foreach_found_aps(callback, user_data) == false)
+               return WIFI_ERROR_OPERATION_FAILED;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_foreach_found_hidden_aps(wifi_found_ap_cb callback,
+                                                void* user_data)
+{
+       if (callback == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (_wifi_libnet_foreach_found_hidden_aps(callback, user_data) == false)
+               return WIFI_ERROR_OPERATION_FAILED;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_connect(wifi_ap_h ap, wifi_connected_cb callback,
+                                                       void* user_data)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (is_init == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       return _wifi_libnet_open_profile(ap, callback, user_data);
+}
+
+EXPORT_API int wifi_disconnect(wifi_ap_h ap, wifi_disconnected_cb callback,
+                                                       void* user_data)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (is_init == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       return _wifi_libnet_close_profile(ap, callback, user_data);
+}
+
+EXPORT_API int wifi_connect_by_wps_pbc(wifi_ap_h ap,
+                                         wifi_connected_cb callback,
+                                         void* user_data)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (is_init == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       return _wifi_libnet_connect_with_wps(ap, callback, user_data);
+}
+
+EXPORT_API int wifi_forget_ap(wifi_ap_h ap)
+{
+       if (_wifi_libnet_check_ap_validity(ap) == false) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (is_init == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       return _wifi_libnet_forget_ap(ap);
+}
+
+EXPORT_API int wifi_set_device_state_changed_cb(
+                                       wifi_device_state_changed_cb callback,
+                                       void* user_data)
+{
+       if (callback == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (is_init == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       return _wifi_set_power_on_off_cb(callback, user_data);
+}
+
+EXPORT_API int wifi_unset_device_state_changed_cb(void)
+{
+       return _wifi_unset_power_on_off_cb();
+}
+
+EXPORT_API int wifi_set_background_scan_cb(
+                                       wifi_scan_finished_cb callback,
+                                       void* user_data)
+{
+       if (callback == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (is_init == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       return _wifi_set_background_scan_cb(callback, user_data);
+}
+
+EXPORT_API int wifi_unset_background_scan_cb(void)
+{
+       return _wifi_unset_background_scan_cb();
+}
+
+EXPORT_API int wifi_set_connection_state_changed_cb(
+                               wifi_connection_state_changed_cb callback,
+                               void* user_data)
+{
+       if (callback == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (is_init == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       return _wifi_set_connection_state_cb(callback, user_data);
+}
+
+EXPORT_API int wifi_unset_connection_state_changed_cb(void)
+{
+       return _wifi_unset_connection_state_cb();
+}
+
+EXPORT_API int wifi_set_rssi_level_changed_cb(
+                               wifi_rssi_level_changed_cb callback,
+                               void* user_data)
+{
+       if (callback == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (rssi_level_changed_cb == NULL)
+               vconf_notify_key_changed(VCONFKEY_WIFI_STRENGTH,
+                                       __rssi_level_changed_cb, NULL);
+       else
+               return WIFI_ERROR_INVALID_OPERATION;
+
+       rssi_level_changed_cb = callback;
+       rssi_level_changed_user_data = user_data;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_unset_rssi_level_changed_cb(void)
+{
+       if (rssi_level_changed_cb != NULL)
+               vconf_ignore_key_changed(VCONFKEY_WIFI_STRENGTH,
+                                               __rssi_level_changed_cb);
+       else
+               return WIFI_ERROR_INVALID_OPERATION;
+
+       rssi_level_changed_cb = NULL;
+       rssi_level_changed_user_data = NULL;
+
+       return WIFI_ERROR_NONE;
+}
index c7640f9b5034c0c35ce1b424d8b8266a73ddce0f..87b737fd4d9d32c870cda88d578cbde1a24449c2 100644 (file)
@@ -673,7 +673,7 @@ static bool __test_found_print_ap_info_callback(wifi_ap_h ap, void *user_data)
                else
                        printf("Fail to get Connection State\n");
 
-               if (wifi_ap_get_ip_config_type(ap, WIFI_ADDRESS_FAMILY_IPV4, &ip_type) == WIFI_ERROR_NONE)
+               if (wifi_ap_wifi_get_ip_config_type(ap, WIFI_ADDRESS_FAMILY_IPV4, &ip_type) == WIFI_ERROR_NONE)
                        printf("IP config type : %d\n", ip_type);
                else
                        printf("Fail to get IP config type\n");
@@ -1286,7 +1286,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                rv = test_is_activated();
                break;
        case '6':
-               rv = test_get_connection_state();  /*TODO*/
+               rv = test_get_connection_state();
                break;
        case '7':
                rv = test_get_mac_address(); /*TODO*/