--- /dev/null
+CMakeCache.txt
+*/CMakeFiles/*
+*.cmake
+CMakeFiles*
+*.a
+*.so
+Testing
+cmake.depends
+cmake.check_depends
+cmake.check_cache
+core
+core.*
+gmon.out
+install_manifest.txt
+doc/html/*
+*~
+.kdev_include_paths
+src.kdev4
+.cproject
+.project
+tet_captured
+tet_lock
+*.pc
+Makefile
+*-test
+TC/config
+samples/.metadata
+TC/results/
+TC/testcase/wifi_test
+build-stamp
+cmake_build_tmp/
+config.cfg
+configure-stamp
+debian/capi-network-wifi-dbg.debhelper.log
+debian/capi-network-wifi-dbg.substvars
+debian/capi-network-wifi-dbg/
+debian/capi-network-wifi-dev.debhelper.log
+debian/capi-network-wifi-dev.substvars
+debian/capi-network-wifi-dev/
+debian/debhelper.log
+debian/files
+debian/substvars
+debian/tmp/
+debian/capi-network-wifi.debhelper.log
+debian/capi-network-wifi.postinst.debhelper
+debian/capi-network-wifi.postrm.debhelper
+debian/capi-network-wifi.substvars
+debian/capi-network-wifi/
+test/wifi_test
+test/wifi_test_regress
+++ /dev/null
-JaeHyun Kim <jeik01.kim@samsung.com>
-ByungWoo Lee <bw1212.lee@samsung.com>
SET(INC_DIR include)
INCLUDE_DIRECTORIES(${INC_DIR})
-SET(dependents "dlog vconf capi-base-common glib-2.0 network")
+SET(dependents "dlog vconf capi-base-common glib-2.0 network capi-system-info")
SET(pc_dependents "capi-base-common")
+IF(TIZEN_DUALSIM_ENABLE)
+ ADD_DEFINITIONS(-DTIZEN_DUALSIM_ENABLE)
+ENDIF(TIZEN_DUALSIM_ENABLE)
+IF(TIZEN_WEARABLE)
+ ADD_DEFINITIONS(-DTIZEN_WEARABLE)
+ENDIF(TIZEN_WEARABLE)
+IF(TIZEN_MOBILE)
+ ADD_DEFINITIONS(-DTIZEN_MOBILE)
+ENDIF(TIZEN_MOBILE)
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_name} REQUIRED ${dependents})
+pkg_check_modules(${fw_name} REQUIRED ${dependents} ${APPFW_REQUIRED_PKGS})
FOREACH(flag ${${fw_name}_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -fvisibility=hidden")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
IF("${ARCH}" STREQUAL "arm")
)
ENDIF(UNIX)
-
-Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
Apache License
Version 2.0, January 2004
--- /dev/null
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE file for Apache License terms and conditions.
--- /dev/null
+<manifest>
+ <assign>
+ <filesystem path="/usr/bin/wifi_test" exec_label="connman"/>
+ </assign>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
Requires: @PC_REQUIRED@
Libs: -L${libdir} @PC_LDFLAGS@
Cflags: -I${includedir}
-
+++ /dev/null
-/usr/include/*
-/usr/include/*/*
-/usr/lib/pkgconfig/*.pc
-
+++ /dev/null
-/usr/lib/lib*.so*
+++ /dev/null
-capi-network-wifi (0.1.1-2) unstable; urgency=low
-
- * Ad UTC files
- * Git: api/wifi
- * Tag: capi-network-wifi_0.1.1-2
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Wed, 04 Jul 2012 11:41:10 +0900
-
-capi-network-wifi (0.1.1-1) unstable; urgency=low
-
- * Add AP initialization functions for user creation
- * Git: api/wifi
- * Tag: capi-network-wifi_0.1.1-1
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Mon, 02 Jul 2012 11:01:10 +0900
-
-capi-network-wifi (0.1.1-0) unstable; urgency=low
-
- * Package implementation
- * Git: api/wifi
- * Tag: capi-network-wifi_0.1.1-0
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Mon, 21 May 2012 19:31:01 +0900
-
-capi-network-wifi (0.1.0-1) unstable; urgency=low
-
- * Initial Upload
- * Git: api/wifi
- * Tag: capi-network-wifi_0.1.0-1
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Mon, 09 Apr 2012 20:54:57 +0900
+++ /dev/null
-Source: capi-network-wifi
-Section: libs
-Priority: extra
-Maintainer: JaeHyun Kim <jeik01.kim@samsung.com>
-Build-Depends: debhelper (>= 5), dlog-dev, capi-base-common-dev, libvconf-dev, libglib2.0-dev, libdbus-glib-1-dev, libnetwork-dev
-
-Package: capi-network-wifi
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: Network Wi-Fi library in TIZEN C API
-
-Package: capi-network-wifi-dev
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, capi-network-wifi (= ${Source-Version}), capi-base-common-dev
-Description: Network Wi-Fi library in TIZEN C API (DEV)
-
-Package: capi-network-wifi-dbg
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, capi-network-wifi (= ${Source-Version})
-Description: Network Wi-Fi library in TIZEN C API (DBG)
-
+++ /dev/null
-#!/usr/bin/make -f
-
-CFLAGS = -Wall -g
-FULLVER ?= $(shell dpkg-parsechangelog | grep Version: | cut -d ' ' -f 2 | cut -d '-' -f 1)
-MAJORVER ?= $(shell echo $(FULLVER) | cut -d '.' -f 1)
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
- CFLAGS += -O0
-else
- CFLAGS += -O2
-endif
-CMAKE_ROOT_DIR ?= $(CURDIR)
-CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
- mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && cmake .. -DFULLVER=${FULLVER} -DMAJORVER=${MAJORVER}
- touch configure-stamp
-
-
-build: build-stamp
-build-stamp: configure-stamp
- dh_testdir
- cd $(CMAKE_BUILD_DIR) && $(MAKE)
- touch $@
-
-clean:
- cd $(CMAKE_ROOT_DIR)
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
- rm -f `find . -name *.pc`
- rm -rf $(CMAKE_BUILD_DIR)
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
-
- cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
-
-binary-indep: build install
-
-binary-arch: build install
- dh_testdir
- dh_testroot
- dh_installchangelogs
- dh_installdocs
- dh_installexamples
- dh_install --sourcedir=debian/tmp
- dh_installman
- dh_link
- dh_strip --dbg-package=capi-network-wifi-dbg
- dh_fixperms
- dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
-
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_NETWORK_WIFI_DOC_H__
+#define __TIZEN_NETWORK_WIFI_DOC_H__
+
+/**
+ * @defgroup CAPI_NETWORK_WIFI_MODULE Wi-Fi
+ * @brief The Wi-Fi API provides functions for managing Wi-Fi and monitoring the state of Wi-Fi.
+ * @ingroup CAPI_NETWORK_FRAMEWORK
+ *
+ * @section CAPI_NETWORK_WIFI_MODULE_HEADER Required Header
+ * \#include <wifi.h>
+ *
+ * @section CAPI_NETWORK_WIFI_MODULE_OVERVIEW Overview
+ * Wi-Fi allows your application to connect to a Wireless Local Area Network (WLAN) and to transfer data over the network.
+ * The Wi-Fi Manager enables your application to activate and deactivate a local Wi-Fi device, and to connect to a WLAN network
+ * in the infrastructure mode.
+ * @section CAPI_NETWORK_WIFI_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.wifi\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_WIFI_MANAGER_MODULE Wi-Fi Manager
+ * @brief The Wi-Fi API provides functions for managing Wi-Fi.
+ * @ingroup CAPI_NETWORK_WIFI_MODULE
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_MODULE_HEADER Required Header
+ * \#include <wifi.h>
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_MODULE_OVERVEW Overview
+ * The Wi-Fi Manager provides functions for managing Wi-Fi.
+ * Using the Wi-Fi Manager, you can implement features that allow the users of your application to:
+ * - Activate / Deactivate the Wi-Fi device
+ * - Connect to the access point
+ * - Scans the access points
+ * @section CAPI_NETWORK_WIFI_MANAGER_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.wifi\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_WIFI_MONITOR_MODULE Wi-Fi Monitor
+ * @brief The Wi-Fi API provides functions for monitoring the state of Wi-Fi.
+ * @ingroup CAPI_NETWORK_WIFI_MODULE
+ *
+ * @section CAPI_NETWORK_WIFI_MONITOR_MODULE_HEADER Required Header
+ * \#include <wifi.h>
+ *
+ * @section CAPI_NETWORK_WIFI_MONITOR_MODULE_OVERVIEW Overview
+ * The Wi-Fi Monitor allows monitoring the changes of Wi-Fi.
+ * @section CAPI_NETWORK_WIFI_MONITOR_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.wifi\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_WIFI_AP_MODULE AP
+ * @brief The Access Point API provides functions for managing the Access Point.
+ * @ingroup CAPI_NETWORK_WIFI_MANAGER_MODULE
+ *
+ * @section CAPI_NETWORK_WIFI_AP_MODULE Required Header
+ * \#include <wifi.h>
+ *
+ * @section CAPI_NETWORK_WIFI_AP_MODULE_OVERVIEW Overview
+ * The Access Point API provides functions for managing the Access Point. You need to create the @a ap handle for using the functions.
+ * You can use Wi-Fi information with the handle.
+ * @section CAPI_NETWORK_WIFI_AP_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.wifi\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_WIFI_AP_NETWORK_MODULE Network Information
+ * @brief The Connection Information API provides functions for managing the network information.
+ * @ingroup CAPI_NETWORK_WIFI_AP_MODULE
+ *
+ * @section CAPI_NETWORK_WIFI_AP_CONNECTION_MODULE Required Header
+ * \#include <wifi.h>
+ *
+ * @section CAPI_NETWORK_WIFI_AP_CONNECTION_MODULE_OVERVIEW Overview
+ * The Connection Information API provides functions for managing the network information. You can manage the network information using the functions.
+ * @section CAPI_NETWORK_WIFI_AP_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.wifi\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_WIFI_AP_SECURITY_MODULE Security Information
+ * @brief The Security Information API provides functions for managing the Security information.
+ * @ingroup CAPI_NETWORK_WIFI_AP_MODULE
+ *
+ * @section CAPI_NETWORK_WIFI_AP_SECURITY_MODULE Required Header
+ * \#include <wifi.h>
+ *
+ * @section CAPI_NETWORK_WIFI_AP_SECURITY_MODULE_OVERVIEW Overview
+ * The Security Information API provides functions for managing the Security information. You can manage the Security information using the functions.
+ * @section CAPI_NETWORK_WIFI_AP_SECURITY_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.wifi\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_WIFI_AP_SECURITY_EAP_MODULE EAP
+ * @brief The EAP API provides functions for managing the EAP information.
+ * @ingroup CAPI_NETWORK_WIFI_AP_SECURITY_MODULE
+ *
+ * @section CAPI_NETWORK_WIFI_AP_SECURITY_EAP_MODULE Required Header
+ * \#include <wifi.h>
+ *
+ * @section CAPI_NETWORK_WIFI_AP_SECURITY_EAP_MODULE_OVERVIEW Overview
+ * The EAP API provides functions for managing the EAP information. You can manage the EAP information using the functions.
+ * @section CAPI_NETWORK_WIFI_AP_SECURITY_EAP_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.wifi\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ *
+ */
+
+
+
+#endif /* __TIZEN_NETWORK_WIFI_DOC_H__ */
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-
-
-#ifndef __NET_CONNECTION_PRIVATE_H__ /* To prevent inclusion of a header file twice */
+#ifndef __NET_CONNECTION_PRIVATE_H__
#define __NET_CONNECTION_PRIVATE_H__
#include <dlog.h>
#include <network-cm-intf.h>
#include <network-wifi-intf.h>
-#include "wifi.h"
-
-#define TIZEN_NET_CONNECTION "net_wifi"
-
-#define WIFI_INFO LOG_VERBOSE
-#define WIFI_ERROR LOG_ERROR
-#define WIFI_WARN LOG_WARN
+#include <system_info.h>
-#define WIFI_LOG(log_level, format, args...) \
- SLOG(log_level,TIZEN_NET_CONNECTION, "[%s][Ln: %d] " format, __FILE__, __LINE__, ##args)
+#include "wifi.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
+#undef LOG_TAG
+#define LOG_TAG "CAPI_NETWORK_WIFI"
+
+#define WIFI_INFO 1
+#define WIFI_ERROR 2
+#define WIFI_WARN 3
+
+#define WIFI_FEATURE "http://tizen.org/feature/network.wifi"
+
+#define CHECK_FEATURE_SUPPORTED(feature_name) \
+ do { \
+ bool feature_supported = FALSE; \
+ if (!system_info_get_platform_bool(feature_name, &feature_supported)) { \
+ if (feature_supported == FALSE) { \
+ LOGE("%s feature is disabled", feature_name); \
+ return WIFI_ERROR_NOT_SUPPORTED; \
+ } \
+ } else { \
+ LOGE("Error - Feature getting from System Info"); \
+ return WIFI_ERROR_OPERATION_FAILED; \
+ } \
+ } while(0)
-bool _wifi_libnet_init(void);
+#define WIFI_LOG(log_level, format, args...) \
+ do { \
+ switch (log_level) { \
+ case WIFI_ERROR: \
+ LOGE(format, ## args); \
+ break; \
+ case WIFI_WARN: \
+ LOGW(format, ## args); \
+ break; \
+ default: \
+ LOGI(format, ## args); \
+ } \
+ } while(0)
+
+#define SECURE_WIFI_LOG(log_level, format, args...) \
+ do { \
+ switch (log_level) { \
+ case WIFI_ERROR: \
+ SECURE_LOGE(format, ## args); \
+ break; \
+ case WIFI_WARN: \
+ SECURE_LOGW(format, ## args); \
+ break; \
+ default: \
+ SECURE_LOGI(format, ## args); \
+ } \
+ } while(0)
+
+bool _wifi_is_init(void);
+
+int _wifi_libnet_init(void);
bool _wifi_libnet_deinit(void);
-int _wifi_activate(void);
-int _wifi_deactivate(void);
+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);
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_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_request(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);
+int _wifi_libnet_foreach_found_aps(wifi_found_ap_cb callback, void *user_data);
-int _wifi_libnet_open_profile(wifi_ap_h ap_h);
-int _wifi_libnet_close_profile(wifi_ap_h ap_h);
-int _wifi_libnet_connect_with_wps(wifi_ap_h ap_h, wifi_wps_type_e type, const char *pin);
+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_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);
int _wifi_unset_power_on_off_cb(void);
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 */
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef __TIZEN_NETWORK_WIFI_H__
#define __TIZEN_NETWORK_WIFI_H__
#endif
/**
-* @addtogroup CAPI_NETWORK_WIFI_MODULE
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
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_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;
/**
-* @brief The state of Wi-Fi connection
+* @}
*/
-typedef enum
-{
- WIFI_CONNECTION_STATE_CONNECTING = 0, /**< Trying to connect(association/configuration) */
- WIFI_CONNECTION_STATE_CONNECTED = 1, /**< Wi-Fi is connected to an AP(ready/online) */
- WIFI_CONNECTION_STATE_DISCONNECTING = 2, /**< Trying to disconnect(connected, but disconnecting process is on going) */
- WIFI_CONNECTION_STATE_DISCONNECTED = 3, /**< Wi-Fi is disconnected */
-} wifi_connection_state_e;
+
/**
-* @brief The WPS(Wi-Fi Protected Setup) type
+* @addtogroup CAPI_NETWORK_WIFI_MONITOR_MODULE
+* @{
*/
-typedef enum
-{
- WIFI_WPS_TYPE_PBC = 0, /**< PBC */
- WIFI_WPS_TYPE_PIN = 1, /**< PIN */
-} wifi_wps_type_e;
/**
-* @brief The state of Wi-Fi device
-*/
+ * @brief Enumeration for the state of the Wi-Fi device.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
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 RSSI level
-*/
+ * @brief Enumeration for the state of the Wi-Fi connection.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+typedef enum
+{
+ 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 Enumeration for the RSSI level.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
typedef enum
{
WIFI_RSSI_LEVEL_0 = 0, /**< level 0 */
*/
/**
-* @brief Net IP configuration Type
-*/
+ * @brief Enumeration for the Net IP configuration type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
typedef enum
{
WIFI_ADDRESS_FAMILY_IPV4 = 0, /**< IPV4 Address family */
} wifi_address_family_e;
/**
-* @brief This enumeration defines the proxy method type.
-*/
+ * @brief Enumeration for the proxy method type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
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;
/**
*/
/**
-* @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
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;
/**
*/
/**
-* @brief EAP type
-*/
+ * @brief Enumeration for EAP type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
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;
/**
*/
/**
-* @brief The handle for Wi-Fi access point.
-*/
+ * @brief The Wi-Fi access point handle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
typedef void* wifi_ap_h;
/**
/**
-* @addtogroup CAPI_NETWORK_WIFI_MODULE
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_MODULE
* @{
*/
/**
-* @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() 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 you get the found access point repeatedly.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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() or wifi_activate_with_wifi_picker_tested() is completed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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() or wifi_connect_by_wps_pin() are completed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 when the device state is changed.
-* @param[in] error_code The error code
-* @param[in] state The device state
-* @param[in] is_requested Indicates whether this change is requested by you
-* @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_error_e error_code, wifi_device_state_e state, bool is_requested, 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_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 connection state is changed.
-* @param[in] error_code The error code
-* @param[in] state The connection state
-* @param[in] ap The access point
-* @param[in] is_requested Indicates whether this change is requested by you
-* @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()
+* @addtogroup CAPI_NETWORK_WIFI_MONITOR_MODULE
+* @{
*/
-typedef void(*wifi_connection_state_changed_cb)(wifi_error_e error_code, wifi_connection_state_e state, wifi_ap_h ap, bool is_requested, 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 device state is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 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
-*/
-int wifi_initialize(void);
+ * @brief Called when the connection state is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 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
-*/
-int wifi_deinitialize(void);
+ * @brief Called when the RSSI of connected Wi-Fi is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 Activates Wi-Fi, asynchronously.
-* @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
+* @}
*/
-int wifi_activate(void);
+
/**
-* @brief Deactivates Wi-Fi, asynchronously.
-* @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
+* @addtogroup CAPI_NETWORK_WIFI_MODULE
+* @{
*/
-int wifi_deactivate(void);
/**
-* @brief Check whether Wi-Fi is activated
-* @param[out] is_requested 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
-*/
-int wifi_is_activated(bool* activated);
+ * @brief Initializes Wi-Fi.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 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
-*/
-int wifi_get_connection_state(wifi_connection_state_e* connection_state);
+ * @brief Deinitializes Wi-Fi.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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);
/**
-* @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
+* @}
*/
-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
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_MODULE
+* @{
*/
-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 Activates Wi-Fi asynchronously.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 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
-*/
-int wifi_get_connected_ap(wifi_ap_h* ap);
+ * @brief Gets the local MAC address.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 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 name of the network interface.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 Connects the access point, asynchronously.
-* @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
-* @post This function invokes wifi_connection_state_changed_cb().
-*/
-int wifi_connect(wifi_ap_h ap);
+ * @brief Starts scan asynchronously.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 Gets the handle of the connected access point.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 Disconnects the access point, asynchronously.
-* @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
-* @post This function invokes wifi_connection_state_changed_cb().
-*/
-int wifi_disconnect(wifi_ap_h ap);
-
-/**
-* @brief Connects the access point with WPS, asynchronously.
-* @param[in] ap The handle of access point
-* @param[in] type The type of WPS
-* @param[in] pin The pin value, which is valid only when type is WIFI_WPS_TYPE_PIN.
-* @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_connection_state_changed_cb().
-*/
-int wifi_connect_with_wps(wifi_ap_h ap, wifi_wps_type_e type, const char* pin);
-
-/**
-* @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 Gets the result of the scan.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 Connects the access point asynchronously.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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);
/**
-* @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 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
-*/
-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
+* @addtogroup CAPI_NETWORK_WIFI_MONITOR_MODULE
+* @{
*/
-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
-*/
-int wifi_unset_background_scan_cb(void);
+ * @brief Gets the connection state.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 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 device state is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 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
-*/
-int wifi_unset_connection_state_changed_cb(void);
+ * @brief Registers the callback called when the background scan is finished periodically.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 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 the callback called when the connection state is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 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 Registers callback called when the RSSI of connected Wi-Fi is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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);
/**
*/
/**
-* @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 Refreshes the access point information.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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);
+
+/**
* @}
*/
*/
/**
-* @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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.
-* @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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
-* @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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
-* @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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
-* @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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
-* @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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.
-* @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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
-* @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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);
/**
*/
/**
-* @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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.
-* @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 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
-*/
+ * @brief Checks whether the WPS(Wi-Fi Protected Setup) is supported or not.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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);
/**
*/
/**
-* @brief Sets the passphrase of EAP.
-* @param[in] ap The handle of access point
-* @param[in] user_name The user name
-* @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 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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 CA Certificate of EAP.
-* @remarks @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 passphrase of EAP.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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.
-* @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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.
-* @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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.
-* @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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);
/**
* @}
*/
-
#ifdef __cplusplus
}
#endif
-#sbs-git:api/wifi
-
-Name: capi-network-wifi
-Summary: Network Wi-Fi library in TIZEN C API
-Version: 0.1.1_2
-Release: 1
-Group: System/Network
-License: Apache License Version 2.0
-Source0: %{name}-%{version}.tar.gz
-BuildRequires: cmake
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(capi-base-common)
-BuildRequires: pkgconfig(network)
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
+Name: capi-network-wifi
+Summary: Network Wi-Fi library in TIZEN C API
+Version: 1.0.44
+Release: 1
+Group: System/Network
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(network)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: model-build-features
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%if "%{?tizen_profile_name}" == "wearable"
+BuildRequires: pkgconfig(capi-appfw-application)
+%endif
%description
Network Wi-Fi library in Tizen C API
%package devel
-Summary: Network Wi-Fi library in Tizen C API (Development)
-Group: System/Network
-Requires: %{name} = %{version}-%{release}
+Summary: Network Wi-Fi library in Tizen C API (Development)
+Group: System/Network
+Requires: %{name} = %{version}-%{release}
%description devel
Network Wi-Fi library in Tizen C API (Development)
-
%prep
%setup -q
%build
+export CFLAGS+=' -Wno-unused-local-typedefs'
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+cmake -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
+%if 0%{?model_build_feature_network_dsds} == 1
+ -DTIZEN_DUALSIM_ENABLE=1 \
+%endif
+%if "%{?tizen_profile_name}" == "wearable"
+ -DTIZEN_WEARABLE=1 \
+%elseif "%{?tizen_profile_name}" == "mobile"
+ -DTIZEN_MOBILE=1 \
+%endif
+ .
+make %{?_smp_mflags}
-make %{?jobs:-j%jobs}
%install
-rm -rf %{buildroot}
%make_install
+#License
+mkdir -p %{buildroot}%{_datadir}/license
+cp LICENSE %{buildroot}%{_datadir}/license/capi-network-wifi
+
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
-%{_libdir}/libcapi-network-wifi.so.*
+%manifest capi-network-wifi.manifest
+%attr(644,-,-) %{_libdir}/libcapi-network-wifi.so.*
+%{_datadir}/license/capi-network-wifi
+%{_bindir}/wifi_test
%files devel
%{_includedir}/network/*.h
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
+#include <glib.h>
+#include <ctype.h>
#include <stdio.h>
#include <string.h>
-#include <ctype.h>
-#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;
void *scan_request_user_data;
wifi_connection_state_changed_cb connection_state_cb;
void *connection_state_user_data;
+ wifi_activated_cb activated_cb;
+ void *activated_user_data;
+ wifi_deactivated_cb deactivated_cb;
+ void *deactivated_user_data;
+ wifi_connected_cb connected_cb;
+ void *connected_user_data;
+ wifi_disconnected_cb disconnected_cb;
+ void *disconnected_user_data;
};
struct _profile_list_s {
net_profile_info_t *profiles;
};
-static struct _wifi_cb_s wifi_callbacks = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
-static struct _profile_list_s 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;
+
+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)
+{
+ switch (err_type) {
+ case NET_ERR_NONE:
+ return WIFI_ERROR_NONE;
+ case NET_ERR_APP_ALREADY_REGISTERED:
+ return WIFI_ERROR_INVALID_OPERATION;
+ case NET_ERR_APP_NOT_REGISTERED:
+ return WIFI_ERROR_INVALID_OPERATION;
+ case NET_ERR_NO_ACTIVE_CONNECTIONS:
+ return WIFI_ERROR_NO_CONNECTION;
+ case NET_ERR_ACTIVE_CONNECTION_EXISTS:
+ return WIFI_ERROR_ALREADY_EXISTS;
+ case NET_ERR_CONNECTION_DHCP_FAILED:
+ return WIFI_ERROR_DHCP_FAILED;
+ case NET_ERR_CONNECTION_INVALID_KEY:
+ return WIFI_ERROR_INVALID_KEY;
+ case NET_ERR_IN_PROGRESS:
+ return WIFI_ERROR_NOW_IN_PROGRESS;
+ case NET_ERR_OPERATION_ABORTED:
+ return WIFI_ERROR_OPERATION_ABORTED;
+ case NET_ERR_TIME_OUT:
+ return WIFI_ERROR_NO_REPLY;
+ case NET_ERR_ACCESS_DENIED:
+ return WIFI_ERROR_PERMISSION_DENIED;
+ default:
+ return WIFI_ERROR_OPERATION_FAILED;
+ }
+}
+
+static const char *__libnet_convert_ap_error_type_to_string(wifi_error_e err_type)
+{
+ switch (err_type) {
+ case WIFI_ERROR_NONE:
+ return "NONE";
+ case WIFI_ERROR_INVALID_PARAMETER:
+ return "INVALID_PARAMETER";
+ case WIFI_ERROR_OUT_OF_MEMORY:
+ return "OUT_OF_MEMORY";
+ case WIFI_ERROR_INVALID_OPERATION:
+ return "INVALID_OPERATION";
+ case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+ return "ADDRESS_FAMILY_NOT_SUPPORTED";
+ case WIFI_ERROR_OPERATION_FAILED:
+ return "OPERATION_FAILED";
+ case WIFI_ERROR_NO_CONNECTION:
+ return "NO_CONNECTION";
+ case WIFI_ERROR_NOW_IN_PROGRESS:
+ return "NOW_IN_PROGRESS";
+ case WIFI_ERROR_ALREADY_EXISTS:
+ return "ALREADY_EXISTS";
+ case WIFI_ERROR_OPERATION_ABORTED:
+ return "OPERATION_ABORTED";
+ case WIFI_ERROR_DHCP_FAILED:
+ return "DHCP_FAILED";
+ case WIFI_ERROR_INVALID_KEY:
+ return "INVALID_KEY";
+ case WIFI_ERROR_NO_REPLY:
+ return "NO_REPLY";
+ case WIFI_ERROR_SECURITY_RESTRICTED:
+ return "SECURITY_RESTRICTED";
+ case WIFI_ERROR_PERMISSION_DENIED:
+ return "PERMISSION_DENIED";
+ case WIFI_ERROR_NOT_SUPPORTED:
+ return "NOT_SUPPROTED";
+ }
+
+ return "UNKNOWN";
+}
+
+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:
+ return "ASSOCIATION";
+ case WIFI_CONNECTION_STATE_CONFIGURATION:
+ return "CONFIGURATION";
+ case WIFI_CONNECTION_STATE_CONNECTED:
+ return "CONNECTED";
+ default:
+ return "UNKNOWN";
+ }
+}
static void __libnet_clear_profile_list(struct _profile_list_s *profile_list)
{
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_convert_profile_info_to_wifi_info(net_wifi_connection_info_t *wifi_info,
g_strlcpy(wifi_info->essid, ap_info->ProfileInfo.Wlan.essid, NET_WLAN_ESSID_LEN+1);
wifi_info->wlan_mode = ap_info->ProfileInfo.Wlan.wlan_mode;
memcpy(&wifi_info->security_info, &ap_info->ProfileInfo.Wlan.security_info, sizeof(wlan_security_info_t));
+ wifi_info->is_hidden = ap_info->ProfileInfo.Wlan.is_hidden;
}
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;
}
+static gboolean __wifi_state_changed_cb(gpointer data)
+{
+ wifi_ap_h ap_info;
+ struct _wifi_state_notify *notify = (struct _wifi_state_notify *)data;
+
+ if (notify == NULL)
+ return FALSE;
+
+ if (notify->ap_info == NULL) {
+ g_free(notify);
+ return FALSE;
+ }
+
+ ap_info = (wifi_ap_h)notify->ap_info;
+
+ _wifi_libnet_add_to_ap_list(ap_info);
+
+ if (wifi_callbacks.connection_state_cb != NULL)
+ wifi_callbacks.connection_state_cb(notify->state, ap_info,
+ wifi_callbacks.connection_state_user_data);
+
+ _wifi_libnet_remove_from_ap_list(ap_info);
+
+ g_free(notify);
+
+ return FALSE;
+}
+
static void __libnet_state_changed_cb(char *profile_name, net_profile_info_t *profile_info,
- wifi_error_e error, wifi_connection_state_e state, bool is_requested)
+ wifi_connection_state_e state)
{
+ guint id;
+ net_profile_info_t *ap_info = NULL;
+ struct _wifi_state_notify *notify = NULL;
+
+ if (_wifi_is_init() != true) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
+ }
+
+ if (wifi_callbacks.connection_state_cb == NULL)
+ return;
+
if (profile_name == NULL)
return;
if (profile_info == NULL) {
- WIFI_LOG(WIFI_ERROR, "Error!! Profile info not found! : %s\n", profile_name);
+ SECURE_WIFI_LOG(WIFI_ERROR, "Failed to find: %s", profile_name);
+ return;
+ }
+
+ ap_info = g_try_malloc0(sizeof(net_profile_info_t));
+ if (ap_info == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Memory allocation error");
+ return;
+ }
+
+ memcpy(ap_info, profile_info, sizeof(net_profile_info_t));
+
+ notify = g_try_new0(struct _wifi_state_notify, 1);
+ if (notify == NULL) {
+ g_free(ap_info);
return;
}
- ap_handle_list = g_slist_append(ap_handle_list, (wifi_ap_h)profile_info);
+ notify->ap_info = ap_info;
+ notify->state = state;
- if (wifi_callbacks.connection_state_cb)
- wifi_callbacks.connection_state_cb(error, state, (wifi_ap_h)profile_info,
- is_requested, wifi_callbacks.connection_state_user_data);
+ id = _wifi_callback_add(__wifi_state_changed_cb, (gpointer)notify);
+ if (!id)
+ g_free(notify);
+}
- ap_handle_list = g_slist_remove(ap_handle_list, (wifi_ap_h)profile_info);
+static void __libnet_set_activated_cb(wifi_activated_cb user_cb, void *user_data)
+{
+ if (user_cb != NULL) {
+ wifi_callbacks.activated_cb = user_cb;
+ wifi_callbacks.activated_user_data = user_data;
+ }
+}
+
+static gboolean __activated_cb_idle(gpointer data)
+{
+ wifi_error_e result = (wifi_error_e)data;
+
+ if (wifi_callbacks.activated_cb != NULL)
+ wifi_callbacks.activated_cb(result, wifi_callbacks.activated_user_data);
+
+ wifi_callbacks.activated_cb = NULL;
+ wifi_callbacks.activated_user_data = NULL;
+
+ return FALSE;
+}
+
+static void __libnet_set_deactivated_cb(wifi_deactivated_cb user_cb, void *user_data)
+{
+ if (user_cb != NULL) {
+ wifi_callbacks.deactivated_cb = user_cb;
+ wifi_callbacks.deactivated_user_data = user_data;
+ }
+}
+
+static gboolean __deactivated_cb_idle(gpointer data)
+{
+ wifi_error_e result = (wifi_error_e)data;
+
+ if (wifi_callbacks.deactivated_cb != NULL)
+ wifi_callbacks.deactivated_cb(result, wifi_callbacks.deactivated_user_data);
+
+ wifi_callbacks.deactivated_cb = NULL;
+ wifi_callbacks.deactivated_user_data = NULL;
+
+ return FALSE;
+}
+
+static gboolean __device_state_cb_idle(gpointer data)
+{
+ wifi_device_state_e state = (wifi_device_state_e)data;
+
+ if (wifi_callbacks.device_state_cb != NULL)
+ wifi_callbacks.device_state_cb(state, wifi_callbacks.device_state_user_data);
+
+ return FALSE;
}
static void __libnet_power_on_off_cb(net_event_info_t *event_cb, bool is_requested)
{
- if (wifi_callbacks.device_state_cb == NULL)
+ 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)
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);
} 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;
}
- wifi_callbacks.device_state_cb(error_code, state, is_requested, wifi_callbacks.device_state_user_data);
+ if (wifi_callbacks.activated_cb != NULL)
+ _wifi_callback_add(__activated_cb_idle, (gpointer)error_code);
+
+ if (wifi_callbacks.deactivated_cb != NULL)
+ _wifi_callback_add(__deactivated_cb_idle, (gpointer)error_code);
+
+ if (wifi_callbacks.device_state_cb != NULL)
+ _wifi_callback_add(__device_state_cb_idle, (gpointer)state);
+}
+
+static gboolean __scan_request_cb_idle(gpointer data)
+{
+ wifi_error_e error_code = (wifi_error_e)data;
+
+ if (wifi_callbacks.scan_request_cb != NULL)
+ wifi_callbacks.scan_request_cb(error_code, wifi_callbacks.scan_request_user_data);
+
+ wifi_callbacks.scan_request_cb = NULL;
+ wifi_callbacks.scan_request_user_data = NULL;
+
+ return FALSE;
+}
+
+static gboolean __bgscan_cb_idle(gpointer data)
+{
+ wifi_error_e error_code = (wifi_error_e)data;
+
+ if (wifi_callbacks.bg_scan_cb != NULL)
+ wifi_callbacks.bg_scan_cb(error_code, wifi_callbacks.bg_scan_user_data);
+
+ return FALSE;
}
static void __libnet_scan_cb(net_event_info_t *event_cb, bool is_requested)
{
wifi_error_e error_code = WIFI_ERROR_NONE;
+ if (_wifi_is_init() != true) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
+ }
+
if (event_cb->Error != NET_ERR_NONE) {
- WIFI_LOG(WIFI_ERROR, "Scan failed!, Error [%d]\n", event_cb->Error);
+ WIFI_LOG(WIFI_ERROR, "Scan failed[%d]", event_cb->Error);
error_code = WIFI_ERROR_OPERATION_FAILED;
}
- if (wifi_callbacks.scan_request_cb) {
- wifi_callbacks.scan_request_cb(error_code, wifi_callbacks.scan_request_user_data);
- wifi_callbacks.scan_request_cb = NULL;
- wifi_callbacks.scan_request_user_data = NULL;
+ if (wifi_callbacks.scan_request_cb != NULL) {
+ _wifi_callback_add(__scan_request_cb_idle, (gpointer)error_code);
return;
}
if (wifi_callbacks.bg_scan_cb != NULL)
- wifi_callbacks.bg_scan_cb(error_code, wifi_callbacks.bg_scan_user_data);
+ _wifi_callback_add(__bgscan_cb_idle, (gpointer)error_code);
+}
+
+static void __libnet_set_connected_cb(wifi_connected_cb user_cb, void *user_data)
+{
+ if (user_cb != NULL) {
+ wifi_callbacks.connected_cb = user_cb;
+ wifi_callbacks.connected_user_data = user_data;
+ }
+}
+
+static gboolean __connected_cb_idle(gpointer data)
+{
+ wifi_error_e result = (wifi_error_e)data;
+
+ if (wifi_callbacks.connected_cb != NULL)
+ wifi_callbacks.connected_cb(result, wifi_callbacks.connected_user_data);
+
+ wifi_callbacks.connected_cb = NULL;
+ wifi_callbacks.connected_user_data = NULL;
+
+ return FALSE;
+}
+
+static void __libnet_connected_cb(wifi_error_e result)
+{
+ if (_wifi_is_init() != true) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
+ }
+
+ if (wifi_callbacks.connected_cb != NULL)
+ _wifi_callback_add(__connected_cb_idle, (gpointer)result);
+}
+
+static void __libnet_set_disconnected_cb(wifi_disconnected_cb user_cb, void *user_data)
+{
+ if (user_cb != NULL) {
+ wifi_callbacks.disconnected_cb = user_cb;
+ wifi_callbacks.disconnected_user_data = user_data;
+ }
+}
+
+static gboolean __disconnected_cb_idle(gpointer data)
+{
+ wifi_error_e result = (wifi_error_e)data;
+
+ if (wifi_callbacks.disconnected_cb != NULL)
+ wifi_callbacks.disconnected_cb(result, wifi_callbacks.disconnected_user_data);
+
+ wifi_callbacks.disconnected_cb = NULL;
+ wifi_callbacks.disconnected_user_data = NULL;
+
+ return FALSE;
+}
+
+static void __libnet_disconnected_cb(wifi_error_e result)
+{
+ if (_wifi_is_init() != true) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
+ }
+
+ if (wifi_callbacks.disconnected_cb != NULL)
+ _wifi_callback_add(__disconnected_cb_idle, (gpointer)result);
}
static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
bool is_requested = false;
net_profile_info_t *prof_info_p = NULL;
net_profile_info_t prof_info;
+ wifi_error_e result = WIFI_ERROR_NONE;
+ int i = 0;
+ bool is_profile_exists = false;
switch (event_cb->Event) {
case NET_EVENT_OPEN_RSP:
case NET_EVENT_WIFI_WPS_RSP:
is_requested = true;
+ /* fall through */
case NET_EVENT_OPEN_IND:
- if (strstr(event_cb->ProfileName, "/wifi_") == NULL) return;
+ if (_wifi_libnet_check_profile_name_validity(event_cb->ProfileName) != true)
+ return;
- WIFI_LOG(WIFI_INFO,
- "Received ACTIVATION(Open RSP/IND) response: %d \n", event_cb->Error);
+ result = __libnet_convert_to_ap_error_type(event_cb->Error);
+ WIFI_LOG(WIFI_INFO, "Connection open error %s",
+ __libnet_convert_ap_error_type_to_string(result));
+
+ if (is_requested)
+ __libnet_connected_cb(result);
switch (event_cb->Error) {
case NET_ERR_NONE:
- WIFI_LOG(WIFI_INFO, "Activation 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_ERROR_NONE,
- WIFI_CONNECTION_STATE_CONNECTED,
- is_requested);
+ WIFI_CONNECTION_STATE_CONNECTED);
return;
- case NET_ERR_TIME_OUT:
- WIFI_LOG(WIFI_ERROR, "Request time out!\n");
- break;
- case NET_ERR_OPERATION_ABORTED:
- WIFI_LOG(WIFI_ERROR, "Connction is aborted!\n");
- break;
- case NET_ERR_UNKNOWN_METHOD:
- WIFI_LOG(WIFI_ERROR, "Method not found!\n");
- break;
- case NET_ERR_UNKNOWN:
- WIFI_LOG(WIFI_ERROR, "Activation Failed!\n");
- break;
- default:
- WIFI_LOG(WIFI_ERROR, "Unknown Error!\n");
+ case NET_ERR_ACTIVE_CONNECTION_EXISTS:
+ return;
+ default :
break;
}
if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE)
__libnet_state_changed_cb(event_cb->ProfileName, &prof_info,
- WIFI_ERROR_OPERATION_FAILED,
- WIFI_CONNECTION_STATE_DISCONNECTED,
- is_requested);
+ WIFI_CONNECTION_STATE_DISCONNECTED);
else
__libnet_state_changed_cb(event_cb->ProfileName, NULL,
- WIFI_ERROR_OPERATION_FAILED,
- WIFI_CONNECTION_STATE_DISCONNECTED,
- is_requested);
+ WIFI_CONNECTION_STATE_DISCONNECTED);
break;
case NET_EVENT_CLOSE_RSP:
is_requested = true;
+ /* fall through */
case NET_EVENT_CLOSE_IND:
- if (strstr(event_cb->ProfileName, "/wifi_") == NULL) return;
+ if (_wifi_libnet_check_profile_name_validity(event_cb->ProfileName) != true)
+ return;
- WIFI_LOG(WIFI_INFO, "Got Close RSP/IND\n");
+ result = __libnet_convert_to_ap_error_type(event_cb->Error);
+ WIFI_LOG(WIFI_ERROR, "Connection close error %s",
+ __libnet_convert_ap_error_type_to_string(result));
+
+ if (is_requested)
+ __libnet_disconnected_cb(result);
switch (event_cb->Error) {
case NET_ERR_NONE:
- /* Successful PDP Deactivation */
- WIFI_LOG(WIFI_INFO, "Deactivation 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_ERROR_NONE,
- WIFI_CONNECTION_STATE_DISCONNECTED,
- is_requested);
+ WIFI_CONNECTION_STATE_DISCONNECTED);
else
__libnet_state_changed_cb(event_cb->ProfileName, NULL,
- WIFI_ERROR_NONE,
- WIFI_CONNECTION_STATE_DISCONNECTED,
- is_requested);
+ WIFI_CONNECTION_STATE_DISCONNECTED);
return;
- case NET_ERR_TIME_OUT:
- WIFI_LOG(WIFI_ERROR, "Request time out!\n");
- break;
- case NET_ERR_IN_PROGRESS:
- WIFI_LOG(WIFI_ERROR, "Disconncting is in progress!\n");
- break;
- case NET_ERR_OPERATION_ABORTED:
- WIFI_LOG(WIFI_ERROR, "Disconnction is aborted!\n");
- break;
- case NET_ERR_UNKNOWN_METHOD:
- WIFI_LOG(WIFI_ERROR, "Service not found!\n");
- break;
- case NET_ERR_UNKNOWN:
- WIFI_LOG(WIFI_ERROR, "Deactivation Failed!\n");
- break;
default:
- WIFI_LOG(WIFI_ERROR, "Unknown Error!\n");
break;
}
- if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE)
- __libnet_state_changed_cb(event_cb->ProfileName, &prof_info,
- WIFI_ERROR_OPERATION_FAILED,
- WIFI_CONNECTION_STATE_DISCONNECTED,
- is_requested);
- else
- __libnet_state_changed_cb(event_cb->ProfileName, NULL,
- WIFI_ERROR_OPERATION_FAILED,
- WIFI_CONNECTION_STATE_DISCONNECTED,
- is_requested);
-
break;
case NET_EVENT_NET_STATE_IND:
- if (strstr(event_cb->ProfileName, "/wifi_") == NULL) return;
-
- WIFI_LOG(WIFI_INFO, "Got State changed IND\n");
- net_state_type_t *profile_state = (net_state_type_t*)event_cb->Data;
-
- if (event_cb->Error == NET_ERR_NONE &&
- event_cb->Datalength == sizeof(net_state_type_t)) {
- switch (*profile_state) {
- case NET_STATE_TYPE_ASSOCIATION:
- WIFI_LOG(WIFI_INFO,
- "Profile State : Association, profile name : %s\n",
- event_cb->ProfileName);
- break;
- case NET_STATE_TYPE_CONFIGURATION:
- WIFI_LOG(WIFI_INFO,
- "Profile State : Configuration, profile name : %s\n",
- event_cb->ProfileName);
- break;
- case NET_STATE_TYPE_IDLE:
- case NET_STATE_TYPE_FAILURE:
- case NET_STATE_TYPE_READY:
- case NET_STATE_TYPE_ONLINE:
- case NET_STATE_TYPE_DISCONNECT:
- case NET_STATE_TYPE_UNKNOWN:
- default:
- WIFI_LOG(WIFI_INFO,
- "Profile State : %d, profile name : %s\n", *profile_state,
- event_cb->ProfileName);
- return;
+ if (_wifi_libnet_check_profile_name_validity(event_cb->ProfileName) != true)
+ return;
+
+ if (event_cb->Datalength != sizeof(net_state_type_t))
+ return;
+
+ net_state_type_t *profile_state = (net_state_type_t *)event_cb->Data;
+ wifi_connection_state_e ap_state = _wifi_convert_to_ap_state(*profile_state);
+
+ WIFI_LOG(WIFI_INFO, "state: %s", __libnet_convert_ap_state_to_string(ap_state));
+ SECURE_WIFI_LOG(WIFI_INFO, "profile name: %s", event_cb->ProfileName);
+
+ if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE)
+ __libnet_state_changed_cb(event_cb->ProfileName, &prof_info, ap_state);
+ else if (ap_state == WIFI_CONNECTION_STATE_DISCONNECTED) {
+ for (i = 0; i < profile_iterator.count; i++) {
+ if (!g_strcmp0(event_cb->ProfileName,
+ profile_iterator.profiles[i].ProfileName)) {
+ is_profile_exists = true;
+ break;
+ }
}
- if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE)
- __libnet_state_changed_cb(event_cb->ProfileName, &prof_info,
- WIFI_ERROR_NONE,
- WIFI_CONNECTION_STATE_CONNECTING,
- is_requested);
- else
- __libnet_state_changed_cb(event_cb->ProfileName, NULL,
- WIFI_ERROR_NONE,
- WIFI_CONNECTION_STATE_CONNECTING,
- is_requested);
- }
+ if (is_profile_exists == true) {
+ profile_iterator.profiles[i].ProfileState = *profile_state;
+ __libnet_state_changed_cb(event_cb->ProfileName,
+ &profile_iterator.profiles[i], ap_state);
+ } else
+ __libnet_state_changed_cb(event_cb->ProfileName,
+ NULL, ap_state);
+ } else
+ __libnet_state_changed_cb(event_cb->ProfileName, NULL, ap_state);
break;
case NET_EVENT_WIFI_SCAN_RSP:
case NET_EVENT_WIFI_SCAN_IND:
- WIFI_LOG(WIFI_ERROR, "Got wifi scan IND\n");
__libnet_scan_cb(event_cb, is_requested);
break;
case NET_EVENT_WIFI_POWER_RSP:
is_requested = true;
+ /* fall through */
case NET_EVENT_WIFI_POWER_IND:
- WIFI_LOG(WIFI_ERROR, "Got wifi 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)
__libnet_clear_profile_list(&profile_iterator);
g_slist_free_full(ap_handle_list, g_free);
+ ap_handle_list = NULL;
memset(&wifi_callbacks, 0, sizeof(struct _wifi_cb_s));
+ __wifi_set_init(false);
+
return true;
}
-int _wifi_activate(void)
+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)
+ rv = net_wifi_power_on(wifi_picker_test);
+ if (rv == NET_ERR_NONE) {
+ __libnet_set_activated_cb(callback, user_data);
return WIFI_ERROR_NONE;
- else if (rv == NET_ERR_INVALID_OPERATION)
+ } 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(void)
+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)
+ if (rv == NET_ERR_NONE) {
+ __libnet_set_deactivated_cb(callback, user_data);
return WIFI_ERROR_NONE;
- else if (rv == NET_ERR_INVALID_OPERATION)
+ } 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;
return false;
bool _wifi_libnet_check_profile_name_validity(const char *profile_name)
{
- const char *profile_header = "/net/connman/service/wifi_";
+ const char *profile_prefix = "/net/connman/service/wifi_";
int i = 0;
- int string_len = 0;
- if (profile_name == NULL || strlen(profile_name) <= strlen(profile_header)) {
- WIFI_LOG(WIFI_ERROR, "Error!!! Profile name is invalid\n");
+ if (profile_name == NULL ||
+ g_str_has_prefix(profile_name, profile_prefix) != TRUE) {
+ WIFI_LOG(WIFI_INFO, "The profile is a hidden or not a regular Wi-Fi profile");
return false;
}
- string_len = strlen(profile_name);
-
- if (strncmp(profile_header, profile_name, strlen(profile_header)) == 0) {
- for (;i < string_len;i++) {
- if (isgraph(profile_name[i]) == 0) {
- WIFI_LOG(WIFI_ERROR, "Error!!! Profile name is invalid\n");
- return false;
- }
+ while (profile_name[i] != '\0') {
+ if (isgraph(profile_name[i]) == 0) {
+ WIFI_LOG(WIFI_INFO, "Invalid format: %s", profile_name);
+ return false;
}
- } else {
- WIFI_LOG(WIFI_ERROR, "Error!!! Profile name is invalid\n");
- return false;
+ i++;
}
- return NET_ERR_NONE;
+ return true;
+}
+
+int _wifi_libnet_get_wifi_device_state(wifi_device_state_e *device_state)
+{
+ net_tech_info_t tech_info;
+
+ 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)
+ *device_state = WIFI_DEVICE_STATE_ACTIVATED;
+ else
+ *device_state = WIFI_DEVICE_STATE_DEACTIVATED;
+
+ 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) {
case WIFI_ON:
*connection_state = WIFI_CONNECTION_STATE_DISCONNECTED;
break;
- case WIFI_CONNECTING:
- *connection_state = WIFI_CONNECTION_STATE_CONNECTING;
+ case WIFI_ASSOCIATION:
+ *connection_state = WIFI_CONNECTION_STATE_ASSOCIATION;
+ break;
+ case WIFI_CONFIGURATION:
+ *connection_state = WIFI_CONNECTION_STATE_CONFIGURATION;
break;
case WIFI_CONNECTED:
*connection_state = WIFI_CONNECTION_STATE_CONNECTED;
break;
case WIFI_DISCONNECTING:
- *connection_state = WIFI_CONNECTION_STATE_DISCONNECTING;
+ *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;
}
return WIFI_ERROR_NONE;
}
-int _wifi_libnet_scan_request(wifi_scan_finished_cb callback, void* user_data)
+int _wifi_libnet_scan_request(wifi_scan_finished_cb callback, void *user_data)
{
int rv;
rv = net_scan_wifi();
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;
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]);
}
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;
}
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++) {
+ if (profile_iterator.profiles[i].ProfileInfo.Wlan.is_hidden == TRUE)
+ continue;
+
rv = callback((wifi_ap_h)(&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)
+int _wifi_libnet_open_profile(wifi_ap_h ap_h, wifi_connected_cb callback, void *user_data)
{
+ int rv;
+ bool valid_profile;
net_profile_info_t *ap_info = ap_h;
- if (ap_info->ProfileInfo.Wlan.security_info.sec_mode == WLAN_SEC_MODE_IEEE8021X)
- return __libnet_connect_with_wifi_info(ap_info);
- else if (_wifi_libnet_check_profile_name_validity(ap_info->ProfileName) == false)
- return __libnet_connect_with_wifi_info(ap_info);
- else if (net_open_connection_with_profile(ap_info->ProfileName) != NET_ERR_NONE)
+ valid_profile =
+ _wifi_libnet_check_profile_name_validity(ap_info->ProfileName);
+
+ if (valid_profile == true && ap_info->Favourite)
+ rv = net_open_connection_with_profile(ap_info->ProfileName);
+ else if (valid_profile == true &&
+ ap_info->ProfileInfo.Wlan.is_hidden != TRUE &&
+ ap_info->ProfileInfo.Wlan.security_info.sec_mode ==
+ WLAN_SEC_MODE_NONE)
+ rv = net_open_connection_with_profile(ap_info->ProfileName);
+ else
+ rv = __libnet_connect_with_wifi_info(ap_info);
+
+ 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_disconnected_cb(callback, user_data);
+
return WIFI_ERROR_NONE;
}
-int _wifi_libnet_close_profile(wifi_ap_h ap_h)
+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_wifi_wps_info_t wps_info;
+ memset(&wps_info, 0, sizeof(net_wifi_wps_info_t));
+
+ wps_info.type = WIFI_WPS_PBC;
- if (net_close_connection(ap_info->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_connected_cb(callback, user_data);
+
return WIFI_ERROR_NONE;
}
-int _wifi_libnet_connect_with_wps(wifi_ap_h ap_h, wifi_wps_type_e type, const char *pin)
+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;
- memset(&wps_info, 0 , sizeof(net_wifi_wps_info_t));
- if (type == WIFI_WPS_TYPE_PIN) {
- wps_info.type = WIFI_WPS_PIN;
- g_strlcpy(wps_info.pin, pin, NET_WLAN_MAX_WPSPIN_LEN+1);
- } else
- wps_info.type = WIFI_WPS_PBC;
+ if (ap_info == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+ return WIFI_ERROR_INVALID_PARAMETER;
+ }
+
+ wps_info.type = WIFI_WPS_PIN;
+ g_strlcpy(wps_info.pin, pin, NET_WLAN_MAX_WPSPIN_LEN + 1);
- if (net_wifi_enroll_wps(ap_info->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);
+
+ return WIFI_ERROR_NONE;
+}
+
+int _wifi_libnet_forget_ap(wifi_ap_h ap)
+{
+ int rv = 0;
+ net_profile_info_t *ap_info = ap;
+
+ if (ap_info == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+ return WIFI_ERROR_INVALID_PARAMETER;
+ }
+
+ 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;
}
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;
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;
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;
}
+static void __wifi_idle_destroy_cb(gpointer data)
+{
+ if (!data)
+ return;
+
+ managed_idler_list = g_slist_remove(managed_idler_list, data);
+ g_free(data);
+}
+
+static gboolean __wifi_idle_cb(gpointer user_data)
+{
+ struct managed_idle_data *data = (struct managed_idle_data *)user_data;
+
+ if (!data)
+ return FALSE;
+
+ return data->func(data->user_data);
+}
+
+guint _wifi_callback_add(GSourceFunc func, gpointer user_data)
+{
+ guint id;
+ struct managed_idle_data *data;
+
+ if (!func)
+ return 0;
+
+ data = g_try_new0(struct managed_idle_data, 1);
+ if (!data)
+ return 0;
+
+ data->func = func;
+ data->user_data = user_data;
+
+ id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, __wifi_idle_cb, data,
+ __wifi_idle_destroy_cb);
+ if (!id) {
+ g_free(data);
+ return id;
+ }
+
+ data->id = id;
+
+ managed_idler_list = g_slist_append(managed_idler_list, data);
+
+ return id;
+}
+
+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;
+}
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
+#include <glib.h>
#include <stdio.h>
#include <string.h>
-#include <glib.h>
#include <vconf/vconf.h>
+
#include "net_wifi_private.h"
-static bool is_init = false;
-static wifi_rssi_level_changed_cb rssi_level_changed_cb = NULL;
-static void *rssi_level_changed_user_data = NULL;
+static __thread wifi_rssi_level_changed_cb rssi_level_changed_cb = NULL;
+static __thread void *rssi_level_changed_user_data = NULL;
+static gboolean __rssi_level_changed_cb_idle(gpointer data)
+{
+ int rssi_level = 0;
+
+ if (vconf_get_int(VCONFKEY_WIFI_STRENGTH, &rssi_level) != 0)
+ return FALSE;
+
+ if (rssi_level_changed_cb != NULL)
+ rssi_level_changed_cb(rssi_level, rssi_level_changed_user_data);
+
+ return FALSE;
+}
static void __rssi_level_changed_cb(keynode_t *node, void *user_data)
{
- int rssi_level = vconf_keynode_get_int(node);
- rssi_level_changed_cb(rssi_level, rssi_level_changed_user_data);
+ if (_wifi_is_init() != true) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
+ }
+
+ if (rssi_level_changed_cb != NULL)
+ _wifi_callback_add(__rssi_level_changed_cb_idle, NULL);
}
-int wifi_initialize(void)
+EXPORT_API int wifi_initialize(void)
{
- if (is_init) {
- WIFI_LOG(WIFI_ERROR, "Already initialized\n");
+ int rv;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ 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");
return WIFI_ERROR_NONE;
}
-int wifi_deinitialize(void)
+EXPORT_API int wifi_deinitialize(void)
{
- if (is_init == false) {
- WIFI_LOG(WIFI_ERROR, "Not initialized\n");
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ 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");
return WIFI_ERROR_NONE;
}
-int wifi_activate(void)
+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");
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_is_init() == false) {
+ WIFI_LOG(WIFI_ERROR, "Not initialized");
return WIFI_ERROR_INVALID_OPERATION;
}
- rv = _wifi_activate();
+ rv = _wifi_activate(callback, FALSE, 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;
}
-int wifi_deactivate(void)
+EXPORT_API int wifi_activate_with_wifi_picker_tested(
+ wifi_activated_cb callback, void* user_data)
{
int rv;
- if (is_init == false) {
- WIFI_LOG(WIFI_ERROR, "Not initialized\n");
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_is_init() == false) {
+ WIFI_LOG(WIFI_ERROR, "Not initialized");
return WIFI_ERROR_INVALID_OPERATION;
}
- rv = _wifi_deactivate();
+ rv = _wifi_activate(callback, TRUE, user_data);
if (rv != WIFI_ERROR_NONE)
- WIFI_LOG(WIFI_ERROR, "Error!! Wi-Fi Deactivation failed.\n");
+ WIFI_LOG(WIFI_ERROR, "Failed to activate Wi-Fi[%d]", rv);
return rv;
}
-int wifi_is_activated(bool* activated)
+EXPORT_API int wifi_deactivate(wifi_deactivated_cb callback, void* user_data)
{
- int status = 0;
+ int rv;
- if (activated == NULL) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
- return WIFI_ERROR_INVALID_PARAMETER;
- }
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
- if (!vconf_get_int(VCONFKEY_NETWORK_WIFI_STATE, &status)) {
- WIFI_LOG(WIFI_INFO, "WiFi = %d\n", status);
- if (status == VCONFKEY_NETWORK_WIFI_OFF)
- *activated = false;
- else
- *activated = true;
- } else {
- WIFI_LOG(WIFI_ERROR, "vconf_get_int Failed = %d\n", status);
- return WIFI_ERROR_OPERATION_FAILED;
+ if (_wifi_is_init() == false) {
+ WIFI_LOG(WIFI_ERROR, "Not initialized");
+ return WIFI_ERROR_INVALID_OPERATION;
}
- return WIFI_ERROR_NONE;
+ rv = _wifi_deactivate(callback, user_data);
+ if (rv != WIFI_ERROR_NONE)
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi deactivation failed");
+
+ return rv;
}
-int wifi_get_connection_state(wifi_connection_state_e* connection_state)
+EXPORT_API int wifi_is_activated(bool* activated)
{
- if (connection_state == NULL) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ int rv;
+ wifi_device_state_e device_state;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (activated == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
return WIFI_ERROR_INVALID_PARAMETER;
}
- if (_wifi_libnet_get_wifi_state(connection_state) == false)
- return WIFI_ERROR_OPERATION_FAILED;
+ 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;
+ return rv;
}
-int wifi_get_mac_address(char** mac_address)
+EXPORT_API int wifi_get_mac_address(char** mac_address)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
-int wifi_get_network_interface_name(char** name)
+EXPORT_API int wifi_get_network_interface_name(char** name)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (name == NULL) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
return WIFI_ERROR_INVALID_PARAMETER;
}
return _wifi_libnet_get_intf_name(name);
}
-int wifi_scan(wifi_scan_finished_cb callback, void* user_data)
+EXPORT_API int wifi_scan(wifi_scan_finished_cb callback, void* user_data)
{
int rv;
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
-int wifi_get_connected_ap(wifi_ap_h* ap)
+EXPORT_API int wifi_get_connected_ap(wifi_ap_h* ap)
{
int rv;
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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);
+ rv = _wifi_libnet_get_connected_profile(ap);
+ WIFI_LOG(WIFI_INFO, "Connected AP %p, rv %d", *ap, rv);
return rv;
}
-int wifi_foreach_found_aps(wifi_found_ap_cb callback, void* user_data)
+EXPORT_API int wifi_foreach_found_aps(wifi_found_ap_cb callback, void* user_data)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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);
}
-int wifi_connect(wifi_ap_h ap)
+EXPORT_API int wifi_connect(wifi_ap_h ap, wifi_connected_cb callback, void* user_data)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ 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_open_profile(ap, callback, user_data);
+}
+
+EXPORT_API int wifi_disconnect(wifi_ap_h ap, wifi_disconnected_cb callback, void* user_data)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_is_init() == false) {
+ WIFI_LOG(WIFI_ERROR, "Not initialized");
return WIFI_ERROR_INVALID_OPERATION;
}
- return _wifi_libnet_open_profile(ap);
+ if (_wifi_libnet_check_ap_validity(ap) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+ return WIFI_ERROR_INVALID_PARAMETER;
+ }
+
+ return _wifi_libnet_close_profile(ap, callback, user_data);
}
-int wifi_disconnect(wifi_ap_h ap)
+EXPORT_API int wifi_connect_by_wps_pbc(wifi_ap_h ap, wifi_connected_cb callback, void* user_data)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ 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)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_is_init() == false) {
+ WIFI_LOG(WIFI_ERROR, "Not initialized");
return WIFI_ERROR_INVALID_OPERATION;
}
- return _wifi_libnet_close_profile(ap);
+ 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);
}
-int wifi_connect_with_wps(wifi_ap_h ap, wifi_wps_type_e type, const char* pin)
+EXPORT_API int wifi_forget_ap(wifi_ap_h ap)
{
- if (_wifi_libnet_check_ap_validity(ap) == false ||
- (type != WIFI_WPS_TYPE_PBC && type != WIFI_WPS_TYPE_PIN) ||
- (type == WIFI_WPS_TYPE_PIN && pin == NULL)) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ 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, "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)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (connection_state == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+ return WIFI_ERROR_INVALID_PARAMETER;
}
- return _wifi_libnet_connect_with_wps(ap, type, pin);
+ return _wifi_libnet_get_wifi_state(connection_state);
}
-int wifi_set_device_state_changed_cb(wifi_device_state_changed_cb callback, void* user_data)
+EXPORT_API int wifi_set_device_state_changed_cb(wifi_device_state_changed_cb callback, void* user_data)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return _wifi_set_power_on_off_cb(callback, user_data);
}
-int wifi_unset_device_state_changed_cb(void)
+EXPORT_API int wifi_unset_device_state_changed_cb(void)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
return _wifi_unset_power_on_off_cb();
}
-int wifi_set_background_scan_cb(wifi_scan_finished_cb callback, void* user_data)
+EXPORT_API int wifi_set_background_scan_cb(wifi_scan_finished_cb callback, void* user_data)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return _wifi_set_background_scan_cb(callback, user_data);
}
-int wifi_unset_background_scan_cb(void)
+EXPORT_API int wifi_unset_background_scan_cb(void)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
return _wifi_unset_background_scan_cb();
}
-int wifi_set_connection_state_changed_cb(wifi_connection_state_changed_cb callback, void* user_data)
+EXPORT_API int wifi_set_connection_state_changed_cb(wifi_connection_state_changed_cb callback, void* user_data)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return _wifi_set_connection_state_cb(callback, user_data);
}
-int wifi_unset_connection_state_changed_cb(void)
+EXPORT_API int wifi_unset_connection_state_changed_cb(void)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
return _wifi_unset_connection_state_cb();
}
-int wifi_set_rssi_level_changed_cb(wifi_rssi_level_changed_cb callback, void* user_data)
+EXPORT_API int wifi_set_rssi_level_changed_cb(wifi_rssi_level_changed_cb callback, void* user_data)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (callback == NULL) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
return WIFI_ERROR_INVALID_PARAMETER;
}
return WIFI_ERROR_NONE;
}
-int wifi_unset_rssi_level_changed_cb(void)
+EXPORT_API int wifi_unset_rssi_level_changed_cb(void)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (rssi_level_changed_cb != NULL)
vconf_ignore_key_changed(VCONFKEY_WIFI_STRENGTH, __rssi_level_changed_cb);
else
return WIFI_ERROR_NONE;
}
-
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
+#include <glib.h>
#include <stdio.h>
#include <string.h>
-#include <glib.h>
+#include <stdlib.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
#include "net_wifi_private.h"
+#define MAX_PREFIX_LENGTH 6
-static char* __ap_convert_ip_to_string(net_addr_t *ip_addr)
+static char *__ap_convert_ip_to_string(net_addr_t *ip_addr, wifi_address_family_e address_family)
{
- unsigned char *ipaddr = (unsigned char *)&ip_addr->Data.Ipv4.s_addr;
+ unsigned char *ipaddr = NULL;
+ char *ipstr = NULL;
- char *ipstr = g_try_malloc0(16);
- if (ipstr == NULL)
- return NULL;
+ if (address_family == WIFI_ADDRESS_FAMILY_IPV4) {
+ ipaddr = (unsigned char *)&ip_addr->Data.Ipv4.s_addr;
+ ipstr = g_try_malloc0(INET_ADDRSTRLEN);
+ if (ipstr == NULL)
+ return NULL;
- snprintf(ipstr, 16, "%d.%d.%d.%d", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]);
+ inet_ntop(AF_INET, ipaddr, ipstr, INET_ADDRSTRLEN);
+ } else {
+ ipaddr = (unsigned char *)&ip_addr->Data.Ipv6;
+ ipstr = g_try_malloc0(INET6_ADDRSTRLEN);
+ if (ipstr == NULL)
+ return NULL;
+ inet_ntop(AF_INET6, ipaddr, ipstr, INET6_ADDRSTRLEN);
+ }
return ipstr;
}
g_strlcpy(profile_info->ProfileInfo.Wlan.essid, essid, NET_WLAN_ESSID_LEN+1);
}
-/* Wi-Fi AP module ********************************************************************************/
+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);
-int wifi_ap_create(const char* essid, wifi_ap_h* ap)
+ 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.is_hidden == TRUE ?
+ NULL : 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;
+
+ switch (state) {
+ case NET_STATE_TYPE_ONLINE:
+ case NET_STATE_TYPE_READY:
+ ap_state = WIFI_CONNECTION_STATE_CONNECTED;
+ break;
+ 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;
+ case NET_STATE_TYPE_ASSOCIATION:
+ ap_state = WIFI_CONNECTION_STATE_ASSOCIATION;
+ break;
+ case NET_STATE_TYPE_CONFIGURATION:
+ ap_state = WIFI_CONNECTION_STATE_CONFIGURATION;
+ break;
+ default:
+ ap_state = -1;
+ break;
+ }
+
+ return ap_state;
+}
+
+/* Wi-Fi AP ******************************************************************/
+EXPORT_API int wifi_ap_create(const char* essid, wifi_ap_h* ap)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (essid == NULL || ap == NULL) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
return WIFI_ERROR_INVALID_PARAMETER;
}
return WIFI_ERROR_NONE;
}
-int wifi_ap_destroy(wifi_ap_h ap)
+EXPORT_API int wifi_ap_hidden_create(const char* essid, wifi_ap_h* ap)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (essid == NULL || ap == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+ return WIFI_ERROR_INVALID_PARAMETER;
+ }
+
+ net_profile_info_t *ap_info = g_try_malloc0(sizeof(net_profile_info_t));
+ if (ap_info == NULL)
+ return WIFI_ERROR_OUT_OF_MEMORY;
+
+ __wifi_init_ap(ap_info, essid);
+ ap_info->ProfileInfo.Wlan.is_hidden = TRUE;
+
+ _wifi_libnet_add_to_ap_list((wifi_ap_h)ap_info);
+ *ap = (wifi_ap_h)ap_info;
+
+ return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_destroy(wifi_ap_h ap)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return WIFI_ERROR_NONE;
}
-int wifi_ap_clone(wifi_ap_h* cloned_ap, wifi_ap_h origin)
+EXPORT_API int wifi_ap_clone(wifi_ap_h* cloned_ap, wifi_ap_h origin)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return WIFI_ERROR_NONE;
}
+EXPORT_API int wifi_ap_refresh(wifi_ap_h ap)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ net_profile_info_t ap_info_local;
+ net_profile_info_t *ap_info = ap;
-/* Wi-Fi network information module ***************************************************************/
+ 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;
+ }
+
+ memcpy(ap, &ap_info_local, sizeof(net_profile_info_t));
-int wifi_ap_get_essid(wifi_ap_h ap, char** essid)
+ return WIFI_ERROR_NONE;
+}
+
+/* Wi-Fi network information *************************************************/
+EXPORT_API int wifi_ap_get_essid(wifi_ap_h ap, char** essid)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return WIFI_ERROR_NONE;
}
-int wifi_ap_get_bssid(wifi_ap_h ap, char** bssid)
+EXPORT_API int wifi_ap_get_bssid(wifi_ap_h ap, char** bssid)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return WIFI_ERROR_NONE;
}
-int wifi_ap_get_rssi(wifi_ap_h ap, int* rssi)
+EXPORT_API int wifi_ap_get_rssi(wifi_ap_h ap, int* rssi)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
-int wifi_ap_get_frequency(wifi_ap_h ap, int* frequency)
+EXPORT_API int wifi_ap_get_frequency(wifi_ap_h ap, int* frequency)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return WIFI_ERROR_NONE;
}
-int wifi_ap_get_max_speed(wifi_ap_h ap, int* max_speed)
+EXPORT_API int wifi_ap_get_max_speed(wifi_ap_h ap, int* max_speed)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
net_profile_info_t *profile_info = ap;
- *max_speed = (int)profile_info->ProfileInfo.Wlan.max_rate;
+ *max_speed = (int)profile_info->ProfileInfo.Wlan.max_rate / 1000000;
return WIFI_ERROR_NONE;
}
-int wifi_ap_is_favorite(wifi_ap_h ap, bool* favorite)
+EXPORT_API int wifi_ap_is_favorite(wifi_ap_h ap, bool* favorite)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return WIFI_ERROR_NONE;
}
-int wifi_ap_get_connection_state(wifi_ap_h ap, wifi_connection_state_e* state)
+EXPORT_API int wifi_ap_is_passpoint(wifi_ap_h ap, bool* passpoint)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_libnet_check_ap_validity(ap) == false || passpoint == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+ return WIFI_ERROR_INVALID_PARAMETER;
+ }
+
+ net_profile_info_t *profile_info = ap;
+
+ if (profile_info->ProfileInfo.Wlan.passpoint)
+ *passpoint = true;
+ else
+ *passpoint = false;
+
+ return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_connection_state(wifi_ap_h ap, wifi_connection_state_e* state)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
net_profile_info_t *profile_info = ap;
- switch (profile_info->ProfileState) {
- case NET_STATE_TYPE_IDLE:
- case NET_STATE_TYPE_FAILURE:
- case NET_STATE_TYPE_DISCONNECT:
- *state = WIFI_CONNECTION_STATE_DISCONNECTED;
- break;
- case NET_STATE_TYPE_ASSOCIATION:
- case NET_STATE_TYPE_CONFIGURATION:
- *state = WIFI_CONNECTION_STATE_CONNECTING;
- break;
- case NET_STATE_TYPE_READY:
- case NET_STATE_TYPE_ONLINE:
- *state = WIFI_CONNECTION_STATE_CONNECTED;
- break;
- default:
+ *state = _wifi_convert_to_ap_state(profile_info->ProfileState);
+
+ if (*state < 0)
return WIFI_ERROR_OPERATION_FAILED;
- }
return WIFI_ERROR_NONE;
}
-int wifi_ap_get_ip_config_type(wifi_ap_h ap, wifi_address_family_e address_family, wifi_ip_config_type_e* type)
+EXPORT_API int wifi_ap_get_ip_config_type(wifi_ap_h ap, wifi_address_family_e address_family, wifi_ip_config_type_e* type)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ net_ip_config_type_t profileType ;
+
if (_wifi_libnet_check_ap_validity(ap) == false ||
(address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
type == NULL) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ 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");
- return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
- }
-
net_profile_info_t *profile_info = ap;
- switch (profile_info->ProfileInfo.Wlan.net_info.IpConfigType) {
- case NET_IP_CONFIG_TYPE_STATIC:
- *type = WIFI_IP_CONFIG_TYPE_STATIC;
- break;
- case NET_IP_CONFIG_TYPE_DYNAMIC:
- *type = WIFI_IP_CONFIG_TYPE_DYNAMIC;
- break;
- case NET_IP_CONFIG_TYPE_AUTO_IP:
- *type = WIFI_IP_CONFIG_TYPE_AUTO;
- break;
- case NET_IP_CONFIG_TYPE_FIXED:
- *type = WIFI_IP_CONFIG_TYPE_FIXED;
- break;
- case NET_IP_CONFIG_TYPE_OFF:
- *type = WIFI_IP_CONFIG_TYPE_NONE;
- break;
- default:
- return WIFI_ERROR_OPERATION_FAILED;
+ if (address_family == WIFI_ADDRESS_FAMILY_IPV4){
+ profileType = profile_info->ProfileInfo.Wlan.net_info.IpConfigType ;
+ } else {
+ profileType = profile_info->ProfileInfo.Wlan.net_info.IpConfigType6 ;
+ }
+
+ if (address_family == WIFI_ADDRESS_FAMILY_IPV4) {
+ switch (profileType) {
+ case NET_IP_CONFIG_TYPE_STATIC:
+ *type = WIFI_IP_CONFIG_TYPE_STATIC;
+ break;
+
+ case NET_IP_CONFIG_TYPE_DYNAMIC:
+ *type = WIFI_IP_CONFIG_TYPE_DYNAMIC;
+ break;
+
+ case NET_IP_CONFIG_TYPE_AUTO_IP:
+ *type = WIFI_IP_CONFIG_TYPE_AUTO;
+ break;
+
+ case NET_IP_CONFIG_TYPE_FIXED:
+ *type = WIFI_IP_CONFIG_TYPE_FIXED;
+ break;
+
+ case NET_IP_CONFIG_TYPE_OFF:
+ *type = WIFI_IP_CONFIG_TYPE_NONE;
+ break;
+
+ default:
+ return WIFI_ERROR_OPERATION_FAILED;
+ }
+ } else {
+ switch (profileType) {
+ case NET_IP_CONFIG_TYPE_STATIC:
+ *type = WIFI_IP_CONFIG_TYPE_STATIC;
+ break;
+ case NET_IP_CONFIG_TYPE_AUTO_IP:
+ *type = WIFI_IP_CONFIG_TYPE_AUTO;
+ break;
+ case NET_IP_CONFIG_TYPE_OFF:
+ *type = WIFI_IP_CONFIG_TYPE_NONE;
+ break;
+ default:
+ return WIFI_ERROR_OPERATION_FAILED;
+ }
}
return WIFI_ERROR_NONE;
}
-int wifi_ap_set_ip_config_type(wifi_ap_h ap, wifi_address_family_e address_family, wifi_ip_config_type_e type)
+EXPORT_API int wifi_ap_set_ip_config_type(wifi_ap_h ap, wifi_address_family_e address_family, wifi_ip_config_type_e type)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ net_ip_config_type_t *profileType = NULL;
+
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");
- return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
- }
-
net_profile_info_t *profile_info = ap;
- switch (type) {
- case WIFI_IP_CONFIG_TYPE_STATIC:
- profile_info->ProfileInfo.Wlan.net_info.IpConfigType = NET_IP_CONFIG_TYPE_STATIC;
- break;
- case WIFI_IP_CONFIG_TYPE_DYNAMIC:
- profile_info->ProfileInfo.Wlan.net_info.IpConfigType = NET_IP_CONFIG_TYPE_DYNAMIC;
- break;
- case WIFI_IP_CONFIG_TYPE_AUTO:
- profile_info->ProfileInfo.Wlan.net_info.IpConfigType = NET_IP_CONFIG_TYPE_AUTO_IP;
- break;
- case WIFI_IP_CONFIG_TYPE_FIXED:
- profile_info->ProfileInfo.Wlan.net_info.IpConfigType = NET_IP_CONFIG_TYPE_FIXED;
- break;
- case WIFI_IP_CONFIG_TYPE_NONE:
- profile_info->ProfileInfo.Wlan.net_info.IpConfigType = NET_IP_CONFIG_TYPE_OFF;
- break;
- default:
- return WIFI_ERROR_INVALID_PARAMETER;
+ if (address_family == WIFI_ADDRESS_FAMILY_IPV4) {
+ profileType = &profile_info->ProfileInfo.Wlan.net_info.IpConfigType ;
+ } else {
+ profileType = &profile_info->ProfileInfo.Wlan.net_info.IpConfigType6 ;
+ }
+
+ if (address_family == WIFI_ADDRESS_FAMILY_IPV4) {
+ switch (type) {
+ case WIFI_IP_CONFIG_TYPE_STATIC:
+ *profileType = NET_IP_CONFIG_TYPE_STATIC;
+ profile_info->ProfileInfo.Wlan.net_info.IpAddr.Data.Ipv4.s_addr = 0;
+ profile_info->ProfileInfo.Wlan.net_info.SubnetMask.Data.Ipv4.s_addr = 0;
+ profile_info->ProfileInfo.Wlan.net_info.GatewayAddr.Data.Ipv4.s_addr = 0 ;
+ break;
+
+ case WIFI_IP_CONFIG_TYPE_DYNAMIC:
+ *profileType = NET_IP_CONFIG_TYPE_DYNAMIC;
+ break;
+
+ case WIFI_IP_CONFIG_TYPE_AUTO:
+ *profileType = NET_IP_CONFIG_TYPE_AUTO_IP;
+ break;
+
+ case WIFI_IP_CONFIG_TYPE_FIXED:
+ *profileType = NET_IP_CONFIG_TYPE_FIXED;
+ break;
+
+ case WIFI_IP_CONFIG_TYPE_NONE:
+ *profileType = NET_IP_CONFIG_TYPE_OFF;
+ break;
+
+ default:
+ return WIFI_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ switch (type) {
+ case WIFI_IP_CONFIG_TYPE_STATIC:
+ *profileType = NET_IP_CONFIG_TYPE_STATIC;
+ inet_pton(AF_INET6, "::", &profile_info->ProfileInfo.Wlan.net_info.IpAddr6.Data.Ipv6);
+ profile_info->ProfileInfo.Wlan.net_info.PrefixLen6 = 0 ;
+ inet_pton(AF_INET6, "::", &profile_info->ProfileInfo.Wlan.net_info.GatewayAddr6.Data.Ipv6);
+ break;
+ case WIFI_IP_CONFIG_TYPE_AUTO:
+ *profileType = NET_IP_CONFIG_TYPE_AUTO_IP;
+ break;
+ case WIFI_IP_CONFIG_TYPE_NONE:
+ *profileType = NET_IP_CONFIG_TYPE_OFF;
+ break;
+ default:
+ return WIFI_ERROR_INVALID_PARAMETER;
+ }
}
if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false)
return _wifi_update_ap_info(profile_info);
}
-int wifi_ap_get_ip_address(wifi_ap_h ap, wifi_address_family_e address_family, char** ip_address)
+EXPORT_API int wifi_ap_get_ip_address(wifi_ap_h ap, wifi_address_family_e address_family, char** ip_address)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (_wifi_libnet_check_ap_validity(ap) == false ||
(address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
ip_address == NULL) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ 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");
- return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
- }
-
net_profile_info_t *profile_info = ap;
- *ip_address = __ap_convert_ip_to_string(&profile_info->ProfileInfo.Wlan.net_info.IpAddr);
+ if (address_family == WIFI_ADDRESS_FAMILY_IPV4)
+ *ip_address = __ap_convert_ip_to_string(
+ &profile_info->ProfileInfo.Wlan.net_info.IpAddr,
+ address_family);
+ else
+ *ip_address = __ap_convert_ip_to_string(
+ &profile_info->ProfileInfo.Wlan.net_info.IpAddr6,
+ address_family);
+
if (*ip_address == NULL)
return WIFI_ERROR_OUT_OF_MEMORY;
return WIFI_ERROR_NONE;
}
-int wifi_ap_set_ip_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* ip_address)
+EXPORT_API int wifi_ap_set_ip_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* ip_address)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (_wifi_libnet_check_ap_validity(ap) == false ||
(address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
- address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
- ip_address == NULL) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ address_family != WIFI_ADDRESS_FAMILY_IPV6)) {
+ 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");
- return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
- }
-
net_profile_info_t *profile_info = ap;
- if (inet_aton(ip_address, &(profile_info->ProfileInfo.Wlan.net_info.IpAddr.Data.Ipv4)) == 0)
- return WIFI_ERROR_INVALID_PARAMETER;
+
+ if (address_family == WIFI_ADDRESS_FAMILY_IPV4) {
+ if (ip_address == NULL)
+ profile_info->ProfileInfo.Wlan.net_info.IpAddr.Data.Ipv4.s_addr = 0;
+ else if (inet_aton(ip_address,
+ &(profile_info->ProfileInfo.Wlan.net_info.IpAddr.Data.Ipv4)) == 0)
+ return WIFI_ERROR_INVALID_PARAMETER;
+ } else {
+ if (ip_address == NULL)
+ inet_pton(AF_INET6, "::",
+ &profile_info->ProfileInfo.Wlan.net_info.IpAddr6.Data.Ipv6);
+ else if (inet_pton(AF_INET6, ip_address,
+ &profile_info->ProfileInfo.Wlan.net_info.IpAddr6.Data.Ipv6) == 0)
+ return WIFI_ERROR_INVALID_PARAMETER;
+ }
if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false)
return WIFI_ERROR_NONE;
return _wifi_update_ap_info(profile_info);
}
-int wifi_ap_get_subnet_mask(wifi_ap_h ap, wifi_address_family_e address_family, char** subnet_mask)
+EXPORT_API int wifi_ap_get_subnet_mask(wifi_ap_h ap, wifi_address_family_e address_family, char** subnet_mask)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ char* prefixlen;
+
if (_wifi_libnet_check_ap_validity(ap) == false ||
(address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
subnet_mask == NULL) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ 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");
- return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+ net_profile_info_t *profile_info = ap;
+ if (address_family == WIFI_ADDRESS_FAMILY_IPV4)
+ *subnet_mask = __ap_convert_ip_to_string(
+ &profile_info->ProfileInfo.Wlan.net_info.SubnetMask,
+ address_family);
+ else {
+ prefixlen = g_try_malloc0(MAX_PREFIX_LENGTH);
+ snprintf(prefixlen, MAX_PREFIX_LENGTH, "%d",
+ profile_info->ProfileInfo.Wlan.net_info.PrefixLen6);
+ *subnet_mask = prefixlen;
}
- net_profile_info_t *profile_info = ap;
- *subnet_mask = __ap_convert_ip_to_string(&profile_info->ProfileInfo.Wlan.net_info.SubnetMask);
if (*subnet_mask == NULL)
return WIFI_ERROR_OUT_OF_MEMORY;
return WIFI_ERROR_NONE;
}
-int wifi_ap_set_subnet_mask(wifi_ap_h ap, wifi_address_family_e address_family, const char* subnet_mask)
+EXPORT_API int wifi_ap_set_subnet_mask(wifi_ap_h ap, wifi_address_family_e address_family, const char* subnet_mask)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (_wifi_libnet_check_ap_validity(ap) == false ||
(address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
- address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
- subnet_mask == NULL) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ address_family != WIFI_ADDRESS_FAMILY_IPV6)) {
+ 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");
- return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+ net_profile_info_t *profile_info = ap;
+
+ /* Based on the family of address provided subnet mask should be set.
+ * For IPv6 address subnet mask is prefix length, an integer, while for
+ * Ipv6 address subnet mask is a ipv6 address.
+ */
+ if (address_family == WIFI_ADDRESS_FAMILY_IPV6){
+ if (subnet_mask == NULL)
+ profile_info->ProfileInfo.Wlan.net_info.PrefixLen6 = 0;
+ else {
+ /* subnet mask provided as input parameter is a string
+ * while for IPv6 address subnet mask in prefix length
+ * which should be in integer form */
+ profile_info->ProfileInfo.Wlan.net_info.PrefixLen6 =
+ atoi(subnet_mask) ;
+ }
+ } else {
+ if (subnet_mask == NULL)
+ profile_info->ProfileInfo.Wlan.net_info.SubnetMask.Data.Ipv4.s_addr = 0;
+ else if (inet_pton(AF_INET, subnet_mask,
+ &(profile_info->ProfileInfo.Wlan.net_info.SubnetMask.Data.Ipv4)) < 1)
+ return WIFI_ERROR_INVALID_PARAMETER;
}
- net_profile_info_t *profile_info = ap;
- if (inet_aton(subnet_mask, &(profile_info->ProfileInfo.Wlan.net_info.SubnetMask.Data.Ipv4)) == 0)
- return WIFI_ERROR_INVALID_PARAMETER;
if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false)
return WIFI_ERROR_NONE;
return _wifi_update_ap_info(profile_info);
}
-int wifi_ap_get_gateway_address(wifi_ap_h ap, wifi_address_family_e address_family, char** gateway_address)
+EXPORT_API int wifi_ap_get_gateway_address(wifi_ap_h ap, wifi_address_family_e address_family, char** gateway_address)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (_wifi_libnet_check_ap_validity(ap) == false ||
(address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
gateway_address == NULL) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ 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");
- return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
- }
-
net_profile_info_t *profile_info = ap;
- *gateway_address = __ap_convert_ip_to_string(&profile_info->ProfileInfo.Wlan.net_info.GatewayAddr);
+
+ /* Based on the family of address provided, gateway should be set.
+ * For IPv6 address gateway is of form GatewayAddr6 but for IPv4
+ * gateway is of form GatewayAddr.
+ */
+ if (address_family == WIFI_ADDRESS_FAMILY_IPV4)
+ *gateway_address = __ap_convert_ip_to_string(
+ &profile_info->ProfileInfo.Wlan.net_info.GatewayAddr,
+ address_family);
+ else
+ *gateway_address = __ap_convert_ip_to_string(
+ &profile_info->ProfileInfo.Wlan.net_info.GatewayAddr6,
+ address_family);
+
if (*gateway_address == NULL)
return WIFI_ERROR_OUT_OF_MEMORY;
return WIFI_ERROR_NONE;
}
-int wifi_ap_set_gateway_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* gateway_address)
+EXPORT_API int wifi_ap_set_gateway_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* gateway_address)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (_wifi_libnet_check_ap_validity(ap) == false ||
(address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
- address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
- gateway_address == NULL) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ address_family != WIFI_ADDRESS_FAMILY_IPV6)) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
return WIFI_ERROR_INVALID_PARAMETER;
}
+ net_profile_info_t *profile_info = ap;
if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
- WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
- return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+ if (gateway_address == NULL)
+ inet_pton(AF_INET6, "::",
+ &profile_info->ProfileInfo.Wlan.net_info.GatewayAddr6.Data.Ipv6);
+ else if (inet_pton(AF_INET6, gateway_address,
+ &profile_info->ProfileInfo.Wlan.net_info.GatewayAddr6.Data.Ipv6) < 1)
+ return WIFI_ERROR_INVALID_PARAMETER;
+ } else {
+ if (gateway_address == NULL)
+ profile_info->ProfileInfo.Wlan.net_info.GatewayAddr.Data.Ipv4.s_addr = 0;
+ else if (inet_pton(AF_INET, gateway_address,
+ &profile_info->ProfileInfo.Wlan.net_info.GatewayAddr.Data.Ipv4) < 1)
+ return WIFI_ERROR_INVALID_PARAMETER;
}
- net_profile_info_t *profile_info = ap;
- if (inet_aton(gateway_address, &(profile_info->ProfileInfo.Wlan.net_info.GatewayAddr.Data.Ipv4)) == 0)
- return WIFI_ERROR_INVALID_PARAMETER;
-
if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false)
return WIFI_ERROR_NONE;
return _wifi_update_ap_info(profile_info);
}
-int wifi_ap_get_proxy_address(wifi_ap_h ap, wifi_address_family_e address_family, char** proxy_address)
+EXPORT_API int wifi_ap_get_proxy_address(wifi_ap_h ap, wifi_address_family_e address_family, char** proxy_address)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (_wifi_libnet_check_ap_validity(ap) == false ||
(address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
proxy_address == NULL) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ 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");
- return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
- }
-
net_profile_info_t *profile_info = ap;
*proxy_address = g_strdup(profile_info->ProfileInfo.Wlan.net_info.ProxyAddr);
if (*proxy_address == NULL)
return WIFI_ERROR_NONE;
}
-int wifi_ap_set_proxy_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* proxy_address)
+EXPORT_API int wifi_ap_set_proxy_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* proxy_address)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (_wifi_libnet_check_ap_validity(ap) == false ||
(address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
- address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
- proxy_address == NULL) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ address_family != WIFI_ADDRESS_FAMILY_IPV6)) {
+ 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");
- return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
- }
-
net_profile_info_t *profile_info = ap;
- g_strlcpy(profile_info->ProfileInfo.Wlan.net_info.ProxyAddr, proxy_address, NET_PROXY_LEN_MAX+1);
+
+ if (proxy_address == NULL)
+ profile_info->ProfileInfo.Wlan.net_info.ProxyAddr[0] = '\0';
+ else
+ g_strlcpy(profile_info->ProfileInfo.Wlan.net_info.ProxyAddr,
+ proxy_address, NET_PROXY_LEN_MAX+1);
if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false)
return WIFI_ERROR_NONE;
return _wifi_update_ap_info(profile_info);
}
-int wifi_ap_get_proxy_type(wifi_ap_h ap, wifi_proxy_type_e* type)
+EXPORT_API int wifi_ap_get_proxy_type(wifi_ap_h ap, wifi_proxy_type_e* type)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
*type = WIFI_PROXY_TYPE_MANUAL;
break;
case NET_PROXY_TYPE_UNKNOWN:
+ *type = WIFI_PROXY_TYPE_DIRECT;
+ break;
default:
return WIFI_ERROR_OPERATION_FAILED;
}
return WIFI_ERROR_NONE;
}
-int wifi_ap_set_proxy_type(wifi_ap_h ap, wifi_proxy_type_e proxy_type)
+EXPORT_API int wifi_ap_set_proxy_type(wifi_ap_h ap, wifi_proxy_type_e proxy_type)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
net_profile_info_t *profile_info = ap;
+ int rv;
switch (proxy_type) {
case WIFI_PROXY_TYPE_DIRECT:
profile_info->ProfileInfo.Wlan.net_info.ProxyMethod = NET_PROXY_TYPE_DIRECT;
break;
case WIFI_PROXY_TYPE_AUTO:
+ profile_info->ProfileInfo.Wlan.net_info.ProxyAddr[0] = '\0';
profile_info->ProfileInfo.Wlan.net_info.ProxyMethod = NET_PROXY_TYPE_AUTO;
break;
case WIFI_PROXY_TYPE_MANUAL:
+ profile_info->ProfileInfo.Wlan.net_info.ProxyAddr[0] = '\0';
profile_info->ProfileInfo.Wlan.net_info.ProxyMethod = NET_PROXY_TYPE_MANUAL;
break;
default:
if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false)
return WIFI_ERROR_NONE;
- return _wifi_update_ap_info(profile_info);
+ rv =_wifi_update_ap_info(profile_info);
+ if (rv != NET_ERR_NONE && proxy_type == WIFI_PROXY_TYPE_MANUAL) {
+ g_strlcpy(profile_info->ProfileInfo.Wlan.net_info.ProxyAddr, "0.0.0.0:8080", 15);
+ rv = _wifi_update_ap_info(profile_info);
+ }
+
+ return rv;
}
-int wifi_ap_get_dns_address(wifi_ap_h ap, int order, wifi_address_family_e address_family, char** dns_address)
+EXPORT_API int wifi_ap_get_dns_address(wifi_ap_h ap, int order, wifi_address_family_e address_family, char** dns_address)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (_wifi_libnet_check_ap_validity(ap) == false ||
(address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
dns_address == NULL ||
order <= 0 ||
order > NET_DNS_ADDR_MAX) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ 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");
- return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
- }
-
net_profile_info_t *profile_info = ap;
- *dns_address = __ap_convert_ip_to_string(&profile_info->ProfileInfo.Wlan.net_info.DnsAddr[order-1]);
+ if(address_family == WIFI_ADDRESS_FAMILY_IPV4)
+ *dns_address = __ap_convert_ip_to_string(
+ &profile_info->ProfileInfo.Wlan.net_info.DnsAddr[order-1],
+ address_family);
+ else
+ *dns_address = __ap_convert_ip_to_string(
+ &profile_info->ProfileInfo.Wlan.net_info.DnsAddr6[order-1],
+ address_family);
+
if (*dns_address == NULL)
return WIFI_ERROR_OUT_OF_MEMORY;
return WIFI_ERROR_NONE;
}
-int wifi_ap_set_dns_address(wifi_ap_h ap, int order, wifi_address_family_e address_family, const char* dns_address)
+EXPORT_API int wifi_ap_set_dns_address(wifi_ap_h ap, int order, wifi_address_family_e address_family, const char* dns_address)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (_wifi_libnet_check_ap_validity(ap) == false ||
(address_family != WIFI_ADDRESS_FAMILY_IPV4 &&
address_family != WIFI_ADDRESS_FAMILY_IPV6) ||
- dns_address == NULL ||
order <= 0 ||
order > NET_DNS_ADDR_MAX) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
return WIFI_ERROR_INVALID_PARAMETER;
}
+ net_profile_info_t *profile_info = ap;
+
if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
- WIFI_LOG(WIFI_ERROR, "Not supported yet\n");
- return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+ profile_info->ProfileInfo.Wlan.net_info.DnsAddr6[order-1].Type =
+ NET_ADDR_IPV6;
+ if (dns_address == NULL)
+ inet_pton(AF_INET6, "::",
+ &profile_info->ProfileInfo.Wlan.net_info.DnsAddr6[order-1].Data.Ipv6);
+ else if (inet_pton(AF_INET6, dns_address,
+ &profile_info->ProfileInfo.Wlan.net_info.DnsAddr6[order-1].Data.Ipv6) < 1)
+ return WIFI_ERROR_INVALID_PARAMETER;
+
+ if (profile_info->ProfileInfo.Wlan.net_info.DnsCount6 < order)
+ profile_info->ProfileInfo.Wlan.net_info.DnsCount6 = order;
+ } else {
+ profile_info->ProfileInfo.Wlan.net_info.DnsAddr[order-1].Type =
+ NET_ADDR_IPV4;
+ if (dns_address == NULL)
+ profile_info->ProfileInfo.Wlan.net_info.DnsAddr[order-1].Data.Ipv4.s_addr = 0;
+ else if (inet_pton(AF_INET, dns_address,
+ &(profile_info->ProfileInfo.Wlan.net_info.DnsAddr[order-1].Data.Ipv4)) < 1)
+ return WIFI_ERROR_INVALID_PARAMETER;
+
+ if (profile_info->ProfileInfo.Wlan.net_info.DnsCount < order)
+ profile_info->ProfileInfo.Wlan.net_info.DnsCount = order;
}
- net_profile_info_t *profile_info = ap;
- if (inet_aton(dns_address, &(profile_info->ProfileInfo.Wlan.net_info.DnsAddr[order-1].Data.Ipv4)) == 0)
- return WIFI_ERROR_INVALID_PARAMETER;
-
if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false)
return WIFI_ERROR_NONE;
return _wifi_update_ap_info(profile_info);
}
-
-
-/* Wi-Fi security information module **************************************************************/
-
-int wifi_ap_get_security_type(wifi_ap_h ap, wifi_security_type_e* type)
+/* Wi-Fi security information ************************************************/
+EXPORT_API int wifi_ap_get_security_type(wifi_ap_h ap, wifi_security_type_e* type)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return WIFI_ERROR_NONE;
}
-int wifi_ap_set_security_type(wifi_ap_h ap, wifi_security_type_e type)
+EXPORT_API int wifi_ap_set_security_type(wifi_ap_h ap, wifi_security_type_e type)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return WIFI_ERROR_INVALID_PARAMETER;
}
+ _wifi_set_profile_name_to_ap(profile_info);
+
return WIFI_ERROR_NONE;
}
-int wifi_ap_get_encryption_type(wifi_ap_h ap, wifi_encryption_type_e* type)
+EXPORT_API int wifi_ap_get_encryption_type(wifi_ap_h ap, wifi_encryption_type_e* type)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return WIFI_ERROR_NONE;
}
-int wifi_ap_set_encryption_type(wifi_ap_h ap, wifi_encryption_type_e type)
+EXPORT_API int wifi_ap_set_encryption_type(wifi_ap_h ap, wifi_encryption_type_e type)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return WIFI_ERROR_NONE;
}
-int wifi_ap_is_passphrase_required(wifi_ap_h ap, bool* required)
+EXPORT_API int wifi_ap_is_passphrase_required(wifi_ap_h ap, bool* required)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
net_profile_info_t *profile_info = ap;
- if (profile_info->ProfileInfo.Wlan.PassphraseRequired)
- *required = true;
- else
+ if (profile_info->Favourite) {
*required = false;
+ return WIFI_ERROR_NONE;
+ }
+
+ switch (profile_info->ProfileInfo.Wlan.security_info.sec_mode) {
+ case WLAN_SEC_MODE_NONE:
+ *required = false;
+ break;
+ case WLAN_SEC_MODE_WEP:
+ case WLAN_SEC_MODE_IEEE8021X:
+ case WLAN_SEC_MODE_WPA_PSK:
+ case WLAN_SEC_MODE_WPA2_PSK:
+ *required = true;
+ break;
+ default:
+ return WIFI_ERROR_OPERATION_FAILED;
+ }
return WIFI_ERROR_NONE;
}
-int wifi_ap_set_passphrase(wifi_ap_h ap, const char* passphrase)
+EXPORT_API int wifi_ap_set_passphrase(wifi_ap_h ap, const char* passphrase)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return WIFI_ERROR_OPERATION_FAILED;
}
- if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false)
- return WIFI_ERROR_NONE;
-
- return _wifi_update_ap_info(profile_info);
+ return WIFI_ERROR_NONE;
}
-int wifi_ap_is_wps_supported(wifi_ap_h ap, bool* supported)
+EXPORT_API int wifi_ap_is_wps_supported(wifi_ap_h ap, bool* supported)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return WIFI_ERROR_NONE;
}
+/* Wi-Fi EAP *****************************************************************/
+EXPORT_API int wifi_ap_set_eap_passphrase(wifi_ap_h ap, const char* user_name, const char* password)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_libnet_check_ap_validity(ap) == false || (user_name == NULL && password == NULL)) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+ return WIFI_ERROR_INVALID_PARAMETER;
+ }
+
+ net_profile_info_t *profile_info = ap;
+ if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
+ return WIFI_ERROR_INVALID_OPERATION;
+ if (user_name)
+ g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.username,
+ user_name, NETPM_WLAN_USERNAME_LEN+1);
-/* Wi-Fi EAP module *******************************************************************************/
+ if (password)
+ g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.password,
+ password, NETPM_WLAN_PASSWORD_LEN+1);
-int wifi_ap_set_eap_passphrase(wifi_ap_h ap, const char* user_name, const char* password)
+ return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_ap_get_eap_passphrase(wifi_ap_h ap, char** user_name, bool* is_password_set)
{
- if (_wifi_libnet_check_ap_validity(ap) == false || user_name == NULL || password == NULL) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_libnet_check_ap_validity(ap) == false ||user_name == NULL || is_password_set == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
return WIFI_ERROR_INVALID_PARAMETER;
}
if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
return WIFI_ERROR_INVALID_OPERATION;
- g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.username,
- user_name, NETPM_WLAN_USERNAME_LEN+1);
- g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.password,
- password, NETPM_WLAN_PASSWORD_LEN+1);
+ *user_name = g_strdup(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.username);
+ if (*user_name == NULL)
+ return WIFI_ERROR_OUT_OF_MEMORY;
+
+ if (strlen(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.password) > 0)
+ *is_password_set = true;
+ else
+ *is_password_set = false;
+
return WIFI_ERROR_NONE;
}
-int wifi_ap_get_eap_ca_cert_file(wifi_ap_h ap, char** file)
+EXPORT_API int wifi_ap_get_eap_ca_cert_file(wifi_ap_h ap, char** file)
{
+ net_profile_info_t *profile_info = NULL;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
return WIFI_ERROR_NONE;
}
-int wifi_ap_set_eap_ca_cert_file(wifi_ap_h ap, const 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;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
return WIFI_ERROR_NONE;
}
-int wifi_ap_get_eap_client_cert_file(wifi_ap_h ap, 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;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
return WIFI_ERROR_NONE;
}
-int wifi_ap_set_eap_client_cert_file(wifi_ap_h ap, const 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;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
return WIFI_ERROR_NONE;
}
-int wifi_ap_get_eap_private_key_file(wifi_ap_h ap, char** file)
+EXPORT_API int wifi_ap_get_eap_private_key_file(wifi_ap_h ap, char** file)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return WIFI_ERROR_NONE;
}
-int wifi_ap_set_eap_private_key_info(wifi_ap_h ap, const char* file, const char* password)
+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 || password == NULL) {
- WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
return WIFI_ERROR_INVALID_PARAMETER;
}
g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.private_key_filename,
file, NETPM_WLAN_PRIVATE_KEY_FILENAME_LEN+1);
- g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.private_key_passwd,
- password, NETPM_WLAN_PRIVATE_KEY_PASSWD_LEN+1);
+
+ if (password) {
+ g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.private_key_passwd,
+ password, NETPM_WLAN_PRIVATE_KEY_PASSWD_LEN+1);
+ }
return WIFI_ERROR_NONE;
}
-int wifi_ap_get_eap_type(wifi_ap_h ap, wifi_eap_type_e* type)
+EXPORT_API int wifi_ap_get_eap_type(wifi_ap_h ap, wifi_eap_type_e* type)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return WIFI_ERROR_NONE;
}
-int wifi_ap_set_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)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return WIFI_ERROR_NONE;
}
-int wifi_ap_get_eap_auth_type(wifi_ap_h ap, wifi_eap_auth_type_e* type)
+EXPORT_API int wifi_ap_get_eap_auth_type(wifi_ap_h ap, wifi_eap_auth_type_e* type)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return WIFI_ERROR_NONE;
}
-int wifi_ap_set_eap_auth_type(wifi_ap_h ap, wifi_eap_auth_type_e type)
+EXPORT_API int wifi_ap_set_eap_auth_type(wifi_ap_h ap, wifi_eap_auth_type_e type)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
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;
}
return WIFI_ERROR_NONE;
}
-
-
+PROJECT(wifi_test C)
+
SET(fw_test "${fw_name}-test")
+SET(dependents "capi-base-common glib-2.0 network")
+SET(pc_dependents "capi-base-common")
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_test} REQUIRED glib-2.0)
+pkg_check_modules(${fw_test} REQUIRED ${dependents})
FOREACH(flag ${${fw_test}_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
ADD_EXECUTABLE(${src_name} ${src})
TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS})
ENDFOREACH()
+
+INSTALL(TARGETS wifi_test RUNTIME DESTINATION bin/)
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <errno.h>
#include <sys/ioctl.h>
#include <signal.h>
-#include "assert.h"
-#include "glib.h"
+#include <assert.h>
#include <wifi.h>
#include <tizen_error.h>
gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data);
+static const char *__test_convert_error_to_string(wifi_error_e err_type)
+{
+ switch (err_type) {
+ case WIFI_ERROR_NONE:
+ return "NONE";
+ case WIFI_ERROR_INVALID_PARAMETER:
+ return "INVALID_PARAMETER";
+ case WIFI_ERROR_OUT_OF_MEMORY:
+ return "OUT_OF_MEMORY";
+ case WIFI_ERROR_INVALID_OPERATION:
+ return "INVALID_OPERATION";
+ case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+ return "ADDRESS_FAMILY_NOT_SUPPORTED";
+ case WIFI_ERROR_OPERATION_FAILED:
+ return "OPERATION_FAILED";
+ case WIFI_ERROR_NO_CONNECTION:
+ return "NO_CONNECTION";
+ case WIFI_ERROR_NOW_IN_PROGRESS:
+ return "NOW_IN_PROGRESS";
+ case WIFI_ERROR_ALREADY_EXISTS:
+ return "ALREADY_EXISTS";
+ case WIFI_ERROR_OPERATION_ABORTED:
+ return "OPERATION_ABORTED";
+ case WIFI_ERROR_DHCP_FAILED:
+ return "DHCP_FAILED";
+ case WIFI_ERROR_INVALID_KEY:
+ return "INVALID_KEY";
+ case WIFI_ERROR_NO_REPLY:
+ return "NO_REPLY";
+ case WIFI_ERROR_SECURITY_RESTRICTED:
+ return "SECURITY_RESTRICTED";
+ case WIFI_ERROR_PERMISSION_DENIED:
+ return "PERMISSION_DENIED";
+ case WIFI_ERROR_NOT_SUPPORTED:
+ return "NOT_SUPPORTED";
+ }
+
+ return "UNKNOWN";
+}
-static void __test_device_state_callback(wifi_error_e error_code, wifi_device_state_e state, bool is_requested, void* user_data)
+static void __test_device_state_callback(wifi_device_state_e state, void* user_data)
{
- printf("Device state changed callback, error code : %d, requested : %d", error_code, is_requested);
+ printf("Device state changed callback");
if (state == WIFI_DEVICE_STATE_ACTIVATED)
printf(", state : Activated\n");
static void __test_bg_scan_completed_callback(wifi_error_e error_code, void* user_data)
{
- printf("Background Scan Completed, error code : %d\n", error_code);
+ printf("Background Scan Completed, error code : %s\n",
+ __test_convert_error_to_string(error_code));
}
static void __test_scan_request_callback(wifi_error_e error_code, void* user_data)
{
- printf("Scan Completed from scan request, error code : %d\n", error_code);
+ printf("Scan Completed from scan request, error code : %s\n",
+ __test_convert_error_to_string(error_code));
}
-static void __test_connection_state_callback(wifi_error_e error_code, wifi_connection_state_e state, wifi_ap_h ap, bool is_requested, void* user_data)
+static void __test_connection_state_callback(wifi_connection_state_e state, wifi_ap_h ap, void* user_data)
{
int rv = 0;
char *ap_name = NULL;
- printf("Connection state changed callback, error code : %d, requested : %d", error_code, is_requested);
+ printf("Connection state changed callback");
switch (state) {
- case WIFI_CONNECTION_STATE_CONNECTING:
- printf(", state : Connecting");
- break;
case WIFI_CONNECTION_STATE_CONNECTED:
printf(", state : Connected");
break;
- case WIFI_CONNECTION_STATE_DISCONNECTING:
- printf(", state : Disconnecting");
+ case WIFI_CONNECTION_STATE_ASSOCIATION:
+ printf(", state : Association");
+ break;
+ case WIFI_CONNECTION_STATE_CONFIGURATION:
+ printf(", state : Configuration");
break;
case WIFI_CONNECTION_STATE_DISCONNECTED:
printf(", state : Disconnected");
break;
+ default:
+ printf(", state : Unknown");
}
rv = wifi_ap_get_essid(ap, &ap_name);
if (rv != WIFI_ERROR_NONE)
- printf(", Fail to get AP name [%d]\n", rv);
+ printf(", Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
else {
printf(", AP name : %s\n", ap_name);
g_free(ap_name);
}
}
+static void __test_activated_callback(wifi_error_e result, void* user_data)
+{
+ if (result == WIFI_ERROR_NONE)
+ printf("Wi-Fi Activation Succeeded\n");
+ else
+ printf("Wi-Fi Activation Failed! error : %s", __test_convert_error_to_string(result));
+}
+
+static void __test_deactivated_callback(wifi_error_e result, void* user_data)
+{
+ if (result == WIFI_ERROR_NONE)
+ printf("Wi-Fi Deactivation Succeeded\n");
+ else
+ printf("Wi-Fi Deactivation Failed! error : %s", __test_convert_error_to_string(result));
+}
+
+static void __test_connected_callback(wifi_error_e result, void* user_data)
+{
+ if (result == WIFI_ERROR_NONE)
+ printf("Wi-Fi Connection Succeeded\n");
+ else
+ printf("Wi-Fi Connection Failed! error : %s", __test_convert_error_to_string(result));
+}
+
+static void __test_disconnected_callback(wifi_error_e result, void* user_data)
+{
+ if (result == WIFI_ERROR_NONE)
+ printf("Wi-Fi Disconnection Succeeded\n");
+ else
+ printf("Wi-Fi Disconnection Failed! error : %s", __test_convert_error_to_string(result));
+}
+
static void __test_rssi_level_callback(wifi_rssi_level_e rssi_level, void* user_data)
{
printf("RSSI level changed callback, level = %d\n", rssi_level);
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_CONNECTING:
- return "Connecting";
+ case WIFI_CONNECTION_STATE_ASSOCIATION:
+ return "Association";
case WIFI_CONNECTION_STATE_CONNECTED:
return "Connected";
- case WIFI_CONNECTION_STATE_DISCONNECTING:
- return "Disconnecting";
+ case WIFI_CONNECTION_STATE_CONFIGURATION:
+ return "Configuration";
}
return "Unknown";
rv = wifi_ap_get_essid(ap, &ap_name);
if (rv != WIFI_ERROR_NONE) {
- printf("Fail to get AP name [%d]\n", rv);
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
return false;
}
rv = wifi_ap_get_connection_state(ap, &state);
if (rv != WIFI_ERROR_NONE) {
- printf("Fail to get State [%d]\n", rv);
+ printf("Fail to get State [%s]\n", __test_convert_error_to_string(rv));
g_free(ap_name);
return false;
}
rv = wifi_ap_get_essid(ap, &ap_name);
if (rv != WIFI_ERROR_NONE) {
- printf("Fail to get AP name [%d]\n", rv);
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
return false;
}
if (strstr(ap_name, ap_name_part) != NULL) {
bool required = false;
- wifi_ap_is_passphrase_required(ap, &required);
+
+ if (wifi_ap_is_passphrase_required(ap, &required) == WIFI_ERROR_NONE)
+ printf("Passphrase required : %s\n", required ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get Passphrase required\n");
if (required) {
char passphrase[100];
printf("Input passphrase for %s : ", ap_name);
- rv = scanf("%100s", passphrase);
+ rv = scanf("%99s", passphrase);
rv = wifi_ap_set_passphrase(ap, passphrase);
if (rv != WIFI_ERROR_NONE) {
- printf("Fail to set passphrase : %d\n", rv);
+ printf("Fail to set passphrase : %s\n", __test_convert_error_to_string(rv));
g_free(ap_name);
return false;
}
}
- rv = wifi_connect(ap);
+ rv = wifi_connect(ap, __test_connected_callback, NULL);
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to connection request [%s]\n", ap_name);
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_found_connect_wps_callback(wifi_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (strstr(ap_name, ap_name_part) != NULL) {
+ rv = wifi_connect(ap, __test_connected_callback, NULL);
if (rv != WIFI_ERROR_NONE)
- printf("Fail to connect [%s] : %d\n", ap_name, rv);
+ printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
else
- printf("Success to connect [%s]\n", ap_name);
+ printf("Success to connection request [%s]\n", ap_name);
g_free(ap_name);
return false;
rv = wifi_ap_get_essid(ap, &ap_name);
if (rv != WIFI_ERROR_NONE) {
- printf("Fail to get AP name [%d]\n", rv);
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
return false;
}
if (strstr(ap_name, ap_name_part) != NULL) {
- rv = wifi_disconnect(ap);
+ rv = wifi_disconnect(ap, __test_disconnected_callback, NULL);
if (rv != WIFI_ERROR_NONE)
- printf("Fail to disconnect %s : [%d]\n", ap_name, rv);
+ printf("Fail to disconnection reqeust %s : [%s]\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to disconnection request %s\n", ap_name);
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_found_forget_ap_callback(wifi_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (strstr(ap_name, ap_name_part) != NULL) {
+ rv = wifi_forget_ap(ap);
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to forget [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to forget [%s]\n", ap_name);
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_found_eap_ap_callback(wifi_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (strstr(ap_name, ap_name_part) != NULL) {
+ wifi_security_type_e type;
+
+ if (wifi_ap_get_security_type(ap, &type) == WIFI_ERROR_NONE)
+ printf("Security type : %d\n", type);
+ else
+ printf("Fail to get Security type\n");
+
+ if (type != WIFI_SECURITY_TYPE_EAP) {
+ g_free(ap_name);
+ return false;
+ }
+
+ char input_str1[100];
+ printf("Input user name for %s : ", ap_name);
+ rv = scanf("%99s", input_str1);
+
+ char input_str2[100];
+ printf("Input password for %s : ", ap_name);
+ rv = scanf("%99s", input_str2);
+
+ rv = wifi_ap_set_eap_passphrase(ap, input_str1, input_str2);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to set eap passphrase : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ char *inputed_name = NULL;
+ bool is_pass_set;
+ rv = wifi_ap_get_eap_passphrase(ap, &inputed_name, &is_pass_set);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get eap passphrase : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ printf("name : %s, is password set : %s\n", inputed_name, is_pass_set ? "TRUE" : "FALSE");
+
+ rv = wifi_connect(ap, __test_connected_callback, NULL);
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to connection request [%s]\n", ap_name);
+
+ g_free(ap_name);
+ g_free(inputed_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool test_get_user_int(const char *msg, int *num)
+{
+ if (msg == NULL || num == NULL)
+ return false;
+
+ int rv;
+ char buf[32] = {0,};
+ printf("%s\n", msg);
+ rv = read(0, buf, 32);
+
+ if (rv < 0 || *buf == 0 || *buf == '\n' || *buf == '\r')
+ return false;
+
+ *num = atoi(buf);
+ return true;
+}
+
+static bool __test_found_change_ip_method_callback(wifi_ap_h ap, void *user_data)
+{
+ int rv;
+ char *ap_name;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (strstr(ap_name, ap_name_part) != NULL) {
+ wifi_ip_config_type_e type;
+ int method;
+ int address_type;
+
+ printf("Input new method type (1:dhcp, 2:manual, 3:auto) :\n");
+ rv = scanf("%9d", &method);
+ if (rv <= 0) {
+ g_free(ap_name);
+ return false;
+ }
+
+ rv = test_get_user_int("Input Address type to get"
+ "(0:IPV4, 1:IPV6):", &address_type);
+
+ if (rv == false || (address_type != 0 && address_type != 1)) {
+ printf("Invalid input!!\n");
+ return false;
+ }
+
+ switch (method) {
+ case 1:
+ type = WIFI_IP_CONFIG_TYPE_DYNAMIC;
+ break;
+ case 2:
+ type = WIFI_IP_CONFIG_TYPE_STATIC;
+ break;
+ case 3:
+ type = WIFI_IP_CONFIG_TYPE_AUTO;
+ break;
+ default:
+ printf("Invalid input!\n");
+ g_free(ap_name);
+ return false;
+ }
+
+ rv = wifi_ap_set_ip_config_type(ap, address_type, type);
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to set ip method type[%s]\n", __test_convert_error_to_string(rv));
+
+ if (type == WIFI_IP_CONFIG_TYPE_STATIC) {
+ char ip_addr[16];
+
+ printf("Input new ip address (x:skip, 0:clear) :\n");
+ rv = scanf("%15s", ip_addr);
+ if (rv > 0) {
+ switch (ip_addr[0]) {
+ case 'x':
+ rv = WIFI_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_ap_set_ip_address(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_ap_set_ip_address(ap, address_type, ip_addr);
+ }
+
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to set ip address[%s]\n",
+ __test_convert_error_to_string(rv));
+ }
+
+ printf("Input new subnet mask (x:skip, 0:clear) :\n");
+ rv = scanf("%15s", ip_addr);
+ if (rv > 0) {
+ switch (ip_addr[0]) {
+ case 'x':
+ rv = WIFI_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_ap_set_subnet_mask(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_ap_set_subnet_mask(ap, address_type, ip_addr);
+ }
+
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to set subnet mask[%s]\n",
+ __test_convert_error_to_string(rv));
+ }
+
+ printf("Input new gateway address (x:skip, 0:clear) :\n");
+ rv = scanf("%15s", ip_addr);
+ if (rv > 0) {
+ switch (ip_addr[0]) {
+ case 'x':
+ rv = WIFI_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_ap_set_gateway_address(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_ap_set_gateway_address(ap, address_type, ip_addr);
+ }
+
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to set gateway address[%s]\n",
+ __test_convert_error_to_string(rv));
+ }
+ }
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_found_change_proxy_method_callback(wifi_ap_h ap, void *user_data)
+{
+ int rv, address_type;
+ char *ap_name;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ printf("ap_name %s, user input name %s\n", ap_name, ap_name_part);
+ if (strstr(ap_name, ap_name_part) != NULL) {
+ wifi_proxy_type_e type;
+ char proxy_addr[65];
+ int method;
+
+ printf("Input new method type (1:direct, 2:manual, 3:auto) :\n");
+ rv = scanf("%9d", &method);
+ if (rv <= 0) {
+ g_free(ap_name);
+ return false;
+ }
+
+ rv = test_get_user_int("Input Address type to get"
+ "(0:IPV4, 1:IPV6):", &address_type);
+
+ if (rv == false || (address_type != 0 && address_type != 1)) {
+ printf("Invalid input!!\n");
+ return false;
+ }
+
+ switch (method) {
+ case 1:
+ type = WIFI_PROXY_TYPE_DIRECT;
+ break;
+ case 2:
+ type = WIFI_PROXY_TYPE_MANUAL;
+ break;
+ case 3:
+ type = WIFI_PROXY_TYPE_AUTO;
+ break;
+ default:
+ printf("Invalid input!\n");
+ g_free(ap_name);
+ return false;
+ }
+
+ rv = wifi_ap_set_proxy_type(ap, type);
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to set proxy method type[%s]\n", __test_convert_error_to_string(rv));
+
+ printf("Input new proxy address (x:skip, 0:clear) :\n");
+ rv = scanf("%64s", proxy_addr);
+
+ if (rv > 0) {
+ switch (proxy_addr[0]) {
+ case 'x':
+ rv = WIFI_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_ap_set_proxy_address(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_ap_set_proxy_address(ap, address_type, proxy_addr);
+ }
+
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to set proxy address[%s]\n", __test_convert_error_to_string(rv));
+ }
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_found_print_ap_info_callback(wifi_ap_h ap, void *user_data)
+{
+ int rv, address_type = 0;
+ char *ap_name;
+ char *str_value;
+ int int_value;
+ wifi_connection_state_e conn_state;
+ wifi_ip_config_type_e ip_type;
+ wifi_proxy_type_e proxy_type;
+ wifi_security_type_e sec_type;
+ wifi_encryption_type_e enc_type;
+ wifi_eap_type_e eap_type;
+ wifi_eap_auth_type_e eap_auth_type;
+ bool bool_value;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ printf("ap_name %s, user input name %s\n", ap_name, ap_name_part);
+ if (strstr(ap_name, ap_name_part) != NULL) {
+
+ /* Basic info */
+ printf("ESSID : %s\n", ap_name);
+
+ if (wifi_ap_get_bssid(ap, &str_value) == WIFI_ERROR_NONE) {
+ printf("BSSID : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get BSSID\n");
+
+ if (wifi_ap_get_rssi(ap, &int_value) == WIFI_ERROR_NONE)
+ printf("RSSI : %d\n", int_value);
+ else
+ printf("Fail to get RSSI\n");
+
+ if (wifi_ap_get_frequency(ap, &int_value) == WIFI_ERROR_NONE)
+ printf("Frequency : %d\n", int_value);
+ else
+ printf("Fail to get Frequency\n");
+
+ if (wifi_ap_get_max_speed(ap, &int_value) == WIFI_ERROR_NONE)
+ printf("Max speed : %d\n", int_value);
+ else
+ printf("Fail to get Max speed\n");
+
+ if (wifi_ap_is_favorite(ap, &bool_value) == WIFI_ERROR_NONE)
+ printf("Favorite : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get Favorite\n");
+
+ /* Network info */
+ if (wifi_ap_get_connection_state(ap, &conn_state) == WIFI_ERROR_NONE)
+ printf("Connection State : %d\n", conn_state);
+ else
+ printf("Fail to get Connection State\n");
+
+ rv = test_get_user_int("Input Address type to get"
+ "(0:IPV4, 1:IPV6):", &address_type);
+
+ if (rv == false || (address_type != 0 && address_type != 1)) {
+ printf("Invalid input!!\n");
+ return false;
+ }
+
+ if (wifi_ap_get_ip_config_type(ap, address_type, &ip_type) == WIFI_ERROR_NONE)
+ printf("IP config type : %d\n", ip_type);
+ else
+ printf("Fail to get IP config type\n");
+
+ if (wifi_ap_get_ip_address(ap, address_type, &str_value) == WIFI_ERROR_NONE) {
+ printf("IP : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get IP\n");
+
+ if (wifi_ap_get_subnet_mask(ap, address_type, &str_value) == WIFI_ERROR_NONE) {
+ printf("Subnet mask : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get Subnet mask\n");
+
+ if (wifi_ap_get_gateway_address(ap, address_type, &str_value) == WIFI_ERROR_NONE) {
+ printf("Gateway : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get Gateway\n");
+
+ if (wifi_ap_get_proxy_type(ap, &proxy_type) == WIFI_ERROR_NONE)
+ printf("Proxy type : %d\n", proxy_type);
+ else
+ printf("Fail to get Proxy type\n");
+
+ if (wifi_ap_get_proxy_address(ap, address_type, &str_value) == WIFI_ERROR_NONE) {
+ printf("Proxy : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get Proxy\n");
+
+ if (wifi_ap_get_dns_address(ap, 1, address_type, &str_value) == WIFI_ERROR_NONE) {
+ printf("DNS1 : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get DNS1\n");
+
+ if (wifi_ap_get_dns_address(ap, 2, address_type, &str_value) == WIFI_ERROR_NONE) {
+ printf("DNS2 : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get DNS2\n");
+
+ /* Security info */
+ if (wifi_ap_get_security_type(ap, &sec_type) == WIFI_ERROR_NONE)
+ printf("Security type : %d\n", sec_type);
+ else
+ printf("Fail to get Security type\n");
+
+ if (wifi_ap_get_encryption_type(ap, &enc_type) == WIFI_ERROR_NONE)
+ printf("Encryption type : %d\n", enc_type);
+ else
+ printf("Fail to get Encryption type\n");
+
+ if (wifi_ap_is_passphrase_required(ap, &bool_value) == WIFI_ERROR_NONE)
+ printf("Passphrase required : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get Passphrase required\n");
+
+ if (wifi_ap_is_wps_supported(ap, &bool_value) == WIFI_ERROR_NONE)
+ printf("WPS supported : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get WPS supported\n");
+
+ if (sec_type != WIFI_SECURITY_TYPE_EAP) {
+ g_free(ap_name);
+ return false;
+ }
+
+ /* EAP info */
+ if (wifi_ap_get_eap_type(ap, &eap_type) == WIFI_ERROR_NONE)
+ printf("EAP type : %d\n", eap_type);
+ else
+ printf("Fail to get EAP type\n");
+
+ if (wifi_ap_get_eap_auth_type(ap, &eap_auth_type) == WIFI_ERROR_NONE)
+ printf("EAP auth type : %d\n", eap_auth_type);
else
- printf("Success to disconnect %s\n", ap_name);
+ printf("Fail to get EAP auth type\n");
+
+ if (wifi_ap_get_eap_passphrase(ap, &str_value, &bool_value) == WIFI_ERROR_NONE) {
+ printf("EAP user name : %s\n", str_value);
+ printf("EAP is password setted : %s\n", bool_value ? "TRUE" : "FALSE");
+ g_free(str_value);
+ } else
+ printf("Fail to get EAP passphrase(user name/password)\n");
+
+ if (wifi_ap_get_eap_ca_cert_file(ap, &str_value) == WIFI_ERROR_NONE) {
+ printf("EAP ca cert file : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get EAP ca cert file\n");
+
+ if (wifi_ap_get_eap_client_cert_file(ap, &str_value) == WIFI_ERROR_NONE) {
+ printf("EAP client cert file : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get EAP client cert file\n");
+
+ if (wifi_ap_get_eap_private_key_file(ap, &str_value) == WIFI_ERROR_NONE) {
+ printf("EAP private key file : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get EAP private key file\n");
g_free(ap_name);
return false;
wifi_set_connection_state_changed_cb(__test_connection_state_callback, NULL);
wifi_set_rssi_level_changed_cb(__test_rssi_level_callback, NULL);
} else {
- printf("Wifi init failed [%d]\n", rv);
+ printf("Wifi init failed [%s]\n", __test_convert_error_to_string(rv));
return -1;
}
rv = wifi_deinitialize();
if (rv != WIFI_ERROR_NONE){
- printf("Wifi deinit failed [%d]\n", rv);
+ printf("Wifi deinit failed [%s]\n", __test_convert_error_to_string(rv));
return -1;
}
{
int rv = 0;
- rv = wifi_activate();
+ rv = wifi_activate(__test_activated_callback, NULL);
if (rv != WIFI_ERROR_NONE) {
- printf("Fail to activate Wi-Fi device [%d]\n", rv);
+ printf("Fail to activate Wi-Fi device [%s]\n", __test_convert_error_to_string(rv));
return -1;
}
{
int rv = 0;
- rv = wifi_deactivate();
+ rv = wifi_deactivate(__test_deactivated_callback, NULL);
if (rv != WIFI_ERROR_NONE) {
- printf("Fail to deactivate Wi-Fi device [%d]\n", rv);
+ printf("Fail to deactivate Wi-Fi device [%s]\n", __test_convert_error_to_string(rv));
return -1;
}
int test_is_activated(void)
{
int rv = 0;
- bool state;
+ bool state = false;
rv = wifi_is_activated(&state);
if (rv != WIFI_ERROR_NONE) {
- printf("Fail to get Wi-Fi device state [%d]\n", rv);
+ printf("Fail to get Wi-Fi device state [%s]\n", __test_convert_error_to_string(rv));
return -1;
}
rv = wifi_get_connection_state(&connection_state);
if (rv != WIFI_ERROR_NONE) {
- printf("Fail to get connection state [%d]\n", rv);
+ printf("Fail to get connection state [%s]\n", __test_convert_error_to_string(rv));
return -1;
}
printf("Success to get connection state : ");
switch (connection_state) {
- case WIFI_CONNECTION_STATE_CONNECTING:
- printf("Connecting\n");
+ case WIFI_CONNECTION_STATE_ASSOCIATION:
+ printf("Association\n");
break;
case WIFI_CONNECTION_STATE_CONNECTED:
printf("Connected\n");
break;
- case WIFI_CONNECTION_STATE_DISCONNECTING:
- printf("Disconnecting\n");
+ case WIFI_CONNECTION_STATE_CONFIGURATION:
+ printf("Configuration\n");
break;
case WIFI_CONNECTION_STATE_DISCONNECTED:
printf("Disconnected\n");
rv = wifi_get_mac_address(&mac_addr);
if (rv != WIFI_ERROR_NONE) {
- printf("Fail to get MAC address [%d]\n", rv);
+ printf("Fail to get MAC address [%s]\n", __test_convert_error_to_string(rv));
return -1;
}
rv = wifi_get_network_interface_name(&if_name);
if (rv != WIFI_ERROR_NONE) {
- printf("Fail to get Interface name [%d]\n", rv);
+ printf("Fail to get Interface name [%s]\n", __test_convert_error_to_string(rv));
return -1;
}
rv = wifi_scan(__test_scan_request_callback, NULL);
if (rv != WIFI_ERROR_NONE) {
- printf("Scan request failed [%d]\n", rv);
+ printf("Scan request failed [%s]\n", __test_convert_error_to_string(rv));
return -1;
}
rv = wifi_get_connected_ap(&ap_h);
if (rv != WIFI_ERROR_NONE) {
- printf("Fail to get connected AP [%d]\n", rv);
+ printf("Fail to get connected AP [%s]\n", __test_convert_error_to_string(rv));
return -1;
}
rv = wifi_ap_get_essid(ap_h, &ap_name);
if (rv != WIFI_ERROR_NONE) {
- printf("Fail to get connected AP [%d]\n", rv);
+ printf("Fail to get essid [%s]\n", __test_convert_error_to_string(rv));
wifi_ap_destroy(ap_h);
return -1;
}
rv = wifi_foreach_found_aps(__test_found_ap_callback, NULL);
if (rv != WIFI_ERROR_NONE) {
- printf("Fail to get AP list [%d]\n", rv);
+ printf("Fail to get AP list [%s]\n", __test_convert_error_to_string(rv));
return -1;
}
int test_connect_ap(void)
{
int rv = 0;
- char ap_name[32];
+ char ap_name[33];
+ bool state = false;
+
+ wifi_is_activated(&state);
+ if (state == false)
+ return -1;
printf("Input a part of AP name to connect : ");
rv = scanf("%32s", ap_name);
rv = wifi_foreach_found_aps(__test_found_connect_ap_callback, ap_name);
if (rv != WIFI_ERROR_NONE) {
- printf("Fail to connect (can't get AP list) [%d]\n", rv);
+ printf("Fail to connect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
return -1;
}
int test_disconnect_ap(void)
{
int rv = 0;
- char ap_name[32];
+ char ap_name[33];
+ bool state = false;
+
+ wifi_is_activated(&state);
+ if (state == false)
+ return -1;
printf("Input a part of AP name to disconnect : ");
rv = scanf("%32s", ap_name);
rv = wifi_foreach_found_aps(__test_found_disconnect_ap_callback, ap_name);
if (rv != WIFI_ERROR_NONE) {
- printf("Fail to disconnect (can't get AP list) [%d]\n", rv);
+ printf("Fail to disconnect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
return -1;
}
return 1;
}
+int test_connect_wps(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_is_activated(&state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to connect by wps : ");
+ rv = scanf("%32s", ap_name);
+
+ rv = wifi_foreach_found_aps(__test_found_connect_wps_callback, ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to connect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Connection step finished\n");
+ return 1;
+}
+
+int test_forget_ap(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_is_activated(&state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to forget : ");
+ rv = scanf("%32s", ap_name);
+
+ rv = wifi_foreach_found_aps(__test_found_forget_ap_callback, ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to forget (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Forget AP finished\n");
+ return 1;
+}
+
+int test_connect_eap_ap(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_is_activated(&state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to connect : ");
+ rv = scanf("%32s", ap_name);
+
+ rv = wifi_foreach_found_aps(__test_found_eap_ap_callback, ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to connect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Connection step finished\n");
+ return 1;
+}
+
+int test_set_ip_method(void)
+{
+ int rv;
+ char ap_name[33];
+ bool state;
+
+ rv = wifi_is_activated(&state);
+ if (rv != WIFI_ERROR_NONE || state == false)
+ return -1;
+
+ printf("Input a part of AP name to change IP method : ");
+ rv = scanf("%32s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_foreach_found_aps(__test_found_change_ip_method_callback, ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to change (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("IP method changing finished\n");
+ return 1;
+}
+
+int test_set_proxy_method(void)
+{
+ int rv;
+ char ap_name[33];
+ bool state;
+
+ rv = wifi_is_activated(&state);
+ if (rv != WIFI_ERROR_NONE || state == false)
+ return -1;
+
+ printf("Input a part of AP name to change Proxy method : ");
+ rv = scanf("%32s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_foreach_found_aps(__test_found_change_proxy_method_callback, ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to change (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Proxy method changing finished\n");
+ return 1;
+}
+
+int test_get_ap_info(void)
+{
+ int rv;
+ char ap_name[33];
+ bool state;
+
+ rv = wifi_is_activated(&state);
+ if (rv != WIFI_ERROR_NONE || state == false)
+ return -1;
+
+ printf("Input a part of AP name to get detailed info : ");
+ rv = scanf("%32s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_foreach_found_aps(__test_found_print_ap_info_callback, ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP info (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("AP info printing finished\n");
+ return 1;
+}
+
int main(int argc, char **argv)
{
GMainLoop *mainloop;
mainloop = g_main_loop_new (NULL, FALSE);
GIOChannel *channel = g_io_channel_unix_new(0);
- g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread,NULL );
+ g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread, NULL);
printf("Test Thread created...\n");
gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
{
- int rv = 0;
- char a[100];
+ int rv;
+ char a[10];
- memset(a, '\0', 100);
printf("Event received from stdin\n");
- rv = read(0, a, 100);
+ rv = read(0, a, 10);
+
+ if (rv <= 0 || a[0] == '0') {
+ rv = wifi_deinitialize();
+
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to deinitialize.\n");
- if (rv < 0 || a[0] == '0') exit(1);
+ exit(1);
+ }
- if (*a == '\n' || *a == '\r'){
+ if (a[0] == '\n' || a[0] == '\r') {
printf("\n\n Network Connection API Test App\n\n");
printf("Options..\n");
printf("1 - Wi-Fi init and set callbacks\n");
printf("b - Get AP list\n");
printf("c - Connect\n");
printf("d - Disconnect\n");
+ printf("e - Connect by wps pbc\n");
+ printf("f - Forget an AP\n");
+ printf("g - Set & connect EAP\n");
+ printf("h - Set IP method type\n");
+ printf("i - Set Proxy method type\n");
+ printf("j - Get Ap info\n");
printf("0 - Exit \n");
printf("ENTER - Show options menu.......\n");
}
switch (a[0]) {
- case '1': {
- rv = test_wifi_init();
- } break;
- case '2': {
- rv = test_wifi_deinit();
- } break;
- case '3': {
- rv = test_wifi_activate();
- } break;
- case '4': {
- rv = test_wifi_deactivate();
- } break;
- case '5': {
- rv = test_is_activated();
- } break;
- case '6': {
- rv = test_get_connection_state();
- } break;
- case '7': {
- rv = test_get_mac_address();
- } break;
- case '8': {
- rv = test_get_interface_name();
- } break;
- case '9': {
- rv = test_scan_request();
- } break;
- case 'a': {
- rv = test_get_connected_ap();
- } break;
- case 'b': {
- rv = test_foreach_found_aps();
- } break;
- case 'c': {
- rv = test_connect_ap();
- } break;
- case 'd': {
- rv = test_disconnect_ap();
- } break;
+ case '1':
+ rv = test_wifi_init();
+ break;
+ case '2':
+ rv = test_wifi_deinit();
+ break;
+ case '3':
+ rv = test_wifi_activate();
+ break;
+ case '4':
+ rv = test_wifi_deactivate();
+ break;
+ case '5':
+ rv = test_is_activated();
+ break;
+ case '6':
+ rv = test_get_connection_state();
+ break;
+ case '7':
+ rv = test_get_mac_address();
+ break;
+ case '8':
+ rv = test_get_interface_name();
+ break;
+ case '9':
+ rv = test_scan_request();
+ break;
+ case 'a':
+ rv = test_get_connected_ap();
+ break;
+ case 'b':
+ rv = test_foreach_found_aps();
+ break;
+ case 'c':
+ rv = test_connect_ap();
+ break;
+ case 'd':
+ rv = test_disconnect_ap();
+ break;
+ case 'e':
+ rv = test_connect_wps();
+ break;
+ case 'f':
+ rv = test_forget_ap();
+ break;
+ case 'g':
+ rv = test_connect_eap_ap();
+ break;
+ case 'h':
+ rv = test_set_ip_method();
+ break;
+ case 'i':
+ rv = test_set_proxy_method();
+ break;
+ case 'j':
+ rv = test_get_ap_info();
+ break;
+ default:
+ break;
}
+
+ if (rv == 1)
+ printf("Operation succeeded!\n");
+ else
+ printf("Operation failed!\n");
+
return TRUE;
}