--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "capi-network-wifi-manager")
+
+PROJECT(${fw_name})
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(LIB ${LIB_PATH})
+SET(LIBDIR ${PREFIX}/${LIB_PATH})
+
+SET(INC_DIR include)
+INCLUDE_DIRECTORIES(${INC_DIR})
+
+SET(dependents "dlog vconf capi-base-common capi-system-info glib-2.0 gio-2.0 gthread-2.0 ")
+SET(pc_dependents "capi-base-common")
+
+IF(TIZEN_WEARABLE)
+ ADD_DEFINITIONS(-DTIZEN_WEARABLE)
+ENDIF(TIZEN_WEARABLE)
+IF(TIZEN_MOBILE)
+ ADD_DEFINITIONS(-DTIZEN_MOBILE)
+ENDIF(TIZEN_MOBILE)
+
+IF(TIZEN_TV)
+ ADD_DEFINITIONS(-DTIZEN_TV)
+ENDIF(TIZEN_TV)
+
+INCLUDE(FindPkgConfig)
+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 -fvisibility=hidden")
+#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DTIZEN_DEBUG")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIBDIR}")
+
+aux_source_directory(src SOURCES)
+ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
+
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
+
+SET_TARGET_PROPERTIES(${fw_name}
+ PROPERTIES
+ VERSION ${FULLVER}
+ SOVERSION ${MAJORVER}
+ CLEAN_DIRECT_OUTPUT 1
+)
+
+INSTALL(TARGETS ${fw_name} DESTINATION ${LIB})
+INSTALL(
+ DIRECTORY ${INC_DIR}/ DESTINATION include/network
+ FILES_MATCHING
+ PATTERN "network_*.h" EXCLUDE
+ PATTERN "wifi_*.h" EXCLUDE
+ PATTERN "${INC_DIR}/*.h"
+ )
+
+SET(PC_NAME ${fw_name})
+SET(PC_REQUIRED ${pc_dependents})
+SET(PC_LDFLAGS -l${fw_name})
+
+CONFIGURE_FILE(
+ ${fw_name}.pc.in
+ ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
+ @ONLY
+)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB}/pkgconfig)
+
+ADD_SUBDIRECTORY(test)
+
+IF(UNIX)
+
+ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
+ADD_CUSTOM_COMMAND(
+ DEPENDS clean
+ COMMENT "distribution clean"
+ COMMAND find
+ ARGS .
+ -not -name config.cmake -and \(
+ -name tester.c -or
+ -name Testing -or
+ -name CMakeFiles -or
+ -name cmake.depends -or
+ -name cmake.check_depends -or
+ -name CMakeCache.txt -or
+ -name cmake.check_cache -or
+ -name *.cmake -or
+ -name Makefile -or
+ -name core -or
+ -name core.* -or
+ -name gmon.out -or
+ -name install_manifest.txt -or
+ -name *.pc -or
+ -name *~ \)
+ | grep -v TC | xargs rm -rf
+ TARGET distclean
+ VERBATIM
+)
+
+ENDIF(UNIX)
--- /dev/null
+Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
--- /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>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib
+includedir=/usr/include/network
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
--- /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_MANAGER_DOC_H__
+#define __TIZEN_NETWORK_WIFI_MANAGER_DOC_H__
+
+/**
+ * @defgroup CAPI_NETWORK_WIFI_PACKAGE Wi-Fi
+ * @ingroup CAPI_NETWORK_FRAMEWORK
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_MODULE_OVERVIEW Overview
+ * Wi-Fi module will be substituted for Wi-Fi Manager module with handle based to support for multi instance.
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_WIFI_MANAGER_MODULE Wi-Fi Manager
+ * @brief The Wi-Fi API provides functions for managing Wi-Fi and monitoring the state of Wi-Fi.
+ * @ingroup CAPI_NETWORK_WIFI_PACKAGE
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_MODULE_HEADER Required Header
+ * \#include <wifi-manager.h>
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_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_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 applications with regard to features, for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, and control your application's actions accordingly.\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 using features in your application can be found in the <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.</a>
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_WIFI_MANAGER_MANAGEMENT_MODULE Wi-Fi Management
+ * @brief The Wi-Fi API provides functions for managing Wi-Fi.
+ * @ingroup CAPI_NETWORK_WIFI_MANAGER_MODULE
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_MANAGEMENT_MODULE_HEADER Required Header
+ * \#include <wifi-manager.h>
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_MANAGEMENT_MODULE_OVERVEW Overview
+ * To use Wifi Manager API, first create a wifi handle using wifi_initialize(). After that, you can obtain wifi information.
+ * You should destroy the created wifi handle if you do not need it anymore.
+ * 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_MANAGEMENT_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 applications with regard to features, for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, and control your application's actions accordingly.\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 using features in your application can be found in the <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.</a>
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_WIFI_MANAGER_MONITOR_MODULE Wi-Fi Monitor
+ * @brief The Wi-Fi API provides functions for monitoring the state of Wi-Fi.
+ * @ingroup CAPI_NETWORK_WIFI_MANAGER_MODULE
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_MONITOR_MODULE_HEADER Required Header
+ * \#include <wifi-manager.h>
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_MONITOR_MODULE_OVERVIEW Overview
+ * The Wi-Fi Monitor allows monitoring the changes of Wi-Fi.
+ * @section CAPI_NETWORK_WIFI_MANAGER_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 applications with regard to features, for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, and control your application's actions accordingly.\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 using features in your application can be found in the <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.</a>
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_WIFI_MANAGER_AP_MODULE AP
+ * @brief The Access Point API provides functions for managing the Access Point.
+ * @ingroup CAPI_NETWORK_WIFI_MANAGER_MANAGEMENT_MODULE
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_AP_MODULE Required Header
+ * \#include <wifi-manager.h>
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_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_MANAGER_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 applications with regard to features, for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, and control your application's actions accordingly.\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 using features in your application can be found in the <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.</a>
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_WIFI_MANAGER_AP_NETWORK_MODULE Network Information
+ * @brief The Connection Information API provides functions for managing the network information.
+ * @ingroup CAPI_NETWORK_WIFI_MANAGER_AP_MODULE
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_AP_NETWORK_MODULE Required Header
+ * \#include <wifi-manager.h>
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_AP_NETWORK_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_MANAGER_AP_NETWORK_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 applications with regard to features, for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, and control your application's actions accordingly.\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 using features in your application can be found in the <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.</a>
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_WIFI_MANAGER_AP_SECURITY_MODULE Security Information
+ * @brief The Security Information API provides functions for managing the Security information.
+ * @ingroup CAPI_NETWORK_WIFI_MANAGER_AP_MODULE
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_AP_SECURITY_MODULE Required Header
+ * \#include <wifi-manager.h>
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_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_MANAGER_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 applications with regard to features, for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, and control your application's actions accordingly.\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 using features in your application can be found in the <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.</a>
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_WIFI_MANAGER_AP_SECURITY_EAP_MODULE EAP
+ * @brief The EAP API provides functions for managing the EAP information.
+ * @ingroup CAPI_NETWORK_WIFI_MANAGER_AP_SECURITY_MODULE
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_AP_SECURITY_EAP_MODULE Required Header
+ * \#include <wifi.h>
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_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_MANAGER_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 applications with regard to features, for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, and control your application's actions accordingly.\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 using features in your application can be found in the <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.</a>
+ *
+ */
+
+
+/**
+ * @defgroup CAPI_NETWORK_WIFI_MANAGER_CONFIG_MODULE Wi-Fi Configuration
+ * @brief The Configuration API provides functions for managing the configuration of Wi-Fi.
+ * @ingroup CAPI_NETWORK_WIFI_MANAGER_MODULE
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_CONFIG_MODULE Required Header
+ * \#include <wifi-manager.h>
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_CONFIG_MODULE_OVERVIEW Overview
+ * The Configuration API provides functions for managing the configuration of Wi-Fi. You can manage the configuration information using the functions.
+ * @section CAPI_NETWORK_WIFI_MANAGER_CONFIG_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 applications with regard to features, for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, and control your application's actions accordingly.\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 using features in your application can be found in the <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.</a>
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_WIFI_MANAGER_TDLS_MODULE Wi-Fi TDLS
+ * @brief The TDLS APIs for managing TDLS.
+ * @ingroup CAPI_NETWORK_WIFI_MANAGER_MODULE
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_TDLS_MODULE Required Header
+ * \#include <wifi-manager.h>
+ *
+ * @section CAPI_NETWORK_WIFI_MANAGER_TDLS_MODULE_OVERVIEW Overview
+ * The TDLS APIs for managing TDLS.
+ * @section CAPI_NETWORK_WIFI_MANAGER_TDLS_MODULE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.wifi.tdls\n
+ *
+ * It is recommended to design applications with regard to features, for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, and control your application's actions accordingly.
+ *
+ * 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 using features in your application can be found in the <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.
+ *
+ */
+
+
+#endif /* __TIZEN_NETWORK_WIFI_MANAGER_DOC_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NETWORK_CONFIG_H__
+#define __NETWORK_CONFIG_H__
+
+#include <netinet/in.h>
+
+#include "network_error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define NET_PROFILE_NAME_LEN_MAX 512 /** Profile name max length */
+#define NET_HOME_URL_LEN_MAX 512 /** Home URL max length in profile account */
+#define NET_IPV4_STR_LEN_MAX 15 /** Maximum length of IPv4 string type e.g.,
+ "165.213.173.105". This length does not
+ include NULL in the last byte. */
+#define NET_IPV4_STR_LEN_MIN 7 /** Minimum length of IPv4 string type e.g.,
+ "0.0.0.0". This length does not
+ include NULL in the last byte. */
+#define NET_IPV6_STR_LEN_MAX 39 /** Maximum length of IPv6 string type e.g.,
+ "fe80:0000:0000:0000:a000:27ff:fe7a:65ea".
+ This length does not include NULL in the last byte. */
+#define NET_IPV6_STR_LEN_MIN 2 /** Minimum length of IPv6 string type e.g.,
+ "::". This length does not include NULL in the last byte. */
+#define NET_PROXY_LEN_MAX 64 /** Maximum length of proxy string */
+#define NET_DNS_ADDR_MAX 2 /** MAX number of DNS Address */
+#define NET_MAX_DEVICE_NAME_LEN 32 /** Maximum length of device name */
+#define NET_MAX_MAC_ADDR_LEN 32 /** Maximum length of MAC address */
+#define NET_IPV6_MAX_PRIVACY_LEN 9 /** Maximum length of IPv6 Privacy
+ ["enabled", "disabled", "preferred"]*/
+#define NET_IPV6_MAX_PREFIX_LEN 128 /** Maximum length of IPv6 Prefix */
+
+typedef enum {
+ NET_ADDR_IPV4 = 0x0, /** IPV4 Address type */
+ NET_ADDR_IPV6 = 0x1, /** IPV6 Address type */
+} net_addr_type_e;
+
+typedef enum {
+ NET_PROXY_TYPE_UNKNOWN = 0x00, /** Not defined */
+ NET_PROXY_TYPE_DIRECT = 0x01, /** Direct connection */
+ NET_PROXY_TYPE_AUTO = 0x02, /** Auto configuration(Use PAC file)
+ * If URL property is not set,
+ DHCP/WPAD auto-discover will be tried */
+ NET_PROXY_TYPE_MANUAL = 0x03, /** Manual configuration */
+} net_proxy_type_e;
+
+typedef enum {
+ NET_IP_CONFIG_TYPE_STATIC = 0x01, /** Manual IP configuration */
+ NET_IP_CONFIG_TYPE_DYNAMIC, /** Config ip using DHCP client*/
+ NET_IP_CONFIG_TYPE_AUTO_IP, /** Config IP from Auto IP pool (169.254/16)
+ * Later with DHCP client, if available */
+ NET_IP_CONFIG_TYPE_FIXED, /** Indicates an IP address that can not be modified */
+ NET_IP_CONFIG_TYPE_OFF, /** Don't use any method */
+} net_ip_config_type_e;
+
+typedef union {
+ struct in_addr Ipv4; /** IP Version 4 address */
+ struct in6_addr Ipv6; /** IP Version 6 address */
+} net_ip_addr_u;
+
+typedef struct {
+ net_addr_type_e Type; /** Address Type: IPv4 or IPv6 */
+ net_ip_addr_u Data; /** IP Address */
+} net_addr_s;
+
+typedef struct {
+ char ProfileName[NET_PROFILE_NAME_LEN_MAX+1]; /** Profile name */
+} net_profile_name_s;
+
+typedef struct {
+ char ProfileName[NET_PROFILE_NAME_LEN_MAX+1]; /** Profile Name of the connection link */
+ char DevName[NET_MAX_DEVICE_NAME_LEN+1]; /** Device Name of the connection link */
+ net_addr_s DnsAddr[NET_DNS_ADDR_MAX]; /** IPv4 Dns Server Address of the connection link */
+ net_addr_s DnsAddr6[NET_DNS_ADDR_MAX]; /** IPv6 Dns Server Address of the connection link */
+ int DnsCount; /** No of IPv4 DNS Address for the connection link */
+ int DnsCount6; /** No of IPv6 DNS Address for the connection link */
+ net_ip_config_type_e IpConfigType; /** Net IP configuration Type */
+ net_addr_s IpAddr; /** IP Address for the connection link */
+ char BNetmask; /** Whether subnet mask present or not. */
+ net_addr_s SubnetMask; /** Subnet mask */
+ char BDefGateway; /** Whether gateway address present or not */
+ net_addr_s GatewayAddr; /** Gateway address */
+ net_proxy_type_e ProxyMethod; /** Proxy Method type */
+ char ProxyAddr[NET_PROXY_LEN_MAX+1]; /** Proxy address */
+ char MacAddr[NET_MAX_MAC_ADDR_LEN+1]; /** MAC address */
+ net_ip_config_type_e IpConfigType6; /** Net IP configuration Type */
+ net_addr_s IpAddr6; /** IP Address for the connection link */
+ int PrefixLen6; /** Prefix Length for the connection link */
+ char BDefGateway6; /** Whether gateway address present or not */
+ net_addr_s GatewayAddr6; /** Gateway address */
+ char Privacy6[NET_IPV6_MAX_PRIVACY_LEN+1]; /** Privacy of the connection link */
+} net_dev_info_s;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /** __NETWORK_CONFIG_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NETWORK_DBUS_H__
+#define __NETWORK_DBUS_H__
+
+#include "network_internal.h"
+#include "network_interface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CONNMAN_CLIENT_DBUS_TYPE_STRING "string"
+#define CONNMAN_CLIENT_DBUS_TYPE_INT16 "int16"
+#define CONNMAN_CLIENT_DBUS_TYPE_UINT16 "uint16"
+#define CONNMAN_CLIENT_DBUS_TYPE_INT32 "int32"
+#define CONNMAN_CLIENT_DBUS_TYPE_UINT32 "uint32"
+#define CONNMAN_CLIENT_DBUS_TYPE_INT64 "int64"
+#define CONNMAN_CLIENT_DBUS_TYPE_UINT64 "uint64"
+#define CONNMAN_CLIENT_DBUS_TYPE_DOUBLE "double"
+#define CONNMAN_CLIENT_DBUS_TYPE_BYTE "byte"
+#define CONNMAN_CLIENT_DBUS_TYPE_BOOLEAN "boolean"
+#define CONNMAN_CLIENT_DBUS_TYPE_OBJECT_PATH "objpath"
+
+#define CONNMAN_CLIENT_DBUS_TYPE_VARIANT "variant"
+#define CONNMAN_CLIENT_DBUS_TYPE_ARRAY "array"
+#define CONNMAN_CLIENT_DBUS_TYPE_DICT_ENTRY "dict"
+
+#define NETCONFIG_AGENT_FIELD_SSID "SSID"
+#define NETCONFIG_AGENT_FIELD_PASSPHRASE "Passphrase"
+#define NETCONFIG_AGENT_FIELD_WPS_PBC "WPS_PBC"
+#define NETCONFIG_AGENT_FIELD_WPS_PIN "WPS_PIN"
+
+#define CONNMAN_CONFIG_FIELD_TYPE "Type"
+#define CONNMAN_CONFIG_FIELD_NAME "Name"
+#define CONNMAN_CONFIG_FIELD_SSID "SSID"
+#define CONNMAN_CONFIG_FIELD_EAP_METHOD "EAP"
+#define CONNMAN_CONFIG_FIELD_IDENTITY "Identity"
+#define CONNMAN_CONFIG_FIELD_PASSPHRASE "Passphrase"
+#define CONNMAN_CONFIG_FIELD_PHASE2 "Phase2"
+#define CONNMAN_CONFIG_FIELD_CA_CERT_FILE "CACertFile"
+#define CONNMAN_CONFIG_FIELD_CLIENT_CERT_FILE "ClientCertFile"
+#define CONNMAN_CONFIG_FIELD_PVT_KEY_FILE "PrivateKeyFile"
+#define CONNMAN_CONFIG_FIELD_PVT_KEY_PASSPHRASE "PrivateKeyPassphrase"
+#define CONNMAN_CONFIG_FIELD_EAP_KEYMGMT_TYPE "KeymgmtType"
+
+typedef struct {
+ char *type;
+ char *mode;
+ char *ssid;
+ char *security;
+ char *passphrase;
+ char *eap_type;
+ char *eap_auth;
+ char *identity;
+ char *password;
+ char *ca_cert_file;
+ char *client_cert_file;
+ char *private_key_file;
+ char *private_key_password;
+ char *eap_keymgmt_type;
+ gboolean is_hidden;
+} net_wifi_connect_service_info_t;
+
+int _net_dbus_open_connection(const char* profile_name);
+int _net_dbus_close_connection(const char* profile_name);
+int _net_dbus_scan_request(void);
+int _net_dbus_set_bgscan_mode(net_wifi_background_scan_mode_e mode);
+int _net_dbus_set_agent_passphrase_and_connect(
+ const char *passphrase, const char *profilename);
+int _net_dbus_get_wps_pin(char **wps_pin);
+int _net_dbus_set_agent_wps_pbc_and_connect(const char *profilename);
+int _net_dbus_set_agent_wps_pin_and_connect(
+ const char *wps_pin, const char *profilename);
+int _net_dbus_get_tech_status(net_tech_info_s* tech_status);
+int _net_dbus_get_wifi_state(char **wifi_state);
+int _net_dbus_connect_service(const net_wifi_connect_service_info_t* wifi_connection_info);
+int _net_dbus_set_profile_ipv4(net_profile_info_s* prof_info, char* profile_name);
+int _net_dbus_set_profile_ipv6(net_profile_info_s* prof_info, char* profile_name);
+int _net_dbus_set_profile_dns(net_profile_info_s* prof_info, char* profile_name);
+int _net_dbus_set_proxy(net_profile_info_s* prof_info, char* profile_name);
+int _net_dbus_get_technology_state(network_tech_state_info_s* tech_state);
+GVariant *_net_invoke_dbus_method(const char *dest, const char *path,
+ const char *interface_name, const char *method,
+ GVariant *params, int *dbus_error);
+int _net_invoke_dbus_method_nonblock(const char *dest, const char *path,
+ const char *interface_name, const char *method,
+ GVariant *params, int timeout,
+ GAsyncReadyCallback notify_func);
+int _net_dbus_load_wifi_driver(gboolean wifi_picker_test);
+int _net_dbus_remove_wifi_driver(void);
+int _net_dbus_specific_scan_request(const char *ssid);
+int _net_dbus_wps_scan_request(void);
+int _net_dbus_get_passpoint(int *enabled);
+int _net_dbus_set_passpoint(int enable);
+
+#if defined TIZEN_TV
+int _net_dbus_cancel_wps(void);
+int _net_dbus_open_connection_without_ssid();
+int _net_dbus_open_pin_connection_without_ssid(const char *pin);
+int _net_dbus_set_agent_wps_pbc(void);
+int _net_dbus_set_agent_wps_pin(const char *wps_pin);
+
+#endif
+
+int _net_dbus_tdls_disconnect(const char* peer_mac_addr);
+int _net_dbus_tdls_connected_peer(char** peer_mac_addr);
+
+int _net_dbus_config_get_id_list(GSList **list);
+int _net_dbus_config_set_field(const gchar *config_id, const gchar *key, const gchar *value);
+int _net_dbus_config_get_passphrase(const gchar *config_id, gchar **passphrase);
+int _net_dbus_config_save_configurations(const gchar *config_id, const gchar *name,
+ const gchar *ssid, const gchar *passphrase, const gchar *proxy_address, gboolean is_hidden);
+int _net_dbus_config_save_eap_configurations(const gchar *config_id,
+ const gchar *name, const gchar *ssid, const gchar *passphrase,
+ const gchar *proxy_address, net_eap_config_s *eap_config, gboolean is_hidden);
+int _net_dbus_config_remove_configurations(const gchar *config_id);
+int _net_dbus_config_load_configurations(const gchar *config_id, gchar **name,
+ net_wifi_security_type_e *security_type, gchar **proxy_address, gboolean *is_hidden, void *last_error);
+int _net_dbus_config_load_eap_configurations(const gchar *config_id,
+ gchar **name, net_wifi_security_type_e *security_type, gchar **proxy_address,
+ gboolean *is_hidden, net_eap_config_s **eap_config, void *last_error);
+
+int _net_dbus_device_policy_get_wifi(int *state);
+int _net_dbus_device_policy_get_wifi_profile(int *state);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __NETWORK_DBUS_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NETWORK_ERROR_H__
+#define __NETWORK_ERROR_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ NET_ERR_NONE = 0x00, /** No error */
+
+ /* Common Error value */
+ NET_ERR_UNKNOWN = -999, /** Error unknown */
+
+ /* Client Register related Errors used in API return */
+ NET_ERR_APP_ALREADY_REGISTERED = -990, /** Application is already registered */
+ NET_ERR_APP_NOT_REGISTERED = -989, /** Application is not registered */
+
+ /* Connection Related Error */
+ NET_ERR_NO_ACTIVE_CONNECTIONS = -899, /** No active connection exists for the given profile name */
+ NET_ERR_ACTIVE_CONNECTION_EXISTS = -898, /** Active connection already exists for the given profile name */
+ NET_ERR_CONNECTION_OUT_OF_RANGE = -897, /** Connection failure : out of range */
+ NET_ERR_CONNECTION_PIN_MISSING = -896, /** Connection failure : pin missing */
+ NET_ERR_CONNECTION_DHCP_FAILED = -895, /** Connection failure : dhcp failed */
+ NET_ERR_CONNECTION_CONNECT_FAILED = -894, /** Connection failure : connect failed */
+ NET_ERR_CONNECTION_LOGIN_FAILED = -893, /** Connection failure : login failed */
+ NET_ERR_CONNECTION_AUTH_FAILED = -892, /** Connection failure : authentication failed */
+ NET_ERR_CONNECTION_INVALID_KEY = -891, /** Connection failure : invalid key */
+
+ /* Other Error */
+ NET_ERR_ACCESS_DENIED = -799, /** Access(permission) denied */
+ NET_ERR_IN_PROGRESS = -798, /** Operation is in progress */
+ NET_ERR_OPERATION_ABORTED = -797, /** Operation was aborted by client or network*/
+ NET_ERR_INVALID_PARAM = -796, /** Invalid value of API parameter */
+ NET_ERR_INVALID_OPERATION = -795, /** Invalid operation depending on current state */
+ NET_ERR_NOT_SUPPORTED = -794, /** Feature not supported */
+ NET_ERR_TIME_OUT = -793, /** TimeOut Error */
+ NET_ERR_NO_SERVICE = -792, /** Network service is not available */
+ NET_ERR_UNKNOWN_METHOD = -791, /** DBus can't find appropriate method */
+ NET_ERR_SECURITY_RESTRICTED = -790, /** Operation is restricted */
+ NET_ERR_ALREADY_EXISTS = -789, /** Already exists */
+ NET_ERR_NO_PROFILE = -788, /** There is no profile */
+
+ /** WiFi driver on/off failed */
+ NET_ERR_WIFI_DRIVER_FAILURE = -699,
+ NET_ERR_WIFI_DRIVER_LOAD_INPROGRESS = -698,
+} net_err_e;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __NETWORK_ERROR_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NETWORK_INTERFACE_H__
+#define __NETWORK_INTERFACE_H__
+
+#include <glib.h>
+#include "network_wlan.h"
+#include "network_error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define WIFI_INFO 1
+#define WIFI_ERROR 2
+#define WIFI_WARN 3
+
+#define WIFI_LOG(log_level, format, args...) \
+ do { \
+ switch (log_level) { \
+ case WIFI_ERROR: \
+ LOGE(format, ## args); \
+ break; \
+ case WIFI_WARN: \
+ LOGW(format, ## args); \
+ break; \
+ default: \
+ LOGI(format, ## args); \
+ } \
+ } while (0)
+
+typedef enum {
+ NET_EVENT_OPEN_RSP,
+ NET_EVENT_CLOSE_RSP,
+ NET_EVENT_OPEN_IND,
+ NET_EVENT_CLOSE_IND,
+ NET_EVENT_NET_STATE_IND,
+ NET_EVENT_WIFI_SCAN_RSP,
+ NET_EVENT_WIFI_SCAN_IND,
+ NET_EVENT_WIFI_MAC_ID_IND, /** This is deprecated Event and maintained only for compatibility */
+ NET_EVENT_WIFI_POWER_RSP,
+ NET_EVENT_WIFI_POWER_IND,
+ NET_EVENT_WIFI_SPECIFIC_SCAN_RSP,
+ NET_EVENT_WIFI_SPECIFIC_SCAN_IND,
+ NET_EVENT_WIFI_WPS_RSP,
+ NET_EVENT_WIFI_SCANNING_IND,
+ NET_EVENT_WIFI_WPS_SCAN_IND,
+ NET_EVENT_WIFI_TDLS_CONNECTED_IND,
+ NET_EVENT_WIFI_TDLS_DISCONNECTED_IND,
+} net_event_e;
+
+typedef enum {
+ WIFI_UNKNOWN = 0x00, /** Unknown state */
+ WIFI_OFF = 0x01, /** Wi-Fi is Off */
+ WIFI_ON = 0x02, /** Wi-Fi is On(idle/failure) */
+ WIFI_ASSOCIATION = 0x03, /** Trying association */
+ WIFI_CONFIGURATION = 0x04, /** Trying configuration */
+ WIFI_CONNECTED = 0x05, /** Wi-Fi is connected */
+ WIFI_DISCONNECTING = 0x06, /** Trying to disconnect */
+} net_wifi_state_e;
+
+typedef enum {
+ WIFI_BGSCAN_MODE_EXPONENTIAL = 0x00, /** scan cycle : 4, 8, 16, ...128s */
+ WIFI_BGSCAN_MODE_PERIODIC, /** scan cycle : 10s */
+} net_wifi_background_scan_mode_e;
+
+typedef enum {
+ WIFI_WPS_PBC = 0x00, /** WPS type is PBC */
+ WIFI_WPS_PIN, /** WPS type is PIN */
+} net_wifi_wps_type_e;
+
+typedef enum {
+ WIFI_MANAGER_EAP_PEAP = 0x00,
+ WIFI_MANAGER_EAP_TLS,
+ WIFI_MANAGER_EAP_TTLS,
+ WIFI_MANAGER_EAP_SIM,
+ WIFI_MANAGER_EAP_AKA,
+} net_wifi_eap_type_e;
+
+typedef enum {
+ WIFI_MANAGER_EAP_AUTH_NONE = 0x00,
+ WIFI_MANAGER_EAP_AUTH_PAP,
+ WIFI_MANAGER_EAP_AUTH_MSCHAP,
+ WIFI_MANAGER_EAP_AUTH_MSCHAPV2,
+ WIFI_MANAGER_EAP_AUTH_GTC,
+ WIFI_MANAGER_EAP_AUTH_MD5,
+} net_wifi_eap_auth_type_e;
+
+typedef enum {
+ WIFI_SEC_NONE = 0x00,
+ WIFI_SEC_WEP,
+ WIFI_SEC_WPA_PSK,
+ WIFI_SEC_WPA2_PSK,
+ WIFI_SEC_EAP,
+} net_wifi_security_type_e;
+
+typedef enum {
+ NET_STATE_TYPE_UNKNOWN = 0x00, /** Not defined */
+ NET_STATE_TYPE_IDLE, /** Idle state */
+ NET_STATE_TYPE_FAILURE, /** Failure state */
+ NET_STATE_TYPE_ASSOCIATION, /** Association state */
+ NET_STATE_TYPE_CONFIGURATION, /** Configuration state */
+ NET_STATE_TYPE_READY, /** Ready state */
+ NET_STATE_TYPE_ONLINE, /** Online state */
+ NET_STATE_TYPE_DISCONNECT, /** Login state */
+} net_state_type_e;
+
+typedef enum {
+ NET_STATE_ERROR_NONE = 0x00,
+ NET_STATE_ERROR_OUT_OF_RANGE = 0x01,
+ NET_STATE_ERROR_PIN_MISSING = 0x02,
+ NET_STATE_ERROR_DHCP_FAILED = 0x03,
+ NET_STATE_ERROR_CONNECT_FAILED = 0x04,
+ NET_STATE_ERROR_LOGIN_FAILED = 0x05,
+ NET_STATE_ERROR_AUTH_FAILED = 0x06,
+ NET_STATE_ERROR_INVALID_KEY = 0x07,
+} net_error_state_type_e;
+
+typedef struct {
+ char ProfileName[NET_PROFILE_NAME_LEN_MAX+1]; /** Profile name */
+ net_state_type_e ProfileState; /** Service state */
+ char essid[NET_WLAN_ESSID_LEN+1]; /** ESSID */
+ char bssid[NET_MAX_MAC_ADDR_LEN+1]; /** Basic service set identification */
+ unsigned char Strength; /** Strength : between 0 and 100 */
+ unsigned int frequency; /** Frequency band(MHz) */
+ unsigned int max_rate; /** Maximum speed of the line(bps) */
+ char PassphraseRequired; /** If a passphrase has been set already or if no
+ passphrase is needed, then this property will
+ be set to FALSE. */
+ wlan_connection_mode_type_e wlan_mode; /** Infrastucture / ad-hoc / auto mode */
+ wlan_security_info_s security_info; /** Security mode and authentication info */
+ gboolean passpoint; /** Passpoint AP or not */
+ net_dev_info_s net_info; /** network information */
+ gboolean is_hidden; /** Hidden network */
+ net_error_state_type_e ProfileErrorState; /** Service error state */
+ char Favourite; /** Favourite flag */
+} net_profile_info_s;
+
+typedef struct {
+ net_wifi_wps_type_e type; /** PBC / PIN */
+ char pin[NET_WLAN_MAX_WPSPIN_LEN + 1]; /** Optional. This pin is needed when the user input PIN code */
+} net_wifi_wps_info_s;
+
+typedef struct {
+ char essid[NET_WLAN_ESSID_LEN + 1]; /** Basic feature */
+ wlan_connection_mode_type_e wlan_mode; /** Infrastructure / ad-hoc / auto mode */
+ wlan_security_info_s security_info; /** Security mode and authentication info */
+ gboolean is_hidden; /** Hidden network */
+} net_wifi_connection_info_s;
+
+typedef struct {
+ char ssid[NET_WLAN_ESSID_LEN + 1];
+ wlan_security_mode_type_e security;
+ char wps;
+} net_ssid_scan_bss_info_s;
+
+typedef struct {
+ unsigned char ssid[NET_WLAN_ESSID_LEN + 1];
+ char bssid[NET_WLAN_BSSID_LEN + 1];
+ int rssi;
+ int mode;
+} net_wps_scan_bss_info_s;
+
+typedef struct {
+ net_event_e Event; /** CM Asynchronous event */
+ char ProfileName[NET_PROFILE_NAME_LEN_MAX+1]; /** Profile Identifier corresponding to the event */
+ net_err_e Error; /** Event Status */
+ int Datalength; /** Event data length */
+ void * Data; /** Event data: Depending on the event, Event Data will be
+ type-casted to the appropriate event info data structure */
+} net_event_info_s;
+
+typedef struct {
+ char powered; /** powered state */
+ char connected; /** connected state */
+} net_tech_info_s;
+
+typedef struct {
+ gchar *ca_cert;
+ gchar *private_key;
+ gchar *client_cert;
+ gchar *anonymous_identity;
+ gchar *identity;
+ gchar *subject_match;
+ net_wifi_eap_type_e eap_type;
+ net_wifi_eap_auth_type_e eap_auth_type;
+} net_eap_config_s;
+
+typedef void (*net_event_cb)(const net_event_info_s* net_event, void* user_data);
+
+int net_register_client_ext(net_event_cb event_cb, void *user_data);
+int net_deregister_client_ext(void);
+
+gboolean net_check_ref_count(void);
+
+int net_open_connection(const char *profile_name);
+int net_close_connection(const char *profile_name);
+
+int net_get_technology_properties(net_tech_info_s *tech_info);
+
+int net_get_profile_info(const char *profile_name, net_profile_info_s *prof_info);
+int net_get_profile_list(GSList **profile_list);
+
+int net_modify_profile(const char *profile_name, net_profile_info_s *prof_info);
+int net_delete_profile(const char *profile_name);
+
+int net_get_wifi_state(net_wifi_state_e *current_state);
+int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_e scan_mode);
+int net_specific_scan_wifi(const char *ssid);
+int net_get_wps_pin(char **wps_pin);
+int net_wps_scan_wifi(void);
+int net_wifi_get_passpoint(int *enable);
+int net_wifi_set_passpoint(int enable);
+
+#if defined TIZEN_TV
+int net_wifi_cancel_wps(void);
+#endif
+
+int net_open_connection_with_wifi_info(const net_wifi_connection_info_s *wifi_info);
+int net_scan_wifi(void);
+int net_wifi_power_on(gboolean wifi_picker_test);
+int net_wifi_power_off(void);
+int net_wifi_enroll_wps(const char *profile_name, net_wifi_wps_info_s *wps_info);
+int net_check_get_privilege(void);
+int net_check_profile_privilege(void);
+
+#if defined TIZEN_TV
+int net_wifi_enroll_wps_without_ssid(net_wifi_wps_info_s *wps_info);
+#endif
+
+int net_wifi_tdls_disconnect(const char* peer_mac_addr);
+int net_wifi_tdls_connected_peer(char** peer_mac_addr);
+
+int net_get_device_policy_wifi(void);
+int net_get_device_policy_wifi_profile(void);
+
+int net_config_get_id_list(GSList **list);
+int net_config_set_field(const gchar *config_id, const gchar *key, const gchar *value);
+int net_config_get_passphrase(const gchar *config_id, gchar **passphrase);
+int net_config_save_configurations(const gchar *config_id, const gchar *name,
+ const gchar *ssid, const gchar *passphrase, const gchar *proxy_address, gboolean is_hidden);
+int net_config_save_eap_configurations(const gchar *config_id,
+ const gchar *name, const gchar *ssid, const gchar *passphrase,
+ const gchar *proxy_address, void *eap_config, gboolean is_hidden);
+int net_config_remove_configurations(const gchar *config_id);
+int net_config_load_configurations(const gchar *config_id, gchar **name,
+ void *security_type, gchar **proxy_address, gboolean *is_hidden, void *last_error);
+int net_config_load_eap_configurations(const gchar *config_id,
+ gchar **name, void *security_type, gchar **proxy_address,
+ gboolean *is_hidden, void **eap_config, void *last_error);
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __NETWORK_INTERFACE_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NETWORK_INTERNAL_H__
+#define __NETWORK_INTERNAL_H__
+
+#include <dlog.h>
+#include <glib.h>
+#include <stdlib.h>
+#include <gio/gio.h>
+#include <glib-object.h>
+
+#include "network_interface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#undef LOG_TAG
+#define LOG_TAG "WIFI_MANAGER"
+
+/** Maximum Profile Count */
+#define NET_PROFILE_LIST_MAX 512
+
+#define NET_TECH_LENGTH_MAX 64
+
+#define CONNMAN_MAX_BUFLEN 512
+
+#define CONNMAN_STATE_STRLEN 16
+
+#define NET_MEMFREE(x) { g_free(x); x = NULL; }
+
+#define CONNMAN_SERVICE "net.connman"
+#define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager"
+#define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology"
+#define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service"
+#define CONNMAN_PROFILE_INTERFACE CONNMAN_SERVICE ".Profile"
+#define CONNMAN_COUNTER_INTERFACE CONNMAN_SERVICE ".Counter"
+#define CONNMAN_ERROR_INTERFACE CONNMAN_SERVICE ".Error"
+#define CONNMAN_AGENT_INTERFACE CONNMAN_SERVICE ".Agent"
+
+#define CONNMAN_MANAGER_PATH "/"
+#define CONNMAN_PATH "/net/connman"
+#define CONNMAN_TECHNOLOGY_PATH "/net/connman/technology"
+
+#define NETCONFIG_SERVICE "net.netconfig"
+#define NETCONFIG_NETWORK_INTERFACE NETCONFIG_SERVICE ".network"
+#define NETCONFIG_WIFI_INTERFACE NETCONFIG_SERVICE ".wifi"
+
+#define NETCONFIG_NETWORK_PATH "/net/netconfig/network"
+#define NETCONFIG_WIFI_PATH "/net/netconfig/wifi"
+
+#if defined TIZEN_TV
+#define NETCONFIG_TV_PROFILE_INTERFACE NETCONFIG_SERVICE ".tv_profile"
+#endif
+
+#define SUPPLICANT_SERVICE "fi.w1.wpa_supplicant1"
+#define SUPPLICANT_INTERFACE "fi.w1.wpa_supplicant1"
+#define SUPPLICANT_IFACE_INTERFACE SUPPLICANT_INTERFACE ".Interface"
+#define SUPPLICANT_IFACE_BSS SUPPLICANT_INTERFACE ".BSS"
+#define SUPPLICANT_PATH "/fi/w1/wpa_supplicant1"
+
+#define DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
+
+#define CONNMAN_MANAGER_SIGNAL_FILTER "type='signal',interface='net.connman.Manager'"
+#define CONNMAN_SERVICE_SIGNAL_FILTER "type='signal',interface='net.connman.Service'"
+#define NETCONFIG_WIFI_FILTER "type='signal',interface='net.netconfig.wifi'"
+#define SUPPLICANT_INTERFACE_SIGNAL_FILTER "type='signal',interface='fi.w1.wpa_supplicant1.Interface'"
+
+#define SIGNAL_PROPERTY_CHANGED "PropertyChanged"
+#define SIGNAL_PROPERTIES_CHANGED "PropertiesChanged"
+#define SIGNAL_TECHNOLOGY_ADDED "TechnologyAdded"
+#define SIGNAL_TECHNOLOGY_REMOVED "TechnologyRemoved"
+#define SIGNAL_SERVICES_CHANGED "ServicesChanged"
+#define SIGNAL_SCAN_DONE "ScanDone"
+
+#define CONNMAN_WIFI_TECHNOLOGY_PREFIX CONNMAN_PATH "/technology/wifi"
+
+#define CONNMAN_WIFI_SERVICE_PROFILE_PREFIX CONNMAN_PATH "/service/wifi_"
+
+/** Network related Daemon Signals */
+#define NETCONFIG_SIGNAL_POWERON_COMPLETED "PowerOnCompleted"
+#define NETCONFIG_SIGNAL_POWEROFF_COMPLETED "PowerOffCompleted"
+#define NETCONFIG_SIGNAL_SPECIFIC_SCAN_DONE "SpecificScanCompleted"
+#define NETCONFIG_SIGNAL_WPS_SCAN_DONE "WpsScanCompleted"
+#define NETCONFIG_SIGNAL_TDLS_CONNECTED "TDLSConnect"
+#define NETCONFIG_SIGNAL_TDLS_DISCONNECTED "TDLSDisconnect"
+#define NETCONFIG_SIGNAL_TDLS_PEER_FOUND "TDLSPeerFound"
+#define NETCONFIG_SIGNAL_WIFI_CONNECT_FAIL "WiFiConnectFail"
+#define NETCONFIG_SIGNAL_DPM_WIFI "DPMWifi"
+#define NETCONFIG_SIGNAL_DPM_WIFI_PROFILE "DPMWifiProfile"
+
+#define __NETWORK_FUNC_ENTER__ /*WIFI_LOG(WIFI_INFO, "Enter (%s)", __func__);*/
+#define __NETWORK_FUNC_EXIT__ /*WIFI_LOG(WIFI_INFO, "Quit (%s)", __func__);*/
+
+typedef enum {
+ NETWORK_REQUEST_TYPE_SCAN = 0x00,
+ NETWORK_REQUEST_TYPE_OPEN_CONNECTION,
+ NETWORK_REQUEST_TYPE_CLOSE_CONNECTION,
+ NETWORK_REQUEST_TYPE_WIFI_POWER,
+ NETWORK_REQUEST_TYPE_ENROLL_WPS,
+ NETWORK_REQUEST_TYPE_SPECIFIC_SCAN,
+ NETWORK_REQUEST_TYPE_WPS_SCAN,
+ NETWORK_REQUEST_TYPE_SET_DEFAULT,
+ NETWORK_REQUEST_TYPE_RESET_DEFAULT,
+ NETWORK_REQUEST_TYPE_MAX
+} network_async_request_type_e;
+
+typedef struct {
+ int flag;
+ char ProfileName[NET_PROFILE_NAME_LEN_MAX+1];
+} network_request_table_s;
+
+typedef struct {
+ net_wifi_state_e wifi_state;
+ net_event_cb ClientEventCb_wifi;
+ void* user_data_wifi;
+ int ref_count;
+ guint handler_id;
+} network_info_s;
+
+typedef struct {
+ char technology[NET_TECH_LENGTH_MAX];
+ char AvailableTechnology;
+ char EnabledTechnology;
+ char ConnectedTechnology;
+ char DefaultTechnology;
+ unsigned char Connected;
+ unsigned char Powered;
+} network_tech_state_info_s;
+
+int _net_get_tech_state(GVariant *iter, network_tech_state_info_s* tech_state);
+char* _net_print_error(net_err_e error);
+int _net_open_connection_with_wifi_info(const net_wifi_connection_info_s* wifi_info);
+int _net_check_profile_name(const char* ProfileName);
+int _net_get_profile_list(GSList **profile_list);
+void _net_client_callback(net_event_info_s *event_data);
+net_wifi_state_e _net_get_wifi_state(net_err_e *net_error);
+void _net_clear_request_table(void);
+
+guint _net_client_callback_add(GSourceFunc func, gpointer user_data);
+void _net_client_callback_cleanup(void);
+
+gboolean _net_dbus_is_pending_call_used(void);
+void _net_dbus_pending_call_ref(void);
+void _net_dbus_pending_call_unref(void);
+int _net_dbus_create_gdbus_call(void);
+int _net_dbus_close_gdbus_call(void);
+GDBusConnection *_net_dbus_get_gdbus_conn(void);
+GCancellable *_net_dbus_get_gdbus_cancellable(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETWORK_INTERNAL_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NETWORK_SIGNAL_H__
+#define __NETWORK_SIGNAL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int _net_deregister_signal(void);
+int _net_register_signal(void);
+int _net_init_service_state_table(void);
+
+/* Device Policy Manager */
+int _net_get_dpm_wifi_state(void);
+void _net_set_dpm_wifi_state(int state);
+int _net_get_dpm_wifi_profile_state(void);
+void _net_set_dpm_wifi_profile_state(int state);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __NETWORK_SIGNAL_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NETWORK_WLAN_H__
+#define __NETWORK_WLAN_H__
+
+#include <glib.h>
+
+#include "network_config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/** Length of essid */
+#define NET_WLAN_ESSID_LEN 128
+
+/** Length of bssid */
+#define NET_WLAN_BSSID_LEN 17
+
+/**
+ * Length of WPS PIN code
+ * WPS PIN code should be 4 or 8 digits
+ */
+#define NET_WLAN_MAX_WPSPIN_LEN 8
+
+/**
+ * Passphrase length should be between 8..63,
+ * If we plan to use encrypted key(hex value generated by wpa_passphrase),
+ * then we have to set this value to some higher number
+ */
+#define NET_WLAN_MAX_PSK_PASSPHRASE_LEN 65
+
+/**
+ * Length of WEP Key
+ * Max of 10 Hex digits allowed in case of 64 bit encryption
+ * Max of 26 Hex digits allowed in case of 128 bit encryption
+ */
+#define NET_WLAN_MAX_WEP_KEY_LEN 26
+
+/**
+ * These lengths depends on authentication server being used,
+ * In case of freeradius server Max allowed length for username/password is 255
+ * Let us restrict this value to some optimal value say 50.
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NET_WLAN_USERNAME_LEN 50
+
+/**
+ * These lengths depends on authentication server being used,
+ * In case of freeradius server Max allowed length for username/password is 255
+ * Let us restrict this value to some optimal value say 50.
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NET_WLAN_PASSWORD_LEN 50
+
+/**
+ * length of CA Cert file name
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NET_WLAN_CA_CERT_FILENAME_LEN 128
+
+/**
+ * length of Client Cert file name
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NET_WLAN_CLIENT_CERT_FILENAME_LEN 128
+
+/**
+ * length of private key file name
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NET_WLAN_PRIVATE_KEY_FILENAME_LEN 128
+
+/**
+ * length of Private key password
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NET_WLAN_PRIVATE_KEY_PASSWD_LEN 50
+
+/**
+ * Below security modes are used in infrastructure and ad-hoc mode
+ * For now all EAP security mechanisms are provided only in infrastructure mode
+ */
+typedef enum {
+ WLAN_SEC_MODE_NONE = 0x01, /** Security disabled */
+ WLAN_SEC_MODE_WEP, /** WEP */
+ WLAN_SEC_MODE_IEEE8021X, /** EAP */
+ WLAN_SEC_MODE_WPA_PSK, /** WPA-PSK */
+ WLAN_SEC_MODE_WPA2_PSK, /** WPA2-PSK */
+ WLAN_SEC_MODE_WPA_FT_PSK,
+} wlan_security_mode_type_e;
+
+/**
+ * Below encryption modes are used in infrastructure and ad-hoc mode
+ */
+typedef enum {
+ WLAN_ENC_MODE_NONE = 0x01, /** Encryption disabled */
+ WLAN_ENC_MODE_WEP, /** WEP */
+ WLAN_ENC_MODE_TKIP, /** TKIP */
+ WLAN_ENC_MODE_AES, /** AES */
+ WLAN_ENC_MODE_TKIP_AES_MIXED, /** TKIP and AES are both supported */
+} wlan_encryption_mode_type_e;
+
+/**
+ * WLAN Operation Mode
+ */
+typedef enum {
+ NET_WLAN_CONNMODE_AUTO = 0x01, /** auto connection mode */
+ NET_WLAN_CONNMODE_ADHOC, /** Connection mode Adhoc */
+ NET_WLAN_CONNMODE_INFRA, /** Infra connection mode */
+} wlan_connection_mode_type_e;
+
+/**
+ * EAP type
+ */
+typedef enum {
+ WLAN_SEC_EAP_TYPE_PEAP = 0x01, /** EAP PEAP type */
+ WLAN_SEC_EAP_TYPE_TLS, /** EAP TLS type */
+ WLAN_SEC_EAP_TYPE_TTLS, /** EAP TTLS type */
+ WLAN_SEC_EAP_TYPE_SIM, /** EAP SIM type */
+ WLAN_SEC_EAP_TYPE_AKA, /** EAP AKA type */
+} wlan_eap_type_e;
+
+/**
+ * EAP phase2 authentication type
+ */
+typedef enum {
+ WLAN_SEC_EAP_AUTH_NONE = 0x01, /** EAP phase2 authentication none */
+ WLAN_SEC_EAP_AUTH_PAP, /** EAP phase2 authentication PAP */
+ WLAN_SEC_EAP_AUTH_MSCHAP, /** EAP phase2 authentication MSCHAP */
+ WLAN_SEC_EAP_AUTH_MSCHAPV2, /** EAP phase2 authentication MSCHAPv2 */
+ WLAN_SEC_EAP_AUTH_GTC, /** EAP phase2 authentication GTC */
+ WLAN_SEC_EAP_AUTH_MD5, /** EAP phase2 authentication MD5 */
+} wlan_eap_auth_type_e;
+
+/**
+ * EAP keymgmt type
+ */
+typedef enum {
+ WLAN_SEC_EAP_KEYMGMT_UNKNOWN = 0x00,
+ WLAN_SEC_EAP_KEYMGMT_NONE,
+ WLAN_SEC_EAP_KEYMGMT_FT,
+ WLAN_SEC_EAP_KEYMGMT_CCKM,
+ WLAN_SEC_EAP_KEYMGMT_OKC,
+} wlan_eap_keymgmt_type_e;
+
+/**
+ * Below structure is used by WPA-PSK or WPA2-PSK
+ * To see the maximum length of PSK passphrase key.
+ */
+typedef struct {
+ char pskKey[NET_WLAN_MAX_PSK_PASSPHRASE_LEN + 1]; /** key value for WPA-PSK or WPA2-PSK */
+} wlan_psk_info_s;
+
+/**
+ * Below structure is used by WEP
+ * To see the maximum length of WEP key.
+ */
+typedef struct {
+ char wepKey[NET_WLAN_MAX_WEP_KEY_LEN + 1]; /** key value for WEP */
+} wlan_wep_info_s;
+
+/**
+ * Below structure is used by EAP
+ */
+typedef struct {
+ char username[NET_WLAN_USERNAME_LEN+1]; /** User name */
+ char password[NET_WLAN_PASSWORD_LEN+1]; /** Password */
+
+ /**
+ * Following fields are mandatory for EAP-TLS,
+ * Optional for EAP-TTLS and EAP-PEAP
+ *
+ * For EAP-TTLS and EAP-PEAP only ca_cert_filename[] can also be provided
+ */
+ char ca_cert_filename[NET_WLAN_CA_CERT_FILENAME_LEN+1]; /* Used to authenticate server */
+ char client_cert_filename[NET_WLAN_CLIENT_CERT_FILENAME_LEN+1]; /** client certificate file name */
+ char private_key_filename[NET_WLAN_PRIVATE_KEY_FILENAME_LEN+1]; /** private key file name */
+ char private_key_passwd[NET_WLAN_PRIVATE_KEY_PASSWD_LEN+1]; /** private key password */
+
+ wlan_eap_type_e eap_type; /** eap type */
+ wlan_eap_auth_type_e eap_auth; /** eap phase2 authentication type */
+ wlan_eap_keymgmt_type_e eap_keymgmt_type; /** eap keymgmt type */
+} wlan_eap_info_s;
+
+/**
+ * At any point of time only one security mechanism is supported
+ */
+typedef union {
+ wlan_wep_info_s wep; /** Wep Authentication */
+ wlan_psk_info_s psk; /** psk Authentication */
+ wlan_eap_info_s eap; /** eap Authentication */
+} wlan_auth_info_u;
+
+/**
+ * This is main security information structure
+ */
+typedef struct {
+ wlan_security_mode_type_e sec_mode; /** security mode type */
+ wlan_encryption_mode_type_e enc_mode; /** encryption mode type */
+ wlan_auth_info_u authentication; /** authentication information */
+ char wps_support; /** If WPS is supported, then this property will be set to TRUE */
+ unsigned int keymgmt; /** If WPS is supported, then this property will be set to TRUE */
+} wlan_security_info_s;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NETWORK_WLAN_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_WIFI_MANAGER_H__
+#define __TIZEN_WIFI_MANAGER_H__
+
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file wifi-manager.h
+ */
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_MODULE
+* @{
+*/
+
+/**
+ * @brief The wifi manager handle.
+ * @since_tizen 3.0
+*/
+typedef void *wifi_manager_h;
+
+/**
+ * @brief Enumeration for the Wi-Fi error type.
+ * @since_tizen 3.0
+ */
+typedef enum {
+ WIFI_MANAGER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ WIFI_MANAGER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ WIFI_MANAGER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory error */
+ WIFI_MANAGER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
+ WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED = TIZEN_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED, /**< Address family not supported */
+ WIFI_MANAGER_ERROR_OPERATION_FAILED = TIZEN_ERROR_WIFI_MANAGER|0x01, /**< Operation failed */
+ WIFI_MANAGER_ERROR_NO_CONNECTION = TIZEN_ERROR_WIFI_MANAGER|0x02, /**< There is no connected AP */
+ WIFI_MANAGER_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /**< Now in progress */
+ WIFI_MANAGER_ERROR_ALREADY_EXISTS = TIZEN_ERROR_WIFI_MANAGER|0x03, /**< Already exists */
+ WIFI_MANAGER_ERROR_OPERATION_ABORTED = TIZEN_ERROR_WIFI_MANAGER|0x04, /**< Operation is aborted */
+ WIFI_MANAGER_ERROR_DHCP_FAILED = TIZEN_ERROR_WIFI_MANAGER|0x05, /**< DHCP failed */
+ WIFI_MANAGER_ERROR_INVALID_KEY = TIZEN_ERROR_WIFI_MANAGER|0x06, /**< Invalid key */
+ WIFI_MANAGER_ERROR_NO_REPLY = TIZEN_ERROR_WIFI_MANAGER|0x07, /**< No reply */
+ WIFI_MANAGER_ERROR_SECURITY_RESTRICTED = TIZEN_ERROR_WIFI_MANAGER|0x08, /**< Restricted by security system policy */
+ WIFI_MANAGER_ERROR_ALREADY_INITIALIZED = TIZEN_ERROR_WIFI_MANAGER|0x09, /**< Already initialized */
+ WIFI_MANAGER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission Denied */
+ WIFI_MANAGER_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED /**< Not Supported */
+} wifi_manager_error_e;
+
+/**
+* @}
+*/
+
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_MONITOR_MODULE
+* @{
+*/
+
+/**
+ * @brief Enumeration for the state of the Wi-Fi device.
+ * @since_tizen 3.0
+ */
+typedef enum {
+ WIFI_MANAGER_DEVICE_STATE_DEACTIVATED = 0, /**< Wi-Fi is Deactivated */
+ WIFI_MANAGER_DEVICE_STATE_ACTIVATED = 1, /**< Wi-Fi is activated */
+} wifi_manager_device_state_e;
+
+/**
+ * @brief Enumeration for the state of the Wi-Fi connection.
+ * @since_tizen 3.0
+ */
+typedef enum {
+ WIFI_MANAGER_CONNECTION_STATE_FAILURE = -1, /**< Connection failed state */
+ WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED = 0, /**< Disconnected state */
+ WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION = 1, /**< Association state */
+ WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION = 2, /**< Configuration state */
+ WIFI_MANAGER_CONNECTION_STATE_CONNECTED = 3, /**< Connected state */
+} wifi_manager_connection_state_e;
+
+/**
+ * @brief Enumeration for the RSSI level.
+ * @since_tizen 3.0
+ */
+typedef enum {
+ WIFI_MANAGER_RSSI_LEVEL_0 = 0, /**< level 0 */
+ WIFI_MANAGER_RSSI_LEVEL_1 = 1, /**< level 1 */
+ WIFI_MANAGER_RSSI_LEVEL_2 = 2, /**< level 2 */
+ WIFI_MANAGER_RSSI_LEVEL_3 = 3, /**< level 3 */
+ WIFI_MANAGER_RSSI_LEVEL_4 = 4, /**< level 4 */
+} wifi_manager_rssi_level_e;
+
+/**
+* @}
+*/
+
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_AP_NETWORK_MODULE
+* @{
+*/
+
+/**
+ * @brief Enumeration for the Net IP configuration type.
+ * @since_tizen 3.0
+ */
+typedef enum {
+ WIFI_MANAGER_IP_CONFIG_TYPE_NONE = 0, /**< Not defined */
+ WIFI_MANAGER_IP_CONFIG_TYPE_STATIC = 1, /**< Manual IP configuration */
+ WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC = 2, /**< Config IP using DHCP client*/
+ WIFI_MANAGER_IP_CONFIG_TYPE_AUTO = 3, /**< Config IP from Auto IP pool (169.254/16). Later with DHCP client, if available */
+ WIFI_MANAGER_IP_CONFIG_TYPE_FIXED = 4, /**< Indicates an IP address that can not be modified */
+} wifi_manager_ip_config_type_e;
+
+/**
+ * @brief Enumeration for the address type.
+ * @since_tizen 3.0
+ */
+typedef enum {
+ WIFI_MANAGER_ADDRESS_FAMILY_IPV4 = 0, /**< IPV4 Address family */
+ WIFI_MANAGER_ADDRESS_FAMILY_IPV6 = 1, /**< IPV6 Address family */
+} wifi_manager_address_family_e;
+
+/**
+ * @brief Enumeration for the proxy method type.
+ * @since_tizen 3.0
+ */
+typedef enum {
+ WIFI_MANAGER_PROXY_TYPE_DIRECT = 0, /**< Direct connection */
+ WIFI_MANAGER_PROXY_TYPE_AUTO = 1, /**< Auto configuration(Use PAC file). If URL property is not set, DHCP/WPAD auto-discover will be tried */
+ WIFI_MANAGER_PROXY_TYPE_MANUAL = 2 /**< Manual configuration */
+} wifi_manager_proxy_type_e;
+
+/**
+* @}
+*/
+
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_AP_SECURITY_MODULE
+* @{
+*/
+
+/**
+ * @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 3.0
+ */
+typedef enum {
+ WIFI_MANAGER_SECURITY_TYPE_NONE = 0, /**< Security disabled */
+ WIFI_MANAGER_SECURITY_TYPE_WEP = 1, /**< WEP */
+ WIFI_MANAGER_SECURITY_TYPE_WPA_PSK = 2, /**< WPA-PSK */
+ WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK = 3, /**< WPA2-PSK */
+ WIFI_MANAGER_SECURITY_TYPE_EAP = 4, /**< EAP */
+} wifi_manager_security_type_e;
+
+/**
+ * @brief Enumeration for Wi-Fi encryption type.
+ * @details The following encryption modes are used in infrastructure and ad-hoc mode.
+ * @since_tizen 3.0
+ */
+typedef enum {
+ WIFI_MANAGER_ENCRYPTION_TYPE_NONE = 0, /**< Encryption disabled */
+ WIFI_MANAGER_ENCRYPTION_TYPE_WEP = 1, /**< WEP */
+ WIFI_MANAGER_ENCRYPTION_TYPE_TKIP = 2, /**< TKIP */
+ WIFI_MANAGER_ENCRYPTION_TYPE_AES = 3, /**< AES */
+ WIFI_MANAGER_ENCRYPTION_TYPE_TKIP_AES_MIXED = 4, /**< TKIP and AES are both supported */
+} wifi_manager_encryption_type_e;
+
+/**
+* @}
+*/
+
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_AP_SECURITY_EAP_MODULE
+* @{
+*/
+
+/**
+ * @brief Enumeration for EAP type.
+ * @since_tizen 3.0
+ */
+typedef enum {
+ WIFI_MANAGER_EAP_TYPE_PEAP = 0, /**< EAP PEAP type */
+ WIFI_MANAGER_EAP_TYPE_TLS = 1, /**< EAP TLS type */
+ WIFI_MANAGER_EAP_TYPE_TTLS = 2, /**< EAP TTLS type */
+ WIFI_MANAGER_EAP_TYPE_SIM = 3, /**< EAP SIM type */
+ WIFI_MANAGER_EAP_TYPE_AKA = 4, /**< EAP AKA type */
+} wifi_manager_eap_type_e;
+
+/**
+ * @brief Enumeration for EAP phase2 authentication type.
+ * @since_tizen 3.0
+ */
+typedef enum {
+ WIFI_MANAGER_EAP_AUTH_TYPE_NONE = 0, /**< EAP phase2 authentication none */
+ WIFI_MANAGER_EAP_AUTH_TYPE_PAP = 1, /**< EAP phase2 authentication PAP */
+ WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAP = 2, /**< EAP phase2 authentication MSCHAP */
+ WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAPV2 = 3, /**< EAP phase2 authentication MSCHAPv2 */
+ WIFI_MANAGER_EAP_AUTH_TYPE_GTC = 4, /**< EAP phase2 authentication GTC */
+ WIFI_MANAGER_EAP_AUTH_TYPE_MD5 = 5, /**< EAP phase2 authentication MD5 */
+} wifi_manager_eap_auth_type_e;
+
+/**
+* @}
+*/
+
+/**
+ * @addtogroup CAPI_NETWORK_WIFI_MANAGER_TDLS_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumeration for the state of the Wi-Fi TDLS.
+ * @since_tizen 3.0
+ */
+typedef enum {
+ WIFI_MANAGER_TDLS_STATE_DISCONNECTED = 0, /**< Wi-Fi TDLS is Disconnected */
+ WIFI_MANAGER_TDLS_STATE_CONNECTED = 1, /**< Wi-Fi TDLS is Connected */
+} wifi_manager_tdls_state_e;
+
+/**
+ * @}
+ */
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_AP_MODULE
+* @{
+*/
+
+/**
+ * @brief The Wi-Fi access point handle.
+ * @since_tizen 3.0
+ */
+typedef void *wifi_manager_ap_h;
+
+/**
+* @}
+*/
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_CONFIG_MODULE
+* @{
+*/
+
+/**
+ * @brief The Wi-Fi access point configuration handle
+ * @since_tizen 3.0
+ */
+typedef void *wifi_manager_config_h;
+
+/**
+* @}
+*/
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_MANAGEMENT_MODULE
+* @{
+*/
+
+/**
+ * @brief Called for each found access point.
+ * @since_tizen 3.0
+ * @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_manager_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_manager_foreach_found_ap() will invoke this callback.
+ * @pre wifi_manager_foreach_found_specific_ap() will invoke this callback.
+ * @see wifi_manager_foreach_found_ap()
+ * @see wifi_manager_foreach_found_specific_ap()
+ */
+typedef bool(*wifi_manager_found_ap_cb)(wifi_manager_ap_h ap, void *user_data);
+
+/**
+ * @brief Called when the scan is finished.
+ * @since_tizen 3.0
+ * @param[in] error_code The error code
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see wifi_manager_scan()
+ * @see wifi_manager_set_background_scan_cb()
+ * @see wifi_manager_unset_background_scan_cb()
+ */
+typedef void(*wifi_manager_scan_finished_cb)(wifi_manager_error_e error_code, void *user_data);
+
+/**
+ * @brief Called after wifi_manager_activate() or wifi_manager_activate_with_wifi_picker_tested() is completed.
+ * @since_tizen 3.0
+ * @param[in] result The result
+ * @param[in] user_data The user data passed from wifi_manager_activate() and wifi_manager_activate_with_wifi_picker_tested()
+ * @pre wifi_manager_activate() or wifi_manager_activate_with_wifi_picker_tested() will invoke this callback function.
+ * @see wifi_manager_activate()
+ * @see wifi_manager_activate_with_wifi_picker_tested()
+ */
+typedef void(*wifi_manager_activated_cb)(wifi_manager_error_e result, void *user_data);
+
+/**
+ * @brief Called after wifi_manager_deactivate() is completed.
+ * @since_tizen 3.0
+ * @param[in] result The result
+ * @param[in] user_data The user data passed from wifi_manager_deactivate()
+ * @pre wifi_manager_deactivate() will invoke this callback function.
+ * @see wifi_manager_deactivate()
+ */
+typedef void(*wifi_manager_deactivated_cb)(wifi_manager_error_e result, void *user_data);
+
+/**
+ * @brief Called after either wifi_manager_connect() or wifi_manager_connect_by_wps_pbc() or wifi_manager_connect_by_wps_pin() are completed.
+ * @since_tizen 3.0
+ * @param[in] result The result
+ * @param[in] user_data The user data passed from either wifi_manager_connect() or wifi_manager_connect_by_wps_pbc() or wifi_manager_connect_by_wps_pin()
+ * @pre Either wifi_manager_connect() or wifi_manager_connect_by_wps_pbc() or wifi_manager_connect_by_wps_pin() will invoke this callback function.
+ * @see wifi_manager_connect()
+ * @see wifi_manager_connect_by_wps_pbc()
+ * @see wifi_manager_connect_by_wps_pin()
+ */
+typedef void(*wifi_manager_connected_cb)(wifi_manager_error_e result, void *user_data);
+
+/**
+ * @brief Called after wifi_manager_disconnect() is completed.
+ * @since_tizen 3.0
+ * @param[in] result The result
+ * @param[in] user_data The user data passed from wifi_manager_disconnect()
+ * @pre wifi_manager_disconnect() will invoke this callback function.
+ * @see wifi_manager_disconnect()
+ */
+typedef void(*wifi_manager_disconnected_cb)(wifi_manager_error_e result, void *user_data);
+
+/**
+* @}
+*/
+
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_MONITOR_MODULE
+* @{
+*/
+
+/**
+ * @brief Called when the device state is changed.
+ * @since_tizen 3.0
+ * @param[in] state The device state
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see wifi_manager_set_device_state_changed_cb()
+ * @see wifi_manager_unset_device_state_changed_cb()
+ */
+typedef void(*wifi_manager_device_state_changed_cb)(wifi_manager_device_state_e state, void *user_data);
+
+/**
+ * @brief Called when the connection state is changed.
+ * @since_tizen 3.0
+ * @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_manager_set_connection_state_changed_cb()
+ * @see wifi_manager_unset_connection_state_changed_cb()
+ */
+typedef void(*wifi_manager_connection_state_changed_cb)(wifi_manager_connection_state_e state, wifi_manager_ap_h ap, void *user_data);
+
+/**
+ * @brief Called when the RSSI of connected Wi-Fi is changed.
+ * @since_tizen 3.0
+ * @param[in] rssi_level The level of RSSI
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see wifi_manager_set_rssi_level_changed_cb()
+ * @see wifi_manager_unset_rssi_level_changed_cb()
+ */
+typedef void(*wifi_manager_rssi_level_changed_cb)(wifi_manager_rssi_level_e rssi_level, void *user_data);
+
+/**
+* @}
+*/
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_CONFIG_MODULE
+* @{
+*/
+
+/**
+ * @brief Called for each found access point configuration.
+ * @since_tizen 3.0
+ * @remarks @a config is valid only in this function. In order to use @a config outside this function, you must copy the config with wifi_manager_config_clone().
+ *
+ * @param[in] config The access point configuration handle
+ * @param[in] user_data The user data passed from the request function
+ *
+ * @return @c true to continue with the next iteration of the loop, otherwise @c false to break out of the loop \n
+ * @pre wifi_manager_config_foreach_configuration() will invoke this callback.
+ * @see wifi_manager_config_foreach_configuration()
+ */
+typedef bool (*wifi_manager_config_list_cb)(const wifi_manager_config_h config, void *user_data);
+
+/**
+* @}
+*/
+
+/**
+ * @addtogroup CAPI_NETWORK_WIFI_MANAGER_TDLS_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when the WiFi TDLS state is changed.
+ * @since_tizen 3.0
+ *
+ * @param[in] state The TDLS state
+ * @param[in] peer_mac_addr MAC address of the TDLS peer
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see wifi_manager_tdls_set_state_changed_cb()
+ * @see wifi_manager_tdls_unset_state_changed_cb()
+ */
+typedef void(*wifi_manager_tdls_state_changed_cb)(wifi_manager_tdls_state_e state,
+ char *peer_mac_addr, void *user_data);
+
+/**
+ * @}
+ */
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_MODULE
+* @{
+*/
+
+/**
+ * @brief Initializes Wi-Fi.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @remarks You must release @a handle using wifi_manager_deinitialize().
+ * @param[out] wifi The wifi handle
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_ALREADY_INITIALIZED Already initialized
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_initialize(wifi_manager_h *wifi);
+
+/**
+ * @brief Deinitializes Wi-Fi.
+ * @since_tizen 3.0
+ * @param[in] wifi The wifi handle
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_deinitialize(wifi_manager_h wifi);
+
+/**
+* @}
+*/
+
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_MANAGEMENT_MODULE
+* @{
+*/
+
+/**
+ * @brief Activates Wi-Fi asynchronously.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set \n
+ * %http://tizen.org/privilege/network.get
+ * @remark This API needs both privileges.
+ * @param[in] wifi The wifi 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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_SECURITY_RESTRICTED Restricted by security system policy
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @post wifi_manager_activated_cb() will be invoked.
+ * @see wifi_manager_activated_cb()
+ * @see wifi_manager_deactivate()
+ */
+int wifi_manager_activate(wifi_manager_h wifi, wifi_manager_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 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set \n
+ * %http://tizen.org/privilege/network.get
+ * @remark This API needs both privileges.
+ * @param[in] wifi The wifi 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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_SECURITY_RESTRICTED Restricted by security system policy
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @post wifi_manager_activated_cb() will be invoked.
+ * @see wifi_manager_activated_cb()
+ * @see wifi_manager_deactivate()
+ */
+int wifi_manager_activate_with_wifi_picker_tested(wifi_manager_h wifi,
+ wifi_manager_activated_cb callback, void *user_data);
+
+/**
+ * @brief Deactivates Wi-Fi asynchronously.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set \n
+ * %http://tizen.org/privilege/network.get
+ * @remark This API needs both privileges.
+ * @param[in] wifi The wifi 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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @post wifi_manager_deactivated_cb() will be invoked.
+ * @see wifi_manager_deactivated_cb()
+ * @see wifi_manager_activate()
+ */
+int wifi_manager_deactivate(wifi_manager_h wifi, wifi_manager_deactivated_cb callback, void *user_data);
+
+/**
+ * @brief Checks whether Wi-Fi is activated.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @param[in] wifi The wifi handle
+ * @param[out] activated @c true if Wi-Fi is activated,
+ * otherwise @c false if Wi-Fi is not activated.
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_is_activated(wifi_manager_h wifi, bool *activated);
+
+/**
+ * @brief Gets the local MAC address.
+ * @since_tizen 3.0
+ * @remarks You must release @a mac_address using free().
+ * @param[in] wifi The wifi handle
+ * @param[out] mac_address The MAC address
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_get_mac_address(wifi_manager_h wifi, char **mac_address);
+
+/**
+ * @brief Gets the name of the network interface.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @remarks You must release @a name using free().
+ * @param[in] wifi The wifi handle
+ * @param[out] name The name of network interface
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_get_network_interface_name(wifi_manager_h wifi, char **name);
+
+/**
+ * @brief Starts scan asynchronously.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set \n
+ * %http://tizen.org/privilege/network.get
+ * @remark This API needs both privileges.
+ * @param[in] wifi The wifi handle
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @post This function invokes wifi_manager_scan_finished_cb().
+ */
+int wifi_manager_scan(wifi_manager_h wifi, wifi_manager_scan_finished_cb callback, void *user_data);
+
+/**
+ * @brief Starts specific AP scan, asynchronously.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set \n
+ * %http://tizen.org/privilege/network.get
+ * @remark This API needs both privileges.
+ * @param[in] wifi The wifi handle
+ * @param[in] essid The essid of hidden AP
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @post This function invokes wifi_manager_scan_finished_cb().
+ */
+int wifi_manager_scan_specific_ap(wifi_manager_h wifi,
+ const char *essid, wifi_manager_scan_finished_cb callback, void *user_data);
+
+/**
+ * @brief Gets the handle of the connected access point.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @remarks You must release @a handle using wifi_manager_ap_destroy().
+ * @param[in] wifi The wifi handle
+ * @param[out] ap The access point handle
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_NO_CONNECTION There is no connected AP
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_get_connected_ap(wifi_manager_h wifi, wifi_manager_ap_h *ap);
+
+/**
+ * @brief Gets the result of the scan.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @param[in] wifi The wifi handle
+ * @param[in] callback The callback to be called
+ * @param[in] user_data The user data passed to the callback function
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @post This function invokes wifi_manager_found_ap_cb().
+ */
+int wifi_manager_foreach_found_ap(wifi_manager_h wifi, wifi_manager_found_ap_cb callback, void *user_data);
+
+/**
+ * @brief Gets the result of specific AP scan.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @param[in] wifi The wifi handle
+ * @param[in] callback The callback to be called
+ * @param[in] user_data The user data passed to the callback function
+ * @return 0 on success, otherwise negative error value.
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @post This function invokes wifi_manager_found_ap_cb().
+ * @see wifi_manager_scan_specific_ap()
+ */
+int wifi_manager_foreach_found_specific_ap(wifi_manager_h wifi,
+ wifi_manager_found_ap_cb callback, void *user_data);
+
+/**
+ * @brief Connects to the access point asynchronously.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set \n
+ * %http://tizen.org/privilege/network.get
+ * @remark This API needs both privileges.
+ * @param[in] wifi The wifi handle
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @post This function invokes wifi_manager_connected_cb().
+ * @see wifi_manager_connected_cb()
+ * @see wifi_manager_connect_by_wps_pbc()
+ * @see wifi_manager_connect_by_wps_pin()
+ * @see wifi_manager_disconnect()
+ */
+int wifi_manager_connect(wifi_manager_h wifi, wifi_manager_ap_h ap, wifi_manager_connected_cb callback, void *user_data);
+
+/**
+ * @brief Disconnects to the access point asynchronously.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set \n
+ * %http://tizen.org/privilege/network.get
+ * @remark This API needs both privileges.
+ * @param[in] wifi The wifi handle
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @post This function invokes wifi_manager_disconnected_cb().
+ * @see wifi_manager_disconnected_cb()
+ * @see wifi_manager_connect_by_wps_pbc()
+ * @see wifi_manager_connect_by_wps_pin()
+ * @see wifi_manager_connect()
+ */
+int wifi_manager_disconnect(wifi_manager_h wifi, wifi_manager_ap_h ap, wifi_manager_disconnected_cb callback, void *user_data);
+
+/**
+ * @brief Connects to the access point with WPS PBC asynchronously.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile \n
+ * %http://tizen.org/privilege/network.get
+ * @remark This API needs both privileges.
+ * @param[in] wifi The wifi handle
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @post This function invokes wifi_manager_connected_cb().
+ * @see wifi_manager_connected_cb()
+ * @see wifi_manager_connect()
+ * @see wifi_manager_disconnect()
+ * @see wifi_manager_ap_is_wps_supported()
+ */
+int wifi_manager_connect_by_wps_pbc(wifi_manager_h wifi,
+ wifi_manager_ap_h ap, wifi_manager_connected_cb callback, void *user_data);
+
+/**
+ * @brief Connects to the access point with WPS PIN asynchronously.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile \n
+ * %http://tizen.org/privilege/network.get
+ * @remark This API needs both privileges.
+ * @param[in] wifi The wifi handle
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @post This function invokes wifi_manager_connected_cb().
+ * @see wifi_manager_connected_cb()
+ * @see wifi_manager_connect()
+ * @see wifi_manager_disconnect()
+ * @see wifi_manager_ap_is_wps_supported()
+ */
+int wifi_manager_connect_by_wps_pin(wifi_manager_h wifi,
+ wifi_manager_ap_h ap, const char *pin, wifi_manager_connected_cb callback, void *user_data);
+
+/**
+ * @brief Deletes the information of a stored access point and disconnects it if it was 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 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile \n
+ * %http://tizen.org/privilege/network.get
+ * @remark This API needs both privileges.
+ * @param[in] wifi The wifi handle
+ * @param[in] ap The access point handle
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_forget_ap(wifi_manager_h wifi, wifi_manager_ap_h ap);
+
+/**
+ * @brief Updates an existing AP.
+ * @details When a AP is changed, these changes will be not applied to the Connection Manager immediately.
+ * When you call this function, your changes affect the Connection Manager and the existing AP is updated.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile \n
+ * %http://tizen.org/privilege/network.get
+ * @remark This API needs both privileges.
+ * @param[in] wifi The wifi handle
+ * @param[in] ap The access point handle
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_update_ap(wifi_manager_h wifi, wifi_manager_ap_h ap);
+
+/**
+* @}
+*/
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_MONITOR_MODULE
+* @{
+*/
+
+/**
+ * @brief Gets the connection state.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @param[in] wifi The wifi handle
+ * @param[out] connection_state The connection state
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_get_connection_state(wifi_manager_h wifi,
+ wifi_manager_connection_state_e *connection_state);
+
+/**
+ * @brief Registers the callback called when the device state is changed.
+ * @since_tizen 3.0
+ * @param[in] wifi The wifi handle
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_set_device_state_changed_cb(wifi_manager_h wifi,
+ wifi_manager_device_state_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback called when the device state is changed.
+ * @since_tizen 3.0
+ * @param[in] wifi The wifi handle
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_unset_device_state_changed_cb(wifi_manager_h wifi);
+
+/**
+ * @brief Registers the callback called when the background scan is finished.
+ * @since_tizen 3.0
+ * @param[in] wifi The wifi handle
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_set_background_scan_cb(wifi_manager_h wifi,
+ wifi_manager_scan_finished_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback called when the scan is finished.
+ * @since_tizen 3.0
+ * @param[in] wifi The wifi handle
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_unset_background_scan_cb(wifi_manager_h wifi);
+
+/**
+ * @brief Registers the callback called when the connection state is changed.
+ * @since_tizen 3.0
+ * @param[in] wifi The wifi handle
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_set_connection_state_changed_cb(wifi_manager_h wifi,
+ wifi_manager_connection_state_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback called when the connection state is changed.
+ * @since_tizen 3.0
+ * @param[in] wifi The wifi handle
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_unset_connection_state_changed_cb(wifi_manager_h wifi);
+
+/**
+ * @brief Registers callback called when the RSSI of connected Wi-Fi is changed.
+ * @since_tizen 3.0
+ * @param[in] wifi The wifi handle
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_set_rssi_level_changed_cb(wifi_manager_h wifi,
+ wifi_manager_rssi_level_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters callback called when the RSSI of connected Wi-Fi is changed.
+ * @since_tizen 3.0
+ * @param[in] wifi The wifi handle
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_unset_rssi_level_changed_cb(wifi_manager_h wifi);
+
+/**
+* @}
+*/
+
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_AP_MODULE
+* @{
+*/
+
+/**
+ * @brief Creates the access point handle.
+ * @since_tizen 3.0
+ * @remarks You must release @a AP using wifi_manager_ap_destroy().
+ * @param[in] wifi The wifi handle
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_ap_destroy()
+ */
+int wifi_manager_ap_create(wifi_manager_h wifi, const char *essid, wifi_manager_ap_h *ap);
+
+/**
+ * @brief Creates the hidden access point handle.
+ * @since_tizen 3.0
+ * @remarks You must release @a AP using wifi_manager_ap_destroy().
+ * @param[in] wifi The wifi handle
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_ap_destroy()
+ */
+int wifi_manager_ap_hidden_create(wifi_manager_h wifi, const char *essid, wifi_manager_ap_h *ap);
+
+/**
+ * @brief Destroys the access point handle.
+ * @since_tizen 3.0
+ * @param[in] ap The access point handle
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_ap_create()
+ */
+int wifi_manager_ap_destroy(wifi_manager_ap_h ap);
+
+/**
+ * @brief Clones the access point handle.
+ * @since_tizen 3.0
+ * @remarks You must release @a cloned_ap using wifi_manager_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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_ap_destroy()
+ */
+int wifi_manager_ap_clone(wifi_manager_ap_h *cloned_ap, wifi_manager_ap_h origin);
+
+/**
+ * @brief Refreshes the access point information.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_refresh(wifi_manager_ap_h ap);
+
+/**
+* @}
+*/
+
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_AP_NETWORK_MODULE
+* @{
+*/
+
+/**
+ * @brief Gets ESSID (Extended Service Set Identifier).
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_essid(wifi_manager_ap_h ap, char **essid);
+
+/**
+ * @brief Gets BSSID (Basic Service Set Identifier).
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_bssid(wifi_manager_ap_h ap, char **bssid);
+
+/**
+ * @brief Gets the RSSI.
+ * @since_tizen 3.0
+ * @param[in] ap The access point handle
+ * @param[out] rssi The RSSI
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_rssi(wifi_manager_ap_h ap, int *rssi);
+
+/**
+ * @brief Gets the frequency band (MHz).
+ * @since_tizen 3.0
+ * @param[in] ap The access point handle
+ * @param[out] frequency The frequency
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_frequency(wifi_manager_ap_h ap, int *frequency);
+
+/**
+ * @brief Gets the max speed (Mbps).
+ * @since_tizen 3.0
+ * @param[in] ap The access point handle
+ * @param[out] max_speed The max speed
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_max_speed(wifi_manager_ap_h ap, int *max_speed);
+
+/**
+ * @brief Checks whether the access point is favorite or not.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_is_favorite(wifi_manager_ap_h ap, bool *favorite);
+
+/**
+ * @brief Checks whether the access point is passpoint or not.
+ * @since_tizen 3.0
+ * @param[in] ap The access point handle
+ * @param[out] passpoint @c true if access point is passpoint,
+ * otherwise @c false if access point is not passpoint.
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_is_passpoint(wifi_manager_ap_h ap, bool *passpoint);
+
+/**
+ * @brief Gets the connection state.
+ * @since_tizen 3.0
+ * @param[in] ap The access point handle
+ * @param[out] state The connection state
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_connection_state(wifi_manager_ap_h ap, wifi_manager_connection_state_e *state);
+
+/**
+ * @brief Gets the config type of IP.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_ip_config_type(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, wifi_manager_ip_config_type_e *type);
+
+/**
+ * @brief Sets the config type of IP.
+ * @details If you set IP config type to #WIFI_MANAGER_IP_CONFIG_TYPE_STATIC,
+ * then IP address, Gateway and Subnet mask will be set to the initial value "0.0.0.0".
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_update_ap()
+ */
+int wifi_manager_ap_set_ip_config_type(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, wifi_manager_ip_config_type_e type);
+
+/**
+ * @brief Gets the IP address.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_ip_address(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, char **ip_address);
+
+/**
+ * @brief Sets the IP address.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_update_ap()
+ */
+int wifi_manager_ap_set_ip_address(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, const char *ip_address);
+
+/**
+ * @brief Gets the subnet mask.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_subnet_mask(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, char **subnet_mask);
+
+/**
+ * @brief Sets the subnet mask.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_update_ap()
+ */
+int wifi_manager_ap_set_subnet_mask(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, const char *subnet_mask);
+
+/**
+ * @brief Gets the gateway address.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_gateway_address(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, char **gateway_address);
+
+/**
+ * @brief Sets the gateway address.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_update_ap()
+ */
+int wifi_manager_ap_set_gateway_address(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, const char *gateway_address);
+
+/**
+ * @brief Gets the proxy address.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_proxy_address(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, char **proxy_address);
+
+/**
+ * @brief Sets the proxy address.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_update_ap()
+ */
+int wifi_manager_ap_set_proxy_address(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, const char *proxy_address);
+
+/**
+ * @brief Gets the Proxy type.
+ * @since_tizen 3.0
+ * @param[in] ap The access point handle
+ * @param[out] proxy_type The type of proxy
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_proxy_type(wifi_manager_ap_h ap,
+ wifi_manager_proxy_type_e *proxy_type);
+
+/**
+ * @brief Sets the Proxy address.
+ * @details If you set Proxy type to #WIFI_MANAGER_PROXY_TYPE_AUTO or #WIFI_MANAGER_PROXY_TYPE_MANUAL, then Proxy will be restored.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_update_ap()
+ */
+int wifi_manager_ap_set_proxy_type(wifi_manager_ap_h ap,
+ wifi_manager_proxy_type_e proxy_type);
+
+/**
+ * @brief Gets the DNS address.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_dns_address(wifi_manager_ap_h ap,
+ int order, wifi_manager_address_family_e address_family, char **dns_address);
+
+/**
+ * @brief Sets the DNS address.
+ * @since_tizen 3.0
+ * @remarks The allowance of DNS address is @c 2 \n
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Address family not supported
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_update_ap()
+ */
+int wifi_manager_ap_set_dns_address(wifi_manager_ap_h ap,
+ int order, wifi_manager_address_family_e address_family, const char *dns_address);
+
+/**
+* @}
+*/
+
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_AP_SECURITY_MODULE
+* @{
+*/
+
+/**
+ * @brief Gets the Wi-Fi security mode.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_security_type(wifi_manager_ap_h ap, wifi_manager_security_type_e *type);
+
+/**
+ * @brief Sets the Wi-Fi security mode.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_set_security_type(wifi_manager_ap_h ap, wifi_manager_security_type_e type);
+
+/**
+ * @brief Gets the Wi-Fi encryption type.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_encryption_type(wifi_manager_ap_h ap, wifi_manager_encryption_type_e *type);
+
+/**
+ * @brief Sets the Wi-Fi encryption type.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_set_encryption_type(wifi_manager_ap_h ap, wifi_manager_encryption_type_e type);
+
+/**
+ * @brief Checks whether the passphrase is required or not.
+ * @since_tizen 3.0
+ * @remarks This function is not valid if security type is #WIFI_MANAGER_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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_is_passphrase_required(wifi_manager_ap_h ap, bool *required);
+
+/**
+ * @brief Sets the passphrase.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_set_passphrase(wifi_manager_ap_h ap, const char *passphrase);
+
+/**
+ * @brief Checks whether the WPS(Wi-Fi Protected Setup) is supported or not.
+ * @since_tizen 3.0
+ * @param[in] ap The access point handle
+ * @param[out] supported @c true if WPS is supported,
+ * otherwise @c false is WPS is not supported.
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_connect_by_wps_pbc()
+ * @see wifi_manager_connect_by_wps_pin()
+ */
+int wifi_manager_ap_is_wps_supported(wifi_manager_ap_h ap, bool *supported);
+
+/**
+* @}
+*/
+
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_AP_SECURITY_EAP_MODULE
+* @{
+*/
+
+/**
+ * @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 3.0
+ * @remarks This function is valid only if the EAP type is #WIFI_MANAGER_EAP_TYPE_PEAP or #WIFI_MANAGER_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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_set_eap_passphrase(wifi_manager_ap_h ap, const char *user_name, const char *password);
+
+/**
+ * @brief Gets the passphrase of EAP.
+ * @since_tizen 3.0
+ * @remarks This function is valid only if the EAP type is #WIFI_MANAGER_EAP_TYPE_PEAP or #WIFI_MANAGER_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 true if password is set,
+ * otherwise @c flase if password is not set.
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_eap_passphrase(wifi_manager_ap_h ap, char **user_name, bool *is_password_set);
+
+/**
+ * @brief Gets the CA Certificate of EAP.
+ * @since_tizen 3.0
+ * @remarks This function is valid only if the EAP type is #WIFI_MANAGER_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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_eap_ca_cert_file(wifi_manager_ap_h ap, char **file);
+
+/**
+ * @brief Sets the CA Certificate of EAP.
+ * @since_tizen 3.0
+ * @remarks This function is valid only if the EAP type is #WIFI_MANAGER_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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_set_eap_ca_cert_file(wifi_manager_ap_h ap, const char *file);
+
+/**
+ * @brief Gets the Client Certificate of EAP.
+ * @since_tizen 3.0
+ * @remarks This function is valid only if the EAP type is #WIFI_MANAGER_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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_eap_client_cert_file(wifi_manager_ap_h ap, char **file);
+
+/**
+ * @brief Sets the CA Certificate of EAP.
+ * @since_tizen 3.0
+ * @remarks This function is valid only if the EAP type is #WIFI_MANAGER_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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_set_eap_client_cert_file(wifi_manager_ap_h ap, const char *file);
+
+/**
+ * @brief Gets the private key file of EAP.
+ * @since_tizen 3.0
+ * @remarks This function is valid only if the EAP type is #WIFI_MANAGER_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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_eap_private_key_file(wifi_manager_ap_h ap, char **file);
+
+/**
+ * @brief Sets the private key information of EAP.
+ * @since_tizen 3.0
+ * @remarks This function is valid only if the EAP type is #WIFI_MANAGER_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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_set_eap_private_key_info(wifi_manager_ap_h ap,
+ const char *file, const char *password);
+
+/**
+ * @brief Gets the EAP type of Wi-Fi.
+ * @since_tizen 3.0
+ * @param[in] ap The access point handle
+ * @param[out] type The type of EAP
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_eap_type(wifi_manager_ap_h ap, wifi_manager_eap_type_e *type);
+
+/**
+ * @brief Sets the EAP type of Wi-Fi.
+ * @since_tizen 3.0
+ * @param[in] ap The access point handle
+ * @param[in] type The type of EAP
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_set_eap_type(wifi_manager_ap_h ap, wifi_manager_eap_type_e type);
+
+/**
+ * @brief Gets the type of EAP phase2 authentication of Wi-Fi.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_get_eap_auth_type(wifi_manager_ap_h ap, wifi_manager_eap_auth_type_e *type);
+
+/**
+ * @brief Sets the type of EAP phase2 authentication of Wi-Fi.
+ * @since_tizen 3.0
+ * @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_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_set_eap_auth_type(wifi_manager_ap_h ap, wifi_manager_eap_auth_type_e type);
+
+/**
+* @}
+*/
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_CONFIG_MODULE
+* @{
+*/
+
+/**
+ * @brief Gets access point configuration handle.
+ * @since_tizen 3.0
+ * @remarks You must release @a config using wifi_manager_config_destroy().
+ *
+ * @param[in] wifi The wifi handle
+ * @param[in] name The access point name
+ * @param[in] passphrase The access point passphrase
+ * @param[in] security_type The access point security type
+ * @param[out] config The access point configuration handle
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_config_destroy()
+ * @pre This API needs wifi_manager_initialize() before use
+ */
+int wifi_manager_config_create(wifi_manager_h wifi, const char *name,
+ const char *passphrase, wifi_manager_security_type_e security_type, wifi_manager_config_h *config);
+
+/**
+ * @brief Clones the access point configuration handle.
+ * @since_tizen 3.0
+ * @remarks You must release @a cloned_config using wifi_manager_config_destroy().
+ *
+ * @param[in] origin The origin access point configuration handle
+ * @param[out] cloned_config The cloned access point configuration handle
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_config_destroy()
+ */
+int wifi_manager_config_clone(wifi_manager_config_h origin, wifi_manager_config_h *cloned_config);
+
+/**
+ * @brief Destroys the access point configuration handle.
+ * @since_tizen 3.0
+ *
+ * @param[in] config The access point configuration handle
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_config_create()
+ * @see wifi_manager_config_clone()
+ */
+int wifi_manager_config_destroy(wifi_manager_config_h config);
+
+/**
+ * @brief Saves Wi-Fi configuration of access point.
+ * @details When a configuration is changed, these changes will be not applied to the Connection Manager immediately.\n
+ * When you call this function, your changes affect the Connection Manager and the existing configuration is updated.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile
+ *
+ * @param[in] wifi The wifi handle
+ * @param[in] config The access point configuration handle
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_config_create()
+ */
+int wifi_manager_config_save(wifi_manager_h wifi, wifi_manager_config_h config);
+
+/**
+ * @brief Removes Wi-Fi configuration of access point.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile
+ *
+ * @param[in] wifi The wifi handle
+ * @param[in] config The access point configuration handle
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_config_create()
+ * @see wifi_manager_config_foreach_configuration()
+ */
+int wifi_manager_config_remove(wifi_manager_h wifi, wifi_manager_config_h config);
+
+/**
+ * @brief Gets configurations of an access point.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile
+ *
+ * @param[in] wifi The wifi handle
+ * @param[in] callback The callback to be called
+ * @param[in] user_data The user data passed to the callback function
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @pre This API needs wifi_manager_initialize() before use.
+ * @post This function invokes wifi_manager_config_list_cb().
+ */
+int wifi_manager_config_foreach_configuration(wifi_manager_h wifi,
+ wifi_manager_config_list_cb callback, void *user_data);
+
+/**
+ * @brief Gets the name of access point from configuration.
+ * @since_tizen 3.0
+ * @remarks You must release @a name using free().
+ *
+ * @param[in] config The access point configuration handle
+ * @param[out] name The name of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_config_get_name(wifi_manager_config_h config, char **name);
+
+/**
+ * @brief Gets the security type of access point from configuration.
+ * @since_tizen 3.0
+ *
+ * @param[in] config The access point configuration handle
+ * @param[out] security_type The security type of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_config_get_security_type(wifi_manager_config_h config,
+ wifi_manager_security_type_e *security_type);
+
+/**
+ * @brief Sets access point proxy address configuration.
+ * @since_tizen 3.0
+ *
+ * @param[in] config The access point configuration handle
+ * @param[in] address_family The address family
+ * @param[in] proxy_address The proxy address
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_config_save()
+ */
+int wifi_manager_config_set_proxy_address(wifi_manager_config_h config,
+ wifi_manager_address_family_e address_family, const char *proxy_address);
+
+/**
+ * @brief Gets the proxy address of access point from configuration.
+ * @since_tizen 3.0
+ * @remarks You must release @a proxy_address using free().
+ *
+ * @param[in] config The access point configuration handle
+ * @param[out] address_family The address family
+ * @param[out] proxy_address The proxy address
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_config_get_proxy_address(wifi_manager_config_h config,
+ wifi_manager_address_family_e *address_family, char **proxy_address);
+
+/**
+ * @brief Sets the hidden property of access point from the configuration.
+ * @since_tizen 3.0
+ *
+ * @param[in] config The access point configuration handle
+ * @param[in] is_hidden The new value of the hidden property
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_config_save()
+ */
+int wifi_manager_config_set_hidden_ap_property(wifi_manager_config_h config, bool is_hidden);
+
+/**
+ * @brief Gets the hidden property of access point from the configuration.
+ * @since_tizen 3.0
+ *
+ * @param[in] config The access point configuration handle
+ * @param[out] is_hidden The hidden property of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_config_get_hidden_ap_property(wifi_manager_config_h config, bool *is_hidden);
+
+/**
+ * @brief Gets access point anonymous identity from configuration.
+ * @since_tizen 3.0
+ * @remarks You must release @a anonymous_identity using free().
+ *
+ * @param[in] config The access point configuration handle
+ * @param[out] anonymous_identity The anonymous identity of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int wifi_manager_config_get_eap_anonymous_identity(wifi_manager_config_h config,
+ char **anonymous_identity);
+
+/**
+ * @brief Sets access point anonymous identity to configuration.
+ * @since_tizen 3.0
+ *
+ * @param[in] config The access point configuration handle
+ * @param[in] anonymous_identity The anonymous identity
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @see wifi_manager_config_save()
+ */
+int wifi_manager_config_set_eap_anonymous_identity(wifi_manager_config_h config,
+ const char *anonymous_identity);
+
+/**
+ * @brief Gets access point cacert file from configuration.
+ * @since_tizen 3.0
+ * @remarks You must release @a ca_cert using free().
+ * @remarks The mediastorage privilege http://tizen.org/privilege/mediastorage is needed \n
+ * if @a image_path is relevant to media storage.\n
+ * The externalstorage privilege http://tizen.org/privilege/externalstorage is needed \n
+ * if @a image_path is relevant to external storage.
+ *
+ * @param[in] config The access point configuration handle
+ * @param[out] ca_cert The certification authority(CA) certificates file of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int wifi_manager_config_get_eap_ca_cert_file(wifi_manager_config_h config, char **ca_cert);
+
+/**
+ * @brief Sets access point cacert file to configuration.
+ * @since_tizen 3.0
+ * @remarks The mediastorage privilege http://tizen.org/privilege/mediastorage is needed \n
+ * if @a image_path is relevant to media storage.\n
+ * The externalstorage privilege http://tizen.org/privilege/externalstorage is needed \n
+ * if @a image_path is relevant to external storage.
+ *
+ * @param[in] config The access point configuration handle
+ * @param[in] ca_cert The certification authority(CA) certificates file of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @see wifi_manager_config_save()
+ */
+int wifi_manager_config_set_eap_ca_cert_file(wifi_manager_config_h config, const char *ca_cert);
+
+/**
+ * @brief Gets access point client cert file from configuration.
+ * @since_tizen 3.0
+ * @remarks You must release @a client_crt using free().
+ *
+ * @param[in] config The access point configuration handle
+ * @param[out] client_cert The certification authority(CA) certificates file of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int wifi_manager_config_get_eap_client_cert_file(wifi_manager_config_h config, char **client_cert);
+
+/**
+ * @brief Sets access point client cert file to configuration.
+ * @since_tizen 3.0
+ *
+ * @param[in] config The access point configuration handle
+ * @param[in] private_key The private key file
+ * @param[in] client_cert The certification authority(CA) certificates file of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @see wifi_manager_config_save()
+ */
+int wifi_manager_config_set_eap_client_cert_file(wifi_manager_config_h config,
+ const char *private_key, const char *client_cert);
+
+/**
+ * @brief Gets access point identity from configuration.
+ * @since_tizen 3.0
+ * @remarks You must release @a identity using free().
+ *
+ * @param[in] config The access point configuration handle
+ * @param[out] identity The identity of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int wifi_manager_config_get_eap_identity(wifi_manager_config_h config, char **identity);
+
+/**
+ * @brief Sets access point identity to configuration.
+ * @since_tizen 3.0
+ *
+ * @param[in] config The access point configuration handle
+ * @param[in] identity The identity
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @see wifi_manager_config_save()
+ */
+int wifi_manager_config_set_eap_identity(wifi_manager_config_h config, const char *identity);
+
+/**
+ * @brief Gets access point EAP type from configuration.
+ * @since_tizen 3.0
+ *
+ * @param[in] config The access point configuration handle
+ * @param[out] eap_type The EAP type of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int wifi_manager_config_get_eap_type(wifi_manager_config_h config, wifi_manager_eap_type_e *eap_type);
+
+/**
+ * @brief Sets access point EAP type to configuration.
+ * @since_tizen 3.0
+ *
+ * @param[in] config The access point configuration handle
+ * @param[in] eap_type The EAP type
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @see wifi_manager_config_save()
+ */
+int wifi_manager_config_set_eap_type(wifi_manager_config_h config, wifi_manager_eap_type_e eap_type);
+
+/**
+ * @brief Gets access point EAP auth type from configuration.
+ * @since_tizen 3.0
+ *
+ * @param[in] config The access point configuration handle
+ * @param[out] eap_auth_type The EAP auth type of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int wifi_manager_config_get_eap_auth_type(wifi_manager_config_h config,
+ wifi_manager_eap_auth_type_e *eap_auth_type);
+
+/**
+ * @brief Sets access point EAP auth type to configuration.
+ * @since_tizen 3.0
+ *
+ * @param[in] config The access point configuration handle
+ * @param[in] eap_auth_type The EAP auth type
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @see wifi_manager_config_save()
+ */
+int wifi_manager_config_set_eap_auth_type(wifi_manager_config_h config,
+ wifi_manager_eap_auth_type_e eap_auth_type);
+
+/**
+ * @brief Gets access point subject match from configuration.
+ * @since_tizen 3.0
+ * @remarks You must release @a subject_match using free().
+ *
+ * @param[in] config The access point configuration handle
+ * @param[out] subject_match The subject match of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int wifi_manager_config_get_eap_subject_match(wifi_manager_config_h config,
+ char **subject_match);
+
+/**
+ * @brief Sets access point subject match to configuration.
+ * @since_tizen 3.0
+ *
+ * @param[in] config The access point configuration handle
+ * @param[in] subject_match The subject match
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @see wifi_manager_config_save()
+ */
+int wifi_manager_config_set_eap_subject_match(wifi_manager_config_h config,
+ const char *subject_match);
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_NETWORK_WIFI_MANAGER_TDLS_MODULE
+ * @{
+ */
+
+/**
+ * @brief Disconnects the connected peer.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set
+ *
+ * @param[in] wifi The wifi handle
+ * @param[in] peer_mac_addr The MAC address of the connected peer
+ *
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_tdls_disconnect(wifi_manager_h wifi, const char *peer_mac_addr);
+
+/**
+ * @brief Gets Peer Mac address of Connected peer.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ *
+ * @remarks The @a peer_mac_addr should be freed using free().
+ * @param[in] wifi The wifi handle
+ * @param[out] peer_mac_addr The MAC address of the connected peer
+ *
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NO_CONNECTION No active TDLS Connection
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_tdls_get_connected_peer(wifi_manager_h wifi, char **peer_mac_addr);
+
+/**
+ * @brief Registers the callback called when TDLS state is changed.
+ * @since_tizen 3.0
+ *
+ * @param[in] wifi The wifi handle
+ * @param[in] callback The callback function to be called
+ * @param[in] user_data The user data passed to the callback function
+ *
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_tdls_set_state_changed_cb(wifi_manager_h wifi,
+ wifi_manager_tdls_state_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback called when TDLS state is changed.
+ * @since_tizen 3.0
+ *
+ * @param[in] wifi The wifi handle
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_tdls_unset_state_changed_cb(wifi_manager_h wifi);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_WIFI_MANAGER_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __WIFI_INTERNAL_H__
+#define __WIFI_INTERNAL_H__
+
+#include <dlog.h>
+#include <glib.h>
+#include <vconf/vconf.h>
+#include <system_info.h>
+
+#include "wifi-manager.h"
+#include "network_interface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#undef LOG_TAG
+#define LOG_TAG "WIFI_MANAGER"
+
+#define WIFI_INFO 1
+#define WIFI_ERROR 2
+#define WIFI_WARN 3
+
+#define WIFI_FEATURE "http://tizen.org/feature/network.wifi"
+#define WIFI_TDLS_FEATURE "http://tizen.org/feature/network.wifi.tdls"
+
+#define WIFI_CONFIG_NAME "Name"
+#define WIFI_CONFIG_SSID "SSID"
+#define WIFI_CONFIG_PASSPHRASE "Passphrase"
+#define WIFI_CONFIG_SECURITY_TYPE "Security"
+#define WIFI_CONFIG_PROXYADDRESS "ProxyAddress"
+#define WIFI_CONFIG_HIDDEN "Hidden"
+#define WIFI_CONFIG_FAILURE "Failure"
+#define WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY "AnonymousIdentity"
+#define WIFI_CONFIG_EAP_CACERT "CACertFile"
+#define WIFI_CONFIG_EAP_CLIENTCERT "ClientCertFile"
+#define WIFI_CONFIG_EAP_PRIVATEKEY "PrivateKeyFile"
+#define WIFI_CONFIG_EAP_IDENTITY "Identity"
+#define WIFI_CONFIG_EAP_TYPE "EapType"
+#define WIFI_CONFIG_EAP_AUTH_TYPE "EapAuthType"
+#define WIFI_CONFIG_EAP_SUBJECT_MATCH "SubjectMatch"
+
+typedef enum {
+ WIFI_SUPPORTED_FEATURE_WIFI,
+ WIFI_SUPPORTED_FEATURE_WIFI_TDLS,
+ WIFI_SUPPORTED_FEATURE_MAX,
+} wifi_supported_feature_e;
+
+
+#define CHECK_FEATURE_SUPPORTED(...) \
+ do { \
+ int rv = _wifi_check_feature_supported(__VA_ARGS__, NULL); \
+ if (rv != WIFI_MANAGER_ERROR_NONE) \
+ return rv; \
+ } while (0)
+
+#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)
+
+typedef enum {
+ WIFI_DEVICE_STATE_CB,
+ WIFI_BG_SCAN_CB,
+ WIFI_SCAN_REQUEST_CB,
+ WIFI_SPECIFIC_SCAN_CB,
+ WIFI_MANAGER_CONNECTION_STATE_CB,
+ WIFI_ACTIVATED_CB,
+ WIFI_DEACTIVATED_CB,
+ WIFI_CONNECTED_CB,
+ WIFI_DISCONNECTED_CB,
+ WIFI_MANAGER_RSSI_LEVEL_CHANGED_CB,
+ WIFI_MANAGER_TDLS_STATE_CHANGED_CB,
+} wifi_manager_handle_cb_e;
+
+typedef struct {
+ int count;
+ net_profile_info_s *profiles;
+} wifi_profile_list_s;
+
+typedef struct {
+ GSourceFunc func;
+ gpointer user_data;
+ guint id;
+} wifi_managed_idle_data_s;
+
+typedef struct {
+ gchar *ca_cert;
+ gchar *private_key;
+ gchar *client_cert;
+ gchar *anonymous_identity;
+ gchar *identity;
+ gchar *subject_match;
+ wifi_manager_eap_type_e eap_type;
+ wifi_manager_eap_auth_type_e eap_auth_type;
+} wifi_eap_config_s;
+
+typedef struct {
+ gchar *name;
+ gchar *passphrase;
+ wifi_manager_security_type_e security_type;
+ gboolean is_saved;
+
+ gboolean is_hidden;
+ gchar *proxy_address;
+ wifi_manager_address_family_e address_family;
+ wifi_eap_config_s *eap_config;
+ wifi_manager_error_e last_error;
+} wifi_config_s;
+
+typedef struct {
+ wifi_manager_device_state_changed_cb device_state_cb;
+ void *device_state_user_data;
+ wifi_manager_scan_finished_cb bg_scan_cb;
+ void *bg_scan_user_data;
+ wifi_manager_scan_finished_cb scan_request_cb;
+ void *scan_request_user_data;
+ wifi_manager_scan_finished_cb specific_scan_cb;
+ void *specific_scan_user_data;
+ wifi_manager_connection_state_changed_cb connection_state_cb;
+ void *connection_state_user_data;
+ wifi_manager_activated_cb activated_cb;
+ void *activated_user_data;
+ wifi_manager_deactivated_cb deactivated_cb;
+ void *deactivated_user_data;
+ wifi_manager_connected_cb connected_cb;
+ void *connected_user_data;
+ wifi_manager_disconnected_cb disconnected_cb;
+ void *disconnected_user_data;
+
+ wifi_manager_rssi_level_changed_cb rssi_level_changed_cb;
+ void *rssi_level_changed_user_data;
+ wifi_manager_tdls_state_changed_cb tdls_state_changed_cb;
+ void *tdls_state_changed_user_data;
+} wifi_manager_handle_s;
+
+/* WIFI Manager */
+int _wifi_init(void);
+bool _wifi_deinit(void);
+
+int _wifi_create_handle(wifi_manager_h *wifi);
+int _wifi_add_to_handle_list(wifi_manager_h* wifi);
+void _wifi_remove_from_handle_list(wifi_manager_h wifi);
+bool _wifi_find_from_handle_list(wifi_manager_h wifi);
+int _wifi_get_count_from_handle_list(void);
+int _wifi_get_callback_count_from_handle_list(wifi_manager_handle_cb_e e);
+
+int _wifi_activate(wifi_manager_h wifi, wifi_manager_activated_cb callback,
+ gboolean wifi_picker_test, void *user_data);
+int _wifi_deactivate(wifi_manager_h wifi, wifi_manager_deactivated_cb callback, void *user_data);
+
+bool _wifi_check_ap_validity(wifi_manager_ap_h ap_h);
+void _wifi_add_to_ap_list(wifi_manager_ap_h ap_h);
+void _wifi_remove_from_ap_list(wifi_manager_ap_h ap_h);
+bool _wifi_check_profile_name_validity(const char *profile_name);
+
+int _wifi_get_wifi_device_state(wifi_manager_device_state_e *device_state);
+int _wifi_get_wifi_state(wifi_manager_connection_state_e* connection_state);
+int _wifi_get_intf_name(char** name);
+int _wifi_scan_request(wifi_manager_h wifi,
+ wifi_manager_scan_finished_cb callback, void *user_data);
+int _wifi_scan_specific_ap(wifi_manager_h wifi, const char *essid,
+ wifi_manager_scan_finished_cb callback, void *user_data);
+int _wifi_get_connected_profile(wifi_manager_ap_h *ap);
+int _wifi_foreach_found_ap(wifi_manager_found_ap_cb callback, void *user_data);
+int _wifi_foreach_found_specific_ap(wifi_manager_found_ap_cb callback, void *user_data);
+
+int _wifi_open_profile(wifi_manager_h wifi, wifi_manager_ap_h ap_h,
+ wifi_manager_connected_cb callback, void *user_data);
+int _wifi_close_profile(wifi_manager_h wifi, wifi_manager_ap_h ap_h,
+ wifi_manager_disconnected_cb callback, void *user_data);
+int _wifi_connect_with_wps_pbc(wifi_manager_h wifi, wifi_manager_ap_h ap,
+ wifi_manager_connected_cb callback, void *user_data);
+int _wifi_connect_with_wps_pin(wifi_manager_h wifi, wifi_manager_ap_h ap,
+ const char *pin, wifi_manager_connected_cb callback, void *user_data);
+int _wifi_forget_ap(wifi_manager_ap_h ap);
+
+void _wifi_rssi_level_changed_cb(keynode_t *node, void *user_data);
+
+int _wifi_update_ap_info(net_profile_info_s *ap_info);
+wifi_manager_connection_state_e _wifi_convert_to_ap_state(net_state_type_e state);
+
+/* WIFI Configuration */
+bool _wifi_check_config_validity(wifi_manager_config_h config_h);
+void _wifi_add_to_config_list(wifi_manager_config_h config_h);
+void _wifi_remove_from_config_list(wifi_manager_config_h config_h);
+gchar * _wifi_config_get_config_id(const gchar *name, wifi_manager_security_type_e security_type);
+int _wifi_config_get_config_id_list(GSList **list);
+
+int _wifi_save_configuration(const gchar *name, const gchar *passphrase,
+ wifi_manager_security_type_e security_type, const gchar *proxy_address, gboolean is_hidden);
+int _wifi_load_configurations(void);
+int _wifi_foreach_configuration(wifi_manager_config_list_cb callback, void *user_data);
+int _wifi_remove_configuration(const gchar *config_id);
+int _wifi_configuration_set_field(const gchar *config_id, const gchar *key, const gchar *value);
+int _wifi_configuration_get_passphrase(const gchar *config_id, gchar **passphrase);
+int _wifi_save_eap_configurations(const gchar *name, const gchar *passphrase,
+ wifi_manager_security_type_e security_type, const gchar *proxy_address,
+ wifi_eap_config_s *eap_config, gboolean is_hidden);
+gchar *_wifi_eap_type_to_string(wifi_manager_eap_type_e eap_type);
+gchar *_wifi_eap_auth_type_to_string(wifi_manager_eap_auth_type_e eap_auth_type);
+
+/* WIFI Privilege Check */
+int _wifi_check_get_privilege();
+int _wifi_check_profile_privilege();
+
+/* WIFI Feature Check */
+bool __check_feature_supported(const char *key, wifi_supported_feature_e feature);
+int _wifi_check_feature_supported(const char *feature_name, ...);
+
+/* WIFI Handle Check */
+bool __wifi_check_handle_validity(wifi_manager_h wifi);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __WIFI_INTERNAL_H__ */
--- /dev/null
+Name: capi-network-wifi-manager
+Summary: Network Wi-Fi library in TIZEN C API
+Version: 1.0.1
+Release: 1
+Group: System/Network
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(gthread-2.0)
+BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(capi-system-info)
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%if "%{profile}" == "wearable"
+BuildRequires: pkgconfig(capi-appfw-application)
+%endif
+
+%description
+Network Wi-Fi Manager library in Tizen C API
+
+%package devel
+Summary: Network Wi-Fi Manager library in Tizen C API (Development)
+Group: System/Network
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+Network Wi-Fi Manager 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} \
+ -DLIB_PATH=%{_lib} \
+%if "%{profile}" == "wearable"
+ -DTIZEN_WEARABLE=1 \
+%else
+%if "%{profile}" == "mobile"
+ -DTIZEN_MOBILE=1 \
+%else
+%if "%{profile}" == "tv"
+ -DTIZEN_TV=1 \
+%endif
+%endif
+%endif
+ .
+
+make %{?_smp_mflags}
+
+
+%install
+%make_install
+
+#License
+mkdir -p %{buildroot}%{_datadir}/license
+cp LICENSE %{buildroot}%{_datadir}/license/capi-network-wifi-manager
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%manifest capi-network-wifi-manager.manifest
+%attr(644,-,-) %{_libdir}/libcapi-network-wifi-manager.so.*
+%{_datadir}/license/capi-network-wifi-manager
+%{_bindir}/wifi_manager_test
+
+%files devel
+%{_includedir}/network/*.h
+%{_libdir}/pkgconfig/*.pc
+%{_libdir}/libcapi-network-wifi-manager.so
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
+#include "wifi_internal.h"
+#include "network_internal.h"
+#include "network_dbus.h"
+
+#define DBUS_REPLY_TIMEOUT (120 * 1000)
+
+#define WIFI_SECURITY_NONE "none"
+#define WIFI_SECURITY_WEP "wep"
+#define WIFI_SECURITY_WPA_PSK "psk"
+#define WIFI_SECURITY_EAP "ieee8021x"
+
+extern __thread network_info_s NetworkInfo;
+extern __thread network_request_table_s request_table[NETWORK_REQUEST_TYPE_MAX];
+
+//LCOV_EXCL_START
+static int __net_error_string_to_enum(const char *error)
+{
+ WIFI_LOG(WIFI_INFO, "Passed error value [%s]", error);
+
+ if (NULL != strstr(error, "NoReply"))
+ return NET_ERR_TIME_OUT;
+ else if (NULL != strstr(error, "Failed"))
+ return NET_ERR_UNKNOWN;
+ else if (NULL != strstr(error, "UnknownMethod"))
+ return NET_ERR_UNKNOWN_METHOD;
+ else if (NULL != strstr(error, "InvalidArguments"))
+ return NET_ERR_INVALID_PARAM;
+ else if (NULL != strstr(error, "AccessDenied"))
+ return NET_ERR_ACCESS_DENIED;
+ else if (NULL != strstr(error, "PermissionDenied"))
+ return NET_ERR_ACCESS_DENIED;
+ else if (NULL != strstr(error, "PassphraseRequired"))
+ return NET_ERR_INVALID_OPERATION;
+ else if (NULL != strstr(error, "NotRegistered"))
+ return NET_ERR_INVALID_OPERATION;
+ else if (NULL != strstr(error, "NotUnique"))
+ return NET_ERR_INVALID_OPERATION;
+ else if (NULL != strstr(error, "NotSupported"))
+ return NET_ERR_NOT_SUPPORTED;
+ else if (NULL != strstr(error, "NotImplemented"))
+ return NET_ERR_NOT_SUPPORTED;
+ else if (NULL != strstr(error, "NotFound"))
+ return NET_ERR_NOT_SUPPORTED;
+ else if (NULL != strstr(error, "NoCarrier"))
+ return NET_ERR_NOT_SUPPORTED;
+ else if (NULL != strstr(error, "InProgress"))
+ return NET_ERR_IN_PROGRESS;
+ else if (NULL != strstr(error, "AlreadyExists"))
+ return NET_ERR_INVALID_OPERATION;
+ else if (NULL != strstr(error, "AlreadyEnabled"))
+ return NET_ERR_INVALID_OPERATION;
+ else if (NULL != strstr(error, "AlreadyDisabled"))
+ return NET_ERR_INVALID_OPERATION;
+ else if (NULL != strstr(error, "AlreadyConnected"))
+ return NET_ERR_ACTIVE_CONNECTION_EXISTS;
+ else if (NULL != strstr(error, "NotConnected"))
+ return NET_ERR_NO_ACTIVE_CONNECTIONS;
+ else if (NULL != strstr(error, "OperationAborted"))
+ return NET_ERR_OPERATION_ABORTED;
+ else if (NULL != strstr(error, "OperationTimeout"))
+ return NET_ERR_TIME_OUT;
+ else if (NULL != strstr(error, "InvalidService"))
+ return NET_ERR_NO_SERVICE;
+ else if (NULL != strstr(error, "InvalidProperty"))
+ return NET_ERR_INVALID_OPERATION;
+ else if (NULL != strstr(error, "NoProfile"))
+ return NET_ERR_NO_PROFILE;
+ return NET_ERR_UNKNOWN;
+}
+
+static int __net_netconfig_error_string_to_enum(const char* error)
+{
+ WIFI_LOG(WIFI_ERROR, "Passed error value [%s]", error);
+
+ if (error == NULL)
+ return NET_ERR_UNKNOWN;
+
+ if (NULL != strstr(error, "WifiDriverFailed"))
+ return NET_ERR_WIFI_DRIVER_FAILURE;
+ else if (NULL != strstr(error, "PermissionDenied"))
+ return NET_ERR_SECURITY_RESTRICTED;
+ else if (NULL != strstr(error, "InProgress"))
+ return NET_ERR_WIFI_DRIVER_LOAD_INPROGRESS;
+ else if (NULL != strstr(error, "AccessDenied"))
+ return NET_ERR_ACCESS_DENIED;
+ else if (NULL != strstr(error, "NoProfile"))
+ return NET_ERR_NO_PROFILE;
+ return NET_ERR_UNKNOWN;
+}
+
+static net_wifi_security_type_e __net_wifi_security_type_to_int(const gchar *type)
+{
+ net_wifi_security_type_e ret = WIFI_SEC_NONE;
+
+ if (type == NULL)
+ return ret;
+
+ if (g_strcmp0(type, WIFI_SECURITY_NONE) == 0)
+ ret = WIFI_SEC_NONE;
+ else if (g_strcmp0(type, WIFI_SECURITY_WEP) == 0)
+ ret = WIFI_SEC_WEP;
+ else if (g_strcmp0(type, WIFI_SECURITY_WPA_PSK) == 0)
+ ret = WIFI_SEC_WPA_PSK;
+ else if (g_strcmp0(type, WIFI_SECURITY_EAP) == 0)
+ ret = WIFI_SEC_EAP;
+ else
+ WIFI_LOG(WIFI_ERROR, "Not supported type (%s)", type);
+
+ return ret;
+}
+
+static int __net_wifi_last_error_to_enum(const gchar *last_error)
+{
+ wifi_manager_error_e ret = WIFI_MANAGER_ERROR_OPERATION_FAILED;
+
+ if (g_strcmp0(last_error, "ERROR_NONE") == 0) {
+ ret = WIFI_MANAGER_ERROR_NONE;
+ } else if (g_strcmp0(last_error, "invalid-key") == 0) {
+ ret = WIFI_MANAGER_ERROR_INVALID_KEY;
+ } else if (g_strcmp0(last_error, "dhcp-failed") == 0) {
+ ret = WIFI_MANAGER_ERROR_DHCP_FAILED;
+ } else {
+ WIFI_LOG(WIFI_ERROR, "Not supported error type (%s)", last_error);
+ ret = WIFI_MANAGER_ERROR_NONE;
+ }
+
+ return ret;
+}
+
+gchar *__net_wifi_eap_type_to_string(net_wifi_eap_type_e eap_type)
+{
+ gchar *type = NULL;
+
+ switch (eap_type) {
+ case WIFI_MANAGER_EAP_PEAP:
+ type = g_strdup("PEAP");
+ break;
+ case WIFI_MANAGER_EAP_TLS:
+ type = g_strdup("TLS");
+ break;
+ case WIFI_MANAGER_EAP_TTLS:
+ type = g_strdup("TTLS");
+ break;
+ case WIFI_MANAGER_EAP_SIM:
+ type = g_strdup("SIM");
+ break;
+ case WIFI_MANAGER_EAP_AKA:
+ type = g_strdup("AKA");
+ break;
+ }
+ return type;
+}
+
+gchar *__net_wifi_eap_auth_type_to_string(net_wifi_eap_auth_type_e eap_auth_type)
+{
+ gchar *type = NULL;
+
+ switch (eap_auth_type) {
+ case WIFI_MANAGER_EAP_AUTH_PAP:
+ type = g_strdup("PAP");
+ break;
+ case WIFI_MANAGER_EAP_AUTH_MSCHAP:
+ type = g_strdup("MSCHAP");
+ break;
+ case WIFI_MANAGER_EAP_AUTH_MSCHAPV2:
+ type = g_strdup("MSCHAPV2");
+ break;
+ case WIFI_MANAGER_EAP_AUTH_GTC:
+ type = g_strdup("GTC");
+ break;
+ case WIFI_MANAGER_EAP_AUTH_MD5:
+ type = g_strdup("MD5");
+ break;
+ default:
+ case WIFI_MANAGER_EAP_AUTH_NONE:
+ type = NULL;
+ break;
+ }
+ return type;
+}
+
+net_wifi_eap_type_e __net_wifi_eap_type_to_int(const gchar *type)
+{
+ net_wifi_eap_type_e ret = -1;
+
+ if (type == NULL)
+ return ret;
+
+ if (g_strcmp0(type, "PEAP") == 0)
+ ret = WIFI_MANAGER_EAP_PEAP;
+ else if (g_strcmp0(type, "TLS") == 0)
+ ret = WIFI_MANAGER_EAP_TLS;
+ else if (g_strcmp0(type, "TTLS") == 0)
+ ret = WIFI_MANAGER_EAP_TTLS;
+ else if (g_strcmp0(type, "SIM") == 0)
+ ret = WIFI_MANAGER_EAP_SIM;
+ else if (g_strcmp0(type, "AKA") == 0)
+ ret = WIFI_MANAGER_EAP_AKA;
+ else
+ WIFI_LOG(WIFI_ERROR, "Not supported type (%s)", type);
+
+ return ret;
+}
+
+static net_wifi_eap_auth_type_e __net_wifi_eap_auth_type_to_int(const gchar *type)
+{
+ net_wifi_eap_auth_type_e ret = WIFI_MANAGER_EAP_AUTH_TYPE_NONE;
+
+ if (type == NULL)
+ return ret;
+
+ if (g_strcmp0(type, "PAP") == 0)
+ ret = WIFI_MANAGER_EAP_AUTH_PAP;
+ else if (g_strcmp0(type, "MSCHAP") == 0)
+ ret = WIFI_MANAGER_EAP_AUTH_MSCHAP;
+ else if (g_strcmp0(type, "MSCHAPV2") == 0)
+ ret = WIFI_MANAGER_EAP_AUTH_MSCHAPV2;
+ else if (g_strcmp0(type, "GTC") == 0)
+ ret = WIFI_MANAGER_EAP_AUTH_GTC;
+ else if (g_strcmp0(type, "MD5") == 0)
+ ret = WIFI_MANAGER_EAP_AUTH_MD5;
+ else
+ WIFI_LOG(WIFI_ERROR, "Not supported type (%s)", type);
+
+ return ret;
+}
+
+static void __net_open_connection_reply(GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_event_info_s event_data = { 0, };
+ net_profile_info_s prof_info;
+ network_request_table_s *open_info =
+ &request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION];
+ network_request_table_s *wps_info =
+ &request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS];
+ GDBusConnection *conn = NULL;
+ GError *error = NULL;
+ net_err_e Error = NET_ERR_NONE;
+
+ WIFI_LOG(WIFI_INFO, "__net_open_connection_reply() called");
+
+ conn = G_DBUS_CONNECTION(source_object);
+ g_dbus_connection_call_finish(conn, res, &error);
+
+ if (error != NULL) {
+ Error = __net_error_string_to_enum(error->message);
+ g_error_free(error);
+ }
+
+ if (Error == NET_ERR_NONE)
+ goto done;
+
+ WIFI_LOG(WIFI_ERROR, "Connection open failed[%d]", Error);
+
+ if (open_info->flag == TRUE) {
+ g_strlcpy(event_data.ProfileName, open_info->ProfileName,
+ NET_PROFILE_NAME_LEN_MAX + 1);
+ memset(open_info, 0, sizeof(network_request_table_s));
+
+ event_data.Error = Error;
+
+ if (Error == NET_ERR_ACTIVE_CONNECTION_EXISTS) {
+ Error = net_get_profile_info(event_data.ProfileName, &prof_info);
+
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Fail to get profile info[%s]",
+ _net_print_error(Error));
+
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+ } else {
+ event_data.Datalength = sizeof(net_profile_info_s);
+ event_data.Data = &prof_info;
+ }
+ }
+
+ event_data.Event = NET_EVENT_OPEN_RSP;
+ WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_OPEN_RSP Error[%s]",
+ _net_print_error(event_data.Error));
+ } else if (wps_info->flag == TRUE) {
+ g_strlcpy(event_data.ProfileName, wps_info->ProfileName,
+ NET_PROFILE_NAME_LEN_MAX + 1);
+ memset(wps_info, 0, sizeof(network_request_table_s));
+
+ event_data.Error = Error;
+
+ if (Error == NET_ERR_ACTIVE_CONNECTION_EXISTS) {
+ Error = net_get_profile_info(event_data.ProfileName, &prof_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Fail to get profile info[%s]",
+ _net_print_error(Error));
+
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+ } else {
+ event_data.Datalength = sizeof(net_profile_info_s);
+ event_data.Data = &prof_info;
+ }
+ }
+
+ event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+
+ WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_WIFI_WPS_RSP Error[%s]",
+ _net_print_error(event_data.Error));
+ } else {
+ _net_dbus_pending_call_unref();
+
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+done:
+ _net_dbus_pending_call_unref();
+
+ _net_client_callback(&event_data);
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+static void __net_close_connection_reply(GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ WIFI_LOG(WIFI_INFO, "__net_close_connection_reply() called");
+
+ net_event_info_s event_data = { 0, };
+ network_request_table_s *close_info =
+ &request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION];
+
+ GDBusConnection *conn = NULL;
+ GError *error = NULL;
+ net_err_e Error = NET_ERR_NONE;
+
+ conn = G_DBUS_CONNECTION(source_object);
+ g_dbus_connection_call_finish(conn, res, &error);
+ if (error != NULL) {
+ Error = __net_error_string_to_enum(error->message);
+ g_error_free(error);
+ }
+
+ if (Error == NET_ERR_NONE)
+ goto done;
+
+ WIFI_LOG(WIFI_ERROR, "Connection close failed[%d]", Error);
+
+ if (close_info->flag == TRUE) {
+ g_strlcpy(event_data.ProfileName, close_info->ProfileName,
+ NET_PROFILE_NAME_LEN_MAX + 1);
+ memset(close_info, 0, sizeof(network_request_table_s));
+
+ event_data.Error = Error;
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+ event_data.Event = NET_EVENT_CLOSE_RSP;
+
+ WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_CLOSE_RSP Error[%s]",
+ _net_print_error(event_data.Error));
+ } else {
+ _net_dbus_pending_call_unref();
+
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+done:
+ _net_dbus_pending_call_unref();
+
+ _net_client_callback(&event_data);
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+static void __net_wifi_power_reply(GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GDBusConnection *conn = NULL;
+ GError *error = NULL;
+ net_err_e Error = NET_ERR_NONE;
+ net_event_info_s event_data = { 0, };
+
+ WIFI_LOG(WIFI_INFO, "__net_wifi_power_reply() called");
+
+ conn = G_DBUS_CONNECTION(source_object);
+ g_dbus_connection_call_finish(conn, res, &error);
+ if (error != NULL) {
+ Error = __net_netconfig_error_string_to_enum(error->message);
+ g_error_free(error);
+ }
+
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR,
+ "Wi-Fi power operation failed. Error [%d]", Error);
+
+ if (Error != NET_ERR_WIFI_DRIVER_LOAD_INPROGRESS) {
+ if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER],
+ 0, sizeof(network_request_table_s));
+
+ event_data.Event = NET_EVENT_WIFI_POWER_RSP;
+
+ WIFI_LOG(WIFI_INFO,
+ "Sending NET_EVENT_WIFI_POWER_RSP Wi-Fi: %d Error = %d",
+ NetworkInfo.wifi_state, Error);
+
+ event_data.Datalength = sizeof(net_wifi_state_e);
+ event_data.Data = &(NetworkInfo.wifi_state);
+ event_data.Error = Error;
+ }
+ }
+ } else {
+ _net_dbus_pending_call_unref();
+
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ _net_dbus_pending_call_unref();
+
+ _net_client_callback(&event_data);
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+static void __net_specific_scan_wifi_reply(GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GDBusConnection *conn = NULL;
+ GError *error = NULL;
+ net_err_e Error = NET_ERR_NONE;
+ net_event_info_s event_data = { 0, };
+
+ conn = G_DBUS_CONNECTION(source_object);
+ g_dbus_connection_call_finish(conn, res, &error);
+ if (error != NULL) {
+ Error = __net_netconfig_error_string_to_enum(error->message);
+ g_error_free(error);
+ }
+
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, "Find specific AP failed[%d]", Error);
+ else
+ WIFI_LOG(WIFI_INFO, "Specific AP found");
+
+ if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
+ if (NET_ERR_NONE != Error) {
+ /* An error occurred.
+ * So lets reset specific scan request entry in the request table */
+ memset(&request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN],
+ 0, sizeof(network_request_table_s));
+ }
+
+ event_data.Event = NET_EVENT_WIFI_SPECIFIC_SCAN_RSP;
+
+ WIFI_LOG(WIFI_INFO,
+ "Sending NET_EVENT_SPECIFIC_SCAN_RSP Wi-Fi: %d Error[%d]",
+ NetworkInfo.wifi_state, Error);
+
+ event_data.Datalength = sizeof(net_wifi_state_e);
+ event_data.Data = &(NetworkInfo.wifi_state);
+ event_data.Error = Error;
+
+ _net_dbus_pending_call_unref();
+ _net_client_callback(&event_data);
+ } else {
+ _net_dbus_pending_call_unref();
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+static void __net_wps_scan_wifi_reply(GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GDBusConnection *conn = NULL;
+ GError *error = NULL;
+ net_err_e Error = NET_ERR_NONE;
+ net_event_info_s event_data = { 0, };
+
+ conn = G_DBUS_CONNECTION(source_object);
+ g_dbus_connection_call_finish(conn, res, &error);
+ if (error != NULL) {
+ Error = __net_netconfig_error_string_to_enum(error->message);
+ g_error_free(error);
+ }
+
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "WPS scan failed[%d]", Error);
+
+ if (request_table[NETWORK_REQUEST_TYPE_WPS_SCAN].flag == TRUE) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_WPS_SCAN],
+ 0, sizeof(network_request_table_s));
+
+ event_data.Event = NET_EVENT_WIFI_WPS_SCAN_IND;
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+ event_data.Error = Error;
+
+ _net_dbus_pending_call_unref();
+
+ _net_client_callback(&event_data);
+
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+ } else
+ WIFI_LOG(WIFI_INFO, "WPS scan succeed");
+
+ _net_dbus_pending_call_unref();
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+static void __net_set_passpoint_reply(GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GDBusConnection *conn = NULL;
+ GError *error = NULL;
+ net_err_e Error = NET_ERR_NONE;
+
+ conn = G_DBUS_CONNECTION(source_object);
+ g_dbus_connection_call_finish(conn, res, &error);
+ if (error != NULL) {
+ Error = __net_netconfig_error_string_to_enum(error->message);
+ g_error_free(error);
+ }
+
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, "set passpoint failed[%d]", Error);
+ else
+ WIFI_LOG(WIFI_INFO, "set passpoint succeeded");
+
+ _net_dbus_pending_call_unref();
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+static char *__net_make_group_name(const char *ssid,
+ const char *net_mode, const char *sec)
+{
+ char *buf = NULL;
+ const char *hidden_str = "hidden";
+ const char *g_sec;
+ char ssid_hex[NET_WLAN_ESSID_LEN * 2 + 1] = { 0, };
+ int i;
+ int ssid_len = 0;
+ int actual_len = 0;
+ int buf_len = 0;
+
+ if (net_mode == NULL || sec == NULL)
+ return NULL;
+
+ if (NULL != ssid) {
+ ssid_len = strlen(ssid);
+ actual_len = ssid_len * 2;
+ } else {
+ ssid_len = strlen(hidden_str);
+ actual_len = ssid_len;
+ }
+
+ if (g_strcmp0(net_mode, "managed") != 0)
+ return NULL;
+
+ if (!g_strcmp0(sec, "wpa") || !g_strcmp0(sec, "rsn"))
+ g_sec = "psk";
+ else
+ g_sec = sec;
+
+ buf_len = actual_len + strlen(net_mode) + strlen(g_sec) + 4;
+
+ buf = g_try_malloc0(buf_len);
+ if (buf == NULL)
+ return NULL;
+
+ if (NULL != ssid) {
+ for (i = 0; i < ssid_len; i++)
+ g_snprintf(ssid_hex + i * 2, 3, "%02x", ssid[i]);
+ } else {
+ g_snprintf(ssid_hex, strlen(hidden_str) + 1, "%s", hidden_str);
+ }
+
+ g_snprintf(buf, buf_len, "_%s_%s_%s", ssid_hex, net_mode, g_sec);
+
+ WIFI_LOG(WIFI_INFO, "Group name: %s", buf);
+
+ return buf;
+}
+
+static int __net_dbus_set_agent_field_and_connect(
+ const char *key, const char *value, const char *profilename)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *params = NULL;
+ GVariantBuilder *builder;
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ g_variant_builder_add(builder, "{sv}", key, g_variant_new_string(value));
+
+ params = g_variant_new("(o@a{sv})",
+ profilename, g_variant_builder_end(builder));
+ g_variant_builder_unref(builder);
+
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH,
+ CONNMAN_AGENT_INTERFACE, "SetField", params,
+ DBUS_REPLY_TIMEOUT, __net_open_connection_reply);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+//LCOV_EXCL_STOP
+
+GVariant *_net_invoke_dbus_method(const char *dest, const char *path,
+ const char *interface_name, const char *method,
+ GVariant *params, int *dbus_error)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GError *error = NULL;
+ GVariant *reply = NULL;
+ *dbus_error = NET_ERR_NONE;
+ GDBusConnection *connection;
+
+ connection = _net_dbus_get_gdbus_conn();
+ if (connection == NULL) {
+ WIFI_LOG(WIFI_ERROR, "GDBusconnection is NULL"); //LCOV_EXCL_LINE
+ *dbus_error = NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ return reply; //LCOV_EXCL_LINE
+ }
+
+ reply = g_dbus_connection_call_sync(connection,
+ dest,
+ path,
+ interface_name,
+ method,
+ params,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ DBUS_REPLY_TIMEOUT,
+ _net_dbus_get_gdbus_cancellable(),
+ &error);
+ if (reply == NULL) {
+ if (error != NULL) {
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "g_dbus_connection_call_sync() failed "
+ "error [%d: %s]", error->code, error->message);
+ *dbus_error = __net_error_string_to_enum(error->message); //LCOV_EXCL_LINE
+ g_error_free(error); //LCOV_EXCL_LINE
+ } else {
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "g_dbus_connection_call_sync() failed");
+ *dbus_error = NET_ERR_UNKNOWN; //LCOV_EXCL_LINE
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NULL;
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return reply;
+}
+
+int _net_invoke_dbus_method_nonblock(const char *dest, const char *path,
+ const char *interface_name, const char *method,
+ GVariant *params, int timeout,
+ GAsyncReadyCallback notify_func)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GDBusConnection *connection;
+
+ connection = _net_dbus_get_gdbus_conn();
+ if (connection == NULL) {
+ WIFI_LOG(WIFI_ERROR, "GDBusconnection is NULL"); //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ g_dbus_connection_call(connection,
+ dest,
+ path,
+ interface_name,
+ method,
+ params,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ timeout,
+ _net_dbus_get_gdbus_cancellable(),
+ (GAsyncReadyCallback) notify_func,
+ NULL);
+
+ if (notify_func != NULL)
+ _net_dbus_pending_call_ref();
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+int _net_dbus_open_connection(const char* profile_name)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ /* use DBus signal than reply pending because of performance reason */
+ Error = _net_invoke_dbus_method_nonblock(CONNMAN_SERVICE, profile_name,
+ CONNMAN_SERVICE_INTERFACE, "Connect", NULL,
+ DBUS_REPLY_TIMEOUT, __net_open_connection_reply);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_close_connection(const char* profile_name)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ /* use DBus signal than reply pending because of performance reason */
+ Error = _net_invoke_dbus_method_nonblock(CONNMAN_SERVICE, profile_name,
+ CONNMAN_SERVICE_INTERFACE, "Disconnect", NULL,
+ DBUS_REPLY_TIMEOUT, __net_close_connection_reply);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_scan_request(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ /* use DBus signal than reply pending because of performance reason */
+ Error = _net_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
+ CONNMAN_WIFI_TECHNOLOGY_PREFIX,
+ CONNMAN_TECHNOLOGY_INTERFACE, "Scan", NULL,
+ DBUS_REPLY_TIMEOUT, NULL);
+
+ if (Error == NET_ERR_IN_PROGRESS)
+ Error = NET_ERR_NONE; //LCOV_EXCL_LINE
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_set_bgscan_mode(net_wifi_background_scan_mode_e mode)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+ GVariant *params;
+
+ char path[CONNMAN_MAX_BUFLEN] = NETCONFIG_WIFI_PATH;
+
+ params = g_variant_new("(u)", mode);
+
+ message = _net_invoke_dbus_method(NETCONFIG_SERVICE, path,
+ NETCONFIG_WIFI_INTERFACE, "SetBgscan", params, &Error);
+
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, "_net_invoke_dbus_method failed"); //LCOV_EXCL_LINE
+
+ if (message != NULL)
+ g_variant_unref(message); //LCOV_EXCL_LINE
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_get_technology_state(network_tech_state_info_s* tech_state)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+
+ if ((tech_state == NULL) || (strlen(tech_state->technology) == 0)) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
+ }
+
+ message = _net_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "GetTechnologies", NULL, &Error);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get technology info"); //LCOV_EXCL_LINE
+ goto done; //LCOV_EXCL_LINE
+ }
+
+ Error = _net_get_tech_state(message, tech_state);
+
+ g_variant_unref(message);
+
+done:
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_get_tech_status(net_tech_info_s* tech_status)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ network_tech_state_info_s tech_state = {{0,},};
+
+ g_strlcpy(tech_state.technology, "wifi", NET_TECH_LENGTH_MAX);
+
+ Error = _net_dbus_get_technology_state(&tech_state);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "_net_dbus_get_technology_state() failed. Error [%s]",
+ _net_print_error(Error));
+ goto done; //LCOV_EXCL_LINE
+ }
+
+ if (tech_state.Powered == TRUE)
+ tech_status->powered = TRUE;
+ else
+ tech_status->powered = FALSE;
+
+ if (tech_state.Connected == TRUE)
+ tech_status->connected = TRUE;
+ else
+ tech_status->connected = FALSE;
+
+done:
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_get_wifi_state(char **wifi_state)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+ const char *method = "GetWifiState";
+
+ if (NULL == wifi_state) {
+ WIFI_LOG(WIFI_ERROR, "Invalid Parameter\n"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
+ }
+
+ message = _net_invoke_dbus_method(
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, method, NULL, &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get wifi state\n"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ g_variant_get(message, "(s)", wifi_state);
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+
+ return Error;
+}
+
+//LCOV_EXCL_START
+int _net_dbus_set_eap_config_fields_and_connect(
+ const net_wifi_connect_service_info_t *wifi_info,
+ const char *profilename)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *params = NULL;
+ GVariantBuilder *builder;
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{ss}"));
+ g_variant_builder_add(builder, "{ss}", CONNMAN_CONFIG_FIELD_TYPE, "wifi");
+
+ if (wifi_info->ssid)
+ g_variant_builder_add(builder, "{ss}",
+ CONNMAN_CONFIG_FIELD_NAME, wifi_info->ssid);
+
+ if (wifi_info->eap_type)
+ g_variant_builder_add(builder, "{ss}",
+ CONNMAN_CONFIG_FIELD_EAP_METHOD, wifi_info->eap_type);
+
+ if (wifi_info->eap_keymgmt_type)
+ g_variant_builder_add(builder, "{ss}",
+ CONNMAN_CONFIG_FIELD_EAP_KEYMGMT_TYPE, wifi_info->eap_keymgmt_type);
+
+ if (wifi_info->identity)
+ g_variant_builder_add(builder, "{ss}",
+ CONNMAN_CONFIG_FIELD_IDENTITY, wifi_info->identity);
+
+ if (wifi_info->password)
+ g_variant_builder_add(builder, "{ss}",
+ CONNMAN_CONFIG_FIELD_PASSPHRASE, wifi_info->password);
+
+ if (wifi_info->eap_auth &&
+ g_strcmp0(wifi_info->eap_auth, "NONE") != 0)
+ g_variant_builder_add(builder, "{ss}",
+ CONNMAN_CONFIG_FIELD_PHASE2, wifi_info->eap_auth);
+
+ if (wifi_info->ca_cert_file)
+ g_variant_builder_add(builder, "{ss}",
+ CONNMAN_CONFIG_FIELD_CA_CERT_FILE, wifi_info->ca_cert_file);
+
+ if (wifi_info->client_cert_file)
+ g_variant_builder_add(builder, "{ss}",
+ CONNMAN_CONFIG_FIELD_CLIENT_CERT_FILE,
+ wifi_info->client_cert_file);
+
+ if (wifi_info->private_key_file)
+ g_variant_builder_add(builder, "{ss}",
+ CONNMAN_CONFIG_FIELD_PVT_KEY_FILE,
+ wifi_info->private_key_file);
+
+ if (wifi_info->private_key_password)
+ g_variant_builder_add(builder, "{ss}",
+ CONNMAN_CONFIG_FIELD_PVT_KEY_PASSPHRASE,
+ wifi_info->private_key_password);
+
+ params = g_variant_new("(o@a{ss})",
+ profilename, g_variant_builder_end(builder));
+ g_variant_builder_unref(builder);
+
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "CreateEapConfig", params,
+ DBUS_REPLY_TIMEOUT, __net_open_connection_reply);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+//LCOV_EXCL_STOP
+
+int _net_dbus_set_agent_passphrase_and_connect(
+ const char *passphrase, const char *profilename)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NULL == passphrase || strlen(passphrase) <= 0 || NULL == profilename) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ Error = __net_dbus_set_agent_field_and_connect(
+ NETCONFIG_AGENT_FIELD_PASSPHRASE,
+ passphrase,
+ profilename);
+ if (NET_ERR_NONE != Error) {
+ WIFI_LOG(WIFI_ERROR, "Configuration failed(%d)", Error); //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_set_agent_fields_and_connect(const char *ssid,
+ const char *passphrase, const char *profilename)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ /* If OPEN network, passphrase can be NULL */
+ if (NULL == ssid || strlen(ssid) <= 0 || NULL == profilename) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
+ }
+
+ GVariant *params = NULL;
+ GVariantBuilder *builder;
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_SSID,
+ g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, ssid,
+ strlen(ssid), sizeof(guchar)));
+
+ if (passphrase)
+ g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_PASSPHRASE,
+ g_variant_new_string(passphrase));
+
+ params = g_variant_new("(o@a{sv})",
+ profilename, g_variant_builder_end(builder));
+ g_variant_builder_unref(builder);
+
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH,
+ CONNMAN_AGENT_INTERFACE, "SetField", params,
+ DBUS_REPLY_TIMEOUT, __net_open_connection_reply);
+ if (NET_ERR_NONE != Error) {
+ WIFI_LOG(WIFI_ERROR, "Configuration failed(%d)", Error); //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+//LCOV_EXCL_START
+int _net_dbus_get_wps_pin(char **wps_pin)
+{
+ __NETWORK_FUNC_ENTER__;
+ net_err_e error = NET_ERR_NONE;
+ GVariant *params = NULL;
+ GVariant *reply = NULL;
+ gchar *value = NULL;
+ char *path = NULL;
+
+ params = g_variant_new("(s)", "wlan0");
+ reply = _net_invoke_dbus_method(SUPPLICANT_SERVICE, SUPPLICANT_PATH,
+ SUPPLICANT_INTERFACE, "GetInterface", params, &error);
+ if (reply == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi interface");
+ return error;
+ }
+ g_variant_get(reply, "(o)", &path);
+
+ reply = _net_invoke_dbus_method(SUPPLICANT_SERVICE, path,
+ SUPPLICANT_INTERFACE ".Interface.WPS", "GetPin", NULL, &error);
+ if (reply == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get wps pin");
+ return error;
+ }
+ g_variant_get(reply, "(s)", &value);
+ *wps_pin = g_strdup_printf("%s", value);
+ g_variant_unref(reply);
+
+ __NETWORK_FUNC_EXIT__;
+ return error;
+}
+
+int _net_dbus_set_agent_wps_pbc_and_connect(const char *profilename)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ Error = __net_dbus_set_agent_field_and_connect(
+ NETCONFIG_AGENT_FIELD_WPS_PBC,
+ "enable",
+ profilename);
+ if (NET_ERR_NONE != Error) {
+ WIFI_LOG(WIFI_ERROR, "PBC configuration failed(%d)", Error);
+ return Error;
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_set_agent_wps_pin_and_connect(
+ const char *wps_pin, const char *profilename)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NULL == wps_pin || strlen(wps_pin) <= 0) {
+ WIFI_LOG(WIFI_ERROR, "Invalid param ");
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ Error = __net_dbus_set_agent_field_and_connect(
+ NETCONFIG_AGENT_FIELD_WPS_PIN,
+ wps_pin,
+ profilename);
+ if (NET_ERR_NONE != Error) {
+ WIFI_LOG(WIFI_ERROR, "PIN configuration failed(%d)", Error);
+ return Error;
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+//LCOV_EXCL_STOP
+
+int _net_dbus_connect_service(const net_wifi_connect_service_info_t *wifi_connection_info)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ char *grp_name = NULL;
+ GSList *list = NULL;
+ GSList *profile_list = NULL;
+ net_profile_info_s *prof_info = NULL;
+
+ /* Get group name with prefix 'ssid' in hex */
+ grp_name = __net_make_group_name(wifi_connection_info->is_hidden == TRUE ?
+ NULL : wifi_connection_info->ssid,
+ wifi_connection_info->mode,
+ wifi_connection_info->security);
+ if (NULL == grp_name) {
+ WIFI_LOG(WIFI_ERROR, "Failed to make a group name"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_UNKNOWN; //LCOV_EXCL_LINE
+ }
+
+ Error = _net_get_profile_list(&profile_list);
+ if (NET_ERR_NONE != Error) {
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "_net_get_profile_list fail. Error [%s]",
+ _net_print_error(Error));
+
+ goto error; //LCOV_EXCL_LINE
+ }
+
+
+
+ for (list = profile_list; list; list = list->next) {
+ prof_info = (net_profile_info_s *)list->data;
+ if (g_strstr_len(prof_info->ProfileName,
+ NET_PROFILE_NAME_LEN_MAX+1, grp_name) != NULL) {
+ WIFI_LOG(WIFI_INFO, "Found profile %s", prof_info->ProfileName);
+
+ if (prof_info->ProfileState == NET_STATE_TYPE_READY ||
+ prof_info->ProfileState == NET_STATE_TYPE_ONLINE) {
+ WIFI_LOG(WIFI_ERROR, "Already profile is connected"); //LCOV_EXCL_LINE
+ Error = NET_ERR_ACTIVE_CONNECTION_EXISTS; //LCOV_EXCL_LINE
+
+ goto error; //LCOV_EXCL_LINE
+ }
+
+ break;
+ }
+ }
+
+ if (!list) {
+ WIFI_LOG(WIFI_ERROR, "No matching profile found"); //LCOV_EXCL_LINE
+ Error = NET_ERR_NO_SERVICE; //LCOV_EXCL_LINE
+
+ goto error; //LCOV_EXCL_LINE
+ }
+
+ if (wifi_connection_info->is_hidden == TRUE) {
+ //LCOV_EXCL_START
+ char *target_name = __net_make_group_name(wifi_connection_info->ssid,
+ wifi_connection_info->mode,
+ wifi_connection_info->security);
+
+ for (list = profile_list; list; list = list->next) {
+ prof_info = (net_profile_info_s *)list->data;
+ if (g_strstr_len(prof_info->ProfileName,
+ NET_PROFILE_NAME_LEN_MAX+1, target_name) != NULL) {
+ g_strlcpy(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
+ prof_info->ProfileName, NET_PROFILE_NAME_LEN_MAX+1);
+
+ break;
+ }
+ }
+
+ g_free(target_name);
+ //LCOV_EXCL_STOP
+ } else {
+ g_strlcpy(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
+ prof_info->ProfileName, NET_PROFILE_NAME_LEN_MAX+1);
+ }
+
+ //LCOV_EXCL_START
+ if (g_strcmp0(wifi_connection_info->security, "ieee8021x") == 0) {
+ /* Create the EAP config file */
+ Error = _net_dbus_set_eap_config_fields_and_connect(
+ wifi_connection_info, prof_info->ProfileName);
+ if (NET_ERR_NONE != Error) {
+ WIFI_LOG(WIFI_ERROR, "Fail to create eap_config");
+
+ goto error;
+ }
+ } else if (wifi_connection_info->is_hidden == TRUE) {
+ Error = _net_dbus_set_agent_fields_and_connect(
+ wifi_connection_info->ssid,
+ wifi_connection_info->passphrase,
+ prof_info->ProfileName);
+ } else if (g_strcmp0(wifi_connection_info->security, "none") != 0) {
+ Error = _net_dbus_set_agent_passphrase_and_connect(
+ wifi_connection_info->passphrase, prof_info->ProfileName);
+ if (NET_ERR_NONE != Error) {
+ WIFI_LOG(WIFI_ERROR, "Fail to set agent_passphrase");
+
+ goto error;
+ }
+ } else
+ Error = _net_dbus_open_connection(prof_info->ProfileName);
+ //LCOV_EXCL_STOP
+
+error :
+ if (NET_ERR_NONE != Error) {
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "Failed to request open connection, Error [%s]",
+ _net_print_error(Error));
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], //LCOV_EXCL_LINE
+ 0, sizeof(network_request_table_s));
+ }
+
+ NET_MEMFREE(prof_info);
+ g_free(grp_name);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_set_profile_ipv4(net_profile_info_s* prof_info, char* profile_name)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ const char *manual_method = "manual";
+ const char *dhcp_method = "dhcp";
+ const char *off_method = "off";
+
+ const char *prop_ipv4_configuration = "IPv4.Configuration";
+ const char *prop_method = "Method";
+ const char *prop_address = "Address";
+ const char *prop_gateway = "Gateway";
+ const char *prop_netmask = "Netmask";
+
+ char ip_buffer[NET_IPV4_STR_LEN_MAX+1] = "";
+ char netmask_buffer[NET_IPV4_STR_LEN_MAX+1] = "";
+ char gateway_buffer[NET_IPV4_STR_LEN_MAX+1] = "";
+
+ char *ipaddress = ip_buffer;
+ char *netmask = netmask_buffer;
+ char *gateway = gateway_buffer;
+
+ GVariant *params = NULL;
+ GVariantBuilder *builder;
+ net_dev_info_s *profile_net_info = NULL;
+
+ GVariant *message = NULL;
+
+ WIFI_LOG(WIFI_INFO, "profile_name: [%s]", profile_name);
+
+ if ((prof_info == NULL) || (profile_name == NULL) || (strlen(profile_name) == 0)) {
+ WIFI_LOG(WIFI_ERROR, "Invalid argument"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
+ }
+
+ profile_net_info = &(prof_info->net_info);
+
+ g_strlcpy(ip_buffer,
+ inet_ntoa(profile_net_info->IpAddr.Data.Ipv4),
+ NET_IPV4_STR_LEN_MAX + 1);
+
+ g_strlcpy(netmask_buffer,
+ inet_ntoa(profile_net_info->SubnetMask.Data.Ipv4),
+ NET_IPV4_STR_LEN_MAX + 1);
+
+ g_strlcpy(gateway_buffer,
+ inet_ntoa(profile_net_info->GatewayAddr.Data.Ipv4),
+ NET_IPV4_STR_LEN_MAX + 1);
+
+ WIFI_LOG(WIFI_INFO, "ip: %s, netmask: %s, gateway: %s",
+ ipaddress, netmask, gateway);
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+ //LCOV_EXCL_START
+ if (profile_net_info->IpConfigType == NET_IP_CONFIG_TYPE_DYNAMIC ||
+ profile_net_info->IpConfigType == NET_IP_CONFIG_TYPE_AUTO_IP) {
+
+ g_variant_builder_add(builder, "{sv}", prop_method, g_variant_new_string(dhcp_method));
+
+ } else if (profile_net_info->IpConfigType == NET_IP_CONFIG_TYPE_OFF) {
+
+ g_variant_builder_add(builder, "{sv}", prop_method, g_variant_new_string(off_method));
+
+ } else if (profile_net_info->IpConfigType == NET_IP_CONFIG_TYPE_STATIC) {
+
+ g_variant_builder_add(builder, "{sv}", prop_method, g_variant_new_string(manual_method));
+
+ if (strlen(ipaddress) >= NET_IPV4_STR_LEN_MIN)
+ g_variant_builder_add(builder, "{sv}", prop_address, g_variant_new_string(ipaddress));
+
+ if (strlen(netmask) >= NET_IPV4_STR_LEN_MIN)
+ g_variant_builder_add(builder, "{sv}", prop_netmask, g_variant_new_string(netmask));
+
+ if (strlen(gateway) >= NET_IPV4_STR_LEN_MIN)
+ g_variant_builder_add(builder, "{sv}", prop_gateway, g_variant_new_string(gateway));
+
+ } else {
+ WIFI_LOG(WIFI_ERROR, "Invalid argument");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+ //LCOV_EXCL_STOP
+
+ params = g_variant_new("(sv)",
+ prop_ipv4_configuration, g_variant_builder_end(builder));
+ g_variant_builder_unref(builder);
+
+ message = _net_invoke_dbus_method(CONNMAN_SERVICE, profile_name,
+ CONNMAN_SERVICE_INTERFACE, "SetProperty", params,
+ &Error);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to set IPv4 Property"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ g_variant_unref(message);
+ WIFI_LOG(WIFI_INFO, "Successfully configured IPv4.Configuration\n");
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+//LCOV_EXCL_START
+int _net_dbus_set_profile_ipv6(net_profile_info_s* prof_info, char* profile_name)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ const char *manual_method = "manual";
+ const char *auto_method = "auto";
+ const char *off_method = "off";
+
+ const char *prop_ipv6_configuration = "IPv6.Configuration";
+ const char *prop_method = "Method";
+ const char *prop_address = "Address";
+ const char *prop_gateway = "Gateway";
+ const char *prop_prefixlen = "PrefixLength";
+
+ char ipaddr6[INET6_ADDRSTRLEN];
+ char gwaddr6[INET6_ADDRSTRLEN];
+
+ char *ip6_ptr = ipaddr6;
+ char *gw6_ptr = gwaddr6;
+ int prefix_length = 0;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *params = NULL;
+ GVariantBuilder *builder;
+ GVariant *message = NULL;
+ net_dev_info_s *profile_net_info = NULL;
+
+ if ((prof_info == NULL) || (profile_name == NULL) || (strlen(profile_name) == 0)) {
+ WIFI_LOG(WIFI_ERROR, "Error!!! Invalid argument\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ profile_net_info = &(prof_info->net_info);
+
+ inet_ntop(AF_INET6, &profile_net_info->IpAddr6.Data.Ipv6, ipaddr6,
+ INET6_ADDRSTRLEN);
+ inet_ntop(AF_INET6, &profile_net_info->GatewayAddr6.Data.Ipv6, gwaddr6,
+ INET6_ADDRSTRLEN);
+ prefix_length = profile_net_info->PrefixLen6;
+
+ WIFI_LOG(WIFI_INFO, "ipaddress : %s, prefix_len : %d, gateway :"
+ " %s\n", ip6_ptr, prefix_length, gw6_ptr);
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+ if (profile_net_info->IpConfigType6 == NET_IP_CONFIG_TYPE_DYNAMIC ||
+ profile_net_info->IpConfigType6 == NET_IP_CONFIG_TYPE_AUTO_IP) {
+
+ g_variant_builder_add(builder, "{sv}", prop_method,
+ g_variant_new_string(auto_method));
+
+ } else if (profile_net_info->IpConfigType6 == NET_IP_CONFIG_TYPE_OFF) {
+
+ g_variant_builder_add(builder, "{sv}", prop_method,
+ g_variant_new_string(off_method));
+
+ WIFI_LOG(WIFI_INFO, "DBus Message 2/2: %s %s\n",
+ prop_method, off_method);
+ } else if (profile_net_info->IpConfigType6 == NET_IP_CONFIG_TYPE_STATIC) {
+
+ g_variant_builder_add(builder, "{sv}", prop_method,
+ g_variant_new_string(manual_method));
+
+ if (strlen(ipaddr6) >= NET_IPV6_STR_LEN_MIN) {
+ g_variant_builder_add(builder, "{sv}", prop_address,
+ g_variant_new_string(ip6_ptr));
+ }
+ if (profile_net_info->PrefixLen6 <= NET_IPV6_MAX_PREFIX_LEN) {
+ g_variant_builder_add(builder, "{sv}", prop_prefixlen,
+ g_variant_new_byte(prefix_length));
+ }
+
+ if (strlen(gwaddr6) >= NET_IPV6_STR_LEN_MIN) {
+ g_variant_builder_add(builder, "{sv}", prop_gateway,
+ g_variant_new_string(gw6_ptr));
+ }
+ WIFI_LOG(WIFI_INFO, "DBus Message 2/2: %s %s %s %s %s %d"
+ " %s %s\n", prop_method, manual_method,
+ prop_address, ipaddr6, prop_prefixlen,
+ prefix_length, prop_gateway, gwaddr6);
+ } else {
+ WIFI_LOG(WIFI_ERROR, "Invalid argument\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ params = g_variant_new("(sv)", prop_ipv6_configuration,
+ g_variant_builder_end(builder));
+ g_variant_builder_unref(builder);
+
+ message = _net_invoke_dbus_method(CONNMAN_SERVICE, profile_name,
+ CONNMAN_SERVICE_INTERFACE, "SetProperty", params,
+ &Error);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to set IPv6 Property");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ g_variant_unref(message);
+ WIFI_LOG(WIFI_INFO, "Successfully configured IPv6.Configuration\n");
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_set_profile_dns(net_profile_info_s* prof_info, char* profile_name)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ const char *prop_nameserver_configuration = "Nameservers.Configuration";
+ char dns_buffer[NET_DNS_ADDR_MAX][NET_IPV4_STR_LEN_MAX+1];
+ char *dns_address[NET_DNS_ADDR_MAX];
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *params = NULL;
+ GVariantBuilder *builder;
+ int i = 0;
+ net_dev_info_s *profile_net_info = NULL;
+ GVariant *message = NULL;
+
+ if ((prof_info == NULL) || (profile_name == NULL) || (strlen(profile_name) == 0)) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ profile_net_info = &(prof_info->net_info);
+
+ if (profile_net_info->DnsCount > NET_DNS_ADDR_MAX) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ for (i = 0; i < profile_net_info->DnsCount; i++) {
+ dns_buffer[i][0] = '\0';
+ dns_address[i] = NULL;
+
+ if (profile_net_info->DnsAddr[i].Data.Ipv4.s_addr != 0)
+ g_strlcpy(dns_buffer[i],
+ inet_ntoa(profile_net_info->DnsAddr[i].Data.Ipv4),
+ NET_IPV4_STR_LEN_MAX + 1);
+
+ dns_address[i] = dns_buffer[i];
+ }
+
+ if (profile_net_info->IpConfigType == NET_IP_CONFIG_TYPE_STATIC) {
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
+ for (i = 0; i < profile_net_info->DnsCount; i++)
+ g_variant_builder_add(builder, "s", dns_address[i]);
+
+ params = g_variant_new("(sv)", prop_nameserver_configuration, g_variant_builder_end(builder));
+ g_variant_builder_unref(builder);
+
+ message = _net_invoke_dbus_method(CONNMAN_SERVICE, profile_name,
+ CONNMAN_SERVICE_INTERFACE, "SetProperty", params,
+ &Error);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to set "
+ "Nameservers.Configuration");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+ WIFI_LOG(WIFI_INFO, "Successfully configured Nameservers.Configuration\n");
+ g_variant_unref(message);
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_set_proxy(net_profile_info_s* prof_info, char* profile_name)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ const char *direct_method = "direct";
+ const char *auto_method = "auto";
+ const char *manual_method = "manual";
+
+ const char *prop_proxy_configuration = "Proxy.Configuration";
+ const char *prop_method = "Method";
+ const char *prop_url = "URL";
+ const char *prop_servers = "Servers";
+
+ char proxy_buffer[NET_PROXY_LEN_MAX+1] = "";
+ char *proxy_address = proxy_buffer;
+
+ GVariant *params = NULL;
+ GVariantBuilder *builder;
+ GVariantBuilder *builder_sub;
+ net_dev_info_s *profile_net_info = NULL;
+
+ GVariant *message = NULL;
+
+ if ((prof_info == NULL) || (profile_name == NULL) || (strlen(profile_name) == 0)) {
+ WIFI_LOG(WIFI_ERROR, "Invalid argument");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ profile_net_info = &(prof_info->net_info);
+
+ g_strlcpy(proxy_buffer,
+ profile_net_info->ProxyAddr, NET_PROXY_LEN_MAX+1);
+
+ WIFI_LOG(WIFI_INFO, "method: %d, proxy address: %s, Profile Name %s",
+ profile_net_info->ProxyMethod, proxy_address, profile_net_info->ProfileName);
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+ switch (profile_net_info->ProxyMethod) {
+ case NET_PROXY_TYPE_AUTO:
+ g_variant_builder_add(builder, "{sv}", prop_method, g_variant_new_string(auto_method));
+ break;
+ case NET_PROXY_TYPE_MANUAL:
+ g_variant_builder_add(builder, "{sv}", prop_method, g_variant_new_string(manual_method));
+ break;
+ default:
+ g_variant_builder_add(builder, "{sv}", prop_method, g_variant_new_string(direct_method));
+ break;
+ }
+
+ if (profile_net_info->ProxyMethod == NET_PROXY_TYPE_AUTO &&
+ proxy_address[0] != '\0') {
+ g_variant_builder_add(builder, "{sv}", prop_url, g_variant_new_string(proxy_address));
+ }
+
+ if (profile_net_info->ProxyMethod == NET_PROXY_TYPE_MANUAL &&
+ proxy_address[0] != '\0') {
+ builder_sub = g_variant_builder_new(G_VARIANT_TYPE("as"));
+ g_variant_builder_add(builder_sub, "s", proxy_address);
+ g_variant_builder_add(builder, "{sv}", prop_servers, g_variant_builder_end(builder_sub));
+ g_variant_builder_unref(builder_sub);
+ }
+
+ params = g_variant_new("(sv)", prop_proxy_configuration, g_variant_builder_end(builder));
+ g_variant_builder_unref(builder);
+
+ message = _net_invoke_dbus_method(CONNMAN_SERVICE, profile_name,
+ CONNMAN_SERVICE_INTERFACE, "SetProperty", params,
+ &Error);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to set Proxy Configuration");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+ WIFI_LOG(WIFI_INFO, "Successfully configured Proxy.Configuration\n");
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+//LCOV_EXCL_STOP
+
+int _net_dbus_load_wifi_driver(gboolean wifi_picker_test)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *params;
+
+ params = g_variant_new("(b)", wifi_picker_test);
+
+ /* use DBus signal than reply pending because of performance reason */
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ "LoadDriver", params, DBUS_REPLY_TIMEOUT,
+ __net_wifi_power_reply);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_remove_wifi_driver(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ /* use DBus signal than reply pending because of performance reason */
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ "RemoveDriver", NULL, DBUS_REPLY_TIMEOUT,
+ __net_wifi_power_reply);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_specific_scan_request(const char *ssid)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GVariant *params = NULL;
+ net_err_e Error = NET_ERR_NONE;
+
+ params = g_variant_new("(s)", ssid);
+
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ "RequestSpecificScan", params, 6 * DBUS_REPLY_TIMEOUT,
+ __net_specific_scan_wifi_reply);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+//LCOV_EXCL_START
+int _net_dbus_wps_scan_request(void)
+{
+ __NETWORK_FUNC_ENTER__;
+ net_err_e Error = NET_ERR_NONE;
+
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ "RequestWpsScan", NULL, 6 * DBUS_REPLY_TIMEOUT,
+ __net_wps_scan_wifi_reply);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_get_passpoint(int *enabled)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GVariant *message = NULL;
+ net_err_e Error = NET_ERR_NONE;
+
+ message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ "GetPasspoint", NULL, &Error);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to Get Passpoint");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ /** Check Reply */
+ int result = 0;
+ g_variant_get(message, "(i)", &result);
+ *enabled = result;
+
+ WIFI_LOG(WIFI_INFO, "Get passpoint result: %d", result);
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_set_passpoint(int enable)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GVariant *params;
+ net_err_e Error = NET_ERR_NONE;
+
+ params = g_variant_new("(i)", enable);
+
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ "SetPasspoint", params, 6 * DBUS_REPLY_TIMEOUT,
+ __net_set_passpoint_reply);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+#if defined TIZEN_TV
+static void __net_wps_cancel_reply(GObject *source_object,
+ GAsyncResult *res, gpointer user_data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ WIFI_LOG(WIFI_INFO, "__net_wps_cancel_wifi_reply() called\n");
+
+ GDBusConnection *conn = NULL;
+ GVariant *dbus_result = NULL;
+ GError *error = NULL;
+
+ conn = G_DBUS_CONNECTION(source_object);
+ dbus_result = g_dbus_connection_call_finish(conn, res, &error);
+
+ if (error != NULL) {
+ WIFI_LOG(WIFI_ERROR, "error msg - [%s]\n", error->message);
+ g_error_free(error);
+ }
+
+ if (dbus_result)
+ g_variant_unref(dbus_result);
+
+ _net_dbus_pending_call_unref();
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+
+int _net_dbus_cancel_wps(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_TV_PROFILE_INTERFACE,
+ "RequestWpsCancel", NULL, DBUS_REPLY_TIMEOUT,
+ __net_wps_cancel_reply);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+
+}
+
+static int __net_dbus_set_agent_field(const char *key, const char *value)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GVariant *params = NULL;
+ GVariantBuilder *builder;
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+
+ char path[CONNMAN_MAX_BUFLEN] = NETCONFIG_WIFI_PATH;
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{ss}"));
+ g_variant_builder_add(builder, "{ss}", key, value);
+
+ params = g_variant_new("(@a{ss})", g_variant_builder_end(builder));
+ g_variant_builder_unref(builder);
+
+ message = _net_invoke_dbus_method(NETCONFIG_SERVICE, path,
+ CONNMAN_AGENT_INTERFACE, "SetField", params, &Error);
+
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, "_net_invoke_dbus_method failed");
+
+ if (message != NULL)
+ g_variant_unref(message);
+ else
+ WIFI_LOG(WIFI_ERROR, "Failed to set agent field");
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+static void __net_wps_connect_wifi_reply(GObject *source_object,
+ GAsyncResult *res, gpointer user_data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ int callback_flag = FALSE;
+ GDBusConnection *conn = NULL;
+ GError *error = NULL;
+ GVariant *dbus_result = NULL;
+ net_event_info_s event_data;
+ net_err_e Error = NET_ERR_NONE;
+ network_request_table_s *wps_info =
+ &request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS];
+ memset(&event_data, 0, sizeof(event_data));
+
+ conn = G_DBUS_CONNECTION(source_object);
+ dbus_result = g_dbus_connection_call_finish(conn, res, &error);
+
+ if (error != NULL) {
+ WIFI_LOG(WIFI_INFO, "error msg - [%s]\n", error->message);
+ Error = __net_error_string_to_enum(error->message);
+ g_error_free(error);
+ } else
+ WIFI_LOG(WIFI_INFO, "error msg is NULL\n");
+
+ if (dbus_result)
+ g_variant_unref(dbus_result);
+
+ if (Error == NET_ERR_NONE)
+ goto done;
+
+ WIFI_LOG(WIFI_ERROR, "Connection open failed. Error [%d]\n", Error);
+
+ memset(wps_info, 0, sizeof(network_request_table_s));
+
+ event_data.Error = Error;
+ event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+
+ WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_WIFI_WPS_RSP Error = %s\n",
+ _net_print_error(event_data.Error));
+
+ callback_flag = TRUE;
+
+done:
+ _net_dbus_pending_call_unref();
+
+ if (callback_flag)
+ _net_client_callback(&event_data);
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+int _net_dbus_open_connection_without_ssid()
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *params = NULL;
+
+ params = g_variant_new("(s)", "PBC");
+ WIFI_LOG(WIFI_ERROR, "Invoke wps connection without ssid");
+
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_TV_PROFILE_INTERFACE,
+ "RequestWpsConnect", params, DBUS_REPLY_TIMEOUT,
+ __net_wps_connect_wifi_reply);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+
+int _net_dbus_open_pin_connection_without_ssid(const char *pin)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ GVariant *params = NULL;
+ params = g_variant_new("(s)", pin);
+
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_TV_PROFILE_INTERFACE,
+ "RequestWpsConnect", params, DBUS_REPLY_TIMEOUT,
+ __net_wps_connect_wifi_reply);
+
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_set_agent_wps_pbc(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ int ret_val;
+
+ ret_val = __net_dbus_set_agent_field(NETCONFIG_AGENT_FIELD_WPS_PBC, "enable");
+ if (NET_ERR_NONE != ret_val) {
+ WIFI_LOG(WIFI_ERROR, "__net_dbus_set_agent_field failed. Error = %d \n", ret_val);
+ return ret_val;
+ }
+
+ WIFI_LOG(WIFI_INFO, "Successfully sent wps pbc\n");
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+int _net_dbus_set_agent_wps_pin(const char *wps_pin)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ int ret_val;
+
+ if (NULL == wps_pin || strlen(wps_pin) <= 0) {
+ WIFI_LOG(WIFI_ERROR, "Invalid param \n");
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ ret_val = __net_dbus_set_agent_field(NETCONFIG_AGENT_FIELD_WPS_PIN, wps_pin);
+ if (NET_ERR_NONE != ret_val) {
+ WIFI_LOG(WIFI_ERROR, "__net_dbus_set_agent_field failed. Error = %d \n", ret_val);
+ return ret_val;
+ }
+
+ WIFI_LOG(WIFI_INFO, "Successfully sent wps pin\n");
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+#endif
+
+int _net_dbus_tdls_disconnect(const char* peer_mac_addr)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+ GVariant *params = NULL;
+ gint32 ret = -1;
+
+ params = g_variant_new("(s)", peer_mac_addr);
+
+ message = _net_invoke_dbus_method(
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "TdlsDisconnect", params, &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to TDLS Disconnect Request\n");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ g_variant_get(message, "(i)", &ret);
+
+ WIFI_LOG(WIFI_INFO, "Status [%d]\n", ret);
+
+ if (ret)
+ Error = NET_ERR_NONE;
+ else
+ Error = NET_ERR_UNKNOWN;
+
+ g_variant_unref(message);
+ __NETWORK_FUNC_EXIT__;
+
+ return Error;
+}
+
+int _net_dbus_tdls_connected_peer(char** peer_mac_addr)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+
+ if (NULL == peer_mac_addr) {
+ WIFI_LOG(WIFI_ERROR, "Invalid Parameter\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ message = _net_invoke_dbus_method(
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "TdlsConnectedPeer", NULL, &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to Get Peer Connected Mac address\n");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ g_variant_get(message, "(s)", peer_mac_addr);
+
+ WIFI_LOG(WIFI_INFO, "TDLS Peer Mac address [%s]\n", *peer_mac_addr);
+
+ g_variant_unref(message);
+ __NETWORK_FUNC_EXIT__;
+
+ return Error;
+}
+
+int _net_dbus_config_get_id_list(GSList **list)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+ GVariantIter *iter = NULL;
+ gchar *config_id = NULL;
+
+ message = _net_invoke_dbus_method(
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "GetConfigIds",
+ g_variant_new("()"), &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to GetConfigIds");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ g_variant_get(message, "(as)", &iter);
+ while (g_variant_iter_loop(iter, "s", &config_id))
+ *list = g_slist_append(*list, g_strdup(config_id));
+
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+
+ return Error;
+}
+
+int _net_dbus_config_set_field(const gchar *config_id, const gchar *key, const gchar *value)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+
+ message = _net_invoke_dbus_method(
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "SetConfigField",
+ g_variant_new("(sss)", config_id, key, value), &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to SetConfigField");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+
+ return Error;
+}
+
+int _net_dbus_config_get_passphrase(const gchar *config_id, gchar **passphrase)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+ gchar *val = NULL;
+
+ message = _net_invoke_dbus_method(
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "GetConfigPassphrase",
+ g_variant_new("(s)", config_id), &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to GetConfigPassphrase");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ g_variant_get(message, "(s)", &val);
+
+ *passphrase = g_strdup(val);
+ g_free(val);
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+
+ return Error;
+}
+
+int _net_dbus_config_save_configurations(const gchar *config_id, const gchar *name,
+ const gchar *ssid, const gchar *passphrase, const gchar *proxy_address, gboolean is_hidden)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariantBuilder *b = NULL;
+ GVariant *params = NULL;
+ GVariant *message = NULL;
+
+ b = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_NAME, g_variant_new_string(name));
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_SSID, g_variant_new_string(ssid));
+ if (passphrase != NULL)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PASSPHRASE, g_variant_new_string(passphrase));
+ if (proxy_address != NULL)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PROXYADDRESS, g_variant_new_string(proxy_address));
+ if (is_hidden == TRUE)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_HIDDEN, g_variant_new_string("TRUE"));
+
+ params = g_variant_new("(s@a{sv})", config_id, g_variant_builder_end(b));
+ g_variant_builder_unref(b);
+
+ message = _net_invoke_dbus_method(
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "SaveConfiguration",
+ params, &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to SaveConfiguration");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+
+ return Error;
+}
+
+int _net_dbus_config_save_eap_configurations(const gchar *config_id,
+ const gchar *name, const gchar *ssid, const gchar *passphrase,
+ const gchar *proxy_address, net_eap_config_s *eap_config, gboolean is_hidden)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariantBuilder *b = NULL;
+ GVariant *params = NULL;
+ GVariant *message = NULL;
+
+ b = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_NAME, g_variant_new_string(name));
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_SSID, g_variant_new_string(ssid));
+ if (passphrase != NULL)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PASSPHRASE, g_variant_new_string(passphrase));
+ if (proxy_address != NULL)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PROXYADDRESS, g_variant_new_string(proxy_address));
+ if (is_hidden == TRUE)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_HIDDEN, g_variant_new_string("TRUE"));
+
+ if (eap_config != NULL) {
+ gchar* auth_type = NULL;
+ gchar* eap_type = NULL;
+ if (eap_config->anonymous_identity != NULL)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY, g_variant_new_string(eap_config->anonymous_identity));
+ if (eap_config->ca_cert != NULL)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_CACERT, g_variant_new_string(eap_config->ca_cert));
+ if (eap_config->client_cert != NULL)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_CLIENTCERT, g_variant_new_string(eap_config->client_cert));
+ if (eap_config->private_key != NULL)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_PRIVATEKEY, g_variant_new_string(eap_config->private_key));
+ if (eap_config->identity != NULL)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_IDENTITY, g_variant_new_string(eap_config->identity));
+ if (eap_config->subject_match != NULL)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_SUBJECT_MATCH, g_variant_new_string(eap_config->subject_match));
+
+ auth_type = __net_wifi_eap_auth_type_to_string(eap_config->eap_auth_type);
+ if (auth_type != NULL)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_AUTH_TYPE, g_variant_new_string(auth_type));
+
+ eap_type = __net_wifi_eap_type_to_string(eap_config->eap_type);
+ if (eap_type != NULL)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_TYPE, g_variant_new_string(eap_type));
+
+ g_free(auth_type);
+ g_free(eap_type);
+ }
+
+ params = g_variant_new("(s@a{sv})", config_id, g_variant_builder_end(b));
+ g_variant_builder_unref(b);
+
+ message = _net_invoke_dbus_method(
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "SaveEapConfiguration",
+ params, &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to SaveEapConfiguration");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+
+ return Error;
+}
+
+int _net_dbus_config_remove_configurations(const gchar *config_id)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+
+ message = _net_invoke_dbus_method(
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "RemoveConfiguration",
+ g_variant_new("(s)", config_id), &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to RemoveConfiguration");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+
+ return Error;
+}
+
+int _net_dbus_config_load_configurations(const gchar *config_id, gchar **name,
+ net_wifi_security_type_e *security_type, gchar **proxy_address, gboolean *is_hidden, void *last_error)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+ GVariantIter *iter;
+ gchar *field;
+ GVariant *value;
+ int *wifi_last_error = (int *)last_error;
+
+ message = _net_invoke_dbus_method(
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "LoadConfiguration",
+ g_variant_new("(s)", config_id), &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to LoadConfiguration");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ g_variant_get(message, "(a{sv})", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
+ if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+ if (g_strcmp0(field, WIFI_CONFIG_NAME) == 0) {
+ *name = g_strdup(g_variant_get_string(value, NULL));
+ } else if (g_strcmp0(field, WIFI_CONFIG_SECURITY_TYPE) == 0) {
+ *security_type = __net_wifi_security_type_to_int(g_variant_get_string(value, NULL));
+ } else if (g_strcmp0(field, WIFI_CONFIG_HIDDEN) == 0) {
+ const gchar *r_hidden = g_variant_get_string(value, NULL);
+ if (g_strcmp0(r_hidden, "TRUE") == 0)
+ *is_hidden = TRUE;
+ else
+ *is_hidden = FALSE;
+ } else if (g_strcmp0(field, WIFI_CONFIG_PROXYADDRESS) == 0) {
+ const gchar *r_proxy_address = g_variant_get_string(value, NULL);
+ if (g_strcmp0(r_proxy_address, "NONE") == 0)
+ *proxy_address = NULL;
+ else
+ *proxy_address = g_strdup(r_proxy_address);
+ } else if (g_strcmp0(field, WIFI_CONFIG_FAILURE) == 0) {
+ *wifi_last_error = __net_wifi_last_error_to_enum(g_variant_get_string(value, NULL));
+ }
+ }
+ }
+
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+
+ return Error;
+}
+
+int _net_dbus_config_load_eap_configurations(const gchar *config_id,
+ gchar **name, net_wifi_security_type_e *security_type, gchar **proxy_address,
+ gboolean *is_hidden, net_eap_config_s **eap_config, void *last_error)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+ GVariantIter *iter;
+ gchar *field;
+ GVariant *value;
+ int *wifi_last_error = (int *)last_error;
+
+ message = _net_invoke_dbus_method(
+ NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "LoadEapConfiguration",
+ g_variant_new("(s)", config_id), &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to LoadEapConfiguration");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ g_variant_get(message, "(a{sv})", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
+ if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+ if (g_strcmp0(field, WIFI_CONFIG_NAME) == 0) {
+ *name = g_strdup(g_variant_get_string(value, NULL));
+ } else if (g_strcmp0(field, WIFI_CONFIG_SECURITY_TYPE) == 0) {
+ *security_type = __net_wifi_security_type_to_int(g_variant_get_string(value, NULL));
+ } else if (g_strcmp0(field, WIFI_CONFIG_HIDDEN) == 0) {
+ const gchar *r_hidden = g_variant_get_string(value, NULL);
+ if (g_strcmp0(r_hidden, "TRUE") == 0)
+ *is_hidden = TRUE;
+ else
+ *is_hidden = FALSE;
+ } else if (g_strcmp0(field, WIFI_CONFIG_PROXYADDRESS) == 0) {
+ const gchar *r_proxy_address = g_variant_get_string(value, NULL);
+ if (g_strcmp0(r_proxy_address, "NONE") == 0)
+ *proxy_address = NULL;
+ else
+ *proxy_address = g_strdup(r_proxy_address);
+ } else if (g_strcmp0(field, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY) == 0) {
+ const gchar *anonymous_identity = g_variant_get_string(value, NULL);
+ (*eap_config)->anonymous_identity = g_strdup(anonymous_identity);
+ } else if (g_strcmp0(field, WIFI_CONFIG_EAP_CACERT) == 0) {
+ const gchar *ca_cert = g_variant_get_string(value, NULL);
+ (*eap_config)->ca_cert = g_strdup(ca_cert);
+ } else if (g_strcmp0(field, WIFI_CONFIG_EAP_CLIENTCERT) == 0) {
+ const gchar *client_cert = g_variant_get_string(value, NULL);
+ (*eap_config)->client_cert = g_strdup(client_cert);
+ } else if (g_strcmp0(field, WIFI_CONFIG_EAP_PRIVATEKEY) == 0) {
+ const gchar *private_key = g_variant_get_string(value, NULL);
+ (*eap_config)->private_key = g_strdup(private_key);
+ } else if (g_strcmp0(field, WIFI_CONFIG_EAP_IDENTITY) == 0) {
+ const gchar *identity = g_variant_get_string(value, NULL);
+ (*eap_config)->identity = g_strdup(identity);
+ } else if (g_strcmp0(field, WIFI_CONFIG_EAP_TYPE) == 0) {
+ const gchar *eap_type = g_variant_get_string(value, NULL);
+ (*eap_config)->eap_type = __net_wifi_eap_type_to_int(eap_type);
+ } else if (g_strcmp0(field, WIFI_CONFIG_EAP_AUTH_TYPE) == 0) {
+ const gchar *auth_type = g_variant_get_string(value, NULL);
+ (*eap_config)->eap_auth_type = __net_wifi_eap_auth_type_to_int(auth_type);
+ } else if (g_strcmp0(field, WIFI_CONFIG_EAP_SUBJECT_MATCH) == 0) {
+ const gchar *subject_match = g_variant_get_string(value, NULL);
+ (*eap_config)->subject_match = g_strdup(subject_match);
+ } else if (g_strcmp0(field, WIFI_CONFIG_FAILURE) == 0) {
+ *wifi_last_error = __net_wifi_last_error_to_enum(g_variant_get_string(value, NULL));
+ }
+ }
+ }
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+
+ return Error;
+}
+
+int _net_dbus_device_policy_get_wifi(int *state)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+
+ if (state == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid Parameter\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_NETWORK_PATH,
+ NETCONFIG_NETWORK_INTERFACE, "DevicePolicyGetWifi", NULL, &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get wifi device policy\n");
+ return Error;
+ }
+
+ g_variant_get(message, "(i)", state);
+
+ WIFI_LOG(WIFI_INFO, "Wifi device policy state [%d]\n", *state);
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_device_policy_get_wifi_profile(int *state)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+
+ if (state == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid Parameter\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_NETWORK_PATH,
+ NETCONFIG_NETWORK_INTERFACE, "DevicePolicyGetWifiProfile", NULL, &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get wifi device policy\n");
+ return Error;
+ }
+
+ g_variant_get(message, "(i)", state);
+
+ WIFI_LOG(WIFI_INFO, "Wifi profile device policy state [%d]\n", *state);
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+//LCOV_EXCL_STOP
+
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <ctype.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <stdio.h>
+#include <arpa/inet.h>
+
+#include "network_interface.h"
+#include "network_internal.h"
+#include "network_dbus.h"
+#include "network_signal.h"
+
+#define DBUS_OBJECT_PATH_MAX 150
+
+__thread network_info_s NetworkInfo = { 0, };
+extern __thread network_request_table_s request_table[NETWORK_REQUEST_TYPE_MAX];
+
+static int __net_check_get_privilege()
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+
+ message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_NETWORK_PATH,
+ NETCONFIG_NETWORK_INTERFACE, "CheckGetPrivilege", NULL, &Error);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to check get privilege"); //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+static int __net_check_profile_privilege()
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+
+ message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_NETWORK_PATH,
+ NETCONFIG_NETWORK_INTERFACE, "CheckProfilePrivilege", NULL, &Error);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to check profile privilege"); //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+static int __net_init_profile_info(net_profile_info_s *ProfInfo)
+{
+ int i = 0;
+ net_dev_info_s *net_info = NULL;
+
+ if (ProfInfo == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid Parameter\n");
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ memset(ProfInfo, 0, sizeof(net_profile_info_s));
+ ProfInfo->Favourite = (char)FALSE;
+
+ ProfInfo->Strength = 0;
+ ProfInfo->frequency = 0;
+ ProfInfo->max_rate = 0;
+ ProfInfo->wlan_mode = 0;
+ ProfInfo->PassphraseRequired = FALSE;
+ ProfInfo->security_info.sec_mode = 0;
+ ProfInfo->security_info.enc_mode = 0;
+ ProfInfo->security_info.wps_support = FALSE;
+
+ net_info = &(ProfInfo->net_info);
+
+ net_info->DnsCount = 0;
+
+ for (i = 0; i < NET_DNS_ADDR_MAX; i++) {
+ net_info->DnsAddr[i].Type = NET_ADDR_IPV4;
+ net_info->DnsAddr[i].Data.Ipv4.s_addr = 0;
+ }
+
+ net_info->IpConfigType = 0;
+ net_info->IpAddr.Type = NET_ADDR_IPV4;
+ net_info->IpAddr.Data.Ipv4.s_addr = 0;
+ net_info->BNetmask = FALSE;
+ net_info->SubnetMask.Type = NET_ADDR_IPV4;
+ net_info->SubnetMask.Data.Ipv4.s_addr = 0;
+ net_info->BDefGateway = FALSE;
+ net_info->GatewayAddr.Type = NET_ADDR_IPV4;
+ net_info->GatewayAddr.Data.Ipv4.s_addr = 0;
+
+ net_info->IpConfigType6 = 0;
+ net_info->IpAddr6.Type = NET_ADDR_IPV6;
+ inet_pton(AF_INET6, "::", &net_info->IpAddr6.Data.Ipv6);
+ net_info->PrefixLen6 = 0;
+ net_info->BDefGateway6 = FALSE;
+ net_info->GatewayAddr6.Type = NET_ADDR_IPV6;
+ inet_pton(AF_INET6, "::", &net_info->GatewayAddr6.Data.Ipv6);
+
+ net_info->ProxyMethod = NET_PROXY_TYPE_UNKNOWN;
+
+ return NET_ERR_NONE;
+}
+
+static net_wifi_state_e __net_get_wifi_connection_state(net_err_e *net_error)
+{
+ net_err_e Error = NET_ERR_NONE;
+ char *wifi_state = NULL;
+ net_wifi_state_e current_state = NetworkInfo.wifi_state;
+
+ __NETWORK_FUNC_ENTER__;
+ Error = _net_dbus_get_wifi_state(&wifi_state);
+
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get wifi state[%s]", //LCOV_EXCL_LINE
+ _net_print_error(Error));
+
+ *net_error = Error; //LCOV_EXCL_LINE
+
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return current_state; //LCOV_EXCL_LINE
+ }
+
+ //LCOV_EXCL_START
+ if (g_strcmp0(wifi_state, "unknown") == 0)
+ current_state = WIFI_UNKNOWN;
+ else if (g_strcmp0(wifi_state, "deactivated") == 0)
+ current_state = WIFI_OFF;
+ else if (g_strcmp0(wifi_state, "disconnected") == 0)
+ current_state = WIFI_ON;
+ else if (g_strcmp0(wifi_state, "association") == 0)
+ current_state = WIFI_ASSOCIATION;
+ else if (g_strcmp0(wifi_state, "configuration") == 0)
+ current_state = WIFI_CONFIGURATION;
+ else if (g_strcmp0(wifi_state, "connected") == 0)
+ current_state = WIFI_CONNECTED;
+ //LCOV_EXCL_STOP
+
+ g_free(wifi_state);
+
+ if (current_state == WIFI_CONNECTED &&
+ request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE)
+ current_state = WIFI_DISCONNECTING; //LCOV_EXCL_LINE
+
+ *net_error = Error;
+
+ __NETWORK_FUNC_EXIT__;
+ return current_state;
+}
+
+//LCOV_EXCL_START
+static int __net_extract_ip(const gchar *value, net_addr_s *ipAddr)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ unsigned char *ipValue = NULL;
+ char *saveptr = NULL;
+ char ipString[NET_IPV4_STR_LEN_MAX+1];
+ char* ipToken[4];
+
+ ipValue = (unsigned char *)&(ipAddr->Data.Ipv4.s_addr);
+
+ if (value != NULL) {
+ g_strlcpy(ipString, value, NET_IPV4_STR_LEN_MAX+1);
+
+ ipToken[0] = strtok_r(ipString, ".", &saveptr);
+
+ if (ipToken[0] != NULL) {
+ ipToken[1] = strtok_r(NULL, ".", &saveptr);
+
+ if (ipToken[1] != NULL) {
+ ipToken[2] = strtok_r(NULL, ".", &saveptr);
+
+ if (ipToken[2] != NULL) {
+ ipToken[3] = strtok_r(NULL, ".", &saveptr);
+
+ if (ipToken[3] != NULL) {
+ ipValue[0] = (unsigned char)atoi(ipToken[0]);
+ ipValue[1] = (unsigned char)atoi(ipToken[1]);
+ ipValue[2] = (unsigned char)atoi(ipToken[2]);
+ ipValue[3] = (unsigned char)atoi(ipToken[3]);
+ }
+ }
+ }
+ }
+ }
+
+ __NETWORK_FUNC_EXIT__;
+
+ return NET_ERR_NONE;
+}
+
+static int __net_extract_common_info(const char *key, GVariant *variant, net_profile_info_s* ProfInfo)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ const gchar *subKey = NULL;
+ const gchar *value = NULL;
+ net_dev_info_s* net_info = NULL;
+ GVariant *var = NULL;
+ GVariantIter *iter = NULL;
+
+ net_info = &(ProfInfo->net_info);
+
+ if (g_strcmp0(key, "State") == 0) {
+ value = g_variant_get_string(variant, NULL);
+
+ if (g_strcmp0(value, "idle") == 0)
+ ProfInfo->ProfileState = NET_STATE_TYPE_IDLE;
+ else if (g_strcmp0(value, "failure") == 0)
+ ProfInfo->ProfileState = NET_STATE_TYPE_FAILURE;
+ else if (g_strcmp0(value, "association") == 0)
+ ProfInfo->ProfileState = NET_STATE_TYPE_ASSOCIATION;
+ else if (g_strcmp0(value, "configuration") == 0)
+ ProfInfo->ProfileState = NET_STATE_TYPE_CONFIGURATION;
+ else if (g_strcmp0(value, "ready") == 0)
+ ProfInfo->ProfileState = NET_STATE_TYPE_READY;
+ else if (g_strcmp0(value, "disconnect") == 0)
+ ProfInfo->ProfileState = NET_STATE_TYPE_DISCONNECT;
+ else if (g_strcmp0(value, "online") == 0)
+ ProfInfo->ProfileState = NET_STATE_TYPE_ONLINE;
+ else
+ ProfInfo->ProfileState = NET_STATE_TYPE_UNKNOWN;
+ } else if (g_strcmp0(key, "Error") == 0) {
+ value = g_variant_get_string(variant, NULL);
+
+ if (g_strcmp0(value, "invalid-key") == 0)
+ ProfInfo->ProfileErrorState = NET_STATE_ERROR_INVALID_KEY;
+ else if (g_strcmp0(value, "connect-failed") == 0)
+ ProfInfo->ProfileErrorState = NET_STATE_ERROR_CONNECT_FAILED;
+ else if (g_strcmp0(value, "auth-failed") == 0)
+ ProfInfo->ProfileErrorState = NET_STATE_ERROR_AUTH_FAILED;
+ else if (g_strcmp0(value, "login-failed") == 0)
+ ProfInfo->ProfileErrorState = NET_STATE_ERROR_LOGIN_FAILED;
+ else if (g_strcmp0(value, "dhcp-failed") == 0)
+ ProfInfo->ProfileErrorState = NET_STATE_ERROR_DHCP_FAILED;
+ else if (g_strcmp0(value, "out-of-range") == 0)
+ ProfInfo->ProfileErrorState = NET_STATE_ERROR_OUT_OF_RANGE;
+ else if (g_strcmp0(value, "pin-missing") == 0)
+ ProfInfo->ProfileErrorState = NET_STATE_ERROR_PIN_MISSING;
+ } else if (g_strcmp0(key, "Favorite") == 0) {
+ gboolean val = g_variant_get_boolean(variant);
+
+ if (val)
+ ProfInfo->Favourite = (char)TRUE;
+ else
+ ProfInfo->Favourite = (char)FALSE;
+ } else if (g_strcmp0(key, "Ethernet") == 0) {
+ g_variant_get(variant, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
+ if (g_strcmp0(subKey, "Interface") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (value != NULL)
+ g_strlcpy(net_info->DevName, value, NET_MAX_DEVICE_NAME_LEN);
+ } else if (g_strcmp0(subKey, "Address") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (value != NULL)
+ g_strlcpy(net_info->MacAddr, value, NET_MAX_MAC_ADDR_LEN);
+ }
+ }
+ g_variant_iter_free(iter);
+ } else if (g_strcmp0(key, "IPv4") == 0) {
+ g_variant_get(variant, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
+ if (g_strcmp0(subKey, "Method") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (g_strcmp0(value, "dhcp") == 0)
+ net_info->IpConfigType = NET_IP_CONFIG_TYPE_DYNAMIC;
+ else if (g_strcmp0(value, "manual") == 0)
+ net_info->IpConfigType = NET_IP_CONFIG_TYPE_STATIC;
+ else if (g_strcmp0(value, "fixed") == 0)
+ net_info->IpConfigType = NET_IP_CONFIG_TYPE_FIXED;
+ else if (g_strcmp0(value, "off") == 0)
+ net_info->IpConfigType = NET_IP_CONFIG_TYPE_OFF;
+
+ } else if (g_strcmp0(subKey, "Address") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ __net_extract_ip(value, &net_info->IpAddr);
+ } else if (g_strcmp0(subKey, "Netmask") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ __net_extract_ip(value, &net_info->SubnetMask);
+ net_info->BNetmask = TRUE;
+ } else if (g_strcmp0(subKey, "Gateway") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ __net_extract_ip(value, &net_info->GatewayAddr);
+ net_info->BDefGateway = TRUE;
+ }
+ }
+ g_variant_iter_free(iter);
+ } else if (g_strcmp0(key, "IPv4.Configuration") == 0) {
+ if (net_info->IpConfigType != NET_IP_CONFIG_TYPE_DYNAMIC &&
+ net_info->IpConfigType != NET_IP_CONFIG_TYPE_STATIC &&
+ net_info->IpConfigType != NET_IP_CONFIG_TYPE_FIXED &&
+ net_info->IpConfigType != NET_IP_CONFIG_TYPE_OFF) {
+
+ g_variant_get(variant, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
+ if (g_strcmp0(subKey, "Method") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (g_strcmp0(value, "dhcp") == 0)
+ net_info->IpConfigType = NET_IP_CONFIG_TYPE_DYNAMIC;
+ else if (g_strcmp0(value, "manual") == 0)
+ net_info->IpConfigType = NET_IP_CONFIG_TYPE_STATIC;
+ else if (g_strcmp0(value, "fixed") == 0)
+ net_info->IpConfigType = NET_IP_CONFIG_TYPE_FIXED;
+ else if (g_strcmp0(value, "off") == 0)
+ net_info->IpConfigType = NET_IP_CONFIG_TYPE_OFF;
+
+ } else if (g_strcmp0(subKey, "Address") == 0 &&
+ net_info->IpAddr.Data.Ipv4.s_addr == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ __net_extract_ip(value, &net_info->IpAddr);
+ } else if (g_strcmp0(subKey, "Netmask") == 0 &&
+ net_info->SubnetMask.Data.Ipv4.s_addr == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ __net_extract_ip(value, &net_info->SubnetMask);
+ net_info->BNetmask = TRUE;
+ } else if (g_strcmp0(subKey, "Gateway") == 0 &&
+ net_info->GatewayAddr.Data.Ipv4.s_addr == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ __net_extract_ip(value, &net_info->GatewayAddr);
+ net_info->BDefGateway = TRUE;
+ }
+ }
+ g_variant_iter_free(iter);
+ }
+ } else if (g_strcmp0(key, "IPv6") == 0) {
+ g_variant_get(variant, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
+ if (g_strcmp0(subKey, "Method") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (g_strcmp0(value, "manual") == 0)
+ net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_STATIC;
+ else if (g_strcmp0(value, "off") == 0)
+ net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_OFF;
+ else if (g_strcmp0(value, "auto") == 0)
+ net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_AUTO_IP;
+
+ } else if (g_strcmp0(subKey, "Address") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ inet_pton(AF_INET6, value, &net_info->IpAddr6.Data.Ipv6);
+ } else if (g_strcmp0(subKey, "PrefixLength") == 0) {
+ net_info->PrefixLen6 = g_variant_get_byte(var);
+ } else if (g_strcmp0(subKey, "Gateway") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ inet_pton(AF_INET6, value, &net_info->GatewayAddr6.Data.Ipv6);
+ net_info->BDefGateway6 = TRUE;
+ } else if (g_strcmp0(subKey, "Privacy") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (value != NULL)
+ g_strlcpy(net_info->Privacy6, value, NET_IPV6_MAX_PRIVACY_LEN);
+ }
+ }
+ g_variant_iter_free(iter);
+ } else if (g_strcmp0(key, "IPv6.Configuration") == 0) {
+ g_variant_get(variant, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
+ if (g_strcmp0(subKey, "Method") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (g_strcmp0(value, "manual") == 0)
+ net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_STATIC;
+ else if (g_strcmp0(value, "off") == 0)
+ net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_OFF;
+ else if (g_strcmp0(value, "auto") == 0)
+ net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_AUTO_IP;
+
+ } else if (g_strcmp0(subKey, "Address") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ inet_pton(AF_INET6, value, &net_info->IpAddr6.Data.Ipv6);
+ } else if (g_strcmp0(subKey, "PrefixLength") == 0) {
+ net_info->PrefixLen6 = g_variant_get_byte(var);
+ } else if (g_strcmp0(subKey, "Gateway") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ inet_pton(AF_INET6, value, &net_info->GatewayAddr6.Data.Ipv6);
+ net_info->BDefGateway6 = TRUE;
+ } else if (g_strcmp0(subKey, "Privacy") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (value != NULL)
+ g_strlcpy(net_info->Privacy6, value, NET_IPV6_MAX_PRIVACY_LEN);
+ }
+ }
+ g_variant_iter_free(iter);
+ } else if (g_strcmp0(key, "Nameservers") == 0) {
+ int dnsCount = 0;
+
+ g_variant_get(variant, "as", &iter);
+ while (g_variant_iter_loop(iter, "s", &value)) {
+ if (g_strcmp0(value, "dhcp") == 0 || g_strcmp0(value, "manual") == 0)
+ continue;
+ __net_extract_ip(value, &net_info->DnsAddr[dnsCount]);
+
+ dnsCount++;
+ if (dnsCount >= NET_DNS_ADDR_MAX) {
+ if (NULL != value)
+ g_free((gchar*)value);
+ break;
+ }
+ }
+
+ g_variant_iter_free(iter);
+
+ net_info->DnsCount = dnsCount;
+ } else if (g_strcmp0(key, "Nameservers.Configuration") == 0 && net_info->DnsCount == 0) {
+ int dnsCount = 0;
+
+ g_variant_get(variant, "as", &iter);
+ while (g_variant_iter_loop(iter, "s", &value)) {
+ if (g_strcmp0(value, "dhcp") == 0 || g_strcmp0(value, "manual") == 0
+ || g_strcmp0(value, "unknown") == 0)
+ continue;
+ __net_extract_ip(value, &net_info->DnsAddr[dnsCount]);
+
+ dnsCount++;
+ if (dnsCount >= NET_DNS_ADDR_MAX) {
+ if (NULL != value)
+ g_free((gchar*)value);
+ break;
+ }
+ }
+ g_variant_iter_free(iter);
+
+ net_info->DnsCount = dnsCount;
+ } else if (g_strcmp0(key, "Domains") == 0) {
+ } else if (g_strcmp0(key, "Domains.Configuration") == 0) {
+ } else if (g_strcmp0(key, "Proxy") == 0) {
+ const gchar *url = NULL;
+ gchar *servers = NULL;
+
+ g_variant_get(variant, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
+ if (g_strcmp0(subKey, "Method") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (g_strcmp0(value, "direct") == 0)
+ net_info->ProxyMethod = NET_PROXY_TYPE_DIRECT;
+ else if (g_strcmp0(value, "auto") == 0)
+ net_info->ProxyMethod = NET_PROXY_TYPE_AUTO;
+ else if (g_strcmp0(value, "manual") == 0)
+ net_info->ProxyMethod = NET_PROXY_TYPE_MANUAL;
+ else
+ net_info->ProxyMethod = NET_PROXY_TYPE_UNKNOWN;
+ } else if (g_strcmp0(subKey, "URL") == 0) {
+ url = g_variant_get_string(var, NULL);
+ } else if (g_strcmp0(subKey, "Servers") == 0) {
+ GVariantIter *iter_sub = NULL;
+
+ g_variant_get(var, "as", &iter_sub);
+ g_variant_iter_loop(iter_sub, "s", &servers);
+ g_variant_iter_free(iter_sub);
+ }
+ }
+ g_variant_iter_free(iter);
+
+ if (net_info->ProxyMethod == NET_PROXY_TYPE_AUTO && url != NULL)
+ g_strlcpy(net_info->ProxyAddr, url, NET_PROXY_LEN_MAX);
+ else if (net_info->ProxyMethod == NET_PROXY_TYPE_MANUAL && servers != NULL)
+ g_strlcpy(net_info->ProxyAddr, servers, NET_PROXY_LEN_MAX);
+
+ if (servers)
+ g_free(servers);
+ } else if (g_strcmp0(key, "Proxy.Configuration") == 0 &&
+ net_info->ProxyMethod != NET_PROXY_TYPE_AUTO &&
+ net_info->ProxyMethod != NET_PROXY_TYPE_MANUAL) {
+
+ const gchar *url = NULL;
+ gchar *servers = NULL;
+
+ g_variant_get(variant, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
+ if (g_strcmp0(subKey, "Method") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (g_strcmp0(value, "direct") == 0)
+ net_info->ProxyMethod = NET_PROXY_TYPE_DIRECT;
+ else if (g_strcmp0(value, "auto") == 0)
+ net_info->ProxyMethod = NET_PROXY_TYPE_AUTO;
+ else if (g_strcmp0(value, "manual") == 0)
+ net_info->ProxyMethod = NET_PROXY_TYPE_MANUAL;
+ else
+ net_info->ProxyMethod = NET_PROXY_TYPE_UNKNOWN;
+ } else if (g_strcmp0(subKey, "URL") == 0) {
+ url = g_variant_get_string(var, NULL);
+ } else if (g_strcmp0(subKey, "Servers") == 0) {
+ GVariantIter *iter_sub = NULL;
+
+ g_variant_get(var, "as", &iter_sub);
+ g_variant_iter_loop(iter_sub, "s", &servers);
+ g_variant_iter_free(iter_sub);
+ }
+ }
+ g_variant_iter_free(iter);
+
+ if (net_info->ProxyMethod == NET_PROXY_TYPE_AUTO && url != NULL)
+ g_strlcpy(net_info->ProxyAddr, url, NET_PROXY_LEN_MAX);
+ else if (net_info->ProxyMethod == NET_PROXY_TYPE_MANUAL && servers != NULL)
+ g_strlcpy(net_info->ProxyAddr, servers, NET_PROXY_LEN_MAX);
+
+ if (servers)
+ g_free(servers);
+ } else if (g_strcmp0(key, "Provider") == 0) {
+ /* Do noting */
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+static wlan_eap_type_e __convert_eap_type_from_string(const char *eap_type)
+{
+ if (eap_type == NULL)
+ return WLAN_SEC_EAP_TYPE_PEAP;
+ else if (g_strcmp0(eap_type, "peap") == 0)
+ return WLAN_SEC_EAP_TYPE_PEAP;
+ else if (g_strcmp0(eap_type, "tls") == 0)
+ return WLAN_SEC_EAP_TYPE_TLS;
+ else if (g_strcmp0(eap_type, "ttls") == 0)
+ return WLAN_SEC_EAP_TYPE_TTLS;
+ else if (g_strcmp0(eap_type, "sim") == 0)
+ return WLAN_SEC_EAP_TYPE_SIM;
+ else if (g_strcmp0(eap_type, "aka") == 0)
+ return WLAN_SEC_EAP_TYPE_AKA;
+ else
+ return WLAN_SEC_EAP_TYPE_PEAP;
+}
+
+static wlan_eap_auth_type_e __convert_eap_auth_from_string(const char *eap_auth)
+{
+ if (eap_auth == NULL)
+ return WLAN_SEC_EAP_AUTH_NONE;
+ else if (g_strcmp0(eap_auth, "NONE") == 0)
+ return WLAN_SEC_EAP_AUTH_NONE;
+ else if (g_strcmp0(eap_auth, "PAP") == 0)
+ return WLAN_SEC_EAP_AUTH_PAP;
+ else if (g_strcmp0(eap_auth, "MSCHAP") == 0)
+ return WLAN_SEC_EAP_AUTH_MSCHAP;
+ else if (g_strcmp0(eap_auth, "MSCHAPV2") == 0)
+ return WLAN_SEC_EAP_AUTH_MSCHAPV2;
+ else if (g_strcmp0(eap_auth, "GTC") == 0)
+ return WLAN_SEC_EAP_AUTH_GTC;
+ else if (g_strcmp0(eap_auth, "MD5") == 0)
+ return WLAN_SEC_EAP_AUTH_MD5;
+ else
+ return WLAN_SEC_EAP_AUTH_NONE;
+}
+
+static int __net_update_connected_wifi_info(net_profile_info_s* ProfInfo)
+{
+ static char ifname[NET_MAX_DEVICE_NAME_LEN+1] = { '\0', };
+ static char interface_path[DBUS_OBJECT_PATH_MAX] = { '\0', };
+ char current_bss_path[DBUS_OBJECT_PATH_MAX] = { '\0', };
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *params = NULL;
+ GVariant *reply = NULL;
+ GVariant *value = NULL;
+ GVariantIter *iter = NULL;
+ gchar *key = NULL;
+ const char *path = NULL;
+
+ /* Get proper interface */
+ if (g_strcmp0(ProfInfo->net_info.DevName, ifname) != 0) {
+ g_strlcpy(ifname, ProfInfo->net_info.DevName,
+ NET_MAX_DEVICE_NAME_LEN+1);
+
+ params = g_variant_new("(s)", ifname);
+ reply = _net_invoke_dbus_method(SUPPLICANT_SERVICE, SUPPLICANT_PATH,
+ SUPPLICANT_INTERFACE, "GetInterface", params, &Error);
+ if (reply == NULL) {
+ ifname[0] = '\0';
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi interface");
+ return Error;
+ }
+ g_variant_get(reply, "(o)", &path);
+ g_strlcpy(interface_path, path, DBUS_OBJECT_PATH_MAX);
+
+ g_variant_unref(reply);
+ }
+
+ /* Get CurrentBSS object path */
+ params = g_variant_new("(ss)", SUPPLICANT_IFACE_INTERFACE, "CurrentBSS");
+ reply = _net_invoke_dbus_method(SUPPLICANT_SERVICE, interface_path,
+ DBUS_PROPERTIES_INTERFACE, "Get", params, &Error);
+ if (reply == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get CurrentBSS");
+ return Error;
+ }
+ g_variant_get(reply, "(v)", &value);
+ path = g_variant_get_string(value, NULL);
+ g_strlcpy(current_bss_path, path, DBUS_OBJECT_PATH_MAX);
+
+ g_variant_unref(value);
+ g_variant_unref(reply);
+
+ /* Get Wi-Fi information */
+ params = g_variant_new("(s)", SUPPLICANT_IFACE_BSS);
+ reply = _net_invoke_dbus_method(SUPPLICANT_SERVICE, current_bss_path,
+ DBUS_PROPERTIES_INTERFACE, "GetAll", params, &Error);
+ if (reply == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi information");
+ return Error;
+ }
+ g_variant_get(reply, "(a{sv})", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ if (g_strcmp0(key, "BSSID") == 0) {
+ gsize bssid_len = 0;
+ const gchar *bssid = NULL;
+
+ bssid =
+ g_variant_get_fixed_array(value, &bssid_len, sizeof(guchar));
+ if (bssid && bssid_len == 6)
+ snprintf(ProfInfo->bssid, 18,
+ "%02x:%02x:%02x:%02x:%02x:%02x",
+ bssid[0], bssid[1], bssid[2],
+ bssid[3], bssid[4], bssid[5]);
+
+ } else if (g_strcmp0(key, "Signal") == 0) {
+ ProfInfo->Strength =
+ (unsigned char)(120 + g_variant_get_int16(value));
+
+ if (ProfInfo->Strength > 100)
+ ProfInfo->Strength = 100;
+
+ } else if (g_strcmp0(key, "Frequency") == 0) {
+ ProfInfo->frequency =
+ (unsigned int)g_variant_get_uint16(value);
+
+ } else if (g_strcmp0(key, "Rates") == 0) {
+ GVariantIter *iter_sub = NULL;
+ guint32 value_sub;
+
+ g_variant_get(value, "au", &iter_sub);
+ while (g_variant_iter_loop(iter_sub, "u", &value_sub)) {
+ ProfInfo->max_rate = (unsigned int)value_sub;
+ break;
+ }
+
+ g_variant_iter_free(iter_sub);
+ }
+ }
+
+ g_variant_iter_free(iter);
+ g_variant_unref(reply);
+
+ return Error;
+}
+
+static int __net_wifi_modify_profile(const char* ProfileName,
+ net_profile_info_s* ProfInfo, net_profile_info_s* exProfInfo)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ int i = 0;
+ char profilePath[NET_PROFILE_NAME_LEN_MAX+1] = "";
+
+ wlan_security_info_s *security_info = &(ProfInfo->security_info);
+ wlan_security_info_s *ex_security_info = &(exProfInfo->security_info);
+ net_dev_info_s *net_info = &(ProfInfo->net_info);
+ net_dev_info_s *ex_net_info = &(exProfInfo->net_info);
+
+ g_strlcpy(profilePath, ProfileName, NET_PROFILE_NAME_LEN_MAX+1);
+
+ /* Compare and Set 'Passphrase' */
+ if (ex_security_info->sec_mode == WLAN_SEC_MODE_WEP) {
+ if (g_strcmp0(security_info->authentication.wep.wepKey,
+ ex_security_info->authentication.wep.wepKey) != 0) {
+ Error = _net_dbus_set_agent_passphrase_and_connect(
+ security_info->authentication.wep.wepKey, ProfileName);
+
+ if (NET_ERR_NONE != Error) {
+ WIFI_LOG(WIFI_ERROR, "Failed to set agent field");
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+ }
+ } else if (ex_security_info->sec_mode == WLAN_SEC_MODE_WPA_PSK ||
+ ex_security_info->sec_mode == WLAN_SEC_MODE_WPA2_PSK) {
+ if (g_strcmp0(security_info->authentication.psk.pskKey,
+ ex_security_info->authentication.psk.pskKey) != 0) {
+ Error = _net_dbus_set_agent_passphrase_and_connect(
+ security_info->authentication.psk.pskKey, ProfileName);
+
+ if (NET_ERR_NONE != Error) {
+ WIFI_LOG(WIFI_ERROR, "Failed to set agent field");
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+ }
+ }
+
+ /* Compare and Set 'Proxy' */
+ if ((ex_net_info->ProxyMethod != net_info->ProxyMethod) ||
+ (g_strcmp0(ex_net_info->ProxyAddr, net_info->ProxyAddr) != 0)) {
+
+ Error = _net_dbus_set_proxy(ProfInfo, profilePath);
+
+ if (Error != NET_ERR_NONE) {
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+ }
+
+ /* Compare and Set 'IPv4 addresses' */
+ if ((ex_net_info->IpConfigType != net_info->IpConfigType) ||
+ (net_info->IpConfigType == NET_IP_CONFIG_TYPE_STATIC &&
+ (net_info->IpAddr.Data.Ipv4.s_addr != ex_net_info->IpAddr.Data.Ipv4.s_addr ||
+ net_info->SubnetMask.Data.Ipv4.s_addr != ex_net_info->SubnetMask.Data.Ipv4.s_addr ||
+ net_info->GatewayAddr.Data.Ipv4.s_addr != ex_net_info->GatewayAddr.Data.Ipv4.s_addr))) {
+ Error = _net_dbus_set_profile_ipv4(ProfInfo, profilePath);
+
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to set IPv4");
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+ }
+
+ /* Compare and Set 'IPv6 addresses' */
+ if ((ex_net_info->IpConfigType6 != net_info->IpConfigType6) ||
+ (net_info->IpConfigType6 == NET_IP_CONFIG_TYPE_STATIC &&
+ (net_info->IpAddr6.Data.Ipv6.s6_addr != ex_net_info->IpAddr6.Data.Ipv6.s6_addr ||
+ net_info->PrefixLen6 != ex_net_info->PrefixLen6 ||
+ net_info->GatewayAddr6.Data.Ipv6.s6_addr != ex_net_info->GatewayAddr6.Data.Ipv6.s6_addr))) {
+
+ Error = _net_dbus_set_profile_ipv6(ProfInfo, profilePath);
+
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Error!!! Can't set IPv6\n");
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+ }
+
+ /* Compare and Set 'DNS addresses' */
+ for (i = 0; i < net_info->DnsCount; i++) {
+ if (i >= NET_DNS_ADDR_MAX) {
+ net_info->DnsCount = NET_DNS_ADDR_MAX;
+
+ break;
+ }
+
+ if (net_info->DnsAddr[i].Data.Ipv4.s_addr !=
+ ex_net_info->DnsAddr[i].Data.Ipv4.s_addr)
+ break;
+ }
+
+ if (i < net_info->DnsCount) {
+ Error = _net_dbus_set_profile_dns(ProfInfo, profilePath);
+
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to set DNS\n");
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+static int __net_wifi_delete_profile(net_profile_name_s* WifiProfName,
+ wlan_security_mode_type_e sec_mode, gboolean passpoint)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+ char param0[NET_PROFILE_NAME_LEN_MAX + 8] = "";
+ GVariant *params;
+
+ if (passpoint == TRUE && WLAN_SEC_MODE_IEEE8021X == sec_mode) {
+ message = _net_invoke_dbus_method(CONNMAN_SERVICE,
+ WifiProfName->ProfileName,
+ CONNMAN_SERVICE_INTERFACE, "Remove", NULL,
+ &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to Remove service(profile)");
+ g_variant_unref(message);
+ goto done;
+ }
+
+ g_variant_unref(message);
+
+ g_snprintf(param0, NET_PROFILE_NAME_LEN_MAX + 8, "string:%s",
+ WifiProfName->ProfileName);
+ params = g_variant_new("(s)", param0);
+
+ message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ "DeleteEapConfig", params, &Error);
+ } else if (passpoint == TRUE || WLAN_SEC_MODE_IEEE8021X != sec_mode) {
+ message = _net_invoke_dbus_method(CONNMAN_SERVICE,
+ WifiProfName->ProfileName,
+ CONNMAN_SERVICE_INTERFACE, "Remove", NULL,
+ &Error);
+ } else {
+ g_snprintf(param0, NET_PROFILE_NAME_LEN_MAX + 8, "string:%s",
+ WifiProfName->ProfileName);
+ params = g_variant_new("(s)", param0);
+
+ message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ "DeleteEapConfig", params, &Error);
+ }
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to Remove service(profile)");
+ goto done;
+ }
+
+ g_variant_unref(message);
+done:
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+static int __net_extract_wifi_info(GVariantIter *array, net_profile_info_s* ProfInfo)
+{
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *var = NULL;
+ const gchar *key = NULL;
+
+ __NETWORK_FUNC_ENTER__;
+
+ while (g_variant_iter_loop(array, "{sv}", &key, &var)) {
+ const gchar *value = NULL;
+
+ if (g_strcmp0(key, "Mode") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (g_strcmp0(value, "managed") == 0)
+ ProfInfo->wlan_mode = NET_WLAN_CONNMODE_INFRA;
+ else if (g_strcmp0(value, "adhoc") == 0)
+ ProfInfo->wlan_mode = NET_WLAN_CONNMODE_ADHOC;
+ else
+ ProfInfo->wlan_mode = NET_WLAN_CONNMODE_AUTO;
+
+ } else if (g_strcmp0(key, "Security") == 0) {
+ GVariantIter *iter_sub = NULL;
+
+ g_variant_get(var, "as", &iter_sub);
+ while (g_variant_iter_loop(iter_sub, "s", &value)) {
+ if (g_strcmp0(value, "none") == 0 &&
+ ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_NONE)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_NONE;
+ else if (g_strcmp0(value, "wep") == 0 &&
+ ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_WEP)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_WEP;
+ else if (g_strcmp0(value, "psk") == 0 &&
+ ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
+ else if (g_strcmp0(value, "ft_psk") == 0 &&
+ ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_WPA_FT_PSK)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_WPA_FT_PSK;
+ else if (g_strcmp0(value, "ieee8021x") == 0 &&
+ ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_IEEE8021X)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_IEEE8021X;
+ else if (g_strcmp0(value, "wpa") == 0 &&
+ ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
+ else if (g_strcmp0(value, "rsn") == 0 &&
+ ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_WPA2_PSK;
+ else if (g_strcmp0(value, "wps") == 0)
+ ProfInfo->security_info.wps_support = TRUE;
+ else if (ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_NONE)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_NONE;
+ }
+ g_variant_iter_free(iter_sub);
+ } else if (g_strcmp0(key, "EncryptionMode") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (g_strcmp0(value, "none") == 0)
+ ProfInfo->security_info.enc_mode = WLAN_ENC_MODE_NONE;
+ else if (g_strcmp0(value, "wep") == 0)
+ ProfInfo->security_info.enc_mode = WLAN_ENC_MODE_WEP;
+ else if (g_strcmp0(value, "tkip") == 0)
+ ProfInfo->security_info.enc_mode = WLAN_ENC_MODE_TKIP;
+ else if (g_strcmp0(value, "aes") == 0)
+ ProfInfo->security_info.enc_mode = WLAN_ENC_MODE_AES;
+ else if (g_strcmp0(value, "mixed") == 0)
+ ProfInfo->security_info.enc_mode = WLAN_ENC_MODE_TKIP_AES_MIXED;
+
+ } else if (g_strcmp0(key, "Passpoint") == 0) {
+ gboolean passpoint;
+
+ passpoint = g_variant_get_boolean(var);
+ if (passpoint)
+ ProfInfo->passpoint = TRUE;
+ else
+ ProfInfo->passpoint = FALSE;
+
+ } else if (g_strcmp0(key, "Strength") == 0) {
+ ProfInfo->Strength = g_variant_get_byte(var);
+ } else if (g_strcmp0(key, "Name") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (value != NULL)
+ g_strlcpy(ProfInfo->essid, value, NET_WLAN_ESSID_LEN);
+ } else if (g_strcmp0(key, "Passphrase") == 0) {
+ wlan_security_info_s *security_info = &(ProfInfo->security_info);
+ value = g_variant_get_string(var, NULL);
+
+ if (security_info->sec_mode == WLAN_SEC_MODE_WEP && value != NULL)
+ g_strlcpy(security_info->authentication.wep.wepKey,
+ value, NET_WLAN_MAX_WEP_KEY_LEN+1);
+ else if ((security_info->sec_mode == WLAN_SEC_MODE_WPA_PSK ||
+ security_info->sec_mode == WLAN_SEC_MODE_WPA2_PSK) &&
+ value != NULL)
+ g_strlcpy(security_info->authentication.psk.pskKey,
+ value, NET_WLAN_MAX_PSK_PASSPHRASE_LEN+1);
+ } else if (g_strcmp0(key, "PassphraseRequired") == 0) {
+ gboolean val;
+
+ val = g_variant_get_boolean(var);
+
+ if (val)
+ ProfInfo->PassphraseRequired = TRUE;
+ else
+ ProfInfo->PassphraseRequired = FALSE;
+ } else if (g_strcmp0(key, "BSSID") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (value != NULL)
+ g_strlcpy(ProfInfo->bssid, value, NET_MAX_MAC_ADDR_LEN);
+
+ } else if (g_strcmp0(key, "MaxRate") == 0) {
+ ProfInfo->max_rate = (unsigned int)g_variant_get_uint32(var);
+
+ } else if (g_strcmp0(key, "Frequency") == 0) {
+ ProfInfo->frequency = (unsigned int)g_variant_get_uint16(var);
+
+ } else if (g_strcmp0(key, "EAP") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (value != NULL)
+ ProfInfo->security_info.authentication.eap.eap_type =
+ __convert_eap_type_from_string(value);
+
+ } else if (g_strcmp0(key, "Phase2") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (value != NULL)
+ ProfInfo->security_info.authentication.eap.eap_auth =
+ __convert_eap_auth_from_string(value);
+
+ } else if (g_strcmp0(key, "Identity") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (value != NULL)
+ g_strlcpy(ProfInfo->security_info.authentication.eap.username,
+ value, NET_WLAN_USERNAME_LEN+1);
+
+ } else if (g_strcmp0(key, "Password") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (value != NULL)
+ g_strlcpy(ProfInfo->security_info.authentication.eap.password,
+ value, NET_WLAN_PASSWORD_LEN+1);
+
+ } else if (g_strcmp0(key, "CACertFile") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (value != NULL)
+ g_strlcpy(ProfInfo->security_info.authentication.eap.ca_cert_filename,
+ value, NET_WLAN_CA_CERT_FILENAME_LEN+1);
+
+ } else if (g_strcmp0(key, "ClientCertFile") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (value != NULL)
+ g_strlcpy(ProfInfo->security_info.authentication.eap.client_cert_filename,
+ value, NET_WLAN_CLIENT_CERT_FILENAME_LEN+1);
+
+ } else if (g_strcmp0(key, "PrivateKeyFile") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (value != NULL)
+ g_strlcpy(ProfInfo->security_info.authentication.eap.private_key_filename,
+ value, NET_WLAN_PRIVATE_KEY_FILENAME_LEN+1);
+
+ } else if (g_strcmp0(key, "PrivateKeyPassphrase") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (value != NULL)
+ g_strlcpy(ProfInfo->security_info.authentication.eap.private_key_passwd,
+ value, NET_WLAN_PRIVATE_KEY_PASSWD_LEN+1);
+
+ } else if (g_strcmp0(key, "Keymgmt") == 0) {
+ ProfInfo->security_info.keymgmt = (unsigned int)g_variant_get_uint32(var);
+
+ } else
+ Error = __net_extract_common_info(key, var, ProfInfo);
+ }
+
+ /* If there are multiple Wi-Fi networks which have the same SSID,
+ * and one of them is connected, we need to get the connected one
+ * rather than ConnMan grouped properties.
+ */
+ if (ProfInfo->ProfileState == NET_STATE_TYPE_READY ||
+ ProfInfo->ProfileState == NET_STATE_TYPE_ONLINE)
+ Error = __net_update_connected_wifi_info(ProfInfo);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+static int __net_extract_service_info(
+ const char* ProfileName, GVariantIter *iter,
+ net_profile_info_s* ProfInfo)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ gchar *key = NULL;
+ GVariant *value = NULL;
+ gboolean isProf = FALSE;
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ const gchar *tech = NULL;
+
+ if (g_strcmp0(key, "Type") == 0) {
+ tech = g_variant_get_string(value, NULL);
+
+ if (g_strcmp0(tech, "wifi") == 0)
+ isProf = TRUE;
+
+ g_variant_unref(value);
+ g_free(key);
+ break;
+ }
+ }
+
+ if (isProf) {
+ if ((Error = __net_init_profile_info(ProfInfo)) != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to init profile");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ g_strlcpy(ProfInfo->ProfileName, ProfileName, NET_PROFILE_NAME_LEN_MAX);
+ g_strlcpy(ProfInfo->net_info.ProfileName,
+ ProfileName, NET_PROFILE_NAME_LEN_MAX);
+
+ Error = __net_extract_wifi_info(iter, ProfInfo);
+ }
+
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR,
+ "Failed to extract service information from received message");
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+static int __net_extract_all_services(GVariantIter *array,
+ const char *service_prefix, GSList **profile_list)
+{
+ net_profile_info_s *ProfInfo = NULL;
+ net_err_e Error = NET_ERR_NONE;
+ gchar *obj;
+ GVariantIter *next = NULL;
+
+ __NETWORK_FUNC_ENTER__;
+
+ if (array == NULL || service_prefix == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ while (g_variant_iter_loop(array, "(oa{sv})", &obj, &next)) {
+ if (obj == NULL)
+ continue;
+
+ if (g_str_has_prefix(obj, service_prefix) == TRUE) {
+ ProfInfo = g_try_malloc0(sizeof(net_profile_info_s));
+
+ if ((Error = __net_init_profile_info(ProfInfo)) != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to init profile");
+ goto error;
+ }
+
+ if (g_strrstr(obj + strlen(service_prefix), "hidden") != NULL)
+ ProfInfo->is_hidden = TRUE;
+
+ g_strlcpy(ProfInfo->ProfileName, obj, NET_PROFILE_NAME_LEN_MAX);
+
+ g_strlcpy(ProfInfo->net_info.ProfileName,
+ obj, NET_PROFILE_NAME_LEN_MAX);
+
+ Error = __net_extract_wifi_info(next, ProfInfo);
+
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to extract service info");
+ goto error;
+ }
+
+ *profile_list = g_slist_append(*profile_list, (net_profile_info_s *)ProfInfo);
+ }
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+
+error:
+ if (next)
+ g_variant_iter_free(next);
+ if (obj)
+ g_free(obj);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+static int __net_extract_services(GVariantIter *message, GSList **profile_list)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ char *service_prefix = NULL;
+
+ service_prefix = CONNMAN_WIFI_SERVICE_PROFILE_PREFIX;
+
+ Error = __net_extract_all_services(message, service_prefix, profile_list);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to extract services from received message");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+static int __net_get_profile_info(
+ const char* ProfileName, net_profile_info_s* ProfInfo)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+ GVariantIter *iter = NULL;
+ GVariantIter *service = NULL;
+ gchar *path = NULL;
+
+ message = _net_invoke_dbus_method(CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE, "GetServices", NULL, &Error);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get profile");
+ goto done;
+ }
+
+ g_variant_get(message, "(a(oa{sv}))", &iter);
+ while (g_variant_iter_loop(iter, "(oa{sv})", &path, &service)) {
+ if (g_strcmp0(ProfileName, path) == 0) {
+ Error = __net_extract_service_info(ProfileName, service, ProfInfo);
+ g_variant_iter_free(service);
+ g_free(path);
+ break;
+ }
+ }
+
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+done:
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+static gboolean __net_is_connecting(const char *profile_name)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ char *svc_name1 = request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
+ char *svc_name2 = request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
+
+ if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
+ g_strcmp0(profile_name, svc_name1) == 0) {
+ __NETWORK_FUNC_EXIT__;
+ return TRUE;
+ } else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
+ g_strcmp0(profile_name, svc_name2) == 0) {
+ __NETWORK_FUNC_EXIT__;
+ return TRUE;
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return FALSE;
+}
+
+static void __net_abort_open_connection(const char *profile_name)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_event_info_s event_data;
+ char event_string[64];
+
+ char *svc_name1 = request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
+ char *svc_name2 = request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
+
+ if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
+ g_strcmp0(profile_name, svc_name1) == 0) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
+ sizeof(network_request_table_s));
+
+ event_data.Event = NET_EVENT_OPEN_RSP;
+ g_strlcpy(event_string, "Sending NET_EVENT_OPEN_RSP", 64);
+
+ _net_dbus_pending_call_unref();
+ } else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
+ g_strcmp0(profile_name, svc_name2) == 0) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+ sizeof(network_request_table_s));
+
+ event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+ g_strlcpy(event_string, "Sending NET_EVENT_WIFI_WPS_RSP", 64);
+
+ _net_dbus_pending_call_unref();
+ } else {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ g_strlcpy(event_data.ProfileName, profile_name, NET_PROFILE_NAME_LEN_MAX+1);
+ event_data.Error = NET_ERR_OPERATION_ABORTED;
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+
+ WIFI_LOG(WIFI_INFO, "%s, Error: %d", event_string, event_data.Error);
+ _net_client_callback(&event_data);
+
+ __NETWORK_FUNC_EXIT__;
+}
+//LCOV_EXCL_STOP
+
+int _net_check_profile_name(const char* ProfileName)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ const char *profileHeader = CONNMAN_PATH"/service/";
+ int i = 0;
+ int stringLen = 0;
+
+ if (ProfileName == NULL || strlen(ProfileName) <= strlen(profileHeader)) {
+ WIFI_LOG(WIFI_ERROR, "Profile name is invalid"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
+ }
+
+ stringLen = strlen(ProfileName);
+
+ if (strncmp(profileHeader, ProfileName, strlen(profileHeader)) == 0) {
+ for (i = 0; i < stringLen; i++) {
+ if (isgraph(ProfileName[i]) == 0) {
+ WIFI_LOG(WIFI_ERROR, "Profile name is invalid"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
+ }
+ }
+ } else {
+ WIFI_LOG(WIFI_ERROR, "Profile name is invalid"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+int _net_get_profile_list(GSList **profile_list)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message;
+ GVariantIter *iter;
+
+ message = _net_invoke_dbus_method(CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE, "GetServices", NULL, &Error);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get service(profile) list"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ g_variant_get(message, "(a(oa{sv}))", &iter);
+ Error = __net_extract_services(iter, profile_list);
+
+ if (iter != NULL)
+ g_variant_iter_free(iter);
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int net_specific_scan_wifi(const char *ssid)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (ssid == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
+ }
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Find hidden AP request in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
+ }
+
+ if (NetworkInfo.wifi_state == WIFI_OFF) {
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
+ }
+ }
+
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "pending call in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
+ }
+
+ request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag = TRUE;
+
+ Error = _net_dbus_specific_scan_request(ssid);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "_net_dbus_specific_scan_request() failed. Error [%s]",
+ _net_print_error(Error));
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN], 0, //LCOV_EXCL_LINE
+ sizeof(network_request_table_s));
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+//LCOV_EXCL_START
+int net_wps_scan_wifi(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "pending call in progress");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+
+ request_table[NETWORK_REQUEST_TYPE_WPS_SCAN].flag = TRUE;
+
+ Error = _net_dbus_wps_scan_request();
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR,
+ "_net_dbus_wps_scan_request() failed. Error [%s]",
+ _net_print_error(Error));
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_WPS_SCAN], 0,
+ sizeof(network_request_table_s));
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+int net_get_wps_pin(char **wps_pin)
+{
+ net_err_e error = NET_ERR_NONE;
+ error = _net_dbus_get_wps_pin(wps_pin);
+
+ if (error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, "Failed to get wps pin : %d", error);
+
+ return error;
+}
+
+int net_wifi_get_passpoint(int *enabled)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ if (NetworkInfo.wifi_state == WIFI_OFF) {
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+ }
+
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "pending call in progress");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+
+ Error = _net_dbus_get_passpoint(enabled);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR,
+ "_net_dbus_get_passpoint() failed. Error [%s]",
+ _net_print_error(Error));
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int net_wifi_set_passpoint(int enable)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ if (NetworkInfo.wifi_state == WIFI_OFF) {
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+ }
+
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "pending call in progress");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+
+ Error = _net_dbus_set_passpoint(enable);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR,
+ "_net_dbus_set_passpoint() failed. Error [%s]",
+ _net_print_error(Error));
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+//LCOV_EXCL_STOP
+
+int net_open_connection_with_wifi_info(const net_wifi_connection_info_s *wifi_info)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (wifi_info == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
+ }
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Connection open request in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
+ }
+
+ if (NetworkInfo.wifi_state == WIFI_OFF) {
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
+ }
+ }
+
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "pending call in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
+ }
+
+ request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag = TRUE;
+
+ Error = _net_open_connection_with_wifi_info(wifi_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "net_open_connection_with_wifi_info() failed. Error [%s]",
+ _net_print_error(Error));
+
+ if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag != 0)
+ memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0, //LCOV_EXCL_LINE
+ sizeof(network_request_table_s));
+
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+int net_wifi_power_on(gboolean wifi_picker_test)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ int hotspot_state = 0;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ if (!net_get_device_policy_wifi()) {
+ WIFI_LOG(WIFI_ERROR, "Wifi profile device policy restricts"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_SECURITY_RESTRICTED; //LCOV_EXCL_LINE
+ }
+
+ vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_state);
+ if (hotspot_state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi hotspot is enabled!"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
+ }
+
+ if (NetworkInfo.wifi_state != WIFI_OFF) {
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_ON) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered on already!"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_ALREADY_EXISTS; //LCOV_EXCL_LINE
+ } else if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Request in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
+ }
+
+ _net_dbus_pending_call_unref();
+ memset(request_table, 0, sizeof(request_table));
+
+ request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag = TRUE;
+
+ Error = _net_dbus_load_wifi_driver(wifi_picker_test);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "Failed to request Wi-Fi power on/off. Error [%s]",
+ _net_print_error(Error));
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER], 0, //LCOV_EXCL_LINE
+ sizeof(network_request_table_s));
+
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+int net_wifi_power_off(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ if (NetworkInfo.wifi_state == WIFI_OFF) {
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off already!"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_ALREADY_EXISTS; //LCOV_EXCL_LINE
+ }
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Request in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
+ }
+
+ //LCOV_EXCL_START
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
+ _net_dbus_pending_call_unref();
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_SCAN],
+ 0, sizeof(network_request_table_s));
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
+ _net_dbus_pending_call_unref();
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION],
+ 0, sizeof(network_request_table_s));
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE) {
+ _net_dbus_pending_call_unref();
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS],
+ 0, sizeof(network_request_table_s));
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE) {
+ _net_dbus_pending_call_unref();
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION],
+ 0, sizeof(network_request_table_s));
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
+ _net_dbus_pending_call_unref();
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN],
+ 0, sizeof(network_request_table_s));
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_WPS_SCAN].flag == TRUE) {
+ _net_dbus_pending_call_unref();
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_WPS_SCAN],
+ 0, sizeof(network_request_table_s));
+ }
+
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "pending call in progress");
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+ }
+ //LCOV_EXCL_STOP
+
+ request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag = TRUE;
+
+ Error = _net_dbus_remove_wifi_driver();
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "Failed to request Wi-Fi power on/off. Error [%s]",
+ _net_print_error(Error));
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER], //LCOV_EXCL_LINE
+ 0, sizeof(network_request_table_s));
+
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+int net_scan_wifi(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Request in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
+ }
+
+ if (NetworkInfo.wifi_state == WIFI_OFF) {
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
+ }
+ }
+
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
+ } else {
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
+ }
+ }
+
+ request_table[NETWORK_REQUEST_TYPE_SCAN].flag = TRUE;
+
+ Error = _net_dbus_scan_request();
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to request scan. Error [%s]", //LCOV_EXCL_LINE
+ _net_print_error(Error));
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_SCAN], 0, //LCOV_EXCL_LINE
+ sizeof(network_request_table_s));
+
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+//LCOV_EXCL_START
+int net_wifi_enroll_wps(const char *profile_name, net_wifi_wps_info_s *wps_info)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Invalid profile name");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Request in progress");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_IN_PROGRESS;
+ }
+
+ if (NetworkInfo.wifi_state == WIFI_OFF) {
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+ }
+
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "pending call in progress");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+
+ request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag = TRUE;
+ g_strlcpy(request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName,
+ profile_name, NET_PROFILE_NAME_LEN_MAX+1);
+
+ if (wps_info->type == WIFI_WPS_PBC)
+ Error = _net_dbus_set_agent_wps_pbc_and_connect(profile_name);
+ else if (wps_info->type == WIFI_WPS_PIN)
+ Error = _net_dbus_set_agent_wps_pin_and_connect(wps_info->pin, profile_name);
+ else
+ Error = NET_ERR_INVALID_PARAM;
+
+ if (NET_ERR_NONE != Error) {
+ WIFI_LOG(WIFI_ERROR,
+ "WPS configuration failed(%s)", _net_print_error(Error));
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+ sizeof(network_request_table_s));
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+#if defined TIZEN_TV
+int net_wifi_cancel_wps(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ WIFI_LOG(WIFI_ERROR, "net_wifi_wps_cancel called\n");
+
+ if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == FALSE) {
+ WIFI_LOG(WIFI_ERROR, "No pending call in progress\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+
+ if (_net_get_wifi_state(&Error) != WIFI_ON) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "pending call in progress\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName[0] != '\0')
+ net_delete_profile(request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName);
+
+ Error = _net_dbus_cancel_wps();
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR,
+ "Failed to request cancel WPS, Error [%s]\n",
+ _net_print_error(Error));
+ }
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+ sizeof(network_request_table_s));
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+#endif
+
+int net_get_wifi_state(net_wifi_state_e *current_state)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ *current_state = __net_get_wifi_connection_state(&Error);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_e scan_mode)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ if (NetworkInfo.wifi_state == WIFI_OFF) {
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+ }
+
+ if ((Error = _net_dbus_set_bgscan_mode(scan_mode)) != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR,
+ "Failed to set bgscan mode. Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+//LCOV_EXCL_STOP
+
+int net_check_get_privilege()
+{
+ net_err_e Error = NET_ERR_NONE;
+
+ Error = __net_check_get_privilege();
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to check get privilege. Error [%s]", //LCOV_EXCL_LINE
+ _net_print_error(Error));
+
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ return Error;
+}
+
+int net_check_profile_privilege()
+{
+ net_err_e Error = NET_ERR_NONE;
+
+ Error = __net_check_profile_privilege();
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to check profile privilege. Error [%s]", //LCOV_EXCL_LINE
+ _net_print_error(Error));
+
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ return Error;
+}
+
+//LCOV_EXCL_START
+#if defined TIZEN_TV
+int net_wifi_enroll_wps_without_ssid(net_wifi_wps_info_s *wps_info)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Request in progress\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_IN_PROGRESS;
+ }
+
+ if (_net_get_wifi_state(&Error) != WIFI_ON) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi is powered off!\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "pending call in progress\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+
+ request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag = TRUE;
+
+ if (wps_info->type == WIFI_WPS_PBC) {
+ /* Look How to change the use of Connman agent */
+ Error = _net_dbus_set_agent_wps_pbc();
+ if (NET_ERR_NONE != Error) {
+ WIFI_LOG(WIFI_ERROR,
+ "_net_dbus_set_agent_wps_pbc() failed\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+ } else if (wps_info->type == WIFI_WPS_PIN) {
+ Error = _net_dbus_set_agent_wps_pin(wps_info->pin);
+ if (NET_ERR_NONE != Error) {
+ WIFI_LOG(WIFI_ERROR,
+ "_net_dbus_set_agent_wps_pin() failed\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+ } else {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ if (wps_info->type == WIFI_WPS_PBC) {
+ Error = _net_dbus_open_connection_without_ssid();
+ } else if (wps_info->type == WIFI_WPS_PIN) {
+ Error = _net_dbus_open_pin_connection_without_ssid(wps_info->pin);
+ } else{
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR,
+ "Failed to request open connection, Error [%s]\n",
+ _net_print_error(Error));
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+ sizeof(network_request_table_s));
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+#endif
+
+int net_wifi_tdls_disconnect(const char* peer_mac_addr)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (peer_mac_addr == NULL) {
+ WIFI_LOG(WIFI_ERROR, "invalid parameter\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ Error = _net_dbus_tdls_disconnect(peer_mac_addr);
+
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, "_net_dbus_tdls_set_device_type failed\n");
+
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+
+}
+
+int net_wifi_tdls_connected_peer(char** peer_mac_addr)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (peer_mac_addr == NULL) {
+ WIFI_LOG(WIFI_ERROR, "invalid parameter\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ Error = _net_dbus_tdls_connected_peer(peer_mac_addr);
+
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, "net_wifi_tdls_connected_peer failed\n");
+
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+
+}
+
+int net_get_device_policy_wifi(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ int state = _net_get_dpm_wifi_state();
+ if (state == -1) {
+ net_err_e Error = _net_dbus_device_policy_get_wifi(&state);
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, "_net_dbus_device_policy_get_wifi failed\n");
+ else
+ _net_set_dpm_wifi_state(state);
+ }
+
+ WIFI_LOG(WIFI_INFO, "Wifi device policy state [%d]\n", state);
+
+ __NETWORK_FUNC_EXIT__;
+ return state;
+}
+
+int net_get_device_policy_wifi_profile(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ int state = _net_get_dpm_wifi_profile_state();
+ if (state == -1) {
+ net_err_e Error = _net_dbus_device_policy_get_wifi_profile(&state);
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, "_net_dbus_device_policy_get_wifi_profile failed\n");
+ else
+ _net_set_dpm_wifi_profile_state(state);
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return state;
+}
+//LCOV_EXCL_STOP
+
+int net_register_client_ext(net_event_cb event_cb, void *user_data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (event_cb == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid EventCb parameter"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
+ }
+
+ if (NetworkInfo.ClientEventCb_wifi != NULL) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi EventCb Already registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_ALREADY_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ if (NetworkInfo.ref_count < 1) {
+ Error = _net_register_signal();
+ if (Error != NET_ERR_NONE && Error != NET_ERR_APP_ALREADY_REGISTERED) {
+ WIFI_LOG(WIFI_ERROR, "Failed to register DBus signal [%s]", //LCOV_EXCL_LINE
+ _net_print_error(Error));
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ Error = _net_init_service_state_table();
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to init service state table [%s]", //LCOV_EXCL_LINE
+ _net_print_error(Error));
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+ }
+
+ NetworkInfo.ClientEventCb_wifi = event_cb;
+ NetworkInfo.user_data_wifi = user_data;
+
+ __sync_fetch_and_add(&NetworkInfo.ref_count, 1);
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+int net_deregister_client_ext()
+{
+ __NETWORK_FUNC_ENTER__;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ if (NetworkInfo.ClientEventCb_wifi == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi EventCb was not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ NetworkInfo.ClientEventCb_wifi = NULL;
+ NetworkInfo.user_data_wifi = NULL;
+
+ if (__sync_sub_and_fetch(&NetworkInfo.ref_count, 1) < 1) {
+ _net_deregister_signal();
+ _net_clear_request_table();
+ _net_client_callback_cleanup();
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+gboolean net_check_ref_count(void)
+{
+ if (NetworkInfo.ref_count > 0)
+ return TRUE;
+
+ return FALSE;
+}
+
+int net_open_connection(const char *profile_name)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ WIFI_LOG(WIFI_INFO, "Open: %s", profile_name);
+
+ if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Invalid profile name"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
+ }
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Request in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
+ }
+
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Pending call in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
+ }
+
+ request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag = TRUE;
+ g_strlcpy(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
+ profile_name, NET_PROFILE_NAME_LEN_MAX+1);
+
+ Error = _net_dbus_open_connection(profile_name);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "Failed to request open connection, Error [%s]",
+ _net_print_error(Error));
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], //LCOV_EXCL_LINE
+ 0, sizeof(network_request_table_s));
+
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+int net_close_connection(const char *profile_name)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ gboolean is_connecting = FALSE;
+
+ WIFI_LOG(WIFI_INFO, "ProfileName [%s] passed", profile_name);
+
+ if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Invalid profile name"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
+ }
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE) {
+ WIFI_LOG(WIFI_ERROR, "Request in progress"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
+ }
+
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ is_connecting = __net_is_connecting(profile_name);
+ if (is_connecting == FALSE) {
+ WIFI_LOG(WIFI_ERROR, "pending call in progress"); //LCOV_EXCL_LINE
+
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE
+ }
+ }
+
+ request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag = TRUE;
+ g_strlcpy(request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName,
+ profile_name, NET_PROFILE_NAME_LEN_MAX+1);
+
+ Error = _net_dbus_close_connection(profile_name);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "Failed to request close connection, Error [%s]",
+ _net_print_error(Error));
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION], //LCOV_EXCL_LINE
+ 0, sizeof(network_request_table_s));
+
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ if (is_connecting == TRUE)
+ __net_abort_open_connection(profile_name);
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+int net_delete_profile(const char* profile_name)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ net_profile_name_s wifi_prof_name;
+ net_profile_info_s prof_info;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ WIFI_LOG(WIFI_ERROR, "Delete Profile [%s]", profile_name);
+
+ if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Invalid Parameter"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
+ }
+
+ Error = __net_get_profile_info(profile_name, &prof_info);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "Failed to get service(profile) information. Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ g_strlcpy(wifi_prof_name.ProfileName, profile_name, NET_PROFILE_NAME_LEN_MAX + 1);
+
+ Error = __net_wifi_delete_profile(&wifi_prof_name,
+ prof_info.security_info.sec_mode,
+ prof_info.passpoint);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "Failed to delete service(profile). Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+int net_modify_profile(const char* profile_name, net_profile_info_s* prof_info)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ net_profile_info_s exProfInfo;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ if (!_net_get_dpm_wifi_state()) {
+ WIFI_LOG(WIFI_ERROR, "Wifi device policy restricts"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_SECURITY_RESTRICTED; //LCOV_EXCL_LINE
+ }
+
+ if (!_net_get_dpm_wifi_profile_state()) {
+ WIFI_LOG(WIFI_ERROR, "Wifi profile device policy restricts"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_SECURITY_RESTRICTED; //LCOV_EXCL_LINE
+ }
+
+ Error = net_get_profile_info(profile_name, &exProfInfo);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "Failed to get service(profile) information. Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ if (prof_info == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid Parameter\n"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
+ }
+
+
+ Error = __net_wifi_modify_profile(profile_name, prof_info, &exProfInfo);
+
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "Failed to modify service(profile) information. Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+int net_get_profile_info(const char *profile_name, net_profile_info_s *prof_info)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ if (prof_info == NULL ||
+ _net_check_profile_name(profile_name) != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Invalid Parameter"); //LCOV_EXCL_LINE
+
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
+ }
+
+ Error = __net_get_profile_info(profile_name, prof_info);
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "Failed to get service(profile) information. Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int net_get_profile_list(GSList **profile_list)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ Error = _net_get_profile_list(profile_list);
+
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "Failed to get service(profile) list. Error [%s]",
+ _net_print_error(Error));
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+int net_get_technology_properties(net_tech_info_s *tech_info)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ if ((Error = _net_dbus_get_tech_status(tech_info)) != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get technology status. Error [%s]", //LCOV_EXCL_LINE
+ _net_print_error(Error));
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+int net_config_get_id_list(GSList **list)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ Error = _net_dbus_config_get_id_list(list);
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "Failed to get config id list. Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int net_config_set_field(const gchar *config_id, const gchar *key, const gchar *value)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ Error = _net_dbus_config_set_field(config_id, key, value);
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR,
+ "Failed to set field. Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int net_config_get_passphrase(const gchar *config_id, gchar **passphrase)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ Error = _net_dbus_config_get_passphrase(config_id, passphrase);
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "Failed to get config id list. Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int net_config_save_configurations(const gchar *config_id, const gchar *name,
+ const gchar *ssid, const gchar *passphrase, const gchar *proxy_address, gboolean is_hidden)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ Error = _net_dbus_config_save_configurations(config_id,
+ name, ssid, passphrase, proxy_address, is_hidden);
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "Failed to save configurations. Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+//LCOV_EXCL_START
+int net_config_save_eap_configurations(const gchar *config_id,
+ const gchar *name, const gchar *ssid, const gchar *passphrase,
+ const gchar *proxy_address, void *eap_config, gboolean is_hidden)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ net_eap_config_s *net_eap_config = (net_eap_config_s *)eap_config;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ Error = _net_dbus_config_save_eap_configurations(config_id,
+ name, ssid, passphrase, proxy_address, net_eap_config, is_hidden);
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR,
+ "Failed to save configurations. Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+//LCOV_EXCL_STOP
+
+int net_config_remove_configurations(const gchar *config_id)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ Error = _net_dbus_config_remove_configurations(config_id);
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "Failed to remove configurations. Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int net_config_load_configurations(const gchar *config_id, gchar **name,
+ void *security_type, gchar **proxy_address, gboolean *is_hidden, void *last_error)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ net_wifi_security_type_e *sec_type = (net_wifi_security_type_e *)security_type;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ Error = _net_dbus_config_load_configurations(config_id, name, sec_type,
+ proxy_address, is_hidden, last_error);
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
+ "Failed to load configurations. Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+//LCOV_EXCL_START
+int net_config_load_eap_configurations(const gchar *config_id,
+ gchar **name, void *security_type, gchar **proxy_address,
+ gboolean *is_hidden, void **eap_config, void *last_error)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ net_eap_config_s **net_eap_config = (net_eap_config_s **)eap_config;
+ net_wifi_security_type_e *sec_type = (net_wifi_security_type_e *)security_type;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ Error = _net_dbus_config_load_eap_configurations(config_id, name, sec_type,
+ proxy_address, is_hidden, net_eap_config, last_error);
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR,
+ "Failed to load eap configurations. Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+//LCOV_EXCL_STOP
+
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlfcn.h>
+
+#include "wifi_internal.h"
+#include "network_internal.h"
+#include "network_dbus.h"
+
+typedef struct {
+ GDBusConnection *connection;
+ int conn_ref_count;
+ GCancellable *cancellable;
+ void *handle_libnetwork;
+} gdbus_connection_data_s;
+
+typedef struct {
+ GSourceFunc func;
+ gpointer user_data;
+ guint id;
+} managed_idle_data_s;
+
+extern __thread network_info_s NetworkInfo;
+__thread network_request_table_s request_table[NETWORK_REQUEST_TYPE_MAX] = { { 0, }, };
+
+static __thread gdbus_connection_data_s gdbus_conn = { NULL, 0, NULL, NULL };
+static __thread GSList *managed_idler_list = NULL;
+
+//LCOV_EXCL_START
+static char *__convert_eap_type_to_string(gchar eap_type)
+{
+ switch (eap_type) {
+ case WLAN_SEC_EAP_TYPE_PEAP:
+ return "peap";
+
+ case WLAN_SEC_EAP_TYPE_TLS:
+ return "tls";
+
+ case WLAN_SEC_EAP_TYPE_TTLS:
+ return "ttls";
+
+ case WLAN_SEC_EAP_TYPE_SIM:
+ return "sim";
+
+ case WLAN_SEC_EAP_TYPE_AKA:
+ return "aka";
+
+ default:
+ return NULL;
+ }
+}
+
+static char *__convert_eap_auth_to_string(gchar eap_auth)
+{
+ switch (eap_auth) {
+ case WLAN_SEC_EAP_AUTH_NONE:
+ return "NONE";
+
+ case WLAN_SEC_EAP_AUTH_PAP:
+ return "PAP";
+
+ case WLAN_SEC_EAP_AUTH_MSCHAP:
+ return "MSCHAP";
+
+ case WLAN_SEC_EAP_AUTH_MSCHAPV2:
+ return "MSCHAPV2";
+
+ case WLAN_SEC_EAP_AUTH_GTC:
+ return "GTC";
+
+ case WLAN_SEC_EAP_AUTH_MD5:
+ return "MD5";
+
+ default:
+ return NULL;
+ }
+}
+
+static char *__convert_eap_keymgmt_type_to_string(gchar eap_keymgmt)
+{
+ switch (eap_keymgmt) {
+ case WLAN_SEC_EAP_KEYMGMT_FT:
+ return "FT";
+
+ case WLAN_SEC_EAP_KEYMGMT_CCKM:
+ return "CCKM";
+
+ case WLAN_SEC_EAP_KEYMGMT_OKC:
+ return "OKC";
+
+ default:
+ return NULL;
+ }
+}
+
+char* _net_print_error(net_err_e error)
+{
+ switch (error) {
+ case NET_ERR_NONE:
+ return "NET_ERR_NONE";
+
+ case NET_ERR_UNKNOWN:
+ return "NET_ERR_UNKNOWN";
+
+ case NET_ERR_APP_ALREADY_REGISTERED:
+ return "NET_ERR_APP_ALREADY_REGISTERED";
+ case NET_ERR_APP_NOT_REGISTERED:
+ return "NET_ERR_APP_NOT_REGISTERED";
+
+ case NET_ERR_NO_ACTIVE_CONNECTIONS:
+ return "NET_ERR_NO_ACTIVE_CONNECTIONS";
+ case NET_ERR_ACTIVE_CONNECTION_EXISTS:
+ return "NET_ERR_ACTIVE_CONNECTION_EXISTS";
+ case NET_ERR_CONNECTION_OUT_OF_RANGE:
+ return "NET_ERR_CONNECTION_OUT_OF_RANGE";
+ case NET_ERR_CONNECTION_PIN_MISSING:
+ return "NET_ERR_CONNECTION_PIN_MISSING";
+ case NET_ERR_CONNECTION_DHCP_FAILED:
+ return "NET_ERR_CONNECTION_DHCP_FAILED";
+ case NET_ERR_CONNECTION_CONNECT_FAILED:
+ return "NET_ERR_CONNECTION_CONNECT_FAILED";
+ case NET_ERR_CONNECTION_LOGIN_FAILED:
+ return "NET_ERR_CONNECTION_LOGIN_FAILED";
+ case NET_ERR_CONNECTION_AUTH_FAILED:
+ return "NET_ERR_CONNECTION_AUTH_FAILED";
+ case NET_ERR_CONNECTION_INVALID_KEY:
+ return "NET_ERR_CONNECTION_INVALID_KEY";
+
+ case NET_ERR_ACCESS_DENIED:
+ return "NET_ERR_ACCESS_DENIED";
+ case NET_ERR_IN_PROGRESS:
+ return "NET_ERR_IN_PROGRESS";
+ case NET_ERR_OPERATION_ABORTED:
+ return "NET_ERR_OPERATION_ABORTED";
+ case NET_ERR_INVALID_PARAM:
+ return "NET_ERR_INVALID_PARAM";
+ case NET_ERR_INVALID_OPERATION:
+ return "NET_ERR_INVALID_OPERATION";
+ case NET_ERR_NOT_SUPPORTED:
+ return "NET_ERR_NOT_SUPPORTED";
+ case NET_ERR_TIME_OUT:
+ return "NET_ERR_TIME_OUT";
+ case NET_ERR_NO_SERVICE:
+ return "NET_ERR_NO_SERVICE";
+ case NET_ERR_UNKNOWN_METHOD:
+ return "NET_ERR_UNKNOWN_METHOD";
+ case NET_ERR_SECURITY_RESTRICTED:
+ return "NET_ERR_SECURITY_RESTRICTED";
+ case NET_ERR_WIFI_DRIVER_FAILURE:
+ return "NET_ERR_WIFI_DRIVER_FAILURE";
+ default:
+ return "INVALID";
+ }
+}
+
+int _net_get_tech_state(GVariant *msg, network_tech_state_info_s* tech_state)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariantIter *iter_main = NULL;
+ GVariantIter *var = NULL;
+ GVariant *value = NULL;
+ gchar *tech_prefix;
+ gchar *path = NULL;
+ gchar *key = NULL;
+ gboolean data;
+
+ tech_prefix = CONNMAN_WIFI_TECHNOLOGY_PREFIX;
+
+ g_variant_get(msg, "(a(oa{sv}))", &iter_main);
+ while (g_variant_iter_loop(iter_main, "(oa{sv})", &path, &var)) {
+
+ if (path == NULL || g_strcmp0(path, tech_prefix) != 0)
+ continue;
+
+ while (g_variant_iter_loop(var, "{sv}", &key, &value)) {
+ if (g_strcmp0(key, "Powered") == 0) {
+ data = g_variant_get_boolean(value);
+
+ if (data)
+ tech_state->Powered = TRUE;
+ else
+ tech_state->Powered = FALSE;
+ } else if (g_strcmp0(key, "Connected") == 0) {
+ data = g_variant_get_boolean(value);
+
+ if (data)
+ tech_state->Connected = TRUE;
+ else
+ tech_state->Connected = FALSE;
+ } else if (g_strcmp0(key, "Tethering") == 0) {
+ /* For further use */
+ }
+ }
+ }
+ g_variant_iter_free(iter_main);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+/** This function is used only to open Wi-Fi connection with hidden APs */
+int _net_open_connection_with_wifi_info(const net_wifi_connection_info_s* wifi_info)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ net_wifi_connect_service_info_t wifi_connection_info;
+ memset(&wifi_connection_info, 0, sizeof(net_wifi_connect_service_info_t));
+
+ wifi_connection_info.type = "wifi";
+
+ if (wifi_info->wlan_mode == NET_WLAN_CONNMODE_ADHOC)
+ wifi_connection_info.mode = "adhoc";
+ else
+ wifi_connection_info.mode = "managed";
+
+ wifi_connection_info.ssid = (char *)wifi_info->essid;
+
+ wifi_connection_info.is_hidden = wifi_info->is_hidden;
+
+ switch (wifi_info->security_info.sec_mode) {
+ case WLAN_SEC_MODE_NONE:
+ wifi_connection_info.security = "none";
+ break;
+
+ case WLAN_SEC_MODE_WEP:
+ wifi_connection_info.security = "wep";
+ wifi_connection_info.passphrase =
+ (char *)wifi_info->security_info.authentication.wep.wepKey;
+ break;
+
+ /** WPA-PSK(equivalent to WPA-NONE in case of Ad-Hoc) */
+ case WLAN_SEC_MODE_WPA_PSK:
+ wifi_connection_info.security = "psk";
+ wifi_connection_info.passphrase =
+ (char *)wifi_info->security_info.authentication.psk.pskKey;
+ break;
+
+ /** WPA2-PSK */
+ /** WPA-PSK / WPA2-PSK supported */
+ case WLAN_SEC_MODE_WPA2_PSK:
+ wifi_connection_info.security = "rsn";
+ wifi_connection_info.passphrase =
+ (char *)wifi_info->security_info.authentication.psk.pskKey;
+ break;
+ case WLAN_SEC_MODE_WPA_FT_PSK:
+ wifi_connection_info.security = "ft_psk";
+ wifi_connection_info.passphrase =
+ (char *)wifi_info->security_info.authentication.psk.pskKey;
+ break;
+
+
+
+ case WLAN_SEC_MODE_IEEE8021X:
+ wifi_connection_info.security = "ieee8021x";
+
+ wifi_connection_info.eap_type =
+ __convert_eap_type_to_string(
+ wifi_info->security_info.authentication.eap.eap_type);
+ wifi_connection_info.eap_auth =
+ __convert_eap_auth_to_string(
+ wifi_info->security_info.authentication.eap.eap_auth);
+ wifi_connection_info.eap_keymgmt_type =
+ __convert_eap_keymgmt_type_to_string(
+ wifi_info->security_info.authentication.eap.eap_keymgmt_type);
+
+ if (wifi_info->security_info.authentication.eap.username[0] != '\0')
+ wifi_connection_info.identity =
+ (char *)wifi_info->security_info.authentication.eap.username;
+
+ if (wifi_info->security_info.authentication.eap.password[0] != '\0')
+ wifi_connection_info.password =
+ (char *)wifi_info->security_info.authentication.eap.password;
+
+ if (wifi_info->security_info.authentication.eap.ca_cert_filename[0] != '\0')
+ wifi_connection_info.ca_cert_file =
+ (char *)wifi_info->security_info.authentication.eap.ca_cert_filename;
+
+ if (wifi_info->security_info.authentication.eap.client_cert_filename[0] != '\0')
+ wifi_connection_info.client_cert_file =
+ (char *)wifi_info->security_info.authentication.eap.client_cert_filename;
+
+ if (wifi_info->security_info.authentication.eap.private_key_filename[0] != '\0')
+ wifi_connection_info.private_key_file =
+ (char *)wifi_info->security_info.authentication.eap.private_key_filename;
+
+ if (wifi_info->security_info.authentication.eap.private_key_passwd[0] != '\0')
+ wifi_connection_info.private_key_password =
+ (char *)wifi_info->security_info.authentication.eap.private_key_passwd;
+ break;
+
+ default:
+ WIFI_LOG(WIFI_ERROR, "Invalid security type");
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ Error = _net_dbus_connect_service(&wifi_connection_info);
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, "Failed to request connect service. Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+static gboolean __net_client_cb_wifi_idle(gpointer data)
+{
+ net_event_info_s *event_data = (net_event_info_s *)data;
+
+ if (NetworkInfo.ClientEventCb_wifi != NULL)
+ NetworkInfo.ClientEventCb_wifi(event_data, NetworkInfo.user_data_wifi);
+
+ if (event_data->Datalength > 0)
+ g_free(event_data->Data);
+
+ g_free(event_data);
+
+ return FALSE;
+}
+
+void _net_client_callback(net_event_info_s *event_data)
+{
+ guint id;
+
+ __NETWORK_FUNC_ENTER__;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered. "
+ "If multi-threaded, thread integrity be broken.");
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ if (NetworkInfo.ClientEventCb_wifi != NULL) {
+ net_event_info_s *client = g_try_new0(net_event_info_s, 1);
+ if (client == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ memcpy(client, event_data, sizeof(net_event_info_s));
+ if (event_data->Datalength > 0) {
+ if (event_data->Event == NET_EVENT_WIFI_SPECIFIC_SCAN_IND ||
+ event_data->Event == NET_EVENT_WIFI_WPS_SCAN_IND) {
+ client->Data = g_try_malloc0(sizeof(GSList));
+ if (client->Data == NULL) {
+ g_free(client);
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ memcpy(client->Data, event_data->Data, sizeof(GSList));
+ } else {
+ client->Data = g_try_malloc0(event_data->Datalength);
+ if (client->Data == NULL) {
+ g_free(client);
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ memcpy(client->Data, event_data->Data, event_data->Datalength);
+ }
+ } else {
+ client->Datalength = 0;
+ client->Data = NULL;
+ }
+
+ id = _net_client_callback_add(__net_client_cb_wifi_idle, (gpointer)client);
+ if (!id) {
+ if (client->Datalength > 0)
+ g_free(client->Data);
+
+ g_free(client);
+ }
+ }
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+net_wifi_state_e _net_get_wifi_state(net_err_e *net_error)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ network_tech_state_info_s tech_state = { { 0, }, };
+ net_wifi_state_e wifi_state = WIFI_UNKNOWN;
+
+ g_strlcpy(tech_state.technology, "wifi", NET_TECH_LENGTH_MAX);
+ Error = _net_dbus_get_technology_state(&tech_state);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR,
+ "_net_dbus_get_technology_state() failed. Error [%s]",
+ _net_print_error(Error));
+ *net_error = Error;
+ goto state_done;
+ }
+
+ if (tech_state.Powered == TRUE)
+ wifi_state = WIFI_ON;
+ else
+ wifi_state = WIFI_OFF;
+
+state_done:
+ __NETWORK_FUNC_EXIT__;
+ return wifi_state;
+}
+
+static void __net_client_idle_destroy_cb(gpointer data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ if (!data) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ managed_idler_list = g_slist_remove(managed_idler_list, data);
+ g_free(data);
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+static gboolean __net_client_idle_cb(gpointer user_data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ managed_idle_data_s *data = (managed_idle_data_s *)user_data;
+
+ if (!data) {
+ __NETWORK_FUNC_EXIT__;
+ return FALSE;
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return data->func(data->user_data);
+}
+
+guint _net_client_callback_add(GSourceFunc func, gpointer user_data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ guint id;
+ managed_idle_data_s *data;
+ GMainContext *context;
+ GSource *src;
+
+ if (!func) {
+ __NETWORK_FUNC_EXIT__;
+ return 0;
+ }
+
+ data = g_try_new0(managed_idle_data_s, 1);
+ if (!data) {
+ __NETWORK_FUNC_EXIT__;
+ return 0;
+ }
+
+ data->func = func;
+ data->user_data = user_data;
+
+ context = g_main_context_get_thread_default();
+ src = g_idle_source_new();
+ g_source_set_callback(src, __net_client_idle_cb, data,
+ __net_client_idle_destroy_cb);
+ id = g_source_attach(src, context);
+ g_source_unref(src);
+ if (!id) {
+ g_free(data);
+ __NETWORK_FUNC_EXIT__;
+ return id;
+ }
+
+ data->id = id;
+
+ managed_idler_list = g_slist_append(managed_idler_list, data);
+
+ __NETWORK_FUNC_EXIT__;
+ return id;
+}
+
+void _net_client_callback_cleanup(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GSList *cur = managed_idler_list;
+ GSource *src;
+ managed_idle_data_s *data;
+
+ while (cur) {
+ GSList *next = cur->next;
+ data = (managed_idle_data_s *)cur->data;
+
+ src = g_main_context_find_source_by_id(g_main_context_default(), data->id);
+ if (src) {
+ g_source_destroy(src);
+ cur = managed_idler_list;
+ } else
+ cur = next;
+ }
+
+ g_slist_free(managed_idler_list);
+ managed_idler_list = NULL;
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+void _net_clear_request_table(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ int i;
+
+ for (i = 0; i < NETWORK_REQUEST_TYPE_MAX; i++)
+ memset(&request_table[i], 0, sizeof(network_request_table_s));
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+gboolean _net_dbus_is_pending_call_used(void)
+{
+ if (gdbus_conn.conn_ref_count > 0)
+ return TRUE;
+
+ return FALSE;
+}
+
+void _net_dbus_pending_call_ref(void)
+{
+ g_object_ref(gdbus_conn.connection);
+
+ __sync_fetch_and_add(&gdbus_conn.conn_ref_count, 1);
+}
+
+void _net_dbus_pending_call_unref(void)
+{
+ if (gdbus_conn.conn_ref_count < 1)
+ return;
+
+ g_object_unref(gdbus_conn.connection);
+
+ if (__sync_sub_and_fetch(&gdbus_conn.conn_ref_count, 1) < 1 &&
+ gdbus_conn.handle_libnetwork != NULL) {
+ WIFI_LOG(WIFI_ERROR, "A handle of libnetwork is not NULL");
+
+ gdbus_conn.connection = NULL;
+ }
+}
+
+int _net_dbus_create_gdbus_call(void)
+{
+ GError *error = NULL;
+
+ if (gdbus_conn.connection != NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_ALREADY_REGISTERED;
+ }
+
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
+#endif
+
+ gdbus_conn.connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (gdbus_conn.connection == NULL) {
+ if (error != NULL) {
+ WIFI_LOG(WIFI_ERROR,
+ "Failed to connect to the D-BUS daemon [%s]", error->message);
+ g_error_free(error);
+ }
+ return NET_ERR_UNKNOWN;
+ }
+
+ gdbus_conn.cancellable = g_cancellable_new();
+
+ if (gdbus_conn.handle_libnetwork != NULL) {
+ WIFI_LOG(WIFI_ERROR,
+ "A handle of libnetwork is not NULL and should be released");
+
+ dlclose(gdbus_conn.handle_libnetwork);
+ gdbus_conn.handle_libnetwork = NULL;
+ }
+
+ return NET_ERR_NONE;
+}
+
+int _net_dbus_close_gdbus_call(void)
+{
+ g_cancellable_cancel(gdbus_conn.cancellable);
+ g_object_unref(gdbus_conn.cancellable);
+ gdbus_conn.cancellable = NULL;
+
+ if (gdbus_conn.conn_ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "There is no pending call");
+
+ g_object_unref(gdbus_conn.connection);
+ gdbus_conn.connection = NULL;
+ } else {
+ WIFI_LOG(WIFI_ERROR,
+ "There are %d pending calls, waiting to be cleared",
+ gdbus_conn.conn_ref_count);
+
+ if (gdbus_conn.handle_libnetwork != NULL)
+ WIFI_LOG(WIFI_ERROR, "A handle of libnetwork is not NULL");
+
+ gdbus_conn.handle_libnetwork = dlopen("/usr/lib/libnetwork.so", RTLD_LAZY);
+
+ g_object_unref(gdbus_conn.connection);
+ }
+
+ return NET_ERR_NONE;
+}
+
+GDBusConnection *_net_dbus_get_gdbus_conn(void)
+{
+ return gdbus_conn.connection;
+}
+
+GCancellable *_net_dbus_get_gdbus_cancellable(void)
+{
+ return gdbus_conn.cancellable;
+}
+//LCOV_EXCL_STOP
+
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "wifi_internal.h"
+#include "network_internal.h"
+#include "network_dbus.h"
+#include "network_signal.h"
+
+extern __thread network_info_s NetworkInfo;
+extern __thread network_request_table_s request_table[NETWORK_REQUEST_TYPE_MAX];
+
+static __thread net_state_type_e service_state_table = NET_STATE_TYPE_UNKNOWN;
+static __thread int net_service_error = NET_ERR_NONE;
+static __thread guint gdbus_conn_subscribe_id_connman_state = 0;
+static __thread guint gdbus_conn_subscribe_id_connman_error = 0;
+static __thread guint gdbus_conn_subscribe_id_supplicant = 0;
+static __thread guint gdbus_conn_subscribe_id_netconfig_wifi = 0;
+static __thread guint gdbus_conn_subscribe_id_netconfig = 0;
+static __thread int net_dpm_wifi_state = -1;
+static __thread int net_dpm_wifi_profile_state = -1;
+
+//LCOV_EXCL_START
+static int string2state(const char *state)
+{
+ if (g_strcmp0(state, "idle") == 0)
+ return NET_STATE_TYPE_IDLE;
+ else if (g_strcmp0(state, "association") == 0)
+ return NET_STATE_TYPE_ASSOCIATION;
+ else if (g_strcmp0(state, "configuration") == 0)
+ return NET_STATE_TYPE_CONFIGURATION;
+ else if (g_strcmp0(state, "ready") == 0)
+ return NET_STATE_TYPE_READY;
+ else if (g_strcmp0(state, "online") == 0)
+ return NET_STATE_TYPE_ONLINE;
+ else if (g_strcmp0(state, "disconnect") == 0)
+ return NET_STATE_TYPE_DISCONNECT;
+ else if (g_strcmp0(state, "failure") == 0)
+ return NET_STATE_TYPE_FAILURE;
+
+ return NET_STATE_TYPE_UNKNOWN;
+}
+
+static int string2error(const char *error)
+{
+ if (g_strcmp0(error, "out-of-range") == 0)
+ return NET_ERR_CONNECTION_OUT_OF_RANGE;
+ else if (g_strcmp0(error, "pin-missing") == 0)
+ return NET_ERR_CONNECTION_PIN_MISSING;
+ else if (g_strcmp0(error, "dhcp-failed") == 0)
+ return NET_ERR_CONNECTION_DHCP_FAILED;
+ else if (g_strcmp0(error, "connect-failed") == 0)
+ return NET_ERR_CONNECTION_CONNECT_FAILED;
+ else if (g_strcmp0(error, "login-failed") == 0)
+ return NET_ERR_CONNECTION_LOGIN_FAILED;
+ else if (g_strcmp0(error, "auth-failed") == 0)
+ return NET_ERR_CONNECTION_AUTH_FAILED;
+ else if (g_strcmp0(error, "invalid-key") == 0)
+ return NET_ERR_CONNECTION_INVALID_KEY;
+
+ return NET_ERR_UNKNOWN;
+}
+
+static int __net_handle_wifi_power_rsp(gboolean value)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_event_info_s event_data = { 0, };
+
+ if (value == TRUE) {
+ NetworkInfo.wifi_state = WIFI_ON;
+ event_data.Error = NET_ERR_NONE;
+ } else {
+ NetworkInfo.wifi_state = WIFI_OFF;
+ event_data.Error = NET_ERR_NONE;
+
+ if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE)
+ memset(&request_table[NETWORK_REQUEST_TYPE_SCAN],
+ 0, sizeof(network_request_table_s));
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER],
+ 0, sizeof(network_request_table_s));
+
+ event_data.Event = NET_EVENT_WIFI_POWER_RSP;
+ WIFI_LOG(WIFI_INFO, "NET_EVENT_WIFI_POWER_RSP wifi state: %d",
+ NetworkInfo.wifi_state);
+
+ _net_dbus_pending_call_unref();
+ } else {
+ event_data.Event = NET_EVENT_WIFI_POWER_IND;
+ WIFI_LOG(WIFI_INFO, "NET_EVENT_WIFI_POWER_IND wifi state: %d",
+ NetworkInfo.wifi_state);
+ }
+
+ event_data.Datalength = sizeof(net_wifi_state_e);
+ event_data.Data = &(NetworkInfo.wifi_state);
+
+ _net_client_callback(&event_data);
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+static wlan_security_mode_type_e __net_get_wlan_sec_mode(int security)
+{
+ switch (security) {
+ case 2:
+ return WLAN_SEC_MODE_WEP;
+ case 3:
+ return WLAN_SEC_MODE_WPA_PSK;
+ case 4:
+ return WLAN_SEC_MODE_IEEE8021X;
+ default:
+ return WLAN_SEC_MODE_NONE;
+ }
+}
+
+static int __net_handle_specific_scan_resp(GSList *bss_info_list)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ int count = 0;;
+ net_event_info_s event_data = { 0, };
+
+ if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN],
+ 0, sizeof(network_request_table_s));
+
+ _net_dbus_pending_call_unref();
+
+ count = (int)g_slist_length(bss_info_list);
+ WIFI_LOG(WIFI_INFO,
+ "Received the signal: %s with total bss count = %d",
+ NETCONFIG_SIGNAL_SPECIFIC_SCAN_DONE,
+ count);
+
+ event_data.Event = NET_EVENT_WIFI_SPECIFIC_SCAN_IND;
+ event_data.Datalength = count;
+ event_data.Data = bss_info_list;
+
+ _net_client_callback(&event_data);
+ } else
+ g_slist_free_full(bss_info_list, g_free);
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+static int __net_handle_wifi_specific_scan_rsp(GVariant *param)
+{
+ GVariantIter *iter = NULL;
+ GVariant *value = NULL;
+ gchar *key = NULL;
+ const gchar *ssid = NULL;
+ gint32 security = 0;
+ gboolean wps = FALSE;
+ GSList *bss_info_list = NULL;
+ gboolean ssid_found = FALSE;
+ gboolean sec_found = FALSE;
+ gboolean wps_found = FALSE;
+
+ g_variant_get(param, "(a{sv})", &iter);
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ if (g_strcmp0(key, "ssid") == 0 && ssid_found == FALSE) {
+ ssid = g_variant_get_string(value, NULL);
+ WIFI_LOG(WIFI_INFO, "SSID: %s", ssid);
+ ssid_found = TRUE;
+ }
+ if (g_strcmp0(key, "security") == 0 && sec_found == FALSE) {
+ security = g_variant_get_int32(value);
+ WIFI_LOG(WIFI_INFO, "with security: %d", security);
+ sec_found = TRUE;
+ }
+ if (g_strcmp0(key, "wps") == 0 && wps_found == FALSE) {
+ wps = g_variant_get_boolean(value);
+ WIFI_LOG(WIFI_INFO, "wps supported: %d", wps);
+ wps_found = TRUE;
+ }
+
+ if (ssid_found == TRUE && sec_found == TRUE && wps_found == TRUE) {
+ net_ssid_scan_bss_info_s *bss = NULL;
+ bss = g_try_new0(net_ssid_scan_bss_info_s, 1);
+ if (bss == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Memory allocation error");
+
+ g_slist_free_full(bss_info_list, g_free);
+ g_variant_unref(value);
+ g_free(key);
+ return NET_ERR_UNKNOWN;
+ }
+
+ g_strlcpy(bss->ssid, ssid, NET_WLAN_ESSID_LEN);
+ bss->security = __net_get_wlan_sec_mode(security);
+ bss->wps = (char)wps;
+ bss_info_list = g_slist_append(bss_info_list, bss);
+
+ ssid_found = sec_found = wps_found = FALSE;
+ }
+ }
+ g_variant_iter_free(iter);
+
+ __net_handle_specific_scan_resp(bss_info_list);
+
+ /* To enhance performance,
+ * BSS list should be release in a delayed manner in _net_client_callback */
+
+ return NET_ERR_NONE;
+}
+
+static int __net_handle_wps_scan_resp(GSList *bss_info_list)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ int count = 0;;
+ net_event_info_s event_data = { 0, };
+
+ if (request_table[NETWORK_REQUEST_TYPE_WPS_SCAN].flag == TRUE) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_WPS_SCAN],
+ 0, sizeof(network_request_table_s));
+
+ _net_dbus_pending_call_unref();
+
+ count = (int)g_slist_length(bss_info_list);
+ WIFI_LOG(WIFI_INFO,
+ "Received the signal: %s with total bss count = %d",
+ NETCONFIG_SIGNAL_WPS_SCAN_DONE,
+ count);
+
+ event_data.Event = NET_EVENT_WIFI_WPS_SCAN_IND;
+ event_data.Datalength = count;
+ event_data.Data = bss_info_list;
+
+ _net_client_callback(&event_data);
+ } else
+ g_slist_free_full(bss_info_list, g_free);
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+static int __net_handle_wifi_wps_scan_rsp(GVariant *param)
+{
+ GVariantIter *iter = NULL;
+ GVariant *value = NULL;
+ gchar *key = NULL;
+ GSList *bss_info_list = NULL;
+ const gchar *ssid = NULL;
+ const gchar *bssid = NULL;
+ gsize ssid_len;
+ int rssi = -89;
+ int mode = 0;
+ gboolean ssid_found = FALSE;
+ gboolean bssid_found = FALSE;
+ gboolean rssi_found = FALSE;
+ gboolean mode_found = FALSE;
+
+ g_variant_get(param, "(a{sv})", &iter);
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ if (g_strcmp0(key, "ssid") == 0) {
+ ssid = g_variant_get_fixed_array(value, &ssid_len, sizeof(guchar));
+ ssid_found = TRUE;
+ } else if (g_strcmp0(key, "bssid") == 0) {
+ bssid = g_variant_get_string(value, NULL);
+ bssid_found = TRUE;
+ } else if (g_strcmp0(key, "rssi") == 0) {
+ rssi = g_variant_get_int32(value);
+ rssi_found = TRUE;
+ } else if (g_strcmp0(key, "mode") == 0) {
+ mode = g_variant_get_int32(value);
+ mode_found = TRUE;
+ }
+
+ if (ssid_found == TRUE && bssid_found == TRUE &&
+ rssi_found == TRUE && mode_found == TRUE) {
+ net_wps_scan_bss_info_s *bss = NULL;
+ bss = g_try_new0(net_wps_scan_bss_info_s, 1);
+ if (bss == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Memory allocation error");
+
+ g_slist_free_full(bss_info_list, g_free);
+ g_variant_unref(value);
+ g_free(key);
+ return NET_ERR_UNKNOWN;
+ }
+
+ memcpy(bss->ssid, ssid, ssid_len);
+ g_strlcpy(bss->bssid, bssid, NET_WLAN_BSSID_LEN+1);
+ bss->rssi = rssi;
+ bss->mode = mode;
+ bss_info_list = g_slist_append(bss_info_list, bss);
+
+ ssid_found = bssid_found = FALSE;
+ rssi_found = mode_found = FALSE;
+ }
+ }
+ g_variant_iter_free(iter);
+
+ __net_handle_wps_scan_resp(bss_info_list);
+
+ return NET_ERR_NONE;
+}
+
+static void __net_handle_state_ind(const char *profile_name,
+ net_state_type_e profile_state)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_event_info_s event_data = { 0, };
+
+ event_data.Error = NET_ERR_NONE;
+ event_data.Event = NET_EVENT_NET_STATE_IND;
+
+ g_strlcpy(event_data.ProfileName, profile_name, sizeof(event_data.ProfileName));
+
+ event_data.Datalength = sizeof(net_state_type_e);
+ event_data.Data = &profile_state;
+
+ WIFI_LOG(WIFI_INFO,
+ "Sending NET_EVENT_NET_STATE_IND, state: %d, profile name: %s",
+ profile_state, event_data.ProfileName);
+
+ _net_client_callback(&event_data);
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+static void __net_handle_failure_ind(const char *profile_name)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_event_info_s event_data = { 0, };
+
+ const char *svc_name1 =
+ request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
+ const char *svc_name2 =
+ request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
+ const char *svc_name3 =
+ request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName;
+
+ if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
+ strstr(profile_name, svc_name1) != NULL) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
+ sizeof(network_request_table_s));
+
+ event_data.Event = NET_EVENT_OPEN_RSP;
+
+ _net_dbus_pending_call_unref();
+ } else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
+ g_strcmp0(profile_name, svc_name2) == 0) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+ sizeof(network_request_table_s));
+
+ event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION], 0,
+ sizeof(network_request_table_s));
+
+ _net_dbus_pending_call_unref();
+ } else if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE &&
+ g_strcmp0(profile_name, svc_name3) == 0) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION], 0,
+ sizeof(network_request_table_s));
+
+ event_data.Event = NET_EVENT_CLOSE_RSP;
+
+ _net_dbus_pending_call_unref();
+ } else {
+ __net_handle_state_ind(profile_name, NET_STATE_TYPE_FAILURE);
+
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ g_strlcpy(event_data.ProfileName,
+ profile_name, NET_PROFILE_NAME_LEN_MAX+1);
+
+ if (net_service_error != NET_ERR_NONE)
+ event_data.Error = net_service_error;
+ else {
+ event_data.Error = NET_ERR_CONNECTION_CONNECT_FAILED;
+ WIFI_LOG(WIFI_ERROR, "Event error defined %d", event_data.Error);
+ }
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+
+ net_service_error = NET_ERR_NONE;
+
+ WIFI_LOG(WIFI_ERROR, "State failure %d", event_data.Error);
+ _net_client_callback(&event_data);
+
+ /* Reseting the state back in case of failure state */
+ service_state_table = NET_STATE_TYPE_IDLE;
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+static int __net_handle_service_state_changed(const gchar *sig_path,
+ const char *key, const char *state)
+{
+ net_err_e Error = NET_ERR_NONE;
+ net_state_type_e old_state, new_state;
+
+ net_event_info_s event_data = { 0, };
+
+ if (sig_path == NULL)
+ return Error;
+
+ WIFI_LOG(WIFI_INFO, "[%s] %s", state, sig_path);
+
+ if (NetworkInfo.wifi_state == WIFI_OFF) {
+ WIFI_LOG(WIFI_INFO, "Wi-Fi is off");
+ return Error;
+ }
+
+ old_state = service_state_table;
+ new_state = string2state(state);
+
+ if (old_state == new_state)
+ return Error;
+
+ service_state_table = new_state;
+
+ switch (new_state) {
+ case NET_STATE_TYPE_IDLE:
+ if (NetworkInfo.wifi_state == WIFI_CONNECTED)
+ NetworkInfo.wifi_state = WIFI_ON;
+ case NET_STATE_TYPE_ASSOCIATION:
+ case NET_STATE_TYPE_CONFIGURATION:
+ __net_handle_state_ind(sig_path, new_state);
+ break;
+
+ case NET_STATE_TYPE_READY:
+ case NET_STATE_TYPE_ONLINE:
+ {
+ if (old_state != NET_STATE_TYPE_READY &&
+ old_state != NET_STATE_TYPE_ONLINE) {
+ const char *svc_name1 =
+ request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
+ const char *svc_name2 =
+ request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
+
+ if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
+ strstr(sig_path, svc_name1) != NULL) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
+ sizeof(network_request_table_s));
+
+ event_data.Event = NET_EVENT_OPEN_RSP;
+
+ WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_OPEN_RSP");
+
+ _net_dbus_pending_call_unref();
+ } else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
+ g_strcmp0(sig_path, svc_name2) == 0) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+ sizeof(network_request_table_s));
+
+ event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+
+ WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_WIFI_WPS_RSP");
+
+ _net_dbus_pending_call_unref();
+ } else {
+ event_data.Event = NET_EVENT_OPEN_IND;
+
+ WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_OPEN_IND");
+ }
+
+ net_profile_info_s prof_info;
+ if ((Error = net_get_profile_info(sig_path, &prof_info)) != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "net_get_profile_info() failed [%s]",
+ _net_print_error(Error));
+
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+ } else {
+ event_data.Datalength = sizeof(net_profile_info_s);
+ event_data.Data = &prof_info;
+ }
+
+ event_data.Error = Error;
+ g_strlcpy(event_data.ProfileName, sig_path, NET_PROFILE_NAME_LEN_MAX+1);
+
+ _net_client_callback(&event_data);
+ } else
+ __net_handle_state_ind(sig_path, new_state);
+
+ break;
+ }
+ case NET_STATE_TYPE_DISCONNECT:
+ {
+ const char *svc_name1 =
+ request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName;
+ const char *svc_name2 =
+ request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
+ const char *svc_name3 =
+ request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
+
+ if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag != TRUE &&
+ request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag != TRUE &&
+ request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag != TRUE) {
+ /** Send Close Ind */
+ event_data.Error = Error;
+ event_data.Event = NET_EVENT_CLOSE_IND;
+ g_strlcpy(event_data.ProfileName, sig_path, NET_PROFILE_NAME_LEN_MAX+1);
+
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+
+ WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_CLOSE_IND");
+
+ _net_client_callback(&event_data);
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
+ strstr(sig_path, svc_name2) != NULL) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
+ sizeof(network_request_table_s));
+
+ /** Send Open Resp */
+ event_data.Error = NET_ERR_OPERATION_ABORTED;
+ event_data.Event = NET_EVENT_OPEN_RSP;
+ g_strlcpy(event_data.ProfileName, sig_path, NET_PROFILE_NAME_LEN_MAX+1);
+
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+
+ WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_OPEN_RSP");
+
+ _net_dbus_pending_call_unref();
+
+ _net_client_callback(&event_data);
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
+ g_strcmp0(sig_path, svc_name3) == 0) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+ sizeof(network_request_table_s));
+
+ /** Send WPS Resp */
+ event_data.Error = NET_ERR_OPERATION_ABORTED;
+ event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+ g_strlcpy(event_data.ProfileName, sig_path, NET_PROFILE_NAME_LEN_MAX+1);
+
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+
+ WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_WIFI_WPS_RSP");
+ _net_dbus_pending_call_unref();
+
+ _net_client_callback(&event_data);
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE &&
+ g_strcmp0(sig_path, svc_name1) == 0) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION], 0,
+ sizeof(network_request_table_s));
+
+ /** Send Close Resp */
+ event_data.Error = Error;
+ event_data.Event = NET_EVENT_CLOSE_RSP;
+ g_strlcpy(event_data.ProfileName, sig_path, NET_PROFILE_NAME_LEN_MAX+1);
+
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+
+ WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_CLOSE_RSP");
+
+ _net_dbus_pending_call_unref();
+
+ _net_client_callback(&event_data);
+ }
+ break;
+ }
+ case NET_STATE_TYPE_FAILURE:
+ __net_handle_failure_ind(sig_path);
+ break;
+
+ default:
+ Error = NET_ERR_UNKNOWN_METHOD;
+ break;
+ }
+
+ return Error;
+}
+
+static int __net_handle_service_set_error(const char *key, const char *error)
+{
+ if (error == NULL || *error == '\0')
+ return NET_ERR_NONE;
+
+ WIFI_LOG(WIFI_ERROR, "[%s] %s", key, error);
+
+ net_service_error = string2error(error);
+
+ return NET_ERR_NONE;
+}
+
+static int __net_handle_scan_done(GVariant *param)
+{
+ net_event_info_s event_data = { 0, };
+
+ if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE)
+ return NET_ERR_NONE;
+ else if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_SCAN], 0,
+ sizeof(network_request_table_s));
+
+ event_data.Event = NET_EVENT_WIFI_SCAN_RSP;
+
+ _net_dbus_pending_call_unref();
+ } else {
+ event_data.Event = NET_EVENT_WIFI_SCAN_IND;
+ }
+
+ event_data.Error = NET_ERR_NONE;
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+
+ _net_client_callback(&event_data);
+
+ return NET_ERR_NONE;
+}
+
+static int __net_handle_network_dpm_wifi_event(GVariant *param)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GVariantIter *iter = NULL;
+ GVariant *value = NULL;
+ const char *key = NULL;
+ const gchar *sig_value = NULL;
+
+ g_variant_get(param, "(a{sv})", &iter);
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ if (g_strcmp0(key, "key") == 0) {
+ sig_value = g_variant_get_string(value, NULL);
+ WIFI_LOG(WIFI_INFO, "Wifi device policy : %s",
+ sig_value);
+ if (g_strcmp0(sig_value, "allowed") == 0)
+ net_dpm_wifi_state = TRUE;
+ else
+ net_dpm_wifi_state = FALSE;
+ }
+ }
+ g_variant_iter_free(iter);
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+static int __net_handle_network_dpm_wifi_profile_event(GVariant *param)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GVariantIter *iter = NULL;
+ GVariant *value = NULL;
+ const char *key = NULL;
+ const gchar *sig_value = NULL;
+
+ g_variant_get(param, "(a{sv})", &iter);
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ if (g_strcmp0(key, "key") == 0) {
+ sig_value = g_variant_get_string(value, NULL);
+ WIFI_LOG(WIFI_INFO, "Wifi profile device policy : %s",
+ sig_value);
+ if (g_strcmp0(sig_value, "allowed") == 0)
+ net_dpm_wifi_profile_state = TRUE;
+ else
+ net_dpm_wifi_profile_state = FALSE;
+ }
+ }
+ g_variant_iter_free(iter);
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+static void __net_connman_service_signal_filter(GDBusConnection *conn,
+ const gchar *name, const gchar *path, const gchar *interface,
+ const gchar *sig, GVariant *param, gpointer user_data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ const char *key = NULL;
+ const char *value = NULL;
+ GVariant *var;
+
+ if (g_strcmp0(sig, SIGNAL_PROPERTY_CHANGED) == 0) {
+ g_variant_get(param, "(sv)", &key, &var);
+
+ if (g_strcmp0(key, "State") == 0) {
+ g_variant_get(var, "s", &value);
+
+ __net_handle_service_state_changed(path, key, value);
+ } else if (g_strcmp0(key, "Error") == 0) {
+ g_variant_get(var, "s", &value);
+
+ __net_handle_service_set_error(key, value);
+ }
+
+ g_free((gchar *)value);
+ g_free((gchar *)key);
+ if (NULL != var)
+ g_variant_unref(var);
+ }
+
+ __NETWORK_FUNC_EXIT__;
+}
+static int __net_handle_wifi_tdls_connected_event(GVariant *param)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GVariantIter *iter = NULL;
+ GVariant *value = NULL;
+ const char *key = NULL;
+ const gchar *sig_value = NULL;
+
+ g_variant_get(param, "(a{sv})", &iter);
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ if (g_strcmp0(key, "peermac") == 0) {
+ sig_value = g_variant_get_string(value, NULL);
+
+ WIFI_LOG(WIFI_ERROR, "TDLS Connected Peer Mac Adress: %s",
+ sig_value);
+ }
+ }
+ g_variant_iter_free(iter);
+
+ net_event_info_s event_data;
+ memset(&event_data, 0, sizeof(event_data));
+
+ event_data.Error = NET_ERR_NONE;
+ event_data.Event = NET_EVENT_WIFI_TDLS_CONNECTED_IND;
+ event_data.Data = g_strdup(sig_value);
+
+ if (event_data.Data)
+ event_data.Datalength = strlen(event_data.Data);
+ else
+ event_data.Datalength = 0;
+
+ WIFI_LOG(WIFI_ERROR, "Sending NET_EVENT_TDLS_CONNECTED_IND");
+ _net_client_callback(&event_data);
+ g_free(event_data.Data);
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+static int __net_handle_wifi_tdls_disconnected_event(GVariant *param)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GVariantIter *iter = NULL;
+ GVariant *value = NULL;
+ const char *key = NULL;
+ const gchar *sig_value = NULL;
+
+ g_variant_get(param, "(a{sv})", &iter);
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ if (g_strcmp0(key, "peermac") == 0) {
+ sig_value = g_variant_get_string(value, NULL);
+
+ WIFI_LOG(WIFI_ERROR, "TDLS Connected Peer Mac Adress: %s",
+ sig_value);
+ }
+ }
+ g_variant_iter_free(iter);
+
+ net_event_info_s event_data;
+ memset(&event_data, 0, sizeof(event_data));
+
+ event_data.Error = NET_ERR_NONE;
+ event_data.Event = NET_EVENT_WIFI_TDLS_DISCONNECTED_IND;
+ event_data.Data = g_strdup(sig_value);
+
+ if (event_data.Data)
+ event_data.Datalength = strlen(event_data.Data);
+ else
+ event_data.Datalength = 0;
+
+ WIFI_LOG(WIFI_ERROR, "Sending NET_EVENT_TDLS_DISCONNECTED_IND");
+ _net_client_callback(&event_data);
+ g_free(event_data.Data);
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+static int __net_handle_wifi_connect_fail_event(GVariant *param)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_event_info_s event_data = { 0, };
+ network_request_table_s *open_info =
+ &request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION];
+ network_request_table_s *wps_info =
+ &request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS];
+
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+
+ WIFI_LOG(WIFI_ERROR, "Failed to connect WiFi");
+
+ if (open_info->flag == TRUE) {
+ memset(open_info, 0, sizeof(network_request_table_s));
+ event_data.Error = NET_ERR_INVALID_OPERATION;
+ event_data.Event = NET_EVENT_OPEN_RSP;
+ WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_OPEN_RSP");
+ } else if (wps_info->flag == TRUE) {
+ memset(wps_info, 0, sizeof(network_request_table_s));
+ event_data.Error = NET_ERR_INVALID_OPERATION;
+ event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+ WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_WIFI_WPS_RSP");
+ } else {
+ WIFI_LOG(WIFI_WARN, "WiFi Connection flag not set");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+ }
+ _net_client_callback(&event_data);
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+static void __net_supplicant_signal_filter(GDBusConnection *conn,
+ const gchar *name, const gchar *path, const gchar *interface,
+ const gchar *sig, GVariant *param, gpointer user_data)
+{
+ if (g_strcmp0(sig, SIGNAL_SCAN_DONE) == 0)
+ __net_handle_scan_done(param);
+}
+
+static void __net_netconfig_signal_filter(GDBusConnection *conn,
+ const gchar *name, const gchar *path, const gchar *interface,
+ const gchar *sig, GVariant *param, gpointer user_data)
+{
+ if (g_strcmp0(sig, NETCONFIG_SIGNAL_POWERON_COMPLETED) == 0)
+ __net_handle_wifi_power_rsp(TRUE);
+ else if (g_strcmp0(sig, NETCONFIG_SIGNAL_POWEROFF_COMPLETED) == 0)
+ __net_handle_wifi_power_rsp(FALSE);
+ else if (g_strcmp0(sig, NETCONFIG_SIGNAL_SPECIFIC_SCAN_DONE) == 0)
+ __net_handle_wifi_specific_scan_rsp(param);
+ else if (g_strcmp0(sig, NETCONFIG_SIGNAL_WPS_SCAN_DONE) == 0)
+ __net_handle_wifi_wps_scan_rsp(param);
+ else if (g_strcmp0(sig, NETCONFIG_SIGNAL_TDLS_CONNECTED) == 0)
+ __net_handle_wifi_tdls_connected_event(param);
+ else if (g_strcmp0(sig, NETCONFIG_SIGNAL_TDLS_DISCONNECTED) == 0)
+ __net_handle_wifi_tdls_disconnected_event(param);
+ else if (g_strcmp0(sig, NETCONFIG_SIGNAL_WIFI_CONNECT_FAIL) == 0)
+ __net_handle_wifi_connect_fail_event(param);
+}
+
+static void __net_netconfig_network_signal_filter(GDBusConnection *conn,
+ const gchar *name, const gchar *path, const gchar *interface,
+ const gchar *sig, GVariant *param, gpointer user_data)
+{
+ if (g_strcmp0(sig, NETCONFIG_SIGNAL_DPM_WIFI) == 0)
+ __net_handle_network_dpm_wifi_event(param);
+ else if (g_strcmp0(sig, NETCONFIG_SIGNAL_DPM_WIFI_PROFILE) == 0)
+ __net_handle_network_dpm_wifi_profile_event(param);
+}
+
+static int __net_get_tech_states(GVariant *msg, net_state_type_e *state_table)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariantIter *iter_main = NULL;
+ GVariantIter *var = NULL;
+ GVariant *value = NULL;
+ gchar *path = NULL;
+ gchar *key = NULL;
+ gboolean data;
+
+ if (NetworkInfo.wifi_state == WIFI_UNKNOWN)
+ NetworkInfo.wifi_state = WIFI_OFF;
+
+ g_variant_get(msg, "(a(oa{sv}))", &iter_main);
+ while (g_variant_iter_loop(iter_main, "(oa{sv})", &path, &var)) {
+
+ if (path == NULL)
+ continue;
+
+ while (g_variant_iter_loop(var, "{sv}", &key, &value)) {
+ if (g_strcmp0(key, "Connected") == 0) {
+ data = g_variant_get_boolean(value);
+ if (!data)
+ continue;
+
+ if (g_strcmp0(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == 0) {
+ *(state_table) = NET_STATE_TYPE_READY;
+ NetworkInfo.wifi_state = WIFI_CONNECTED;
+ } else
+ WIFI_LOG(WIFI_ERROR, "Invalid technology type");
+ } else if (g_strcmp0(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == 0 &&
+ g_strcmp0(key, "Powered") == 0) {
+ data = g_variant_get_boolean(value);
+ if (data == FALSE)
+ NetworkInfo.wifi_state = WIFI_OFF;
+ else if (data == TRUE && NetworkInfo.wifi_state < WIFI_ON)
+ NetworkInfo.wifi_state = WIFI_ON;
+ }
+ }
+ }
+ g_variant_iter_free(iter_main);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+static int __net_dbus_get_technology_states(net_state_type_e *state_table)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+
+ message = _net_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "GetTechnologies", NULL, &Error);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get technology info");
+ goto done;
+ }
+
+ Error = __net_get_tech_states(message, state_table);
+
+ g_variant_unref(message);
+
+done:
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_get_dpm_wifi_state(void)
+{
+ return net_dpm_wifi_state;
+}
+
+void _net_set_dpm_wifi_state(int state)
+{
+ net_dpm_wifi_state = state;
+}
+
+gboolean _net_get_dpm_wifi_profile_state()
+{
+ return net_dpm_wifi_profile_state;
+}
+
+void _net_set_dpm_wifi_profile_state(int state)
+{
+ net_dpm_wifi_profile_state = state;
+}
+//LCOV_EXCL_STOP
+
+int _net_deregister_signal(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GDBusConnection *connection;
+ net_err_e Error = NET_ERR_NONE;
+
+ connection = _net_dbus_get_gdbus_conn();
+ if (connection == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Already de-registered"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
+ }
+
+ g_dbus_connection_signal_unsubscribe(connection,
+ gdbus_conn_subscribe_id_connman_state);
+ g_dbus_connection_signal_unsubscribe(connection,
+ gdbus_conn_subscribe_id_connman_error);
+ g_dbus_connection_signal_unsubscribe(connection,
+ gdbus_conn_subscribe_id_supplicant);
+ g_dbus_connection_signal_unsubscribe(connection,
+ gdbus_conn_subscribe_id_netconfig_wifi);
+ g_dbus_connection_signal_unsubscribe(connection,
+ gdbus_conn_subscribe_id_netconfig);
+
+ Error = _net_dbus_close_gdbus_call();
+ if (Error != NET_ERR_NONE) {
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_register_signal(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GDBusConnection *connection;
+ net_err_e Error = NET_ERR_NONE;
+
+ Error = _net_dbus_create_gdbus_call();
+ if (Error != NET_ERR_NONE) {
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ connection = _net_dbus_get_gdbus_conn();
+ if (connection == NULL) {
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return NET_ERR_UNKNOWN; //LCOV_EXCL_LINE
+ }
+
+ /* Create connman service state connection */
+ gdbus_conn_subscribe_id_connman_state = g_dbus_connection_signal_subscribe(
+ connection,
+ CONNMAN_SERVICE,
+ CONNMAN_SERVICE_INTERFACE,
+ SIGNAL_PROPERTY_CHANGED,
+ NULL,
+ "State",
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __net_connman_service_signal_filter,
+ NULL,
+ NULL);
+
+ /* Create connman service error connection */
+ gdbus_conn_subscribe_id_connman_error = g_dbus_connection_signal_subscribe(
+ connection,
+ CONNMAN_SERVICE,
+ CONNMAN_SERVICE_INTERFACE,
+ SIGNAL_PROPERTY_CHANGED,
+ NULL,
+ "Error",
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __net_connman_service_signal_filter,
+ NULL,
+ NULL);
+
+ /* Create net-config service connection for network */
+ gdbus_conn_subscribe_id_netconfig = g_dbus_connection_signal_subscribe(
+ connection,
+ NETCONFIG_SERVICE,
+ NETCONFIG_NETWORK_INTERFACE,
+ NULL,
+ NETCONFIG_NETWORK_PATH,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __net_netconfig_network_signal_filter,
+ NULL,
+ NULL);
+
+ /* Create supplicant service connection */
+ gdbus_conn_subscribe_id_supplicant = g_dbus_connection_signal_subscribe(
+ connection,
+ SUPPLICANT_SERVICE,
+ SUPPLICANT_IFACE_INTERFACE,
+ "ScanDone",
+ NULL,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __net_supplicant_signal_filter,
+ NULL,
+ NULL);
+
+ /* Create net-config service connection */
+ gdbus_conn_subscribe_id_netconfig_wifi = g_dbus_connection_signal_subscribe(
+ connection,
+ NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_INTERFACE,
+ NULL,
+ NETCONFIG_WIFI_PATH,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __net_netconfig_signal_filter,
+ NULL,
+ NULL);
+
+ if (gdbus_conn_subscribe_id_connman_state == 0 ||
+ gdbus_conn_subscribe_id_connman_error == 0 ||
+ gdbus_conn_subscribe_id_netconfig == 0 ||
+ gdbus_conn_subscribe_id_supplicant == 0 ||
+ gdbus_conn_subscribe_id_netconfig_wifi == 0) {
+ WIFI_LOG(WIFI_ERROR, "Failed register signals " //LCOV_EXCL_LINE
+ "connman_state(%d), connman_error(%d), netconfig(%d), "
+ "supplicant(%d), netconfig_wifi(%d)",
+ gdbus_conn_subscribe_id_connman_state,
+ gdbus_conn_subscribe_id_connman_error,
+ gdbus_conn_subscribe_id_netconfig,
+ gdbus_conn_subscribe_id_supplicant,
+ gdbus_conn_subscribe_id_netconfig_wifi);
+ Error = NET_ERR_NOT_SUPPORTED; //LCOV_EXCL_LINE
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_init_service_state_table(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ Error = __net_dbus_get_technology_states(&service_state_table);
+ if (Error != NET_ERR_NONE) {
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ WIFI_LOG(WIFI_INFO, "init service state table. "
+ "wifi:%d", service_state_table);
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
+#include "wifi_internal.h"
+
+#define MAX_PREFIX_LENGTH 6
+
+//LCOV_EXCL_START
+static char *__ap_convert_ip_to_string(net_addr_s *ip_addr,
+ wifi_manager_address_family_e address_family)
+{
+ unsigned char *ipaddr = NULL;
+ char *ipstr = NULL;
+
+ if (address_family == WIFI_MANAGER_ADDRESS_FAMILY_IPV4) {
+ ipaddr = (unsigned char *)&ip_addr->Data.Ipv4.s_addr;
+ ipstr = g_try_malloc0(INET_ADDRSTRLEN);
+ if (ipstr == NULL)
+ return NULL;
+
+ 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;
+}
+
+static void __wifi_init_ap(net_profile_info_s *profile_info, const char *essid)
+{
+ profile_info->ProfileState = NET_STATE_TYPE_IDLE;
+ profile_info->net_info.IpConfigType = NET_IP_CONFIG_TYPE_OFF;
+ profile_info->net_info.ProxyMethod = NET_PROXY_TYPE_DIRECT;
+ profile_info->wlan_mode = NET_WLAN_CONNMODE_AUTO;
+ profile_info->security_info.sec_mode = WLAN_SEC_MODE_NONE;
+ profile_info->security_info.enc_mode = WLAN_ENC_MODE_NONE;
+ g_strlcpy(profile_info->essid, essid, NET_WLAN_ESSID_LEN+1);
+}
+
+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 == NET_WLAN_CONNMODE_ADHOC) {
+ WIFI_LOG(WIFI_ERROR, "wlan_mode is adhoc");
+ return NULL;
+ }
+
+ switch (sec_mode) {
+ case WLAN_SEC_MODE_NONE:
+ g_sec = "none";
+ break;
+ case WLAN_SEC_MODE_WEP:
+ g_sec = "wep";
+ break;
+ case WLAN_SEC_MODE_WPA_PSK:
+ case WLAN_SEC_MODE_WPA2_PSK:
+ g_sec = "psk";
+ break;
+ case WLAN_SEC_MODE_IEEE8021X:
+ g_sec = "ieee8021x";
+ break;
+ default:
+ WIFI_LOG(WIFI_ERROR, "Invalid security type");
+ return NULL;
+ }
+
+ if (NULL != ssid) {
+ ssid_len = strlen(ssid);
+ actual_len = ssid_len * 2;
+ } else {
+ ssid_len = strlen(hidden_str);
+ actual_len = ssid_len;
+ }
+
+ buf = g_try_malloc0(actual_len + strlen(mode) + strlen(g_sec) + 3);
+ if (buf == NULL)
+ return NULL;
+
+ if (NULL != ssid) {
+ pbuf = buf;
+
+ for (i = 0; i < ssid_len; i++) {
+ g_snprintf(pbuf, 3, "%02x", ssid[i]);
+ pbuf += 2;
+ }
+ } else
+ g_strlcat(buf, hidden_str,
+ actual_len + strlen(mode) + strlen(g_sec) + 3);
+
+ g_snprintf(buf_tmp, 32, "_%s_%s", mode, g_sec);
+ g_strlcat(buf, buf_tmp,
+ actual_len + strlen(mode) + strlen(g_sec) + 3);
+
+ WIFI_LOG(WIFI_INFO, "Profile name: %s", buf);
+
+ return buf;
+}
+
+static bool _wifi_set_profile_name_to_ap(net_profile_info_s *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->is_hidden == TRUE ?
+ NULL : ap_info->essid,
+ ap_info->wlan_mode,
+ ap_info->security_info.sec_mode);
+ if (profile_name == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to make a group name");
+ return false;
+ }
+
+ g_strlcpy(ap_info->net_info.ProfileName,
+ profile_name, NET_PROFILE_NAME_LEN_MAX);
+
+ g_free(profile_name);
+
+ return true;
+}
+
+wifi_manager_connection_state_e _wifi_convert_to_ap_state(net_state_type_e state)
+{
+ wifi_manager_connection_state_e ap_state;
+
+ switch (state) {
+ case NET_STATE_TYPE_ONLINE:
+ case NET_STATE_TYPE_READY:
+ ap_state = WIFI_MANAGER_CONNECTION_STATE_CONNECTED;
+ break;
+ case NET_STATE_TYPE_FAILURE:
+ ap_state = WIFI_MANAGER_CONNECTION_STATE_FAILURE;
+ break;
+ case NET_STATE_TYPE_IDLE:
+ case NET_STATE_TYPE_DISCONNECT:
+ ap_state = WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED;
+ break;
+ case NET_STATE_TYPE_ASSOCIATION:
+ ap_state = WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION;
+ break;
+ case NET_STATE_TYPE_CONFIGURATION:
+ ap_state = WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION;
+ break;
+ default:
+ ap_state = -1;
+ break;
+ }
+
+ return ap_state;
+}
+//LCOV_EXCL_STOP
+
+EXPORT_API int wifi_manager_ap_create(wifi_manager_h wifi,
+ const char *essid, wifi_manager_ap_h *ap)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (essid == NULL || ap == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *ap_info = g_try_malloc0(sizeof(net_profile_info_s));
+ if (ap_info == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+
+ __wifi_init_ap(ap_info, essid);
+
+ _wifi_add_to_ap_list((wifi_manager_ap_h)ap_info);
+ *ap = (wifi_manager_ap_h)ap_info;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_hidden_create(wifi_manager_h wifi,
+ const char *essid, wifi_manager_ap_h *ap)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (essid == NULL || ap == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *ap_info = g_try_malloc0(sizeof(net_profile_info_s));
+ if (ap_info == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+
+ __wifi_init_ap(ap_info, essid);
+ ap_info->is_hidden = TRUE;
+
+ _wifi_add_to_ap_list((wifi_manager_ap_h)ap_info);
+ *ap = (wifi_manager_ap_h)ap_info;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_destroy(wifi_manager_ap_h ap)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ _wifi_remove_from_ap_list(ap);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_clone(wifi_manager_ap_h *cloned_ap, wifi_manager_ap_h origin)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(origin) == false || cloned_ap == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *ap_info = g_try_malloc0(sizeof(net_profile_info_s));
+ if (ap_info == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+
+ memcpy(ap_info, origin, sizeof(net_profile_info_s));
+
+ _wifi_add_to_ap_list((wifi_manager_ap_h)ap_info);
+ *cloned_ap = (wifi_manager_ap_h)ap_info;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_refresh(wifi_manager_ap_h ap)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ net_profile_info_s ap_info_local;
+ net_profile_info_s *ap_info = ap;
+
+ if (_wifi_check_ap_validity(ap) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ 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"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to getprofile_info"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ memcpy(ap, &ap_info_local, sizeof(net_profile_info_s));
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+/* Wi-Fi network information ************************************************/
+EXPORT_API int wifi_manager_ap_get_essid(wifi_manager_ap_h ap, char **essid)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || essid == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+ *essid = g_strdup(profile_info->essid);
+ if (*essid == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_bssid(wifi_manager_ap_h ap, char **bssid)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || bssid == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+ *bssid = g_strdup(profile_info->bssid);
+ if (*bssid == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_rssi(wifi_manager_ap_h ap, int *rssi)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || rssi == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+ *rssi = (int)(profile_info->Strength - 120);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_frequency(wifi_manager_ap_h ap, int *frequency)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || frequency == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+ *frequency = (int)profile_info->frequency;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_max_speed(wifi_manager_ap_h ap, int *max_speed)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || max_speed == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+ *max_speed = (int)profile_info->max_rate / 1000000;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_is_favorite(wifi_manager_ap_h ap, bool *favorite)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || favorite == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ if (profile_info->Favourite)
+ *favorite = true;
+ else
+ *favorite = false;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_is_passpoint(wifi_manager_ap_h ap, bool *passpoint)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || passpoint == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ if (profile_info->passpoint)
+ *passpoint = true;
+ else
+ *passpoint = false;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_connection_state(wifi_manager_ap_h ap,
+ wifi_manager_connection_state_e *state)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || state == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ *state = _wifi_convert_to_ap_state(profile_info->ProfileState);
+
+ if (*state < 0)
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_ip_config_type(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, wifi_manager_ip_config_type_e *type)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ net_ip_config_type_e profileType ;
+
+ if (_wifi_check_ap_validity(ap) == false ||
+ (address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
+ address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6) ||
+ type == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ if (address_family == WIFI_MANAGER_ADDRESS_FAMILY_IPV4)
+ profileType = profile_info->net_info.IpConfigType ;
+ else
+ profileType = profile_info->net_info.IpConfigType6 ; //LCOV_EXCL_LINE
+
+ if (address_family == WIFI_MANAGER_ADDRESS_FAMILY_IPV4) {
+ switch (profileType) {
+ //LCOV_EXCL_START
+ case NET_IP_CONFIG_TYPE_STATIC:
+ *type = WIFI_MANAGER_IP_CONFIG_TYPE_STATIC;
+ break;
+
+ case NET_IP_CONFIG_TYPE_DYNAMIC:
+ *type = WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC;
+ break;
+
+ case NET_IP_CONFIG_TYPE_AUTO_IP:
+ *type = WIFI_MANAGER_IP_CONFIG_TYPE_AUTO;
+ break;
+
+ case NET_IP_CONFIG_TYPE_FIXED:
+ *type = WIFI_MANAGER_IP_CONFIG_TYPE_FIXED;
+ break;
+
+ case NET_IP_CONFIG_TYPE_OFF:
+ *type = WIFI_MANAGER_IP_CONFIG_TYPE_NONE;
+ break;
+
+ default:
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ //LCOV_EXCL_STOP
+ }
+ } else {
+ //LCOV_EXCL_START
+ switch (profileType) {
+ case NET_IP_CONFIG_TYPE_STATIC:
+ *type = WIFI_MANAGER_IP_CONFIG_TYPE_STATIC;
+ break;
+ case NET_IP_CONFIG_TYPE_AUTO_IP:
+ *type = WIFI_MANAGER_IP_CONFIG_TYPE_AUTO;
+ break;
+ case NET_IP_CONFIG_TYPE_OFF:
+ *type = WIFI_MANAGER_IP_CONFIG_TYPE_NONE;
+ break;
+ default:
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ }
+ //LCOV_EXCL_STOP
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_set_ip_config_type(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, wifi_manager_ip_config_type_e type)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ net_ip_config_type_e *profileType = NULL;
+
+ if (_wifi_check_ap_validity(ap) == false ||
+ (address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
+ address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6)) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ if (address_family == WIFI_MANAGER_ADDRESS_FAMILY_IPV4)
+ profileType = &profile_info->net_info.IpConfigType ;
+ else
+ profileType = &profile_info->net_info.IpConfigType6 ;
+
+ if (address_family == WIFI_MANAGER_ADDRESS_FAMILY_IPV4) {
+ //LCOV_EXCL_START
+ switch (type) {
+ case WIFI_MANAGER_IP_CONFIG_TYPE_STATIC:
+ *profileType = NET_IP_CONFIG_TYPE_STATIC;
+ profile_info->net_info.IpAddr.Data.Ipv4.s_addr = 0;
+ profile_info->net_info.SubnetMask.Data.Ipv4.s_addr = 0;
+ profile_info->net_info.GatewayAddr.Data.Ipv4.s_addr = 0 ;
+ break;
+
+ case WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC:
+ *profileType = NET_IP_CONFIG_TYPE_DYNAMIC;
+ break;
+
+ case WIFI_MANAGER_IP_CONFIG_TYPE_AUTO:
+ *profileType = NET_IP_CONFIG_TYPE_AUTO_IP;
+ break;
+
+ case WIFI_MANAGER_IP_CONFIG_TYPE_FIXED:
+ *profileType = NET_IP_CONFIG_TYPE_FIXED;
+ break;
+
+ case WIFI_MANAGER_IP_CONFIG_TYPE_NONE:
+ *profileType = NET_IP_CONFIG_TYPE_OFF;
+ break;
+
+ default:
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ }
+ //LCOV_EXCL_STOP
+ } else {
+ //LCOV_EXCL_START
+ switch (type) {
+ case WIFI_MANAGER_IP_CONFIG_TYPE_STATIC:
+ *profileType = NET_IP_CONFIG_TYPE_STATIC;
+ inet_pton(AF_INET6, "::", &profile_info->net_info.IpAddr6.Data.Ipv6);
+ profile_info->net_info.PrefixLen6 = 0 ;
+ inet_pton(AF_INET6, "::", &profile_info->net_info.GatewayAddr6.Data.Ipv6);
+ break;
+ case WIFI_MANAGER_IP_CONFIG_TYPE_AUTO:
+ *profileType = NET_IP_CONFIG_TYPE_AUTO_IP;
+ break;
+ case WIFI_MANAGER_IP_CONFIG_TYPE_NONE:
+ *profileType = NET_IP_CONFIG_TYPE_OFF;
+ break;
+ default:
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ }
+ //LCOV_EXCL_STOP
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_ip_address(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, char **ip_address)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false ||
+ (address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
+ address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6) ||
+ ip_address == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+ if (address_family == WIFI_MANAGER_ADDRESS_FAMILY_IPV4)
+ *ip_address = __ap_convert_ip_to_string(
+ &profile_info->net_info.IpAddr,
+ address_family);
+ else
+ *ip_address = __ap_convert_ip_to_string(
+ &profile_info->net_info.IpAddr6,
+ address_family);
+
+ if (*ip_address == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_set_ip_address(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, const char *ip_address)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false ||
+ (address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
+ address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6)) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ if (address_family == WIFI_MANAGER_ADDRESS_FAMILY_IPV4) {
+ if (ip_address == NULL)
+ profile_info->net_info.IpAddr.Data.Ipv4.s_addr = 0;
+ else if (inet_aton(ip_address,
+ &(profile_info->net_info.IpAddr.Data.Ipv4)) == 0)
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ } else {
+ //LCOV_EXCL_START
+ if (ip_address == NULL)
+ inet_pton(AF_INET6, "::",
+ &profile_info->net_info.IpAddr6.Data.Ipv6);
+ else if (inet_pton(AF_INET6, ip_address,
+ &profile_info->net_info.IpAddr6.Data.Ipv6) == 0)
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ //LCOV_EXCL_STOP
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_subnet_mask(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, char **subnet_mask)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ char* prefixlen;
+
+ if (_wifi_check_ap_validity(ap) == false ||
+ (address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
+ address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6) ||
+ subnet_mask == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+ if (address_family == WIFI_MANAGER_ADDRESS_FAMILY_IPV4)
+ *subnet_mask = __ap_convert_ip_to_string(
+ &profile_info->net_info.SubnetMask,
+ address_family);
+ else {
+ //LCOV_EXCL_START
+ prefixlen = g_try_malloc0(MAX_PREFIX_LENGTH);
+ if (prefixlen != NULL) {
+ snprintf(prefixlen, MAX_PREFIX_LENGTH, "%d",
+ profile_info->net_info.PrefixLen6);
+ *subnet_mask = prefixlen;
+ } else
+ *subnet_mask = NULL;
+ //LCOV_EXCL_STOP
+ }
+
+ if (*subnet_mask == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_set_subnet_mask(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, const char *subnet_mask)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false ||
+ (address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
+ address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6)) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *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_MANAGER_ADDRESS_FAMILY_IPV6) {
+ //LCOV_EXCL_START
+ if (subnet_mask == NULL)
+ profile_info->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->net_info.PrefixLen6 =
+ atoi(subnet_mask) ;
+ }
+ //LCOV_EXCL_STOP
+ } else {
+ if (subnet_mask == NULL)
+ profile_info->net_info.SubnetMask.Data.Ipv4.s_addr = 0;
+ else if (inet_pton(AF_INET, subnet_mask,
+ &(profile_info->net_info.SubnetMask.Data.Ipv4)) < 1)
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_gateway_address(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, char **gateway_address)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false ||
+ (address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
+ address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6) ||
+ gateway_address == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ /* 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_MANAGER_ADDRESS_FAMILY_IPV4)
+ *gateway_address = __ap_convert_ip_to_string(
+ &profile_info->net_info.GatewayAddr,
+ address_family);
+ else
+ *gateway_address = __ap_convert_ip_to_string( //LCOV_EXCL_LINE
+ &profile_info->net_info.GatewayAddr6,
+ address_family);
+
+ if (*gateway_address == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_set_gateway_address(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, const char *gateway_address)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false ||
+ (address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
+ address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6)) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+ if (address_family == WIFI_MANAGER_ADDRESS_FAMILY_IPV6) {
+ //LCOV_EXCL_START
+ if (gateway_address == NULL)
+ inet_pton(AF_INET6, "::",
+ &profile_info->net_info.GatewayAddr6.Data.Ipv6);
+ else if (inet_pton(AF_INET6, gateway_address,
+ &profile_info->net_info.GatewayAddr6.Data.Ipv6) < 1)
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ //LCOV_EXCL_STOP
+ } else {
+ if (gateway_address == NULL)
+ profile_info->net_info.GatewayAddr.Data.Ipv4.s_addr = 0;
+ else if (inet_pton(AF_INET, gateway_address,
+ &profile_info->net_info.GatewayAddr.Data.Ipv4) < 1)
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_proxy_address(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, char **proxy_address)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false ||
+ (address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
+ address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6) ||
+ proxy_address == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+ *proxy_address = g_strdup(profile_info->net_info.ProxyAddr);
+ if (*proxy_address == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_set_proxy_address(wifi_manager_ap_h ap,
+ wifi_manager_address_family_e address_family, const char *proxy_address)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false ||
+ (address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
+ address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6)) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ if (proxy_address == NULL)
+ profile_info->net_info.ProxyAddr[0] = '\0';
+ else
+ g_strlcpy(profile_info->net_info.ProxyAddr,
+ proxy_address, NET_PROXY_LEN_MAX+1);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_proxy_type(wifi_manager_ap_h ap,
+ wifi_manager_proxy_type_e *proxy_type)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || proxy_type == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ //LCOV_EXCL_START
+ switch (profile_info->net_info.ProxyMethod) {
+ case NET_PROXY_TYPE_DIRECT:
+ *proxy_type = WIFI_MANAGER_PROXY_TYPE_DIRECT;
+ break;
+ case NET_PROXY_TYPE_AUTO:
+ *proxy_type = WIFI_MANAGER_PROXY_TYPE_AUTO;
+ break;
+ case NET_PROXY_TYPE_MANUAL:
+ *proxy_type = WIFI_MANAGER_PROXY_TYPE_MANUAL;
+ break;
+ case NET_PROXY_TYPE_UNKNOWN:
+ *proxy_type = WIFI_MANAGER_PROXY_TYPE_DIRECT;
+ break;
+ default:
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ }
+ //LCOV_EXCL_STOP
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_set_proxy_type(wifi_manager_ap_h ap,
+ wifi_manager_proxy_type_e proxy_type)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ //LCOV_EXCL_START
+ switch (proxy_type) {
+ case WIFI_MANAGER_PROXY_TYPE_DIRECT:
+ profile_info->net_info.ProxyMethod = NET_PROXY_TYPE_DIRECT;
+ break;
+ case WIFI_MANAGER_PROXY_TYPE_AUTO:
+ profile_info->net_info.ProxyAddr[0] = '\0';
+ profile_info->net_info.ProxyMethod = NET_PROXY_TYPE_AUTO;
+ break;
+ case WIFI_MANAGER_PROXY_TYPE_MANUAL:
+ profile_info->net_info.ProxyAddr[0] = '\0';
+ profile_info->net_info.ProxyMethod = NET_PROXY_TYPE_MANUAL;
+ g_strlcpy(profile_info->net_info.ProxyAddr, "0.0.0.0:8080", 15);
+ break;
+ default:
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ }
+ //LCOV_EXCL_STOP
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_dns_address(wifi_manager_ap_h ap,
+ int order, wifi_manager_address_family_e address_family, char **dns_address)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false ||
+ (address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
+ address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6) ||
+ dns_address == NULL ||
+ order <= 0 ||
+ order > NET_DNS_ADDR_MAX) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ if (address_family == WIFI_MANAGER_ADDRESS_FAMILY_IPV4)
+ *dns_address = __ap_convert_ip_to_string(
+ &profile_info->net_info.DnsAddr[order-1],
+ address_family);
+ else
+ *dns_address = __ap_convert_ip_to_string( //LCOV_EXCL_LINE
+ &profile_info->net_info.DnsAddr6[order-1],
+ address_family);
+
+ if (*dns_address == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_set_dns_address(wifi_manager_ap_h ap,
+ int order, wifi_manager_address_family_e address_family, const char *dns_address)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false ||
+ (address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
+ address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6) ||
+ order <= 0 ||
+ order > NET_DNS_ADDR_MAX) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ if (address_family == WIFI_MANAGER_ADDRESS_FAMILY_IPV6) {
+ //LCOV_EXCL_START
+ profile_info->net_info.DnsAddr6[order-1].Type =
+ NET_ADDR_IPV6;
+ if (dns_address == NULL)
+ inet_pton(AF_INET6, "::",
+ &profile_info->net_info.DnsAddr6[order-1].Data.Ipv6);
+ else if (inet_pton(AF_INET6, dns_address,
+ &profile_info->net_info.DnsAddr6[order-1].Data.Ipv6) < 1)
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+
+ if (profile_info->net_info.DnsCount6 < order)
+ profile_info->net_info.DnsCount6 = order;
+ //LCOV_EXCL_STOP
+ } else {
+ profile_info->net_info.DnsAddr[order-1].Type =
+ NET_ADDR_IPV4;
+ if (dns_address == NULL)
+ profile_info->net_info.DnsAddr[order-1].Data.Ipv4.s_addr = 0;
+ else if (inet_pton(AF_INET, dns_address,
+ &(profile_info->net_info.DnsAddr[order-1].Data.Ipv4)) < 1)
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+
+ if (profile_info->net_info.DnsCount < order)
+ profile_info->net_info.DnsCount = order;
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+/* Wi-Fi security information ************************************************/
+EXPORT_API int wifi_manager_ap_get_security_type(wifi_manager_ap_h ap,
+ wifi_manager_security_type_e *type)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || type == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ //LCOV_EXCL_START
+ switch (profile_info->security_info.sec_mode) {
+ case WLAN_SEC_MODE_NONE:
+ *type = WIFI_MANAGER_SECURITY_TYPE_NONE;
+ break;
+ case WLAN_SEC_MODE_WEP:
+ *type = WIFI_MANAGER_SECURITY_TYPE_WEP;
+ break;
+ case WLAN_SEC_MODE_IEEE8021X:
+ *type = WIFI_MANAGER_SECURITY_TYPE_EAP;
+ break;
+ case WLAN_SEC_MODE_WPA_PSK:
+ *type = WIFI_MANAGER_SECURITY_TYPE_WPA_PSK;
+ break;
+ case WLAN_SEC_MODE_WPA2_PSK:
+ *type = WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK;
+ break;
+ default:
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ }
+ //LCOV_EXCL_STOP
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_set_security_type(wifi_manager_ap_h ap,
+ wifi_manager_security_type_e type)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ //LCOV_EXCL_START
+ switch (type) {
+ case WIFI_MANAGER_SECURITY_TYPE_NONE:
+ profile_info->security_info.sec_mode = WLAN_SEC_MODE_NONE;
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_WEP:
+ profile_info->security_info.sec_mode = WLAN_SEC_MODE_WEP;
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_EAP:
+ profile_info->security_info.sec_mode = WLAN_SEC_MODE_IEEE8021X;
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
+ profile_info->security_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
+ profile_info->security_info.sec_mode = WLAN_SEC_MODE_WPA2_PSK;
+ break;
+ default:
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ }
+ //LCOV_EXCL_STOP
+
+ _wifi_set_profile_name_to_ap(profile_info);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_encryption_type(wifi_manager_ap_h ap,
+ wifi_manager_encryption_type_e *type)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || type == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ //LCOV_EXCL_START
+ switch (profile_info->security_info.enc_mode) {
+ case WLAN_ENC_MODE_NONE:
+ *type = WIFI_MANAGER_ENCRYPTION_TYPE_NONE;
+ break;
+ case WLAN_ENC_MODE_WEP:
+ *type = WIFI_MANAGER_ENCRYPTION_TYPE_WEP;
+ break;
+ case WLAN_ENC_MODE_TKIP:
+ *type = WIFI_MANAGER_ENCRYPTION_TYPE_TKIP;
+ break;
+ case WLAN_ENC_MODE_AES:
+ *type = WIFI_MANAGER_ENCRYPTION_TYPE_AES;
+ break;
+ case WLAN_ENC_MODE_TKIP_AES_MIXED:
+ *type = WIFI_MANAGER_ENCRYPTION_TYPE_TKIP_AES_MIXED;
+ break;
+ default:
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ }
+ //LCOV_EXCL_STOP
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_set_encryption_type(wifi_manager_ap_h ap,
+ wifi_manager_encryption_type_e type)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ //LCOV_EXCL_START
+ switch (type) {
+ case WIFI_MANAGER_ENCRYPTION_TYPE_NONE:
+ profile_info->security_info.enc_mode = WLAN_ENC_MODE_NONE;
+ break;
+ case WIFI_MANAGER_ENCRYPTION_TYPE_WEP:
+ profile_info->security_info.enc_mode = WLAN_ENC_MODE_WEP;
+ break;
+ case WIFI_MANAGER_ENCRYPTION_TYPE_TKIP:
+ profile_info->security_info.enc_mode = WLAN_ENC_MODE_TKIP;
+ break;
+ case WIFI_MANAGER_ENCRYPTION_TYPE_AES:
+ profile_info->security_info.enc_mode = WLAN_ENC_MODE_AES;
+ break;
+ case WIFI_MANAGER_ENCRYPTION_TYPE_TKIP_AES_MIXED:
+ profile_info->security_info.enc_mode = WLAN_ENC_MODE_TKIP_AES_MIXED;
+ break;
+ default:
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ }
+ //LCOV_EXCL_STOP
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_is_passphrase_required(wifi_manager_ap_h ap,
+ bool *required)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || required == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ if (profile_info->Favourite) {
+ *required = false;
+ return WIFI_MANAGER_ERROR_NONE;
+ }
+
+ //LCOV_EXCL_START
+ switch (profile_info->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_MANAGER_ERROR_OPERATION_FAILED;
+ }
+ //LCOV_EXCL_STOP
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_set_passphrase(wifi_manager_ap_h ap, const char *passphrase)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || passphrase == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ //LCOV_EXCL_START
+ switch (profile_info->security_info.sec_mode) {
+ case WLAN_SEC_MODE_WEP:
+ g_strlcpy(profile_info->security_info.authentication.wep.wepKey,
+ passphrase, NET_WLAN_MAX_WEP_KEY_LEN+1);
+ break;
+ case WLAN_SEC_MODE_WPA_PSK:
+ case WLAN_SEC_MODE_WPA2_PSK:
+ g_strlcpy(profile_info->security_info.authentication.psk.pskKey,
+ passphrase, NET_WLAN_MAX_PSK_PASSPHRASE_LEN+1);
+ break;
+ case WLAN_SEC_MODE_NONE:
+ case WLAN_SEC_MODE_IEEE8021X:
+ default:
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ }
+ //LCOV_EXCL_STOP
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_is_wps_supported(wifi_manager_ap_h ap, bool *supported)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || supported == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ if (profile_info->security_info.wps_support)
+ *supported = true;
+ else
+ *supported = false;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+/* Wi-Fi EAP *****************************************************************/
+EXPORT_API int wifi_manager_ap_set_eap_passphrase(wifi_manager_ap_h ap,
+ const char *user_name, const char *password)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || (user_name == NULL && password == NULL)) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+ if (profile_info->security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+
+ if (user_name)
+ g_strlcpy(profile_info->security_info.authentication.eap.username,
+ user_name, NET_WLAN_USERNAME_LEN+1);
+
+ if (password)
+ g_strlcpy(profile_info->security_info.authentication.eap.password,
+ password, NET_WLAN_PASSWORD_LEN+1);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_eap_passphrase(wifi_manager_ap_h ap,
+ char **user_name, bool *is_password_set)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || user_name == NULL || is_password_set == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+ if (profile_info->security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+
+ *user_name = g_strdup(profile_info->security_info.authentication.eap.username);
+ if (*user_name == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+
+ if (strlen(profile_info->security_info.authentication.eap.password) > 0)
+ *is_password_set = true;
+ else
+ *is_password_set = false;
+
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_eap_ca_cert_file(wifi_manager_ap_h ap, char **file)
+{
+ net_profile_info_s *profile_info = NULL;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || file == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ profile_info = (net_profile_info_s *)ap;
+ if (profile_info->security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+
+ *file = g_strdup(profile_info->security_info.authentication.eap.ca_cert_filename);
+ if (*file == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_set_eap_ca_cert_file(wifi_manager_ap_h ap, const char *file)
+{
+ net_profile_info_s *profile_info = NULL;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || file == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ profile_info = (net_profile_info_s *)ap;
+ if (profile_info->security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+
+ g_strlcpy(profile_info->security_info.authentication.eap.ca_cert_filename,
+ file, NET_WLAN_CA_CERT_FILENAME_LEN+1);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_eap_client_cert_file(wifi_manager_ap_h ap, char **file)
+{
+ net_profile_info_s *profile_info = NULL;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || file == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ profile_info = (net_profile_info_s *)ap;
+ if (profile_info->security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+
+ *file = g_strdup(profile_info->security_info.authentication.eap.client_cert_filename);
+ if (*file == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_set_eap_client_cert_file(wifi_manager_ap_h ap,
+ const char *file)
+{
+ net_profile_info_s *profile_info = NULL;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || file == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ profile_info = (net_profile_info_s *)ap;
+ if (profile_info->security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+
+ g_strlcpy(profile_info->security_info.authentication.eap.client_cert_filename,
+ file, NET_WLAN_CLIENT_CERT_FILENAME_LEN+1);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_eap_private_key_file(wifi_manager_ap_h ap, char **file)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || file == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+ if (profile_info->security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+
+ *file = g_strdup(profile_info->security_info.authentication.eap.private_key_filename);
+ if (*file == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_set_eap_private_key_info(wifi_manager_ap_h ap,
+ const char *file, const char *password)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || file == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+ if (profile_info->security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+
+ g_strlcpy(profile_info->security_info.authentication.eap.private_key_filename,
+ file, NET_WLAN_PRIVATE_KEY_FILENAME_LEN+1);
+
+ if (password) {
+ g_strlcpy(profile_info->security_info.authentication.eap.private_key_passwd,
+ password, NET_WLAN_PRIVATE_KEY_PASSWD_LEN+1);
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_eap_type(wifi_manager_ap_h ap,
+ wifi_manager_eap_type_e *type)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || type == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+ if (profile_info->security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+
+ //LCOV_EXCL_START
+ switch (profile_info->security_info.authentication.eap.eap_type) {
+ case WLAN_SEC_EAP_TYPE_PEAP:
+ *type = WIFI_MANAGER_EAP_TYPE_PEAP;
+ break;
+ case WLAN_SEC_EAP_TYPE_TLS:
+ *type = WIFI_MANAGER_EAP_TYPE_TLS;
+ break;
+ case WLAN_SEC_EAP_TYPE_TTLS:
+ *type = WIFI_MANAGER_EAP_TYPE_TTLS;
+ break;
+ case WLAN_SEC_EAP_TYPE_SIM:
+ *type = WIFI_MANAGER_EAP_TYPE_SIM;
+ break;
+ case WLAN_SEC_EAP_TYPE_AKA:
+ *type = WIFI_MANAGER_EAP_TYPE_AKA;
+ break;
+ default:
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ }
+ //LCOV_EXCL_STOP
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_set_eap_type(wifi_manager_ap_h ap,
+ wifi_manager_eap_type_e type)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+ if (profile_info->security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+
+ //LCOV_EXCL_START
+ switch (type) {
+ case WIFI_MANAGER_EAP_TYPE_PEAP:
+ profile_info->security_info.authentication.eap.eap_type = WLAN_SEC_EAP_TYPE_PEAP;
+ break;
+ case WIFI_MANAGER_EAP_TYPE_TLS:
+ profile_info->security_info.authentication.eap.eap_type = WLAN_SEC_EAP_TYPE_TLS;
+ break;
+ case WIFI_MANAGER_EAP_TYPE_TTLS:
+ profile_info->security_info.authentication.eap.eap_type = WLAN_SEC_EAP_TYPE_TTLS;
+ break;
+ case WIFI_MANAGER_EAP_TYPE_SIM:
+ profile_info->security_info.authentication.eap.eap_type = WLAN_SEC_EAP_TYPE_SIM;
+ break;
+ case WIFI_MANAGER_EAP_TYPE_AKA:
+ profile_info->security_info.authentication.eap.eap_type = WLAN_SEC_EAP_TYPE_AKA;
+ break;
+ default:
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ }
+ //LCOV_EXCL_STOP
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_eap_auth_type(wifi_manager_ap_h ap,
+ wifi_manager_eap_auth_type_e *type)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || type == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+ if (profile_info->security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+
+ //LCOV_EXCL_START
+ switch (profile_info->security_info.authentication.eap.eap_auth) {
+ case WLAN_SEC_EAP_AUTH_NONE:
+ *type = WIFI_MANAGER_EAP_AUTH_TYPE_NONE;
+ break;
+ case WLAN_SEC_EAP_AUTH_PAP:
+ *type = WIFI_MANAGER_EAP_AUTH_TYPE_PAP;
+ break;
+ case WLAN_SEC_EAP_AUTH_MSCHAP:
+ *type = WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAP;
+ break;
+ case WLAN_SEC_EAP_AUTH_MSCHAPV2:
+ *type = WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAPV2;
+ break;
+ case WLAN_SEC_EAP_AUTH_GTC:
+ *type = WIFI_MANAGER_EAP_AUTH_TYPE_GTC;
+ break;
+ case WLAN_SEC_EAP_AUTH_MD5:
+ *type = WIFI_MANAGER_EAP_AUTH_TYPE_MD5;
+ break;
+ default:
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ }
+ //LCOV_EXCL_STOP
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_set_eap_auth_type(wifi_manager_ap_h ap,
+ wifi_manager_eap_auth_type_e type)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+ if (profile_info->security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X)
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+
+ //LCOV_EXCL_START
+ switch (type) {
+ case WIFI_MANAGER_EAP_AUTH_TYPE_NONE:
+ profile_info->security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_NONE;
+ break;
+ case WIFI_MANAGER_EAP_AUTH_TYPE_PAP:
+ profile_info->security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_PAP;
+ break;
+ case WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAP:
+ profile_info->security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_MSCHAP;
+ break;
+ case WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAPV2:
+ profile_info->security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_MSCHAPV2;
+ break;
+ case WIFI_MANAGER_EAP_AUTH_TYPE_GTC:
+ profile_info->security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_GTC;
+ break;
+ case WIFI_MANAGER_EAP_AUTH_TYPE_MD5:
+ profile_info->security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_MD5;
+ break;
+ default:
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ }
+ //LCOV_EXCL_STOP
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "wifi-manager.h"
+#include "wifi_internal.h"
+
+/**
+ * Wifi Configuration CAPI
+ */
+EXPORT_API int wifi_manager_config_create(wifi_manager_h wifi, const char *name,
+ const char *passphrase, wifi_manager_security_type_e security_type, wifi_manager_config_h *config)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = NULL;
+
+ if (!(__wifi_check_handle_validity(wifi)) ||
+ config == NULL || name == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ h = g_new0(wifi_config_s, 1);
+ if (h == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+
+ h->name = g_strdup(name);
+ h->passphrase = g_strdup(passphrase);
+ h->security_type = security_type;
+ h->is_saved = FALSE;
+ h->is_hidden = FALSE;
+ h->proxy_address = NULL;
+ h->address_family = WIFI_MANAGER_ADDRESS_FAMILY_IPV4;
+ h->eap_config = NULL;
+
+ if (security_type == WIFI_MANAGER_SECURITY_TYPE_EAP) {
+ h->eap_config = g_new0(wifi_eap_config_s, 1);
+ if (h->eap_config == NULL) {
+ g_free(h->name); //LCOV_EXCL_LINE
+ g_free(h->passphrase); //LCOV_EXCL_LINE
+ g_free(h); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+
+ h->eap_config->ca_cert = NULL;
+ h->eap_config->client_cert = NULL;
+ h->eap_config->private_key = NULL;
+ h->eap_config->anonymous_identity = NULL;
+ h->eap_config->identity = NULL;
+ h->eap_config->subject_match = NULL;
+ h->eap_config->eap_type = -1;
+ h->eap_config->eap_auth_type = WIFI_MANAGER_EAP_AUTH_TYPE_NONE;
+ }
+
+ _wifi_add_to_config_list((wifi_manager_config_h)h);
+ *config = (wifi_manager_config_h)h;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_clone(wifi_manager_config_h origin, wifi_manager_config_h *cloned_config)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = NULL;
+ wifi_config_s *config = NULL;
+
+ if (_wifi_check_config_validity(origin) == false || cloned_config == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ config = (wifi_config_s *)origin;
+
+ h = g_new0(wifi_config_s, 1);
+ if (h == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+
+ h->name = g_strdup(config->name);
+ h->passphrase = g_strdup(config->passphrase);
+ h->security_type = config->security_type;
+ h->is_saved = config->is_saved;
+ h->is_hidden = config->is_hidden;
+ h->proxy_address = g_strdup(config->proxy_address);
+ h->address_family = config->address_family;
+
+ if (config->eap_config) {
+ h->eap_config = g_new0(wifi_eap_config_s, 1);
+ if (h->eap_config == NULL) {
+ g_free(h->name); //LCOV_EXCL_LINE
+ g_free(h->passphrase); //LCOV_EXCL_LINE
+ g_free(h->proxy_address); //LCOV_EXCL_LINE
+ g_free(h); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+
+ h->eap_config->ca_cert = g_strdup(config->eap_config->ca_cert);
+ h->eap_config->client_cert = g_strdup(config->eap_config->client_cert);
+ h->eap_config->private_key = g_strdup(config->eap_config->private_key);
+ h->eap_config->anonymous_identity = g_strdup(config->eap_config->anonymous_identity);
+ h->eap_config->identity = g_strdup(config->eap_config->identity);
+ h->eap_config->subject_match = g_strdup(config->eap_config->subject_match);
+ h->eap_config->eap_type = config->eap_config->eap_type;
+ h->eap_config->eap_auth_type = config->eap_config->eap_auth_type;
+ }
+
+ _wifi_add_to_config_list((wifi_manager_config_h)h);
+ *cloned_config = (wifi_manager_config_h)h;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_destroy(wifi_manager_config_h config)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ g_free(h->name);
+ g_free(h->passphrase);
+ g_free(h->proxy_address);
+ if (h->eap_config) {
+ g_free(h->eap_config->ca_cert);
+ g_free(h->eap_config->client_cert);
+ g_free(h->eap_config->private_key);
+ g_free(h->eap_config->anonymous_identity);
+ g_free(h->eap_config->identity);
+ g_free(h->eap_config->subject_match);
+ g_free(h->eap_config);
+ }
+
+ _wifi_remove_from_config_list(config);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_save(wifi_manager_h wifi,
+ wifi_manager_config_h config)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ int ret = WIFI_MANAGER_ERROR_NONE;
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (!(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (_wifi_check_config_validity(config) == false || h->name == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (h->security_type == WIFI_MANAGER_SECURITY_TYPE_EAP) {
+ ret = _wifi_save_eap_configurations(h->name, h->passphrase,
+ h->security_type, h->proxy_address, h->eap_config, h->is_hidden);
+ if (ret != WIFI_MANAGER_ERROR_NONE)
+ WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_eap_configurations"); //LCOV_EXCL_LINE
+ } else {
+ ret = _wifi_save_configuration(h->name,
+ h->passphrase, h->security_type, h->proxy_address, h->is_hidden);
+ if (ret != WIFI_MANAGER_ERROR_NONE)
+ WIFI_LOG(WIFI_ERROR, "Fail to save configurations [%d]", ret); //LCOV_EXCL_LINE
+ }
+
+ h->is_saved = TRUE;
+
+ return ret;
+}
+
+EXPORT_API int wifi_manager_config_remove(wifi_manager_h wifi, wifi_manager_config_h config)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ int ret = WIFI_MANAGER_ERROR_NONE;
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (!(__wifi_check_handle_validity(wifi)) ||
+ config == NULL || h->name == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (_wifi_check_config_validity(config) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (h->is_saved == TRUE) {
+ gchar *config_id = NULL;
+
+ config_id = _wifi_config_get_config_id(h->name, h->security_type);
+
+ ret = _wifi_remove_configuration(config_id);
+ if (ret != WIFI_MANAGER_ERROR_NONE)
+ WIFI_LOG(WIFI_ERROR, "Fail to remove configurations [%d]", ret);
+
+ g_free(config_id);
+ }
+
+ return ret;
+}
+
+EXPORT_API int wifi_manager_config_foreach_configuration(wifi_manager_h wifi,
+ wifi_manager_config_list_cb callback, void *user_data)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ int ret = WIFI_MANAGER_ERROR_NONE;
+
+ if (!(__wifi_check_handle_validity(wifi)) || callback == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ ret = _wifi_load_configurations();
+ if (ret != WIFI_MANAGER_ERROR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Fail to load configurations [%d]", ret); //LCOV_EXCL_LINE
+ return ret; //LCOV_EXCL_LINE
+ }
+
+ return _wifi_foreach_configuration(callback, user_data);
+}
+
+EXPORT_API int wifi_manager_config_get_name(wifi_manager_config_h config, char **name)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false || name == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (h->name != NULL)
+ *name = g_strdup(h->name);
+ else
+ *name = NULL;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_get_security_type(wifi_manager_config_h config,
+ wifi_manager_security_type_e *security_type)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false || security_type == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ *security_type = h->security_type;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+/**
+ * wifi configuration set field
+ */
+EXPORT_API int wifi_manager_config_set_proxy_address(wifi_manager_config_h config,
+ wifi_manager_address_family_e address_family, const char *proxy_address)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+ int ret = WIFI_MANAGER_ERROR_NONE;
+
+ if (_wifi_check_config_validity(config) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if ((address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 && address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6)) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (address_family == WIFI_MANAGER_ADDRESS_FAMILY_IPV6) {
+ WIFI_LOG(WIFI_ERROR, "Not supported yet"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; //LCOV_EXCL_LINE
+ }
+
+ h->address_family = address_family;
+ h->proxy_address = g_strdup(proxy_address);
+
+ return ret;
+}
+
+EXPORT_API int wifi_manager_config_get_proxy_address(wifi_manager_config_h config,
+ wifi_manager_address_family_e *address_family, char **proxy_address)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false ||
+ address_family == NULL || proxy_address == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ *address_family = h->address_family;
+ *proxy_address = g_strdup(h->proxy_address);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_set_hidden_ap_property(wifi_manager_config_h config, bool hidden)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+ int ret = WIFI_MANAGER_ERROR_NONE;
+
+ if (_wifi_check_config_validity(config) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ h->is_hidden = hidden;
+
+ return ret;
+}
+
+EXPORT_API int wifi_manager_config_get_hidden_ap_property(wifi_manager_config_h config,
+ bool *hidden)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false || hidden == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ *hidden = h->is_hidden;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_get_eap_anonymous_identity(wifi_manager_config_h config,
+ char **anonymous_identity)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false ||
+ h->eap_config == NULL || anonymous_identity == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ *anonymous_identity = g_strdup(h->eap_config->anonymous_identity);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_set_eap_anonymous_identity(wifi_manager_config_h config,
+ const char *anonymous_identity)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false || h->eap_config == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ h->eap_config->anonymous_identity = g_strdup(anonymous_identity);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_get_eap_ca_cert_file(wifi_manager_config_h config,
+ char **ca_cert)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false ||
+ h->eap_config == NULL || ca_cert == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ *ca_cert = g_strdup(h->eap_config->ca_cert);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_set_eap_ca_cert_file(wifi_manager_config_h config,
+ const char *ca_cert)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false || h->eap_config == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ h->eap_config->ca_cert = g_strdup(ca_cert);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_get_eap_client_cert_file(wifi_manager_config_h config,
+ char **client_cert)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false ||
+ h->eap_config == NULL || client_cert == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ *client_cert = g_strdup(h->eap_config->client_cert);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_set_eap_client_cert_file(wifi_manager_config_h config,
+ const char *private_key, const char *client_cert)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false || h->eap_config == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ h->eap_config->private_key = g_strdup(private_key);
+ h->eap_config->client_cert = g_strdup(client_cert);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_get_eap_identity(wifi_manager_config_h config, char **identity)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false ||
+ h->eap_config == NULL || identity == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ *identity = g_strdup(h->eap_config->identity);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_set_eap_identity(wifi_manager_config_h config, const char *identity)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false || h->eap_config == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ h->eap_config->identity = g_strdup(identity);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_get_eap_type(wifi_manager_config_h config,
+ wifi_manager_eap_type_e *eap_type)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false ||
+ h->eap_config == NULL || eap_type == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ *eap_type = h->eap_config->eap_type;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_set_eap_type(wifi_manager_config_h config,
+ wifi_manager_eap_type_e eap_type)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false || h->eap_config == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ h->eap_config->eap_type = eap_type;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_get_eap_auth_type(wifi_manager_config_h config,
+ wifi_manager_eap_auth_type_e *eap_auth_type)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false ||
+ h->eap_config == NULL || eap_auth_type == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ *eap_auth_type = h->eap_config->eap_auth_type;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_set_eap_auth_type(wifi_manager_config_h config,
+ wifi_manager_eap_auth_type_e eap_auth_type)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false || h->eap_config == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ h->eap_config->eap_auth_type = eap_auth_type;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_get_eap_subject_match(wifi_manager_config_h config,
+ char **subject_match)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false ||
+ h->eap_config == NULL || subject_match == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ *subject_match = g_strdup(h->eap_config->subject_match);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_set_eap_subject_match(wifi_manager_config_h config,
+ const char *subject_match)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false || h->eap_config == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ h->eap_config->subject_match = g_strdup(subject_match);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "wifi_internal.h"
+
+#define WIFI_SECURITY_NONE "none"
+#define WIFI_SECURITY_WEP "wep"
+#define WIFI_SECURITY_WPA_PSK "psk"
+#define WIFI_SECURITY_EAP "ieee8021x"
+
+static __thread GSList *wifi_manager_handle_list = NULL;
+static __thread GSList *ap_handle_list = NULL;
+static __thread GSList *config_handle_list = NULL;
+
+static __thread GSList *profile_iterator = NULL;
+static __thread GSList *specific_profile_iterator = NULL;
+static __thread GSList *config_iterator = NULL;
+static __thread char specific_profile_essid[NET_WLAN_ESSID_LEN + 1] = { 0, };
+static __thread bool wifi_is_feature_checked[WIFI_SUPPORTED_FEATURE_MAX] = {0, };
+static __thread bool wifi_feature_supported[WIFI_SUPPORTED_FEATURE_MAX] = {0, };
+
+//LCOV_EXCL_START
+static wifi_manager_error_e __convert_to_ap_error_type(net_err_e err_type)
+{
+ switch (err_type) {
+ case NET_ERR_NONE:
+ return WIFI_MANAGER_ERROR_NONE;
+ case NET_ERR_APP_ALREADY_REGISTERED:
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION;
+ case NET_ERR_APP_NOT_REGISTERED:
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION;
+ case NET_ERR_NO_ACTIVE_CONNECTIONS:
+ return WIFI_MANAGER_ERROR_NO_CONNECTION;
+ case NET_ERR_ACTIVE_CONNECTION_EXISTS:
+ return WIFI_MANAGER_ERROR_ALREADY_EXISTS;
+ case NET_ERR_CONNECTION_DHCP_FAILED:
+ return WIFI_MANAGER_ERROR_DHCP_FAILED;
+ case NET_ERR_CONNECTION_INVALID_KEY:
+ return WIFI_MANAGER_ERROR_INVALID_KEY;
+ case NET_ERR_IN_PROGRESS:
+ return WIFI_MANAGER_ERROR_NOW_IN_PROGRESS;
+ case NET_ERR_OPERATION_ABORTED:
+ return WIFI_MANAGER_ERROR_OPERATION_ABORTED;
+ case NET_ERR_TIME_OUT:
+ return WIFI_MANAGER_ERROR_NO_REPLY;
+ case NET_ERR_ACCESS_DENIED:
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
+ default:
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ }
+}
+
+static const char *__convert_ap_error_type_to_string(wifi_manager_error_e err_type)
+{
+ switch (err_type) {
+ case WIFI_MANAGER_ERROR_NONE:
+ return "NONE";
+ case WIFI_MANAGER_ERROR_INVALID_PARAMETER:
+ return "INVALID_PARAMETER";
+ case WIFI_MANAGER_ERROR_OUT_OF_MEMORY:
+ return "OUT_OF_MEMORY";
+ case WIFI_MANAGER_ERROR_INVALID_OPERATION:
+ return "INVALID_OPERATION";
+ case WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+ return "ADDRESS_FAMILY_NOT_SUPPORTED";
+ case WIFI_MANAGER_ERROR_OPERATION_FAILED:
+ return "OPERATION_FAILED";
+ case WIFI_MANAGER_ERROR_NO_CONNECTION:
+ return "NO_CONNECTION";
+ case WIFI_MANAGER_ERROR_NOW_IN_PROGRESS:
+ return "NOW_IN_PROGRESS";
+ case WIFI_MANAGER_ERROR_ALREADY_EXISTS:
+ return "ALREADY_EXISTS";
+ case WIFI_MANAGER_ERROR_OPERATION_ABORTED:
+ return "OPERATION_ABORTED";
+ case WIFI_MANAGER_ERROR_DHCP_FAILED:
+ return "DHCP_FAILED";
+ case WIFI_MANAGER_ERROR_INVALID_KEY:
+ return "INVALID_KEY";
+ case WIFI_MANAGER_ERROR_NO_REPLY:
+ return "NO_REPLY";
+ case WIFI_MANAGER_ERROR_SECURITY_RESTRICTED:
+ return "SECURITY_RESTRICTED";
+ case WIFI_MANAGER_ERROR_ALREADY_INITIALIZED:
+ return "ALREADY_INITIALIZED";
+ case WIFI_MANAGER_ERROR_PERMISSION_DENIED:
+ return "PERMISSION_DENIED";
+ case WIFI_MANAGER_ERROR_NOT_SUPPORTED:
+ return "NOT_SUPPROTED";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static const char *__convert_ap_state_to_string(wifi_manager_connection_state_e state)
+{
+ switch (state) {
+ case WIFI_MANAGER_CONNECTION_STATE_FAILURE:
+ return "FAILURE";
+ case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED:
+ return "DISCONNECTED";
+ case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION:
+ return "ASSOCIATION";
+ case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION:
+ return "CONFIGURATION";
+ case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
+ return "CONNECTED";
+ default:
+ return "UNKNOWN";
+ }
+}
+//LCOV_EXCL_STOP
+
+static gchar *__wifi_change_name_to_hexadecimal(const gchar *name)
+{
+ GString *string;
+ gint i = 0;
+ gint length = 0;
+ gchar *hex = NULL;
+
+ if (name == NULL)
+ return NULL;
+
+ length = strlen(name);
+
+ string = g_string_sized_new((gsize)(length * 2));
+ if (string == NULL)
+ return NULL;
+
+ for (i = 0; i < length; i++)
+ g_string_append_printf(string, "%02x", name[i]);
+
+ hex = g_strdup_printf("%s", string->str);
+ g_string_free(string, TRUE);
+
+ return hex;
+}
+
+//LCOV_EXCL_START
+static gchar *__wifi_security_type_to_string(wifi_manager_security_type_e security_type)
+{
+ switch (security_type) {
+ case WIFI_MANAGER_SECURITY_TYPE_NONE:
+ return WIFI_SECURITY_NONE;
+
+ case WIFI_MANAGER_SECURITY_TYPE_WEP:
+ return WIFI_SECURITY_WEP;
+
+ case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
+ case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
+ return WIFI_SECURITY_WPA_PSK;
+
+ case WIFI_MANAGER_SECURITY_TYPE_EAP:
+ return WIFI_SECURITY_EAP;
+
+ default:
+ return NULL;
+ }
+}
+
+gchar *_wifi_eap_type_to_string(wifi_manager_eap_type_e eap_type)
+{
+ gchar *type = NULL;
+
+ switch (eap_type) {
+ case WIFI_MANAGER_EAP_TYPE_PEAP:
+ type = g_strdup("PEAP");
+ break;
+ case WIFI_MANAGER_EAP_TYPE_TLS:
+ type = g_strdup("TLS");
+ break;
+ case WIFI_MANAGER_EAP_TYPE_TTLS:
+ type = g_strdup("TTLS");
+ break;
+ case WIFI_MANAGER_EAP_TYPE_SIM:
+ type = g_strdup("SIM");
+ break;
+ case WIFI_MANAGER_EAP_TYPE_AKA:
+ type = g_strdup("AKA");
+ break;
+ }
+ return type;
+}
+
+gchar *_wifi_eap_auth_type_to_string(wifi_manager_eap_auth_type_e eap_auth_type)
+{
+ gchar *type = NULL;
+
+ switch (eap_auth_type) {
+ case WIFI_MANAGER_EAP_AUTH_TYPE_PAP:
+ type = g_strdup("PAP");
+ break;
+ case WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAP:
+ type = g_strdup("MSCHAP");
+ break;
+ case WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAPV2:
+ type = g_strdup("MSCHAPV2");
+ break;
+ case WIFI_MANAGER_EAP_AUTH_TYPE_GTC:
+ type = g_strdup("GTC");
+ break;
+ case WIFI_MANAGER_EAP_AUTH_TYPE_MD5:
+ type = g_strdup("MD5");
+ break;
+ default:
+ case WIFI_MANAGER_EAP_AUTH_TYPE_NONE:
+ type = NULL;
+ break;
+ }
+ return type;
+}
+//LCOV_EXCL_STOP
+
+static void __clear_profile_list(void)
+{
+ profile_iterator = g_slist_nth(profile_iterator, 0);
+ g_slist_free_full(profile_iterator, g_free);
+ profile_iterator = NULL;
+}
+
+static void __clear_specific_profile_list(void)
+{
+ specific_profile_iterator = g_slist_nth(specific_profile_iterator, 0);
+ g_slist_free_full(specific_profile_iterator, g_free);
+ specific_profile_iterator = NULL;
+}
+
+static void __clear_config_list(void)
+{
+ config_iterator = g_slist_nth(config_iterator, 0);
+ g_slist_free_full(config_iterator, g_free);
+ config_iterator = NULL;
+}
+
+static int __update_profile_iterator(void)
+{
+ int rv;
+
+ __clear_profile_list();
+
+ rv = net_get_profile_list(&profile_iterator);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+static void __convert_profile_info_to_wifi_info(net_wifi_connection_info_s *wifi_info,
+ net_profile_info_s *ap_info)
+{
+ g_strlcpy(wifi_info->essid, ap_info->essid, NET_WLAN_ESSID_LEN+1);
+ wifi_info->wlan_mode = ap_info->wlan_mode;
+ memcpy(&wifi_info->security_info, &ap_info->security_info, sizeof(wlan_security_info_s));
+ wifi_info->is_hidden = ap_info->is_hidden;
+}
+
+static int __connect_with_wifi_info(net_profile_info_s *ap_info)
+{
+ int rv;
+ net_wifi_connection_info_s wifi_info;
+ memset(&wifi_info, 0, sizeof(net_wifi_connection_info_s));
+
+ __convert_profile_info_to_wifi_info(&wifi_info, ap_info);
+
+ rv = net_open_connection_with_wifi_info(&wifi_info);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied");
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE)
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+static int __load_configurations(const gchar *config_id, gchar **name,
+ wifi_manager_security_type_e *security_type, gchar **proxy_address, gboolean *is_hidden,
+ wifi_manager_error_e *last_error)
+{
+ int rv;
+
+ rv = net_config_load_configurations(config_id, name, security_type,
+ proxy_address, is_hidden, last_error);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+static int __load_eap_configurations(const gchar *config_id, gchar **name,
+ wifi_manager_security_type_e *security_type, gchar **proxy_address, gboolean *is_hidden,
+ wifi_eap_config_s **eap_config, wifi_manager_error_e *last_error)
+{
+ int rv;
+
+ rv = net_config_load_eap_configurations(config_id, name, security_type,
+ proxy_address, is_hidden, (void **)eap_config, last_error);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+//LCOV_EXCL_START
+static void __state_changed_cb(char *profile_name,
+ net_profile_info_s *profile_info, wifi_manager_connection_state_e state)
+{
+ GSList *list;
+ net_profile_info_s *ap_info = NULL;
+
+ if (profile_name == NULL)
+ return;
+
+ WIFI_LOG(WIFI_INFO, "%s state changed : %d", profile_name, state);
+
+ if (_wifi_get_callback_count_from_handle_list(WIFI_MANAGER_CONNECTION_STATE_CB)) {
+ ap_info = g_try_malloc0(sizeof(net_profile_info_s));
+ if (ap_info == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Memory allocation error");
+ return;
+ }
+
+ WIFI_LOG(WIFI_INFO, "[Ap info] profile name(%s) essid(%s) bssid(%s)",
+ ap_info->ProfileName, ap_info->essid, ap_info->bssid);
+
+ if (profile_info)
+ memcpy(ap_info, profile_info, sizeof(net_profile_info_s));
+
+ WIFI_LOG(WIFI_INFO, "[Ap info] profile name(%s) essid(%s) bssid(%s)",
+ ap_info->ProfileName, ap_info->essid, ap_info->bssid);
+
+ _wifi_add_to_ap_list(ap_info);
+
+ for (list = wifi_manager_handle_list; list; list = list->next) {
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
+ if (local_handle->connection_state_cb)
+ local_handle->connection_state_cb(state, ap_info,
+ local_handle->connection_state_user_data);
+ }
+
+ _wifi_remove_from_ap_list(ap_info);
+ }
+}
+
+static void __set_activated_cb(wifi_manager_h wifi,
+ wifi_manager_activated_cb user_cb, void *user_data)
+{
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
+
+ if (user_cb != NULL) {
+ local_handle->activated_cb = user_cb;
+ local_handle->activated_user_data = user_data;
+ }
+}
+
+static void __set_deactivated_cb(wifi_manager_h wifi,
+ wifi_manager_deactivated_cb user_cb, void *user_data)
+{
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
+
+ if (user_cb != NULL) {
+ local_handle->deactivated_cb = user_cb;
+ local_handle->deactivated_user_data = user_data;
+ }
+}
+
+static void __power_on_off_cb(net_event_info_s *event_cb, bool is_requested)
+{
+ if (net_check_ref_count() != true) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
+ }
+
+ if (!_wifi_get_callback_count_from_handle_list(WIFI_ACTIVATED_CB) &&
+ !_wifi_get_callback_count_from_handle_list(WIFI_DEACTIVATED_CB) &&
+ !_wifi_get_callback_count_from_handle_list(WIFI_DEVICE_STATE_CB))
+ return;
+
+ GSList *list;
+ wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE;
+ wifi_manager_device_state_e state = WIFI_MANAGER_DEVICE_STATE_DEACTIVATED;
+ net_wifi_state_e *wifi_state = (net_wifi_state_e *)event_cb->Data;
+
+ if (event_cb->Error == NET_ERR_NONE &&
+ event_cb->Datalength == sizeof(net_wifi_state_e)) {
+ if (*wifi_state == WIFI_ON) {
+ WIFI_LOG(WIFI_INFO, "Wi-Fi power on");
+ state = WIFI_MANAGER_DEVICE_STATE_ACTIVATED;
+ } else if (*wifi_state == WIFI_OFF) {
+ WIFI_LOG(WIFI_INFO, "Wi-Fi power off");
+ state = WIFI_MANAGER_DEVICE_STATE_DEACTIVATED;
+ __clear_profile_list();
+ __clear_specific_profile_list();
+ } else {
+ WIFI_LOG(WIFI_ERROR, "Error Wi-Fi state %d", *wifi_state);
+ error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ state = WIFI_MANAGER_DEVICE_STATE_DEACTIVATED;
+ }
+ } else {
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi power request failed(%d)", event_cb->Error);
+
+ if (event_cb->Error == NET_ERR_SECURITY_RESTRICTED)
+ error_code = WIFI_MANAGER_ERROR_SECURITY_RESTRICTED;
+ else
+ error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED;
+
+ state = WIFI_MANAGER_DEVICE_STATE_DEACTIVATED;
+ }
+
+ if (_wifi_get_callback_count_from_handle_list(WIFI_ACTIVATED_CB)) {
+ for (list = wifi_manager_handle_list; list; list = list->next) {
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
+ if (local_handle->activated_cb)
+ local_handle->activated_cb(error_code, local_handle->activated_user_data);
+
+ local_handle->activated_cb = NULL;
+ local_handle->activated_user_data = NULL;
+ }
+ }
+
+ if (_wifi_get_callback_count_from_handle_list(WIFI_DEACTIVATED_CB)) {
+ for (list = wifi_manager_handle_list; list; list = list->next) {
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
+ if (local_handle->deactivated_cb != NULL)
+ local_handle->deactivated_cb(error_code, local_handle->deactivated_user_data);
+
+ local_handle->deactivated_cb = NULL;
+ local_handle->deactivated_user_data = NULL;
+ }
+ }
+
+ if (_wifi_get_callback_count_from_handle_list(WIFI_DEVICE_STATE_CB)) {
+ for (list = wifi_manager_handle_list; list; list = list->next) {
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
+ if (local_handle->device_state_cb)
+ local_handle->device_state_cb(state, local_handle->device_state_user_data);
+ }
+ }
+}
+
+static void __set_scan_cb(wifi_manager_h wifi,
+ wifi_manager_scan_finished_cb user_cb, void *user_data)
+{
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
+
+ if (user_cb) {
+ local_handle->scan_request_cb = user_cb;
+ local_handle->scan_request_user_data = user_data;
+ }
+}
+
+static void __set_specific_scan_cb(wifi_manager_h wifi,
+ wifi_manager_scan_finished_cb user_cb, void *user_data)
+{
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
+
+ if (user_cb) {
+ local_handle->specific_scan_cb = user_cb;
+ local_handle->specific_scan_user_data = user_data;
+ }
+}
+
+static void __scan_cb(net_event_info_s *event_cb, bool is_requested)
+{
+ GSList *list;
+ wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE;
+
+ if (net_check_ref_count() != true) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
+ }
+
+ if (event_cb->Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Scan failed[%d]", event_cb->Error);
+ error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ }
+
+ if (_wifi_get_callback_count_from_handle_list(WIFI_SCAN_REQUEST_CB)) {
+ for (list = wifi_manager_handle_list; list; list = list->next) {
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
+ if (local_handle->scan_request_cb)
+ local_handle->scan_request_cb(error_code, local_handle->scan_request_user_data);
+
+ local_handle->scan_request_cb = NULL;
+ local_handle->scan_request_user_data = NULL;
+ }
+ return;
+ }
+
+ if (_wifi_get_callback_count_from_handle_list(WIFI_BG_SCAN_CB)){
+ for (list = wifi_manager_handle_list; list; list = list->next) {
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
+ if (local_handle->bg_scan_cb)
+ local_handle->bg_scan_cb(error_code, local_handle->bg_scan_user_data);
+ }
+ }
+}
+
+static void __specific_scan_cb(net_event_info_s *event_cb)
+{
+ GSList *list;
+ wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE;
+
+ __clear_specific_profile_list();
+
+ if (event_cb->Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Specific scan failed!, Error [%d]\n", event_cb->Error);
+ error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ } else if (event_cb->Data) {
+ specific_profile_iterator = (GSList *)event_cb->Data;
+ WIFI_LOG(WIFI_INFO, "Specific AP count : %d\n",
+ (int)g_slist_length(specific_profile_iterator));
+ }
+
+ if (_wifi_get_callback_count_from_handle_list(WIFI_SPECIFIC_SCAN_CB)) {
+ for (list = wifi_manager_handle_list; list; list = list->next) {
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
+ if (local_handle->specific_scan_cb)
+ local_handle->specific_scan_cb(error_code, local_handle->specific_scan_user_data);
+
+ local_handle->specific_scan_cb = NULL;
+ local_handle->specific_scan_user_data = NULL;
+ }
+ }
+}
+
+static void __set_connected_cb(wifi_manager_h wifi,
+ wifi_manager_connected_cb user_cb, void *user_data)
+{
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
+
+ if (user_cb != NULL) {
+ local_handle->connected_cb = user_cb;
+ local_handle->connected_user_data = user_data;
+ }
+}
+
+static void __connected_cb(wifi_manager_error_e result)
+{
+ GSList *list;
+
+ if (net_check_ref_count() != true) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
+ }
+
+ if (_wifi_get_callback_count_from_handle_list(WIFI_CONNECTED_CB)) {
+ for (list = wifi_manager_handle_list; list; list = list->next) {
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
+ if (local_handle->connected_cb != NULL)
+ local_handle->connected_cb(result, local_handle->connected_user_data);
+
+ local_handle->connected_cb = NULL;
+ local_handle->connected_user_data = NULL;
+ }
+ }
+}
+
+static void __set_disconnected_cb(wifi_manager_h wifi,
+ wifi_manager_disconnected_cb user_cb, void *user_data)
+{
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
+
+ if (user_cb != NULL) {
+ local_handle->disconnected_cb = user_cb;
+ local_handle->disconnected_user_data = user_data;
+ }
+}
+
+static void __disconnected_cb(wifi_manager_error_e result)
+{
+ GSList *list;
+
+ if (net_check_ref_count() != true) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
+ }
+
+ if (_wifi_get_callback_count_from_handle_list(WIFI_DISCONNECTED_CB)) {
+ for (list = wifi_manager_handle_list; list; list = list->next) {
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
+ if (local_handle->disconnected_cb != NULL)
+ local_handle->disconnected_cb(result, local_handle->disconnected_user_data);
+
+ local_handle->disconnected_cb = NULL;
+ local_handle->disconnected_user_data = NULL;
+ }
+ }
+}
+//LCOV_EXCL_STOP
+
+static void _wifi_evt_cb(net_event_info_s *event_cb, void *user_data)
+{
+ bool is_requested = false;
+ net_profile_info_s *prof_info_p = NULL;
+ net_profile_info_s prof_info;
+ wifi_manager_error_e result = WIFI_MANAGER_ERROR_NONE;
+ bool is_profile_exists = false;
+ GSList *list = NULL;
+
+ switch (event_cb->Event) {
+ case NET_EVENT_OPEN_RSP:
+ case NET_EVENT_WIFI_WPS_RSP:
+ is_requested = true;
+ /* fall through */
+ case NET_EVENT_OPEN_IND:
+ if (_wifi_check_profile_name_validity(event_cb->ProfileName) != true)
+ return;
+
+ result = __convert_to_ap_error_type(event_cb->Error);
+ WIFI_LOG(WIFI_INFO, "Connection open error %s",
+ __convert_ap_error_type_to_string(result));
+
+ if (is_requested)
+ __connected_cb(result);
+
+ switch (event_cb->Error) {
+ case NET_ERR_NONE:
+ if (event_cb->Datalength == sizeof(net_profile_info_s))
+ prof_info_p = (net_profile_info_s *)event_cb->Data;
+
+ __state_changed_cb(event_cb->ProfileName, prof_info_p,
+ WIFI_MANAGER_CONNECTION_STATE_CONNECTED);
+ return;
+ case NET_ERR_ACTIVE_CONNECTION_EXISTS:
+ return;
+ default:
+ break;
+ }
+
+ if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE)
+ __state_changed_cb(event_cb->ProfileName, &prof_info,
+ WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED);
+ else
+ __state_changed_cb(event_cb->ProfileName, NULL,
+ WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED);
+
+ break;
+ case NET_EVENT_CLOSE_RSP:
+ is_requested = true;
+ /* fall through */
+ case NET_EVENT_CLOSE_IND:
+ if (_wifi_check_profile_name_validity(event_cb->ProfileName) != true)
+ return;
+
+ result = __convert_to_ap_error_type(event_cb->Error);
+ WIFI_LOG(WIFI_ERROR, "Connection close error %s",
+ __convert_ap_error_type_to_string(result));
+
+ if (is_requested)
+ __disconnected_cb(result);
+
+ switch (event_cb->Error) {
+ case NET_ERR_NONE:
+ if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE)
+ __state_changed_cb(event_cb->ProfileName, &prof_info,
+ WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED);
+ else
+ __state_changed_cb(event_cb->ProfileName, NULL,
+ WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED);
+ return;
+ default:
+ break;
+ }
+
+ break;
+ case NET_EVENT_NET_STATE_IND:
+ if (_wifi_check_profile_name_validity(event_cb->ProfileName) != true)
+ return;
+
+ if (event_cb->Datalength != sizeof(net_state_type_e))
+ return;
+
+ net_state_type_e *profile_state = (net_state_type_e *)event_cb->Data;
+ wifi_manager_connection_state_e ap_state = _wifi_convert_to_ap_state(*profile_state);
+
+ WIFI_LOG(WIFI_INFO, "state: %s", __convert_ap_state_to_string(ap_state));
+ WIFI_LOG(WIFI_INFO, "profile name: %s", event_cb->ProfileName);
+
+ if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE)
+ __state_changed_cb(event_cb->ProfileName, &prof_info, ap_state);
+ else if (ap_state == WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED) {
+ net_profile_info_s *profile = NULL;
+ for (list = profile_iterator; list; list = list->next) {
+ profile = (net_profile_info_s *)list->data;
+ if (!g_strcmp0(event_cb->ProfileName, profile->ProfileName)) {
+ is_profile_exists = true;
+ break;
+ }
+ }
+
+ if (is_profile_exists == true) {
+ profile->ProfileState = *profile_state;
+ __state_changed_cb(event_cb->ProfileName, profile, ap_state);
+ } else
+ __state_changed_cb(event_cb->ProfileName,
+ NULL, ap_state);
+ } else
+ __state_changed_cb(event_cb->ProfileName, NULL, ap_state);
+
+ break;
+ case NET_EVENT_WIFI_SCAN_RSP:
+ case NET_EVENT_WIFI_SCAN_IND:
+ __scan_cb(event_cb, is_requested);
+ break;
+ case NET_EVENT_WIFI_SPECIFIC_SCAN_RSP:
+ WIFI_LOG(WIFI_INFO, "Got Wi-Fi specific scan RSP\n");
+ break;
+ case NET_EVENT_WIFI_SPECIFIC_SCAN_IND:
+ WIFI_LOG(WIFI_INFO, "Got Wi-Fi specific scan IND\n");
+ __specific_scan_cb(event_cb);
+ break;
+ case NET_EVENT_WIFI_POWER_RSP:
+ is_requested = true;
+ /* fall through */
+ case NET_EVENT_WIFI_POWER_IND:
+ __power_on_off_cb(event_cb, is_requested);
+ break;
+ default:
+ break;
+ }
+}
+
+int _wifi_init(void)
+{
+ int rv;
+
+ rv = net_register_client_ext((net_event_cb)_wifi_evt_cb, NULL);
+ if (rv != NET_ERR_NONE && rv != NET_ERR_APP_ALREADY_REGISTERED) {
+ WIFI_LOG(WIFI_ERROR, "Failed to register client [%d]", rv);
+ return rv;
+ }
+
+ return NET_ERR_NONE;
+}
+
+int _wifi_create_handle(wifi_manager_h *wifi)
+{
+ *wifi = g_try_malloc0(sizeof(wifi_manager_handle_s));
+
+ if (*wifi != NULL)
+ WIFI_LOG(WIFI_INFO, "New handle create[%p]", *wifi);
+ else {
+ WIFI_LOG(WIFI_ERROR, "Failed to create wifi handle");
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_add_to_handle_list(wifi_manager_h *wifi)
+{
+ wifi_manager_handle_list = g_slist_append(wifi_manager_handle_list, *wifi);
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+void _wifi_remove_from_handle_list(wifi_manager_h wifi)
+{
+ wifi_manager_handle_list = g_slist_remove(wifi_manager_handle_list, wifi);
+
+ g_free(wifi);
+ wifi = NULL;
+}
+
+bool _wifi_find_from_handle_list(wifi_manager_h wifi)
+{
+ if (g_slist_find(wifi_manager_handle_list, wifi) != NULL)
+ return true;
+ else
+ return false;
+}
+
+int _wifi_get_count_from_handle_list(void)
+{
+ return ((int)g_slist_length(wifi_manager_handle_list));
+}
+
+int _wifi_get_callback_count_from_handle_list(wifi_manager_handle_cb_e e)
+{
+ GSList *list;
+ int count = 0;
+
+ for (list = wifi_manager_handle_list; list; list = list->next) {
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
+ switch (e) {
+ case WIFI_DEVICE_STATE_CB:
+ if (local_handle->device_state_cb)
+ ++count;
+ break;
+ case WIFI_BG_SCAN_CB:
+ if (local_handle->bg_scan_cb)
+ ++count;
+ break;
+ case WIFI_SCAN_REQUEST_CB:
+ if (local_handle->scan_request_cb)
+ ++count;
+ break;
+ case WIFI_SPECIFIC_SCAN_CB:
+ if (local_handle->specific_scan_cb)
+ ++count;
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_CB:
+ if (local_handle->connection_state_cb)
+ ++count;
+ break;
+ case WIFI_ACTIVATED_CB:
+ if (local_handle->activated_cb)
+ ++count;
+ break;
+ case WIFI_DEACTIVATED_CB:
+ if (local_handle->deactivated_cb)
+ ++count;
+ break;
+ case WIFI_CONNECTED_CB:
+ if (local_handle->connected_cb)
+ ++count;
+ break;
+ case WIFI_DISCONNECTED_CB:
+ if (local_handle->disconnected_cb)
+ ++count;
+ break;
+ case WIFI_MANAGER_RSSI_LEVEL_CHANGED_CB:
+ if (local_handle->rssi_level_changed_cb)
+ ++count;
+ break;
+ case WIFI_MANAGER_TDLS_STATE_CHANGED_CB:
+ if (local_handle->tdls_state_changed_cb)
+ ++count;
+ break;
+ default:
+ break;
+ }
+ }
+
+ return count;
+}
+
+bool _wifi_deinit(void)
+{
+ int rv = net_deregister_client_ext();
+ if (rv != NET_ERR_NONE && rv != NET_ERR_APP_NOT_REGISTERED)
+ return false;
+
+ __clear_profile_list();
+ __clear_specific_profile_list();
+
+ g_slist_free_full(ap_handle_list, g_free);
+ ap_handle_list = NULL;
+
+ g_slist_free_full(config_handle_list, g_free);
+ config_handle_list = NULL;
+
+ g_slist_free_full(config_iterator, g_free);
+ config_iterator = NULL;
+
+ return true;
+}
+
+int _wifi_activate(wifi_manager_h wifi, wifi_manager_activated_cb callback,
+ gboolean wifi_picker_test, void *user_data)
+{
+ int rv = NET_ERR_NONE;
+
+ rv = net_wifi_power_on(wifi_picker_test);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_INVALID_OPERATION) {
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_ALREADY_EXISTS) {
+ return WIFI_MANAGER_ERROR_ALREADY_EXISTS; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_IN_PROGRESS) {
+ return WIFI_MANAGER_ERROR_NOW_IN_PROGRESS; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_SECURITY_RESTRICTED) {
+ return WIFI_MANAGER_ERROR_SECURITY_RESTRICTED; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_NONE) {
+ __set_activated_cb(wifi, callback, user_data);
+ return WIFI_MANAGER_ERROR_NONE;
+ }
+
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+}
+
+int _wifi_deactivate(wifi_manager_h wifi, wifi_manager_deactivated_cb callback, void *user_data)
+{
+ int rv = NET_ERR_NONE;
+
+ rv = net_wifi_power_off();
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_INVALID_OPERATION) {
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_ALREADY_EXISTS) {
+ return WIFI_MANAGER_ERROR_ALREADY_EXISTS; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_IN_PROGRESS) {
+ return WIFI_MANAGER_ERROR_NOW_IN_PROGRESS; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_SECURITY_RESTRICTED) {
+ return WIFI_MANAGER_ERROR_SECURITY_RESTRICTED; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_NONE) {
+ __set_deactivated_cb(wifi, callback, user_data);
+ return WIFI_MANAGER_ERROR_NONE;
+ }
+
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+}
+
+bool _wifi_check_ap_validity(wifi_manager_ap_h ap_h)
+{
+ 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 (list = profile_iterator; list; list = list->next)
+ if (ap_h == list->data) return true;
+
+ for (list = specific_profile_iterator; list; list = list->next)
+ if (ap_h == list->data) return true;
+
+ return false;
+}
+
+void _wifi_add_to_ap_list(wifi_manager_ap_h ap_h)
+{
+ ap_handle_list = g_slist_append(ap_handle_list, ap_h);
+}
+
+void _wifi_remove_from_ap_list(wifi_manager_ap_h ap_h)
+{
+ ap_handle_list = g_slist_remove(ap_handle_list, ap_h);
+ g_free(ap_h);
+}
+
+bool _wifi_check_profile_name_validity(const char *profile_name)
+{
+ const char *profile_prefix = "/net/connman/service/wifi_";
+ int i = 0;
+
+ if (profile_name == NULL ||
+ g_str_has_prefix(profile_name, profile_prefix) != TRUE) {
+ WIFI_LOG(WIFI_INFO, "The profile is a hidden or not a regular Wi-Fi profile");
+ return false;
+ }
+
+ while (profile_name[i] != '\0') {
+ if (isgraph(profile_name[i]) == 0) {
+ WIFI_LOG(WIFI_INFO, "Invalid format: %s", profile_name); //LCOV_EXCL_LINE
+ return false; //LCOV_EXCL_LINE
+ }
+ i++;
+ }
+
+ return true;
+}
+
+int _wifi_get_wifi_device_state(wifi_manager_device_state_e *device_state)
+{
+ net_tech_info_s tech_info;
+
+ int rv = NET_ERR_NONE;
+ rv = net_get_technology_properties(&tech_info);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get technology properties"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ if (tech_info.powered)
+ *device_state = WIFI_MANAGER_DEVICE_STATE_ACTIVATED;
+ else
+ *device_state = WIFI_MANAGER_DEVICE_STATE_DEACTIVATED;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_get_wifi_state(wifi_manager_connection_state_e *connection_state)
+{
+ int rv;
+ net_wifi_state_e wlan_state = 0;
+
+ rv = net_get_wifi_state(&wlan_state);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ switch (wlan_state) {
+ //LCOV_EXCL_START
+ case WIFI_OFF:
+ case WIFI_ON:
+ *connection_state = WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED;
+ break;
+ case WIFI_ASSOCIATION:
+ *connection_state = WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION;
+ break;
+ case WIFI_CONFIGURATION:
+ *connection_state = WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION;
+ break;
+ case WIFI_CONNECTED:
+ *connection_state = WIFI_MANAGER_CONNECTION_STATE_CONNECTED;
+ break;
+ case WIFI_DISCONNECTING:
+ *connection_state = WIFI_MANAGER_CONNECTION_STATE_CONNECTED;
+ break;
+ default:
+ WIFI_LOG(WIFI_ERROR, "Unknown state");
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ //LCOV_EXCL_STOP
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_get_intf_name(char** name)
+{
+ int rv;
+
+ if ((int)g_slist_length(profile_iterator) == 0) {
+ rv = __update_profile_iterator();
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ }
+ }
+
+ if ((int)g_slist_length(profile_iterator) == 0) {
+ WIFI_LOG(WIFI_ERROR, "There is no AP"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile = (net_profile_info_s *)profile_iterator->data;
+ *name = g_strdup(profile->net_info.DevName);
+ if (*name == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_scan_request(wifi_manager_h wifi,
+ wifi_manager_scan_finished_cb callback, void *user_data)
+{
+ int rv;
+ rv = net_scan_wifi();
+
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_INVALID_OPERATION) {
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_NONE) {
+ __set_scan_cb(wifi, callback, user_data);
+ return WIFI_MANAGER_ERROR_NONE;
+ }
+
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+}
+
+int _wifi_scan_specific_ap(wifi_manager_h wifi, const char *essid,
+ wifi_manager_scan_finished_cb callback, void *user_data)
+{
+ int rv;
+ rv = net_specific_scan_wifi(essid);
+
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_INVALID_OPERATION) {
+ return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_NONE) {
+ g_strlcpy(specific_profile_essid, essid, NET_WLAN_ESSID_LEN+1);
+ __set_specific_scan_cb(wifi, callback, user_data);
+ return WIFI_MANAGER_ERROR_NONE;
+ }
+
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+}
+
+int _wifi_get_connected_profile(wifi_manager_ap_h *ap)
+{
+ int rv;
+ wifi_manager_ap_h ap_h = NULL;
+ GSList *list;
+
+ rv = __update_profile_iterator();
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ }
+
+ for (list = profile_iterator; list; list = list->next) {
+ net_profile_info_s *prof_info = (net_profile_info_s *)list->data;
+ if (prof_info->ProfileState == NET_STATE_TYPE_ONLINE ||
+ prof_info->ProfileState == NET_STATE_TYPE_READY) {
+ ap_h = (wifi_manager_ap_h)prof_info;
+ break;
+ }
+ }
+
+ if (ap_h == NULL) {
+ WIFI_LOG(WIFI_ERROR, "There is no connected AP"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_NO_CONNECTION; //LCOV_EXCL_LINE
+ }
+
+ *ap = g_try_malloc0(sizeof(net_profile_info_s));
+ if (*ap == NULL)
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY;
+
+ memcpy(*ap, ap_h, sizeof(net_profile_info_s));
+
+ _wifi_add_to_ap_list(*ap);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_foreach_found_ap(wifi_manager_found_ap_cb callback, void *user_data)
+{
+ int rv;
+ GSList *list;
+
+ rv = __update_profile_iterator();
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ }
+
+ if ((int)g_slist_length(profile_iterator) == 0) {
+ WIFI_LOG(WIFI_WARN, "There is no AP"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_NONE; //LCOV_EXCL_LINE
+ }
+
+ for (list = profile_iterator; list; list = list->next) {
+ net_profile_info_s *prof_info = (net_profile_info_s *)list->data;
+ if (prof_info->is_hidden == TRUE)
+ continue;
+
+ rv = callback((wifi_manager_ap_h)prof_info, user_data);
+ if (rv == false) break;
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_foreach_found_specific_ap(wifi_manager_found_ap_cb callback, void *user_data)
+{
+ int rv;
+ GSList *list;
+
+ if ((int)g_slist_length(specific_profile_iterator) == 0) {
+ WIFI_LOG(WIFI_WARN, "There is no specific APs");
+
+ rv = __update_profile_iterator();
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ }
+
+ if ((int)g_slist_length(profile_iterator) == 0) {
+ WIFI_LOG(WIFI_WARN, "There is no APs"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_NONE; //LCOV_EXCL_LINE
+ }
+
+ for (list = profile_iterator; list; list = list->next) {
+ net_profile_info_s *prof_info = (net_profile_info_s *)list->data;
+ if (!g_strcmp0(specific_profile_essid, prof_info->essid)) {
+ rv = callback((wifi_manager_ap_h)prof_info, user_data);
+ if (rv == false) break;
+ }
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+ }
+
+ for (list = specific_profile_iterator; list; list = list->next) {
+ net_profile_info_s *prof_info = (net_profile_info_s *)list->data;
+ rv = callback((wifi_manager_ap_h)prof_info, user_data);
+ if (rv == false) break;
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_open_profile(wifi_manager_h wifi, wifi_manager_ap_h ap_h,
+ wifi_manager_connected_cb callback, void *user_data)
+{
+ int rv;
+ bool valid_profile;
+ net_profile_info_s *ap_info = ap_h;
+
+ valid_profile =
+ _wifi_check_profile_name_validity(ap_info->ProfileName);
+
+ if (valid_profile == true && ap_info->Favourite)
+ rv = net_open_connection(ap_info->ProfileName);
+ else if (valid_profile == true &&
+ ap_info->is_hidden != TRUE &&
+ ap_info->security_info.sec_mode == WLAN_SEC_MODE_NONE)
+ rv = net_open_connection(ap_info->ProfileName);
+ else
+ rv = __connect_with_wifi_info(ap_info);
+
+ rv = __convert_to_ap_error_type(rv);
+ if (rv == WIFI_MANAGER_ERROR_NONE)
+ __set_connected_cb(wifi, callback, user_data);
+
+ return rv;
+}
+
+int _wifi_close_profile(wifi_manager_h wifi, wifi_manager_ap_h ap_h,
+ wifi_manager_disconnected_cb callback, void *user_data)
+{
+ int rv;
+ net_profile_info_s *ap_info = ap_h;
+
+ rv = net_close_connection(ap_info->ProfileName);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE) {
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ __set_disconnected_cb(wifi, callback, user_data);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+//LCOV_EXCL_START
+int _wifi_connect_with_wps_pbc(wifi_manager_h wifi, wifi_manager_ap_h ap_h,
+ wifi_manager_connected_cb callback, void *user_data)
+{
+ int rv;
+ net_profile_info_s *ap_info = ap_h;
+ net_wifi_wps_info_s wps_info;
+ memset(&wps_info, 0, sizeof(net_wifi_wps_info_s));
+
+ wps_info.type = WIFI_WPS_PBC;
+
+ rv = net_wifi_enroll_wps(ap_info->ProfileName, &wps_info);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied");
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE) {
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ }
+
+ __set_connected_cb(wifi, callback, user_data);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_connect_with_wps_pin(wifi_manager_h wifi, wifi_manager_ap_h ap_h,
+ const char *pin, wifi_manager_connected_cb callback, void *user_data)
+{
+ int rv;
+ net_profile_info_s *ap_info = ap_h;
+ net_wifi_wps_info_s wps_info;
+
+ if (ap_info == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ }
+
+ wps_info.type = WIFI_WPS_PIN;
+ g_strlcpy(wps_info.pin, pin, NET_WLAN_MAX_WPSPIN_LEN + 1);
+
+ rv = net_wifi_enroll_wps(ap_info->ProfileName, &wps_info);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied");
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE) {
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ }
+
+ __set_connected_cb(wifi, callback, user_data);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+//LCOV_EXCL_STOP
+
+int _wifi_forget_ap(wifi_manager_ap_h ap)
+{
+ int rv = 0;
+ net_profile_info_s *ap_info = ap;
+
+ if (ap_info == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = net_delete_profile(ap_info->ProfileName);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE) {
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ ap_info->Favourite = (char)FALSE;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+void _wifi_rssi_level_changed_cb(keynode_t *node, void *user_data)
+{
+ GSList *list;
+ wifi_manager_handle_s *handle;
+ int rssi_level = 0;
+
+ if (net_check_ref_count() != true) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
+ }
+
+ for (list = wifi_manager_handle_list; list; list = list->next) {
+ handle = (wifi_manager_handle_s *)list->data;
+
+ if (__wifi_check_handle_validity((wifi_manager_h)handle) != true)
+ return;
+
+ if (vconf_get_int(VCONFKEY_WIFI_STRENGTH, &rssi_level) != 0)
+ return;
+
+ if (handle->rssi_level_changed_cb)
+ handle->rssi_level_changed_cb(rssi_level,
+ handle->rssi_level_changed_user_data);
+ }
+}
+
+int _wifi_update_ap_info(net_profile_info_s *ap_info)
+{
+ int 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"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_SECURITY_RESTRICTED) {
+ WIFI_LOG(WIFI_ERROR, "Security restricted"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_SECURITY_RESTRICTED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE) {
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+bool _wifi_check_config_validity(wifi_manager_config_h config_h)
+{
+ GSList *list = NULL;
+
+ if (config_h == NULL)
+ return false;
+
+ for (list = config_handle_list; list; list = list->next)
+ if (config_h == list->data) return true;
+
+ for (list = config_iterator; list; list = list->next)
+ if (config_h == list->data) return true;
+
+ return false;
+}
+
+void _wifi_add_to_config_list(wifi_manager_config_h config_h)
+{
+ config_handle_list = g_slist_append(config_handle_list, config_h);
+}
+
+void _wifi_remove_from_config_list(wifi_manager_config_h config_h)
+{
+ config_handle_list = g_slist_remove(config_handle_list, config_h);
+ g_free(config_h);
+}
+
+gchar *_wifi_config_get_config_id(const gchar *name, wifi_manager_security_type_e security_type)
+{
+ gchar *config_id = NULL;
+ gchar *ssid = NULL;
+ gchar *type = NULL;
+
+ ssid = __wifi_change_name_to_hexadecimal(name);
+ type = g_strdup(__wifi_security_type_to_string(security_type));
+ config_id = g_strdup_printf("%s_managed_%s", ssid, type);
+
+ g_free(ssid);
+ g_free(type);
+
+ return config_id;
+}
+
+int _wifi_config_get_config_id_list(GSList **list)
+{
+ int rv;
+
+ rv = net_config_get_id_list(list);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_NO_PROFILE) {
+ WIFI_LOG(WIFI_ERROR, "There is no configuration"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_NONE; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE) {
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_save_configuration(const gchar *name, const gchar *passphrase,
+ wifi_manager_security_type_e security_type, const gchar *proxy_address, gboolean is_hidden)
+{
+ int rv;
+ gchar *config_id = NULL;
+ gchar *ssid = NULL;
+
+ if (security_type != WIFI_MANAGER_SECURITY_TYPE_NONE) {
+ if (passphrase == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_configurations " //LCOV_EXCL_LINE
+ "[secu_type is not NONE[%d] but passphrase is NULL]", security_type);
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ } else {
+ if (strlen(passphrase) == 0) {
+ WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_configurations " //LCOV_EXCL_LINE
+ "passphrase length is 0");
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+ }
+ }
+
+ config_id = _wifi_config_get_config_id(name, security_type);
+ ssid = __wifi_change_name_to_hexadecimal(name);
+
+ rv = net_config_save_configurations(config_id, name, ssid, passphrase, proxy_address, is_hidden);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE) {
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_load_configurations(void)
+{
+ int rv;
+ GSList *config_ids = NULL;
+
+ __clear_config_list();
+
+ rv = _wifi_config_get_config_id_list(&config_ids);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Fail to load configurations [%d]", rv); //LCOV_EXCL_LINE
+ return rv; //LCOV_EXCL_LINE
+ }
+
+ if (config_ids == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Fail to get config id list"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_NONE; //LCOV_EXCL_LINE
+ }
+
+ while (config_ids) {
+ bool rv = 0;
+ wifi_config_s *h;
+ gchar *id = config_ids->data;
+
+ h = g_new0(wifi_config_s, 1);
+ if (h == NULL) {
+ rv = WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ break;
+ }
+
+ if (g_str_has_suffix(id, "ieee8021x") == TRUE) {
+ h->eap_config = g_new0(wifi_eap_config_s, 1);
+ if (h->eap_config == NULL) {
+ rv = WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ break;
+ }
+ rv = __load_eap_configurations(id, &h->name,
+ &h->security_type, &h->proxy_address, &h->is_hidden, &h->eap_config, &h->last_error);
+ } else {
+ rv = __load_configurations(id, &h->name,
+ &h->security_type, &h->proxy_address, &h->is_hidden, &h->last_error);
+ }
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Fail to load configurations [%d]", rv); //LCOV_EXCL_LINE
+ return rv; //LCOV_EXCL_LINE
+ }
+
+ h->address_family = WIFI_MANAGER_ADDRESS_FAMILY_IPV4;
+ h->is_saved = TRUE;
+
+ config_iterator = g_slist_append(config_iterator, (wifi_manager_config_h)h);
+
+ config_ids = config_ids->next;
+ }
+
+ config_ids = g_slist_nth(config_ids, 0);
+ g_slist_free_full(config_ids, g_free);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_foreach_configuration(wifi_manager_config_list_cb callback, void *user_data)
+{
+ int rv;
+ GSList *list;
+
+ for (list = config_iterator; list; list = list->next) {
+ rv = callback((wifi_manager_config_h)list->data, user_data);
+ if (rv == false)
+ break;
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_remove_configuration(const gchar *config_id)
+{
+ int rv;
+
+ rv = net_config_remove_configurations(config_id);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+//LCOV_EXCL_START
+int _wifi_save_eap_configurations(const gchar *name, const gchar *passphrase,
+ wifi_manager_security_type_e security_type, const gchar *proxy_address,
+ wifi_eap_config_s *eap_config, gboolean is_hidden)
+{
+ int rv;
+ gchar *config_id = NULL;
+ gchar *ssid = NULL;
+
+ if (security_type != WIFI_MANAGER_SECURITY_TYPE_EAP) {
+ WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_configurations "
+ "[secu_type is not EAP[%d]]", security_type);
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ }
+
+ if (passphrase == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_configurations [secu_type is not NONE[%d] "
+ "but passphrase is NULL]", security_type);
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ } else {
+ if (strlen(passphrase) == 0) {
+ WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_configurations passphrase length is 0");
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ if (security_type == (WIFI_MANAGER_EAP_TYPE_SIM | WIFI_MANAGER_EAP_TYPE_AKA))
+ WIFI_LOG(WIFI_INFO, "security_type: %d", security_type);
+
+ config_id = _wifi_config_get_config_id(name, security_type);
+ ssid = __wifi_change_name_to_hexadecimal(name);
+
+
+ rv = net_config_save_eap_configurations(config_id, name,
+ ssid, passphrase, proxy_address, (void *)eap_config, is_hidden);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_configuration_set_field(const gchar *config_id, const gchar *key, const gchar *value)
+{
+ int rv;
+
+ rv = net_config_set_field(config_id, key, value);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_configuration_get_passphrase(const gchar *config_id, gchar **passphrase)
+{
+ int rv;
+
+ rv = net_config_get_passphrase(config_id, passphrase);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+//LCOV_EXCL_STOP
+
+int _wifi_check_get_privilege()
+{
+ int rv;
+
+ rv = net_check_get_privilege();
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_check_profile_privilege()
+{
+ int rv = net_check_profile_privilege();
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+bool __check_feature_supported(const char *key, wifi_supported_feature_e feature)
+{
+ if (!wifi_is_feature_checked[feature]) {
+ if (system_info_get_platform_bool(key, &wifi_feature_supported[feature]) < 0) {
+ WIFI_LOG(WIFI_ERROR, "Error - Feature getting from System Info"); //LCOV_EXCL_LINE
+ set_last_result(WIFI_MANAGER_ERROR_OPERATION_FAILED); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+ wifi_is_feature_checked[feature] = true;
+ }
+ return wifi_feature_supported[feature];
+}
+
+int _wifi_check_feature_supported(const char *feature_name, ...)
+{
+ va_list list;
+ const char *key;
+ bool value = false;
+ bool feature_supported = false;
+
+ va_start(list, feature_name);
+ key = feature_name;
+ while (1) {
+ if (strcmp(key, WIFI_FEATURE) == 0)
+ value = __check_feature_supported(key, WIFI_SUPPORTED_FEATURE_WIFI);
+ else if (strcmp(key, WIFI_TDLS_FEATURE) == 0)
+ value = __check_feature_supported(key, WIFI_SUPPORTED_FEATURE_WIFI_TDLS);
+
+ feature_supported |= value;
+ key = va_arg(list, const char *);
+ if (!key) break;
+ }
+ if (!feature_supported) {
+ WIFI_LOG(WIFI_ERROR, "Error - Feature is not supported"); //LCOV_EXCL_LINE
+ set_last_result(WIFI_MANAGER_ERROR_NOT_SUPPORTED); //LCOV_EXCL_LINE
+ va_end(list);
+ return WIFI_MANAGER_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
+ }
+
+ va_end(list);
+ set_last_result(WIFI_MANAGER_ERROR_NONE);
+ return WIFI_MANAGER_ERROR_NONE;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <stdio.h>
+#include <string.h>
+#include <vconf/vconf.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <glib.h>
+
+#include "wifi_internal.h"
+
+#define WIFI_MAC_ADDR_LENGTH 17
+#define WIFI_MAC_ADDR_PATH "/sys/class/net/wlan0/address"
+
+//LCOV_EXCL_START
+bool __wifi_check_handle_validity(wifi_manager_h wifi)
+{
+ if (wifi == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Wifi handle is null");
+ return false;
+ }
+
+ return _wifi_find_from_handle_list(wifi);
+}
+
+static int __wifi_set_device_state_changed_cb(wifi_manager_h wifi,
+ void *callback, void *user_data)
+{
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
+
+ local_handle->device_state_cb = callback;
+ local_handle->device_state_user_data = user_data;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+static int __wifi_set_background_scan_cb(wifi_manager_h wifi,
+ void *callback, void *user_data)
+{
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
+
+ local_handle->bg_scan_cb = callback;
+ local_handle->bg_scan_user_data = user_data;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+static int __wifi_set_connection_state_changed_cb(wifi_manager_h wifi,
+ void *callback, void *user_data)
+{
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
+
+ local_handle->connection_state_cb = callback;
+ local_handle->connection_state_user_data = user_data;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+static int __wifi_set_rssi_level_changed_cb(wifi_manager_h wifi,
+ void *callback, void *user_data)
+{
+ static __thread gint refcount = 0;
+ wifi_manager_handle_s *local_handle;
+
+ local_handle = (wifi_manager_handle_s *)wifi;
+
+ if (callback) {
+ if (refcount == 0)
+ vconf_notify_key_changed(VCONFKEY_WIFI_STRENGTH,
+ _wifi_rssi_level_changed_cb, NULL);
+
+ refcount++;
+ WIFI_LOG(WIFI_INFO, "Successfully registered(%d)", refcount);
+ } else {
+ if (refcount > 0 && local_handle->rssi_level_changed_cb) {
+ if (--refcount == 0) {
+ if (vconf_ignore_key_changed(VCONFKEY_WIFI_STRENGTH,
+ _wifi_rssi_level_changed_cb) < 0) {
+ WIFI_LOG(WIFI_ERROR, "Error to de-register vconf callback(%d)", refcount);
+ } else {
+ WIFI_LOG(WIFI_INFO, "Successfully de-registered(%d)", refcount);
+ }
+ }
+ }
+ }
+
+ local_handle->rssi_level_changed_cb = callback;
+ local_handle->rssi_level_changed_user_data = user_data;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+static int __wifi_get_handle_count(void)
+{
+ return _wifi_get_count_from_handle_list();
+}
+//LCOV_EXCL_STOP
+
+EXPORT_API int wifi_manager_initialize(wifi_manager_h *wifi)
+{
+ int rv;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (wifi == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (__wifi_check_handle_validity(*wifi)) {
+ WIFI_LOG(WIFI_ERROR, "Already initialized"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_ALREADY_INITIALIZED; //LCOV_EXCL_LINE
+ }
+
+ rv = _wifi_init();
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Init failed[%d]", rv); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ rv = _wifi_create_handle(wifi);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Init failed[%d]", rv); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+
+ _wifi_add_to_handle_list(wifi);
+ WIFI_LOG(WIFI_INFO, "Wi-Fi successfully initialized");
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_deinitialize(wifi_manager_h wifi)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ wifi_manager_unset_rssi_level_changed_cb(wifi);
+
+ WIFI_LOG(WIFI_INFO, "Destroy handle: %p", wifi);
+
+ _wifi_remove_from_handle_list(wifi);
+
+ if (__wifi_get_handle_count() == 0) {
+ if (_wifi_deinit() == false) {
+ WIFI_LOG(WIFI_ERROR, "Deinit failed"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+ }
+
+ WIFI_LOG(WIFI_INFO, "Wi-Fi successfully de-initialized");
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_activate(wifi_manager_h wifi,
+ wifi_manager_activated_cb callback, void *user_data)
+{
+ int rv;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi)) || callback == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = _wifi_activate(wifi, callback, FALSE, user_data);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ WIFI_LOG(WIFI_ERROR, "Failed to activate Wi-Fi[%d]", rv); //LCOV_EXCL_LINE
+
+ return rv;
+}
+
+EXPORT_API int wifi_manager_activate_with_wifi_picker_tested(
+ wifi_manager_h wifi, wifi_manager_activated_cb callback, void *user_data)
+{
+ int rv;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi)) || callback == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = _wifi_activate(wifi, callback, TRUE, user_data);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ WIFI_LOG(WIFI_ERROR, "Failed to activate Wi-Fi[%d]", rv); //LCOV_EXCL_LINE
+
+ return rv;
+}
+
+EXPORT_API int wifi_manager_deactivate(wifi_manager_h wifi,
+ wifi_manager_deactivated_cb callback, void *user_data)
+{
+ int rv;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi)) || callback == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = _wifi_deactivate(wifi, callback, user_data);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi deactivation failed"); //LCOV_EXCL_LINE
+
+ return rv;
+}
+
+EXPORT_API int wifi_manager_is_activated(wifi_manager_h wifi, bool *activated)
+{
+ int rv;
+ wifi_manager_device_state_e device_state;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (activated == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = _wifi_get_wifi_device_state(&device_state);
+ if (rv == WIFI_MANAGER_ERROR_NONE) {
+ if (WIFI_MANAGER_DEVICE_STATE_DEACTIVATED == device_state)
+ *activated = false;
+ else
+ *activated = true;
+ }
+
+ return rv;
+}
+
+EXPORT_API int wifi_manager_get_mac_address(wifi_manager_h wifi, char **mac_address)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (mac_address == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+#if defined TIZEN_TV
+ FILE *fp = NULL;
+ char buf[WIFI_MAC_ADDR_LENGTH + 1];
+ if (0 == access(WIFI_MAC_ADDR_PATH, F_OK))
+ fp = fopen(WIFI_MAC_ADDR_PATH, "r");
+
+ if (fp == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to open file" //LCOV_EXCL_LINE
+ " %s\n", WIFI_MAC_ADDR_PATH);
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ if (fgets(buf, sizeof(buf), fp) == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get MAC"
+ " info from %s\n", WIFI_MAC_ADDR_PATH); //LCOV_EXCL_LINE
+ fclose(fp); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ WIFI_LOG(WIFI_INFO, "%s : %s\n", WIFI_MAC_ADDR_PATH, buf);
+
+ *mac_address = (char *)g_try_malloc0(WIFI_MAC_ADDR_LENGTH + 1);
+ if (*mac_address == NULL) {
+ WIFI_LOG(WIFI_ERROR, "malloc() failed"); //LCOV_EXCL_LINE
+ fclose(fp); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+ g_strlcpy(*mac_address, buf, WIFI_MAC_ADDR_LENGTH + 1);
+ fclose(fp);
+#else
+ *mac_address = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
+
+ if (*mac_address == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get vconf" //LCOV_EXCL_LINE
+ " from %s", VCONFKEY_WIFI_BSSID_ADDRESS);
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+#endif
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_get_network_interface_name(wifi_manager_h wifi, char **name)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (name == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return _wifi_get_intf_name(name);
+}
+
+EXPORT_API int wifi_manager_scan(wifi_manager_h wifi,
+ wifi_manager_scan_finished_cb callback, void *user_data)
+{
+ int rv;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi)) || callback == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = _wifi_scan_request(wifi, callback, user_data);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi scan failed"); //LCOV_EXCL_LINE
+
+ return rv;
+}
+
+EXPORT_API int wifi_manager_scan_specific_ap(wifi_manager_h wifi,
+ const char* essid, wifi_manager_scan_finished_cb callback, void *user_data)
+{
+ int rv;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi)) ||
+ essid == NULL || callback == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = _wifi_scan_specific_ap(wifi, essid, callback, user_data);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi hidden scan failed.\n"); //LCOV_EXCL_LINE
+
+ return rv;
+}
+
+
+
+EXPORT_API int wifi_manager_get_connected_ap(wifi_manager_h wifi, wifi_manager_ap_h *ap)
+{
+ int rv;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (ap == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = _wifi_get_connected_profile(ap);
+ WIFI_LOG(WIFI_INFO, "Connected AP %p, rv %d", *ap, rv);
+
+ return rv;
+}
+
+EXPORT_API int wifi_manager_foreach_found_ap(wifi_manager_h wifi,
+ wifi_manager_found_ap_cb callback, void *user_data)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (callback == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return _wifi_foreach_found_ap(callback, user_data);
+}
+
+EXPORT_API int wifi_manager_foreach_found_specific_ap(wifi_manager_h wifi,
+ wifi_manager_found_ap_cb callback, void* user_data)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (callback == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return _wifi_foreach_found_specific_ap(callback, user_data);
+}
+
+EXPORT_API int wifi_manager_connect(wifi_manager_h wifi,
+ wifi_manager_ap_h ap, wifi_manager_connected_cb callback, void *user_data)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi)) || callback == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (_wifi_check_ap_validity(ap) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return _wifi_open_profile(wifi, ap, callback, user_data);
+}
+
+EXPORT_API int wifi_manager_disconnect(wifi_manager_h wifi,
+ wifi_manager_ap_h ap, wifi_manager_disconnected_cb callback, void *user_data)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi)) || callback == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (_wifi_check_ap_validity(ap) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return _wifi_close_profile(wifi, ap, callback, user_data);
+}
+
+//LCOV_EXCL_START
+EXPORT_API int wifi_manager_connect_by_wps_pbc(wifi_manager_h wifi,
+ wifi_manager_ap_h ap, wifi_manager_connected_cb callback, void *user_data)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi)) || callback == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (_wifi_check_ap_validity(ap) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return _wifi_connect_with_wps_pbc(wifi, ap, callback, user_data);
+}
+
+EXPORT_API int wifi_manager_connect_by_wps_pin(wifi_manager_h wifi,
+ wifi_manager_ap_h ap, const char *pin, wifi_manager_connected_cb callback, void *user_data)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi)) || callback == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (_wifi_check_ap_validity(ap) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (NULL == pin || 0 == strlen(pin) || strlen(pin) > NET_WLAN_MAX_WPSPIN_LEN) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return _wifi_connect_with_wps_pin(wifi, ap, pin, callback, user_data);
+}
+//LCOV_EXCL_STOP
+
+EXPORT_API int wifi_manager_forget_ap(wifi_manager_h wifi, wifi_manager_ap_h ap)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (_wifi_check_ap_validity(ap) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return _wifi_forget_ap(ap);
+}
+
+EXPORT_API int wifi_manager_update_ap(wifi_manager_h wifi, wifi_manager_ap_h ap)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi)) ||
+ (_wifi_check_ap_validity(ap) == false)) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ if (_wifi_check_profile_name_validity(profile_info->ProfileName) == false)
+ return WIFI_MANAGER_ERROR_NONE;
+
+ return _wifi_update_ap_info(profile_info);
+}
+
+EXPORT_API int wifi_manager_get_connection_state(wifi_manager_h wifi,
+ wifi_manager_connection_state_e *connection_state)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (connection_state == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return _wifi_get_wifi_state(connection_state);
+}
+
+EXPORT_API int wifi_manager_set_device_state_changed_cb(wifi_manager_h wifi,
+ wifi_manager_device_state_changed_cb callback, void *user_data)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (callback == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return __wifi_set_device_state_changed_cb(wifi, callback, user_data);
+}
+
+EXPORT_API int wifi_manager_unset_device_state_changed_cb(wifi_manager_h wifi)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return __wifi_set_device_state_changed_cb(wifi, NULL, NULL);
+}
+
+EXPORT_API int wifi_manager_set_background_scan_cb(wifi_manager_h wifi,
+ wifi_manager_scan_finished_cb callback, void *user_data)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (callback == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return __wifi_set_background_scan_cb(wifi, callback, user_data);
+}
+
+EXPORT_API int wifi_manager_unset_background_scan_cb(wifi_manager_h wifi)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return __wifi_set_background_scan_cb(wifi, NULL, NULL);
+}
+
+EXPORT_API int wifi_manager_set_connection_state_changed_cb(wifi_manager_h wifi,
+ wifi_manager_connection_state_changed_cb callback, void *user_data)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (callback == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return __wifi_set_connection_state_changed_cb(wifi, callback, user_data);
+}
+
+EXPORT_API int wifi_manager_unset_connection_state_changed_cb(wifi_manager_h wifi)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return __wifi_set_connection_state_changed_cb(wifi, NULL, NULL);
+}
+
+EXPORT_API int wifi_manager_set_rssi_level_changed_cb(wifi_manager_h wifi,
+ wifi_manager_rssi_level_changed_cb callback, void *user_data)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (callback == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return __wifi_set_rssi_level_changed_cb(wifi, callback, user_data);
+}
+
+EXPORT_API int wifi_manager_unset_rssi_level_changed_cb(wifi_manager_h wifi)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return __wifi_set_rssi_level_changed_cb(wifi, NULL, NULL);
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "wifi-manager.h"
+#include "wifi_internal.h"
+
+/**
+ * wifi tunneled direct link setup
+ */
+
+//LCOV_EXCL_START
+EXPORT_API int wifi_manager_tdls_disconnect(wifi_manager_h wifi, const char *peer_mac_addr)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE);
+
+ if (peer_mac_addr == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ }
+
+ int rv = 0;
+ rv = net_wifi_tdls_disconnect(peer_mac_addr);
+
+ if (rv != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to disconnect tdls");
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_tdls_get_connected_peer(wifi_manager_h wifi, char **peer_mac_addr)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE);
+
+ if (peer_mac_addr == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ }
+
+ int rv = 0;
+ rv = net_wifi_tdls_connected_peer(peer_mac_addr);
+
+ if (rv != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get connected peer");
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ }
+
+ if (g_strcmp0(*peer_mac_addr, "00.00.00.00.00.00") == 0) {
+ g_free(*peer_mac_addr);
+ return WIFI_MANAGER_ERROR_NO_CONNECTION;
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_tdls_set_state_changed_cb(wifi_manager_h wifi,
+ wifi_manager_tdls_state_changed_cb callback, void *user_data)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_tdls_unset_state_changed_cb(wifi_manager_h wifi)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+//LCOV_EXCL_STOP
+
--- /dev/null
+PROJECT(wifi_manager_test C)
+
+SET(fw_test "${fw_name}-test")
+
+SET(dependents "capi-base-common glib-2.0")
+SET(pc_dependents "capi-base-common")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_test} REQUIRED ${dependents})
+FOREACH(flag ${${fw_test}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+aux_source_directory(. sources)
+FOREACH(src ${sources})
+ GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
+ MESSAGE("${src_name}")
+ ADD_EXECUTABLE(${src_name} ${src})
+ TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS})
+ENDFOREACH()
+
+INSTALL(TARGETS wifi_manager_test RUNTIME DESTINATION bin/)
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/un.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <signal.h>
+#include <assert.h>
+#include <wifi-manager.h>
+#include <tizen_error.h>
+
+#define LOG_RED "\033[0;31m"
+#define LOG_GREEN "\033[0;32m"
+#define LOG_BROWN "\033[0;33m"
+#define LOG_BLUE "\033[0;34m"
+#define LOG_END "\033[0;m"
+
+wifi_manager_h wifi = NULL;
+wifi_manager_h wifi2 = NULL;
+
+gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data);
+
+static const char *__test_convert_error_to_string(wifi_manager_error_e err_type)
+{
+ switch (err_type) {
+ case WIFI_MANAGER_ERROR_NONE:
+ return "NONE";
+ case WIFI_MANAGER_ERROR_INVALID_PARAMETER:
+ return "INVALID_PARAMETER";
+ case WIFI_MANAGER_ERROR_OUT_OF_MEMORY:
+ return "OUT_OF_MEMORY";
+ case WIFI_MANAGER_ERROR_INVALID_OPERATION:
+ return "INVALID_OPERATION";
+ case WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+ return "ADDRESS_FAMILY_NOT_SUPPORTED";
+ case WIFI_MANAGER_ERROR_OPERATION_FAILED:
+ return "OPERATION_FAILED";
+ case WIFI_MANAGER_ERROR_NO_CONNECTION:
+ return "NO_CONNECTION";
+ case WIFI_MANAGER_ERROR_NOW_IN_PROGRESS:
+ return "NOW_IN_PROGRESS";
+ case WIFI_MANAGER_ERROR_ALREADY_EXISTS:
+ return "ALREADY_EXISTS";
+ case WIFI_MANAGER_ERROR_OPERATION_ABORTED:
+ return "OPERATION_ABORTED";
+ case WIFI_MANAGER_ERROR_DHCP_FAILED:
+ return "DHCP_FAILED";
+ case WIFI_MANAGER_ERROR_INVALID_KEY:
+ return "INVALID_KEY";
+ case WIFI_MANAGER_ERROR_NO_REPLY:
+ return "NO_REPLY";
+ case WIFI_MANAGER_ERROR_SECURITY_RESTRICTED:
+ return "SECURITY_RESTRICTED";
+ case WIFI_MANAGER_ERROR_ALREADY_INITIALIZED:
+ return "ALREADY_INITIALIZED";
+ case WIFI_MANAGER_ERROR_PERMISSION_DENIED:
+ return "PERMISSION_DENIED";
+ case WIFI_MANAGER_ERROR_NOT_SUPPORTED:
+ return "NOT_SUPPORTED";
+ }
+
+ return "UNKNOWN";
+}
+
+static void __test_device_state_callback(wifi_manager_device_state_e state, void* user_data)
+{
+ printf("[%s] Device state changed callback", (char *)user_data);
+
+ if (state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED)
+ printf(", state : Activated\n");
+ else
+ printf(", state : Deactivated\n");
+}
+
+static void __test_bg_scan_completed_callback(wifi_manager_error_e error_code, void* user_data)
+{
+ printf("[%s] Background Scan Completed, error code : %s\n",
+ (char *)user_data, __test_convert_error_to_string(error_code));
+}
+
+static void __test_scan_request_callback(wifi_manager_error_e error_code, void* user_data)
+{
+ if (user_data != NULL)
+ printf("user_data : %s\n", (char *)user_data);
+
+ printf("Scan Completed from scan request, error code : %s\n",
+ __test_convert_error_to_string(error_code));
+}
+
+static void __test_connection_state_callback(wifi_manager_connection_state_e state, wifi_manager_ap_h ap, void* user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+
+ printf("[%s] Connection state changed callback", (char *)user_data);
+
+ switch (state) {
+ case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
+ printf(", state : Connected");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION:
+ printf(", state : Association");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION:
+ printf(", state : Configuration");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED:
+ printf(", state : Disconnected");
+ break;
+ default:
+ printf(", state : Unknown");
+ }
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ 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_manager_error_e result, void* user_data)
+{
+ if (result == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi Activation Succeeded\n");
+ else
+ printf("Wi-Fi Activation Failed! error : %s\n", __test_convert_error_to_string(result));
+}
+
+static void __test_deactivated_callback(wifi_manager_error_e result, void* user_data)
+{
+ if (result == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi Deactivation Succeeded\n");
+ else
+ printf("Wi-Fi Deactivation Failed! error : %s\n", __test_convert_error_to_string(result));
+}
+
+static void __test_connected_callback(wifi_manager_error_e result, void* user_data)
+{
+ if (result == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi Connection Succeeded\n");
+ else
+ printf("Wi-Fi Connection Failed! error : %s\n", __test_convert_error_to_string(result));
+}
+
+static void __test_disconnected_callback(wifi_manager_error_e result, void* user_data)
+{
+ if (result == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi Disconnection Succeeded\n");
+ else
+ printf("Wi-Fi Disconnection Failed! error : %s\n", __test_convert_error_to_string(result));
+}
+
+static void __test_rssi_level_callback(wifi_manager_rssi_level_e rssi_level, void* user_data)
+{
+ printf("[%s] RSSI level changed callback, level = %d\n", (char *)user_data, rssi_level);
+}
+
+static const char* __test_print_state(wifi_manager_connection_state_e state)
+{
+ switch (state) {
+ case WIFI_MANAGER_CONNECTION_STATE_FAILURE:
+ return "Failure";
+ case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED:
+ return "Disconnected";
+ case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION:
+ return "Association";
+ case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
+ return "Connected";
+ case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION:
+ return "Configuration";
+ }
+
+ return "Unknown";
+}
+
+static bool __test_compare_ap_name(const char *ap_name, const char *ap_name_part)
+{
+ int ap_name_len = strlen(ap_name);
+ int ap_name_part_len = strlen(ap_name_part);
+
+ if (strncmp(ap_name, ap_name_part,
+ ap_name_len > ap_name_part_len ? ap_name_len : ap_name_part_len) == 0)
+ return true;
+ else
+ return false;
+}
+
+static bool __test_found_ap_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ wifi_manager_connection_state_e state;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ rv = wifi_manager_ap_get_connection_state(ap, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get State [%s]\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ printf("AP name : %s, state : %s\n", ap_name, __test_print_state(state));
+ g_free(ap_name);
+
+ return true;
+}
+
+static bool __test_found_connect_ap_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ bool required = false;
+
+ if (wifi_manager_ap_is_passphrase_required(ap, &required) == WIFI_MANAGER_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("%99s", passphrase);
+
+ rv = wifi_manager_ap_set_passphrase(ap, passphrase);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set passphrase : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+ }
+
+ rv = wifi_manager_connect(wifi, ap, __test_connected_callback, NULL);
+ if (rv != WIFI_MANAGER_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_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ int user_sel;
+ char pin[32] = {0,};
+
+ printf("%s - Input WPS method (1:PBC, 2:PIN) :\n", ap_name);
+ rv = scanf("%9d", &user_sel);
+
+ switch (user_sel) {
+ case 1:
+ rv = wifi_manager_connect_by_wps_pbc(wifi, ap, __test_connected_callback, NULL);
+ break;
+ case 2:
+ printf("Input PIN code :\n");
+ rv = scanf("%31s", pin);
+ rv = wifi_manager_connect_by_wps_pin(wifi, ap, pin, __test_connected_callback, NULL);
+ break;
+ default:
+ printf("Invalid input!\n");
+ g_free(ap_name);
+ return false;
+ }
+
+ if (rv != WIFI_MANAGER_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_disconnect_ap_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ rv = wifi_manager_disconnect(wifi, ap, __test_disconnected_callback, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ 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_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ rv = wifi_manager_forget_ap(wifi, ap);
+ if (rv != WIFI_MANAGER_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_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ wifi_manager_security_type_e type;
+
+ if (wifi_manager_ap_get_security_type(ap, &type) == WIFI_MANAGER_ERROR_NONE)
+ printf("Security type : %d\n", type);
+ else
+ printf("Fail to get Security type\n");
+
+ if (type != WIFI_MANAGER_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_manager_ap_set_eap_passphrase(ap, input_str1, input_str2);
+ if (rv != WIFI_MANAGER_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_manager_ap_get_eap_passphrase(ap, &inputed_name, &is_pass_set);
+ if (rv != WIFI_MANAGER_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");
+
+ printf("Input certificate file:\n");
+ rv = scanf("%99s", input_str1);
+
+ rv = wifi_manager_ap_set_eap_ca_cert_file(ap, input_str1);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set eap certificatefile : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ int input_int;
+ printf("Input EAP type:\n");
+ printf("0 -> WIFI_MANAGER_EAP_TYPE_PEAP\n");
+ printf("1 -> WIFI_MANAGER_EAP_TYPE_TLS\n");
+ printf("2 -> WIFI_MANAGER_EAP_TYPE_TTLS\n");
+ printf("3 -> WIFI_MANAGER_EAP_TYPE_SIM\n");
+ printf("4 -> WIFI_MANAGER_EAP_TYPE_AKA\n");
+ rv = scanf("%d", &input_int);
+
+ rv = wifi_manager_ap_set_eap_type(ap, input_int);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set eap type : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ printf("Input EAP authentication type:\n");
+ printf("0 -> WIFI_MANAGER_EAP_AUTH_TYPE_NONE\n");
+ printf("1 -> WIFI_MANAGER_EAP_AUTH_TYPE_PAP\n");
+ printf("2 -> WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAP\n");
+ printf("3 -> WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAPV2\n");
+ printf("4 -> WIFI_MANAGER_EAP_AUTH_TYPE_GTC\n");
+ printf("5 -> WIFI_MANAGER_EAP_AUTH_TYPE_MD5\n");
+ rv = scanf("%d", &input_int);
+
+ rv = wifi_manager_ap_set_eap_auth_type(ap, input_int);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set eap auth type : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ rv = wifi_manager_connect(wifi, ap, __test_connected_callback, NULL);
+ if (rv != WIFI_MANAGER_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_get_user_string(const char *msg, char *buf, int buf_size)
+{
+ if (msg == NULL || buf == NULL || buf_size < 2)
+ return false;
+
+ int rv;
+ printf("%s\n", msg);
+ memset(buf, 0, buf_size);
+ rv = read(0, buf, buf_size - 1);
+
+ if (rv < 0 || buf[0] == '\0' || buf[0] == '\n' || buf[0] == '\r') {
+ buf[0] = '\0';
+ return false;
+ }
+
+ buf[rv-1] = '\0';
+ return true;
+}
+
+static bool __test_found_change_ip_method_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv;
+ char *ap_name;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ wifi_manager_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_MANAGER_IP_CONFIG_TYPE_DYNAMIC;
+ break;
+ case 2:
+ type = WIFI_MANAGER_IP_CONFIG_TYPE_STATIC;
+ break;
+ case 3:
+ type = WIFI_MANAGER_IP_CONFIG_TYPE_AUTO;
+ break;
+ default:
+ printf("Invalid input!\n");
+ g_free(ap_name);
+ return false;
+ }
+
+ rv = wifi_manager_ap_set_ip_config_type(ap, address_type, type);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to set ip method type[%s]\n", __test_convert_error_to_string(rv));
+
+ if (type == WIFI_MANAGER_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_MANAGER_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_manager_ap_set_ip_address(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_ap_set_ip_address(ap, address_type, ip_addr);
+ }
+
+ if (rv != WIFI_MANAGER_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_MANAGER_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_manager_ap_set_subnet_mask(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_ap_set_subnet_mask(ap, address_type, ip_addr);
+ }
+
+ if (rv != WIFI_MANAGER_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_MANAGER_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_manager_ap_set_gateway_address(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_ap_set_gateway_address(ap, address_type, ip_addr);
+ }
+
+ if (rv != WIFI_MANAGER_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_manager_ap_h ap, void *user_data)
+{
+ int rv, address_type;
+ char *ap_name;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_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 (__test_compare_ap_name(ap_name, ap_name_part)) {
+ wifi_manager_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_MANAGER_PROXY_TYPE_DIRECT;
+ break;
+ case 2:
+ type = WIFI_MANAGER_PROXY_TYPE_MANUAL;
+ break;
+ case 3:
+ type = WIFI_MANAGER_PROXY_TYPE_AUTO;
+ break;
+ default:
+ printf("Invalid input!\n");
+ g_free(ap_name);
+ return false;
+ }
+
+ rv = wifi_manager_ap_set_proxy_type(ap, type);
+ if (rv != WIFI_MANAGER_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_MANAGER_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_manager_ap_set_proxy_address(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_ap_set_proxy_address(ap, address_type, proxy_addr);
+ }
+
+ if (rv != WIFI_MANAGER_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_manager_ap_h ap, void *user_data)
+{
+ int rv, address_type = 0;
+ char *ap_name;
+ char *str_value;
+ int int_value;
+ wifi_manager_connection_state_e conn_state;
+ wifi_manager_ip_config_type_e ip_type;
+ wifi_manager_proxy_type_e proxy_type;
+ wifi_manager_security_type_e sec_type;
+ wifi_manager_encryption_type_e enc_type;
+ wifi_manager_eap_type_e eap_type;
+ wifi_manager_eap_auth_type_e eap_auth_type;
+ bool bool_value;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_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 (__test_compare_ap_name(ap_name, ap_name_part)) {
+ /* Basic info */
+ printf("ESSID : %s\n", ap_name);
+
+ if (wifi_manager_ap_get_bssid(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("BSSID : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get BSSID\n");
+
+ if (wifi_manager_ap_get_rssi(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("RSSI : %d\n", int_value);
+ else
+ printf("Fail to get RSSI\n");
+
+ if (wifi_manager_ap_get_frequency(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("Frequency : %d\n", int_value);
+ else
+ printf("Fail to get Frequency\n");
+
+ if (wifi_manager_ap_get_max_speed(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("Max speed : %d\n", int_value);
+ else
+ printf("Fail to get Max speed\n");
+
+ if (wifi_manager_ap_is_favorite(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("Favorite : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get Favorite\n");
+
+ /* Network info */
+ if (wifi_manager_ap_get_connection_state(ap, &conn_state) == WIFI_MANAGER_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_manager_ap_get_ip_config_type(ap, address_type, &ip_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("IP config type : %d\n", ip_type);
+ else
+ printf("Fail to get IP config type\n");
+
+ if (wifi_manager_ap_get_ip_address(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("IP : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get IP\n");
+
+ if (wifi_manager_ap_get_subnet_mask(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("Subnet mask : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get Subnet mask\n");
+
+ if (wifi_manager_ap_get_gateway_address(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("Gateway : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get Gateway\n");
+
+ if (wifi_manager_ap_get_proxy_type(ap, &proxy_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("Proxy type : %d\n", proxy_type);
+ else
+ printf("Fail to get Proxy type\n");
+
+ if (wifi_manager_ap_get_proxy_address(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("Proxy : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get Proxy\n");
+
+ if (wifi_manager_ap_get_dns_address(ap, 1, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("DNS1 : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get DNS1\n");
+
+ if (wifi_manager_ap_get_dns_address(ap, 2, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("DNS2 : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get DNS2\n");
+
+ /* Security info */
+ if (wifi_manager_ap_get_security_type(ap, &sec_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("Security type : %d\n", sec_type);
+ else
+ printf("Fail to get Security type\n");
+
+ if (wifi_manager_ap_get_encryption_type(ap, &enc_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("Encryption type : %d\n", enc_type);
+ else
+ printf("Fail to get Encryption type\n");
+
+ if (wifi_manager_ap_is_passphrase_required(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("Passphrase required : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get Passphrase required\n");
+
+ if (wifi_manager_ap_is_wps_supported(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("WPS supported : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get WPS supported\n");
+
+ if (sec_type != WIFI_MANAGER_SECURITY_TYPE_EAP) {
+ g_free(ap_name);
+ return false;
+ }
+
+ /* EAP info */
+ if (wifi_manager_ap_get_eap_type(ap, &eap_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("EAP type : %d\n", eap_type);
+ else
+ printf("Fail to get EAP type\n");
+
+ if (wifi_manager_ap_get_eap_auth_type(ap, &eap_auth_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("EAP auth type : %d\n", eap_auth_type);
+ else
+ printf("Fail to get EAP auth type\n");
+
+ if (wifi_manager_ap_get_eap_passphrase(ap, &str_value, &bool_value) == WIFI_MANAGER_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_manager_ap_get_eap_ca_cert_file(ap, &str_value) == WIFI_MANAGER_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_manager_ap_get_eap_client_cert_file(ap, &str_value) == WIFI_MANAGER_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_manager_ap_get_eap_private_key_file(ap, &str_value) == WIFI_MANAGER_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;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool _test_config_list_cb(const wifi_manager_config_h config, void *user_data)
+{
+ gchar *name = NULL;
+ wifi_manager_security_type_e security_type;
+
+ wifi_manager_config_get_name(config, &name);
+ wifi_manager_config_get_security_type(config, &security_type);
+
+ printf("Name[%s] ", name);
+ printf("Security type[%d] ", security_type);
+ if (security_type == WIFI_MANAGER_SECURITY_TYPE_EAP) {
+ wifi_manager_eap_type_e eap_type;
+ wifi_manager_eap_auth_type_e eap_auth_type;
+ wifi_manager_config_get_eap_type(config, &eap_type);
+ printf("Eap type[%d] ", eap_type);
+ wifi_manager_config_get_eap_auth_type(config, &eap_auth_type);
+ printf("Eap auth type[%d]", eap_auth_type);
+ }
+ printf("\n");
+
+ g_free(name);
+
+ return true;
+}
+
+struct _wifi_conf {
+ char name[33];
+ int type;
+};
+static bool _test_config_list_cb_for_remove(const wifi_manager_config_h config, void *user_data)
+{
+
+ struct _wifi_conf *c = (struct _wifi_conf *)user_data;
+ gchar *name = NULL;
+ wifi_manager_security_type_e security_type;
+
+ wifi_manager_config_get_name(config, &name);
+ wifi_manager_config_get_security_type(config, &security_type);
+
+ if (__test_compare_ap_name(name, c->name) && security_type == c->type) {
+ int rv = wifi_manager_config_remove(wifi, config);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to remove configurations [%s]\n", __test_convert_error_to_string(rv));
+ else
+ printf("Success to remove configuration [%s]\n", name);
+ g_free(name);
+ return false;
+ }
+
+ return true;
+}
+
+static bool __test_found_specific_ap_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ printf("Found specific ap Completed\n");
+
+ int rv;
+ char *ap_name = NULL;
+ wifi_manager_security_type_e security_type = WIFI_MANAGER_SECURITY_TYPE_NONE;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ printf("[AP name] : %s\n", ap_name);
+
+ rv = wifi_manager_ap_get_security_type(ap, &security_type);
+ if (rv == WIFI_MANAGER_ERROR_NONE)
+ printf("[Security type] : %d\n", security_type);
+ else {
+ printf("Fail to get Security type\n");
+ g_free(ap_name);
+ return false;
+ }
+
+ switch (security_type) {
+ case WIFI_MANAGER_SECURITY_TYPE_WEP:
+ case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
+ case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
+ {
+ char passphrase[100];
+ printf("Input passphrase for %s : ", ap_name);
+ rv = scanf("%99s", passphrase);
+
+ rv = wifi_manager_ap_set_passphrase(ap, passphrase);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set passphrase : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+ }
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_EAP:
+ {
+ 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_manager_ap_set_eap_passphrase(ap, input_str1, input_str2);
+ if (rv != WIFI_MANAGER_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_manager_ap_get_eap_passphrase(ap, &inputed_name, &is_pass_set);
+ if (rv != WIFI_MANAGER_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");
+ g_free(inputed_name);
+ }
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_NONE:
+ default:
+ break;
+ }
+
+ rv = wifi_manager_connect(wifi, ap, __test_connected_callback, NULL);
+ if (rv != WIFI_MANAGER_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 true;
+}
+
+static void __test_scan_specific_ap_callback(wifi_manager_error_e error_code, void* user_data)
+{
+ int rv;
+
+ printf("Specific scan Completed from scan request, error code : %s\n",
+ __test_convert_error_to_string(error_code));
+
+ if (error_code != WIFI_MANAGER_ERROR_NONE)
+ return;
+
+ rv = wifi_manager_foreach_found_specific_ap(wifi, __test_found_specific_ap_callback, user_data);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get specific AP(can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return;
+ }
+}
+
+int test_wifi_manager_init(void)
+{
+ int rv = wifi_manager_initialize(&wifi);
+
+ if (rv == WIFI_MANAGER_ERROR_NONE) {
+ wifi_manager_set_device_state_changed_cb(wifi, __test_device_state_callback, "1");
+ wifi_manager_set_background_scan_cb(wifi, __test_bg_scan_completed_callback, "1");
+ wifi_manager_set_connection_state_changed_cb(wifi, __test_connection_state_callback, "1");
+ wifi_manager_set_rssi_level_changed_cb(wifi, __test_rssi_level_callback, "1");
+ } else {
+ printf("[1] Wifi init failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ rv = wifi_manager_initialize(&wifi2);
+
+ if (rv == WIFI_MANAGER_ERROR_NONE) {
+ wifi_manager_set_device_state_changed_cb(wifi2, __test_device_state_callback, "2");
+ wifi_manager_set_background_scan_cb(wifi2, __test_bg_scan_completed_callback, "2");
+ wifi_manager_set_connection_state_changed_cb(wifi2, __test_connection_state_callback, "2");
+ wifi_manager_set_rssi_level_changed_cb(wifi2, __test_rssi_level_callback, "2");
+ } else {
+ printf("[2] Wifi init failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Wifi init succeeded\n");
+ return 1;
+}
+
+int test_wifi_manager_deinit(void)
+{
+ int rv = wifi_manager_deinitialize(wifi);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("[1] Wifi deinit failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ rv = wifi_manager_deinitialize(wifi2);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("[2] Wifi deinit failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Wifi deinit succeeded\n");
+ return 1;
+}
+
+int test_wifi_manager_activate(void)
+{
+ int rv = 0;
+
+ rv = wifi_manager_activate(wifi, __test_activated_callback, NULL);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to activate Wi-Fi device [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Success to activate Wi-Fi device\n");
+
+ return 1;
+}
+
+int test_wifi_manager_deactivate(void)
+{
+ int rv = 0;
+
+ rv = wifi_manager_deactivate(wifi, __test_deactivated_callback, NULL);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to deactivate Wi-Fi device [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Success to deactivate Wi-Fi device\n");
+
+ return 1;
+}
+
+int test_wifi_manager_is_activated(void)
+{
+ int rv = 0;
+ bool state = false;
+
+ rv = wifi_manager_is_activated(wifi, &state);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get Wi-Fi device state [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Success to get Wi-Fi device state : %s\n", (state) ? "TRUE" : "FALSE");
+
+ return 1;
+}
+
+int test_wifi_manager_get_connection_state(void)
+{
+ int rv = 0;
+ wifi_manager_connection_state_e connection_state;
+
+ rv = wifi_manager_get_connection_state(wifi, &connection_state);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ 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_MANAGER_CONNECTION_STATE_ASSOCIATION:
+ printf("Association\n");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
+ printf("Connected\n");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION:
+ printf("Configuration\n");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED:
+ printf("Disconnected\n");
+ break;
+ default:
+ printf("Unknown\n");
+ }
+
+ return 1;
+}
+
+int test_wifi_manager_get_mac_address(void)
+{
+ int rv = 0;
+ char *mac_addr = NULL;
+
+ rv = wifi_manager_get_mac_address(wifi, &mac_addr);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get MAC address [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("MAC address : %s\n", mac_addr);
+ g_free(mac_addr);
+
+ return 1;
+}
+
+int test_wifi_manager_get_interface_name(void)
+{
+ int rv = 0;
+ char *if_name = NULL;
+
+ rv = wifi_manager_get_network_interface_name(wifi, &if_name);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get Interface name [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Interface name : %s\n", if_name);
+ g_free(if_name);
+
+ return 1;
+}
+
+int test_wifi_manager_scan(void)
+{
+ int rv = 0;
+
+ rv = wifi_manager_scan(wifi, __test_scan_request_callback, NULL);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Scan request failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Scan request succeeded\n");
+
+ return 1;
+}
+
+int test_wifi_manager_get_connected_ap(void)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ wifi_manager_ap_h ap_h;
+
+ rv = wifi_manager_get_connected_ap(wifi, &ap_h);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get connected AP [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ rv = wifi_manager_ap_get_essid(ap_h, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get essid [%s]\n", __test_convert_error_to_string(rv));
+ wifi_manager_ap_destroy(ap_h);
+ return -1;
+ }
+
+ printf("Connected AP : %s\n", ap_name);
+ g_free(ap_name);
+ wifi_manager_ap_destroy(ap_h);
+
+ return 1;
+}
+
+int test_wifi_manager_foreach_found_ap(void)
+{
+ int rv = 0;
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_ap_callback, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP list [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Get AP list finished\n");
+
+ return 1;
+}
+
+int test_wifi_manager_connect(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to connect : ");
+ rv = scanf("%32s", ap_name);
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_connect_ap_callback, ap_name);
+ if (rv != WIFI_MANAGER_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_wifi_manager_connect_specific_ap(void)
+{
+ int rv;
+ char ap_name[33];
+
+ printf("Input a part of specific AP name to connect : ");
+ rv = scanf("%32s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_scan_specific_ap(wifi, ap_name, __test_scan_specific_ap_callback, NULL);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Scan request failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Scan specific AP request succeeded\n");
+ return 1;
+}
+
+int test_wifi_manager_disconnect(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to disconnect : ");
+ rv = scanf("%32s", ap_name);
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_disconnect_ap_callback, ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to disconnect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Disconnection step finished\n");
+ return 1;
+}
+
+int test_wifi_manager_connect_wps(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to connect by wps : ");
+ rv = scanf("%32s", ap_name);
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_connect_wps_callback, ap_name);
+ if (rv != WIFI_MANAGER_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_wifi_manager_forget_ap(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to forget : ");
+ rv = scanf("%32s", ap_name);
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_forget_ap_callback, ap_name);
+ if (rv != WIFI_MANAGER_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_wifi_manager_connect_eap_ap(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to connect : ");
+ rv = scanf("%32s", ap_name);
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_eap_ap_callback, ap_name);
+ if (rv != WIFI_MANAGER_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_wifi_manager_set_ip_method(void)
+{
+ int rv;
+ char ap_name[33];
+ bool state;
+
+ rv = wifi_manager_is_activated(wifi, &state);
+ if (rv != WIFI_MANAGER_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_manager_foreach_found_ap(wifi, __test_found_change_ip_method_callback, ap_name);
+ if (rv != WIFI_MANAGER_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_wifi_manager_set_proxy_method(void)
+{
+ int rv;
+ char ap_name[33];
+ bool state;
+
+ rv = wifi_manager_is_activated(wifi, &state);
+ if (rv != WIFI_MANAGER_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_manager_foreach_found_ap(wifi, __test_found_change_proxy_method_callback, ap_name);
+ if (rv != WIFI_MANAGER_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_wifi_manager_get_ap_info(void)
+{
+ int rv;
+ char ap_name[33];
+ bool state;
+
+ rv = wifi_manager_is_activated(wifi, &state);
+ if (rv != WIFI_MANAGER_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_manager_foreach_found_ap(wifi, __test_found_print_ap_info_callback, ap_name);
+ if (rv != WIFI_MANAGER_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 test_wifi_manager_config_load_configuration(void)
+{
+ int rv;
+
+ rv = wifi_manager_config_foreach_configuration(wifi, _test_config_list_cb, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+
+ return 1;
+}
+
+int test_wifi_manager_config_save(void)
+{
+ int rv;
+ char name[33] = { 0, };
+ char passphrase[100] = { 0, };
+ int type = 0;
+ char proxy[100] = { 0, };
+ int hidden = 0;
+ wifi_manager_config_h config;
+
+ printf("Input AP configuration\n");
+ printf("Name : ");
+ rv = scanf("%32s", name);
+ if (rv <= 0)
+ return -1;
+
+ printf("Passphrase : ");
+ rv = scanf("%99s", passphrase);
+ if (rv <= 0)
+ return -1;
+
+ printf("Security type(None(0), WEP(1), WPA-PSK(2), EAP(4)) : ");
+ rv = scanf("%d", &type);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_config_create(wifi, name, passphrase, type, &config);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+
+ if (test_get_user_string("Proxy(server:port) - (Enter for skip): ", proxy, 99)) {
+ rv = wifi_manager_config_set_proxy_address(config, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, proxy);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_int("Hidden(1:Hidden) - (Enter for skip): ", &hidden)) {
+ if (hidden == 1)
+ rv = wifi_manager_config_set_hidden_ap_property(config, TRUE);
+ else
+ rv = wifi_manager_config_set_hidden_ap_property(config, FALSE);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (type == WIFI_MANAGER_SECURITY_TYPE_EAP) {
+ char anonymous[100] = { 0, };
+ char ca_cert[100] = { 0, };
+ char private_key[100] = { 0, };
+ char client_cert[100] = { 0, };
+ char eap_identity[100] = { 0, };
+ int eap_type;
+ int eap_auth_type;
+ char subject_match[100] = { 0, };
+
+ if (test_get_user_string("EAP Anonymous Identity - (Enter for skip): ", anonymous, 99)) {
+ rv = wifi_manager_config_set_eap_anonymous_identity(config, anonymous);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_string("EAP ca cert file - (Enter for skip): ", ca_cert, 99)) {
+ rv = wifi_manager_config_set_eap_ca_cert_file(config, ca_cert);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_string("EAP private key - (Enter for skip): ", private_key, 99) &&
+ test_get_user_string("EAP client cert file - (Enter for skip): ", client_cert, 99)) {
+ rv = wifi_manager_config_set_eap_client_cert_file(config, private_key, client_cert);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_string("EAP identity - (Enter for skip): ", eap_identity, 99)) {
+ rv = wifi_manager_config_set_eap_identity(config, eap_identity);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_int("EAP type (PEAP(0), TLS(1), TTLS(2), SIM(3), AKA(4)) - (Enter for skip): ", &eap_type)) {
+ rv = wifi_manager_config_set_eap_type(config, eap_type);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_int("EAP auth type (None(0), PAP(1), MSCHAP(2), MSCHAPv2(3), GTC(4), MD5(5)) - (Enter for skip): ", &eap_auth_type)) {
+ rv = wifi_manager_config_set_eap_auth_type(config, eap_auth_type);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_string("EAP subject match - (Enter for skip): ", subject_match, 99)) {
+ rv = wifi_manager_config_set_eap_subject_match(config, subject_match);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+ }
+
+ rv = wifi_manager_config_save(wifi, config);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+
+ rv = wifi_manager_config_destroy(config);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+
+ return 1;
+}
+
+int test_wifi_manager_config_remove(void)
+{
+ int rv;
+ struct _wifi_conf c;
+
+ printf("Input AP configuration\n");
+ printf("Name : ");
+ rv = scanf("%32s", c.name);
+ if (rv <= 0)
+ return -1;
+
+ printf("Security type(None(0), WEP(1), WPA-PSK(2), EAP(4) : ");
+ rv = scanf("%d", &c.type);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_config_foreach_configuration(wifi, _test_config_list_cb_for_remove, &c);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get configurations [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+int test_wifi_manager_tdls_disconnect(void)
+{
+ int rv = 0;
+
+ char peer_mac[18];
+ printf("Enter Mac_address: ");
+ if (scanf(" %17s", peer_mac) < 1)
+ return -1;
+
+ if (strlen(peer_mac) > 17) {
+ printf("Wrong Mac_address\n");
+ return -1;
+ }
+
+ rv = wifi_manager_tdls_disconnect(wifi, peer_mac);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("test_wifi_tdls_disconnect() is failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ return 1;
+}
+
+int test_wifi_manager_tdls_get_connected_peer(void)
+{
+ int rv = 0;
+ char *mac_addr = NULL;
+
+ rv = wifi_manager_tdls_get_connected_peer(wifi, &mac_addr);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("wifi_manager_tdls_get_connected_peer() is failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ printf("Peer Mac address is [%s]\n", mac_addr);
+ g_free(mac_addr);
+ return 1;
+}
+
+int main(int argc, char **argv)
+{
+ GMainLoop *mainloop;
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
+#endif
+ 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);
+
+ printf("Test Thread created...\n");
+
+ g_main_loop_run(mainloop);
+
+ return 0;
+}
+
+gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
+{
+ int rv;
+ char a[10];
+
+ printf("Event received from stdin\n");
+
+ rv = read(0, a, 10);
+
+ if (rv <= 0 || a[0] == '0') {
+ rv = wifi_manager_deinitialize(wifi);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to deinitialize.\n");
+
+ exit(1);
+ }
+
+ if (a[0] == '\n' || a[0] == '\r') {
+ printf("\n\n Network Connection API Test App\n\n");
+ printf("Options..\n");
+ printf(LOG_GREEN "1 - Wi-Fi init and set callbacks\n" LOG_END);
+ printf("2 - Wi-Fi deinit(unset callbacks automatically)\n");
+ printf(LOG_GREEN "3 - Activate Wi-Fi device\n" LOG_END);
+ printf("4 - Deactivate Wi-Fi device\n");
+ printf("5 - Is Wi-Fi activated?\n");
+ printf("6 - Get connection state\n");
+ printf("7 - Get MAC address\n");
+ printf("8 - Get Wi-Fi interface name\n");
+ printf(LOG_GREEN "9 - Scan request\n" LOG_END);
+ printf("a - Get Connected AP\n");
+ printf("b - Get AP list\n");
+ printf(LOG_GREEN "c - Connect\n" LOG_END);
+ 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("k - Connect Specific AP\n");
+ printf("l - Load configuration\n");
+ printf("m - Save configuration\n");
+ printf("n - Remove configuration\n");
+ printf("o - TDLS TearDown\n");
+ printf("p - TDLS Get Connected Peer\n");
+ printf(LOG_RED "0 - Exit \n" LOG_END);
+
+ printf("ENTER - Show options menu.......\n");
+ }
+
+ switch (a[0]) {
+ case '1':
+ rv = test_wifi_manager_init();
+ break;
+ case '2':
+ rv = test_wifi_manager_deinit();
+ break;
+ case '3':
+ rv = test_wifi_manager_activate();
+ break;
+ case '4':
+ rv = test_wifi_manager_deactivate();
+ break;
+ case '5':
+ rv = test_wifi_manager_is_activated();
+ break;
+ case '6':
+ rv = test_wifi_manager_get_connection_state();
+ break;
+ case '7':
+ rv = test_wifi_manager_get_mac_address();
+ break;
+ case '8':
+ rv = test_wifi_manager_get_interface_name();
+ break;
+ case '9':
+ rv = test_wifi_manager_scan();
+ break;
+ case 'a':
+ rv = test_wifi_manager_get_connected_ap();
+ break;
+ case 'b':
+ rv = test_wifi_manager_foreach_found_ap();
+ break;
+ case 'c':
+ rv = test_wifi_manager_connect();
+ break;
+ case 'd':
+ rv = test_wifi_manager_disconnect();
+ break;
+ case 'e':
+ rv = test_wifi_manager_connect_wps();
+ break;
+ case 'f':
+ rv = test_wifi_manager_forget_ap();
+ break;
+ case 'g':
+ rv = test_wifi_manager_connect_eap_ap();
+ break;
+ case 'h':
+ rv = test_wifi_manager_set_ip_method();
+ break;
+ case 'i':
+ rv = test_wifi_manager_set_proxy_method();
+ break;
+ case 'j':
+ rv = test_wifi_manager_get_ap_info();
+ break;
+ case 'k':
+ rv = test_wifi_manager_connect_specific_ap();
+ break;
+ case 'l':
+ rv = test_wifi_manager_config_load_configuration();
+ break;
+ case 'm':
+ rv = test_wifi_manager_config_save();
+ break;
+ case 'n':
+ rv = test_wifi_manager_config_remove();
+ break;
+ case 'o':
+ rv = test_wifi_manager_tdls_disconnect();
+ break;
+ case 'p':
+ rv = test_wifi_manager_tdls_get_connected_peer();
+ break;
+
+ default:
+ break;
+ }
+
+ if (rv == 1)
+ printf("Operation succeeded!\n");
+ else
+ printf("Operation failed!\n");
+
+ return TRUE;
+}
+