CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(wfd-manager C)
-#SET(PREFIX $(CMAKE_INSTALL_PREFIX))
-SET(prefix "/usr")
-SET(EXEC_PREFIX "\${prefix}")
-SET(LIBDIR "\${prefix}/lib")
-SET(INCLUDEDIR "\${prefix}/include")
-
INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED capi-network-wifi-direct glib-2.0 gio-2.0 gobject-2.0 dlog libnl-2.0 capi-appfw-application vconf cynara-client cynara-creds-socket cynara-session aul${MDM_REQUIRED_PKGS})
FOREACH(flag ${pkgs_CFLAGS})
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -ldl)
+
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/files/dhcpd-notify.sh.in ${CMAKE_SOURCE_DIR}/files/dhcpd-notify.sh @ONLY)
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/files/dhcpd.conf.in ${CMAKE_SOURCE_DIR}/files/dhcpd.conf @ONLY)
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/files/p2p_supp.conf.in ${CMAKE_SOURCE_DIR}/files/p2p_supp.conf @ONLY)
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/files/p2p_supp.sh.in ${CMAKE_SOURCE_DIR}/files/p2p_supp.sh @ONLY)
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/files/udhcp_script.non-autoip.in ${CMAKE_SOURCE_DIR}/files/udhcp_script.non-autoip @ONLY)
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/files/wifi-direct-dhcp.sh.in ${CMAKE_SOURCE_DIR}/files/wifi-direct-dhcp.sh @ONLY)
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/files/wifi-direct-server.sh.in ${CMAKE_SOURCE_DIR}/files/wifi-direct-server.sh @ONLY)
+
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/udhcp_script.non-autoip DESTINATION etc/wifi-direct)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/wifi-direct-server.sh DESTINATION bin)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/p2p_supp.sh DESTINATION sbin)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/ccode.conf DESTINATION etc/wifi-direct)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/dhcpd-notify.sh DESTINATION bin)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/p2p_supp.conf DESTINATION etc/wifi-direct)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/p2p_supp.conf DESTINATION /opt/etc)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/dhcpd.conf DESTINATION etc/wifi-direct)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/wifi-direct-dhcp.sh DESTINATION bin)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/udhcp_script.non-autoip DESTINATION ${TZ_SYS_RO_ETC}/wifi-direct)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/wifi-direct-server.sh DESTINATION ${BIN_DIR})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/p2p_supp.sh DESTINATION ${SBIN_DIR})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/ccode.conf DESTINATION ${TZ_SYS_RO_ETC}/wifi-direct)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/dhcpd-notify.sh DESTINATION ${BIN_DIR})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/p2p_supp.conf DESTINATION ${TZ_SYS_RO_ETC}/wifi-direct)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/p2p_supp.conf DESTINATION ${TZ_SYS_ETC})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/dhcpd.conf DESTINATION ${TZ_SYS_RO_ETC}/wifi-direct)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/wifi-direct-dhcp.sh DESTINATION ${BIN_DIR})
IF("${ARCH}" MATCHES "^arm.*|.*86.*")
IF(CTRL_IFACE_DBUS)
+++ /dev/null
-#!/bin/sh
-# Dump DHCP lease data: MAC IP Time
-/usr/bin/dumpleases -f /opt/var/lib/misc/dhcpd.leases | /bin/awk '$1!="Mac" {print $1, $2, $3}' > /tmp/dhcp-client-table
-
-#Update vconf value to notify wifi-direct
-/usr/bin/vconftool set -t int memory/private/wifi_direct_manager/dhcp_ip_lease 1 -f
-#cat /tmp/dhcp-client-table
--- /dev/null
+#!/bin/sh
+# Dump DHCP lease data: MAC IP Time
+@BIN_DIR@/dumpleases -f @TZ_SYS_VAR@/lib/misc/dhcpd.leases | /bin/awk '$1!="Mac" {print $1, $2, $3}' > /tmp/dhcp-client-table
+
+#Update vconf value to notify wifi-direct
+@BIN_DIR@/vconftool set -t int memory/private/wifi_direct_manager/dhcp_ip_lease 1 -f
+#cat /tmp/dhcp-client-table
start 192.168.49.20 #default: 192.168.0.20
end 192.168.49.40 #default: 192.168.0.254
max_leases 20 #default: 254
-notify_file /usr/bin/dhcpd-notify.sh
-lease_file /opt/var/lib/misc/dhcpd.leases #default: /var/lib/misc/udhcpd.leases
+notify_file @BIN_DIR@/dhcpd-notify.sh
+lease_file @TZ_SYS_VAR@/lib/misc/dhcpd.leases #default: /var/lib/misc/udhcpd.leases
option subnet 255.255.255.0
option router 192.168.49.1
##### p2p_supplicant configuration file template #####
-ctrl_interface=/var/run/wpa_supplicant
+ctrl_interface=@TZ_SYS_RUN@/wpa_supplicant
update_config=1
eapol_version=1
ap_scan=1
+++ /dev/null
-#!/bin/sh
-
-PROGRAM="/usr/sbin/wpa_supplicant"
-
-start()
-{
- HARDWARE_MODEL=`/bin/grep Hardware /proc/cpuinfo | /bin/awk "{print \\$3}"`
- /bin/echo "Hardware Model=${HARDWARE_MODEL}"
-
- if [ -e /opt/etc/p2p_supp.conf ]; then
- echo "File exist: /opt/etc/p2p_supp.conf"
- else
- echo "File not exist. Reinstall: /opt/etc/p2p_supp.conf"
- /bin/cp /usr/etc/wifi-direct/p2p_supp.conf /opt/etc/
- fi
- ## For Hawk-P Platform, Hardware model is Samsung
- if [ $HARDWARE_MODEL = "Samsung" ];then
- /usr/sbin/wpa_supplicant -t -B -ddd -Dnl80211 -ip2p0 -c/opt/etc/p2p_supp.conf -g/var/run/wpa_global -f/var/log/wpa_supplicant.log
- else
- /usr/sbin/wpa_supplicant -t -B -C/var/run/wpa_supplicant -ddd -Dnl80211 -iwlan0 -c/opt/etc/p2p_supp.conf -f/var/log/wpa_supplicant.log
- fi
- }
-
-start_p2p0()
-{
- if [ -e /opt/etc/p2p_supp.conf ]; then
- echo "File exist: /opt/etc/p2p_supp.conf"
- else
- echo "File not exist. Reinstall: /opt/etc/p2p_supp.conf"
- /bin/cp /usr/etc/wifi-direct/p2p_supp.conf /opt/etc/
- fi
- /usr/sbin/wpa_supplicant -t -B -ddd -Dnl80211 -ip2p0 -c/opt/etc/p2p_supp.conf -f/var/log/wpa_supplicant.log
-}
-
-start_dbus()
-{
- program=${PROGRAM}
- run=`/bin/ps -eo comm|/bin/grep ${program}`
- if [ "X${run}" == "X" ]; then
- echo "${program} is not running"
- if [ -e /opt/etc/p2p_supp.conf ]; then
- echo "File exist: /opt/etc/p2p_supp.conf"
- else
- echo "File not exist. Reinstall: /opt/etc/p2p_supp.conf"
- /bin/cp /usr/etc/wifi-direct/p2p_supp.conf /opt/etc/
- fi
- /usr/sbin/wpa_supplicant -t -B -u -ddd -K -f/var/log/wpa_supplicant.log
- else
- echo "${program} is already running"
- fi
-}
-
-stop()
-{
- /usr/bin/pkill -x wpa_supplicant
-}
-
-case $1 in
-"start")
-start
-;;
-"start_p2p0")
-start_p2p0
-;;
-"start_dbus")
-start_dbus
-;;
-"stop")
-stop
-;;
-*)
-/bin/echo p2p_supp.sh [start] [start_p2p0] [start_dbus] [stop]
-exit 1
-;;
-esac
--- /dev/null
+#!/bin/sh
+
+PROGRAM="@SBIN_DIR@/wpa_supplicant"
+
+start()
+{
+ HARDWARE_MODEL=`/bin/grep Hardware /proc/cpuinfo | /bin/awk "{print \\$3}"`
+ /bin/echo "Hardware Model=${HARDWARE_MODEL}"
+
+ if [ -e @TZ_SYS_ETC@/p2p_supp.conf ]; then
+ echo "File exist: @TZ_SYS_ETC@/p2p_supp.conf"
+ else
+ echo "File not exist. Reinstall: @TZ_SYS_ETC@/p2p_supp.conf"
+ /bin/cp @TZ_SYS_RO_ETC@/wifi-direct/p2p_supp.conf @TZ_SYS_ETC@/
+ fi
+ ## For Hawk-P Platform, Hardware model is Samsung
+ if [ $HARDWARE_MODEL = "Samsung" ];then
+ @SBIN_DIR@/wpa_supplicant -t -B -ddd -Dnl80211 -ip2p0 -c@TZ_SYS_ETC@/p2p_supp.conf -g@TZ_SYS_RUN@/wpa_global -f/var/log/wpa_supplicant.log
+ else
+ @SBIN_DIR@/wpa_supplicant -t -B -C@TZ_SYS_RUN@/wpa_supplicant -ddd -Dnl80211 -iwlan0 -c@TZ_SYS_ETC@/p2p_supp.conf -f/var/log/wpa_supplicant.log
+ fi
+ }
+
+start_p2p0()
+{
+ if [ -e @TZ_SYS_ETC@/p2p_supp.conf ]; then
+ echo "File exist: @TZ_SYS_ETC@/p2p_supp.conf"
+ else
+ echo "File not exist. Reinstall: @TZ_SYS_ETC@/p2p_supp.conf"
+ /bin/cp @TZ_SYS_RO_ETC@/wifi-direct/p2p_supp.conf @TZ_SYS_ETC@/
+ fi
+ @SBIN_DIR@/wpa_supplicant -t -B -ddd -Dnl80211 -ip2p0 -c@TZ_SYS_ETC@/p2p_supp.conf -f/var/log/wpa_supplicant.log
+}
+
+start_dbus()
+{
+ program=${PROGRAM}
+ run=`/bin/ps -eo comm|/bin/grep ${program}`
+ if [ "X${run}" == "X" ]; then
+ echo "${program} is not running"
+ if [ -e @TZ_SYS_ETC@/p2p_supp.conf ]; then
+ echo "File exist: @TZ_SYS_ETC@/p2p_supp.conf"
+ else
+ echo "File not exist. Reinstall: @TZ_SYS_ETC@/p2p_supp.conf"
+ /bin/cp @TZ_SYS_RO_ETC@/wifi-direct/p2p_supp.conf @TZ_SYS_ETC@/
+ fi
+ @SBIN_DIR@/wpa_supplicant -t -B -u -ddd -K -f/var/log/wpa_supplicant.log
+ else
+ echo "${program} is already running"
+ fi
+}
+
+stop()
+{
+ @BIN_DIR@/pkill -x wpa_supplicant
+}
+
+case $1 in
+"start")
+start
+;;
+"start_p2p0")
+start_p2p0
+;;
+"start_dbus")
+start_dbus
+;;
+"stop")
+stop
+;;
+*)
+/bin/echo p2p_supp.sh [start] [start_p2p0] [start_dbus] [stop]
+exit 1
+;;
+esac
local_gateway="0.0.0.0"
fi
- /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_ifname ${interface} -f
- /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_subnet_mask ${subnet} -f
- /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_gateway ${local_gateway} -f
- /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/dhcpc_server_ip ${serverid} -f
- /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_local_ip ${ip} -f
+ @BIN_DIR@/vconftool set -t string memory/private/wifi_direct_manager/p2p_ifname ${interface} -f
+ @BIN_DIR@/vconftool set -t string memory/private/wifi_direct_manager/p2p_subnet_mask ${subnet} -f
+ @BIN_DIR@/vconftool set -t string memory/private/wifi_direct_manager/p2p_gateway ${local_gateway} -f
+ @BIN_DIR@/vconftool set -t string memory/private/wifi_direct_manager/dhcpc_server_ip ${serverid} -f
+ @BIN_DIR@/vconftool set -t string memory/private/wifi_direct_manager/p2p_local_ip ${ip} -f
echo $i >> $TEMP_DHCP_FILE
;;
esac
+++ /dev/null
-#!/bin/sh
-if [ $2 ]; then
-INTERFACE_NAME="$2"
-else
-INTERFACE_NAME="p2p0"
-fi
-INTERFACE_PREFIX="p2p"
-TARGET="TM1"
-DEFAULT_IP="192.168.49.1"
-DEFAULT_NET="192.168.49.1/24"
-DEFAULT_BRD="192.168.49.255"
-
-#interface=`/sbin/ifconfig|/bin/grep ^${INTERFACE_NAME}|/usr/bin/cut -d" " -f1`
-interface=`/sbin/ifconfig|/bin/grep ^${INTERFACE_NAME}|/usr/bin/cut -d":" -f1`
-#interface=`/usr/sbin/ip link|/bin/grep ^${INTERFACE_NAME}|/usr/bin/cut -d":" -f2`
-echo "Target is ${TARGET} and interface ${INTERFACE_PREFIX}: ${interface}."
-
-start_dhcp_server()
-{
- if [ "X${interface}" == "X" ]; then
- echo "interface(${INTERFACE_PREFIX}) is not up"
- return 0
- fi
-
- /bin/rm /opt/var/lib/misc/dhcpd.leases
- /bin/touch /opt/var/lib/misc/dhcpd.leases
- /usr/sbin/ip addr add ${DEFAULT_NET} brd ${DEFAULT_BRD} dev ${interface}
- /usr/sbin/dhcpd -S -i ${interface} /usr/etc/wifi-direct/dhcpd.conf -f &
-
- route=`/bin/cat /usr/etc/wifi-direct/dhcpd.conf | /bin/grep router | /bin/awk '{print $3}'`
- if [ -z $route ]; then
- route="192.168.49.1"
- fi
- subnet=`/bin/cat /usr/etc/wifi-direct/dhcpd.conf | /bin/grep subnet | /bin/awk '{print $3}'`
-
- if [ -z $subnet ]; then
- subnet="255.255.255.0"
- fi
-
- /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_ifname ${interface} -f
- /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_subnet_mask ${subnet} -f
- /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_gateway ${route} -f
- /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_local_ip ${DEFAULT_IP} -f
-}
-
-start_dhcp_client()
-{
- if [ "X${interface}" == "X" ]; then
- echo "interface(${INTERFACE_PREFIX}) is not up"
- return 0
- fi
-
- /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/dhcpc_server_ip "0.0.0.0" -f
- /usr/bin/dhcp -S -i $interface -s /usr/etc/wifi-direct/udhcp_script.non-autoip &
-}
-
-
-clean_vconfs()
-{
- /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_ifname "" -f
- /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_subnet_mask "" -f
- /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_gateway "" -f
- /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_local_ip "" -f
- /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/dhcpc_server_ip "0.0.0.0" -f
-}
-
-stop_dhcp()
-{
- /usr/bin/pkill -x dhcp
- /usr/bin/pkill -x dhcpd
- if [ "X${interface}" == "X" ]; then
- echo "interface(${INTERFACE_PREFIX}) is not up"
- return 0
- fi
- /usr/sbin/ip addr del ${local_ip_net} dev ${interface}
-}
-
-is_running()
-{
- program=$1
- run=`/bin/ps -eo comm|/bin/grep ${program}`
- if [ "X${run}" == "X" ]; then
- echo "${program} is not running"
- else
- echo "${program} is already running"
- fi
-}
-
-status_dhcp()
-{
- is_running /usr/bin/dhcp
- is_running /usr/sbin/dhcpd
-}
-
-
-case $1 in
-"server")
-stop_dhcp
-start_dhcp_server
-;;
-"client")
-clean_vconfs
-stop_dhcp
-start_dhcp_client
-;;
-"stop")
-clean_vconfs
-stop_dhcp
-;;
-"status")
-status_dhcp
-;;
-*)
-/bin/echo wifi-direct-dhcp.sh [server] [client] [stop] [status]
-exit 1
-;;
-esac
-
--- /dev/null
+#!/bin/sh
+if [ $2 ]; then
+INTERFACE_NAME="$2"
+else
+INTERFACE_NAME="p2p0"
+fi
+INTERFACE_PREFIX="p2p"
+TARGET="TM1"
+DEFAULT_IP="192.168.49.1"
+DEFAULT_NET="192.168.49.1/24"
+DEFAULT_BRD="192.168.49.255"
+
+#interface=`/sbin/ifconfig|/bin/grep ^${INTERFACE_NAME}|@BIN_DIR@/cut -d" " -f1`
+interface=`/sbin/ifconfig|/bin/grep ^${INTERFACE_NAME}|@BIN_DIR@/cut -d":" -f1`
+#interface=`@SBIN_DIR@/ip link|/bin/grep ^${INTERFACE_NAME}|@BIN_DIR@/cut -d":" -f2`
+echo "Target is ${TARGET} and interface ${INTERFACE_PREFIX}: ${interface}."
+
+start_dhcp_server()
+{
+ if [ "X${interface}" == "X" ]; then
+ echo "interface(${INTERFACE_PREFIX}) is not up"
+ return 0
+ fi
+
+ /bin/rm /@TZ_SYS_VAR@/lib/misc/dhcpd.leases
+ /bin/touch @TZ_SYS_VAR@/lib/misc/dhcpd.leases
+ @SBIN_DIR@/ip addr add ${DEFAULT_NET} brd ${DEFAULT_BRD} dev ${interface}
+ @SBIN_DIR@/dhcpd -S -i ${interface} @TZ_SYS_RO_ETC@/wifi-direct/dhcpd.conf -f &
+
+ route=`/bin/cat @TZ_SYS_RO_ETC@/wifi-direct/dhcpd.conf | /bin/grep router | /bin/awk '{print $3}'`
+ if [ -z $route ]; then
+ route="192.168.49.1"
+ fi
+ subnet=`/bin/cat @TZ_SYS_RO_ETC@/wifi-direct/dhcpd.conf | /bin/grep subnet | /bin/awk '{print $3}'`
+
+ if [ -z $subnet ]; then
+ subnet="255.255.255.0"
+ fi
+
+ @BIN_DIR@/vconftool set -t string memory/private/wifi_direct_manager/p2p_ifname ${interface} -f
+ @BIN_DIR@/vconftool set -t string memory/private/wifi_direct_manager/p2p_subnet_mask ${subnet} -f
+ @BIN_DIR@/vconftool set -t string memory/private/wifi_direct_manager/p2p_gateway ${route} -f
+ @BIN_DIR@/vconftool set -t string memory/private/wifi_direct_manager/p2p_local_ip ${DEFAULT_IP} -f
+}
+
+start_dhcp_client()
+{
+ if [ "X${interface}" == "X" ]; then
+ echo "interface(${INTERFACE_PREFIX}) is not up"
+ return 0
+ fi
+
+ @BIN_DIR@/vconftool set -t string memory/private/wifi_direct_manager/dhcpc_server_ip "0.0.0.0" -f
+ @BIN_DIR@/dhcp -S -i $interface -s @TZ_SYS_RO_ETC@/wifi-direct/udhcp_script.non-autoip &
+}
+
+
+clean_vconfs()
+{
+ @BIN_DIR@/vconftool set -t string memory/private/wifi_direct_manager/p2p_ifname "" -f
+ @BIN_DIR@/vconftool set -t string memory/private/wifi_direct_manager/p2p_subnet_mask "" -f
+ @BIN_DIR@/vconftool set -t string memory/private/wifi_direct_manager/p2p_gateway "" -f
+ @BIN_DIR@/vconftool set -t string memory/private/wifi_direct_manager/p2p_local_ip "" -f
+ @BIN_DIR@/vconftool set -t string memory/private/wifi_direct_manager/dhcpc_server_ip "0.0.0.0" -f
+}
+
+stop_dhcp()
+{
+ @BIN_DIR@/pkill -x dhcp
+ @BIN_DIR@/pkill -x dhcpd
+ if [ "X${interface}" == "X" ]; then
+ echo "interface(${INTERFACE_PREFIX}) is not up"
+ return 0
+ fi
+ @SBIN_DIR@/ip addr del ${local_ip_net} dev ${interface}
+}
+
+is_running()
+{
+ program=$1
+ run=`/bin/ps -eo comm|/bin/grep ${program}`
+ if [ "X${run}" == "X" ]; then
+ echo "${program} is not running"
+ else
+ echo "${program} is already running"
+ fi
+}
+
+status_dhcp()
+{
+ is_running @BIN_DIR@/dhcp
+ is_running @SBIN_DIR@/dhcpd
+}
+
+
+case $1 in
+"server")
+stop_dhcp
+start_dhcp_server
+;;
+"client")
+clean_vconfs
+stop_dhcp
+start_dhcp_client
+;;
+"stop")
+clean_vconfs
+stop_dhcp
+;;
+"status")
+status_dhcp
+;;
+*)
+/bin/echo wifi-direct-dhcp.sh [server] [client] [stop] [status]
+exit 1
+;;
+esac
+
if [ "X${target}" == "X" ]; then
echo "${program} is not running"
echo "Launching ${program}"
- /usr/bin/${program}&
+ @BIN_DIR@/${program}&
/bin/sleep 1
else
echo "${program} is already running"
echo "${program} is not running"
else
echo "${program} is running.. Killing it"
- /usr/bin/pkill -x ${program}
+ @BIN_DIR@/pkill -x ${program}
fi
}
#define WIFI_DIRECT_MAX_SSID_LEN 32
#define WIFI_DIRECT_MAX_DEVICE_NAME_LEN 32
#define WIFI_DIRECT_WPS_PIN_LEN 8
-#define WIFI_DIRECT_MAC_ADDRESS_INFO_FILE "/opt/etc/.mac.info"
#define WIFI_DIRECT_MAX_SERVICES_LEN 1024
#define WIFI_DIRECT_MAX_SERVICE_NAME_LEN 256
#ifndef __WIFI_DIRECT_UTIL_H__
#define __WIFI_DIRECT_UTIL_H__
-#if defined TIZEN_MOBILE
-# define DEFAULT_MAC_FILE_PATH "/opt/etc/.mac.info"
-#endif /* TIZEN_MOBILE */
-
-#if defined TIZEN_TV
-# if defined TIZEN_WIFI_MODULE_BUNDLE
-# define DEFAULT_MAC_FILE_PATH "/sys/class/net/wlan0/address"
-# else /* TIZEN_WIFI_MODULE_BUNDLE */
-# define DEFAULT_MAC_FILE_PATH "/sys/class/net/p2p0/address"
-# endif /* TIZEN_WIFI_MODULE_BUNDLE */
-#endif /* TIZEN_TV */
-
-#ifndef DEFAULT_MAC_FILE_PATH
-# define DEFAULT_MAC_FILE_PATH "/sys/class/net/p2p0/address"
-#endif
-
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
#define IP2STR(a) (a)[0], (a)[1], (a)[2], (a)[3]
#define VCONFKEY_DHCPC_SERVER_IP "memory/private/wifi_direct_manager/dhcpc_server_ip"
#define VCONFKEY_LOCAL_IP "memory/private/wifi_direct_manager/p2p_local_ip"
#define DHCP_DUMP_FILE "/tmp/dhcp-client-table"
-#define COUNTRY_CODE_FILE "/usr/etc/wifi-direct/ccode.conf"
#define MAX_DHCP_DUMP_SIZE 64 // Single lease format: [99:66:dd:00:11:aa 192.168.16.20 00:00:60]
#define SOCK_FD_MIN 3
Name: wifi-direct-manager
Summary: Wi-Fi Direct manger
-Version: 1.2.141
+Version: 1.2.143
Release: 1
Group: Network & Connectivity/Wireless
License: Apache-2.0
BuildRequires: pkgconfig(cynara-session)
BuildRequires: pkgconfig(capi-appfw-application)
+
+BuildRequires: pkgconfig(libtzplatform-config)
+
BuildRequires: cmake
#BuildRequires: model-build-features
Requires: net-tools
cp -a %{SOURCE2} .
%build
+
export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
%if "%{?_lib}" == "lib64"
-DTIZEN_ARCH_64=1 \
%endif
--DCMAKE_LIB_DIR=%{_libdir}
+-DLIB_DIR=%{_libdir} \
+-DBIN_DIR=%{_bindir} \
+-DSBIN_DIR=%{_sbindir} \
+-DTZ_SYS_RO_ETC=%TZ_SYS_RO_ETC \
+-DTZ_SYS_VAR=%TZ_SYS_VAR \
+-DTZ_SYS_ETC=%TZ_SYS_ETC \
+-DTZ_SYS_RUN=%TZ_SYS_RUN
make %{?_smp_mflags}
cp net.wifidirect.service %{buildroot}%{_datadir}/dbus-1/system-services/net.wifidirect.service
%post
-chmod 644 /usr/etc/wifi-direct/dhcpd.*.conf
-chmod 755 /usr/bin/dhcpd-notify.sh
-chmod 755 /usr/etc/wifi-direct/udhcp_script.non-autoip
-chmod 755 /usr/bin/wifi-direct-server.sh
-chmod 755 /usr/bin/wifi-direct-dhcp.sh
-chmod 755 /usr/sbin/p2p_supp.sh
-
-%if "%{profile}" == "tv"
- if [ ! -d /opt/var/lib/misc ]; then
- mkdir -p /opt/var/lib/misc
- fi
-
- touch /opt/var/lib/misc/dhcpd.leases
- chmod 666 /opt/var/lib/misc/dhcpd.leases
-%else
- if [ ! -d /var/lib/misc ]; then
- mkdir -p /var/lib/misc
- fi
-
- touch /var/lib/misc/dhcpd.leases
- chmod 666 /var/lib/misc/dhcpd.leases
-%endif
+chmod 644 %{TZ_SYS_RO_ETC}/wifi-direct/dhcpd.conf
+chmod 755 %{_bindir}/dhcpd-notify.sh
+chmod 755 %{TZ_SYS_RO_ETC}/wifi-direct/udhcp_script.non-autoip
+chmod 755 %{_bindir}/wifi-direct-server.sh
+chmod 755 %{_bindir}/wifi-direct-dhcp.sh
+chmod 755 %{_sbindir}/p2p_supp.sh
-%postun
+if [ ! -d %{TZ_SYS_VAR}/lib/misc ]; then
+ mkdir -p %{TZ_SYS_VAR}/lib/misc
+fi
+touch %{TZ_SYS_VAR}/lib/misc/dhcpd.leases
+chmod 666 %{TZ_SYS_VAR}/lib/misc/dhcpd.leases
%files
%manifest wifi-direct-manager.manifest
%license LICENSE
%defattr(-,root,root,-)
%{_bindir}/wfd-manager
-/usr/etc/wifi-direct/dhcpd.conf
-/usr/etc/wifi-direct/udhcp_script.non-autoip
-/usr/etc/wifi-direct/p2p_supp.conf
-/opt/etc/p2p_supp.conf
-/usr/etc/wifi-direct/ccode.conf
+%config %TZ_SYS_RO_ETC/wifi-direct/ccode.conf
+%config %TZ_SYS_RO_ETC/wifi-direct/dhcpd.conf
+%config %TZ_SYS_RO_ETC/wifi-direct/p2p_supp.conf
+%config %TZ_SYS_RO_ETC/wifi-direct/udhcp_script.non-autoip
+%config %{_sysconfdir}/dbus-1/system.d/wfd-manager.conf
+%TZ_SYS_RO_ETC/wifi-direct/ccode.conf
+%TZ_SYS_RO_ETC/wifi-direct/dhcpd.conf
+%TZ_SYS_RO_ETC/wifi-direct/p2p_supp.conf
+%TZ_SYS_RO_ETC/wifi-direct/udhcp_script.non-autoip
+%TZ_SYS_ETC/p2p_supp.conf
%{_bindir}/dhcpd-notify.sh
%{_bindir}/wifi-direct-server.sh
%{_bindir}/wifi-direct-dhcp.sh
%attr(755,-,-) %{_bindir}/dhcpd-notify.sh
%attr(755,-,-) %{_bindir}/wifi-direct-server.sh
%attr(755,-,-) %{_bindir}/wifi-direct-dhcp.sh
-%attr(755,-,-) /usr/etc/wifi-direct/udhcp_script.non-autoip
+%attr(755,-,-) %{TZ_SYS_RO_ETC}/wifi-direct/udhcp_script.non-autoip
%attr(644,root,root) %{_sysconfdir}/dbus-1/system.d/*
%attr(644,root,root) %{_datadir}/dbus-1/system-services/*
%attr(755,-,-) %{_sbindir}/p2p_supp.sh
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(LIBDIR ${CMAKE_LIB_DIR})
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/oem)
INCLUDE_DIRECTORIES(SRCS include)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME})
# install
-INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIBDIR})
+INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIB_DIR})
#define IPSECSTR "%d..%d"
#define OBJECT_PATH_MAX 150
+#define CONF_FILE_PATH "/etc/wpa_supplicant/wpa_supplicant.conf"
+
#if defined TIZEN_MOBILE
-# define CONF_FILE_PATH "/etc/wpa_supplicant/wpa_supplicant.conf"
-# define DEFAULT_MAC_FILE_PATH "/opt/etc/.mac.info"
-# define COMMON_IFACE_NAME "wlan0"
+#define COMMON_IFACE_NAME "wlan0"
# if defined TIZEN_WLAN_BOARD_SPRD
# define P2P_IFACE_NAME "p2p0"
#endif /* TIZEN_MOBILE */
#if defined TIZEN_TV
-# define CONF_FILE_PATH "/opt/etc/p2p_supp.conf"
# if defined TIZEN_WIFI_MODULE_BUNDLE
-# define DEFAULT_MAC_FILE_PATH "/sys/class/net/wlan0/address"
# define COMMON_IFACE_NAME "wlan0"
# define GROUP_IFACE_NAME "wlan0"
# define GROUP_IFACE_PREFIX "wlan"
# else /* TIZEN_WIFI_MODULE_BUNDLE */
-# define DEFAULT_MAC_FILE_PATH "/sys/class/net/p2p0/address"
# define COMMON_IFACE_NAME "p2p0"
# define GROUP_IFACE_NAME "p2p0"
# define GROUP_IFACE_PREFIX "p2p"
#include <glib.h>
#include <gio/gio.h>
+#include <tzplatform_config.h>
+
#include "wifi-direct-oem.h"
#include "wfd-plugin-log.h"
#include "wfd-plugin-wpasupplicant.h"
#define NETCONFIG_DBUS_REPLY_TIMEOUT (10 * 1000)
+#if defined TIZEN_MOBILE
+#define DEFAULT_MAC_FILE_PATH tzplatform_mkpath(TZ_SYS_ETC, ".mac.info")
+#endif
+
+#if defined TIZEN_WIFI_MODULE_BUNDLE
+#define DEFAULT_MAC_FILE_PATH "/sys/class/net/wlan0/address"
+#endif
+
+#ifndef DEFAULT_MAC_FILE_PATH
+#define DEFAULT_MAC_FILE_PATH "/sys/class/net/p2p0/address"
+#endif
+
static wfd_oem_ops_s supplicant_ops = {
.init = ws_init,
.deinit = ws_deinit,
{
__WDP_LOG_FUNC_ENTER__;
FILE *fd = NULL;
- unsigned char local_mac[WS_MACSTR_LEN] = {0, };
+ const char *file_path = DEFAULT_MAC_FILE_PATH;
+ char local_mac[OEM_MACSTR_LEN] = {0, };
char *ptr = NULL;
int res = 0;
errno = 0;
- fd = fopen(DEFAULT_MAC_FILE_PATH, "r");
+ fd = fopen(file_path, "r");
if (!fd) {
- WDP_LOGE("Failed to open MAC info file (%s)", strerror(errno));
+ WDP_LOGE("Failed to open MAC info file [%s] (%s)",file_path, strerror(errno));
__WDP_LOG_FUNC_EXIT__;
return -1;
}
WDP_SECLOGD("Local MAC address [%s]", ptr);
WDP_SECLOGD("Local MAC address [%s]", local_mac);
- res = __ws_txt_to_mac(local_mac, dev_mac);
+ res = __ws_txt_to_mac((unsigned char *)local_mac, dev_mac);
if (res < 0) {
WDP_LOGE("Failed to convert text to MAC address");
fclose(fd);
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(LIBDIR ${CMAKE_LIB_DIR})
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/oem)
INCLUDE_DIRECTORIES(SRCS include)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME})
# install
-INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIBDIR})
+INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIB_DIR})
#define SOCK_FD_MIN 3
#define GLOBAL_INTF_PATH "/tmp/wpa_ctrl_global"
-#define SUPPL_GLOBAL_INTF_PATH "/var/run/wpa_global"
-#define SUPPL_IFACE_PATH "/var/run/wpa_supplicant/"
-#define SUPPL_GROUP_IFACE_PATH "/var/run/wpa_supplicant/"
-
-#if defined TIZEN_MOBILE
-#define DEFAULT_MAC_FILE_PATH "/opt/etc/.mac.info"
-#endif
-
-#if defined TIZEN_WIFI_MODULE_BUNDLE
-#define DEFAULT_MAC_FILE_PATH "/sys/class/net/wlan0/address"
-#endif
-
-#ifndef DEFAULT_MAC_FILE_PATH
-#define DEFAULT_MAC_FILE_PATH "/sys/class/net/p2p0/address"
-#endif
#if defined TIZEN_MOBILE
#define COMMON_IFACE_NAME "wlan0"
#include <glib.h>
#include <gio/gio.h>
+#include <tzplatform_config.h>
+
#include "wifi-direct-oem.h"
#include "wfd-plugin-log.h"
#include "wfd-plugin-wpasupplicant.h"
#define NETCONFIG_DBUS_REPLY_TIMEOUT (10 * 1000)
+#define SUPPL_GLOBAL_INTF_PATH tzplatform_getenv(TZ_SYS_RUN, "wpa_global/")
+#define SUPPL_IFACE_PATH tzplatform_getenv(TZ_SYS_RUN, "wpa_supplicant/")
+#define SUPPL_GROUP_IFACE_PATH tzplatform_getenv(TZ_SYS_RUN, "wpa_supplicant/")
+
+#if defined TIZEN_MOBILE
+#define DEFAULT_MAC_FILE_PATH tzplatform_mkpath(TZ_SYS_ETC, ".mac.info")
+#endif
+
+#if defined TIZEN_WIFI_MODULE_BUNDLE
+#define DEFAULT_MAC_FILE_PATH "/sys/class/net/wlan0/address"
+#endif
+
+#ifndef DEFAULT_MAC_FILE_PATH
+#define DEFAULT_MAC_FILE_PATH "/sys/class/net/p2p0/address"
+#endif
+
ws_string_s ws_event_strs[] = {
// discovery
{"P2P-DEVICE-FOUND", WS_EVENT_DEVICE_FOUND},
{
__WDP_LOG_FUNC_ENTER__;
FILE *fd = NULL;
+ const char *file_path = DEFAULT_MAC_FILE_PATH;
char local_mac[OEM_MACSTR_LEN] = {0, };
char *ptr = NULL;
int res = 0;
errno = 0;
- fd = fopen(DEFAULT_MAC_FILE_PATH, "r");
+ fd = fopen(file_path, "r");
if (!fd) {
- WDP_LOGE("Failed to open MAC info file (%s)", strerror(errno));
+ WDP_LOGE("Failed to open MAC info file [%s] (%s)",file_path, strerror(errno));
__WDP_LOG_FUNC_EXIT__;
return -1;
}
}
WDP_SECLOGD("Local MAC address [%s]", ptr);
- res = _ws_txt_to_mac(local_mac, g_pd->local_dev_addr);
+ res = _ws_txt_to_mac((unsigned char *)local_mac, g_pd->local_dev_addr);
if (res < 0) {
WDP_LOGE("Failed to convert text to MAC address");
fclose(fd);
#include <glib.h>
#include <vconf.h>
+#include <tzplatform_config.h>
#if defined(TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT)
#include <app_control.h>
#include <aul.h>
#define TIZEN_P2P_GO_IPADDR "192.168.49.1"
#define MAX_SIZE_ERROR_BUFFER 256
+#if defined TIZEN_MOBILE
+#define DEFAULT_MAC_FILE_PATH tzplatform_mkpath(TZ_SYS_ETC, ".mac.info")
+#endif /* TIZEN_MOBILE */
+
+#if defined TIZEN_TV
+# if defined TIZEN_WIFI_MODULE_BUNDLE
+# define DEFAULT_MAC_FILE_PATH "/sys/class/net/wlan0/address"
+# else /* TIZEN_WIFI_MODULE_BUNDLE */
+# define DEFAULT_MAC_FILE_PATH "/sys/class/net/p2p0/address"
+# endif /* TIZEN_WIFI_MODULE_BUNDLE */
+#endif /* TIZEN_TV */
+
+#ifndef DEFAULT_MAC_FILE_PATH
+# define DEFAULT_MAC_FILE_PATH "/sys/class/net/p2p0/address"
+#endif
+
+#define COUNTRY_CODE_FILE tzplatform_mkpath(TZ_SYS_RO_ETC, "wifi-direct/ccode.conf")
+
static int _txt_to_mac(char *txt, unsigned char *mac)
{
int i = 0;
char mcc[4] = {0, };
char *ccode;
GKeyFile *keyfile = NULL;
+ const char *file_path = COUNTRY_CODE_FILE;
GError * err = NULL;
if (!manager) {
snprintf(mcc, 4, "%d", plmn);
keyfile = g_key_file_new();
- res = g_key_file_load_from_file(keyfile, COUNTRY_CODE_FILE, 0, &err);
+ res = g_key_file_load_from_file(keyfile, file_path, 0, &err);
if (!res) {
WDS_LOGE("Failed to load key file(%s)", err->message);
g_key_file_free(keyfile);
int wfd_util_get_local_dev_mac(unsigned char *dev_mac)
{
__WDS_LOG_FUNC_ENTER__;
+ const char *file_path = DEFAULT_MAC_FILE_PATH;
FILE *fd = NULL;
char local_mac[MACSTR_LEN] = {0, };
char *ptr = NULL;
int res = 0;
errno = 0;
- fd = fopen(DEFAULT_MAC_FILE_PATH, "r");
+ fd = fopen(file_path, "r");
if (!fd) {
- WDS_LOGE("Failed to open MAC info file (%s)", strerror(errno));
+ WDS_LOGE("Failed to open MAC info file [%s] (%s)",file_path , strerror(errno));
__WDS_LOG_FUNC_EXIT__;
return -1;
}