netconfig-iface*-glue.h
.project
.cproject
+.settings
+++ /dev/null
-Danny Jeongseok Seo <s.seo@samsung.com>
-Jeik Jaehyun Kim <jeik01.kim@samsung.com>
-Sunkey Lee <yuvjjang.lee@samsung.com>
-Sanghoon Cho <sanghoon80.cho@samsung.com>
-DongHoo Park <donghoo.park@samsung.com>
\ No newline at end of file
SET(SRCS
src/main.c
+ src/wifi.c
src/neterror.c
+ src/wifi-eap.c
+ src/wifi-wps.c
+ src/wifi-agent.c
+ src/wifi-ccode.c
src/wifi-power.c
src/wifi-state.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-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/dbus/netdbus.c
- src/dbus/netsupplicant.c
- src/utils/util.c
src/utils/emulator.c
- src/utils/mdm-private.c
+ src/wifi-eap-config.c
+ src/network-statistics.c
+ src/dbus/netsupplicant.c
+ src/wifi-background-scan.c
+ src/wifi-tel-intf.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_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_MOBILE)
+# ADD_DEFINITIONS(-DTIZEN_MOBILE)
+#ENDIF(TIZEN_MOBILE)
+IF(TIZEN_WEARABLE)
+ ADD_DEFINITIONS(-DTIZEN_WEARABLE)
+ENDIF(TIZEN_WEARABLE)
+
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(pkgs REQUIRED
- glib-2.0
- dbus-glib-1
dlog
+ tapi
vconf
- wifi-direct
- syspopup-caller)
+ journal
+ gio-2.0
+ glib-2.0
+ dbus-glib-1
+ notification
+ 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 -Werror -fvisibility=hidden")
+SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} -Wall -Werror -fvisibility=hidden -fvisibility-inlines-hidden")
+SET(CMAKE_C_FLAGS "-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}\"")
ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${PCAP_LIB})
ADD_CUSTOM_TARGET(netconfig-iface-network-state-glue.h
COMMAND dbus-binding-tool --mode=glib-server --prefix=netconfig_iface_network_state
+++ /dev/null
-net-config (0.1.88-5) unstable; urgency=low
-
- * wifi-state notifier
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.88-5
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Fri, 17 Aug 2012 00:24:16 +0900
-
-net-config (0.1.88-4) unstable; urgency=low
-
- * Re-factor wifi-state, statistics
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.88-4
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 16 Aug 2012 16:52:47 +0900
-
-net-config (0.1.88-3) unstable; urgency=low
-
- * Fix build break
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.88-3
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 14 Aug 2012 13:30:07 +0900
-
-net-config (0.1.88-2) unstable; urgency=low
-
- * Implement SSID scan for Finding Hidden Network
- * First draft from Sanghoon Cho, Praveen C
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.88-2
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Sat, 11 Aug 2012 16:30:06 +0900
-
-net-config (0.1.88-1) unstable; urgency=low
-
- * Revise functions for dbus method call to avoid GPL license issue
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.88-1
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Fri, 10 Aug 2012 19:22:42 +0900
-
-net-config (0.1.87-3) unstable; urgency=low
-
- * Revise test_device_picker to refer service favorite
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.87-3
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Mon, 06 Aug 2012 19:43:16 +0900
-
-net-config (0.1.87-2) unstable; urgency=low
-
- * Revise codes to make public source release
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.87-2
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Fri, 03 Aug 2012 18:07:18 +0900
-
-net-config (0.1.87-1) unstable; urgency=low
-
- * Wi-Fi ANT BAR update (updated)
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.87-1
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 18 Jul 2012 14:44:47 +0900
-
-net-config (0.1.86-7) unstable; urgency=low
-
- * Add power on/off completed signal
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.86-7
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 17 Jul 2012 16:40:10 +0900
-
-net-config (0.1.86-6) unstable; urgency=low
-
- * Implement to delete Wi-Fi found notification when Wi-Fi is turned off
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.86-6
-
- -- Sanghoon Cho <sanghoon80.cho@samsung.com> Mon, 16 Jul 2012 16:40:40 +0900
-
-net-config (0.1.86-5) unstable; urgency=low
-
- * Fix not showing 3G alert popup
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.86-5
-
- -- Sanghoon Cho <sanghoon80.cho@samsung.com> Fri, 13 Jul 2012 21:03:36 +0900
-
-net-config (0.1.86-4) unstable; urgency=low
-
- * No update RSSI when LCD off
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.86-4
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 11 Jul 2012 23:19:51 +0900
-
-net-config (0.1.86-3) unstable; urgency=low
-
- * Fix Wi-Fi state update during Wi-Fi power off
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.86-3
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Sat, 07 Jul 2012 20:53:21 +0900
-
-net-config (0.1.86-2) unstable; urgency=low
-
- * No device picker during connecting
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.86-2
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Sat, 07 Jul 2012 16:45:40 +0900
-
-net-config (0.1.86-1) unstable; urgency=low
-
- * Implement to set/get network statistics
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.86-1
-
- -- Sanghoon Cho <sanghoon80.cho@samsung.com> Fri, 06 Jul 2012 19:47:02 +0900
-
-net-config (0.1.85-6) unstable; urgency=low
-
- * Fix wifi indicator update bug
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.85-6
-
- -- Sanghoon Cho <sanghoon80.cho@samsung.com> Fri, 06 Jul 2012 16:36:04 +0900
-
-net-config (0.1.85-5) unstable; urgency=low
-
- * Implement Wi-Fi found notification
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.85-5
-
- -- Sanghoon Cho <sanghoon80.cho@samsung.com> Tue, 03 Jul 2012 14:07:28 +0900
-
-net-config (0.1.85-4) unstable; urgency=low
-
- * Re-factor Wi-Fi indicator
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.85-4
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 05 Jun 2012 16:28:12 +0900
-
-net-config (0.1.85-3) unstable; urgency=low
-
- * Remove logging of libnet-client and net-config
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.85-3
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 12 Jun 2012 19:57:12 +0900
-
-net-config (0.1.85-2) unstable; urgency=low
-
- * Clean up the useless
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.85-2
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 05 Jun 2012 10:41:42 +0900
-
-net-config (0.1.85-1) unstable; urgency=low
-
- * Fix Wi-Fi BG Scan bug for default value
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.85-1
-
- -- Sanghoon Cho <sanghoon80.cho@samsung.com> Fri, 01 Jun 2012 15:12:49 +0900
-
-net-config (0.1.84-1) unstable; urgency=low
-
- * Fix Wi-Fi power state update
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.84-1
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 30 May 2012 13:34:17 +0900
-
-net-config (0.1.83) unstable; urgency=low
-
- * Revise emulator support
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.83
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 17 May 2012 17:55:47 +0900
-
-net-config (0.1.82) unstable; urgency=low
-
- * Check NULL: Wi-Fi technology state
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.82
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 17 May 2012 16:20:17 +0900
-
-net-config (0.1.81) unstable; urgency=low
-
- * Revise private vconf key name
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.81
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 15 May 2012 13:54:28 +0900
-
-net-config (0.1.80) unstable; urgency=low
-
- * Revise unnecessary funtions
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.80
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 09 May 2012 15:13:52 +0900
-
-net-config (0.1.79) unstable; urgency=low
-
- * Revise net-config signal filter handler
- * Revise Wi-Fi state management
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.79
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 09 May 2012 11:41:09 +0900
-
-net-config (0.1.78) unstable; urgency=low
-
- * Revise ConnMan profile prefix to fit ConnMan 0.78
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.78
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 08 May 2012 15:55:04 +0900
-
-net-config (0.1.77) unstable; urgency=low
-
- * Revise net-config to fit Android supplicant
- * Revise net-config log
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.77
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 24 Apr 2012 23:08:11 +0900
-
-net-config (0.1.76) unstable; urgency=low
-
- * Add a vconf key for local MAC address of Wi-Fi device
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.76
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 17 Apr 2012 10:28:08 +0900
-
-net-config (0.1.75) unstable; urgency=low
-
- * Modify background scan policy
- * disallow to request bg scan in case the state is connected and rssi is below level 2
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.75
-
- -- Sanghoon Cho <sanghoon80.cho@samsung.com> Fri, 13 Apr 2012 16:37:55 +0900
-
-net-config (0.1.74) unstable; urgency=low
-
- * Fix Wi-Fi power bug when Wi-Fi direct is on
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.74
-
- -- Sanghoon Cho <sanghoon80.cho@samsung.com> Thu, 12 Apr 2012 22:06:27 +0900
-
-net-config (0.1.73) unstable; urgency=low
-
- * Fix Wi-Fi tethering state bugs
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.73
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Mon, 02 Apr 2012 17:27:06 +0900
-
-net-config (0.1.72) unstable; urgency=low
-
- * Fix emulator proxy setting
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.72
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 29 Mar 2012 10:45:15 +0900
-
-net-config (0.1.71) unstable; urgency=low
-
- * Enable DBus auto-activation
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.71
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 27 Mar 2012 14:01:40 +0900
-
-net-config (0.1.70) unstable; urgency=low
-
- * Implement Wi-Fi device picker service
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.70
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Fri, 23 Mar 2012 19:28:01 +0900
-
-net-config (0.1.69) unstable; urgency=low
-
- * Change alert popup name to net-popup
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.69
-
- -- Sunkey Lee <yuvjjang.lee@samsung.com> Fri, 16 Mar 2012 10:21:53 +0900
-
-net-config (0.1.68) unstable; urgency=low
-
- * Revise Network State update DBus interface name (object path)
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.68
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 15 Mar 2012 13:33:17 +0900
-
-net-config (0.1.67) unstable; urgency=low
-
- * Write update default connection information
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.67
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 14 Mar 2012 21:31:57 +0900
-
-net-config (0.1.66) unstable; urgency=low
-
- * Write initial Network Configuration Module based on exist sonet
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.66
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 14 Mar 2012 19:00:26 +0900
-
-net-config (0.1.65) unstable; urgency=low
-
- * Fix network status update
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.65
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 08 Mar 2012 22:17:24 +0900
-
-net-config (0.1.64) unstable; urgency=low
-
- * Fix vconf memory backend to be installed
- * Git: magnolia/framework/connectivity/net-config
- * Tag: net-config_0.1.64
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 06 Mar 2012 21:11:08 +0900
-
-sonet (0.1.0) unstable; urgency=low
-
- * Initial Release
-
- -- DongHoo Park <donghoo.park@samsung.com> Tue, 23 Aug 2011 11:22:04 +0900
+++ /dev/null
-Source: net-config
-Section: net
-Priority: extra
-Maintainer: Danny Jeongseok Seo <s.seo@samsung.com>
-Uploaders: Danny Jeongseok Seo <s.seo@samsung.com>, Jeik Jaehyun Kim <jeik01.kim@samsung.com>, Misun Kim <ms0123.kim@samsung.com>, Sanghoon Cho <sanghoon80.cho@samsung.com>
-Build-Depends: debhelper (>= 5), libdbus-1-dev (>= 1.1.1), libglib2.0-dev, libdbus-glib-1-dev, dlog-dev, syspopup-caller-dev, libwifi-direct-dev
-Standards-Version: 3.7.2
-
-Package: net-config
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: TIZEN Network Configuration Module
-
-Package: net-config-dbg
-Architecture: any
-Depends: net-config (= ${Source-Version}), ${shlibs:Depends}, ${misc:Depends}
-Description: debug symbols for TIZEN Network Configuration Module
+++ /dev/null
-@PREFIX@/sbin/*
-@PREFIX@/share/dbus-1/services/*
-@PREFIX@/etc/dbus-1/system.d/*
-/opt/etc/resolv.conf
-/etc/rc.d/init.d/net-config
-/etc/rc.d/rc3.d/S60net-config
-/etc/rc.d/rc5.d/S60net-config
+++ /dev/null
-#!/bin/sh
-
-vconftool set -t int memory/dnet/state 0 -i
-vconftool set -t int memory/wifi/state 0 -i
-vconftool set -t int memory/wifi/strength 0 -i
-
-vconftool set -t int memory/dnet/cellular 0 -i
-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
-
-vconftool set -t string memory/wifi/connected_ap_name "" -i
-
-vconftool set -t string db/wifi/bssid_address ""
-
-#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"
-
-vconftool set -t int file/private/wifi/last_power_state "0"
-
-#Change File Permission
-#Resource
-chmod 644 /opt/etc/resolv.conf
-
+++ /dev/null
-#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-CFLAGS += -g -rdynamic
-CFLAGS += -Wall -Werror
-LDFLAGS ?=
-PREFIX ?= /usr
-DATADIR ?= /usr/share
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
- CFLAGS += -O0
-else
- CFLAGS += -O2
-endif
-
-LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
-
-CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
- # Add here commands to configure the package.
- mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && \
- CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" cmake .. -DCMAKE_INSTALL_PREFIX="$(PREFIX)"
-
- touch configure-stamp
-
-build: build-stamp
-
-build-stamp: configure-stamp
- dh_testdir
-
- # Add here commands to compile the package.
- cd $(CMAKE_BUILD_DIR) && $(MAKE)
-
- for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
- cat $$f > $${f%.in}; \
- sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
- sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
- done
-
- touch $@
-
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
- rm -f $(CURDIR)/src/*.service
- rm -f $(CURDIR)/include/*-glue.h
-
- # Add here commands to clean up after the build process.
- rm -rf $(CMAKE_BUILD_DIR)
-
- for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
- rm -f $${f%.in}; \
- done
-
- rm -f ../net-config_*.deb
- rm -f ../net-config-*.deb
- rm -f ../net-config_*.changes
- rm -f ../net-config_*.dsc
- rm -f ../net-config_*.tar.gz
-
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
-
- # Add here commands to install the package into debian/wavplayer.
- cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
-
- mkdir -p $(CURDIR)/debian/tmp$(PREFIX)/share/dbus-1/services
- cp -f $(CURDIR)/resources$(PREFIX)/share/dbus-1/services/net.netconfig.service \
- $(CURDIR)/debian/tmp$(PREFIX)/share/dbus-1/services/net.netconfig.service
- mkdir -p $(CURDIR)/debian/tmp$(PREFIX)/etc/dbus-1/system.d
- cp -f $(CURDIR)/resources$(PREFIX)/etc/dbus-1/system.d/net-config.conf \
- $(CURDIR)/debian/tmp$(PREFIX)/etc/dbus-1/system.d/net-config.conf
- mkdir -p $(CURDIR)/debian/tmp/opt/etc
- cp -f $(CURDIR)/resources/opt/etc/resolv.conf $(CURDIR)/debian/tmp/opt/etc/resolv.conf
- mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/init.d
- cp -f $(CURDIR)/resources/etc/rc.d/init.d/net-config $(CURDIR)/debian/tmp/etc/rc.d/init.d/net-config
- mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc3.d
- ln -s ../init.d/net-config $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/S60net-config
- mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc5.d
- ln -s ../init.d/net-config $(CURDIR)/debian/tmp/etc/rc.d/rc5.d/S60net-config
-
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
- dh_testdir
- dh_testroot
-# dh_installchangelogs
-# dh_installdocs
-# dh_installexamples
- dh_install --sourcedir=debian/tmp
-# dh_installmenu
-# dh_installdebconf
-# dh_installlogrotate
-# dh_installemacsen
-# dh_installpam
-# dh_installmime
-# dh_python
-# dh_installinit
-# dh_installcron
-# dh_installinfo
-# dh_installman
- dh_link
- dh_strip --dbg-package=net-config-dbg
- dh_compress
- dh_fixperms
-# dh_perl
- dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
--- /dev/null
+/*
+ * 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_ONLINE = 0x02,
+};
+
+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__ */
#endif
#include <dlog.h>
-#include <stdio.h>
#include <string.h>
-#define __LOG(level, format, arg...) \
- do { \
- char *ch = strrchr(__FILE__, '/'); \
- ch = ch ? ch + 1 : __FILE__; \
- SLOG(level, PACKAGE, "%s:%s() "format"\n", ch, __FUNCTION__, ## arg); \
- } while(0)
+#define NETCONFIG_DEBUG_FILE (1)
-#define __PRT(level, format, arg...) \
+void __netconfig_debug(const char *format, ...);
+
+#define __LOG(level, format, arg...) \
do { \
- char *ch = strrchr(__FILE__, '/'); \
- ch = ch ? ch + 1 : __FILE__; \
- fprintf(stderr, PACKAGE": %s:%s() "format"\n", ch, __FUNCTION__, ## arg); \
+ if (NETCONFIG_DEBUG_FILE) { \
+ __netconfig_debug("%s "format"\n", __FUNCTION__, ## arg); \
+ } else { \
+ SLOG(level, PACKAGE, "%s "format"\n", __FUNCTION__, ## arg); \
+ } \
} while(0)
#define DBG(format, arg...) __LOG(LOG_DEBUG, format, ## arg)
*
*/
-#ifndef MDM_PRIVATE_H_
-#define MDM_PRIVATE_H_
+#ifndef __MDM_PRIVATE_H__
+#define __MDM_PRIVATE_H__
#ifdef __cplusplus
extern "C" {
#include <glib.h>
-gboolean netconfig_is_wifi_allowed(void);
+static inline gboolean netconfig_is_wifi_allowed(void) { return TRUE; }
+static inline void netconfig_check_allowed_ap(const char *path) { return; }
#ifdef __cplusplus
}
#endif
-#endif /* MDM_PRIVATE_H_ */
+#endif /* __MDM_PRIVATE_H__ */
#ifndef __NETCONFIG_NETDBUS_H__
#define __NETCONFIG_NETDBUS_H__
+#include <glib.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-#include <glib.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
+#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_CELLULAR_SERVICE_PROFILE_PREFIX CONNMAN_PATH "/service/cellular_"
#define CONNMAN_WIFI_SERVICE_PROFILE_PREFIX CONNMAN_PATH "/service/wifi_"
-#define CONNMAN_WIFI_TECHNOLOGY_PREFIX CONNMAN_PATH "/technology/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"
NETCONFIG_DBUS_RESULT_DEFAULT_TECHNOLOGY,
} netconfig_dbus_result_type;
-char *netconfig_wifi_get_connected_service_name(DBusMessage *message);
+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);
+
+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[]);
-void netconfig_dbus_parse_recursive(DBusMessageIter *iter,
- netconfig_dbus_result_type result_type, void *data);
-char *netconfig_dbus_get_string(DBusMessage *msg);
+
+gboolean netconfig_dbus_get_basic_params_string(DBusMessage *message,
+ char **key, int type, void *value);
+gboolean netconfig_dbus_get_basic_params_array(DBusMessage *message,
+ const char *key, void **value);
DBusGConnection *netconfig_setup_dbus(void);
#include "glib.h"
-G_BEGIN_DECLS
+#define NETCONFIG_ERROR_QUARK (netconfig_error_quark())
+#define NETCONFIG_CONNMAN_AGENT_ERROR_QUARK (netconfig_connman_agent_error_quark())
-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_WIFI_DRIVER_FAILURE = 0x06,
- NETCONFIG_ERROR_SECURITY_RESTRICTED = 0x07,
- NETCONFIG_ERROR_MAX = 0x08,
-} NETCONFIG_ERROR;
-
-GQuark netconfig_error_quark(void);
-
-#define NETCONFIG_ERROR_QUARK (netconfig_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_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);
-G_END_DECLS
+void netconfig_error_init(void);
#ifdef __cplusplus
}
#endif
-void netconfig_error_wifi_driver_failed(GError **error);
-void netconfig_error_security_restricted(GError **error);
-void netconfig_error_wifi_direct_failed(GError **error);
-
#endif /* __NETCONFIG_ERROR_H__ */
#ifndef __NETCONFIG_NETSUPPLICANT_H__
#define __NETCONFIG_NETSUPPLICANT_H__
+#include <glib.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-#include <glib.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
+#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_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);
+/* 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,
const char *path, const char *interface_name,
const char *method, GList *args);
+dbus_bool_t netconfig_supplicant_invoke_dbus_method_nonblock(const char *dest,
+ const char *path, const char *interface_name,
+ const char *method, GList *args,
+ DBusPendingCallNotifyFunction notify_func);
+DBusMessage *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);
#ifdef __cplusplus
}
--- /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__ */
--- /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_NETWORK_CLOCK_H__
+#define __NETCONFIG_NETWORK_CLOCK_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void netconfig_clock_init(void);
+void netconfig_clock_deinit(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_NETWORK_CLOCK_H__ */
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(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 ) )
+#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);
+gpointer netconfig_network_state_create_and_init(DBusGConnection *connection);
G_END_DECLS
+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_proxy(void);
+const char *netconfig_wifi_get_connected_essid(const char *default_profile);
+
+void netconfig_update_default(void);
+void netconfig_update_default_profile(const char *profile);
+char *netconfig_network_get_ifname(const char *profile);
+
#ifdef __cplusplus
}
#endif
*
*/
-#ifndef NETWORK_STATISTICS_H_
-#define NETWORK_STATISTICS_H_
+#ifndef __NETWORK_STATISTICS_H__
+#define __NETWORK_STATISTICS_H__
#ifdef __cplusplus
extern "C" {
#include <glib-object.h>
#include <dbus/dbus-glib.h>
-#include <wifi-state.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 ) )
+#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);
+gpointer netconfig_network_statistics_create_and_init(
+ DBusGConnection *connection);
-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);
+G_END_DECLS
+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);
+
+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__ */
#include "wifi.h"
-void netconfig_start_timer_seconds(int secs,
+#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"
+
+GKeyFile *netconfig_keyfile_load(const char *pathname);
+void netconfig_keyfile_save(GKeyFile *keyfile, const char *pathname);
+
+void netconfig_start_timer_seconds(guint secs,
gboolean(*callback) (gpointer), void *user_data, guint *timer_id);
-void netconfig_start_timer(int msecs,
+void netconfig_start_timer(guint msecs,
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,
+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_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);
+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_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
}
#endif
--- /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_AGENT_H__
+#define __NETCONFIG_WIFI_AGENT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "wifi.h"
+
+gboolean netconfig_agent_register(void);
+gboolean netconfig_agent_unregister(void);
+
+gboolean netconfig_wifi_set_agent_field_for_eap_network(
+ const char *name, const char *identity, const char *passphrase);
+
+gboolean netconfig_iface_wifi_set_field(NetconfigWifi *wifi,
+ gchar *service, GHashTable *fields,
+ DBusGMethodInvocation *context);
+gboolean netconfig_iface_wifi_request_input(NetconfigWifi *wifi,
+ gchar *service, GHashTable *fields,
+ DBusGMethodInvocation *context);
+gboolean netconfig_iface_wifi_report_error(NetconfigWifi *wifi,
+ gchar *service, gchar *error,
+ DBusGMethodInvocation *context);
+
+gboolean netconfig_iface_wifi_request_browser(NetconfigWifi *wifi,
+ gchar *service, gchar *url,
+ DBusGMethodInvocation *context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFI_AGENT_H__ */
#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 netconfig_iface_wifi_set_bgscan(
+ NetconfigWifi *wifi, guint scan_mode, GError **error);
+gboolean netconfig_iface_wifi_resume_bgscan(
+ NetconfigWifi *wifi, GError **error);
+gboolean netconfig_iface_wifi_pause_bgscan(
+ NetconfigWifi *wifi, GError **error);
-gboolean netconfig_iface_wifi_set_bgscan(NetconfigWifi *wifi, guint scan_mode, GError **error);
#ifdef __cplusplus
}
*
*/
-#ifndef __NETCONFIG_H__
-#define __NETCONFIG_H__
+#ifndef __NETCONFIG_WIFI_CCODE_H__
+#define __NETCONFIG_WIFI_CCODE_H__
#ifdef __cplusplus
extern "C" {
#endif
-#define NETCONFIG_SERVICE "net.netconfig"
+void netconfig_wifi_ccode_init(void);
#ifdef __cplusplus
}
#endif
-#endif /* __NETCONFIG_H__ */
+#endif /* __NETCONFIG_WIFI_CCODE_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_EAP_CONFIG_H__
+#define __NETCONFIG_WIFI_EAP_CONFIG_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "wifi.h"
+
+gboolean netconfig_iface_wifi_create_config(NetconfigWifi *wifi,
+ gchar *service, GHashTable *fields,
+ DBusGMethodInvocation *context);
+gboolean netconfig_iface_wifi_delete_config(NetconfigWifi *wifi,
+ gchar *profile,
+ DBusGMethodInvocation *context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFI_EAP_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_EAP_H__
+#define __NETCONFIG_WIFI_EAP_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#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);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFI_EAP_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_FIRMWARE_H__
+#define __NETCONFIG_WIFI_FIRMWARE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+
+enum netconfig_wifi_firmware {
+ NETCONFIG_WIFI_OFF = 0x00,
+ NETCONFIG_WIFI_STA = 0x01,
+ NETCONFIG_WIFI_P2P = 0x02,
+ NETCONFIG_WIFI_SOFTAP = 0x03,
+};
+
+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);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFI_FIRMWARE_H__ */
#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);
--- /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_PASSPOINT_H__
+#define __NETCONFIG_WIFI_PASSPOINT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "wifi.h"
+
+gboolean netconfig_iface_wifi_get_passpoint(NetconfigWifi *wifi,
+ int *result, GError **error);
+gboolean netconfig_iface_wifi_set_passpoint(NetconfigWifi *wifi,
+ int enable, GError **error);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFI_PASSPOINT_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_POWER_H__
+#define __NETCONFIG_WIFI_POWER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+
+void netconfig_wifi_power_initialize(void);
+
+int netconfig_wifi_on(void);
+int netconfig_wifi_off(void);
+void netconfig_wifi_fetch_airplane_mode(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 netconfig_iface_wifi_load_driver(
+ NetconfigWifi *wifi, gboolean device_picker_test, GError **error);
+gboolean netconfig_iface_wifi_remove_driver(
+ NetconfigWifi *wifi, GError **error);
+
+gboolean netconfig_iface_wifi_load_p2p_driver(
+ NetconfigWifi *wifi, GError **error);
+gboolean netconfig_iface_wifi_remove_p2p_driver(
+ NetconfigWifi *wifi, GError **error);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFI_POWER_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_POWERSAVE_H__
+#define __NETCONFIG_WIFI_POWERSAVE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+gboolean netconfig_wifi_is_powersave_mode(void);
+
+void netconfig_wifi_powersave_start(void);
+void netconfig_wifi_powersave_stop(void);
+
+void netconfig_wifi_powersave_init(void);
+void netconfig_wifi_powersave_deinit(void);
+void netconfig_wifi_early_suspend(gboolean value);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFI_POWERSAVE_H__ */
#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(DBusMessage *message);
+void netconfig_wifi_notify_ssid_scan_done(void);
void netconfig_wifi_bss_added(DBusMessage *message);
+gboolean netconfig_wifi_ssid_scan(const char *ssid);
+
gboolean netconfig_iface_wifi_request_specific_scan(NetconfigWifi *wifi,
- gchar *ssid, GError **error);
+ gchar *ssid, GError **error);
#ifdef __cplusplus
}
#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_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);
-gchar *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
+ 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(void);
-
+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 netconfig_iface_wifi_request_wps_scan(
+ NetconfigWifi *wifi, GError **error);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFI_WPS_H__ */
*/
#ifndef __NETCONFIG_WIFI_H__
-#define __NETCONFIG_WIFI_H__
+#define __NETCONFIG_WIFI_H__
#ifdef __cplusplus
extern "C" {
#include <glib-object.h>
#include <dbus/dbus-glib.h>
+#define WIFI_STORAGEDIR "/var/lib/wifi"
+#define WIFI_CERT_STORAGEDIR "/var/lib/wifi/cert"
+#define CONNMAN_STORAGEDIR "/var/lib/connman"
+
G_BEGIN_DECLS
typedef struct NetconfigWifi NetconfigWifi;
typedef struct NetconfigWifiClass NetconfigWifiClass;
-#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"
+#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) )
-enum netconfig_wifi_power_state {
- WIFI_POWER_OFF = 0x00,
- WIFI_POWER_ON = 0x01,
-};
+#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) )
GType netconfig_wifi_get_type(void);
-gpointer netconfig_wifi_create_and_init(DBusGConnection *conn);
+gpointer netconfig_wifi_create_and_init(DBusGConnection *connection);
G_END_DECLS
<?xml version="1.0" encoding="UTF-8"?>
<node name="/net/netconfig/network">
<interface name="net.netconfig.network">
- <method name="UpdateDefaultConnectionInfo">
- <arg type="s" name="connection_type" direction="in" />
- <arg type="s" name="connection_state" direction="in" />
- <arg type="s" name="ip_addr" direction="in" />
- <arg type="s" name="proxy_addr" direction="in" />
+ <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="gateway" direction="in"/>
+ <arg type="i" name="address_family" direction="in"/>
+ <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="gateway" direction="in"/>
+ <arg type="i" name="address_family" direction="in"/>
+ <arg type="b" name="result" direction="out"/>
+ </method>
+ <method name="CheckGetPrivilege"></method>
+ <method name="CheckProfilePrivilege"></method>
</interface>
</node>
<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>
- <signal name="DriverLoaded">
- <arg name="mac" type="s"/>
- </signal>
- <signal name="PowerOn">
- <arg name="error" type="s"/>
- </signal>
+ <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">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="o" name="Service" direction="in"/>
+ <arg type="a{ss}" name="Fields" direction="in"/>
+ </method>
+ <method name="DeleteConfig">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="s" name="Profile" direction="in"/>
+ </method>
+ <method name="GetSimImsi">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <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"/>
+ </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"/>
+ </method>
+ <method name="GetSimAuth">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="ay" name="auth_data" direction="out"/>
+ </method>
+ <method name="GetAkaAuth">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="ay" name="auth_data" direction="out"/>
+ </method>
+ </interface>
+ <interface name="net.connman.Agent">
+ <method name="SetField">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <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="Service" direction="in"/>
+ <arg type="a{sv}" name="Fields" direction="in"/>
+ <arg type="a{sv}" name="OutFields" direction="out"/>
+ </method>
+ <method name="ReportError">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="o" name="Service" direction="in"/>
+ <arg type="s" name="Error" direction="in"/>
+ </method>
+ <method name="RequestBrowser">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <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>
+ <method name="Stop">
+ <arg type="s" name="Device" direction="in"/>
+ </method>
</interface>
</node>
--- /dev/null
+<manifest>
+ <define>
+ <domain name="net-config"/>
+ <request>
+ <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="wpasupplicant" type="rwx"/>
+ <smack request="deviced::power" type="rwx"/>
+ <smack request="deviced::display" type="rwx"/>
+ <smack request="telephony_framework::api_private" type="rwx"/>
+ <smack request="telephony_framework::api_sim" type="rwx"/>
+ <smack request="system::use_internet" type="rwx"/>
+ <smack request="system::vconf_system" type="rwx"/>
+ <smack request="system::vconf_network" type="rwx"/>
+ <smack request="system::vconf_setting" type="rwx"/>
+ </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/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"/>
+ <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="DeleteConfig">
+ <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="CreateConfig">
+ <annotation name="net.netconfig.smack" value="connman::profile"/>
+ </method>
+ <method name="LoadDriver">
+ <annotation name="net.netconfig.smack" value="connman::set"/>
+ </method>
+ <method name="LaunchDirect">
+ <annotation name="net.netconfig.smack" value="wifi-direct"/>
+ </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>
+ <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>
-#sbs-git:magnolia/framework/connectivity/net-config
-
-Name: net-config
-Summary: TIZEN Network Configuration Module
-Version: 0.1.88_5
-Release: 1
-Group: System/Network
-License: Apache License Version 2.0
-Source0: %{name}-%{version}.tar.gz
-
-BuildRequires: cmake
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(dbus-glib-1)
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(wifi-direct)
-BuildRequires: pkgconfig(syspopup-caller)
+Name: net-config
+Summary: TIZEN Network Configuration service
+Version: 1.0.79
+Release: 1
+Group: System/Network
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(tapi)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(appsvc)
+BuildRequires: pkgconfig(journal)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(dbus-glib-1)
+BuildRequires: pkgconfig(notification)
+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: /bin/cp
+Requires: /bin/mv
+Requires: /bin/rm
+Requires: /bin/cat
+Requires: /bin/sed
+Requires: /bin/tar
+Requires: /bin/mkdir
+Requires: /bin/touch
+Requires: /sbin/route
+Requires: /bin/netstat
+Requires: /sbin/ifconfig
+Requires: /usr/bin/xargs
+Requires: /usr/bin/vconftool
+Requires(post): systemd
+Requires(post): vconf
+Requires(preun): systemd
+Requires(postun): systemd
%description
-TIZEN Network Configuration Module
-
+TIZEN Network Configuration service
%prep
%setup -q
%build
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
-make %{?jobs:-j%jobs}
+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 0%{?model_build_feature_wlan_wearable} == 1
+ -DTIZEN_WEARABLE=1 \
+%endif
+ .
+
+make %{?_smp_mflags}
+
%install
-rm -rf %{buildroot}
%make_install
-mkdir -p %{buildroot}/usr/share/dbus-1/services
-cp resources/usr/share/dbus-1/services/net.netconfig.service %{buildroot}/usr/share/dbus-1/services/net.netconfig.service
-mkdir -p %{buildroot}/usr/etc/dbus-1/system.d
-cp resources/usr/etc/dbus-1/system.d/net-config.conf %{buildroot}/usr/etc/dbus-1/system.d/net-config.conf
-mkdir -p %{buildroot}/opt/etc
-cp resources/opt/etc/resolv.conf %{buildroot}/opt/etc/resolv.conf
-mkdir -p %{buildroot}/etc/rc.d/init.d
-cp resources/etc/rc.d/init.d/net-config %{buildroot}/etc/rc.d/init.d/net-config
-mkdir -p %{buildroot}/etc/rc.d/rc3.d
-ln -s ../init.d/net-config %{buildroot}/etc/rc.d/rc3.d/S60net-config
-mkdir -p %{buildroot}/etc/rc.d/rc5.d
-ln -s ../init.d/net-config %{buildroot}/etc/rc.d/rc5.d/S60net-config
+#Systemd service file
+mkdir -p %{buildroot}%{_libdir}/systemd/system/
+cp resources/usr/lib/systemd/system/net-config.service %{buildroot}%{_libdir}/systemd/system/net-config.service
+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
+
+mkdir -p %{buildroot}%{_datadir}/dbus-1/services/
+cp resources/usr/share/dbus-1/services/net.netconfig.service %{buildroot}%{_datadir}/dbus-1/services/net.netconfig.service
+
+mkdir -p %{buildroot}%{_sysconfdir}/
+cp resources/etc/resolv.conf %{buildroot}%{_sysconfdir}/resolv.conf
+
+mkdir -p %{buildroot}%{_sysconfdir}/wifi/
+cp resources/etc/wifi/ccode.conf %{buildroot}%{_sysconfdir}/wifi/ccode.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
+%if 0%{?model_build_feature_wlan_wearable} == 1
+#softreset scripts
+mkdir -p %{buildroot}/usr/system/RestoreDir/softreset_prepare
+cp resources/usr/system/RestoreDir/softreset_prepare/network_reset_pre.sh %{buildroot}/usr/system/RestoreDir/softreset_prepare/network_reset_pre.sh
+
+mkdir -p %{buildroot}/usr/system/RestoreDir/softreset_post
+cp resources/usr/system/RestoreDir/softreset_post/network_reset_post.sh %{buildroot}/usr/system/RestoreDir/softreset_post/network_reset_post.sh
+%endif
+
+#License
+mkdir -p %{buildroot}%{_datadir}/license
+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/strength 0 -i
+vconftool set -t int memory/dnet/state 0 -i -f -s system::vconf_network
+vconftool set -t int memory/wifi/state 0 -i -f -s system::vconf_network
+vconftool set -t int memory/wifi/transfer_state 0 -i -f -s system::vconf_network
+vconftool set -t int memory/wifi/strength 0 -i -f -s system::vconf_network
-vconftool set -t int memory/dnet/cellular 0 -i
-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
+vconftool set -t int memory/dnet/cellular 0 -i -f -s system::vconf_network
+vconftool set -t int memory/dnet/wifi 0 -i -f -s system::vconf_network
+vconftool set -t int memory/dnet/network_config 0 -i -f -s system::vconf_network
+vconftool set -t int memory/dnet/status 0 -i -f -s system::vconf_network
+vconftool set -t string memory/dnet/ip "" -i -f -s system::vconf_network
+vconftool set -t string memory/dnet/proxy "" -i -f -s system::vconf_network
-vconftool set -t string memory/wifi/connected_ap_name "" -i
+vconftool set -t string memory/wifi/connected_ap_name "" -i -f -s system::vconf_network
-vconftool set -t string db/wifi/bssid_address ""
+vconftool set -t string db/wifi/bssid_address "" -f -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"
+vconftool set -t int db/dnet/statistics/cellular/totalsnt 0 -f -s system::vconf_network
+vconftool set -t int db/dnet/statistics/cellular/totalrcv 0 -f -s system::vconf_network
+vconftool set -t int db/dnet/statistics/cellular/lastsnt 0 -f -s system::vconf_network
+vconftool set -t int db/dnet/statistics/cellular/lastrcv 0 -f -s system::vconf_network
+vconftool set -t int db/dnet/statistics/wifi/totalsnt 0 -f -s system::vconf_network
+vconftool set -t int db/dnet/statistics/wifi/totalrcv 0 -f -s system::vconf_network
+vconftool set -t int db/dnet/statistics/wifi/lastsnt 0 -f -s system::vconf_network
+vconftool set -t int db/dnet/statistics/wifi/lastrcv 0 -f -s system::vconf_network
+
+#Wi-Fi last power state
+vconftool set -t int file/private/wifi/last_power_state 0 -f -s system::vconf_network
+
+#Wi-Fi power state due to airplane mode
+vconftool set -t int file/private/wifi/wifi_off_by_airplane 0 -f -s system::vconf_network
+
+#Wi-Fi power state due to restricted mode
+vconftool set -t int file/private/wifi/wifi_off_by_restricted 0 -f -s system::vconf_network
+
+#Wi-Fi power state due to emergency mode
+vconftool set -t int file/private/wifi/wifi_off_by_emergency 0 -f -s system::vconf_network
+
+#Wi-Fi sleep policy
+vconftool set -t int file/private/wifi/sleep_policy 0 -g 6519 -f -s system::vconf_setting
+
+%if 0%{?model_build_feature_wlan_wearable} == 1
+#Wearable use Wi-Fi
+vconftool set -t int db/private/wifi/wearable_wifi_use 1 -g 6519 -f -s net-config
+%endif
+
+#Network logs
+mkdir -p /opt/usr/data/network
+chmod 755 /opt/usr/data/network
-vconftool set -t int file/private/wifi/last_power_state "0"
+#systemctl daemon-reload
+#systemctl restart net-config.service
-#Change File Permission
-#Resource
-chmod 644 /opt/etc/resolv.conf
+%preun
+#systemctl stop net-config.service
%postun
+#systemctl daemon-reload
%files
-%defattr(-,root,root,-)
-%{_sbindir}/*
-%{_datadir}/dbus-1/services/*
-/opt/etc/resolv.conf
-%{_prefix}/etc/dbus-1/system.d/*
-%{_sysconfdir}/rc.d/init.d/net-config
-%{_sysconfdir}/rc.d/rc3.d/S60net-config
-%{_sysconfdir}/rc.d/rc5.d/S60net-config
+%manifest net-config.manifest
+%attr(500,root,root) %{_sbindir}/*
+%attr(644,root,root) %{_sysconfdir}/resolv.conf
+%attr(400,root,root) %{_sysconfdir}/wifi/ccode.conf
+%attr(644,root,root) %{_datadir}/dbus-1/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
+%{_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
+
+%if 0%{?model_build_feature_wlan_wearable} == 1
+%attr(700,root,root) /usr/system/RestoreDir/softreset_prepare/network_reset_pre.sh
+%attr(700,root,root) /usr/system/RestoreDir/softreset_post/network_reset_post.sh
+%endif
+++ /dev/null
-#!/bin/sh
-
-/usr/sbin/net-config &
-
-bssid="$(vconftool -t string get db/wifi/bssid_address | sed -n "/\([0-9A-F][0-9A-F]:\)\{5\}[0-9A-F][0-9A-F]/p")"
-if [ "$bssid" = "" ]; then
- if [ -f /opt/etc/.mac.info ]; then
- cat /opt/etc/.mac.info | sed -n "/^\([0-9A-F][0-9A-F]:\)\{5\}[0-9A-F][0-9A-F]$/p" | xargs vconftool set -t string db/wifi/bssid_address -f
- fi
-fi
--- /dev/null
+# Generated by Connection Manager
+nameserver 127.0.0.1
+#nameserver ::1
+
+options timeout:5
+options attempts:8
--- /dev/null
+#This group is for mcc to country code mapping.
+[mcc_iso_map]
+
+202=gr
+204=nl
+206=be
+208=fr
+212=mc
+213=ad
+214=es
+216=hu
+218=ba
+219=hr
+220=rs
+222=it
+225=va
+226=ro
+228=ch
+230=cz
+231=sk
+232=at
+234=gb
+235=gb
+238=dk
+240=se
+242=no
+244=fi
+246=lt
+247=lv
+248=ee
+250=ru
+255=ua
+257=by
+259=md
+260=pl
+262=de
+266=gi
+268=pt
+270=lu
+272=ie
+274=is
+276=al
+278=mt
+280=cy
+282=ge
+283=am
+284=bg
+286=tr
+288=fo
+289=ge
+290=gl
+292=sm
+293=si
+294=mk
+295=li
+297=me
+302=ca
+308=pm
+310=us
+311=us
+312=us
+313=us
+314=us
+315=us
+316=us
+330=pr
+332=vi
+334=mx
+338=jm
+340=gp
+342=bb
+344=ag
+346=ky
+348=vg
+350=bm
+352=gd
+354=ms
+356=kn
+358=lc
+360=vc
+362=ai
+363=aw
+364=bs
+365=ai
+366=dm
+368=cu
+370=do
+372=ht
+374=tt
+376=tc
+400=az
+401=kz
+402=bt
+404=in
+405=in
+410=pk
+412=af
+413=lk
+414=mm
+415=lb
+416=jo
+417=sy
+418=iq
+419=kw
+420=sa
+421=ye
+422=om
+423=ps
+424=ae
+425=il
+426=bh
+427=qa
+428=mn
+429=np
+430=ae
+431=ae
+432=ir
+434=uz
+436=tj
+437=kg
+438=tm
+440=jp
+441=jp
+450=kr
+452=vn
+454=hk
+455=mo
+456=kh
+457=la
+460=cn
+461=cn
+466=tw
+467=kp
+470=bd
+472=mv
+502=my
+505=au
+510=id
+514=tl
+515=ph
+520=th
+525=sg
+528=bn
+530=nz
+534=mp
+535=gu
+536=nr
+537=pg
+539=to
+540=sb
+541=vu
+542=fj
+543=wf
+544=as
+545=ki
+546=nc
+547=pf
+548=ck
+549=ws
+550=fm
+551=mh
+552=pw
+602=eg
+603=dz
+604=ma
+605=tn
+606=ly
+607=gm
+608=sn
+609=mr
+610=ml
+611=gn
+612=ci
+613=bf
+614=ne
+615=tg
+616=bj
+617=mu
+618=lr
+619=sl
+620=gh
+621=ng
+622=td
+623=cf
+624=cm
+625=cv
+626=st
+627=gq
+628=ga
+629=cg
+630=cg
+631=ao
+632=gw
+633=sc
+634=sd
+635=rw
+636=et
+637=so
+638=dj
+639=ke
+640=tz
+641=ug
+642=bi
+643=mz
+645=zm
+646=mg
+647=re
+648=zw
+649=na
+650=mw
+651=ls
+652=bw
+653=sz
+654=km
+655=za
+657=er
+702=bz
+704=gt
+706=sv
+708=hn
+710=ni
+712=cr
+714=pa
+716=pe
+722=ar
+724=br
+730=cl
+732=co
+734=ve
+736=bo
+738=gy
+740=ec
+742=gf
+744=py
+746=sr
+748=uy
+750=fk
--- /dev/null
+#!/bin/sh
+
+#--------------------------------------
+# network
+#--------------------------------------
+
+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
--- /dev/null
+[Unit]
+Description=Network Configuration service
+After=tizen-system.target
+
+[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
+#!/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
+
+/bin/rm /var/lib/wifi/.pseudonym.info
+/bin/rm /var/lib/wifi/.pseudonym_sim.info
--- /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
+
+# 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);
+}
#include "log.h"
#include "netdbus.h"
-#include "netconfig.h"
#define NETCONFIG_DBUS_REPLY_TIMEOUT (10 * 1000)
#define DBUS_PARAM_TYPE_BOOLEAN "boolean"
#define DBUS_PARAM_TYPE_OBJECT_PATH "objpath"
#define DBUS_PARAM_TYPE_VARIANT "variant"
+#define DBUS_PARAM_TYPE_ARRAY "array"
-static int __netconfig_dbus_append_param(DBusMessage *message, char *param_array[])
+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("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);
+
+ dbus_message_iter_close_container(&value, &array);
+
+ 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("Not supported data format[\"%s\"]", args);
+ return FALSE;
+ }
+ } else {
+ ERR("Not supported data format[\"%s\"]", args);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean __netconfig_dbus_append_param(
+ DBusMessage *message, char *param_array[])
{
int count = 0;
+ dbus_int16_t int16 = 0;
+ dbus_uint16_t uint16 = 0;
+ dbus_int32_t int32 = 0;
dbus_uint32_t uint32 = 0;
+ dbus_int64_t int64 = 0;
+ dbus_uint64_t uint64 = 0;
DBusMessageIter iter;
- DBusMessageIter container_iter;
- char *args = NULL;
- char *ch = NULL;
+ char *args = NULL, *ch = NULL;
if (param_array == NULL)
return TRUE;
while (param_array[count] != NULL) {
args = param_array[count];
- DBG("parameter %d - [%s]", count, param_array[count]);
+
+ DBG("parameter [%s]", param_array[count]);
ch = strchr(args, ':');
if (ch == NULL) {
- ERR("Error!!! Invalid parameter[\"%s\"]\n", args);
+ ERR("Invalid parameter[\"%s\"]", args);
return FALSE;
}
- *ch = 0; ch++;
+ *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_INT16) == 0) {
+ int16 = (dbus_int16_t)strtol(ch, NULL, 0);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT16, &int16);
+ } else if (strcmp(args, DBUS_PARAM_TYPE_UINT16) == 0) {
+ uint16 = (dbus_uint16_t)strtoul(ch, NULL, 0);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT16, &uint16);
+ } else if (strcmp(args, DBUS_PARAM_TYPE_INT32) == 0) {
+ int32 = strtol(ch, NULL, 0);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &int32);
} 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_INT64) == 0) {
+ int64 = strtoq(ch, NULL, 0);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT64, &int64);
+ } else if (strcmp(args, DBUS_PARAM_TYPE_UINT64) == 0) {
+ uint64 = strtouq(ch, NULL, 0);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT64, &uint64);
} 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);
+ ERR("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_STRING_AS_STRING, &container_iter);
- dbus_message_iter_append_basic(&container_iter, DBUS_TYPE_STRING, &ch);
- dbus_message_iter_close_container(&iter, &container_iter);
- } else {
- ERR("Error!!! Not supported data format[\"%s\"]\n", args);
+ 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\"]\n", args);
+ ERR("Not supported data format[\"%s\"]", args);
return FALSE;
}
return TRUE;
}
-char *netconfig_dbus_get_string(DBusMessage * msg)
+gboolean netconfig_dbus_get_basic_params_string(DBusMessage *message,
+ char **key, int type, void *value)
{
- DBusMessageIter args;
- char *sigvalue = NULL;
-
- /** read these parameters */
- if (!dbus_message_iter_init(msg, &args))
- DBG("Message does not have parameters");
- else if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args))
- DBG("Argument is not string");
- else
- dbus_message_iter_get_basic(&args, &sigvalue);
-
- return sigvalue;
-}
+ DBusMessageIter iter, iter_variant;
-DBusMessage *netconfig_invoke_dbus_method(const char *dest, const char *path,
- const char *interface_name, const char *method, char *param_array[])
-{
- DBusError error;
- DBusConnection *conn = NULL;
- DBusMessage *reply = NULL;
- DBusMessage *message = NULL;
+ 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;
+ }
- DBG("[DBUS Sync] %s %s %s", interface_name, method, path);
+ dbus_message_iter_get_basic(&iter, key);
- conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
- if (conn == NULL) {
- ERR("Failed to get system bus");
- return NULL;
- }
+ if (value == NULL)
+ return TRUE;
- 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;
+ 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 (__netconfig_dbus_append_param(message, param_array) == FALSE) {
- ERR("Error!!! __netconfig_dbus_append_param() failed\n");
- dbus_message_unref(message);
- dbus_connection_unref(conn);
- return NULL;
- }
+ dbus_message_iter_recurse(&iter, &iter_variant);
+ if (dbus_message_iter_get_arg_type(&iter_variant) != type)
+ return FALSE;
- dbus_error_init(&error);
+ dbus_message_iter_get_basic(&iter_variant, value);
- reply = dbus_connection_send_with_reply_and_block(conn, message,
- NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
+ return TRUE;
+}
- 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);
+gboolean netconfig_dbus_get_basic_params_array(DBusMessage *message,
+ const char *key, void **value)
+{
+ int type = 0;
+ gboolean find = FALSE;
+ const char *arg = NULL;
+ DBusMessageIter args, dict, entry, variant;
- dbus_error_free(&error);
- } else
- ERR("Error!!! Failed to get properties");
+ if (key == NULL || value == NULL)
+ return FALSE;
- dbus_message_unref(message);
- dbus_connection_unref(conn);
+ /* read parameters */
+ if (dbus_message_iter_init(message, &args) == FALSE) {
+ DBG("Message does not have parameters");
+ return FALSE;
+ }
- return NULL;
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_ARRAY) {
+ DBG("Argument type %d", dbus_message_iter_get_arg_type(&args));
+ return FALSE;
}
- dbus_message_unref(message);
- dbus_connection_unref(conn);
+ dbus_message_iter_recurse(&args, &dict);
- return reply;
-}
+ while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
+ dbus_message_iter_recurse(&dict, &entry);
-char *netconfig_wifi_get_connected_service_name(DBusMessage *message)
-{
- int is_connected = 0;
- char *essid_name = NULL;
- DBusMessageIter iter, array;
+ if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING) {
+ DBG("Argument type %d", dbus_message_iter_get_arg_type(&entry));
+ return FALSE;
+ }
- dbus_message_iter_init(message, &iter);
- dbus_message_iter_recurse(&iter, &array);
+ dbus_message_iter_get_basic(&entry, &arg);
- while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
- DBusMessageIter entry, string;
- const char *key = NULL;
+ if (g_strcmp0(key, arg) != 0) {
+ dbus_message_iter_next(&dict);
+ continue;
+ }
- dbus_message_iter_recurse(&array, &entry);
- dbus_message_iter_get_basic(&entry, &key);
+ dbus_message_iter_next(&entry);
- 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(&entry) != DBUS_TYPE_VARIANT) {
+ DBG("Argument type %d", dbus_message_iter_get_arg_type(&entry));
+ return FALSE;
+ }
- if (dbus_message_iter_get_arg_type(&string) == DBUS_TYPE_STRING) {
- dbus_message_iter_get_basic(&string, &key);
+ dbus_message_iter_recurse(&entry, &variant);
+
+ type = dbus_message_iter_get_arg_type(&variant);
+ if (type == DBUS_TYPE_STRING) {
+ find = TRUE;
+ 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) {
+ find = TRUE;
+ dbus_message_iter_get_basic(&variant, *value);
+ } else
+ DBG("Argument type %d", type);
- 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 (find == TRUE)
+ break;
- if (dbus_message_iter_get_arg_type(&string) == DBUS_TYPE_STRING) {
- dbus_message_iter_get_basic(&string, &key);
+ dbus_message_iter_next(&dict);
+ }
- essid_name = (char *)g_strdup(key);
- }
- }
+ return find;
+}
- dbus_message_iter_next(&array);
- }
+gboolean netconfig_is_cellular_internet_profile(const char *profile)
+{
+ const char internet_suffix[] = "_1";
+ char *suffix = NULL;
- if (is_connected == 1 && essid_name != NULL)
- return essid_name;
+ if (profile == NULL)
+ return FALSE;
- if (essid_name != NULL)
- g_free(essid_name);
+ if (g_str_has_prefix(profile, CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX)
+ == TRUE) {
+ suffix = strrchr(profile, '_');
+ if (g_strcmp0(suffix, internet_suffix) == 0)
+ return TRUE;
+ }
- return NULL;
+ return FALSE;
}
-void netconfig_dbus_parse_recursive(DBusMessageIter *iter,
- netconfig_dbus_result_type result_type, void *data)
+gboolean netconfig_is_cellular_profile(const char *profile)
{
- unsigned char *bgscan_mode = NULL;
- static dbus_bool_t default_tech_flag = FALSE;
- char *default_tech = NULL;
+ if (profile == NULL)
+ return FALSE;
- if (result_type == NETCONFIG_DBUS_RESULT_GET_BGSCAN_MODE)
- bgscan_mode = (unsigned char *)data;
- else if (result_type == NETCONFIG_DBUS_RESULT_DEFAULT_TECHNOLOGY)
- default_tech = (char *)data;
+ return g_str_has_prefix(profile, CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX);
+}
- do {
- int ArgType = dbus_message_iter_get_arg_type(iter);
+gboolean netconfig_is_wifi_profile(const char *profile)
+{
+ if (profile == NULL)
+ return FALSE;
- if (ArgType == DBUS_TYPE_INVALID)
- break;
+ return g_str_has_prefix(profile, CONNMAN_WIFI_SERVICE_PROFILE_PREFIX);
+}
- switch (ArgType) {
- case DBUS_TYPE_BYTE:
- {
- unsigned char Value = 0;
+gboolean netconfig_is_ethernet_profile(const char *profile)
+{
+ if (profile == NULL)
+ return FALSE;
- dbus_message_iter_get_basic(iter, &Value);
+ return g_str_has_prefix(profile, CONNMAN_ETHERNET_SERVICE_PROFILE_PREFIX);
+}
- *bgscan_mode = Value;
- INFO("BG scan mode: %d, %d", *bgscan_mode, Value);
- break;
- }
+gboolean netconfig_is_bluetooth_profile(const char *profile)
+{
+ if (profile == NULL)
+ return FALSE;
- case DBUS_TYPE_STRING:
- {
- char *Value = NULL;
-
- dbus_message_iter_get_basic(iter, &Value);
-
- INFO("result type: %d, string: %s", result_type, Value);
- if (result_type == NETCONFIG_DBUS_RESULT_DEFAULT_TECHNOLOGY) {
- if (strcmp(Value, "DefaultTechnology") == 0) {
- default_tech_flag = TRUE;
- } else {
- if (default_tech_flag == TRUE) {
- sprintf(default_tech, "%s", Value);
- INFO("default technology: %s", default_tech);
- default_tech_flag = FALSE;
- }
- }
- }
- break;
- }
+ return g_str_has_prefix(profile, CONNMAN_BLUETOOTH_SERVICE_PROFILE_PREFIX);
+}
- case DBUS_TYPE_SIGNATURE:
- {
- char *Value = NULL;
+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)
+{
+ dbus_bool_t result;
+ DBusPendingCall *call;
+ DBusMessage *message = NULL;
+ DBusConnection *connection = NULL;
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
+ DBG("[DBUS Async] %s %s %s", interface_name, method, path);
- case DBUS_TYPE_OBJECT_PATH:
- {
- char *Value = NULL;
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (connection == NULL) {
+ ERR("Failed to get system bus");
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
+ return FALSE;
+ }
- case DBUS_TYPE_INT16:
- {
- dbus_int16_t Value = 0;
+ message = dbus_message_new_method_call(dest, path, interface_name, method);
+ if (message == NULL) {
+ ERR("Failed DBus method call");
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
+ dbus_connection_unref(connection);
- case DBUS_TYPE_UINT16:
- {
- dbus_uint16_t Value = 0;
+ return FALSE;
+ }
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
+ if (__netconfig_dbus_append_param(message, param_array) == FALSE) {
+ ERR("Failed to append DBus params");
- case DBUS_TYPE_INT32:
- {
- dbus_int32_t Value = 0;
+ dbus_message_unref(message);
+ dbus_connection_unref(connection);
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
+ return FALSE;
+ }
- case DBUS_TYPE_UINT32:
- {
- dbus_uint32_t Value = 0;
+ result = dbus_connection_send_with_reply(connection, message, &call,
+ NETCONFIG_DBUS_REPLY_TIMEOUT);
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
+ if (result != TRUE || call == NULL) {
+ ERR("dbus_connection_send_with_reply() failed.");
- case DBUS_TYPE_INT64:
- {
- dbus_int64_t Value = 0;
+ dbus_message_unref(message);
+ dbus_connection_unref(connection);
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
+ return FALSE;
+ }
- case DBUS_TYPE_UINT64:
- {
- dbus_uint64_t Value = 0;
+ if (notify_func == NULL)
+ dbus_pending_call_cancel(call);
+ else
+ dbus_pending_call_set_notify(call, notify_func, NULL, NULL);
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
+ dbus_message_unref(message);
+ dbus_connection_unref(connection);
- case DBUS_TYPE_DOUBLE:
- {
- double Value = 0;
+ return TRUE;
+}
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
+DBusMessage *netconfig_invoke_dbus_method(const char *dest, const char *path,
+ const char *interface_name, const char *method, char *param_array[])
+{
+ DBusError error;
+ DBusMessage *reply = NULL;
+ DBusMessage *message = NULL;
+ DBusConnection *connection = NULL;
- case DBUS_TYPE_BOOLEAN:
- {
- dbus_bool_t Value = 0;
+ DBG("[DBUS Sync] %s %s %s", interface_name, method, path);
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (connection == NULL) {
+ ERR("Failed to get system bus");
- case DBUS_TYPE_VARIANT:
- {
- DBusMessageIter SubIter;
+ return NULL;
+ }
- dbus_message_iter_recurse(iter, &SubIter);
- netconfig_dbus_parse_recursive(&SubIter,
- result_type, data);
- break;
- }
+ message = dbus_message_new_method_call(dest, path, interface_name, method);
+ if (message == NULL) {
+ ERR("Failed DBus method call");
- case DBUS_TYPE_ARRAY:
- {
- int CurrentType = 0;
- DBusMessageIter SubIter;
+ dbus_connection_unref(connection);
- dbus_message_iter_recurse(iter, &SubIter);
- CurrentType = dbus_message_iter_get_arg_type(&SubIter);
+ return NULL;
+ }
- while (CurrentType != DBUS_TYPE_INVALID) {
- netconfig_dbus_parse_recursive(&SubIter,
- result_type, data);
+ if (__netconfig_dbus_append_param(message, param_array) == FALSE) {
+ ERR("Failed to append DBus params");
- dbus_message_iter_next(&SubIter);
- CurrentType = dbus_message_iter_get_arg_type(&SubIter);
- }
- break;
- }
+ dbus_message_unref(message);
+ dbus_connection_unref(connection);
- case DBUS_TYPE_DICT_ENTRY:
- {
- DBusMessageIter SubIter;
+ return NULL;
+ }
- dbus_message_iter_recurse(iter, &SubIter);
- netconfig_dbus_parse_recursive(&SubIter, result_type, data);
+ dbus_error_init(&error);
- dbus_message_iter_next(&SubIter);
- netconfig_dbus_parse_recursive(&SubIter, result_type, data);
- break;
- }
+ reply = dbus_connection_send_with_reply_and_block(connection, message,
+ NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
- case DBUS_TYPE_STRUCT:
- {
- int CurrentType = 0;
- DBusMessageIter SubIter;
+ 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_message_iter_recurse(iter, &SubIter);
+ dbus_error_free(&error);
+ } else
+ ERR("Failed to get properties");
- while ((CurrentType = dbus_message_iter_get_arg_type(&SubIter))
- != DBUS_TYPE_INVALID) {
- netconfig_dbus_parse_recursive(&SubIter, result_type, data);
+ dbus_message_unref(message);
+ dbus_connection_unref(connection);
- dbus_message_iter_next(&SubIter);
- }
- break;
- }
+ return NULL;
+ }
- default:
- ERR("Error!!! Invalid Argument Type [%c]", ArgType);
- }
- } while (dbus_message_iter_next(iter));
+ dbus_message_unref(message);
+ dbus_connection_unref(connection);
+
+ return reply;
}
DBusGConnection *netconfig_setup_dbus(void)
{
- DBusGConnection* connection = NULL;
- GError *error = NULL;
- DBusGProxy *proxy;
guint rv = 0;
+ DBusGProxy *proxy;
+ GError *error = NULL;
+ DBusGConnection* connection = NULL;
connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
if (connection == NULL) {
ERR("Fail to get DBus(%s)", error->message);
+ g_error_free(error);
return connection;
}
- 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");
G_TYPE_INVALID)) {
ERR("Failed to acquire service(%s) error(%s)",
NETCONFIG_SERVICE, error->message);
+ g_error_free(error);
dbus_g_connection_unref(connection);
#include "netdbus.h"
#include "netsupplicant.h"
-#define NETCONFIG_DBUS_REPLY_TIMEOUT (10 * 1000)
+#define DBUS_OBJECT_PATH_MAX 150
+#define NETCONFIG_DBUS_REPLY_TIMEOUT (10 * 1000)
static void setup_dbus_args(gpointer data, gpointer user_data)
{
- struct dbus_input_arguments *args;
DBusMessageIter *iter;
+ struct dbus_input_arguments *args;
- if (data != NULL && user_data != NULL) {
- args = (struct dbus_input_arguments *)data;
- iter = (DBusMessageIter *) user_data;
-
- dbus_message_iter_append_basic(iter, args->type,
- &(args->data));
+ 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;
}
}
-static GList *setup_input_args(GList *list,
- struct dbus_input_arguments *items)
+GList *setup_input_args(GList *list, struct dbus_input_arguments *items)
{
struct dbus_input_arguments *iter = items;
return list;
}
-gboolean netconfig_wifi_get_ifname(char **ifname)
+const char *netconfig_wifi_get_supplicant_interface(void)
{
- 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;
+ DBusMessage *message = NULL;
struct dbus_input_arguments args[] = {
- {DBUS_TYPE_STRING, SUPPLICANT_INTERFACE ".Interface"},
- {DBUS_TYPE_STRING, "Ifname"},
- {0, NULL}
+ {DBUS_TYPE_STRING, WIFI_IFNAME},
+ {DBUS_TYPE_INVALID, NULL}
};
+ const char *path;
+ static char obj_path[DBUS_OBJECT_PATH_MAX] = { '\0', };
- 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;
- }
+ if (obj_path[0] != '\0')
+ return (const char *)obj_path;
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);
+ SUPPLICANT_SERVICE, SUPPLICANT_PATH,
+ SUPPLICANT_INTERFACE, "GetInterface", 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 (message == NULL)
+ return NULL;
- if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
- const char *err_ptr = dbus_message_get_error_name(message);
- ERR("Error!!! Error message received %s", err_ptr);
+ 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_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;
+ dbus_message_get_args(message, NULL, DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID);
- g_strlcpy(ptr, temp, 16);
+ g_strlcpy(obj_path, path, DBUS_OBJECT_PATH_MAX);
dbus_message_unref(message);
- dbus_connection_unref(connection);
- return TRUE;
+ return (const char *)obj_path;
error:
if (message != NULL)
dbus_message_unref(message);
- if (connection != NULL)
- dbus_connection_unref(connection);
-
- return FALSE;
+ return NULL;
}
-gboolean netconfig_wifi_get_supplicant_interface(char **path)
+DBusMessage *netconfig_supplicant_invoke_dbus_method(const char *dest,
+ const char *path, const char *interface_name,
+ const char *method, GList *args)
{
- DBusConnection *connection = NULL;
- DBusMessage *message = NULL;
+ DBusError error;
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}
- };
+ DBusMessage *reply = NULL;
+ DBusMessage *message = NULL;
+ DBusConnection *connection = NULL;
- if (ptr == NULL)
- return FALSE;
+ INFO("[DBUS Sync] %s %s %s", interface_name, method, path);
connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
if (connection == NULL) {
- ERR("Error!!! Fail to get system DBus");
- return FALSE;
+ ERR("Failed to get system bus");
+ return NULL;
}
- input_args = setup_input_args(input_args, args);
+ 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;
+ }
- message = netconfig_supplicant_invoke_dbus_method(
- SUPPLICANT_SERVICE, connection,
- SUPPLICANT_PATH,
- SUPPLICANT_GLOBAL_INTERFACE, "Get",
- input_args);
+ dbus_message_iter_init_append(message, &iter);
- g_list_free(input_args);
+ if (args != NULL)
+ g_list_foreach(args, setup_dbus_args, (gpointer)&iter);
- if (message == NULL) {
- ERR("Error!!! Failed to get service properties");
- goto error;
- }
+ dbus_error_init(&error);
- MessageType = dbus_message_get_type(message);
+ reply = dbus_connection_send_with_reply_and_block(connection, message,
+ NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
- 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;
- }
+ 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_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;
+ dbus_error_free(&error);
} else
- goto error;
- } else
- goto error;
+ ERR("Failed to get properties");
- g_strlcpy(ptr, temp, DBUS_PATH_MAX_BUFLEN);
+ dbus_message_unref(message);
+ dbus_connection_unref(connection);
+
+ return NULL;
+ }
dbus_message_unref(message);
dbus_connection_unref(connection);
- return TRUE;
+ return reply;
+}
-error:
- if (message != NULL)
- dbus_message_unref(message);
+dbus_bool_t netconfig_supplicant_invoke_dbus_method_nonblock(const char *dest,
+ const char *path, const char *interface_name,
+ const char *method, GList *args,
+ DBusPendingCallNotifyFunction notify_func)
+{
+ dbus_bool_t result = FALSE;
+ DBusMessageIter iter;
+ DBusPendingCall *call;
+ DBusMessage *message = NULL;
+ DBusConnection *connection = NULL;
- if (connection != NULL)
+ INFO("[DBUS Async] %s %s %s", interface_name, method, path);
+
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (connection == NULL) {
+ ERR("Failed to get system bus");
+ return result;
+ }
+
+ message = dbus_message_new_method_call(dest, path, interface_name, method);
+ if (message == NULL) {
+ ERR("Failed DBus method call");
dbus_connection_unref(connection);
+ return result;
+ }
- return FALSE;
+ dbus_message_iter_init_append(message, &iter);
+
+ if (args != NULL)
+ g_list_foreach(args, setup_dbus_args, (gpointer)&iter);
+
+ result = dbus_connection_send_with_reply(connection, message, &call,
+ NETCONFIG_DBUS_REPLY_TIMEOUT);
+ if (result == FALSE || call == NULL) {
+ 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;
}
-DBusMessage *netconfig_supplicant_invoke_dbus_method(const char *dest,
- DBusConnection *connection,
- 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 *key)
{
DBusError error;
- DBusMessageIter iter;
DBusMessage *reply = NULL;
DBusMessage *message = NULL;
+ DBusConnection *connection = NULL;
+ const char *path;
- message = dbus_message_new_method_call(dest, path, interface_name, method);
- if (message == NULL) {
- ERR("Error!!! DBus method call fail");
+ ERR("[DBUS] property_get : %s", key);
+
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (connection == NULL) {
+ ERR("Failed to get system bus");
return NULL;
}
- dbus_message_iter_init_append(message, &iter);
+ path = netconfig_wifi_get_supplicant_interface();
+ if (path == NULL) {
+ DBG("Failed to get wpa_supplicant DBus path");
+ dbus_connection_unref(connection);
+ return NULL;
+ }
- if (args != NULL)
- g_list_foreach(args, setup_dbus_args, (gpointer) &iter);
+ 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_error_init(&error);
+ dbus_message_append_args(message, DBUS_TYPE_STRING, &interface,
+ DBUS_TYPE_STRING, &key, NULL);
- reply = dbus_connection_send_with_reply_and_block(connection, message,
- NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
+ 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("Error!!! dbus_connection_send_with_reply_and_block() failed. DBus error [%s: %s]",
- error.name, error.message);
+ ERR("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");
+ ERR("Failed to get properties");
dbus_message_unref(message);
+ dbus_connection_unref(connection);
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)
+{
+ dbus_bool_t result = FALSE;
+ DBusPendingCall *call;
+ DBusMessage *message = NULL;
+ DBusConnection *connection = NULL;
+ DBusMessageIter iter, value;
+ 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();
+ 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);
+
+ result = dbus_connection_send_with_reply(connection, message, &call,
+ NETCONFIG_DBUS_REPLY_TIMEOUT);
+ if (result == FALSE || call == NULL) {
+ 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;
+}
*
*/
+#include <errno.h>
#include <unistd.h>
+#include <sys/stat.h>
#include "log.h"
#include "wifi.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 "network-statistics.h"
static GMainLoop *main_loop = NULL;
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
DBusGConnection *connection;
- DBG("Network Configuration Module");
+ umask(0077);
+ DBG("Network Configuration service");
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");
+ }
+
+ 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 (connection == NULL)
return -1;
- if (netconfig_network_state_create_and_init(connection) == NULL)
- return -1;
-
netconfig_register_signal();
+ netconfig_agent_register();
+
+ netconfig_wifi_fetch_airplane_mode();
+
if (netconfig_wifi_create_and_init(connection) == NULL)
return -1;
+ if (netconfig_network_state_create_and_init(connection) == NULL)
+ return -1;
+
if (netconfig_network_statistics_create_and_init(connection) == NULL)
return -1;
+ netconfig_error_init();
+
/* If its environment uses Emulator, network configuration is set by emulator default */
netconfig_emulator_test_and_start();
g_main_loop_run(main_loop);
- netconfig_wifi_state_notifier_cleanup();
netconfig_deregister_signal();
+ netconfig_wifi_state_notifier_cleanup();
+
+ /* Unregistering the agent */
+ netconfig_agent_unregister();
return 0;
}
#include <glib.h>
+#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_MAX = 0x10,
+} NETCONFIG_ERROR;
#define NETCONFIG_ERROR_INTERFACE NETCONFIG_SERVICE ".Error"
+#define CONNMAN_AGENT_ERROR_INTERFACE "net.connman.Agent.Error"
GQuark netconfig_error_quark(void)
{
return quark;
}
-void netconfig_error_wifi_driver_failed(GError **error)
+GQuark netconfig_connman_agent_error_quark(void)
{
- g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_WIFI_DRIVER_FAILURE,
- NETCONFIG_ERROR_INTERFACE ".WifiDriverFailed");
+ static GQuark quark = 0;
+
+ if (!quark)
+ quark = g_quark_from_static_string("netconfig_connman_agent_error");
+
+ return quark;
+}
+
+void netconfig_error_inprogress(GError **error)
+{
+ g_set_error(error, netconfig_error_quark(),
+ NETCONFIG_ERROR_INPROGRESS,
+ NETCONFIG_ERROR_INTERFACE ".InProgress");
}
-void netconfig_error_security_restricted(GError **error)
+void netconfig_error_already_exists(GError **error)
{
- g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_SECURITY_RESTRICTED,
- NETCONFIG_ERROR_INTERFACE ".SecurityRestricted");
+ g_set_error(error, netconfig_error_quark(),
+ NETCONFIG_ERROR_ALREADYEXISTS,
+ NETCONFIG_ERROR_INTERFACE ".AlreadyExists");
+}
+
+void netconfig_error_invalid_parameter(GError **error)
+{
+ g_set_error(error, netconfig_error_quark(),
+ NETCONFIG_ERROR_INVALID_PARAMETER,
+ NETCONFIG_ERROR_INTERFACE ".InvalidParameter");
+}
+
+void netconfig_error_permission_denied(GError **error)
+{
+ g_set_error(error, netconfig_error_quark(),
+ NETCONFIG_ERROR_PERMISSION_DENIED,
+ NETCONFIG_ERROR_INTERFACE ".PermissionDenied");
+}
+
+void netconfig_error_wifi_driver_failed(GError **error)
+{
+ g_set_error(error, netconfig_error_quark(),
+ NETCONFIG_ERROR_WIFI_DRIVER_FAILURE,
+ NETCONFIG_ERROR_INTERFACE ".WifiDriverFailed");
}
void netconfig_error_wifi_direct_failed(GError **error)
{
- g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_WIFI_DRIVER_FAILURE,
+ g_set_error(error, netconfig_error_quark(),
+ NETCONFIG_ERROR_WIFI_DRIVER_FAILURE,
NETCONFIG_ERROR_INTERFACE ".WifiDirectFailed");
}
+
+void netconfig_error_fail_get_imsi(GError **error)
+{
+ g_set_error(error, netconfig_error_quark(),
+ NETCONFIG_ERROR_FAILED_GET_IMSI,
+ NETCONFIG_ERROR_INTERFACE".FailGetSimImsi");
+}
+
+void netconfig_error_fail_req_sim_auth(GError **error)
+{
+ g_set_error(error, netconfig_error_quark(),
+ NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH,
+ NETCONFIG_ERROR_INTERFACE".FailReqSimAuth");
+}
+
+void netconfig_error_fail_req_sim_auth_wrong_param(GError **error)
+{
+ g_set_error(error, 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)
+{
+ g_set_error(error, 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)
+{
+ g_set_error(error, netconfig_error_quark(),
+ NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_DELAY,
+ NETCONFIG_ERROR_INTERFACE".FailGetSimAuthDelay");
+}
+
+void netconfig_error_init(void)
+{
+ /* TODO: register GError domain to make error_name */
+ /*
+ dbus_g_error_domain_register(NETCONFIG_ERROR_QUARK,
+ NETCONFIG_ERROR_INTERFACE,
+ code_num_netconfig);
+
+ dbus_g_error_domain_register(NETCONFIG_CONNMAN_AGENT_ERROR_QUARK,
+ CONNMAN_AGENT_ERROR_INTERFACE,
+ code_num_connman);
+ */
+}
--- /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 <vconf-keys.h>
+
+#include "log.h"
+#include "util.h"
+#include "netdbus.h"
+#include "wifi-state.h"
+
+#define NTP_SERVER "pool.ntp.org"
+#define CONNMAN_GLOBAL_SETTING "/var/lib/connman/settings"
+
+static void __netconfig_clock_clear_timeserver(void)
+{
+ GKeyFile *keyfile = NULL;
+
+ keyfile = netconfig_keyfile_load(CONNMAN_GLOBAL_SETTING);
+
+ if (keyfile == NULL)
+ return;
+
+ g_key_file_remove_key(keyfile, "global", "Timeservers", NULL);
+
+ netconfig_keyfile_save(keyfile, CONNMAN_GLOBAL_SETTING);
+}
+
+static gboolean __netconfig_clock_clear_timeserver_timer(gpointer data)
+{
+ INFO("Clear NTP server");
+
+ __netconfig_clock_clear_timeserver();
+
+ return FALSE;
+}
+
+static void __netconfig_clock_set_timeserver(const char *server)
+{
+ DBusMessage* reply = NULL;
+ char param0[] = "string:Timeservers";
+ char *param1 = NULL;
+ char *param_array[] = { NULL, NULL, NULL };
+
+ param1 = g_strdup_printf("variant:array:string:%s", server);
+
+ param_array[0] = param0;
+ param_array[1] = param1;
+
+ reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_CLOCK_INTERFACE,
+ "SetProperty", param_array);
+ if (reply == NULL) {
+ ERR("Failed to configure NTP server");
+
+ g_free(param1);
+ return;
+ }
+
+ g_free(param1);
+ dbus_message_unref(reply);
+}
+
+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;
+
+ vconf_get_bool(
+ VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL,
+ &automatic_time_update);
+
+ if (automatic_time_update == FALSE) {
+ INFO("Automatic time update is not set (%d)", automatic_time_update);
+ return;
+ }
+
+ __netconfig_clock_set_timeserver((const char *)NTP_SERVER);
+
+ netconfig_start_timer_seconds(5, __netconfig_clock_clear_timeserver_timer,
+ NULL, ×erver_clear_timer);
+}
+
+static struct netconfig_wifi_state_notifier netconfig_clock_notifier = {
+ .netconfig_wifi_state_changed = __netconfig_clock,
+ .user_data = NULL,
+};
+
+void netconfig_clock_init(void)
+{
+ netconfig_wifi_state_notifier_register(&netconfig_clock_notifier);
+}
+
+void netconfig_clock_deinit(void)
+{
+ netconfig_wifi_state_notifier_unregister(&netconfig_clock_notifier);
+}
#include <vconf.h>
#include <vconf-keys.h>
-#include <syspopup_caller.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 "log.h"
+#include "util.h"
+#include "netdbus.h"
#include "neterror.h"
#include "emulator.h"
+#include "wifi-state.h"
+#include "wifi-power.h"
#include "network-state.h"
+#include "netsupplicant.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 110208"
+#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 704512"
+#define NET_TCP_BUFFERSIZE_HSPAP_WRITE "4096 16384 262144"
+#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"
+
#define NETCONFIG_NETWORK_STATE_PATH "/net/netconfig/network"
#define PROP_DEFAULT FALSE
-#define PROP_DEFAULT_STR NULL
+#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_update_default_connection_info(
+gboolean netconfig_iface_network_state_remove_route(
NetconfigNetworkState *master,
- gchar *connection_type, gchar *connection_state,
- gchar *ip_addr, gchar *proxy_addr, GError **error);
+ gchar *ip_addr, gchar *netmask,
+ gchar *interface, gchar *gateway, gint32 address_family, gboolean *result, GError **error);
+
+gboolean netconfig_iface_network_state_check_get_privilege();
+
+gboolean netconfig_iface_network_state_check_profile_privilege();
#include "netconfig-iface-network-state-glue.h"
struct NetconfigNetworkState {
GObject parent;
- DBusGConnection *conn;
+ DBusGConnection *connection;
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)
{
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);
+ network_state->connection = g_value_get_boxed(value);
break;
}
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;
}
static void netconfig_network_state_init(NetconfigNetworkState *network_state)
{
- DBG("network_state initialize");
-
- network_state->conn = NULL;
+ network_state->connection = NULL;
network_state->path = g_strdup(PROP_DEFAULT_STR);
}
{
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;
/* property */
g_object_class_install_property(object_class, PROP_NETWORK_STATE_CONN,
- g_param_spec_boxed("conn", "CONNECTION", "DBus connection",
+ g_param_spec_boxed("connection", "CONNECTION", "DBus connection",
DBUS_TYPE_G_CONNECTION,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
-static void __netconfig_pop_3g_alert_syspoppup(void)
+struct netconfig_default_connection {
+ char *profile;
+ char *ifname;
+ char *ipaddress;
+ char *proxy;
+ char *essid;
+};
+
+static struct netconfig_default_connection
+ netconfig_default_connection_info = { NULL, };
+
+static gboolean __netconfig_is_connected(DBusMessageIter *array)
{
- int rv = 0;
- bundle *b = NULL;
- int wifi_ug_state = 0;
+ gboolean is_connected = FALSE;
+
+ while (dbus_message_iter_get_arg_type(array) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry, variant;
+ const char *key = NULL;
+ const char *value = NULL;
+
+ dbus_message_iter_recurse(array, &entry);
+ dbus_message_iter_get_basic(&entry, &key);
+
+ if (g_str_equal(key, "State") != TRUE) {
+ dbus_message_iter_next(array);
+ continue;
+ }
+
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &variant);
+
+ if (dbus_message_iter_get_arg_type(&variant) ==
+ DBUS_TYPE_STRING) {
+ dbus_message_iter_get_basic(&variant, &value);
+
+ if (g_str_equal(value, "ready") == TRUE ||
+ g_str_equal(value, "online") == TRUE)
+ is_connected = TRUE;
+ }
+
+ break;
+ }
+
+ return is_connected;
+}
+
+static char *__netconfig_get_default_profile(void)
+{
+ DBusMessage *message = NULL;
+ DBusMessageIter iter, dict;
+ char *default_profile = NULL;
+
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "GetServices", NULL);
+ if (message == NULL) {
+ ERR("Failed to get profiles");
+ return NULL;
+ }
- vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE, &wifi_ug_state);
- if (wifi_ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND)
+ 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;
+ DBusMessageIter array;
+ const char *object_path = NULL;
+
+ dbus_message_iter_recurse(&dict, &entry);
+ dbus_message_iter_get_basic(&entry, &object_path);
+
+ if (object_path == NULL) {
+ dbus_message_iter_next(&dict);
+ continue;
+ }
+
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &array);
+
+ if (__netconfig_is_connected(&array) == TRUE) {
+ default_profile = g_strdup(object_path);
+ break;
+ }
+
+ dbus_message_iter_next(&dict);
+ }
+
+ dbus_message_unref(message);
+
+ return default_profile;
+}
+
+static void __netconfig_get_default_connection_info(const char *profile)
+{
+ DBusMessage *message = NULL;
+ DBusMessageIter iter, array;
+
+ 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 &&
+ 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(netconfig_default_connection_info.essid != NULL) {
+ g_free(netconfig_default_connection_info.essid);
+ netconfig_default_connection_info.essid = 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);
+
+ if(netconfig_default_connection_info.ifname != NULL) {
+ g_free(netconfig_default_connection_info.ifname);
+ netconfig_default_connection_info.ifname = 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);
+
+ if(netconfig_default_connection_info.ipaddress != NULL) {
+ g_free(netconfig_default_connection_info.ipaddress);
+ netconfig_default_connection_info.ipaddress = 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);
- b = bundle_create();
+ 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);
- bundle_add(b, "_SYSPOPUP_TITLE_", "Cellular connection popup");
- bundle_add(b, "_SYSPOPUP_TYPE_", "notification");
- bundle_add(b, "_SYSPOPUP_CONTENT_", "connected");
+ 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);
- DBG("Launch 3G alert network popup");
- rv = syspopup_launch("net-popup", b);
+ /* TODO: support IPv6
+ netconfig_default_connection_info.ipaddress = g_strdup(value);
+ */
+ }
- bundle_free(b);
+ 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)
+ break;
+
+ dbus_message_iter_get_basic(&iter4, &value);
+ if (value != NULL && (strlen(value) > 0)) {
+ if(netconfig_default_connection_info.proxy != NULL) {
+ g_free(netconfig_default_connection_info.proxy);
+ netconfig_default_connection_info.proxy = NULL;
+ }
+ 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)
+ break;
+
+ dbus_message_iter_get_basic(&iter3, &value);
+ if (g_strcmp0(value, "direct") == 0) {
+ g_free(netconfig_default_connection_info.proxy);
+ netconfig_default_connection_info.proxy = NULL;
+
+ break;
+ }
+ }
+
+ dbus_message_iter_next(&iter1);
+ }
+ }
+
+ dbus_message_iter_next(&array);
+ }
+
+done:
+ if (message != NULL)
+ dbus_message_unref(message);
}
-gboolean netconfig_iface_network_state_update_default_connection_info(
- NetconfigNetworkState *master,
- gchar *connection_type, gchar *connection_state,
- gchar *ip_addr, gchar *proxy_addr, GError **error)
+static void __netconfig_adjust_tcp_buffer_size(void)
{
- char *ip = NULL;
- char *proxy = NULL;
- int wifi_state = 0;
- int previous_network_status = 0;
+ 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) {
+ int telephony_svctype = 0, telephony_pstype = 0;
+
+ vconf_get_int(VCONFKEY_TELEPHONY_SVCTYPE, &telephony_svctype);
+ vconf_get_int(VCONFKEY_TELEPHONY_PSTYPE, &telephony_pstype);
+
+ DBG("Default cellular %d, %d", telephony_svctype, telephony_pstype);
+
+ 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;
+ 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");
+
+ rbuf_size = NET_TCP_BUFFERSIZE_DEFAULT_READ;
+ wbuf_size = NET_TCP_BUFFERSIZE_DEFAULT_WRITE;
+ }
+
+ 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;
- DBG("connection type (%s), connection state(%s), ip_addr(%s), proxy_addr(%s)",
- connection_type, connection_state, ip_addr, proxy_addr);
+ 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 *proxy_addr = netconfig_get_default_proxy();
if (netconfig_emulator_is_emulated() == TRUE)
- return FALSE;
+ return;
- vconf_get_int(VCONFKEY_NETWORK_WIFI_STATE, &wifi_state);
- vconf_get_int(VCONFKEY_NETWORK_STATUS, &previous_network_status);
+ if (profile == NULL)
+ DBG("Reset network state configuration");
+ else
+ DBG("%s: ip(%s) proxy(%s)", profile, ip_addr, proxy_addr);
- if (g_str_equal(connection_state, "idle") == TRUE &&
- previous_network_status != VCONFKEY_NETWORK_OFF) {
- vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_OFF);
+ vconf_get_int(VCONFKEY_NETWORK_STATUS, &old_network_status);
- if (g_str_equal(connection_type, "wifi") == TRUE)
- if (wifi_state != VCONFKEY_NETWORK_WIFI_OFF)
- vconf_set_int(VCONFKEY_NETWORK_WIFI_STATE,
- VCONFKEY_NETWORK_WIFI_NOT_CONNECTED);
+ if (profile == NULL && old_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);
DBG("Successfully clear IP and PROXY up");
- } else if (g_str_equal(connection_state, "ready") == TRUE ||
- g_str_equal(connection_state, "online") == TRUE) {
- ip = vconf_get_str(VCONFKEY_NETWORK_IP);
- proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
+ } 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)
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_WIFI);
+ else if (netconfig_is_cellular_profile(profile) == TRUE)
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_CELLULAR);
+ 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)
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_IP, "");
+ else
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_IP, ip_addr);
+ }
+ g_free(old_ip);
+
+ if (g_strcmp0(old_proxy, proxy_addr) != 0) {
+ if (proxy_addr == NULL)
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_PROXY, "");
+ else
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_PROXY, proxy_addr);
+ }
+ g_free(old_proxy);
+
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 1);
+
+ DBG("Successfully update default network configuration");
+ }
+
+ __netconfig_adjust_tcp_buffer_size();
+}
+
+static gboolean __netconfig_is_tech_state_connected(void)
+{
+ gboolean ret = FALSE;
+ DBusMessage *message;
+ DBusMessageIter iter, array;
+
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "GetTechnologies", NULL);
+
+ if (message == NULL) {
+ DBG("Fail to get technology state");
+ return FALSE;
+ }
- DBG("existed ip (%s), proxy (%s)", ip, proxy);
+ if (!dbus_message_iter_init(message, &iter)) {
+ DBG("Message does not have parameters");
+ goto done;
+ }
- if (g_str_equal(connection_type, "wifi") == TRUE) {
- vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_WIFI);
+ dbus_message_iter_recurse(&iter, &array);
- if (wifi_state != VCONFKEY_NETWORK_WIFI_OFF)
- vconf_set_int(VCONFKEY_NETWORK_WIFI_STATE,
- VCONFKEY_NETWORK_WIFI_CONNECTED);
- } else if (g_str_equal(connection_type, "cellular") == TRUE) {
- vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_CELLULAR);
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRUCT) {
+ DBusMessageIter entry, dict;
+ char *path = NULL;
- if (wifi_state != VCONFKEY_NETWORK_WIFI_OFF)
- vconf_set_int(VCONFKEY_NETWORK_WIFI_STATE,
- VCONFKEY_NETWORK_WIFI_NOT_CONNECTED);
+ dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_get_basic(&entry, &path);
- if (previous_network_status != VCONFKEY_NETWORK_CELLULAR)
- __netconfig_pop_3g_alert_syspoppup();
+ if (path == NULL) {
+ dbus_message_iter_next(&array);
+ continue;
}
- if (ip != NULL && ip_addr != NULL &&
- g_str_equal(ip, ip_addr) != TRUE)
- vconf_set_str(VCONFKEY_NETWORK_IP, ip_addr);
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &dict);
- if (proxy != NULL && proxy_addr != NULL &&
- g_str_equal(proxy, proxy_addr) != TRUE)
- vconf_set_str(VCONFKEY_NETWORK_PROXY, proxy_addr);
+ while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry1, value1;
+ const char *key;
+ dbus_bool_t data;
- vconf_set_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 1);
+ dbus_message_iter_recurse(&dict, &entry1);
+ dbus_message_iter_get_basic(&entry1, &key);
- DBG("Successfully update default network configuration");
+ if (0 == g_strcmp0(key, "Connected")) {
+ 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);
+ DBG("%s [%s: %s]", path, key, data ? "True" : "False");
+
+ if (TRUE == data) {
+ ret = TRUE;
+ goto done;
+ }
+ }
+ }
+ dbus_message_iter_next(&dict);
+ }
+
+ dbus_message_iter_next(&array);
+ }
+
+done:
+ if (message != NULL)
+ dbus_message_unref(message);
+
+ return ret;
+}
+
+static void __netconfig_update_if_service_connected(void)
+{
+ DBusMessage *message;
+ DBusMessageIter iter, array;
+
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "GetServices", NULL);
+
+ if (message == NULL) {
+ DBG("Fail to get services");
+ return;
+ }
+
+ if (!dbus_message_iter_init(message, &iter)) {
+ DBG("Message does not have parameters");
+ goto done;
+ }
+
+ dbus_message_iter_recurse(&iter, &array);
+
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRUCT) {
+ DBusMessageIter entry, dict;
+ char *path = NULL;
+
+ dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_get_basic(&entry, &path);
+
+ if (path == NULL) {
+ dbus_message_iter_next(&array);
+ 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 */
+ dbus_message_iter_next(&array);
+ continue;
+ }
+ /* Process this */
+ } else if (g_str_has_prefix(path,
+ CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX) == TRUE) {
+ /* Process this */
+ } else {
+ dbus_message_iter_next(&array);
+ continue;
+ }
+
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &dict);
+
+ while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry1, value1;
+ const char *key, *sdata;
+
+ dbus_message_iter_recurse(&dict, &entry1);
+ dbus_message_iter_get_basic(&entry1, &key);
+
+ if (0 == g_strcmp0(key, "State")) {
+ dbus_message_iter_next(&entry1);
+ dbus_message_iter_recurse(&entry1, &value1);
+
+ if (dbus_message_iter_get_arg_type(&value1) ==
+ DBUS_TYPE_STRING) {
+ dbus_message_iter_get_basic(&value1, &sdata);
+ DBG("%s [%s: %s]", path, key, sdata);
+
+ if (0 == g_strcmp0(sdata, "online") ||
+ 0 == g_strcmp0(sdata, "ready")) {
+
+ /* Found a connected WiFi / 3G service.
+ * Lets update the default profile info.
+ */
+ netconfig_update_default_profile(path);
+ goto done;
+ }
+ }
+ }
+ dbus_message_iter_next(&dict);
+ }
+
+ dbus_message_iter_next(&array);
+ }
+
+done:
+ if (message != NULL)
+ dbus_message_unref(message);
+}
+
+const char *netconfig_get_default_profile(void)
+{
+ 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_proxy(void)
+{
+ return netconfig_default_connection_info.proxy;
+}
+
+const char *netconfig_wifi_get_connected_essid(const char *default_profile)
+{
+ if (default_profile == NULL)
+ return NULL;
+
+ if (netconfig_is_wifi_profile(default_profile) != TRUE)
+ return NULL;
+
+ if (g_str_equal(default_profile, netconfig_default_connection_info.profile)
+ != TRUE)
+ return NULL;
+
+ return netconfig_default_connection_info.essid;
+}
+
+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) == TRUE)
+ __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.ifname);
+ netconfig_default_connection_info.ifname = NULL;
+
+ g_free(netconfig_default_connection_info.ipaddress);
+ netconfig_default_connection_info.ipaddress = NULL;
+
+ g_free(netconfig_default_connection_info.proxy);
+ netconfig_default_connection_info.proxy = NULL;
+
+ if (netconfig_wifi_state_get_service_state()
+ != NETCONFIG_WIFI_CONNECTED) {
+ g_free(netconfig_default_connection_info.essid);
+ netconfig_default_connection_info.essid = NULL;
+ }
+ }
+
+ if (profile == NULL) {
+ default_profile = __netconfig_get_default_profile();
+ if (default_profile == NULL) {
+ __netconfig_update_default_connection_info();
+ return;
+ }
+ netconfig_default_connection_info.profile = default_profile;
+ } else
+ netconfig_default_connection_info.profile = g_strdup(profile);
+
+ __netconfig_get_default_connection_info(
+ netconfig_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_adjust_tcp_buffer_size();
+}
+
+char *netconfig_network_get_ifname(const char *profile)
+{
+ DBusMessage *message = NULL;
+ DBusMessageIter iter, array;
+ char *ifname = NULL;
+
+ if (profile == NULL)
+ return NULL;
+
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, profile,
+ CONNMAN_SERVICE_INTERFACE, "GetProperties", NULL);
+ if (message == NULL) {
+ ERR("Failed to get service properties");
+ return NULL;
+ }
+
+ 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, iter1, iter2, iter3;
+ const char *key = NULL;
+
+ dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_get_basic(&entry, &key);
+
+ 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) {
+ const char *value;
+
+ 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);
+
+ ifname = g_strdup(value);
+ }
+ dbus_message_iter_next(&iter1);
+ }
+ }
+ dbus_message_iter_next(&array);
+ }
+
+done:
+ if (message != NULL)
+ dbus_message_unref(message);
+
+ return ifname;
+}
+
+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)
+{
+ const char *path = ROUTE_EXEC_PATH;
+ char *const args[] = { "/sbin/route", "add", "-net", ip_addr,
+ "netmask", netmask, "dev", interface, NULL };
+ char *const envs[] = { NULL };
+ const char* buf = NULL;
+ char* ch = NULL;
+ int prefix_len = 0;
+ int pos = 0;
+
+ DBG("ip_addr(%s), netmask(%s), interface(%s), gateway(%s)", ip_addr, netmask, interface, gateway);
+
+ switch(address_family) {
+ case AF_INET:
+ if (ip_addr == NULL || netmask == NULL || interface == NULL) {
+ ERR("Invalid parameter");
+ netconfig_error_invalid_parameter(error);
+ *result = FALSE;
+ return FALSE;
+ }
+ if (netconfig_execute_file(path, args, envs) < 0) {
+ DBG("Failed to add a new route");
+ netconfig_error_permission_denied(error);
+ *result = FALSE;
+ return FALSE;
+ }
+ break;
+ case AF_INET6:
+ if (ip_addr == NULL || interface == NULL || gateway == NULL) {
+ ERR("Invalid parameter");
+ netconfig_error_invalid_parameter(error);
+ *result = FALSE;
+ return FALSE;
+ }
+
+ buf = ip_addr;
+ ch = strchr(buf, '/');
+ pos = ch - buf + 1;
+ if (ch) {
+ prefix_len = atoi(ch + 1);
+ ip_addr[pos-1] = '\0';
+ } else {
+ prefix_len = 128;
+ }
+
+ 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;
+ return FALSE;
+ }
+ break;
+ default:
+ DBG("Unknown Address Family");
+ netconfig_error_invalid_parameter(error);
+ *result = FALSE;
+ return FALSE;
}
+ DBG("Successfully added a new route");
+ *result = TRUE;
return TRUE;
}
-gpointer netconfig_network_state_create_and_init(DBusGConnection *conn)
+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)
{
- GObject *object;
+ const char *path = ROUTE_EXEC_PATH;
+ char *const args[] = { "/sbin/route", "del", "-net", ip_addr,
+ "netmask", netmask, "dev", interface, NULL };
+ char *const envs[] = { NULL };
+ const char* buf = NULL;
+ char* ch = NULL;
+ int prefix_len = 0;
+ int pos = 0;
- g_return_val_if_fail(conn != NULL, NULL);
+ DBG("ip_addr(%s), netmask(%s), interface(%s), gateway(%s)", ip_addr, netmask, interface, gateway);
- object = g_object_new(NETCONFIG_TYPE_NETWORK_STATE, "conn", conn, "path",
- NETCONFIG_NETWORK_STATE_PATH, NULL);
+ switch(address_family) {
+ case AF_INET:
+ if (ip_addr == NULL || netmask == NULL || interface == NULL) {
+ DBG("Invalid parameter!");
+ netconfig_error_invalid_parameter(error);
+ *result = FALSE;
+ return FALSE;
+ }
+ if (netconfig_execute_file(path, args, envs) < 0) {
+ DBG("Failed to remove the route");
+ netconfig_error_permission_denied(error);
+ *result = FALSE;
+ return FALSE;
+ }
+ break;
+ case AF_INET6:
+ if (ip_addr == NULL || interface == NULL || gateway == NULL) {
+ DBG("Invalid parameter!");
+ netconfig_error_invalid_parameter(error);
+ *result = FALSE;
+ return FALSE;
+ }
- INFO("create network_state(%p)", object);
+ buf = ip_addr;
+ ch = strchr(buf, '/');
+ pos = ch - buf + 1;
+ if (ch) {
+ prefix_len = atoi(ch + 1);
+ ip_addr[pos-1] = '\0';
+ } else {
+ prefix_len = 128;
+ }
- dbus_g_connection_register_g_object(conn, NETCONFIG_NETWORK_STATE_PATH, object);
+ 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;
+ return FALSE;
+ }
+ break;
+ default:
+ DBG("Unknown Address Family");
+ netconfig_error_invalid_parameter(error);
+ *result = FALSE;
+ return FALSE;
+ }
+
+ DBG("Successfully removed the route");
+ *result = TRUE;
+
+ return TRUE;
+}
+
+gpointer netconfig_network_state_create_and_init(DBusGConnection *connection)
+{
+ GObject *object;
- INFO("network_state(%p) register DBus path(%s)", object, NETCONFIG_NETWORK_STATE_PATH);
+ g_return_val_if_fail(connection != NULL, NULL);
+
+ object = g_object_new(NETCONFIG_TYPE_NETWORK_STATE, "connection",
+ connection, "path", NETCONFIG_NETWORK_STATE_PATH, NULL);
+
+ dbus_g_connection_register_g_object(connection,
+ NETCONFIG_NETWORK_STATE_PATH, object);
return object;
}
+
+gboolean netconfig_iface_network_state_check_get_privilege()
+{
+ return TRUE;
+}
+
+gboolean netconfig_iface_network_state_check_profile_privilege()
+{
+ return TRUE;
+}
*
*/
+#include <stdio.h>
#include <vconf.h>
#include <vconf-keys.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"
#define NETCONFIG_NETWORK_STATISTICS_PATH "/net/netconfig/network_statistics"
-#define NETCONFIG_PROCDEVFILE "/proc/net/dev"
+#define NETCONFIG_PROCDEV "/proc/net/dev"
#define PROP_DEFAULT FALSE
#define PROP_DEFAULT_STR NULL
struct NetconfigNetworkStatistics {
GObject parent;
- DBusGConnection *conn;
+ DBusGConnection *connection;
gchar *path;
};
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);
+ 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);
+ network_statistics->connection = g_value_get_boxed(value);
break;
}
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;
}
}
}
-static void netconfig_network_statistics_init(NetconfigNetworkStatistics *network_statistics)
+static void netconfig_network_statistics_init(
+ NetconfigNetworkStatistics *network_statistics)
{
- DBG("network_statistics initialize");
-
- network_statistics->conn = NULL;
+ network_statistics->connection = NULL;
network_statistics->path = g_strdup(PROP_DEFAULT_STR);
}
-static void netconfig_network_statistics_class_init(NetconfigNetworkStatisticsClass *klass)
+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;
+ 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,
/* property */
g_object_class_install_property(object_class, PROP_NETWORK_STATISTICS_CONN,
- g_param_spec_boxed("conn", "CONNECTION", "DBus connection",
+ g_param_spec_boxed("connection", "CONNECTION", "DBus connection",
DBUS_TYPE_G_CONNECTION,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
-static gboolean __netconfig_wifi_get_bytes_statistics(guint64 *tx, guint64 *rx)
+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_ifname = buf;
while (*p_ifname == ' ') p_ifname++;
p_entry = strchr(p_ifname, ':');
+ if(p_entry == NULL)
+ goto endline;
*p_entry++ = '\0';
- if (g_str_equal(p_ifname, ifname) != TRUE)
+ if (g_str_equal(p_ifname, WIFI_IFNAME) != TRUE)
continue;
/* read interface statistics */
sscanf(p_entry,
"%llu %llu %lu %lu %lu %lu %lu %lu "
"%llu %llu %lu %lu %lu %lu %lu %lu",
- rx, /* rx bytes */
+ rx, /* rx bytes */
&llval, /* rx packet */
&lval, /* rx errors */
&lval, /* rx dropped */
&lval, /* rx compressed */
&lval, /* rx multicast */
- tx, /* tx bytes */
+ tx, /* tx bytes */
&llval, /* tx packet */
&lval, /* tx errors */
&lval, /* tx dropped */
&lval, /* tx fifo errors */
&lval, /* collisions */
&lval, /* tx carrier errors */
- &lval /* tx compressed */
+ &lval /* tx compressed */
);
ret = TRUE;
return ret;
}
-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_tx_bytes(
+ NetconfigNetworkStatistics *network_statistics,
+ guint64 *total_bytes, GError **error)
{
guint64 tx = 0, rx = 0;
guint64 tx_bytes = 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;
+ if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
+ *total_bytes = tx + tx_bytes;
else
- *total_bytes = (guint64)tx_bytes;
+ *total_bytes = tx_bytes;
return TRUE;
}
-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_total_rx_bytes(
+ NetconfigNetworkStatistics *network_statistics,
+ guint64 *total_bytes, GError **error)
{
guint64 tx = 0, rx = 0;
guint64 rx_bytes = 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;
+ if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
+ *total_bytes = rx + rx_bytes;
else
- *total_bytes = (guint64)rx_bytes;
+ *total_bytes = rx_bytes;
return TRUE;
}
-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_tx_bytes(
+ NetconfigNetworkStatistics *network_statistics,
+ guint64 *last_bytes, GError **error)
{
guint64 tx = 0, rx = 0;
guint64 tx_bytes = 0;
tx_bytes = (guint64)val;
if (netconfig_wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED) {
- *last_bytes = (guint64)tx_bytes;
+ *last_bytes = tx_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;
+ if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
+ *last_bytes = tx < tx_bytes ? 0 : tx - tx_bytes;
else
- *last_bytes = (guint64)tx_bytes;
+ *last_bytes = tx_bytes;
return TRUE;
}
-gboolean netconfig_iface_network_statistics_get_wifi_last_rx_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)
{
guint64 tx = 0, rx = 0;
guint64 rx_bytes = 0;
rx_bytes = (guint64)val;
if (netconfig_wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED) {
- *last_bytes = (guint64)rx_bytes;
+ *last_bytes = rx_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;
+ if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
+ *last_bytes = rx < rx_bytes ? 0 : rx - rx_bytes;
else
- *last_bytes = (guint64)rx_bytes;
+ *last_bytes = rx_bytes;
return TRUE;
}
-gboolean netconfig_iface_network_statistics_reset_cellular_total_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+gboolean netconfig_iface_network_statistics_reset_cellular_total_tx_bytes(
+ NetconfigNetworkStatistics *network_statistics, GError **error)
{
- vconf_set_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT, 0);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT, 0);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_reset_cellular_total_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+gboolean netconfig_iface_network_statistics_reset_cellular_total_rx_bytes(
+ NetconfigNetworkStatistics *network_statistics, GError **error)
{
- vconf_set_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV, 0);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV, 0);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_reset_cellular_last_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+gboolean netconfig_iface_network_statistics_reset_cellular_last_tx_bytes(
+ NetconfigNetworkStatistics *network_statistics, GError **error)
{
- vconf_set_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT, 0);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT, 0);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_reset_cellular_last_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+gboolean netconfig_iface_network_statistics_reset_cellular_last_rx_bytes(
+ NetconfigNetworkStatistics *network_statistics, GError **error)
{
- vconf_set_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV, 0);
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV, 0);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_reset_wifi_total_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+gboolean netconfig_iface_network_statistics_reset_wifi_total_tx_bytes(
+ NetconfigNetworkStatistics *network_statistics, GError **error)
{
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);
+ if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
+ 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);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_reset_wifi_total_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+gboolean netconfig_iface_network_statistics_reset_wifi_total_rx_bytes(
+ NetconfigNetworkStatistics *network_statistics, GError **error)
{
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);
+ if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
+ 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);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_reset_wifi_last_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+gboolean netconfig_iface_network_statistics_reset_wifi_last_tx_bytes(
+ NetconfigNetworkStatistics *network_statistics, GError **error)
{
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);
return TRUE;
}
- if (__netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, (int)tx);
+ if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
+ 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);
return TRUE;
}
-gboolean netconfig_iface_network_statistics_reset_wifi_last_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+gboolean netconfig_iface_network_statistics_reset_wifi_last_rx_bytes(
+ NetconfigNetworkStatistics *network_statistics, GError **error)
{
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);
return TRUE;
}
- if (__netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
- vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, (int)rx);
+ if (netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
+ 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);
return TRUE;
}
guint64 total_tx = 0, total_rx = 0;
int val = 0;
- if (__netconfig_wifi_get_bytes_statistics(&cur_tx, &cur_rx) != TRUE)
+ if (netconfig_wifi_get_bytes_statistics(&cur_tx, &cur_rx) != TRUE)
return;
vconf_get_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_SNT, &val);
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;
}
- if (__netconfig_wifi_get_bytes_statistics(&tx, &rx) != TRUE)
+ if (netconfig_wifi_get_bytes_statistics(&tx, &rx) != TRUE)
return;
if (state == NETCONFIG_WIFI_CONNECTED) {
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)
+gpointer netconfig_network_statistics_create_and_init(
+ DBusGConnection *connection)
{
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);
+ g_return_val_if_fail(connection != NULL, NULL);
- dbus_g_connection_register_g_object(conn, NETCONFIG_NETWORK_STATISTICS_PATH, object);
+ object = g_object_new(NETCONFIG_TYPE_NETWORK_STATISTICS, "connection",
+ connection, "path", NETCONFIG_NETWORK_STATISTICS_PATH, NULL);
- INFO("network_statistics(%p) register DBus path(%s)", object, NETCONFIG_NETWORK_STATISTICS_PATH);
+ dbus_g_connection_register_g_object(connection,
+ NETCONFIG_NETWORK_STATISTICS_PATH, object);
netconfig_wifi_statistics_update_state(NETCONFIG_WIFI_IDLE, NULL);
netconfig_wifi_state_notifier_register(&state_notifier);
#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 "mdm-private.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 "neterror.h"
-#define SIGNAL_SCAN_DONE "ScanDone"
-#define SIGNAL_BSS_ADDED "BSSAdded"
+#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_SCAN_COMPLETED "ScanCompleted"
+#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'"
+#define CONNMAN_TECHNOLOGY_SIGNAL_FILTER \
+ "type='signal',interface='"CONNMAN_TECHNOLOGY_INTERFACE"'"
+#define CONNMAN_SERVICE_STATE_SIGNAL_FILTER \
+ "type='signal',interface='"CONNMAN_SERVICE_INTERFACE \
+ "',member='PropertyChanged',arg0='State'"
-static DBusConnection *signal_connection = NULL;
+#define CONNMAN_SERVICE_PROXY_SIGNAL_FILTER \
+ "type='signal',interface='"CONNMAN_SERVICE_INTERFACE \
+ "',member='PropertyChanged',arg0='Proxy'"
-static int __netconfig_get_state(DBusMessage *msg, char *state)
-{
- char *key_name = NULL;
- char *svc_state = NULL;
- DBusMessageIter iter, sub_iter;
- int Error = NETCONFIG_ERROR_INTERNAL;
-
- /* Get state */
- dbus_message_iter_init(msg, &iter);
- int ArgType = dbus_message_iter_get_arg_type(&iter);
-
- if (ArgType != DBUS_TYPE_STRING)
- goto done;
-
- dbus_message_iter_get_basic(&iter, &key_name);
- if (g_str_equal(key_name, "State") != TRUE)
- goto done;
-
- dbus_message_iter_next(&iter);
- ArgType = dbus_message_iter_get_arg_type(&iter);
- if (ArgType != DBUS_TYPE_VARIANT)
- goto done;
-
- dbus_message_iter_recurse(&iter, &sub_iter);
- ArgType = dbus_message_iter_get_arg_type(&sub_iter);
- if (ArgType != DBUS_TYPE_STRING)
- goto done;
-
- dbus_message_iter_get_basic(&sub_iter, &svc_state);
- snprintf(state, strlen(svc_state) + 1, "%s", svc_state);
- Error = NETCONFIG_NO_ERROR;
-
-done:
- return Error;
-}
+#define SUPPLICANT_INTERFACE_REMOVED_SIGNAL_FILTER \
+ "type='signal',interface='"SUPPLICANT_INTERFACE \
+ "',member='"SIGNAL_INTERFACE_REMOVED"'"
-static char *__netconfig_get_property(DBusMessage * msg, char **property)
-{
- DBusMessageIter args, variant;
- char *sigvalue = NULL;
+#define SUPPLICANT_INTERFACE_PROPERTIESCHANGED_SIGNAL_FILTER \
+ "type='signal',interface='"SUPPLICANT_IFACE_INTERFACE \
+ "',member='"SIGNAL_PROPERTIES_CHANGED"'"
- /** 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, &sigvalue);
- dbus_message_iter_next(&args);
- dbus_message_iter_recurse(&args, &variant);
- if (dbus_message_iter_get_arg_type(&variant) == DBUS_TYPE_STRING)
- dbus_message_iter_get_basic(&variant, property);
- else
- *property = NULL;
- }
+#define SUPPLICANT_INTERFACE_BSSADDED_SIGNAL_FILTER \
+ "type='signal',interface='"SUPPLICANT_IFACE_INTERFACE \
+ "',member='"SIGNAL_BSS_ADDED"'"
- return sigvalue;
-}
+#define SUPPLICANT_INTERFACE_SCANDONE_SIGNAL_FILTER \
+ "type='signal',interface='"SUPPLICANT_IFACE_INTERFACE \
+ "',member='"SIGNAL_SCAN_DONE"'"
-static void __netconfig_wifi_technology_state_signal_handler(
- const char *sigvalue, const char *property)
-{
- static char previous_technology_state[DBUS_STATE_MAX_BUFLEN] = {0};
+#define SUPPLICANT_INTERFACE_DRIVERHANGED_SIGNAL_FILTER \
+ "type='signal',interface='"SUPPLICANT_IFACE_INTERFACE \
+ "',member='"SIGNAL_PROPERTIES_DRIVER_HANGED"'"
- if (sigvalue == NULL || property == NULL)
- return;
-
- if (g_str_equal(sigvalue, "State") != TRUE)
- return;
+#define SUPPLICANT_INTERFACE_SESSIONOVERLAPPED_SIGNAL_FILTER \
+ "type='signal',interface='"SUPPLICANT_IFACE_INTERFACE \
+ "',member='"SIGNAL_PROPERTIES_SESSION_OVERLAPPED"'"
- if (g_str_equal(property, "unknown") == TRUE)
- return;
+#define CONNMAN_SERVICE_NAMECHANGED_SIGNAL_FILTER \
+ "type='signal',sender='"DBUS_SERVICE_DBUS \
+ "',interface='"DBUS_INTERFACE_DBUS \
+ "',member='NameOwnerChanged',path='/org/freedesktop/DBus'" \
+ ",arg0='"CONNMAN_SERVICE"'"
- if (g_str_equal(previous_technology_state, property) == TRUE)
- return;
- g_strlcpy(previous_technology_state, property, sizeof(previous_technology_state));
+static DBusConnection *signal_connection = NULL;
- INFO("Technology state value is %s, property %s", sigvalue, property);
+static void __netconfig_technology_signal_handler(DBusMessage *msg)
+{
+ char *key = NULL;
+ const char *tech = NULL;
+ dbus_bool_t value = FALSE;
- if (g_str_equal(property, "offline") == TRUE) {
- gchar *wifi_tech_state = NULL;
+ if (netconfig_dbus_get_basic_params_string(msg,
+ &key, DBUS_TYPE_BOOLEAN, &value) != TRUE)
+ return;
- wifi_tech_state = netconfig_wifi_get_technology_state();
+ tech = dbus_message_get_path(msg);
+ if (key == NULL || tech == NULL)
+ return;
- if (wifi_tech_state == NULL)
- netconfig_wifi_update_power_state(FALSE);
- else {
- if (g_str_equal(wifi_tech_state, "EnabledTechnologies") != TRUE)
+ if (g_str_has_prefix(tech, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == TRUE) {
+ if (g_strcmp0(key, "Powered") == 0) {
+ /* Power state */
+ if (value == TRUE) {
+ netconfig_wifi_update_power_state(TRUE);
+ } else {
netconfig_wifi_update_power_state(FALSE);
-
- g_free(wifi_tech_state);
+ }
+ } 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 */
+ netconfig_wifi_state_set_technology_state(
+ NETCONFIG_WIFI_TECH_TETHERED);
}
- } else if (g_str_equal(property, "enabled") == TRUE)
- netconfig_wifi_update_power_state(TRUE);
+ } else if (g_str_has_prefix(tech,
+ CONNMAN_CELLULAR_TECHNOLOGY_PREFIX) == TRUE) {
+ /* Cellular technology state */
+ }
}
-static void netconfig_wifi_set_essid(const char *active_profile)
+static void __netconfig_service_signal_handler(DBusMessage *msg)
{
- int err;
- char *essid_name = NULL;
- DBusMessage *message = NULL;
- int MessageType = 0;
+ char *sigvalue = NULL;
+ char *property = NULL;
+ char *service_profile = NULL;
+ DBusMessageIter args, variant, iter1, iter2, iter3, iter4;
+ const char *value = NULL;
- if (active_profile == NULL) {
- ERR("Can't get active_profile");
+ service_profile = (char *)dbus_message_get_path(msg);
+ if (service_profile == NULL)
return;
- }
-
- message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, active_profile,
- CONNMAN_SERVICE_INTERFACE, "GetProperties", NULL);
- if (message == NULL) {
- ERR("Failed to get service properties");
+ dbus_message_iter_init(msg, &args);
+ dbus_message_iter_get_basic(&args, &sigvalue);
+ if (sigvalue == NULL)
return;
- }
- MessageType = dbus_message_get_type(message);
+ 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 (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
- const char *ptr = dbus_message_get_error_name(message);
- ERR("Error!!! Error message received [%s]", ptr);
- goto done;
- }
+ DBG("[%s] %s", property, service_profile);
+ if (netconfig_is_wifi_profile(service_profile) == TRUE) {
+ int wifi_state = 0;
- essid_name = netconfig_wifi_get_connected_service_name(message);
+ vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
+ if (wifi_state == VCONFKEY_WIFI_OFF)
+ return;
- if (essid_name == NULL) {
- ERR("Wi-Fi is not connected");
- goto done;
- }
+ if (g_str_equal(property, "ready") == TRUE ||
+ g_str_equal(property, "online") == TRUE) {
+ if (wifi_state >= VCONFKEY_WIFI_CONNECTED)
+ return;
- err = vconf_set_str(VCONFKEY_WIFI_CONNECTED_AP_NAME, essid_name);
- if (err != 0) {
- ERR("Can't set essid [%d]", err);
- }
+ netconfig_update_default_profile(service_profile);
- g_free(essid_name);
- essid_name = NULL;
+ netconfig_wifi_state_set_service_state(NETCONFIG_WIFI_CONNECTED);
-done:
- dbus_message_unref(message);
-}
+ netconfig_check_allowed_ap(service_profile);
+
+ } else if (g_str_equal(property, "failure") == TRUE ||
+ g_str_equal(property, "disconnect") == TRUE ||
+ g_str_equal(property, "idle") == TRUE) {
+ if (netconfig_get_default_profile() == NULL ||
+ netconfig_is_wifi_profile(netconfig_get_default_profile())
+ != TRUE) {
+ if (g_str_equal(property, "failure") == TRUE)
+ netconfig_wifi_state_set_service_state(
+ NETCONFIG_WIFI_FAILURE);
+ else
+ netconfig_wifi_state_set_service_state(
+ NETCONFIG_WIFI_IDLE);
+ return;
+ }
+
+ if (g_str_equal(service_profile, netconfig_get_default_profile())
+ != TRUE)
+ return;
+
+ netconfig_update_default_profile(NULL);
+
+ if (g_str_equal(property, "failure") == TRUE)
+ 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) {
+ if (netconfig_get_default_profile() == NULL ||
+ netconfig_is_wifi_profile(netconfig_get_default_profile()) != TRUE) {
+ if (g_str_equal(property, "association") == TRUE)
+ netconfig_wifi_state_set_service_state(
+ NETCONFIG_WIFI_ASSOCIATION);
+ else
+ netconfig_wifi_state_set_service_state(
+ NETCONFIG_WIFI_CONFIGURATION);
+ return;
+ }
+
+ if (g_str_equal(service_profile, netconfig_get_default_profile()) != TRUE)
+ return;
+
+ netconfig_update_default_profile(NULL);
+
+ if (g_str_equal(property, "association") == TRUE)
+ netconfig_wifi_state_set_service_state(
+ NETCONFIG_WIFI_ASSOCIATION);
+ else
+ netconfig_wifi_state_set_service_state(
+ NETCONFIG_WIFI_CONFIGURATION);
-static void netconfig_wifi_unset_essid(void)
-{
- vconf_set_str(VCONFKEY_WIFI_CONNECTED_AP_NAME, "");
-}
+ }
+ } else {
+ if (g_str_equal(property, "ready") == TRUE ||
+ g_str_equal(property, "online") == TRUE) {
+ if (netconfig_get_default_profile() == NULL)
+ netconfig_update_default_profile(service_profile);
+
+ if (netconfig_is_cellular_profile(service_profile) == TRUE)
+ netconfig_cellular_state_set_service_state(NETCONFIG_CELLULAR_ONLINE);
+ } else if (g_str_equal(property, "failure") == TRUE ||
+ g_str_equal(property, "disconnect") == TRUE ||
+ g_str_equal(property, "idle") == TRUE) {
+ if (netconfig_get_default_profile() == NULL)
+ return;
+
+ if (netconfig_is_cellular_profile(service_profile) == TRUE)
+ netconfig_cellular_state_set_service_state(NETCONFIG_CELLULAR_IDLE);
+
+ if (g_str_equal(service_profile, netconfig_get_default_profile()) != TRUE)
+ return;
+
+ netconfig_update_default_profile(NULL);
+ } else if (g_str_equal(property, "association") == TRUE ||
+ g_str_equal(property, "configuration") == TRUE) {
+ if (netconfig_get_default_profile() == NULL)
+ return;
+
+ if (netconfig_is_cellular_profile(service_profile) == TRUE)
+ netconfig_cellular_state_set_service_state(NETCONFIG_CELLULAR_IDLE);
+
+ if (g_str_equal(service_profile, netconfig_get_default_profile()) != TRUE)
+ return;
+
+ netconfig_update_default_profile(NULL);
+ }
+ }
+ } else if (g_str_equal(sigvalue, "Proxy") == TRUE) {
+ dbus_message_iter_next(&args);
+ dbus_message_iter_recurse(&args, &variant);
-static void __netconfig_wifi_service_state_signal_handler(DBusMessage *msg, const char *profile)
-{
- char state[DBUS_STATE_MAX_BUFLEN] = {0};
- static char current_profile[DBUS_PATH_MAX_BUFLEN] = {0};
+ if (netconfig_is_wifi_profile(service_profile) != TRUE ||
+ g_strcmp0(service_profile, netconfig_get_default_profile()) != 0)
+ return;
- if (profile == NULL)
- return;
+ if (dbus_message_iter_get_arg_type(&variant) != DBUS_TYPE_ARRAY)
+ return;
- if (__netconfig_get_state(msg, state) == NETCONFIG_NO_ERROR) {
- int wifi_state = 0;
+ 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, &property);
- DBG("Signaled profile [%s] ==> state %s", profile, state);
+ if (g_strcmp0(property, "Servers") == 0) {
+ dbus_message_iter_next(&iter2);
+ dbus_message_iter_recurse(&iter2, &iter3);
- vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
- DBG("Current Wi-Fi state: %d", wifi_state);
+ if (dbus_message_iter_get_arg_type(&iter3) !=
+ DBUS_TYPE_ARRAY)
+ return;
- if (g_str_equal(state, "ready") == TRUE ||
- g_str_equal(state, "online") == TRUE) {
- if (wifi_state > VCONFKEY_WIFI_OFF && wifi_state != VCONFKEY_WIFI_CONNECTED) {
+ dbus_message_iter_recurse(&iter3, &iter4);
+ if (dbus_message_iter_get_arg_type(&iter4) !=
+ DBUS_TYPE_STRING)
+ return;
- INFO("Wifi connected");
+ dbus_message_iter_get_basic(&iter4, &value);
+ DBG("Proxy - [%s]", value);
- if ((vconf_set_int(VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_CONNECTED)) < 0)
- ERR("Error!!! vconf_set_int failed");
+ vconf_set_str(VCONFKEY_NETWORK_PROXY, value);
+ break;
+ } else if (g_strcmp0(property, "Method") == 0) {
+ dbus_message_iter_next(&iter2);
+ dbus_message_iter_recurse(&iter2, &iter3);
- netconfig_wifi_state_set_service_state(NETCONFIG_WIFI_CONNECTED);
+ if (dbus_message_iter_get_arg_type(&iter3) !=
+ DBUS_TYPE_STRING)
+ return;
- netconfig_wifi_set_essid(profile);
+ dbus_message_iter_get_basic(&iter3, &value);
+ DBG("Method - [%s]", value);
- netconfig_wifi_indicator_start();
+ if (g_strcmp0(value, "direct") == 0)
+ vconf_set_str(VCONFKEY_NETWORK_PROXY, "");
- g_strlcpy(current_profile, profile, sizeof(current_profile));
+ break;
}
- } else if (g_str_equal(state, "failure") == TRUE ||
- g_str_equal(state, "disconnect") == TRUE ||
- g_str_equal(state, "idle") == TRUE) {
- if ((g_str_equal(profile, current_profile)) != TRUE)
- return;
-
- INFO("Wifi disconnected: %s", profile);
-
- if (wifi_state > VCONFKEY_WIFI_UNCONNECTED)
- if ((vconf_set_int (VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_UNCONNECTED)) < 0)
- ERR("Error!!! vconf_set_int failed");
+ dbus_message_iter_next(&iter1);
+ }
+ }
+}
- netconfig_wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
+static void __netconfig_dbus_name_changed_signal_handler(DBusMessage *msg)
+{
+ char *name, *old, *new;
- netconfig_wifi_unset_essid();
+ dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_STRING, &old, DBUS_TYPE_STRING, &new);
- netconfig_wifi_indicator_stop();
+ if (g_strcmp0(name, CONNMAN_SERVICE) == 0 && *new == '\0') {
+ DBG("ConnMan destroyed: name %s, old %s, new %s", name, old, new);
- memset(current_profile, 0, sizeof(current_profile));
- } else if (g_str_equal(state, "association") == TRUE ||
- g_str_equal(state, "configuration") == TRUE) {
- netconfig_wifi_state_set_service_state(NETCONFIG_WIFI_CONNECTING);
- }
- } else
- DBG("Signaled profile [%s] has error to get its state", profile);
+ netconfig_agent_register();
+ }
}
static DBusHandlerResult __netconfig_signal_filter_handler(
DBusConnection *conn, DBusMessage *msg, void *user_data)
{
- char *sigvalue = NULL;
-
if (msg == NULL) {
- INFO("Invalid Message. Ignore");
-
- /* We have handled this message, don't pass it on */
+ DBG("Invalid Message. Ignore");
return DBUS_HANDLER_RESULT_HANDLED;
}
- if (dbus_message_is_signal(msg, CONNMAN_MANAGER_INTERFACE,
+ if (dbus_message_is_signal(msg, CONNMAN_TECHNOLOGY_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_MANAGER_INTERFACE,
- CONNMAN_SIGNAL_SCAN_COMPLETED)) {
- DBusMessageIter args;
- dbus_bool_t val = FALSE;
- int qs_enable = 0;
- int wifi_state = 0;
- int ug_state = 0;
-
- if (vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, &qs_enable) < 0) {
- DBG("failed to get vconf");
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- if (qs_enable) {
- if (vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state) < 0) {
- DBG("failed to get vconf");
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- if (wifi_state == VCONFKEY_WIFI_CONNECTED) {
- DBG("Wi-Fi is Connected");
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- if (vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE, &ug_state) < 0) {
- DBG("failed to get vconf");
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- if (ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND) {
- DBG("Wi-Fi UG is running on foreground");
- return DBUS_HANDLER_RESULT_HANDLED;
- }
+ __netconfig_technology_signal_handler(msg);
- if (!dbus_message_iter_init(msg, &args)) {
- DBG("Message does not have parameters");
- } else if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_BOOLEAN) {
- DBG("Argument is not boolean");
- } else {
- dbus_message_iter_get_basic(&args, &val);
- if (val)
- netconfig_wifi_check_network_notification();
- }
- }
return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_signal(msg, CONNMAN_TECHNOLOGY_INTERFACE,
+ } else if (dbus_message_is_signal(msg, CONNMAN_SERVICE_INTERFACE,
CONNMAN_SIGNAL_PROPERTY_CHANGED)) {
- char *property = NULL;
- char *technology_path = NULL;
-
- sigvalue = __netconfig_get_property(msg, &property);
- if (sigvalue == NULL)
- return DBUS_HANDLER_RESULT_HANDLED;
+ __netconfig_service_signal_handler(msg);
- technology_path = (char *)dbus_message_get_path(msg);
- INFO("technology object path: %s", technology_path);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ } else if (dbus_message_is_signal(msg, SUPPLICANT_INTERFACE,
+ SIGNAL_INTERFACE_REMOVED)) {
+ if (netconfig_wifi_is_wps_enabled() == TRUE)
+ netconfig_wifi_wps_signal_scanaborted();
- if (g_str_has_prefix(technology_path,
- CONNMAN_WIFI_TECHNOLOGY_PREFIX) == TRUE) {
- __netconfig_wifi_technology_state_signal_handler(
- (const char *)sigvalue, (const char *)property);
- return DBUS_HANDLER_RESULT_HANDLED;
+ 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,
+ "Scanning", &property) == TRUE) {
+ if (scanning == TRUE)
+ netconfig_wifi_set_scanning(TRUE);
}
- /* We have handled this message, don't pass it on */
return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_signal(msg, CONNMAN_SERVICE_INTERFACE,
- CONNMAN_SIGNAL_PROPERTY_CHANGED)) {
- sigvalue = netconfig_dbus_get_string(msg);
-
- if (sigvalue == NULL)
- 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);
+ else
+ netconfig_wifi_set_bss_found(TRUE);
- if (g_str_equal(sigvalue, "State") == TRUE) {
- char *service_profile = NULL;
+ return DBUS_HANDLER_RESULT_HANDLED;
+ } else if (dbus_message_is_signal(msg, SUPPLICANT_INTERFACE ".Interface",
+ SIGNAL_SCAN_DONE)) {
+ netconfig_wifi_set_scanning(FALSE);
- service_profile = (char *)dbus_message_get_path(msg);
- INFO("service profile: %s", service_profile);
+ 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_HANDLER_RESULT_HANDLED;
+ }
- if (g_str_has_prefix(service_profile,
- CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE) {
- __netconfig_wifi_service_state_signal_handler(
- msg, service_profile);
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
+ 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();
}
+
+ 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);
+ SIGNAL_PROPERTIES_DRIVER_HANGED)) {
+ ERR("Critical. Wi-Fi firmware crashed");
+
+ netconfig_wifi_recover_firmware();
+
+ return DBUS_HANDLER_RESULT_HANDLED;
} else if (dbus_message_is_signal(msg, SUPPLICANT_INTERFACE ".Interface",
- SIGNAL_SCAN_DONE))
- netconfig_wifi_notify_ssid_scan_done(msg);
+ SIGNAL_PROPERTIES_SESSION_OVERLAPPED)) {
+ ERR("WPS PBC SESSION OVERLAPPED");
+#if !defined TIZEN_WEARABLE
+ netconfig_send_message_to_net_popup("WPS Error",
+ "wps session overlapped", "popup", NULL);
+#endif
+ return DBUS_HANDLER_RESULT_HANDLED;
+ } else if (dbus_message_is_signal(msg, DBUS_INTERFACE_DBUS,
+ "NameOwnerChanged")) {
+ __netconfig_dbus_name_changed_signal_handler(msg);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
void netconfig_register_signal(void)
{
- DBusConnection *conn = NULL;
DBusError err;
-
- DBG("Register DBus signal filters");
+ DBusConnection *conn = NULL;
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);
+ ERR("Failed to get system bus [%s]", err.message);
dbus_error_free(&err);
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_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);
+ ERR("Match error (%s)", err.message);
dbus_error_free(&err);
return;
}
- dbus_bus_add_match(conn, CONNMAN_TECHNOLOGY_SIGNAL_FILTER, &err);
+ dbus_bus_add_match(conn, CONNMAN_SERVICE_STATE_SIGNAL_FILTER, &err);
dbus_connection_flush(conn);
if (dbus_error_is_set(&err)) {
- ERR("Error! Match Error (%s)", err.message);
+ ERR("Match error (%s)", err.message);
dbus_error_free(&err);
return;
}
- dbus_bus_add_match(conn, CONNMAN_SERVICE_SIGNAL_FILTER, &err);
+ dbus_bus_add_match(conn, CONNMAN_SERVICE_PROXY_SIGNAL_FILTER, &err);
dbus_connection_flush(conn);
if (dbus_error_is_set(&err)) {
- ERR("Error! Match Error (%s)", err.message);
+ ERR("Match error (%s)", err.message);
dbus_error_free(&err);
return;
}
- dbus_bus_add_match(conn, SUPPLICANT_INTERFACE_SIGNAL_FILTER, &err);
+ dbus_bus_add_match(conn, SUPPLICANT_INTERFACE_REMOVED_SIGNAL_FILTER, &err);
dbus_connection_flush(conn);
if (dbus_error_is_set(&err)) {
- ERR("Error! Match Error (%s)", err.message);
+ ERR("Match error (%s)", err.message);
+ dbus_error_free(&err);
+ return;
+ }
+
+ dbus_bus_add_match(conn,
+ SUPPLICANT_INTERFACE_PROPERTIESCHANGED_SIGNAL_FILTER, &err);
+ dbus_connection_flush(conn);
+ if (dbus_error_is_set(&err)) {
+ ERR("Match error (%s)", err.message);
+ dbus_error_free(&err);
+ return;
+ }
+
+ dbus_bus_add_match(conn, SUPPLICANT_INTERFACE_BSSADDED_SIGNAL_FILTER, &err);
+ dbus_connection_flush(conn);
+ if (dbus_error_is_set(&err)) {
+ ERR("Match error (%s)", err.message);
+ dbus_error_free(&err);
+ return;
+ }
+
+ dbus_bus_add_match(conn, SUPPLICANT_INTERFACE_SCANDONE_SIGNAL_FILTER, &err);
+ dbus_connection_flush(conn);
+ if (dbus_error_is_set(&err)) {
+ ERR("Match error (%s)", err.message);
+ dbus_error_free(&err);
+ return;
+ }
+
+ dbus_bus_add_match(conn,
+ SUPPLICANT_INTERFACE_DRIVERHANGED_SIGNAL_FILTER, &err);
+ dbus_connection_flush(conn);
+ if (dbus_error_is_set(&err)) {
+ ERR("Match error (%s)", err.message);
+ dbus_error_free(&err);
+ return;
+ }
+
+ dbus_bus_add_match(conn,
+ SUPPLICANT_INTERFACE_SESSIONOVERLAPPED_SIGNAL_FILTER, &err);
+ dbus_connection_flush(conn);
+ if (dbus_error_is_set(&err)) {
+ ERR("Match error (%s)", err.message);
+ dbus_error_free(&err);
+ return;
+ }
+
+ dbus_bus_add_match(conn, CONNMAN_SERVICE_NAMECHANGED_SIGNAL_FILTER, &err);
+ dbus_connection_flush(conn);
+ if (dbus_error_is_set(&err)) {
+ ERR("Match error (%s)", err.message);
dbus_error_free(&err);
return;
}
return;
}
- INFO("Successfully register signal filters");
+ INFO("Successfully register DBus signal filters");
+
+ /* 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");
+ ERR("Already de-registered. Nothing to be done");
return;
}
*
*/
+#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");
- uname(&buf);
+ 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 (buf.machine != NULL &&
- 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_CELLULAR);
+ vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_ETHERNET);
vconf_set_int(VCONFKEY_DNET_STATE, VCONFKEY_DNET_NORMAL_CONNECTED);
}
{
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 != NULL)
+ 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);
+}
*
*/
+/* MDM security is supported in private only,
+ * do not make in public and share usage.
+ *
+ * For the purpose of TIZEN release
+ * 1. eliminate libmdm-dev Build-Depends in debian/control
+ * 2. eliminate pkgconfig(mdm) BuildRequire in packaging/net-config.spec
+ * 3. eliminate mdm pkgs REQUIRED in CMakeLists.txt
+ * 4. eliminate "#include <mdm.h>" in mdm-private.c
+ * 5. eliminate implementation body of netconfig_is_wifi_allowed()
+ * 6. make netconfig_is_wifi_allowed, witch always return TRUE such as
+ * gboolean netconfig_is_wifi_allowed(void)
+ * {
+ * return TRUE;
+ * }
+ */
+
+#include <mdm.h>
+
+#include "log.h"
+#include "netdbus.h"
#include "mdm-private.h"
+enum netconfig_wifi_sec_level {
+ WIFI_SEC_LEVEL_UNKNOWN = 0,
+ WIFI_SEC_LEVEL_NONE = 1,
+ WIFI_SEC_LEVEL_WEP = 2,
+ WIFI_SEC_LEVEL_PSK = 3,
+ WIFI_SEC_LEVEL_EAP_PEAP = 4,
+ WIFI_SEC_LEVEL_EAP_TLS = 5,
+ WIFI_SEC_LEVEL_EAP_TTLS = 6,
+ WIFI_SEC_LEVEL_EAP_SIM = 7,
+ WIFI_SEC_LEVEL_EAP_AKA = 8,
+};
+
+#if defined MDM_PHASE_2
+static enum netconfig_wifi_sec_level __netconfig_get_eap_level(const char *eap)
+{
+ if (eap == NULL)
+ return WIFI_SEC_LEVEL_EAP_PEAP;
+ else if (g_str_equal(eap, "peap") == TRUE)
+ return WIFI_SEC_LEVEL_EAP_PEAP;
+ else if (g_str_equal(eap, "tls") == TRUE)
+ return WIFI_SEC_LEVEL_EAP_TLS;
+ else if (g_str_equal(eap, "ttls") == TRUE)
+ return WIFI_SEC_LEVEL_EAP_TTLS;
+ else if (g_str_equal(eap, "sim") == TRUE)
+ return WIFI_SEC_LEVEL_EAP_SIM;
+ else if (g_str_equal(eap, "aka") == TRUE)
+ return WIFI_SEC_LEVEL_EAP_AKA;
+ else
+ return WIFI_SEC_LEVEL_EAP_PEAP;
+}
+
+static enum netconfig_wifi_sec_level __netconfig_get_sec_level(
+ const char *security, const char *eap)
+{
+ if (g_str_equal(security, "none") == TRUE)
+ return WIFI_SEC_LEVEL_NONE;
+ else if (g_str_equal(security, "wep") == TRUE)
+ return WIFI_SEC_LEVEL_WEP;
+ else if (g_str_equal(security, "psk") == TRUE)
+ return WIFI_SEC_LEVEL_PSK;
+ else if (g_str_equal(security, "ieee8021x") == TRUE)
+ return __netconfig_get_eap_level(eap);
+
+ return WIFI_SEC_LEVEL_UNKNOWN;
+}
+
+static gboolean __netconfig_is_ap_allowed(const char *ssid,
+ const char *security, const char *eap)
+{
+ gboolean ret = FALSE;
+ mdm_result_t result;
+
+ result = mdm_get_service();
+
+ if (result != MDM_RESULT_SUCCESS) {
+ ret = TRUE;
+ goto done;
+ }
+
+ mdm_status_t rv = mdm_is_network_blocked(ssid);
+
+ if (rv == MDM_TRUE)
+ goto done;
+
+ mdm_wifi_sec_type_e sec_type = mdm_get_minimum_required_security();
+ enum netconfig_wifi_sec_level sec_level =
+ __netconfig_get_sec_level(security, eap);
+
+ switch (sec_type) {
+ case SECURITY_LEVEL_NONE:
+ case SECURITY_LEVEL_OPEN:
+ break;
+ case SECURITY_LEVEL_WEP:
+ if (sec_level < WIFI_SEC_LEVEL_WEP)
+ goto done;
+ break;
+ case SECURITY_LEVEL_WPA_PSK:
+ case SECURITY_LEVEL_WPA2_PSK:
+ if (sec_level < WIFI_SEC_LEVEL_PSK)
+ goto done;
+ break;
+ case SECURITY_LEVEL_EAP_PEAP:
+ if (sec_level < WIFI_SEC_LEVEL_EAP_PEAP)
+ goto done;
+ break;
+ case SECURITY_LEVEL_EAP_TLS:
+ if (sec_level < WIFI_SEC_LEVEL_EAP_TLS)
+ goto done;
+ break;
+ case SECURITY_LEVEL_EAP_TTLS:
+ if (sec_level < WIFI_SEC_LEVEL_EAP_TTLS)
+ goto done;
+ break;
+ case SECURITY_LEVEL_EAP_SIM:
+ if (sec_level < WIFI_SEC_LEVEL_EAP_SIM)
+ goto done;
+ break;
+ case SECURITY_LEVEL_EAP_AKA:
+ if (sec_level < WIFI_SEC_LEVEL_EAP_AKA)
+ goto done;
+ break;
+ default:
+ break;
+ }
+
+ ret = TRUE;
+
+done:
+ mdm_release_service();
+
+ return ret;
+}
+
+static gboolean __netconfig_get_ap_info(const char *path, char **essid,
+ char **security, char **eap)
+{
+ gboolean ret = FALSE;
+ DBusMessage *message = NULL;
+ DBusMessageIter iter, array;
+
+ if (essid == NULL || security == NULL || eap == NULL ||
+ netconfig_is_wifi_profile(path) != TRUE) {
+ ERR("Invalid parameter");
+ goto done;
+ }
+
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, path,
+ CONNMAN_SERVICE_INTERFACE, "GetProperties", NULL);
+ if (message == NULL) {
+ ERR("Failed to get service properties");
+ goto done;
+ }
+
+ 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, sub_array;
+ const char *key = NULL, *value = NULL;
+
+ 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, "Name") == TRUE) {
+ if (dbus_message_iter_get_arg_type(&variant) == DBUS_TYPE_STRING) {
+ dbus_message_iter_get_basic(&variant, &value);
+
+ if (value) {
+ *essid = g_strdup(value);
+ }
+ }
+ } else if (g_str_equal(key, "Security") == TRUE) {
+ dbus_message_iter_recurse(&variant, &sub_array);
+
+ if (dbus_message_iter_get_arg_type(&sub_array) ==
+ DBUS_TYPE_STRING) {
+ dbus_message_iter_get_basic(&sub_array, &value);
+
+ if (value) {
+ *security = g_strdup(value);
+ }
+ }
+ } else if (g_str_equal(key, "EAP") == TRUE) {
+ if (dbus_message_iter_get_arg_type(&variant) == DBUS_TYPE_STRING) {
+ dbus_message_iter_get_basic(&variant, &value);
+
+ if (value) {
+ *eap = g_strdup(value);
+ }
+ }
+ }
+
+ dbus_message_iter_next(&array);
+ }
+
+ ret = TRUE;
+
+done:
+ if (message != NULL)
+ dbus_message_unref(message);
+
+ return ret;
+}
+
+static void __netconfig_disconnect_ap(const char *path)
+{
+ DBusMessage *message = NULL;
+
+ if (netconfig_is_wifi_profile(path) != TRUE) {
+ ERR("Invalid parameter");
+ return;
+ }
+
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, path,
+ CONNMAN_SERVICE_INTERFACE, "Disconnect", NULL);
+
+ if (message == NULL)
+ return;
+
+ 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);
+ }
+
+ if (message != NULL)
+ dbus_message_unref(message);
+}
+#endif
+
gboolean netconfig_is_wifi_allowed(void)
{
- return TRUE;
+ gboolean ret = TRUE;
+
+ mdm_result_t result;
+
+ result = mdm_get_service();
+
+ if (result == MDM_RESULT_SUCCESS) {
+ if (mdm_get_allow_wifi() == MDM_RESTRICTED)
+ ret = FALSE;
+
+ mdm_release_service();
+ }
+
+ return ret;
+}
+
+void netconfig_check_allowed_ap(const char *path)
+{
+#if defined MDM_PHASE_2
+ gboolean ret = FALSE;
+ char *essid = NULL;
+ char *security = NULL;
+ char *eap = NULL;
+
+ ret = __netconfig_get_ap_info(path, &essid, &security, &eap);
+
+ if (ret == FALSE)
+ return;
+
+ ret = __netconfig_is_ap_allowed(essid, security, eap);
+ g_free(essid);
+ g_free(security);
+ g_free(eap);
+
+ if (ret == TRUE)
+ return;
+
+ __netconfig_disconnect_ap(path);
+#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.
+ *
+ */
+
+#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();
+ return FALSE;
+ } 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;
+}
+
+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();
+ }
+}
*
*/
-#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 <unistd.h>
+#include <net/if.h>
+#include <net/route.h>
+#include <arpa/inet.h>
#include <sys/wait.h>
-#include <vconf.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
#include <vconf-keys.h>
-#include <wifi-direct.h>
#include <syspopup_caller.h>
#include "log.h"
#include "neterror.h"
#include "wifi-state.h"
-void netconfig_start_timer_seconds(int secs,
+#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)
+{
+ GKeyFile *keyfile = NULL;
+ GError *error = NULL;
+
+ keyfile = g_key_file_new();
+ if (g_key_file_load_from_file(keyfile, pathname, 0, &error) != TRUE) {
+ DBG("Unable to open %s, error %s", pathname, error->message);
+ g_error_free(error);
+
+ g_key_file_free(keyfile);
+ keyfile = NULL;
+ }
+
+ return keyfile;
+}
+
+void netconfig_keyfile_save(GKeyFile *keyfile, const char *pathname)
+{
+ gsize size = 0;
+ GError *error = NULL;
+ gchar *keydata = NULL;
+ gchar *needle = NULL, *directory = NULL;
+
+ directory = g_strdup(pathname);
+ needle = g_strrstr(directory, "/");
+
+ if (needle != NULL)
+ *needle = '\0';
+
+ if (directory == NULL || (*directory) == '\0') {
+ g_free(directory);
+ return;
+ }
+
+ if (g_file_test(directory, G_FILE_TEST_IS_DIR) != TRUE) {
+ if (g_mkdir_with_parents(directory,
+ S_IRUSR | S_IWUSR | S_IXUSR) != 0) {
+ g_free(directory);
+ return;
+ }
+ }
+ g_free(directory);
+
+ keydata = g_key_file_to_data(keyfile, &size, &error);
+ if (g_file_set_contents(pathname, keydata, size, &error) != TRUE) {
+ DBG("Unable to save %s, error %s", pathname, error->message);
+ g_error_free(error);
+ }
+
+ chmod(pathname, S_IRUSR | S_IWUSR);
+
+ g_free(keydata);
+
+ g_key_file_free(keyfile);
+}
+
+void netconfig_start_timer_seconds(guint secs,
gboolean(*callback) (gpointer), void *user_data, guint *timer_id)
{
guint t_id = 0;
- INFO("Register timer with callback pointer (%p)", callback);
-
if (callback == NULL) {
ERR("callback function is NULL");
return;
*timer_id = t_id;
}
-void netconfig_start_timer(int msecs,
+void netconfig_start_timer(guint msecs,
gboolean(*callback) (gpointer), void *user_data, guint *timer_id)
{
guint t_id = 0;
static void __netconfig_pop_device_picker(void)
{
- int rv = 0;
+#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;
b = bundle_create();
DBG("Launch Wi-Fi device picker");
- rv = syspopup_launch("wifi-qs", b);
+ 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;
guint timer_id = 0;
+#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;
}
-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;
}
-gboolean netconfig_iface_wifi_launch_direct(NetconfigWifi *wifi, GError **error)
+int netconfig_add_route_ipv6(gchar *ip_addr, gchar *interface, gchar *gateway, unsigned char prefix_len)
{
- gboolean ret = TRUE;
+ struct in6_rtmsg rt;
+ int fd = 0;
+ int err = 0;
+
+ memset(&rt, 0, sizeof(rt));
+
+ rt.rtmsg_dst_len = prefix_len;
+ rt.rtmsg_flags = RTF_UP | RTF_HOST;
+
+ if (inet_pton(AF_INET6, ip_addr, &rt.rtmsg_dst) < 0) {
+ err = -errno;
+ return err;
+ }
+
+ if (gateway != NULL) {
+ rt.rtmsg_flags |= RTF_GATEWAY;
+ if (inet_pton(AF_INET6, gateway, &rt.rtmsg_gateway) < 0) {
+ err = -errno;
+ return err;
+ }
+ }
+
+ rt.rtmsg_metric = 1;
+
+ fd = socket(AF_INET6, SOCK_DGRAM, 0);
+ if (fd < 0)
+ return -1;
+
+ rt.rtmsg_ifindex = 0;
+
+ if (interface) {
+ struct ifreq ifr;
+ memset(&ifr, 0, sizeof(ifr));
+ g_strlcpy(ifr.ifr_name, interface, strlen(ifr.ifr_name)-1);
+ ioctl(fd, SIOCGIFINDEX, &ifr);
+ rt.rtmsg_ifindex = ifr.ifr_ifindex;
+ }
+
+ if ((err = ioctl(fd, SIOCADDRT, &rt)) < 0) {
+ DBG("Failed to add route: %d\n", err);
+ close(fd);
+ return -1;
+ }
+
+ close(fd);
+
+ return 1;
+}
+
+int netconfig_del_route_ipv6(gchar *ip_addr, gchar *interface, gchar *gateway, unsigned char prefix_len)
+{
+ struct in6_rtmsg rt;
+ int fd = 0;
+ int err = 0;
+
+ memset(&rt, 0, sizeof(rt));
+
+ rt.rtmsg_dst_len = prefix_len;
+
+ rt.rtmsg_flags = RTF_UP | RTF_HOST;
+
+ if (inet_pton(AF_INET6, ip_addr, &rt.rtmsg_dst) < 0) {
+ err = -errno;
+ return err;
+ }
+
+ if (gateway != NULL) {
+ rt.rtmsg_flags |= RTF_GATEWAY;
+ if (inet_pton(AF_INET6, gateway, &rt.rtmsg_gateway) < 0) {
+ err = -errno;
+ return err;
+ }
+ }
+
+ rt.rtmsg_metric = 1;
+
+ fd = socket(AF_INET6, SOCK_DGRAM, 0);
+ if (fd < 0)
+ return -1;
+
+ rt.rtmsg_ifindex = 0;
+
+ if (interface) {
+ struct ifreq ifr;
+ memset(&ifr, 0, sizeof(ifr));
+ g_strlcpy(ifr.ifr_name, interface, strlen(ifr.ifr_name)-1);
+ ioctl(fd, SIOCGIFINDEX, &ifr);
+ rt.rtmsg_ifindex = ifr.ifr_ifindex;
+ }
+
+ if ((err = ioctl(fd, SIOCDELRT, &rt)) < 0) {
+ DBG("Failed to add route: %d\n", err);
+ close(fd);
+ return -1;
+ }
+
+ close(fd);
+
+ return 1;
+}
+
+gboolean netconfig_iface_wifi_launch_direct(NetconfigWifi *wifi, GError **error)
+{
+#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" };
- 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");
+ ret = netconfig_execute_file(path, args, envs);
+ if (ret < 0) {
+ ERR("Failed to launch Wi-Fi direct daemon");
netconfig_error_wifi_direct_failed(error);
+ return FALSE;
}
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+
+gboolean netconfig_send_notification_to_net_popup(const char * noti, const char * ssid)
+{
+ int ret = 0;
+ bundle *b;
+ static gboolean is_found_noti_exists = FALSE;
+ static gboolean is_portal_noti_exists = FALSE;
+
+ 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;
+
+ is_found_noti_exists = FALSE;
+ } else if (g_strcmp0(noti, NETCONFIG_ADD_FOUND_AP_NOTI) == 0) {
+ if (is_found_noti_exists == TRUE)
+ return TRUE;
+
+ 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;
+ }
+
+ b = bundle_create();
+ bundle_add(b, "_SYSPOPUP_TYPE_", noti);
+
+ if (ssid != NULL) {
+ DBG("ssid (%s)", ssid);
+ bundle_add(b, "_AP_NAME_", ssid);
+ }
+
+ ret = aul_launch_app("net.netpopup", b);
+
+ bundle_free(b);
+
+ if (ret < 0) {
+ ERR("Unable to launch noti-popup. Err = %d", ret);
+ return FALSE;
+ }
+
+ DBG("Successfully sent notification (%s)", noti);
+ return TRUE;
+}
+
+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();
+
+ bundle_add(b, "_SYSPOPUP_TITLE_", title);
+ bundle_add(b, "_SYSPOPUP_CONTENT_", content);
+ bundle_add(b, "_SYSPOPUP_TYPE_", type);
+ bundle_add(b, "_AP_NAME_", ssid);
+
+ ret = aul_launch_app("net.netpopup", b);
+
+ bundle_free(b);
+
return ret;
}
+
+void netconfig_set_vconf_int(const char * key, int value)
+{
+ int ret = 0;
+
+ DBG("[%s: %d]", key, value);
+
+ ret = vconf_set_int(key, value);
+ if (ret != VCONF_OK)
+ ERR("Failed to set");
+}
+
+void netconfig_set_vconf_str(const char * key, const char * value)
+{
+ int ret = 0;
+
+ DBG("[%s: %s]", key, value);
+
+ 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;
+ if((entry = strtok_r(entry, "=", &last)) != NULL){
+ 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;
+}
--- /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 <app.h>
+#include <stdio.h>
+#include <vconf.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <vconf-keys.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 struct netconfig_wifi_agent agent;
+
+static void __netconfig_agent_clear_fields(void)
+{
+ 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)
+{
+ DBusError error;
+ DBusMessageIter iter;
+ DBusMessage *reply = NULL;
+ DBusMessage *message = NULL;
+ DBusConnection *connection = NULL;
+ const char *path = NETCONFIG_WIFI_PATH;
+
+ DBG("ConnMan agent register");
+
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (connection == NULL) {
+ ERR("Failed to get system bus");
+ return FALSE;
+ }
+
+ message = dbus_message_new_method_call(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE, "RegisterAgent");
+ if (message == NULL) {
+ ERR("Failed DBus method call");
+ dbus_connection_unref(connection);
+ return FALSE;
+ }
+
+ dbus_message_iter_init_append(message, &iter);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &path);
+
+ do {
+ dbus_error_init(&error);
+
+ reply = dbus_connection_send_with_reply_and_block(connection, message,
+ 10 * 1000, &error);
+
+ if (reply == NULL) {
+ if (dbus_error_is_set(&error) == TRUE) {
+ if (g_strcmp0(error.name,
+ "net.connman.Error.AlreadyExists") == 0) {
+ dbus_error_free(&error);
+
+ break;
+ } else {
+ ERR("Fail to register agent [%s: %s]",
+ error.name, error.message);
+ dbus_error_free(&error);
+ }
+ } else {
+ ERR("Fail to register agent");
+ }
+ }
+
+ if (reply != NULL)
+ dbus_message_unref(reply);
+
+ sleep(1);
+ } while (TRUE);
+
+ dbus_message_unref(message);
+ dbus_connection_unref(connection);
+
+ return TRUE;
+}
+
+gboolean netconfig_agent_unregister(void)
+{
+ gboolean reply;
+ char param0[] = "objpath:" NETCONFIG_WIFI_PATH;
+ char *param_array[] = { NULL, NULL };
+
+ param_array[0] = param0;
+
+ DBG("ConnMan agent unregister");
+
+ reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "UnregisterAgent", param_array, NULL);
+
+ if (reply != TRUE)
+ ERR("Fail to unregister agent");
+
+ /* Clearing the agent fields */
+ __netconfig_agent_clear_fields();
+
+ return reply;
+}
+
+gboolean netconfig_wifi_set_agent_field_for_eap_network(
+ const char *name, const char *identity, const char *passphrase)
+{
+ int name_len;
+
+ if (name == NULL)
+ return FALSE;
+
+ __netconfig_agent_clear_fields();
+
+ 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 (identity)
+ agent.identity = g_strdup(identity);
+
+ if (passphrase)
+ agent.passphrase = g_strdup(passphrase);
+
+ DBG("Successfully configured for EAP network");
+
+ return TRUE;
+}
+
+gboolean netconfig_iface_wifi_set_field(NetconfigWifi *wifi,
+ gchar *service, GHashTable *fields,
+ DBusGMethodInvocation *context)
+{
+ GError *error;
+ GHashTableIter iter;
+ gpointer field, value;
+ gboolean updated = FALSE;
+ gboolean reply = FALSE;
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ DBG("Set agent fields for %s", service);
+
+ if (netconfig_is_wifi_profile(service) != TRUE) {
+ error = g_error_new(DBUS_GERROR,
+ DBUS_GERROR_AUTH_FAILED,
+ CONNMAN_ERROR_INTERFACE ".InvalidService");
+
+ dbus_g_method_return_error(context, error);
+ g_clear_error(&error);
+
+ return reply;
+ }
+
+ __netconfig_agent_clear_fields();
+
+ g_hash_table_iter_init(&iter, fields);
+
+ while (g_hash_table_iter_next(&iter, &field, &value)) {
+ if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_PASSPHRASE) == 0) {
+ g_free(agent.passphrase);
+ if (G_VALUE_TYPE(value) == G_TYPE_STRING) {
+ agent.passphrase = g_value_dup_string(value);
+ updated = TRUE;
+
+ 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_VALUE_TYPE(value) == G_TYPE_STRING &&
+ g_strcmp0(g_value_get_string(value), "enable") == 0) {
+ agent.wps_pbc = TRUE;
+ updated = TRUE;
+
+ 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;
+ if (G_VALUE_TYPE(value) == G_TYPE_STRING) {
+ agent.wps_pin = g_value_dup_string(value);
+ 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_VALUE_TYPE(value) == G_TYPE_STRING) {
+ agent.name = g_value_dup_string(value);
+ 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;
+ }
+
+ if (G_VALUE_HOLDS(value, DBUS_TYPE_G_UCHAR_ARRAY) == TRUE) {
+ GByteArray *array = (GByteArray *)g_value_get_boxed(value);
+ 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_VALUE_TYPE(value) == G_TYPE_STRING) {
+ agent.identity = g_value_dup_string(value);
+ updated = TRUE;
+
+ DBG("Field [%s] - []", field);
+ } else {
+ agent.identity = NULL;
+ }
+ }
+ }
+
+ if (updated == TRUE) {
+ reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
+ service, CONNMAN_SERVICE_INTERFACE, "Connect", NULL, NULL);
+ if (reply == TRUE) {
+ dbus_g_method_return(context);
+ } else {
+ error = g_error_new(DBUS_GERROR,
+ DBUS_GERROR_AUTH_FAILED,
+ CONNMAN_ERROR_INTERFACE ".InvalidArguments");
+
+ dbus_g_method_return_error(context, error);
+ g_clear_error(&error);
+ }
+ } else {
+ error = g_error_new(DBUS_GERROR,
+ DBUS_GERROR_AUTH_FAILED,
+ CONNMAN_ERROR_INTERFACE ".InvalidArguments");
+
+ dbus_g_method_return_error(context, error);
+ g_clear_error(&error);
+ }
+
+ if (reply != TRUE) {
+ ERR("Fail to connect Wi-Fi");
+
+ __netconfig_agent_clear_fields();
+ }
+
+ return reply;
+}
+
+static void __g_slice_value_free(gpointer data)
+{
+ g_slice_free(GValue, data);
+}
+
+gboolean netconfig_iface_wifi_request_input(NetconfigWifi *wifi,
+ gchar *service, GHashTable *fields,
+ DBusGMethodInvocation *context)
+{
+ GError *error;
+ GHashTableIter iter;
+ gpointer field, r_value;
+ GHashTable *out_table = NULL;
+ GValue *value = NULL;
+ gboolean updated = FALSE;
+
+ g_return_val_if_fail(wifi != 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_slice_value_free);
+ if (NULL == out_table)
+ return FALSE;
+
+ g_hash_table_iter_init(&iter, fields);
+
+ while (g_hash_table_iter_next(&iter, &field, &r_value)) {
+ if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_PASSPHRASE) == 0 &&
+ agent.passphrase != NULL) {
+ value = g_slice_new0(GValue);
+
+ g_value_init(value, G_TYPE_STRING);
+ g_value_set_string(value, agent.passphrase);
+ g_hash_table_insert(out_table, g_strdup(field), value);
+
+ updated = TRUE;
+ DBG("Setting [%s] - []", field);
+ } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_WPS) == 0 &&
+ (agent.wps_pbc == TRUE || agent.wps_pin != NULL)) {
+ value = g_slice_new0(GValue);
+
+ g_value_init(value, G_TYPE_STRING);
+
+ if (agent.wps_pbc == TRUE) {
+ /* Sending empty string for WPS push button method */
+ g_value_set_string(value, "");
+ g_hash_table_insert(out_table, g_strdup(field), value);
+
+ updated = TRUE;
+ DBG("Setting empty string for [%s]", field);
+ } else if (agent.wps_pin != NULL) {
+ g_value_set_string(value, agent.wps_pin);
+ g_hash_table_insert(out_table, g_strdup(field), value);
+
+ updated = TRUE;
+ DBG("Setting string [%s] - []", field);
+ }
+ } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_NAME) == 0 &&
+ agent.name != NULL) {
+ value = g_slice_new0(GValue);
+
+ g_value_init(value, G_TYPE_STRING);
+ g_value_set_string(value, agent.name);
+ g_hash_table_insert(out_table, g_strdup(field), value);
+
+ updated = TRUE;
+ DBG("Settings [%s] - []", field);
+ } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_SSID) == 0 &&
+ agent.ssid != NULL) {
+ value = g_slice_new0(GValue);
+
+ g_value_init(value, DBUS_TYPE_G_UCHAR_ARRAY);
+ g_value_set_boxed(value, agent.ssid);
+ g_hash_table_insert(out_table, g_strdup(field), value);
+
+ updated = TRUE;
+ DBG("Settings [%s] - []", field);
+ } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_IDENTITY) == 0 &&
+ agent.identity != NULL) {
+ value = g_slice_new0(GValue);
+
+ g_value_init(value, G_TYPE_STRING);
+ g_value_set_string(value, agent.identity);
+ g_hash_table_insert(out_table, g_strdup(field), value);
+
+ updated = TRUE;
+ DBG("Settings [%s] - []", field);
+ }
+ }
+
+ if (updated == TRUE)
+ dbus_g_method_return(context, out_table);
+ else {
+ error = g_error_new(DBUS_GERROR,
+ DBUS_GERROR_AUTH_FAILED,
+ "net.connman.Agent.Error.Canceled");
+
+ dbus_g_method_return_error(context, error);
+ g_clear_error(&error);
+ }
+
+ __netconfig_agent_clear_fields();
+ g_hash_table_destroy(out_table);
+
+ return updated;
+}
+
+gboolean netconfig_iface_wifi_report_error(NetconfigWifi *wifi,
+ gchar *service, gchar *error,
+ DBusGMethodInvocation *context)
+{
+ gboolean ret = TRUE;
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ dbus_g_method_return(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;
+ DBusMessage *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)
+ dbus_message_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("");
+
+ 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 netconfig_iface_wifi_request_browser(NetconfigWifi *wifi,
+ gchar *service, gchar *url,
+ DBusGMethodInvocation *context)
+{
+#if defined TIZEN_CAPTIVE_PORTAL
+ gboolean ret = FALSE;
+ gboolean ignore_portal = FALSE;
+ const char * ssid = NULL;
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ dbus_g_method_return(context);
+ 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!!");
+ return ret;
+ }
+
+ ignore_portal = __check_ignore_portal_list(ssid);
+
+ if (ignore_portal == TRUE)
+ 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)
+ 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);
+
+ return ret;
+#else
+ GError *error;
+ error = g_error_new(DBUS_GERROR,
+ DBUS_GERROR_AUTH_FAILED,
+ CONNMAN_ERROR_INTERFACE ".NotSupported");
+
+ dbus_g_method_return_error(context, error);
+ g_clear_error(&error);
+
+ return FALSE;
+#endif
+}
#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,
guint timer_id;
};
+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;
}
if (is_set_mode != TRUE)
return bgscan_mode;
- if (mode < WIFI_BGSCAN_MODE_MAX && mode >= WIFI_BGSCAN_MODE_EXPONENTIAL)
+ if (mode < WIFI_BGSCAN_MODE_MAX)
bgscan_mode = mode;
DBG("Wi-Fi background scan mode set %d", bgscan_mode);
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;
- char param1[] = "string:wifi";
- char *param_array[] = {NULL, NULL};
+ gboolean reply;
+ 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 TRUE;
+
+ 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;
+ }
- if (netconfig_wifi_state_get_service_state() == NETCONFIG_WIFI_CONNECTING)
- return FALSE;
+ netconfig_wifi_set_scanning(TRUE);
- param_array[0] = param1;
+ 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);
- reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
- CONNMAN_MANAGER_INTERFACE, "RequestScan", param_array);
+ 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;
+ }
- DBG("Wi-Fi background scan with exponentially increasing period");
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;
- DBG("Wi-Fi background scan periodically");
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);
- netconfig_start_timer_seconds(data->time, __netconfig_wifi_bgscan_request_scan, data, &(data->timer_id));
+ DBG("Scan immediately[%d], mode[%d], next[%d]",
+ immediate_scan, data->mode, data->time);
+
+ netconfig_start_timer_seconds(data->time,
+ __netconfig_wifi_bgscan_next_scan, data, &(data->timer_id));
}
static void __netconfig_wifi_bgscan_stop_timer(struct bgscan_timer_data *data)
if (data == NULL)
return;
- DBG("Stop Wi-Fi background scan timer");
-
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;
if (timer == NULL)
return FALSE;
- DBG("Request Wi-Fi scan to ConnMan");
+ /* 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);
+ __netconfig_wifi_bgscan_start_timer(TRUE, timer);
- __netconfig_wifi_bgscan_request_connman_scan();
+ return FALSE;
+}
- __netconfig_wifi_bgscan_start_timer(timer);
+void netconfig_wifi_set_bgscan_pause(gboolean pause)
+{
+ DBG("[%s] Wi-Fi background scan", pause ? "Pause" : "Resume");
+ netconfig_bgscan_paused = pause;
+}
- return FALSE;
+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)
{
- struct bgscan_timer_data *timer_data = __netconfig_wifi_bgscan_get_bgscan_data();
+ 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;
- __netconfig_wifi_bgscan_request_connman_scan();
+ 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)
{
- struct bgscan_timer_data *timer_data = __netconfig_wifi_bgscan_get_bgscan_data();
+ struct bgscan_timer_data *timer_data =
+ __netconfig_wifi_bgscan_get_bgscan_data();
if (timer_data == NULL)
return;
__netconfig_wifi_bgscan_stop_timer(timer_data);
}
-gboolean netconfig_iface_wifi_set_bgscan(NetconfigWifi *wifi, guint scan_mode, GError **error)
+gboolean netconfig_wifi_get_bgscan_state(void)
{
- struct bgscan_timer_data *timer_data = __netconfig_wifi_bgscan_get_bgscan_data();
+ struct bgscan_timer_data *timer_data =
+ __netconfig_wifi_bgscan_get_bgscan_data();
- DBG("Wi-Fi background scan mode set: %d", scan_mode);
+ return ((timer_data->timer_id > (guint)0) ? TRUE : FALSE);
+}
- if (scan_mode >= WIFI_BGSCAN_MODE_MAX || scan_mode < WIFI_BGSCAN_MODE_EXPONENTIAL)
- return FALSE;
+gboolean netconfig_wifi_get_scanning(void)
+{
+ return netconfig_wifi_scanning;
+}
- switch (scan_mode) {
- case WIFI_BGSCAN_MODE_PERIODIC:
- DBG("[%s]BG scan mode is periodic", __FUNCTION__);
- break;
- case WIFI_BGSCAN_MODE_EXPONENTIAL:
- DBG("[%s]BG scan mode is exponential", __FUNCTION__);
- break;
- default:
- DBG("[%s]strange value [%d]", __FUNCTION__, scan_mode);
- break;
- }
+void netconfig_wifi_set_scanning(gboolean scanning)
+{
+ if (netconfig_wifi_scanning != scanning)
+ netconfig_wifi_scanning = scanning;
+}
+
+gboolean netconfig_iface_wifi_set_bgscan(
+ NetconfigWifi *wifi, guint scan_mode, GError **error)
+{
+ gint old_mode = 0;
+ int pm_state = VCONFKEY_PM_STATE_NORMAL;
+
+ old_mode = __netconfig_wifi_bgscan_get_mode();
+ if (old_mode == scan_mode)
+ return TRUE;
__netconfig_wifi_bgscan_set_mode(scan_mode);
- if (timer_data->timer_id != 0) {
- netconfig_wifi_bgscan_stop();
- netconfig_wifi_bgscan_start();
- }
+ netconfig_wifi_bgscan_stop();
+
+ /* 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);
+
+ return TRUE;
+}
+
+gboolean netconfig_iface_wifi_resume_bgscan(
+ NetconfigWifi *wifi, GError **error)
+{
+ netconfig_wifi_set_bgscan_pause(FALSE);
return TRUE;
}
+
+gboolean netconfig_iface_wifi_pause_bgscan(
+ NetconfigWifi *wifi, GError **error)
+{
+ netconfig_wifi_set_bgscan_pause(TRUE);
+
+ 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 <glib.h>
+#include <errno.h>
+#include <vconf.h>
+#include <unistd.h>
+#include <net/if.h>
+#include <sys/ioctl.h>
+#include <vconf-keys.h>
+
+#include "log.h"
+#include "util.h"
+#include "netsupplicant.h"
+
+#define CCODE_CONFIG_FILE "/etc/wifi/ccode.conf"
+#define MCC_TO_ISO_MAP_GROUP_NAME "mcc_iso_map"
+#define DEFAULT_CCODE "GB"
+
+/* Structure to send private command to Wi-Fi driver */
+typedef struct netconfig_wifi_priv_cmd {
+ char *buf;
+ int used_len;
+ int total_len;
+} netconfig_wifi_priv_cmd;
+
+static char *__netconfig_get_mcc(void)
+{
+ int plmn = 0;
+ char mcc[4] = { 0, };
+ const int mcc_length = 3;
+
+ if (vconf_get_int(VCONFKEY_TELEPHONY_PLMN, &plmn) != 0) {
+ ERR("OPERATION_FAILED");
+ return NULL;
+ }
+
+ g_snprintf(mcc, mcc_length + 1, "%d", plmn);
+
+ return g_strdup(mcc);
+}
+
+static char *__netconfig_wifi_ccode_get_csc(void)
+{
+ char *iso = NULL;
+
+ iso = vconf_get_str(VCONFKEY_CSC_COUNTRY_ISO);
+ if (iso == NULL)
+ ERR("Failed to get CSC country ISO code");
+
+ return iso;
+}
+
+/*
+ * Get the iso code and rev number from Broadcom config file with mcc
+ * Input: valid keyfile of the config file, valid mcc
+ * Return: the ISO on success
+ * NULL on failure
+ */
+static gchar *__netconfig_wifi_ccode_get_iso_from_mcc(
+ GKeyFile *keyfile, char *mcc)
+{
+ gchar *iso = NULL;
+
+ if (keyfile == NULL || mcc == NULL)
+ return NULL;
+
+ iso = g_key_file_get_string(keyfile, MCC_TO_ISO_MAP_GROUP_NAME, mcc, NULL);
+ if (iso == NULL)
+ ERR("Failed to get ISO with mcc %s", mcc);
+
+ return iso;
+}
+
+void netconfig_wifi_ccode_init(void)
+{
+ char *iso = NULL;
+ char *mcc = NULL;
+ GKeyFile *keyfile = NULL;
+ struct ifreq ifr;
+ char buf[248] = { 0, }; /* Max driver command size is 248 */
+ netconfig_wifi_priv_cmd priv_cmd;
+ int ret = 0;
+ int ioctl_sock = 0;
+ size_t buf_len;
+
+ DBG("Init Wi-Fi country code");
+
+ keyfile = netconfig_keyfile_load(CCODE_CONFIG_FILE);
+ if (keyfile == NULL) {
+ DBG("Unable to get ISO code... Default ISO=[%s]", DEFAULT_CCODE);
+ goto SET_COUNTRY_REV;
+ }
+
+ mcc = __netconfig_get_mcc();
+ iso = __netconfig_wifi_ccode_get_iso_from_mcc(keyfile, mcc);
+
+ if (iso == NULL) {
+ /*
+ * Unable to get the ISO code using mcc.
+ * Lets get it from CSC.
+ */
+ iso = __netconfig_wifi_ccode_get_csc();
+ }
+
+
+SET_COUNTRY_REV:
+
+ if (mcc != NULL)
+ g_free(mcc);
+
+ if (keyfile != NULL)
+ g_key_file_free(keyfile);
+
+ if (iso == NULL) {
+ g_snprintf(buf, sizeof(buf), "COUNTRY %s", DEFAULT_CCODE);
+ } else {
+ char *iso_upper = g_ascii_strup(iso, -1);
+ g_snprintf(buf, sizeof(buf), "COUNTRY %s", iso_upper);
+ g_free(iso_upper);
+ g_free(iso);
+ }
+
+ memset(&ifr, 0, sizeof(struct ifreq));
+ g_strlcpy((char *)ifr.ifr_name, WIFI_IFNAME, IFNAMSIZ);
+
+ DBG("CCode command: [%s]", buf);
+ memset(&priv_cmd, 0, sizeof(priv_cmd));
+ buf_len = strlen(buf);
+ priv_cmd.buf = buf;
+ priv_cmd.used_len = buf_len;
+ priv_cmd.total_len = buf_len;
+ ifr.ifr_data = (char *)&priv_cmd;
+
+ ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
+ if (ioctl_sock < 0) {
+ DBG("socket(PF_INET,SOCK_DGRAM) failed");
+ return;
+ }
+
+ ret = ioctl(ioctl_sock, SIOCDEVPRIVATE + 1, &ifr);
+ if (ret < 0)
+ ERR("Fail to issue private commands: %d %s", ret, strerror(errno));
+
+ close(ioctl_sock);
+}
--- /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 <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+#include "log.h"
+#include "util.h"
+#include "netdbus.h"
+#include "wifi-agent.h"
+#include "wifi-state.h"
+#include "wifi-eap-config.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 *str = NULL;
+ char *pstr = NULL;
+ int i = 0, len = 0;
+
+ if (name == NULL)
+ return NULL;
+
+ len = strlen(name);
+
+ str = g_try_malloc0(len * 2 + 1);
+ if (str == NULL)
+ return NULL;
+
+ pstr = str;
+ for (i = 0; i < len; i++) {
+ g_snprintf(pstr, 3, "%02x", name[i]);
+ pstr += 2;
+ }
+
+ return str;
+}
+
+static int __config_save(const char *ssid, GKeyFile *keyfile)
+{
+ gchar *data = NULL;
+ gchar *config_file = NULL;
+ gsize length = 0;
+ FILE *file = NULL;
+ 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);
+
+ 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 err;
+}
+
+static int __config_delete(const char *ssid)
+{
+ int err = 0;
+ gchar *group_name = NULL;
+ gchar *config_file = NULL;
+ 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 -ENOMEM;
+
+ keyfile = g_key_file_new();
+
+ 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 err;
+}
+
+static gboolean __netconfig_copy_config(const char *src, const char *dst)
+{
+ 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);
+
+ if (remove(src) != 0)
+ WARN("Failed to remove %s", src);
+
+ return result;
+}
+
+static gboolean __netconfig_create_config(GHashTable *fields)
+{
+ GKeyFile *keyfile = NULL;
+ GHashTableIter iter;
+ gchar *encoded_ssid = NULL;
+ gchar *dirname = NULL;
+ gchar *group_name = NULL;
+ gpointer field, value;
+ gboolean updated = FALSE;
+ gchar *cert_file = NULL;
+ gchar *cert_path = NULL;
+ int err = 0;
+
+ g_hash_table_iter_init(&iter, fields);
+ while (g_hash_table_iter_next(&iter, &field, &value)) {
+ if (value != NULL) {
+ if (g_strcmp0(field, CONNMAN_CONFIG_FIELD_NAME) == 0) {
+ encoded_ssid = __get_encoded_ssid((const char *)value);
+ break;
+ } else if (g_strcmp0(field, CONNMAN_CONFIG_FIELD_SSID) == 0) {
+ encoded_ssid = g_strdup((const char *)value);
+ break;
+ }
+ }
+ }
+
+ if (encoded_ssid == NULL) {
+ ERR("Failed to fetch SSID");
+ goto out;
+ }
+
+ /* Create unique service group name */
+ 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 (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)) {
+ 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 (value != NULL)
+ g_key_file_set_string(keyfile, group_name, field, value);
+ }
+ }
+
+ 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 != NULL)
+ g_key_file_free(keyfile);
+
+ 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;
+ }
+
+ wifi_ident = strstr(profile, "wifi_");
+ if (wifi_ident == NULL) {
+ ERR("Invalid profile name");
+ return FALSE;
+ }
+
+ essid = strchr(wifi_ident + 5, '_');
+ if (essid == NULL) {
+ ERR("Invalid profile name");
+ return FALSE;
+ }
+
+ 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_create_config(NetconfigWifi *wifi,
+ gchar *service, GHashTable *fields,
+ DBusGMethodInvocation *context)
+{
+ GError *error;
+ gboolean updated = FALSE;
+ gboolean reply = FALSE;
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ DBG("Set agent fields for %s", service);
+
+ if (netconfig_is_wifi_profile(service) != TRUE) {
+ error = g_error_new(DBUS_GERROR,
+ DBUS_GERROR_AUTH_FAILED,
+ CONNMAN_ERROR_INTERFACE ".InvalidService");
+
+ dbus_g_method_return_error(context, error);
+ g_clear_error(&error);
+
+ return reply;
+ }
+
+ updated = __netconfig_create_config(fields);
+ if (updated == TRUE) {
+ dbus_g_method_return(context);
+
+ if (g_strstr_len(service, strlen(service), "_hidden_") != NULL) {
+ GHashTableIter iter;
+ gpointer field, value;
+ const char *name = NULL;
+ const char *identity = NULL;
+ const char *passphrase = NULL;
+
+ g_hash_table_iter_init(&iter, fields);
+
+ while (g_hash_table_iter_next(&iter, &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);
+ }
+
+ reply = 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 {
+ error = g_error_new(DBUS_GERROR,
+ DBUS_GERROR_AUTH_FAILED,
+ CONNMAN_ERROR_INTERFACE ".InvalidArguments");
+
+ dbus_g_method_return_error(context, error);
+ g_clear_error(&error);
+ }
+
+ if (reply != TRUE)
+ ERR("Fail to connect %s", service);
+
+ return reply;
+}
+
+gboolean netconfig_iface_wifi_delete_config(NetconfigWifi *wifi,
+ gchar *profile,
+ DBusGMethodInvocation *context)
+{
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ dbus_g_method_return(context);
+
+ return __netconfig_delete_config((const char *)profile);
+}
--- /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 "log.h"
+#include "util.h"
+#include "netdbus.h"
+#include "neterror.h"
+#include "wifi-tel-intf.h"
+#include "network-state.h"
+
+#define SIM_RAND_DATA_LEN 16
+#define SIM_AUTH_MAX_RESP_DATA_LEN 128
+#define SIM_AUTH_SRES_LEN 4
+#define SIM_AUTH_KC_LEN 8
+
+#define AKA_RAND_DATA_LEN 16
+#define AKA_AUTN_DATA_LEN 16
+#define AKA_AUTH_RES_MAX_LEN 16
+#define AKA_AUTH_RES_MIN_LEN 4
+#define AKA_AUTH_CK_LEN 16
+#define AKA_AUTH_IK_LEN 16
+
+struct wifii_authentication_data {
+ int auth_result;
+ int resp_length;
+ int authentication_key_length;
+ int cipher_length;
+ int integrity_length;
+ char *resp_data;
+ char *authentication_key;
+ char *cipher_data;
+ char *integrity_data;
+};
+
+static struct wifii_authentication_data *wifi_authdata;
+
+static void *__netconfig_wifi_free_wifi_authdata(
+ struct wifii_authentication_data *data)
+{
+ if (data != NULL) {
+ if (data->resp_data)
+ g_free(data->resp_data);
+ if (data->authentication_key)
+ g_free(data->authentication_key);
+ if (data->cipher_data)
+ g_free(data->cipher_data);
+ if (data->integrity_data)
+ g_free(data->integrity_data);
+
+ g_free(data);
+ data = NULL;
+ }
+
+ return NULL;
+}
+
+static void __netconfig_wifi_clean_authentication(void)
+{
+ netconfig_tel_deinit();
+
+ wifi_authdata = __netconfig_wifi_free_wifi_authdata(wifi_authdata);
+}
+
+static gboolean __netconfig_wifi_get_sim_imsi(DBusGMethodInvocation *context)
+{
+ int ret;
+ GError *error = NULL;
+ TapiHandle *handle;
+ TelSimImsiInfo_t imsi_info;
+ char *imsi;
+
+ handle = (TapiHandle *)netconfig_tel_init();
+ if (handle == NULL) {
+ ERR("tapi_init failed");
+
+ netconfig_error_fail_get_imsi(&error);
+ dbus_g_method_return_error(context, error);
+ g_clear_error(&error);
+ return FALSE;
+ }
+
+ 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);
+ g_clear_error(&error);
+
+ return FALSE;
+ }
+
+ imsi = g_strdup_printf("%s%s%s", imsi_info.szMcc,
+ imsi_info.szMnc, imsi_info.szMsin);
+
+ dbus_g_method_return(context, imsi);
+ g_free(imsi);
+
+ return TRUE;
+}
+
+void __netconfig_response_sim_authentication(TapiHandle *handle,
+ int result, void *data, void *user_data)
+{
+ 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;
+ if (auth_resp == NULL) {
+ ERR("the auth response is NULL");
+
+ wifi_authdata->auth_result = -1;
+ return;
+ } 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;
+
+ 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);
+ } 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)
+{
+ 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;
+ if (auth_resp == NULL) {
+ ERR("the auth response is NULL");
+
+ wifi_authdata->auth_result = -1;
+ return;
+ } 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->cipher_length = auth_resp->cipher_length;
+ wifi_authdata->integrity_length = auth_resp->integrity_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)
+{
+ int i;
+ int ret;
+ TapiHandle *handle;
+ TelSimAuthenticationData_t auth_data;
+
+ 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);
+ 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);
+ 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);
+
+ handle = (TapiHandle *)netconfig_tel_init();
+ if (handle == NULL) {
+ netconfig_error_fail_req_sim_auth(error);
+ return FALSE;
+ }
+
+ 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);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean __netconfig_wifi_req_aka_auth(
+ GArray *rand_data, GArray *autn_data, GError **error)
+{
+ int i;
+ int ret;
+ TapiHandle *handle;
+ TelSimAuthenticationData_t auth_data;
+
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+
+ handle = (TapiHandle *)netconfig_tel_init();
+ if (handle == NULL) {
+ netconfig_error_fail_req_sim_auth(error);
+ return FALSE;
+ }
+
+ ret = tel_req_sim_authentication(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);
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean __netconfig_wifi_get_sim_authdata(DBusGMethodInvocation *context)
+{
+ 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);
+ g_clear_error(&error);
+
+ 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);
+ } 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);
+ g_clear_error(&error);
+
+ __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);
+ g_clear_error(&error);
+
+ __netconfig_wifi_clean_authentication();
+
+ return FALSE;
+ }
+
+ __netconfig_wifi_clean_authentication();
+
+ return TRUE;
+}
+
+static gboolean __netconfig_wifi_get_aka_authdata(DBusGMethodInvocation *context)
+{
+ 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);
+ g_clear_error(&error);
+
+ return FALSE;
+ }
+
+ switch (wifi_authdata->auth_result) {
+ case TAPI_SIM_AUTH_NO_ERROR:
+ break;
+
+ 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);
+ 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);
+
+ dbus_g_method_return(context, array);
+ g_array_free (array, TRUE);
+
+ __netconfig_wifi_clean_authentication();
+
+ return TRUE;
+
+ default:
+ netconfig_error_fail_get_sim_auth_wrong_data(&error);
+ dbus_g_method_return_error(context, error);
+ g_clear_error(&error);
+
+ __netconfig_wifi_clean_authentication();
+
+ return FALSE;
+ }
+
+ if ((wifi_authdata->resp_length >= AKA_AUTH_RES_MIN_LEN ||
+ 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);
+
+ 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);
+ } 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);
+
+ netconfig_error_fail_get_sim_auth_wrong_data(&error);
+ dbus_g_method_return_error(context, error);
+ g_clear_error(&error);
+
+ __netconfig_wifi_clean_authentication();
+
+ return FALSE;
+ }
+
+ __netconfig_wifi_clean_authentication();
+
+ return TRUE;
+}
+
+gboolean netconfig_iface_wifi_get_sim_imsi(NetconfigWifi *wifi,
+ DBusGMethodInvocation *context)
+{
+ gboolean ret = TRUE;
+
+ DBG("Get IMSI");
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ ret = __netconfig_wifi_get_sim_imsi(context);
+
+ return ret;
+}
+
+gboolean netconfig_iface_wifi_req_sim_auth(NetconfigWifi *wifi,
+ GArray *rand_data, gboolean *result, GError **error)
+{
+ gboolean ret = TRUE;
+
+ DBG("Request SIM Authentication");
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ ret = __netconfig_wifi_req_sim_auth(rand_data, error);
+
+ *result = ret;
+ return ret;
+}
+
+gboolean netconfig_iface_wifi_req_aka_auth(NetconfigWifi *wifi,
+ GArray *rand_data, GArray *autn_data, gboolean *result, GError **error)
+{
+ gboolean ret = TRUE;
+
+ DBG("Request AKA Authentication");
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ ret = __netconfig_wifi_req_aka_auth(rand_data, autn_data, error);
+
+ *result = ret;
+ return ret;
+}
+
+gboolean netconfig_iface_wifi_get_sim_auth(NetconfigWifi *wifi,
+ DBusGMethodInvocation *context)
+{
+ gboolean ret = TRUE;
+
+ DBG("Get SIM Authdata");
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ ret = __netconfig_wifi_get_sim_authdata(context);
+
+ return ret;
+}
+
+gboolean netconfig_iface_wifi_get_aka_auth(NetconfigWifi *wifi,
+ DBusGMethodInvocation *context)
+{
+ gboolean ret = TRUE;
+
+ DBG("Get AKA Authdata");
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ ret = __netconfig_wifi_get_aka_authdata(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 <errno.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include "log.h"
+#include "util.h"
+#include "netdbus.h"
+#include "emulator.h"
+#include "neterror.h"
+#include "wifi-ccode.h"
+#include "netsupplicant.h"
+#include "wifi-firmware.h"
+#include "network-statistics.h"
+
+#define WLAN_DRIVER_SCRIPT "/usr/bin/wlan.sh"
+#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_execute_file(path, args, envs);
+ if (rv < 0)
+ return -EIO;
+
+ /* Do CCODE initialization here */
+ netconfig_wifi_ccode_init();
+
+ 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_execute_file(path, args, envs);
+ if (rv < 0)
+ return -EIO;
+
+ 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;
+
+ DBG("Successfully loaded p2p device driver");
+ return 0;
+#else
+ return -ENODEV;
+#endif
+}
+
+static int __netconfig_p2p_firmware_stop(void)
+{
+#if defined TIZEN_P2P_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_execute_file(path, args, envs);
+ if (rv < 0)
+ return -EIO;
+
+ DBG("Successfully removed p2p device driver");
+ return 0;
+#else
+ 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;
+
+ DBG("Successfully loaded softap device driver");
+ return 0;
+#else
+ return -ENODEV;
+#endif
+}
+
+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_execute_file(path, args, envs);
+ if (rv < 0)
+ return -EIO;
+
+ DBG("Successfully removed softap device driver");
+ return 0;
+#else
+ return -ENODEV;
+#endif
+}
+
+static int __netconfig_wifi_firmware_start(enum netconfig_wifi_firmware type)
+{
+ if (netconfig_emulator_is_emulated() == TRUE)
+ return -EIO;
+
+ switch (type) {
+ case NETCONFIG_WIFI_STA:
+ 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 -ENXIO;
+}
+
+static int __netconfig_wifi_firmware_stop(enum netconfig_wifi_firmware type)
+{
+ if (netconfig_emulator_is_emulated() == TRUE)
+ return -EIO;
+
+ switch (type) {
+ case NETCONFIG_WIFI_STA:
+ 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;
+ }
+
+ return -ENXIO;
+}
+
+int netconfig_wifi_firmware(enum netconfig_wifi_firmware type, gboolean enable)
+{
+ int err;
+ static enum netconfig_wifi_firmware current_driver = NETCONFIG_WIFI_OFF;
+ enum netconfig_wifi_firmware alias = type;
+
+#if defined WLAN_CONCURRENT_MODE
+ int flight_mode = 0;
+
+ if (type == NETCONFIG_WIFI_P2P)
+ alias = NETCONFIG_WIFI_STA;
+#endif
+
+ 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_CONCURRENT_MODE
+ vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode);
+
+ if (flight_mode == 0 && type == NETCONFIG_WIFI_STA &&
+ netconfig_is_wifi_direct_on() == TRUE) {
+ netconfig_interface_down(WIFI_IFNAME);
+
+ return -EALREADY;
+ }
+
+ if (type == NETCONFIG_WIFI_P2P &&
+ netconfig_wifi_state_get_technology_state() >
+ NETCONFIG_WIFI_TECH_OFF) {
+ netconfig_interface_down(WLAN_P2P_IFACE_NAME);
+
+ return -EALREADY;
+ }
+#endif
+ err = __netconfig_wifi_firmware_stop(type);
+ if (err < 0 && err != -EALREADY)
+ return err;
+
+ current_driver = NETCONFIG_WIFI_OFF;
+
+ return err;
+ }
+
+ return -EIO;
+ }
+
+ if (current_driver > NETCONFIG_WIFI_OFF) {
+ if (current_driver == alias) {
+
+#if defined WLAN_CONCURRENT_MODE
+ if (type == NETCONFIG_WIFI_STA)
+ netconfig_interface_up(WIFI_IFNAME);
+#if defined TIZEN_P2P_ENABLE
+ else if (type == NETCONFIG_WIFI_P2P)
+ netconfig_interface_up(WLAN_P2P_IFACE_NAME);
+#endif
+#endif
+ return -EALREADY;
+ }
+
+ return -EIO;
+ }
+
+ err = __netconfig_wifi_firmware_start(type);
+ if (err < 0)
+ DBG("Failed to execute script file");
+ else
+ current_driver = alias;
+
+ return err;
+}
+
+gboolean netconfig_iface_wifi_start(
+ NetconfigWifi *wifi, gchar *device, GError **error)
+{
+ int err;
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ DBG("Wi-Fi firmware start %s", device != NULL ? device : "null");
+
+ if (g_strcmp0("p2p", device) == 0)
+ err = netconfig_wifi_firmware(NETCONFIG_WIFI_P2P, TRUE);
+ else if (g_strcmp0("softap", device) == 0)
+ err = netconfig_wifi_firmware(NETCONFIG_WIFI_SOFTAP, TRUE);
+ else
+ err = -EINVAL;
+
+ if (err < 0) {
+ if (err == -EALREADY)
+ netconfig_error_already_exists(error);
+ else
+ netconfig_error_wifi_driver_failed(error);
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+gboolean netconfig_iface_wifi_stop(
+ NetconfigWifi *wifi, gchar *device, GError **error)
+{
+ int err;
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ DBG("Wi-Fi firmware stop %s", device != NULL ? device : "null");
+
+ if (g_strcmp0("p2p", device) == 0)
+ err = netconfig_wifi_firmware(NETCONFIG_WIFI_P2P, FALSE);
+ else if (g_strcmp0("softap", device) == 0)
+ err = netconfig_wifi_firmware(NETCONFIG_WIFI_SOFTAP, FALSE);
+ else
+ err = -EINVAL;
+
+ if (err < 0) {
+ if (err == -EALREADY)
+ netconfig_error_already_exists(error);
+ else
+ netconfig_error_wifi_driver_failed(error);
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
*
*/
+#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 VCONFKEY_WIFI_SNR_MIN -89
-#define NETCONFIG_WIFI_INDICATOR_INTERVAL 3
+#define NETCONFIG_WIFI_INDICATOR_INTERVAL 1
+#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)
+int netconfig_wifi_get_rssi(void)
{
- 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;
+ return netconfig_wifi_rssi;
}
-static int __netconfig_wifi_get_rssi_from_supplicant(void)
+static int __netconfig_wifi_update_and_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;
+ 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;
}
- rssi_dbm = __netconfig_wifi_get_signal((const char *)path_ptr);
-
- return rssi_dbm;
-}
-#endif /* #if defined NL80211 */
-
-#if !defined NL80211
-static int __netconfig_wifi_get_rssi_from_system(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;
+ /* 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_str_equal(p_ifname, WIFI_IFNAME) != TRUE)
+ 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;
}
- /* 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;
- }
-
- 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;
- }
- close(fd);
-
- rssi_dbm = stats.qual.level - 255; /** signed integer, so 255 */
+endline:
+ fclose(fp);
+ netconfig_wifi_rssi = rssi_dbm;
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
-
- 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 void __netconfig_wifi_data_activity_booster(int level)
+{
+ gboolean reply = FALSE;
+ char level1[] = "int32:1";
+ char level2[] = "int32:2";
+ char level3[] = "int32:3";
+
+ char lock[] = "int32:2000";
+ char unlock[] = "int32:0";
+
+ char *param_array[] = { NULL, NULL, NULL };
+ static int old_level = 0;
+
+ if (level < 0)
+ return;
+
+ if (level > 0) {
+ /* enable booster */
+ switch(level) {
+ case 1:
+ param_array[0] = level1;
+ break;
+ case 2:
+ param_array[0] = level2;
+ break;
+ case 3:
+ param_array[0] = level3;
+ break;
+ default:
+ ERR("Invalid level");
+ return;
+ }
+ param_array[1] = lock;
+
+ reply = netconfig_invoke_dbus_method_nonblock(
+ "org.tizen.system.deviced",
+ "/Org/Tizen/System/DeviceD/PmQos",
+ "org.tizen.system.deviced.PmQos",
+ "WifiThroughput",
+ param_array,
+ NULL);
+ if (reply != TRUE)
+ return;
+ }
+
+ /* disable previous booster */
+ if (old_level == 0 || old_level == level)
+ return;
+
+ switch(old_level) {
+ case 1:
+ param_array[0] = level1;
+ break;
+ case 2:
+ param_array[0] = level2;
+ break;
+ case 3:
+ param_array[0] = level3;
+ break;
+ default:
+ ERR("Invalid level");
+ return;
+ }
+ param_array[1] = unlock;
+
+ reply = netconfig_invoke_dbus_method_nonblock(
+ "org.tizen.system.deviced",
+ "/Org/Tizen/System/DeviceD/PmQos",
+ "org.tizen.system.deviced.PmQos",
+ "WifiThroughput",
+ param_array,
+ 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) {
+ 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
+ transfer_state = VCONFKEY_WIFI_TRANSFER_STATE_TX;
+ } else {
+ if (rx_diff > 0)
+ transfer_state = VCONFKEY_WIFI_TRANSFER_STATE_RX;
+ else
+ 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;
- rssi_dbm = netconfig_wifi_get_rssi();
+ 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_set_rssi_level(rssi_dbm);
+ __netconfig_wifi_update_indicator();
return TRUE;
}
{
INFO("Start Wi-Fi indicator");
- vconf_set_int(VCONFKEY_WIFI_STRENGTH, VCONFKEY_WIFI_STRENGTH_MAX);
+ 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;
}
--- /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 "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)
+{
+ DBusMessage *reply;
+ DBusMessageIter iter, variant;
+ dbus_bool_t 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 result;
+ }
+
+ if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
+ const char *err_msg = dbus_message_get_error_name(reply);
+ ERR("Error!!! Error message received[%s]", err_msg);
+ return result;
+ }
+
+ dbus_message_iter_init(reply, &iter);
+
+ if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_VARIANT) {
+ dbus_message_iter_recurse(&iter, &variant);
+ if (dbus_message_iter_get_arg_type(&variant) == DBUS_TYPE_INT32) {
+ dbus_message_iter_get_basic(&variant, &value);
+ if (value == TRUE)
+ *enabled = 1;
+ else
+ *enabled = 0;
+
+ result = TRUE;
+ }
+ }
+
+ dbus_message_unref(reply);
+
+ return result;
+}
+
+static gboolean netconfig_wifi_set_passpoint(gint32 enable)
+{
+ gint32 value = enable ? 1 : 0;
+ gboolean result = FALSE;
+ GList *input_args = NULL;
+
+ struct dbus_input_arguments args_enable[2] = {
+ {DBUS_TYPE_INT32, &value},
+ {DBUS_TYPE_INVALID, NULL}
+ };
+
+ input_args = setup_input_args(input_args, args_enable);
+
+ result = netconfig_supplicant_invoke_dbus_interface_property_set(
+ SUPPLICANT_IFACE_INTERFACE, "Passpoint",
+ DBUS_TYPE_INT32_AS_STRING, input_args, NULL);
+ if (result == FALSE)
+ ERR("Fail to set passpoint enable[%d]", enable);
+
+ g_list_free(input_args);
+
+ return result;
+}
+#endif
+
+gboolean netconfig_iface_wifi_get_passpoint(NetconfigWifi *wifi,
+ gint32 *result, GError **error)
+{
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+#if defined TIZEN_WLAN_PASSPOINT
+ if (netconfig_wifi_get_passpoint(result))
+ return TRUE;
+
+ return FALSE;
+#else
+ *result = 0;
+
+ return TRUE;
+#endif
+}
+
+gboolean netconfig_iface_wifi_set_passpoint(NetconfigWifi *wifi,
+ gint32 enable, GError **error)
+{
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+#if defined TIZEN_WLAN_PASSPOINT
+ return netconfig_wifi_set_passpoint(enable);
+#else
+ return FALSE;
+#endif
+}
*
*/
-#include <stdio.h>
-#include <unistd.h>
+#include <errno.h>
#include <vconf.h>
#include <vconf-keys.h>
+#include <ITapiSim.h>
+#include <TapiUtility.h>
+
+#if defined TIZEN_P2P_ENABLE && !defined WLAN_CONCURRENT_MODE
+#if defined TIZEN_P2P_ENABLE
#include <wifi-direct.h>
+#endif
+#endif
#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-wps.h"
+#include "wifi-power.h"
#include "wifi-state.h"
-#include "wifi-ssid-scan.h"
+#include "wifi-tel-intf.h"
+#include "netsupplicant.h"
+#include "network-state.h"
+#include "wifi-firmware.h"
#include "wifi-background-scan.h"
-#include "mdm-private.h"
-
-gboolean netconfig_iface_wifi_load_driver(NetconfigWifi *wifi, GError **error);
-gboolean netconfig_iface_wifi_remove_driver(NetconfigWifi *wifi, GError **error);
-
-#include "netconfig-iface-wifi-glue.h"
-
-#define WLAN_DRIVER_SCRIPT "/usr/bin/wlan.sh"
-
-#define PROP_DEFAULT FALSE
-#define PROP_DEFAULT_STR NULL
-
-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;
+#include "mdm-private.h"
- /* member variable */
- DBusGConnection *conn;
- gchar *path;
-};
+#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"
-static guint32 signals[SIG_LAST] = { 0, };
+#if defined TIZEN_WEARABLE
+#define VCONF_WIFI_WEARABLE_WIFI_USE \
+ "db/private/wifi/wearable_wifi_use"
+#endif
-G_DEFINE_TYPE(NetconfigWifi, netconfig_wifi, G_TYPE_OBJECT);
+static gboolean connman_wifi_technology_state = FALSE;
+static gboolean wifi_firmware_recovery_mode = FALSE;
-static void __netconfig_wifi_gobject_get_property(GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- return;
-}
+static int airplane_mode = 0;
-static void __netconfig_wifi_gobject_set_property(GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+static void __netconfig_wifi_technology_reply(DBusPendingCall *call, void *data)
{
- NetconfigWifi *wifi = NETCONFIG_WIFI(object);
+ DBusMessage *message;
- switch (prop_id) {
- case PROP_WIFI_CONN:
- {
- wifi->conn = g_value_get_boxed(value);
- INFO("wifi(%p) set conn(%p)", wifi, wifi->conn);
- break;
- }
+ message = dbus_pending_call_steal_reply(call);
- case PROP_WIFI_PATH:
- {
- if (wifi->path)
- g_free(wifi->path);
+ if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) {
+ ERR("%s", dbus_message_get_error_name(message));
- wifi->path = g_value_dup_string(value);
- INFO("wifi(%p) path(%s)", wifi, wifi->path);
-
- break;
+ if (dbus_message_is_error(message,
+ CONNMAN_ERROR_INTERFACE ".AlreadyEnabled") == TRUE)
+ netconfig_wifi_update_power_state(TRUE);
+ else if (dbus_message_is_error(message,
+ CONNMAN_ERROR_INTERFACE ".AlreadyDisabled") == TRUE)
+ netconfig_wifi_update_power_state(FALSE);
+ } else {
+ DBG("Successfully requested");
}
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- }
+ dbus_message_unref(message);
+ dbus_pending_call_unref(call);
}
-static void netconfig_wifi_init(NetconfigWifi *wifi)
+static gboolean __netconfig_is_wifi_restricted(void)
{
- DBG("wifi initialize");
+ int restricted_mode = 0;
- wifi->conn = NULL;
- wifi->path = g_strdup(PROP_DEFAULT_STR);
-}
+ vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, &restricted_mode);
+ if (restricted_mode != 0) {
+ DBG("network restricted mode[%d]", restricted_mode);
+ return TRUE;
+ }
-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);
+ return FALSE;
}
-
-static gboolean __netconfig_wifi_enable_technology(void)
+static int __netconfig_wifi_connman_technology(gboolean enable)
{
- DBusMessage *reply = NULL;
- char path[DBUS_PATH_MAX_BUFLEN] = "/";
- char param1[] = "string:wifi";
- char *param_array[] = {NULL, NULL};
-
- param_array[0] = param1;
+ gboolean reply = FALSE;
+ char key[] = "string:Powered";
+ char value_enable[] = "variant:boolean:true";
+ char value_disable[] = "variant:boolean:false";
+ char *param_array[] = { NULL, NULL, NULL };
+
+ if (connman_wifi_technology_state == enable)
+ return -EALREADY;
+
+ param_array[0] = key;
+ if (enable == TRUE)
+ param_array[1] = value_enable;
+ else
+ param_array[1] = value_disable;
- reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE, path,
- CONNMAN_MANAGER_INTERFACE, "EnableTechnology", param_array);
+ reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
+ CONNMAN_WIFI_TECHNOLOGY_PREFIX, CONNMAN_TECHNOLOGY_INTERFACE,
+ "SetProperty", param_array, __netconfig_wifi_technology_reply);
- if (reply == NULL) {
- ERR("Error! Request failed");
- return FALSE;
+ if (reply != TRUE) {
+ ERR("Fail to set technology %s", enable == TRUE ? "enable" : "disable");
+ return -ESRCH;
}
- dbus_message_unref(reply);
+ /* If Wi-Fi powered off,
+ * Do not remove Wi-Fi driver until ConnMan technology state updated
+ */
+ if (enable == TRUE)
+ connman_wifi_technology_state = enable;
+
+ /* 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 TRUE;
+ return 0;
}
-static gboolean __netconfig_wifi_disable_technology(void)
+static int __netconfig_wifi_supplicant(gboolean enable)
{
- DBusMessage *reply = NULL;
- char path[DBUS_PATH_MAX_BUFLEN] = "/";
- char param1[] = "string:wifi";
- char *param_array[] = {NULL, NULL};
+ int rv = 0;
+ const char *path = WLAN_SUPPLICANT_SCRIPT;
+ char *const args_enable[] = { "/usr/sbin/wpa_supp.sh", "start", NULL };
+ char *const args_disable[] = { "/usr/sbin/wpa_supp.sh", "stop", NULL };
+ char *const envs[] = { NULL };
+ static gboolean enabled = FALSE;
- param_array[0] = param1;
+ if (enabled == enable)
+ return -EALREADY;
- reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE, path,
- CONNMAN_MANAGER_INTERFACE, "DisableTechnology", param_array);
+ 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;
- if (reply == NULL) {
- ERR("Error! Request failed");
- return FALSE;
- }
+ DBG("wpa_supplicant %s", enable == TRUE ? "started" : "stopped");
- dbus_message_unref(reply);
+ enabled = enable;
- return TRUE;
+ return 0;
}
-static gboolean __netconfig_wifi_load_driver(void)
+static int __netconfig_p2p_supplicant(gboolean enable)
{
- gboolean rv = FALSE;
- const char *path = WLAN_DRIVER_SCRIPT;
- char *const args[] = { "wlan.sh", "start" };
+ 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 };
- if (netconfig_emulator_is_emulated() == TRUE)
- return rv;
+ 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;
- rv = netconfig_execute_file(path, args, envs);
- if (rv != TRUE) {
- DBG("Failed to load wireless device driver");
- return FALSE;
- }
+ DBG("p2p_supplicant %s", enable == TRUE ? "started" : "stopped");
- DBG("Successfully loaded wireless device drivers");
- return TRUE;
+ return 0;
}
-static gboolean __netconfig_wifi_remove_driver(void)
+void netconfig_wifi_recover_firmware(void)
{
- gboolean rv = FALSE;
- const char *path = WLAN_DRIVER_SCRIPT;
- char *const args[] = { "wlan.sh", "stop" };
- char *const env[] = { NULL };
+ wifi_firmware_recovery_mode = TRUE;
- if (netconfig_emulator_is_emulated() == TRUE)
- return rv;
+ netconfig_wifi_bgscan_stop();
- rv = netconfig_execute_file(path, args, env);
- if (rv != TRUE) {
- DBG("Failed to remove(unload) driver for wireless device");
- return FALSE;
- }
-
- DBG("Successfully removed(unloaded) wireless driver");
- return TRUE;
+ netconfig_wifi_off();
}
-static gboolean __netconfig_wifi_try_to_load_driver(void);
-static gboolean __netconfig_wifi_try_to_remove_driver(void);
-
+#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) {
- __netconfig_wifi_try_to_load_driver();
-
- return;
+ err = netconfig_wifi_on();
+ if (err < 0) {
+ if (err == -EALREADY)
+ netconfig_wifi_update_power_state(TRUE);
+ else
+ netconfig_wifi_notify_power_failed();
+ }
}
-
- /* TODO: error report */
}
static gboolean __netconfig_wifi_direct_power_off(void)
return TRUE;
}
+#endif
-static gboolean __netconfig_wifi_try_to_load_driver(void)
+static int __netconfig_wifi_try_to_load_driver_and_supplicant(void)
{
- int count = 0;
- gchar *wifi_tech_state = NULL;
+ int err = 0;
+ enum netconfig_wifi_tech_state wifi_tech_state;
- if (netconfig_is_wifi_allowed() != TRUE)
- return FALSE;
+ 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;
+
+ 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);
+
+ return 0;
+}
+
+static int __netconfig_wifi_try_to_remove_driver_and_supplicant(void)
+{
+ int err = 0;
+
+ if (wifi_firmware_recovery_mode != TRUE &&
+ netconfig_wifi_is_wps_enabled() == TRUE) {
+ DBG("Wi-Fi WPS mode");
+ return 0;
+ }
+
+ err = netconfig_wifi_firmware(NETCONFIG_WIFI_STA, FALSE);
+ if (err < 0 && err != -EALREADY)
+ return err;
+
+ err = __netconfig_wifi_supplicant(FALSE);
+ if (err < 0 && err != -EALREADY)
+ return err;
+
+ 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");
+
+ wifi_firmware_recovery_mode = FALSE;
+ }
+
+ return 0;
+}
+
+int netconfig_wifi_driver_and_supplicant(gboolean enable)
+{
+ /* 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 __netconfig_wifi_try_to_remove_driver_and_supplicant();
+ }
+}
+
+void netconfig_wifi_disable_technology_state_by_only_connman_signal(void)
+{
+ /* Important: it's only done by ConnMan technology signal update */
+ connman_wifi_technology_state = FALSE;
+}
+
+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) {
+ ERR("MDM: Wi-Fi disabled");
+ netconfig_send_message_to_net_popup("Network connection popup",
+ "wifi restricted", "popup", NULL);
+ return -EPERM;
+ }
+
+ if (__netconfig_is_wifi_restricted() == TRUE)
+ return -EPERM;
if (netconfig_is_wifi_tethering_on() == TRUE) {
/* TODO: Wi-Fi tethering turns off here */
/* return TRUE; */
- return FALSE;
+ 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)
- return TRUE;
- else
- return FALSE;
+ return -EINPROGRESS;
+ else {
+ ERR("Failed to turn Wi-Fi direct off");
+ return -EBUSY;
+ }
}
+#endif
- if (__netconfig_wifi_load_driver() != TRUE) {
- __netconfig_wifi_remove_driver();
+ err = netconfig_wifi_driver_and_supplicant(TRUE);
+ if (err < 0 && err != -EALREADY)
+ return err;
- return FALSE;
- }
+ err = __netconfig_wifi_connman_technology(TRUE);
- for (count = 0; count < 3; count++) {
- __netconfig_wifi_enable_technology();
+ return err;
+}
- wifi_tech_state = netconfig_wifi_get_technology_state();
+int netconfig_wifi_off(void)
+{
+ int err;
- if (wifi_tech_state == NULL) {
- DBG("Failed to get Wi-Fi technology state");
- continue;
- }
+ __netconfig_p2p_supplicant(FALSE);
- if (g_str_equal(wifi_tech_state, "EnabledTechnologies") == TRUE) {
- netconfig_wifi_update_power_state(TRUE);
+ err = __netconfig_wifi_connman_technology(FALSE);
+ if (err == -EALREADY)
+ netconfig_wifi_update_power_state(FALSE);
- netconfig_wifi_device_picker_service_start();
+ return 0;
+}
- g_free(wifi_tech_state);
- wifi_tech_state = NULL;
+#if defined TIZEN_WEARABLE
+int netconfig_wifi_on_wearable(void)
+{
+ int err = 0;
+ int wifi_use;
+ int ps_mode;
+ 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 (vconf_get_int(VCONF_WIFI_WEARABLE_WIFI_USE, &wifi_use) < 0) {
+ ERR("Fail to get VCONF_WIFI_WEARABLE_WIFI_USE");
+ return -EIO;
+ }
- return TRUE;
+ if (wifi_use > 0) {
+ if (vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &ps_mode) < 0) {
+ ERR("Fail to get VCONFKEY_SETAPPL_PSMODE");
+ return -EIO;
}
- g_free(wifi_tech_state);
- wifi_tech_state = NULL;
+ 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;
}
- __netconfig_wifi_try_to_remove_driver();
+ err = netconfig_wifi_driver_and_supplicant(TRUE);
+ if (err < 0 && err != -EALREADY)
+ return err;
- return FALSE;
+ err = __netconfig_wifi_connman_technology(TRUE);
+
+ return err;
}
-static gboolean __netconfig_wifi_try_to_remove_driver(void)
+static void __netconfig_wifi_wearable_wifi_use_mode(keynode_t* node,
+ void* user_data)
{
- int count = 0;
- gchar *wifi_tech_state = NULL;
-
- netconfig_wifi_device_picker_service_stop();
+ int wifi_state;
+ int wifi_use;
- netconfig_wifi_statistics_update_powered_off();
+ if (vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state) < 0) {
+ ERR("Fail to get VCONFKEY_WIFI_STATE");
+ return;
+ }
- for (count = 0; count < 3; count++) {
- __netconfig_wifi_disable_technology();
+ if (node != NULL)
+ wifi_use = vconf_keynode_get_int(node);
+ else
+ vconf_get_int(VCONF_WIFI_WEARABLE_WIFI_USE, &wifi_use);
- wifi_tech_state = netconfig_wifi_get_technology_state();
+ if (wifi_use > 0) {
+ DBG("wifi use on");
+ if (wifi_state > VCONFKEY_WIFI_OFF) {
+ WARN("Wi-Fi is already turned on");
+ return;
+ }
- if (wifi_tech_state == NULL) {
- DBG("Failed to get Wi-Fi technology state");
- continue;
+ netconfig_wifi_on_wearable();
+ } else {
+ DBG("wifi use off");
+ if (wifi_state == VCONFKEY_WIFI_OFF) {
+ WARN("Wi-Fi is already turned off");
+ return;
}
- if (g_str_equal(wifi_tech_state, "EnabledTechnologies") != TRUE) {
- g_free(wifi_tech_state);
- wifi_tech_state = NULL;
+ netconfig_wifi_off();
+ }
+}
+#endif
- break;
- }
+void netconfig_wifi_fetch_airplane_mode(void)
+{
+ int airplane_state = 0;
+ vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &airplane_state);
+ airplane_mode = airplane_state;
+ DBG("airplane mode %s", airplane_state > 0 ? "ON" : "OFF");
+}
+
+#if defined TIZEN_WEARABLE
+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);
- g_free(wifi_tech_state);
- wifi_tech_state = NULL;
+ 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);
}
+}
+#else
+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;
- if (__netconfig_wifi_remove_driver() == TRUE) {
- netconfig_wifi_update_power_state(FALSE);
- return TRUE;
+ vconf_get_int(VCONF_WIFI_OFF_STATE_BY_AIRPLANE, &wifi_off_by_airplane);
+
+ vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
+
+ 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 (airplane_mode == airplane_state)
+ return ;
+
+ airplane_mode = airplane_state;
+
+ if (airplane_state > 0) {
+ /* airplane mode on */
+ if (wifi_state == VCONFKEY_WIFI_OFF)
+ return;
+
+ netconfig_wifi_off();
+
+ 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);
+
+ if (wifi_state > VCONFKEY_WIFI_OFF)
+ return;
+
+ netconfig_wifi_on();
}
+}
+#endif
- return FALSE;
+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_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_RESTRICTED, 0);
+
+ if (wifi_state > VCONFKEY_WIFI_OFF)
+ return;
+
+ netconfig_wifi_on();
+ }
}
-static void __netconfig_wifi_airplane_mode(keynode_t* node,
- void* user_data)
+static void __netconfig_wifi_emergency_mode(keynode_t *node, void *user_data)
{
- int value = 0;
- int wifi_state = 0;
- static gboolean powered_off_by_flightmode = FALSE;
+ int wifi_state = 0, emergency = 0;
+ int wifi_off_by_emergency = 0;
+#if !defined TIZEN_WEARABLE
+ int emergency_by_fmm = 0;
+#endif
+
+ vconf_get_int(VCONF_WIFI_OFF_STATE_BY_EMERGENCY, &wifi_off_by_emergency);
- vconf_get_bool(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, &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 !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);
- if (value > 0) {
- /* flight mode enabled */
+ 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;
- DBG("Turning Wi-Fi off");
+ 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_wifi_try_to_remove_driver();
+ netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_EMERGENCY, 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_wearable();
+ }
+#else
+ if (emergency > SETTING_PSMODE_POWERFUL) {
+ /* emergency mode on */
+ if (wifi_state == VCONFKEY_WIFI_OFF)
return;
- __netconfig_wifi_try_to_load_driver();
+ 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
- powered_off_by_flightmode = FALSE;
- } else
- DBG("Invalid value (%d)", value);
}
-static void __netconfig_wifi_pm_state_mode(keynode_t* node,
- void* user_data)
+static void __netconfig_wifi_pm_state_mode(keynode_t* node, void* user_data)
{
- int value = -1;
+ int new_state = -1;
int wifi_state = 0;
static int prev_state = VCONFKEY_PM_STATE_NORMAL;
- /*** vconf-keys.h ***
- * VCONFKEY_PM_STATE_NORMAL = 1,
- * VCONFKEY_PM_STATE_LCDDIM,
- * VCONFKEY_PM_STATE_LCDOFF,
- * VCONFKEY_PM_STATE_SLEEP
- */
-
- 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)
- return;
- }
-
- 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);
+
+ DBG("wifi state: %d (0 off / 1 on / 2 connected)", wifi_state);
+ DBG("Old PM state: %d, current: %d", prev_state, new_state);
- if((value == VCONFKEY_PM_STATE_NORMAL) && (prev_state >= VCONFKEY_PM_STATE_LCDOFF)) {
- DBG("PM state : Wake UP!");
+ 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);
+ } else if ((new_state == VCONFKEY_PM_STATE_LCDOFF) &&
+ (prev_state < VCONFKEY_PM_STATE_LCDOFF)) {
}
- prev_state = value;
+ prev_state = new_state;
}
-static void __netconfig_wifi_power_configuration(void)
+static void _tapi_noti_sim_status_cb(TapiHandle *handle, const char *noti_id,
+ void *data, void *user_data)
{
- int wifi_last_power_state = 0;
+ TelSimCardStatus_t *status = data;
- vconf_notify_key_changed(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL,
- __netconfig_wifi_airplane_mode, NULL);
+ if (*status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED) {
+ DBG("Turn Wi-Fi on automatically");
+#if defined TIZEN_WEARABLE
+ netconfig_wifi_on_wearable();
+#else
+ netconfig_wifi_on();
+#endif
+ netconfig_tel_deinit();
+ }
+}
- vconf_notify_key_changed(VCONFKEY_PM_STATE,
- __netconfig_wifi_pm_state_mode, NULL);
+static gboolean netconfig_tapi_check_sim_state(void)
+{
+ int ret, card_changed;
+ TelSimCardStatus_t status;
+ TapiHandle *tapi_handle = NULL;
- vconf_get_int(VCONF_WIFI_LAST_POWER_STATE, &wifi_last_power_state);
+ tapi_handle = (TapiHandle *)netconfig_tel_init();
- if (wifi_last_power_state == WIFI_POWER_ON) {
- DBG("Turn Wi-Fi on automatically");
+ 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;
+ }
- __netconfig_wifi_try_to_load_driver();
+ 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;
}
-static void __netconfig_wifi_notify_power_completed(gboolean power_on)
+static void __netconfig_tapi_state_changed_cb(keynode_t * node, void *data)
{
- DBusMessage *signal;
- DBusConnection *connection = NULL;
- DBusError error;
- char *sig_name = NULL;
+ int tapi_state = 0;
- if (power_on)
- sig_name = "PowerOnCompleted";
+ if (node != NULL)
+ tapi_state = vconf_keynode_get_int(node);
else
- sig_name = "PowerOffCompleted";
+ vconf_get_int(VCONFKEY_TELEPHONY_TAPI_STATE, &tapi_state);
- dbus_error_init(&error);
+ if (tapi_state != VCONFKEY_TELEPHONY_TAPI_STATE_NONE) {
+ if (netconfig_tapi_check_sim_state() == FALSE) {
+ DBG("Sim is not initialized yet.");
- 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);
- return;
- }
-
- signal = dbus_message_new_signal(NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, sig_name);
- if (signal == NULL)
+ goto done;
+ }
+ } else
return;
- dbus_connection_send(connection, signal, NULL);
+ DBG("Turn Wi-Fi on automatically");
- dbus_message_unref(signal);
- dbus_connection_unref(connection);
+#if defined TIZEN_WEARABLE
+ netconfig_wifi_on_wearable();
+#else
+ netconfig_wifi_on();
+#endif
- INFO("(%s)", sig_name);
+done:
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_TAPI_STATE,
+ __netconfig_tapi_state_changed_cb);
}
-gpointer netconfig_wifi_create_and_init(DBusGConnection *conn)
+void netconfig_wifi_power_initialize(void)
{
- GObject *object;
+ int tapi_state = 0;
+ int airplane_state = 0;
+ int wifi_last_power_state = 0;
- g_return_val_if_fail(conn != NULL, NULL);
+ vconf_get_int(VCONF_WIFI_LAST_POWER_STATE, &wifi_last_power_state);
- object = g_object_new(NETCONFIG_TYPE_WIFI, "conn", conn, "path",
- NETCONFIG_WIFI_PATH, NULL);
+ if (wifi_last_power_state > VCONFKEY_WIFI_OFF) {
+ vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &airplane_state);
- INFO("create wifi(%p)", object);
+ if (airplane_state == 0) {
+ vconf_get_int(VCONFKEY_TELEPHONY_TAPI_STATE, &tapi_state);
- dbus_g_connection_register_g_object(conn, NETCONFIG_WIFI_PATH, object);
+ if (tapi_state == VCONFKEY_TELEPHONY_TAPI_STATE_NONE) {
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_TAPI_STATE,
+ __netconfig_tapi_state_changed_cb, NULL);
- INFO("wifi(%p) register DBus path(%s)", object, NETCONFIG_WIFI_PATH);
+ goto done;
+ } else {
+ if (netconfig_tapi_check_sim_state() == FALSE) {
+ DBG("Sim is not initialized yet.");
- __netconfig_wifi_power_configuration();
+ goto done;
+ }
+ }
+ }
- return object;
+ DBG("Turn Wi-Fi on automatically");
+
+#if defined TIZEN_WEARABLE
+ netconfig_wifi_on_wearable();
+#else
+ netconfig_wifi_on();
+#endif
+ }
+
+done:
+#if defined TIZEN_WEARABLE
+ vconf_notify_key_changed(VCONF_WIFI_WEARABLE_WIFI_USE,
+ __netconfig_wifi_wearable_wifi_use_mode, NULL);
+#endif
+
+#if defined TIZEN_WEARABLE
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+ __netconfig_wifi_wearable_airplane_mode, NULL);
+#else
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+ __netconfig_wifi_airplane_mode, NULL);
+#endif
+
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE,
+ __netconfig_wifi_restrict_mode, NULL);
+
+ 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);
}
-gboolean netconfig_iface_wifi_load_driver(NetconfigWifi *wifi, GError **error)
+gboolean netconfig_iface_wifi_load_driver(NetconfigWifi *wifi,
+ gboolean device_picker_test, GError **error)
{
- DBG("Wi-Fi turned on");
+ int err;
+
+ DBG("Wi-Fi power on requested");
g_return_val_if_fail(wifi != NULL, FALSE);
- if (netconfig_is_wifi_allowed() != TRUE) {
- netconfig_error_security_restricted(error);
+#if defined TIZEN_WEARABLE
+ err = netconfig_wifi_on_wearable();
+#else
+ err = netconfig_wifi_on();
+#endif
+ if (err < 0) {
+ if (err == -EINPROGRESS)
+ netconfig_error_inprogress(error);
+ else if (err == -EALREADY)
+ netconfig_error_already_exists(error);
+ else if (err == -EPERM)
+ netconfig_error_permission_denied(error);
+ else
+ netconfig_error_wifi_driver_failed(error);
return FALSE;
}
- if (__netconfig_wifi_try_to_load_driver() != TRUE) {
- netconfig_error_wifi_driver_failed(error);
+ if (device_picker_test == TRUE)
+ netconfig_wifi_enable_device_picker_test();
- return FALSE;
- }
+ netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_AIRPLANE, 0);
- __netconfig_wifi_notify_power_completed(TRUE);
return TRUE;
}
gboolean netconfig_iface_wifi_remove_driver(NetconfigWifi *wifi, GError **error)
{
- DBG("Wi-Fi turned off");
+ int err;
+
+ DBG("Wi-Fi power off requested");
g_return_val_if_fail(wifi != NULL, FALSE);
- if (__netconfig_wifi_try_to_remove_driver() != TRUE) {
- netconfig_error_wifi_driver_failed(error);
+ err = netconfig_wifi_off();
+ if (err < 0) {
+ if (err == -EINPROGRESS)
+ netconfig_error_inprogress(error);
+ else if (err == -EALREADY)
+ netconfig_error_already_exists(error);
+ else if (err == -EPERM)
+ netconfig_error_permission_denied(error);
+ else
+ netconfig_error_wifi_driver_failed(error);
return FALSE;
}
- __netconfig_wifi_notify_power_completed(FALSE);
+ netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_AIRPLANE, 0);
+
return TRUE;
}
+
+gboolean netconfig_iface_wifi_load_p2p_driver(NetconfigWifi *wifi, GError **error)
+{
+ int err = 0;
+
+ DBG("P2P power on requested");
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+#if defined TIZEN_WEARABLE
+ err = netconfig_wifi_on_wearable();
+#elif defined WLAN_CONCURRENT_MODE
+ err = netconfig_wifi_on();
+#else
+ err = netconfig_wifi_firmware(NETCONFIG_WIFI_STA, TRUE);
+#endif
+ if (err < 0)
+ if (err != -EINPROGRESS && err != -EALREADY)
+ return FALSE;
+
+ netconfig_set_vconf_int(VCONF_WIFI_OFF_STATE_BY_AIRPLANE, 0);
+
+ err = __netconfig_p2p_supplicant(TRUE);
+ if (err < 0)
+ return FALSE;
+
+ return TRUE;
+}
+
+gboolean netconfig_iface_wifi_remove_p2p_driver(NetconfigWifi *wifi, GError **error)
+{
+ int err = 0;
+
+ DBG("P2P power off requested");
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ err = __netconfig_p2p_supplicant(FALSE);
+ if (err < 0)
+ return FALSE;
+
+ 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 <alarm.h>
+#include <vconf.h>
+#include <unistd.h>
+#include <net/if.h>
+#include <sys/ioctl.h>
+#include <vconf-keys.h>
+
+#include "log.h"
+#include "util.h"
+#include "wifi-state.h"
+#include "wifi-power.h"
+#include "netsupplicant.h"
+#include "wifi-powersave.h"
+#include "wifi-background-scan.h"
+
+#define VCONF_WIFI_SLEEPPOLICY "file/private/wifi/sleep_policy"
+#define NETCONFIG_POWERSAVE_DELAY 900 /* 15 mins */
+
+enum netconfig_wifi_powersave_mode {
+ NETCONFIG_WIFI_ALWAYS_KEEP_CONNECTED = 0x00,
+ NETCONFIG_WIFI_KEEP_CONNECTED_WHEN_PLUGGED_IN = 0x01,
+ NETCONFIG_WIFI_NEVER_KEEP = 0x02,
+};
+
+struct netconfig_wifi_priv_cmd {
+ char *buf;
+ int used_len;
+ int total_len;
+};
+
+
+static alarm_id_t netconfig_wifi_powersave_timer_id = 0;
+static gboolean netconfig_wifi_powersave_state = FALSE;
+
+static void __netconfig_wifi_powersave_start_alarm_timer(void)
+{
+ int result;
+
+ result = alarmmgr_add_alarm(ALARM_TYPE_VOLATILE, NETCONFIG_POWERSAVE_DELAY,
+ 0, NULL, &netconfig_wifi_powersave_timer_id);
+ if (result == ALARMMGR_RESULT_SUCCESS)
+ DBG("Deep sleep mode alarm added successfully -[%d]",
+ netconfig_wifi_powersave_timer_id);
+ else
+ DBG("Deep sleep mode alarm add failed - [%d]", result);
+}
+
+static void __netconfig_wifi_powersave_stop_alarm_timer(int alarm_id)
+{
+ int result;
+
+ result = alarmmgr_remove_alarm(alarm_id);
+ if (result == ALARMMGR_RESULT_SUCCESS) {
+ netconfig_wifi_powersave_timer_id = 0;
+ DBG("Deep sleep mode alarm removed successfully - [%d]", alarm_id);
+ } else
+ DBG("Deep sleep mode alarm remove failed - [%d]", result);
+}
+
+static void __netconfig_wifi_powersave_private_cmd(gboolean start)
+{
+ int fd;
+ char buf[8192] = { 0, };
+ const char *START = "START";
+ const char *STOP = "STOP";
+ const char *cmd;
+
+ struct ifreq ifr;
+ struct netconfig_wifi_priv_cmd priv_cmd;
+
+ fd = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+ if (fd < 0)
+ return;
+
+ memset(&ifr, 0, sizeof(ifr));
+ memset(&priv_cmd, 0, sizeof(priv_cmd));
+ g_strlcpy(ifr.ifr_name, WIFI_IFNAME, IFNAMSIZ);
+
+ if (start == TRUE)
+ cmd = START;
+ else
+ cmd = STOP;
+ g_strlcpy(buf, cmd, sizeof(buf));
+ priv_cmd.buf = buf;
+ priv_cmd.used_len = 8192;
+ priv_cmd.total_len = 8192;
+ ifr.ifr_data = (void *)&priv_cmd;
+
+ if (ioctl(fd, SIOCDEVPRIVATE + 1, &ifr) < 0)
+ ERR("Failed private command %s and reply %s", cmd, buf);
+
+ DBG("Private command %s and reply %s", cmd, buf);
+ close(fd);
+}
+
+int __netconfig_wifi_powersave_timer_expired(alarm_id_t alarm_id,
+ void *user_param)
+{
+ DBG("Wi-Fi power save mode");
+
+ netconfig_wifi_powersave_state = TRUE;
+
+ __netconfig_wifi_powersave_stop_alarm_timer(alarm_id);
+
+ __netconfig_wifi_powersave_private_cmd(TRUE);
+
+ netconfig_wifi_bgscan_stop();
+
+ netconfig_wifi_off();
+
+ return 0;
+}
+
+void netconfig_wifi_early_suspend(gboolean value)
+{
+ static gboolean old_state = FALSE;
+ struct ifreq ifr;
+ char buf[248] = { '\0' }; /* Max driver command size is 248 */
+ struct netconfig_wifi_priv_cmd priv_cmd;
+ int ret = 0;
+ int ioctl_sock = 0;
+ int pm_state = 0;
+ enum netconfig_wifi_service_state wifi_state;
+ size_t buf_len;
+
+ if (old_state == value)
+ return;
+
+ if (vconf_get_int(VCONFKEY_PM_STATE, &pm_state) < 0)
+ ERR("Fail to get VCONFKEY_PM_STATE");
+
+ wifi_state = netconfig_wifi_state_get_service_state();
+
+ if (value == TRUE &&
+ (pm_state < VCONFKEY_PM_STATE_LCDOFF ||
+ wifi_state == NETCONFIG_WIFI_ASSOCIATION ||
+ wifi_state == NETCONFIG_WIFI_CONFIGURATION))
+ return;
+
+ g_snprintf(buf, sizeof(buf), "SETSUSPENDMODE %d", value);
+
+ memset(&ifr, 0, sizeof(struct ifreq));
+ g_strlcpy((char *)ifr.ifr_name, WIFI_IFNAME, IFNAMSIZ);
+
+ DBG("Early suspend command: [%s]", buf);
+
+ memset(&priv_cmd, 0, sizeof(priv_cmd));
+ buf_len = strlen(buf);
+ priv_cmd.buf = buf;
+ priv_cmd.used_len = buf_len;
+ priv_cmd.total_len = buf_len;
+ ifr.ifr_data = (char *)&priv_cmd;
+
+ ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
+ if (ioctl_sock < 0) {
+ DBG("socket(PF_INET,SOCK_DGRAM) failed");
+ return;
+ }
+
+ ret = ioctl(ioctl_sock, SIOCDEVPRIVATE + 1, &ifr);
+ if (ret < 0)
+ ERR("Fail to issue private commands: %d", ret);
+ else
+ old_state = value;
+
+ close(ioctl_sock);
+}
+
+gboolean netconfig_wifi_is_powersave_mode(void)
+{
+ return netconfig_wifi_powersave_state;
+}
+
+void netconfig_wifi_powersave_start(void)
+{
+ int powersave_policy = 0;
+ int charger_state = 0;
+
+ if (netconfig_wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED)
+ return;
+
+ DBG("Check Wi-Fi deep sleep mode activation");
+
+ /* Deep sleep policy options
+ * 0 : Always - Wi-Fi always ON; No need to handle deep sleep mode
+ * 1 : Plugged-in - Handle deep sleep mode only when phone plugged-in
+ * 2 : Never - Handle deep sleep mode always
+ */
+ if (vconf_get_int(VCONF_WIFI_SLEEPPOLICY, &powersave_policy) < 0) {
+ ERR("Fail to get VCONF_WIFI_SLEEPPOLICY");
+ return;
+ }
+ DBG("Deep sleep policy: %d", powersave_policy);
+
+ if (powersave_policy == NETCONFIG_WIFI_KEEP_CONNECTED_WHEN_PLUGGED_IN) {
+ /* Charger connection status
+ * VCONFKEY_SYSMAN_CHARGER_DISCONNECTED = 0
+ * VCONFKEY_SYSMAN_CHARGER_CONNECTED
+ */
+ if (vconf_get_int(VCONFKEY_SYSMAN_CHARGER_STATUS, &charger_state) < 0) {
+ ERR("Fail to get VCONFKEY_SYSMAN_CHARGER_STATUS");
+ return;
+ }
+ DBG("Charger status: %d", charger_state);
+ }
+
+ if (powersave_policy == NETCONFIG_WIFI_NEVER_KEEP ||
+ (powersave_policy == NETCONFIG_WIFI_KEEP_CONNECTED_WHEN_PLUGGED_IN &&
+ charger_state == VCONFKEY_SYSMAN_CHARGER_DISCONNECTED))
+ __netconfig_wifi_powersave_start_alarm_timer();
+}
+
+void netconfig_wifi_powersave_stop(void)
+{
+ DBG("Check Wi-Fi deep sleep mode de-activation");
+
+ if (netconfig_wifi_powersave_state == TRUE) {
+ DBG("Out of deep sleep mode");
+
+ __netconfig_wifi_powersave_private_cmd(FALSE);
+
+ netconfig_wifi_on();
+
+ netconfig_wifi_powersave_state = FALSE;
+ } else
+ __netconfig_wifi_powersave_stop_alarm_timer(
+ netconfig_wifi_powersave_timer_id);
+}
+
+void netconfig_wifi_powersave_init(void)
+{
+ int result;
+
+ result = alarmmgr_init(PACKAGE);
+ if (result == ALARMMGR_RESULT_SUCCESS) {
+ DBG("Alarm manager init successful");
+
+ result = alarmmgr_set_cb(__netconfig_wifi_powersave_timer_expired, NULL);
+ if (result == ALARMMGR_RESULT_SUCCESS)
+ DBG("Alarm manager set callback successful");
+ else
+ DBG("Alarm manager set callback failed - [%d]", result);
+ } else
+ DBG("Alarm manager init failed - [%d]", result);
+}
+
+void netconfig_wifi_powersave_deinit(void)
+{
+ alarmmgr_fini();
+}
*/
#include "log.h"
+#include "util.h"
#include "neterror.h"
#include "netdbus.h"
#include "netsupplicant.h"
#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;
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)
+{
+ netconfig_wifi_notify_ssid_scan_done();
+
+ return FALSE;
+}
-static void __netconfig_wifi_ssid_scan_start(void)
+static void __netconfig_wifi_ssid_scan_started(void)
{
+ INFO("Wi-Fi SSID scan started");
wifi_ssid_scan_state = TRUE;
+
+ netconfig_start_timer_seconds(5,
+ __netconfig_wifi_ssid_scan_timeout,
+ NULL,
+ &netconfig_wifi_ssid_scan_timer);
}
-static void __netconfig_wifi_ssid_scan_stop(void)
+static void __netconfig_wifi_ssid_scan_finished(void)
{
+ INFO("Wi-Fi SSID scan finished");
wifi_ssid_scan_state = FALSE;
+
+ netconfig_stop_timer(&netconfig_wifi_ssid_scan_timer);
}
static gboolean __netconfig_wifi_invoke_ssid_scan(
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);
if (connection == NULL) {
- ERR("Error!!! Failed to get system DBus");
+ ERR("Failed to get system DBus");
goto error;
}
goto error;
}
- MessageType = dbus_message_get_type(reply);
- if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
+ if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
const char *err_msg = dbus_message_get_error_name(reply);
ERR("Error!!! Error message received %s", err_msg);
goto error;
}
- INFO("Message type :%d", MessageType);
+ if (g_ssid != NULL) {
+ g_free(g_ssid);
+ }
+ g_ssid = g_strdup(ssid);
dbus_message_unref(message);
dbus_message_unref(reply);
DBusConnection *connection = NULL;
DBusMessageIter dict, type, array, value;
DBusError error;
- char *prop_ssid = "ssid";
- char *prop_security = "security";
+
+ GSList* list = NULL;
+ const char *prop_ssid = "ssid";
+ const char *prop_security = "security";
+ const char *prop_wps = "wps";
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);
+ ERR("Failed to get system DBus, error [%s]", error.message);
dbus_error_free(&error);
g_slist_free_full(wifi_bss_info_list, g_free);
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);
g_slist_free_full(wifi_bss_info_list, g_free);
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);
+ for (list = wifi_bss_info_list; list != NULL; list = list->next) {
+ struct bss_info_t *bss_info = (struct bss_info_t *)list->data;
- /* Lets pack the SSID */
+ if (bss_info && g_strcmp0((char *)bss_info->ssid, g_ssid) == 0) {
+ char *ssid = (char *)bss_info->ssid;
+ enum netconfig_wifi_security security = bss_info->security;
+ dbus_bool_t wps = bss_info->wps;
+ DBG("BSS found; SSID:%s security:%d WPS:%d", ssid, security, wps);
+
+ /* 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_close_container(&type, &value);
dbus_message_iter_close_container(&dict, &type);
- /* Lets pack the Security */
+ /* 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_open_container(&type, DBUS_TYPE_VARIANT, DBUS_TYPE_INT32_AS_STRING, &value);
- dbus_message_iter_append_basic(&value, DBUS_TYPE_INT16, &security);
+ dbus_message_iter_append_basic(&value, DBUS_TYPE_INT32, &security);
+ dbus_message_iter_close_container(&type, &value);
+ dbus_message_iter_close_container(&dict, &type);
+
+ /* WPS */
+ dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, 0, &type);
+ dbus_message_iter_append_basic(&type, DBUS_TYPE_STRING, &prop_wps);
+ dbus_message_iter_open_container(&type, DBUS_TYPE_VARIANT, DBUS_TYPE_BOOLEAN_AS_STRING, &value);
+
+ dbus_message_iter_append_basic(&value, DBUS_TYPE_BOOLEAN, &wps);
dbus_message_iter_close_container(&type, &value);
dbus_message_iter_close_container(&dict, &type);
}
- list = g_slist_next(list);
}
dbus_message_iter_close_container(&array, &dict);
- dbus_error_init(&error);
dbus_connection_send(connection, signal, NULL);
dbus_message_unref(signal);
g_slist_free_full(wifi_bss_info_list, g_free);
wifi_bss_info_list = NULL;
- INFO("(%s)", sig_name);
-}
-
-static gboolean __netconfig_wifi_ssid_scan(const char *ssid)
-{
- char object_path[DBUS_PATH_MAX_BUFLEN] = { 0, };
- char *path_ptr = &object_path[0];
-
- if (ssid == NULL)
- return FALSE;
-
- DBG("Start SSID Scan with %s", 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 (g_ssid != NULL) {
+ g_free(g_ssid);
+ g_ssid = NULL;
}
- if (__netconfig_wifi_invoke_ssid_scan(
- (const char *)object_path, ssid) == TRUE) {
- __netconfig_wifi_ssid_scan_start();
-
- return TRUE;
- }
-
- return FALSE;
+ INFO("(%s)", sig_name);
}
static void __netconfig_wifi_check_security(const char *str_keymgmt, struct bss_info_t *bss_data)
return wifi_ssid_scan_state;
}
-void netconfig_wifi_notify_ssid_scan_done(DBusMessage *message)
+void netconfig_wifi_notify_ssid_scan_done(void)
{
- DBusMessageIter args;
- dbus_bool_t val = FALSE;
-
if (netconfig_wifi_get_ssid_scan_state() != TRUE)
return;
- __netconfig_wifi_ssid_scan_stop();
+ __netconfig_wifi_ssid_scan_finished();
- INFO("SSID scan finishes");
-
- if (!dbus_message_iter_init(message, &args))
- DBG("Message does not have parameters");
- else if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_BOOLEAN)
- DBG("Argument is not boolean");
- else {
- dbus_message_iter_get_basic(&args, &val);
- DBG("!!!!!!! SpecificScanDone : %d", val);
-
- __netconfig_wifi_notify_ssid_scan_done();
- }
+ __netconfig_wifi_notify_ssid_scan_done();
}
void netconfig_wifi_bss_added(DBusMessage *message)
}
bss_info = g_try_new0(struct bss_info_t, 1);
+ 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_next(&dict);
}
- if (bss_info->ssid == NULL) {
+ if (bss_info->ssid[0] == '\0') {
g_free(bss_info);
return;
}
wifi_bss_info_list = g_slist_append(wifi_bss_info_list, bss_info);
}
+gboolean netconfig_wifi_ssid_scan(const char *ssid)
+{
+ const char *if_path;
+ static char *scan_ssid = NULL;
+
+ netconfig_wifi_bgscan_stop();
+
+ if (ssid != NULL) {
+ g_free(scan_ssid);
+ scan_ssid = g_strdup(ssid);
+ }
+
+ 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 in progress, %s scan will be delayed", scan_ssid);
+ return TRUE;
+ }
+
+ if (wifi_bss_info_list) {
+ g_slist_free_full(wifi_bss_info_list, g_free);
+ wifi_bss_info_list = NULL;
+ }
+
+ 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);
+ scan_ssid = NULL;
+
+ 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)
{
g_return_val_if_fail(wifi != NULL, FALSE);
+ g_return_val_if_fail(ssid != NULL, FALSE);
- /* TODO: If already scan with SSID, make error in-progress */
- /* if (netconfig_wifi_get_ssid_scan_state() != TRUE)
- * netconfig_error_ssid_scan_in_progress();
- */
-
- return __netconfig_wifi_ssid_scan((const char *)ssid);
+ return netconfig_wifi_ssid_scan((const char *)ssid);
}
*
*/
+#include <aul.h>
#include <vconf.h>
#include <vconf-keys.h>
-#include <syspopup_caller.h>
+#include <journal/wifi.h>
#include "log.h"
#include "util.h"
#include "netdbus.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 "wifi-powersave.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 gboolean __netconfig_wifi_add_network_notification(void)
+static void __netconfig_pop_wifi_connected_poppup(const char *ssid)
{
- int rv = 0;
bundle *b = NULL;
+ if (ssid == NULL)
+ return;
+
b = bundle_create();
- bundle_add(b, "_SYSPOPUP_TYPE_", "wifi_notification");
- bundle_add(b, "_SYSPOPUP_CONTENT_", "add");
- DBG("Register Wi-Fi network notification");
- rv = syspopup_launch("net-popup", b);
+ 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);
- bundle_free(b);
+ DBG("Launch Wi-Fi connected alert network popup");
+ aul_launch_app("net.netpopup", b);
- return TRUE;
+ bundle_free(b);
}
-static gboolean __netconfig_wifi_del_network_notification(void)
+static void __netconfig_wifi_state_connected_activation(void)
{
- int rv = 0;
+ /* Add activation of services when Wi-Fi is connected */
bundle *b = NULL;
b = bundle_create();
- bundle_add(b, "_SYSPOPUP_TYPE_", "wifi_notification");
- bundle_add(b, "_SYSPOPUP_CONTENT_", "delete");
-
- DBG("Delete Wi-Fi network notification");
- rv = syspopup_launch("net-popup", b);
-
+ aul_launch_app("org.tizen.keepit-service-standby", b);
bundle_free(b);
- return TRUE;
+ /* logd service checks Wi-Fi state */
+ journal_wifi_network_connected();
}
-static void __netconfig_wifi_set_profiles_count(const int count)
+static void __netconfig_wifi_state_disconnected_activation(void)
{
- profiles_count = count;
+ /* Add activation of services when Wi-Fi is disconnected */
+
+ /* logd service checks Wi-Fi state */
+ journal_wifi_network_disconnected();
}
-static int __netconfig_wifi_get_profiles_count(void)
+static void __netconfig_wifi_state_powered_activation(gboolean powered)
{
- return profiles_count;
+ if (powered == TRUE) {
+ /* Add activation when Wi-Fi is powered on */
+
+ /* logd service checks Wi-Fi power state */
+ journal_wifi_on();
+ } else {
+ /* Add activation when Wi-Fi is powered off */
+
+ /* logd service checks Wi-Fi power state */
+ journal_wifi_off();
+ }
}
-static GSList *__netconfig_wifi_state_get_service_profiles(DBusMessage *message)
+static void __netconfig_wifi_set_essid(void)
{
- GSList *service_profiles = NULL;
- DBusMessageIter iter, dict;
+ const char *essid_name = NULL;
+ const char *wifi_profile = netconfig_get_default_profile();
- dbus_message_iter_init(message, &iter);
- dbus_message_iter_recurse(&iter, &dict);
+ if (netconfig_wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED)
+ return;
- while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
- DBusMessageIter keyValue, array, value;
- const char *key = NULL;
- const char *object_path = NULL;
+ if (wifi_profile == NULL ||
+ netconfig_is_wifi_profile(wifi_profile) != TRUE) {
+ ERR("Can't get Wi-Fi profile");
+ return;
+ }
- dbus_message_iter_recurse(&dict, &keyValue);
- dbus_message_iter_get_basic(&keyValue, &key);
+ essid_name = netconfig_wifi_get_connected_essid(wifi_profile);
+ if (essid_name == NULL) {
+ ERR("Can't get Wi-Fi name");
+ return;
+ }
- if (g_str_equal(key, "Services") != TRUE) {
- dbus_message_iter_next(&dict);
- continue;
- }
+ netconfig_set_vconf_str(VCONFKEY_WIFI_CONNECTED_AP_NAME, essid_name);
- dbus_message_iter_next(&keyValue);
- dbus_message_iter_recurse(&keyValue, &array);
- if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
- return service_profiles;
+ __netconfig_pop_wifi_connected_poppup(essid_name);
+}
+
+static void __netconfig_wifi_unset_essid(void)
+{
+ netconfig_set_vconf_str(VCONFKEY_WIFI_CONNECTED_AP_NAME, "");
+}
+
+static gboolean __netconfig_is_wifi_profile_available(void)
+{
+ DBusMessage *message = NULL;
+ DBusMessageIter iter, array;
+ int ret = FALSE;
- dbus_message_iter_recurse(&array, &value);
- if (dbus_message_iter_get_arg_type(&value) != DBUS_TYPE_OBJECT_PATH)
- return service_profiles;
+ 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;
+ }
- while (dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_OBJECT_PATH) {
- dbus_message_iter_get_basic(&value, &object_path);
+ dbus_message_iter_init(message, &iter);
+ dbus_message_iter_recurse(&iter, &array);
- if (g_str_has_prefix(object_path, CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE)
- service_profiles = g_slist_append(service_profiles, g_strdup(object_path));
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRUCT) {
+ DBusMessageIter entry;
+ const char *obj = NULL;
- dbus_message_iter_next(&value);
+ dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_get_basic(&entry, &obj);
+
+ if (obj == NULL || netconfig_is_wifi_profile(obj) == FALSE) {
+ dbus_message_iter_next(&array);
+ continue;
}
- dbus_message_iter_next(&dict);
+ ret = TRUE;
+ goto done;
}
- return service_profiles;
+done:
+ dbus_message_unref(message);
+
+ return ret;
}
static char *__netconfig_wifi_get_connman_favorite_service(void)
{
char *favorite_service = NULL;
DBusMessage *message = NULL;
- GSList *service_profiles = NULL;
- GSList *list = NULL;
+ DBusMessageIter iter, array;
message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
- CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE, "GetProperties", NULL);
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "GetServices", NULL);
if (message == NULL) {
ERR("Failed to get service list");
-
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;
+ dbus_message_iter_init(message, &iter);
+ dbus_message_iter_recurse(&iter, &array);
- if (favorite_service != NULL)
- break;
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRUCT) {
+ DBusMessageIter entry;
+ DBusMessageIter dict;
+ const char *obj = NULL;
- message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
- profile_path, CONNMAN_SERVICE_INTERFACE, "GetProperties", NULL);
+ dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_get_basic(&entry, &obj);
- if (message == NULL) {
- ERR("Failed to get service information of %s", profile_path);
+ if (obj == NULL || netconfig_is_wifi_profile(obj) == FALSE) {
+ dbus_message_iter_next(&array);
continue;
}
- dbus_message_iter_init(message, &iter);
- dbus_message_iter_recurse(&iter, &array);
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &dict);
- while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
+ while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
DBusMessageIter entry, variant;
const char *key = NULL;
dbus_bool_t value;
- dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_recurse(&dict, &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);
+ dbus_message_iter_next(&dict);
continue;
}
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &variant);
+
dbus_message_iter_get_basic(&variant, &value);
if (value)
- favorite_service = g_strdup(profile_path);
+ favorite_service = g_strdup(obj);
- break;
+ goto done;
}
- dbus_message_unref(message);
+ dbus_message_iter_next(&array);
}
- g_slist_free(service_profiles);
+done:
+ dbus_message_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)
+{
+ dbus_bool_t result;
+ const char *if_path;
+ GList *input_args = NULL;
+ static gboolean old_state = TRUE;
+
+ struct dbus_input_arguments args_disable[2] = {
+ {DBUS_TYPE_STRING, "POWERMODE 1"},
+ {DBUS_TYPE_INVALID, NULL}
+ };
+ struct dbus_input_arguments args_enable[2] = {
+ {DBUS_TYPE_STRING, "POWERMODE 0"},
+ {DBUS_TYPE_INVALID, NULL}
+ };
+
+ 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 = setup_input_args(input_args, args_enable);
+ else
+ input_args = setup_input_args(input_args, 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;
+
+ g_list_free(input_args);
+}
+
+static void __netconfig_wifi_state_set_power_lock(gboolean power_lock)
+{
+ int ret = 0;
+ DBusMessage *reply;
+ char state[] = "string:lcdoff";
+ char flag[] = "string:staycurstate";
+ char standby[] = "string:NULL";
+ char timeout[] = "int32:0";
+ char sleepmargin[] = "string:sleepmargin";
+ char *param_array[] = { NULL, NULL, NULL, NULL, NULL };
+
+ 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 */
+ param_array[0] = state;
+ param_array[1] = flag;
+ param_array[2] = standby;
+ param_array[3] = timeout;
+
+ lock_method = lockstate;
+ } else {
+ /* deviced power lock disable */
+ param_array[0] = state;
+ param_array[1] = 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,
+ param_array);
+ if (reply == NULL)
+ return;
+
+ dbus_message_get_args(reply, NULL, DBUS_TYPE_INT32,
+ &ret, DBUS_TYPE_INVALID);
+ if (ret < 0)
+ ERR("Failed to set power lock %s with ret %d",
+ power_lock == TRUE ? "enable" : "disable", ret);
+ else
+ old_state = power_lock;
+
+ dbus_message_unref(reply);
+}
+
void netconfig_wifi_state_set_service_state(
- enum netconfig_wifi_service_state state)
+ enum netconfig_wifi_service_state new_state)
{
- if (wifi_service_state == state)
+ static gboolean dhcp_stage = FALSE;
+ enum netconfig_wifi_service_state old_state = wifi_service_state;
+
+ if (old_state == new_state)
return;
- wifi_service_state = state;
- DBG("Wi-Fi state %d", 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_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);
+
+ __netconfig_wifi_set_essid();
+
+ netconfig_wifi_indicator_start();
+ } else if (old_state == NETCONFIG_WIFI_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_wifi_indicator_stop();
+
+ netconfig_wifi_set_bgscan_pause(FALSE);
+
+ netconfig_wifi_bgscan_stop();
+ netconfig_wifi_bgscan_start(TRUE);
+ }
- if (wifi_service_state == NETCONFIG_WIFI_CONNECTED)
- __netconfig_wifi_del_network_notification();
+ __netconfig_wifi_state_changed(new_state);
- __netconfig_wifi_state_changed(state);
+ if (new_state == NETCONFIG_WIFI_CONNECTED){
+ __netconfig_wifi_state_connected_activation();
+ } else if (old_state == NETCONFIG_WIFI_CONNECTED)
+ __netconfig_wifi_state_disconnected_activation();
}
enum netconfig_wifi_service_state
return wifi_service_state;
}
-gchar *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 args, dict;
- gboolean wifi_tech_available = FALSE;
- gboolean wifi_tech_enabled = FALSE;
+ DBusMessageIter iter, array;
+ enum netconfig_wifi_tech_state ret = NETCONFIG_WIFI_TECH_OFF;
+ gboolean wifi_tech_powered = FALSE;
+ gboolean wifi_tech_connected = FALSE;
+
+ 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, "GetProperties", NULL);
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "GetTechnologies", NULL);
if (message == NULL) {
ERR("Failed to get Wi-Fi technology state");
- return NULL;
+ return NETCONFIG_WIFI_TECH_UNKNOWN;
}
- dbus_message_iter_init(message, &args);
- dbus_message_iter_recurse(&args, &dict);
+ 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;
- while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
- DBusMessageIter key_iter, sub_iter1, sub_iter2;
- const char *key = NULL;
- const char *tech_name = NULL;
+ dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_get_basic(&entry, &path);
- dbus_message_iter_recurse(&dict, &key_iter);
- dbus_message_iter_get_basic(&key_iter, &key);
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &dict);
- if (g_str_equal(key, "AvailableTechnologies") == TRUE ||
- g_str_equal(key, "EnabledTechnologies") == TRUE) {
- dbus_message_iter_next(&key_iter);
- dbus_message_iter_recurse(&key_iter, &sub_iter1);
+ if (path == NULL ||
+ g_str_equal(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == FALSE) {
+ dbus_message_iter_next(&array);
+ continue;
+ }
- if (dbus_message_iter_get_arg_type(&sub_iter1) == DBUS_TYPE_ARRAY)
- dbus_message_iter_recurse(&sub_iter1, &sub_iter2);
- else
- goto next_dict;
+ while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry1, value1;
+ const char *key, *sdata;
+ dbus_bool_t data;
- while (dbus_message_iter_get_arg_type(&sub_iter2) == DBUS_TYPE_STRING) {
- dbus_message_iter_get_basic(&sub_iter2, &tech_name);
+ dbus_message_iter_recurse(&dict, &entry1);
+ dbus_message_iter_get_basic(&entry1, &key);
- if (tech_name != NULL && g_str_equal(tech_name, "wifi") == TRUE) {
- if (g_str_equal(key, "AvailableTechnologies") == TRUE)
- wifi_tech_available = TRUE;
- else if (g_str_equal(key, "EnabledTechnologies") == TRUE)
- wifi_tech_enabled = TRUE;
- }
+ dbus_message_iter_next(&entry1);
+ dbus_message_iter_recurse(&entry1, &value1);
- dbus_message_iter_next(&sub_iter2);
+ if (dbus_message_iter_get_arg_type(&value1) ==
+ DBUS_TYPE_BOOLEAN) {
+ dbus_message_iter_get_basic(&value1, &data);
+ DBG("key-[%s] - %s", key, data ? "True" : "False");
+
+ if (strcmp(key, "Powered") == 0 && data) {
+ wifi_tech_powered = TRUE;
+ } else if (strcmp(key, "Connected") == 0 && data) {
+ wifi_tech_connected = TRUE;
+ } else if (strcmp(key, "Tethering") == 0 && data) {
+ /* For further use */
+ }
+ } else if (dbus_message_iter_get_arg_type(&value1) ==
+ DBUS_TYPE_STRING) {
+ dbus_message_iter_get_basic(&value1, &sdata);
+ DBG("%s", sdata);
}
+
+ dbus_message_iter_next(&dict);
}
-next_dict:
- dbus_message_iter_next(&dict);
+ dbus_message_iter_next(&array);
}
dbus_message_unref(message);
- if (wifi_tech_enabled)
- return g_strdup("EnabledTechnologies");
- else if (wifi_tech_available)
- return g_strdup("AvailableTechnologies");
+ if (wifi_tech_powered == TRUE)
+ ret = NETCONFIG_WIFI_TECH_POWERED;
+
+ if (wifi_tech_connected == TRUE)
+ ret = NETCONFIG_WIFI_TECH_CONNECTED;
+
+ wifi_technology_state = ret;
+
+ return wifi_technology_state;
+}
+
+void netconfig_wifi_notify_power_failed(void)
+{
+ DBusMessage *signal;
+ DBusConnection *connection = NULL;
+ DBusError error;
+ char *sig_name = "PowerOperationFailed";
+
+ dbus_error_init(&error);
+
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (connection == NULL) {
+ ERR("Failed to get system DBus, error [%s]", error.message);
+ dbus_error_free(&error);
+ return;
+ }
+
+ signal = dbus_message_new_signal(NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, sig_name);
+ if (signal == NULL)
+ return;
+
+ dbus_connection_send(connection, signal, NULL);
+
+ dbus_message_unref(signal);
+ dbus_connection_unref(connection);
+}
+
+void netconfig_wifi_notify_power_completed(gboolean power_on)
+{
+ DBusMessage *signal;
+ DBusConnection *connection = NULL;
+ DBusError error;
+ char *sig_name = NULL;
+
+ if (power_on)
+ sig_name = "PowerOnCompleted";
else
- return NULL;
+ sig_name = "PowerOffCompleted";
+
+ dbus_error_init(&error);
+
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (connection == NULL) {
+ ERR("Failed to get system DBus, error [%s]", error.message);
+ dbus_error_free(&error);
+ return;
+ }
+
+ signal = dbus_message_new_signal(NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, sig_name);
+ if (signal == NULL)
+ return;
+
+ dbus_connection_send(connection, signal, NULL);
+
+ DBG("Successfully sent signal [%s]", sig_name);
+
+ dbus_message_unref(signal);
+ dbus_connection_unref(connection);
+}
+
+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)
+{
+ vconf_notify_key_changed(VCONFKEY_WIFI_ENABLE_QS,
+ __netconfig_notification_value_changed_cb, NULL);
+}
+
+static void __netconfig_deregister_network_notification(void)
+{
+ 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;
- vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
+ /* It's automatically updated by signal-handler
+ * DO NOT update manually
+ * It includes Wi-Fi state configuration
+ */
+ 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");
+ 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");
+
+ netconfig_wifi_state_set_technology_state(
+ NETCONFIG_WIFI_TECH_POWERED);
- vconf_set_int(VCONFKEY_NETWORK_WIFI_STATE, VCONFKEY_NETWORK_WIFI_NOT_CONNECTED);
+ netconfig_wifi_notify_power_completed(TRUE);
- vconf_set_int(VCONF_WIFI_LAST_POWER_STATE, WIFI_POWER_ON);
+ netconfig_wifi_device_picker_service_start();
- vconf_set_int(VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_UNCONNECTED);
+ 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_wifi_bgscan_start();
+ 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");
+ } else if (wifi_tech_state > NETCONFIG_WIFI_TECH_OFF) {
+ DBG("Wi-Fi turned off or in power-save mode");
- __netconfig_wifi_del_network_notification();
+ netconfig_wifi_state_set_technology_state(
+ NETCONFIG_WIFI_TECH_WPS_ONLY);
- netconfig_wifi_bgscan_stop();
+ netconfig_wifi_device_picker_service_stop();
- __netconfig_wifi_set_profiles_count(0);
+ netconfig_wifi_disable_technology_state_by_only_connman_signal();
+ netconfig_wifi_driver_and_supplicant(FALSE);
- vconf_set_int(VCONFKEY_NETWORK_WIFI_STATE, VCONFKEY_NETWORK_WIFI_OFF);
+ netconfig_wifi_notify_power_completed(FALSE);
- vconf_set_int(VCONF_WIFI_LAST_POWER_STATE, WIFI_POWER_OFF);
+ 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);
- vconf_set_int(VCONFKEY_WIFI_STATE, VCONFKEY_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_state_powered_activation(powered);
}
char *netconfig_wifi_get_favorite_service(void)
return __netconfig_wifi_get_connman_favorite_service();
}
-void netconfig_wifi_check_network_notification(void)
+static gboolean __netconfig_wifi_check_network_notification(gpointer data)
{
- DBusMessage *message = NULL;
- DBusMessageIter iter, dict;
- int profiles_count = 0;
-
- message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
- CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE, "GetProperties", NULL);
- if (message == NULL) {
- ERR("Failed to get service list");
- return;
- }
-
- dbus_message_iter_init(message, &iter);
- dbus_message_iter_recurse(&iter, &dict);
+ int qs_enable = 0, ug_state = 0;
+ static gboolean check_again = FALSE;
- while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
- DBusMessageIter keyValue, array, value;
- const char *key = NULL;
- const char *object_path = NULL;
+ enum netconfig_wifi_tech_state wifi_tech_state;
+ enum netconfig_wifi_service_state wifi_service_state;
- dbus_message_iter_recurse(&dict, &keyValue);
- dbus_message_iter_get_basic(&keyValue, &key);
+#if defined TIZEN_WEARABLE
+ /* In case of wearable device, no need to notify available Wi-Fi APs */
+ return FALSE;
+#endif
- if (g_str_equal(key, "Services") != TRUE) {
- dbus_message_iter_next(&dict);
- continue;
- }
-
- dbus_message_iter_next(&keyValue);
- dbus_message_iter_recurse(&keyValue, &array);
- if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
- continue;
+ 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;
+ }
- dbus_message_iter_recurse(&array, &value);
- while (dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_OBJECT_PATH) {
- dbus_message_iter_get_basic(&value, &object_path);
+ wifi_service_state = netconfig_wifi_state_get_service_state();
+ if (wifi_service_state == NETCONFIG_WIFI_CONNECTED) {
+ DBG("Service state is connected");
+ 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 (g_str_has_prefix(object_path, CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE)
- profiles_count++;
+ if (__netconfig_is_wifi_profile_available() == FALSE) {
+ netconfig_send_notification_to_net_popup(
+ NETCONFIG_DEL_FOUND_AP_NOTI, NULL);
+ goto cleanup;
+ }
- dbus_message_iter_next(&value);
- }
+ vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, &qs_enable);
+ if (qs_enable != VCONFKEY_WIFI_QS_ENABLE) {
+ DBG("qs_enable != VCONFKEY_WIFI_QS_ENABLE");
+ goto cleanup;
+ }
- dbus_message_iter_next(&dict);
+ vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE, &ug_state);
+ if (ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND) {
+ goto cleanup;
}
- dbus_message_unref(message);
+ netconfig_send_notification_to_net_popup(NETCONFIG_ADD_FOUND_AP_NOTI, NULL);
- if (__netconfig_wifi_get_profiles_count() < profiles_count) {
- DBG("profiles prev_count (%d) - profiles count (%d)",
- __netconfig_wifi_get_profiles_count(), profiles_count);
+ netconfig_wifi_set_bss_found(FALSE);
- __netconfig_wifi_add_network_notification();
- }
+cleanup:
+ netconfig_stop_timer(&network_noti_timer_id);
+ return FALSE;
+}
- __netconfig_wifi_set_profiles_count(profiles_count);
+void netconfig_wifi_start_timer_network_notification(void)
+{
+ netconfig_start_timer(NETCONFIG_NETWORK_NOTIFICATION_TIMEOUT,
+ __netconfig_wifi_check_network_notification, NULL, &network_noti_timer_id);
}
void netconfig_wifi_state_notifier_cleanup(void)
--- /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 "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)
+{
+ DBusMessage *signal;
+ DBusConnection *connection = NULL;
+ DBusMessageIter dict, type, array, value, iter;
+ DBusError error;
+
+ GSList* list = NULL;
+ const char *prop_ssid = "ssid";
+ const char *prop_bssid = "bssid";
+ const char *prop_rssi = "rssi";
+ const char *prop_mode = "mode";
+ const char *sig_name = "WpsScanCompleted";
+
+ dbus_error_init(&error);
+
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (connection == NULL) {
+ ERR("Failed to get system DBus, error [%s]", error.message);
+ dbus_error_free(&error);
+ return;
+ }
+
+ signal = dbus_message_new_signal(NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, sig_name);
+ if (signal == NULL) {
+ dbus_connection_unref(connection);
+ return;
+ }
+
+ dbus_message_iter_init_append(signal, &array);
+ dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY, "{sv}", &dict);
+
+ 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) {
+ char bssid_buff[18] = { 0, };
+ char *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;
+ 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);
+
+ 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_ARRAY_AS_STRING
+ DBUS_TYPE_BYTE_AS_STRING,
+ &value);
+ dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &iter);
+ dbus_message_iter_append_fixed_array(&iter, DBUS_TYPE_BYTE, &ssid, ssid_len);
+ dbus_message_iter_close_container(&value, &iter);
+ dbus_message_iter_close_container(&type, &value);
+ dbus_message_iter_close_container(&dict, &type);
+
+ dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, 0, &type);
+ dbus_message_iter_append_basic(&type, DBUS_TYPE_STRING, &prop_bssid);
+ dbus_message_iter_open_container(&type, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &value);
+ dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &bssid_str);
+ dbus_message_iter_close_container(&type, &value);
+ dbus_message_iter_close_container(&dict, &type);
+
+ dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, 0, &type);
+ dbus_message_iter_append_basic(&type, DBUS_TYPE_STRING, &prop_rssi);
+ dbus_message_iter_open_container(&type, DBUS_TYPE_VARIANT, DBUS_TYPE_INT32_AS_STRING, &value);
+ dbus_message_iter_append_basic(&value, DBUS_TYPE_INT32, &rssi);
+ dbus_message_iter_close_container(&type, &value);
+ dbus_message_iter_close_container(&dict, &type);
+
+ dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, 0, &type);
+ dbus_message_iter_append_basic(&type, DBUS_TYPE_STRING, &prop_mode);
+ dbus_message_iter_open_container(&type, DBUS_TYPE_VARIANT, DBUS_TYPE_INT32_AS_STRING, &value);
+ dbus_message_iter_append_basic(&value, DBUS_TYPE_INT32, &mode);
+ dbus_message_iter_close_container(&type, &value);
+ dbus_message_iter_close_container(&dict, &type);
+ }
+ }
+
+ dbus_message_iter_close_container(&array, &dict);
+
+ dbus_connection_send(connection, signal, NULL);
+
+ dbus_message_unref(signal);
+ dbus_connection_unref(connection);
+
+ g_slist_free_full(wps_bss_info_list, g_free);
+ wps_bss_info_list = NULL;
+ wps_bss_list_count = 0;
+}
+
+static void __netconfig_wifi_wps_get_bss_info_result(
+ DBusPendingCall *call, void *data)
+{
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ DBusMessageIter dict;
+ struct wps_bss_info_t *bss_info;
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR)
+ goto done;
+
+ if (dbus_message_iter_init(reply, &iter) == FALSE)
+ goto done;
+
+ bss_info = g_try_new0(struct wps_bss_info_t, 1);
+ if (bss_info == NULL)
+ goto done;
+
+ if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_ARRAY) {
+ dbus_message_iter_recurse(&iter, &dict);
+
+ while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry, value;
+ const char *key;
+
+ dbus_message_iter_recurse(&dict, &entry);
+
+ if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING)
+ break;
+
+ dbus_message_iter_get_basic(&entry, &key);
+ dbus_message_iter_next(&entry);
+
+ if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT)
+ break;
+
+ dbus_message_iter_recurse(&entry, &value);
+
+ if (key != NULL) {
+ if (g_strcmp0(key, "BSSID") == 0) {
+ DBusMessageIter array;
+ unsigned char *bssid;
+ int bssid_len;
+
+ dbus_message_iter_recurse(&value, &array);
+ dbus_message_iter_get_fixed_array(&array, &bssid, &bssid_len);
+
+ if (bssid_len == NETCONFIG_BSSID_LEN)
+ memcpy(bss_info->bssid, bssid, bssid_len);
+ } else if (g_strcmp0(key, "SSID") == 0) {
+ DBusMessageIter array;
+ unsigned char *ssid;
+ int ssid_len;
+
+ dbus_message_iter_recurse(&value, &array);
+ dbus_message_iter_get_fixed_array(&array, &ssid, &ssid_len);
+
+ 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 char *mode = NULL;
+
+ dbus_message_iter_get_basic(&value, &mode);
+
+ if (mode == NULL)
+ bss_info->mode = 0;
+ else {
+ if (g_str_equal(mode, "infrastructure") == TRUE)
+ bss_info->mode = 1;
+ else if (g_str_equal(mode, "ad-hoc") == TRUE)
+ bss_info->mode = 2;
+ else
+ bss_info->mode = 0;
+ }
+ } else if (g_strcmp0(key, "Signal") == 0) {
+ dbus_int16_t signal = 0;
+
+ dbus_message_iter_get_basic(&value, &signal);
+
+ bss_info->rssi = signal;
+ }
+ }
+
+ dbus_message_iter_next(&dict);
+ }
+ }
+
+ if (bss_info->ssid[0] == '\0')
+ g_free(bss_info);
+ else
+ wps_bss_info_list = g_slist_append(wps_bss_info_list, bss_info);
+
+done:
+ dbus_message_unref(reply);
+
+ dbus_pending_call_unref(call);
+
+ 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;
+ char *param0 = NULL;
+ char *param_array[] = { NULL, NULL };
+
+ param0 = g_strdup_printf("string:%s", SUPPLICANT_IFACE_BSS);
+ param_array[0] = param0;
+ reply = netconfig_invoke_dbus_method_nonblock(SUPPLICANT_SERVICE,
+ path, DBUS_INTERFACE_PROPERTIES,
+ "GetAll", param_array, __netconfig_wifi_wps_get_bss_info_result);
+ if (reply != TRUE)
+ ERR("Fail to invoke_dbus_method_nonblock GetAll");
+
+ if (param0)
+ g_free(param0);
+}
+
+static void __netconfig_wifi_wps_get_bsss_result(
+ DBusPendingCall *call, void *data)
+{
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ char *path;
+ gboolean counter_flag = FALSE;
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR)
+ goto done;
+
+ if (dbus_message_iter_init(reply, &iter) == FALSE)
+ goto done;
+
+ if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_VARIANT) {
+ DBusMessageIter variant, entry;
+
+ dbus_message_iter_recurse(&iter, &variant);
+
+ if (dbus_message_iter_get_arg_type(&variant) == DBUS_TYPE_ARRAY) {
+ dbus_message_iter_recurse(&variant, &entry);
+ while (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_INVALID) {
+ dbus_message_iter_get_basic(&entry, &path);
+ if (path != NULL && g_strcmp0(path, "/") != 0) {
+ __netconfig_wifi_wps_get_bss_info(path, ++wps_bss_list_count);
+
+ counter_flag = TRUE;
+ }
+
+ dbus_message_iter_next(&entry);
+ }
+ }
+ }
+
+done:
+ dbus_message_unref(reply);
+
+ dbus_pending_call_unref(call);
+
+ /* 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;
+ char *param0 = NULL;
+ char param1[] = "string:BSSs";
+ char *param_array[] = { NULL, NULL, NULL };
+
+ if_path = netconfig_wifi_get_supplicant_interface();
+ if (if_path == NULL) {
+ DBG("Fail to get wpa_supplicant DBus path");
+ return -ESRCH;
+ }
+
+ param0 = g_strdup_printf("string:%s", SUPPLICANT_IFACE_INTERFACE);
+ param_array[0] = param0;
+ param_array[1] = param1;
+
+ reply = netconfig_invoke_dbus_method_nonblock(SUPPLICANT_SERVICE,
+ if_path, DBUS_INTERFACE_PROPERTIES,
+ "Get", param_array, __netconfig_wifi_wps_get_bsss_result);
+ if (reply != TRUE) {
+ ERR("Fail to invoke_dbus_method_nonblock Get");
+
+ if (param0)
+ g_free(param0);
+ return -ESRCH;
+ }
+
+ if (param0)
+ g_free(param0);
+ 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)
+{
+ dbus_bool_t result = FALSE;
+ DBusConnection *connection = NULL;
+ DBusMessage *message = NULL;
+ DBusPendingCall *call;
+ DBusMessageIter iter, dict, entry;
+ DBusMessageIter value;
+ 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 = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (connection == NULL) {
+ ERR("Failed to get system bus");
+ return -EIO;
+ }
+
+ message = dbus_message_new_method_call(SUPPLICANT_SERVICE,
+ if_path, SUPPLICANT_INTERFACE ".Interface", "Scan");
+ if (message == NULL) {
+ ERR("Failed DBus method call");
+ dbus_connection_unref(connection);
+ return -EIO;
+ }
+
+ 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);
+
+ 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);
+
+ dbus_message_iter_close_container(&entry, &value);
+ dbus_message_iter_close_container(&dict, &entry);
+ dbus_message_iter_close_container(&iter, &dict);
+
+ result = dbus_connection_send_with_reply(connection, message, &call,
+ NETCONFIG_WPS_DBUS_REPLY_TIMEOUT);
+ if (result == FALSE || call == NULL) {
+ ERR("dbus_connection_send_with_reply() failed");
+
+ dbus_message_unref(message);
+ dbus_connection_unref(connection);
+
+ return -ESRCH;
+ }
+
+ dbus_pending_call_cancel(call);
+ dbus_message_unref(message);
+ dbus_connection_unref(connection);
+
+ /* 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(
+ DBusPendingCall *call, void *data)
+{
+ DBusMessage *message;
+ DBusMessageIter iter;
+ const char *path = NULL;
+
+ message = dbus_pending_call_steal_reply(call);
+ if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_ERROR) {
+ dbus_message_iter_init(message, &iter);
+ dbus_message_iter_get_basic(&iter, &path);
+
+ if (path)
+ __netconfig_wifi_wps_request_scan(path);
+ } else {
+ DBG("Failed to create interface");
+ }
+
+ dbus_message_unref(message);
+ dbus_pending_call_unref(call);
+}
+
+static int __netconfig_wifi_wps_create_interface(void)
+{
+ dbus_bool_t result = FALSE;
+ DBusConnection *connection = NULL;
+ DBusMessage *message = NULL;
+ DBusPendingCall *call;
+ DBusMessageIter iter, dict, entry, value;
+ const char *key = "Ifname";
+ const char *val = WIFI_IFNAME;
+
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (connection == NULL) {
+ ERR("Failed to get system bus");
+ return -EIO;
+ }
+
+ message = dbus_message_new_method_call(SUPPLICANT_SERVICE,
+ SUPPLICANT_PATH, SUPPLICANT_INTERFACE, "CreateInterface");
+ if (message == NULL) {
+ ERR("Failed DBus method call");
+ dbus_connection_unref(connection);
+ return -EIO;
+ }
+
+ 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, &key);
+ dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
+ DBUS_TYPE_STRING_AS_STRING, &value);
+ dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &val);
+ dbus_message_iter_close_container(&entry, &value);
+ dbus_message_iter_close_container(&dict, &entry);
+ dbus_message_iter_close_container(&iter, &dict);
+
+ result = dbus_connection_send_with_reply(connection, message, &call,
+ NETCONFIG_WPS_DBUS_REPLY_TIMEOUT);
+ if (result == FALSE || call == NULL) {
+ ERR("dbus_connection_send_with_reply() failed");
+
+ dbus_message_unref(message);
+ dbus_connection_unref(connection);
+
+ return -ESRCH;
+ }
+
+ dbus_pending_call_set_notify(call,
+ __netconfig_wifi_interface_create_result, NULL, NULL);
+
+ dbus_message_unref(message);
+ dbus_connection_unref(connection);
+
+ 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 netconfig_iface_wifi_request_wps_scan(NetconfigWifi *wifi,
+ GError **error)
+{
+ 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");
+ return -EBUSY;
+ }
+
+#if !defined TIZEN_WEARABLE
+ if (netconfig_wifi_is_bgscan_paused()) {
+ ERR("Scan is paused");
+ return FALSE;
+ }
+#endif
+
+ wifi_tech_state = netconfig_wifi_state_get_technology_state();
+ if (wifi_tech_state <= NETCONFIG_WIFI_TECH_OFF) {
+ vconf_get_int(VCONF_WIFI_ALWAYS_ALLOW_SCANNING, &enabled);
+
+ if (enabled == 0) {
+ netconfig_error_permission_denied(error);
+ return FALSE;
+ }
+ }
+
+ __netconfig_wps_set_mode(TRUE);
+
+ err = __netconfig_wifi_wps_scan();
+ if (err < 0) {
+ if (err == -EINPROGRESS)
+ netconfig_error_inprogress(error);
+ else
+ netconfig_error_wifi_driver_failed(error);
+
+ return FALSE;
+ }
+
+ 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 <unistd.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include "log.h"
+#include "wifi.h"
+#include "util.h"
+#include "netdbus.h"
+#include "neterror.h"
+#include "wifi-eap.h"
+#include "wifi-wps.h"
+#include "wifi-power.h"
+#include "wifi-agent.h"
+#include "wifi-firmware.h"
+#include "wifi-ssid-scan.h"
+#include "wifi-passpoint.h"
+#include "wifi-eap-config.h"
+#include "wifi-background-scan.h"
+
+#include "netconfig-iface-wifi-glue.h"
+
+#define PROP_DEFAULT FALSE
+#define PROP_DEFAULT_STR NULL
+
+enum {
+ PROP_O,
+ PROP_WIFI_CONN,
+ PROP_WIFI_PATH,
+};
+
+struct NetconfigWifiClass {
+ GObjectClass parent;
+};
+
+struct NetconfigWifi {
+ GObject parent;
+
+ DBusGConnection *connection;
+ gchar *path;
+};
+
+G_DEFINE_TYPE(NetconfigWifi, netconfig_wifi, G_TYPE_OBJECT);
+
+static void __netconfig_wifi_gobject_get_property(GObject *object, guint prop_id,
+ GValue *value, GParamSpec *pspec)
+{
+ return;
+}
+
+static void __netconfig_wifi_gobject_set_property(GObject *object, guint prop_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ NetconfigWifi *wifi = NETCONFIG_WIFI(object);
+
+ switch (prop_id) {
+ case PROP_WIFI_CONN:
+ {
+ wifi->connection = g_value_get_boxed(value);
+ break;
+ }
+
+ case PROP_WIFI_PATH:
+ {
+ if (wifi->path)
+ g_free(wifi->path);
+
+ wifi->path = g_value_dup_string(value);
+ break;
+ }
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ }
+}
+
+static void netconfig_wifi_init(NetconfigWifi *wifi)
+{
+ wifi->connection = NULL;
+ wifi->path = g_strdup(PROP_DEFAULT_STR);
+}
+
+static void netconfig_wifi_class_init(NetconfigWifiClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ 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("connection", "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));
+}
+
+gpointer netconfig_wifi_create_and_init(DBusGConnection *connection)
+{
+ GObject *object;
+
+ g_return_val_if_fail(connection != NULL, NULL);
+
+ object = g_object_new(NETCONFIG_TYPE_WIFI, "connection", connection, "path",
+ NETCONFIG_WIFI_PATH, NULL);
+
+ dbus_g_connection_register_g_object(connection, NETCONFIG_WIFI_PATH, object);
+
+ netconfig_wifi_power_initialize();
+
+ return object;
+}