SET(BINDIR "${PREFIX}/sbin")
SET(DATADIR "${PREFIX}/share")
SET(LIBDIR "${PREFIX}/lib")
+SET(INTERFACES "${CMAKE_SOURCE_DIR}/interfaces")
SET(SRCS
src/main.c
- src/neterror.c
src/wifi.c
+ src/neterror.c
+ src/wifi-eap.c
+ src/wifi-wps.c
+ src/wifi-agent.c
src/wifi-power.c
src/wifi-state.c
- src/wifi-eap.c
+ src/cellular-state.c
src/wifi-passpoint.c
+ src/utils/log.c
+ src/utils/util.c
+ src/dbus/netdbus.c
src/network-clock.c
src/network-state.c
src/network-monitor.c
- src/network-statistics.c
+ src/wifi-firmware.c
src/wifi-indicator.c
src/signal-handler.c
src/wifi-ssid-scan.c
- src/wifi-background-scan.c
- src/wifi-agent.c
+ src/utils/emulator.c
src/wifi-eap-config.c
- src/dbus/netdbus.c
+ src/network-statistics.c
src/dbus/netsupplicant.c
- src/utils/util.c
- src/utils/emulator.c
- src/utils/mdm-private.c
- src/wifi-firmware.c
+ src/wifi-background-scan.c
+ src/wifi-tel-intf.c
+ src/wifi-config.c
+ src/clatd-handler.c
)
IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+IF(TIZEN_WLAN_PASSPOINT)
+ ADD_DEFINITIONS(-DTIZEN_WLAN_PASSPOINT)
+ENDIF(TIZEN_WLAN_PASSPOINT)
+
+IF(TIZEN_WLAN_USE_P2P_INTERFACE)
+ ADD_DEFINITIONS(-DTIZEN_WLAN_USE_P2P_INTERFACE)
+ENDIF(TIZEN_WLAN_USE_P2P_INTERFACE)
+
IF(TIZEN_P2P_ENABLE)
ADD_DEFINITIONS(-DTIZEN_P2P_ENABLE)
+ SET(P2P_REQUIRED_PKGS "capi-network-wifi-direct")
ENDIF(TIZEN_P2P_ENABLE)
+IF(TIZEN_TETHERING_ENABLE)
+ ADD_DEFINITIONS(-DTIZEN_TETHERING_ENABLE)
+ENDIF(TIZEN_TETHERING_ENABLE)
+
+IF(TIZEN_CAPTIVE_PORTAL)
+ ADD_DEFINITIONS(-DTIZEN_CAPTIVE_PORTAL)
+ SET(SRCS ${SRCS} src/utils/network-accessibility.c)
+ENDIF(TIZEN_CAPTIVE_PORTAL)
+
+IF(TIZEN_TV)
+ ADD_DEFINITIONS(-DTIZEN_TV)
+ENDIF(TIZEN_TV)
+
+IF(TIZEN_WEARABLE)
+ ADD_DEFINITIONS(-DTIZEN_WEARABLE)
+ SET(WEARABLE_REQUIRED_PKGS "weconn")
+ENDIF(TIZEN_WEARABLE)
+
+IF(TIZEN_TELEPHONY_ENABLE)
+ ADD_DEFINITIONS(-TIZEN_TELEPHONY_ENABLE)
+ENDIF(TIZEN_TELEPHONY_ENABLE)
+
+IF(TIZEN_DEBUG_DISABLE)
+ ADD_DEFINITIONS(-DTIZEN_DEBUG_DISABLE)
+ SET(SRCS ${SRCS} src/wifi-dump.c)
+ENDIF(TIZEN_DEBUG_DISABLE)
+
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(pkgs REQUIRED
- glib-2.0
- dbus-glib-1
dlog
- vconf
- capi-network-wifi-direct
tapi
- libsystemd-daemon)
+ vconf
+ bundle
+ gio-2.0
+ glib-2.0
+ gio-unix-2.0
+ eventsystem
+ alarm-service
+ syspopup-caller
+ capi-system-info
+ capi-appfw-application
+ ${P2P_REQUIRED_PKGS}
+ ${WEARABLE_REQUIRED_PKGS}
+ )
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall")
-SET(CMAKE_C_FLAGS "-I${CMAKE_SOURCE_DIR}/include ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-SET(CMAKE_C_FLAGS_RELEASE "-O2")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -fvisibility=hidden")
+SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} -Wall -Werror -fvisibility=hidden -fvisibility-inlines-hidden")
+SET(CMAKE_C_FLAGS "-I${CMAKE_SOURCE_DIR} -I${CMAKE_SOURCE_DIR}/include ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -fPIE")
+SET(CMAKE_C_FLAGS_RELEASE "-O2 -fPIE")
+
+IF(WLAN_CONCURRENT_MODE)
+ ADD_DEFINITIONS(-DWLAN_CONCURRENT_MODE)
+ENDIF(WLAN_CONCURRENT_MODE)
FIND_PROGRAM(UNAME NAMES uname)
EXEC_PROGRAM("${UNAME}" ARGS "-m"
OUTPUT_VARIABLE "ARCH")
IF("${ARCH}" STREQUAL "arm")
- ADD_DEFINITIONS("-DEMBEDDED_TARGET")
- MESSAGE("add -DEMBEDDED_TARGET")
+ ADD_DEFINITIONS("-DTARGET_ARM")
+ MESSAGE("add -DTARGET_ARM")
ENDIF("${ARCH}" STREQUAL "arm")
ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
-ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
-
-ADD_CUSTOM_TARGET(netconfig-iface-network-state-glue.h
- COMMAND dbus-binding-tool --mode=glib-server --prefix=netconfig_iface_network_state
- --output=${CMAKE_SOURCE_DIR}/include/netconfig-iface-network-state-glue.h
- ${CMAKE_SOURCE_DIR}/interfaces/netconfig-iface-network-state.xml
- DEPENDS ${CMAKE_SOURCE_DIR}/interfaces/netconfig-iface-network-state.xml
-)
-ADD_CUSTOM_TARGET(netconfig-iface-network-statistics-glue.h
- COMMAND dbus-binding-tool --mode=glib-server --prefix=netconfig_iface_network_statistics
- --output=${CMAKE_SOURCE_DIR}/include/netconfig-iface-network-statistics-glue.h
- ${CMAKE_SOURCE_DIR}/interfaces/netconfig-iface-network-statistics.xml
- DEPENDS ${CMAKE_SOURCE_DIR}/interfaces/netconfig-iface-network-statistics.xml
-)
-ADD_CUSTOM_TARGET(netconfig-iface-wifi-glue.h
- COMMAND dbus-binding-tool --mode=glib-server --prefix=netconfig_iface_wifi
- --output=${CMAKE_SOURCE_DIR}/include/netconfig-iface-wifi-glue.h
- ${CMAKE_SOURCE_DIR}/interfaces/netconfig-iface-wifi.xml
- DEPENDS ${CMAKE_SOURCE_DIR}/interfaces/netconfig-iface-wifi.xml
-)
-
-ADD_DEPENDENCIES(${PROJECT_NAME} netconfig-iface-network-state-glue.h)
-ADD_DEPENDENCIES(${PROJECT_NAME} netconfig-iface-network-statistics-glue.h)
-ADD_DEPENDENCIES(${PROJECT_NAME} netconfig-iface-wifi-glue.h)
+ADD_CUSTOM_COMMAND(
+ WORKING_DIRECTORY
+ OUTPUT ${CMAKE_SOURCE_DIR}/generated-code.c
+ COMMAND gdbus-codegen --interface-prefix net.netconfig.
+ --generate-c-code generated-code
+ --c-generate-object-manager
+ --generate-docbook generated-code-docs
+ ${INTERFACES}/netconfig-iface-network-state.xml ${INTERFACES}/netconfig-iface-network-statistics.xml ${INTERFACES}/netconfig-iface-wifi.xml
+ COMMENT "Generating GDBus .c/.h")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS} ${CMAKE_SOURCE_DIR}/generated-code.c)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${PCAP_LIB})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
--- /dev/null
+Copyright (c) 2000 - 2012 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
-
- 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.APLv2 file for Apache License terms and conditions.
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 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 __NETCONFIG_CELLULAR_STATE_H__
+#define __NETCONFIG_CELLULAR_STATE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum netconfig_cellular_service_state {
+ NETCONFIG_CELLULAR_UNKNOWN = 0x00,
+ NETCONFIG_CELLULAR_IDLE = 0x01,
+ NETCONFIG_CELLULAR_CONNECTING = 0x02,
+ NETCONFIG_CELLULAR_ONLINE = 0x03,
+};
+
+struct netconfig_cellular_state_notifier {
+ void (*netconfig_cellular_state_changed)
+ (enum netconfig_cellular_service_state, void *user_data);
+ void *user_data;
+};
+
+void netconfig_cellular_state_set_service_state(
+ enum netconfig_cellular_service_state new_state);
+enum netconfig_cellular_service_state
+ netconfig_cellular_state_get_service_state(void);
+
+void netconfig_cellular_state_notifier_cleanup(void);
+void netconfig_cellular_state_notifier_register(
+ struct netconfig_cellular_state_notifier *notifier);
+void netconfig_cellular_state_notifier_unregister(
+ struct netconfig_cellular_state_notifier *notifier);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_CELLULAR_STATE_H__ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2015 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 __NETCONFIG_CLATD_HANDLER__
+#define __NETCONFIG_CLATD_HANDLER__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int netconfig_clatd_enable(void);
+int netconfig_clatd_disable(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_CLATD_HANDLER__ */
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 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.
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 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.
#endif
#include <dlog.h>
-#include <stdio.h>
#include <string.h>
-#undef LOG_TAG
-#define LOG_TAG "NET_CONFIG"
+#define NETCONFIG_DEBUG_FILE (1)
-#define DBG(format, arg...) LOGD(format, ## arg)
-#define INFO(format, arg...) LOGI(format, ## arg)
-#define WARN(format, arg...) LOGW(format, ## arg)
-#define ERR(format, arg...) LOGE(format, ## arg)
+#define NETCONFIG_TAG "NETCONFIG"
+
+void __netconfig_debug(const char *format, ...);
+
+#define __LOG(level, format, arg...) \
+ do { \
+ if (NETCONFIG_DEBUG_FILE) { \
+ __netconfig_debug("%s(%d) "format"\n", __FUNCTION__, __LINE__, ## arg); \
+ } \
+ SLOG(level, NETCONFIG_TAG, format, ## arg); \
+ } while(0)
+
+#define DBG(format, arg...) __LOG(LOG_DEBUG, format, ## arg)
+#define INFO(format, arg...) __LOG(LOG_INFO, format, ## arg)
+#define WARN(format, arg...) __LOG(LOG_WARN, format, ## arg)
+#define ERR(format, arg...) __LOG(LOG_ERROR, format, ## arg)
#ifdef __cplusplus
}
+++ /dev/null
-/*
- * Network Configuration Module
- *
- * 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 MDM_PRIVATE_H_
-#define MDM_PRIVATE_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <glib.h>
-
-gboolean netconfig_is_wifi_allowed(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* MDM_PRIVATE_H_ */
+++ /dev/null
-/*
- * Network Configuration Module
- *
- * 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 __NETCONFIG_H__
-#define __NETCONFIG_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define NETCONFIG_SERVICE "net.netconfig"
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NETCONFIG_H__ */
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 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.
#ifndef __NETCONFIG_NETDBUS_H__
#define __NETCONFIG_NETDBUS_H__
+#include <glib.h>
+#include <gio/gio.h>
+#include <glib-object.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-#include <glib.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
+#define DBUS_REPLY_TIMEOUT (120 * 1000)
+#define NETCONFIG_DBUS_REPLY_TIMEOUT (10 * 1000)
+#define DBUS_INTERFACE_PROPERTIES "org.freedesktop.DBus.Properties"
+
+#define NETCONFIG_SERVICE "net.netconfig"
#define CONNMAN_SERVICE "net.connman"
#define CONNMAN_PATH "/net/connman"
-#define CONNMAN_CLOCK_INTERFACE CONNMAN_SERVICE ".Clock"
-#define CONNMAN_ERROR_INTERFACE CONNMAN_SERVICE ".Error"
-#define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager"
-#define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service"
-#define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology"
-#define CONNMAN_MANAGER_PATH "/"
+#define CONNMAN_CLOCK_INTERFACE CONNMAN_SERVICE ".Clock"
+#define CONNMAN_ERROR_INTERFACE CONNMAN_SERVICE ".Error"
+#define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager"
+#define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service"
+#define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology"
+#define CONNMAN_MANAGER_PATH "/"
-#define CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX CONNMAN_PATH "/service/cellular_"
+#define CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX CONNMAN_PATH "/service/cellular_"
#define CONNMAN_WIFI_SERVICE_PROFILE_PREFIX CONNMAN_PATH "/service/wifi_"
-#define CONNMAN_ETHERNET_SERVICE_PROFILE_PREFIX CONNMAN_PATH "/service/ethernet_"
-#define CONNMAN_BLUETOOTH_SERVICE_PROFILE_PREFIX CONNMAN_PATH "/service/bluetooth_"
-#define CONNMAN_CELLULAR_TECHNOLOGY_PREFIX CONNMAN_PATH "/technology/cellular"
-#define CONNMAN_WIFI_TECHNOLOGY_PREFIX CONNMAN_PATH "/technology/wifi"
-
-#define NETCONFIG_WIFI_INTERFACE "net.netconfig.wifi"
-#define NETCONFIG_WIFI_PATH "/net/netconfig/wifi"
+#define CONNMAN_ETHERNET_SERVICE_PROFILE_PREFIX CONNMAN_PATH "/service/ethernet_"
+#define CONNMAN_BLUETOOTH_SERVICE_PROFILE_PREFIX \
+ CONNMAN_PATH "/service/bluetooth_"
+
+#define CONNMAN_CELLULAR_TECHNOLOGY_PREFIX CONNMAN_PATH "/technology/cellular"
+#define CONNMAN_WIFI_TECHNOLOGY_PREFIX CONNMAN_PATH "/technology/wifi"
+#define CONNMAN_ETHERNET_TECHNOLOGY_PREFIX CONNMAN_PATH "/technology/ethernet"
+#define CONNMAN_BLUETOOTH_TECHNOLOGY_PREFIX CONNMAN_PATH "/technology/bluetooth"
+
+#define NETCONFIG_WIFI_INTERFACE "net.netconfig.wifi"
+#define NETCONFIG_WIFI_PATH "/net/netconfig/wifi"
+#define NETCONFIG_NETWORK_STATE_PATH "/net/netconfig/network"
+#define NETCONFIG_NETWORK_STATISTICS_PATH "/net/netconfig/network_statistics"
#define NETCONFIG_NETWORK_PATH "/net/netconfig/network"
#define NETCONFIG_NETWORK_INTERFACE "net.netconfig.network"
NETCONFIG_DBUS_RESULT_DEFAULT_TECHNOLOGY,
} netconfig_dbus_result_type;
+typedef void (*netconfig_got_name_cb)(void);
+
+GDBusObjectManagerServer *netconfig_get_wifi_manager(void);
+GDBusObjectManagerServer *netconfig_get_state_manager(void);
+GDBusObjectManagerServer *netconfig_get_statistics_manager(void);
+GDBusConnection *netconfig_gdbus_get_connection(void);
+GCancellable *netconfig_gdbus_get_gdbus_cancellable(void);
+void netconfig_gdbus_pending_call_ref(void);
+void netconfig_gdbus_pending_call_unref(void);
+int netconfig_create_gdbus_call(GDBusConnection *conn);
+
+gboolean netconfig_is_cellular_internet_profile(const char *profile);
gboolean netconfig_is_cellular_profile(const char *profile);
gboolean netconfig_is_wifi_profile(const char *profile);
gboolean netconfig_is_ethernet_profile(const char *profile);
gboolean netconfig_is_bluetooth_profile(const char *profile);
-char *netconfig_wifi_get_connected_service_name(DBusMessage *message);
-
-gboolean netconfig_invoke_dbus_method_nonblock(
- const char *dest, const char *path,
- const char *interface_name, const char *method, char *param_array[],
- DBusPendingCallNotifyFunction notify_func);
-DBusMessage *netconfig_invoke_dbus_method(const char *dest, const char *path,
- const char *interface_name, const char *method, char *param_array[]);
-
-gboolean netconfig_dbus_get_basic_params_string(DBusMessage *message,
- char **key, int type, void *value);
-gboolean netconfig_dbus_get_basic_params_array(DBusMessage *message,
- char **key, void **value);
+gboolean netconfig_invoke_dbus_method_nonblock(const char *dest, const char *path,
+ const char *interface_name, const char *method, GVariant *params,
+ GAsyncReadyCallback notify_func);
+GVariant *netconfig_invoke_dbus_method(const char *dest, const char *path,
+ const char *interface_name, const char *method,
+ GVariant *params);
-DBusGConnection *netconfig_setup_dbus(void);
+int netconfig_setup_gdbus(netconfig_got_name_cb cb);
+void netconfig_cleanup_gdbus(void);
#ifdef __cplusplus
}
#endif
#include "glib.h"
+#include <gio/gio.h>
+#include <glib-object.h>
#define NETCONFIG_ERROR_QUARK (netconfig_error_quark())
#define NETCONFIG_CONNMAN_AGENT_ERROR_QUARK (netconfig_connman_agent_error_quark())
-void netconfig_error_inprogress(GError **error);
-void netconfig_error_already_exists(GError **error);
-void netconfig_error_invalid_parameter(GError **error);
-void netconfig_error_permission_denied(GError **error);
-void netconfig_error_wifi_driver_failed(GError **error);
-void netconfig_error_security_restricted(GError **error);
-void netconfig_error_wifi_direct_failed(GError **error);
-void netconfig_error_fail_get_imsi(GError **error);
-void netconfig_error_fail_req_sim_auth(GError **error);
-void netconfig_error_fail_req_sim_auth_wrong_param(GError **error);
-void netconfig_error_fail_get_sim_auth_wrong_data(GError **error);
-void netconfig_error_fail_get_sim_auth_delay(GError **error);
-void netconfig_error_invalid_parameter(GError **error);
-void netconfig_error_permission_denied(GError **error);
-void netconfig_error_wifi_load_inprogress(GError **error);
+typedef enum {
+ NETCONFIG_NO_ERROR = 0x00,
+ NETCONFIG_ERROR_INTERNAL = 0x01,
+ NETCONFIG_ERROR_NO_SERVICE = 0x02,
+ NETCONFIG_ERROR_TRASPORT = 0x03,
+ NETCONFIG_ERROR_NO_PROFILE = 0x04,
+ NETCONFIG_ERROR_WRONG_PROFILE = 0x05,
+ NETCONFIG_ERROR_INPROGRESS = 0x06,
+ NETCONFIG_ERROR_ALREADYEXISTS = 0x07,
+ NETCONFIG_ERROR_INVALID_PARAMETER = 0x08,
+ NETCONFIG_ERROR_PERMISSION_DENIED = 0x09,
+ NETCONFIG_ERROR_WIFI_DRIVER_FAILURE = 0x0A,
+ NETCONFIG_ERROR_FAILED_GET_IMSI = 0x0B,
+ NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH = 0x0C,
+ NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM = 0x0D,
+ NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_WRONG_DATA = 0x0E,
+ NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_DELAY = 0x0F,
+ NETCONFIG_ERROR_FAILED_REQ_AKA_AUTH = 0x10,
+ NETCONFIG_ERROR_MAX = 0x11,
+} netconfig_error_e;
+void netconfig_error_no_profile(GDBusMethodInvocation *context);
+void netconfig_error_inprogress(GDBusMethodInvocation *context);
+void netconfig_error_already_exists(GDBusMethodInvocation *context);
+void netconfig_error_invalid_parameter(GDBusMethodInvocation *context);
+void netconfig_error_permission_denied(GDBusMethodInvocation *context);
+void netconfig_error_wifi_driver_failed(GDBusMethodInvocation *context);
+void netconfig_error_wifi_direct_failed(GDBusMethodInvocation *context);
+void netconfig_error_fail_get_imsi(GDBusMethodInvocation *context);
+void netconfig_error_fail_req_sim_auth(GDBusMethodInvocation *context);
+void netconfig_error_fail_req_sim_auth_wrong_param(GDBusMethodInvocation *context);
+void netconfig_error_fail_get_sim_auth_wrong_data(GDBusMethodInvocation *context);
+void netconfig_error_fail_get_sim_auth_delay(GDBusMethodInvocation *context);
+void netconfig_error_dbus_method_return(GDBusMethodInvocation *context, netconfig_error_e error, const gchar *message);
+
+void netconfig_error_init(void);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* __NETCONFIG_ERROR_H__ */
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 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.
#ifndef __NETCONFIG_NETSUPPLICANT_H__
#define __NETCONFIG_NETSUPPLICANT_H__
+#include "netdbus.h"
+
#ifdef __cplusplus
extern "C" {
#endif
-#include <glib.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-
-#define WIFI_IFNAME "wlan0"
+#define WIFI_IFNAME "wlan0"
#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_IFACE_WPS SUPPLICANT_INTERFACE ".Interface.WPS"
#define SUPPLICANT_PATH "/fi/w1/wpa_supplicant1"
-#define SUPPLICANT_GLOBAL_INTERFACE "org.freedesktop.DBus.Properties"
struct dbus_input_arguments {
int type;
void *data;
};
-gboolean netconfig_wifi_get_ifname(char **ifname);
-gboolean netconfig_wifi_get_supplicant_interface(char **path);
-
-const char *netconfig_wifi_get_supplicant_interface_(void);
+/* Returns Supplicant interface
+ * Do not free the returned interface */
+const char *netconfig_wifi_get_supplicant_interface(void);
GList *setup_input_args(GList *list, struct dbus_input_arguments *items);
-
-DBusMessage *netconfig_supplicant_invoke_dbus_method(const char *dest,
- DBusConnection *connection,
+GVariant *netconfig_supplicant_invoke_dbus_method(const char *dest, const char *path,
+ const char *interface_name, const char *method,
+ GVariant *params);
+gboolean netconfig_supplicant_invoke_dbus_method_nonblock(const char *dest,
const char *path, const char *interface_name,
- const char *method, GList *args);
-
-DBusMessage *netconfig_supplicant_invoke_dbus_method_(const char *dest,
- const char *path, const char *interface_name,
- const char *method, GList *args);
-
-DBusMessage *netconfig_supplicant_invoke_dbus_interface_property_get(const char *interface,
+ const char *method, GVariant *params,
+ GAsyncReadyCallback notify_func);
+GVariant *netconfig_supplicant_invoke_dbus_interface_property_get(const char *interface,
const char *key);
-dbus_bool_t netconfig_supplicant_invoke_dbus_interface_property_set(const char *interface,
- const char *key, const char *type, GList *args,
- DBusPendingCallNotifyFunction notify_func);
+gboolean netconfig_supplicant_invoke_dbus_interface_property_set(const char *interface,
+ const char *key, GVariant *message,
+ GAsyncReadyCallback notify_func);
+
#ifdef __cplusplus
}
#endif
--- /dev/null
+/*
+* internet-accessibility check
+*
+* Copyright 2012 Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.1 (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.tizenopensource.org/license
+*
+* 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 __NETCONFIG_NETWORK_ACCESSIBILITY_H__
+#define __NETCONFIG_NETWORK_ACCESSIBILITY_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void netconfig_check_internet_accessibility(void);
+void netconfig_stop_internet_check(void);
+
+/* Alert: Please do not use netconfig_get_internet_status() API to get the
+ * status of Internet availability on general Wifi access points, as this module
+ * primarily checks for Internet availability on portal enabled Wifi access
+ * points, so we only check for below criteria in server's response to conclude
+ * whether Internet is accessible.
+ * 1) If the HTTP status != 302
+ * 2) If the HTTP status != (200 with redirection),
+*/
+gboolean netconfig_get_internet_status();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_NETWORK_ACCESSIBILITY_H__ */
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 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.
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 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.
extern "C" {
#endif
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-
-G_BEGIN_DECLS
-
-typedef struct NetconfigNetworkState NetconfigNetworkState;
-typedef struct NetconfigNetworkStateClass NetconfigNetworkStateClass;
-
-#define NETCONFIG_TYPE_NETWORK_STATE ( netconfig_network_state_get_type() )
-#define NETCONFIG_NETWORK_STATE(obj) ( G_TYPE_CHECK_INSTANCE_CAST( (obj),NETCONFIG_TYPE_NETWORK_STATE, NetconfigNetworkState ) )
-#define NETCONFIG_IS_NETWORK_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE( (obj), NETCONFIG_TYPE_NETWORK_STATE) )
-
-#define NETCONFIG_NETWORK_STATE_CLASS(klass) ( G_TYPE_CHECK_CLASS_CAST( (klass), NETCONFIG_TYPE_NETWORK_STATE, NetconfigNetworkStateClass) )
-#define NETCONFIG_IS_NETWORK_STATE_CLASS(klass) ( G_TYPE_CHECK_CLASS_TYPE( (klass), NETCONFIG_TYPE_NETWORK_STATE) )
-#define NETCONFIG_NETWORK_STATE_GET_CLASS(obj) ( G_TYPE_INSTANCE_GET_CLASS( (obj), NETCONFIG_TYPE_NETWORK_STATE, NetconfigNetworkStateClass ) )
-
-GType netconfig_network_state_get_type(void);
-
-gpointer netconfig_network_state_create_and_init(DBusGConnection *conn);
+void netconfig_network_state_create_and_init(void);
void netconfig_network_notify_ethernet_cable_state(const char *key);
const char *netconfig_get_default_profile(void);
+const char *netconfig_get_default_ifname(void);
const char *netconfig_get_default_ipaddress(void);
+const char *netconfig_get_default_ipaddress6(void);
const char *netconfig_get_default_proxy(void);
+unsigned int netconfig_get_default_frequency(void);
const char *netconfig_wifi_get_connected_essid(const char *default_profile);
-void netconfig_set_default_profile(const char *profile);
-G_END_DECLS
+void netconfig_update_default(void);
+void netconfig_update_default_profile(const char *profile);
+char *netconfig_network_get_ifname(const char *profile);
#ifdef __cplusplus
}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 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.
*
*/
-#ifndef NETWORK_STATISTICS_H_
-#define NETWORK_STATISTICS_H_
+#ifndef __NETWORK_STATISTICS_H__
+#define __NETWORK_STATISTICS_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-#include <wifi-state.h>
-
-G_BEGIN_DECLS
-
-typedef struct NetconfigNetworkStatistics NetconfigNetworkStatistics;
-typedef struct NetconfigNetworkStatisticsClass NetconfigNetworkStatisticsClass;
-
-#define NETCONFIG_TYPE_NETWORK_STATISTICS ( netconfig_network_statistics_get_type() )
-#define NETCONFIG_NETWORK_STATISTICS(obj) ( G_TYPE_CHECK_INSTANCE_CAST( (obj),NETCONFIG_TYPE_NETWORK_STATISTICS, NetconfigNetworkStatistics ) )
-#define NETCONFIG_IS_NETWORK_STATISTICS(obj) (G_TYPE_CHECK_INSTANCE_TYPE( (obj), NETCONFIG_TYPE_NETWORK_STATISTICS) )
-
-#define NETCONFIG_NETWORK_STATISTICS_CLASS(klass) ( G_TYPE_CHECK_CLASS_CAST( (klass), NETCONFIG_TYPE_NETWORK_STATISTICS, NetconfigNetworkStatisticsClass) )
-#define NETCONFIG_IS_NETWORK_STATISTICS_CLASS(klass) ( G_TYPE_CHECK_CLASS_TYPE( (klass), NETCONFIG_TYPE_NETWORK_STATISTICS) )
-#define NETCONFIG_NETWORK_STATISTICS_GET_CLASS(obj) ( G_TYPE_INSTANCE_GET_CLASS( (obj), NETCONFIG_TYPE_NETWORK_STATISTICS, NetconfigNetworkStatisticsClass ) )
-
-GType netconfig_network_statistics_get_type(void);
-
-gpointer netconfig_network_statistics_create_and_init(DBusGConnection *conn);
-
-
-gboolean netconfig_iface_network_statistics_get_wifi_total_tx_bytes(NetconfigNetworkStatistics *network_statistics, guint64 *total_bytes, GError **error);
-gboolean netconfig_iface_network_statistics_get_wifi_total_rx_bytes(NetconfigNetworkStatistics *network_statistics, guint64 *total_bytes, GError **error);
-gboolean netconfig_iface_network_statistics_get_wifi_last_tx_bytes(NetconfigNetworkStatistics *network_statistics, guint64 *last_bytes, GError **error);
-gboolean netconfig_iface_network_statistics_get_wifi_last_rx_bytes(NetconfigNetworkStatistics *network_statistics, guint64 *last_bytes, GError **error);
-
-gboolean netconfig_iface_network_statistics_reset_cellular_total_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error);
-gboolean netconfig_iface_network_statistics_reset_cellular_total_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error);
-gboolean netconfig_iface_network_statistics_reset_cellular_last_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error);
-gboolean netconfig_iface_network_statistics_reset_cellular_last_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error);
-
-gboolean netconfig_iface_network_statistics_reset_wifi_total_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error);
-gboolean netconfig_iface_network_statistics_reset_wifi_total_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error);
-gboolean netconfig_iface_network_statistics_reset_wifi_last_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error);
-gboolean netconfig_iface_network_statistics_reset_wifi_last_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error);
+#include "wifi-state.h"
+void netconfig_network_statistics_create_and_init(void);
gboolean netconfig_wifi_get_bytes_statistics(guint64 *tx, guint64 *rx);
void netconfig_wifi_statistics_update_powered_off(void);
-G_END_DECLS
-
#ifdef __cplusplus
}
#endif
-#endif /* NETWORK_STATISTICS_H_ */
+#endif /* __NETWORK_STATISTICS_H__ */
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 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.
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "wifi.h"
+#define NETCONFIG_ADD_FOUND_AP_NOTI "add_found_ap_noti"
+#define NETCONFIG_DEL_FOUND_AP_NOTI "del_found_ap_noti"
+#define NETCONFIG_ADD_PORTAL_NOTI "add_portal_noti"
+#define NETCONFIG_DEL_PORTAL_NOTI "del_portal_noti"
+#define NETCONFIG_TIZENMOBILEENV "/run/tizen-mobile-env"
+
#define MAX_SIZE_ERROR_BUFFER 256
+#if defined TIZEN_WEARABLE
+typedef enum {
+ WC_POPUP_TYPE_SESSION_OVERLAPPED,
+ WC_POPUP_TYPE_WIFI_CONNECTED,
+ WC_POPUP_TYPE_CAPTIVE_PORTAL,
+ WC_POPUP_TYPE_WIFI_RESTRICT
+}netconfig_wcpopup_type_e;
+#endif
+
GKeyFile *netconfig_keyfile_load(const char *pathname);
void netconfig_keyfile_save(GKeyFile *keyfile, const char *pathname);
gboolean(*callback) (gpointer), void *user_data, guint *timer_id);
void netconfig_stop_timer(guint *timer_id);
+void netconfig_wifi_enable_device_picker_test(void);
void netconfig_wifi_device_picker_service_start(void);
void netconfig_wifi_device_picker_service_stop(void);
gboolean netconfig_is_wifi_direct_on(void);
gboolean netconfig_is_wifi_tethering_on(void);
-gboolean netconfig_execute_file(const char *file_path,
- char *const args[], char *const env[]);
+gboolean netconfig_interface_up(const char *ifname);
+gboolean netconfig_interface_down(const char *ifname);
+
+int netconfig_execute_file(const char *file_path, char *const args[], char *const env[]);
+int netconfig_execute_clatd(const char *file_path, char *const args[]);
int netconfig_add_route_ipv6(gchar *ip_addr, gchar *interface, gchar *gateway, unsigned char prefix_len);
int netconfig_del_route_ipv6(gchar *ip_addr, gchar *interface, gchar *gateway, unsigned char prefix_len);
-gboolean netconfig_iface_wifi_launch_direct(NetconfigWifi *wifi, GError **error);
-void netconfig_set_wifi_mac_address(void);
-
-void netconfig_add_wifi_found_notification(void);
-void netconfig_del_wifi_found_notification(void);
-gboolean netconfig_interface_up(const char *ifname);
-gboolean netconfig_interface_down(const char *ifname);
+gboolean handle_launch_direct(Wifi *wifi, GDBusMethodInvocation *context);
+gboolean netconfig_send_notification_to_net_popup(const char * noti, const char * data);
+int netconfig_send_message_to_net_popup(const char *title,
+ const char *content, const char *type, const char *ssid);
+void netconfig_set_system_event(const char * sys_evt, const char * evt_key, const char * evt_val);
+#if defined TIZEN_WEARABLE
+int wc_launch_syspopup(netconfig_wcpopup_type_e type);
+int wc_launch_popup(netconfig_wcpopup_type_e type);
+#endif
+void netconfig_set_vconf_int(const char * key, int value);
+void netconfig_set_vconf_str(const char * key, const char * value);
+char* netconfig_get_env(const char *key);
#ifdef __cplusplus
}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 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.
*/
#ifndef __NETCONFIG_WIFI_AGENT_H__
-#define __NETCONFIG_WIFI_AGENT_H__
+#define __NETCONFIG_WIFI_AGENT_H__
#ifdef __cplusplus
extern "C" {
gboolean netconfig_agent_register(void);
gboolean netconfig_agent_unregister(void);
-gboolean netconfig_iface_wifi_set_field(NetconfigWifi *wifi,
- GHashTable *fields, GError **error);
-gboolean netconfig_iface_wifi_request_input(NetconfigWifi *wifi,
- gchar *service, GHashTable *fields,
- DBusGMethodInvocation *context);
+
+gboolean netconfig_wifi_set_agent_field_for_eap_network(
+ const char *name, const char *identity, const char *passphrase);
+
+gboolean handle_set_field(NetConnmanAgent *connman_agent,
+ GDBusMethodInvocation *context, const gchar *service, GVariant *fields);
+gboolean handle_request_input(NetConnmanAgent *connman_agent,
+ GDBusMethodInvocation *context, const gchar *service, GVariant *fields);
+gboolean handle_report_error(NetConnmanAgent *connman_agent,
+ GDBusMethodInvocation *context,
+ const gchar *service, const gchar *error);
+
+gboolean handle_request_browser(NetConnmanAgent *connman_agent,
+ GDBusMethodInvocation *context,
+ const gchar *service, const gchar *url);
#ifdef __cplusplus
}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "wifi.h"
-void netconfig_wifi_bgscan_start(void);
+void netconfig_wifi_bgscan_start(gboolean immediate_scan);
void netconfig_wifi_bgscan_stop(void);
gboolean netconfig_wifi_get_bgscan_state(void);
gboolean netconfig_wifi_get_scanning(void);
void netconfig_wifi_set_scanning(gboolean scanning);
+gboolean netconfig_wifi_is_bgscan_paused(void);
+void netconfig_wifi_set_bgscan_pause(gboolean pause);
+
+gboolean handle_set_bgscan(Wifi *wifi, GDBusMethodInvocation *context, guint scan_mode);
+gboolean handle_resume_bgscan(Wifi *wifi, GDBusMethodInvocation *context);
+gboolean handle_pause_bgscan(Wifi *wifi, GDBusMethodInvocation *context);
-gboolean netconfig_iface_wifi_set_bgscan(NetconfigWifi *wifi, guint scan_mode, GError **error);
-void netconfig_wifi_init_bgscan();
-void netconfig_wifi_deinit_bgscan();
#ifdef __cplusplus
}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 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 __NETCONFIG_WIFI_CONFIG_H__
+#define __NETCONFIG_WIFI_CONFIG_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "wifi.h"
+
+gboolean handle_get_config_ids(Wifi *wifi, GDBusMethodInvocation *context);
+gboolean handle_load_configuration(Wifi *wifi, GDBusMethodInvocation *context, const gchar *config_id);
+gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context, const gchar *config_id, GVariant *configuration);
+gboolean handle_remove_configuration(Wifi *wifi, GDBusMethodInvocation *context, const gchar *config_id);
+gboolean handle_set_config_field(Wifi *wifi, GDBusMethodInvocation *context, const gchar *config_id, const gchar *key, const gchar *value);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFI_CONFIG_H */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 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 __NETCONFIG_WIFI_DUMP_H__
+#define __NETCONFIG_WIFI_DUMP_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define DUMP_SERVICE_BUS_NAME "org.tizen.system.dumpservice"
+#define DUMP_SERVICE_OBJECT_PATH "/Org/Tizen/System/DumpService"
+#define DUMP_SERVICE_INTERFACE "org.tizen.system.dumpservice"
+
+#define DUMP_SIGNAL "Dump"
+#define DUMP_START_SIGNAL "Start"
+#define DUMP_FINISH_SIGNAL "Finish"
+
+int netconfig_dump_log(const char *path);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 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.
*/
#ifndef __NETCONFIG_WIFI_EAP_CONFIG_H__
-#define __NETCONFIG_WIFI_EAP_CONFIG_H__
+#define __NETCONFIG_WIFI_EAP_CONFIG_H__
#ifdef __cplusplus
extern "C" {
#include "wifi.h"
-#define CONNMAN_STORAGEDIR "/var/lib/connman"
-
-#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"
-
-gboolean netconfig_iface_wifi_create_config(NetconfigWifi *wifi,
- GHashTable *fields, GError **error);
-gboolean netconfig_iface_wifi_delete_config(NetconfigWifi *wifi,
- gchar *profile, GError **error);
+gboolean handle_create_eap_config(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *service, GVariant *fields);
+gboolean handle_delete_eap_config(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *profile);
#ifdef __cplusplus
}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "wifi.h"
-gboolean netconfig_iface_wifi_get_sim_imsi(NetconfigWifi *wifi, DBusGMethodInvocation *context);
-gboolean netconfig_iface_wifi_req_sim_auth(NetconfigWifi *wifi, GArray *rand_data, gboolean *result, GError **error);
-gboolean netconfig_iface_wifi_req_aka_auth(NetconfigWifi *wifi, GArray *rand_data, GArray *autn_data, gboolean *result, GError **error);
-gboolean netconfig_iface_wifi_get_sim_auth(NetconfigWifi *wifi, DBusGMethodInvocation *context);
-gboolean netconfig_iface_wifi_get_aka_auth(NetconfigWifi *wifi, DBusGMethodInvocation *context);
+gboolean handle_get_sim_imsi(Wifi *wifi, GDBusMethodInvocation *context);
+gboolean handle_req_sim_auth(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *rand_data);
+gboolean handle_req_aka_auth(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *rand_data, const gchar *autn_data);
+gboolean handle_get_sim_auth(Wifi *wifi, GDBusMethodInvocation *context);
+gboolean handle_get_aka_auth(Wifi *wifi, GDBusMethodInvocation *context);
#ifdef __cplusplus
}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 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.
*
*/
-
#ifndef __NETCONFIG_WIFI_FIRMWARE_H__
#define __NETCONFIG_WIFI_FIRMWARE_H__
#endif
#include <glib.h>
+#include "wifi.h"
enum netconfig_wifi_firmware {
NETCONFIG_WIFI_OFF = 0x00,
int netconfig_wifi_firmware(enum netconfig_wifi_firmware type, gboolean enable);
-gboolean netconfig_iface_wifi_start(
- NetconfigWifi *wifi, gchar *device, GError **error);
-gboolean netconfig_iface_wifi_stop(
- NetconfigWifi *wifi, gchar *device, GError **error);
+gboolean handle_start(WifiFirmware *firmware, GDBusMethodInvocation *context, const gchar *device);
+gboolean handle_stop(WifiFirmware *firmware, GDBusMethodInvocation *context, const gchar *device);
#ifdef __cplusplus
}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 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.
#endif
int netconfig_wifi_get_rssi(void);
+int netconfig_wifi_rssi_level(const int rssi_dbm);
void netconfig_wifi_indicator_start(void);
void netconfig_wifi_indicator_stop(void);
-/*\r
- * Network Configuration Module\r
- *\r
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#ifndef __NETCONFIG_WIFI_PASSPOINT_H__\r
-#define __NETCONFIG_WIFI_PASSPOINT_H__\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-#include "wifi.h"\r
-\r
-gboolean netconfig_iface_wifi_get_passpoint(NetconfigWifi *wifi,\r
- int *result, GError **error);\r
-gboolean netconfig_iface_wifi_set_passpoint(NetconfigWifi *wifi,\r
- int enable, GError **error);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif /* __NETCONFIG_WIFI_PASSPOINT_H__ */\r
-\r
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 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 __NETCONFIG_WIFI_PASSPOINT_H__
+#define __NETCONFIG_WIFI_PASSPOINT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "wifi.h"
+
+gboolean handle_get_passpoint(Wifi *wifi, GDBusMethodInvocation *context);
+gboolean handle_set_passpoint(Wifi *wifi, GDBusMethodInvocation *context, gint enable);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFI_PASSPOINT_H__ */
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 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.
extern "C" {
#endif
-#include <glib.h>
+#include "wifi.h"
-void netconfig_set_power_in_progress(gboolean in_progress);
-void netconfig_check_fm_waiting(void);
-void netconfig_wifi_power_configuration(void);
+void netconfig_wifi_power_initialize(void);
+void netconfig_wifi_power_deinitialize(void);
-gboolean netconfig_iface_wifi_load_driver(NetconfigWifi *wifi, GError **error);
-gboolean netconfig_iface_wifi_remove_driver(NetconfigWifi *wifi, GError **error);
+int netconfig_wifi_on(void);
+int netconfig_wifi_off(void);
+int netconfig_wifi_driver_and_supplicant(gboolean enable);
+void netconfig_wifi_disable_technology_state_by_only_connman_signal(void);
+
+void netconfig_wifi_recover_firmware(void);
+
+gboolean handle_load_driver(Wifi *wifi,
+ GDBusMethodInvocation *context, gboolean device_picker_test);
+gboolean handle_remove_driver(Wifi *wifi, GDBusMethodInvocation *context);
+
+gboolean handle_load_p2p_driver(Wifi *wifi, GDBusMethodInvocation *context);
+gboolean handle_remove_p2p_driver(Wifi *wifi, GDBusMethodInvocation *context);
+
+#if defined TIZEN_TV
+ void __netconfig_set_ether_macaddr();
+#endif
#ifdef __cplusplus
}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "wifi.h"
-enum netconfig_wifi_security {
- WIFI_SECURITY_UNKNOWN = 0x00,
- WIFI_SECURITY_NONE = 0x01,
- WIFI_SECURITY_WEP = 0x02,
- WIFI_SECURITY_PSK = 0x03,
- WIFI_SECURITY_IEEE8021X = 0x04,
-};
-
gboolean netconfig_wifi_get_ssid_scan_state(void);
void netconfig_wifi_notify_ssid_scan_done(void);
-void netconfig_wifi_bss_added(DBusMessage *message);
+void netconfig_wifi_bss_added(GVariant *message);
gboolean netconfig_wifi_ssid_scan(const char *ssid);
-gboolean netconfig_iface_wifi_request_specific_scan(NetconfigWifi *wifi,
- gchar *ssid, GError **error);
+gboolean handle_request_specific_scan(Wifi *wifi,
+ GDBusMethodInvocation *context, const gchar *ssid);
#ifdef __cplusplus
}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 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.
#endif
#include <glib.h>
-#include <dbus/dbus.h>
enum netconfig_wifi_service_state {
NETCONFIG_WIFI_UNKNOWN = 0x00,
NETCONFIG_WIFI_IDLE = 0x01,
- NETCONFIG_WIFI_CONNECTING = 0x02,
- NETCONFIG_WIFI_CONNECTED = 0x03,
+ NETCONFIG_WIFI_ASSOCIATION = 0x02,
+ NETCONFIG_WIFI_CONFIGURATION = 0x03,
+ NETCONFIG_WIFI_CONNECTED = 0x04,
+ NETCONFIG_WIFI_FAILURE = 0x05,
};
enum netconfig_wifi_tech_state {
- NETCONFIG_WIFI_TECH_UNKNOWN = 0x00,
- NETCONFIG_WIFI_TECH_OFF = 0x01,
- NETCONFIG_WIFI_TECH_POWERED = 0x02,
- NETCONFIG_WIFI_TECH_CONNECTED = 0x03,
- NETCONFIG_WIFI_TECH_TETHERING_ON = 0x04,
+ NETCONFIG_WIFI_TECH_UNKNOWN = 0x00,
+ NETCONFIG_WIFI_TECH_OFF = 0x01,
+ NETCONFIG_WIFI_TECH_WPS_ONLY = 0x02,
+ NETCONFIG_WIFI_TECH_POWERED = 0x03,
+ NETCONFIG_WIFI_TECH_CONNECTED = 0x04,
+ NETCONFIG_WIFI_TECH_TETHERED = 0x05,
};
struct netconfig_wifi_state_notifier {
void *user_data;
};
+#define VCONF_WIFI_LAST_POWER_STATE "file/private/wifi/last_power_state"
+
+void netconfig_wifi_set_bss_found(const gboolean found);
+gboolean netconfig_wifi_is_bss_found(void);
void netconfig_wifi_state_set_service_state(
- enum netconfig_wifi_service_state state);
+ enum netconfig_wifi_service_state new_state);
enum netconfig_wifi_service_state
netconfig_wifi_state_get_service_state(void);
+void netconfig_wifi_state_set_technology_state(
+ enum netconfig_wifi_tech_state new_state);
enum netconfig_wifi_tech_state
- netconfig_wifi_get_technology_state(void);
+ netconfig_wifi_state_get_technology_state(void);
+void netconfig_wifi_notify_power_failed(void);
+void netconfig_wifi_notify_power_completed(gboolean power_on);
void netconfig_wifi_update_power_state(gboolean powered);
char *netconfig_wifi_get_favorite_service(void);
-void netconfig_wifi_check_network_notification(DBusMessage *message);
+void netconfig_wifi_start_timer_network_notification(void);
void netconfig_wifi_state_notifier_cleanup(void);
void netconfig_wifi_state_notifier_register(
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 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 __NETCONFIG_WIFI_TEL_INTF_H__
+#define __NETCONFIG_WIFI_TEL_INTF_H__
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#include <ITapiSim.h>
+#include <TapiUtility.h>
+#include "wifi.h"
+
+TapiHandle * netconfig_tel_init(void);
+void netconfig_tel_deinit(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFI_TEL_INTERFACE_H__ */
+
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 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 __NETCONFIG_WIFI_WPS_H__
+#define __NETCONFIG_WIFI_WPS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "wifi.h"
+
+gboolean netconfig_wifi_is_wps_enabled(void);
+
+void netconfig_wifi_wps_signal_scandone(void);
+void netconfig_wifi_wps_signal_scanaborted(void);
+
+gboolean handle_request_wps_scan(Wifi *wifi, GDBusMethodInvocation *context);
+gboolean netconfig_iface_wifi_request_wps_cancel(Wifi *wifi, GDBusMethodInvocation **context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFI_WPS_H__ */
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 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.
*/
#ifndef __NETCONFIG_WIFI_H__
-#define __NETCONFIG_WIFI_H__
+#define __NETCONFIG_WIFI_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <glib.h>
+#include <gio/gio.h>
#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-G_BEGIN_DECLS
+#include "generated-code.h"
-typedef struct NetconfigWifi NetconfigWifi;
-typedef struct NetconfigWifiClass NetconfigWifiClass;
+#define WIFI_STORAGEDIR "/var/lib/wifi"
+#define WIFI_CERT_STORAGEDIR "/var/lib/wifi/cert"
+#define CONNMAN_STORAGEDIR "/var/lib/connman"
-#define NETCONFIG_TYPE_WIFI (netconfig_wifi_get_type())
-#define NETCONFIG_WIFI(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NETCONFIG_TYPE_WIFI, NetconfigWifi))
-#define NETCONFIG_IS_WIFI(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NETCONFIG_TYPE_WIFI))
-#define NETCONFIG_WIFI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), NETCONFIG_TYPE_WIFI, NetconfigWifiClass))
-#define NETCONFIG_IS_WIFI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NETCONFIG_TYPE_WIFI))
-#define NETCONFIG_WIFI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), NETCONFIG_TYPE_WIFI, NetconfigWifiClass))
-
-#define VCONF_WIFI_LAST_POWER_STATE "file/private/wifi/last_power_state"
-
-enum netconfig_wifi_power_state {
- WIFI_POWER_OFF = 0x00,
- WIFI_POWER_ON = 0x01,
-};
-
-GType netconfig_wifi_get_type(void);
-
-gpointer netconfig_wifi_create_and_init(DBusGConnection *conn);
-gboolean netconfig_wifi_remove_driver(void);
-void netconfig_wifi_notify_power_completed(gboolean power_on);
-
-G_END_DECLS
+void netconfig_wifi_create_and_init(void);
+void netconfig_wifi_init(void);
+Wifi *get_netconfig_wifi_object(void);
#ifdef __cplusplus
}
<node name="/net/netconfig/network">
<interface name="net.netconfig.network">
<method name="AddRoute">
- <arg type="s" name="ip_addr" direction="in" />
- <arg type="s" name="netmask" direction="in" />
- <arg type="s" name="interface" direction="in" />
+ <arg type="s" name="ip_addr" direction="in"/>
+ <arg type="s" name="netmask" direction="in"/>
+ <arg type="s" name="interface" direction="in"/>
<arg type="s" name="gateway" direction="in"/>
<arg type="i" name="address_family" direction="in"/>
- <arg type="b" name="result" direction="out" />
+ <arg type="b" name="result" direction="out"/>
</method>
<method name="RemoveRoute">
- <arg type="s" name="ip_addr" direction="in" />
- <arg type="s" name="netmask" direction="in" />
- <arg type="s" name="interface" direction="in" />
+ <arg type="s" name="ip_addr" direction="in"/>
+ <arg type="s" name="netmask" direction="in"/>
+ <arg type="s" name="interface" direction="in"/>
<arg type="s" name="gateway" direction="in"/>
<arg type="i" name="address_family" direction="in"/>
- <arg type="b" name="result" direction="out" />
+ <arg type="b" name="result" direction="out"/>
</method>
<method name="EthernetCableState">
<arg type="i" name="state" direction="out"/>
</method>
+ <method name="CheckGetPrivilege"></method>
+ <method name="CheckProfilePrivilege"></method>
</interface>
-</node>
+</node>
\ No newline at end of file
<node name="/net/netconfig/network_statistics">
<interface name="net.netconfig.network_statistics">
<method name="GetWifiTotalTxBytes">
- <arg type="t" name="total_bytes" direction="out" />
+ <arg type="t" name="total_bytes" direction="out"/>
</method>
<method name="GetWifiTotalRxBytes">
- <arg type="t" name="total_bytes" direction="out" />
+ <arg type="t" name="total_bytes" direction="out"/>
</method>
<method name="GetWifiLastTxBytes">
- <arg type="t" name="last_bytes" direction="out" />
+ <arg type="t" name="last_bytes" direction="out"/>
</method>
<method name="GetWifiLastRxBytes">
- <arg type="t" name="last_bytes" direction="out" />
+ <arg type="t" name="last_bytes" direction="out"/>
</method>
<method name="ResetCellularTotalTxBytes">
</method>
<node name="/net/netconfig/wifi">
<interface name="net.netconfig.wifi">
<method name="LoadDriver">
+ <arg type="b" name="DevicePickerTest" direction="in"/>
</method>
<method name="RemoveDriver">
</method>
<method name="LaunchDirect">
</method>
+ <method name="LoadP2pDriver">
+ </method>
+ <method name="RemoveP2pDriver">
+ </method>
<method name="SetBgscan">
<arg type="u" name="ScanMode" direction="in"/>
</method>
+ <method name="ResumeBgscan">
+ </method>
+ <method name="PauseBgscan">
+ </method>
<method name="RequestSpecificScan">
<arg type="s" name="SSID" direction="in"/>
</method>
+ <method name="RequestWpsScan">
+ </method>
<method name="GetPasspoint">
<arg type="i" name="enable" direction="out"/>
</method>
<method name="SetPasspoint">
<arg type="i" name="enable" direction="in"/>
</method>
- <method name="CreateConfig">
+ <method name="SetConfigField">
+ <arg type="s" name="config_id" direction="in"/>
+ <arg type="s" name="key" direction="in"/>
+ <arg type="s" name="value" direction="in"/>
+ </method>
+ <method name="SaveConfiguration">
+ <arg type="s" name="config_id" direction="in"/>
+ <arg type="a{sv}" name="Configuration" direction="in"/>
+ </method>
+ <method name="RemoveConfiguration">
+ <arg type="s" name="config_id" direction="in"/>
+ </method>
+ <method name="GetConfigIds">
+ <arg type="as" name="config_ids" direction="out"/>
+ </method>
+ <method name="LoadConfiguration">
+ <arg type="s" name="config_id" direction="in"/>
+ <arg type="s" name="name" direction="out"/>
+ <arg type="s" name="passphrase" direction="out"/>
+ <arg type="s" name="security_type" direction="out"/>
+ <arg type="s" name="proxy_address" direction="out"/>
+ <arg type="s" name="is_hidden" direction="out"/>
+ <arg type="s" name="last_error" direction="out"/>
+ </method>
+ <method name="CreateEapConfig">
+ <arg type="o" name="Service" direction="in"/>
<arg type="a{ss}" name="Fields" direction="in"/>
</method>
- <method name="DeleteConfig">
+ <method name="DeleteEapConfig">
<arg type="s" name="Profile" direction="in"/>
</method>
<method name="GetSimImsi">
- <annotation name="org.freedesktop.DBus.GLib.Async" value="yes"/>
- <arg type="s" name="imsi_data" direction="out" />
+ <arg type="s" name="imsi_data" direction="out"/>
</method>
<method name="ReqSimAuth">
- <arg type="ay" name="rand_data" direction="in" />
- <arg type="b" name="result" direction="out" />
+ <arg type="ay" name="rand_data" direction="in"/>
+ <arg type="b" name="result" direction="out"/>
</method>
<method name="ReqAkaAuth">
- <arg type="ay" name="rand_data" direction="in" />
- <arg type="ay" name="autn_data" direction="in" />
- <arg type="b" name="result" direction="out" />
+ <arg type="ay" name="rand_data" direction="in"/>
+ <arg type="ay" name="autn_data" direction="in"/>
+ <arg type="b" name="result" direction="out"/>
</method>
<method name="GetSimAuth">
- <annotation name="org.freedesktop.DBus.GLib.Async" value="yes"/>
- <arg type="ay" name="auth_data" direction="out" />
+ <arg type="ay" name="auth_data" direction="out"/>
</method>
<method name="GetAkaAuth">
- <annotation name="org.freedesktop.DBus.GLib.Async" value="yes"/>
- <arg type="ay" name="auth_data" direction="out" />
- </method>
- <signal name="DriverLoaded">
- <arg name="mac" type="s"/>
+ <arg type="ay" name="auth_data" direction="out"/>
+ </method>
+ <method name="CheckBlackList">
+ <arg type="s" name="name" direction="in"/>
+ <arg type="s" name="security_type" direction="in"/>
+ <arg type="s" name="eap" direction="in"/>
+ <arg type="b" name="allowed" direction="out"/>
+ </method>
+ <signal name="PowerOnCompleted"></signal>
+ <signal name="PowerOffCompleted"></signal>
+ <signal name="PowerOperationFailed"></signal>
+ <signal name="SpecificScanCompleted">
+ <arg type="a{sv}" name="Fields" direction="out"/>
</signal>
- <signal name="PowerOn">
- <arg name="error" type="s"/>
+ <signal name="WpsScanCompleted">
+ <arg type="a{sv}" name="Fields" direction="out"/>
</signal>
</interface>
<interface name="net.connman.Agent">
<method name="SetField">
- <arg type="a{ss}" name="Field" direction="in"/>
+ <arg type="o" name="Service" direction="in"/>
+ <arg type="a{sv}" name="Fields" direction="in"/>
</method>
<method name="RequestInput">
- <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
- <arg type="o" name="Path" direction="in"/>
+ <arg type="o" name="Service" direction="in"/>
<arg type="a{sv}" name="Fields" direction="in"/>
<arg type="a{sv}" name="OutFields" direction="out"/>
</method>
+ <method name="ReportError">
+ <arg type="o" name="Service" direction="in"/>
+ <arg type="s" name="Error" direction="in"/>
+ </method>
+ <method name="RequestBrowser">
+ <arg type="o" name="Service" direction="in"/>
+ <arg type="s" name="url" direction="in"/>
+ </method>
</interface>
<interface name="net.netconfig.wifi.Firmware">
<method name="Start">
<arg type="s" name="Device" direction="in"/>
</method>
</interface>
+ <interface name="net.netconfig.tv_profile">
+ <method name="RequestWpsCancel">
+ </method>
+ </interface>
</node>
--- /dev/null
+<manifest>
+ <define>
+ <domain name="net-config"/>
+ <request>
+ <smack request="aul" type="rwx"/>
+ <smack request="dbus" type="rwx"/>
+ <smack request="connman" type="rwx"/>
+ <smack request="connman::set" type="rwx"/>
+ <smack request="connman::get" type="rwx"/>
+ <smack request="connman::profile" type="rwx"/>
+ <smack request="weconn" type="rwx"/>
+ <smack request="wifi-direct" type="rwx"/>
+ <smack request="wpasupplicant" type="rwx"/>
+ <smack request="deviced::power" type="rwx"/>
+ <smack request="deviced::display" type="rwx"/>
+ <smack request="system::use_internet" type="rwx"/>
+ <smack request="tizen::vconf::platform::r" type="rwx"/>
+ <smack request="tizen::vconf::platform::rw" type="rwx"/>
+ <smack request="tizen::vconf::public::r::platform::rw" type="rwx"/>
+ <smack request="tizen::vconf::public::r" type="rwx"/>
+ <smack request="tizen::vconf::network" type="rwx"/>
+ <smack request="tizen::vconf::setting::admin" type="rwx"/>
+ <smack request="telephony_framework::api_private" type="rwx"/>
+ <smack request="telephony_framework::api_ps_public" type="rwx"/>
+ <smack request="telephony_framework::api_ps_private" type="rwx"/>
+ <smack request="telephony_framework::api_ps_profile" type="rwx"/>
+ <smack request="telephony_framework::properties" type="rw"/>
+ <smack request="device::sys_logging" type="rw"/>
+ <smack request="device::app_logging" type="rw"/>
+ </request>
+ <permit>
+ <smack permit="dbus" type="rwx"/>
+ <smack permit="system::use_internet" type="rwx"/>
+ </permit>
+ </define>
+ <assign>
+ <filesystem path="/etc/resolv.conf" label="_"/>
+ <filesystem path="/usr/lib/systemd/system/net-config.service" label="_"/>
+ <filesystem path="/usr/lib/systemd/system/multi-user.target.wants/net-config.service" label="_"/>
+ <filesystem path="/usr/share/dbus-1/system-services/net.netconfig.service" label="_"/>
+ <filesystem path="/usr/sbin/net-config.service" label="_" exec_label="none"/>
+ <filesystem path="/usr/share/license/net-config" label="_"/>
+ <filesystem path="/opt/etc/dump.d/module.d/network_log_dump.sh" label="_" exec_label="none"/>
+ <filesystem path="/opt/var/lib/net-config/network_dump.sh" label="_" exec_label="none"/>
+ <dbus name="net.netconfig" own="net-config" bus="system">
+ <node name="/net/netconfig/*">
+ <interface name="net.netconfig.network">
+ <annotation name="net.netconfig.smack" value="net-config"/>
+ <method name="AddRoute">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ <method name="RemoveRoute">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ <method name="CheckGetPrivilege">
+ <annotation name="net.netconfig.smack" value="connman::get"/>
+ </method>
+ <method name="CheckProfilePrivilege">
+ <annotation name="net.netconfig.smack" value="connman::profile"/>
+ </method>
+ </interface>
+ <interface name="net.netconfig.network_statistics">
+ <annotation name="net.netconfig.smack" value="net-config"/>
+ <method name="GetWifiLastRxBytes">
+ <annotation name="net.netconfig.smack" value="connman::get"/>
+ </method>
+ <method name="GetWifiLastTxBytes">
+ <annotation name="net.netconfig.smack" value="connman::get"/>
+ </method>
+ <method name="GetWifiTotalRxBytes">
+ <annotation name="net.netconfig.smack" value="connman::get"/>
+ </method>
+ <method name="GetWifiTotalTxBytes">
+ <annotation name="net.netconfig.smack" value="connman::get"/>
+ </method>
+ <method name="ResetCellularLastRxBytes">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ <method name="ResetCellularLastTxBytes">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ <method name="ResetCellularTotalRxBytes">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ <method name="ResetCellularTotalTxBytes">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ <method name="ResetWifiLastRxBytes">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ <method name="ResetWifiLastTxBytes">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ <method name="ResetWifiTotalRxBytes">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ <method name="ResetWifiTotalTxBytes">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ </interface>
+ <interface name="net.netconfig.wifi">
+ <annotation name="net.netconfig.smack" value="net-config"/>
+ <method name="DeleteEapConfig">
+ <annotation name="net.netconfig.smack" value="connman::profile"/>
+ </method>
+ <method name="RequestSpecificScan">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ <method name="RequestWpsScan">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ <method name="CreateEapConfig">
+ <annotation name="net.netconfig.smack" value="connman::profile"/>
+ </method>
+ <method name="LoadDriver">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ <method name="RemoveDriver">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ <method name="SetBgscan">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ <method name="ResumeBgscan">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ <method name="PauseBgscan">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ <method name="LaunchDirect">
+ <annotation name="net.netconfig.smack" value="wifi-direct"/>
+ </method>
+ <method name="SaveConfiguration">
+ <annotation name="net.netconfig.smack" value="connman::profile"/>
+ </method>
+ <method name="RemoveConfiguration">
+ <annotation name="net.netconfig.smack" value="connman::profile"/>
+ </method>
+ <method name="LoadConfiguration">
+ <annotation name="net.netconfig.smack" value="connman::profile"/>
+ </method>
+ <method name="GetConfigIds">
+ <annotation name="net.netconfig.smack" value="connman::profile"/>
+ </method>
+ <method name="SetConfigField">
+ <annotation name="net.netconfig.smack" value="connman::profile"/>
+ </method>
+ <signal name="PowerOnCompleted">
+ <annotation name="net.netconfig.smack" value="connman::get"/>
+ </signal>
+ <signal name="PowerOffCompleted">
+ <annotation name="net.netconfig.smack" value="connman::get"/>
+ </signal>
+ <signal name="SpecificScanCompleted">
+ <annotation name="net.netconfig.smack" value="connman::get"/>
+ </signal>
+ <signal name="WpsScanCompleted">
+ <annotation name="net.netconfig.smack" value="connman::get"/>
+ </signal>
+ </interface>
+ <interface name="net.connman.Agent">
+ <annotation name="net.netconfig.smack" value="net-config"/>
+ <method name="SetField">
+ <annotation name="net.netconfig.smack" value="connman::profile"/>
+ </method>
+ </interface>
+ </node>
+ </dbus>
+ </assign>
+ <request>
+ <domain name="net-config"/>
+ </request>
+</manifest>
+++ /dev/null
-<manifest>
- <request>
- <domain name="_"/>
- </request>
-</manifest>
-Name: net-config
-Summary: TIZEN Network Configuration Module
-Version: 0.1.90_36
-Release: 1
-Group: System/Network
-License: Apache-2.0
-Source0: %{name}-%{version}.tar.gz
-Source1001: net-config.manifest
-
-BuildRequires: cmake
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(dbus-glib-1)
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(capi-network-wifi-direct)
-BuildRequires: pkgconfig(tapi)
-Requires(post): /usr/bin/vconftool
-BuildRequires: pkgconfig(libsystemd-daemon)
-%{?systemd_requires}
+Name: net-config
+Summary: TIZEN Network Configuration service
+Version: 1.1.28
+Release: 2
+Group: System/Network
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(tapi)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(eventsystem)
+BuildRequires: pkgconfig(alarm-service)
+BuildRequires: pkgconfig(syspopup-caller)
+BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(capi-network-wifi-direct)
+BuildRequires: cmake
+BuildRequires: model-build-features
+Requires: vconf
+Requires: connman
+Requires: systemd
+Requires(post): systemd
+Requires(post): vconf
+Requires(preun): systemd
+Requires(postun): systemd
%description
-TIZEN Network Configuration Module
+TIZEN Network Configuration service
%prep
%setup -q
-cp %{SOURCE1001} .
-
%build
-%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+ -DTIZEN_WLAN_PASSPOINT=1 \
+%if 0%{?model_build_feature_wlan_concurrent_mode}
+ -DWLAN_CONCURRENT_MODE=1 \
+%endif
+%if ! 0%{?model_build_feature_wlan_p2p_disable}
-DTIZEN_P2P_ENABLE=1 \
+%endif
+%if ! 0%{?model_build_feature_network_tethering_disable}
+ -DTIZEN_TETHERING_ENABLE=1 \
+%endif
+%if "%{?tizen_profile_name}" == "tv"
+ -DTIZEN_TV=1 \
+%endif
+%if 0%{?model_build_feature_wlan_wearable} == 1
+ -DTIZEN_WEARABLE=1 \
+ -DTIZEN_CAPTIVE_PORTAL=1 \
+%endif
+ .
make %{?_smp_mflags}
%install
%make_install
-mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services
-cp resources/usr/share/dbus-1/services/net.netconfig.service %{buildroot}%{_datadir}/dbus-1/system-services/net.netconfig.service
-mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d
-cp resources/etc/dbus-1/system.d/net-config.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/net-config.conf
-
-# Systemd service file
+#Systemd service file
+mkdir -p %{buildroot}%{_libdir}/systemd/system/
+%if "%{?_lib}" == "lib64"
mkdir -p %{buildroot}%{_unitdir}
+%endif
+
+%if "%{?tizen_profile_name}" == "tv"
+cp resources/usr/lib/systemd/system/net-config_tv.service %{buildroot}%{_libdir}/systemd/system/net-config.service
+mkdir -p %{buildroot}%{_libdir}/udev/rules.d/
+cp resources/usr/lib/udev/rules.d/99-wifiusb-dev.rules %{buildroot}%{_libdir}/udev/rules.d/99-wifiusb-dev.rules
+%else
+cp resources/usr/lib/systemd/system/net-config.service %{buildroot}%{_libdir}/systemd/system/net-config.service
+%if "%{?_lib}" == "lib64"
cp resources/usr/lib/systemd/system/net-config.service %{buildroot}%{_unitdir}/net-config.service
+%endif
+%endif
+
+mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/
+ln -s ../net-config.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/net-config.service
+%if "%{?_lib}" == "lib64"
mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants/
ln -s ../net-config.service %{buildroot}%{_unitdir}/multi-user.target.wants/net-config.service
+%endif
+
+mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/
+cp resources/usr/share/dbus-1/system-services/net.netconfig.service %{buildroot}%{_datadir}/dbus-1/system-services/net.netconfig.service
+
+mkdir -p %{buildroot}%{_sysconfdir}/
+cp resources/etc/resolv.conf %{buildroot}%{_sysconfdir}/resolv.conf
+
+mkdir -p %{buildroot}%{_sbindir}/
+cp resources/usr/sbin/net-config.service %{buildroot}%{_sbindir}/net-config.service
+
+mkdir -p %{buildroot}/opt/dbspace
+sqlite3 %{buildroot}/opt/dbspace/.wifi_offload.db < resources/usr/share/wifi_offloading.sql
+
+#DBus DAC (net-config.manifest enables DBus SMACK)
+#mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d
+#cp resources/etc/dbus-1/system.d/net-config.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/net-config.conf
+
+#log dump
+mkdir -p %{buildroot}/opt/etc/dump.d/module.d/
+cp resources/opt/etc/dump.d/module.d/network_log_dump.sh %{buildroot}/opt/etc/dump.d/module.d/network_log_dump.sh
+mkdir -p %{buildroot}/opt/var/lib/net-config/
+cp resources/opt/etc/dump.d/module.d/network_log_dump.sh %{buildroot}/opt/var/lib/net-config/network_log_dump.sh
+cp resources/opt/etc/dump.d/module.d/network_dump.sh %{buildroot}/opt/var/lib/net-config/network_dump.sh
+
+%if 0%{?model_build_feature_wlan_wearable} == 1
+#softreset scripts
+mkdir -p %{buildroot}/usr/system/RestoreDir/softreset
+cp resources/usr/system/RestoreDir/softreset/network_softreset.sh %{buildroot}/usr/system/RestoreDir/softreset/network_softreset.sh
+%endif
#License
mkdir -p %{buildroot}%{_datadir}/license
-cp LICENSE.APLv2 %{buildroot}%{_datadir}/license/net-config
+cp LICENSE %{buildroot}%{_datadir}/license/net-config
%post
-vconftool set -t int memory/dnet/state 0 -i
-vconftool set -t int memory/wifi/state 0 -i
-vconftool set -t int memory/wifi/transfer_state 0 -i
-vconftool set -t int memory/wifi/strength 0 -i
-vconftool set -t int memory/wifi/bgscan_mode 0 -i
+%if "%{?tizen_profile_name}" == "tv"
+vconftool set -t string db/dnet/mac_address "" -s system::vconf_network
+%endif
+
+#Wi-Fi statistics
+vconftool set -t int db/dnet/statistics/wifi/totalsnt 0 -s tizen::vconf::network
+vconftool set -t int db/dnet/statistics/wifi/totalrcv 0 -s tizen::vconf::network
+vconftool set -t int db/dnet/statistics/wifi/lastsnt 0 -s tizen::vconf::network
+vconftool set -t int db/dnet/statistics/wifi/lastrcv 0 -s tizen::vconf::network
+
+#Wi-Fi last power state
+vconftool set -t int file/private/wifi/last_power_state 0 -s system::vconf_network
-vconftool set -t int memory/dnet/wifi 0 -i
-vconftool set -t int memory/dnet/network_config 0 -i
-vconftool set -t int memory/dnet/status 0 -i
-vconftool set -t string memory/dnet/ip "" -i
-vconftool set -t string memory/dnet/proxy "" -i
+#Wi-Fi power state due to airplane mode
+vconftool set -t int file/private/wifi/wifi_off_by_airplane 0 -s system::vconf_network
-vconftool set -t string memory/wifi/connected_ap_name "" -i
+#Wi-Fi power state due to restricted mode
+vconftool set -t int file/private/wifi/wifi_off_by_restricted 0 -s system::vconf_network
-vconftool set -t string db/wifi/bssid_address ""
+#Wi-Fi power state due to emergency mode
+vconftool set -t int file/private/wifi/wifi_off_by_emergency 0 -s system::vconf_network
-#Default Call Statistics
-vconftool set -t int db/dnet/statistics/cellular/totalsnt "0"
-vconftool set -t int db/dnet/statistics/cellular/totalrcv "0"
-vconftool set -t int db/dnet/statistics/cellular/lastsnt "0"
-vconftool set -t int db/dnet/statistics/cellular/lastrcv "0"
-vconftool set -t int db/dnet/statistics/wifi/totalsnt "0"
-vconftool set -t int db/dnet/statistics/wifi/totalrcv "0"
-vconftool set -t int db/dnet/statistics/wifi/lastsnt "0"
-vconftool set -t int db/dnet/statistics/wifi/lastrcv "0"
+#Wi-Fi sleep policy
+vconftool set -t int file/private/wifi/sleep_policy 0 -g 6519 -s system::vconf_setting
-vconftool set -t int file/private/wifi/last_power_state "0"
+%if 0%{?model_build_feature_wlan_wearable} == 1
+#Wearable use Wi-Fi
+vconftool set -t int db/private/wifi/wearable_wifi_use 0 -g 6519 -s net-config
+%endif
-systemctl daemon-reload
-if [ "$1" == "1" ]; then
- systemctl restart net-config.service
-fi
+#Wi-Fi Network Frequency for Wi-Fi Direct
+vconftool set -t int memory/private/wifi/frequency 0 -i -s tizen::vconf::platform::r
+
+#Network logs
+mkdir -p /opt/usr/data/network
+chmod 755 /opt/usr/data/network
+
+#Add net-config.service to systemd extra default dependency ignore list
+mkdir -p %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+ln -sf %{_libdir}/systemd/system/net-config.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+%if "%{?_lib}" == "lib64"
+ln -sf %{_unitdir}/net-config.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+%endif
+
+#systemctl daemon-reload
+#systemctl restart net-config.service
%preun
-if [ "$1" == "0" ]; then
- systemctl stop net-config.service
-fi
+#systemctl stop net-config.service
%postun
-systemctl daemon-reload
-if [ "$1" == "1" ]; then
- systemctl restart net-config.service
-fi
+#systemctl daemon-reload
+
%files
-%manifest %{name}.manifest
-%{_sbindir}/*
-%{_datadir}/dbus-1/system-services/*
-%{_sysconfdir}/dbus-1/system.d/*
-%{_unitdir}/net-config.service
-%{_unitdir}/multi-user.target.wants/net-config.service
+%manifest net-config.manifest
+%attr(500,root,root) %{_sbindir}/*
+%attr(644,root,root) %{_sysconfdir}/resolv.conf
+%attr(644,root,root) %{_datadir}/dbus-1/system-services/*
+#DBus DAC
+#%attr(644,root,root) %{_sysconfdir}/dbus-1/system.d/*
+%attr(644,root,root) %{_libdir}/systemd/system/net-config.service
+%attr(644,root,root) %{_libdir}/systemd/system/multi-user.target.wants/net-config.service
+%if "%{?_lib}" == "lib64"
+%attr(644,root,root) %{_unitdir}/net-config.service
+%attr(644,root,root) %{_unitdir}/multi-user.target.wants/net-config.service
+%endif
%{_datadir}/license/net-config
+%attr(660,root,root) /opt/dbspace/.wifi_offload.db
+%attr(664,root,root) /opt/dbspace/.wifi_offload.db-journal
+%attr(500,root,root) /opt/etc/dump.d/module.d/network_log_dump.sh
+%attr(500,root,root) /opt/var/lib/net-config/network_log_dump.sh
+%attr(500,root,root) /opt/var/lib/net-config/network_dump.sh
+%if "%{?tizen_profile_name}" == "tv"
+%attr(644,root,root) %{_libdir}/udev/rules.d/99-wifiusb-dev.rules
+%endif
+%if 0%{?model_build_feature_wlan_wearable} == 1
+%attr(700,root,root) /usr/system/RestoreDir/softreset/network_softreset.sh
+
+%endif
--- /dev/null
+# Generated by Connection Manager
+nameserver 127.0.0.1
+#nameserver ::1
+
+options timeout:5
+options attempts:8
--- /dev/null
+#!/bin/sh
+
+# $1 is passed by dump_service
+
+export DISPLAY=:0.0
+NETWORK_ORG=/opt/usr/data/network
+NETWORK_DEBUG=$1/network
+
+/bin/mkdir -p ${NETWORK_DEBUG}
+/bin/tar -czf ${NETWORK_DEBUG}/network.tar.gz -C ${NETWORK_ORG} .
--- /dev/null
+#!/bin/sh
+
+#--------------------------------------
+# network
+#--------------------------------------
+
+# not allow to use relative path
+if [[ $1 == *"../"* ]]
+then
+ exit -1
+fi
+
+export DISPLAY=:0.0
+NETWORK_ORG=/opt/usr/data/network
+NETWORK_DEBUG=$1/network
+
+/bin/mkdir -p ${NETWORK_DEBUG}
+
+/sbin/ifconfig > ${NETWORK_DEBUG}/ifconfig
+/bin/netstat -na > ${NETWORK_DEBUG}/netstat
+/sbin/route -n > ${NETWORK_DEBUG}/route
+/bin/cat /proc/net/wireless > ${NETWORK_DEBUG}/wireless
+/bin/cat /etc/resolv.conf > ${NETWORK_DEBUG}/resolv.conf
+/usr/bin/vconftool get memory/dnet >> ${NETWORK_DEBUG}/status
+/usr/bin/vconftool get memory/wifi >> ${NETWORK_DEBUG}/status
+/usr/bin/vconftool get file/private/wifi >> ${NETWORK_DEBUG}/status
+/usr/bin/vconftool get db/wifi >> ${NETWORK_DEBUG}/status
+/sbin/ifconfig -a > ${NETWORK_DEBUG}/ifconfig
+/bin/mv ${NETWORK_ORG}/tcpdump*.pcap $1/../
+/bin/tar -czf ${NETWORK_DEBUG}/network.tar.gz -C ${NETWORK_ORG} .
+++ /dev/null
-search localdomain
-nameserver 127.0.0.1
\ No newline at end of file
[Unit]
-Description=net config service
-Requires=vconf-setup.service
-After=syslog.target vconf-setup.service
+Description=Network Configuration service
+Requires=dbus.socket
+After=dbus.socket
[Service]
-Type=notify
-ExecStart=/usr/sbin/net-config --nofork
+Type=dbus
+BusName=net.netconfig
+RemainAfterExit=yes
+ExecStartPre=-/usr/sbin/net-config.service
+ExecStart=/usr/sbin/net-config
[Install]
WantedBy=multi-user.target
--- /dev/null
+[Unit]
+Description=Network Configuration service
+
+[Service]
+Type=dbus
+BusName=net.netconfig
+RemainAfterExit=yes
+ExecStartPre=-/usr/sbin/net-config.service
+ExecStart=/usr/sbin/net-config
+
+[Install]
+WantedBy=multi-user.target
--- /dev/null
+# Udev Rules for WiFi Chip attach/detach Events
+
+
+ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan0", RUN+="/usr/bin/vconftool set -t int memory/wifi/device/status_uevent 1 -f"
+ACTION=="remove", SUBSYSTEM=="net", KERNEL=="wlan0", RUN+="/usr/bin/vconftool set -t int memory/wifi/device/status_uevent 0 -f"
+
--- /dev/null
+#!/bin/sh
+
+if [ -f /opt/etc/.mac.info ]; then
+ bssid="$(/usr/bin/vconftool get -t string db/wifi/bssid_address | /bin/sed -n "/\([0-9A-F][0-9A-F]:\)\{5\}[0-9A-F][0-9A-F]/p")"
+ fbssid="$(/bin/cat /opt/etc/.mac.info | /bin/sed -n "/\([0-9A-F][0-9A-F]:\)\{5\}[0-9A-F][0-9A-F]/p")"
+
+ if [ "$bssid" != "$fbssid" ]; then
+ /bin/cat /opt/etc/.mac.info | /bin/sed -n "/^\([0-9A-F][0-9A-F]:\)\{5\}[0-9A-F][0-9A-F]$/p" | /usr/bin/xargs /usr/bin/vconftool set -t string db/wifi/bssid_address -f
+ fi
+fi
+
+if [ ! -d /var/lib/net-config ]; then
+ /bin/mkdir -p /var/lib/net-config
+fi
+
+if [ ! -f /var/lib/net-config/.provisioned ]; then
+ /bin/cp -R /opt/system/csc-default/usr/wifi/preprofiles/* /var/lib/connman/
+ /bin/touch /var/lib/net-config/.provisioned
+fi
+
+[ -e /var/lib/wifi/.pseudonym.info ] && /bin/rm /var/lib/wifi/.pseudonym.info
+[ -e /var/lib/wifi/.pseudonym_sim.info ] && /bin/rm /var/lib/wifi/.pseudonym_sim.info
--- /dev/null
+[D-BUS Service]
+Name=net.netconfig
+Exec=/bin/false
+SystemdService=net-config.service
+User=root
--- /dev/null
+PRAGMA journal_mode = PERSIST;
+
+DROP TABLE IF EXISTS "connected_wifi";
+CREATE TABLE connected_wifi(
+ wifi_id INTEGER PRIMARY KEY,
+ ssid TEXT
+);
+
+DROP TABLE IF EXISTS "related_cell";
+CREATE TABLE related_cell(
+ cell_id INTEGER,
+ registered INTEGER,
+ max_rscp INTEGER,
+ min_rscp INTEGER,
+ wifi_id INTEGER
+);
+
+CREATE INDEX related_cell_ix_1 ON related_cell (wifi_id);
--- /dev/null
+#!/bin/sh
+
+#Keep network config files
+pkg -k /var/lib/connman
+pkg -k /var/lib/wifi
+pkg -k /var/lib/net-config
+
+#Keep network vconf for the last state of wifi
+pkg -v file/private/wifi/last_power_state
+pkg -v file/private/wifi/wifi_off_by_airplane
+pkg -v file/private/wifi/wifi_off_by_emergency
+pkg -v db/private/wifi/wearable_wifi_use
+
--- /dev/null
+#!/bin/sh
+
+# restore network config files
+/bin/rm -rf /var/lib/connman /var/lib/wifi /var/lib/net-config
+
+/bin/mv /opt/system/softreset_preserved/network/* /var/lib/
--- /dev/null
+#!/bin/sh
+
+# Make directory for backup
+/bin/mkdir -p /opt/system/softreset_preserved/network/
+cd /opt/system/softreset_preserved/network/
+
+# Move network config files
+/bin/mv /var/lib/connman /var/lib/wifi /var/lib/net-config .
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 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 "log.h"
+#include "cellular-state.h"
+
+static enum netconfig_cellular_service_state
+ cellular_service_state = NETCONFIG_CELLULAR_UNKNOWN;
+
+static GSList *notifier_list = NULL;
+
+static void __netconfig_cellular_state_changed(
+ enum netconfig_cellular_service_state state)
+{
+ GSList *list;
+
+ for (list = notifier_list; list; list = list->next) {
+ struct netconfig_cellular_state_notifier *notifier = list->data;
+
+ if (notifier->netconfig_cellular_state_changed != NULL)
+ notifier->netconfig_cellular_state_changed(state, notifier->user_data);
+ }
+}
+
+void netconfig_cellular_state_set_service_state(
+ enum netconfig_cellular_service_state new_state)
+{
+ enum netconfig_cellular_service_state old_state = cellular_service_state;
+
+ if (old_state == new_state)
+ return;
+
+ cellular_service_state = new_state;
+ DBG("Cellular state %d ==> %d", old_state, new_state);
+ __netconfig_cellular_state_changed(new_state);
+}
+
+enum netconfig_cellular_service_state
+netconfig_cellular_state_get_service_state(void)
+{
+ return cellular_service_state;
+}
+
+void netconfig_cellular_state_notifier_cleanup(void)
+{
+ g_slist_free_full(notifier_list, NULL);
+}
+
+void netconfig_cellular_state_notifier_register(
+ struct netconfig_cellular_state_notifier *notifier)
+{
+ DBG("register notifier");
+
+ notifier_list = g_slist_append(notifier_list, notifier);
+}
+
+void netconfig_cellular_state_notifier_unregister(
+ struct netconfig_cellular_state_notifier *notifier)
+{
+ DBG("un-register notifier");
+
+ notifier_list = g_slist_remove_all(notifier_list, notifier);
+}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2015 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 <unistd.h>
+#include <stdlib.h>
+
+#include "log.h"
+#include "util.h"
+#include "network-state.h"
+#include "clatd-handler.h"
+
+#define CLAT_EXEC_PATH "/usr/sbin/clatd"
+#define ROUTE_EXEC_PATH "/sbin/route"
+#define KILLALL_EXEC_PATH "/usr/bin/killall"
+#define IFCONFIG_EXEC_PATH "/sbin/ifconfig"
+
+char g_ifname[32] = {0, };
+
+int netconfig_clatd_enable(void)
+{
+ int rv = 0;
+
+ if (g_ifname[0] != '\0') {
+ rv = netconfig_clatd_disable();
+
+ if (rv < 0) {
+ DBG("Failed to disable existing clatd process");
+ return -1;
+ }
+ }
+
+ const char *if_name = netconfig_get_default_ifname();
+
+ if (if_name == NULL) {
+ DBG("There is no interface name");
+ return -1;
+ }
+
+ memset(g_ifname, 0, sizeof(g_ifname));
+ g_strlcat(g_ifname, if_name, 32);
+
+ const char *path = CLAT_EXEC_PATH;
+ char *const args[] = { "/usr/sbin/clatd", "-i", g_ifname, NULL };
+
+ rv = netconfig_execute_clatd(path, args);
+
+ if (rv < 0) {
+ DBG("Failed to enable clatd process %d", rv);
+ return -1;
+ }
+
+ DBG("Successfully enabled clatd process with %s interface", g_ifname);
+ return 0;
+}
+
+int netconfig_clatd_disable(void)
+{
+ int rv = 0;
+
+ const char *path = KILLALL_EXEC_PATH;
+ char *const args[] = { "/usr/bin/kill -15", "clatd", NULL };
+ char *const envs[] = { NULL };
+
+ if (g_ifname[0] == '\0') {
+ DBG("There is no clatd process");
+ return -1;
+ }
+
+ memset(g_ifname, 0, sizeof(g_ifname));
+
+ rv = netconfig_execute_file(path, args, envs);
+
+ if (rv < 0) {
+ DBG("Failed to disable clatd process %d", rv);
+ return -1;
+ }
+
+ DBG("Successfully disable clatd process");;
+ return 0;
+}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "log.h"
#include "netdbus.h"
-#include "netconfig.h"
-
-#define NETCONFIG_DBUS_REPLY_TIMEOUT (10 * 1000)
#define DBUS_PARAM_TYPE_STRING "string"
#define DBUS_PARAM_TYPE_INT16 "int16"
#define DBUS_PARAM_TYPE_VARIANT "variant"
#define DBUS_PARAM_TYPE_ARRAY "array"
+static GDBusObjectManagerServer *manager_server_wifi = NULL;
+static GDBusObjectManagerServer *manager_server_state = NULL;
+static GDBusObjectManagerServer *manager_server_statistics = NULL;
+static guint owner_id = 0;
+static netconfig_got_name_cb g_callback = NULL;
-static gboolean __netconfig_dbus_append_param_variant(
- DBusMessageIter *iter, char *type, char *param)
-{
- DBusMessageIter value, array;
- char *args = NULL, *ch = NULL;
- dbus_bool_t b_value = FALSE;
-
- if (strcmp(type, DBUS_PARAM_TYPE_STRING) == 0) {
- dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
- DBUS_TYPE_STRING_AS_STRING, &value);
-
- dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, ¶m);
-
- dbus_message_iter_close_container(iter, &value);
- } else if (strcmp(type, DBUS_PARAM_TYPE_BOOLEAN) == 0) {
- if (strcmp(param, "true") == 0) {
- b_value = TRUE;
- dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
- DBUS_TYPE_BOOLEAN_AS_STRING, &value);
- dbus_message_iter_append_basic(&value,
- DBUS_TYPE_BOOLEAN, &b_value);
- dbus_message_iter_close_container(iter, &value);
- } else if (strcmp(param, "false") == 0) {
- b_value = FALSE;
- dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
- DBUS_TYPE_BOOLEAN_AS_STRING, &value);
- dbus_message_iter_append_basic(&value,
- DBUS_TYPE_BOOLEAN, &b_value);
- dbus_message_iter_close_container(iter, &value);
- } else {
- ERR("Error!!! Expected \"true\" or"
- "\"false\" instead of \"%s\"", ch);
- return FALSE;
- }
- } else if (strcmp(type, DBUS_PARAM_TYPE_OBJECT_PATH) == 0) {
- dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &value);
-
- dbus_message_iter_append_basic(&value, DBUS_TYPE_OBJECT_PATH, ¶m);
-
- dbus_message_iter_close_container(iter, &value);
- } else if (strcmp(type, DBUS_PARAM_TYPE_ARRAY) == 0) {
- args = param;
- ch = strchr(args, ':');
- if (ch == NULL) {
- ERR("Error!!! Invalid data format[\"%s\"]", args);
- return FALSE;
- }
- *ch = 0; ch++;
-
- if (strcmp(args, DBUS_PARAM_TYPE_STRING) == 0) {
- dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_STRING_AS_STRING, &array);
-
- dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING, &ch);
+struct gdbus_conn_data {
+ GDBusConnection *connection;
+ int conn_ref_count;
+ GCancellable *cancellable;
+};
- dbus_message_iter_close_container(&value, &array);
+static struct gdbus_conn_data gconn_data = {NULL, 0, NULL};
- dbus_message_iter_close_container(iter, &value);
- } else if (strcmp(args, DBUS_PARAM_TYPE_OBJECT_PATH) == 0) {
- dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &array);
-
- dbus_message_iter_append_basic(&array, DBUS_TYPE_OBJECT_PATH, &ch);
-
- dbus_message_iter_close_container(&value, &array);
-
- dbus_message_iter_close_container(iter, &value);
- } else {
- ERR("Error!!! Not supported data format[\"%s\"]", args);
- return FALSE;
- }
- } else {
- ERR("Error!!! Not supported data format[\"%s\"]", args);
- return FALSE;
- }
-
- return TRUE;
+GDBusObjectManagerServer *netconfig_get_wifi_manager(void)
+{
+ return manager_server_wifi;
}
-static gboolean __netconfig_dbus_append_param(
- DBusMessage *message, char *param_array[])
+GDBusObjectManagerServer *netconfig_get_state_manager(void)
{
- int count = 0;
- dbus_uint32_t uint32 = 0;
- DBusMessageIter iter;
- char *args = NULL, *ch = NULL;
-
- if (param_array == NULL)
- return TRUE;
-
- dbus_message_iter_init_append(message, &iter);
-
- while (param_array[count] != NULL) {
- args = param_array[count];
- DBG("parameter %d - [%s]", count, param_array[count]);
+ return manager_server_state;
+}
- ch = strchr(args, ':');
- if (ch == NULL) {
- ERR("Error!!! Invalid parameter[\"%s\"]\n", args);
- return FALSE;
- }
- *ch = 0; ch++;
-
- if (strcmp(args, DBUS_PARAM_TYPE_STRING) == 0) {
- dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &ch);
- } else if (strcmp(args, DBUS_PARAM_TYPE_UINT32) == 0) {
- uint32 = strtoul(ch, NULL, 0);
- dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &uint32);
- } else if (strcmp(args, DBUS_PARAM_TYPE_VARIANT) == 0) {
- args = ch;
- ch = strchr(args, ':');
- if (ch == NULL) {
- ERR("Error!!! Invalid data format[\"%s\"]\n", args);
- return FALSE;
- }
- *ch = 0; ch++;
-
- if (__netconfig_dbus_append_param_variant(&iter, args, ch) != TRUE)
- return FALSE;
-
- } else if (strcmp(args, DBUS_PARAM_TYPE_OBJECT_PATH) == 0) {
- dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &ch);
- } else {
- ERR("Error!!! Not supported data format[\"%s\"]", args);
- return FALSE;
- }
+GDBusObjectManagerServer *netconfig_get_statistics_manager(void)
+{
+ return manager_server_statistics;
+}
- count++;
- }
+GDBusConnection *netconfig_gdbus_get_connection(void)
+{
+ return gconn_data.connection;
+}
- return TRUE;
+GCancellable *netconfig_gdbus_get_gdbus_cancellable(void)
+{
+ return gconn_data.cancellable;
}
-gboolean netconfig_dbus_get_basic_params_string(DBusMessage *message,
- char **key, int type, void *value)
+void netconfig_gdbus_pending_call_ref(void)
{
- DBusMessageIter iter, iter_variant;
+ g_object_ref(gconn_data.connection);
- dbus_message_iter_init(message, &iter);
- if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) {
- DBG("Argument type %d", dbus_message_iter_get_arg_type(&iter));
- return FALSE;
- }
+ __sync_fetch_and_add(&gconn_data.conn_ref_count, 1);
+}
- dbus_message_iter_get_basic(&iter, key);
+void netconfig_gdbus_pending_call_unref(void)
+{
+ if (gconn_data.conn_ref_count < 1)
+ return;
- if (value == NULL)
- return TRUE;
+ g_object_unref(gconn_data.connection);
- dbus_message_iter_next(&iter);
- if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) {
- DBG("Argument type %d", dbus_message_iter_get_arg_type(&iter));
- return TRUE;
+ if (__sync_sub_and_fetch(&gconn_data.conn_ref_count, 1) < 1) {
+ /* TODO: Check this
+ * gconn_data.connection = NULL;
+ */
}
-
- dbus_message_iter_recurse(&iter, &iter_variant);
- if (dbus_message_iter_get_arg_type(&iter_variant) != type)
- return FALSE;
-
- dbus_message_iter_get_basic(&iter_variant, value);
-
- return TRUE;
}
-gboolean netconfig_dbus_get_basic_params_array(DBusMessage *message,
- char **key, void **value)
+int netconfig_create_gdbus_call(GDBusConnection *conn)
{
- DBusMessageIter args, dict, entry, variant;
- int type = 0;
-
- if (key == NULL)
- return FALSE;
-
- /* read parameters */
- if (dbus_message_iter_init(message, &args) == FALSE) {
- DBG("Message does not have parameters");
- return FALSE;
+ if (gconn_data.connection != NULL) {
+ ERR("Connection already set");
+ return -1;
}
- if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_ARRAY) {
- DBG("Argument type %d", dbus_message_iter_get_arg_type(&args));
- return FALSE;
+ gconn_data.connection = conn;
+ if (gconn_data.connection == NULL) {
+ ERR("Failed to connect to the D-BUS daemon");
+ return -1;
}
- dbus_message_iter_recurse(&args, &dict);
+ gconn_data.cancellable = g_cancellable_new();
- if (dbus_message_iter_get_arg_type(&dict) != DBUS_TYPE_DICT_ENTRY) {
- DBG("Argument type %d", dbus_message_iter_get_arg_type(&dict));
- return FALSE;
- }
+ return 0;
+}
- dbus_message_iter_recurse(&dict, &entry);
+gboolean netconfig_is_cellular_internet_profile(const char *profile)
+{
+ const char internet_suffix[] = "_1";
+ char *suffix = NULL;
- if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING) {
- DBG("Argument type %d", dbus_message_iter_get_arg_type(&entry));
+ if (profile == NULL)
return FALSE;
- }
-
- dbus_message_iter_get_basic(&entry, key);
-
- if (value == NULL)
- return TRUE;
- dbus_message_iter_next(&entry);
-
- if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT) {
- DBG("Argument type %d", dbus_message_iter_get_arg_type(&entry));
- return TRUE;
+ if (g_str_has_prefix(profile, CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX)
+ == TRUE) {
+ suffix = strrchr(profile, '_');
+ if (g_strcmp0(suffix, internet_suffix) == 0)
+ return TRUE;
}
- dbus_message_iter_recurse(&entry, &variant);
-
- type = dbus_message_iter_get_arg_type(&variant);
- if (type == DBUS_TYPE_STRING)
- dbus_message_iter_get_basic(&variant, value);
- else if (type == DBUS_TYPE_BYTE || type == DBUS_TYPE_BOOLEAN ||
- type == DBUS_TYPE_INT16 || type == DBUS_TYPE_UINT16 ||
- type == DBUS_TYPE_INT32 || type == DBUS_TYPE_UINT32 ||
- type == DBUS_TYPE_DOUBLE)
- dbus_message_iter_get_basic(&variant, *value);
- else
- DBG("Argument type %d", type);
-
- return TRUE;
+ return FALSE;
}
gboolean netconfig_is_cellular_profile(const char *profile)
return g_str_has_prefix(profile, CONNMAN_BLUETOOTH_SERVICE_PROFILE_PREFIX);
}
-gboolean netconfig_invoke_dbus_method_nonblock(
- const char *dest, const char *path,
- const char *interface_name, const char *method, char *param_array[],
- DBusPendingCallNotifyFunction notify_func)
+gboolean netconfig_invoke_dbus_method_nonblock(const char *dest, const char *path,
+ const char *interface_name, const char *method, GVariant *params,
+ GAsyncReadyCallback notify_func)
{
- dbus_bool_t result;
- DBusPendingCall *call;
- DBusMessage *message = NULL;
- DBusConnection *connection = NULL;
+ GDBusConnection *connection = NULL;
- DBG("[DBUS Async] %s %s %s", interface_name, method, path);
+ DBG("[GDBUS Async] %s %s %s", interface_name, method, path);
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ connection = netconfig_gdbus_get_connection();
if (connection == NULL) {
- ERR("Failed to get system bus");
-
+ ERR("Failed to get gdbus connection");
return FALSE;
}
- message = dbus_message_new_method_call(dest, path, interface_name, method);
- if (message == NULL) {
- ERR("Failed DBus method call");
-
- dbus_connection_unref(connection);
-
- return FALSE;
- }
-
- if (__netconfig_dbus_append_param(message, param_array) == FALSE) {
- ERR("Failed to append DBus params");
-
- dbus_message_unref(message);
- dbus_connection_unref(connection);
-
- return FALSE;
- }
-
- result = dbus_connection_send_with_reply(connection, message, &call,
- NETCONFIG_DBUS_REPLY_TIMEOUT);
-
- if (result != TRUE || call == NULL) {
- ERR("dbus_connection_send_with_reply() failed.");
-
- dbus_message_unref(message);
- dbus_connection_unref(connection);
-
- return FALSE;
- }
-
- if (notify_func == NULL)
- dbus_pending_call_cancel(call);
- else
- dbus_pending_call_set_notify(call, notify_func, NULL, NULL);
-
- dbus_message_unref(message);
- dbus_connection_unref(connection);
+ g_dbus_connection_call(connection,
+ dest,
+ path,
+ interface_name,
+ method,
+ params,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ NETCONFIG_DBUS_REPLY_TIMEOUT,
+ netconfig_gdbus_get_gdbus_cancellable(),
+ (GAsyncReadyCallback) notify_func,
+ NULL);
+
+ if (notify_func != NULL)
+ netconfig_gdbus_pending_call_ref();
return TRUE;
}
-DBusMessage *netconfig_invoke_dbus_method(const char *dest, const char *path,
- const char *interface_name, const char *method, char *param_array[])
+GVariant *netconfig_invoke_dbus_method(const char *dest, const char *path,
+ const char *interface_name, const char *method, GVariant *params)
{
- DBusError error;
- DBusConnection *conn = NULL;
- DBusMessage *reply = NULL;
- DBusMessage *message = NULL;
-
- DBG("[DBUS Sync] %s %s %s", interface_name, method, path);
- conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
- if (conn == NULL) {
- ERR("Failed to get system bus");
-
- return NULL;
- }
-
- message = dbus_message_new_method_call(dest, path, interface_name, method);
- if (message == NULL) {
- ERR("Error!!! Failed to GetProperties");
-
- dbus_connection_unref(conn);
-
- return NULL;
- }
-
- if (__netconfig_dbus_append_param(message, param_array) == FALSE) {
- ERR("Error!!! __netconfig_dbus_append_param() failed");
-
- dbus_message_unref(message);
- dbus_connection_unref(conn);
+ GError *error = NULL;
+ GVariant *reply = NULL;
+ GDBusConnection *connection;
- return NULL;
+ connection = netconfig_gdbus_get_connection();
+ if (connection == NULL) {
+ ERR("Failed to get GDBusconnection");
+ return reply;
}
- dbus_error_init(&error);
-
- reply = dbus_connection_send_with_reply_and_block(conn, message,
- NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
+ reply = g_dbus_connection_call_sync(
+ connection,
+ dest,
+ path,
+ interface_name,
+ method,
+ params,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ NETCONFIG_DBUS_REPLY_TIMEOUT,
+ netconfig_gdbus_get_gdbus_cancellable(),
+ &error);
if (reply == NULL) {
- if (dbus_error_is_set(&error) == TRUE) {
- ERR("Error!!! dbus_connection_send_with_reply_and_block() failed. "
- "DBus error [%s: %s]", error.name, error.message);
-
- dbus_error_free(&error);
- } else
- ERR("Error!!! Failed to get properties");
-
- dbus_message_unref(message);
- dbus_connection_unref(conn);
+ if (error != NULL) {
+ ERR("g_dbus_connection_call_sync() failed"
+ "error [%d: %s]", error->code, error->message);
+ g_error_free(error);
+ } else {
+ ERR("g_dbus_connection_call_sync() failed");
+ }
return NULL;
}
- dbus_message_unref(message);
- dbus_connection_unref(conn);
-
return reply;
}
-char *netconfig_wifi_get_connected_service_name(DBusMessage *message)
+static void __netconfig_got_bus_cb(GDBusConnection *conn, const gchar *name,
+ gpointer user_data)
{
- int is_connected = 0;
- char *essid_name = NULL;
- DBusMessageIter iter, array;
-
- dbus_message_iter_init(message, &iter);
- dbus_message_iter_recurse(&iter, &array);
-
- while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
- DBusMessageIter entry, string;
- const char *key = NULL;
-
- dbus_message_iter_recurse(&array, &entry);
- dbus_message_iter_get_basic(&entry, &key);
-
- if (g_str_equal(key, "State") == TRUE && is_connected == 0) {
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &string);
-
- if (dbus_message_iter_get_arg_type(&string) == DBUS_TYPE_STRING) {
- dbus_message_iter_get_basic(&string, &key);
-
- if (g_str_equal(key, "ready") == TRUE ||
- g_str_equal(key, "online") == TRUE)
- is_connected = 1;
- }
- } else if (g_str_equal(key, "Name") == TRUE) {
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &string);
-
- if (dbus_message_iter_get_arg_type(&string) == DBUS_TYPE_STRING) {
- dbus_message_iter_get_basic(&string, &key);
+ netconfig_create_gdbus_call(conn);
+}
- essid_name = (char *)g_strdup(key);
- }
- }
+static void __netconfig_got_name_cb(GDBusConnection *conn, const gchar *name,
+ gpointer user_data)
+{
+ INFO("Got gdbus name: [%s] and gdbus connection: [%p]", name, conn);
- dbus_message_iter_next(&array);
+ if (g_callback != NULL) {
+ g_callback();
}
+}
- if (is_connected == 1 && essid_name != NULL)
- return essid_name;
-
- if (essid_name != NULL)
- g_free(essid_name);
+static void __netconfig_lost_name_cb(GDBusConnection *conn, const gchar *name,
+ gpointer user_data)
+{
+ /* May service name is already in use */
+ ERR("Service name is already in use");
- return NULL;
+ /* The result of DBus name request is only permitted,
+ * such as DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER.
+ */
+ exit(2);
}
-DBusGConnection *netconfig_setup_dbus(void)
+int netconfig_setup_gdbus(netconfig_got_name_cb cb)
{
- DBusGConnection* connection = NULL;
- GError *error = NULL;
- DBusGProxy *proxy;
- guint rv = 0;
-
- connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
- if (connection == NULL) {
- ERR("Fail to get DBus(%s)", error->message);
- g_error_free(error);
+ g_callback = cb;
- return connection;
+ manager_server_wifi = g_dbus_object_manager_server_new(
+ NETCONFIG_WIFI_PATH);
+ if (manager_server_wifi == NULL) {
+ ERR("Manager server for WIFI_PATH not created.");
+ exit(1);
}
- INFO("Successfully get system DBus connection(%p)", connection);
-
- proxy = dbus_g_proxy_new_for_name(connection, "org.freedesktop.DBus",
- "/org/freedesktop/DBus",
- "org.freedesktop.DBus");
-
- if (!dbus_g_proxy_call(proxy, "RequestName", &error,
- G_TYPE_STRING, NETCONFIG_SERVICE, G_TYPE_UINT, 0,
- G_TYPE_INVALID, G_TYPE_UINT, &rv,
- G_TYPE_INVALID)) {
- ERR("Failed to acquire service(%s) error(%s)",
- NETCONFIG_SERVICE, error->message);
- g_error_free(error);
-
- dbus_g_connection_unref(connection);
+ manager_server_state = g_dbus_object_manager_server_new(
+ NETCONFIG_NETWORK_STATE_PATH);
+ if (manager_server_state == NULL) {
+ ERR("Manager server for STATE_PATH not created.");
+ exit(1);
+ }
- return NULL;
+ manager_server_statistics = g_dbus_object_manager_server_new(
+ NETCONFIG_NETWORK_STATISTICS_PATH);
+ if (manager_server_statistics == NULL) {
+ ERR("Manager server for STATISTICS_PATH not created.");
+ exit(1);
}
- if (rv != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- ERR("Service name is already in use");
+ owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, NETCONFIG_SERVICE,
+ G_BUS_NAME_OWNER_FLAGS_NONE, __netconfig_got_bus_cb,
+ __netconfig_got_name_cb, __netconfig_lost_name_cb,
+ NULL, NULL);
+ if (!owner_id) {
+ ERR("Could not get system bus!");
+ return -EIO;
+ }
- dbus_g_connection_unref(connection);
+ INFO("Got system bus!");
+ return 0;
+}
- return NULL;
- }
+void netconfig_cleanup_gdbus(void)
+{
+ g_bus_unown_name (owner_id);
- return connection;
+ return;
}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "netsupplicant.h"
#define DBUS_OBJECT_PATH_MAX 150
-#define NETCONFIG_DBUS_REPLY_TIMEOUT (10 * 1000)
-static void setup_dbus_args(gpointer data, gpointer user_data)
+const char *netconfig_wifi_get_supplicant_interface(void)
{
- DBusMessageIter *iter;
- struct dbus_input_arguments *args;
-
- if (data == NULL || user_data == NULL)
- return;
-
- iter = (DBusMessageIter *) user_data;
- args = (struct dbus_input_arguments *)data;
-
- if (args->data == NULL)
- return;
-
- switch (args->type) {
- case DBUS_TYPE_STRING:
- case DBUS_TYPE_OBJECT_PATH:
- DBG("parameter [%s]", args->data);
- dbus_message_iter_append_basic(iter, args->type, &(args->data));
- break;
- case DBUS_TYPE_BOOLEAN:
- case DBUS_TYPE_UINT32:
- case DBUS_TYPE_INT32:
- DBG("parameter [%d]", args->data);
- dbus_message_iter_append_basic(iter, args->type, args->data);
- break;
- case DBUS_TYPE_INVALID:
- default:
- return;
- }
-}
-
-GList *setup_input_args(GList *list,
- struct dbus_input_arguments *items)
-{
- struct dbus_input_arguments *iter = items;
-
- if (iter == NULL)
- return NULL;
-
- while (iter->data) {
- list = g_list_append(list, iter); //Adds a new element on to the end of the list
- iter++;
- }
-
- return list;
-}
-
-gboolean netconfig_wifi_get_ifname(char **ifname)
-{
- DBusConnection *connection = NULL;
- DBusMessage *message = NULL;
- DBusMessageIter iter;
- int MessageType = 0;
- char *ptr = (char *)*ifname;
- const char *temp = NULL;
-
- char object_path[DBUS_PATH_MAX_BUFLEN] = { 0, };
- char *path_ptr = &object_path[0];
-
- GList *input_args = NULL;
- struct dbus_input_arguments args[] = {
- {DBUS_TYPE_STRING, SUPPLICANT_INTERFACE ".Interface"},
- {DBUS_TYPE_STRING, "Ifname"},
- {0, NULL}
- };
-
- if (ptr == NULL)
- return FALSE;
-
- if (netconfig_wifi_get_supplicant_interface(&path_ptr) != TRUE) {
- DBG("Fail to get wpa_supplicant DBus path");
- return FALSE;
- }
-
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
- if (connection == NULL) {
- ERR("Error!!! Fail to get system DBus");
- return FALSE;
- }
-
- input_args = setup_input_args(input_args, args);
-
- message = netconfig_supplicant_invoke_dbus_method(
- SUPPLICANT_SERVICE, connection,
- path_ptr,
- SUPPLICANT_GLOBAL_INTERFACE, "Get",
- input_args);
-
- g_list_free(input_args);
-
- if (message == NULL) {
- ERR("Error!!! Failed to get service properties");
- goto error;
- }
-
- MessageType = dbus_message_get_type(message);
-
- if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
- const char *err_ptr = dbus_message_get_error_name(message);
- ERR("Error!!! Error message received %s", err_ptr);
- goto error;
- }
-
- dbus_message_iter_init(message, &iter);
-
- if ((MessageType = dbus_message_iter_get_arg_type(&iter))
- == DBUS_TYPE_VARIANT) {
- DBusMessageIter string_type;
- dbus_message_iter_recurse(&iter, &string_type);
-
- if ((MessageType = dbus_message_iter_get_arg_type(&string_type))
- == DBUS_TYPE_STRING) {
- dbus_message_iter_get_basic(&string_type, &temp);
- } else
- goto error;
- } else
- goto error;
-
- g_strlcpy(ptr, temp, 16);
-
- dbus_message_unref(message);
- dbus_connection_unref(connection);
-
- return TRUE;
-
-error:
- if (message != NULL)
- dbus_message_unref(message);
-
- if (connection != NULL)
- dbus_connection_unref(connection);
-
- return FALSE;
-}
-
-gboolean netconfig_wifi_get_supplicant_interface(char **path)
-{
- DBusConnection *connection = NULL;
- DBusMessage *message = NULL;
- DBusMessageIter iter;
- int MessageType = 0;
- char *ptr = (char *)*path;
- const char *temp = NULL;
-
- GList *input_args = NULL;
- struct dbus_input_arguments args[] = {
- {DBUS_TYPE_STRING, SUPPLICANT_INTERFACE},
- {DBUS_TYPE_STRING, "Interfaces"},
- {0, NULL}
- };
-
- if (ptr == NULL)
- return FALSE;
-
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
- if (connection == NULL) {
- ERR("Error!!! Fail to get system DBus");
- return FALSE;
- }
-
- input_args = setup_input_args(input_args, args);
-
- message = netconfig_supplicant_invoke_dbus_method(
- SUPPLICANT_SERVICE, connection,
- SUPPLICANT_PATH,
- SUPPLICANT_GLOBAL_INTERFACE, "Get",
- input_args);
-
- g_list_free(input_args);
-
- if (message == NULL) {
- ERR("Error!!! Failed to get service properties");
- goto error;
- }
-
- MessageType = dbus_message_get_type(message);
-
- if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
- const char *err_msg = dbus_message_get_error_name(message);
- ERR("Error!!! Error message received %s", err_msg);
- goto error;
- }
-
- dbus_message_iter_init(message, &iter);
- if ((MessageType = dbus_message_iter_get_arg_type(&iter))
- == DBUS_TYPE_VARIANT) {
- DBusMessageIter array;
- dbus_message_iter_recurse(&iter, &array);
-
- if ((MessageType = dbus_message_iter_get_arg_type(&array))
- == DBUS_TYPE_ARRAY) {
- DBusMessageIter object_path;
- dbus_message_iter_recurse(&array, &object_path);
-
- if ((MessageType = dbus_message_iter_get_arg_type(&object_path))
- == DBUS_TYPE_OBJECT_PATH)
- dbus_message_iter_get_basic(&object_path, &temp);
- else
- goto error;
- } else
- goto error;
- } else
- goto error;
-
- g_strlcpy(ptr, temp, DBUS_PATH_MAX_BUFLEN);
-
- dbus_message_unref(message);
- dbus_connection_unref(connection);
-
- return TRUE;
-
-error:
- if (message != NULL)
- dbus_message_unref(message);
-
- if (connection != NULL)
- dbus_connection_unref(connection);
-
- return FALSE;
-}
-
-const char *netconfig_wifi_get_supplicant_interface_(void)
-{
- GList *input_args = NULL;
- DBusMessage *message = NULL;
- struct dbus_input_arguments args[] = {
- {DBUS_TYPE_STRING, WIFI_IFNAME},
- {DBUS_TYPE_INVALID, NULL}
- };
+ GVariant *message = NULL;
+ GVariant *params = NULL;
const char *path;
static char obj_path[DBUS_OBJECT_PATH_MAX] = { '\0', };
if (obj_path[0] != '\0')
return (const char *)obj_path;
- input_args = setup_input_args(input_args, args);
+ params = g_variant_new("(s)", WIFI_IFNAME);
- message = netconfig_supplicant_invoke_dbus_method_(
+ message = netconfig_supplicant_invoke_dbus_method(
SUPPLICANT_SERVICE, SUPPLICANT_PATH,
- SUPPLICANT_INTERFACE, "GetInterface", input_args);
+ SUPPLICANT_INTERFACE, "GetInterface", params);
- g_list_free(input_args);
-
- if (message == NULL)
+ if (message == NULL) {
+ ERR("Failed to get object path");
return NULL;
-
- if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) {
- const char *err_msg = dbus_message_get_error_name(message);
- ERR("Error!!! Error message received %s", err_msg);
- goto error;
}
- dbus_message_get_args(message, NULL, DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
+ g_variant_get(message, "(o)", &path);
g_strlcpy(obj_path, path, DBUS_OBJECT_PATH_MAX);
- dbus_message_unref(message);
+ g_variant_unref(message);
return (const char *)obj_path;
-
-error:
- if (message != NULL)
- dbus_message_unref(message);
-
- return NULL;
}
-
-DBusMessage *netconfig_supplicant_invoke_dbus_method(const char *dest,
- DBusConnection *connection,
- const char *path, const char *interface_name,
- const char *method, GList *args)
+GVariant *netconfig_supplicant_invoke_dbus_method(const char *dest, const char *path,
+ const char *interface_name, const char *method, GVariant *params)
{
- DBusError error;
- DBusMessageIter iter;
- DBusMessage *reply = NULL;
- DBusMessage *message = NULL;
+ GError *error = NULL;
+ GVariant *reply = NULL;
+ GDBusConnection *connection = NULL;
- message = dbus_message_new_method_call(dest, path, interface_name, method);
- if (message == NULL) {
- ERR("Error!!! DBus method call fail");
+ INFO("[DBUS Sync] %s %s %s", interface_name, method, path);
+
+ connection = netconfig_gdbus_get_connection();
+ if (connection == NULL) {
+ ERR("Failed to get GDBus Connection");
return NULL;
}
- dbus_message_iter_init_append(message, &iter);
-
- if (args != NULL)
- g_list_foreach(args, setup_dbus_args, (gpointer) &iter);
-
- dbus_error_init(&error);
-
- reply = dbus_connection_send_with_reply_and_block(connection, message,
- NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
+ reply = g_dbus_connection_call_sync(
+ connection,
+ dest,
+ path,
+ interface_name,
+ method,
+ params,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ NETCONFIG_DBUS_REPLY_TIMEOUT,
+ netconfig_gdbus_get_gdbus_cancellable(),
+ &error);
if (reply == NULL) {
- if (dbus_error_is_set(&error) == TRUE) {
- ERR("Error!!! dbus_connection_send_with_reply_and_block() failed. DBus error [%s: %s]",
- error.name, error.message);
-
- dbus_error_free(&error);
- } else
- ERR("Error!!! Failed to get properties");
-
- dbus_message_unref(message);
+ if (error != NULL) {
+ ERR("g_dbus_connection_call_sync() failed"
+ "error [%d: %s]", error->code, error->message);
+ g_error_free(error);
+ } else {
+ ERR("g_dbus_connection_call_sync() failed");
+ }
return NULL;
}
- dbus_message_unref(message);
-
return reply;
}
-DBusMessage *netconfig_supplicant_invoke_dbus_method_(const char *dest,
+gboolean netconfig_supplicant_invoke_dbus_method_nonblock(const char *dest,
const char *path, const char *interface_name,
- const char *method, GList *args)
+ const char *method, GVariant *params,
+ GAsyncReadyCallback notify_func)
{
- DBusError error;
- DBusMessageIter iter;
- DBusMessage *reply = NULL;
- DBusMessage *message = NULL;
- DBusConnection *connection = NULL;
+ GDBusConnection *connection = NULL;
-// DBG("[DBUS Sync] %s %s %s", interface_name, method, path);
+ INFO("[DBUS Async] %s %s %s", interface_name, method, path);
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ connection = netconfig_gdbus_get_connection();
if (connection == NULL) {
- ERR("Failed to get system bus");
- return NULL;
- }
-
- message = dbus_message_new_method_call(dest, path, interface_name, method);
- if (message == NULL) {
- ERR("Failed DBus method call");
- dbus_connection_unref(connection);
- return NULL;
+ DBG("Failed to get GDBusconnection");
+ return FALSE;
}
- dbus_message_iter_init_append(message, &iter);
-
- if (args != NULL)
- g_list_foreach(args, setup_dbus_args, (gpointer)&iter);
-
- dbus_error_init(&error);
-
- reply = dbus_connection_send_with_reply_and_block(connection, message,
- NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
-
- if (reply == NULL) {
- if (dbus_error_is_set(&error) == TRUE) {
- ERR("dbus_connection_send_with_reply_and_block() failed. "
- "DBus error [%s: %s]", error.name, error.message);
-
- dbus_error_free(&error);
- } else
- ERR("Failed to get properties");
+ g_dbus_connection_call(connection,
+ dest,
+ path,
+ interface_name,
+ method,
+ params,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ NETCONFIG_DBUS_REPLY_TIMEOUT,
+ netconfig_gdbus_get_gdbus_cancellable(),
+ (GAsyncReadyCallback) notify_func,
+ NULL);
- dbus_message_unref(message);
- dbus_connection_unref(connection);
+ if (notify_func != NULL)
+ netconfig_gdbus_pending_call_ref();
- return NULL;
- }
-
- dbus_message_unref(message);
- dbus_connection_unref(connection);
-
- return reply;
+ return TRUE;
}
-DBusMessage *netconfig_supplicant_invoke_dbus_interface_property_get(const char *interface,
+GVariant *netconfig_supplicant_invoke_dbus_interface_property_get(const char *interface,
const char *key)
{
- DBusError error;
- DBusMessage *reply = NULL;
- DBusMessage *message = NULL;
- DBusConnection *connection = NULL;
+ GVariant *params = NULL;
+ GVariant *reply = NULL;
const char *path;
- ERR("[DBUS] property_get : %s", key);
+ ERR("[GDBUS] property_get : %s", key);
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
- if (connection == NULL) {
- ERR("Failed to get system bus");
- return NULL;
- }
-
- path = netconfig_wifi_get_supplicant_interface_();
+ path = netconfig_wifi_get_supplicant_interface();
if (path == NULL) {
DBG("Failed to get wpa_supplicant DBus path");
- dbus_connection_unref(connection);
- return NULL;
- }
-
- message = dbus_message_new_method_call(SUPPLICANT_SERVICE, path,
- DBUS_INTERFACE_PROPERTIES, "Get");
- if (message == NULL) {
- ERR("Failed DBus method call");
- dbus_connection_unref(connection);
return NULL;
}
- dbus_message_append_args(message, DBUS_TYPE_STRING, &interface,
- DBUS_TYPE_STRING, &key, NULL);
+ params = g_variant_new("(ss)", interface, key);
- dbus_error_init(&error);
+ reply = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE,
+ path,
+ DBUS_INTERFACE_PROPERTIES,
+ "Get",
+ params);
- reply = dbus_connection_send_with_reply_and_block(connection, message,
- NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
if (reply == NULL) {
- if (dbus_error_is_set(&error) == TRUE) {
- ERR("dbus_connection_send_with_reply_and_block() failed. "
- "DBus error [%s: %s]", error.name, error.message);
-
- dbus_error_free(&error);
- } else
- ERR("Failed to get properties");
-
- dbus_message_unref(message);
- dbus_connection_unref(connection);
-
+ ERR("netconfig_supplicant_invoke_dbus_method() failed.");
return NULL;
}
- dbus_message_unref(message);
- dbus_connection_unref(connection);
-
return reply;
}
-dbus_bool_t netconfig_supplicant_invoke_dbus_interface_property_set(const char *interface,
- const char *key, const char *type, GList *args,
- DBusPendingCallNotifyFunction notify_func)
+gboolean netconfig_supplicant_invoke_dbus_interface_property_set(const char *interface,
+ const char *key, GVariant *var,
+ GAsyncReadyCallback notify_func)
{
- dbus_bool_t result = FALSE;
- DBusPendingCall *call;
- DBusMessage *message = NULL;
- DBusConnection *connection = NULL;
- DBusMessageIter iter, value;
+ gboolean result = FALSE;
+ GVariant *message = NULL;
const char *path;
DBG("[DBUS] property_set : %s", key);
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
- if (connection == NULL) {
- ERR("Failed to get system bus");
- return result;
- }
-
- path = netconfig_wifi_get_supplicant_interface_();
+ path = netconfig_wifi_get_supplicant_interface();
if (path == NULL) {
ERR("Failed to get wpa_supplicant DBus path");
- dbus_connection_unref(connection);
- return result;
- }
-
- message = dbus_message_new_method_call(SUPPLICANT_SERVICE, path,
- DBUS_INTERFACE_PROPERTIES, "Set");
- if (message == NULL) {
- ERR("Failed DBus method call");
- dbus_connection_unref(connection);
return result;
}
- dbus_message_iter_init_append(message, &iter);
- dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &interface);
- dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
- type, &value);
-
- if (args != NULL)
- g_list_foreach(args, setup_dbus_args, (gpointer)&value);
-
- dbus_message_iter_close_container(&iter, &value);
+ message = g_variant_new("(ssv)", interface, key, var);
+ result = netconfig_invoke_dbus_method_nonblock(SUPPLICANT_SERVICE,
+ path,
+ DBUS_INTERFACE_PROPERTIES,
+ "Set",
+ message,
+ notify_func);
- result = dbus_connection_send_with_reply(connection, message, &call,
- NETCONFIG_DBUS_REPLY_TIMEOUT);
- if (result == FALSE || call == NULL) {
+ if (result == FALSE) {
ERR("dbus_connection_send_with_reply() failed");
- dbus_message_unref(message);
- dbus_connection_unref(connection);
-
return result;
}
- if (notify_func == NULL)
- dbus_pending_call_cancel(call);
- else
- dbus_pending_call_set_notify(call, notify_func, NULL, NULL);
-
- dbus_message_unref(message);
- dbus_connection_unref(connection);
-
return result;
}
-
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
#include <stdio.h>
-#include <systemd/sd-daemon.h>
-#include <getopt.h>
-#include <unistd.h>
-#include <signal.h>
#include <errno.h>
-//#include <system_info.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <system_info.h>
#include "log.h"
#include "wifi.h"
-#include "util.h"
-#include "emulator.h"
#include "netdbus.h"
+#include "emulator.h"
+#include "neterror.h"
+#include "wifi-agent.h"
+#include "wifi-power.h"
#include "network-clock.h"
#include "network-state.h"
-#include "network-statistics.h"
-#include "signal-handler.h"
-#include "wifi-agent.h"
#include "network-monitor.h"
+#include "signal-handler.h"
+#include "network-statistics.h"
static GMainLoop *main_loop = NULL;
-//#define ETHERNET_FEATURE "http://tizen.org/feature/network.ethernet"
-static int no_fork = FALSE;
+#define ETHERNET_FEATURE "http://tizen.org/feature/network.ethernet"
/*Poll the ethernet Cable Plug-in /Plug-out status at every 1000 ms*/
-#define ETH_POLLING_TIME 1000
+#define ETH_POLLING_TIME 1000
/* Callback to Poll the Ethernet Status*/
gboolean __net_ethernet_cable_status_polling_callback(gpointer data)
return TRUE;
}
-void netconfig_signal_handler_SIGTERM(int signum)
-{
- g_main_loop_quit(main_loop);
-}
-
-int netconfig_register_signal_handler_SIGTERM(void)
-{
- struct sigaction sigset;
-
- sigemptyset(&sigset.sa_mask);
- sigaddset( &sigset.sa_mask, SIGTERM );
- sigset.sa_flags = 0;
- sigset.sa_handler = netconfig_signal_handler_SIGTERM;
-
- if (sigaction( SIGTERM, &sigset, NULL) < 0) {
- ERR("Sigaction for SIGTERM failed [%s]", strerror( errno ));
- return -1;
- }
-
- INFO( "Handler for SIGTERM ok" );
- return 0;
-}
-
-int netconfig_test_input_parameters(int argc, char* argv[])
+void __netconfig_got_name_cb(void)
{
- struct option tab[] = {
- { "nofork", no_argument, 0, 0 },
- { NULL, 0, NULL, 0 }
- };
- int idx = 0;
+ netconfig_wifi_create_and_init();
+ netconfig_network_state_create_and_init();
+ netconfig_network_statistics_create_and_init();
- while (getopt_long(argc, argv, "", tab, &idx) >= 0) {
+ netconfig_register_signal();
+ netconfig_agent_register();
- if (idx == 0)
- no_fork = TRUE;
- idx = 0;
- }
- return 0;
+#if defined TIZEN_TV
+ __netconfig_set_ether_macaddr();
+#endif
}
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- DBusGConnection *connection;
+ int ret;
int check_ethernet_monitor_timer = 0;
- //bool ethernet_feature_supported = FALSE;
+ bool ethernet_feature_supported = FALSE;
- DBG("Network Configuration Module");
+ umask(0077);
- /*
- * Call parameters veryfication
- */
- netconfig_test_input_parameters(argc, argv);
+ DBG("Network Configuration service");
+ if (daemon(0, 0) != 0)
+ DBG("Cannot start daemon");
- if (!no_fork) {
- if (daemon(0, 0) != 0)
- DBG("Cannot start daemon");
+ if (mkdir(WIFI_STORAGEDIR, S_IRUSR | S_IWUSR | S_IXUSR |
+ S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) {
+ if (errno != EEXIST)
+ ERR("Failed to create Wi-Fi directory");
}
- netconfig_set_wifi_mac_address();
+ if (mkdir(WIFI_CERT_STORAGEDIR, S_IRUSR | S_IWUSR | S_IXUSR |
+ S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) {
+ if (errno != EEXIST)
+ ERR("Failed to create cert directory");
+ }
+#if !GLIB_CHECK_VERSION(2,36,0)
g_type_init();
+#endif
main_loop = g_main_loop_new(NULL, FALSE);
+ if (main_loop == NULL) {
+ ERR("Couldn't create GMainLoop\n");
+ return 0;
+ }
- connection = netconfig_setup_dbus();
- if (connection == NULL)
- return -1;
-
- if (netconfig_network_state_create_and_init(connection) == NULL)
- return -1;
-
- netconfig_register_signal();
-
- /* Registering the agent for exchanging security credentials */
- netconfig_agent_register();
-
- if (netconfig_wifi_create_and_init(connection) == NULL)
- return -1;
+ ret = netconfig_setup_gdbus(__netconfig_got_name_cb);
+ if (ret > 0) {
+ ERR("_netconfig_setup_gdbus is failed\n");
+ return 0;
+ }
- if (netconfig_network_statistics_create_and_init(connection) == NULL)
- return -1;
+ netconfig_error_init();
- /* Register SIGCHLD signal handler function */
- if (netconfig_register_signal_handler_SIGTERM() != 0)
- return -1;
+#if !defined TIZEN_TELEPHONY_ENABLE
+ netconfig_clock_init();
+#endif
/* If its environment uses Emulator, network configuration is set by emulator default */
netconfig_emulator_test_and_start();
-/*
+
+ /*In case no emulator, set the ETH0 Mac address*/
+#if defined TIZEN_TV
+ if (netconfig_emulator_is_emulated() == FALSE)
+ __netconfig_set_ether_macaddr();
+#endif
+
if (!system_info_get_platform_bool(ETHERNET_FEATURE, ðernet_feature_supported)) {
if (ethernet_feature_supported == TRUE) {
//Register the callback to check the ethernet Plug-in /Plug-out Status
} else {
ERR("Error - Feature getting from System Info");
}
-*/
-
- // Notyfication to systemd
- sd_notify(0, "READY=1");
g_main_loop_run(main_loop);
+ netconfig_cleanup_gdbus();
+
netconfig_deregister_signal();
+
+ netconfig_wifi_power_deinitialize();
+
netconfig_wifi_state_notifier_cleanup();
/*remove the Timer*/
#include "netdbus.h"
#include "neterror.h"
-#include "netconfig.h"
-
-typedef enum {
- NETCONFIG_NO_ERROR = 0x00,
- NETCONFIG_ERROR_INTERNAL = 0x01,
- NETCONFIG_ERROR_NO_SERVICE = 0x02,
- NETCONFIG_ERROR_TRASPORT = 0x03,
- NETCONFIG_ERROR_NO_PROFILE = 0x04,
- NETCONFIG_ERROR_WRONG_PROFILE = 0x05,
- NETCONFIG_ERROR_INPROGRESS = 0x06,
- NETCONFIG_ERROR_ALREADYEXISTS = 0x07,
- NETCONFIG_ERROR_INVALID_PARAMETER = 0x08,
- NETCONFIG_ERROR_PERMISSION_DENIED = 0x09,
- NETCONFIG_ERROR_WIFI_DRIVER_FAILURE = 0x0A,
- NETCONFIG_ERROR_FAILED_GET_IMSI = 0x0B,
- NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH = 0x0C,
- NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM = 0x0D,
- NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_WRONG_DATA = 0x0E,
- NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_DELAY = 0x0F,
- NETCONFIG_ERROR_SECURITY_RESTRICTED = 0x10,
- NETCONFIG_ERROR_WIFI_LOAD_INPROGRESS = 0x11,
- NETCONFIG_ERROR_MAX = 0x12,
-
-} NETCONFIG_ERROR;
#define NETCONFIG_ERROR_INTERFACE NETCONFIG_SERVICE ".Error"
#define CONNMAN_AGENT_ERROR_INTERFACE "net.connman.Agent.Error"
return quark;
}
-void netconfig_error_wifi_load_inprogress(GError **error)
+
+void netconfig_error_no_profile(GDBusMethodInvocation *context)
{
- g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_WIFI_LOAD_INPROGRESS,
- NETCONFIG_ERROR_INTERFACE ".WifiLoadInprogress");
+ g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
+ NETCONFIG_ERROR_NO_PROFILE,
+ NETCONFIG_ERROR_INTERFACE ".NoProfile");
}
-
-
-void netconfig_error_inprogress(GError **error)
+void netconfig_error_inprogress(GDBusMethodInvocation *context)
{
- g_set_error(error, netconfig_error_quark(),
+ g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
NETCONFIG_ERROR_INPROGRESS,
NETCONFIG_ERROR_INTERFACE ".InProgress");
}
-void netconfig_error_already_exists(GError **error)
+void netconfig_error_already_exists(GDBusMethodInvocation *context)
{
- g_set_error(error, netconfig_error_quark(),
+ g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
NETCONFIG_ERROR_ALREADYEXISTS,
NETCONFIG_ERROR_INTERFACE ".AlreadyExists");
}
-void netconfig_error_invalid_parameter(GError **error)
+void netconfig_error_invalid_parameter(GDBusMethodInvocation *context)
{
- g_set_error(error, netconfig_error_quark(),
+ g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
NETCONFIG_ERROR_INVALID_PARAMETER,
NETCONFIG_ERROR_INTERFACE ".InvalidParameter");
}
-void netconfig_error_permission_denied(GError **error)
+void netconfig_error_permission_denied(GDBusMethodInvocation *context)
{
- g_set_error(error, netconfig_error_quark(),
+ g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
NETCONFIG_ERROR_PERMISSION_DENIED,
NETCONFIG_ERROR_INTERFACE ".PermissionDenied");
}
-
-void netconfig_error_security_restricted(GError **error)
-{
- g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_SECURITY_RESTRICTED,
- NETCONFIG_ERROR_INTERFACE ".SecurityRestricted");
-}
-
-void netconfig_error_wifi_driver_failed(GError **error)
+void netconfig_error_wifi_driver_failed(GDBusMethodInvocation *context)
{
- g_set_error(error, netconfig_error_quark(),
+ g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
NETCONFIG_ERROR_WIFI_DRIVER_FAILURE,
NETCONFIG_ERROR_INTERFACE ".WifiDriverFailed");
}
-void netconfig_error_wifi_direct_failed(GError **error)
+void netconfig_error_wifi_direct_failed(GDBusMethodInvocation *context)
{
- g_set_error(error, netconfig_error_quark(),
+ g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
NETCONFIG_ERROR_WIFI_DRIVER_FAILURE,
NETCONFIG_ERROR_INTERFACE ".WifiDirectFailed");
}
-void netconfig_error_fail_get_imsi(GError **error)
+void netconfig_error_fail_get_imsi(GDBusMethodInvocation *context)
{
- g_set_error(error, netconfig_error_quark(),
+ g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
NETCONFIG_ERROR_FAILED_GET_IMSI,
NETCONFIG_ERROR_INTERFACE".FailGetSimImsi");
}
-void netconfig_error_fail_req_sim_auth(GError **error)
+void netconfig_error_fail_req_sim_auth(GDBusMethodInvocation *context)
{
- g_set_error(error, netconfig_error_quark(),
+ g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH,
NETCONFIG_ERROR_INTERFACE".FailReqSimAuth");
}
-void netconfig_error_fail_req_sim_auth_wrong_param(GError **error)
+void netconfig_error_fail_req_sim_auth_wrong_param(GDBusMethodInvocation *context)
{
- g_set_error(error, netconfig_error_quark(),
+ g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM,
NETCONFIG_ERROR_INTERFACE".FailReqSimAuthWrongParam");
}
-void netconfig_error_fail_get_sim_auth_wrong_data(GError **error)
+void netconfig_error_fail_get_sim_auth_wrong_data(GDBusMethodInvocation *context)
{
- g_set_error(error, netconfig_error_quark(),
+ g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_WRONG_DATA,
NETCONFIG_ERROR_INTERFACE".FailGetSimAuthWrongData");
}
-void netconfig_error_fail_get_sim_auth_delay(GError **error)
+void netconfig_error_fail_get_sim_auth_delay(GDBusMethodInvocation *context)
{
- g_set_error(error, netconfig_error_quark(),
+ g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_DELAY,
NETCONFIG_ERROR_INTERFACE".FailGetSimAuthDelay");
}
+void netconfig_error_fail_save_congifuration(GDBusMethodInvocation *context)
+{
+ g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
+ NETCONFIG_ERROR_INTERNAL,
+ NETCONFIG_ERROR_INTERFACE".FailSaveConfiguration");
+}
+
+void netconfig_error_dbus_method_return(GDBusMethodInvocation *context, netconfig_error_e error, const gchar *message)
+{
+ gchar *msg = NULL;
+
+ msg = g_strdup_printf("%s.%s", NETCONFIG_ERROR_INTERFACE, message);
+ g_dbus_method_invocation_return_error_literal(context, netconfig_error_quark(), error, msg);
+
+ g_free(msg);
+}
void netconfig_error_init(void)
{
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 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.
static void __netconfig_clock_set_timeserver(const char *server)
{
- DBusMessage* reply = NULL;
- char param1[] = "string:Timeservers";
- char *param2 = NULL;
- char *param_array[] = {NULL, NULL, NULL};
+ GVariant* reply = NULL;
+ const char param0[] = "Timeservers";
+ GVariant *params = NULL;
+ GVariantBuilder *builder;
- param2 = g_strdup_printf("variant:array:string:%s", server);
+ builder = g_variant_builder_new(G_VARIANT_TYPE ("as"));
+ g_variant_builder_add(builder, "s", server);
- param_array[0] = param1;
- param_array[1] = param2;
+ params = g_variant_new("(sv)",param0, g_variant_builder_end(builder));
+ g_variant_builder_unref(builder);
reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
CONNMAN_MANAGER_PATH, CONNMAN_CLOCK_INTERFACE,
- "SetProperty", param_array);
- if (reply == NULL) {
+ "SetProperty", params);
+
+ if (reply == NULL)
ERR("Failed to configure NTP server");
- return;
- }
+ else
+ g_variant_unref(reply);
+
+ return;
+}
+
+static void __netconfig_set_timeserver(void)
+{
+ guint timeserver_clear_timer = 0;
- dbus_message_unref(reply);
+ __netconfig_clock_set_timeserver((const char *)NTP_SERVER);
+
+ netconfig_start_timer_seconds(5, __netconfig_clock_clear_timeserver_timer,
+ NULL, ×erver_clear_timer);
}
static void __netconfig_clock(
enum netconfig_wifi_service_state state, void *user_data)
{
gboolean automatic_time_update = 0;
- guint timeserver_clear_timer = 0;
if (state != NETCONFIG_WIFI_CONNECTED)
return;
return;
}
- __netconfig_clock_set_timeserver((const char *)NTP_SERVER);
-
- netconfig_start_timer_seconds(5, __netconfig_clock_clear_timeserver_timer,
- NULL, ×erver_clear_timer);
+ __netconfig_set_timeserver();
}
static struct netconfig_wifi_state_notifier netconfig_clock_notifier = {
.user_data = NULL,
};
+static void __automatic_time_update_changed_cb(keynode_t *node, void *user_data)
+{
+ gboolean automatic_time_update = FALSE;
+ enum netconfig_wifi_service_state wifi_state = NETCONFIG_WIFI_UNKNOWN;
+
+ if (node != NULL) {
+ automatic_time_update = vconf_keynode_get_bool(node);
+ } else {
+ vconf_get_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, &automatic_time_update);
+ }
+
+ if (automatic_time_update == FALSE) {
+ INFO("Automatic time update is changed to 'FALSE'");
+ return;
+ }
+
+ wifi_state = netconfig_wifi_state_get_service_state();
+
+ if (wifi_state != NETCONFIG_WIFI_CONNECTED) {
+ INFO("WiFi state is not NETCONFIG_WIFI_CONNECTED");
+ return;
+ }
+
+ __netconfig_set_timeserver();
+}
+
void netconfig_clock_init(void)
{
+ INFO("netconfig_clock_init is called");
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL,
+ __automatic_time_update_changed_cb, NULL);
+
netconfig_wifi_state_notifier_register(&netconfig_clock_notifier);
}
ret = mdata->val_out;
ret = ret & BMSR_LINK_VALID;
- if(ret == 4) {
+ if(ret == 4) {
if(!g_chk_eth_send_notification)
netconfig_network_notify_ethernet_cable_state("ATTACHED");
g_chk_eth_send_notification = TRUE;
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <vconf.h>
#include <vconf-keys.h>
+#include <fcntl.h>
+#include <unistd.h>
#include <stdlib.h>
+#include <aul.h>
+#include <net/if.h>
#include <arpa/inet.h>
#include <netinet/in.h>
+#include <sys/ioctl.h>
+#include <ITapiSim.h>
+#include <TapiUtility.h>
-#include "wifi.h"
#include "log.h"
#include "util.h"
#include "netdbus.h"
#include "neterror.h"
#include "emulator.h"
#include "wifi-state.h"
-#include "network-monitor.h"
+#include "wifi-power.h"
#include "network-state.h"
-
-#define NETCONFIG_NETWORK_STATE_PATH "/net/netconfig/network"
-#define ROUTE_EXEC_PATH "/sbin/route"
-
-#define PROP_DEFAULT FALSE
-#define PROP_DEFAULT_STR NULL
-
-
-gboolean netconfig_iface_network_state_add_route(
- NetconfigNetworkState *master,
- gchar *ip_addr, gchar *netmask,
- gchar *interface, gchar *gateway, gint32 address_family, gboolean *result, GError **error);
-
-gboolean netconfig_iface_network_state_remove_route(
- NetconfigNetworkState *master,
- gchar *ip_addr, gchar *netmask,
- gchar *interface, gchar *gateway, gint32 address_family, gboolean *result, GError **error);
-
-gboolean netconfig_iface_network_state_ethernet_cable_state(
- NetconfigNetworkState *master, gint32 *state, GError **error);
-
-#include "netconfig-iface-network-state-glue.h"
-
-enum {
- PROP_O,
- PROP_NETWORK_STATE_CONN,
- PROP_NETWORK_STATE_PATH,
-};
-
-struct NetconfigNetworkStateClass {
- GObjectClass parent;
-};
-
-struct NetconfigNetworkState {
- GObject parent;
-
- DBusGConnection *conn;
- gchar *path;
-};
-
-G_DEFINE_TYPE(NetconfigNetworkState, netconfig_network_state, G_TYPE_OBJECT);
-
-
-static void __netconfig_network_state_gobject_get_property(GObject *object,
- guint prop_id, GValue *value, GParamSpec *pspec)
-{
- return;
-}
-
-static void __netconfig_network_state_gobject_set_property(GObject *object,
- guint prop_id, const GValue *value, GParamSpec *pspec)
-{
- NetconfigNetworkState *network_state = NETCONFIG_NETWORK_STATE(object);
-
- switch (prop_id) {
- case PROP_NETWORK_STATE_CONN:
- {
- network_state->conn = g_value_get_boxed(value);
- INFO("network_state(%p) set conn(%p)", network_state, network_state->conn);
- break;
- }
-
- case PROP_NETWORK_STATE_PATH:
- {
- if (network_state->path)
- g_free(network_state->path);
-
- network_state->path = g_value_dup_string(value);
- INFO("network_state(%p) path(%s)", network_state, network_state->path);
-
- break;
- }
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- }
-}
-
-static void netconfig_network_state_init(NetconfigNetworkState *network_state)
-{
- DBG("network_state initialize");
-
- network_state->conn = NULL;
- network_state->path = g_strdup(PROP_DEFAULT_STR);
-}
-
-static void netconfig_network_state_class_init(NetconfigNetworkStateClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
- DBG("class initialize");
-
- object_class->get_property = __netconfig_network_state_gobject_get_property;
- object_class->set_property = __netconfig_network_state_gobject_set_property;
-
- /* DBus register */
- dbus_g_object_type_install_info(NETCONFIG_TYPE_NETWORK_STATE,
- &dbus_glib_netconfig_iface_network_state_object_info);
-
- /* property */
- g_object_class_install_property(object_class, PROP_NETWORK_STATE_CONN,
- g_param_spec_boxed("conn", "CONNECTION", "DBus connection",
- DBUS_TYPE_G_CONNECTION,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property(object_class, PROP_NETWORK_STATE_PATH,
- g_param_spec_string("path", "Path", "Object path",
- PROP_DEFAULT_STR,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-}
+#include "network-monitor.h"
+#include "netsupplicant.h"
+#include "wifi-tel-intf.h"
+#include "clatd-handler.h"
+
+#include "generated-code.h"
+/* Define TCP buffer sizes for various networks */
+/* ReadMin, ReadInitial, ReadMax */ /* WriteMin, WriteInitial, WriteMax */
+#define NET_TCP_BUFFERSIZE_DEFAULT_READ "4096 87380 704512"
+#define NET_TCP_BUFFERSIZE_DEFAULT_WRITE "4096 16384 110208"
+#define NET_TCP_BUFFERSIZE_WIFI_READ "524288 1048576 2560000"
+#define NET_TCP_BUFFERSIZE_WIFI_WRITE "524288 1048576 2560000"
+#define NET_TCP_BUFFERSIZE_LTE_READ "524288 1048576 2560000"
+#define NET_TCP_BUFFERSIZE_LTE_WRITE "524288 1048576 2560000"
+#define NET_TCP_BUFFERSIZE_UMTS_READ "4094 87380 704512"
+#define NET_TCP_BUFFERSIZE_UMTS_WRITE "4096 16384 110208"
+#define NET_TCP_BUFFERSIZE_HSPA_READ "4092 87380 704512"
+#define NET_TCP_BUFFERSIZE_HSPA_WRITE "4096 16384 262144"
+#define NET_TCP_BUFFERSIZE_HSDPA_READ "4092 87380 704512"
+#define NET_TCP_BUFFERSIZE_HSDPA_WRITE "4096 16384 262144"
+#define NET_TCP_BUFFERSIZE_HSUPA_READ "4092 87380 704512"
+#define NET_TCP_BUFFERSIZE_HSUPA_WRITE "4096 16384 262144"
+#define NET_TCP_BUFFERSIZE_HSPAP_READ "4092 87380 1220608"
+#define NET_TCP_BUFFERSIZE_HSPAP_WRITE "4096 16384 1220608"
+#define NET_TCP_BUFFERSIZE_EDGE_READ "4093 26280 35040"
+#define NET_TCP_BUFFERSIZE_EDGE_WRITE "4096 16384 35040"
+#define NET_TCP_BUFFERSIZE_GPRS_READ "4096 30000 30000"
+#define NET_TCP_BUFFERSIZE_GPRS_WRITE "4096 8760 11680"
+
+#define NET_TCP_BUFFERSIZE_WIFI_RMEM_MAX "1048576"
+#define NET_TCP_BUFFERSIZE_WIFI_WMEM_MAX "2097152"
+#define NET_TCP_BUFFERSIZE_LTE_RMEM_MAX "5242880"
+
+#define NET_TCP_BUFFERSIZE_WIFID_WMEM_MAX "2097152"
+
+#define NET_PROC_SYS_NET_IPV4_TCP_RMEM "/proc/sys/net/ipv4/tcp_rmem"
+#define NET_PROC_SYS_NET_IPv4_TCP_WMEM "/proc/sys/net/ipv4/tcp_wmem"
+#define NET_PROC_SYS_NET_CORE_RMEM_MAX "/proc/sys/net/core/rmem_max"
+#define NET_PROC_SYS_NET_CORE_WMEM_MAX "/proc/sys/net/core/wmem_max"
+
+#define ROUTE_EXEC_PATH "/sbin/route"
+
+static Network *netconfigstate = NULL;
struct netconfig_default_connection {
char *profile;
char *ifname;
char *ipaddress;
+ char *ipaddress6;
char *proxy;
char *essid;
+ unsigned int freq;
};
static struct netconfig_default_connection
- netconfig_default_connection_info;
+ netconfig_default_connection_info = { NULL, };
-static void __netconfig_pop_3g_alert_syspoppup(void)
-{
- int wifi_ug_state = 0;
-
- vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE, &wifi_ug_state);
- if (wifi_ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND)
- return;
+gboolean netconfig_iface_network_state_ethernet_cable_state(gint32 *state);
- DBG("Launch 3G alert network popup");
- // TODO : display a popup
-
-}
-
-static gboolean __netconfig_is_connected(const char *profile)
+static gboolean __netconfig_is_connected(GVariantIter *array)
{
gboolean is_connected = FALSE;
- DBusMessage *message = NULL;
- DBusMessageIter iter, array;
-
- if (profile == NULL)
- return FALSE;
-
- message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, profile,
- CONNMAN_SERVICE_INTERFACE, "GetProperties", NULL);
- if (message == NULL) {
- ERR("Failed to get service properties");
- return is_connected;
- }
-
- if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) {
- const char *ptr = dbus_message_get_error_name(message);
- ERR("Error!!! Error message received [%s]", ptr);
- goto done;
- }
-
- dbus_message_iter_init(message, &iter);
- dbus_message_iter_recurse(&iter, &array);
-
- while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
- DBusMessageIter entry, string;
- const char *key = NULL;
-
- dbus_message_iter_recurse(&array, &entry);
- dbus_message_iter_get_basic(&entry, &key);
+ GVariant *variant = NULL;
+ gchar *key = NULL;
+ const gchar *value = NULL;
- if (g_str_equal(key, "State") == TRUE) {
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &string);
-
- if (dbus_message_iter_get_arg_type(&string) == DBUS_TYPE_STRING) {
- dbus_message_iter_get_basic(&string, &key);
-
- if (g_str_equal(key, "ready") == TRUE ||
- g_str_equal(key, "online") == TRUE) {
- is_connected = TRUE;
+ while (g_variant_iter_loop(array, "{sv}", &key, &variant)) {
+ if (g_strcmp0(key, "State") != 0) {
+ continue;
+ }
- break;
- }
- }
+ if (g_variant_is_of_type(variant, G_VARIANT_TYPE_STRING)) {
+ value = g_variant_get_string(variant, NULL);
+ if (g_strcmp0(value, "ready") == 0 || g_strcmp0(value, "online") == 0)
+ is_connected = TRUE;
}
- dbus_message_iter_next(&array);
+ g_free(key);
+ g_variant_unref(variant);
+ break;
}
-done:
- if (message != NULL)
- dbus_message_unref(message);
-
return is_connected;
}
static char *__netconfig_get_default_profile(void)
{
- DBusMessage *message = NULL;
- GSList *service_profiles = NULL;
- GSList *list = NULL;
- DBusMessageIter iter, dict;
- char *default_profile = NULL;
+ GVariant *message = NULL;
+ GVariantIter *iter;
+ GVariantIter *next;
+ gchar *default_profile = NULL;
+ gchar *object_path;
message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
return NULL;
}
- dbus_message_iter_init(message, &iter);
- dbus_message_iter_recurse(&iter, &dict);
-
- while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_STRUCT) {
- DBusMessageIter entry;
- const char *object_path = NULL;
-
- dbus_message_iter_recurse(&dict, &entry);
- dbus_message_iter_get_basic(&entry, &object_path);
-
- if (object_path)
- service_profiles = g_slist_append(
- service_profiles,
- g_strdup(object_path));
-
- dbus_message_iter_next(&dict);
- }
+ g_variant_get(message, "(a(oa{sv}))", &iter);
+ while (g_variant_iter_loop(iter, "(oa{sv})", &object_path, &next)) {
+ if (object_path == NULL) {
+ continue;
+ }
- for (list = service_profiles; list != NULL; list = list->next) {
- char *profile_path = list->data;
+ if(netconfig_is_cellular_profile(object_path) && !netconfig_is_cellular_internet_profile(object_path)){
+ continue;
+ }
- if (__netconfig_is_connected((const char *)profile_path) == TRUE) {
- default_profile = g_strdup(profile_path);
+ if (__netconfig_is_connected(next) == TRUE) {
+ default_profile = g_strdup(object_path);
+ g_free(object_path);
+ g_variant_iter_free(next);
break;
}
}
-
- g_slist_free(service_profiles);
-
- dbus_message_unref(message);
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
return default_profile;
}
static void __netconfig_get_default_connection_info(const char *profile)
{
- DBusMessage *message = NULL;
- DBusMessageIter iter, array;
+ GVariant *message = NULL, *variant = NULL, *variant2 = NULL;
+ GVariantIter *iter = NULL, *iter1 = NULL;
+ GVariant *next = NULL;
+ gchar *key = NULL;
+ gchar *key1 = NULL;
+ gchar *key2 = NULL;
message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, profile,
CONNMAN_SERVICE_INTERFACE, "GetProperties", NULL);
if (message == NULL) {
ERR("Failed to get service properties");
- return;
- }
-
- if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) {
- const char *ptr = dbus_message_get_error_name(message);
- ERR("Error!!! Error message received [%s]", ptr);
goto done;
}
- dbus_message_iter_init(message, &iter);
- dbus_message_iter_recurse(&iter, &array);
-
- while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
- DBusMessageIter entry, variant, string, iter1, iter2, iter3;
- const char *key = NULL, *value = NULL;
-
- dbus_message_iter_recurse(&array, &entry);
- dbus_message_iter_get_basic(&entry, &key);
-
- if (g_str_equal(key, "Name") == TRUE &&
+ g_variant_get(message, "(a{sv})", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &key, &next)) {
+ const gchar *value = NULL;
+ guint16 freq = 0;
+ if (g_strcmp0(key, "Name") == 0 &&
netconfig_is_wifi_profile(profile) == TRUE) {
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &string);
-
- if (dbus_message_iter_get_arg_type(&string) == DBUS_TYPE_STRING) {
- dbus_message_iter_get_basic(&string, &value);
+ if (g_variant_is_of_type(next, G_VARIANT_TYPE_STRING)) {
+ value = g_variant_get_string(next, NULL);
netconfig_default_connection_info.essid = g_strdup(value);
}
- } else if (g_str_equal(key, "Ethernet") == TRUE) {
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &variant);
- dbus_message_iter_recurse(&variant, &iter1);
-
- while (dbus_message_iter_get_arg_type(&iter1)
- == DBUS_TYPE_DICT_ENTRY) {
- dbus_message_iter_recurse(&iter1, &iter2);
- dbus_message_iter_get_basic(&iter2, &key);
-
- if (g_str_equal(key, "Interface") == TRUE) {
- dbus_message_iter_next(&iter2);
- dbus_message_iter_recurse(&iter2, &iter3);
- dbus_message_iter_get_basic(&iter3, &value);
-
+ } else if (g_strcmp0(key, "Ethernet") == 0) {
+ g_variant_get(next, "a{sv}", &iter1);
+ while (g_variant_iter_loop(iter1, "{sv}", &key1, &variant)) {
+ if (g_strcmp0(key1, "Interface") == 0) {
+ value = g_variant_get_string(variant, NULL);
netconfig_default_connection_info.ifname = g_strdup(value);
}
-
- dbus_message_iter_next(&iter1);
}
- } else if (g_str_equal(key, "IPv4") == TRUE) {
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &variant);
- dbus_message_iter_recurse(&variant, &iter1);
-
- while (dbus_message_iter_get_arg_type(&iter1)
- == DBUS_TYPE_DICT_ENTRY) {
- dbus_message_iter_recurse(&iter1, &iter2);
- dbus_message_iter_get_basic(&iter2, &key);
-
- if (g_str_equal(key, "Address") == TRUE) {
- dbus_message_iter_next(&iter2);
- dbus_message_iter_recurse(&iter2, &iter3);
- dbus_message_iter_get_basic(&iter3, &value);
-
+ } else if (g_strcmp0(key, "IPv4") == 0) {
+ g_variant_get(next, "a{sv}", &iter1);
+ while (g_variant_iter_loop(iter1, "{sv}", &key1, &variant)) {
+ if (g_strcmp0(key1, "Address") == 0) {
+ value = g_variant_get_string(variant, NULL);
netconfig_default_connection_info.ipaddress = g_strdup(value);
}
-
- dbus_message_iter_next(&iter1);
}
- } else if (g_str_equal(key, "IPv6") == TRUE) {
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &variant);
- dbus_message_iter_recurse(&variant, &iter1);
-
- while (dbus_message_iter_get_arg_type(&iter1)
- == DBUS_TYPE_DICT_ENTRY) {
- dbus_message_iter_recurse(&iter1, &iter2);
- dbus_message_iter_get_basic(&iter2, &key);
-
- if (g_str_equal(key, "Address") == TRUE) {
- dbus_message_iter_next(&iter2);
- dbus_message_iter_recurse(&iter2, &iter3);
- dbus_message_iter_get_basic(&iter3, &value);
-
- netconfig_default_connection_info.ipaddress = g_strdup(value);
+ } else if (g_strcmp0(key, "IPv6") == 0) {
+ g_variant_get(next, "a{sv}", &iter1);
+ while (g_variant_iter_loop(iter1, "{sv}", &key1, &variant)) {
+ if (g_strcmp0(key1, "Address") == 0) {
+ value = g_variant_get_string(variant, NULL);
+ netconfig_default_connection_info.ipaddress6 = g_strdup(value);
}
-
- dbus_message_iter_next(&iter1);
}
- } else if (g_str_equal(key, "Proxy") == TRUE) {
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &variant);
- dbus_message_iter_recurse(&variant, &iter1);
-
- while (dbus_message_iter_get_arg_type(&iter1)
- == DBUS_TYPE_DICT_ENTRY) {
- DBusMessageIter iter4;
-
- dbus_message_iter_recurse(&iter1, &iter2);
- dbus_message_iter_get_basic(&iter2, &key);
-
- if (g_str_equal(key, "Servers") == TRUE) {
- dbus_message_iter_next(&iter2);
- dbus_message_iter_recurse(&iter2, &iter3);
- if (dbus_message_iter_get_arg_type(&iter3)
- != DBUS_TYPE_ARRAY)
- break;
-
- dbus_message_iter_recurse(&iter3, &iter4);
- if (dbus_message_iter_get_arg_type(&iter4)
- != DBUS_TYPE_STRING)
+ } else if (g_strcmp0(key, "Proxy") == 0) {
+ g_variant_get(next, "a{sv}", &iter1);
+ while (g_variant_iter_loop(iter1, "{sv}", &key2, &variant2)) {
+ GVariantIter *iter_sub = NULL;
+
+ if (g_strcmp0(key2, "Servers") == 0) {
+ if (!g_variant_is_of_type(next, G_VARIANT_TYPE_STRING_ARRAY)) {
+ g_free(key2);
+ g_variant_unref(variant2);
break;
+ }
- dbus_message_iter_get_basic(&iter4, &value);
+ g_variant_get(variant2, "as", &iter_sub);
+ g_variant_iter_loop(iter_sub, "s", &value);
+ g_variant_iter_free(iter_sub);
if (value != NULL && (strlen(value) > 0))
netconfig_default_connection_info.proxy = g_strdup(value);
-
- } else if (g_str_equal(key, "Method") == TRUE) {
- dbus_message_iter_next(&iter2);
- dbus_message_iter_recurse(&iter2, &iter3);
- if (dbus_message_iter_get_arg_type(&iter3)
- != DBUS_TYPE_STRING)
+ } else if (g_strcmp0(key2, "Method") == 0) {
+ if (g_variant_is_of_type(variant2, G_VARIANT_TYPE_STRING)) {
+ g_free(key2);
+ g_variant_unref(variant2);
break;
+ }
- dbus_message_iter_get_basic(&iter3, &value);
+ value = g_variant_get_string(variant2, NULL);
if (g_strcmp0(value, "direct") == 0) {
g_free(netconfig_default_connection_info.proxy);
netconfig_default_connection_info.proxy = NULL;
+ g_free(key2);
+ g_variant_unref(variant2);
break;
}
}
+ }
+ } else if (g_strcmp0(key, "Frequency") == 0) {
+ if (g_variant_is_of_type(next, G_VARIANT_TYPE_UINT16)) {
+ freq = g_variant_get_uint16(next);
+ netconfig_default_connection_info.freq = freq;
+ }
+ }
+ }
+
+done:
+ if (message)
+ g_variant_unref(message);
+
+ if (iter)
+ g_variant_iter_free (iter);
+
+ if (iter1)
+ g_variant_iter_free (iter1);
+
+ return;
+}
+
+static void __netconfig_adjust_tcp_buffer_size(void)
+{
+ int fdr = 0, fdw = 0;
+ int fdrmax = 0, fdwmax = 0;
+ const char *rbuf_size = NULL;
+ const char *wbuf_size = NULL;
+ const char *rmax_size = NULL;
+ const char *wmax_size = NULL;
+ const char *profile = netconfig_get_default_profile();
+
+ if (profile == NULL) {
+ DBG("There is no default connection");
+
+ rbuf_size = NET_TCP_BUFFERSIZE_DEFAULT_READ;
+ wbuf_size = NET_TCP_BUFFERSIZE_DEFAULT_WRITE;
+ } else if (netconfig_is_wifi_profile(profile) == TRUE) {
+ DBG("Default connection: Wi-Fi");
+
+ rbuf_size = NET_TCP_BUFFERSIZE_WIFI_READ;
+ wbuf_size = NET_TCP_BUFFERSIZE_WIFI_WRITE;
+ rmax_size = NET_TCP_BUFFERSIZE_WIFI_RMEM_MAX;
+ wmax_size = NET_TCP_BUFFERSIZE_WIFI_WMEM_MAX;
+ } else if (netconfig_is_cellular_profile(profile) == TRUE) {
+ TapiHandle *tapi_handle = NULL;
+ int telephony_svctype = 0, telephony_pstype = 0;
+
+ tapi_handle = (TapiHandle *)netconfig_tel_init();
+ if (NULL != tapi_handle) {
+ tel_get_property_int(tapi_handle,
+ TAPI_PROP_NETWORK_SERVICE_TYPE,
+ &telephony_svctype);
+ tel_get_property_int(tapi_handle, TAPI_PROP_NETWORK_PS_TYPE,
+ &telephony_pstype);
+ netconfig_tel_deinit();
+ }
+
+ DBG("Default cellular %d, %d", telephony_svctype, telephony_pstype);
- dbus_message_iter_next(&iter1);
+ switch (telephony_pstype) {
+ case VCONFKEY_TELEPHONY_PSTYPE_HSPA:
+ rbuf_size = NET_TCP_BUFFERSIZE_HSPA_READ;
+ wbuf_size = NET_TCP_BUFFERSIZE_HSPA_WRITE;
+ break;
+ case VCONFKEY_TELEPHONY_PSTYPE_HSUPA:
+ rbuf_size = NET_TCP_BUFFERSIZE_HSUPA_READ;
+ wbuf_size = NET_TCP_BUFFERSIZE_HSDPA_WRITE;
+ break;
+ case VCONFKEY_TELEPHONY_PSTYPE_HSDPA:
+ rbuf_size = NET_TCP_BUFFERSIZE_HSDPA_READ;
+ wbuf_size = NET_TCP_BUFFERSIZE_HSDPA_WRITE;
+ break;
+#if !defined TIZEN_WEARABLE
+ case VCONFKEY_TELEPHONY_PSTYPE_HSPAP:
+ rbuf_size = NET_TCP_BUFFERSIZE_HSPAP_READ;
+ wbuf_size = NET_TCP_BUFFERSIZE_HSPAP_WRITE;
+ break;
+#endif
+ default:
+ switch (telephony_svctype) {
+ case VCONFKEY_TELEPHONY_SVCTYPE_LTE:
+ rbuf_size = NET_TCP_BUFFERSIZE_LTE_READ;
+ wbuf_size = NET_TCP_BUFFERSIZE_LTE_WRITE;
+ rmax_size = NET_TCP_BUFFERSIZE_LTE_RMEM_MAX;
+ break;
+ case VCONFKEY_TELEPHONY_SVCTYPE_3G:
+ rbuf_size = NET_TCP_BUFFERSIZE_UMTS_READ;
+ wbuf_size = NET_TCP_BUFFERSIZE_UMTS_WRITE;
+ break;
+ case VCONFKEY_TELEPHONY_SVCTYPE_2_5G_EDGE:
+ rbuf_size = NET_TCP_BUFFERSIZE_EDGE_READ;
+ wbuf_size = NET_TCP_BUFFERSIZE_EDGE_WRITE;
+ break;
+ case VCONFKEY_TELEPHONY_SVCTYPE_2_5G:
+ rbuf_size = NET_TCP_BUFFERSIZE_GPRS_READ;
+ wbuf_size = NET_TCP_BUFFERSIZE_GPRS_WRITE;
+ break;
+ default:
+ /* TODO: Check LTE support */
+ rbuf_size = NET_TCP_BUFFERSIZE_DEFAULT_READ;
+ wbuf_size = NET_TCP_BUFFERSIZE_DEFAULT_WRITE;
+ break;
}
+ break;
}
+ } else {
+ DBG("Default TCP buffer configured");
- dbus_message_iter_next(&array);
+ rbuf_size = NET_TCP_BUFFERSIZE_DEFAULT_READ;
+ wbuf_size = NET_TCP_BUFFERSIZE_DEFAULT_WRITE;
}
-done:
- if (message != NULL)
- dbus_message_unref(message);
+ if (rbuf_size != NULL) {
+ fdr = open(NET_PROC_SYS_NET_IPV4_TCP_RMEM, O_RDWR | O_CLOEXEC);
+
+ if (fdr < 0 || write(fdr, rbuf_size, strlen(rbuf_size)) < 0)
+ ERR("Failed to set TCP read buffer size");
+
+ if (fdr >= 0)
+ close(fdr);
+ }
+
+ if (wbuf_size != NULL) {
+ fdw = open(NET_PROC_SYS_NET_IPv4_TCP_WMEM, O_RDWR | O_CLOEXEC);
+
+ if (fdw < 0 || write(fdw, wbuf_size, strlen(wbuf_size)) < 0)
+ ERR("Failed to set TCP write buffer size");
+
+ if (fdw >= 0)
+ close(fdw);
+ }
+
+ /* As default */
+ if (rmax_size == NULL)
+ rmax_size = NET_TCP_BUFFERSIZE_WIFI_RMEM_MAX;
+ if (wmax_size == NULL)
+ wmax_size = NET_TCP_BUFFERSIZE_WIFI_WMEM_MAX;
+
+ if (rmax_size != NULL) {
+ fdrmax = open(NET_PROC_SYS_NET_CORE_RMEM_MAX, O_RDWR | O_CLOEXEC);
+
+ if (fdrmax < 0 || write(fdrmax, rmax_size, strlen(rmax_size)) < 0)
+ ERR("Failed to set TCP rmem_max size");
+
+ if (fdrmax >= 0)
+ close(fdrmax);
+ }
+
+ if (wmax_size != NULL) {
+ fdwmax = open(NET_PROC_SYS_NET_CORE_WMEM_MAX, O_RDWR | O_CLOEXEC);
+
+ if (fdwmax < 0 || write(fdwmax, wmax_size, strlen(wmax_size)) < 0)
+ ERR("Failed to set TCP wmem_max size");
+
+ if (fdwmax >= 0)
+ close(fdwmax);
+ }
}
static void __netconfig_update_default_connection_info(void)
int old_network_status = 0;
const char *profile = netconfig_get_default_profile();
const char *ip_addr = netconfig_get_default_ipaddress();
+ const char *ip_addr6 = netconfig_get_default_ipaddress6();
const char *proxy_addr = netconfig_get_default_proxy();
+ unsigned int freq = netconfig_get_default_frequency();
if (netconfig_emulator_is_emulated() == TRUE)
return;
vconf_get_int(VCONFKEY_NETWORK_STATUS, &old_network_status);
if (profile == NULL && old_network_status != VCONFKEY_NETWORK_OFF) {
- vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_OFF);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_OFF);
- vconf_set_str(VCONFKEY_NETWORK_IP, "");
- vconf_set_str(VCONFKEY_NETWORK_PROXY, "");
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_IP, "");
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_PROXY, "");
- vconf_set_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 0);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 0);
+ netconfig_set_vconf_int("memory/private/wifi/frequency", 0);
DBG("Successfully clear IP and PROXY up");
- } else if (profile != NULL) {
+
+ /* Disable clatd if it is in running state */
+ netconfig_clatd_disable();
+ }
+ else if (profile != NULL) {
char *old_ip = vconf_get_str(VCONFKEY_NETWORK_IP);
char *old_proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
if (netconfig_is_wifi_profile(profile) == TRUE) {
- vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_WIFI);
- } else if (netconfig_is_cellular_profile(profile) == TRUE) {
- vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_CELLULAR);
-
- if (old_network_status != VCONFKEY_NETWORK_CELLULAR)
- __netconfig_pop_3g_alert_syspoppup();
- } else if (netconfig_is_ethernet_profile(profile) == TRUE) {
- vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_ETHERNET);
- } else if (netconfig_is_bluetooth_profile(profile) == TRUE) {
- vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_BLUETOOTH);
- } else {
- vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_OFF);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_WIFI);
+ netconfig_set_vconf_int("memory/private/wifi/frequency", freq);
+ }
+ else if (netconfig_is_cellular_profile(profile) ){
+
+ if( !netconfig_is_cellular_internet_profile(profile)){
+ DBG("connection is not a internet profile - stop to update the cellular state");
+ return;
+ }
+
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_CELLULAR);
+
+ /* Enable clatd if IPv6 is set and no IPv4 address */
+ if (!ip_addr && ip_addr6 )
+ netconfig_clatd_enable();
+ }
+ else if (netconfig_is_ethernet_profile(profile) == TRUE){
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_ETHERNET);
+ }
+ else if (netconfig_is_bluetooth_profile(profile) == TRUE){
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_BLUETOOTH);
+ }
+ else{
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_OFF);
}
- if (g_strcmp0(old_ip, ip_addr) != 0) {
- if (ip_addr == NULL)
- vconf_set_str(VCONFKEY_NETWORK_IP, "");
+ if (g_strcmp0(old_ip, ip_addr) != 0 || old_ip == NULL) {
+ if (ip_addr != NULL)
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_IP, ip_addr);
+ else if (ip_addr6 != NULL)
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_IP, ip_addr6);
else
- vconf_set_str(VCONFKEY_NETWORK_IP, ip_addr);
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_IP, "");
}
+ g_free(old_ip);
if (g_strcmp0(old_proxy, proxy_addr) != 0) {
if (proxy_addr == NULL)
- vconf_set_str(VCONFKEY_NETWORK_PROXY, "");
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_PROXY, "");
else
- vconf_set_str(VCONFKEY_NETWORK_PROXY, proxy_addr);
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_PROXY, proxy_addr);
}
+ g_free(old_proxy);
- vconf_set_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 1);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 1);
DBG("Successfully update default network configuration");
+
+ /* Disable clatd if it is in running state */
+ if (netconfig_is_cellular_profile(profile) != TRUE)
+ netconfig_clatd_disable();
}
+
+ __netconfig_adjust_tcp_buffer_size();
}
-static void __netconfig_network_notify_result(const char *sig_name, const char *key)
+static gboolean __netconfig_is_tech_state_connected(void)
{
- DBusMessage *signals;
- DBusConnection *connection = NULL;
- DBusMessageIter iter, dict_iter, type, value;
- DBusError error;
- const char *prop_key = "key";
+ gboolean ret = FALSE;
+ GVariant *message = NULL, *variant;
+ GVariantIter *iter, *next;
+ gchar *path;
+ gchar *key;
- dbus_error_init(&error);
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "GetTechnologies", NULL);
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
- if (connection == NULL) {
- ERR("Error!!! Failed to get system DBus, error [%s]", error.message);
- dbus_error_free(&error);
+ if (message == NULL) {
+ DBG("Fail to get technology state");
+ return FALSE;
+ }
- return;
+ g_variant_get(message, "(a(oa{sv}))", &iter);
+ while (g_variant_iter_loop(iter, "(oa{sv})", &path, &next)) {
+ if (path == NULL) {
+ continue;
+ }
+
+ while (g_variant_iter_loop(next, "{sv}", &key, &variant)) {
+ gboolean data;
+ if (g_strcmp0(key, "Connected") == 0) {
+ data = g_variant_get_boolean(variant);
+ DBG("%s [%s: %s]", path, key, data ? "True" : "False");
+ if (TRUE == data) {
+ ret = TRUE;
+ g_free(path);
+ g_free(key);
+ g_variant_unref(variant);
+ g_variant_iter_free(next);
+ goto done;
+ }
+ }
+ }
}
- signals = dbus_message_new_signal(NETCONFIG_NETWORK_PATH,
- NETCONFIG_NETWORK_INTERFACE, sig_name);
- if (signals == NULL) {
- dbus_connection_unref(connection);
+done:
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ return ret;
+}
+
+static void __netconfig_update_if_service_connected(void)
+{
+ GVariant *message = NULL, *var;
+ GVariantIter *iter, *next;
+ gchar *path;
+ gchar *key;
+
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "GetServices", NULL);
+
+ if (message == NULL) {
+ ERR("Failed to get services");
return;
}
- dbus_message_iter_init_append(signals, &iter);
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}",
- &dict_iter);
+ g_variant_get(message, "(a(oa{sv}))", &iter);
+ while (g_variant_iter_loop(iter, "(oa{sv})", &path, &next)) {
+ if (path == NULL) {
+ continue;
+ }
+
+ if (g_str_has_prefix(path,
+ CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE) {
+ if (g_strrstr(path + strlen(CONNMAN_WIFI_SERVICE_PROFILE_PREFIX),
+ "hidden") != NULL) {
+ /* skip hidden profiles */
+ continue;
+ }
+ /* Process this */
+ } else if (g_str_has_prefix(path,
+ CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX) == TRUE) {
+ /* Process this */
+ } else {
+ continue;
+ }
+
+ while (g_variant_iter_loop(next, "{sv}", &key, &var)) {
+ if (g_strcmp0(key, "State") == 0) {
+ const gchar *sdata = NULL;
+ sdata = g_variant_get_string(var, NULL);
+ DBG("%s [%s: %s]", path, key, sdata);
+
+ if (g_strcmp0(sdata, "online") == 0 || g_strcmp0(sdata, "ready") == 0) {
+
+ /* Found a connected WiFi / 3G service.
+ * Lets update the default profile info.
+ */
+ netconfig_update_default_profile((const gchar*)path);
+ g_free(key);
+ g_free(path);
+ g_variant_unref(var);
+ g_variant_iter_free(next);
+ goto done;
+ }
+ }
+ }
+ }
+done:
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ return;
+}
+
+static void __netconfig_network_notify_result(const char *sig_name, const char *key)
+{
+ gboolean reply;
+ GVariantBuilder *builder = NULL;
+ GDBusConnection *connection = NULL;
+ GError *error = NULL;
+ const char *prop_key = "key";
+
+ INFO("[Signal] %s %s", sig_name, key);
- /* Packing the key */
- dbus_message_iter_open_container(&dict_iter, DBUS_TYPE_DICT_ENTRY, 0, &type);
- dbus_message_iter_append_basic(&type, DBUS_TYPE_STRING, &prop_key);
- dbus_message_iter_open_container(&type, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &value);
+ connection = netconfig_gdbus_get_connection();
+ if (connection == NULL) {
+ ERR("Failed to get GDBus Connection");
+ return;
+ }
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
+ g_variant_builder_add(builder, "{sv}", prop_key, g_variant_new("(s)", key));
- dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &key);
- dbus_message_iter_close_container(&type, &value);
- dbus_message_iter_close_container(&dict_iter, &type);
+ reply = g_dbus_connection_emit_signal(connection,
+ NULL,
+ NETCONFIG_NETWORK_PATH,
+ NETCONFIG_NETWORK_INTERFACE,
+ sig_name,
+ g_variant_builder_end(builder),
+ &error);
- dbus_message_iter_close_container(&iter, &dict_iter);
+ if (builder)
+ g_variant_builder_unref(builder);
- dbus_connection_send(connection, signals, NULL);
+ if (reply != TRUE) {
+ if (error != NULL) {
+ ERR("Failed to send signal [%s]", error->message);
+ g_error_free(error);
+ }
+ return;
+ }
- dbus_message_unref(signals);
- dbus_connection_unref(connection);
- ERR("Sent signal (%s), key (%s)", sig_name, key);
+ INFO("Sent signal (%s), key (%s)", sig_name, key);
return;
}
return netconfig_default_connection_info.profile;
}
+const char *netconfig_get_default_ifname(void)
+{
+ return netconfig_default_connection_info.ifname;
+}
+
const char *netconfig_get_default_ipaddress(void)
{
return netconfig_default_connection_info.ipaddress;
}
+const char *netconfig_get_default_ipaddress6(void)
+{
+ return netconfig_default_connection_info.ipaddress6;
+}
+
const char *netconfig_get_default_proxy(void)
{
return netconfig_default_connection_info.proxy;
}
+unsigned int netconfig_get_default_frequency(void)
+{
+ return netconfig_default_connection_info.freq;
+}
+
const char *netconfig_wifi_get_connected_essid(const char *default_profile)
{
if (default_profile == NULL)
if (netconfig_is_wifi_profile(default_profile) != TRUE)
return NULL;
- if (g_str_equal(default_profile, netconfig_default_connection_info.profile)
- != TRUE)
+ if (g_strcmp0(default_profile, netconfig_default_connection_info.profile) != 0)
return NULL;
return netconfig_default_connection_info.essid;
}
-void netconfig_set_default_profile(const char *profile)
+static int __netconfig_reset_ipv4_socket(void)
+{
+ int ret;
+ int fd;
+ struct ifreq ifr;
+ struct sockaddr_in sai;
+ const char *ipaddr = netconfig_get_default_ipaddress();
+ DBG("ipaddr-[%s]", ipaddr);
+
+ if (!ipaddr)
+ return -1;
+
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (fd < 0)
+ return -1;
+
+ memset(&sai, 0, sizeof(struct sockaddr_in));
+ sai.sin_family = AF_INET;
+ sai.sin_port = 0;
+ if (!inet_aton(ipaddr, &sai.sin_addr)) {
+ DBG("fail to inet_aton()");
+ close(fd);
+ return -1;
+ }
+
+ memset(&ifr, 0, sizeof(struct ifreq));
+ memcpy(&ifr.ifr_addr, &sai, sizeof(sai));
+ g_strlcpy((char *)ifr.ifr_name, WIFI_IFNAME, IFNAMSIZ);
+
+#ifndef SIOCKILLADDR
+#define SIOCKILLADDR 0x8939
+#endif
+
+ ret = ioctl(fd, SIOCKILLADDR, &ifr);
+ if (ret < 0) {
+ DBG("fail to ioctl[SIOCKILLADDR]");
+ close(fd);
+ return -1;
+ }
+
+ close(fd);
+ return 0;
+}
+
+void netconfig_update_default_profile(const char *profile)
{
- char *default_profile = NULL;
+ static char *old_profile = NULL;
/* It's automatically updated by signal-handler
* DO NOT update manually
*
* It is going to update default connection information
*/
+
if (netconfig_default_connection_info.profile != NULL) {
+
+ if (netconfig_is_wifi_profile(netconfig_default_connection_info.profile))
+ __netconfig_reset_ipv4_socket();
+
+ g_free(old_profile);
+ old_profile = strdup(netconfig_default_connection_info.profile);
+
g_free(netconfig_default_connection_info.profile);
netconfig_default_connection_info.profile = NULL;
g_free(netconfig_default_connection_info.ipaddress);
netconfig_default_connection_info.ipaddress = NULL;
+ g_free(netconfig_default_connection_info.ipaddress6);
+ netconfig_default_connection_info.ipaddress6 = NULL;
+
g_free(netconfig_default_connection_info.proxy);
netconfig_default_connection_info.proxy = NULL;
+ netconfig_default_connection_info.freq = 0;
+
if (netconfig_wifi_state_get_service_state()
!= NETCONFIG_WIFI_CONNECTED) {
g_free(netconfig_default_connection_info.essid);
}
}
- if (profile == NULL) {
- default_profile = __netconfig_get_default_profile();
- if (default_profile == NULL) {
+ //default profile is NULL and new connected profile is NULL
+ if( !profile ){
+ profile = __netconfig_get_default_profile();
+
+ if (profile && netconfig_is_cellular_profile(profile) &&
+ !netconfig_is_cellular_internet_profile(profile)){
+ DBG("not a default cellular profile");
+ profile = NULL;
+ }
+
+ if(!profile){
__netconfig_update_default_connection_info();
return;
}
}
- if (profile != NULL)
- netconfig_default_connection_info.profile = g_strdup(profile);
+ netconfig_default_connection_info.profile = g_strdup(profile);
+ __netconfig_get_default_connection_info(profile);
+ __netconfig_update_default_connection_info();
+
+}
+
+void netconfig_update_default(void)
+{
+ if (__netconfig_is_tech_state_connected() == TRUE)
+ __netconfig_update_if_service_connected();
else
- netconfig_default_connection_info.profile = default_profile;
+ __netconfig_adjust_tcp_buffer_size();
+}
+
+char *netconfig_network_get_ifname(const char *profile)
+{
+ GVariant *message = NULL, *variant;
+ GVariantIter *iter, *next;
+ gchar *key;
+ gchar *key1;
+ const gchar *value = NULL;
+ gchar *ifname = NULL;
- __netconfig_get_default_connection_info(
- netconfig_default_connection_info.profile);
+ if (profile == NULL)
+ return NULL;
- __netconfig_update_default_connection_info();
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, profile,
+ CONNMAN_SERVICE_INTERFACE, "GetProperties", NULL);
+ if (message == NULL) {
+ ERR("Failed to get service properties");
+ return NULL;
+ }
+
+ g_variant_get(message, "(a{sv})", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &key, &next)) {
+ if (g_strcmp0(key, "Ethernet") == 0) {
+ while (g_variant_iter_loop(next, "{sv}", &key1, &variant)) {
+ if (g_strcmp0(key1, "Interface") == 0) {
+ value = g_variant_get_string(variant, NULL);
+ ifname = g_strdup(value);
+ }
+ }
+ }
+ }
+
+ g_variant_unref(message);
+
+ g_variant_iter_free(iter);
+
+ return ifname;
}
/* Check Ethernet Cable Plug-in /Plug-out Status */
void netconfig_network_notify_ethernet_cable_state(const char *key)
{
- __netconfig_network_notify_result("EthernetCableState", key);
+ __netconfig_network_notify_result("EthernetCableState", key);
}
-gboolean netconfig_iface_network_state_add_route(
- NetconfigNetworkState *master,
- gchar *ip_addr, gchar *netmask,
- gchar *interface, gchar *gateway, gint32 address_family, gboolean *result, GError **error)
+static gboolean handle_add_route(
+ Network *object,
+ GDBusMethodInvocation *context,
+ gchar *ip_addr,
+ gchar *netmask,
+ gchar *interface, gchar *gateway, gint address_family)
{
- const char *path = ROUTE_EXEC_PATH;
- char *const args[] = { "/sbin/route", "add", "-net", ip_addr,
+ const gchar *path = ROUTE_EXEC_PATH;
+ gchar *const args[] = { "/sbin/route", "add", "-net", ip_addr,
"netmask", netmask, "dev", interface, NULL };
- char *const envs[] = { NULL };
- const char* buf = NULL;
- char* ch = NULL;
+ gchar *const envs[] = { NULL };
+ const gchar* buf = NULL;
+ gchar* ch = NULL;
int prefix_len = 0;
int pos = 0;
case AF_INET:
if (ip_addr == NULL || netmask == NULL || interface == NULL) {
ERR("Invalid parameter");
- netconfig_error_invalid_parameter(error);
- *result = FALSE;
+ netconfig_error_invalid_parameter(context);
return FALSE;
}
+
if (netconfig_execute_file(path, args, envs) < 0) {
DBG("Failed to add a new route");
- netconfig_error_permission_denied(error);
- *result = FALSE;
+ netconfig_error_permission_denied(context);
return FALSE;
}
+
break;
case AF_INET6:
if (ip_addr == NULL || interface == NULL || gateway == NULL) {
ERR("Invalid parameter");
- netconfig_error_invalid_parameter(error);
- *result = FALSE;
+ netconfig_error_invalid_parameter(context);
return FALSE;
}
if (netconfig_add_route_ipv6(ip_addr, interface, gateway, prefix_len) < 0) {
DBG("Failed to add a new route");
- netconfig_error_permission_denied(error);
- *result = FALSE;
+ netconfig_error_permission_denied(context);
return FALSE;
}
break;
default:
DBG("Unknown Address Family");
- netconfig_error_invalid_parameter(error);
- *result = FALSE;
+ netconfig_error_invalid_parameter(context);
return FALSE;
}
DBG("Successfully added a new route");
- *result = TRUE;
+ network_complete_add_route(object, context, TRUE);
return TRUE;
}
-gboolean netconfig_iface_network_state_remove_route(
- NetconfigNetworkState *master,
- gchar *ip_addr, gchar *netmask,
- gchar *interface, gchar *gateway, gint32 address_family, gboolean *result, GError **error)
+static gboolean handle_remove_route(
+ Network *object,
+ GDBusMethodInvocation *context,
+ gchar *ip_addr,
+ gchar *netmask,
+ gchar *interface, gchar *gateway, gint address_family)
{
const char *path = ROUTE_EXEC_PATH;
- char *const args[] = { "/sbin/route", "del", "-net", ip_addr,
+ gchar *const args[] = { "/sbin/route", "del", "-net", ip_addr,
"netmask", netmask, "dev", interface, NULL };
char *const envs[] = { NULL };
const char* buf = NULL;
case AF_INET:
if (ip_addr == NULL || netmask == NULL || interface == NULL) {
DBG("Invalid parameter!");
- netconfig_error_invalid_parameter(error);
- *result = FALSE;
+ netconfig_error_invalid_parameter(context);
return FALSE;
}
if (netconfig_execute_file(path, args, envs) < 0) {
DBG("Failed to remove the route");
- netconfig_error_permission_denied(error);
- *result = FALSE;
+ netconfig_error_permission_denied(context);
return FALSE;
}
break;
case AF_INET6:
if (ip_addr == NULL || interface == NULL || gateway == NULL) {
DBG("Invalid parameter!");
- netconfig_error_invalid_parameter(error);
- *result = FALSE;
+ netconfig_error_invalid_parameter(context);
return FALSE;
}
if (netconfig_del_route_ipv6(ip_addr, interface, gateway, prefix_len) < 0) {
DBG("Failed to remove the route");
- netconfig_error_permission_denied(error);
- *result = FALSE;
+ netconfig_error_permission_denied(context);
return FALSE;
}
break;
default:
DBG("Unknown Address Family");
- netconfig_error_invalid_parameter(error);
- *result = FALSE;
+ netconfig_error_invalid_parameter(context);
return FALSE;
}
DBG("Successfully removed the route");
- *result = TRUE;
-
+ network_complete_remove_route(object, context, TRUE);
return TRUE;
}
-gboolean netconfig_iface_network_state_ethernet_cable_state(
- NetconfigNetworkState *master, gint32 *state, GError **error)
+static gboolean handle_check_get_privilege(Network *object,
+ GDBusMethodInvocation *context)
{
- int ret = 0;
+ network_complete_check_get_privilege(object, context);
+ return TRUE;
+}
- ret = netconfig_get_ethernet_cable_state(state);
- if(ret != 0) {
- DBG("Failed to get ethernet cable state");
- return FALSE;
- }
- DBG("Successfully get ethernet cable state[%d]", *state);
+static gboolean handle_check_profile_privilege(Network *object,
+ GDBusMethodInvocation *context)
+{
+ network_complete_check_profile_privilege(object, context);
return TRUE;
}
-gpointer netconfig_network_state_create_and_init(DBusGConnection *conn)
+gboolean netconfig_iface_network_state_ethernet_cable_state(gint32 *state)
{
- GObject *object;
-
- g_return_val_if_fail(conn != NULL, NULL);
-
- object = g_object_new(NETCONFIG_TYPE_NETWORK_STATE, "conn", conn, "path",
- NETCONFIG_NETWORK_STATE_PATH, NULL);
+ int ret = 0;
- INFO("create network_state(%p)", object);
+ ret = netconfig_get_ethernet_cable_state(state);
+ if(ret != 0) {
+ DBG("Failed to get ethernet cable state");
+ return FALSE;
+ }
- dbus_g_connection_register_g_object(conn, NETCONFIG_NETWORK_STATE_PATH, object);
+ DBG("Successfully get ethernet cable state[%d]", state);
+ return TRUE;
+}
- INFO("network_state(%p) register DBus path(%s)", object, NETCONFIG_NETWORK_STATE_PATH);
+void netconfig_network_state_create_and_init(void)
+{
+ DBG("Creating network state object");
+ GDBusInterfaceSkeleton *interface = NULL;
+ GDBusConnection *connection = NULL;
+ GDBusObjectManagerServer *server = netconfig_get_state_manager();
+ if (server == NULL)
+ return;
- return object;
+ connection = netconfig_gdbus_get_connection();
+ g_dbus_object_manager_server_set_connection(server, connection);
+
+ /*Interface 1*/
+ netconfigstate = network_skeleton_new();
+
+ interface = G_DBUS_INTERFACE_SKELETON(netconfigstate);
+ g_signal_connect(netconfigstate, "handle-add-route",
+ G_CALLBACK(handle_add_route), NULL);
+ g_signal_connect(netconfigstate, "handle-check-get-privilege",
+ G_CALLBACK(handle_check_get_privilege), NULL);
+ g_signal_connect(netconfigstate, "handle-check-profile-privilege",
+ G_CALLBACK(handle_check_profile_privilege), NULL);
+ g_signal_connect(netconfigstate, "handle-remove-route",
+ G_CALLBACK(handle_remove_route), NULL);
+
+ if (!g_dbus_interface_skeleton_export(interface, connection,
+ NETCONFIG_NETWORK_STATE_PATH, NULL)) {
+ ERR("Export with path failed");
+ }
}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
+#include <stdio.h>
#include <vconf.h>
#include <vconf-keys.h>
-#include "wifi.h"
#include "log.h"
#include "util.h"
#include "netsupplicant.h"
-#include "wifi-indicator.h"
#include "network-statistics.h"
-#include "netconfig-iface-network-statistics-glue.h"
+#include "generated-code.h"
-#define NETCONFIG_NETWORK_STATISTICS_PATH "/net/netconfig/network_statistics"
-
-#define NETCONFIG_PROCDEVFILE "/proc/net/dev"
-
-#define PROP_DEFAULT FALSE
-#define PROP_DEFAULT_STR NULL
-
-enum {
- PROP_O,
- PROP_NETWORK_STATISTICS_CONN,
- PROP_NETWORK_STATISTICS_PATH,
-};
-
-struct NetconfigNetworkStatisticsClass {
- GObjectClass parent;
-};
-
-struct NetconfigNetworkStatistics {
- GObject parent;
-
- DBusGConnection *conn;
- gchar *path;
-};
-
-G_DEFINE_TYPE(NetconfigNetworkStatistics, netconfig_network_statistics, G_TYPE_OBJECT);
-
-static void __netconfig_network_statistics_gobject_get_property(GObject *object,
- guint prop_id, GValue *value, GParamSpec *pspec)
-{
- return;
-}
-
-static void __netconfig_network_statistics_gobject_set_property(GObject *object,
- guint prop_id, const GValue *value, GParamSpec *pspec)
-{
- NetconfigNetworkStatistics *network_statistics = NETCONFIG_NETWORK_STATISTICS(object);
-
- switch (prop_id) {
- case PROP_NETWORK_STATISTICS_CONN:
- {
- network_statistics->conn = g_value_get_boxed(value);
- INFO("network_statistics(%p) set conn(%p)", network_statistics, network_statistics->conn);
- break;
- }
-
- case PROP_NETWORK_STATISTICS_PATH:
- {
- if (network_statistics->path)
- g_free(network_statistics->path);
-
- network_statistics->path = g_value_dup_string(value);
- INFO("network_statistics(%p) path(%s)", network_statistics, network_statistics->path);
-
- break;
- }
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- }
-}
-
-static void netconfig_network_statistics_init(NetconfigNetworkStatistics *network_statistics)
-{
- DBG("network_statistics initialize");
-
- network_statistics->conn = NULL;
- network_statistics->path = g_strdup(PROP_DEFAULT_STR);
-}
-
-static void netconfig_network_statistics_class_init(NetconfigNetworkStatisticsClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
- DBG("class initialize");
-
- object_class->get_property = __netconfig_network_statistics_gobject_get_property;
- object_class->set_property = __netconfig_network_statistics_gobject_set_property;
-
- /* DBus register */
- dbus_g_object_type_install_info(NETCONFIG_TYPE_NETWORK_STATISTICS,
- &dbus_glib_netconfig_iface_network_statistics_object_info);
-
- /* property */
- g_object_class_install_property(object_class, PROP_NETWORK_STATISTICS_CONN,
- g_param_spec_boxed("conn", "CONNECTION", "DBus connection",
- DBUS_TYPE_G_CONNECTION,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property(object_class, PROP_NETWORK_STATISTICS_PATH,
- g_param_spec_string("path", "Path", "Object path",
- PROP_DEFAULT_STR,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-}
+#define NETCONFIG_PROCDEV "/proc/net/dev"
+static Network_statistics *netconfigstatistics = NULL;
gboolean netconfig_wifi_get_bytes_statistics(guint64 *tx, guint64 *rx)
{
gboolean ret = FALSE;
FILE *fp;
gchar buf[1024];
- gchar ifname[16] = { 0, };
gchar *p_ifname = NULL, *p_entry = NULL;
- gchar *ifname_ptr = &ifname[0];
*tx = 0;
*rx = 0;
- if (netconfig_wifi_get_ifname(&ifname_ptr) != TRUE) {
- DBG("Fail to get Wi-Fi ifname from wpa_supplicant: %s", ifname_ptr);
- return FALSE;
- }
-
- fp = fopen(NETCONFIG_PROCDEVFILE, "r");
+ fp = fopen(NETCONFIG_PROCDEV, "r");
if (fp == NULL) {
- ERR("Failed to open file %s", NETCONFIG_PROCDEVFILE);
+ ERR("Failed to open %s", NETCONFIG_PROCDEV);
return FALSE;
}
p_entry = strchr(p_ifname, ':');
*p_entry++ = '\0';
- if (g_str_equal(p_ifname, ifname) != TRUE)
+ if (g_strcmp0(p_ifname, WIFI_IFNAME) != 0)
continue;
/* read interface statistics */
return ret;
}
-gboolean netconfig_iface_network_statistics_get_wifi_total_tx_bytes(NetconfigNetworkStatistics *network_statistics, guint64 *total_bytes, GError **error)
+static gboolean handle_get_wifi_total_tx_bytes(
+ Network_statistics *object,
+ GDBusMethodInvocation *context)
{
guint64 tx = 0, rx = 0;
guint64 tx_bytes = 0;
+ guint64 total_bytes = 0;
int val = 0;
vconf_get_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_SNT, &val);
tx_bytes = (guint64)val;
if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
- *total_bytes = (guint64)tx + (guint64)tx_bytes;
+ total_bytes = tx + tx_bytes;
else
- *total_bytes = (guint64)tx_bytes;
+ total_bytes = tx_bytes;
+ network_statistics_complete_get_wifi_total_tx_bytes(object, context, total_bytes);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_get_wifi_total_rx_bytes(NetconfigNetworkStatistics *network_statistics, guint64 *total_bytes, GError **error)
+static gboolean handle_get_wifi_total_rx_bytes(
+ Network_statistics *object,
+ GDBusMethodInvocation *context)
{
guint64 tx = 0, rx = 0;
guint64 rx_bytes = 0;
+ guint64 total_bytes = 0;
int val = 0;
vconf_get_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_RCV, &val);
rx_bytes = (guint64)val;
if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
- *total_bytes = (guint64)rx + (guint64)rx_bytes;
+ total_bytes = rx + rx_bytes;
else
- *total_bytes = (guint64)rx_bytes;
+ total_bytes = rx_bytes;
+ network_statistics_complete_get_wifi_total_rx_bytes(object, context, total_bytes);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_get_wifi_last_tx_bytes(NetconfigNetworkStatistics *network_statistics, guint64 *last_bytes, GError **error)
+static gboolean handle_get_wifi_last_tx_bytes(
+ Network_statistics *object,
+ GDBusMethodInvocation *context)
{
guint64 tx = 0, rx = 0;
guint64 tx_bytes = 0;
+ guint64 last_bytes = 0;
int val = 0;
vconf_get_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, &val);
tx_bytes = (guint64)val;
if (netconfig_wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED) {
- *last_bytes = (guint64)tx_bytes;
+ last_bytes = tx_bytes;
+ network_statistics_complete_get_wifi_last_tx_bytes(object, context, last_bytes);
return TRUE;
}
if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
- *last_bytes = (((guint64)tx - (guint64)tx_bytes) > (guint64)0) ?
- ((guint64)tx - (guint64)tx_bytes) : (guint64)0;
+ last_bytes = tx < tx_bytes ? 0 : tx - tx_bytes;
else
- *last_bytes = (guint64)tx_bytes;
+ last_bytes = tx_bytes;
+ network_statistics_complete_get_wifi_last_tx_bytes(object, context, last_bytes);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_get_wifi_last_rx_bytes(NetconfigNetworkStatistics *network_statistics, guint64 *last_bytes, GError **error)
+static gboolean handle_get_wifi_last_rx_bytes(
+ Network_statistics *object,
+ GDBusMethodInvocation *context)
{
guint64 tx = 0, rx = 0;
guint64 rx_bytes = 0;
+ guint64 last_bytes = 0;
int val = 0;
vconf_get_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, &val);
rx_bytes = (guint64)val;
if (netconfig_wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED) {
- *last_bytes = (guint64)rx_bytes;
+ last_bytes = rx_bytes;
+ network_statistics_complete_get_wifi_last_rx_bytes(object, context, last_bytes);
return TRUE;
}
if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
- *last_bytes = (((guint64)rx - (guint64)rx_bytes) > (guint64)0) ?
- ((guint64)rx - (guint64)rx_bytes) : (guint64)0;
+ last_bytes = rx < rx_bytes ? 0 : rx - rx_bytes;
else
- *last_bytes = (guint64)rx_bytes;
+ last_bytes = rx_bytes;
+ network_statistics_complete_get_wifi_last_rx_bytes(object, context, last_bytes);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_reset_cellular_total_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+static gboolean handle_reset_cellular_total_tx_bytes(
+ Network_statistics *object,
+ GDBusMethodInvocation *context)
{
- vconf_set_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT, 0);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT, 0);
+ network_statistics_complete_reset_cellular_total_tx_bytes(object, context);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_reset_cellular_total_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+static gboolean handle_reset_cellular_total_rx_bytes(
+ Network_statistics *object,
+ GDBusMethodInvocation *context)
{
- vconf_set_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV, 0);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV, 0);
+ network_statistics_complete_reset_cellular_total_rx_bytes(object, context);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_reset_cellular_last_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+static gboolean handle_reset_cellular_last_tx_bytes(
+ Network_statistics *object,
+ GDBusMethodInvocation *context)
{
- vconf_set_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT, 0);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT, 0);
+ network_statistics_complete_reset_cellular_last_tx_bytes(object, context);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_reset_cellular_last_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+static gboolean handle_reset_cellular_last_rx_bytes(
+ Network_statistics *object,
+ GDBusMethodInvocation *context)
{
- vconf_set_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV, 0);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV, 0);
+ network_statistics_complete_reset_cellular_last_rx_bytes(object, context);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_reset_wifi_total_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+static gboolean handle_reset_wifi_total_tx_bytes(
+ Network_statistics *object,
+ GDBusMethodInvocation *context)
{
guint64 tx = 0, rx = 0;
if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_SNT, -(int)tx);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_SNT, -(int)tx);
else
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_SNT, 0);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_SNT, 0);
+
+ network_statistics_complete_reset_wifi_total_tx_bytes(object, context);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_reset_wifi_total_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+static gboolean handle_reset_wifi_total_rx_bytes(
+ Network_statistics *object,
+ GDBusMethodInvocation *context)
{
guint64 tx = 0, rx = 0;
if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_RCV, -(int)rx);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_RCV, -(int)rx);
else
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_RCV, 0);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_RCV, 0);
+ network_statistics_complete_reset_wifi_total_rx_bytes(object, context);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_reset_wifi_last_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+static gboolean handle_reset_wifi_last_tx_bytes(
+ Network_statistics *object,
+ GDBusMethodInvocation *context)
{
guint64 tx = 0, rx = 0;
if (netconfig_wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED) {
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, 0);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, 0);
+ network_statistics_complete_reset_wifi_last_tx_bytes(object, context);
return TRUE;
}
if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, (int)tx);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, (int)tx);
else
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, 0);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, 0);
+
+ network_statistics_complete_reset_wifi_last_tx_bytes(object, context);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_reset_wifi_last_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+static gboolean handle_reset_wifi_last_rx_bytes(
+ Network_statistics *object,
+ GDBusMethodInvocation *context)
{
guint64 tx = 0, rx = 0;
if (netconfig_wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED) {
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, 0);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, 0);
+ network_statistics_complete_reset_wifi_last_rx_bytes(object, context);
return TRUE;
}
if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, (int)rx);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, (int)rx);
else
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, 0);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, 0);
+
+ network_statistics_complete_reset_wifi_last_rx_bytes(object, context);
return TRUE;
}
total_tx = prev_tx + cur_tx;
total_rx = prev_rx + cur_rx;
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_SNT, (int)total_tx);
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_RCV, (int)total_rx);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_SNT, (int)total_tx);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_RCV, (int)total_rx);
}
static void netconfig_wifi_statistics_update_state(
static enum netconfig_wifi_service_state prev_state = NETCONFIG_WIFI_UNKNOWN;
if (prev_state == NETCONFIG_WIFI_UNKNOWN) {
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, 0);
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, 0);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, 0);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, 0);
prev_state = NETCONFIG_WIFI_IDLE;
return;
vconf_get_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, &val);
last_rx = (guint64)val;
- last_tx = (((guint64)tx - (guint64)last_tx) > (guint64)0) ?
- ((guint64)tx - (guint64)last_tx) : (guint64)0;
- last_rx = (((guint64)rx - (guint64)last_rx) > (guint64)0) ?
- ((guint64)rx - (guint64)last_rx) : (guint64)0;
+ last_tx = tx < last_tx ? 0 : tx - last_tx;
+ last_rx = rx < last_rx ? 0 : rx - last_rx;
}
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, (int)last_tx);
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, (int)last_rx);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, (int)last_tx);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, (int)last_rx);
prev_state = state;
}
.user_data = NULL,
};
-gpointer netconfig_network_statistics_create_and_init(DBusGConnection *conn)
+void netconfig_network_statistics_create_and_init(void)
{
- GObject *object;
-
- g_return_val_if_fail(conn != NULL, NULL);
-
- object = g_object_new(NETCONFIG_TYPE_NETWORK_STATISTICS, "conn", conn, "path",
- NETCONFIG_NETWORK_STATISTICS_PATH, NULL);
-
- INFO("create network_statistics(%p)", object);
-
- dbus_g_connection_register_g_object(conn, NETCONFIG_NETWORK_STATISTICS_PATH, object);
+ DBG("Creating statistics object");
+ GDBusInterfaceSkeleton *interface = NULL;
+ GDBusConnection *connection = NULL;
+ GDBusObjectManagerServer *server = netconfig_get_statistics_manager();
+ if (server == NULL)
+ return;
- INFO("network_statistics(%p) register DBus path(%s)", object, NETCONFIG_NETWORK_STATISTICS_PATH);
+ connection = netconfig_gdbus_get_connection();
+ g_dbus_object_manager_server_set_connection(server, connection);
+
+ /*Interface 1*/
+ netconfigstatistics = network_statistics_skeleton_new();
+
+ interface = G_DBUS_INTERFACE_SKELETON(netconfigstatistics);
+ g_signal_connect(netconfigstatistics, "handle-get-wifi-last-rx-bytes",
+ G_CALLBACK(handle_get_wifi_last_rx_bytes), NULL);
+ g_signal_connect(netconfigstatistics, "handle-get-wifi-last-tx-bytes",
+ G_CALLBACK(handle_get_wifi_last_tx_bytes), NULL);
+ g_signal_connect(netconfigstatistics, "handle-get-wifi-total-rx-bytes",
+ G_CALLBACK(handle_get_wifi_total_rx_bytes), NULL);
+ g_signal_connect(netconfigstatistics, "handle-get-wifi-total-tx-bytes",
+ G_CALLBACK(handle_get_wifi_total_tx_bytes), NULL);
+ g_signal_connect(netconfigstatistics, "handle-reset-cellular-last-rx-bytes",
+ G_CALLBACK(handle_reset_cellular_last_rx_bytes), NULL);
+ g_signal_connect(netconfigstatistics, "handle-reset-cellular-last-tx-bytes",
+ G_CALLBACK(handle_reset_cellular_last_tx_bytes), NULL);
+ g_signal_connect(netconfigstatistics, "handle-reset-cellular-total-rx-bytes",
+ G_CALLBACK(handle_reset_cellular_total_rx_bytes), NULL);
+ g_signal_connect(netconfigstatistics, "handle-reset-cellular-total-tx-bytes",
+ G_CALLBACK(handle_reset_cellular_total_tx_bytes), NULL);
+ g_signal_connect(netconfigstatistics, "handle-reset-wifi-last-rx-bytes",
+ G_CALLBACK(handle_reset_wifi_last_rx_bytes), NULL);
+ g_signal_connect(netconfigstatistics, "handle-reset-wifi-last-tx-bytes",
+ G_CALLBACK(handle_reset_wifi_last_tx_bytes), NULL);
+ g_signal_connect(netconfigstatistics, "handle-reset-wifi-total-rx-bytes",
+ G_CALLBACK(handle_reset_wifi_total_rx_bytes), NULL);
+ g_signal_connect(netconfigstatistics, "handle-reset-wifi-total-tx-bytes",
+ G_CALLBACK(handle_reset_wifi_total_tx_bytes), NULL);
+
+ if (!g_dbus_interface_skeleton_export(interface, connection,
+ NETCONFIG_NETWORK_STATISTICS_PATH, NULL)) {
+ ERR("Export with path failed");
+ }
netconfig_wifi_statistics_update_state(NETCONFIG_WIFI_IDLE, NULL);
netconfig_wifi_state_notifier_register(&state_notifier);
- return object;
+ return;
}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <stdio.h>
#include <string.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
#include <vconf.h>
#include <vconf-keys.h>
#include "log.h"
#include "util.h"
#include "netdbus.h"
-#include "netsupplicant.h"
+#include "neterror.h"
+#include "wifi-wps.h"
+#include "wifi-agent.h"
+#include "wifi-power.h"
#include "wifi-state.h"
-#include "wifi-indicator.h"
+#include "netsupplicant.h"
+#include "network-state.h"
+#include "cellular-state.h"
+#include "signal-handler.h"
#include "wifi-ssid-scan.h"
#include "wifi-background-scan.h"
-#include "network-state.h"
-#include "neterror.h"
-#include "wifi.h"
-#include "wifi-power.h"
-
-#define SIGNAL_SCAN_DONE "ScanDone"
-#define SIGNAL_BSS_ADDED "BSSAdded"
-#define SIGNAL_PROPERTIES_CHANGED "PropertiesChanged"
+#if defined TIZEN_DEBUG_DISABLE
+#include "wifi-dump.h"
+#endif
+
+#define DBUS_SERVICE_DBUS "org.freedesktop.DBus"
+#define DBUS_INTERFACE_DBUS "org.freedesktop.DBus"
+#define SIGNAL_INTERFACE_REMOVED "InterfaceRemoved"
+#define SIGNAL_SCAN_DONE "ScanDone"
+#define SIGNAL_BSS_ADDED "BSSAdded"
+#define SIGNAL_PROPERTIES_CHANGED "PropertiesChanged"
+#define SIGNAL_PROPERTIES_DRIVER_HANGED "DriverHanged"
+#define SIGNAL_PROPERTIES_SESSION_OVERLAPPED "SessionOverlapped"
#define CONNMAN_SIGNAL_SERVICES_CHANGED "ServicesChanged"
#define CONNMAN_SIGNAL_PROPERTY_CHANGED "PropertyChanged"
-
-#define CONNMAN_MANAGER_SIGNAL_FILTER "type='signal',interface='net.connman.Manager'"
-#define CONNMAN_TECHNOLOGY_SIGNAL_FILTER "type='signal',interface='net.connman.Technology'"
-#define CONNMAN_SERVICE_SIGNAL_FILTER "type='signal',interface='net.connman.Service'"
-#define SUPPLICANT_INTERFACE_SIGNAL_FILTER "type='signal',interface='fi.w1.wpa_supplicant1.Interface'"
-
-
-static DBusConnection *signal_connection = NULL;
-
-static char *__netconfig_get_property(DBusMessage *msg, int *prop_value)
-{
- DBusMessageIter args, variant;
- char *property = NULL;
- dbus_bool_t data;
-
- /** read these parameters */
- if (!dbus_message_iter_init(msg, &args)) {
- ERR("Message does not have parameters");
- } else if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING) {
- ERR("Argument is not string");
- } else {
- dbus_message_iter_get_basic(&args, &property);
- dbus_message_iter_next(&args);
- dbus_message_iter_recurse(&args, &variant);
- /* Right now, checking for only 'Powered' property which has
- * Boolean type values
- */
- if (dbus_message_iter_get_arg_type(&variant) == DBUS_TYPE_BOOLEAN) {
- dbus_message_iter_get_basic(&variant, &data);
- if (data)
- *prop_value = TRUE;
- else
- *prop_value = FALSE;
- } else {
- *prop_value = FALSE;
- }
- }
-
- return property;
-}
-
-static void __netconfig_technology_signal_handler(DBusMessage *msg)
+#define CONNMAN_SIGNAL_NAME_CHANGED "NameOwnerChanged"
+
+#define MAX_SIG_LEN 64
+#define TOTAL_CONN_SIGNALS 3
+
+typedef enum {
+ SIG_INTERFACE_REMOVED = 0,
+ SIG_PROPERTIES_CHANGED,
+ SIG_BSS_ADDED,
+ SIG_SCAN_DONE,
+ SIG_DRIVER_HANGED,
+ SIG_SESSION_OVERLAPPED,
+ SIG_MAX
+} SuppSigArrayIndex;
+
+static int conn_subscription_ids[TOTAL_CONN_SIGNALS] = {0};
+static const char supp_signals[SIG_MAX][MAX_SIG_LEN] = {
+ SIGNAL_INTERFACE_REMOVED,
+ SIGNAL_PROPERTIES_CHANGED,
+ SIGNAL_BSS_ADDED,
+ SIGNAL_SCAN_DONE,
+ SIGNAL_PROPERTIES_DRIVER_HANGED,
+ SIGNAL_PROPERTIES_SESSION_OVERLAPPED,
+};
+
+static int supp_subscription_ids[SIG_MAX] = {0};
+static int dumpservice_subscription_id = 0;
+
+typedef void (*netconfig_supplicant_signal_handler)(GDBusConnection *conn,
+ const gchar *name, const gchar *path, const gchar *interface,
+ const gchar *sig, GVariant *param, gpointer user_data);
+typedef void (*netconfig_connman_signal_handler)(GDBusConnection *conn,
+ const gchar *name, const gchar *path, const gchar *interface,
+ const gchar *sig, GVariant *param, gpointer user_data);
+
+static void __netconfig_technology_signal_handler(GDBusConnection *conn,
+ const gchar *name, const gchar *path, const gchar *interface,
+ const gchar *sig, GVariant *param, gpointer user_data)
{
- char *key = NULL;
- const char *tech = NULL;
- dbus_bool_t value = FALSE;
-
- if (netconfig_dbus_get_basic_params_string(msg,
- &key, DBUS_TYPE_BOOLEAN, &value) != TRUE)
- return;
+ const char *key = NULL;
+ gboolean value = FALSE;
+ GVariant *var;
- tech = dbus_message_get_path(msg);
- if (key == NULL || tech == NULL)
+ if (param == NULL)
return;
- if (g_str_has_prefix(tech, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == TRUE) {
- INFO("Wi-Fi Technology %s, property %d", key, value);
-
+ if (g_str_has_prefix(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == TRUE) {
+ g_variant_get(param, "(sv)", &key, &var);
if (g_strcmp0(key, "Powered") == 0) {
/* Power state */
- if (value == TRUE)
+ value = g_variant_get_boolean(var);
+ if (value == TRUE) {
netconfig_wifi_update_power_state(TRUE);
- else
+ } else {
netconfig_wifi_update_power_state(FALSE);
-
- netconfig_set_power_in_progress(FALSE);
- netconfig_check_fm_waiting();
+ }
} else if (g_strcmp0(key, "Connected") == 0) {
/* Connection state */
+ netconfig_wifi_state_set_technology_state(
+ NETCONFIG_WIFI_TECH_CONNECTED);
} else if (g_strcmp0(key, "Tethering") == 0) {
/* Tethering state */
- if (value == TRUE)
- netconfig_wifi_update_power_state(FALSE);
- else
- netconfig_wifi_update_power_state(TRUE);
+ netconfig_wifi_state_set_technology_state(
+ NETCONFIG_WIFI_TECH_TETHERED);
}
- } else if (g_str_has_prefix(tech,
- CONNMAN_CELLULAR_TECHNOLOGY_PREFIX) == TRUE) {
- /* Cellular technology state */
}
}
-static void __netconfig_wifi_service_state_signal_handler(DBusMessage *msg)
+static void __netconfig_service_signal_handler(GDBusConnection *conn,
+ const gchar *name, const gchar *path,
+ const gchar *interface, const gchar *sig, GVariant *param, gpointer user_data)
{
- char *sigvalue = NULL;
- char *property = NULL;
- char *service_profile = NULL;
- DBusMessageIter args, variant;
+ gchar *sigvalue = NULL;
+ gchar *property;
+ GVariant *variant = NULL, *var;
+ GVariantIter *iter;
+ const gchar *value = NULL;
- service_profile = (char *)dbus_message_get_path(msg);
- if (service_profile == NULL)
- return;
+ if (path == NULL || param == NULL)
+ goto done;
- dbus_message_iter_init(msg, &args);
- dbus_message_iter_get_basic(&args, &sigvalue);
+ g_variant_get(param, "(sv)", &sigvalue, &variant);
if (sigvalue == NULL)
- return;
+ goto done;
+
+ if (g_strcmp0(sig, CONNMAN_SIGNAL_PROPERTY_CHANGED) != 0) {
+ goto done;
+ }
- if (g_str_equal(sigvalue, "State") == TRUE) {
- dbus_message_iter_next(&args);
- dbus_message_iter_recurse(&args, &variant);
- dbus_message_iter_get_basic(&variant, &property);
+ if (g_strcmp0(sigvalue, "State") == 0) {
+ g_variant_get(variant, "s", &property);
- DBG("[%s] %s", property, service_profile);
- if (netconfig_is_wifi_profile(service_profile) == TRUE) {
+ DBG("[%s] %s", property, path);
+ if (netconfig_is_wifi_profile(path) == TRUE) {
int wifi_state = 0;
vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
if (wifi_state == VCONFKEY_WIFI_OFF)
- return;
+ goto done;
- if (g_str_equal(property, "ready") == TRUE ||
- g_str_equal(property, "online") == TRUE) {
+ if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
if (wifi_state >= VCONFKEY_WIFI_CONNECTED)
- return;
+ goto done;
- netconfig_set_default_profile(service_profile);
+ netconfig_update_default_profile(path);
netconfig_wifi_state_set_service_state(NETCONFIG_WIFI_CONNECTED);
- } else if (g_str_equal(property, "failure") == TRUE ||
- g_str_equal(property, "disconnect") == TRUE ||
- g_str_equal(property, "idle") == TRUE) {
+ } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
if (netconfig_get_default_profile() == NULL ||
netconfig_is_wifi_profile(netconfig_get_default_profile())
!= TRUE) {
- netconfig_wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
- return;
+ if (g_strcmp0(property, "failure") == 0)
+ netconfig_wifi_state_set_service_state(
+ NETCONFIG_WIFI_FAILURE);
+ else
+ netconfig_wifi_state_set_service_state(
+ NETCONFIG_WIFI_IDLE);
+ goto done;
}
- if (g_str_equal(service_profile, netconfig_get_default_profile()) != TRUE)
- return;
+ if (g_strcmp0(path, netconfig_get_default_profile()) != 0)
+ goto done;
- netconfig_set_default_profile(NULL);
+ netconfig_update_default_profile(NULL);
- netconfig_wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
+ if (g_strcmp0(property, "failure") == 0)
+ netconfig_wifi_state_set_service_state(
+ NETCONFIG_WIFI_FAILURE);
+ else
+ netconfig_wifi_state_set_service_state(
+ NETCONFIG_WIFI_IDLE);
- } else if (g_str_equal(property, "association") == TRUE ||
- g_str_equal(property, "configuration") == TRUE) {
+ } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
if (netconfig_get_default_profile() == NULL ||
- netconfig_is_wifi_profile(netconfig_get_default_profile())
- != TRUE) {
- netconfig_wifi_state_set_service_state(NETCONFIG_WIFI_CONNECTING);
- return;
+ netconfig_is_wifi_profile(netconfig_get_default_profile()) != TRUE) {
+ if (g_strcmp0(property, "association") == 0)
+ netconfig_wifi_state_set_service_state(
+ NETCONFIG_WIFI_ASSOCIATION);
+ else
+ netconfig_wifi_state_set_service_state(
+ NETCONFIG_WIFI_CONFIGURATION);
+ goto done;
}
- if (g_str_equal(service_profile, netconfig_get_default_profile()) != TRUE)
- return;
+ if (g_strcmp0(path, netconfig_get_default_profile()) != 0)
+ goto done;
+
+ netconfig_update_default_profile(NULL);
- netconfig_set_default_profile(NULL);
+ if (g_strcmp0(property, "association") == 0)
+ netconfig_wifi_state_set_service_state(
+ NETCONFIG_WIFI_ASSOCIATION);
+ else
+ netconfig_wifi_state_set_service_state(
+ NETCONFIG_WIFI_CONFIGURATION);
- netconfig_wifi_state_set_service_state(NETCONFIG_WIFI_CONNECTING);
}
} else {
- if (g_str_equal(property, "ready") == TRUE ||
- g_str_equal(property, "online") == TRUE) {
- if (netconfig_get_default_profile() == NULL)
- netconfig_set_default_profile(service_profile);
-
- } else if (g_str_equal(property, "failure") == TRUE ||
- g_str_equal(property, "disconnect") == TRUE ||
- g_str_equal(property, "idle") == TRUE) {
+ if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
+ if (netconfig_get_default_profile() == NULL) {
+ if(!netconfig_is_cellular_profile(path)) {
+ netconfig_update_default_profile(path);
+ } else {
+ if (netconfig_is_cellular_internet_profile(path)) {
+ netconfig_update_default_profile(path);
+ netconfig_cellular_state_set_service_state(NETCONFIG_CELLULAR_ONLINE);
+ }
+ }
+ }
+ } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
if (netconfig_get_default_profile() == NULL)
- return;
+ goto done;
- if (g_str_equal(service_profile, netconfig_get_default_profile()) != TRUE)
- return;
+ if (netconfig_is_cellular_profile(path) == TRUE)
+ netconfig_cellular_state_set_service_state(NETCONFIG_CELLULAR_IDLE);
- netconfig_set_default_profile(NULL);
+ if (g_strcmp0(path, netconfig_get_default_profile()) != 0)
+ goto done;
- } else if (g_str_equal(property, "association") == TRUE ||
- g_str_equal(property, "configuration") == TRUE) {
+ netconfig_update_default_profile(NULL);
+ } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
if (netconfig_get_default_profile() == NULL)
- return;
+ goto done;
- if (g_str_equal(service_profile, netconfig_get_default_profile()) != TRUE)
- return;
+ if (netconfig_is_cellular_profile(path) == TRUE)
+ netconfig_cellular_state_set_service_state(NETCONFIG_CELLULAR_CONNECTING);
- netconfig_set_default_profile(NULL);
+ if (g_strcmp0(path, netconfig_get_default_profile()) != 0)
+ goto done;
+
+ netconfig_update_default_profile(NULL);
+ }
+ }
+ } else if (g_strcmp0(sigvalue, "Proxy") == 0) {
+ if (netconfig_is_wifi_profile(path) != TRUE || g_strcmp0(path, netconfig_get_default_profile()) != 0)
+ goto done;
+
+ if (!g_variant_type_equal(variant, G_VARIANT_TYPE_ARRAY))
+ goto done;
+
+ g_variant_get(variant, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &property, &var)) {
+ if (g_strcmp0(property, "Servers") == 0) {
+ GVariantIter *iter_sub = NULL;
+
+ g_variant_get(var, "as", &iter_sub);
+ g_variant_iter_loop(iter_sub, "s", &value);
+ g_variant_iter_free(iter_sub);
+
+ DBG("Proxy - [%s]", value);
+ vconf_set_str(VCONFKEY_NETWORK_PROXY, value);
+
+ g_free(property);
+ g_variant_unref(var);
+ break;
+ } else if (g_strcmp0(property, "Method") == 0) {
+ value = g_variant_get_string(var, NULL);
+ DBG("Method - [%s]", value);
+
+ if (g_strcmp0(value, "direct") == 0)
+ vconf_set_str(VCONFKEY_NETWORK_PROXY, "");
+
+ g_free(property);
+ g_variant_unref(var);
+ break;
}
}
+
+ g_variant_iter_free(iter);
+ } else if (g_strcmp0(sigvalue, "Error") == 0) {
+ g_variant_get(variant, "s", &property);
+ INFO("[%s] Property : %s", sigvalue, property);
}
+done:
+ if (sigvalue)
+ g_free(sigvalue);
+
+ if (variant)
+ g_variant_unref(variant);
+
+ return;
}
-static DBusHandlerResult __netconfig_signal_filter_handler(
- DBusConnection *conn, DBusMessage *msg, void *user_data)
+static void __netconfig_dbus_name_changed_signal_handler(GDBusConnection *conn,
+ const gchar *Name, const gchar *path, const gchar *interface,
+ const gchar *sig, GVariant *param, gpointer user_data)
{
- char *sigvalue = NULL;
+ char *name, *old, *new;
- if (msg == NULL) {
- DBG("Invalid Message. Ignore");
- return DBUS_HANDLER_RESULT_HANDLED;
- }
+ if (param == NULL)
+ return;
- if (dbus_message_is_signal(msg, CONNMAN_MANAGER_INTERFACE,
- CONNMAN_SIGNAL_PROPERTY_CHANGED)) {
- /* We have handled this message, don't pass it on */
- return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_signal(msg, CONNMAN_TECHNOLOGY_INTERFACE,
- CONNMAN_SIGNAL_PROPERTY_CHANGED)) {
- __netconfig_technology_signal_handler(msg);
-
- return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_signal(msg, CONNMAN_SERVICE_INTERFACE,
- CONNMAN_SIGNAL_PROPERTY_CHANGED)) {
- __netconfig_wifi_service_state_signal_handler(msg);
-
- return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_signal(msg, CONNMAN_MANAGER_INTERFACE,
- CONNMAN_SIGNAL_SERVICES_CHANGED)) {
- DBG("Received CONNMAN_SIGNAL_SERVICES_CHANGED message");
- netconfig_wifi_check_network_notification(msg);
-
- return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_signal(msg, SUPPLICANT_INTERFACE ".Interface",
- SIGNAL_PROPERTIES_CHANGED)) {
- dbus_bool_t scanning = FALSE;
- void *property = &scanning;
-
- if (netconfig_dbus_get_basic_params_array(msg,
- &sigvalue, &property) != TRUE)
- return DBUS_HANDLER_RESULT_HANDLED;
-
- if (sigvalue == NULL)
- return DBUS_HANDLER_RESULT_HANDLED;
-
- if (scanning == TRUE)
- netconfig_wifi_set_scanning(TRUE);
-
- return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_signal(msg, SUPPLICANT_INTERFACE ".Interface",
- SIGNAL_BSS_ADDED)) {
- if (netconfig_wifi_get_ssid_scan_state() == TRUE)
- netconfig_wifi_bss_added(msg);
-
- return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_signal(msg, SUPPLICANT_INTERFACE ".Interface",
- SIGNAL_SCAN_DONE)) {
- netconfig_wifi_set_scanning(FALSE);
-
- if (netconfig_wifi_get_bgscan_state() != TRUE) {
- if (netconfig_wifi_get_ssid_scan_state() == TRUE)
- netconfig_wifi_notify_ssid_scan_done();
- else
- netconfig_wifi_ssid_scan(NULL);
- }
+ g_variant_get(param, "(sss)", &name, &old, &new);
+
+ if (g_strcmp0(name, CONNMAN_SERVICE) == 0 && *new == '\0') {
+ DBG("ConnMan destroyed: name %s, old %s, new %s", name, old, new);
- return DBUS_HANDLER_RESULT_HANDLED;
+ netconfig_agent_register();
}
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ return;
}
-void netconfig_register_signal(void)
+static void __netconfig_supplicant_interface_removed(GDBusConnection *conn,
+ const gchar *name, const gchar *path, const gchar *interface,
+ const gchar *sig, GVariant *param, gpointer user_data)
{
- DBusConnection *conn = NULL;
- DBusError err;
+ DBG("Interface removed handling!");
+ if (netconfig_wifi_is_wps_enabled() == TRUE)
+ netconfig_wifi_wps_signal_scanaborted();
- DBG("Register DBus signal filters");
+ return;
+}
- dbus_error_init(&err);
- conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
- if (conn == NULL) {
- ERR("Error! Failed to connect to the D-BUS daemon: [%s]",
- err.message);
- dbus_error_free(&err);
+static void __netconfig_supplicant_properties_changed(GDBusConnection *conn,
+ const gchar *name, const gchar *path, const gchar *interface,
+ const gchar *sig, GVariant *param, gpointer user_data)
+{
+ DBG("Properties changed handling!");
+ gchar *key;
+ GVariantIter *iter;
+ GVariant *variant;
+ gboolean scanning = FALSE;
+
+ if (param == NULL)
return;
+
+ g_variant_get(param, "(a{sv})", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
+ if (g_strcmp0(key, "Scanning") == 0) {
+ scanning = g_variant_get_boolean(variant);
+ if (scanning == TRUE)
+ netconfig_wifi_set_scanning(TRUE);
+
+ g_variant_unref(variant);
+ g_free(key);
+ break;
+ }
}
- signal_connection = conn;
+ g_variant_iter_free(iter);
- dbus_connection_setup_with_g_main(conn, NULL);
+ return;
+}
- /* listening to messages from all objects as no path is specified */
- /* see signals from the given interface */
- dbus_bus_add_match(conn, CONNMAN_MANAGER_SIGNAL_FILTER, &err);
- dbus_connection_flush(conn);
- if (dbus_error_is_set(&err)) {
- ERR("Error! Match Error (%s)", err.message);
- dbus_error_free(&err);
- return;
+static void __netconfig_supplicant_bss_added(GDBusConnection *conn,
+ const gchar *name, const gchar *path, const gchar *interface,
+ const gchar *sig, GVariant *param, gpointer user_data)
+{
+ DBG("BSS added handling!");
+ if (netconfig_wifi_get_ssid_scan_state() == TRUE)
+ netconfig_wifi_bss_added(param);
+ else
+ netconfig_wifi_set_bss_found(TRUE);
+
+ return;
+}
+
+static void __netconfig_supplicant_scan_done(GDBusConnection *conn,
+ const gchar *name, const gchar *path, const gchar *interface,
+ const gchar *sig, GVariant *param, gpointer user_data)
+{
+ DBG("Scan Done handling!");
+ netconfig_wifi_set_scanning(FALSE);
+
+ if (netconfig_wifi_is_wps_enabled() == TRUE) {
+ netconfig_wifi_wps_signal_scandone();
+ if (netconfig_wifi_state_get_technology_state() <
+ NETCONFIG_WIFI_TECH_POWERED)
+ return;
}
- dbus_bus_add_match(conn, CONNMAN_TECHNOLOGY_SIGNAL_FILTER, &err);
- dbus_connection_flush(conn);
- if (dbus_error_is_set(&err)) {
- ERR("Error! Match Error (%s)", err.message);
- dbus_error_free(&err);
- return;
+ if (netconfig_wifi_get_bgscan_state() != TRUE) {
+ if (netconfig_wifi_get_ssid_scan_state() == TRUE)
+ netconfig_wifi_notify_ssid_scan_done();
+ else
+ netconfig_wifi_ssid_scan(NULL);
+ } else {
+ if (netconfig_wifi_state_get_technology_state() >=
+ NETCONFIG_WIFI_TECH_POWERED)
+ netconfig_wifi_bgscan_start(FALSE);
+
+ netconfig_wifi_start_timer_network_notification();
}
- dbus_bus_add_match(conn, CONNMAN_SERVICE_SIGNAL_FILTER, &err);
- dbus_connection_flush(conn);
- if (dbus_error_is_set(&err)) {
- ERR("Error! Match Error (%s)", err.message);
- dbus_error_free(&err);
+ return;
+}
+
+static void __netconfig_supplicant_driver_hanged(GDBusConnection *conn,
+ const gchar *name, const gchar *path, const gchar *interface,
+ const gchar *sig, GVariant *param, gpointer user_data)
+{
+ DBG("Driver Hanged handling!");
+ ERR("Critical. Wi-Fi firmware crashed");
+
+ netconfig_wifi_recover_firmware();
+
+ return;
+}
+
+static void __netconfig_supplicant_session_overlapped(GDBusConnection *conn,
+ const gchar *name, const gchar *path, const gchar *interface,
+ const gchar *sig, GVariant *param, gpointer user_data)
+{
+ DBG("Driver session overlapped handling!");
+ ERR("WPS PBC SESSION OVERLAPPED");
+#if defined TIZEN_WEARABLE
+ wc_launch_syspopup(WC_POPUP_TYPE_SESSION_OVERLAPPED);
+#else
+ netconfig_send_message_to_net_popup("WPS Error",
+ "wps session overlapped", "popup", NULL);
+#endif
+}
+
+static netconfig_supplicant_signal_handler supp_handlers[SIG_MAX] = {
+ __netconfig_supplicant_interface_removed,
+ __netconfig_supplicant_properties_changed,
+ __netconfig_supplicant_bss_added,
+ __netconfig_supplicant_scan_done,
+ __netconfig_supplicant_driver_hanged,
+ __netconfig_supplicant_session_overlapped
+};
+
+#if defined TIZEN_DEBUG_DISABLE
+static void __netconfig_dumpservice_handler(GDBusConnection *conn,
+ const gchar *name, const gchar *path, const gchar *interface,
+ const gchar *sig, GVariant *param, gpointer user_data)
+{
+ int mode;
+ gchar *signal_path = NULL;
+
+ if (param == NULL)
return;
- }
- dbus_bus_add_match(conn, SUPPLICANT_INTERFACE_SIGNAL_FILTER, &err);
- dbus_connection_flush(conn);
- if (dbus_error_is_set(&err)) {
- ERR("Error! Match Error (%s)", err.message);
- dbus_error_free(&err);
+ g_variant_get(param, "(io)", &mode, &signal_path);
+ DBG("Path: %s and mode: %d", signal_path, mode);
+ netconfig_dump_log(path);
+
+ return;
+}
+#endif
+
+void netconfig_register_signal(void)
+{
+ GDBusConnection *connection = NULL;
+ const char *interface = NULL;
+ SuppSigArrayIndex sig;
+ connection = netconfig_gdbus_get_connection();
+
+ if (connection == NULL) {
+ ERR("Failed to get GDbus Connection");
return;
}
- if (dbus_connection_add_filter(conn,
- __netconfig_signal_filter_handler, NULL, NULL) == FALSE) {
- ERR("Error! dbus_connection_add_filter() failed");
- return;
+ /* listening to messages from all objects as no path is specified */
+ /* see signals from the given interface */
+ conn_subscription_ids[0] = g_dbus_connection_signal_subscribe(
+ connection,
+ CONNMAN_SERVICE,
+ CONNMAN_TECHNOLOGY_INTERFACE,
+ NULL,
+ NULL,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __netconfig_technology_signal_handler,
+ NULL,
+ NULL);
+
+ conn_subscription_ids[1] = g_dbus_connection_signal_subscribe(
+ connection,
+ CONNMAN_SERVICE,
+ CONNMAN_SERVICE_INTERFACE,
+ CONNMAN_SIGNAL_PROPERTY_CHANGED,
+ NULL,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __netconfig_service_signal_handler,
+ NULL,
+ NULL);
+
+ conn_subscription_ids[2] = g_dbus_connection_signal_subscribe(
+ connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_INTERFACE_DBUS,
+ CONNMAN_SIGNAL_NAME_CHANGED,
+ NULL,
+ CONNMAN_SERVICE,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __netconfig_dbus_name_changed_signal_handler,
+ NULL,
+ NULL);
+
+ INFO("Successfully register connman DBus signal filters");
+
+ for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
+ /*
+ * For SIG_INTERFACE_REMOVED INTERFACE_ADDED
+ */
+ interface = (sig == SIG_INTERFACE_REMOVED) ?
+ SUPPLICANT_INTERFACE : SUPPLICANT_IFACE_INTERFACE;
+
+ supp_subscription_ids[sig] = g_dbus_connection_signal_subscribe(
+ connection,
+ SUPPLICANT_SERVICE,
+ interface,
+ supp_signals[sig],
+ NULL,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ supp_handlers[sig],
+ NULL,
+ NULL);
}
- INFO("Successfully register signal filters");
+ INFO("Successfully register Supplicant DBus signal filters");
+
+#if defined TIZEN_DEBUG_DISABLE
+ dumpservice_subscription_id = g_dbus_connection_signal_subscribe(
+ connection,
+ /*
+ * Sender => For testing purpose made NULL
+ *WPA_SUPPLICANT,
+ */
+ NULL,
+ DUMP_SERVICE_INTERFACE,
+ DUMP_SIGNAL,
+ NULL,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __netconfig_dumpservice_handler,
+ NULL,
+ NULL);
+
+ INFO("Successfully register Dumpservice DBus signal filter");
+#endif
+ /* In case ConnMan precedes this signal register,
+ * net-config should update the default connected profile.
+ */
+ netconfig_update_default();
}
void netconfig_deregister_signal(void)
{
- if (signal_connection == NULL) {
- ERR("Error! Already de-registered. Nothing to be done");
+ GDBusConnection *connection = NULL;
+ int signal;
+ SuppSigArrayIndex sig;
+ connection = netconfig_gdbus_get_connection();
+ if (!connection) {
+ ERR("Already de-registered. Nothing to be done");
return;
}
- dbus_connection_remove_filter(signal_connection,
- __netconfig_signal_filter_handler, NULL);
- INFO("Successfully remove DBus signal filters");
+ for (signal = 0; signal < TOTAL_CONN_SIGNALS; signal++) {
+ if (conn_subscription_ids[signal]) {
+ g_dbus_connection_signal_unsubscribe(connection,
+ conn_subscription_ids[signal]);
+ }
+ }
- dbus_connection_unref(signal_connection);
- signal_connection = NULL;
+ for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
+ if (supp_subscription_ids[sig]) {
+ g_dbus_connection_signal_unsubscribe(connection,
+ supp_subscription_ids[sig]);
+ }
+ }
- netconfig_wifi_deinit_bgscan();
+ g_dbus_connection_signal_unsubscribe(connection,
+ dumpservice_subscription_id);
}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
+#include <vconf.h>
+#include <net/if.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
-#include <net/if.h>
-#include <sys/utsname.h>
-#include <vconf.h>
#include <vconf-keys.h>
+#include <system_info.h>
#include "log.h"
#include "emulator.h"
+#include "util.h"
static gboolean netconfig_is_emulated = FALSE;
static gboolean __netconfig_emulator_test_emulation_env(void)
{
- struct utsname buf;
- const char *EMUL_UTSNAME_MACHINE_SUFFIX = "emulated";
+ int ret;
+ char *model = NULL;
DBG("Test emulation environment");
- if (uname(&buf) != 0)
+ ret = system_info_get_platform_string("tizen.org/system/model_name", &model);
+ if (ret != SYSTEM_INFO_ERROR_NONE) {
+ ERR("Failed to get system information(%d)", ret);
return FALSE;
+ }
- if (g_str_has_suffix(buf.machine, EMUL_UTSNAME_MACHINE_SUFFIX) == TRUE)
+ if (model && strncmp(model, "Emulator", strlen("Emulator")) == 0) {
+ free(model);
return TRUE;
+ }
+
+ if (model)
+ free(model);
return FALSE;
}
static void __netconfig_emulator_set_ip(void)
{
- const int BUF_LEN_MAX = 255;
const char EMUL_IFNAME[] = "eth0";
- char ip[BUF_LEN_MAX];
+ char ip[30] = { 0, };
int sockfd = 0;
struct ifreq ifr;
- if ((sockfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
+ sockfd = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+ if (sockfd < 0) {
ERR("Failed to open socket");
return;
}
memset(&ifr, 0, sizeof(struct ifreq));
- g_strlcpy((char*)&ifr.ifr_name, EMUL_IFNAME, sizeof(EMUL_IFNAME));
+ g_strlcpy((char *)ifr.ifr_name, EMUL_IFNAME, 16);
if (ioctl(sockfd, SIOCGIFADDR, &ifr) < 0) {
- ERR("Error getting IP address");
+ ERR("Failed to get IP address");
close(sockfd);
return;
}
- g_strlcpy(ip, (char*)inet_ntoa(((struct sockaddr_in*)&ifr.ifr_addr)->sin_addr), BUF_LEN_MAX);
+ close(sockfd);
- vconf_set_str(VCONFKEY_NETWORK_IP, ip);
+ g_strlcpy(ip,
+ inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr), 30);
- close(sockfd);
+ vconf_set_str(VCONFKEY_NETWORK_IP, ip);
}
static void __netconfig_emulator_set_proxy(void)
const char HTTP_PROXY[] = "http_proxy";
char *proxy = NULL;
- proxy = getenv(HTTP_PROXY);
+ proxy = netconfig_get_env(HTTP_PROXY);
DBG("Get system proxy: %s", proxy);
- if(proxy != NULL)
+ if (proxy != NULL){
vconf_set_str(VCONFKEY_NETWORK_PROXY, proxy);
+ free(proxy);
+ }
}
static void __netconfig_emulator_set_network_state(void)
{
vconf_set_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 1);
vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_ETHERNET);
- vconf_set_int(VCONFKEY_DNET_STATE, VCONFKEY_DNET_OFF);
+ vconf_set_int(VCONFKEY_DNET_STATE, VCONFKEY_DNET_NORMAL_CONNECTED);
}
static void __netconfig_emulator_config_emul_env(void)
{
netconfig_is_emulated = __netconfig_emulator_test_emulation_env();
- DBG("Emulation environment tested: %s", netconfig_is_emulated ? "It's emulated" : "Not emulated");
+ DBG("Emulation environment tested: %s", netconfig_is_emulated ?
+ "It's emulated" : "Not emulated");
if (netconfig_is_emulated == TRUE)
__netconfig_emulator_config_emul_env();
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 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 <time.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+#include "log.h"
+
+#define LOG_FILE_PATH "/opt/usr/data/network/netconfig.log"
+#define MAX_LOG_SIZE 1 * 1024 * 1024
+#define MAX_LOG_COUNT 1
+
+static FILE *log_file = NULL;
+
+static inline void __netconfig_log_update_file_revision(int rev)
+{
+ int next_log_rev = 0;
+ char *log_file = NULL;
+ char *next_log_file = NULL;
+
+ next_log_rev = rev + 1;
+
+ log_file = g_strdup_printf("%s.%d", LOG_FILE_PATH, rev);
+ next_log_file = g_strdup_printf("%s.%d", LOG_FILE_PATH, next_log_rev);
+
+ if (next_log_rev >= MAX_LOG_COUNT)
+ remove(next_log_file);
+
+ if (access(next_log_file, F_OK) == 0)
+ __netconfig_log_update_file_revision(next_log_rev);
+
+ if (rename(log_file, next_log_file) != 0)
+ remove(log_file);
+
+ g_free(log_file);
+ g_free(next_log_file);
+}
+
+static inline void __netconfig_log_make_backup(void)
+{
+ const int rev = 0;
+ char *backup = NULL;
+
+ backup = g_strdup_printf("%s.%d", LOG_FILE_PATH, rev);
+
+ if (access(backup, F_OK) == 0)
+ __netconfig_log_update_file_revision(rev);
+
+ if (rename(LOG_FILE_PATH, backup) != 0)
+ remove(LOG_FILE_PATH);
+
+ g_free(backup);
+}
+
+static inline void __netconfig_log_get_local_time(char *strtime, const int size)
+{
+ time_t buf;
+ struct tm *local_ptm;
+
+ time(&buf);
+ buf = time(NULL);
+ local_ptm = localtime(&buf);
+
+ if(local_ptm)
+ strftime(strtime, size, "%m/%d %H:%M:%S", local_ptm);
+}
+
+void __netconfig_debug(const char *format, ...)
+{
+ va_list ap;
+ int log_size = 0;
+ struct stat buf;
+ char str[256];
+ char strtime[40];
+
+ if (log_file == NULL)
+ log_file = (FILE *)fopen(LOG_FILE_PATH, "a+");
+
+ if (log_file == NULL)
+ return;
+
+ va_start(ap, format);
+
+ if (fstat(fileno(log_file), &buf) == 0)
+ log_size = buf.st_size;
+
+ if (log_size >= MAX_LOG_SIZE) {
+ fclose(log_file);
+ log_file = NULL;
+
+ __netconfig_log_make_backup();
+
+ log_file = (FILE *)fopen(LOG_FILE_PATH, "a+");
+
+ if (log_file == NULL) {
+ va_end(ap);
+ return;
+ }
+ }
+
+ __netconfig_log_get_local_time(strtime, sizeof(strtime));
+
+ if (vsnprintf(str, sizeof(str), format, ap) > 0)
+ fprintf(log_file, "%s %s", strtime, str);
+
+ va_end(ap);
+}
+++ /dev/null
-/*
- * Network Configuration Module
- *
- * 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 "mdm-private.h"
-
-gboolean netconfig_is_wifi_allowed(void)
-{
- return TRUE;
-}
--- /dev/null
+/*
+ * Internet-accessibility check
+ *
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (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.tizenopensource.org/license
+ *
+ * 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 <net/if.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/inotify.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netinet/if_ether.h>
+#include <net/if_arp.h>
+#include <netinet/ip.h>
+#include <netinet/tcp.h>
+#include <netinet/udp.h>
+#include <net/route.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include "log.h"
+#include "util.h"
+#include "wifi-agent.h"
+#include "netsupplicant.h"
+#include "network-state.h"
+#include "network-accessibility.h"
+
+#define BUF_SIZE 2048
+#define NETCONFIG_INTERNET_CHECK_TIMEOUT 3
+
+enum netconfig_internet_check_state {
+ INTERNET_CHECK_STATE_NONE,
+ INTERNET_CHECK_STATE_DNS_CHECK,
+ INTERNET_CHECK_STATE_PACKET_CHECK
+};
+
+struct internet_params {
+ int fd;
+ char *addr;
+ int port;
+ guint transport_watch;
+ guint send_watch;
+ gboolean header_done;
+ gboolean request_started;
+ GCancellable *resolv_cancel;
+};
+
+const static char* url_list[] = {
+ "www.google.com",
+ "www.msn.com",
+ "www.yahoo.com",
+ "m.google.com",
+ "www.amazon.com",
+ "www.youtube.com"
+ };
+
+static guint timer_id = 0;
+static const char *proxy_addr = NULL;
+static gboolean perform_recheck = TRUE;
+struct internet_params *net_params = NULL;
+static gboolean is_internet_available = FALSE;
+const static int url_list_num = 6;
+static int url_index = 0;
+static char * redirect_url1 = NULL;
+static char * redirect_url2 = NULL;
+static enum netconfig_internet_check_state check_state =
+ INTERNET_CHECK_STATE_NONE;
+
+static void __netconfig_connect_sockets(void);
+static void __internet_check_state(
+ enum netconfig_internet_check_state state);
+
+gboolean netconfig_get_internet_status()
+{
+ return is_internet_available;
+}
+
+static void __netconfig_update_internet_status(unsigned char *reply)
+{
+ /* If the HTTP response is either 302 or 200 with redirection,
+ * then no Internet is available */
+ char *temp = NULL;
+ is_internet_available = FALSE;
+
+ if (NULL != reply) {
+ if ((NULL != g_strrstr((char*)reply, "HTTP/1.1 200")) &&
+ (NULL != g_strrstr((char*)reply, "auth action"))) {
+ DBG("200 OK but redirection found so:: Internet is un-available");
+ } else if (NULL != g_strrstr((char*)reply, "HTTP/1.1 302")) {
+ DBG("302:: Internet is un-available");
+ } else if ((temp = g_strrstr((char*)reply, "Location:")) != NULL) {
+ char * location = strtok(temp, "\r");
+ if (location != NULL) {
+ DBG("%s", location);
+ if (redirect_url1 == NULL)
+ redirect_url1 = g_strdup(location + strlen("Location: "));
+ else if (redirect_url2 == NULL)
+ redirect_url2 = g_strdup(location + strlen("Location: "));
+
+ if (redirect_url1 != NULL && redirect_url2 != NULL) {
+ DBG("[%s] [%s]", redirect_url1, redirect_url2);
+ if (g_strcmp0(redirect_url1, redirect_url2) == 0) {
+ DBG("Internet is un-available(Redirection to Error page)");
+ is_internet_available = FALSE;
+ } else
+ is_internet_available = TRUE;
+
+ g_free(redirect_url1);
+ g_free(redirect_url2);
+ redirect_url1 = NULL;
+ redirect_url2 = NULL;
+ }
+ }
+ } else {
+ is_internet_available = TRUE;
+ DBG("Internet is available");
+ }
+ }
+
+ if (is_internet_available == TRUE)
+ netconfig_send_notification_to_net_popup(NETCONFIG_DEL_PORTAL_NOTI, NULL);
+}
+
+static gboolean __netconfig_data_activity_timeout(gpointer data)
+{
+ DBG("Timer timed-out");
+ enum netconfig_internet_check_state prev_state =
+ (enum netconfig_internet_check_state)data;
+ INFO("Prev_state: state=%d (1:dns check / 2:packet check)",prev_state);
+
+ if (net_params == NULL)
+ return FALSE;
+
+ if (TRUE == perform_recheck && prev_state != INTERNET_CHECK_STATE_NONE) {
+ perform_recheck = FALSE;
+ if (prev_state == INTERNET_CHECK_STATE_DNS_CHECK) {
+ net_params->request_started = FALSE;
+ netconfig_check_internet_accessibility();
+ } else /* (state == NETCONFIG_DATA_ACTIVITY_STATE_PACKET_CHECK) */
+ __netconfig_connect_sockets();
+ } else {
+ perform_recheck = TRUE;
+ __internet_check_state(INTERNET_CHECK_STATE_NONE);
+ }
+
+ return FALSE;
+}
+
+static void __netconfig_internet_check_timer_stop(void)
+{
+ if (timer_id != 0)
+ netconfig_stop_timer(&timer_id);
+}
+
+static void __netconfig_internet_check_timer_start(
+ enum netconfig_internet_check_state state)
+{
+ static guint timeout = 0;
+ if (timer_id != 0) {
+ DBG("netconfig_data_activity_timer is already running, so stop it");
+ __netconfig_internet_check_timer_stop();
+ }
+
+ if (state == INTERNET_CHECK_STATE_NONE)
+ return;
+ else if (state == INTERNET_CHECK_STATE_DNS_CHECK)
+ timeout = NETCONFIG_INTERNET_CHECK_TIMEOUT;
+ else if (state == INTERNET_CHECK_STATE_PACKET_CHECK)
+ timeout = NETCONFIG_INTERNET_CHECK_TIMEOUT;
+
+ netconfig_start_timer_seconds(timeout,
+ __netconfig_data_activity_timeout,
+ (void *)state,
+ &timer_id);
+}
+
+static void __internet_check_state(
+ enum netconfig_internet_check_state state)
+{
+ if (check_state == state)
+ return;
+
+ INFO("state change (%d) -> (%d)", check_state, state);
+ switch (state) {
+ case INTERNET_CHECK_STATE_DNS_CHECK:
+ __netconfig_internet_check_timer_start(state);
+ break;
+ case INTERNET_CHECK_STATE_PACKET_CHECK:
+ if (check_state == INTERNET_CHECK_STATE_DNS_CHECK)
+ __netconfig_internet_check_timer_stop();
+
+ __netconfig_internet_check_timer_start(state);
+ break;
+ case INTERNET_CHECK_STATE_NONE:
+ switch (check_state) {
+ case INTERNET_CHECK_STATE_DNS_CHECK:
+ case INTERNET_CHECK_STATE_PACKET_CHECK:
+ __netconfig_internet_check_timer_stop();
+ netconfig_stop_internet_check();
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ check_state = state;
+}
+
+void netconfig_stop_internet_check(void)
+{
+ if (net_params == NULL)
+ return;
+
+ net_params->header_done = FALSE;
+ net_params->request_started = FALSE;
+
+ if (net_params->resolv_cancel != NULL) {
+ g_cancellable_cancel(net_params->resolv_cancel);
+ g_object_unref(net_params->resolv_cancel);
+ net_params->resolv_cancel = NULL;
+ }
+
+ if (net_params->transport_watch > 0) {
+ g_source_remove(net_params->transport_watch);
+ net_params->transport_watch = 0;
+ }
+
+ if (net_params->send_watch > 0) {
+ g_source_remove(net_params->send_watch);
+ net_params->send_watch = 0;
+ }
+
+ if (net_params->fd > 0) {
+ close(net_params->fd);
+ net_params->fd = -1;
+ }
+
+ if (net_params->addr != NULL) {
+ g_free(net_params->addr);
+ net_params->addr = NULL;
+ }
+
+ g_free(net_params);
+ net_params = NULL;
+
+ if (redirect_url1) {
+ g_free(redirect_url1);
+ redirect_url1 = NULL;
+ }
+
+ if (redirect_url2) {
+ g_free(redirect_url2);
+ redirect_url2 = NULL;
+ }
+}
+
+static gboolean __received_data_event(GIOChannel *channel,
+ GIOCondition condition, gpointer data)
+{
+ int n, fd;
+ unsigned char buf[BUF_SIZE] = { 0, };
+
+ if (net_params == NULL)
+ return FALSE;
+
+ if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
+ goto cleanup;
+
+ fd = g_io_channel_unix_get_fd(channel);
+ if (fd < 0)
+ goto cleanup;
+
+ n = read(fd, buf, BUF_SIZE - 1);
+ DBG("Received %d bytes[%s]", n, buf);
+ buf[BUF_SIZE - 1] = '\0';
+
+ if (n < 0) {
+ ERR("read failed. %s", strerror(errno));
+
+ goto cleanup;
+ } else if (n == 0) {
+ INFO("connection closed");
+
+ goto cleanup;
+ }
+
+ /* We got data from server successfully */
+ __netconfig_update_internet_status(buf);
+ __internet_check_state(INTERNET_CHECK_STATE_NONE);
+
+ return TRUE;
+
+cleanup:
+ /* Fail to get data from server */
+ __internet_check_state(INTERNET_CHECK_STATE_NONE);
+
+ return FALSE;
+}
+
+static gboolean __send_data_event(GIOChannel *channel,
+ GIOCondition condition, gpointer data)
+{
+ int n, fd;
+ const char *request_data =
+ "GET /index.html HTTP/1.1\r\nHost: connman.net\r\n\r\n";
+
+ if (net_params == NULL)
+ return FALSE;
+
+ if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
+ goto cleanup;
+
+ fd = g_io_channel_unix_get_fd(channel);
+ if (fd < 0)
+ goto cleanup;
+
+ /* We don't need to send anymore. Just return here.*/
+ /* Socket will be closed received part*/
+ if (net_params->header_done == TRUE)
+ return FALSE;
+
+ n = send(fd, request_data, strlen(request_data), 0);
+ DBG("Sent %d bytes", n);
+
+ if (n < 0) {
+ ERR("send failed. %s", strerror(errno));
+
+ goto cleanup;
+ } else if (n == 0) {
+ INFO("connection closed");
+
+ goto cleanup;
+ }
+
+ net_params->header_done = TRUE;
+ return TRUE;
+
+cleanup:
+ __internet_check_state(INTERNET_CHECK_STATE_NONE);
+
+ return FALSE;
+}
+
+static void __netconfig_connect_sockets(void)
+{
+ GIOFlags flags;
+ struct sockaddr_in addr;
+ GIOChannel *channel = NULL;
+ int sock;
+
+ if (net_params == NULL || net_params->addr == NULL)
+ return;
+
+ sock = socket(PF_INET, SOCK_STREAM, 0);
+ if (sock < 0)
+ goto cleanup;
+
+ if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE,
+ WIFI_IFNAME, strlen(WIFI_IFNAME) + 1) < 0) {
+ ERR("Bind to device error");
+ close(sock);
+ goto cleanup;
+ }
+
+ memset(&addr, 0, sizeof(struct sockaddr_in));
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = inet_addr(net_params->addr);
+ addr.sin_port = htons(net_params->port);
+
+ /* Register Watch */
+ channel = g_io_channel_unix_new(sock);
+
+ flags = g_io_channel_get_flags(channel);
+ g_io_channel_set_flags(channel, flags | G_IO_FLAG_NONBLOCK, NULL);
+ g_io_channel_set_encoding(channel, NULL, NULL);
+ g_io_channel_set_buffered(channel, FALSE);
+
+ if (connect(sock, (struct sockaddr *)&addr,
+ sizeof(struct sockaddr_in)) < 0) {
+ if (errno != EINPROGRESS) {
+ INFO("connect fail");
+ close(sock);
+ goto cleanup;
+ }
+ }
+
+ DBG("Connect successful");
+
+ net_params->fd = sock;
+ net_params->transport_watch = g_io_add_watch(channel,
+ (GIOCondition) (G_IO_IN | G_IO_HUP | G_IO_NVAL | G_IO_ERR),
+ (GIOFunc) __received_data_event, NULL);
+ net_params->send_watch = g_io_add_watch(channel,
+ (GIOCondition) (G_IO_OUT | G_IO_HUP | G_IO_NVAL | G_IO_ERR),
+ (GIOFunc) __send_data_event, NULL);
+
+ __internet_check_state(INTERNET_CHECK_STATE_PACKET_CHECK);
+ return;
+
+ cleanup:
+ __internet_check_state(INTERNET_CHECK_STATE_NONE);
+}
+
+static void __netconfig_obtain_host_ip_addr_cb(GObject *src,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GList *list, *cur;
+ GInetAddress *addr;
+ gchar *str_addr;
+
+ if (net_params == NULL)
+ return;
+
+ if (check_state == INTERNET_CHECK_STATE_NONE)
+ return;
+
+ list = g_resolver_lookup_by_name_finish((GResolver *)src, res, NULL);
+ if (!list) {
+ INFO("no data");
+ goto cleanup;
+ }
+
+ for (cur = list; cur; cur = cur->next) {
+ addr = cur->data;
+ str_addr = g_inet_address_to_string(addr);
+ if (!str_addr)
+ continue;
+
+ if (net_params != NULL) {
+ g_free(net_params->addr);
+ net_params->addr = str_addr;
+ }
+
+ g_object_unref(cur->data);
+ break;
+ }
+
+ g_list_free(list);
+
+ if (net_params->addr == NULL)
+ goto cleanup;
+
+ net_params->port = 80;
+ __netconfig_connect_sockets();
+
+ return;
+
+cleanup:
+ __internet_check_state(INTERNET_CHECK_STATE_NONE);
+}
+
+gboolean __netconfig_obtain_host_ip_addr(void)
+{
+ char *host, *addr, *port;
+
+ if (net_params == NULL)
+ return FALSE;
+
+ if (net_params->request_started == TRUE)
+ return FALSE;
+ else
+ net_params->request_started = TRUE;
+
+ if (net_params->addr != NULL)
+ return TRUE;
+
+ proxy_addr = netconfig_get_default_proxy();
+ DBG("Proxy(%s)", proxy_addr);
+
+ if (++url_index >= url_list_num)
+ url_index = 0;
+
+ DBG("addr (%s)", url_list[url_index]);
+
+ /* FIXME: domain proxy should be resolved */
+ if (proxy_addr == NULL) {
+ GResolver *r = NULL;
+ net_params->resolv_cancel = g_cancellable_new();
+ r = g_resolver_get_default();
+
+ g_resolver_lookup_by_name_async(r,
+ url_list[url_index],
+ net_params->resolv_cancel,
+ __netconfig_obtain_host_ip_addr_cb,
+ NULL);
+ __internet_check_state(INTERNET_CHECK_STATE_DNS_CHECK);
+
+ g_object_unref(r);
+ return FALSE;
+ } else {
+ host = g_strdup(proxy_addr);
+ if (host == NULL)
+ goto cleanup;
+
+ addr = strtok(host, ":");
+ if (addr == NULL)
+ goto cleanup;
+
+ port = strrchr(proxy_addr, ':');
+ if (port == NULL)
+ goto cleanup;
+ else {
+ char *end;
+ int tmp = strtol(port + 1, &end, 10);
+
+ if (*end == '\0') {
+ *port = '\0';
+ net_params->port = tmp;
+ }
+ }
+ g_free(net_params->addr);
+ net_params->addr = g_strdup(addr);
+
+ g_free(host);
+ }
+ return TRUE;
+
+cleanup:
+ g_free(host);
+ netconfig_stop_internet_check();
+
+ return FALSE;
+}
+
+void netconfig_check_internet_accessibility(void)
+{
+ DBG("::Entry");
+
+ if (net_params == NULL) {
+ net_params = g_try_malloc0(sizeof(struct internet_params));
+ if (net_params == NULL)
+ return;
+ net_params->fd = -1;
+ }
+
+ if ((check_state != INTERNET_CHECK_STATE_NONE) ||
+ (net_params->request_started == TRUE)) {
+ DBG("Older query in progress");
+ return;
+ }
+
+ is_internet_available = FALSE;
+
+ /* If the host IP is resolved, directly go for connecting to sockets*/
+ if (__netconfig_obtain_host_ip_addr() == TRUE) {
+ __netconfig_connect_sockets();
+ }
+}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
-#include <unistd.h>
+#include <aul.h>
+#include <app.h>
+#include <errno.h>
+#include <vconf.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
+#include <unistd.h>
#include <net/if.h>
#include <net/route.h>
#include <arpa/inet.h>
-#include <vconf.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
#include <vconf-keys.h>
-#include <wifi-direct.h>
+#include <syspopup_caller.h>
+#include <bundle.h>
+#include <bundle_internal.h>
+#include <eventsystem.h>
#include "log.h"
#include "util.h"
#include "neterror.h"
#include "wifi-state.h"
-#define WIFI_MAC_INFO_FILE "/opt/etc/.mac.info"
-#define WIFI_MAC_INFO_LENGTH 17
-#define WIFI_DEV_NAME "wlan0"
+#define WC_POPUP_EXTRA_DATA_KEY "http://samsung.com/appcontrol/data/connection_type"
+
+static gboolean netconfig_device_picker_test = FALSE;
GKeyFile *netconfig_keyfile_load(const char *pathname)
{
g_error_free(error);
}
- if (chmod(pathname, S_IRUSR | S_IWUSR) != 0)
- DBG("Unable to change permission of %s", pathname);
+ chmod(pathname, S_IRUSR | S_IWUSR);
g_free(keydata);
static void __netconfig_pop_device_picker(void)
{
+#if defined TIZEN_WEARABLE
+ int ret = 0;
+ app_control_h control = NULL;
+
+ ret = app_control_create(&control);
+ if (APP_CONTROL_ERROR_NONE != ret) {
+ DBG("failed to create app control");
+ return ;
+ }
+
+ app_control_add_extra_data(control, "viewtype", "scanlist");
+
+ app_control_set_app_id(control, "org.tizen.wifi");
+ ret = app_control_send_launch_request(control, NULL, NULL);
+ if (APP_CONTROL_ERROR_NONE == ret)
+ DBG("Launch request sent successfully");
+
+ app_control_destroy(control);
+#else
+ bundle *b = NULL;
int wifi_ug_state = 0;
vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE, &wifi_ug_state);
if (wifi_ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND)
return;
+ b = bundle_create();
+
DBG("Launch Wi-Fi device picker");
- // TODO : display a popup
+ syspopup_launch("wifi-qs", b);
+ bundle_free(b);
+#endif
}
static gboolean __netconfig_wifi_try_device_picker(gpointer data)
return __netconfig_wifi_device_picker_timer_id(FALSE, -1);
}
+void netconfig_wifi_enable_device_picker_test(void)
+{
+ netconfig_device_picker_test = TRUE;
+}
+
void netconfig_wifi_device_picker_service_start(void)
{
- int wifi_ug_state;
const int NETCONFIG_WIFI_DEVICE_PICKER_INTERVAL = 700;
- int hotspot_wifi_state = VCONFKEY_MOBILE_HOTSPOT_WIFI_OFF;
guint timer_id = 0;
- vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE, &wifi_ug_state);
- if (wifi_ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND)
+ if (netconfig_device_picker_test == TRUE)
+ netconfig_device_picker_test = FALSE;
+ else
return;
- /* If Wi-Fi tethering is pending on, don't show device picker UI*/
- vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_WIFI_STATE, &hotspot_wifi_state);
- if (hotspot_wifi_state == VCONFKEY_MOBILE_HOTSPOT_WIFI_PENDING_ON) {
- DBG("hotspot_wifi_state %d", hotspot_wifi_state);
+#if defined TIZEN_WEARABLE
+ if (aul_app_is_running("org.tizen.wifi") > 0) {
+ DBG("wifi app is running");
return;
}
+#else
+ int wifi_ug_state;
+
+ if (netconfig_device_picker_test == TRUE)
+ netconfig_device_picker_test = FALSE;
+ else
+ return;
+
+ vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE, &wifi_ug_state);
+ if (wifi_ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND)
+ return;
+#endif
DBG("Register device picker timer with %d milliseconds",
NETCONFIG_WIFI_DEVICE_PICKER_INTERVAL);
gboolean netconfig_is_wifi_direct_on(void)
{
+#if defined TIZEN_P2P_ENABLE
int wifi_direct_state = 0;
vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &wifi_direct_state);
DBG("Wi-Fi direct mode %d", wifi_direct_state);
return (wifi_direct_state != 0) ? TRUE : FALSE;
+#else
+ return FALSE;
+#endif
}
gboolean netconfig_is_wifi_tethering_on(void)
{
+#if defined TIZEN_TETHERING_ENABLE
int wifi_tethering_state = 0;
vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &wifi_tethering_state);
DBG("Wi-Ti tethering mode %d", wifi_tethering_state);
if (wifi_tethering_state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI)
return TRUE;
-
+#endif
return FALSE;
}
-/* args[] and env[] should be terminated with NULL pointer */
-gboolean netconfig_execute_file(const char *file_path,
- char *const args[], char *const env[])
+gboolean netconfig_interface_up(const char *ifname)
+{
+ int fd;
+ struct ifreq ifr;
+
+ fd = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+ if (fd < 0)
+ return FALSE;
+
+ memset(&ifr, 0, sizeof(ifr));
+ g_strlcpy((char *)ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+
+ if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
+ close(fd);
+ return FALSE;
+ }
+
+ ifr.ifr_flags |= (IFF_UP | IFF_DYNAMIC);
+ if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
+ close(fd);
+ return FALSE;
+ }
+
+ close(fd);
+
+ DBG("Successfully activated wireless interface");
+ return TRUE;
+}
+
+gboolean netconfig_interface_down(const char *ifname)
+{
+ int fd;
+ struct ifreq ifr;
+
+ fd = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+ if (fd < 0)
+ return FALSE;
+
+ memset(&ifr, 0, sizeof(ifr));
+ g_strlcpy((char *)ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+
+ if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
+ close(fd);
+ return FALSE;
+ }
+
+ ifr.ifr_flags = (ifr.ifr_flags & ~IFF_UP) | IFF_DYNAMIC;
+ if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
+ close(fd);
+ return FALSE;
+ }
+
+ close(fd);
+
+ DBG("Successfully de-activated wireless interface");
+ return TRUE;
+}
+
+int netconfig_execute_file(const char *file_path,
+ char *const args[], char *const envs[])
{
pid_t pid = 0;
+ int status = 0;
int rv = 0;
errno = 0;
+ register unsigned int index = 0;
+
+ while (args[index] != NULL) {
+ DBG("%s", args[index]);
+ index++;
+ }
if (!(pid = fork())) {
- register unsigned int index = 0;
- INFO("pid(%d), ppid (%d)", getpid(), getppid());
- INFO("Inside child, exec (%s) command", file_path);
-
- index = 0;
- while (args[index] != NULL) {
- INFO(" %s", args[index]);
- index++;
- }
+ DBG("pid(%d), ppid (%d)", getpid(), getppid());
+ DBG("Inside child, exec (%s) command", file_path);
errno = 0;
- if (execve(file_path, args, env) == -1) {
- DBG("Fail to execute command...(%s)",
- strerror(errno));
- return FALSE;
+ if (execve(file_path, args, envs) == -1) {
+ DBG("Fail to execute command (%s)", strerror(errno));
+ exit(1);
}
} else if (pid > 0) {
- if (waitpid(pid, &rv, 0) == -1) {
- DBG("wait pid (%u) rv (%d)", pid, rv);
-
- if (WIFEXITED(rv)) {
- DBG("exited, rv=%d", WEXITSTATUS(rv));
- } else if (WIFSIGNALED(rv)) {
- DBG("killed by signal %d", WTERMSIG(rv));
- } else if (WIFSTOPPED(rv)) {
- DBG("stopped by signal %d", WSTOPSIG(rv));
- } else if (WIFCONTINUED(rv)) {
- DBG("continued");
- }
+ if (waitpid(pid, &status, 0) == -1)
+ DBG("wait pid (%u) status (%d)", pid, status);
+
+ if (WIFEXITED(status)) {
+ rv = WEXITSTATUS(status);
+ DBG("exited, status=%d", rv);
+ } else if (WIFSIGNALED(status)) {
+ DBG("killed by signal %d", WTERMSIG(status));
+ } else if (WIFSTOPPED(status)) {
+ DBG("stopped by signal %d", WSTOPSIG(status));
+ } else if (WIFCONTINUED(status)) {
+ DBG("continued");
}
- return TRUE;
+
+ return rv;
}
- DBG("failed to fork()...(%s)", strerror(errno));
- return FALSE;
+ DBG("failed to fork(%s)", strerror(errno));
+ return -EIO;
+}
+
+static void on_clat_handler()
+{
+ pid_t clat_pid = 0;
+ int state = 0;
+
+ clat_pid = waitpid(-1, &state, WNOHANG);
+
+ DBG("clat(%d) state(%d)", clat_pid, WEXITSTATUS(state));
+}
+
+int netconfig_execute_clatd(const char *file_path, char *const args[])
+{
+ pid_t pid = 0;
+ int rv = 0;
+ errno = 0;
+ register unsigned int index = 0;
+
+ struct sigaction act;
+ int state = 0;
+
+ act.sa_handler = on_clat_handler;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+
+ state = sigaction(SIGCHLD, &act, 0);
+ if (state != 0) {
+ DBG("sigaction() : %d");
+ return -1;
+ }
+
+ while (args[index] != NULL) {
+ DBG("%s", args[index]);
+ index++;
+ }
+
+ if (!(pid = fork())) {
+ DBG("pid(%d), ppid (%d)", getpid(), getppid());
+ DBG("Inside child, exec (%s) command", file_path);
+
+ errno = 0;
+ if (execvp(file_path, args) == -1) {
+ ERR("Fail to execute command (%s)", strerror(errno));
+ return -1;
+ }
+ } else if (pid > 0) {
+ ERR("Success to launch clatd");
+ return rv;
+ }
+
+ DBG("failed to fork(%s)", strerror(errno));
+ return -EIO;
}
int netconfig_add_route_ipv6(gchar *ip_addr, gchar *interface, gchar *gateway, unsigned char prefix_len)
if (interface) {
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
- strcpy(ifr.ifr_name, interface);
+ strncpy(ifr.ifr_name, interface, sizeof(ifr.ifr_name)-1);
ioctl(fd, SIOCGIFINDEX, &ifr);
rt.rtmsg_ifindex = ifr.ifr_ifindex;
}
if (interface) {
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
- strcpy(ifr.ifr_name, interface);
+ strncpy(ifr.ifr_name, interface, sizeof(ifr.ifr_name)-1);
ioctl(fd, SIOCGIFINDEX, &ifr);
rt.rtmsg_ifindex = ifr.ifr_ifindex;
}
return 1;
}
-gboolean netconfig_iface_wifi_launch_direct(NetconfigWifi *wifi, GError **error)
+gboolean handle_launch_direct(Wifi *wifi, GDBusMethodInvocation *context)
{
- gboolean ret = TRUE;
-
+#if defined TIZEN_P2P_ENABLE
+ int ret = 0;
DBG("Launch Wi-Fi direct daemon");
const char *path = "/usr/bin/wifi-direct-server.sh";
- char *const args[] = { "wifi-direct-server.sh", "start", NULL};
- char *const env[] = { NULL };
-
- ret = netconfig_execute_file(path, args, env);
+ char *const args[] = { "wifi-direct-server.sh", "start", NULL };
+ char *const envs[] = { NULL };
- if (ret != TRUE) {
- INFO("Failed to launch Wi-Fi direct daemon");
-
- netconfig_error_wifi_direct_failed(error);
+ ret = netconfig_execute_file(path, args, envs);
+ if (ret < 0) {
+ ERR("Failed to launch Wi-Fi direct daemon");
+ netconfig_error_wifi_direct_failed(context);
+ return FALSE;
}
-
- return ret;
+ wifi_complete_launch_direct(wifi, context);
+ return TRUE;
+#else
+ wifi_complete_launch_direct(wifi, context);
+ return FALSE;
+#endif
}
-void netconfig_add_wifi_found_notification(void)
+gboolean netconfig_send_notification_to_net_popup(const char * noti, const char * ssid)
{
- INFO("Add wifi found notification");
-}
+ int ret = 0;
+ bundle *b;
+ static gboolean is_found_noti_exists = FALSE;
+ static gboolean is_portal_noti_exists = FALSE;
-void netconfig_del_wifi_found_notification(void)
-{
- INFO("Delete wifi found notification");
-}
+ if (noti == NULL) {
+ ERR("Invalid notification");
+ return FALSE;
+ }
+ if (g_strcmp0(noti, NETCONFIG_DEL_FOUND_AP_NOTI) == 0) {
+ if (is_found_noti_exists == FALSE)
+ return TRUE;
-void netconfig_set_wifi_mac_address(void)
-{
- FILE *fp = NULL;
- struct ifreq ifr;
- int ctl_sk = -1;
- char buf[WIFI_MAC_INFO_LENGTH + 1];
- char *mac_info;
+ is_found_noti_exists = FALSE;
+ } else if (g_strcmp0(noti, NETCONFIG_ADD_FOUND_AP_NOTI) == 0) {
+ if (is_found_noti_exists == TRUE)
+ return TRUE;
- mac_info = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
- if (mac_info == NULL) {
- ERR("Failed to open vconf key %s", VCONFKEY_WIFI_BSSID_ADDRESS);
+ is_found_noti_exists = TRUE;
+ } else if (g_strcmp0(noti, NETCONFIG_ADD_PORTAL_NOTI) == 0) {
+ if (is_portal_noti_exists == TRUE)
+ return TRUE;
+
+ is_portal_noti_exists = TRUE;
+ } else if (g_strcmp0(noti, NETCONFIG_DEL_PORTAL_NOTI) == 0) {
+ if (is_portal_noti_exists == FALSE)
+ return TRUE;
+
+ is_portal_noti_exists = FALSE;
}
- INFO("%s : %s", VCONFKEY_WIFI_BSSID_ADDRESS, mac_info);
+ b = bundle_create();
+ bundle_add(b, "_SYSPOPUP_TYPE_", noti);
- fp = fopen(WIFI_MAC_INFO_FILE, "r");
- if (fp != NULL) {
- if (fgets(buf, sizeof(buf), fp) == NULL) {
- ERR("Failed to get MAC info from %s", WIFI_MAC_INFO_FILE);
- goto done;
- }
+ if (ssid != NULL) {
+ DBG("ssid (%s)", ssid);
+ bundle_add(b, "_AP_NAME_", ssid);
+ }
- INFO("%s : %s", WIFI_MAC_INFO_FILE, buf);
+ ret = aul_launch_app("net.netpopup", b);
- if (strlen(buf) < WIFI_MAC_INFO_LENGTH) {
- ERR("Failed to get MAC info from %s", WIFI_MAC_INFO_FILE);
- goto done;
- }
+ bundle_free(b);
- buf[WIFI_MAC_INFO_LENGTH] = '\0';
- } else {
- // not MAC into file use ioctl to get MAC
- ctl_sk = socket(PF_INET,SOCK_DGRAM,0);
- if (ctl_sk < 0 ) {
- ERR("Failed to open socket");
- goto done;
- }
+ if (ret < 0) {
+ ERR("Unable to launch noti-popup. Err = %d", ret);
+ return FALSE;
+ }
- memset(&ifr, 0, sizeof(struct ifreq));
- strncpy(ifr.ifr_name, WIFI_DEV_NAME, sizeof(ifr.ifr_name) - 1);
- ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = 0;
+ DBG("Successfully sent notification (%s)", noti);
+ return TRUE;
+}
- if (ioctl(ctl_sk, SIOCGIFHWADDR, &ifr) != 0) {
- ERR("Failed to SIOCGIFHWADDR ioctl");
- goto done;
- }
+int netconfig_send_message_to_net_popup(const char *title,
+ const char *content, const char *type, const char *ssid)
+{
+ int ret = 0;
+ bundle *b = bundle_create();
- snprintf(buf, WIFI_MAC_INFO_LENGTH + 1,
- "%02x:%02x:%02x:%02x:%02x:%02x",
- (unsigned char)ifr.ifr_hwaddr.sa_data[0],
- (unsigned char)ifr.ifr_hwaddr.sa_data[1],
- (unsigned char)ifr.ifr_hwaddr.sa_data[2],
- (unsigned char)ifr.ifr_hwaddr.sa_data[3],
- (unsigned char)ifr.ifr_hwaddr.sa_data[4],
- (unsigned char)ifr.ifr_hwaddr.sa_data[5]);
+ bundle_add(b, "_SYSPOPUP_TITLE_", title);
+ bundle_add(b, "_SYSPOPUP_CONTENT_", content);
+ bundle_add(b, "_SYSPOPUP_TYPE_", type);
+ bundle_add(b, "_AP_NAME_", ssid);
- INFO("%s MAC address: %s", WIFI_DEV_NAME, buf);
- }
+ ret = aul_launch_app("net.netpopup", b);
- if (mac_info && (g_str_equal(mac_info, buf) == TRUE))
- goto done;
+ bundle_free(b);
- if (vconf_set_str(VCONFKEY_WIFI_BSSID_ADDRESS, buf) != 0)
- ERR("Failed to set MAC info to %s", VCONFKEY_WIFI_BSSID_ADDRESS);
+ return ret;
+}
-done:
- g_free(mac_info);
+void netconfig_set_system_event(const char * sys_evt, const char * evt_key, const char * evt_val)
+{
+ bundle *b = NULL;
- if (fp != NULL) {
- fclose(fp);
- }
+ DBG("System event set [%s : %s : %s]", sys_evt, evt_key, evt_val);
- if (ctl_sk >= 0) {
- close(ctl_sk);
- }
+ b = bundle_create();
+ bundle_add_str(b, evt_key, evt_val);
+ eventsystem_send_system_event(sys_evt, b);
+ bundle_free(b);
}
-gboolean netconfig_interface_up(const char *ifname)
+#if defined TIZEN_WEARABLE
+int wc_launch_syspopup(netconfig_wcpopup_type_e type)
{
- int fd;
- struct ifreq ifr;
+ int ret;
+ bundle* b;
+ char *ssid = NULL;
+
+ b = bundle_create();
+ if (!b) {
+ ERR("Failed to create bundle");
+ return -1;
+ }
+
+ switch (type) {
+ case WC_POPUP_TYPE_SESSION_OVERLAPPED:
+ bundle_add(b, "event-type", "wps-session-overlapped");
+ break;
+ case WC_POPUP_TYPE_WIFI_CONNECTED:
+ ssid = vconf_get_str(VCONFKEY_WIFI_CONNECTED_AP_NAME);
+ if (ssid == NULL) {
+ ERR("Failed to get connected ap ssid");
+ ssid = g_strdup(" ");
+ }
+ bundle_add(b, "event-type", "wifi-connected");
+ bundle_add(b, "ssid", ssid);
+ if (ssid)
+ g_free(ssid);
+ break;
+ case WC_POPUP_TYPE_WIFI_RESTRICT:
+ bundle_add(b, "event-type", "wifi-restrict");
+ break;
+ default:
+ ERR("Popup is not supported[%d]", type);
+ bundle_free(b);
+ return -1;
+ }
+
+ ret = syspopup_launch("wc-syspopup", b);
+ if (ret < 0)
+ ERR("Failed to launch syspopup");
+
+ bundle_free(b);
+
+ return ret;
+}
- fd = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
- if (fd < 0)
- return FALSE;
+int wc_launch_popup(netconfig_wcpopup_type_e type)
+{
+ int ret;
+ app_control_h app_control = NULL;
- memset(&ifr, 0, sizeof(ifr));
- g_strlcpy((char *)ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ ret = app_control_create(&app_control);
+ if (ret != APP_CONTROL_ERROR_NONE) {
+ ERR("Failed to create appcontrol[%d]", ret);
+ return -1;
+ }
- if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
- close(fd);
- return FALSE;
+ switch (type) {
+ case WC_POPUP_TYPE_CAPTIVE_PORTAL:
+ app_control_add_extra_data(app_control, WC_POPUP_EXTRA_DATA_KEY, "captive-portal");
+ break;
+ default:
+ ERR("Popup is not supported[%d]", type);
+ app_control_destroy(app_control);
+ return -1;
}
- ifr.ifr_flags |= (IFF_UP | IFF_DYNAMIC);
- if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
- close(fd);
- return FALSE;
+ app_control_set_app_id(app_control, "com.samsung.weconn-popup");
+ ret = app_control_send_launch_request(app_control, NULL, NULL);
+ if (ret != APP_CONTROL_ERROR_NONE) {
+ DBG("failed appcontrol launch request [%d]", ret);
+ app_control_destroy(app_control);
+ return -1;
}
- close(fd);
+ app_control_destroy(app_control);
- INFO("Successfully activated wireless interface");
- return TRUE;
+ return 0;
}
+#endif
-gboolean netconfig_interface_down(const char *ifname)
+void netconfig_set_vconf_int(const char * key, int value)
{
- int fd;
- struct ifreq ifr;
+ int ret = 0;
- fd = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
- if (fd < 0)
- return FALSE;
+ DBG("[%s: %d]", key, value);
- memset(&ifr, 0, sizeof(ifr));
- g_strlcpy((char *)ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
-
- if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
- close(fd);
- return FALSE;
- }
+ ret = vconf_set_int(key, value);
+ if (ret != VCONF_OK)
+ ERR("Failed to set");
+}
- ifr.ifr_flags = (ifr.ifr_flags & ~IFF_UP) | IFF_DYNAMIC;
- if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
- close(fd);
- return FALSE;
- }
+void netconfig_set_vconf_str(const char * key, const char * value)
+{
+ int ret = 0;
- close(fd);
+ DBG("[%s: %s]", key, value);
- DBG("Successfully de-activated wireless interface");
- return TRUE;
+ ret = vconf_set_str(key, value);
+ if (ret != VCONF_OK)
+ ERR("Failed to set");
}
+char* netconfig_get_env(const char *key)
+{
+ FILE *fp;
+ char buf[256], *entry = NULL, *value = NULL, *last;
+ int len=0;
+
+ if (!key)
+ return NULL;
+
+ fp = fopen(NETCONFIG_TIZENMOBILEENV, "r");
+ if (!fp)
+ return NULL;
+
+ while (fgets(buf, sizeof(buf), fp)) {
+ entry = buf;
+ entry = strtok_r(entry, "=", &last);
+ if (entry) {
+ if (strstr(entry, key)) {
+ entry = strtok_r(NULL, "\n", &last);
+ if(entry){
+ len = strlen(entry);
+ value = (char*)malloc(len+1);
+ g_strlcpy(value, entry, len+1);
+ }
+ else{
+ value = (char*)malloc(sizeof(char));
+ g_strlcpy(value, "\n", sizeof(char));
+ }
+ break;
+ }
+ }
+ }
+
+ fclose(fp);
+ return value;
+}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
+#include <app.h>
#include <stdio.h>
+#include <vconf.h>
+#include <stdlib.h>
#include <unistd.h>
+#include <vconf-keys.h>
-#include "wifi-agent.h"
#include "log.h"
+#include "util.h"
#include "wifi.h"
#include "netdbus.h"
-
+#include "wifi-agent.h"
+#include "wifi-state.h"
+#include "wifi-eap-config.h"
+#include "network-state.h"
+#include "network-accessibility.h"
+
+#define NETCONFIG_AGENT_FIELD_NAME "Name"
+#define NETCONFIG_AGENT_FIELD_SSID "SSID"
+#define NETCONFIG_AGENT_FIELD_IDENTITY "Identity"
#define NETCONFIG_AGENT_FIELD_PASSPHRASE "Passphrase"
#define NETCONFIG_AGENT_FIELD_WPS "WPS"
#define NETCONFIG_AGENT_FIELD_WPS_PBC "WPS_PBC"
#define NETCONFIG_AGENT_FIELD_WPS_PIN "WPS_PIN"
+#define NETCONFIG_AGENT_ERR_CONNECT_FAILED "connect-failed"
+
struct netconfig_wifi_agent {
+ GByteArray *ssid;
+ char *name;
+ char *identity;
char *passphrase;
char *wps_pin;
gboolean wps_pbc;
static void __netconfig_agent_clear_fields(void)
{
- DBG("__netconfig_agent_clear_fields");
-
+ g_byte_array_free(agent.ssid, TRUE);
+ g_free(agent.name);
+ g_free(agent.identity);
g_free(agent.passphrase);
g_free(agent.wps_pin);
+ agent.ssid = NULL;
+ agent.name = NULL;
+ agent.identity = NULL;
agent.passphrase = NULL;
agent.wps_pin = NULL;
agent.wps_pbc = FALSE;
}
-gboolean netconfig_agent_register(void)
+int netconfig_agent_register(void)
+{
+ GVariant *reply = NULL;
+ GVariant *params = NULL;
+ GError *error;
+ GDBusConnection *connection = NULL;
+
+ connection = netconfig_gdbus_get_connection();
+ if (connection == NULL) {
+ ERR("GDBusconnection is NULL");
+ return -1;
+ }
+
+ do {
+ error = NULL;
+ params = g_variant_new("(o)", NETCONFIG_WIFI_PATH);
+
+ reply = g_dbus_connection_call_sync(
+ connection,
+ CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE,
+ "RegisterAgent",
+ params,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ DBUS_REPLY_TIMEOUT,
+ netconfig_gdbus_get_gdbus_cancellable(),
+ &error);
+
+ if (reply == NULL) {
+ if (error != NULL) {
+ if (g_strcmp0(error->message,
+ "GDBus.Error:net.connman.Error.AlreadyExists: Already exists") == 0) {
+ break;
+ } else {
+ ERR("Fail to register agent [%d: %s]",
+ error->code, error->message);
+ }
+
+ g_error_free(error);
+ } else
+ ERR("Fail to register agent");
+ } else
+ g_variant_unref(reply);
+
+ sleep(1);
+ } while (TRUE);
+
+ INFO("Registered to connman agent successfully");
+
+ return 0;
+}
+
+int netconfig_agent_unregister(void)
{
- DBG("netconfig_agent_register");
+ gboolean reply = FALSE;
+ GVariant *param = NULL;
+ const char *path = NETCONFIG_WIFI_PATH;
- DBusMessage *reply = NULL;
- char param1[64] = "";
- char *param_array[] = {NULL, NULL};
+ param = g_variant_new("(o)", path);
- snprintf(param1, 64, "objpath:%s", NETCONFIG_WIFI_PATH);
- param_array[0] = param1;
+ DBG("ConnMan agent unregister");
- reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
- "RegisterAgent", param_array);
+ "UnregisterAgent", param, NULL);
- if (reply == NULL) {
- ERR("Error! Request failed");
- return FALSE;
- }
+ if (reply != TRUE)
+ ERR("Fail to unregister agent");
- dbus_message_unref(reply);
+ /* Clearing the agent fields */
+ __netconfig_agent_clear_fields();
- return TRUE;
+ return reply;
}
-gboolean netconfig_agent_unregister(void)
+gboolean netconfig_wifi_set_agent_field_for_eap_network(
+ const char *name, const char *identity, const char *passphrase)
{
- DBG("netconfig_agent_unregister");
+ int name_len;
- DBusMessage *reply = NULL;
- char param1[64] = "";
- char *param_array[] = {NULL, NULL};
+ if (name == NULL)
+ return FALSE;
- snprintf(param1, 64, "objpath:%s", NETCONFIG_WIFI_PATH);
- param_array[0] = param1;
+ __netconfig_agent_clear_fields();
- reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
- CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
- "UnregisterAgent", param_array);
+ name_len = strlen(name);
+ agent.ssid = g_byte_array_sized_new(name_len);
+ agent.ssid->len = name_len;
+ memcpy(agent.ssid->data, name, name_len);
- if (reply == NULL) {
- ERR("Error! Request failed");
- return FALSE;
- }
+ if (identity)
+ agent.identity = g_strdup(identity);
- dbus_message_unref(reply);
+ if (passphrase)
+ agent.passphrase = g_strdup(passphrase);
- /* Clearing the agent fields */
- __netconfig_agent_clear_fields();
+ DBG("Successfully configured for EAP network");
return TRUE;
}
-gboolean netconfig_iface_wifi_set_field(NetconfigWifi *wifi,
- GHashTable *fields, GError **error)
+gboolean handle_set_field(NetConnmanAgent *connman_agent,
+ GDBusMethodInvocation *context, const gchar *service, GVariant *fields)
{
- GHashTableIter iter;
- gpointer field, value;
+ GError *error = NULL;
+ GVariantIter *iter;
+ gpointer field;
+ GVariant *value;
+ gboolean updated = FALSE;
+ gboolean reply = FALSE;
- DBG("Set agent fields");
+ g_return_val_if_fail(connman_agent != NULL, FALSE);
- g_return_val_if_fail(wifi != NULL, FALSE);
+ DBG("Set agent fields for %s", service);
- __netconfig_agent_clear_fields();
+ if (netconfig_is_wifi_profile(service) != TRUE) {
+ error = g_error_new(G_DBUS_ERROR,
+ G_DBUS_ERROR_AUTH_FAILED,
+ CONNMAN_ERROR_INTERFACE ".InvalidService");
- g_hash_table_iter_init(&iter, fields);
+ g_dbus_method_invocation_return_gerror(context, error);
+ g_clear_error(&error);
- while (g_hash_table_iter_next(&iter, &field, &value)) {
- DBG("Field - [%s]", field);
+ return reply;
+ }
+
+ __netconfig_agent_clear_fields();
+ g_variant_get(fields, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_PASSPHRASE) == 0) {
g_free(agent.passphrase);
- agent.passphrase = g_strdup(value);
+ if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+ agent.passphrase = g_strdup(g_variant_get_string(value, NULL));
+ updated = TRUE;
- DBG("Field [%s] - []", field);
+ DBG("Field [%s] - []", field);
+ } else {
+ agent.passphrase = NULL;
+ }
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_WPS_PBC) == 0) {
agent.wps_pbc = FALSE;
- if (g_strcmp0(value, "enable") == 0)
+ if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING) &&
+ g_strcmp0(g_variant_get_string(value, NULL), "enable") == 0) {
agent.wps_pbc = TRUE;
+ updated = TRUE;
- DBG("Field [%s] - [%d]", field, agent.wps_pbc);
+ DBG("Field [%s] - [%d]", field, agent.wps_pbc);
+ }
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_WPS_PIN) == 0) {
g_free(agent.wps_pin);
agent.wps_pbc = FALSE;
- agent.wps_pin = g_strdup(value);
+ if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+ agent.wps_pin = g_strdup(g_variant_get_string(value, NULL));
+ updated = TRUE;
+
+ DBG("Field [%s] - []", field);
+ } else {
+ agent.wps_pin = NULL;
+ }
+ } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_NAME) == 0) {
+ g_free(agent.name);
+ if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+ agent.name = g_strdup(g_variant_get_string(value, NULL));
+ updated = TRUE;
+
+ DBG("Field [%s] - []", field);
+ } else {
+ agent.name = NULL;
+ }
+ } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_SSID) == 0) {
+ if (agent.ssid != NULL) {
+ g_byte_array_free(agent.ssid, TRUE);
+ agent.ssid = NULL;
+ }
- DBG("Field [%s] - []", field);
+ if (g_variant_is_of_type(value, G_VARIANT_TYPE_BYTESTRING)) {
+ guint8 char_value;
+ GVariantIter *iter1;
+ GByteArray *array = g_byte_array_new();
+
+ g_variant_get(value, "ay", &iter1);
+ while(g_variant_iter_loop(iter1, "y", &char_value)) {
+ g_byte_array_append(array, &char_value, 1);
+ }
+ g_variant_iter_free(iter1);
+ if (array != NULL && (array->len > 0)) {
+ agent.ssid = g_byte_array_sized_new(array->len);
+ agent.ssid->len = array->len;
+ memcpy(agent.ssid->data, array->data, array->len);
+ updated = TRUE;
+
+ DBG("Field [%s] - []", field);
+ }
+ }
+ } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_IDENTITY) == 0) {
+ g_free(agent.identity);
+ if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+ agent.identity = g_strdup(g_variant_get_string(value, NULL));
+ updated = TRUE;
+
+ DBG("Field [%s] - []", field);
+ } else {
+ agent.identity = NULL;
+ }
}
}
- return TRUE;
+ if (updated == TRUE) {
+ reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
+ service, CONNMAN_SERVICE_INTERFACE, "Connect", NULL, NULL);
+ if (reply == TRUE) {
+ g_dbus_method_invocation_return_value (context, NULL);
+ } else {
+ error = g_error_new(G_DBUS_ERROR,
+ G_DBUS_ERROR_AUTH_FAILED,
+ CONNMAN_ERROR_INTERFACE ".InvalidArguments");
+
+ g_dbus_method_invocation_return_gerror(context, error);
+ g_clear_error(&error);
+ }
+ } else {
+ error = g_error_new(G_DBUS_ERROR,
+ G_DBUS_ERROR_AUTH_FAILED,
+ CONNMAN_ERROR_INTERFACE ".InvalidArguments");
+
+ g_dbus_method_invocation_return_gerror(context, error);
+ g_clear_error(&error);
+ }
+
+ if (reply != TRUE) {
+ ERR("Fail to connect Wi-Fi");
+
+ __netconfig_agent_clear_fields();
+ }
+ g_variant_iter_free(iter);
+
+ net_connman_agent_complete_set_field(connman_agent, context);
+ return reply;
}
-gboolean netconfig_iface_wifi_request_input(NetconfigWifi *wifi,
- gchar *service, GHashTable *fields,
- DBusGMethodInvocation *context)
+gboolean handle_request_input(NetConnmanAgent *connman_agent,
+ GDBusMethodInvocation *context, const gchar *service, GVariant *fields)
{
- GHashTableIter iter;
- gpointer field, value;
- GHashTable *out_table = NULL;
- GValue *ret_value = NULL;
+ GVariantIter *iter;
+ gchar *field = NULL;
+ GVariant *r_value = NULL;
+ GVariant *out_table = NULL;
+ gboolean updated = FALSE;
+ GVariantBuilder *builder = NULL;
- g_return_val_if_fail(wifi != NULL, FALSE);
+ g_return_val_if_fail(connman_agent != NULL, FALSE);
if (NULL == service)
return FALSE;
DBG("Agent fields requested for service: %s", service);
- out_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
- if (NULL == out_table)
- return FALSE;
+ builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
- g_hash_table_iter_init(&iter, fields);
+ g_variant_get(fields, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &field, &r_value)) {
- while (g_hash_table_iter_next(&iter, &field, &value)) {
if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_PASSPHRASE) == 0 &&
agent.passphrase != NULL) {
- ret_value = g_slice_new0(GValue);
-
- g_value_init(ret_value, G_TYPE_STRING);
- g_value_set_string(ret_value, agent.passphrase);
- g_hash_table_insert(out_table, g_strdup(field), ret_value);
+ g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_PASSPHRASE,
+ g_variant_new_string(agent.passphrase));
+ updated = TRUE;
DBG("Setting [%s] - []", field);
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_WPS) == 0 &&
(agent.wps_pbc == TRUE || agent.wps_pin != NULL)) {
- ret_value = g_slice_new0(GValue);
-
- g_value_init(ret_value, G_TYPE_STRING);
-
if (agent.wps_pbc == TRUE) {
- /* Sending empty string for WPS push button method */
- g_value_set_string(ret_value, "");
+ // Sending empty string for WPS push button method
+ g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_WPS, g_variant_new_string(""));
+ updated = TRUE;
DBG("Setting empty string for [%s]", field);
} else if (agent.wps_pin != NULL) {
- g_value_set_string(ret_value, agent.wps_pin);
+ g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_WPS, g_variant_new_string(agent.wps_pin));
+ updated = TRUE;
DBG("Setting string [%s] - []", field);
}
+ } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_NAME) == 0 &&
+ agent.name != NULL) {
+ g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_NAME, g_variant_new_string(agent.name));
+
+ updated = TRUE;
+ DBG("Settings [%s] - []", field);
+ } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_SSID) == 0 &&
+ agent.ssid != NULL) {
+ int i = 0;
+ GVariantBuilder *builder1 = NULL;
+ builder1 = g_variant_builder_new (G_VARIANT_TYPE ("ay"));
+
+ for (i = 0; i < (agent.ssid->len); i++) {
+ g_variant_builder_add (builder1, "y", agent.ssid->data[i]);
+ }
+
+ g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_SSID, g_variant_builder_end(builder1));
+ if (builder1 != NULL)
+ g_variant_builder_unref(builder1);
- g_hash_table_insert(out_table, g_strdup(field), ret_value);
+ updated = TRUE;
+ DBG("Settings [%s] - []", field);
+ } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_IDENTITY) == 0 &&
+ agent.identity != NULL) {
+ g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_IDENTITY, g_variant_new_string(agent.identity));
+
+ updated = TRUE;
+ DBG("Settings [%s] - []", field);
}
}
- dbus_g_method_return(context, out_table);
+ out_table = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+
+ if (builder)
+ g_variant_builder_unref(builder);
+
+ g_variant_iter_free(iter);
+
+
+ if (NULL == out_table){
+ net_connman_agent_complete_request_input(connman_agent, context, out_table);
+
+ return FALSE;
+ }
+
+ if (updated == TRUE)
+ g_dbus_method_invocation_return_value (context, out_table);
+ else {
+ GError *error = NULL;
+ error = g_error_new(G_DBUS_ERROR,
+ G_DBUS_ERROR_AUTH_FAILED,
+ "net.connman.Agent.Error.Canceled");
+
+ g_dbus_method_invocation_return_gerror(context, error);
+ g_clear_error(&error);
+ }
__netconfig_agent_clear_fields();
+ g_variant_unref(out_table);
- return TRUE;
+ return updated;
+}
+
+
+gboolean handle_report_error(NetConnmanAgent *connman_agent,
+ GDBusMethodInvocation *context, const gchar *service, const gchar *error)
+{
+ gboolean ret = TRUE;
+
+ g_return_val_if_fail(connman_agent != NULL, FALSE);
+
+ net_connman_agent_complete_report_error(connman_agent, context);
+ DBG("Agent error for service[%s] - [%s]", service, error);
+
+ // Do something when it failed to make a connection
+
+ return ret;
+}
+
+#if defined TIZEN_CAPTIVE_PORTAL
+#if defined TIZEN_WEARABLE
+#define QUERY_FOR_INTERNET_INTERVAL 2
+#define TIMER_THRESHOLD 4
+#else
+#define QUERY_FOR_INTERNET_INTERVAL 20
+#define TIMER_THRESHOLD 120
+#endif
+
+static gboolean is_monitor_notifier_registered = FALSE;
+
+#if defined TIZEN_WEARABLE
+static gboolean is_portal_msg_shown = FALSE;
+static guint portal_msg_timer = 0;
+#endif
+
+struct poll_timer_data {
+ guint time_elapsed;
+ guint timer_id;
+ void* data;
+};
+
+static struct poll_timer_data timer_data =
+ {QUERY_FOR_INTERNET_INTERVAL, 0, NULL};
+
+static gboolean __check_ignore_portal_list(const char * ssid)
+{
+ char def_str[1024];
+ int i = 0;
+ int ignore_ap_count = 0;
+
+ if (ssid == NULL)
+ return FALSE;
+
+ DBG("checking ssid [%s]", ssid);
+
+ DBG("csc string [%s]", def_str);
+ gchar ** ignore_ap_list = g_strsplit(def_str, ",", 0);
+ ignore_ap_count = g_strv_length(ignore_ap_list);
+ for(i = 0; i < ignore_ap_count; i++) {
+ DBG("[%d] - [%s]", i, ignore_ap_list[i]);
+ if (strncmp(ignore_ap_list[i], ssid, strlen(ssid)) == 0) {
+ g_strfreev(ignore_ap_list);
+ return TRUE;
+ }
+ }
+
+ g_strfreev(ignore_ap_list);
+ return FALSE;
+}
+
+static void __wifi_state_monitor(enum netconfig_wifi_service_state state,
+ void *user_data);
+
+static struct netconfig_wifi_state_notifier wifi_state_monitor_notifier = {
+ .netconfig_wifi_state_changed = __wifi_state_monitor,
+ .user_data = NULL,
+};
+
+static void __wifi_state_monitor(enum netconfig_wifi_service_state state,
+ void *user_data)
+{
+ DBG("Wi-Fi state: %x", state);
+
+ if (state == NETCONFIG_WIFI_CONNECTED)
+ return;
+
+ if (is_monitor_notifier_registered == TRUE) {
+ netconfig_wifi_state_notifier_unregister(&wifi_state_monitor_notifier);
+ is_monitor_notifier_registered = FALSE;
+ }
+
+#if defined TIZEN_WEARABLE
+ is_portal_msg_shown = FALSE;
+#endif
+
+ /* suspend if Internet check activity in progress */
+ if (timer_data.timer_id == 0)
+ return;
+
+ netconfig_stop_timer(&timer_data.timer_id);
+ netconfig_stop_internet_check();
+
+ DBG("Stopped Internet accessibility check");
+}
+
+static gboolean __netconfig_wifi_portal_login_timeout(gpointer data)
+{
+ char *service_profile = NULL;
+ GVariant *reply = NULL;
+
+ DBG("");
+
+ struct poll_timer_data *timer = (struct poll_timer_data *)data;
+ if (timer == NULL)
+ return FALSE;
+
+ if (TRUE == netconfig_get_internet_status()) {
+ if (is_monitor_notifier_registered == TRUE) {
+ netconfig_wifi_state_notifier_unregister(
+ &wifi_state_monitor_notifier);
+ is_monitor_notifier_registered = FALSE;
+ }
+
+ DBG("Portal logged in successfully and update ConnMan state");
+ return FALSE; /* to stop the timer */
+ } else {
+ if (timer->time_elapsed >= TIMER_THRESHOLD) {
+ DBG("Login failed, update ConnMan");
+
+ if (is_monitor_notifier_registered == TRUE) {
+ netconfig_wifi_state_notifier_unregister(
+ &wifi_state_monitor_notifier);
+ is_monitor_notifier_registered = FALSE;
+ }
+
+ /* Disconnect and forget the AP */
+ service_profile = (char*) netconfig_get_default_profile();
+ if (service_profile && netconfig_is_wifi_profile(service_profile)) {
+ /* Now forget the AP*/
+ reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ service_profile, CONNMAN_SERVICE_INTERFACE, "Remove",
+ NULL);
+
+ if (reply != NULL)
+ g_variant_unref(reply);
+ else
+ ERR("Failed to forget the AP ");
+ }
+ } else {
+ if (NETCONFIG_WIFI_CONNECTED ==
+ netconfig_wifi_state_get_service_state()) {
+ /* check Internet availability by sending and receiving data*/
+ netconfig_check_internet_accessibility();
+ /* Returning TRUE itself is enough to restart the timer */
+ timer->time_elapsed = timer->time_elapsed +
+ QUERY_FOR_INTERNET_INTERVAL;
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+#if defined TIZEN_WEARABLE
+static gboolean __netconfig_display_portal_msg(gpointer data)
+{
+ DBG("");
+ wc_launch_popup(WC_POPUP_TYPE_CAPTIVE_PORTAL);
+
+ netconfig_stop_timer(&portal_msg_timer);
+
+ return FALSE;
+}
+#endif
+
+static void __netconfig_wifi_portal_login_timer_start(struct poll_timer_data
+ *data)
+{
+ DBG("__netconfig_wifi_browser_start_timer...starting timer");
+
+ if (data == NULL)
+ return;
+
+ netconfig_stop_timer(&(data->timer_id));
+
+ /* Timer logic: After successful launch of browser, we would check for
+ * Internet status for every 20s until a threshold of 120s
+ */
+
+ data->time_elapsed = QUERY_FOR_INTERNET_INTERVAL;
+ netconfig_start_timer_seconds(QUERY_FOR_INTERNET_INTERVAL,
+ __netconfig_wifi_portal_login_timeout, data, &(data->timer_id));
+}
+#endif
+
+gboolean handle_request_browser(NetConnmanAgent *connman_agent,
+ GDBusMethodInvocation *context, const gchar *service, const gchar *url)
+{
+#if defined TIZEN_CAPTIVE_PORTAL
+ gboolean ret = FALSE;
+ gboolean ignore_portal = FALSE;
+ const char * ssid = NULL;
+
+ g_return_val_if_fail(connman_agent != NULL, FALSE);
+
+ DBG("service[%s] - url[%s]", service, url);
+
+ ssid = netconfig_wifi_get_connected_essid(netconfig_get_default_profile());
+ if (ssid == NULL) {
+ ERR("Connected AP name is NULL!!");
+ net_connman_agent_complete_request_browser(connman_agent, context);
+ return FALSE;
+ }
+
+ ignore_portal = __check_ignore_portal_list(ssid);
+
+ if (ignore_portal == TRUE){
+ net_connman_agent_complete_request_browser(connman_agent, context);
+ return TRUE;
+ }
+ /* Register for Wifi state change notifier*/
+ if (is_monitor_notifier_registered == FALSE) {
+ netconfig_wifi_state_notifier_register(&wifi_state_monitor_notifier);
+ is_monitor_notifier_registered = TRUE;
+ }
+
+#if defined TIZEN_WEARABLE
+ if (is_portal_msg_shown){
+ net_connman_agent_complete_request_browser(connman_agent, context);
+ return TRUE;
+ }
+
+ is_portal_msg_shown = TRUE;
+ netconfig_start_timer_seconds(4, __netconfig_display_portal_msg, NULL, &portal_msg_timer);
+#else
+ ret = netconfig_send_notification_to_net_popup(NETCONFIG_ADD_PORTAL_NOTI, ssid);
+#endif
+
+ timer_data.time_elapsed = 0;
+ __netconfig_wifi_portal_login_timer_start(&timer_data);
+
+ net_connman_agent_complete_request_browser(connman_agent, context);
+ return ret;
+#else
+ GError *error = NULL;
+ error = g_error_new(G_DBUS_ERROR,
+ G_DBUS_ERROR_AUTH_FAILED,
+ CONNMAN_ERROR_INTERFACE ".NotSupported");
+
+ g_dbus_method_invocation_return_gerror(context, error);
+ g_clear_error(&error);
+
+ return FALSE;
+#endif
}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "log.h"
#include "util.h"
-#include "wifi.h"
#include "netdbus.h"
#include "wifi-state.h"
#include "wifi-background-scan.h"
+#if defined TIZEN_WEARABLE
+#define SCAN_PERIODIC_DELAY 15
+#define SCAN_EXPONENTIAL_MIN 5
+#define SCAN_EXPONENTIAL_MAX 320
+#else
#define SCAN_PERIODIC_DELAY 10
#define SCAN_EXPONENTIAL_MIN 4
#define SCAN_EXPONENTIAL_MAX 128
+#endif
enum {
WIFI_BGSCAN_MODE_EXPONENTIAL = 0x00,
};
static gboolean netconfig_wifi_scanning = FALSE;
+static gboolean netconfig_bgscan_paused = FALSE;
static struct bgscan_timer_data *__netconfig_wifi_bgscan_get_bgscan_data(void)
{
- static struct bgscan_timer_data timer_data = {SCAN_EXPONENTIAL_MIN, WIFI_BGSCAN_MODE_EXPONENTIAL, 0};
+ static struct bgscan_timer_data timer_data =
+ {SCAN_EXPONENTIAL_MIN, WIFI_BGSCAN_MODE_EXPONENTIAL, 0};
return &timer_data;
}
return __netconfig_wifi_bgscan_mode(FALSE, -1);
}
-static gboolean __netconfig_wifi_bgscan_request_connman_scan(void)
+static gboolean __netconfig_wifi_bgscan_request_connman_scan(int retries)
{
- DBusMessage *reply = NULL;
+ gboolean reply = FALSE;
+ guint state = netconfig_wifi_state_get_service_state();
- if (netconfig_wifi_state_get_service_state() == NETCONFIG_WIFI_CONNECTED)
+ if (state == NETCONFIG_WIFI_CONNECTED)
if (__netconfig_wifi_bgscan_get_mode() == WIFI_BGSCAN_MODE_EXPONENTIAL)
- return FALSE;
+ return TRUE;
- if (netconfig_wifi_state_get_service_state() == NETCONFIG_WIFI_CONNECTING)
- return FALSE;
+ if (state == NETCONFIG_WIFI_ASSOCIATION ||state == NETCONFIG_WIFI_CONFIGURATION) {
+ /* During Wi-Fi connecting, Wi-Fi can be disappeared.
+ * After 1 sec, try scan even if connecting state */
+ if (retries < 2)
+ return FALSE;
+ }
netconfig_wifi_set_scanning(TRUE);
- reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE, CONNMAN_WIFI_TECHNOLOGY_PREFIX,
- CONNMAN_TECHNOLOGY_INTERFACE, "Scan", NULL);
+ reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
+ CONNMAN_WIFI_TECHNOLOGY_PREFIX,
+ CONNMAN_TECHNOLOGY_INTERFACE, "Scan", NULL, NULL);
+ if (reply != TRUE)
+ netconfig_wifi_set_scanning(FALSE);
+
+ return reply;
+}
+
+static gboolean __netconfig_wifi_bgscan_next_scan(gpointer data);
- if (reply == NULL) {
- ERR("Error! Request failed");
+static gboolean __netconfig_wifi_bgscan_immediate_scan(gpointer data)
+{
+ static int retries = 0;
+
+#if !defined TIZEN_WEARABLE
+ if (netconfig_wifi_is_bgscan_paused())
+ return FALSE;
+#endif
+
+ if (__netconfig_wifi_bgscan_request_connman_scan(retries) == TRUE) {
+ retries = 0;
+ return FALSE;
+ } else if (retries > 2) {
+ retries = 0;
return FALSE;
}
- dbus_message_unref(reply);
+ retries++;
return TRUE;
}
-static gboolean __netconfig_wifi_bgscan_request_scan(gpointer data);
-
-static void __netconfig_wifi_bgscan_start_timer(struct bgscan_timer_data *data)
+static void __netconfig_wifi_bgscan_start_timer(gboolean immediate_scan,
+ struct bgscan_timer_data *data)
{
- if (data == NULL)
+ if (!data)
return;
netconfig_stop_timer(&(data->timer_id));
data->mode = __netconfig_wifi_bgscan_get_mode();
+ if (data->time < SCAN_EXPONENTIAL_MIN)
+ data->time = SCAN_EXPONENTIAL_MIN;
+
switch (data->mode) {
case WIFI_BGSCAN_MODE_EXPONENTIAL:
- if (data->time == 0)
- data->time = SCAN_EXPONENTIAL_MIN;
- else if ((data->time >= SCAN_EXPONENTIAL_MAX) ||
- (data->time > SCAN_EXPONENTIAL_MAX / 2))
- data->time = SCAN_EXPONENTIAL_MAX;
- else
- data->time = data->time * 2;
+ if (immediate_scan == TRUE) {
+ if ((data->time * 2) > SCAN_EXPONENTIAL_MAX)
+ data->time = SCAN_EXPONENTIAL_MAX;
+ else
+ data->time = data->time * 2;
+ }
break;
case WIFI_BGSCAN_MODE_PERIODIC:
- data->time = SCAN_PERIODIC_DELAY;
+ if ((data->time * 2) > SCAN_PERIODIC_DELAY)
+ data->time = SCAN_PERIODIC_DELAY;
+ else
+ data->time = data->time * 2;
break;
default:
- DBG("Error! Wi-Fi background scan mode [%d]", data->mode);
+ DBG("Invalid Wi-Fi background scan mode[%d]", data->mode);
return;
}
- DBG("Register background scan timer with %d seconds", data->time);
+ if (immediate_scan == TRUE)
+ g_timeout_add(500, __netconfig_wifi_bgscan_immediate_scan, NULL);
+
+ DBG("Scan immediately[%d], mode[%d], next[%d]",
+ immediate_scan, data->mode, data->time);
netconfig_start_timer_seconds(data->time,
- __netconfig_wifi_bgscan_request_scan, data, &(data->timer_id));
+ __netconfig_wifi_bgscan_next_scan, data, &(data->timer_id));
}
static void __netconfig_wifi_bgscan_stop_timer(struct bgscan_timer_data *data)
netconfig_stop_timer(&(data->timer_id));
}
-static gboolean __netconfig_wifi_bgscan_request_scan(gpointer data)
+static gboolean __netconfig_wifi_bgscan_next_scan(gpointer data)
{
struct bgscan_timer_data *timer = (struct bgscan_timer_data *)data;
int pm_state = VCONFKEY_PM_STATE_NORMAL;
- int hotspot_wifi_state = VCONFKEY_MOBILE_HOTSPOT_WIFI_OFF;
if (timer == NULL)
return FALSE;
- /* If Wi-Fi tethering is pending on, don't trigger scan event*/
- vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_WIFI_STATE, &hotspot_wifi_state);
- if (hotspot_wifi_state == VCONFKEY_MOBILE_HOTSPOT_WIFI_PENDING_ON) {
- DBG("hotspot_wifi_state %d", hotspot_wifi_state);
- return TRUE;
- }
-
/* In case of LCD off, we don't need Wi-Fi scan */
vconf_get_int(VCONFKEY_PM_STATE, &pm_state);
if (pm_state >= VCONFKEY_PM_STATE_LCDOFF)
return TRUE;
- __netconfig_wifi_bgscan_stop_timer(timer);
-
- DBG("Request Wi-Fi scan to ConnMan");
- __netconfig_wifi_bgscan_request_connman_scan();
-
- __netconfig_wifi_bgscan_start_timer(timer);
+ __netconfig_wifi_bgscan_start_timer(TRUE, timer);
return FALSE;
}
-static void __netconfig_wifi_bgscan_mode_cb(keynode_t* node, void* user_data)
+void netconfig_wifi_set_bgscan_pause(gboolean pause)
{
- int value;
- int wifi_state;
-
- if (vconf_get_int(VCONFKEY_WIFI_BGSCAN_MODE, &value) < 0) {
- ERR("VCONFKEY_WIFI_BGSCAN_MODE get failed");
- return;
- }
-
- DBG("Background scanning mode is changed : %d", value);
-
- __netconfig_wifi_bgscan_set_mode((guint)value);
-
- if (vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state) < 0) {
- ERR("VCONFKEY_WIFI_STATE get failed");
- return;
- }
-
- if (wifi_state == VCONFKEY_WIFI_OFF)
- return;
-
- struct bgscan_timer_data *timer_data = __netconfig_wifi_bgscan_get_bgscan_data();
-
- if (timer_data->timer_id != 0)
- netconfig_wifi_bgscan_stop();
+ DBG("[%s] Wi-Fi background scan", pause ? "Pause" : "Resume");
+ netconfig_bgscan_paused = pause;
+}
- netconfig_wifi_bgscan_start();
+gboolean netconfig_wifi_is_bgscan_paused(void)
+{
+ DBG("Wi-Fi background scan is [%s]", netconfig_bgscan_paused ? "Paused" : "Runnable");
+ return netconfig_bgscan_paused;
}
-void netconfig_wifi_bgscan_start(void)
+void netconfig_wifi_bgscan_start(gboolean immediate_scan)
{
+ enum netconfig_wifi_tech_state wifi_tech_state;
struct bgscan_timer_data *timer_data =
__netconfig_wifi_bgscan_get_bgscan_data();
if (timer_data == NULL)
return;
- DBG("Wi-Fi background scan start");
+ wifi_tech_state = netconfig_wifi_state_get_technology_state();
+ if (wifi_tech_state < NETCONFIG_WIFI_TECH_POWERED)
+ return;
+
+ DBG("Wi-Fi background scan started or re-started(%d)", immediate_scan);
- __netconfig_wifi_bgscan_start_timer(timer_data);
+ __netconfig_wifi_bgscan_start_timer(immediate_scan, timer_data);
}
void netconfig_wifi_bgscan_stop(void)
netconfig_wifi_scanning = scanning;
}
-gboolean netconfig_iface_wifi_set_bgscan(NetconfigWifi *wifi, guint scan_mode, GError **error)
+gboolean handle_set_bgscan(Wifi *wifi, GDBusMethodInvocation *context,
+ guint scan_mode)
{
- struct bgscan_timer_data *timer_data = __netconfig_wifi_bgscan_get_bgscan_data();
+ gint old_mode = 0;
+ int pm_state = VCONFKEY_PM_STATE_NORMAL;
+
+ old_mode = __netconfig_wifi_bgscan_get_mode();
+ if (old_mode == scan_mode){
+ wifi_complete_set_bgscan(wifi, context);
+ return TRUE;
+ }
__netconfig_wifi_bgscan_set_mode(scan_mode);
- if (timer_data->timer_id != 0)
- netconfig_wifi_bgscan_stop();
+ netconfig_wifi_bgscan_stop();
- netconfig_wifi_bgscan_start();
+ /* In case of LCD off, we don't need Wi-Fi scan right now */
+ vconf_get_int(VCONFKEY_PM_STATE, &pm_state);
+ if (pm_state >= VCONFKEY_PM_STATE_LCDOFF)
+ netconfig_wifi_bgscan_start(FALSE);
+ else
+ netconfig_wifi_bgscan_start(TRUE);
+ wifi_complete_set_bgscan(wifi, context);
return TRUE;
}
-void netconfig_wifi_init_bgscan()
+gboolean handle_resume_bgscan(Wifi *wifi, GDBusMethodInvocation *context)
{
- guint scan_mode = __netconfig_wifi_bgscan_get_mode();
-
- if (scan_mode == WIFI_BGSCAN_MODE_PERIODIC)
- vconf_set_int(VCONFKEY_WIFI_BGSCAN_MODE, VCONFKEY_WIFI_BGSCAN_MODE_PERIODIC);
- else
- vconf_set_int(VCONFKEY_WIFI_BGSCAN_MODE, VCONFKEY_WIFI_BGSCAN_MODE_EXPONENTIAL);
+ netconfig_wifi_set_bgscan_pause(FALSE);
- if (vconf_notify_key_changed(VCONFKEY_WIFI_BGSCAN_MODE,
- __netconfig_wifi_bgscan_mode_cb, NULL))
- DBG("Failed to set notify callback");
+ wifi_complete_resume_bgscan (wifi, context);
+ return TRUE;
}
-void netconfig_wifi_deinit_bgscan()
+gboolean handle_pause_bgscan(Wifi *wifi, GDBusMethodInvocation *context)
{
- if (vconf_ignore_key_changed(VCONFKEY_WIFI_BGSCAN_MODE,
- __netconfig_wifi_bgscan_mode_cb))
- DBG("Failed to unset notify callback");
+ netconfig_wifi_set_bgscan_pause(TRUE);
+
+ wifi_complete_pause_bgscan(wifi, context);
+ return TRUE;
}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <glib.h>
+#include <unistd.h>
+
+#include <vconf.h>
+
+#include "log.h"
+#include "util.h"
+#include "neterror.h"
+#include "wifi-config.h"
+
+#define CONNMAN_STORAGE "/var/lib/connman"
+#define WIFI_CONFIG_PREFIX "wifi_"
+
+#define WIFI_CONFIG_NAME "Name"
+#define WIFI_CONFIG_SSID "SSID"
+#define WIFI_CONFIG_PASSPHRASE "Passphrase"
+#define WIFI_CONFIG_SECURITY_TYPE "Security"
+#define WIFI_CONFIG_FAVORITE "Favorite"
+#define WIFI_CONFIG_AUTOCONNECT "AutoConnect"
+#define WIFI_CONFIG_HIDDEN "Hidden"
+#define WIFI_CONFIG_FAILURE "Failure"
+#define WIFI_CONFIG_PROXYADDRESS "ProxyAddress"
+#define WIFI_CONFIG_PROXY_METHOD "Proxy.Method"
+#define WIFI_CONFIG_PROXY_SERVER "Proxy.Servers"
+
+#define WIFI_SECURITY_NONE "none"
+#define WIFI_SECURITY_WEP "wep"
+#define WIFI_SECURITY_WPA_PSK "psk"
+#define WIFI_SECURITY_EAP "ieee8021x"
+
+#define WIFI_PREFIX_LENGTH 18 // wifi_485a3f2f506a_
+
+struct wifi_config {
+ gchar *name;
+ gchar *ssid;
+ gchar *passphrase;
+ gchar *security_type;
+ gboolean favorite;
+ gboolean autoconnect;
+ gchar *is_hidden;
+ gchar *proxy_address;
+ gchar *last_error;
+};
+
+static gint __netconfig_get_mac_address(gchar **mac_address)
+{
+ gchar *tmp_mac = NULL;
+ gchar *tmp = NULL;
+ gchar mac[13] = { 0, };
+ gint i = 0, j = 0;
+
+ tmp_mac = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
+ if (tmp_mac == NULL) {
+ ERR("vconf_get_str(WIFI_BSSID_ADDRESS) Failed");
+ *mac_address = NULL;
+ return -1;
+ }
+ tmp = g_ascii_strdown(tmp_mac, (gssize)strlen(tmp_mac));
+ g_free(tmp_mac);
+
+ while (tmp[i]) {
+ if (tmp[i] != ':') {
+ mac[j++] = tmp[i];
+ }
+ i++;
+ }
+ mac[12] = '\0';
+ *mac_address = g_strdup(mac);
+
+ return 0;
+}
+
+static gboolean ___netconfig_remove_file(const gchar *pathname, const gchar *filename)
+{
+ gboolean ret = FALSE;
+ gchar *path;
+
+ path = g_strdup_printf("%s/%s", pathname, filename);
+ if (g_file_test(path, G_FILE_TEST_EXISTS) == FALSE) {
+ ret = TRUE;
+ } else if (g_file_test(path, G_FILE_TEST_IS_REGULAR) == TRUE) {
+ unlink(path);
+ ret = TRUE;
+ }
+
+ g_free(path);
+ return ret;
+}
+
+static gboolean __netconfig_remove_configuration(const gchar *pathname)
+{
+ int ret = 0;
+
+ if (___netconfig_remove_file(pathname, "settings") != TRUE) {
+ ERR("Cannot remove [%s/settings]", pathname);
+ return FALSE;
+ }
+ if (___netconfig_remove_file(pathname, "data") != TRUE) {
+ ERR("Cannot remove [%s/data]", pathname);
+ return FALSE;
+ }
+
+ ret = rmdir(pathname);
+ if (ret == -1) {
+ ERR("Cannot remove [%s]", pathname);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gint _netconfig_get_security_type(const gchar *config_id, gchar **type)
+{
+ int ret = 0;
+
+ if (g_str_has_suffix(config_id, WIFI_SECURITY_NONE) == TRUE) {
+ *type = g_strdup(WIFI_SECURITY_NONE);
+ } else if (g_str_has_suffix(config_id, WIFI_SECURITY_WEP) == TRUE) {
+ *type = g_strdup(WIFI_SECURITY_WEP);
+ } else if (g_str_has_suffix(config_id, WIFI_SECURITY_WPA_PSK) == TRUE) {
+ *type = g_strdup(WIFI_SECURITY_WPA_PSK);
+ } else if (g_str_has_suffix(config_id, WIFI_SECURITY_EAP) == TRUE) {
+ *type = g_strdup(WIFI_SECURITY_EAP);
+ } else {
+ *type = NULL;
+ ret = -1;
+ }
+
+ return ret;
+}
+
+static gboolean _netconfig_load_wifi_configuration(const gchar *config_id,
+ struct wifi_config *config)
+{
+ GKeyFile *keyfile;
+ gchar *path;
+ gchar *group_name;
+ gchar *mac_address = NULL;
+ gboolean hidden = FALSE;
+
+ __netconfig_get_mac_address(&mac_address);
+ if (strlen(mac_address) == 0) {
+ ERR("mac_address is NULL");
+ return FALSE;
+ }
+
+ group_name = g_strdup_printf(WIFI_CONFIG_PREFIX "%s_%s", mac_address, config_id);
+ g_free(mac_address);
+ path = g_strdup_printf("/var/lib/connman/%s/settings", group_name);
+
+ DBG("group_name %s", group_name);
+ DBG("path %s", path);
+
+ keyfile = netconfig_keyfile_load(path);
+ if (keyfile == NULL) {
+ ERR("keyfile[%s] is NULL", path);
+ return FALSE;
+ }
+ config->name = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_NAME, NULL);
+ config->passphrase = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_PASSPHRASE, NULL);
+ _netconfig_get_security_type(config_id, &config->security_type);
+ config->proxy_address = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_PROXY_SERVER, NULL);
+ hidden = g_key_file_get_boolean(keyfile, group_name, WIFI_CONFIG_HIDDEN, NULL);
+ if (hidden) {
+ config->is_hidden = g_strdup("TRUE");
+ } else {
+ config->is_hidden = g_strdup("FALSE");
+ }
+ config->last_error = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_FAILURE, NULL);
+
+ g_free(group_name);
+ g_free(path);
+
+ return TRUE;
+}
+
+static gboolean _netconfig_save_wifi_configuration(const gchar *config_id,
+ const struct wifi_config *config)
+{
+ GKeyFile *keyfile;
+ gchar *dir;
+ gchar *path;
+ gchar *group_name;
+ gchar *mac_address = NULL;
+
+ __netconfig_get_mac_address(&mac_address);
+ if (mac_address == NULL) {
+ ERR("mac_address is NULL");
+ return FALSE;
+ }
+
+ group_name = g_strdup_printf("wifi_%s_%s", mac_address, config_id);
+ g_free(mac_address);
+
+ dir = g_strdup_printf(CONNMAN_STORAGE "/%s", group_name);
+ if (g_file_test(dir, G_FILE_TEST_IS_DIR) == TRUE) {
+ if (__netconfig_remove_configuration(dir) != TRUE) {
+ ERR("[%s] is existed, but cannot remove", dir);
+ g_free(group_name);
+ g_free(dir);
+ return FALSE;
+ }
+ }
+
+ if (mkdir(dir, (S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) < 0) {
+ ERR("Cannot mkdir %s", dir);
+ g_free(group_name);
+ g_free(dir);
+ return FALSE;
+ }
+
+ keyfile = g_key_file_new();
+ g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_NAME, config->name);
+ g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_SSID, config->ssid);
+
+ if (config->passphrase != NULL)
+ g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_PASSPHRASE, config->passphrase);
+
+ g_key_file_set_boolean(keyfile, group_name, WIFI_CONFIG_FAVORITE, config->favorite);
+ g_key_file_set_boolean(keyfile, group_name, WIFI_CONFIG_AUTOCONNECT, config->autoconnect);
+
+ // Optional field
+ if (config->proxy_address != NULL) {
+ g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_PROXY_METHOD, "manual");
+ g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_PROXY_SERVER, config->proxy_address);
+ }
+
+ if (config->is_hidden != NULL) {
+ gboolean hidden = FALSE;
+ if (g_strcmp0(config->is_hidden, "TRUE") == 0) {
+ hidden = TRUE;
+ }
+ g_key_file_set_boolean(keyfile, group_name, WIFI_CONFIG_HIDDEN, hidden);
+ }
+
+ path = g_strdup_printf(CONNMAN_STORAGE "/%s/settings", group_name);
+ netconfig_keyfile_save(keyfile, path);
+ g_free(group_name);
+ g_free(dir);
+ g_free(path);
+
+ return TRUE;
+}
+
+static gboolean _netconfig_remove_wifi_configuration(const gchar *config_id)
+{
+ gboolean ret = FALSE;
+ gchar *dir;
+ gchar *group_name;
+ gchar *mac_address = NULL;
+
+ __netconfig_get_mac_address(&mac_address);
+ if (mac_address == NULL) {
+ ERR("mac_address is NULL");
+ return FALSE;
+ }
+
+ group_name = g_strdup_printf("wifi_%s_%s", mac_address, config_id);
+ g_free(mac_address);
+
+ dir = g_strdup_printf(CONNMAN_STORAGE "/%s", group_name);
+ if (g_file_test(dir, G_FILE_TEST_IS_DIR) == TRUE) {
+ if (__netconfig_remove_configuration(dir) != TRUE) {
+ ERR("[%s] is existed, but cannot remove", dir);
+ ret = FALSE;
+ }
+ INFO("Success to remove [%s]", dir);
+ ret = TRUE;
+ } else {
+ ERR("[%s] is not existed", dir);
+ ret = FALSE;
+ }
+
+ g_free(group_name);
+ g_free(dir);
+
+ return ret;
+}
+
+static gboolean _netconfig_set_wifi_config_field(const gchar *config_id,
+ const gchar *key, const gchar *value)
+{
+ gboolean ret = TRUE;
+ GKeyFile *keyfile;
+ gchar *path;
+ gchar *group_name;
+ gchar *mac_address = NULL;
+
+ __netconfig_get_mac_address(&mac_address);
+ if (strlen(mac_address) == 0) {
+ ERR("mac_address is NULL");
+ return FALSE;
+ }
+
+ group_name = g_strdup_printf(WIFI_CONFIG_PREFIX "%s_%s", mac_address, config_id);
+ g_free(mac_address);
+ path = g_strdup_printf("/var/lib/connman/%s/settings", group_name);
+
+ DBG("group_name %s", group_name);
+ DBG("path %s", path);
+
+ keyfile = netconfig_keyfile_load(path);
+ if (keyfile == NULL) {
+ ERR("keyfile[%s] is NULL", path);
+ return FALSE;
+ }
+
+ if (g_strcmp0(key, WIFI_CONFIG_PROXY_METHOD) == 0) {
+ g_key_file_set_string(keyfile, group_name, key, value);
+ }else if (g_strcmp0(key, WIFI_CONFIG_PROXY_SERVER) == 0) {
+ g_key_file_set_string(keyfile, group_name, key, value);
+ } else if (g_strcmp0(key, WIFI_CONFIG_HIDDEN) == 0) {
+ gboolean hidden = FALSE;
+ if (g_strcmp0(value, "TRUE") == 0) {
+ hidden = TRUE;
+ }
+ g_key_file_set_boolean(keyfile, group_name, key, hidden);
+ } else {
+ ERR("key[%s] is not supported", key);
+ ret = FALSE;
+ }
+
+ netconfig_keyfile_save(keyfile, path);
+ g_free(group_name);
+ g_free(path);
+
+ return ret;
+}
+
+static GSList *_netconfig_get_wifi_config_list(void)
+{
+ GSList *list = NULL;
+ struct dirent *d;
+ DIR *dir;
+
+ dir = opendir(CONNMAN_STORAGE);
+ if (dir == NULL) {
+ ERR("Cannot open dir %s", CONNMAN_STORAGE);
+ return NULL;
+ }
+
+ while ((d = readdir(dir))) {
+ if (g_strcmp0(d->d_name, ".") == 0 ||
+ g_strcmp0(d->d_name, "..") == 0 ||
+ strncmp(d->d_name, WIFI_CONFIG_PREFIX, strlen(WIFI_CONFIG_PREFIX)) != 0) {
+ continue;
+ }
+ gchar *config_id = g_strdup(d->d_name + WIFI_PREFIX_LENGTH);
+ list = g_slist_append(list, g_strdup(config_id));
+ g_free(config_id);
+ }
+ closedir(dir);
+
+ return list;
+}
+
+gboolean handle_get_config_ids(Wifi *wifi, GDBusMethodInvocation *context)
+{
+ guint i = 0;
+ GSList *config_ids = NULL;
+ guint length;
+ gchar **result = NULL;
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ config_ids = _netconfig_get_wifi_config_list();
+ if (config_ids == NULL) {
+ netconfig_error_no_profile(context);
+ ERR("Fail to get config list");
+ return FALSE;
+ }
+
+ length = g_slist_length(config_ids);
+ result = g_new0(gchar *, length + 1);
+ for (i = 0; i < length; i++) {
+ gchar *config_id = g_slist_nth_data(config_ids, i);
+ result[i] = g_strdup(config_id);
+ }
+
+ config_ids = g_slist_nth(config_ids, 0);
+ g_slist_free_full(config_ids, g_free);
+
+ wifi_complete_get_config_ids(wifi, context, (const gchar * const*)result);
+ return TRUE;
+}
+
+gboolean handle_load_configuration(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *config_id)
+{
+ gboolean ret = FALSE;
+ gchar *name = NULL, *passphrase = NULL, *security_type = NULL;
+ gchar *proxy_address = NULL, *is_hidden = NULL, *last_error = NULL;
+ struct wifi_config *conf = NULL;
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ conf = g_new0(struct wifi_config, 1);
+
+ ret = _netconfig_load_wifi_configuration(config_id, conf);
+ if (ret != TRUE) {
+ g_free(conf);
+ ERR("No wifi configuration");
+ netconfig_error_no_profile(context);
+ return FALSE;
+ }
+
+ name = g_strdup(conf->name);
+ passphrase = g_strdup(conf->passphrase);
+ security_type = g_strdup(conf->security_type);
+ is_hidden = g_strdup(conf->is_hidden);
+
+ if (conf->proxy_address != NULL) {
+ proxy_address = g_strdup(conf->proxy_address);
+ g_free(conf->proxy_address);
+ } else {
+ proxy_address = g_strdup("NONE");
+ }
+ if (conf->last_error != NULL) {
+ last_error = g_strdup(conf->last_error);
+ g_free(conf->last_error);
+ } else {
+ last_error = g_strdup("ERROR_NONE");
+ }
+
+ g_free(conf->name);
+ g_free(conf->passphrase);
+ g_free(conf->security_type);
+ g_free(conf->is_hidden);
+ g_free(conf);
+
+ wifi_complete_load_configuration (wifi, context, name,
+ passphrase, security_type, proxy_address, is_hidden, last_error);
+
+ return TRUE;
+}
+
+gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *config_id, GVariant *configuration)
+{
+ gboolean ret = FALSE;
+ struct wifi_config *conf = NULL;
+ GVariantIter *iter;
+ GVariant *value;
+ gchar *field;
+
+ if ((wifi == NULL) || (config_id == NULL) || (configuration == NULL)) {
+ ERR("Invaliad parameter");
+ netconfig_error_invalid_parameter(context);
+ return FALSE;
+ }
+
+ conf = g_new0(struct wifi_config, 1);
+
+ g_variant_get(configuration, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
+ if (g_strcmp0(field, WIFI_CONFIG_NAME) == 0) {
+ if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+ conf->name = g_strdup(g_variant_get_string(value, NULL));
+ ERR("name [%s]", conf->name);
+ } else {
+ conf->name = NULL;
+ }
+ } else if (g_strcmp0(field, WIFI_CONFIG_SSID) == 0) {
+ if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+ conf->ssid = g_strdup(g_variant_get_string(value, NULL));
+ ERR("ssid [%s]", conf->ssid);
+ } else {
+ conf->ssid = NULL;
+ }
+ } else if (g_strcmp0(field, WIFI_CONFIG_PASSPHRASE) == 0) {
+ if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+ conf->passphrase = g_strdup(g_variant_get_string(value, NULL));
+ ERR("passphrase [%s]", conf->passphrase);
+ } else {
+ conf->passphrase = NULL;
+ }
+ } else if (g_strcmp0(field, WIFI_CONFIG_HIDDEN) == 0) {
+ if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+ conf->is_hidden = g_strdup(g_variant_get_string(value, NULL));
+ ERR("is_hidden [%s]", conf->is_hidden);
+ } else {
+ conf->is_hidden = NULL;
+ }
+ } else if (g_strcmp0(field, WIFI_CONFIG_PROXYADDRESS) == 0) {
+ conf->proxy_address = g_strdup(g_variant_get_string(value, NULL));
+ ERR("proxy_address [%s]", conf->proxy_address);
+ } else {
+ conf->proxy_address = NULL;
+ }
+ }
+ conf->favorite = TRUE;
+ conf->autoconnect = TRUE;
+ ret = _netconfig_save_wifi_configuration(config_id, conf);
+
+ g_free(conf->name);
+ g_free(conf->ssid);
+ g_free(conf->passphrase);
+ g_free(conf->is_hidden);
+ g_free(conf->proxy_address);
+ g_free(conf);
+
+ g_variant_iter_free(iter);
+
+ if (ret == TRUE) {
+ wifi_complete_save_configuration(wifi, context);
+ } else {
+ netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailSaveConfiguration");
+ }
+
+ return ret;
+}
+
+gboolean handle_remove_configuration(Wifi *wifi, GDBusMethodInvocation *context, const gchar *config_id)
+{
+ gboolean ret = FALSE;
+
+ if ((wifi == NULL) || (config_id == NULL)) {
+ ERR("Invaliad parameter");
+ netconfig_error_invalid_parameter(context);
+ return FALSE;
+ }
+
+ ret = _netconfig_remove_wifi_configuration(config_id);
+ if (ret != TRUE) {
+ // no configuration or error
+ ERR("No [%s] configuration", config_id);
+ netconfig_error_no_profile(context);
+ return FALSE;
+ }
+
+ wifi_complete_remove_configuration(wifi, context);
+ return ret;
+}
+
+// config field key / value
+/*
+ * [wifi_macaddress_config_id]
+ * Name=name (mandatory)
+ * SSID=SSID (mandatory)
+ * Frequency=2462 (X)
+ * Favorite=true (X)
+ * AutoConnect=true (Default true)
+ * Modified=2015-03-20 (X)
+ * IPv4.method=manual (O)
+ * IPv4.DHCP.LastAddress=192.0.0.1 (X)
+ * IPv6.method=auto (X)
+ * IPv6.privacy=disabled (X)
+ * IPv4.netmask_prefixlen=24 (X)
+ * IPv4.local_address=192.0.0.1 (O)
+ * IPv4.gateway=192.0.0.1 (O ? X ?)
+ * Nameservers=192.168.43.22; (O)
+ * Proxy.Method=manual (O)
+ * Proxy.Servers=trst.com:8888; (O)
+ */
+gboolean handle_set_config_field(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *config_id, const gchar *key, const gchar *value)
+{
+ gboolean ret = FALSE;
+ gchar *keyfile_key = NULL;
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+ g_return_val_if_fail(config_id != NULL, FALSE);
+ g_return_val_if_fail(key != NULL, FALSE);
+
+ DBG("Key[%s] Value[%d]", key, value);
+
+ if (g_strcmp0(key, WIFI_CONFIG_PROXYADDRESS) == 0) {
+ ret = _netconfig_set_wifi_config_field(config_id, WIFI_CONFIG_PROXY_METHOD, "manual");
+ if (!ret) {
+ ERR("Fail to [%s]set_wifi_config_field(%s/manual)", config_id, WIFI_CONFIG_PROXY_METHOD);
+ netconfig_error_invalid_parameter(context);
+ return FALSE;
+ }
+ keyfile_key = g_strdup_printf("%s", WIFI_CONFIG_PROXY_SERVER);
+ } else if (g_strcmp0(key, WIFI_CONFIG_HIDDEN) == 0) {
+ keyfile_key = g_strdup_printf("%s", WIFI_CONFIG_HIDDEN);
+ } else {
+ ERR("Not supported key[%s]", key);
+ netconfig_error_invalid_parameter(context);
+ return FALSE;
+ }
+
+ ret = _netconfig_set_wifi_config_field(config_id, keyfile_key, (const gchar *)value);
+ if (!ret) {
+ ERR("Fail to [%s]set_wifi_config_field(%s/%s)", config_id, key, value);
+ ret = FALSE;
+ }
+
+ if (keyfile_key != NULL)
+ g_free(keyfile_key);
+
+ wifi_complete_set_config_field(wifi,context);
+ return ret;
+}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 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 "log.h"
+
+#include "util.h"
+#include "netdbus.h"
+#include "wifi-dump.h"
+
+#define NETWORK_DUMP_SCRIPT "/opt/var/lib/net-config/network_dump.sh"
+
+static int _start_dump(gchar *dump_path)
+{
+ int rv = 0;
+ gchar *path = NETWORK_DUMP_SCRIPT;
+ char *const args[] = { "/opt/var/lib/net-config/network_dump.sh", dump_path, NULL };
+ char *const envs[] = { NULL };
+
+ rv = netconfig_execute_file(path, args, envs);
+ if (rv < 0) {
+ ERR("Fail to execute network_dump.sh");
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static void _send_dump_signal(const gchar *sig_name)
+{
+ gboolean reply;
+ GDBusConnection *connection = NULL;
+ GError *error = NULL;
+
+ connection = netconfig_gdbus_get_connection();
+ if (connection == NULL) {
+ DBG("GDBusconnection is NULL");
+ return;
+ }
+
+ reply = g_dbus_connection_emit_signal(connection,
+ NULL,
+ DUMP_SERVICE_OBJECT_PATH,
+ DUMP_SERVICE_INTERFACE,
+ sig_name,
+ NULL,
+ &error);
+ if (reply != TRUE) {
+ if (error != NULL) {
+ ERR("Failed to send signal [%s]", error->message);
+ g_error_free(error);
+ }
+ return;
+ }
+}
+
+int netconfig_dump_log(const char *path)
+{
+ gchar *dump_path = NULL;
+
+ if (!path) {
+ ERR("path is NULL. Dump Fail");
+ return -1;
+ }
+ ERR("Dump is started");
+ _send_dump_signal(DUMP_START_SIGNAL);
+
+ dump_path = g_strdup(path);
+ _start_dump(dump_path);
+ g_free(dump_path);
+
+ _send_dump_signal(DUMP_FINISH_SIGNAL);
+ ERR("Dump is finished");
+ return 0;
+}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
+#include <errno.h>
#include <stdio.h>
#include <unistd.h>
+#include <sys/stat.h>
-#include "wifi-eap-config.h"
#include "log.h"
-#include "wifi.h"
-
-static char *__get_ssid(const char *name)
+#include "util.h"
+#include "netdbus.h"
+#include "wifi-agent.h"
+#include "wifi-state.h"
+#include "wifi-eap-config.h"
+#include "neterror.h"
+
+#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"
+
+static char *__get_encoded_ssid(const char *name)
{
- char *buf = NULL;
- char buf_tmp[32] = {0,};
- int i = 0;
- int len = 0;
+ char *str = NULL;
+ char *pstr = NULL;
+ int i = 0, len = 0;
- if (NULL == name)
+ if (name == NULL)
return NULL;
len = strlen(name);
- buf = g_try_malloc0(len * 2 + 1);
- if (buf == NULL)
+ str = g_try_malloc0(len * 2 + 1);
+ if (str == NULL)
return NULL;
+ pstr = str;
for (i = 0; i < len; i++) {
- snprintf(buf_tmp, 3, "%02x", name[i]);
- strcat(buf, buf_tmp);
+ g_snprintf(pstr, 3, "%02x", name[i]);
+ pstr += 2;
}
- DBG("SSID - [%s]\n", buf);
-
- return buf;
+ return str;
}
-static gboolean __config_save(GKeyFile *keyfile, char *file_name)
+static int __config_save(const char *ssid, GKeyFile *keyfile)
{
gchar *data = NULL;
+ gchar *config_file = NULL;
gsize length = 0;
FILE *file = NULL;
- int ret = TRUE;
+ int err = 0;
+
+ config_file = g_strdup_printf("%s/%s.config", CONNMAN_STORAGEDIR, ssid);
+ if (config_file == NULL) {
+ err = -ENOMEM;
+ goto out;
+ }
data = g_key_file_to_data(keyfile, &length, NULL);
- DBG("Data lenght-[%d]", length);
- file = fopen(file_name, "w");
- if (NULL == file) {
- DBG("fopen() fails!");
- ret = FALSE;
- } else {
- fputs(data, file);
- fclose(file);
- DBG("Wrote data successfully to [%s] file!", file_name);
+ file = fopen(config_file, "w");
+ if (file == NULL) {
+ ERR("Failed to open %s", config_file);
+
+ err = -EIO;
+ goto out;
}
+ /* Do POSIX file operation to create and remove config files,
+ * Do not use g_file_set_contents, it breaks inotify operations */
+ if (fputs(data, file) < 0) {
+ ERR("Failed to write %s", config_file);
+
+ err = -EIO;
+ goto out;
+ }
+
+out:
+ if (file != NULL)
+ fclose(file);
+
g_free(data);
+ g_free(config_file);
- return ret;
+ return err;
}
-static gboolean __config_delete(const char *ssid)
+static int __config_delete(const char *ssid)
{
+ int err = 0;
+ gchar *group_name = NULL;
gchar *config_file = NULL;
- gboolean ret = FALSE;
+ gchar *dirname = NULL;
+ gchar *cert_path = NULL;
+ GKeyFile *keyfile = NULL;
+ GError *error = NULL;
- config_file = g_strdup_printf("%s/%s.config", CONNMAN_STORAGEDIR,
- ssid);
- if(config_file == NULL)
- return FALSE;
+ config_file = g_strdup_printf("%s/%s.config", CONNMAN_STORAGEDIR, ssid);
+ if (config_file == NULL)
+ return -ENOMEM;
+
+ keyfile = g_key_file_new();
- if (g_file_test(config_file, G_FILE_TEST_EXISTS) == FALSE) {
- ret = TRUE;
- } else if (g_file_test(config_file, G_FILE_TEST_IS_REGULAR) == TRUE) {
- unlink(config_file);
- ret = TRUE;
+ if (g_key_file_load_from_file(keyfile, config_file, 0, &error) != TRUE) {
+ ERR("Unable to load %s[%s]", config_file, error->message);
+ g_clear_error(&error);
+
+ err = -EIO;
+ goto out;
+ }
+
+ group_name = g_strdup_printf("service_%s", ssid);
+
+ cert_path = g_key_file_get_string(keyfile, group_name,
+ CONNMAN_CONFIG_FIELD_CA_CERT_FILE, NULL);
+ DBG("Temporal %s", cert_path);
+ if (cert_path != NULL && remove(cert_path) != 0)
+ ERR("Failed to remove %s", cert_path);
+ g_free(cert_path);
+
+ cert_path = g_key_file_get_string(keyfile, group_name,
+ CONNMAN_CONFIG_FIELD_CLIENT_CERT_FILE, NULL);
+ DBG("Temporal %s", cert_path);
+ if (cert_path != NULL && remove(cert_path) != 0)
+ ERR("Failed to remove %s", cert_path);
+ g_free(cert_path);
+
+ cert_path = g_key_file_get_string(keyfile, group_name,
+ CONNMAN_CONFIG_FIELD_PVT_KEY_FILE, NULL);
+ DBG("Temporal %s", cert_path);
+ if (cert_path != NULL && remove(cert_path) != 0)
+ ERR("Failed to remove %s", cert_path);
+ g_free(cert_path);
+
+ cert_path = g_key_file_get_string(keyfile, group_name,
+ CONNMAN_CONFIG_FIELD_PVT_KEY_PASSPHRASE, NULL);
+ DBG("Temporal %s", cert_path);
+ if (cert_path != NULL && remove(cert_path) != 0)
+ ERR("Failed to remove %s", cert_path);
+ g_free(cert_path);
+
+ dirname = g_strdup_printf("%s/%s", WIFI_CERT_STORAGEDIR, ssid);
+ if (dirname != NULL) {
+ if (g_file_test(dirname, G_FILE_TEST_EXISTS) == TRUE)
+ if (g_file_test(dirname, G_FILE_TEST_IS_DIR) == TRUE)
+ rmdir(dirname);
+
+ g_free(dirname);
}
+ if (remove(config_file) != 0) {
+ err = -EIO;
+ goto out;
+ }
+
+out:
+ g_key_file_free(keyfile);
g_free(config_file);
+ g_free(group_name);
- return ret;
+ return err;
}
-gboolean netconfig_iface_wifi_create_config(NetconfigWifi *wifi,
- GHashTable *fields, GError **error)
+static gboolean __netconfig_copy_config(const char *src, const char *dst)
{
- DBG("netconfig_iface_wifi_create_config");
- g_return_val_if_fail(wifi != NULL, FALSE);
+ gchar *buf = NULL;
+ gsize length = 0;
+ GError *error = NULL;
+ gboolean result;
+
+ result = g_file_get_contents(src, &buf, &length, &error);
+ if (result != TRUE) {
+ ERR("Failed to read %s[%s]", error->message);
+ g_error_free(error);
+
+ return result;
+ }
+
+ result = g_file_set_contents(dst, buf, length, &error);
+ if (result != TRUE) {
+ ERR("Failed to write %s[%s]", error->message);
+ g_error_free(error);
+ }
+
+ INFO("Successfully installed[%d]", length);
+ g_free(buf);
- gboolean ret = TRUE;
+ if (remove(src) != 0)
+ WARN("Failed to remove %s", src);
+
+ return result;
+}
+
+static gboolean __netconfig_create_config(GVariant *fields)
+{
GKeyFile *keyfile = NULL;
- GHashTableIter iter;
- gpointer field, value;
- gchar *file_name = NULL;
- gchar *ssid_hex = NULL;
- gchar *grp_name = NULL;
-
- g_hash_table_iter_init(&iter, fields);
- while (g_hash_table_iter_next(&iter, &field, &value)) {
- if (NULL != value) {
- if (!strcmp(field, CONNMAN_CONFIG_FIELD_NAME)) {
- ssid_hex = __get_ssid(value);
+ GVariantIter *iter;
+ gchar *encoded_ssid = NULL;
+ gchar *dirname = NULL;
+ gchar *group_name = NULL;
+ gchar *field, *value;
+ gboolean updated = FALSE;
+ gchar *cert_file = NULL;
+ gchar *cert_path = NULL;
+ int err = 0;
+
+ g_variant_get(fields, "a{ss}", &iter);
+ while (g_variant_iter_loop(iter, "{ss}", &field, &value)) {
+ if (value != NULL) {
+ if (g_strcmp0(field, CONNMAN_CONFIG_FIELD_NAME) == 0) {
+ encoded_ssid = __get_encoded_ssid(value);
+
+ g_free(value);
+ g_free(field);
break;
- } else if (!strcmp(field, CONNMAN_CONFIG_FIELD_SSID)) {
- ssid_hex = g_strdup_printf("%s",
- (gchar *)value);
+ } else if (g_strcmp0(field, CONNMAN_CONFIG_FIELD_SSID) == 0) {
+ encoded_ssid = g_strdup(value);
+
+ g_free(field);
+ g_free(value);
break;
}
}
}
- if (NULL == ssid_hex) {
- DBG("Fail! Could not fetch the ssid");
- return FALSE;
+ if (encoded_ssid == NULL) {
+ ERR("Failed to fetch SSID");
+ goto out;
}
/* Create unique service group name */
- grp_name = g_strdup_printf("service_%s", ssid_hex);
- if(NULL == grp_name) {
- DBG("Fail! Could not create the service group name");
- g_free(ssid_hex);
- return FALSE;
+ group_name = g_strdup_printf("service_%s", encoded_ssid);
+ if (group_name == NULL) {
+ ERR("Failed to create service group name");
+ goto out;
}
keyfile = g_key_file_new();
- if (NULL == keyfile) {
- DBG("g_key_file_new() fails!");
- g_free(grp_name);
- g_free(ssid_hex);
- return FALSE;
+ if (keyfile == NULL) {
+ ERR("Failed to g_key_file_new");
+ goto out;
}
- g_hash_table_iter_init(&iter, fields);
- while (g_hash_table_iter_next(&iter, &field, &value)) {
- DBG("Field - [%s] Value - [%s]", field, value);
+ g_variant_iter_free(iter);
+
+ g_variant_get(fields, "a{ss}", &iter);
+ while (g_variant_iter_loop(iter, "{ss}", &field, &value)) {
+ if (g_strcmp0(field, CONNMAN_CONFIG_FIELD_SSID) == 0 ||
+ g_strcmp0(field, CONNMAN_CONFIG_FIELD_EAP_METHOD) == 0 ||
+ g_strcmp0(field, CONNMAN_CONFIG_FIELD_PHASE2) == 0) {
+ DBG("field: %s, value: %s", field, value);
+
+ if (value != NULL)
+ g_key_file_set_string(keyfile, group_name, field, value);
+ } else if (g_strcmp0(field, CONNMAN_CONFIG_FIELD_CA_CERT_FILE) == 0 ||
+ g_strcmp0(field, CONNMAN_CONFIG_FIELD_CLIENT_CERT_FILE) == 0 ||
+ g_strcmp0(field, CONNMAN_CONFIG_FIELD_PVT_KEY_FILE) == 0 ||
+ g_strcmp0(field, CONNMAN_CONFIG_FIELD_PVT_KEY_PASSPHRASE) == 0) {
+ if (value != NULL) {
+ cert_file = strrchr(value, '/');
+ if (cert_file == NULL) {
+ ERR("Failed to get cert file: %s", value);
+ goto out;
+ }
+
+ cert_file++;
+ DBG("field: %s, value: %s", field, cert_file);
+
+ dirname = g_strdup_printf("%s/%s",
+ WIFI_CERT_STORAGEDIR, encoded_ssid);
+ if (dirname == NULL) {
+ ERR("Failed to create dirname");
+ goto out;
+ }
+ if (g_file_test(dirname, G_FILE_TEST_IS_DIR) != TRUE) {
+ if (mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP |
+ S_IXGRP | S_IROTH | S_IXOTH) < 0) {
+ if (errno != EEXIST) {
+ g_free(dirname);
+ goto out;
+ }
+ }
+ }
+ g_free(dirname);
+
+ cert_path = g_strdup_printf("%s/%s/%s",
+ WIFI_CERT_STORAGEDIR, encoded_ssid, cert_file);
+ if (cert_path == NULL) {
+ ERR("Failed to create cert path");
+ goto out;
+ }
+ if (__netconfig_copy_config(value, cert_path) != TRUE) {
+ ERR("Failed to read cert file %s", value);
+ g_free(cert_path);
+ goto out;
+ }
+
+ g_key_file_set_string(keyfile, group_name, field, cert_path);
+ g_free(cert_path);
+ }
+ } else {
+ //DBG("field: %s, value:", field);
+ DBG("Temporal field: %s, value: %s", field, value);
- if (NULL != value)
- g_key_file_set_string(keyfile, grp_name, field, value);
+ if (value != NULL)
+ g_key_file_set_string(keyfile, group_name, field, value);
+ }
}
- file_name = g_strdup_printf("%s/%s.config", CONNMAN_STORAGEDIR,
- ssid_hex);
- if(NULL == file_name) {
- DBG("g_strdup_printf() fails. Could not save config!");
+ err = __config_save((const char *)encoded_ssid, keyfile);
+ if (err < 0)
+ ERR("Failed to create configuration %s[%d]", encoded_ssid, err);
+ else {
+ DBG("Successfully created %s", encoded_ssid);
+ updated = TRUE;
+ }
+
+out:
+ if (keyfile)
g_key_file_free(keyfile);
- g_free(grp_name);
- g_free(ssid_hex);
+
+ g_variant_iter_free(iter);
+
+ if (field)
+ g_free(field);
+
+ if (value)
+ g_free(value);
+
+ g_free(group_name);
+ g_free(encoded_ssid);
+
+ return updated;
+}
+
+static gboolean __netconfig_delete_config(const char *profile)
+{
+ char *wifi_ident = NULL;
+ char *essid = NULL;
+ char *mode = NULL;
+ char *ssid = NULL;
+ int ssid_len = 0;
+ int err = 0;
+
+ if (NULL == profile) {
+ ERR("Invalid profile name");
return FALSE;
}
- ret = __config_save(keyfile, file_name);
- if (FALSE == ret)
- DBG("Could not save config!");
- else
- DBG("Saved config in [%s] successfully", file_name);
+ wifi_ident = strstr(profile, "wifi_");
+ if (wifi_ident == NULL) {
+ ERR("Invalid profile name");
+ return FALSE;
+ }
- g_key_file_free(keyfile);
- g_free(file_name);
- g_free(grp_name);
- g_free(ssid_hex);
+ essid = strchr(wifi_ident + 5, '_');
+ if (essid == NULL) {
+ ERR("Invalid profile name");
+ return FALSE;
+ }
- return ret;
+ essid++;
+ mode = strchr(essid, '_');
+
+ ssid_len = mode - essid;
+
+ ssid = g_try_malloc0(ssid_len + 1);
+ if (ssid == NULL) {
+ ERR("Memory allocation failed");
+ return FALSE;
+ }
+
+ g_strlcpy(ssid, essid, ssid_len + 1); /* include NULL-terminated */
+ err = __config_delete((const char *)ssid);
+ if (err < 0) {
+ ERR("Failed to delete configuration %s[%d]", ssid, err);
+ g_free(ssid);
+ return FALSE;
+ }
+
+ DBG("Successfully deleted %s with length %d", ssid, ssid_len);
+
+ g_free(ssid);
+ return TRUE;
+}
+
+static void __netconfig_eap_state(
+ enum netconfig_wifi_service_state state, void *user_data);
+
+static struct netconfig_wifi_state_notifier netconfig_eap_notifier = {
+ .netconfig_wifi_state_changed = __netconfig_eap_state,
+ .user_data = NULL,
+};
+
+static void __netconfig_eap_state(
+ enum netconfig_wifi_service_state state, void *user_data)
+{
+ const char *wifi_profile = (const char *)user_data;
+
+ if (wifi_profile == NULL) {
+ netconfig_wifi_state_notifier_unregister(&netconfig_eap_notifier);
+ return;
+ }
+
+ if (state != NETCONFIG_WIFI_CONNECTED && state != NETCONFIG_WIFI_FAILURE)
+ return;
+
+ if (state == NETCONFIG_WIFI_FAILURE)
+ __netconfig_delete_config(wifi_profile);
+
+ g_free(netconfig_eap_notifier.user_data);
+ netconfig_eap_notifier.user_data = NULL;
+
+ netconfig_wifi_state_notifier_unregister(&netconfig_eap_notifier);
}
-gboolean netconfig_iface_wifi_delete_config(NetconfigWifi *wifi,
- gchar *profile, GError **error)
+gboolean handle_create_eap_config(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *service, GVariant *fields)
{
- DBG("netconfig_iface_wifi_delete_config");
+ gboolean updated = FALSE;
+ gboolean reply = FALSE;
+ gboolean result = FALSE;
+
g_return_val_if_fail(wifi != NULL, FALSE);
- gboolean ret = TRUE;
- char *str1 = NULL;
- char *str2 = NULL;
- char *str3 = NULL;
- char ssid[512] = "";
- int ssid_len = 0;
+ DBG("Set agent fields for %s", service);
- str1 = strstr(profile, "wifi_");
- if (NULL != str1) {
- str2 = strchr(str1 + 5, '_');
- if (NULL != str2) {
- str3 = strchr(str2 + 1, '_');
- ssid_len = str3 - str2 - 1;
- strncpy(ssid, str2 + 1, ssid_len);
- DBG("ssid_len - [%d] SSID - [%s]", ssid_len, ssid);
-
- ret = __config_delete(ssid);
- if (TRUE == ret)
- DBG("Deleted the config file successfully");
- else
- DBG("Deletion of config file failed");
- } else {
- DBG("Fetching of SSID fails");
+ if (netconfig_is_wifi_profile(service) != TRUE) {
+ netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_WRONG_PROFILE, "InvalidService");
+ return reply;
+ }
+
+ updated = __netconfig_create_config(fields);
+ if (updated == TRUE) {
+ wifi_complete_create_eap_config(wifi, context);
+
+ if (g_strstr_len(service, strlen(service), "_hidden_") != NULL) {
+ GVariantIter *iter;
+ char *field, *value;
+ const char *name = NULL;
+ const char *identity = NULL;
+ const char *passphrase = NULL;
+
+ g_variant_get(fields, "a{ss}", &iter);
+
+ while (g_variant_iter_loop(iter, "{ss}", &field, &value)) {
+ if (g_strcmp0(field, CONNMAN_CONFIG_FIELD_NAME) == 0)
+ name = (const char *)value;
+ else if (g_strcmp0(field, CONNMAN_CONFIG_FIELD_SSID) == 0)
+ name = (const char *)value;
+ else if (g_strcmp0(field, CONNMAN_CONFIG_FIELD_IDENTITY) == 0)
+ identity = (const char *)value;
+ else if (g_strcmp0(field, CONNMAN_CONFIG_FIELD_PASSPHRASE) == 0)
+ passphrase = (const char *)value;
+ }
+
+ netconfig_wifi_set_agent_field_for_eap_network(
+ name, identity, passphrase);
+
+ g_variant_iter_free(iter);
}
+
+ result = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
+ service, CONNMAN_SERVICE_INTERFACE, "Connect", NULL, NULL);
+
+ if (netconfig_eap_notifier.user_data != NULL) {
+ g_free(netconfig_eap_notifier.user_data);
+ netconfig_eap_notifier.user_data = NULL;
+
+ netconfig_wifi_state_notifier_unregister(&netconfig_eap_notifier);
+ }
+
+ netconfig_eap_notifier.user_data = g_strdup(service);
+ netconfig_wifi_state_notifier_register(&netconfig_eap_notifier);
} else {
- DBG("Fetching of SSID fails");
+ netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INVALID_PARAMETER, "InvalidArguments");
}
+ if (result != TRUE)
+ ERR("Fail to connect %s", service);
+ else
+ reply = TRUE;
+
+ return reply;
+}
+
+gboolean handle_delete_eap_config(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *profile)
+{
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ wifi_complete_delete_eap_config(wifi, context);
+
+ gboolean ret = __netconfig_delete_config((const char *)profile);
+
return ret;
}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
-#include <tapi_common.h>
-#include <TapiUtility.h>
-#include <ITapiSim.h>
-
#include "log.h"
#include "util.h"
#include "netdbus.h"
#include "neterror.h"
+#include "wifi-tel-intf.h"
+#include "network-state.h"
+#include "wifi-eap.h"
#define SIM_RAND_DATA_LEN 16
#define SIM_AUTH_MAX_RESP_DATA_LEN 128
char *integrity_data;
};
-TapiHandle *tapi_handle = NULL;
static struct wifii_authentication_data *wifi_authdata;
-static void *__netconfig_wifi_free_wifi_authdata(struct wifii_authentication_data *data)
+static void *__netconfig_wifi_free_wifi_authdata(
+ struct wifii_authentication_data *data)
{
- if (data) {
+ if (data != NULL) {
if (data->resp_data)
g_free(data->resp_data);
if (data->authentication_key)
return NULL;
}
-static void __netconfig_tapi_init()
+static void __netconfig_wifi_clean_authentication(void)
{
- tapi_handle = tel_init(NULL);
-}
-
-static void __netconfig_tapi_deinit()
-{
- tel_deinit(tapi_handle);
- tapi_handle = NULL;
+ netconfig_tel_deinit();
wifi_authdata = __netconfig_wifi_free_wifi_authdata(wifi_authdata);
}
-static gboolean __netconfig_wifi_get_sim_imsi(DBusGMethodInvocation *context)
+static gboolean __netconfig_wifi_get_sim_imsi(Wifi *wifi,
+ GDBusMethodInvocation *context)
{
- DBG(" ");
-
int ret;
- GError *error = NULL;
+ TapiHandle *handle;
TelSimImsiInfo_t imsi_info;
char *imsi;
- if (tapi_handle == NULL)
- __netconfig_tapi_init();
+ handle = (TapiHandle *)netconfig_tel_init();
+ if (handle == NULL) {
+ ERR("tapi_init failed");
+ netconfig_error_fail_get_imsi(context);
+ return FALSE;
+ }
- ret = tel_get_sim_imsi(tapi_handle, &imsi_info);
+ ERR("before tel_get_sim_imsi");
+ ret = tel_get_sim_imsi(handle, &imsi_info);
+ ERR("after tel_get_sim_imsi");
if (ret != TAPI_API_SUCCESS) {
ERR("Failed tel_get_sim_imsi() : [%d]", ret);
- netconfig_error_fail_get_imsi(&error);
- dbus_g_method_return_error(context, error);
+ netconfig_error_fail_get_imsi(context);
return FALSE;
}
- imsi = g_strdup_printf("%s%s%s", imsi_info.szMcc, imsi_info.szMnc, imsi_info.szMsin);
+ imsi = g_strdup_printf("%s%s%s", imsi_info.szMcc,
+ imsi_info.szMnc, imsi_info.szMsin);
- dbus_g_method_return(context, imsi);
+ wifi_complete_get_sim_imsi(wifi, context, imsi);
g_free(imsi);
return TRUE;
}
-void __netconfig_response_sim_authentication(TapiHandle *handle, int result, void *data, void *user_data)
+void __netconfig_response_sim_authentication(TapiHandle *handle,
+ int result, void *data, void *user_data)
{
- DBG(" ");
-
if (wifi_authdata != NULL)
wifi_authdata = __netconfig_wifi_free_wifi_authdata(wifi_authdata);
wifi_authdata = g_try_new0(struct wifii_authentication_data, 1);
- TelSimAuthenticationResponse_t *auth_resp = (TelSimAuthenticationResponse_t *) data;
+ TelSimAuthenticationResponse_t *auth_resp =
+ (TelSimAuthenticationResponse_t *) data;
if (auth_resp == NULL) {
ERR("the auth response is NULL");
+
wifi_authdata->auth_result = -1;
return;
- } else {
+ } else
wifi_authdata->auth_result = auth_resp->auth_result;
- }
if (auth_resp->auth_result == TAPI_SIM_AUTH_NO_ERROR) {
wifi_authdata->resp_length = auth_resp->resp_length;
- wifi_authdata->authentication_key_length = auth_resp->authentication_key_length;
+ wifi_authdata->authentication_key_length =
+ auth_resp->authentication_key_length;
if (wifi_authdata->resp_data != NULL)
g_free(wifi_authdata->resp_data);
+
wifi_authdata->resp_data = g_strdup(auth_resp->resp_data);
if (wifi_authdata->authentication_key != NULL)
g_free(wifi_authdata->authentication_key);
- wifi_authdata->authentication_key = g_strdup(auth_resp->authentication_key);
+
+ wifi_authdata->authentication_key =
+ g_strdup(auth_resp->authentication_key);
} else {
ERR("the result error for sim auth : [%d]", auth_resp->auth_result);
+
wifi_authdata->resp_length = 0;
wifi_authdata->authentication_key_length = 0;
}
}
-void __netconfig_response_aka_authentication(TapiHandle *handle, int result, void *data, void *user_data)
+void __netconfig_response_aka_authentication(TapiHandle *handle,
+ int result, void *data, void *user_data)
{
- DBG(" ");
-
if (wifi_authdata != NULL)
wifi_authdata = __netconfig_wifi_free_wifi_authdata(wifi_authdata);
wifi_authdata = g_try_new0(struct wifii_authentication_data, 1);
- TelSimAuthenticationResponse_t *auth_resp = (TelSimAuthenticationResponse_t *) data;
+ TelSimAuthenticationResponse_t *auth_resp =
+ (TelSimAuthenticationResponse_t *) data;
if (auth_resp == NULL) {
ERR("the auth response is NULL");
+
wifi_authdata->auth_result = -1;
return;
- } else {
+ } else
wifi_authdata->auth_result = auth_resp->auth_result;
- }
if (auth_resp->auth_result == TAPI_SIM_AUTH_NO_ERROR) {
wifi_authdata->resp_length = auth_resp->resp_length;
if (wifi_authdata->resp_data != NULL)
g_free(wifi_authdata->resp_data);
+
wifi_authdata->resp_data = g_strdup(auth_resp->resp_data);
if (wifi_authdata->cipher_data != NULL)
g_free(wifi_authdata->cipher_data);
+
wifi_authdata->cipher_data = g_strdup(auth_resp->cipher_data);
if (wifi_authdata->integrity_data != NULL)
g_free(wifi_authdata->integrity_data);
+
wifi_authdata->integrity_data = g_strdup(auth_resp->integrity_data);
} else {
ERR("the result error for aka auth : [%d]", auth_resp->auth_result);
+
if (auth_resp->auth_result == TAPI_SIM_AUTH_SQN_FAILURE ||
auth_resp->auth_result == TAPI_SIM_AUTH_SYNCH_FAILURE) {
wifi_authdata->resp_length = auth_resp->resp_length;
if (wifi_authdata->resp_data != NULL)
g_free(wifi_authdata->resp_data);
+
wifi_authdata->resp_data = g_strdup(auth_resp->resp_data);
}
}
}
-static gboolean __netconfig_wifi_req_sim_auth(GArray *rand_data, GError **error)
+static gboolean __netconfig_wifi_req_sim_auth(GArray *rand_data,
+ GDBusMethodInvocation *context)
{
- DBG(" ");
-
int i;
int ret;
+ TapiHandle *handle;
TelSimAuthenticationData_t auth_data;
+ if (rand_data == NULL)
+ return FALSE;
+
if (rand_data->len != SIM_RAND_DATA_LEN) {
ERR("wrong rand data len : [%d]", rand_data->len);
- netconfig_error_fail_req_sim_auth_wrong_param(error);
+
+ netconfig_error_fail_req_sim_auth_wrong_param(context);
return FALSE;
}
if ((ret = g_array_get_element_size(rand_data)) != 1) {
ERR("wrong rand data size : [%d]", ret);
- netconfig_error_fail_req_sim_auth_wrong_param(error);
+
+ netconfig_error_fail_req_sim_auth_wrong_param(context);
return FALSE;
}
memset(&auth_data, 0, sizeof(auth_data));
+
auth_data.auth_type = TAPI_SIM_AUTH_TYPE_GSM;
auth_data.rand_length = SIM_RAND_DATA_LEN;
+
for (i=0; i<rand_data->len; i++)
auth_data.rand_data[i] = g_array_index(rand_data, guint8, i);
- if (tapi_handle == NULL)
- __netconfig_tapi_init();
+ handle = (TapiHandle *)netconfig_tel_init();
+ if (handle == NULL) {
+ netconfig_error_fail_req_sim_auth(context);
+ return FALSE;
+ }
- ret = tel_req_sim_authentication(tapi_handle, &auth_data, __netconfig_response_sim_authentication, NULL);
+ ret = tel_req_sim_authentication(handle,
+ &auth_data, __netconfig_response_sim_authentication, NULL);
if (ret != TAPI_API_SUCCESS) {
ERR("Failed tel_req_sim_authentication() : [%d]", ret);
- netconfig_error_fail_req_sim_auth(error);
+
+ netconfig_error_fail_req_sim_auth(context);
return FALSE;
}
return TRUE;
}
-static gboolean __netconfig_wifi_req_aka_auth(GArray *rand_data, GArray *autn_data, GError **error)
+static gboolean __netconfig_wifi_req_aka_auth(
+ GArray *rand_data, GArray *autn_data, GDBusMethodInvocation *context)
{
- DBG(" ");
-
int i;
int ret;
+ TapiHandle *handle;
TelSimAuthenticationData_t auth_data;
+ if (rand_data == NULL || autn_data == NULL)
+ return FALSE;
+
if (rand_data->len != AKA_RAND_DATA_LEN) {
ERR("wrong rand data len : [%d]", rand_data->len);
- netconfig_error_fail_req_sim_auth_wrong_param(error);
+
+ netconfig_error_fail_req_sim_auth_wrong_param(context);
return FALSE;
}
if (autn_data->len != AKA_AUTN_DATA_LEN) {
ERR("wrong autn data len : [%d]", autn_data->len);
- netconfig_error_fail_req_sim_auth_wrong_param(error);
+
+ netconfig_error_fail_req_sim_auth_wrong_param(context);
return FALSE;
}
if ((ret = g_array_get_element_size(rand_data)) != 1) {
ERR("wrong rand data size : [%d]", ret);
- netconfig_error_fail_req_sim_auth_wrong_param(error);
+
+ netconfig_error_fail_req_sim_auth_wrong_param(context);
return FALSE;
}
if ((ret = g_array_get_element_size(autn_data)) != 1) {
ERR("wrong autn data size : [%d]", ret);
- netconfig_error_fail_req_sim_auth_wrong_param(error);
+
+ netconfig_error_fail_req_sim_auth_wrong_param(context);
return FALSE;
}
memset(&auth_data, 0, sizeof(auth_data));
+
auth_data.auth_type = TAPI_SIM_AUTH_TYPE_3G;
auth_data.rand_length = AKA_RAND_DATA_LEN;
auth_data.autn_length = AKA_AUTN_DATA_LEN;
+
for (i=0; i<rand_data->len; i++)
auth_data.rand_data[i] = g_array_index(rand_data, guint8, i);
+
for (i=0; i<autn_data->len; i++)
auth_data.autn_data[i] = g_array_index(autn_data, guint8, i);
- if (tapi_handle == NULL)
- __netconfig_tapi_init();
+ handle = (TapiHandle *)netconfig_tel_init();
+ if (handle == NULL) {
+ netconfig_error_fail_req_sim_auth(context);
+ return FALSE;
+ }
+
+ ret = tel_req_sim_authentication(handle, &auth_data,
+ __netconfig_response_aka_authentication, NULL);
- ret = tel_req_sim_authentication(tapi_handle, &auth_data, __netconfig_response_aka_authentication, NULL);
if (ret != TAPI_API_SUCCESS) {
ERR("Failed tel_req_sim_authentication() : [%d]", ret);
- netconfig_error_fail_req_sim_auth(error);
+
+ netconfig_error_fail_req_sim_auth(context);
return FALSE;
}
-
return TRUE;
}
-static gboolean __netconfig_wifi_get_sim_authdata(DBusGMethodInvocation *context)
+static gboolean __netconfig_wifi_get_sim_authdata(Wifi *wifi,
+ GDBusMethodInvocation *context)
{
- DBG(" ");
-
GArray *array = NULL;
- GError *error = NULL;
if (wifi_authdata == NULL) {
DBG("the status error : no response yet");
- netconfig_error_fail_get_sim_auth_delay(&error);
- dbus_g_method_return_error(context, error);
+ netconfig_error_fail_get_sim_auth_delay(context);
return FALSE;
}
if (wifi_authdata->auth_result == TAPI_SIM_AUTH_NO_ERROR) {
if (wifi_authdata->resp_length == SIM_AUTH_SRES_LEN &&
wifi_authdata->authentication_key_length == SIM_AUTH_KC_LEN) {
- array = g_array_sized_new(FALSE, FALSE, sizeof(guchar), SIM_AUTH_SRES_LEN+SIM_AUTH_KC_LEN);
- g_array_append_vals(array, wifi_authdata->resp_data, SIM_AUTH_SRES_LEN);
- g_array_append_vals(array, wifi_authdata->authentication_key, SIM_AUTH_KC_LEN);
- dbus_g_method_return(context, array);
- g_array_free (array, TRUE);
+ array = g_array_sized_new(FALSE, FALSE, sizeof(guchar),
+ SIM_AUTH_SRES_LEN+SIM_AUTH_KC_LEN);
+ g_array_append_vals(array, wifi_authdata->resp_data,
+ SIM_AUTH_SRES_LEN);
+ g_array_append_vals(array, wifi_authdata->authentication_key,
+ SIM_AUTH_KC_LEN);
} else {
ERR("auth data length is wrong, SRES = [%d], Kc = [%d]",
- wifi_authdata->resp_length, wifi_authdata->authentication_key_length);
-
- netconfig_error_fail_get_sim_auth_wrong_data(&error);
- dbus_g_method_return_error(context, error);
- __netconfig_tapi_deinit();
+ wifi_authdata->resp_length,
+ wifi_authdata->authentication_key_length);
+ netconfig_error_fail_get_sim_auth_wrong_data(context);
+ __netconfig_wifi_clean_authentication();
return FALSE;
}
} else {
ERR("failed auth result = [%d]", wifi_authdata->auth_result);
- netconfig_error_fail_get_sim_auth_wrong_data(&error);
- dbus_g_method_return_error(context, error);
- __netconfig_tapi_deinit();
+ netconfig_error_fail_get_sim_auth_wrong_data(context);
+ __netconfig_wifi_clean_authentication();
return FALSE;
}
- __netconfig_tapi_deinit();
+ wifi_complete_get_sim_auth(wifi, context, array->data);
+ g_array_free (array, TRUE);
+ __netconfig_wifi_clean_authentication();
return TRUE;
}
-static gboolean __netconfig_wifi_get_aka_authdata(DBusGMethodInvocation *context)
+static gboolean __netconfig_wifi_get_aka_authdata(Wifi *wifi, GDBusMethodInvocation *context)
{
- DBG(" ");
-
GArray *array = NULL;
- GError *error = NULL;
guchar res_len;
if (wifi_authdata == NULL) {
DBG("the status error : no response yet");
- netconfig_error_fail_get_sim_auth_delay(&error);
- dbus_g_method_return_error(context, error);
+ netconfig_error_fail_get_sim_auth_delay(context);
return FALSE;
}
case TAPI_SIM_AUTH_SQN_FAILURE:
case TAPI_SIM_AUTH_SYNCH_FAILURE:
- array = g_array_sized_new(FALSE, FALSE, sizeof(guchar), wifi_authdata->resp_length+1);
+ array = g_array_sized_new(FALSE, FALSE, sizeof(guchar),
+ wifi_authdata->resp_length+1);
res_len = (guchar)((wifi_authdata->resp_length-1) & 0xff);
g_array_append_vals(array, &res_len, 1);
- g_array_append_vals(array, wifi_authdata->resp_data, wifi_authdata->resp_length);
+ g_array_append_vals(array, wifi_authdata->resp_data,
+ wifi_authdata->resp_length);
- dbus_g_method_return(context, array);
+ wifi_complete_get_aka_auth(wifi, context, array->data);
g_array_free (array, TRUE);
- g_free(wifi_authdata->resp_data);
- g_free(wifi_authdata);
- wifi_authdata = NULL;
+ __netconfig_wifi_clean_authentication();
return TRUE;
default:
- netconfig_error_fail_get_sim_auth_wrong_data(&error);
- dbus_g_method_return_error(context, error);
- __netconfig_tapi_deinit();
+ netconfig_error_fail_get_sim_auth_wrong_data(context);
+ __netconfig_wifi_clean_authentication();
return FALSE;
}
wifi_authdata->resp_length <= AKA_AUTH_RES_MAX_LEN) &&
wifi_authdata->cipher_length == AKA_AUTH_CK_LEN &&
wifi_authdata->integrity_length == AKA_AUTH_IK_LEN) {
- array = g_array_sized_new(FALSE, FALSE, sizeof(guchar), wifi_authdata->resp_length+AKA_AUTH_CK_LEN+AKA_AUTH_IK_LEN+1);
+ array = g_array_sized_new(FALSE, FALSE, sizeof(guchar),
+ wifi_authdata->resp_length+AKA_AUTH_CK_LEN+AKA_AUTH_IK_LEN+1);
res_len = (guchar)((wifi_authdata->resp_length-1) & 0xff);
g_array_append_vals(array, &res_len, 1);
- g_array_append_vals(array, wifi_authdata->resp_data, wifi_authdata->resp_length);
- g_array_append_vals(array, wifi_authdata->cipher_data, AKA_AUTH_CK_LEN);
- g_array_append_vals(array, wifi_authdata->integrity_data, AKA_AUTH_IK_LEN);
-
- dbus_g_method_return(context, array);
- g_array_free (array, TRUE);
+ g_array_append_vals(array, wifi_authdata->resp_data,
+ wifi_authdata->resp_length);
+ g_array_append_vals(array, wifi_authdata->cipher_data,
+ AKA_AUTH_CK_LEN);
+ g_array_append_vals(array, wifi_authdata->integrity_data,
+ AKA_AUTH_IK_LEN);
} else {
ERR("auth data length is wrong, res = [%d], Kc = [%d], Ki = [%d]",
- wifi_authdata->resp_length, wifi_authdata->cipher_length, wifi_authdata->integrity_length);
+ wifi_authdata->resp_length, wifi_authdata->cipher_length,
+ wifi_authdata->integrity_length);
- netconfig_error_fail_get_sim_auth_wrong_data(&error);
- dbus_g_method_return_error(context, error);
- __netconfig_tapi_deinit();
+ netconfig_error_fail_get_sim_auth_wrong_data(context);
+ __netconfig_wifi_clean_authentication();
return FALSE;
}
- __netconfig_tapi_deinit();
+ wifi_complete_get_aka_auth(wifi, context, array->data);
+ g_array_free (array, TRUE);
+ __netconfig_wifi_clean_authentication();
+
return TRUE;
}
-gboolean netconfig_iface_wifi_get_sim_imsi(NetconfigWifi *wifi, DBusGMethodInvocation *context)
+gboolean handle_get_sim_imsi(Wifi *wifi, GDBusMethodInvocation *context)
{
gboolean ret = TRUE;
- DBG("Get sim Imsi");
+ DBG("Get IMSI");
g_return_val_if_fail(wifi != NULL, FALSE);
- ret = __netconfig_wifi_get_sim_imsi(context);
+ ret = __netconfig_wifi_get_sim_imsi(wifi, context);
return ret;
}
-gboolean netconfig_iface_wifi_req_sim_auth(NetconfigWifi *wifi, GArray *rand_data, gboolean *result, GError **error)
+gboolean handle_req_sim_auth(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *rand_data)
{
- gboolean ret = TRUE;
+ gboolean result = TRUE;
- DBG("Req sim Authentication");
+ DBG("Request SIM Authentication");
g_return_val_if_fail(wifi != NULL, FALSE);
- ret = __netconfig_wifi_req_sim_auth(rand_data, error);
+ result = __netconfig_wifi_req_sim_auth((GArray *)rand_data, context);
- *result = ret;
- return ret;
+ if (result)
+ wifi_complete_req_sim_auth(wifi, context, result);
+
+ return result;
}
-gboolean netconfig_iface_wifi_req_aka_auth(NetconfigWifi *wifi, GArray *rand_data, GArray *autn_data, gboolean *result, GError **error)
+gboolean handle_req_aka_auth(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *rand_data, const gchar *autn_data)
{
- gboolean ret = TRUE;
+ gboolean result = TRUE;
+ GArray *rand_data_garray;
+ GArray *autn_data_garray;
+
+ rand_data_garray = g_array_sized_new(FALSE, FALSE, sizeof(guchar),
+ strlen(rand_data));
+ memcpy(rand_data_garray->data, rand_data, rand_data_garray->len);
- DBG("Req aka Authentication");
+ autn_data_garray = g_array_sized_new(FALSE, FALSE, sizeof(guchar),
+ strlen(autn_data));
+ memcpy(autn_data_garray->data, rand_data, autn_data_garray->len);
+
+ DBG("Request AKA Authentication");
g_return_val_if_fail(wifi != NULL, FALSE);
- ret = __netconfig_wifi_req_aka_auth(rand_data, autn_data, error);
+ result = __netconfig_wifi_req_aka_auth(rand_data_garray, autn_data_garray, context);
+ if (result) {
+ wifi_complete_req_aka_auth(wifi, context, result);
+ } else {
+ netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_FAILED_REQ_AKA_AUTH, "FailReqAkaAuth");
+ }
+
+ g_array_free(rand_data_garray, FALSE);
+ g_array_free(autn_data_garray, FALSE);
- *result = ret;
- return ret;
+ return result;
}
-gboolean netconfig_iface_wifi_get_sim_auth(NetconfigWifi *wifi, DBusGMethodInvocation *context)
+gboolean handle_get_sim_auth(Wifi *wifi, GDBusMethodInvocation *context)
{
gboolean ret = TRUE;
- DBG("Get sim Authdata");
+ DBG("Get SIM Authdata");
g_return_val_if_fail(wifi != NULL, FALSE);
- ret = __netconfig_wifi_get_sim_authdata(context);
-
+ ret = __netconfig_wifi_get_sim_authdata(wifi, context);
return ret;
}
-gboolean netconfig_iface_wifi_get_aka_auth(NetconfigWifi *wifi, DBusGMethodInvocation *context)
+gboolean handle_get_aka_auth(Wifi *wifi, GDBusMethodInvocation *context)
{
gboolean ret = TRUE;
- DBG("Get aka Authdata");
+ DBG("Get AKA Authdata");
g_return_val_if_fail(wifi != NULL, FALSE);
- ret = __netconfig_wifi_get_aka_authdata(context);
+ ret = __netconfig_wifi_get_aka_authdata(wifi, context);
return ret;
}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
-
#include <errno.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+
#include "log.h"
#include "util.h"
#include "netdbus.h"
#include "netsupplicant.h"
#include "wifi-firmware.h"
#include "network-statistics.h"
+#if defined WLAN_CHECK_POWERSAVE
+#include "wifi-powersave.h"
+#endif
-
+#define WLAN_DRIVER_SCRIPT "/usr/bin/wlan.sh"
+#define WLAN_IFACE_NAME "wlan0"
#define WLAN_P2P_IFACE_NAME "p2p0"
static int __netconfig_sta_firmware_start(void)
{
int rv = 0;
+ const char *path = WLAN_DRIVER_SCRIPT;
+ char *const args[] = { "/usr/bin/wlan.sh", "start", NULL };
+ char *const envs[] = { NULL };
- rv = netconfig_interface_up(WIFI_IFNAME);
- if (!rv)
+ rv = netconfig_execute_file(path, args, envs);
+ if (rv < 0)
return -EIO;
- INFO("Successfully loaded wireless device driver");
+ rv = netconfig_interface_up(WLAN_IFACE_NAME);
+ if (rv != TRUE)
+ return -EIO;
+
+ DBG("Successfully loaded wireless device driver");
return 0;
}
static int __netconfig_sta_firmware_stop(void)
{
-
int rv = 0;
+ const char *path = WLAN_DRIVER_SCRIPT;
+ char *const args[] = { "/usr/bin/wlan.sh", "stop", NULL };
+ char *const envs[] = { NULL };
/* Update statistics before driver remove */
netconfig_wifi_statistics_update_powered_off();
- rv = netconfig_interface_down(WIFI_IFNAME);
- if (!rv)
+ rv = netconfig_interface_down(WLAN_IFACE_NAME);
+ if (rv != TRUE)
+ return -EIO;
+
+ rv = netconfig_execute_file(path, args, envs);
+ if (rv < 0)
return -EIO;
- INFO("Successfully removed wireless device driver");
+ DBG("Successfully removed wireless device driver");
return 0;
}
-
static int __netconfig_p2p_firmware_start(void)
{
-
#if defined TIZEN_P2P_ENABLE
int rv = 0;
+ const char *path = WLAN_DRIVER_SCRIPT;
+ char *const args[] = { "/usr/bin/wlan.sh", "p2p", NULL };
+ char *const envs[] = { NULL };
+
+ rv = netconfig_execute_file(path, args, envs);
+ if (rv < 0)
+ return -EIO;
+
+ rv = netconfig_interface_up(WLAN_IFACE_NAME);
+ if (rv != TRUE)
+ return -EIO;
+
+#if defined TIZEN_WLAN_USE_P2P_INTERFACE
rv = netconfig_interface_up(WLAN_P2P_IFACE_NAME);
- if (!rv)
+ if (rv != TRUE)
return -EIO;
+#endif
- INFO("Successfully up p2p device driver");
- return 0;
+ DBG("Successfully loaded p2p device driver");
+ return 0;
#else
- INFO("P2P Device is not supported");
return -ENODEV;
#endif
-
}
static int __netconfig_p2p_firmware_stop(void)
{
-
#if defined TIZEN_P2P_ENABLE
int rv = 0;
- rv = netconfig_interface_down(WLAN_P2P_IFACE_NAME);
- if (!rv)
+ const char *path = WLAN_DRIVER_SCRIPT;
+ char *const args[] = { "/usr/bin/wlan.sh", "stop", NULL };
+ char *const envs[] = { NULL };
+
+ rv = netconfig_interface_down(WLAN_IFACE_NAME);
+ if (rv != TRUE)
+ return -EIO;
+
+ rv = netconfig_execute_file(path, args, envs);
+ if (rv < 0)
return -EIO;
- INFO("Successfully down p2p device driver");
- return 0;
+ DBG("Successfully removed p2p device driver");
+ return 0;
#else
- INFO("P2P Device is not supported");
return -ENODEV;
#endif
+}
+
+static int __netconfig_softap_firmware_start(void)
+{
+#if defined TIZEN_TETHERING_ENABLE
+ int rv = 0;
+ const char *path = WLAN_DRIVER_SCRIPT;
+ char *const args[] = { "/usr/bin/wlan.sh", "softap", NULL };
+ char *const envs[] = { NULL };
+ rv = netconfig_execute_file(path, args, envs);
+ if (rv < 0)
+ return -EIO;
+
+ if (netconfig_interface_up(WLAN_IFACE_NAME) == FALSE)
+ return -EIO;
+
+ DBG("Successfully loaded softap device driver");
+ return 0;
+#else
+ return -ENODEV;
+#endif
}
-static int __netconfig_wifi_firmware_start(
- enum netconfig_wifi_firmware type)
+
+static int __netconfig_softap_firmware_stop(void)
{
+#if defined TIZEN_TETHERING_ENABLE
+ int rv = 0;
+ const char *path = WLAN_DRIVER_SCRIPT;
+ char *const args[] = { "/usr/bin/wlan.sh", "stop", NULL };
+ char *const envs[] = { NULL };
+
+ rv = netconfig_interface_down(WLAN_IFACE_NAME);
+ if (rv != TRUE)
+ return -EIO;
+
+ rv = netconfig_execute_file(path, args, envs);
+ if (rv < 0)
+ return -EIO;
+
+ DBG("Successfully removed softap device driver");
+ return 0;
+#else
+ return -ENODEV;
+#endif
+}
- INFO(" %d",type);
+static int __netconfig_wifi_firmware_start(enum netconfig_wifi_firmware type)
+{
if (netconfig_emulator_is_emulated() == TRUE)
return -EIO;
return __netconfig_sta_firmware_start();
case NETCONFIG_WIFI_P2P:
return __netconfig_p2p_firmware_start();
+ case NETCONFIG_WIFI_SOFTAP:
+ return __netconfig_softap_firmware_start();
default:
break;
}
return __netconfig_sta_firmware_stop();
case NETCONFIG_WIFI_P2P:
return __netconfig_p2p_firmware_stop();
+ case NETCONFIG_WIFI_SOFTAP:
+ return __netconfig_softap_firmware_stop();
default:
break;
}
alias = NETCONFIG_WIFI_STA;
#endif
- INFO("Wi-Fi current firmware %d (type: %d %s)", current_driver, type,
+ DBG("Wi-Fi current firmware %d (type: %d %s)", current_driver, type,
enable == TRUE ? "enable" : "disable");
if (enable == FALSE) {
if (current_driver == NETCONFIG_WIFI_OFF) {
return -EALREADY;
} else if (current_driver == alias) {
+#if defined WLAN_CHECK_POWERSAVE
+ if (type == NETCONFIG_WIFI_STA &&
+ netconfig_wifi_is_powersave_mode() == TRUE) {
+ netconfig_interface_down(WIFI_IFNAME);
+
+ return -EALREADY;
+ }
+#endif
#if defined WLAN_CONCURRENT_MODE
+#if defined TIZEN_TELEPHONY_ENABLE
vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode);
-
+#endif
if (flight_mode == 0 && type == NETCONFIG_WIFI_STA &&
netconfig_is_wifi_direct_on() == TRUE) {
netconfig_interface_down(WIFI_IFNAME);
if (current_driver > NETCONFIG_WIFI_OFF) {
if (current_driver == alias) {
+#if defined WLAN_CHECK_POWERSAVE
+ if (type == NETCONFIG_WIFI_STA &&
+ netconfig_wifi_is_powersave_mode() == TRUE) {
+ netconfig_interface_up(WIFI_IFNAME);
+
+ return -EALREADY;
+ }
+#endif
#if defined WLAN_CONCURRENT_MODE
if (type == NETCONFIG_WIFI_STA)
err = __netconfig_wifi_firmware_start(type);
if (err < 0)
- INFO("Failed to start the Firmware");
+ DBG("Failed to execute script file");
else
current_driver = alias;
return err;
}
-gboolean netconfig_iface_wifi_start(
- NetconfigWifi *wifi, gchar *device, GError **error)
+gboolean handle_start(WifiFirmware *firmware, GDBusMethodInvocation *context, const gchar *device)
{
int err;
- g_return_val_if_fail(wifi != NULL, FALSE);
+ g_return_val_if_fail(firmware != NULL, FALSE);
- INFO("Wi-Fi firmware start %s", device != NULL ? device : "null");
+ DBG("Wi-Fi firmware start %s", device != NULL ? device : "null");
if (g_strcmp0("p2p", device) == 0)
err = netconfig_wifi_firmware(NETCONFIG_WIFI_P2P, TRUE);
if (err < 0) {
if (err == -EALREADY)
- netconfig_error_already_exists(error);
+ netconfig_error_already_exists(context);
else
- netconfig_error_wifi_driver_failed(error);
+ netconfig_error_wifi_driver_failed(context);
+ wifi_firmware_complete_start(firmware, context);
return FALSE;
}
+ wifi_firmware_complete_start(firmware, context);
return TRUE;
}
-gboolean netconfig_iface_wifi_stop(
- NetconfigWifi *wifi, gchar *device, GError **error)
+gboolean handle_stop(WifiFirmware *firmware, GDBusMethodInvocation *context, const gchar *device)
{
int err;
- g_return_val_if_fail(wifi != NULL, FALSE);
+ g_return_val_if_fail(firmware != NULL, FALSE);
- INFO("Wi-Fi firmware stop %s", device != NULL ? device : "null");
+ DBG("Wi-Fi firmware stop %s", device != NULL ? device : "null");
if (g_strcmp0("p2p", device) == 0)
err = netconfig_wifi_firmware(NETCONFIG_WIFI_P2P, FALSE);
if (err < 0) {
if (err == -EALREADY)
- netconfig_error_already_exists(error);
+ netconfig_error_already_exists(context);
else
- netconfig_error_wifi_driver_failed(error);
+ netconfig_error_wifi_driver_failed(context);
+ wifi_firmware_complete_start(firmware, context);
return FALSE;
}
+ wifi_firmware_complete_start(firmware, context);
return TRUE;
}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
-
+#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include "log.h"
#include "util.h"
#include "netdbus.h"
+#include "wifi-state.h"
+#include "network-state.h"
#include "network-statistics.h"
#include "netsupplicant.h"
#include "wifi-indicator.h"
#define NETCONFIG_WIFI_INDICATOR_INTERVAL 1
-static guint64 netconfig_wifi_tx_bytes = 0;
-static guint64 netconfig_wifi_rx_bytes = 0;
+#if defined TIZEN_WEARABLE
+#define NETCONFIG_WIFI_DATA_ACTIVITY_BOOSTER_LEVEL1 (19200 * 1024)
+#define NETCONFIG_WIFI_DATA_ACTIVITY_BOOSTER_LEVEL2 (2560 * 1024)
+#define NETCONFIG_WIFI_DATA_ACTIVITY_BOOSTER_LEVEL3 (1536 * 1024)
+#else
+#define NETCONFIG_WIFI_DATA_ACTIVITY_BOOSTER_LEVEL1 (19200 * 1024)
+#define NETCONFIG_WIFI_DATA_ACTIVITY_BOOSTER_LEVEL2 (7680 * 1024)
+#define NETCONFIG_WIFI_DATA_ACTIVITY_BOOSTER_LEVEL3 (3840 * 1024)
+#endif
+#define NETCONFIG_PROCWIRELESS "/proc/net/wireless"
+static int netconfig_wifi_rssi = VCONFKEY_WIFI_SNR_MIN;
static guint netconfig_wifi_indicator_timer = 0;
-#if defined NL80211
-static int __netconfig_wifi_get_signal(const char *object_path)
-{
- DBusConnection *connection = NULL;
- DBusMessage *message = NULL;
- DBusMessageIter iter;
- int rssi_dbm = 0;
- int MessageType = 0;
-
- if (object_path == NULL) {
- ERR("Error!!! path is NULL");
- goto error;
- }
-
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
- if (connection == NULL) {
- ERR("Error!!! Failed to get system DBus");
- goto error;
- }
-
- message = netconfig_supplicant_invoke_dbus_method(
- SUPPLICANT_SERVICE, connection, object_path,
- SUPPLICANT_INTERFACE ".Interface", "GetLinkSignal",
- NULL);
-
- if (message == NULL) {
- ERR("Error!!! Failed to get service properties");
- goto error;
- }
-
- MessageType = dbus_message_get_type(message);
-
- if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
- const char *err_msg = dbus_message_get_error_name(message);
- ERR("Error!!! Error message received [%s]", err_msg);
- goto error;
- }
-
- dbus_message_iter_init(message, &iter);
-
- if ((MessageType = dbus_message_iter_get_arg_type(&iter)) == DBUS_TYPE_INT32)
- dbus_message_iter_get_basic(&iter, &rssi_dbm);
- else
- goto error;
-
- dbus_message_unref(message);
- dbus_connection_unref(connection);
-
- return rssi_dbm;
-
-error:
- if (message != NULL)
- dbus_message_unref(message);
-
- if (connection != NULL)
- dbus_connection_unref(connection);
-
- return VCONFKEY_WIFI_SNR_MIN;
-}
-
-static int __netconfig_wifi_get_rssi_from_supplicant(void)
+int netconfig_wifi_get_rssi(void)
{
- int rssi_dbm =0;
-
- char object_path[DBUS_PATH_MAX_BUFLEN] = { 0, };
- char *path_ptr = &object_path[0];
-
- if (netconfig_wifi_get_supplicant_interface(&path_ptr) != TRUE) {
- DBG("Fail to get wpa_supplicant DBus path");
- return VCONFKEY_WIFI_SNR_MIN;
- }
-
- rssi_dbm = __netconfig_wifi_get_signal((const char *)path_ptr);
-
- return rssi_dbm;
+ return netconfig_wifi_rssi;
}
-#endif /* #if defined NL80211 */
-#if !defined NL80211
-static int __netconfig_wifi_get_rssi_from_system(void)
+static int __netconfig_wifi_update_and_get_rssi(void)
{
- int rssi_dbm = 0;
- char ifname[16] = { 0, };
- char *ifname_ptr = &ifname[0];
-
- int fd = -1;
- struct iwreq wifi_req;
- struct iw_statistics stats;
- unsigned int iw_stats_len = sizeof(struct iw_statistics);
-
- if (netconfig_wifi_get_ifname(&ifname_ptr) != TRUE) {
- DBG("Fail to get Wi-Fi ifname from wpa_supplicant: %s", ifname_ptr);
- return VCONFKEY_WIFI_SNR_MIN;
- }
-
- /* Set device name */
- memset(wifi_req.ifr_name, 0, sizeof(wifi_req.ifr_name));
- strncpy(wifi_req.ifr_name, ifname, sizeof(wifi_req.ifr_name) - 1);
- wifi_req.ifr_name[sizeof(wifi_req.ifr_name) - 1] = '\0';
-
- wifi_req.u.data.pointer = (caddr_t) &stats;
- wifi_req.u.data.length = iw_stats_len;
- wifi_req.u.data.flags = 1; /* Clear updated flag */
-
- if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP)) < 0) {
- DBG("Fail to open socket to get rssi");
- return VCONFKEY_WIFI_SNR_MIN;
+ FILE *fp;
+ char buf[512];
+ char *p_ifname = NULL, *p_entry = NULL;
+ int rssi_dbm = VCONFKEY_WIFI_SNR_MIN;
+
+ fp = fopen(NETCONFIG_PROCWIRELESS, "r");
+ if (fp == NULL) {
+ ERR("Failed to open %s", NETCONFIG_PROCWIRELESS);
+ return rssi_dbm;
}
- memset(&stats, 0, iw_stats_len);
-
- if (ioctl(fd, SIOCGIWSTATS, &wifi_req) < 0) {
- DBG("Fail to execute ioctl for SIOCGIWSTATS");
- close(fd);
-
- return VCONFKEY_WIFI_SNR_MIN;
+ /* skip the first and second line */
+ if (fgets(buf, sizeof(buf), fp) == NULL ||
+ fgets(buf, sizeof(buf), fp) == NULL)
+ goto endline;
+
+ while (fgets(buf, sizeof(buf), fp)) {
+ unsigned int status;
+ int link, noise;
+ /* No need to read */
+ /*
+ unsigned long nwid, crypt, frag, retry, misc, missed;
+ */
+
+ p_ifname = buf;
+ while (*p_ifname == ' ') p_ifname++;
+ p_entry = strchr(p_ifname, ':');
+ if (p_entry == NULL)
+ goto endline;
+ *p_entry++ = '\0';
+
+ if (g_strcmp0(p_ifname, WIFI_IFNAME) != 0)
+ continue;
+
+ /* read wireless status */
+ p_entry = strtok(p_entry, " ."); // status "%x"
+ if (p_entry != NULL)
+ sscanf(p_entry, "%x", &status);
+ p_entry = strtok(NULL, " ."); // Quality link "%d"
+ if (p_entry != NULL)
+ sscanf(p_entry, "%d", &link);
+ p_entry = strtok(NULL, " ."); // Quality level "%d"
+ if (p_entry != NULL)
+ sscanf(p_entry, "%d", &rssi_dbm);
+ p_entry = strtok(NULL, " ."); // Quality noise "%d"
+ if (p_entry != NULL)
+ sscanf(p_entry, "%d", &noise);
+
+ /* No need to read */
+ /*
+ p_entry = strtok(NULL, " ."); // Discarded nwid "%lu"
+ sscanf(p_entry, "%lu", &nwid);
+ p_entry = strtok(NULL, " ."); // Discarded crypt "%lu"
+ sscanf(p_entry, "%lu", &crypt);
+ p_entry = strtok(NULL, " ."); // Discarded frag "%lu"
+ sscanf(p_entry, "%lu", &frag);
+ p_entry = strtok(NULL, " ."); // Discarded retry "%lu"
+ sscanf(p_entry, "%lu", &retry);
+ p_entry = strtok(NULL, " ."); // Discarded misc "%lu"
+ sscanf(p_entry, "%lu", &misc);
+ p_entry = strtok(NULL, " ."); // Discarded missed "%lu"
+ sscanf(p_entry, "%lu", &missed);
+ */
+
+ break;
}
- close(fd);
-
- rssi_dbm = stats.qual.level - 255; /** signed integer, so 255 */
-
- return rssi_dbm;
-}
-#endif /* #if !defined NL80211 */
-int netconfig_wifi_get_rssi(void)
-{
- int rssi_dbm = 0;
-
- /* There are two ways to get Wi-Fi RSSI:
- * - WEXT interface, get DBus path of wpa_supplicant,
- * and get Wi-Fi interface name e.g. wlan0 from wpa_supplicant.
- * IOCTL with ifname will return RSSI dB.
- * - NL80211 interface, get DBus path of wpa_supplicant,
- * and get RSSI from wpa_supplicant directly.
- * However, in this case wpa_supplicant needs some modification
- * to get RSSI from DBus interface. */
-
-#if defined NL80211
- rssi_dbm = __netconfig_wifi_get_rssi_from_supplicant();
-#else
- rssi_dbm = __netconfig_wifi_get_rssi_from_system();
-#endif
+endline:
+ fclose(fp);
+ netconfig_wifi_rssi = rssi_dbm;
return rssi_dbm;
}
-static void __netconfig_wifi_set_rssi_level(int rssi_dbm)
+int netconfig_wifi_rssi_level(const int rssi_dbm)
{
int snr_level = 0;
- static int last_snr_level = 0;
/* Wi-Fi Signal Strength Display
*
else
snr_level = 1;
- if (snr_level != last_snr_level) {
- INFO("Wi-Fi RSSI: %d dB, %d level", rssi_dbm, snr_level);
+ return snr_level;
+}
- vconf_set_int(VCONFKEY_WIFI_STRENGTH, snr_level);
+static void __netconfig_wifi_set_rssi_level(const int snr_level)
+{
+ static int last_snr_level = 0;
+ if (snr_level != last_snr_level) {
+ netconfig_set_vconf_int(VCONFKEY_WIFI_STRENGTH, snr_level);
last_snr_level = snr_level;
}
}
-static gboolean __netconfig_wifi_indicator_monitor(gpointer data)
+static void __netconfig_wifi_data_activity_booster(int level)
{
- int rssi_dbm = 0;
- int pm_state = VCONFKEY_PM_STATE_NORMAL;
- guint64 tx = 0, rx = 0;
+ gboolean reply = FALSE;
+ GVariant *params = NULL;
+ int level1 = 1;
+ int level2 = 2;
+ int level3 = 3;
+
+ int lock = 2000;
+ int unlock = 0;
+
+ static int old_level = 0;
+
+ if (level < 0)
+ return;
+
+ if (level > 0) {
+ /* enable booster */
+ switch(level) {
+ case 1:
+ params = g_variant_new("(ii)", level1, lock);
+ break;
+ case 2:
+ params = g_variant_new("(ii)", level2, lock);
+ break;
+ case 3:
+ params = g_variant_new("(ii)", level3, lock);
+ break;
+ default:
+ ERR("Invalid level");
+ return;
+ }
- /* In case of LCD off, we don't need to update Wi-Fi indicator */
- vconf_get_int(VCONFKEY_PM_STATE, &pm_state);
- if (pm_state >= VCONFKEY_PM_STATE_LCDOFF)
- return TRUE;
+ reply = netconfig_invoke_dbus_method_nonblock(
+ "org.tizen.system.deviced",
+ "/Org/Tizen/System/DeviceD/PmQos",
+ "org.tizen.system.deviced.PmQos",
+ "WifiThroughput",
+ params,
+ NULL);
+ if (reply != TRUE)
+ return;
+ }
+
+ /* disable previous booster */
+ if (old_level == 0 || old_level == level)
+ return;
+
+ switch(old_level) {
+ case 1:
+ params = g_variant_new("(ii)", level1, unlock);
+ break;
+ case 2:
+ params = g_variant_new("(ii)", level2, unlock);
+ break;
+ case 3:
+ params = g_variant_new("(ii)", level3, unlock);
+ break;
+ default:
+ ERR("Invalid level");
+ return;
+ }
- rssi_dbm = netconfig_wifi_get_rssi();
+ reply = netconfig_invoke_dbus_method_nonblock(
+ "org.tizen.system.deviced",
+ "/Org/Tizen/System/DeviceD/PmQos",
+ "org.tizen.system.deviced.PmQos",
+ "WifiThroughput",
+ params,
+ NULL);
+ if (reply != TRUE)
+ return;
+
+ old_level = level;
+}
+
+static void __netconfig_wifi_update_indicator(void)
+{
+ static int last_transfer_state = 0;
+ static guint64 netconfig_wifi_tx_bytes = 0;
+ static guint64 netconfig_wifi_rx_bytes = 0;
+ static int booster_tic = 0;
+ static int old_level = 0;
+ int booster_level = 0;
+ guint64 tx, rx, tx_diff, rx_diff;
+ int transfer_state;
if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE) {
- if (netconfig_wifi_tx_bytes < tx) {
- if (netconfig_wifi_rx_bytes < rx)
- vconf_set_int(VCONFKEY_WIFI_TRANSFER_STATE, VCONFKEY_WIFI_TRANSFER_STATE_TXRX);
+ tx_diff = tx - netconfig_wifi_tx_bytes;
+ rx_diff = rx - netconfig_wifi_rx_bytes;
+
+ if (tx_diff > 0) {
+ if (rx_diff > 0)
+ transfer_state = VCONFKEY_WIFI_TRANSFER_STATE_TXRX;
else
- vconf_set_int(VCONFKEY_WIFI_TRANSFER_STATE, VCONFKEY_WIFI_TRANSFER_STATE_TX);
+ transfer_state = VCONFKEY_WIFI_TRANSFER_STATE_TX;
} else {
- if (netconfig_wifi_rx_bytes < rx)
- vconf_set_int(VCONFKEY_WIFI_TRANSFER_STATE, VCONFKEY_WIFI_TRANSFER_STATE_RX);
+ if (rx_diff > 0)
+ transfer_state = VCONFKEY_WIFI_TRANSFER_STATE_RX;
else
- vconf_set_int(VCONFKEY_WIFI_TRANSFER_STATE, VCONFKEY_WIFI_TRANSFER_STATE_NONE);
+ transfer_state = VCONFKEY_WIFI_TRANSFER_STATE_NONE;
+ }
+
+ if (transfer_state != last_transfer_state) {
+ netconfig_set_vconf_int(VCONFKEY_WIFI_TRANSFER_STATE,
+ transfer_state);
+ last_transfer_state = transfer_state;
}
+ /* NETCONFIG_WIFI_DATA_ACTIVITY_BOOSTER */
+ if (tx_diff >= NETCONFIG_WIFI_DATA_ACTIVITY_BOOSTER_LEVEL1 ||
+ rx_diff >= NETCONFIG_WIFI_DATA_ACTIVITY_BOOSTER_LEVEL1)
+ booster_level = 1;
+ else if (tx_diff >= NETCONFIG_WIFI_DATA_ACTIVITY_BOOSTER_LEVEL2 ||
+ rx_diff >= NETCONFIG_WIFI_DATA_ACTIVITY_BOOSTER_LEVEL2)
+ booster_level = 2;
+ else if (tx_diff >= NETCONFIG_WIFI_DATA_ACTIVITY_BOOSTER_LEVEL3 ||
+ rx_diff >= NETCONFIG_WIFI_DATA_ACTIVITY_BOOSTER_LEVEL3)
+ booster_level = 3;
+
+ if (old_level == booster_level) {
+ if (--booster_tic <= 0) {
+ __netconfig_wifi_data_activity_booster(booster_level);
+
+ booster_tic = 2;
+ }
+ } else {
+ __netconfig_wifi_data_activity_booster(booster_level);
+
+ if (booster_level > 0)
+ booster_tic = 2;
+ else
+ booster_tic = 0;
+ }
+
+ old_level = booster_level;
+
netconfig_wifi_tx_bytes = tx;
netconfig_wifi_rx_bytes = rx;
}
+}
+
+static gboolean __netconfig_wifi_indicator_monitor(gpointer data)
+{
+ int rssi_dbm = 0;
+ int snr_level = 0;
+ int pm_state = VCONFKEY_PM_STATE_NORMAL;
+
+ if (netconfig_wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED)
+ return FALSE;
+
+ /* In case of LCD off, we don't need to update Wi-Fi indicator */
+ vconf_get_int(VCONFKEY_PM_STATE, &pm_state);
+ if (pm_state >= VCONFKEY_PM_STATE_LCDOFF)
+ return TRUE;
- __netconfig_wifi_set_rssi_level(rssi_dbm);
+ rssi_dbm = __netconfig_wifi_update_and_get_rssi();
+ //INFO("%d dbm", rssi_dbm);
+ snr_level = netconfig_wifi_rssi_level(rssi_dbm);
+ __netconfig_wifi_set_rssi_level(snr_level);
+
+ __netconfig_wifi_update_indicator();
return TRUE;
}
void netconfig_wifi_indicator_start(void)
{
- guint64 tx = 0, rx = 0;
-
INFO("Start Wi-Fi indicator");
- vconf_set_int(VCONFKEY_WIFI_STRENGTH, VCONFKEY_WIFI_STRENGTH_MAX);
-
- if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE) {
- netconfig_wifi_tx_bytes = tx;
- netconfig_wifi_rx_bytes = rx;
- } else {
- netconfig_wifi_tx_bytes = 0;
- netconfig_wifi_rx_bytes = 0;
- }
+ netconfig_set_vconf_int(VCONFKEY_WIFI_STRENGTH, VCONFKEY_WIFI_STRENGTH_MAX);
netconfig_start_timer_seconds(
NETCONFIG_WIFI_INDICATOR_INTERVAL,
{
INFO("Stop Wi-Fi indicator");
- vconf_set_int(VCONFKEY_WIFI_STRENGTH, VCONFKEY_WIFI_STRENGTH_MAX);
-
netconfig_stop_timer(&netconfig_wifi_indicator_timer);
+
+ netconfig_wifi_rssi = VCONFKEY_WIFI_SNR_MIN;
}
-/*\r
- * Network Configuration Module\r
- *\r
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <errno.h>\r
-\r
-#include "log.h"\r
-#include "util.h"\r
-#include "neterror.h"\r
-#include "netdbus.h"\r
-#include "netsupplicant.h"\r
-#include "wifi-passpoint.h"\r
-\r
-\r
-static gboolean netconfig_wifi_get_passpoint(gint32 *enabled)\r
-{\r
- DBusMessage *reply;\r
- DBusMessageIter iter, variant;\r
- dbus_bool_t value;\r
- gboolean result = FALSE;\r
-\r
- reply = netconfig_supplicant_invoke_dbus_interface_property_get(SUPPLICANT_IFACE_INTERFACE,\r
- "Passpoint");\r
- if (reply == NULL) {\r
- ERR("Error!!! Failed to get passpoint property");\r
- return result;\r
- }\r
-\r
- if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {\r
- const char *err_msg = dbus_message_get_error_name(reply);\r
- ERR("Error!!! Error message received [%s]", err_msg);\r
- return result;\r
- }\r
-\r
- dbus_message_iter_init(reply, &iter);\r
-\r
- if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_VARIANT) {\r
- dbus_message_iter_recurse(&iter, &variant);\r
- if (dbus_message_iter_get_arg_type(&variant) == DBUS_TYPE_INT32) {\r
- dbus_message_iter_get_basic(&variant, &value);\r
- if (value == TRUE)\r
- *enabled = 1;\r
- else\r
- *enabled = 0;\r
-\r
- result = TRUE;\r
- }\r
- }\r
-\r
- dbus_message_unref(reply);\r
-\r
- return result;\r
-}\r
-\r
-static gboolean netconfig_wifi_set_passpoint(gint32 enable)\r
-{\r
- gint32 value = enable;\r
- gboolean result = FALSE;\r
- GList *input_args = NULL;\r
-\r
- struct dbus_input_arguments args_enable[2] = {\r
- {DBUS_TYPE_INT32, &value},\r
- {DBUS_TYPE_INVALID, NULL}\r
- };\r
-\r
- input_args = setup_input_args(input_args, args_enable);\r
-\r
- result = netconfig_supplicant_invoke_dbus_interface_property_set(SUPPLICANT_IFACE_INTERFACE,\r
- "Passpoint", DBUS_TYPE_INT32_AS_STRING, input_args, NULL);\r
- if (result == FALSE)\r
- ERR("Fail to set passpoint enable [%d]", enable);\r
-\r
- g_list_free(input_args);\r
-\r
- return result;\r
-}\r
-\r
-gboolean netconfig_iface_wifi_get_passpoint(NetconfigWifi *wifi,\r
- gint32 *result, GError **error)\r
-{\r
- g_return_val_if_fail(wifi != NULL, FALSE);\r
-\r
- if (netconfig_wifi_get_passpoint(result))\r
- return TRUE;\r
-\r
- return FALSE;\r
-}\r
-\r
-gboolean netconfig_iface_wifi_set_passpoint(NetconfigWifi *wifi,\r
- gint32 enable, GError **error)\r
-{\r
- g_return_val_if_fail(wifi != NULL, FALSE);//Verifies that the expression expr , usually representing a precondition, evaluates to TRUE. If the function does not return a value, use g_return_if_fail() instead\r
-\r
- return netconfig_wifi_set_passpoint(enable);\r
-}\r
-\r
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 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 <errno.h>
+
+#include "log.h"
+#include "util.h"
+#include "neterror.h"
+#include "netdbus.h"
+#include "netsupplicant.h"
+#include "wifi-passpoint.h"
+
+#if defined TIZEN_WLAN_PASSPOINT
+static gboolean netconfig_wifi_get_passpoint(gint32 *enabled)
+{
+ GVariant *reply;
+ gboolean value;
+ gboolean result = FALSE;
+
+ reply = netconfig_supplicant_invoke_dbus_interface_property_get(SUPPLICANT_IFACE_INTERFACE,
+ "Passpoint");
+ if (reply == NULL) {
+ ERR("Error!!! Failed to get passpoint property");
+ return FALSE;
+ }
+
+ if (g_variant_is_of_type(reply, G_VARIANT_TYPE_INT32)) {
+ value = g_variant_get_int32(reply);
+ if (value == TRUE)
+ *enabled = 1;
+ else
+ *enabled = 0;
+
+ result = TRUE;
+ }
+
+ g_variant_unref(reply);
+
+ return result;
+}
+
+static gboolean netconfig_wifi_set_passpoint(gint32 enable)
+{
+ gint32 value = enable ? 1 : 0;
+ gboolean result = FALSE;
+ GVariant *input_args = NULL;
+
+ input_args = g_variant_new_int32(value);
+
+ result = netconfig_supplicant_invoke_dbus_interface_property_set(
+ SUPPLICANT_IFACE_INTERFACE, "Passpoint", input_args, NULL);
+ if (result == FALSE)
+ ERR("Fail to set passpoint enable[%d]", enable);
+
+ return result;
+}
+#endif
+
+gboolean handle_get_passpoint(Wifi *wifi, GDBusMethodInvocation *context)
+{
+ gint32 enable = 0;
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+#if defined TIZEN_WLAN_PASSPOINT
+ if (netconfig_wifi_get_passpoint(&enable)){
+ wifi_complete_get_passpoint(wifi, context, enable);
+ return TRUE;
+ }
+ wifi_complete_get_passpoint(wifi, context, enable);
+ return FALSE;
+#else
+ enable = 0;
+ wifi_complete_get_passpoint(wifi, context, enable);
+ return TRUE;
+#endif
+}
+
+gboolean handle_set_passpoint(Wifi *wifi, GDBusMethodInvocation *context, gint enable)
+{
+ gboolean result = FALSE;
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+#if defined TIZEN_WLAN_PASSPOINT
+ result = netconfig_wifi_set_passpoint(enable);
+ wifi_complete_set_passpoint(wifi, context);
+ return result;
+#else
+ wifi_complete_set_passpoint(wifi, context);
+ return result;
+#endif
+}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
-#include <stdio.h>
-#include <unistd.h>
+#include <errno.h>
#include <vconf.h>
#include <vconf-keys.h>
+#include <ITapiSim.h>
+#include <TapiUtility.h>
+#include <stdio.h>
+
+#if defined TIZEN_P2P_ENABLE && !defined WLAN_CONCURRENT_MODE
#include <wifi-direct.h>
+#endif
+
+#if defined TIZEN_WEARABLE
+#include <weconn.h>
+#endif
-#include "wifi.h"
#include "log.h"
-#include "wifi.h"
#include "util.h"
#include "netdbus.h"
#include "neterror.h"
-#include "netconfig.h"
-#include "emulator.h"
-#include "network-statistics.h"
-#include "wifi-background-scan.h"
+#include "wifi-wps.h"
#include "wifi-power.h"
#include "wifi-state.h"
-#include "mdm-private.h"
-#include "wifi-agent.h"
-#include "wifi-eap-config.h"
+#include "wifi-tel-intf.h"
+#include "netsupplicant.h"
+#include "network-state.h"
#include "wifi-firmware.h"
+#include "wifi-background-scan.h"
-
-#define WLAN_DRIVER_SCRIPT "/usr/bin/wlan.sh"
#define WLAN_SUPPLICANT_SCRIPT "/usr/sbin/wpa_supp.sh"
+#define P2P_SUPPLICANT_SCRIPT "/usr/sbin/p2p_supp.sh"
+#define VCONF_WIFI_OFF_STATE_BY_AIRPLANE \
+ "file/private/wifi/wifi_off_by_airplane"
+#define VCONF_WIFI_OFF_STATE_BY_RESTRICTED \
+ "file/private/wifi/wifi_off_by_restricted"
+#define VCONF_WIFI_OFF_STATE_BY_EMERGENCY \
+ "file/private/wifi/wifi_off_by_emergency"
+
+#if defined TIZEN_WEARABLE
+static weconn_h weconn_handle = NULL;
+#define VCONF_WIFI_WEARABLE_WIFI_USE "db/private/wifi/wearable_wifi_use"
+#endif
-static gboolean power_in_progress = FALSE;
-static gboolean fm_waiting = FALSE;
+#define WLAN_MAC_INFO "/opt/etc/.mac.info"
+#define WLAN_MAC_ADDR_MAX 20
+#define VCONF_WIFI_BSSID_ADDRESS "db/wifi/bssid_address"
-static void __netconfig_wifi_technology_reply(DBusPendingCall *call, void *data)
-{
- DBusMessage *message;
-
- message = dbus_pending_call_steal_reply(call);
+#if defined TIZEN_TV
+#define ETH_MAC_ADDR_SIZE 6
+#define VCONF_ETH_MAC_ADDRESS "db/dnet/mac_address"
+#define NET_EXEC_PATH "/sbin/ifconfig"
+#define OS_RANDOM_FILE "/dev/urandom"
+#endif
- if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) {
- ERR("%s", dbus_message_get_error_name(message));
+static gboolean connman_wifi_technology_state = FALSE;
+static gboolean wifi_firmware_recovery_mode = FALSE;
+static int airplane_mode = 0;
- if (dbus_message_is_error(message,
- CONNMAN_ERROR_INTERFACE ".AlreadyEnabled") == TRUE) {
- netconfig_wifi_update_power_state(TRUE);
- power_in_progress = FALSE;
- } else if (dbus_message_is_error(message,
- CONNMAN_ERROR_INTERFACE ".AlreadyDisabled") == TRUE) {
- netconfig_wifi_update_power_state(FALSE);
- power_in_progress = FALSE;
+static void __netconfig_wifi_technology_reply(GObject *source_object,
+ GAsyncResult *res, gpointer user_data)
+{
+ GVariant *reply;
+ GDBusConnection *conn = NULL;
+ GError *error = NULL;
+
+ conn = G_DBUS_CONNECTION (source_object);
+ reply = g_dbus_connection_call_finish(conn, res, &error);
+
+ if (reply == NULL) {
+ if (error != NULL) {
+ if (g_strcmp0(error->message,
+ CONNMAN_ERROR_INTERFACE ".AlreadyEnabled") == 0) {
+ netconfig_wifi_update_power_state(TRUE);
+ } else if (g_strcmp0(error->message,
+ CONNMAN_ERROR_INTERFACE ".AlreadyDisabled") == 0) {
+ netconfig_wifi_update_power_state(FALSE);
+ } else {
+ ERR("Fail to request status [%d: %s]",
+ error->code, error->message);
+ }
+ g_error_free(error);
+ } else {
+ ERR("Fail torequest status");
}
} else {
DBG("Successfully requested");
}
- dbus_message_unref(message);
- dbus_pending_call_unref(call);
+ g_variant_unref(reply);
+ netconfig_gdbus_pending_call_unref();
}
-static gboolean __netconfig_wifi_enable_technology(void)
+static gboolean __netconfig_is_wifi_restricted(void)
{
- gboolean reply = FALSE;
- char param0[] = "string:Powered";
- char param1[] = "variant:boolean:true";
- char *param_array[] = { NULL, NULL, NULL };
-
- param_array[0] = param0;
- param_array[1] = param1;
-
- reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
- CONNMAN_WIFI_TECHNOLOGY_PREFIX, CONNMAN_TECHNOLOGY_INTERFACE,
- "SetProperty", param_array, __netconfig_wifi_technology_reply);
+#if defined TIZEN_WEARABLE
+ return FALSE;
+#endif
+ int restricted_mode = 0;
- if (reply != TRUE)
- ERR("Fail to enable Wi-Fi");
+ vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, &restricted_mode);
+ if (restricted_mode != 0) {
+ DBG("network restricted mode[%d]", restricted_mode);
+ return TRUE;
+ }
- return reply;
+ return FALSE;
}
-static gboolean __netconfig_wifi_disable_technology(void)
+static int __netconfig_wifi_connman_technology(gboolean enable)
{
gboolean reply = FALSE;
- char param0[] = "string:Powered";
- char param1[] = "variant:boolean:false";
- char *param_array[] = { NULL, NULL, NULL };
+ GVariant *param0 = NULL;
+ GVariant *params = NULL;
+ char key[] = "Powered";
+ gboolean value_enable = TRUE;
+ gboolean value_disable = FALSE;
- param_array[0] = param0;
- param_array[1] = param1;
+ if (connman_wifi_technology_state == enable)
+ return -EALREADY;
+
+ if (enable == TRUE)
+ param0 = g_variant_new_boolean(value_enable);
+ else
+ param0 = g_variant_new_boolean(value_disable);
+
+ params = g_variant_new("(sv)",key, param0);
reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
CONNMAN_WIFI_TECHNOLOGY_PREFIX, CONNMAN_TECHNOLOGY_INTERFACE,
- "SetProperty", param_array, __netconfig_wifi_technology_reply);
+ "SetProperty", params, __netconfig_wifi_technology_reply);
+
+ if (reply != TRUE) {
+ ERR("Fail to set technology %s", enable == TRUE ? "enable" : "disable");
+ return -ESRCH;
+ }
+
+ /* If Wi-Fi powered off,
+ * Do not remove Wi-Fi driver until ConnMan technology state updated
+ */
+ if (enable == TRUE)
+ connman_wifi_technology_state = enable;
- if (reply != TRUE)
- ERR("Fail to disable Wi-Fi");
+ /* To be keep safe, early disable Wi-Fi tech state */
+ if (enable != TRUE)
+ netconfig_wifi_state_set_technology_state(NETCONFIG_WIFI_TECH_WPS_ONLY);
- return reply;
+ return 0;
}
static int __netconfig_wifi_supplicant(gboolean enable)
return 0;
}
+#if defined TIZEN_P2P_ENABLE && defined WLAN_CONCURRENT_MODE
+static int __netconfig_p2p_supplicant(gboolean enable)
+{
+ int rv = 0;
+ const char *path = P2P_SUPPLICANT_SCRIPT;
+ char *const args_enable[] = { P2P_SUPPLICANT_SCRIPT, "start", NULL };
+ char *const args_disable[] = { P2P_SUPPLICANT_SCRIPT, "stop", NULL };
+ char *const envs[] = { NULL };
-static gboolean __netconfig_wifi_load_driver(void)
+ if (enable == TRUE)
+ rv = netconfig_execute_file(path, args_enable, envs);
+ else
+ rv = netconfig_execute_file(path, args_disable, envs);
+ if (rv < 0)
+ return -EIO;
+
+ DBG("p2p_supplicant %s", enable == TRUE ? "started" : "stopped");
+
+ return 0;
+}
+#endif
+
+void netconfig_wifi_recover_firmware(void)
{
- gboolean rv = FALSE;
+ wifi_firmware_recovery_mode = TRUE;
- if (netconfig_emulator_is_emulated() == TRUE)
- return rv;
+ netconfig_wifi_bgscan_stop();
-#if defined EMBEDDED_TARGET
- const char *path = WLAN_DRIVER_SCRIPT;
- char *const args[] = { "wlan.sh", "start", NULL };
- char *const envs[] = { NULL };
+ netconfig_wifi_off();
+}
- rv = netconfig_execute_file(path, args, envs);
- if (rv != TRUE) {
- DBG("Failed to load wireless device driver");
- return FALSE;
+#if defined TIZEN_P2P_ENABLE && !defined WLAN_CONCURRENT_MODE
+static void __netconfig_wifi_direct_state_cb(int error_code,
+ wifi_direct_device_state_e device_state, void *user_data)
+{
+ int err;
+
+ wifi_direct_unset_device_state_changed_cb();
+ wifi_direct_deinitialize();
+
+ if (device_state == WIFI_DIRECT_DEVICE_STATE_DEACTIVATED) {
+ err = netconfig_wifi_on();
+ if (err < 0) {
+ if (err == -EALREADY)
+ netconfig_wifi_update_power_state(TRUE);
+ else
+ netconfig_wifi_notify_power_failed();
+ }
}
-#else
- /*start the Supplicant Daemon*/
+}
+
+static gboolean __netconfig_wifi_direct_power_off(void)
+{
+ DBG("Wi-Fi direct is turning off");
+
+ if (wifi_direct_initialize() < 0)
+ return FALSE;
+
+ if (wifi_direct_set_device_state_changed_cb(
+ __netconfig_wifi_direct_state_cb, NULL) < 0)
+ return FALSE;
+
+ if (wifi_direct_deactivate() < 0)
+ return FALSE;
+
+ return TRUE;
+}
+#endif
+
+static int __netconfig_wifi_try_to_load_driver_and_supplicant(void)
+{
int err = 0;
+ enum netconfig_wifi_tech_state wifi_tech_state;
+
+ wifi_tech_state = netconfig_wifi_state_get_technology_state();
+ if (wifi_tech_state > NETCONFIG_WIFI_TECH_OFF)
+ return -EALREADY;
+
err = __netconfig_wifi_supplicant(TRUE);
if (err < 0 && err != -EALREADY)
return err;
-#endif
+ err = netconfig_wifi_firmware(NETCONFIG_WIFI_STA, TRUE);
+ if (err < 0 && err != -EALREADY) {
+ __netconfig_wifi_supplicant(FALSE);
+ return err;
+ }
+ netconfig_wifi_state_set_technology_state(NETCONFIG_WIFI_TECH_WPS_ONLY);
- DBG("Successfully loaded wireless device driver");
- return TRUE;
+ return 0;
}
-gboolean netconfig_wifi_remove_driver(void)
+static int __netconfig_wifi_try_to_remove_driver_and_supplicant(void)
{
- gboolean rv = FALSE;
+ int err = 0;
- if (netconfig_emulator_is_emulated() == TRUE)
- return rv;
+ if (wifi_firmware_recovery_mode != TRUE &&
+ netconfig_wifi_is_wps_enabled() == TRUE) {
+ DBG("Wi-Fi WPS mode");
+ return 0;
+ }
-#if defined EMBEDDED_TARGET
- const char *path = WLAN_DRIVER_SCRIPT;
- char *const args[] = { "wlan.sh", "stop", NULL };
- char *const env[] = { NULL };
+ err = netconfig_wifi_firmware(NETCONFIG_WIFI_STA, FALSE);
+ if (err < 0 && err != -EALREADY)
+ return err;
- rv = netconfig_execute_file(path, args, env);
- if (rv != TRUE) {
- DBG("Failed to remove wireless device driver");
- return FALSE;
- }
-#else
- /*Stop the Supplicant Daemon*/
- int err = 0;
err = __netconfig_wifi_supplicant(FALSE);
if (err < 0 && err != -EALREADY)
return err;
-#endif
+ netconfig_wifi_state_set_technology_state(NETCONFIG_WIFI_TECH_OFF);
+ if (wifi_firmware_recovery_mode == TRUE) {
+ if (netconfig_wifi_on() < 0)
+ ERR("Failed to recover Wi-Fi firmware");
- DBG("Successfully removed wireless device driver");
- return TRUE;
-}
+ wifi_firmware_recovery_mode = FALSE;
+ }
-static int __netconfig_wifi_try_to_load_driver(void);
-static gboolean __netconfig_wifi_try_to_remove_driver(void);
+ return 0;
+}
-void netconfig_wifi_notify_power_completed(gboolean power_on)
+static void __netconfig_set_wifi_bssid(void)
{
- DBusMessage *signal;
- DBusConnection *connection;
- DBusError error;
- char *sig_name;
-
- if (power_on)
- sig_name = "PowerOnCompleted";
- else
- sig_name = "PowerOffCompleted";
+ int rv = 0;
+ char bssid[WLAN_MAC_ADDR_MAX];
- dbus_error_init(&error);
+ FILE *fp = fopen(WLAN_MAC_INFO, "r");
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
- if (connection == NULL) {
- ERR("Error!!! Failed to get system DBus, error [%s]", error.message);
- dbus_error_free(&error);
+ if (fp == NULL) {
+ ERR("Fail to open file");
return;
}
- signal = dbus_message_new_signal(NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, sig_name);
- if (signal == NULL)
- return;
+ fseek(fp, 0L, SEEK_SET);
+ rv = fscanf(fp, "%s", bssid);
- dbus_connection_send(connection, signal, NULL);
+ if (rv < 0)
+ ERR("Fail to read bssid");
- dbus_message_unref(signal);
- dbus_connection_unref(connection);
+ netconfig_set_vconf_str(VCONF_WIFI_BSSID_ADDRESS, bssid);
- INFO("(%s)", sig_name);
+ fclose(fp);
}
-static void __netconfig_wifi_direct_state_cb(int error_code,
- wifi_direct_device_state_e device_state, void *user_data)
+int netconfig_wifi_driver_and_supplicant(gboolean enable)
{
- wifi_direct_unset_device_state_changed_cb();
- wifi_direct_deinitialize();
-
- if (device_state == WIFI_DIRECT_DEVICE_STATE_DEACTIVATED) {
- if (__netconfig_wifi_try_to_load_driver() < 0) {
- power_in_progress = FALSE;
-
- /* TODO: error report */
+ /* There are 3 thumb rules for Wi-Fi power management
+ * 1. Do not make exposed API to control wpa_supplicant and driver directly.
+ * It probably breaks ConnMan technology operation.
+ *
+ * 2. Do not remove driver and wpa_supplicant if ConnMan already enabled.
+ * It breaks ConnMan technology operation.
+ *
+ * 3. Final the best rule: make it as simple as possible.
+ * Simple code enables easy maintenance and reduces logical errors.
+ */
+ if (enable == TRUE)
+ return __netconfig_wifi_try_to_load_driver_and_supplicant();
+ else {
+ if (connman_wifi_technology_state == TRUE)
+ return -ENOSYS;
- return;
- }
+ return __netconfig_wifi_try_to_remove_driver_and_supplicant();
}
}
-static gboolean __netconfig_wifi_direct_power_off(void)
+void netconfig_wifi_disable_technology_state_by_only_connman_signal(void)
{
- DBG("Wi-Fi direct is turning off");
-
- if (wifi_direct_initialize() < 0)
- return FALSE;
-
- if (wifi_direct_set_device_state_changed_cb(
- __netconfig_wifi_direct_state_cb, NULL) < 0)
- return FALSE;
-
- if (wifi_direct_deactivate() < 0)
- return FALSE;
-
- return TRUE;
+ /* Important: it's only done by ConnMan technology signal update */
+ connman_wifi_technology_state = FALSE;
}
-static int __netconfig_wifi_try_to_load_driver(void)
+int netconfig_wifi_on(void)
{
+ int err = 0;
+ enum netconfig_wifi_tech_state wifi_tech_state;
+
+ wifi_tech_state = netconfig_wifi_state_get_technology_state();
+ if (wifi_tech_state >= NETCONFIG_WIFI_TECH_POWERED)
+ return -EALREADY;
- if (netconfig_is_wifi_allowed() != TRUE)
+ if (__netconfig_is_wifi_restricted() == TRUE)
return -EPERM;
if (netconfig_is_wifi_tethering_on() == TRUE) {
/* TODO: Wi-Fi tethering turns off here */
/* return TRUE; */
+ ERR("Failed to turn tethering off");
return -EBUSY;
}
+#if defined TIZEN_P2P_ENABLE && !defined WLAN_CONCURRENT_MODE
if (netconfig_is_wifi_direct_on() == TRUE) {
- if (__netconfig_wifi_direct_power_off() == TRUE) {
- power_in_progress = TRUE;
+ if (__netconfig_wifi_direct_power_off() == TRUE)
return -EINPROGRESS;
- } else
+ else {
+ ERR("Failed to turn Wi-Fi direct off");
return -EBUSY;
+ }
}
+#endif
+
+ err = netconfig_wifi_driver_and_supplicant(TRUE);
+ if (err < 0 && err != -EALREADY)
+ return err;
- if (__netconfig_wifi_load_driver() != TRUE) {
- netconfig_wifi_remove_driver();
+ err = __netconfig_wifi_connman_technology(TRUE);
- return -EIO;
+ __netconfig_set_wifi_bssid();
+
+ return err;
+}
+
+int netconfig_wifi_off(void)
+{
+ int err;
+
+#if defined TIZEN_P2P_ENABLE && defined WLAN_CONCURRENT_MODE
+ __netconfig_p2p_supplicant(FALSE);
+#endif
+
+ err = __netconfig_wifi_connman_technology(FALSE);
+ if (err == -EALREADY)
+ netconfig_wifi_update_power_state(FALSE);
+
+ return 0;
+}
+
+#if defined TIZEN_WEARABLE
+int netconfig_wifi_on_wearable(gboolean device_picker_test)
+{
+ int err = 0;
+ int wifi_use;
+ int ps_mode;
+ enum netconfig_wifi_tech_state wifi_tech_state;
+ weconn_service_state_e weconn_state;
+
+ wifi_tech_state = netconfig_wifi_state_get_technology_state();
+ if (wifi_tech_state >= NETCONFIG_WIFI_TECH_POWERED)
+ return -EALREADY;
+
+ err = weconn_get_service_state(weconn_handle, W_SERVICE_TYPE_BT,
+ &weconn_state);
+ if (err == 0 && weconn_state == W_SERVICE_STATE_CONNECTED) {
+ WARN("Not permitted Wi-Fi on");
+ return -EPERM;
}
- if (__netconfig_wifi_enable_technology() != TRUE) {
- netconfig_wifi_remove_driver();
+ if (vconf_get_int(VCONF_WIFI_WEARABLE_WIFI_USE, &wifi_use) < 0) {
+ ERR("Fail to get VCONF_WIFI_WEARABLE_WIFI_USE");
return -EIO;
}
- power_in_progress = TRUE;
+ if (wifi_use > 0) {
+ if (vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &ps_mode) < 0) {
+ ERR("Fail to get VCONFKEY_SETAPPL_PSMODE");
+ return -EIO;
+ }
- return 0;
+ if (ps_mode > SETTING_PSMODE_NORMAL) {
+ WARN("ps mode is on(%d), Not turn on Wi-Fi", ps_mode);
+ return -EPERM;
+ }
+ } else {
+ WARN("Not permitted Wi-Fi on");
+ return -EPERM;
+ }
+
+ err = netconfig_wifi_driver_and_supplicant(TRUE);
+ if (err < 0 && err != -EALREADY)
+ return err;
+
+ err = __netconfig_wifi_connman_technology(TRUE);
+
+ if (device_picker_test == TRUE)
+ netconfig_wifi_enable_device_picker_test();
+
+ return err;
}
-static gboolean __netconfig_wifi_try_to_remove_driver(void)
+static void __netconfig_wifi_wearable_weconn_service_state_changed_cb(
+ weconn_service_state_e state, void *user_data)
{
- netconfig_wifi_device_picker_service_stop();
+ int wifi_state;
- netconfig_wifi_statistics_update_powered_off();
+ if (vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state) < 0) {
+ ERR("Fail to get VCONFKEY_WIFI_STATE");
+ return;
+ }
- if (__netconfig_wifi_disable_technology() != TRUE)
- return FALSE;
+ if (state == W_SERVICE_STATE_CONNECTED) {
+ DBG("SAP is connected");
+ if (wifi_state > VCONFKEY_WIFI_OFF)
+ netconfig_wifi_off();
+ } else if (state == W_SERVICE_STATE_DISCONNECTED) {
+ DBG("SAP is disconnected");
+ netconfig_wifi_on_wearable(TRUE);
+ }
+}
- power_in_progress = TRUE;
+static int __netconfig_wifi_wearable_set_state_changed_cb(int service_type,
+ void *user_data)
+{
+ int ret;
- return TRUE;
+ if (weconn_handle) {
+ weconn_destroy(weconn_handle);
+ weconn_handle = NULL;
+ }
+
+ ret = weconn_create(&weconn_handle);
+ if (ret < 0) {
+ ERR("Failed weconn_create(%d)", ret);
+ return -1;
+ }
+
+ ret = weconn_set_service_state_change_cb(weconn_handle,
+ __netconfig_wifi_wearable_weconn_service_state_changed_cb,
+ service_type, user_data);
+ if (ret < 0) {
+ ERR("Failed weconn_set_service_state_change_cb(%d)", ret);
+ return -1;
+ }
+
+ return 0;
}
-static void __netconfig_wifi_airplane_mode(keynode_t* node,
+static void __netconfig_wifi_wearable_wifi_use_mode(keynode_t* node,
void* user_data)
{
- int value = 0;
- int wifi_state = 0;
- static gboolean powered_off_by_flightmode = FALSE;
+ int wifi_state;
+ int wifi_use;
+ gboolean wifi_restrict = FALSE;
- if (power_in_progress) {
- fm_waiting = TRUE;
+ if (vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state) < 0) {
+ ERR("Fail to get VCONFKEY_WIFI_STATE");
return;
}
- fm_waiting = FALSE;
+ if (node != NULL)
+ wifi_use = vconf_keynode_get_int(node);
+ else
+ vconf_get_int(VCONF_WIFI_WEARABLE_WIFI_USE, &wifi_use);
+
+ if (wifi_use > 0) {
+ DBG("wifi use on");
+ if (wifi_state > VCONFKEY_WIFI_OFF) {
+ WARN("Wi-Fi is already turned on");
+ return;
+ }
+
+ wifi_restrict = netconfig_is_wifi_allowed();
+ if (wifi_restrict == FALSE) {
+ DBG("launch wifi restrict popup");
+ netconfig_set_vconf_int(VCONF_WIFI_WEARABLE_WIFI_USE, 0);
+ wc_launch_syspopup(WC_POPUP_TYPE_WIFI_RESTRICT);
+ } else {
+ netconfig_wifi_on_wearable(TRUE);
+ }
+ } else {
+ DBG("wifi use off");
+ if (wifi_state == VCONFKEY_WIFI_OFF) {
+ WARN("Wi-Fi is already turned off");
+ return;
+ }
+
+ netconfig_wifi_off();
+ }
+}
+
+#if defined TIZEN_TELEPHONY_ENABLE
+static void __netconfig_wifi_wearable_airplane_mode(keynode_t *node,
+ void *user_data)
+{
+ int wifi_use = 0, airplane_state = 0;
+ int wifi_use_off_by_airplane = 0;
+
+ vconf_get_int(VCONF_WIFI_OFF_STATE_BY_AIRPLANE,
+ &wifi_use_off_by_airplane);
+
+ vconf_get_int(VCONF_WIFI_WEARABLE_WIFI_USE, &wifi_use);
+
+ if (node != NULL)
+ airplane_state = vconf_keynode_get_bool(node);
+ else
+ vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &airplane_state);
+
+ DBG("airplane mode %s (prev:%d)", airplane_state > 0 ? "ON" : "OFF", airplane_mode);
+ DBG("Wi-Fi use %d, Wi-Fi was off by flight mode %s", wifi_use,
+ wifi_use_off_by_airplane ? "Yes" : "No");
+
+ if (airplane_mode == airplane_state)
+ return ;
+
+ airplane_mode = airplane_state;
+
+ if (airplane_state > 0) {
+ /* airplane mode on */
+ if (wifi_use == 0)
+ return;
+
+ netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_AIRPLANE, 1);
+ netconfig_set_vconf_int(VCONF_WIFI_WEARABLE_WIFI_USE, 0);
+
+ } else {
+ /* airplane mode off */
+ if (!wifi_use_off_by_airplane)
+ return;
+
+ netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_AIRPLANE, 0);
+ netconfig_set_vconf_int(VCONF_WIFI_WEARABLE_WIFI_USE, 1);
+ }
+}
+#endif
+#else
+#if defined TIZEN_TELEPHONY_ENABLE
+static void __netconfig_wifi_airplane_mode(keynode_t *node, void *user_data)
+{
+ int wifi_state = 0, airplane_state = 0;
+ int wifi_off_by_airplane = 0;
+
+ vconf_get_int(VCONF_WIFI_OFF_STATE_BY_AIRPLANE, &wifi_off_by_airplane);
- vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &value);
vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
- DBG("flight mode %s", value > 0 ? "ON" : "OFF");
- DBG("Wi-Fi state %d, Wi-Fi was off by flight mode %s",
- wifi_state, powered_off_by_flightmode == TRUE ? "Yes" : "No");
+ if (node != NULL)
+ airplane_state = vconf_keynode_get_bool(node);
+ else
+ vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &airplane_state);
+
+ DBG("airplane mode %s (prev:%d)", airplane_state > 0 ? "ON" : "OFF", airplane_mode);
+ DBG("Wi-Fi state %d, Wi-Fi was off by flight mode %s", wifi_state,
+ wifi_off_by_airplane ? "Yes" : "No");
- if (value > 0) {
- /* flight mode enabled */
+ if (airplane_mode == airplane_state)
+ return ;
+
+ airplane_mode = airplane_state;
+
+ if (airplane_state > 0) {
+ /* airplane mode on */
if (wifi_state == VCONFKEY_WIFI_OFF)
return;
- DBG("Turning Wi-Fi off");
+ netconfig_wifi_off();
- __netconfig_wifi_try_to_remove_driver();
+ netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_AIRPLANE, 1);
+ } else {
+ /* airplane mode off */
+ if (!wifi_off_by_airplane)
+ return;
+
+ netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_AIRPLANE, 0);
- powered_off_by_flightmode = TRUE;
- } else if (value == 0) {
- /* flight mode disabled */
if (wifi_state > VCONFKEY_WIFI_OFF)
return;
- if (powered_off_by_flightmode != TRUE)
+ netconfig_wifi_on();
+ }
+}
+#endif
+#endif
+
+#if !defined TIZEN_WEARABLE
+static void __netconfig_wifi_restrict_mode(keynode_t *node, void *user_data)
+{
+ int wifi_state = 0, restricted = 0;
+ int wifi_off_by_restricted = 0;
+
+ vconf_get_int(VCONF_WIFI_OFF_STATE_BY_RESTRICTED, &wifi_off_by_restricted);
+
+ vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
+
+ if (node != NULL)
+ restricted = vconf_keynode_get_bool(node);
+ else
+ vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, &restricted);
+
+ DBG("network restricted mode %s", restricted > 0 ? "ON" : "OFF");
+ DBG("Wi-Fi state %d, Wi-Fi was off by restricted mode %s", wifi_state,
+ wifi_off_by_restricted ? "Yes" : "No");
+
+ if (restricted > 0) {
+ /* network restricted on */
+ if (wifi_state == VCONFKEY_WIFI_OFF)
+ return;
+
+ netconfig_wifi_off();
+
+ netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_RESTRICTED, 1);
+ } else {
+ /* network restricted off */
+ if (!wifi_off_by_restricted)
return;
- __netconfig_wifi_try_to_load_driver();
+ netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_RESTRICTED, 0);
- powered_off_by_flightmode = FALSE;
- } else
- DBG("Invalid value (%d)", value);
+ if (wifi_state > VCONFKEY_WIFI_OFF)
+ return;
+
+ netconfig_wifi_on();
+ }
}
+#endif
-static void __netconfig_wifi_pm_state_mode(keynode_t* node,
- void* user_data)
+static void __netconfig_wifi_emergency_mode(keynode_t *node, void *user_data)
{
- int value = -1;
- int wifi_state = 0;
- static int prev_state = VCONFKEY_PM_STATE_NORMAL;
+ int wifi_state = 0, emergency = 0;
+ int wifi_off_by_emergency = 0;
+#if !defined TIZEN_WEARABLE
+ int emergency_by_fmm = 0;
+#endif
- /*** vconf-keys.h ***
- * VCONFKEY_PM_STATE_NORMAL = 1,
- * VCONFKEY_PM_STATE_LCDDIM,
- * VCONFKEY_PM_STATE_LCDOFF,
- * VCONFKEY_PM_STATE_SLEEP
- */
+ vconf_get_int(VCONF_WIFI_OFF_STATE_BY_EMERGENCY, &wifi_off_by_emergency);
+
+ vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
+
+#if !defined TIZEN_WEARABLE
+ vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_PERMIT_WITH_LCD_OFF_LIMIT, &emergency_by_fmm);
+ DBG("emergency mode by Find My Mobile (%d)", emergency_by_fmm);
+ if (emergency_by_fmm == 1)
+ return;
+#endif
+
+ if (node != NULL)
+ emergency = vconf_keynode_get_int(node);
+ else
+ vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &emergency);
+
+ DBG("emergency mode %s", emergency > SETTING_PSMODE_POWERFUL ? "ON" : "OFF");
+ DBG("Wi-Fi state %d, Wi-Fi was off by emergency mode %s", wifi_state,
+ wifi_off_by_emergency ? "Yes" : "No");
+
+#if defined TIZEN_WEARABLE
+ if (emergency == SETTING_PSMODE_WEARABLE) {
+ /* basic power saving mode on */
+ } else if (emergency == SETTING_PSMODE_WEARABLE_ENHANCED) {
+ /* enhanced power saving mode on */
+ if (wifi_state == VCONFKEY_WIFI_OFF)
+ return;
+
+ netconfig_wifi_off();
+
+ netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_EMERGENCY, 1);
+ } else {
+ /* power saving mode off */
+ if (!wifi_off_by_emergency)
+ return;
+
+ netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_EMERGENCY, 0);
- if(vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state) == 0) {
- DBG("wifi state : %d (0 off / 1 on / 2 connected)", wifi_state);
- if(wifi_state <= VCONFKEY_WIFI_OFF)
+ if (wifi_state > VCONFKEY_WIFI_OFF)
return;
+
+ netconfig_wifi_on_wearable(TRUE);
}
+#else
+ if (emergency > SETTING_PSMODE_POWERFUL) {
+ /* emergency mode on */
+ if (wifi_state == VCONFKEY_WIFI_OFF)
+ return;
+
+ netconfig_wifi_off();
+
+ netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_EMERGENCY, 1);
+ } else {
+ /* emergency mode off */
+ if (!wifi_off_by_emergency)
+ return;
+
+ netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_EMERGENCY, 0);
+
+ if (wifi_state > VCONFKEY_WIFI_OFF)
+ return;
+
+ netconfig_wifi_on();
+ }
+#endif
+
+}
+
+static void __netconfig_wifi_pm_state_mode(keynode_t* node, void* user_data)
+{
+ int new_state = -1;
+ int wifi_state = 0;
+ static int prev_state = VCONFKEY_PM_STATE_NORMAL;
- if(vconf_get_int(VCONFKEY_PM_STATE, &value) < 0) {
- ERR("VCONFKEY_PM_STATE get failed");
+ if (vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state) < 0) {
+ ERR("Fail to get VCONFKEY_WIFI_STATE");
return;
}
- DBG("Old state: %d, current: %d", prev_state, value);
+ /* PM state
+ * VCONFKEY_PM_STATE_NORMAL = 1,
+ * VCONFKEY_PM_STATE_LCDDIM,
+ * VCONFKEY_PM_STATE_LCDOFF,
+ * VCONFKEY_PM_STATE_SLEEP
+ */
+ if (node != NULL)
+ new_state = vconf_keynode_get_int(node);
+ else
+ vconf_get_int(VCONFKEY_PM_STATE, &new_state);
- if((value == VCONFKEY_PM_STATE_NORMAL) && (prev_state >= VCONFKEY_PM_STATE_LCDOFF)) {
- DBG("PM state : Wake UP!");
+ DBG("wifi state: %d (0 off / 1 on / 2 connected)", wifi_state);
+ DBG("Old PM state: %d, current: %d", prev_state, new_state);
+ if ((new_state == VCONFKEY_PM_STATE_NORMAL) &&
+ (prev_state >= VCONFKEY_PM_STATE_LCDOFF)) {
netconfig_wifi_bgscan_stop();
- netconfig_wifi_bgscan_start();
+ netconfig_wifi_bgscan_start(TRUE);
}
- prev_state = value;
+ prev_state = new_state;
}
-void netconfig_set_power_in_progress(gboolean in_progress)
+#if defined TIZEN_TETLEPHONY_ENABLE
+static void _tapi_noti_sim_status_cb(TapiHandle *handle, const char *noti_id,
+ void *data, void *user_data)
{
- power_in_progress = in_progress;
+ TelSimCardStatus_t *status = data;
+
+ if (*status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED) {
+ DBG("Turn Wi-Fi on automatically");
+#if defined TIZEN_WEARABLE
+ netconfig_wifi_on_wearable(TRUE);
+#else
+ netconfig_wifi_on();
+#endif
+ netconfig_tel_deinit();
+ }
}
-void netconfig_check_fm_waiting(void)
+static gboolean netconfig_tapi_check_sim_state(void)
{
- if (fm_waiting)
- __netconfig_wifi_airplane_mode(NULL, NULL);
+ int ret, card_changed;
+ TelSimCardStatus_t status;
+ TapiHandle *tapi_handle = NULL;
+
+ tapi_handle = (TapiHandle *)netconfig_tel_init();
+
+ ret = tel_get_sim_init_info(tapi_handle, &status, &card_changed);
+ if (ret != TAPI_API_SUCCESS) {
+ ERR("tel_get_sim_init_info() Failed");
+ netconfig_tel_deinit();
+ return FALSE;
+ }
+
+ switch (status) {
+ case TAPI_SIM_STATUS_UNKNOWN:
+ case TAPI_SIM_STATUS_CARD_ERROR:
+ case TAPI_SIM_STATUS_CARD_NOT_PRESENT:
+ case TAPI_SIM_STATUS_CARD_BLOCKED:
+ case TAPI_SIM_STATUS_SIM_INIT_COMPLETED:
+ break;
+ case TAPI_SIM_STATUS_SIM_PIN_REQUIRED:
+ case TAPI_SIM_STATUS_SIM_INITIALIZING:
+ case TAPI_SIM_STATUS_SIM_PUK_REQUIRED:
+ case TAPI_SIM_STATUS_SIM_LOCK_REQUIRED:
+ case TAPI_SIM_STATUS_SIM_NCK_REQUIRED:
+ case TAPI_SIM_STATUS_SIM_NSCK_REQUIRED:
+ case TAPI_SIM_STATUS_SIM_SPCK_REQUIRED:
+ case TAPI_SIM_STATUS_SIM_CCK_REQUIRED:
+ tel_register_noti_event(tapi_handle, TAPI_NOTI_SIM_STATUS,
+ _tapi_noti_sim_status_cb, NULL);
+ return FALSE;
+ default:
+ ERR("not defined status(%d)", status);
+ break;
+ }
+
+ netconfig_tel_deinit();
+
+ return TRUE;
}
-void netconfig_wifi_power_configuration(void)
+static void __netconfig_tapi_state_changed_cb(keynode_t * node, void *data)
+{
+ int tapi_state = 0;
+
+ if (node != NULL)
+ tapi_state = vconf_keynode_get_int(node);
+ else
+ vconf_get_bool(VCONFKEY_TELEPHONY_READY, &tapi_state);
+
+ if (tapi_state != FALSE) {
+ if (netconfig_tapi_check_sim_state() == FALSE) {
+ DBG("Sim is not initialized yet.");
+
+ goto done;
+ }
+ } else
+ return;
+
+ DBG("Turn Wi-Fi on automatically");
+
+#if defined TIZEN_WEARABLE
+ netconfig_wifi_on_wearable(TRUE);
+#else
+ netconfig_wifi_on();
+#endif
+
+done:
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_READY,
+ __netconfig_tapi_state_changed_cb);
+}
+#endif
+
+void netconfig_wifi_power_initialize(void)
{
int wifi_last_power_state = 0;
+ /* Initialize Airplane mode */
+#if defined TIZEN_TELEPHONY_ENABLE
+ vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &airplane_mode);
+#endif
+ DBG("Airplane[%s]", airplane_mode > 0 ? "ON" : "OFF");
+
+ /* Update the last Wi-Fi power state */
+ vconf_get_int(VCONF_WIFI_LAST_POWER_STATE, &wifi_last_power_state);
+ if (wifi_last_power_state > VCONFKEY_WIFI_OFF && airplane_mode == 0) {
+#if defined TIZEN_TELEPHONY_ENABLE
+ int tapi_state = 0;
+ vconf_get_bool(VCONFKEY_TELEPHONY_READY, &tapi_state);
+ if (tapi_state == FALSE) {
+ DBG("Telephony API is not initialized yet");
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_READY,
+ __netconfig_tapi_state_changed_cb, NULL);
+
+ goto done;
+ } else {
+ if (netconfig_tapi_check_sim_state() == FALSE) {
+ DBG("SIM is not initialized yet");
+
+ goto done;
+ }
+ }
+#endif
+ DBG("Turn Wi-Fi on automatically");
+#if defined TIZEN_WEARABLE
+ netconfig_wifi_on_wearable(TRUE);
+#else
+ netconfig_wifi_on();
+#endif
+ }
+
+#if defined TIZEN_TELEPHONY_ENABLE
+done:
+#endif
+
+#if defined TIZEN_WEARABLE
+ __netconfig_wifi_wearable_set_state_changed_cb(W_SERVICE_TYPE_BT, NULL);
+
+ vconf_notify_key_changed(VCONF_WIFI_WEARABLE_WIFI_USE,
+ __netconfig_wifi_wearable_wifi_use_mode, NULL);
+
+#if defined TIZEN_TELEPHONY_ENABLE
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+ __netconfig_wifi_wearable_airplane_mode, NULL);
+#endif
+#else
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE,
+ __netconfig_wifi_restrict_mode, NULL);
+#if defined TIZEN_TELEPHONY_ENABLE
vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
__netconfig_wifi_airplane_mode, NULL);
+#endif
+#endif
+
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE,
+ __netconfig_wifi_emergency_mode, NULL);
vconf_notify_key_changed(VCONFKEY_PM_STATE,
__netconfig_wifi_pm_state_mode, NULL);
+}
- vconf_get_int(VCONF_WIFI_LAST_POWER_STATE, &wifi_last_power_state);
-
- if (wifi_last_power_state == WIFI_POWER_ON) {
- DBG("Turn Wi-Fi on automatically");
-
- __netconfig_wifi_try_to_load_driver();
- }
+void netconfig_wifi_power_deinitialize(void)
+{
}
-gboolean netconfig_iface_wifi_load_driver(NetconfigWifi *wifi, GError **error)
+gboolean handle_load_driver(Wifi *wifi,
+ GDBusMethodInvocation *context, gboolean device_picker_test)
{
+ int err;
+
DBG("Wi-Fi power on requested");
g_return_val_if_fail(wifi != NULL, FALSE);
- int err;
+#if defined TIZEN_WEARABLE
+ err = netconfig_wifi_on_wearable(device_picker_test);
+#else
+ err = netconfig_wifi_on();
- if (netconfig_is_wifi_allowed() != TRUE) {
- netconfig_error_security_restricted(error);
+ if (device_picker_test == TRUE)
+ netconfig_wifi_enable_device_picker_test();
+#endif
+ if (err < 0) {
+ if (err == -EINPROGRESS)
+ netconfig_error_inprogress(context);
+ else if (err == -EALREADY)
+ netconfig_error_already_exists(context);
+ else if (err == -EPERM)
+ netconfig_error_permission_denied(context);
+ else
+ netconfig_error_wifi_driver_failed(context);
return FALSE;
}
- if (power_in_progress) {
- netconfig_error_wifi_driver_failed(error);
- return FALSE;
- }
- err = __netconfig_wifi_try_to_load_driver();
+ netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_AIRPLANE, 0);
+
+ wifi_complete_load_driver(wifi, context);
+ return TRUE;
+}
+
+gboolean handle_remove_driver(Wifi *wifi, GDBusMethodInvocation *context)
+{
+ int err;
+
+ DBG("Wi-Fi power off requested");
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ err = netconfig_wifi_off();
if (err < 0) {
if (err == -EINPROGRESS)
- netconfig_error_wifi_load_inprogress(error);
+ netconfig_error_inprogress(context);
+ else if (err == -EALREADY)
+ netconfig_error_already_exists(context);
+ else if (err == -EPERM)
+ netconfig_error_permission_denied(context);
else
- netconfig_error_wifi_driver_failed(error);
-
+ netconfig_error_wifi_driver_failed(context);
return FALSE;
}
+ netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_AIRPLANE, 0);
+
+ wifi_complete_remove_driver(wifi, context);
return TRUE;
}
-gboolean netconfig_iface_wifi_remove_driver(NetconfigWifi *wifi, GError **error)
+gboolean handle_load_p2p_driver(Wifi *wifi, GDBusMethodInvocation *context)
{
- DBG("Wi-Fi power off requested");
+ int err = 0;
+
+ DBG("P2P power on requested");
g_return_val_if_fail(wifi != NULL, FALSE);
- if (power_in_progress) {
- netconfig_error_wifi_driver_failed(error);
+#if defined TIZEN_WEARABLE
+ err = netconfig_wifi_on_wearable(FALSE);
+#else
+ err = netconfig_wifi_on();
+#endif
+ if (err < 0)
+ if (err != -EINPROGRESS && err != -EALREADY) {
+ netconfig_error_inprogress(context);
+ return FALSE;
+ }
+
+ netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_AIRPLANE, 0);
+
+#if defined TIZEN_P2P_ENABLE && defined WLAN_CONCURRENT_MODE
+ err = __netconfig_p2p_supplicant(TRUE);
+ if (err < 0) {
+ netconfig_error_wifi_direct_failed(context);
return FALSE;
}
+#endif
- if (__netconfig_wifi_try_to_remove_driver() != TRUE) {
- netconfig_error_wifi_driver_failed(error);
+ wifi_complete_load_p2p_driver(wifi, context);
+ return TRUE;
+}
+gboolean handle_remove_p2p_driver(Wifi *wifi, GDBusMethodInvocation *context)
+{
+#if defined TIZEN_P2P_ENABLE && defined WLAN_CONCURRENT_MODE
+ int err = 0;
+#endif
+
+ DBG("P2P power off requested");
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+#if defined TIZEN_P2P_ENABLE && defined WLAN_CONCURRENT_MODE
+ err = __netconfig_p2p_supplicant(FALSE);
+ if (err < 0) {
+ netconfig_error_wifi_direct_failed(context);;
return FALSE;
}
+#endif
+ wifi_complete_remove_p2p_driver(wifi, context);
return TRUE;
}
+
+#if defined TIZEN_TV
+static int __netconfig_get_random_mac(unsigned char *mac_buf, int mac_len)
+{
+ DBG("Generate Random Mac address of ethernet");
+ FILE *fp;
+ int rc;
+
+ fp = fopen(OS_RANDOM_FILE, "rb");
+
+ if (fp == NULL) {
+ ERR("Could not open /dev/urandom");
+ return -1;
+ }
+ rc = fread(mac_buf, 1, mac_len, fp);
+ if (fp)
+ fclose(fp);
+
+ return rc != mac_len ? -1 : 0;
+}
+
+void __netconfig_set_ether_macaddr()
+{
+
+ DBG("Set wired Mac address ");
+ char *mac_addr = NULL;
+ int rv = -1;
+
+ mac_addr = vconf_get_str(VCONF_ETH_MAC_ADDRESS);
+ if (mac_addr == NULL) {
+ DBG("vconf_get_str Failed\n");
+ return;
+ }
+ /* Checking Invalid MAC Address */
+ if ((strlen(mac_addr) == 0)) {
+ ERR("Failed to get valid MAC Address from vconf");
+ /*Generate the Random Mac address*/
+ unsigned char rand_mac_add[ETH_MAC_ADDR_SIZE+1];
+
+ if (__netconfig_get_random_mac(rand_mac_add, ETH_MAC_ADDR_SIZE == -1)) {
+
+ ERR("Could not generate the Random Mac address");
+ g_free(mac_addr);
+ return;
+ }
+
+ rand_mac_add[0] &= 0xFE; /*Clear multicase bit*/
+ rand_mac_add[0] |= 0x02; /*set local assignment bit*/
+
+ /*Set the Mac address in Vconf*/
+ sprintf(mac_addr, "%x:%x:%x:%x:%x:%x",
+ rand_mac_add[0], rand_mac_add[1],
+ rand_mac_add[2], rand_mac_add[3],
+ rand_mac_add[4], rand_mac_add[5]);
+
+ netconfig_set_vconf_str(VCONF_ETH_MAC_ADDRESS, mac_addr);
+ }
+
+ DBG("MAC Address of eth0 [%s]",mac_addr);
+ const char *path = NET_EXEC_PATH;
+ char *const args[] = { "/sbin/ifconfig", "eth0", "hw",
+ "ether",mac_addr, "up", NULL};
+ char *const envs[] = { NULL };
+ rv = netconfig_execute_file(path, args, envs);
+
+ if (rv < 0) {
+ ERR("Unable to execute system command");
+ }
+ g_free(mac_addr);
+
+}
+#endif
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "wifi-ssid-scan.h"
#include "wifi-background-scan.h"
+enum netconfig_wifi_security {
+ WIFI_SECURITY_UNKNOWN = 0x00,
+ WIFI_SECURITY_NONE = 0x01,
+ WIFI_SECURITY_WEP = 0x02,
+ WIFI_SECURITY_PSK = 0x03,
+ WIFI_SECURITY_IEEE8021X = 0x04,
+};
+
struct bss_info_t {
- unsigned char ssid[32];
+ unsigned char ssid[33];
enum netconfig_wifi_security security;
- dbus_bool_t privacy;
- dbus_bool_t wps;
+ gboolean privacy;
+ gboolean wps;
};
static gboolean wifi_ssid_scan_state = FALSE;
static GSList *wifi_bss_info_list = NULL;
static guint netconfig_wifi_ssid_scan_timer = 0;
+static char *g_ssid = NULL;
static gboolean __netconfig_wifi_ssid_scan_timeout(gpointer data)
{
INFO("Wi-Fi SSID scan started");
wifi_ssid_scan_state = TRUE;
- netconfig_start_timer_seconds(
- 5,
+ netconfig_start_timer_seconds(5,
__netconfig_wifi_ssid_scan_timeout,
NULL,
&netconfig_wifi_ssid_scan_timer);
/* TODO: Revise following code */
#define NETCONFIG_DBUS_REPLY_TIMEOUT (10 * 1000)
-
- DBusConnection *connection = NULL;
- DBusMessage *message = NULL;
- DBusMessage *reply = NULL;
- DBusMessageIter iter, dict, entry;
- DBusMessageIter value, array, array2;
- DBusError error;
- int MessageType = 0;
- const char *key1 = "Type";
- const char *val1 = "active";
- const char *key2 = "SSIDs";
-
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ GDBusConnection *connection = NULL;
+ GVariant *reply = NULL;
+ GVariant *params = NULL;
+ GError *error = NULL;
+ GVariantBuilder *builder1 = NULL;
+ GVariantBuilder *builder2 = NULL;
+ GVariantBuilder *builder3 = NULL;
+ const gchar *key1 = "Type";
+ const gchar *val1 = "active";
+ const gchar *key2 = "SSIDs";
+ int i = 0;
+
+ connection = netconfig_gdbus_get_connection();
if (connection == NULL) {
- ERR("Error!!! Failed to get system DBus");
- goto error;
- }
-
- message = dbus_message_new_method_call(SUPPLICANT_SERVICE,
- object_path, SUPPLICANT_INTERFACE ".Interface", "Scan");
- if (message == NULL) {
- ERR("Error!!! DBus method call fail");
- goto error;
+ DBG("Failed to get GDBusconnection");
+ return FALSE;
}
- dbus_message_iter_init_append(message, &iter);
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
-
- dbus_message_iter_open_container(&dict,
- DBUS_TYPE_DICT_ENTRY, NULL, &entry);
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key1);
+ builder1 = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
+ g_variant_builder_add(builder1, "{sv}", key1, g_variant_new_string(val1));
- dbus_message_iter_open_container(&entry,
- DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &value);
- dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &val1);
+ builder2 = g_variant_builder_new(G_VARIANT_TYPE ("aay"));
+ builder3 = g_variant_builder_new (G_VARIANT_TYPE ("ay"));
- dbus_message_iter_close_container(&entry, &value);
- dbus_message_iter_close_container(&dict, &entry);
-
- dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key2);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING
- DBUS_TYPE_ARRAY_AS_STRING
- DBUS_TYPE_BYTE_AS_STRING,
- &value);
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_ARRAY_AS_STRING
- DBUS_TYPE_BYTE_AS_STRING,
- &array);
- dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &array2);
+ for (i = 0; i < strlen(ssid); i++) {
+ g_variant_builder_add (builder3, "y", ssid[i]);
+ }
- dbus_message_iter_append_fixed_array(&array2, DBUS_TYPE_BYTE, &ssid, strlen(ssid));
+ g_variant_builder_add(builder2, "@ay", g_variant_builder_end(builder3));
+ g_variant_builder_add(builder1, "{sv}", key2, g_variant_builder_end(builder2));
- dbus_message_iter_close_container(&array, &array2);
- dbus_message_iter_close_container(&value, &array);
- dbus_message_iter_close_container(&entry, &value);
- dbus_message_iter_close_container(&dict, &entry);
- dbus_message_iter_close_container(&iter, &dict);
+ params = g_variant_new("(@a{sv})", g_variant_builder_end(builder1));
- dbus_error_init(&error);
+ g_variant_builder_unref(builder1);
+ g_variant_builder_unref(builder2);
+ g_variant_builder_unref(builder3);
- reply = dbus_connection_send_with_reply_and_block(connection, message,
- NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
+ reply = g_dbus_connection_call_sync(
+ connection,
+ SUPPLICANT_SERVICE,
+ object_path,
+ SUPPLICANT_INTERFACE ".Interface",
+ "Scan",
+ params,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ NETCONFIG_DBUS_REPLY_TIMEOUT,
+ netconfig_gdbus_get_gdbus_cancellable(),
+ &error);
if (reply == NULL) {
- if (dbus_error_is_set(&error) == TRUE) {
+ if (error != NULL) {
ERR("Error!!! dbus_connection_send_with_reply_and_block() failed. "
- "DBus error [%s: %s]", error.name, error.message);
-
- dbus_error_free(&error);
- return FALSE;
+ "DBus error [%d: %s]", error->code, error->message);
+ g_error_free(error);
} else
ERR("Error!!! Failed to get properties");
- goto error;
+ return FALSE;
}
- MessageType = dbus_message_get_type(reply);
- if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
- const char *err_msg = dbus_message_get_error_name(reply);
- ERR("Error!!! Error message received %s", err_msg);
- goto error;
+ if (g_ssid != NULL) {
+ g_free(g_ssid);
}
- dbus_message_unref(message);
- dbus_message_unref(reply);
- dbus_connection_unref(connection);
+ g_ssid = g_strdup(ssid);
- return TRUE;
+ g_variant_unref(reply);
-error:
- if (message != NULL)
- dbus_message_unref(message);
-
- if (reply != NULL)
- dbus_message_unref(reply);
-
- if (connection != NULL)
- dbus_connection_unref(connection);
-
- return FALSE;
+ return TRUE;
}
static void __netconfig_wifi_notify_ssid_scan_done(void)
{
- DBusMessage *signal;
- DBusConnection *connection = NULL;
- DBusMessageIter dict, type, array, value;
- DBusError error;
- char *prop_ssid = "ssid";
- char *prop_security = "security";
- const char *sig_name = "SpecificScanCompleted";
-
- dbus_error_init(&error);
-
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
- if (connection == NULL) {
- /* TODO: If this occurs then UG should be informed abt SCAN fail. CHECK THIS. */
- ERR("Error!!! Failed to get system DBus, error [%s]", error.message);
- dbus_error_free(&error);
-
- g_slist_free_full(wifi_bss_info_list, g_free);
- wifi_bss_info_list = NULL;
-
- return;
+ GVariantBuilder *builder = NULL;
+ GSList* list = NULL;
+ const char *prop_ssid = "ssid";
+ const char *prop_security = "security";
+ const char *prop_wps = "wps";
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
+ for (list = wifi_bss_info_list; list != NULL; list = list->next) {
+ struct bss_info_t *bss_info = (struct bss_info_t *)list->data;
+ if (bss_info && g_strcmp0((char *)bss_info->ssid, g_ssid) == 0) {
+ const gchar *ssid = (char *)bss_info->ssid;
+ enum netconfig_wifi_security security = bss_info->security;
+ gboolean wps = bss_info->wps;
+ DBG("BSS found; SSID:%s security:%d WPS:%d", ssid, security, wps);
+
+ /* SSID */
+ g_variant_builder_add(builder, "{sv}", prop_ssid, g_variant_new("(s)", ssid));
+ /* Security */
+ g_variant_builder_add(builder, "{sv}", prop_security, g_variant_new_int32(security));
+ /* WPS */
+ g_variant_builder_add(builder, "{sv}", prop_wps, g_variant_new_boolean(wps));
+ }
}
- signal = dbus_message_new_signal(NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE, sig_name);
- if (signal == NULL) {
- /* TODO: If this occurs then UG should be informed abt SCAN fail. CHECK THIS. */
- dbus_connection_unref(connection);
+ wifi_emit_specific_scan_completed((Wifi *)get_netconfig_wifi_object(),
+ g_variant_builder_end(builder));
+
+ if (builder)
+ g_variant_builder_unref(builder);
+ if (wifi_bss_info_list != NULL) {
g_slist_free_full(wifi_bss_info_list, g_free);
wifi_bss_info_list = NULL;
-
- return;
}
- dbus_message_iter_init_append(signal, &array);
- dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY, "{sv}", &dict);
- GSList* list = wifi_bss_info_list;
- while (list) {
- struct bss_info_t *bss_info = (struct bss_info_t *)g_slist_nth_data(list, 0);
-
- if (bss_info) {
- char *ssid = (char *)&(bss_info->ssid[0]);
- dbus_int16_t security = bss_info->security;
- DBG("Bss found. SSID: %s; Sec mode: %d;", ssid, security);
-
- /* Lets pack the SSID */
- dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, 0, &type);
- dbus_message_iter_append_basic(&type, DBUS_TYPE_STRING, &prop_ssid);
- dbus_message_iter_open_container(&type, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &value);
-
- dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &ssid);
- dbus_message_iter_close_container(&type, &value);
- dbus_message_iter_close_container(&dict, &type);
-
- /* Lets pack the Security */
- dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, 0, &type);
- dbus_message_iter_append_basic(&type, DBUS_TYPE_STRING, &prop_security);
- dbus_message_iter_open_container(&type, DBUS_TYPE_VARIANT, DBUS_TYPE_INT16_AS_STRING, &value);
-
- dbus_message_iter_append_basic(&value, DBUS_TYPE_INT16, &security);
- dbus_message_iter_close_container(&type, &value);
- dbus_message_iter_close_container(&dict, &type);
- }
- list = g_slist_next(list);
+ if (g_ssid != NULL) {
+ g_free(g_ssid);
+ g_ssid = NULL;
}
- dbus_message_iter_close_container(&array, &dict);
-
- dbus_error_init(&error);
- dbus_connection_send(connection, signal, NULL);
+ INFO("SpecificScanCompleted");
- dbus_message_unref(signal);
- dbus_connection_unref(connection);
-
- g_slist_free_full(wifi_bss_info_list, g_free);
- wifi_bss_info_list = NULL;
-
- INFO("(%s)", sig_name);
+ return;
}
static void __netconfig_wifi_check_security(const char *str_keymgmt, struct bss_info_t *bss_data)
}
}
-static void __netconfig_wifi_parse_keymgmt_message(DBusMessageIter *iter, struct bss_info_t *bss_data)
+static void __netconfig_wifi_parse_keymgmt_message(GVariant *param, struct bss_info_t *bss_data)
{
- DBusMessageIter dict, entry, array, value;
- const char *key;
-
- if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
- return;
-
- dbus_message_iter_recurse(iter, &dict);
- while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
- dbus_message_iter_recurse(&dict, &entry);
-
- if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING)
- return;
-
- dbus_message_iter_get_basic(&entry, &key);
- if (g_strcmp0(key, "KeyMgmt") == 0) {
- dbus_message_iter_next(&entry);
-
- if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT)
- return;
-
- dbus_message_iter_recurse(&entry, &array);
- if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
- return;
-
- dbus_message_iter_recurse(&array, &value);
- while (dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_STRING) {
- const char *str = NULL;
-
- dbus_message_iter_get_basic(&value, &str);
- if (str == NULL)
- return;
-
+ GVariantIter *iter1;
+ GVariant *var;
+ gchar *key;
+
+ g_variant_get(param, "a{sv}", &iter1);
+ while (g_variant_iter_loop(iter1, "{sv}", &key, &var)) {
+ if (g_strcmp0(key, "KeyMgmt") == 0) {//check this :iterate
+ GVariantIter *iter2;
+ g_variant_get(var, "as", &iter2);
+ char *str;
+ while (g_variant_iter_loop(iter2, "s", &str)) {
+ if (str == NULL) {
+ break;
+ }
__netconfig_wifi_check_security(str, bss_data);
- dbus_message_iter_next(&value);
}
+ g_variant_iter_free (iter2);
}
-
- dbus_message_iter_next(&dict);
}
+
+ g_variant_iter_free (iter1);
+
+ return;
}
gboolean netconfig_wifi_get_ssid_scan_state(void)
__netconfig_wifi_ssid_scan_finished();
__netconfig_wifi_notify_ssid_scan_done();
-
- netconfig_wifi_bgscan_start();
}
-void netconfig_wifi_bss_added(DBusMessage *message)
+void netconfig_wifi_bss_added(GVariant *message)
{
- DBusMessageIter iter, dict, entry;
- DBusMessageIter value, array;
- const char *key;
+ GVariantIter *iter;
+ GVariant *value;
+ const gchar *path = NULL;
+ const gchar *key;
struct bss_info_t *bss_info;
if (netconfig_wifi_get_ssid_scan_state() != TRUE)
INFO("NEW BSS added");
- if (!dbus_message_iter_init(message, &iter)) {
+ if (message == NULL) {
DBG("Message does not have parameters");
return;
}
- dbus_message_iter_next(&iter);
- if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) {
- DBG("Invalid message type");
- return;
- }
+ if (path != NULL)
+ INFO("Object path of BSS added is %s",path);
bss_info = g_try_new0(struct bss_info_t, 1);
- if (bss_info == NULL) {
- DBG("Out of memory");
+ if (bss_info == NULL)
return;
- }
-
- dbus_message_iter_recurse(&iter, &dict);
- while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
- dbus_message_iter_recurse(&dict, &entry);
-
- if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING)
- goto error;
-
- dbus_message_iter_get_basic(&entry, &key);
- if (key == NULL)
- goto error;
-
- dbus_message_iter_next(&entry);
- if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT)
- goto error;
-
- dbus_message_iter_recurse(&entry, &value);
+ g_variant_get(message, "(oa{sv})", &path, &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
if (g_strcmp0(key, "SSID") == 0) {
- unsigned char *ssid;
- int ssid_len;
-
- dbus_message_iter_recurse(&value, &array);
- dbus_message_iter_get_fixed_array(&array, &ssid, &ssid_len);
-
+ const guchar *ssid;
+ gsize ssid_len;
+ ssid = g_variant_get_fixed_array(value, &ssid_len, sizeof(guchar));
if (ssid_len > 0 && ssid_len < 33)
memcpy(bss_info->ssid, ssid, ssid_len);
else
memset(bss_info->ssid, 0, sizeof(bss_info->ssid));
} else if (g_strcmp0(key, "Privacy") == 0) {
- dbus_bool_t privacy = FALSE;
-
- dbus_message_iter_get_basic(&value, &privacy);
+ gboolean privacy = FALSE;
+ privacy = g_variant_get_boolean(value);
bss_info->privacy = privacy;
} else if ((g_strcmp0(key, "RSN") == 0) || (g_strcmp0(key, "WPA") == 0)) {
-
- __netconfig_wifi_parse_keymgmt_message(&value, bss_info);
+ __netconfig_wifi_parse_keymgmt_message(value, bss_info);
} else if (g_strcmp0(key, "IEs") == 0) {
- unsigned char *ie;
- int ie_len;
-
- dbus_message_iter_recurse(&value, &array);
- dbus_message_iter_get_fixed_array(&array, &ie, &ie_len);
+ const guchar *ie;
+ gsize ie_len;
+ ie = g_variant_get_fixed_array(value, &ie_len, sizeof(guchar));
+ DBG("The IE : %s",ie);
}
-
- dbus_message_iter_next(&dict);
}
- if (bss_info->ssid[0] == 0)
- goto error;
+ g_variant_iter_free(iter);
+
+ if (bss_info->ssid[0] == '\0') {
+ g_free(bss_info);
+ return;
+ }
if (bss_info->security == WIFI_SECURITY_UNKNOWN) {
if (bss_info->privacy == TRUE)
}
wifi_bss_info_list = g_slist_append(wifi_bss_info_list, bss_info);
- return;
-
-error:
- g_free(bss_info);
}
gboolean netconfig_wifi_ssid_scan(const char *ssid)
{
- char object_path[DBUS_PATH_MAX_BUFLEN] = { 0, };
- char *path_ptr = &object_path[0];
+ const char *if_path;
static char *scan_ssid = NULL;
netconfig_wifi_bgscan_stop();
scan_ssid = g_strdup(ssid);
}
- if (scan_ssid == NULL) {
- netconfig_wifi_bgscan_start();
- return FALSE;
+ if (scan_ssid == NULL)
+ goto error;
+
+ if_path = netconfig_wifi_get_supplicant_interface();
+ if (if_path == NULL) {
+ DBG("Fail to get wpa_supplicant DBus path");
+ goto error;
}
if (netconfig_wifi_get_scanning() == TRUE) {
- DBG("Wi-Fi scan is in progress! SSID %s scan will be delayed",
- scan_ssid);
- return FALSE;
+ DBG("Wi-Fi scan in progress, %s scan will be delayed", scan_ssid);
+ g_free(scan_ssid);
+ return TRUE;
}
- INFO("Start SSID Scan with %s", scan_ssid);
-
if (wifi_bss_info_list) {
g_slist_free_full(wifi_bss_info_list, g_free);
wifi_bss_info_list = NULL;
}
- if (netconfig_wifi_get_supplicant_interface(&path_ptr) != TRUE) {
- DBG("Fail to get wpa_supplicant DBus path");
- return FALSE;
- }
-
- if (__netconfig_wifi_invoke_ssid_scan(
- (const char *)object_path, (const char *)scan_ssid) == TRUE) {
+ INFO("Start Wi-Fi scan with %s(%d)", scan_ssid, strlen(scan_ssid));
+ if (__netconfig_wifi_invoke_ssid_scan(if_path,
+ (const char *)scan_ssid) == TRUE) {
__netconfig_wifi_ssid_scan_started();
g_free(scan_ssid);
return TRUE;
}
+error:
+ if (scan_ssid != NULL) {
+ g_free(scan_ssid);
+ scan_ssid = NULL;
+ }
+
+ netconfig_wifi_bgscan_start(FALSE);
+
return FALSE;
}
-gboolean netconfig_iface_wifi_request_specific_scan(NetconfigWifi *wifi,
- gchar *ssid, GError **error)
+gboolean handle_request_specific_scan(Wifi *wifi,
+ GDBusMethodInvocation *context, const gchar *ssid)
{
+ gboolean result = FALSE;
+
g_return_val_if_fail(wifi != NULL, FALSE);
g_return_val_if_fail(ssid != NULL, FALSE);
- netconfig_wifi_ssid_scan((const char *)ssid);
+ result = netconfig_wifi_ssid_scan((const char *)ssid);
- return TRUE;
+ if (result != TRUE) {
+ netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailSpecificScan");
+ } else {
+ wifi_complete_request_wps_scan(wifi, context);
+ }
+
+ return result;
}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
+#include <aul.h>
#include <vconf.h>
#include <vconf-keys.h>
+#include <bundle.h>
+#include <bundle_internal.h>
+#include <eventsystem.h>
#include "log.h"
#include "util.h"
#include "netdbus.h"
-#include "network-state.h"
-#include "network-statistics.h"
#include "wifi-state.h"
+#include "wifi-power.h"
+#include "netsupplicant.h"
+#include "network-state.h"
#include "wifi-indicator.h"
+#include "network-statistics.h"
#include "wifi-background-scan.h"
-static int profiles_count = 0;
+#define NETCONFIG_NETWORK_NOTIFICATION_TIMEOUT 15 * 1000
+
+static gboolean new_bss_found = FALSE;
+static guint network_noti_timer_id = 0;
static enum netconfig_wifi_service_state
wifi_service_state = NETCONFIG_WIFI_UNKNOWN;
+static enum netconfig_wifi_tech_state
+ wifi_technology_state = NETCONFIG_WIFI_TECH_UNKNOWN;
static GSList *notifier_list = NULL;
-static void __netconfig_wifi_set_profiles_count(const int count)
+static void __netconfig_pop_wifi_connected_poppup(const char *ssid)
{
- profiles_count = count;
+ bundle *b = NULL;
+
+ if (ssid == NULL)
+ return;
+
+ b = bundle_create();
+
+ bundle_add(b, "_SYSPOPUP_TITLE_", "Network connection popup");
+ bundle_add(b, "_SYSPOPUP_TYPE_", "notification");
+ bundle_add(b, "_SYSPOPUP_CONTENT_", "wifi connected");
+ bundle_add(b, "_AP_NAME_", ssid);
+
+ DBG("Launch Wi-Fi connected alert network popup");
+ aul_launch_app("net.netpopup", b);
+
+ bundle_free(b);
}
-static int __netconfig_wifi_get_profiles_count(void)
+static void __netconfig_wifi_state_connected_activation(void)
{
- return profiles_count;
+ /* Add activation of services when Wi-Fi is connected */
+ bundle *b = NULL;
+
+ b = bundle_create();
+ aul_launch_app("com.samsung.keepit-service-standby", b);
+ bundle_free(b);
}
static void __netconfig_wifi_set_essid(void)
return;
}
- vconf_set_str(VCONFKEY_WIFI_CONNECTED_AP_NAME, essid_name);
+ netconfig_set_vconf_str(VCONFKEY_WIFI_CONNECTED_AP_NAME, essid_name);
+
+ __netconfig_pop_wifi_connected_poppup(essid_name);
}
static void __netconfig_wifi_unset_essid(void)
{
- vconf_set_str(VCONFKEY_WIFI_CONNECTED_AP_NAME, "");
+ netconfig_set_vconf_str(VCONFKEY_WIFI_CONNECTED_AP_NAME, "");
}
-static GSList *__netconfig_wifi_state_get_service_profiles(DBusMessage *message)
+static gboolean __netconfig_is_wifi_profile_available(void)
{
- GSList *service_profiles = NULL;
- DBusMessageIter iter, dict;
+ GVariant *message = NULL;
+ GVariantIter *iter, *next;
+ gchar *obj;
+
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "GetServices", NULL);
+ if (message == NULL) {
+ ERR("Failed to get service list");
+ return FALSE;
+ }
- dbus_message_iter_init(message, &iter);
- dbus_message_iter_recurse(&iter, &dict);
+ g_variant_get(message, "(a(oa{sv}))", &iter);
+ while (g_variant_iter_loop(iter, "(oa{sv})", &obj, &next)) {
+ if (obj == NULL || netconfig_is_wifi_profile((const gchar*)obj) == FALSE) {
+ continue;
+ }
+
+ g_variant_iter_free(next);
+ g_free(obj);
+ break;
+ }
+
+ g_variant_unref(message);
- while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_STRUCT) {
- DBusMessageIter entry;
- const char *object_path = NULL;
+ g_variant_iter_free(iter);
- dbus_message_iter_recurse(&dict, &entry);
- dbus_message_iter_get_basic(&entry, &object_path);
+ return TRUE;
+}
+
+static gboolean __netconfig_wifi_is_favorited(GVariantIter *array)
+{
+ gboolean is_favorite = FALSE;
+ gchar *key;
+ GVariant *var;
- if (object_path == NULL) {
- dbus_message_iter_next(&dict);
+ while (g_variant_iter_loop(array, "{sv}", &key, &var)) {
+ gboolean value;
+
+ if (g_str_equal(key, "Favorite") != TRUE) {
continue;
}
- if (netconfig_is_wifi_profile(object_path) == TRUE)
- service_profiles = g_slist_append(service_profiles,
- g_strdup(object_path));
-
- dbus_message_iter_next(&dict);
+ value = g_variant_get_boolean(var);
+ if (value)
+ is_favorite = TRUE;
+ g_free(key);
+ g_variant_unref(var);
+ break;
}
- return service_profiles;
+ return is_favorite;
}
static char *__netconfig_wifi_get_connman_favorite_service(void)
{
char *favorite_service = NULL;
- DBusMessage *message = NULL;
- GSList *service_profiles = NULL;
- GSList *list = NULL;
+ GVariant *message = NULL;
+ gchar *obj;
+ GVariantIter *iter, *next;
message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
return NULL;
}
- /* Get service profiles from ConnMan Manager */
- service_profiles = __netconfig_wifi_state_get_service_profiles(message);
- dbus_message_unref(message);
-
- for (list = service_profiles; list != NULL; list = list->next) {
- char *profile_path = list->data;
- DBusMessageIter iter, array;
-
- if (favorite_service != NULL)
- break;
-
- message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
- profile_path, CONNMAN_SERVICE_INTERFACE, "GetProperties", NULL);
-
- if (message == NULL) {
- ERR("Failed to get service information of %s", profile_path);
+ g_variant_get(message, "(a(oa{sv}))", &iter);
+ while (g_variant_iter_loop(iter, "(oa{sv})", &obj, &next)) {
+ if (obj == NULL || netconfig_is_wifi_profile(obj) == FALSE) {
continue;
}
- dbus_message_iter_init(message, &iter);
- dbus_message_iter_recurse(&iter, &array);
-
- while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
- DBusMessageIter entry, variant;
- const char *key = NULL;
- dbus_bool_t value;
-
- dbus_message_iter_recurse(&array, &entry);
- dbus_message_iter_get_basic(&entry, &key);
-
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &variant);
-
- if (g_str_equal(key, "Favorite") != TRUE) {
- dbus_message_iter_next(&array);
- continue;
- }
-
- dbus_message_iter_get_basic(&variant, &value);
-
- if (value)
- favorite_service = g_strdup(profile_path);
-
+ if (__netconfig_wifi_is_favorited(next) == TRUE) {
+ favorite_service = g_strdup(obj);
+ g_free(obj);
+ g_variant_iter_free(next);
break;
}
-
- dbus_message_unref(message);
}
- g_slist_free(service_profiles);
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
return favorite_service;
}
}
}
+void netconfig_wifi_set_bss_found(const gboolean found)
+{
+ if (found != new_bss_found)
+ new_bss_found = found;
+}
+
+gboolean netconfig_wifi_is_bss_found(void)
+{
+ return new_bss_found;
+}
+
+static void __netconfig_wifi_state_set_power_save(gboolean power_save)
+{
+ gboolean result;
+ const char *if_path;
+ GVariant *input_args = NULL;
+ static gboolean old_state = TRUE;
+ const gchar *args_disable = "POWERMODE 1";
+ const gchar *args_enable = "POWERMODE 0";
+ if (old_state == power_save)
+ return;
+
+ if_path = netconfig_wifi_get_supplicant_interface();
+ if (if_path == NULL) {
+ ERR("Fail to get wpa_supplicant DBus path");
+ return;
+ }
+
+ if (power_save)
+ input_args = g_variant_new_string(args_enable);
+ else
+ input_args = g_variant_new_string(args_disable);
+
+ result = netconfig_supplicant_invoke_dbus_method_nonblock(
+ SUPPLICANT_SERVICE,
+ if_path,
+ SUPPLICANT_INTERFACE ".Interface",
+ "Driver",
+ input_args,
+ NULL);
+ if (result == FALSE)
+ ERR("Fail to set power save mode POWERMODE %d", power_save);
+ else
+ old_state = power_save;
+
+ return;
+}
+
+static void __netconfig_wifi_state_set_power_lock(gboolean power_lock)
+{
+ gint32 ret = 0;
+ GVariant *reply;
+ GVariant *params;
+ char state[] = "lcdoff";
+ char flag[] = "staycurstate";
+ char standby[] = "NULL";
+ int timeout = 0;
+ char sleepmargin[] = "sleepmargin";
+
+ const char *lockstate = "lockstate";
+ const char *unlockstate = "unlockstate";
+ static gboolean old_state = FALSE;
+ const char *lock_method;
+
+ if (old_state == power_lock)
+ return;
+
+ if (power_lock == TRUE) {
+ /* deviced power lock enable */
+ params = g_variant_new("(sssi)", state, flag, standby, timeout);
+
+ lock_method = lockstate;
+ } else {
+ /* deviced power lock disable */
+ params = g_variant_new("(ss)", state, sleepmargin);
+
+ lock_method = unlockstate;
+ }
+
+ reply = netconfig_invoke_dbus_method(
+ "org.tizen.system.deviced",
+ "/Org/Tizen/System/DeviceD/Display",
+ "org.tizen.system.deviced.display",
+ lock_method,
+ params);
+ if (reply == NULL){
+ ERR("Failed to set_power_lock");
+ return;
+ }
+
+ ret = g_variant_get_int32(reply);
+ if (ret < 0)
+ ERR("Failed to set power lock %s with ret %d",
+ power_lock == TRUE ? "enable" : "disable", ret);
+ else
+ old_state = power_lock;
+
+ return;
+}
+
void netconfig_wifi_state_set_service_state(
enum netconfig_wifi_service_state new_state)
{
+ static gboolean dhcp_stage = FALSE;
enum netconfig_wifi_service_state old_state = wifi_service_state;
if (old_state == new_state)
wifi_service_state = new_state;
DBG("Wi-Fi state %d ==> %d", old_state, new_state);
+ /* During DHCP, temporarily disable Wi-Fi power saving */
+ if ((old_state < NETCONFIG_WIFI_ASSOCIATION ||
+ old_state == NETCONFIG_WIFI_FAILURE) &&
+ new_state == NETCONFIG_WIFI_CONFIGURATION) {
+ __netconfig_wifi_state_set_power_lock(TRUE);
+ __netconfig_wifi_state_set_power_save(FALSE);
+ dhcp_stage = TRUE;
+ } else if (dhcp_stage == TRUE) {
+ __netconfig_wifi_state_set_power_lock(FALSE);
+ __netconfig_wifi_state_set_power_save(TRUE);
+ dhcp_stage = FALSE;
+ }
+
if (new_state == NETCONFIG_WIFI_CONNECTED) {
- netconfig_del_wifi_found_notification();
+ netconfig_send_notification_to_net_popup(NETCONFIG_DEL_FOUND_AP_NOTI, NULL);
+
+ netconfig_set_vconf_int(VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_CONNECTED);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_STATE,
+ VCONFKEY_NETWORK_WIFI_CONNECTED);
- vconf_set_int(VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_CONNECTED);
- vconf_set_int(VCONFKEY_NETWORK_WIFI_STATE, VCONFKEY_NETWORK_WIFI_CONNECTED);
+ netconfig_set_system_event(SYS_EVENT_WIFI_STATE, EVT_KEY_WIFI_STATE, EVT_VAL_WIFI_CONNECTED);
__netconfig_wifi_set_essid();
netconfig_wifi_indicator_start();
} else if (old_state == NETCONFIG_WIFI_CONNECTED) {
- vconf_set_int (VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_UNCONNECTED);
- vconf_set_int(VCONFKEY_NETWORK_WIFI_STATE, VCONFKEY_NETWORK_WIFI_NOT_CONNECTED);
+ netconfig_send_notification_to_net_popup(NETCONFIG_DEL_PORTAL_NOTI, NULL);
__netconfig_wifi_unset_essid();
+ netconfig_set_vconf_int (VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_UNCONNECTED);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_STATE,
+ VCONFKEY_NETWORK_WIFI_NOT_CONNECTED);
+
+ netconfig_set_system_event(SYS_EVENT_WIFI_STATE, EVT_KEY_WIFI_STATE, EVT_VAL_WIFI_ON);
+
netconfig_wifi_indicator_stop();
+
+ netconfig_wifi_set_bgscan_pause(FALSE);
+
+ netconfig_wifi_bgscan_stop();
+ netconfig_wifi_bgscan_start(TRUE);
+ } else if ( (old_state > NETCONFIG_WIFI_IDLE && old_state < NETCONFIG_WIFI_CONNECTED)
+ && new_state == NETCONFIG_WIFI_IDLE){
+ //in ipv6 case disconnect/association -> association
+ DBG("reset the bg scan period");
+ netconfig_wifi_set_bgscan_pause(FALSE);
+
+ netconfig_wifi_bgscan_stop();
+ netconfig_wifi_bgscan_start(TRUE);
}
__netconfig_wifi_state_changed(new_state);
+
+ if (new_state == NETCONFIG_WIFI_CONNECTED){
+ __netconfig_wifi_state_connected_activation();
+#if defined TIZEN_WEARABLE
+ wc_launch_syspopup(WC_POPUP_TYPE_WIFI_CONNECTED);
+#endif
+ }
}
enum netconfig_wifi_service_state
return wifi_service_state;
}
-enum netconfig_wifi_tech_state netconfig_wifi_get_technology_state(void)
+void netconfig_wifi_state_set_technology_state(
+ enum netconfig_wifi_tech_state new_state)
+{
+ enum netconfig_wifi_tech_state old_state = wifi_technology_state;
+
+ if (old_state == new_state)
+ return;
+
+ wifi_technology_state = new_state;
+
+ DBG("Wi-Fi technology state %d ==> %d", old_state, new_state);
+}
+
+enum netconfig_wifi_tech_state netconfig_wifi_state_get_technology_state(void)
{
- DBusMessage *message = NULL;
- DBusMessageIter iter, array;
+ GVariant *message = NULL, *variant;
+ GVariantIter *iter, *next;
enum netconfig_wifi_tech_state ret = NETCONFIG_WIFI_TECH_OFF;
gboolean wifi_tech_powered = FALSE;
gboolean wifi_tech_connected = FALSE;
- gboolean wifi_tethering = FALSE;
+ const char *path;
+ gchar *key;
+
+ if (wifi_technology_state > NETCONFIG_WIFI_TECH_UNKNOWN)
+ return wifi_technology_state;
message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
"GetTechnologies", NULL);
if (message == NULL) {
- ERR("Failed to get Wi-Fi technology state");
+ ERR("Failed to get_technology_state");
return NETCONFIG_WIFI_TECH_UNKNOWN;
}
- dbus_message_iter_init(message, &iter);
- dbus_message_iter_recurse(&iter, &array);
-
- while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRUCT) {
- DBusMessageIter entry, dict;
- const char *path;
-
- dbus_message_iter_recurse(&array, &entry);
- dbus_message_iter_get_basic(&entry, &path);
-
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &dict);
-
- if (path == NULL ||
- g_str_equal(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == FALSE) {
- dbus_message_iter_next(&array);
+ g_variant_get(message, "(a(oa{sv}))", &iter);
+ while (g_variant_iter_loop(iter, "(oa{sv})", &path, &next)) {
+ if (path == NULL || g_strcmp0(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) != 0) {
continue;
}
- while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
- DBusMessageIter entry1, value1;
- const char *key, *sdata;
- dbus_bool_t data;
+ while (g_variant_iter_loop(next, "{sv}", &key, &variant)) {
+ const gchar *sdata = NULL;
+ gboolean data;
- dbus_message_iter_recurse(&dict, &entry1);
- dbus_message_iter_get_basic(&entry1, &key);
-
- dbus_message_iter_next(&entry1);
- dbus_message_iter_recurse(&entry1, &value1);
-
- if (dbus_message_iter_get_arg_type(&value1) ==
- DBUS_TYPE_BOOLEAN) {
- dbus_message_iter_get_basic(&value1, &data);
+ if (g_variant_is_of_type(variant, G_VARIANT_TYPE_BOOLEAN)) {
+ data = g_variant_get_boolean(variant);
DBG("key-[%s] - %s", key, data ? "True" : "False");
if (strcmp(key, "Powered") == 0 && data) {
} else if (strcmp(key, "Connected") == 0 && data) {
wifi_tech_connected = TRUE;
} else if (strcmp(key, "Tethering") == 0 && data) {
- wifi_tethering = TRUE;
+ // For further use
}
- } else if (dbus_message_iter_get_arg_type(&value1) ==
- DBUS_TYPE_STRING) {
- dbus_message_iter_get_basic(&value1, &sdata);
+ } else if (g_variant_is_of_type(variant, G_VARIANT_TYPE_STRING)) {
+ sdata = g_variant_get_string(variant, NULL);
DBG("%s", sdata);
}
- dbus_message_iter_next(&dict);
}
-
- dbus_message_iter_next(&array);
+ g_variant_iter_free (next);
}
- dbus_message_unref(message);
+ g_variant_unref(message);
- if (wifi_tech_powered)
+ g_variant_iter_free (iter);
+
+ if (wifi_tech_powered == TRUE)
ret = NETCONFIG_WIFI_TECH_POWERED;
- if (wifi_tech_connected)
+ if (wifi_tech_connected == TRUE)
ret = NETCONFIG_WIFI_TECH_CONNECTED;
- if (wifi_tethering)
- ret = NETCONFIG_WIFI_TECH_TETHERING_ON;
+ wifi_technology_state = ret;
+
+ return wifi_technology_state;
+}
+
+void netconfig_wifi_notify_power_failed(void)
+{
+ wifi_emit_power_operation_failed((Wifi *)get_netconfig_wifi_object());
+
+ DBG("Successfully sent signal [PowerOperationFailed]");
+}
+
+void netconfig_wifi_notify_power_completed(gboolean power_on)
+{
+ if (power_on)
+ wifi_emit_power_on_completed((Wifi *)get_netconfig_wifi_object());
+ else
+ wifi_emit_power_off_completed((Wifi *)get_netconfig_wifi_object());
+
+ DBG("Successfully sent signal [%s]",(power_on)?"powerOn":"powerOff");
+}
+
+static void __netconfig_notification_value_changed_cb(
+ keynode_t *node, void *user_data)
+{
+ int value = -1;
+
+ if (vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, &value) < 0) {
+ return;
+ }
+
+ if (value == VCONFKEY_WIFI_QS_DISABLE) {
+ netconfig_send_notification_to_net_popup(NETCONFIG_DEL_FOUND_AP_NOTI,
+ NULL);
+ }
+}
+
+static void __netconfig_register_network_notification(void)
+{
+#if defined TIZEN_WEARABLE
+ return;
+#endif
+ vconf_notify_key_changed(VCONFKEY_WIFI_ENABLE_QS,
+ __netconfig_notification_value_changed_cb, NULL);
+}
- return ret;
+static void __netconfig_deregister_network_notification(void)
+{
+#if defined TIZEN_WEARABLE
+ return;
+#endif
+ vconf_ignore_key_changed(VCONFKEY_WIFI_ENABLE_QS,
+ __netconfig_notification_value_changed_cb);
}
void netconfig_wifi_update_power_state(gboolean powered)
{
- int wifi_state = 0;
+ enum netconfig_wifi_tech_state wifi_tech_state;
/* It's automatically updated by signal-handler
* DO NOT update manually
* It includes Wi-Fi state configuration
*/
- vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
+ wifi_tech_state = netconfig_wifi_state_get_technology_state();
if (powered == TRUE) {
- if (wifi_state == VCONFKEY_WIFI_OFF &&
- netconfig_is_wifi_direct_on() != TRUE &&
- netconfig_is_wifi_tethering_on() != TRUE) {
- DBG("Wi-Fi successfully turned on or waken up from power-save mode");
+ if (wifi_tech_state < NETCONFIG_WIFI_TECH_POWERED &&
+ netconfig_is_wifi_tethering_on() != TRUE) {
+ DBG("Wi-Fi turned on or waken up from power-save mode");
- vconf_set_int(VCONFKEY_NETWORK_WIFI_STATE, VCONFKEY_NETWORK_WIFI_NOT_CONNECTED);
- vconf_set_int(VCONF_WIFI_LAST_POWER_STATE, WIFI_POWER_ON);
- vconf_set_int(VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_UNCONNECTED);
+ netconfig_wifi_state_set_technology_state(
+ NETCONFIG_WIFI_TECH_POWERED);
netconfig_wifi_notify_power_completed(TRUE);
netconfig_wifi_device_picker_service_start();
- netconfig_wifi_bgscan_start();
+ netconfig_set_vconf_int(VCONF_WIFI_LAST_POWER_STATE,
+ VCONFKEY_WIFI_UNCONNECTED);
+ netconfig_set_vconf_int(VCONFKEY_WIFI_STATE,
+ VCONFKEY_WIFI_UNCONNECTED);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_STATE,
+ VCONFKEY_NETWORK_WIFI_NOT_CONNECTED);
+
+ netconfig_set_system_event(SYS_EVENT_WIFI_STATE, EVT_KEY_WIFI_STATE, EVT_VAL_WIFI_ON);
+
+ netconfig_wifi_bgscan_stop();
+ netconfig_wifi_bgscan_start(TRUE);
+
+ /* Add callback to track change in notification setting */
+ __netconfig_register_network_notification();
}
- } else {
- if (wifi_state != VCONFKEY_WIFI_OFF) {
- DBG("Wi-Fi successfully turned off or in power-save mode");
+ } else if (wifi_tech_state > NETCONFIG_WIFI_TECH_OFF) {
+ DBG("Wi-Fi turned off or in power-save mode");
- netconfig_wifi_device_picker_service_stop();
+ netconfig_wifi_state_set_technology_state(
+ NETCONFIG_WIFI_TECH_WPS_ONLY);
- if (netconfig_is_wifi_tethering_on() != TRUE)
- netconfig_wifi_remove_driver();
+ netconfig_wifi_device_picker_service_stop();
- vconf_set_int(VCONFKEY_NETWORK_WIFI_STATE, VCONFKEY_NETWORK_WIFI_OFF);
- vconf_set_int(VCONF_WIFI_LAST_POWER_STATE, WIFI_POWER_OFF);
- vconf_set_int(VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_OFF);
+ netconfig_wifi_disable_technology_state_by_only_connman_signal();
+ netconfig_wifi_driver_and_supplicant(FALSE);
- netconfig_wifi_notify_power_completed(FALSE);
+ netconfig_wifi_notify_power_completed(FALSE);
- netconfig_del_wifi_found_notification();
+ netconfig_set_vconf_int(VCONF_WIFI_LAST_POWER_STATE, VCONFKEY_WIFI_OFF);
+ netconfig_set_vconf_int(VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_OFF);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_STATE,
+ VCONFKEY_NETWORK_WIFI_OFF);
- netconfig_wifi_bgscan_stop();
+ netconfig_set_system_event(SYS_EVENT_WIFI_STATE, EVT_KEY_WIFI_STATE, EVT_VAL_WIFI_OFF);
+
+ netconfig_wifi_set_bgscan_pause(FALSE);
+ netconfig_wifi_bgscan_stop();
+
+ netconfig_wifi_set_bss_found(FALSE);
+
+ /* Inform net-popup to remove the wifi found notification */
+ netconfig_send_notification_to_net_popup(NETCONFIG_DEL_FOUND_AP_NOTI, NULL);
+ netconfig_send_notification_to_net_popup(NETCONFIG_DEL_PORTAL_NOTI, NULL);
+
+ __netconfig_deregister_network_notification();
- __netconfig_wifi_set_profiles_count(0);
- }
}
}
return __netconfig_wifi_get_connman_favorite_service();
}
-void netconfig_wifi_check_network_notification(DBusMessage *message)
+static gboolean __netconfig_wifi_check_network_notification(gpointer data)
{
- DBusMessageIter iter;
- int profiles_count = 0;
- int qs_enable, ug_state;
+ int qs_enable = 0, ug_state = 0;
+ static gboolean check_again = FALSE;
+
+ enum netconfig_wifi_tech_state wifi_tech_state;
+ enum netconfig_wifi_service_state wifi_service_state;
+
+ wifi_tech_state = netconfig_wifi_state_get_technology_state();
+ if (wifi_tech_state < NETCONFIG_WIFI_TECH_POWERED) {
+ DBG("Wi-Fi off or WPS only supported[%d]", wifi_tech_state);
+ goto cleanup;
+ }
- if (netconfig_wifi_state_get_service_state() == NETCONFIG_WIFI_CONNECTED) {
+ wifi_service_state = netconfig_wifi_state_get_service_state();
+ if (wifi_service_state == NETCONFIG_WIFI_CONNECTED) {
DBG("Service state is connected");
- return;
+ goto cleanup;
+ } else if (wifi_service_state == NETCONFIG_WIFI_ASSOCIATION ||
+ wifi_service_state == NETCONFIG_WIFI_CONFIGURATION) {
+ DBG("Service state is connecting (check again : %d)", check_again);
+ if (!check_again) {
+ check_again = TRUE;
+ return TRUE;
+ } else
+ check_again = FALSE;
}
- if (vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, &qs_enable) == -1) {
- DBG("Fail to get %s", VCONFKEY_WIFI_ENABLE_QS);
- return;
+ if (__netconfig_is_wifi_profile_available() == FALSE) {
+ netconfig_send_notification_to_net_popup(
+ NETCONFIG_DEL_FOUND_AP_NOTI, NULL);
+ goto cleanup;
}
+ vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, &qs_enable);
if (qs_enable != VCONFKEY_WIFI_QS_ENABLE) {
DBG("qs_enable != VCONFKEY_WIFI_QS_ENABLE");
- return;
- }
-
- if (vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE, &ug_state) == -1) {
- DBG("Fail to get %s", VCONFKEY_WIFI_UG_RUN_STATE);
- return;
+ goto cleanup;
}
+ vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE, &ug_state);
if (ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND) {
- DBG("ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND");
- return;
- }
-
- if (message == NULL) {
- ERR("Failed to get service list");
- return;
- }
-
- dbus_message_iter_init(message, &iter);
- DBusMessageIter array, value;
- dbus_message_iter_recurse(&iter, &array);
- if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_STRUCT) {
- DBG("Array not found. type %d", dbus_message_iter_get_arg_type(&array));
- return;
+ goto cleanup;
}
- dbus_message_iter_recurse(&array, &value);
- while (dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_OBJECT_PATH) {
- const char *object_path = NULL;
-
- dbus_message_iter_get_basic(&value, &object_path);
+ netconfig_send_notification_to_net_popup(NETCONFIG_ADD_FOUND_AP_NOTI, NULL);
- DBG("found a profile: %s", object_path);
- if (netconfig_is_wifi_profile(object_path) == TRUE) {
- profiles_count++;
- DBG("Total wifi profile cnt = %d", profiles_count);
- }
-
- dbus_message_iter_next(&array);
- if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_STRUCT) {
- DBG("Not a structure entry. Arg type = %d", dbus_message_iter_get_arg_type(&array));
- break;
- }
- dbus_message_iter_recurse(&array, &value);
- }
+ netconfig_wifi_set_bss_found(FALSE);
- if (__netconfig_wifi_get_profiles_count() != profiles_count) {
- DBG("profiles prev_count (%d) - profiles count (%d)",
- __netconfig_wifi_get_profiles_count(), profiles_count);
+cleanup:
+ netconfig_stop_timer(&network_noti_timer_id);
+ return FALSE;
+}
- netconfig_add_wifi_found_notification();
- __netconfig_wifi_set_profiles_count(profiles_count);
- } else
- DBG("No change in profile count[%d]", profiles_count);
+void netconfig_wifi_start_timer_network_notification(void)
+{
+#if defined TIZEN_WEARABLE
+ /* In case of wearable device, no need to notify available Wi-Fi APs */
+ return ;
+#endif
+ netconfig_start_timer(NETCONFIG_NETWORK_NOTIFICATION_TIMEOUT,
+ __netconfig_wifi_check_network_notification, NULL, &network_noti_timer_id);
}
void netconfig_wifi_state_notifier_cleanup(void)
{
- /*
- * Now, all the user_data of notifier_list's element
- * is NULL, so we don't free that, only use g_slist_free.
- * If user_data is not NULL, using g_slist_free_full with
- * destory_notify function to free user_data
- */
- g_slist_free(notifier_list);
+ g_slist_free_full(notifier_list, NULL);
}
void netconfig_wifi_state_notifier_register(
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 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 <vconf.h>
+
+#include "log.h"
+#include "wifi-tel-intf.h"
+
+#define TAPI_HANDLE_MAX 2
+
+#define SIM_SLOT_DUAL 2
+#define SIM_SLOT_SINGLE 1
+
+#define VCONF_TELEPHONY_DEFAULT_DATA_SERVICE "db/telephony/dualsim/default_data_service"
+#define DEFAULT_DATA_SERVICE_SIM1 0
+#define DEFAULT_DATA_SERVICE_SIM2 1
+
+static TapiHandle *tapi_handle_dual[TAPI_HANDLE_MAX+1];
+static TapiHandle *tapi_handle = NULL;
+
+static int _check_current_sim()
+{
+#if defined TIZEN_WEARABLE
+ return -1;
+#else
+ int current_sim = 0;
+ int sim_slot_count = 0;
+
+ if ((vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT_COUNT, &sim_slot_count) != 0)
+ || sim_slot_count == SIM_SLOT_SINGLE) {
+ ERR("failed to get sim slot count (%d)", sim_slot_count);
+ return -1;
+ }
+
+ if (vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE, ¤t_sim) != 0) {
+ ERR("failed to get default data service = %d\n", current_sim);
+ return 0;
+ }
+
+ DBG("default data service [SIM%d]", current_sim);
+ return current_sim;
+#endif
+}
+
+TapiHandle * netconfig_tel_init(void)
+{
+ char **cp_list = NULL;
+ int current_sim = _check_current_sim();
+
+ if (current_sim < 0) {
+ if (tapi_handle == NULL) {
+ tapi_handle = tel_init(NULL);
+ if (tapi_handle == NULL)
+ ERR("tel_init() Failed - modem %d", current_sim);
+ }
+ return tapi_handle;
+ } else {
+ if (tapi_handle_dual[current_sim] == NULL) {
+ cp_list = tel_get_cp_name_list();
+ if (!cp_list) {
+ ERR("tel_get_cp_name_list() Failed");
+ return NULL;
+ }
+
+ tapi_handle_dual[current_sim] = tel_init(cp_list[current_sim]);
+ if (tapi_handle_dual[current_sim] == NULL)
+ ERR("tel_init() Failed - modem %d", current_sim);
+
+ g_strfreev(cp_list);
+ }
+ return tapi_handle_dual[current_sim];
+ }
+}
+
+void netconfig_tel_deinit(void)
+{
+ int current_sim = _check_current_sim();
+
+ if (current_sim < 0){
+ if (tapi_handle)
+ tel_deinit(tapi_handle);
+
+ tapi_handle = NULL;
+ } else {
+ unsigned int i = 0;
+ while (tapi_handle_dual[i]) {
+ tel_deinit(tapi_handle_dual[i]);
+ tapi_handle_dual[i] = NULL;
+ i++;
+ }
+ }
+}
+
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 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 <errno.h>
+#include <vconf.h>
+#include <glib.h>
+
+#include "log.h"
+#include "util.h"
+#include "netdbus.h"
+#include "neterror.h"
+#include "wifi-wps.h"
+#include "wifi-power.h"
+#include "wifi-state.h"
+#include "netsupplicant.h"
+#include "wifi-background-scan.h"
+
+#define NETCONFIG_SSID_LEN 32
+#define NETCONFIG_BSSID_LEN 6
+#define NETCONFIG_WPS_DBUS_REPLY_TIMEOUT (10 * 1000)
+
+#define VCONF_WIFI_ALWAYS_ALLOW_SCANNING \
+ "file/private/wifi/always_allow_scanning"
+
+static gboolean netconfig_is_wps_enabled = FALSE;
+static gboolean netconfig_is_device_scanning = FALSE;
+static gboolean netconfig_is_wps_scan_aborted = FALSE;
+static int wps_bss_list_count = 0;
+
+struct wps_bss_info_t {
+ unsigned char ssid[NETCONFIG_SSID_LEN + 1];
+ unsigned char bssid[NETCONFIG_BSSID_LEN + 1];
+ int ssid_len;
+ int rssi;
+ int mode;
+};
+
+static GSList *wps_bss_info_list = NULL;
+
+static void __netconfig_wps_set_mode(gboolean enable)
+{
+ if (netconfig_is_wps_enabled == enable)
+ return;
+
+ netconfig_is_wps_enabled = enable;
+}
+
+gboolean netconfig_wifi_is_wps_enabled(void)
+{
+ return netconfig_is_wps_enabled;
+}
+
+static void __netconfig_wifi_wps_notify_scan_done(void)//check this
+{
+ GVariantBuilder *builder = NULL;
+ GVariantBuilder *builder1 = NULL;
+ GSList* list = NULL;
+ const char *prop_ssid = "ssid";
+ const char *prop_bssid = "bssid";
+ const char *prop_rssi = "rssi";
+ const char *prop_mode = "mode";
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
+ for (list = wps_bss_info_list; list != NULL; list = list->next) {
+ struct wps_bss_info_t *bss_info = (struct wps_bss_info_t *)list->data;
+
+ if (bss_info) {
+ gchar bssid_buff[18] = { 0, };
+ gchar *bssid_str = bssid_buff;
+ unsigned char *ssid = (unsigned char *)bss_info->ssid;
+ int ssid_len = (int)bss_info->ssid_len;
+ int rssi = (int)bss_info->rssi;
+ int mode = (int)bss_info->mode;
+ int i = 0;
+ g_snprintf(bssid_buff, 18, "%02x:%02x:%02x:%02x:%02x:%02x",
+ bss_info->bssid[0], bss_info->bssid[1], bss_info->bssid[2],
+ bss_info->bssid[3], bss_info->bssid[4], bss_info->bssid[5]);
+
+ DBG("BSS found; SSID %s, BSSID %s, RSSI %d MODE %d", ssid, bssid_str, rssi, mode);
+
+ builder1 = g_variant_builder_new (G_VARIANT_TYPE ("ay"));
+ for (i = 0; i < ssid_len; i++) {
+ g_variant_builder_add (builder1, "y", ssid[i]);
+ }
+ g_variant_builder_add(builder, "{sv}", prop_ssid, g_variant_builder_end(builder1));
+ g_variant_builder_unref(builder1);
+
+ g_variant_builder_add(builder, "{sv}", prop_bssid, g_variant_new_string(bssid_str));
+ g_variant_builder_add(builder, "{sv}", prop_rssi, g_variant_new_int32(rssi));
+ g_variant_builder_add(builder, "{sv}", prop_mode, g_variant_new_int32(mode));
+ }
+ }
+
+ wifi_emit_wps_scan_completed((Wifi *)get_netconfig_wifi_object(),
+ g_variant_builder_end(builder));
+ g_variant_builder_unref(builder);
+
+ if (wps_bss_info_list != NULL) {
+ g_slist_free_full(wps_bss_info_list, g_free);
+ }
+
+ wps_bss_info_list = NULL;
+ wps_bss_list_count = 0;
+ INFO("WpsScanCompleted");
+
+ return;
+}
+
+static void __netconfig_wifi_wps_get_bss_info_result(
+ GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ GVariant *reply = NULL;
+ GVariant *value;
+ GVariantIter *iter;
+ gchar *key;
+ struct wps_bss_info_t *bss_info;
+ GDBusConnection *conn = NULL;
+ GError *error = NULL;
+
+ conn = G_DBUS_CONNECTION (source_object);
+ reply = g_dbus_connection_call_finish(conn, res, &error);
+
+ if (error != NULL) {
+ ERR("Error code: [%d] Error message: [%s]", error->code, error->message);
+ g_error_free(error);
+ goto done;
+ }
+
+ bss_info = g_try_new0(struct wps_bss_info_t, 1);
+ if (bss_info == NULL)
+ goto done;
+
+ g_variant_get(reply, "(a{sv})", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ if (key != NULL) {
+ if (g_strcmp0(key, "BSSID") == 0) {
+ const guchar *bssid;
+ gsize bssid_len;
+
+ bssid = g_variant_get_fixed_array(value, &bssid_len, sizeof(guchar));
+ if (bssid_len == NETCONFIG_BSSID_LEN)
+ memcpy(bss_info->bssid, bssid, bssid_len);
+ } else if (g_strcmp0(key, "SSID") == 0) {
+ const guchar *ssid;
+ gsize ssid_len;
+
+ ssid = g_variant_get_fixed_array(value, &ssid_len, sizeof(guchar));
+ if (ssid_len > 0 && ssid_len <= NETCONFIG_SSID_LEN) {
+ memcpy(bss_info->ssid, ssid, ssid_len);
+ bss_info->ssid_len = ssid_len;
+ } else {
+ memset(bss_info->ssid, 0, sizeof(bss_info->ssid));
+ bss_info->ssid_len = 0;
+ }
+ } else if (g_strcmp0(key, "Mode") == 0) {
+ const gchar *mode = NULL;
+
+ g_variant_get(value, "s", &mode);
+ if (mode == NULL)
+ bss_info->mode = 0;
+ else {
+ if (g_strcmp0(mode, "infrastructure") == 0)
+ bss_info->mode = 1;
+ else if (g_strcmp0(mode, "ad-hoc") == 0)
+ bss_info->mode = 2;
+ else
+ bss_info->mode = 0;
+ }
+ } else if (g_strcmp0(key, "Signal") == 0) {
+ gint16 signal;
+
+ signal = g_variant_get_int16(value);
+ bss_info->rssi = signal;
+ }
+ }
+ }
+
+ if (bss_info->ssid[0] == '\0')
+ g_free(bss_info);
+ else
+ wps_bss_info_list = g_slist_append(wps_bss_info_list, bss_info);
+
+ g_variant_iter_free(iter);
+done:
+ if (reply)
+ g_variant_unref(reply);
+
+ netconfig_gdbus_pending_call_unref();
+
+ wps_bss_list_count--;
+ if (wps_bss_list_count <= 0) {
+ __netconfig_wifi_wps_notify_scan_done();
+
+ if (netconfig_is_wps_scan_aborted == FALSE)
+ netconfig_wifi_driver_and_supplicant(FALSE);
+ }
+}
+
+static void __netconfig_wifi_wps_get_bss_info(const char *path, int index)
+{
+ gboolean reply = FALSE;
+ GVariant *param = NULL;
+
+ param = g_variant_new("(s)", SUPPLICANT_IFACE_BSS);
+
+ reply = netconfig_invoke_dbus_method_nonblock(SUPPLICANT_SERVICE,
+ path, DBUS_INTERFACE_PROPERTIES,
+ "GetAll", param, __netconfig_wifi_wps_get_bss_info_result);
+ if (reply != TRUE)
+ ERR("Fail to invoke_dbus_method_nonblock GetAll");
+
+ return;
+}
+
+static void __netconfig_wifi_wps_get_bsss_result(GObject *source_object,
+ GAsyncResult *res, gpointer user_data)
+{
+ GVariant *reply = NULL;
+ GVariant *value = NULL;
+ GVariantIter *iter = NULL;
+ GDBusConnection *conn = NULL;
+ gchar *path = NULL;
+ gboolean counter_flag = FALSE;
+ GError *error = NULL;
+
+ conn = G_DBUS_CONNECTION (source_object);
+ reply = g_dbus_connection_call_finish(conn, res, &error);
+ if (error != NULL) {
+ ERR("Error code: [%d] Error message: [%s]", error->code, error->message);
+ g_error_free(error);
+ goto done;
+ }
+
+ g_variant_get(reply, "(v)", &value);
+ if (g_variant_is_of_type(value, G_VARIANT_TYPE_OBJECT_PATH_ARRAY)) {
+ g_variant_get(value, "ao", &iter);
+ while (g_variant_iter_next(iter, "o", &path)) {
+ if (path != NULL && g_strcmp0(path, "/") != 0) {
+ __netconfig_wifi_wps_get_bss_info(path, ++wps_bss_list_count);
+
+ counter_flag = TRUE;
+ }
+
+ if (path)
+ g_free(path);
+ }
+ }
+
+ if (iter)
+ g_variant_iter_free(iter);
+
+ if (value)
+ g_variant_unref(value);
+
+done:
+ if (reply)
+ g_variant_unref(reply);
+
+ netconfig_gdbus_pending_call_unref();
+
+ /* Send WpsScanCompleted signal even when the BSS count is 0 */
+ if (wps_bss_list_count <= 0 && counter_flag == FALSE) {
+ __netconfig_wifi_wps_notify_scan_done();
+
+ if (netconfig_is_wps_scan_aborted == FALSE)
+ netconfig_wifi_driver_and_supplicant(FALSE);
+ }
+}
+
+static int _netconfig_wifi_wps_get_bsss(void)
+{
+ gboolean reply = FALSE;
+ const char *if_path = NULL;
+ GVariant *params = NULL;
+
+ if_path = netconfig_wifi_get_supplicant_interface();
+ if (if_path == NULL) {
+ DBG("Fail to get wpa_supplicant DBus path");
+ return -ESRCH;
+ }
+
+ params = g_variant_new("(ss)", SUPPLICANT_IFACE_INTERFACE, "BSSs");
+
+ reply = netconfig_invoke_dbus_method_nonblock(SUPPLICANT_SERVICE,
+ if_path, DBUS_INTERFACE_PROPERTIES,
+ "Get", params, __netconfig_wifi_wps_get_bsss_result);
+ if (reply != TRUE) {
+ ERR("Fail to method: Get");
+
+ return -ESRCH;
+ }
+
+ return 0;
+}
+
+void netconfig_wifi_wps_signal_scandone(void)
+{
+ wps_bss_list_count = 0;
+ _netconfig_wifi_wps_get_bsss();
+
+ netconfig_is_device_scanning = FALSE;
+
+ __netconfig_wps_set_mode(FALSE);
+}
+
+void netconfig_wifi_wps_signal_scanaborted(void)
+{
+ wps_bss_list_count = 0;
+ netconfig_is_wps_scan_aborted = TRUE;
+ _netconfig_wifi_wps_get_bsss();
+
+ netconfig_is_device_scanning = FALSE;
+
+ __netconfig_wps_set_mode(FALSE);
+}
+
+static int __netconfig_wifi_wps_request_scan(const char *if_path)
+{
+ GDBusConnection *connection = NULL;
+ GVariant *message = NULL;
+ GVariantBuilder *builder = NULL;
+ const char *key1 = "Type";
+ const char *val1 = "passive";
+
+ if (if_path == NULL)
+ if_path = netconfig_wifi_get_supplicant_interface();
+
+ if (if_path == NULL) {
+ DBG("Fail to get wpa_supplicant DBus path");
+ return -ESRCH;
+ }
+
+ connection = netconfig_gdbus_get_connection();
+ if (connection == NULL) {
+ DBG("Failed to get GDBusconnection");
+ return -EIO;
+ }
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
+ g_variant_builder_add(builder, "{sv}", key1, g_variant_new_string(val1));
+ message = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+ g_variant_builder_unref(builder);
+
+ g_dbus_connection_call(connection,
+ SUPPLICANT_SERVICE,
+ if_path,
+ SUPPLICANT_INTERFACE ".Interface",
+ "Scan",
+ message,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ NETCONFIG_WPS_DBUS_REPLY_TIMEOUT,
+ netconfig_gdbus_get_gdbus_cancellable(),
+ NULL,
+ NULL);
+
+ g_variant_unref(message);
+ /* Clear bss_info_list for the next scan result */
+ if (wps_bss_info_list) {
+ g_slist_free_full(wps_bss_info_list, g_free);
+ wps_bss_info_list = NULL;
+ }
+
+ netconfig_is_wps_scan_aborted = FALSE;
+
+ return 0;
+}
+
+static void __netconfig_wifi_interface_create_result(
+ GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ GVariant *message;
+ const char *path = NULL;
+ GDBusConnection *conn = NULL;
+ GError *error = NULL;
+
+ conn = G_DBUS_CONNECTION (source_object);
+
+ message = g_dbus_connection_call_finish(conn, res, &error);
+ if (error == NULL) {
+ g_variant_get(message, "(o)", &path);
+
+ if (path)
+ __netconfig_wifi_wps_request_scan(path);
+ } else {
+ DBG("Failed to create interface, Error: %d[%s]", error->code, error->message);
+ }
+
+ g_variant_unref(message);
+ netconfig_gdbus_pending_call_unref();
+}
+
+static int __netconfig_wifi_wps_create_interface(void)
+{
+ GDBusConnection *connection = NULL;
+ GVariant *message = NULL;
+ GVariantBuilder *builder = NULL;
+ const char *key = "Ifname";
+ const char *val = WIFI_IFNAME;
+
+ connection = netconfig_gdbus_get_connection();
+ if (connection == NULL) {
+ DBG("Failed to get GDBusconnection");
+ return -EIO;
+ }
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
+ g_variant_builder_add(builder, "{sv}", key, g_variant_new_string(val));
+ message = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+
+ g_dbus_connection_call(connection,
+ SUPPLICANT_SERVICE,
+ SUPPLICANT_PATH,
+ SUPPLICANT_INTERFACE,
+ "CreateInterface",
+ message,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ NETCONFIG_WPS_DBUS_REPLY_TIMEOUT,
+ netconfig_gdbus_get_gdbus_cancellable(),
+ (GAsyncReadyCallback) __netconfig_wifi_interface_create_result,
+ NULL);
+
+ netconfig_gdbus_pending_call_ref();
+ g_variant_unref(message);
+
+ return 0;
+}
+
+static int __netconfig_wifi_wps_scan(void)
+{
+ int err = 0;
+ enum netconfig_wifi_tech_state wifi_tech_state;
+
+ if (netconfig_is_device_scanning == TRUE)
+ return -EINPROGRESS;
+
+ wifi_tech_state = netconfig_wifi_state_get_technology_state();
+ if (wifi_tech_state <= NETCONFIG_WIFI_TECH_OFF)
+ err = netconfig_wifi_driver_and_supplicant(TRUE);
+
+ if (err < 0 && err != -EALREADY)
+ return err;
+
+ netconfig_is_device_scanning = TRUE;
+
+ DBG("WPS scan requested");
+ if (wifi_tech_state >= NETCONFIG_WIFI_TECH_POWERED) {
+ if (netconfig_wifi_get_scanning() == TRUE)
+ return -EINPROGRESS;
+
+ netconfig_wifi_bgscan_start(TRUE);
+
+ if (wifi_tech_state == NETCONFIG_WIFI_TECH_CONNECTED)
+ __netconfig_wifi_wps_request_scan(NULL);
+ } else {
+ err = __netconfig_wifi_wps_create_interface();
+ }
+
+ return err;
+}
+
+gboolean handle_request_wps_scan(Wifi *wifi, GDBusMethodInvocation *context)
+{
+ int err, enabled = 0;
+ enum netconfig_wifi_tech_state wifi_tech_state;
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ if (netconfig_is_wifi_tethering_on() == TRUE) {
+ ERR("Wi-Fi Tethering is enabled");
+ netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_NO_SERVICE, "TetheringEnabled");
+ return -EBUSY;
+ }
+
+#if !defined TIZEN_WEARABLE
+ if (netconfig_wifi_is_bgscan_paused()) {
+ ERR("Scan is paused");
+ netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_NO_SERVICE, "ScanPaused");
+ return FALSE;
+ }
+#endif
+
+ wifi_tech_state = netconfig_wifi_state_get_technology_state();
+ if (wifi_tech_state <= NETCONFIG_WIFI_TECH_OFF) {
+#if !defined TIZEN_WEARABLE
+ vconf_get_int(VCONF_WIFI_ALWAYS_ALLOW_SCANNING, &enabled);
+#endif
+ if (enabled == 0) {
+ netconfig_error_permission_denied(context);
+ return FALSE;
+ }
+ }
+
+ __netconfig_wps_set_mode(TRUE);
+
+ err = __netconfig_wifi_wps_scan();
+ if (err < 0) {
+ if (err == -EINPROGRESS)
+ netconfig_error_inprogress(context);
+ else
+ netconfig_error_wifi_driver_failed(context);
+
+ return FALSE;
+ }
+
+ wifi_complete_request_wps_scan(wifi, context);
+ return TRUE;
+}
+
+#if defined TIZEN_TV
+static void __interface_wps_cancel_result(GObject *source_object,
+ GAsyncResult *res, gpointer user_data)
+{
+ GVariant *reply;
+ GDBusConnection *conn = NULL;
+ GError *error = NULL;
+
+ conn = G_DBUS_CONNECTION (source_object);
+ reply = g_dbus_connection_call_finish(conn, res, &error);
+
+ if (reply == NULL) {
+ if (error != NULL) {
+ ERR("Fail to request status [%d: %s]",
+ error->code, error->message);
+ g_error_free(error);
+ } else {
+ ERR("Fail torequest status");
+ }
+ } else {
+ DBG("Successfully M/W--->WPAS: Interface.WPS.Cancel Method");
+ }
+
+ g_variant_unref(reply);
+ netconfig_gdbus_pending_call_unref();
+}
+
+static gboolean __netconfig_wifi_invoke_wps_cancel()
+{
+ gboolean reply = FALSE;
+ const char *if_path = NULL;
+
+ if_path = netconfig_wifi_get_supplicant_interface();
+ if (if_path == NULL) {
+ DBG("Fail to get wpa_supplicant DBus path");
+ return -ESRCH;
+ }
+
+ DBG("M/W--->WPAS: Interface.WPS.Cancel Method");
+
+ reply = netconfig_invoke_dbus_method_nonblock(SUPPLICANT_SERVICE,
+ if_path, SUPPLICANT_IFACE_WPS,
+ "Cancel", NULL, __interface_wps_cancel_result);
+
+ if (reply != TRUE)
+ ERR("M/W--->WPAS: Interface.WPS.Cancel Method Failed");
+
+ return reply;
+}
+#endif
+
+gboolean netconfig_iface_wifi_request_wps_cancel(Wifi *wifi, GDBusMethodInvocation **context)
+{
+#if defined TIZEN_TV
+ DBG("Received WPS PBC Cancel Request");
+ g_return_val_if_fail(wifi != NULL, FALSE);
+ return __netconfig_wifi_invoke_wps_cancel();
+#else
+ /*Not supported for mobile and Wearable profile*/
+ return FALSE;
+#endif
+}
/*
* Network Configuration Module
*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "util.h"
#include "netdbus.h"
#include "neterror.h"
-#include "netconfig.h"
+#include "wifi-eap.h"
+#include "wifi-wps.h"
#include "wifi-power.h"
-#include "wifi-state.h"
+#include "wifi-agent.h"
+#include "wifi-firmware.h"
#include "wifi-ssid-scan.h"
-#include "wifi-eap.h"
#include "wifi-passpoint.h"
#include "wifi-eap-config.h"
#include "wifi-background-scan.h"
-#include "wifi-agent.h"
-#include "wifi-firmware.h"
-
-#include "netconfig-iface-wifi-glue.h"
-
-
-#define PROP_DEFAULT FALSE
-#define PROP_DEFAULT_STR NULL
+#include "wifi-config.h"
-enum {
- PROP_O,
- PROP_WIFI_CONN,
- PROP_WIFI_PATH,
-};
-
-enum {
- SIG_WIFI_DRIVER,
- SIG_LAST
-};
-
-struct NetconfigWifiClass {
- GObjectClass parent;
-
- /* method and signals */
- void (*driver_loaded) (NetconfigWifi *wifi, gchar *mac);
-};
-
-struct NetconfigWifi {
- GObject parent;
-
- /* member variable */
- DBusGConnection *conn;
- gchar *path;
-};
-
-static guint32 signals[SIG_LAST] = { 0, };
-
-G_DEFINE_TYPE(NetconfigWifi, netconfig_wifi, G_TYPE_OBJECT);
+static Wifi *netconfigwifi = NULL;
+static NetConnmanAgent *netconnmanagent = NULL;
+static WifiFirmware *netconfigwififirmware = NULL;
+Wifi *get_netconfig_wifi_object(void){
+ return netconfigwifi;
+}
-static void __netconfig_wifi_gobject_get_property(GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+static gboolean handle_check_black_list(Wifi *wifi, GDBusMethodInvocation *context,
+ const gchar *name, const gchar *security_type, const gchar *eap)
{
- return;
+ ERR("Name (%s)", name);
+ INFO("disable to check");
+ wifi_complete_check_black_list (wifi, context, TRUE);
+ return TRUE;
}
-static void __netconfig_wifi_gobject_set_property(GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+void netconfig_wifi_create_and_init(void)
{
- NetconfigWifi *wifi = NETCONFIG_WIFI(object);
-
- switch (prop_id) {
- case PROP_WIFI_CONN:
- {
- wifi->conn = g_value_get_boxed(value);
- INFO("wifi(%p) set conn(%p)", wifi, wifi->conn);
- break;
+ DBG("Create wifi object.");
+ GDBusInterfaceSkeleton *interface = NULL;
+ GDBusConnection *connection;
+ GDBusObjectManagerServer *server = netconfig_get_wifi_manager();
+ if (server == NULL)
+ return;
+
+ connection = netconfig_gdbus_get_connection();
+ g_dbus_object_manager_server_set_connection(server, connection);
+
+ /*Interface*/
+ netconfigwifi = wifi_skeleton_new();
+ interface = G_DBUS_INTERFACE_SKELETON(netconfigwifi);
+
+ // WIFI power
+ g_signal_connect(netconfigwifi, "handle-load-driver",
+ G_CALLBACK(handle_load_driver), NULL);
+ g_signal_connect(netconfigwifi, "handle-remove-driver",
+ G_CALLBACK(handle_remove_driver), NULL);
+ g_signal_connect(netconfigwifi, "handle-load-p2p-driver",
+ G_CALLBACK(handle_load_p2p_driver), NULL);
+ g_signal_connect(netconfigwifi, "handle-remove-p2p-driver",
+ G_CALLBACK(handle_remove_p2p_driver), NULL);
+
+ // WIFI scan
+ g_signal_connect(netconfigwifi, "handle-request-specific-scan",
+ G_CALLBACK(handle_request_specific_scan), NULL);
+ g_signal_connect(netconfigwifi, "handle-request-wps-scan",
+ G_CALLBACK(handle_request_wps_scan), NULL);
+
+ // WIFI direct
+ g_signal_connect(netconfigwifi, "handle-launch-direct",
+ G_CALLBACK(handle_launch_direct), NULL);
+
+ // EAP config
+ g_signal_connect(netconfigwifi, "handle-create-eap-config",
+ G_CALLBACK(handle_create_eap_config), NULL);
+ g_signal_connect(netconfigwifi, "handle-delete-eap-config",
+ G_CALLBACK(handle_delete_eap_config), NULL);
+
+ // WIFI configuration
+ g_signal_connect(netconfigwifi, "handle-save-configuration",
+ G_CALLBACK(handle_save_configuration), NULL);
+ g_signal_connect(netconfigwifi, "handle-remove-configuration",
+ G_CALLBACK(handle_remove_configuration), NULL);
+ g_signal_connect(netconfigwifi, "handle-get-config-ids",
+ G_CALLBACK(handle_get_config_ids), NULL);
+ g_signal_connect(netconfigwifi, "handle-load-configuration",
+ G_CALLBACK(handle_load_configuration), NULL);
+ g_signal_connect(netconfigwifi, "handle-set-config-field",
+ G_CALLBACK(handle_set_config_field), NULL);
+
+ // BG scan mode
+ g_signal_connect(netconfigwifi, "handle-set-bgscan",
+ G_CALLBACK(handle_set_bgscan), NULL);
+ g_signal_connect(netconfigwifi, "handle-resume-bgscan",
+ G_CALLBACK(handle_resume_bgscan), NULL);
+ g_signal_connect(netconfigwifi, "handle-pause-bgscan",
+ G_CALLBACK(handle_pause_bgscan), NULL);
+
+ // Passpoint
+ g_signal_connect(netconfigwifi, "handle-set-passpoint",
+ G_CALLBACK(handle_set_passpoint), NULL);
+ g_signal_connect(netconfigwifi, "handle-get-passpoint",
+ G_CALLBACK(handle_get_passpoint), NULL);
+
+ // EAP authentication
+ g_signal_connect(netconfigwifi, "handle-get-aka-auth",
+ G_CALLBACK(handle_get_aka_auth), NULL);
+ g_signal_connect(netconfigwifi, "handle-get-sim-auth",
+ G_CALLBACK(handle_get_sim_auth), NULL);
+ g_signal_connect(netconfigwifi, "handle-get-sim-imsi",
+ G_CALLBACK(handle_get_sim_imsi), NULL);
+ g_signal_connect(netconfigwifi, "handle-req-aka-auth",
+ G_CALLBACK(handle_req_aka_auth), NULL);
+ g_signal_connect(netconfigwifi, "handle-req-sim-auth",
+ G_CALLBACK(handle_req_sim_auth), NULL);
+
+ // WIFI MDM blacklist
+ g_signal_connect(netconfigwifi, "handle-check-black-list",
+ G_CALLBACK(handle_check_black_list), NULL);
+
+ if (!g_dbus_interface_skeleton_export(interface, connection,
+ NETCONFIG_WIFI_PATH, NULL)) {
+ ERR("Export WIFI_PATH for wifi failed");
}
- case PROP_WIFI_PATH:
- {
- if (wifi->path)
- g_free(wifi->path);
+ interface = NULL;
- wifi->path = g_value_dup_string(value);
- INFO("wifi(%p) path(%s)", wifi, wifi->path);
+ /*Interface 2*/
+ netconnmanagent = net_connman_agent_skeleton_new();
- break;
- }
+ interface = G_DBUS_INTERFACE_SKELETON(netconnmanagent);
+ g_signal_connect(netconnmanagent, "handle-report-error",
+ G_CALLBACK(handle_report_error), NULL);
+ g_signal_connect(netconnmanagent, "handle-request-browser",
+ G_CALLBACK(handle_request_browser), NULL);
+ g_signal_connect(netconnmanagent, "handle-request-input",
+ G_CALLBACK(handle_request_input), NULL);
+ g_signal_connect(netconnmanagent, "handle-set-field",
+ G_CALLBACK(handle_set_field), NULL);
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ if (!g_dbus_interface_skeleton_export(interface, connection,
+ NETCONFIG_WIFI_PATH, NULL)) {
+ ERR("Export WIFI_PATH for agent failed");
}
-}
-
-static void netconfig_wifi_init(NetconfigWifi *wifi)
-{
- DBG("wifi initialize");
-
- wifi->conn = NULL;
- wifi->path = g_strdup(PROP_DEFAULT_STR);
-}
-
-static void netconfig_wifi_class_init(NetconfigWifiClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
- DBG("class initialize");
-
- object_class->get_property = __netconfig_wifi_gobject_get_property;
- object_class->set_property = __netconfig_wifi_gobject_set_property;
-
- /* DBus register */
- dbus_g_object_type_install_info(NETCONFIG_TYPE_WIFI,
- &dbus_glib_netconfig_iface_wifi_object_info);
-
- /* property */
- g_object_class_install_property(object_class, PROP_WIFI_CONN,
- g_param_spec_boxed("conn", "CONNECTION", "DBus connection",
- DBUS_TYPE_G_CONNECTION,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property(object_class, PROP_WIFI_PATH,
- g_param_spec_string("path", "PATH", "Object Path",
- PROP_DEFAULT_STR,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- /* signal */
- signals[SIG_WIFI_DRIVER] = g_signal_new("driver-loaded",
- G_OBJECT_CLASS_TYPE(klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(NetconfigWifiClass,
- driver_loaded),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-}
-
-gpointer netconfig_wifi_create_and_init(DBusGConnection *conn)
-{
- GObject *object;
- g_return_val_if_fail(conn != NULL, NULL);
+ interface = NULL;
- object = g_object_new(NETCONFIG_TYPE_WIFI, "conn", conn, "path",
- NETCONFIG_WIFI_PATH, NULL);
+ /*Interface 3*/
+ netconfigwififirmware = wifi_firmware_skeleton_new();
- INFO("create wifi(%p)", object);
+ interface = G_DBUS_INTERFACE_SKELETON(netconfigwififirmware);
+ g_signal_connect(netconfigwififirmware, "handle-start",
+ G_CALLBACK(handle_start), NULL);
+ g_signal_connect(netconfigwififirmware, "handle-stop",
+ G_CALLBACK(handle_stop), NULL);
- dbus_g_connection_register_g_object(conn, NETCONFIG_WIFI_PATH, object);
-
- INFO("wifi(%p) register DBus path(%s)", object, NETCONFIG_WIFI_PATH);
+ if (!g_dbus_interface_skeleton_export(interface, connection,
+ NETCONFIG_WIFI_PATH, NULL)) {
+ ERR("Export WIFI_PATH for firmware failed");
+ }
- netconfig_wifi_power_configuration();
- netconfig_wifi_init_bgscan();
+ netconfig_wifi_power_initialize();
- return object;
+ return;
}
+