diff options
author | Seonah Moon <seonah1.moon@samsung.com> | 2015-02-03 17:41:38 +0900 |
---|---|---|
committer | Seonah Moon <seonah1.moon@samsung.com> | 2015-02-03 17:42:19 +0900 |
commit | e4f3757407a3f24d8b1d182c43b880e867788fd7 (patch) | |
tree | c2f6174dc237d40b592012f4dc0c647993444db7 | |
parent | 5098a5395928164e07f4b59aeabc012a5a381831 (diff) | |
download | wifi-tizen_3.0.2014.q4_common.tar.gz wifi-tizen_3.0.2014.q4_common.tar.bz2 wifi-tizen_3.0.2014.q4_common.zip |
Merge 2.3 codesubmit/tizen/20150204.041505accepted/tizen/wearable/20150205.062017accepted/tizen/tv/20150205.022524accepted/tizen/mobile/20150205.041939accepted/tizen/common/20150204.152745tizen_3.0.2015.q1_commontizen_3.0.2014.q4_common
Change-Id: Idd07c63ee7545a7852edc7d37386fa7c6e97bb72
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
-rw-r--r-- | include/net_wifi_private.h | 23 | ||||
-rw-r--r-- | include/wifi.h | 1919 | ||||
-rw-r--r-- | packaging/capi-network-wifi.spec | 2 | ||||
-rwxr-xr-x | src/libnetwork.c | 376 | ||||
-rwxr-xr-x | src/net_wifi.c | 186 | ||||
-rwxr-xr-x | src/net_wifi_ap.c | 243 | ||||
-rw-r--r-- | test/wifi_test.c | 6 |
7 files changed, 1709 insertions, 1046 deletions
diff --git a/include/net_wifi_private.h b/include/net_wifi_private.h index 3027178..de59fd2 100644 --- a/include/net_wifi_private.h +++ b/include/net_wifi_private.h @@ -48,10 +48,11 @@ extern "C" { #endif /* __cplusplus */ +bool _wifi_is_init(void); -bool _wifi_libnet_init(void); +int _wifi_libnet_init(void); bool _wifi_libnet_deinit(void); -int _wifi_activate(wifi_activated_cb callback, void *user_data); +int _wifi_activate(wifi_activated_cb callback, gboolean wifi_picker_test, void *user_data); int _wifi_deactivate(wifi_deactivated_cb callback, void *user_data); bool _wifi_libnet_check_ap_validity(wifi_ap_h ap_h); @@ -59,19 +60,21 @@ 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_wifi_device_state(wifi_device_state_e *device_state); +int _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_foreach_found_aps(wifi_found_ap_cb callback, void *user_data); +int _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_connect_with_wps_pbc(wifi_ap_h ap, + wifi_connected_cb callback, void *user_data); +int _wifi_libnet_connect_with_wps_pin(wifi_ap_h ap, const char *pin, + 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); @@ -83,6 +86,10 @@ 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); + +guint _wifi_callback_add(GSourceFunc func, gpointer user_data); +void _wifi_callback_cleanup(void); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/include/wifi.h b/include/wifi.h index fcf3add..2932e63 100644 --- a/include/wifi.h +++ b/include/wifi.h @@ -24,29 +24,36 @@ extern "C" { #endif /** + * @file wifi.h + */ + +/** * @addtogroup CAPI_NETWORK_WIFI_MANAGER_MODULE * @{ */ /** -* @brief The Wi-Fi error type -*/ + * @brief Enumeration for the Wi-Fi error type. + * @since_tizen 2.3 + */ typedef enum { - WIFI_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - WIFI_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - WIFI_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory error */ - WIFI_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */ + WIFI_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + WIFI_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + WIFI_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory error */ + WIFI_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */ WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED = TIZEN_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED, /**< Address family not supported */ - WIFI_ERROR_OPERATION_FAILED = TIZEN_ERROR_NETWORK_CLASS|0x0301, /**< Operation failed */ - WIFI_ERROR_NO_CONNECTION = TIZEN_ERROR_NETWORK_CLASS|0x0302, /**< There is no connected AP */ - WIFI_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /** Now in progress */ - WIFI_ERROR_ALREADY_EXISTS = TIZEN_ERROR_NETWORK_CLASS|0x0303, /**< Already exists */ - WIFI_ERROR_OPERATION_ABORTED = TIZEN_ERROR_NETWORK_CLASS|0x0304, /**< Operation is aborted */ - WIFI_ERROR_DHCP_FAILED = TIZEN_ERROR_NETWORK_CLASS|0x0306, /**< DHCP failed */ - WIFI_ERROR_INVALID_KEY = TIZEN_ERROR_NETWORK_CLASS|0x0307, /**< Invalid key */ - WIFI_ERROR_NO_REPLY = TIZEN_ERROR_NETWORK_CLASS|0x0308, /**< No reply */ - WIFI_ERROR_SECURITY_RESTRICTED = TIZEN_ERROR_NETWORK_CLASS|0x0309, /**< Restricted by security system policy */ + WIFI_ERROR_OPERATION_FAILED = TIZEN_ERROR_WIFI|0x0301, /**< Operation failed */ + WIFI_ERROR_NO_CONNECTION = TIZEN_ERROR_WIFI|0x0302, /**< There is no connected AP */ + WIFI_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /**< Now in progress */ + WIFI_ERROR_ALREADY_EXISTS = TIZEN_ERROR_WIFI|0x0303, /**< Already exists */ + WIFI_ERROR_OPERATION_ABORTED = TIZEN_ERROR_WIFI|0x0304, /**< Operation is aborted */ + WIFI_ERROR_DHCP_FAILED = TIZEN_ERROR_WIFI|0x0306, /**< DHCP failed */ + WIFI_ERROR_INVALID_KEY = TIZEN_ERROR_WIFI|0x0307, /**< Invalid key */ + WIFI_ERROR_NO_REPLY = TIZEN_ERROR_WIFI|0x0308, /**< No reply */ + WIFI_ERROR_SECURITY_RESTRICTED = TIZEN_ERROR_WIFI|0x0309, /**< Restricted by security system policy */ + WIFI_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission Denied */ + WIFI_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED /**< Not Supported */ } wifi_error_e; /** @@ -60,28 +67,32 @@ typedef enum */ /** -* @brief The state of Wi-Fi device -*/ + * @brief Enumeration for the state of the Wi-Fi device. + * @since_tizen 2.3 + */ typedef enum { WIFI_DEVICE_STATE_DEACTIVATED = 0, /**< Wi-Fi is Deactivated */ - WIFI_DEVICE_STATE_ACTIVATED = 1, /**< Wi-Fi is activated */ + WIFI_DEVICE_STATE_ACTIVATED = 1, /**< Wi-Fi is activated */ } wifi_device_state_e; /** -* @brief The state of Wi-Fi connection -*/ + * @brief Enumeration for the state of the Wi-Fi connection. + * @since_tizen 2.3 + */ typedef enum { - WIFI_CONNECTION_STATE_DISCONNECTED = 0, /**< Disconnected state */ - WIFI_CONNECTION_STATE_ASSOCIATION = 1, /**< Association state */ - WIFI_CONNECTION_STATE_CONFIGURATION = 2, /**< Configuration state */ - WIFI_CONNECTION_STATE_CONNECTED = 3, /**< Connected state */ + WIFI_CONNECTION_STATE_FAILURE = -1, /**< Connection failed state */ + WIFI_CONNECTION_STATE_DISCONNECTED = 0, /**< Disconnected state */ + WIFI_CONNECTION_STATE_ASSOCIATION = 1, /**< Association state */ + WIFI_CONNECTION_STATE_CONFIGURATION = 2, /**< Configuration state */ + WIFI_CONNECTION_STATE_CONNECTED = 3, /**< Connected state */ } wifi_connection_state_e; /** -* @brief The RSSI level -*/ + * @brief Enumeration for the RSSI level. + * @since_tizen 2.3 + */ typedef enum { WIFI_RSSI_LEVEL_0 = 0, /**< level 0 */ @@ -102,20 +113,22 @@ typedef enum */ /** -* @brief Net IP configuration Type -*/ + * @brief Enumeration for the Net IP configuration type. + * @since_tizen 2.3 + */ typedef enum { - WIFI_IP_CONFIG_TYPE_NONE = 0, /**< Not defined */ - WIFI_IP_CONFIG_TYPE_STATIC = 1, /**< Manual IP configuration */ - WIFI_IP_CONFIG_TYPE_DYNAMIC = 2, /**< Config IP using DHCP client*/ - WIFI_IP_CONFIG_TYPE_AUTO = 3, /**< Config IP from Auto IP pool (169.254/16). Later with DHCP client, if available */ - WIFI_IP_CONFIG_TYPE_FIXED = 4, /**< Indicates an IP address that can not be modified */ + WIFI_IP_CONFIG_TYPE_NONE = 0, /**< Not defined */ + WIFI_IP_CONFIG_TYPE_STATIC = 1, /**< Manual IP configuration */ + WIFI_IP_CONFIG_TYPE_DYNAMIC = 2, /**< Config IP using DHCP client*/ + WIFI_IP_CONFIG_TYPE_AUTO = 3, /**< Config IP from Auto IP pool (169.254/16). Later with DHCP client, if available */ + WIFI_IP_CONFIG_TYPE_FIXED = 4, /**< Indicates an IP address that can not be modified */ } wifi_ip_config_type_e; /** -* @brief Address type -*/ + * @brief Enumeration for the address type. + * @since_tizen 2.3 + */ typedef enum { WIFI_ADDRESS_FAMILY_IPV4 = 0, /**< IPV4 Address family */ @@ -123,13 +136,14 @@ typedef enum } wifi_address_family_e; /** -* @brief This enumeration defines the proxy method type. -*/ + * @brief Enumeration for the proxy method type. + * @since_tizen 2.3 + */ typedef enum { - WIFI_PROXY_TYPE_DIRECT = 0, /**< Direct connection */ - WIFI_PROXY_TYPE_AUTO = 1, /**< Auto configuration(Use PAC file). If URL property is not set, DHCP/WPAD auto-discover will be tried */ - WIFI_PROXY_TYPE_MANUAL = 2 /**< Manual configuration */ + WIFI_PROXY_TYPE_DIRECT = 0, /**< Direct connection */ + WIFI_PROXY_TYPE_AUTO = 1, /**< Auto configuration(Use PAC file). If URL property is not set, DHCP/WPAD auto-discover will be tried */ + WIFI_PROXY_TYPE_MANUAL = 2 /**< Manual configuration */ } wifi_proxy_type_e; /** @@ -143,28 +157,33 @@ typedef enum */ /** -* @brief Below security modes are used in infrastructure and ad-hoc mode -* For now all EAP security mechanisms are provided only in infrastructure mode -*/ + * @brief Enumeration for Wi-Fi security type. + * @details The following security modes are used in infrastructure and ad-hoc mode. + * For now all EAP security mechanisms are provided only in infrastructure mode. + * + * @since_tizen 2.3 + */ typedef enum { - WIFI_SECURITY_TYPE_NONE = 0, /**< Security disabled */ - WIFI_SECURITY_TYPE_WEP = 1, /**< WEP */ - WIFI_SECURITY_TYPE_WPA_PSK = 2, /**< WPA-PSK */ - WIFI_SECURITY_TYPE_WPA2_PSK = 3, /**< WPA2-PSK */ - WIFI_SECURITY_TYPE_EAP = 4, /**< EAP */ + WIFI_SECURITY_TYPE_NONE = 0, /**< Security disabled */ + WIFI_SECURITY_TYPE_WEP = 1, /**< WEP */ + WIFI_SECURITY_TYPE_WPA_PSK = 2, /**< WPA-PSK */ + WIFI_SECURITY_TYPE_WPA2_PSK = 3, /**< WPA2-PSK */ + WIFI_SECURITY_TYPE_EAP = 4, /**< EAP */ } wifi_security_type_e; /** -* @brief Below encryption modes are used in infrastructure and ad-hoc mode -*/ + * @brief Enumeration for Wi-Fi encryption type. + * @details The following encryption modes are used in infrastructure and ad-hoc mode. + * @since_tizen 2.3 + */ typedef enum { - WIFI_ENCRYPTION_TYPE_NONE = 0, /**< Encryption disabled */ - WIFI_ENCRYPTION_TYPE_WEP = 1, /**< WEP */ - WIFI_ENCRYPTION_TYPE_TKIP = 2, /**< TKIP */ - WIFI_ENCRYPTION_TYPE_AES = 3, /**< AES */ - WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED = 4, /**< TKIP and AES are both supported */ + WIFI_ENCRYPTION_TYPE_NONE = 0, /**< Encryption disabled */ + WIFI_ENCRYPTION_TYPE_WEP = 1, /**< WEP */ + WIFI_ENCRYPTION_TYPE_TKIP = 2, /**< TKIP */ + WIFI_ENCRYPTION_TYPE_AES = 3, /**< AES */ + WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED = 4, /**< TKIP and AES are both supported */ } wifi_encryption_type_e; /** @@ -178,28 +197,30 @@ typedef enum */ /** -* @brief EAP type -*/ + * @brief Enumeration for EAP type. + * @since_tizen 2.3 + */ typedef enum { - WIFI_EAP_TYPE_PEAP = 0, /**< EAP PEAP type */ - WIFI_EAP_TYPE_TLS = 1, /**< EAP TLS type */ - WIFI_EAP_TYPE_TTLS = 2, /**< EAP TTLS type */ - WIFI_EAP_TYPE_SIM = 3, /**< EAP SIM type */ - WIFI_EAP_TYPE_AKA = 4, /**< EAP AKA type */ + WIFI_EAP_TYPE_PEAP = 0, /**< EAP PEAP type */ + WIFI_EAP_TYPE_TLS = 1, /**< EAP TLS type */ + WIFI_EAP_TYPE_TTLS = 2, /**< EAP TTLS type */ + WIFI_EAP_TYPE_SIM = 3, /**< EAP SIM type */ + WIFI_EAP_TYPE_AKA = 4, /**< EAP AKA type */ } wifi_eap_type_e; /** -* @brief EAP phase2 authentication type -*/ + * @brief Enumeration for EAP phase2 authentication type. + * @since_tizen 2.3 + */ typedef enum { - WIFI_EAP_AUTH_TYPE_NONE = 0, /**< EAP phase2 authentication none */ - WIFI_EAP_AUTH_TYPE_PAP = 1, /**< EAP phase2 authentication PAP */ - WIFI_EAP_AUTH_TYPE_MSCHAP = 2, /**< EAP phase2 authentication MSCHAP */ - WIFI_EAP_AUTH_TYPE_MSCHAPV2 = 3, /**< EAP phase2 authentication MSCHAPv2 */ - WIFI_EAP_AUTH_TYPE_GTC = 4, /**< EAP phase2 authentication GTC */ - WIFI_EAP_AUTH_TYPE_MD5 = 5, /**< EAP phase2 authentication MD5 */ + WIFI_EAP_AUTH_TYPE_NONE = 0, /**< EAP phase2 authentication none */ + WIFI_EAP_AUTH_TYPE_PAP = 1, /**< EAP phase2 authentication PAP */ + WIFI_EAP_AUTH_TYPE_MSCHAP = 2, /**< EAP phase2 authentication MSCHAP */ + WIFI_EAP_AUTH_TYPE_MSCHAPV2 = 3, /**< EAP phase2 authentication MSCHAPv2 */ + WIFI_EAP_AUTH_TYPE_GTC = 4, /**< EAP phase2 authentication GTC */ + WIFI_EAP_AUTH_TYPE_MD5 = 5, /**< EAP phase2 authentication MD5 */ } wifi_eap_auth_type_e; /** @@ -213,8 +234,9 @@ typedef enum */ /** -* @brief The handle for Wi-Fi access point. -*/ + * @brief The Wi-Fi access point handle. + * @since_tizen 2.3 + */ typedef void* wifi_ap_h; /** @@ -228,64 +250,71 @@ typedef void* wifi_ap_h; */ /** -* @brief Called when you get the found access point repeatedly. -* @remarks @a ap is valid only in this function. In order to use the ap outside this function, you must copy the ap with wifi_ap_clone(). -* @param[in] ap The access point -* @param[in] user_data The user data passed from the request function -* @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop -* @pre wifi_foreach_found_aps() and wifi_foreach_found_hidden_aps() will invoke this callback. -* @see wifi_foreach_found_aps() -* @see wifi_foreach_found_hidden_aps() -*/ -typedef bool(*wifi_found_ap_cb)(wifi_ap_h ap, void* user_data); + * @brief Called when you get the found access point repeatedly. + * @since_tizen 2.3 + * @remarks @a ap is valid only in this function. In order to use @a ap outside this function, you must copy the ap with wifi_ap_clone(). + * @param[in] ap The access point + * @param[in] user_data The user data passed from the request function + * @return @c true to continue with the next iteration of the loop, \n + * otherwise @c false to break out of the loop + * @pre wifi_foreach_found_aps() will invoke this callback. + * @see wifi_foreach_found_aps() + */ +typedef bool(*wifi_found_ap_cb)(wifi_ap_h ap, void *user_data); /** -* @brief Called when the scan is finished. -* @param[in] error_code The error code -* @param[in] user_data The user data passed from the callback registration function -* @see wifi_scan() -* @see wifi_scan_hidden_ap() -* @see wifi_set_background_scan_cb() -* @see wifi_unset_background_scan_cb() -*/ -typedef void(*wifi_scan_finished_cb)(wifi_error_e error_code, void* user_data); + * @brief Called when the scan is finished. + * @since_tizen 2.3 + * @param[in] error_code The error code + * @param[in] user_data The user data passed from the callback registration function + * @see wifi_scan() + * @see wifi_set_background_scan_cb() + * @see wifi_unset_background_scan_cb() + */ +typedef void(*wifi_scan_finished_cb)(wifi_error_e error_code, void *user_data); /** -* @brief Called after wifi_activate() is completed. -* @param[in] result The result -* @param[in] user_data The user data passed from wifi_activate() -* @pre wifi_activate() will invoke this callback function. -* @see wifi_activate() -*/ -typedef void(*wifi_activated_cb)(wifi_error_e result, void* user_data); + * @brief Called after wifi_activate() or wifi_activate_with_wifi_picker_tested() is completed. + * @since_tizen 2.3 + * @param[in] result The result + * @param[in] user_data The user data passed from wifi_activate() and wifi_activate_with_wifi_picker_tested() + * @pre wifi_activate() or wifi_activate_with_wifi_picker_tested() will invoke this callback function. + * @see wifi_activate() + * @see wifi_activate_with_wifi_picker_tested() + */ +typedef void(*wifi_activated_cb)(wifi_error_e result, void *user_data); /** -* @brief Called after wifi_deactivate() is completed. -* @param[in] result The result -* @param[in] user_data The user data passed from wifi_deactivate() -* @pre wifi_deactivate() will invoke this callback function. -* @see wifi_deactivate() -*/ -typedef void(*wifi_deactivated_cb)(wifi_error_e result, void* user_data); + * @brief Called after wifi_deactivate() is completed. + * @since_tizen 2.3 + * @param[in] result The result + * @param[in] user_data The user data passed from wifi_deactivate() + * @pre wifi_deactivate() will invoke this callback function. + * @see wifi_deactivate() + */ +typedef void(*wifi_deactivated_cb)(wifi_error_e result, void *user_data); /** -* @brief Called after either wifi_connect() or wifi_connect_by_wps_pbc() are completed. -* @param[in] result The result -* @param[in] user_data The user data passed from either wifi_connect() or wifi_connect_by_wps_pbc() -* @pre Either wifi_connect() or wifi_connect_by_wps_pbc() will invoke this callback function. -* @see wifi_connect() -* @see wifi_connect_by_wps_pbc() -*/ -typedef void(*wifi_connected_cb)(wifi_error_e result, void* user_data); + * @brief Called after either wifi_connect() or wifi_connect_by_wps_pbc() or wifi_connect_by_wps_pin() are completed. + * @since_tizen 2.3 + * @param[in] result The result + * @param[in] user_data The user data passed from either wifi_connect() or wifi_connect_by_wps_pbc() or wifi_connect_by_wps_pin() + * @pre Either wifi_connect() or wifi_connect_by_wps_pbc() or wifi_connect_by_wps_pin() will invoke this callback function. + * @see wifi_connect() + * @see wifi_connect_by_wps_pbc() + * @see wifi_connect_by_wps_pin() + */ +typedef void(*wifi_connected_cb)(wifi_error_e result, void *user_data); /** -* @brief Called after wifi_disconnect() is completed. -* @param[in] result The result -* @param[in] user_data The user data passed from wifi_disconnect() -* @pre wifi_disconnect() will invoke this callback function. -* @see wifi_disconnect() -*/ -typedef void(*wifi_disconnected_cb)(wifi_error_e result, void* user_data); + * @brief Called after wifi_disconnect() is completed. + * @since_tizen 2.3 + * @param[in] result The result + * @param[in] user_data The user data passed from wifi_disconnect() + * @pre wifi_disconnect() will invoke this callback function. + * @see wifi_disconnect() + */ +typedef void(*wifi_disconnected_cb)(wifi_error_e result, void *user_data); /** * @} @@ -298,32 +327,35 @@ typedef void(*wifi_disconnected_cb)(wifi_error_e result, void* user_data); */ /** -* @brief Called when the device state is changed. -* @param[in] state The device state -* @param[in] user_data The user data passed from the callback registration function -* @see wifi_set_device_state_changed_cb() -* @see wifi_unset_device_state_changed_cb() -*/ -typedef void(*wifi_device_state_changed_cb)(wifi_device_state_e state, void* user_data); + * @brief Called when the device state is changed. + * @since_tizen 2.3 + * @param[in] state The device state + * @param[in] user_data The user data passed from the callback registration function + * @see wifi_set_device_state_changed_cb() + * @see wifi_unset_device_state_changed_cb() + */ +typedef void(*wifi_device_state_changed_cb)(wifi_device_state_e state, void *user_data); /** -* @brief Called when the connection state is changed. -* @param[in] state The connection state -* @param[in] ap The access point -* @param[in] user_data The user data passed from the callback registration function -* @see wifi_set_connection_state_changed_cb() -* @see wifi_unset_connection_state_changed_cb() -*/ -typedef void(*wifi_connection_state_changed_cb)(wifi_connection_state_e state, wifi_ap_h ap, void* user_data); + * @brief Called when the connection state is changed. + * @since_tizen 2.3 + * @param[in] state The connection state + * @param[in] ap The access point + * @param[in] user_data The user data passed from the callback registration function + * @see wifi_set_connection_state_changed_cb() + * @see wifi_unset_connection_state_changed_cb() + */ +typedef void(*wifi_connection_state_changed_cb)(wifi_connection_state_e state, wifi_ap_h ap, void *user_data); /** -* @brief Called when the RSSI of connected Wi-Fi changed. -* @param[in] rssi_level The level of RSSI -* @param[in] user_data The user data passed from the callback registration function -* @see wifi_set_rssi_level_changed_cb() -* @see wifi_unset_rssi_level_changed_cb() -*/ -typedef void(*wifi_rssi_level_changed_cb)(wifi_rssi_level_e rssi_level, void* user_data); + * @brief Called when the RSSI of connected Wi-Fi is changed. + * @since_tizen 2.3 + * @param[in] rssi_level The level of RSSI + * @param[in] user_data The user data passed from the callback registration function + * @see wifi_set_rssi_level_changed_cb() + * @see wifi_unset_rssi_level_changed_cb() + */ +typedef void(*wifi_rssi_level_changed_cb)(wifi_rssi_level_e rssi_level, void *user_data); /** * @} @@ -336,21 +368,27 @@ typedef void(*wifi_rssi_level_changed_cb)(wifi_rssi_level_e rssi_level, void* us */ /** -* @brief Initializes Wi-Fi -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Initializes Wi-Fi. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * @return @c 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_initialize(void); /** -* @brief Deinitializes Wi-Fi -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Deinitializes Wi-Fi. + * @since_tizen 2.3 + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_deinitialize(void); /** @@ -364,79 +402,138 @@ int wifi_deinitialize(void); */ /** -* @brief Activates Wi-Fi, asynchronously. -* @param[in] callback The callback function to be called. This can be NULL if you don't want to get the notification. -* @param[in] user_data The user data passed to the callback function -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -* @retval #WIFI_ERROR_SECURITY_RESTRICTED Restricted by security system policy -* @post wifi_activated_cb() will be invoked -* @see wifi_activated_cb() -* @see wifi_deactivate() -*/ -int wifi_activate(wifi_activated_cb callback, void* user_data); - -/** -* @brief Deactivates Wi-Fi, asynchronously. -* @param[in] callback The callback function to be called. This can be NULL if you don't want to get the notification. -* @param[in] user_data The user data passed to the callback function -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -* @post wifi_deactivated_cb() will be invoked -* @see wifi_deactivated_cb() -* @see wifi_activate() -*/ -int wifi_deactivate(wifi_deactivated_cb callback, void* user_data); - -/** -* @brief Check whether Wi-Fi is activated. -* @param[out] activated Indicates whether wifi is activated or not -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Activates Wi-Fi asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.set \n + * %http://tizen.org/privilege/network.get + * @remark This API needs both privileges. + * @param[in] callback The callback function to be called \n + * This can be @c NULL if you don't want to get the notification. + * @param[in] user_data The user data passed to the callback function + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_SECURITY_RESTRICTED Restricted by security system policy + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + * @post wifi_activated_cb() will be invoked. + * @see wifi_activated_cb() + * @see wifi_deactivate() + */ +int wifi_activate(wifi_activated_cb callback, void *user_data); + +/** + * @brief Activates Wi-Fi asynchronously and displays Wi-Fi picker (popup) when Wi-Fi is not automatically connected. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.set \n + * %http://tizen.org/privilege/network.get + * @remark This API needs both privileges. + * @param[in] callback The callback function to be called \n + * This can be @c NULL if you don't want to get the notification. + * @param[in] user_data The user data passed to the callback function + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_SECURITY_RESTRICTED Restricted by security system policy + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + * @post wifi_activated_cb() will be invoked. + * @see wifi_activated_cb() + * @see wifi_deactivate() + */ +int wifi_activate_with_wifi_picker_tested(wifi_activated_cb callback, void *user_data); + +/** + * @brief Deactivates Wi-Fi asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.set \n + * %http://tizen.org/privilege/network.get + * @remark This API needs both privileges. + * @param[in] callback The callback function to be called \n + * This can be @c NULL if you don't want to get the notification. + * @param[in] user_data The user data passed to the callback function + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + * @post wifi_deactivated_cb() will be invoked. + * @see wifi_deactivated_cb() + * @see wifi_activate() + */ +int wifi_deactivate(wifi_deactivated_cb callback, void *user_data); + +/** + * @brief Checks whether Wi-Fi is activated. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * @param[out] activated @c ture if Wi-Fi is activated, + * otherwise @c false if Wi-Fi is not activated. + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_is_activated(bool* activated); /** -* @brief Gets the local MAC address. -* @remarks @a mac_address must be released with free() by you. -* @param[out] mac_address The mac address -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Gets the local MAC address. + * @since_tizen 2.3 + * @remarks You must release @a mac_address using free(). + * @param[out] mac_address The MAC address + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_get_mac_address(char** mac_address); /** -* @brief Gets the name of network interface. -* @remarks @a name must be released with free() by you. -* @param[out] name The name of network interface -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Gets the name of the network interface. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * @remarks You must release @a name using free(). + * @param[out] name The name of network interface + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_get_network_interface_name(char** name); /** -* @brief Starts scan, asynchronously. -* @param[in] callback The callback function to be called -* @param[in] user_data The user data passed to the callback function -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -* @post This function invokes wifi_scan_finished_cb(). -*/ -int wifi_scan(wifi_scan_finished_cb callback, void* user_data); + * @brief Starts scan asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.set \n + * %http://tizen.org/privilege/network.get + * @remark This API needs both privileges. + * @param[in] callback The callback function to be called + * @param[in] user_data The user data passed to the callback function + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + * @post This function invokes wifi_scan_finished_cb(). + */ +int wifi_scan(wifi_scan_finished_cb callback, void *user_data); /** * @brief Starts hidden ap scan, asynchronously. @@ -453,28 +550,38 @@ int wifi_scan(wifi_scan_finished_cb callback, void* user_data); int wifi_scan_hidden_ap(const char* essid, wifi_scan_finished_cb callback, void* user_data); /** -* @brief Gets the handle of connected access point. -* @remarks @a handle must be released with wifi_ap_destroy(). -* @param[out] ap The handle of access point -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory -* @retval #WIFI_ERROR_NO_CONNECTION There is no connected AP -*/ + * @brief Gets the handle of the connected access point. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * @remarks You must release @a handle using wifi_ap_destroy(). + * @param[out] ap The access point handle + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_ERROR_NO_CONNECTION There is no connected AP + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_get_connected_ap(wifi_ap_h* ap); /** -* @brief Gets the result of scan. -* @param[in] callback The callback to be called -* @param[in] user_data The user data passed to the callback function -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -* @post This function invokes wifi_found_ap_cb(). -*/ -int wifi_foreach_found_aps(wifi_found_ap_cb callback, void* user_data); + * @brief Gets the result of the scan. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * @param[in] callback The callback to be called + * @param[in] user_data The user data passed to the callback function + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + * @post This function invokes wifi_found_ap_cb(). + */ +int wifi_foreach_found_aps(wifi_found_ap_cb callback, void *user_data); /** * @brief Gets the result of hidden ap scan. @@ -489,68 +596,127 @@ int wifi_foreach_found_aps(wifi_found_ap_cb callback, void* user_data); int wifi_foreach_found_hidden_aps(wifi_found_ap_cb callback, void* user_data); /** -* @brief Connects the access point, asynchronously. -* @param[in] ap The handle of access point -* @param[in] callback The callback function to be called. This can be NULL if you don't want to get the notification. -* @param[in] user_data The user data passed to the callback function -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -* @post This function invokes wifi_connected_cb(). -* @see wifi_connected_cb() -* @see wifi_connect_by_wps_pbc() -* @see wifi_disconnect() -*/ -int wifi_connect(wifi_ap_h ap, wifi_connected_cb callback, void* user_data); - -/** -* @brief Disconnects the access point, asynchronously. -* @param[in] ap The handle of access point -* @param[in] callback The callback function to be called. This can be NULL if you don't want to get the notification. -* @param[in] user_data The user data passed to the callback function -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -* @post This function invokes wifi_disconnected_cb(). -* @see wifi_disconnected_cb() -* @see wifi_connect_by_wps_pbc() -* @see wifi_connect() -*/ -int wifi_disconnect(wifi_ap_h ap, wifi_disconnected_cb callback, void* user_data); - -/** -* @brief Connects the access point with WPS PBC, asynchronously. -* @param[in] ap The handle of access point -* @param[in] callback The callback function to be called. This can be NULL if you don't want to get the notification. -* @param[in] user_data The user data passed to the callback function -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -* @post This function invokes wifi_connected_cb(). -* @see wifi_connected_cb() -* @see wifi_connect() -* @see wifi_disconnect() -* @see wifi_ap_is_wps_supported() -*/ -int wifi_connect_by_wps_pbc(wifi_ap_h ap, wifi_connected_cb callback, void* user_data); - -/** -* @brief Deletes the information of stored access point. -* @details If an AP is connected, then connection information will be stored. -* This information is used when a connection to that AP is established automatically. -* @param[in] ap The handle of access point -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Connects the access point asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.set \n + * %http://tizen.org/privilege/network.get + * @remark This API needs both privileges. + * @param[in] ap The access point handle + * @param[in] callback The callback function to be called \n + * This can be @c NULL if you don't want to get the notification. + * @param[in] user_data The user data passed to the callback function + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + * @post This function invokes wifi_connected_cb(). + * @see wifi_connected_cb() + * @see wifi_connect_by_wps_pbc() + * @see wifi_connect_by_wps_pin() + * @see wifi_disconnect() + */ +int wifi_connect(wifi_ap_h ap, wifi_connected_cb callback, void *user_data); + +/** + * @brief Disconnects the access point asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.set \n + * %http://tizen.org/privilege/network.get + * @remark This API needs both privileges. + * @param[in] ap The access point handle + * @param[in] callback The callback function to be called \n + * This can be @c NULL if you don't want to get the notification. + * @param[in] user_data The user data passed to the callback function + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + * @post This function invokes wifi_disconnected_cb(). + * @see wifi_disconnected_cb() + * @see wifi_connect_by_wps_pbc() + * @see wifi_connect_by_wps_pin() + * @see wifi_connect() + */ +int wifi_disconnect(wifi_ap_h ap, wifi_disconnected_cb callback, void *user_data); + +/** + * @brief Connects the access point with WPS PBC asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n + * %http://tizen.org/privilege/network.get + * @remark This API needs both privileges. + * @param[in] ap The access point handle + * @param[in] callback The callback function to be called \n + * This can be NULL if you don't want to get the notification. + * @param[in] user_data The user data passed to the callback function + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + * @post This function invokes wifi_connected_cb(). + * @see wifi_connected_cb() + * @see wifi_connect() + * @see wifi_disconnect() + * @see wifi_ap_is_wps_supported() + */ +int wifi_connect_by_wps_pbc(wifi_ap_h ap, wifi_connected_cb callback, void *user_data); + +/** + * @brief Connects the access point with WPS PIN asynchronously. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n + * %http://tizen.org/privilege/network.get + * @remark This API needs both privileges. + * @param[in] ap The access point handle + * @param[in] pin The WPS PIN is a non-NULL string with length greater than 0 and less than or equal to 8 + * @param[in] callback The callback function to be called (this can be NULL if you don't want to get the notification) + * @param[in] user_data The user data passed to the callback function + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + * @post This function invokes wifi_connected_cb(). + * @see wifi_connected_cb() + * @see wifi_connect() + * @see wifi_disconnect() + * @see wifi_ap_is_wps_supported() + */ +int wifi_connect_by_wps_pin(wifi_ap_h ap, const char *pin, wifi_connected_cb callback, void *user_data); + +/** + * @brief Deletes the information of stored access point and disconnects it when it connected. + * @details If an AP is connected, then connection information will be stored. + * This information is used when a connection to that AP is established automatically. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n +* %http://tizen.org/privilege/network.get + * @remark This API needs both privileges. + * @param[in] ap The access point handle + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_forget_ap(wifi_ap_h ap); /** @@ -564,89 +730,110 @@ int wifi_forget_ap(wifi_ap_h ap); */ /** -* @brief Gets connection state -* @param[out] connection_state The connection state -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Gets the connection state. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * @param[out] connection_state The connection state + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_get_connection_state(wifi_connection_state_e* connection_state); /** -* @brief Registers the callback called when the device state is changed. -* @param[in] callback The callback function to be called -* @param[in] user_data The user data passed to the callback function -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -*/ -int wifi_set_device_state_changed_cb(wifi_device_state_changed_cb callback, void* user_data); + * @brief Registers the callback called when the device state is changed. + * @since_tizen 2.3 + * @param[in] callback The callback function to be called + * @param[in] user_data The user data passed to the callback function + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ +int wifi_set_device_state_changed_cb(wifi_device_state_changed_cb callback, void *user_data); /** -* @brief Unregisters the callback called when the device state is changed. -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -*/ + * @brief Unregisters the callback called when the device state is changed. + * @since_tizen 2.3 + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_unset_device_state_changed_cb(void); /** -* @brief Registers the callback called when the background scan is finished periodically. -* @param[in] callback The callback function to be called -* @param[in] user_data The user data passed to the callback function -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -*/ -int wifi_set_background_scan_cb(wifi_scan_finished_cb callback, void* user_data); + * @brief Registers the callback called when the background scan is finished periodically. + * @since_tizen 2.3 + * @param[in] callback The callback function to be called + * @param[in] user_data The user data passed to the callback function + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ +int wifi_set_background_scan_cb(wifi_scan_finished_cb callback, void *user_data); /** -* @brief Unregisters the callback called when the scan is finished periodically. -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -*/ + * @brief Unregisters the callback called when the scan is finished periodically. + * @since_tizen 2.3 + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_unset_background_scan_cb(void); /** -* @brief Registers the callback called when the connection state is changed. -* @param[in] callback The callback function to be called -* @param[in] user_data The user data passed to the callback function -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -*/ -int wifi_set_connection_state_changed_cb(wifi_connection_state_changed_cb callback, void* user_data); + * @brief Registers the callback called when the connection state is changed. + * @since_tizen 2.3 + * @param[in] callback The callback function to be called + * @param[in] user_data The user data passed to the callback function + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ +int wifi_set_connection_state_changed_cb(wifi_connection_state_changed_cb callback, void *user_data); /** -* @brief Unregisters the callback called when the connection state is changed. -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -*/ + * @brief Unregisters the callback called when the connection state is changed. + * @since_tizen 2.3 + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_unset_connection_state_changed_cb(void); /** -* @brief Registers callback called when the RSSI of connected Wi-Fi changed. -* @param[in] callback The callback function to be called -* @param[in] user_data The user data passed to the callback function -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -*/ -int wifi_set_rssi_level_changed_cb(wifi_rssi_level_changed_cb callback, void* user_data); + * @brief Registers callback called when the RSSI of connected Wi-Fi is changed. + * @since_tizen 2.3 + * @param[in] callback The callback function to be called + * @param[in] user_data The user data passed to the callback function + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ +int wifi_set_rssi_level_changed_cb(wifi_rssi_level_changed_cb callback, void *user_data); /** -* @brief Unregisters callback called when the RSSI of connected Wi-Fi changed. -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -*/ + * @brief Unregisters callback called when the RSSI of connected Wi-Fi is changed. + * @since_tizen 2.3 + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_unset_rssi_level_changed_cb(void); /** @@ -660,51 +847,81 @@ int wifi_unset_rssi_level_changed_cb(void); */ /** -* @brief Creates the handle of access point. -* @remarks @a ap must be released with wifi_ap_destroy(). -* @param[in] essid The ESSID(Extended Service Set Identifier) -* @param[out] ap The handle of access point -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory -* @see wifi_ap_destroy() -*/ + * @brief Creates the access point handle. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n + * %http://tizen.org/privilege/network.get + * @remarks You must release @a ap using wifi_ap_destroy(). \n + * This API needs both privileges. + * @param[in] essid The ESSID (Extended Service Set Identifier) should be null-terminated and can be UTF-8 encoded + * @param[out] ap The access point handle + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + * @see wifi_ap_destroy() + */ int wifi_ap_create(const char* essid, wifi_ap_h* ap); /** -* @brief Destroys the handle of access point. -* @param[in] ap The handle of access point -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @see wifi_ap_create() -*/ + * @brief Creates the hidden access point handle. + * @since_tizen 2.3 + * @remarks You must release @a ap using wifi_ap_destroy(). + * @param[in] essid The ESSID (Extended Service Set Identifier) should be null-terminated and can be UTF-8 encoded + * @param[out] ap The access point handle + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + * @see wifi_ap_destroy() + */ +int wifi_ap_hidden_create(const char* essid, wifi_ap_h* ap); + +/** + * @brief Destroys the access point handle. + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + * @see wifi_ap_create() + */ int wifi_ap_destroy(wifi_ap_h ap); /** -* @brief Clons the handle of access point. -* @remarks @a cloned_ap must be released with wifi_ap_destroy(). -* @param[out] cloned_ap The handle of cloned access point -* @param[in] origin The handle of origin access point -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory -* @see wifi_ap_destroy() -*/ + * @brief Clones the access point handle. + * @since_tizen 2.3 + * @remarks You must release @a cloned_ap using wifi_ap_destroy(). + * @param[out] cloned_ap The cloned access point handle + * @param[in] origin The origin access point handle + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + * @see wifi_ap_destroy() + */ int wifi_ap_clone(wifi_ap_h* cloned_ap, wifi_ap_h origin); /** -* @brief Refresh the information of access point. -* @remarks You should call this function in order to get the current information because the information of access point can be changed. -* @param[in] ap The handle of access point -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -* @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory -*/ + * @brief Refreshes the access point information. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * @remarks You should call this function in order to get the current access point information, because the information can be changed. + * @param[in] ap The access point handle + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_refresh(wifi_ap_h ap); /** @@ -718,271 +935,367 @@ int wifi_ap_refresh(wifi_ap_h ap); */ /** -* @brief Gets ESSID(Extended Service Set Identifier). -* @remarks @a essid must be released with free() by you. -* @param[in] ap The handle of access point -* @param[out] essid The ESSID -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory -*/ + * @brief Gets ESSID (Extended Service Set Identifier). + * @since_tizen 2.3 + * @remarks You must release @a essid using free(). + * @param[in] ap The access point handle + * @param[out] essid The ESSID + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_essid(wifi_ap_h ap, char** essid); /** -* @brief Gets BSSID(Basic Service Set Identifier). -* @remarks @a bssid must be released with free() by you. -* @param[in] ap The handle of access point -* @param[out] bssid The BSSID -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory -*/ + * @brief Gets BSSID (Basic Service Set Identifier). + * @since_tizen 2.3 + * @remarks You must release @a bssid using free(). + * @param[in] ap The access point handle + * @param[out] bssid The BSSID + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_bssid(wifi_ap_h ap, char** bssid); /** -* @brief Gets the RSSI. -* @param[in] ap The handle of access point -* @param[out] rssi The RSSI -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Gets the RSSI. + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[out] rssi The RSSI + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_rssi(wifi_ap_h ap, int* rssi); /** -* @brief Gets the Frequency band (MHz). -* @param[in] ap The handle of access point -* @param[out] frequency The frequency -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Gets the frequency band (MHz). + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[out] frequency The frequency + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_frequency(wifi_ap_h ap, int* frequency); /** -* @brief Gets the max speed (Mbps). -* @param[in] ap The handle of access point -* @param[out] max_speed The max speed -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Gets the max speed (Mbps). + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[out] max_speed The max speed + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_max_speed(wifi_ap_h ap, int* max_speed); /** -* @brief Indicates whether the access point is favorite or not. -* @param[in] ap The handle of access point -* @param[out] favourite Indicates whether access point is favorite or not. -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Checks whether the access point is favorite or not. + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[out] favorite @c true if access point is favorite, + * otherwise @c false if access point is not favorite + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_is_favorite(wifi_ap_h ap, bool* favorite); /** -* @brief Gets the connection state. -* @param[in] ap The handle of access point -* @param[out] state The connection state -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Checks whether the access point is passpoint or not. + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[out] passpoint @c ture if access point is passpoint, + * otherwise @c false if access point is not passpoint. + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ +int wifi_ap_is_passpoint(wifi_ap_h ap, bool* passpoint); + +/** + * @brief Gets the connection state. + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[out] state The connection state + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_connection_state(wifi_ap_h ap, wifi_connection_state_e* state); /** -* @brief Gets the config type of IP. -* @param[in] ap The handle of access point -* @param[in] address_family The address family -* @param[out] type The type of IP config -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -* @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported -*/ + * @brief Gets the config type of IP. + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[in] address_family The address family + * @param[out] type The type of IP config + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported + * @retval #WIFI_ERROR_NOT_SUPPORTED 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); /** -* @brief Sets the config type of IP. -* @details If you set IP config type to #WIFI_IP_CONFIG_TYPE_STATIC, -* then IP address, Gateway and Subnet mask will be set to the initial value "0.0.0.0". -* @param[in] ap The handle of access point -* @param[in] address_family The address family -* @param[in] type The type of IP config -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -* @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported -*/ + * @brief Sets the config type of IP. + * @details If you set IP config type to #WIFI_IP_CONFIG_TYPE_STATIC, + * then IP address, Gateway and Subnet mask will be set to the initial value "0.0.0.0". + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n + * %http://tizen.org/privilege/network.get + * @remark This API needs both privileges. + * @param[in] ap The access point handle + * @param[in] address_family The address family + * @param[in] type The type of IP config + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_set_ip_config_type(wifi_ap_h ap, wifi_address_family_e address_family, wifi_ip_config_type_e type); /** -* @brief Gets the IP address. -* @remarks @a ip_address must be released with free() by you. -* @param[in] ap The handle of access point -* @param[in] address_family The address family -* @param[out] ip_address The IP address -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory -* @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported -*/ + * @brief Gets the IP address. + * @since_tizen 2.3 + * @remarks You must release @a ip_address using free(). + * @param[in] ap The access point handle + * @param[in] address_family The address family + * @param[out] ip_address The IP address + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_ip_address(wifi_ap_h ap, wifi_address_family_e address_family, char** ip_address); /** -* @brief Sets the IP address. -* @param[in] ap The handle of access point -* @param[in] address_family The address family -* @param[in] ip_address The IP address. If you set this value to NULL, then the existing value will be deleted. -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -* @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported -*/ + * @brief Sets the IP address. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n + * %http://tizen.org/privilege/network.get + * @remark This API needs both privileges. + * @param[in] ap The access point handle + * @param[in] address_family The address family + * @param[in] ip_address The IP address; if you set this value to NULL, then the existing value will be deleted + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_set_ip_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* ip_address); /** -* @brief Gets the subnet mask. -* @remarks @a subnet_mask must be released with free() by you. -* @param[in] ap The handle of access point -* @param[in] address_family The address family -* @param[out] subnet_mask The subnet mask -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory -* @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported -*/ + * @brief Gets the subnet mask. + * @since_tizen 2.3 + * @remarks You must release @a subnet_mask using free(). + * @param[in] ap The access point handle + * @param[in] address_family The address family + * @param[out] subnet_mask The subnet mask + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_subnet_mask(wifi_ap_h ap, wifi_address_family_e address_family, char** subnet_mask); /** -* @brief Sets the subnet mask. -* @param[in] ap The handle of access point -* @param[in] address_family The address family -* @param[in] subnet_mask The subnet mask. If you set this value to NULL, then the existing value will be deleted. -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -* @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported -*/ + * @brief Sets the subnet mask. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n + * %http://tizen.org/privilege/network.get + * @remark This API needs both privileges. + * @param[in] ap The access point handle + * @param[in] address_family The address family + * @param[in] subnet_mask The subnet mask; if you set this value to NULL, then the existing value will be deleted + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_set_subnet_mask(wifi_ap_h ap, wifi_address_family_e address_family, const char* subnet_mask); /** -* @brief Gets the gateway address. -* @remarks @a gateway_address must be released with free() by you. -* @param[in] ap The handle of access point -* @param[in] address_family The address family -* @param[out] gateway_address The gateway address -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory -* @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported -*/ + * @brief Gets the gateway address. + * @since_tizen 2.3 + * @remarks You must release @a gateway_address using free(). + * @param[in] ap The access point handle + * @param[in] address_family The address family + * @param[out] gateway_address The gateway address + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_gateway_address(wifi_ap_h ap, wifi_address_family_e address_family, char** gateway_address); /** -* @brief Sets the gateway address. -* @param[in] ap The handle of access point -* @param[in] address_family The address family -* @param[in] gateway_address The gateway address. If you set this value to NULL, then the existing value will be deleted. -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -* @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported -*/ + * @brief Sets the gateway address. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n + * %http://tizen.org/privilege/network.get + * @remark This API needs both privileges. + * @param[in] ap The access point handle + * @param[in] address_family The address family + * @param[in] gateway_address The gateway address \n + * If you set this value to @c NULL, then the existing value will be deleted. + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_set_gateway_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* gateway_address); /** -* @brief Gets the proxy address. -* @remarks @a proxy_address must be released with free() by you. -* @param[in] ap The handle of access point -* @param[in] address_family The address family -* @param[out] proxy_address The proxy address -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory -* @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported -*/ + * @brief Gets the proxy address. + * @since_tizen 2.3 + * @remarks You must release @a proxy_address using free(). + * @param[in] ap The access point handle + * @param[in] address_family The address family + * @param[out] proxy_address The proxy address + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_proxy_address(wifi_ap_h ap, wifi_address_family_e address_family, char** proxy_address); /** -* @brief Sets the proxy address. -* @param[in] ap The handle of access point -* @param[in] address_family The address family -* @param[in] proxy_address The proxy address. If you set this value to NULL, then the existing value will be deleted. -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -* @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported -*/ + * @brief Sets the proxy address. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n + * %http://tizen.org/privilege/network.get + * @remark This API needs both privileges. + * @param[in] ap The access point handle + * @param[in] address_family The address family + * @param[in] proxy_address The proxy address \n + * If you set this value to @c NULL, then the existing value will be deleted. + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_set_proxy_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* proxy_address); /** -* @brief Gets the Proxy type. -* @param[in] ap The handle of access point -* @param[out] type The type of proxy -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Gets the Proxy type. + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[out] type The type of proxy + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_proxy_type(wifi_ap_h ap, wifi_proxy_type_e* type); /** -* @brief Sets the Proxy address. -* @details If you set Proxy type to #WIFI_PROXY_TYPE_AUTO or #WIFI_PROXY_TYPE_MANUAL, then Proxy will be restored. -* @param[in] ap The handle of access point -* @param[in] type The type of proxy -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Sets the Proxy address. + * @details If you set Proxy type to #WIFI_PROXY_TYPE_AUTO or #WIFI_PROXY_TYPE_MANUAL, then Proxy will be restored. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n + * %http://tizen.org/privilege/network.get + * @remark This API needs both privileges. + * @param[in] ap The access point handle + * @param[in] proxy_type The type of proxy + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_set_proxy_type(wifi_ap_h ap, wifi_proxy_type_e proxy_type); /** -* @brief Gets the DNS address. -* @remarks The allowance of DNS address is 2. @a dns_address must be released with free() by you. -* @param[in] ap The handle of access point -* @param[in] order The order of DNS address. It starts from 1, which means first DNS address. -* @param[in] address_family The address family -* @param[out] dns_address The DNS address -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory -* @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported -*/ + * @brief Gets the DNS address. + * @since_tizen 2.3 + * @remarks The allowance of DNS address is @c 2.You must release @a dns_address using free(). + * @param[in] ap The access point handle + * @param[in] order The order of DNS address; it starts from 1, which means first DNS address + * @param[in] address_family The address family + * @param[out] dns_address The DNS address + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_dns_address(wifi_ap_h ap, int order, wifi_address_family_e address_family, char** dns_address); /** -* @brief Sets the DNS address. -* @remarks The allowance of DNS address is 2. -* @param[in] ap The handle of access point -* @param[in] order The order of DNS address. It starts from 1, which means first DNS address. -* @param[in] address_family The address family -* @param[in] dns_address The DNS address. If you set this value to NULL, then the existing value will be deleted. -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -* @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported -*/ + * @brief Sets the DNS address. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n + * %http://tizen.org/privilege/network.get + * @remarks The allowance of DNS address is @c 2 \n + * This API needs both privileges. + * @param[in] ap The access point handle + * @param[in] order The order of DNS address \n + * It starts from @c 1, which means first DNS address. + * @param[in] address_family The address family + * @param[in] dns_address The DNS address \n + * If you set this value to @c NULL, then the existing value will be deleted. + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported + * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_set_dns_address(wifi_ap_h ap, int order, wifi_address_family_e address_family, const char* dns_address); /** @@ -996,82 +1309,99 @@ int wifi_ap_set_dns_address(wifi_ap_h ap, int order, wifi_address_family_e addre */ /** -* @brief Gets the security mode of Wi-Fi. -* @param[in] ap The handle of access point -* @param[out] type The type of Wi-Fi security -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Gets the Wi-Fi security mode. + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[out] type The type of Wi-Fi security + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_security_type(wifi_ap_h ap, wifi_security_type_e* type); /** -* @brief Sets the security mode of Wi-Fi. -* @param[in] ap The handle of access point -* @param[in] type The type of Wi-Fi security -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Sets the Wi-Fi security mode. + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[in] type The type of Wi-Fi security + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_set_security_type(wifi_ap_h ap, wifi_security_type_e type); /** -* @brief Gets the encryption type of Wi-Fi. -* @param[in] ap The handle of access point -* @param[out] type The type of Wi-Fi encryption -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Gets the Wi-Fi encryption type. + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[out] type The type of Wi-Fi encryption + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_encryption_type(wifi_ap_h ap, wifi_encryption_type_e* type); /** -* @brief Sets the encryption type of Wi-Fi. -* @param[in] ap The handle of access point -* @param[in] type The type of Wi-Fi encryption -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Sets the Wi-Fi encryption type. + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[in] type The type of Wi-Fi encryption + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_set_encryption_type(wifi_ap_h ap, wifi_encryption_type_e type); /** -* @brief Indicates whether the passphrase is required or not. -* @remarks This function is not valid if security type is #WIFI_SECURITY_TYPE_EAP. -* @param[in] ap The handle of access point -* @param[out] required Indicates whether passphrase is required or not -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Checks whether the passphrase is required or not. + * @since_tizen 2.3 + * @remarks This function is not valid if security type is #WIFI_SECURITY_TYPE_EAP. + * @param[in] ap The access point handle + * @param[out] required @c true if passphrase is required, + * @c false if passphrase is not required. + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_is_passphrase_required(wifi_ap_h ap, bool* required); /** -* @brief Sets the passphrase. -* @param[in] ap The handle of access point -* @param[in] passphrase The passphrase of access point -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Sets the passphrase. + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[in] passphrase The passphrase of access point + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_set_passphrase(wifi_ap_h ap, const char* passphrase); /** -* @brief Indicates whether the WPS(Wi-Fi Protected Setup) is supported or not. -* @param[in] ap The handle of access point -* @param[out] supported Indicates whether WPS is supported or not -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -* @see wifi_connect_by_wps_pbc() -*/ + * @brief Checks whether the WPS(Wi-Fi Protected Setup) is supported or not. + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[out] supported @c ture if WPS is supported, + * otherwise @c false is WPS is not supported. + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + * @see wifi_connect_by_wps_pbc() + * @see wifi_connect_by_wps_pin() + */ int wifi_ap_is_wps_supported(wifi_ap_h ap, bool* supported); /** @@ -1085,159 +1415,186 @@ int wifi_ap_is_wps_supported(wifi_ap_h ap, bool* supported); */ /** -* @brief Sets the passphrase of EAP. -* @details You can set one of @a user_name and @a password as NULL. -* In this case, the value of a parameter which is set as NULL will be the previous value. -* But it is not allowed that both @a user_name and @a password are set as NULL. -* @remarks This function is valid only if the EAP type is #WIFI_EAP_TYPE_PEAP or #WIFI_EAP_TYPE_TTLS. -* @param[in] ap The handle of access point -* @param[in] user_name The user name. This value can be NULL. -* @param[in] password The password. This value can be NULL. -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -*/ + * @brief Sets the passphrase of EAP. + * @details You can set one of @a user_name and @a password as @c NULL. + * In this case, the value of a parameter which is set as @c NULL will be the previous value. + * But it is not allowed that both @a user_name and @a password are set as @c NULL. + * @since_tizen 2.3 + * @remarks This function is valid only if the EAP type is #WIFI_EAP_TYPE_PEAP or #WIFI_EAP_TYPE_TTLS. + * @param[in] ap The access point handle + * @param[in] user_name The user name \n + * This value can be @c NULL. + * @param[in] password The password \n + * This value can be @c NULL. + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_set_eap_passphrase(wifi_ap_h ap, const char* user_name, const char* password); /** -* @brief Gets the passphrase of EAP. -* @remarks This function is valid only if the EAP type is #WIFI_EAP_TYPE_PEAP or #WIFI_EAP_TYPE_TTLS. -* @a user_name must be released with free() by you. -* @param[in] ap The handle of access point -* @param[out] user_name The user name -* @param[out] password Indicates whether password is set or not (@c true = set, @c false = not set) -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -*/ + * @brief Gets the passphrase of EAP. + * @since_tizen 2.3 + * @remarks This function is valid only if the EAP type is #WIFI_EAP_TYPE_PEAP or #WIFI_EAP_TYPE_TTLS. + * You must release @a user_name using free(). + * @param[in] ap The access point handle + * @param[out] user_name The user name + * @param[out] is_password_set @c ture if password is set, + * otherwise @c flase if password is not set. + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_eap_passphrase(wifi_ap_h ap, char** user_name, bool* is_password_set); /** -* @brief Gets the CA Certificate of EAP. -* @remarks This function is valid only if the EAP type is #WIFI_EAP_TYPE_TLS. -* @a file must be released with free() by you. -* @param[in] ap The handle of access point -* @param[out] file The file path of CA Certificate -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -*/ + * @brief Gets the CA Certificate of EAP. + * @since_tizen 2.3 + * @remarks This function is valid only if the EAP type is #WIFI_EAP_TYPE_TLS. + * You must release @a file using free(). + * @param[in] ap The access point handle + * @param[out] file The file path of CA Certificate + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_eap_ca_cert_file(wifi_ap_h ap, char** file); /** -* @brief Sets the CA Certificate of EAP. -* @remarks This function is valid only if the EAP type is #WIFI_EAP_TYPE_TLS. -* @param[in] ap The handle of access point -* @param[in] file The file path of CA Certificate -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -*/ + * @brief Sets the CA Certificate of EAP. + * @since_tizen 2.3 + * @remarks This function is valid only if the EAP type is #WIFI_EAP_TYPE_TLS. + * @param[in] ap The access point handle + * @param[in] file The file path of CA Certificate + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_set_eap_ca_cert_file(wifi_ap_h ap, const char* file); /** -* @brief Gets the Client Certificate of EAP. -* @remarks This function is valid only if the EAP type is #WIFI_EAP_TYPE_TLS. -* @a file must be released with free() by you. -* @param[in] ap The handle of access point -* @param[out] file The file path of Client Certificate -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -*/ + * @brief Gets the Client Certificate of EAP. + * @since_tizen 2.3 + * @remarks This function is valid only if the EAP type is #WIFI_EAP_TYPE_TLS. + * You must release @a file using free(). + * @param[in] ap The access point handle + * @param[out] file The file path of Client Certificate + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_eap_client_cert_file(wifi_ap_h ap, char** file); /** -* @brief Sets the CA Certificate of EAP. -* @remarks This function is valid only if the EAP type is #WIFI_EAP_TYPE_TLS. -* @param[in] ap The handle of access point -* @param[in] file The file path of Client Certificate -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -*/ + * @brief Sets the CA Certificate of EAP. + * @since_tizen 2.3 + * @remarks This function is valid only if the EAP type is #WIFI_EAP_TYPE_TLS. + * @param[in] ap The access point handle + * @param[in] file The file path of Client Certificate + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_set_eap_client_cert_file(wifi_ap_h ap, const char* file); /** -* @brief Gets the private key file of EAP. -* @remarks This function is valid only if the EAP type is #WIFI_EAP_TYPE_TLS. -* @a file must be released with free() by you. -* @param[in] ap The handle of access point -* @param[out] file The file path of private key -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -*/ + * @brief Gets the private key file of EAP. + * @since_tizen 2.3 + * @remarks This function is valid only if the EAP type is #WIFI_EAP_TYPE_TLS. + * You must release @a file using free(). + * @param[in] ap The access point handle + * @param[out] file The file path of private key + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_eap_private_key_file(wifi_ap_h ap, char** file); /** -* @brief Sets the private key information of EAP. -* @remarks This function is valid only if the EAP type is #WIFI_EAP_TYPE_TLS. -* @param[in] ap The handle of access point -* @param[in] file The file path of private key -* @param[in] password The password -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -*/ + * @brief Sets the private key information of EAP. + * @since_tizen 2.3 + * @remarks This function is valid only if the EAP type is #WIFI_EAP_TYPE_TLS. + * @param[in] ap The access point handle + * @param[in] file The file path of private key + * @param[in] password The password + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_set_eap_private_key_info(wifi_ap_h ap, const char* file, const char* password); /** -* @brief Gets the EAP type of Wi-Fi. -* @param[in] ap The handle of access point -* @param[out] type The type of EAP -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Gets the EAP type of Wi-Fi. + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[out] type The type of EAP + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_eap_type(wifi_ap_h ap, wifi_eap_type_e* type); /** -* @brief Sets the EAP type of Wi-Fi. -* @param[in] ap The handle of access point -* @param[in] type The type of EAP -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -*/ + * @brief Sets the EAP type of Wi-Fi. + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[in] type The type of EAP + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_set_eap_type(wifi_ap_h ap, wifi_eap_type_e type); /** -* @brief Gets the type of EAP phase2 authentication of Wi-Fi. -* @param[in] ap The handle of access point -* @param[out] type The type of EAP phase2 authentication -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -* @retval #WIFI_ERROR_OPERATION_FAILED Operation failed -*/ + * @brief Gets the type of EAP phase2 authentication of Wi-Fi. + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[out] type The type of EAP phase2 authentication + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_get_eap_auth_type(wifi_ap_h ap, wifi_eap_auth_type_e* type); /** -* @brief Sets the type of EAP phase2 authentication of Wi-Fi. -* @param[in] ap The handle of access point -* @param[in] type The type of EAP phase2 authentication -* @return 0 on success, otherwise negative error value. -* @retval #WIFI_ERROR_NONE Successful -* @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation -*/ + * @brief Sets the type of EAP phase2 authentication of Wi-Fi. + * @since_tizen 2.3 + * @param[in] ap The access point handle + * @param[in] type The type of EAP phase2 authentication + * @return 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ int wifi_ap_set_eap_auth_type(wifi_ap_h ap, wifi_eap_auth_type_e type); /** diff --git a/packaging/capi-network-wifi.spec b/packaging/capi-network-wifi.spec index 97e99e1..af9377f 100644 --- a/packaging/capi-network-wifi.spec +++ b/packaging/capi-network-wifi.spec @@ -1,6 +1,6 @@ Name: capi-network-wifi Summary: Network Wi-Fi library in TIZEN C API -Version: 0.1.2_24 +Version: 0.1.2_25 Release: 1 Group: System/Network License: Apache-2.0 diff --git a/src/libnetwork.c b/src/libnetwork.c index 1198c5f..33f41aa 100755 --- a/src/libnetwork.c +++ b/src/libnetwork.c @@ -20,7 +20,8 @@ #include <glib.h> #include "net_wifi_private.h" -static GSList *ap_handle_list = NULL; +static __thread bool is_init = false; +static __thread GSList *ap_handle_list = NULL; struct _wifi_cb_s { wifi_device_state_changed_cb device_state_cb; @@ -48,10 +49,31 @@ struct _profile_list_s { net_profile_info_t *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}; +struct _wifi_state_notify { + net_profile_info_t *ap_info; + wifi_connection_state_e state; +}; + +struct managed_idle_data { + GSourceFunc func; + gpointer user_data; + guint id; +}; + +static __thread struct _wifi_cb_s wifi_callbacks = { 0, }; +static __thread struct _profile_list_s profile_iterator = { 0, NULL }; +static __thread GSList *managed_idler_list = NULL; +static __thread struct _profile_list_s hidden_profile_iterator = {0, NULL}; + +bool _wifi_is_init(void) +{ + return is_init; +} +static void __wifi_set_init(bool tag) +{ + is_init = tag; +} static wifi_error_e __libnet_convert_to_ap_error_type(net_err_t err_type) { @@ -76,6 +98,8 @@ static wifi_error_e __libnet_convert_to_ap_error_type(net_err_t err_type) return WIFI_ERROR_OPERATION_ABORTED; case NET_ERR_TIME_OUT: return WIFI_ERROR_NO_REPLY; + case NET_ERR_ACCESS_DENIED: + return WIFI_ERROR_PERMISSION_DENIED; default: return WIFI_ERROR_OPERATION_FAILED; } @@ -112,6 +136,10 @@ static const char *__libnet_convert_ap_error_type_to_string(wifi_error_e err_typ return "NO_REPLY"; case WIFI_ERROR_SECURITY_RESTRICTED: return "SECURITY_RESTRICTED"; + case WIFI_ERROR_PERMISSION_DENIED: + return "PERMISSION_DENIED"; + case WIFI_ERROR_NOT_SUPPORTED: + return "NOT_SUPPROTED"; } return "UNKNOWN"; @@ -120,6 +148,8 @@ static const char *__libnet_convert_ap_error_type_to_string(wifi_error_e err_typ static const char *__libnet_convert_ap_state_to_string(wifi_connection_state_e state) { switch (state) { + case WIFI_CONNECTION_STATE_FAILURE: + return "FAILURE"; case WIFI_CONNECTION_STATE_DISCONNECTED: return "DISCONNECTED"; case WIFI_CONNECTION_STATE_ASSOCIATION: @@ -142,20 +172,28 @@ static void __libnet_clear_profile_list(struct _profile_list_s *profile_list) profile_list->profiles = NULL; } -static void __libnet_update_profile_iterator(void) +static int __libnet_update_profile_iterator(void) { - struct _profile_list_s wifi_profiles = {0, NULL}; + int rv; + struct _profile_list_s wifi_profiles = { 0, NULL }; __libnet_clear_profile_list(&profile_iterator); - 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); + rv = net_get_profile_list(NET_DEVICE_WIFI, &wifi_profiles.profiles, &wifi_profiles.count); + WIFI_LOG(WIFI_INFO, "Wi-Fi profile count: %d", wifi_profiles.count); + + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_ERROR_PERMISSION_DENIED; + } if (wifi_profiles.count == 0) - return; + return WIFI_ERROR_NONE; profile_iterator.count = wifi_profiles.count; profile_iterator.profiles = wifi_profiles.profiles; + + return WIFI_ERROR_NONE; } static void __libnet_update_hidden_profile_iterator(GSList *ap_list) @@ -197,12 +235,17 @@ static void __libnet_convert_profile_info_to_wifi_info(net_wifi_connection_info_ static int __libnet_connect_with_wifi_info(net_profile_info_t *ap_info) { + int rv; net_wifi_connection_info_t wifi_info; memset(&wifi_info, 0, sizeof(net_wifi_connection_info_t)); __libnet_convert_profile_info_to_wifi_info(&wifi_info, ap_info); - if (net_open_connection_with_wifi_info(&wifi_info) != NET_ERR_NONE) + rv = net_open_connection_with_wifi_info(&wifi_info); + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) return WIFI_ERROR_OPERATION_FAILED; return WIFI_ERROR_NONE; @@ -247,7 +290,7 @@ static void __libnet_activated_cb(wifi_error_e result) static void __libnet_set_deactivated_cb(wifi_disconnected_cb user_cb, void *user_data) { - if (user_cb) { + if (user_cb != NULL) { wifi_callbacks.deactivated_cb = user_cb; wifi_callbacks.deactivated_user_data = user_data; } @@ -264,34 +307,44 @@ static void __libnet_deactivated_cb(wifi_error_e result) static void __libnet_power_on_off_cb(net_event_info_t *event_cb, bool is_requested) { + if (_wifi_is_init() != true) { + WIFI_LOG(WIFI_ERROR, "Application is not registered" + "If multi-threaded, thread integrity be broken."); + return; + } + if (wifi_callbacks.device_state_cb == NULL && - wifi_callbacks.activated_cb == NULL && - wifi_callbacks.deactivated_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; + wifi_device_state_e state = WIFI_DEVICE_STATE_DEACTIVATED; + 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)) { - + event_cb->Datalength == sizeof(net_wifi_state_t)) { if (*wifi_state == WIFI_ON) { - WIFI_LOG(WIFI_INFO, "Wi-Fi State : Power ON\n"); + WIFI_LOG(WIFI_INFO, "Wi-Fi power on"); state = WIFI_DEVICE_STATE_ACTIVATED; } else if (*wifi_state == WIFI_OFF) { - WIFI_LOG(WIFI_INFO, "Wi-Fi State : Power OFF\n"); + WIFI_LOG(WIFI_INFO, "Wi-Fi power off"); 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"); + WIFI_LOG(WIFI_ERROR, "Error Wi-Fi state %d", *wifi_state); 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; + WIFI_LOG(WIFI_ERROR, "Wi-Fi power request failed(%d)", event_cb->Error); + + if (event_cb->Error == NET_ERR_SECURITY_RESTRICTED) + error_code = WIFI_ERROR_SECURITY_RESTRICTED; + else + error_code = WIFI_ERROR_OPERATION_FAILED; + state = WIFI_DEVICE_STATE_DEACTIVATED; } @@ -402,19 +455,15 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data) 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; + 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; } @@ -442,16 +491,14 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data) switch (event_cb->Error) { case NET_ERR_NONE: - WIFI_LOG(WIFI_INFO, "Connection close succeeded!\n"); 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); + WIFI_CONNECTION_STATE_DISCONNECTED); else __libnet_state_changed_cb(event_cb->ProfileName, NULL, - WIFI_CONNECTION_STATE_DISCONNECTED); + WIFI_CONNECTION_STATE_DISCONNECTED); return; default: - WIFI_LOG(WIFI_ERROR, "Connection close failed!\n"); break; } @@ -460,12 +507,10 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data) 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; + 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, @@ -478,7 +523,6 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data) else __libnet_state_changed_cb(event_cb->ProfileName, NULL, ap_state); - break; case NET_EVENT_WIFI_SCAN_RSP: case NET_EVENT_WIFI_SCAN_IND: @@ -496,23 +540,24 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data) 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"); + break; } } -bool _wifi_libnet_init(void) +int _wifi_libnet_init(void) { int rv; rv = net_register_client_ext((net_event_cb_t)__libnet_evt_cb, NET_DEVICE_WIFI, NULL); if (rv != NET_ERR_NONE) - return false; + return rv; - return true; + __wifi_set_init(true); + + return NET_ERR_NONE; } bool _wifi_libnet_deinit(void) @@ -529,47 +574,65 @@ bool _wifi_libnet_deinit(void) return true; } -int _wifi_activate(wifi_activated_cb callback, void *user_data) +int _wifi_activate(wifi_activated_cb callback, gboolean wifi_picker_test, + void *user_data) { - int rv; + int rv = NET_ERR_NONE; 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_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_ERROR_PERMISSION_DENIED; } else if (rv == NET_ERR_INVALID_OPERATION) return WIFI_ERROR_INVALID_OPERATION; else if (rv == NET_ERR_ALREADY_EXISTS) return WIFI_ERROR_ALREADY_EXISTS; + else if (rv == NET_ERR_IN_PROGRESS) + return WIFI_ERROR_NOW_IN_PROGRESS; + else if (rv == NET_ERR_SECURITY_RESTRICTED) + return WIFI_ERROR_SECURITY_RESTRICTED; return WIFI_ERROR_OPERATION_FAILED; } int _wifi_deactivate(wifi_deactivated_cb callback, void *user_data) { - int rv; + int rv = NET_ERR_NONE; 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_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_ERROR_PERMISSION_DENIED; } else if (rv == NET_ERR_INVALID_OPERATION) return WIFI_ERROR_INVALID_OPERATION; else if (rv == NET_ERR_ALREADY_EXISTS) return WIFI_ERROR_ALREADY_EXISTS; + else if (rv == NET_ERR_IN_PROGRESS) + return WIFI_ERROR_NOW_IN_PROGRESS; + else if (rv == NET_ERR_SECURITY_RESTRICTED) + return WIFI_ERROR_SECURITY_RESTRICTED; return WIFI_ERROR_OPERATION_FAILED; } bool _wifi_libnet_check_ap_validity(wifi_ap_h ap_h) { - GSList *list; - int i = 0; + int i; + GSList *list = NULL; + + if (ap_h == NULL) + return false; for (list = ap_handle_list; list; list = list->next) if (ap_h == list->data) return true; - for (; i < profile_iterator.count; i++) + for (i = 0; i < profile_iterator.count; i++) if (ap_h == &profile_iterator.profiles[i]) return true; for (i = 0; i < hidden_profile_iterator.count; i++) @@ -596,13 +659,13 @@ bool _wifi_libnet_check_profile_name_validity(const char *profile_name) if (profile_name == NULL || g_str_has_prefix(profile_name, profile_prefix) != TRUE) { - WIFI_LOG(WIFI_ERROR, "Error!!! Profile name is invalid\n"); + WIFI_LOG(WIFI_INFO, "The profile is a hidden or not a regular Wi-Fi profile"); return false; } while (profile_name[i] != '\0') { if (isgraph(profile_name[i]) == 0) { - WIFI_LOG(WIFI_ERROR, "Error!!! Profile name is invalid\n"); + WIFI_LOG(WIFI_INFO, "Invalid format: %s", profile_name); return false; } i++; @@ -611,13 +674,18 @@ bool _wifi_libnet_check_profile_name_validity(const char *profile_name) return true; } -bool _wifi_libnet_get_wifi_device_state(wifi_device_state_e *device_state) +int _wifi_libnet_get_wifi_device_state(wifi_device_state_e *device_state) { net_tech_info_t tech_info; - if (net_get_technology_properties(NET_DEVICE_WIFI, &tech_info) != NET_ERR_NONE) { - WIFI_LOG(WIFI_ERROR, "Error!! net_get_technology_properties() failed.\n"); - return false; + int rv = NET_ERR_NONE; + rv = net_get_technology_properties(NET_DEVICE_WIFI, &tech_info); + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, "Failed to get technology properties"); + return WIFI_ERROR_OPERATION_FAILED; } if (tech_info.powered) @@ -625,19 +693,22 @@ bool _wifi_libnet_get_wifi_device_state(wifi_device_state_e *device_state) else *device_state = WIFI_DEVICE_STATE_DEACTIVATED; - WIFI_LOG(WIFI_ERROR, "Wi-Fi device state: %d", *device_state); - - return true; + return WIFI_ERROR_NONE; } -bool _wifi_libnet_get_wifi_state(wifi_connection_state_e* connection_state) +int _wifi_libnet_get_wifi_state(wifi_connection_state_e* connection_state) { + int rv; net_wifi_state_t wlan_state = 0; 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; + rv = net_get_wifi_state(&wlan_state, &profile_name); + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); + return WIFI_ERROR_OPERATION_FAILED; } switch (wlan_state) { @@ -645,9 +716,6 @@ bool _wifi_libnet_get_wifi_state(wifi_connection_state_e* connection_state) 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; @@ -655,20 +723,27 @@ bool _wifi_libnet_get_wifi_state(wifi_connection_state_e* connection_state) *connection_state = WIFI_CONNECTION_STATE_CONNECTED; break; default : - WIFI_LOG(WIFI_ERROR, "Error!! Unknown state\n"); - return false; + WIFI_LOG(WIFI_ERROR, "Unknown state"); + return WIFI_ERROR_OPERATION_FAILED; } - return true; + return WIFI_ERROR_NONE; } int _wifi_libnet_get_intf_name(char** name) { - if (profile_iterator.count == 0) - __libnet_update_profile_iterator(); + int rv; if (profile_iterator.count == 0) { - WIFI_LOG(WIFI_ERROR, "Error!! There is no AP\n"); + rv = __libnet_update_profile_iterator(); + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_ERROR_PERMISSION_DENIED; + } + } + + if (profile_iterator.count == 0) { + WIFI_LOG(WIFI_ERROR, "There is no AP"); return WIFI_ERROR_OPERATION_FAILED; } @@ -688,6 +763,9 @@ int _wifi_libnet_scan_request(wifi_scan_finished_cb callback, void *user_data) wifi_callbacks.scan_request_cb = callback; wifi_callbacks.scan_request_user_data = user_data; return WIFI_ERROR_NONE; + } else if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_ERROR_PERMISSION_DENIED; } else if (rv == NET_ERR_INVALID_OPERATION) return WIFI_ERROR_INVALID_OPERATION; @@ -712,12 +790,16 @@ int _wifi_libnet_scan_hidden_ap(const char *essid, int _wifi_libnet_get_connected_profile(wifi_ap_h *ap) { - int i = 0; + int i, rv; wifi_ap_h ap_h = NULL; - __libnet_update_profile_iterator(); + rv = __libnet_update_profile_iterator(); + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_ERROR_PERMISSION_DENIED; + } - for (;i < profile_iterator.count;i++) { + for (i = 0; i < profile_iterator.count; i++) { if (profile_iterator.profiles[i].ProfileState == NET_STATE_TYPE_ONLINE || profile_iterator.profiles[i].ProfileState == NET_STATE_TYPE_READY) { ap_h = (wifi_ap_h)(&profile_iterator.profiles[i]); @@ -726,7 +808,7 @@ int _wifi_libnet_get_connected_profile(wifi_ap_h *ap) } if (ap_h == NULL) { - WIFI_LOG(WIFI_ERROR, "Error!! There is no connected AP.\n"); + WIFI_LOG(WIFI_ERROR, "There is no connected AP"); return WIFI_ERROR_NO_CONNECTION; } @@ -741,99 +823,128 @@ int _wifi_libnet_get_connected_profile(wifi_ap_h *ap) return WIFI_ERROR_NONE; } -bool _wifi_libnet_foreach_found_aps(wifi_found_ap_cb callback, void *user_data) +int _wifi_libnet_foreach_found_aps(wifi_found_ap_cb callback, void *user_data) { - int i = 0; - bool rv = true; + int i, rv; - __libnet_update_profile_iterator(); + rv = __libnet_update_profile_iterator(); + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_ERROR_PERMISSION_DENIED; + } if (profile_iterator.count == 0) { - WIFI_LOG(WIFI_INFO, "There is no APs.\n"); - return true; + WIFI_LOG(WIFI_WARN, "There is no AP"); + return WIFI_ERROR_NONE; } - for (;i < profile_iterator.count;i++) { + for (i = 0; i < profile_iterator.count; i++) { rv = callback((wifi_ap_h)(&profile_iterator.profiles[i]), user_data); if (rv == false) break; } - return true; + return WIFI_ERROR_NONE; } -bool _wifi_libnet_foreach_found_hidden_aps(wifi_found_ap_cb callback, void *user_data) +int _wifi_libnet_foreach_found_hidden_aps(wifi_found_ap_cb callback, void *user_data) { - int i = 0; - bool rv = true; + int i, rv; if (hidden_profile_iterator.count == 0) { - WIFI_LOG(WIFI_INFO, "There is no hidden APs.\n"); - return true; + WIFI_LOG(WIFI_INFO, "There is no hidden APs."); + return WIFI_ERROR_NONE; } - for (;i < hidden_profile_iterator.count;i++) { + for (i =0; i < hidden_profile_iterator.count; i++) { rv = callback((wifi_ap_h)(&hidden_profile_iterator.profiles[i]), user_data); if (rv == false) break; } - return true; + return WIFI_ERROR_NONE; } int _wifi_libnet_open_profile(wifi_ap_h ap_h, wifi_connected_cb callback, void *user_data) { int rv; bool valid_profile; - net_profile_name_t profile_name; 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); + _wifi_libnet_check_profile_name_validity(ap_info->ProfileName); if (valid_profile == true && ap_info->Favourite) - rv = net_open_connection_with_profile(profile_name.ProfileName); + rv = net_open_connection_with_profile(ap_info->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); + rv = net_open_connection_with_profile(ap_info->ProfileName); else rv = __libnet_connect_with_wifi_info(ap_info); - if (rv != NET_ERR_NONE) + rv = __libnet_convert_to_ap_error_type(rv); + if (rv == WIFI_ERROR_NONE) + __libnet_set_connected_cb(callback, user_data); + + return rv; +} + +int _wifi_libnet_close_profile(wifi_ap_h ap_h, wifi_disconnected_cb callback, void *user_data) +{ + int rv; + net_profile_info_t *ap_info = ap_h; + + rv = net_close_connection(ap_info->ProfileName); + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) return WIFI_ERROR_OPERATION_FAILED; - __libnet_set_connected_cb(callback, user_data); + __libnet_set_disconnected_cb(callback, user_data); return WIFI_ERROR_NONE; } -int _wifi_libnet_close_profile(wifi_ap_h ap_h, wifi_disconnected_cb callback, void *user_data) +int _wifi_libnet_connect_with_wps_pbc(wifi_ap_h ap_h, wifi_connected_cb callback, void *user_data) { + int rv; net_profile_info_t *ap_info = ap_h; - net_profile_name_t profile_name; + net_wifi_wps_info_t wps_info; + 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; - if (net_close_connection(profile_name.ProfileName) != NET_ERR_NONE) + rv = net_wifi_enroll_wps(ap_info->ProfileName, &wps_info); + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) return WIFI_ERROR_OPERATION_FAILED; - __libnet_set_disconnected_cb(callback, user_data); + __libnet_set_connected_cb(callback, user_data); return WIFI_ERROR_NONE; } -int _wifi_libnet_connect_with_wps(wifi_ap_h ap_h, wifi_connected_cb callback, void *user_data) +int _wifi_libnet_connect_with_wps_pin(wifi_ap_h ap_h, const char *pin, + wifi_connected_cb callback, void *user_data) { + int rv; 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); + if (ap_info == NULL) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); + return WIFI_ERROR_INVALID_PARAMETER; + } - wps_info.type = WIFI_WPS_PBC; + wps_info.type = WIFI_WPS_PIN; + g_strlcpy(wps_info.pin, pin, NET_WLAN_MAX_WPSPIN_LEN + 1); - if (net_wifi_enroll_wps(profile_name.ProfileName, &wps_info) != NET_ERR_NONE) + rv = net_wifi_enroll_wps(ap_info->ProfileName, &wps_info); + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) return WIFI_ERROR_OPERATION_FAILED; __libnet_set_connected_cb(callback, user_data); @@ -844,26 +955,35 @@ int _wifi_libnet_connect_with_wps(wifi_ap_h ap_h, wifi_connected_cb callback, vo 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); + if (ap_info == NULL) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); + return WIFI_ERROR_INVALID_PARAMETER; + } - rv = net_delete_profile(profile_name.ProfileName); - if (rv != NET_ERR_NONE) + rv = net_delete_profile(ap_info->ProfileName); + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) return WIFI_ERROR_OPERATION_FAILED; + ap_info->Favourite = (char)FALSE; + 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) + if (wifi_callbacks.device_state_cb != NULL) return WIFI_ERROR_INVALID_OPERATION; wifi_callbacks.device_state_cb = callback; wifi_callbacks.device_state_user_data = user_data; + WIFI_LOG(WIFI_INFO, "Wi-Fi registered device state changed callback"); + return WIFI_ERROR_NONE; } @@ -880,7 +1000,7 @@ int _wifi_unset_power_on_off_cb(void) int _wifi_set_background_scan_cb(wifi_scan_finished_cb callback, void *user_data) { - if (wifi_callbacks.bg_scan_cb) + if (wifi_callbacks.bg_scan_cb != NULL) return WIFI_ERROR_INVALID_OPERATION; wifi_callbacks.bg_scan_cb = callback; @@ -902,7 +1022,7 @@ int _wifi_unset_background_scan_cb(void) int _wifi_set_connection_state_cb(wifi_connection_state_changed_cb callback, void *user_data) { - if (wifi_callbacks.connection_state_cb) + if (wifi_callbacks.connection_state_cb != NULL) return WIFI_ERROR_INVALID_OPERATION; wifi_callbacks.connection_state_cb = callback; @@ -924,8 +1044,36 @@ int _wifi_unset_connection_state_cb() int _wifi_update_ap_info(net_profile_info_t *ap_info) { - if (net_modify_profile(ap_info->ProfileName, ap_info) != NET_ERR_NONE) + int rv = NET_ERR_NONE; + rv = net_modify_profile(ap_info->ProfileName, ap_info); + + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) return WIFI_ERROR_OPERATION_FAILED; return WIFI_ERROR_NONE; } + +void _wifi_callback_cleanup(void) +{ + GSList *cur = managed_idler_list; + GSource *src; + struct managed_idle_data *data; + + while (cur) { + GSList *next = cur->next; + data = (struct managed_idle_data *)cur->data; + + src = g_main_context_find_source_by_id(g_main_context_default(), data->id); + if (src) { + g_source_destroy(src); + cur = managed_idler_list; + } else + cur = next; + } + + g_slist_free(managed_idler_list); + managed_idler_list = NULL; +} diff --git a/src/net_wifi.c b/src/net_wifi.c index 97b87be..e3204c2 100755 --- a/src/net_wifi.c +++ b/src/net_wifi.c @@ -33,39 +33,44 @@ static void __rssi_level_changed_cb(keynode_t *node, void *user_data) EXPORT_API int wifi_initialize(void) { - if (is_init) { - WIFI_LOG(WIFI_ERROR, "Already initialized\n"); + int rv; + + if (_wifi_is_init() == true) { + WIFI_LOG(WIFI_ERROR, "Already initialized"); return WIFI_ERROR_INVALID_OPERATION; } - if (_wifi_libnet_init() == false) { - WIFI_LOG(WIFI_ERROR, "Init failed!\n"); + rv = _wifi_libnet_init(); + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_ERROR_PERMISSION_DENIED; + } + else if (rv != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, "Init failed[%d]", rv); return WIFI_ERROR_OPERATION_FAILED; } - is_init = true; - - WIFI_LOG(WIFI_INFO, "Wi-Fi successfully initialized!\n"); + WIFI_LOG(WIFI_INFO, "Wi-Fi successfully initialized"); return WIFI_ERROR_NONE; } EXPORT_API int wifi_deinitialize(void) { - if (is_init == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized\n"); + if (_wifi_is_init() == false) { + WIFI_LOG(WIFI_ERROR, "Not initialized"); return WIFI_ERROR_INVALID_OPERATION; } if (_wifi_libnet_deinit() == false) { - WIFI_LOG(WIFI_ERROR, "Deinit failed!\n"); + WIFI_LOG(WIFI_ERROR, "Deinit failed"); return WIFI_ERROR_OPERATION_FAILED; } - is_init = false; wifi_unset_rssi_level_changed_cb(); + _wifi_callback_cleanup(); - WIFI_LOG(WIFI_INFO, "Wi-Fi successfully de-initialized!\n"); + WIFI_LOG(WIFI_INFO, "Wi-Fi successfully de-initialized"); return WIFI_ERROR_NONE; } @@ -74,14 +79,31 @@ 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"); + if (_wifi_is_init() == false) { + WIFI_LOG(WIFI_ERROR, "Not initialized"); + return WIFI_ERROR_INVALID_OPERATION; + } + + rv = _wifi_activate(callback, FALSE, user_data); + if (rv != WIFI_ERROR_NONE) + WIFI_LOG(WIFI_ERROR, "Failed to activate Wi-Fi[%d]", rv); + + return rv; +} + +EXPORT_API int wifi_activate_with_wifi_picker_tested( + wifi_activated_cb callback, void* user_data) +{ + int rv; + + if (_wifi_is_init() == false) { + WIFI_LOG(WIFI_ERROR, "Not initialized"); return WIFI_ERROR_INVALID_OPERATION; } - rv = _wifi_activate(callback, user_data); + rv = _wifi_activate(callback, TRUE, user_data); if (rv != WIFI_ERROR_NONE) - WIFI_LOG(WIFI_ERROR, "Error!! Wi-Fi Activation failed.\n"); + WIFI_LOG(WIFI_ERROR, "Failed to activate Wi-Fi[%d]", rv); return rv; } @@ -90,76 +112,60 @@ 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"); + if (_wifi_is_init() == false) { + WIFI_LOG(WIFI_ERROR, "Not initialized"); return WIFI_ERROR_INVALID_OPERATION; } rv = _wifi_deactivate(callback, user_data); if (rv != WIFI_ERROR_NONE) - WIFI_LOG(WIFI_ERROR, "Error!! Wi-Fi Deactivation failed.\n"); + WIFI_LOG(WIFI_ERROR, "Wi-Fi deactivation failed"); return rv; } EXPORT_API int wifi_is_activated(bool* activated) { + int rv; wifi_device_state_e device_state; if (activated == NULL) { - WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); 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); + rv = _wifi_libnet_get_wifi_device_state(&device_state); + if (rv == WIFI_ERROR_NONE) { 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; + return rv; } EXPORT_API int wifi_get_mac_address(char** mac_address) { if (mac_address == NULL) { - WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); 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"); + WIFI_LOG(WIFI_ERROR, "vconf_get_str Failed"); 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -171,18 +177,18 @@ 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } - if (is_init == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized\n"); + if (_wifi_is_init() == false) { + WIFI_LOG(WIFI_ERROR, "Not initialized"); 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"); + WIFI_LOG(WIFI_ERROR, "Wi-Fi scan failed"); return rv; } @@ -213,12 +219,12 @@ EXPORT_API int wifi_get_connected_ap(wifi_ap_h* ap) int rv; if (ap == NULL) { - WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } rv = _wifi_libnet_get_connected_profile(ap); - WIFI_LOG(WIFI_INFO, "Connected AP %p, rv %d\n", *ap, rv); + WIFI_LOG(WIFI_INFO, "Connected AP %p, rv %d", *ap, rv); return rv; } @@ -226,14 +232,11 @@ EXPORT_API int wifi_get_connected_ap(wifi_ap_h* ap) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } - if (_wifi_libnet_foreach_found_aps(callback, user_data) == false) - return WIFI_ERROR_OPERATION_FAILED; - - return WIFI_ERROR_NONE; + return _wifi_libnet_foreach_found_aps(callback, user_data); } EXPORT_API int wifi_foreach_found_hidden_aps(wifi_found_ap_cb callback, void* user_data) @@ -252,15 +255,10 @@ EXPORT_API int wifi_foreach_found_hidden_aps(wifi_found_ap_cb callback, void* us 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); 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); } @@ -281,43 +279,73 @@ EXPORT_API int wifi_disconnect(wifi_ap_h ap, wifi_disconnected_cb callback, void EXPORT_API int wifi_connect_by_wps_pbc(wifi_ap_h ap, wifi_connected_cb callback, void* user_data) { + if (_wifi_is_init() == false) { + WIFI_LOG(WIFI_ERROR, "Not initialized"); + return WIFI_ERROR_INVALID_OPERATION; + } + if (_wifi_libnet_check_ap_validity(ap) == false) { - WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } - if (is_init == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized\n"); + return _wifi_libnet_connect_with_wps_pbc(ap, callback, user_data); +} + +EXPORT_API int wifi_connect_by_wps_pin(wifi_ap_h ap, const char *pin, wifi_connected_cb callback, void* user_data) +{ + if (_wifi_is_init() == false) { + WIFI_LOG(WIFI_ERROR, "Not initialized"); return WIFI_ERROR_INVALID_OPERATION; } - return _wifi_libnet_connect_with_wps(ap, callback, user_data); + if (_wifi_libnet_check_ap_validity(ap) == false) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); + return WIFI_ERROR_INVALID_PARAMETER; + } + + if (NULL == pin || 0 == strlen(pin) || strlen(pin) > NET_WLAN_MAX_WPSPIN_LEN) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); + return WIFI_ERROR_INVALID_PARAMETER; + } + + return _wifi_libnet_connect_with_wps_pin(ap, pin, callback, user_data); } EXPORT_API int wifi_forget_ap(wifi_ap_h ap) { + if (_wifi_is_init() == false) { + WIFI_LOG(WIFI_ERROR, "Not initialized"); + return WIFI_ERROR_INVALID_OPERATION; + } + if (_wifi_libnet_check_ap_validity(ap) == false) { - WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); 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_get_connection_state(wifi_connection_state_e* connection_state) +{ + if (connection_state == NULL) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); + return WIFI_ERROR_INVALID_PARAMETER; } - return _wifi_libnet_forget_ap(ap); + return _wifi_libnet_get_wifi_state(connection_state); } 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } - if (is_init == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized\n"); + if (_wifi_is_init() == false) { + WIFI_LOG(WIFI_ERROR, "Not initialized"); return WIFI_ERROR_INVALID_OPERATION; } @@ -332,12 +360,12 @@ EXPORT_API int wifi_unset_device_state_changed_cb(void) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } - if (is_init == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized\n"); + if (_wifi_is_init() == false) { + WIFI_LOG(WIFI_ERROR, "Not initialized"); return WIFI_ERROR_INVALID_OPERATION; } @@ -352,12 +380,12 @@ EXPORT_API int wifi_unset_background_scan_cb(void) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } - if (is_init == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized\n"); + if (_wifi_is_init() == false) { + WIFI_LOG(WIFI_ERROR, "Not initialized"); return WIFI_ERROR_INVALID_OPERATION; } @@ -372,7 +400,7 @@ EXPORT_API int wifi_unset_connection_state_changed_cb(void) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } diff --git a/src/net_wifi_ap.c b/src/net_wifi_ap.c index c31cd4a..b66b651 100755 --- a/src/net_wifi_ap.c +++ b/src/net_wifi_ap.c @@ -45,6 +45,100 @@ static void __wifi_init_ap(net_profile_info_t *profile_info, const char *essid) g_strlcpy(profile_info->ProfileInfo.Wlan.essid, essid, NET_WLAN_ESSID_LEN+1); } +static char *__wifi_create_profile_name(const char *ssid, const int net_mode, const int sec_mode) +{ + char *buf = NULL; + char *pbuf = NULL; + const char *hidden_str = "hidden"; + char buf_tmp[32] = { 0, }; + int i; + int ssid_len = 0; + int actual_len = 0; + const char *mode = "managed"; + char *g_sec = NULL; + + if (net_mode == NETPM_WLAN_CONNMODE_ADHOC) { + WIFI_LOG(WIFI_ERROR, "wlan_mode is adhoc"); + return NULL; + } + + switch (sec_mode) { + case WLAN_SEC_MODE_NONE: + g_sec = "none"; + break; + case WLAN_SEC_MODE_WEP: + g_sec = "wep"; + break; + case WLAN_SEC_MODE_WPA_PSK: + case WLAN_SEC_MODE_WPA2_PSK: + g_sec = "psk"; + break; + case WLAN_SEC_MODE_IEEE8021X: + g_sec = "ieee8021x"; + break; + default: + WIFI_LOG(WIFI_ERROR, "Invalid security type"); + return NULL; + } + + if (NULL != ssid) { + ssid_len = strlen(ssid); + actual_len = ssid_len * 2; + } else { + ssid_len = strlen(hidden_str); + actual_len = ssid_len; + } + + buf = g_try_malloc0(actual_len + strlen(mode) + strlen(g_sec) + 3); + if (buf == NULL) + return NULL; + + if (NULL != ssid) { + pbuf = buf; + + for (i = 0; i < ssid_len; i++) { + g_snprintf(pbuf, 3, "%02x", ssid[i]); + pbuf += 2; + } + } else + g_strlcat(buf, hidden_str, + actual_len + strlen(mode) + strlen(g_sec) + 3); + + g_snprintf(buf_tmp, 32, "_%s_%s", mode, g_sec); + g_strlcat(buf, buf_tmp, + actual_len + strlen(mode) + strlen(g_sec) + 3); + + WIFI_LOG(WIFI_INFO, "Profile name: %s", buf); + + return buf; +} + +static bool _wifi_set_profile_name_to_ap(net_profile_info_t *ap_info) +{ + char *profile_name = NULL; + + if (ap_info == NULL) { + WIFI_LOG(WIFI_ERROR, "profile_info is NULL"); + return false; + } + + profile_name = __wifi_create_profile_name( + ap_info->ProfileInfo.Wlan.essid, + ap_info->ProfileInfo.Wlan.wlan_mode, + ap_info->ProfileInfo.Wlan.security_info.sec_mode); + if (profile_name == NULL) { + WIFI_LOG(WIFI_ERROR, "Failed to make a group name"); + return false; + } + + g_strlcpy(ap_info->ProfileInfo.Wlan.net_info.ProfileName, + profile_name, NET_PROFILE_NAME_LEN_MAX); + + g_free(profile_name); + + return true; +} + wifi_connection_state_e _wifi_convert_to_ap_state(net_state_type_t state) { wifi_connection_state_e ap_state; @@ -54,8 +148,10 @@ wifi_connection_state_e _wifi_convert_to_ap_state(net_state_type_t state) case NET_STATE_TYPE_READY: ap_state = WIFI_CONNECTION_STATE_CONNECTED; break; - case NET_STATE_TYPE_IDLE: case NET_STATE_TYPE_FAILURE: + ap_state = WIFI_CONNECTION_STATE_FAILURE; + break; + case NET_STATE_TYPE_IDLE: case NET_STATE_TYPE_DISCONNECT: ap_state = WIFI_CONNECTION_STATE_DISCONNECTED; break; @@ -67,6 +163,7 @@ wifi_connection_state_e _wifi_convert_to_ap_state(net_state_type_t state) break; default: ap_state = -1; + break; } return ap_state; @@ -76,7 +173,7 @@ wifi_connection_state_e _wifi_convert_to_ap_state(net_state_type_t state) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -95,7 +192,7 @@ EXPORT_API int wifi_ap_create(const char* essid, wifi_ap_h* ap) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -107,7 +204,7 @@ EXPORT_API int wifi_ap_destroy(wifi_ap_h ap) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -128,8 +225,18 @@ EXPORT_API int wifi_ap_refresh(wifi_ap_h ap) net_profile_info_t ap_info_local; 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"); + if (_wifi_libnet_check_ap_validity(ap) == false) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); + return WIFI_ERROR_INVALID_PARAMETER; + } + + int rv = NET_ERR_NONE; + rv = net_get_profile_info(ap_info->ProfileName, &ap_info_local); + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, "Failed to getprofile_info"); return WIFI_ERROR_OPERATION_FAILED; } @@ -142,7 +249,7 @@ EXPORT_API int wifi_ap_refresh(wifi_ap_h ap) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -157,7 +264,7 @@ EXPORT_API int wifi_ap_get_essid(wifi_ap_h ap, char** essid) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -172,12 +279,12 @@ EXPORT_API int wifi_ap_get_bssid(wifi_ap_h ap, char** bssid) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } net_profile_info_t *profile_info = ap; - *rssi = (int)profile_info->ProfileInfo.Wlan.Strength; + *rssi = (int)(profile_info->ProfileInfo.Wlan.Strength - 120); return WIFI_ERROR_NONE; } @@ -185,7 +292,7 @@ EXPORT_API int wifi_ap_get_rssi(wifi_ap_h ap, int* rssi) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -198,7 +305,7 @@ EXPORT_API int wifi_ap_get_frequency(wifi_ap_h ap, int* frequency) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -211,7 +318,7 @@ EXPORT_API int wifi_ap_get_max_speed(wifi_ap_h ap, int* max_speed) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -228,7 +335,7 @@ EXPORT_API int wifi_ap_is_favorite(wifi_ap_h ap, bool* favorite) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -248,12 +355,12 @@ EXPORT_API int wifi_ap_get_ip_config_type(wifi_ap_h ap, wifi_address_family_e ad (address_family != WIFI_ADDRESS_FAMILY_IPV4 && address_family != WIFI_ADDRESS_FAMILY_IPV6) || type == NULL) { - WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } if (address_family == WIFI_ADDRESS_FAMILY_IPV6) { - WIFI_LOG(WIFI_ERROR, "Not supported yet\n"); + WIFI_LOG(WIFI_ERROR, "Not supported yet"); return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; } @@ -287,12 +394,12 @@ EXPORT_API int wifi_ap_set_ip_config_type(wifi_ap_h ap, wifi_address_family_e ad 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } if (address_family == WIFI_ADDRESS_FAMILY_IPV6) { - WIFI_LOG(WIFI_ERROR, "Not supported yet\n"); + WIFI_LOG(WIFI_ERROR, "Not supported yet"); return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; } @@ -330,12 +437,12 @@ EXPORT_API int wifi_ap_get_ip_address(wifi_ap_h ap, wifi_address_family_e addres (address_family != WIFI_ADDRESS_FAMILY_IPV4 && address_family != WIFI_ADDRESS_FAMILY_IPV6) || ip_address == NULL) { - WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } if (address_family == WIFI_ADDRESS_FAMILY_IPV6) { - WIFI_LOG(WIFI_ERROR, "Not supported yet\n"); + WIFI_LOG(WIFI_ERROR, "Not supported yet"); return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; } @@ -352,12 +459,12 @@ EXPORT_API int wifi_ap_set_ip_address(wifi_ap_h ap, wifi_address_family_e addres 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } if (address_family == WIFI_ADDRESS_FAMILY_IPV6) { - WIFI_LOG(WIFI_ERROR, "Not supported yet\n"); + WIFI_LOG(WIFI_ERROR, "Not supported yet"); return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; } @@ -380,12 +487,12 @@ EXPORT_API int wifi_ap_get_subnet_mask(wifi_ap_h ap, wifi_address_family_e addre (address_family != WIFI_ADDRESS_FAMILY_IPV4 && address_family != WIFI_ADDRESS_FAMILY_IPV6) || subnet_mask == NULL) { - WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } if (address_family == WIFI_ADDRESS_FAMILY_IPV6) { - WIFI_LOG(WIFI_ERROR, "Not supported yet\n"); + WIFI_LOG(WIFI_ERROR, "Not supported yet"); return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; } @@ -402,12 +509,12 @@ EXPORT_API int wifi_ap_set_subnet_mask(wifi_ap_h ap, wifi_address_family_e addre 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } if (address_family == WIFI_ADDRESS_FAMILY_IPV6) { - WIFI_LOG(WIFI_ERROR, "Not supported yet\n"); + WIFI_LOG(WIFI_ERROR, "Not supported yet"); return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; } @@ -430,12 +537,12 @@ EXPORT_API int wifi_ap_get_gateway_address(wifi_ap_h ap, wifi_address_family_e a (address_family != WIFI_ADDRESS_FAMILY_IPV4 && address_family != WIFI_ADDRESS_FAMILY_IPV6) || gateway_address == NULL) { - WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } if (address_family == WIFI_ADDRESS_FAMILY_IPV6) { - WIFI_LOG(WIFI_ERROR, "Not supported yet\n"); + WIFI_LOG(WIFI_ERROR, "Not supported yet"); return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; } @@ -452,12 +559,12 @@ EXPORT_API int wifi_ap_set_gateway_address(wifi_ap_h ap, wifi_address_family_e a 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } if (address_family == WIFI_ADDRESS_FAMILY_IPV6) { - WIFI_LOG(WIFI_ERROR, "Not supported yet\n"); + WIFI_LOG(WIFI_ERROR, "Not supported yet"); return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; } @@ -480,12 +587,12 @@ EXPORT_API int wifi_ap_get_proxy_address(wifi_ap_h ap, wifi_address_family_e add (address_family != WIFI_ADDRESS_FAMILY_IPV4 && address_family != WIFI_ADDRESS_FAMILY_IPV6) || proxy_address == NULL) { - WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } if (address_family == WIFI_ADDRESS_FAMILY_IPV6) { - WIFI_LOG(WIFI_ERROR, "Not supported yet\n"); + WIFI_LOG(WIFI_ERROR, "Not supported yet"); return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; } @@ -502,12 +609,12 @@ EXPORT_API int wifi_ap_set_proxy_address(wifi_ap_h ap, wifi_address_family_e add 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } if (address_family == WIFI_ADDRESS_FAMILY_IPV6) { - WIFI_LOG(WIFI_ERROR, "Not supported yet\n"); + WIFI_LOG(WIFI_ERROR, "Not supported yet"); return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; } @@ -528,7 +635,7 @@ EXPORT_API int wifi_ap_set_proxy_address(wifi_ap_h ap, wifi_address_family_e add 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -557,7 +664,7 @@ EXPORT_API int wifi_ap_get_proxy_type(wifi_ap_h ap, wifi_proxy_type_e* type) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -600,12 +707,12 @@ EXPORT_API int wifi_ap_get_dns_address(wifi_ap_h ap, int order, wifi_address_fam dns_address == NULL || order <= 0 || order > NET_DNS_ADDR_MAX) { - WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } if (address_family == WIFI_ADDRESS_FAMILY_IPV6) { - WIFI_LOG(WIFI_ERROR, "Not supported yet\n"); + WIFI_LOG(WIFI_ERROR, "Not supported yet"); return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; } @@ -625,12 +732,12 @@ EXPORT_API int wifi_ap_set_dns_address(wifi_ap_h ap, int order, wifi_address_fam address_family != WIFI_ADDRESS_FAMILY_IPV6) || order <= 0 || order > NET_DNS_ADDR_MAX) { - WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } if (address_family == WIFI_ADDRESS_FAMILY_IPV6) { - WIFI_LOG(WIFI_ERROR, "Not supported yet\n"); + WIFI_LOG(WIFI_ERROR, "Not supported yet"); return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; } @@ -654,7 +761,7 @@ EXPORT_API int wifi_ap_set_dns_address(wifi_ap_h ap, int order, wifi_address_fam 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -686,7 +793,7 @@ EXPORT_API int wifi_ap_get_security_type(wifi_ap_h ap, wifi_security_type_e* typ 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -712,13 +819,15 @@ EXPORT_API int wifi_ap_set_security_type(wifi_ap_h ap, wifi_security_type_e type return WIFI_ERROR_INVALID_PARAMETER; } + _wifi_set_profile_name_to_ap(profile_info); + 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -750,7 +859,7 @@ EXPORT_API int wifi_ap_get_encryption_type(wifi_ap_h ap, wifi_encryption_type_e* 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -782,7 +891,7 @@ EXPORT_API int wifi_ap_set_encryption_type(wifi_ap_h ap, wifi_encryption_type_e 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -813,7 +922,7 @@ EXPORT_API int wifi_ap_is_passphrase_required(wifi_ap_h ap, bool* required) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -841,7 +950,7 @@ EXPORT_API int wifi_ap_set_passphrase(wifi_ap_h ap, const char* passphrase) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -859,7 +968,7 @@ EXPORT_API int wifi_ap_is_wps_supported(wifi_ap_h ap, bool* supported) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -881,7 +990,7 @@ EXPORT_API int wifi_ap_set_eap_passphrase(wifi_ap_h ap, const char* user_name, c 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -904,12 +1013,14 @@ EXPORT_API int wifi_ap_get_eap_passphrase(wifi_ap_h ap, char** user_name, bool* EXPORT_API int wifi_ap_get_eap_ca_cert_file(wifi_ap_h ap, char** file) { + net_profile_info_t *profile_info = NULL; + if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) { - WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } - net_profile_info_t *profile_info = ap; + profile_info = (net_profile_info_t *)ap; if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) return WIFI_ERROR_INVALID_OPERATION; @@ -922,12 +1033,14 @@ EXPORT_API int wifi_ap_get_eap_ca_cert_file(wifi_ap_h ap, char** file) EXPORT_API int wifi_ap_set_eap_ca_cert_file(wifi_ap_h ap, const char* file) { + net_profile_info_t *profile_info = NULL; + if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) { - WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } - net_profile_info_t *profile_info = ap; + profile_info = (net_profile_info_t *)ap; if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) return WIFI_ERROR_INVALID_OPERATION; @@ -939,12 +1052,14 @@ EXPORT_API int wifi_ap_set_eap_ca_cert_file(wifi_ap_h ap, const char* file) EXPORT_API int wifi_ap_get_eap_client_cert_file(wifi_ap_h ap, char** file) { + net_profile_info_t *profile_info = NULL; + if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) { - WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } - net_profile_info_t *profile_info = ap; + profile_info = (net_profile_info_t *)ap; if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) return WIFI_ERROR_INVALID_OPERATION; @@ -957,12 +1072,14 @@ EXPORT_API int wifi_ap_get_eap_client_cert_file(wifi_ap_h ap, char** file) EXPORT_API int wifi_ap_set_eap_client_cert_file(wifi_ap_h ap, const char* file) { + net_profile_info_t *profile_info = NULL; + if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) { - WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } - net_profile_info_t *profile_info = ap; + profile_info = (net_profile_info_t *)ap; if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) return WIFI_ERROR_INVALID_OPERATION; @@ -975,7 +1092,7 @@ EXPORT_API int wifi_ap_set_eap_client_cert_file(wifi_ap_h ap, const char* file) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -993,7 +1110,7 @@ EXPORT_API int wifi_ap_get_eap_private_key_file(wifi_ap_h ap, char** file) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -1015,7 +1132,7 @@ EXPORT_API int wifi_ap_set_eap_private_key_info(wifi_ap_h ap, const char* file, 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -1049,7 +1166,7 @@ EXPORT_API int wifi_ap_get_eap_type(wifi_ap_h ap, wifi_eap_type_e* type) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -1083,7 +1200,7 @@ EXPORT_API int wifi_ap_set_eap_type(wifi_ap_h ap, wifi_eap_type_e type) 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } @@ -1120,7 +1237,7 @@ EXPORT_API int wifi_ap_get_eap_auth_type(wifi_ap_h ap, wifi_eap_auth_type_e* typ 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"); + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_ERROR_INVALID_PARAMETER; } diff --git a/test/wifi_test.c b/test/wifi_test.c index 2ed97a9..7a5a792 100644 --- a/test/wifi_test.c +++ b/test/wifi_test.c @@ -64,6 +64,10 @@ static const char *__test_convert_error_to_string(wifi_error_e err_type) return "NO_REPLY"; case WIFI_ERROR_SECURITY_RESTRICTED: return "SECURITY_RESTRICTED"; + case WIFI_ERROR_PERMISSION_DENIED: + return "PERMISSION_DENIED"; + case WIFI_ERROR_NOT_SUPPORTED: + return "NOT_SUPPORTED"; } return "UNKNOWN"; @@ -204,6 +208,8 @@ static void __test_rssi_level_callback(wifi_rssi_level_e rssi_level, void* user_ static const char* __test_print_state(wifi_connection_state_e state) { switch (state) { + case WIFI_CONNECTION_STATE_FAILURE: + return "Failure"; case WIFI_CONNECTION_STATE_DISCONNECTED: return "Disconnected"; case WIFI_CONNECTION_STATE_ASSOCIATION: |