From 09b243ffde24b8d42a6551a756f32f11a8173f97 Mon Sep 17 00:00:00 2001 From: Yu Jiung Date: Wed, 9 Mar 2016 18:28:19 +0900 Subject: [PATCH] Remove DHCP operation files which are dependent on interface name Description: We can put the group inteface name into the dhcpd daemon in runtime because dhcpd in toybox provides the -i option. Also, dhcp which plays the DHCP client role already has same one. So, we can use this to remove additional files for each profile. Change-Id: I484ad68653991f4790c5aae6279372efdcc89f0b igned-off-by: Yu jiung --- CMakeLists.txt | 42 ++------- files/TM1/dhcpd.p2p.conf | 10 --- files/TM1/p2p_supp.conf | 4 - files/bundle/dhcpd-notify.sh | 7 -- files/bundle/wifi-direct-dhcp.sh | 109 ----------------------- files/{common => }/ccode.conf | 0 files/common/dhcpd-notify.sh | 7 -- files/common/dhcpd.p2p.conf | 10 --- files/common/p2p_supp.conf | 4 - files/common/persistent-peer | 0 files/common/wfd-manager.conf | 15 ---- files/common/wifi-direct-dhcp.sh | 124 --------------------------- files/{tv => }/dhcpd-notify.sh | 0 files/{bundle/dhcpd.wlan.conf => dhcpd.conf} | 1 - files/{bundle => }/p2p_supp.conf | 12 ++- files/{common => }/p2p_supp.sh | 0 files/tv/dhcpd.p2p.conf | 11 --- files/tv/p2p_supp.conf | 16 ---- files/tv/wifi-direct-dhcp.sh | 109 ----------------------- files/{common => }/udhcp_script.non-autoip | 0 files/{TM1 => }/wifi-direct-dhcp.sh | 33 +++++-- files/{common => }/wifi-direct-server.sh | 0 include/wifi-direct-util.h | 8 +- packaging/wifi-direct-manager.spec | 4 +- src/wifi-direct-group.c | 11 +-- src/wifi-direct-util.c | 20 +++-- 26 files changed, 63 insertions(+), 494 deletions(-) delete mode 100644 files/TM1/dhcpd.p2p.conf delete mode 100644 files/TM1/p2p_supp.conf delete mode 100755 files/bundle/dhcpd-notify.sh delete mode 100644 files/bundle/wifi-direct-dhcp.sh rename files/{common => }/ccode.conf (100%) delete mode 100755 files/common/dhcpd-notify.sh delete mode 100755 files/common/dhcpd.p2p.conf delete mode 100755 files/common/p2p_supp.conf delete mode 100755 files/common/persistent-peer delete mode 100644 files/common/wfd-manager.conf delete mode 100755 files/common/wifi-direct-dhcp.sh rename files/{tv => }/dhcpd-notify.sh (100%) rename files/{bundle/dhcpd.wlan.conf => dhcpd.conf} (89%) mode change 100755 => 100644 rename files/{bundle => }/p2p_supp.conf (59%) rename files/{common => }/p2p_supp.sh (100%) delete mode 100755 files/tv/dhcpd.p2p.conf delete mode 100755 files/tv/p2p_supp.conf delete mode 100755 files/tv/wifi-direct-dhcp.sh rename files/{common => }/udhcp_script.non-autoip (100%) rename files/{TM1 => }/wifi-direct-dhcp.sh (73%) rename files/{common => }/wifi-direct-server.sh (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index a08893f..8979ab3 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,39 +94,15 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -ldl) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/common/udhcp_script.non-autoip DESTINATION etc/wifi-direct) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/common/wifi-direct-server.sh DESTINATION bin) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/common/p2p_supp.sh DESTINATION sbin) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/common/ccode.conf DESTINATION etc/wifi-direct) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/common/wfd-manager.conf DESTINATION /etc/dbus-1/system.d) -IF(TIZEN_TV) - IF(TIZEN_WIFI_MODULE_BUNDLE) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/bundle/p2p_supp.conf DESTINATION etc/wifi-direct) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/bundle/p2p_supp.conf DESTINATION /opt/etc) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/bundle/dhcpd.wlan.conf DESTINATION etc/wifi-direct) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/bundle/dhcpd-notify.sh DESTINATION bin) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/bundle/wifi-direct-dhcp.sh DESTINATION bin) - ELSE(TIZEN_WIFI_MODULE_BUNDLE) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/tv/dhcpd-notify.sh DESTINATION bin) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/tv/p2p_supp.conf DESTINATION etc/wifi-direct) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/tv/p2p_supp.conf DESTINATION /opt/etc) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/tv/dhcpd.p2p.conf DESTINATION etc/wifi-direct) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/tv/wifi-direct-dhcp.sh DESTINATION bin) - ENDIF(TIZEN_WIFI_MODULE_BUNDLE) -ELSE(TIZEN_TV) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/common/dhcpd-notify.sh DESTINATION bin) - IF(TIZEN_WLAN_BOARD_SPRD) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/TM1/p2p_supp.conf DESTINATION etc/wifi-direct) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/TM1/p2p_supp.conf DESTINATION /opt/etc) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/TM1/dhcpd.p2p.conf DESTINATION etc/wifi-direct) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/TM1/wifi-direct-dhcp.sh DESTINATION bin) - ELSE(TIZEN_WLAN_BOARD_SPRD) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/common/p2p_supp.conf DESTINATION etc/wifi-direct) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/common/p2p_supp.conf DESTINATION /opt/etc) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/common/dhcpd.p2p.conf DESTINATION etc/wifi-direct) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/common/wifi-direct-dhcp.sh DESTINATION bin) - ENDIF(TIZEN_WLAN_BOARD_SPRD) -ENDIF(TIZEN_TV) +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) IF("${ARCH}" MATCHES "^arm.*|.*86.*") IF(CTRL_IFACE_DBUS) diff --git a/files/TM1/dhcpd.p2p.conf b/files/TM1/dhcpd.p2p.conf deleted file mode 100644 index 91de9f7..0000000 --- a/files/TM1/dhcpd.p2p.conf +++ /dev/null @@ -1,10 +0,0 @@ -start 192.168.49.20 #default: 192.168.0.20 -end 192.168.49.40 #default: 192.168.0.254 -interface p2p0 #default: wlan0 -max_leases 20 #default: 254 -notify_file /usr/bin/dhcpd-notify.sh - -option subnet 255.255.255.0 -option router 192.168.49.1 -option lease 864000 #10 days of seconds -option broadcast 192.168.49.255 diff --git a/files/TM1/p2p_supp.conf b/files/TM1/p2p_supp.conf deleted file mode 100644 index 5cd2582..0000000 --- a/files/TM1/p2p_supp.conf +++ /dev/null @@ -1,4 +0,0 @@ -##### p2p_supplicant configuration file template ##### -update_config=1 -eapol_version=1 -ap_scan=1 diff --git a/files/bundle/dhcpd-notify.sh b/files/bundle/dhcpd-notify.sh deleted file mode 100755 index e6c0afe..0000000 --- a/files/bundle/dhcpd-notify.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/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 diff --git a/files/bundle/wifi-direct-dhcp.sh b/files/bundle/wifi-direct-dhcp.sh deleted file mode 100644 index 1e36995..0000000 --- a/files/bundle/wifi-direct-dhcp.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/sh -INTERFACE_NAME="wlan0" -INTERFACE_PREFIX="wlan" -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=`/usr/sbin/ip link|/bin/grep ^${INTERFACE_NAME}|/usr/bin/cut -d":" -f2` -#echo "interface is ${INTERFACE_PREFIX}: ${interface}." - -start_dhcp_server() -{ - if [ "X${INTERFACE_NAME}" == "X" ]; then - echo "interface(${INTERFACE_PREFIX}) is not up" - return 0 - fi - - /bin/rm /var/lib/misc/udhcpd.leases - /bin/touch /var/lib/misc/udhcpd.leases - /sbin/ifconfig ${INTERFACE_NAME} ${DEFAULT_IP} up - /usr/sbin/ip addr add ${DEFAULT_NET} brd ${DEFAULT_BRD} dev ${INTERFACE_NAME} - /usr/sbin/dhcpd /usr/etc/wifi-direct/dhcpd.${INTERFACE_PREFIX}.conf -f & - - route=`/bin/cat /usr/etc/wifi-direct/dhcpd.${INTERFACE_PREFIX}.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.${INTERFACE_PREFIX}.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_NAME} -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_NAME}" == "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 -i ${INTERFACE_NAME} -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 - /sbin/ifconfig ${INTERFACE_NAME} 0.0.0.0 -} - -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 - diff --git a/files/common/ccode.conf b/files/ccode.conf similarity index 100% rename from files/common/ccode.conf rename to files/ccode.conf diff --git a/files/common/dhcpd-notify.sh b/files/common/dhcpd-notify.sh deleted file mode 100755 index 734fd20..0000000 --- a/files/common/dhcpd-notify.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -# Dump DHCP lease data: MAC IP Time -/usr/bin/dumpleases | /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 diff --git a/files/common/dhcpd.p2p.conf b/files/common/dhcpd.p2p.conf deleted file mode 100755 index 6c50ed2..0000000 --- a/files/common/dhcpd.p2p.conf +++ /dev/null @@ -1,10 +0,0 @@ -start 192.168.49.20 #default: 192.168.0.20 -end 192.168.49.40 #default: 192.168.0.254 -interface p2p-wlan0-0 #default: wlan0 -max_leases 20 #default: 254 -notify_file /usr/bin/dhcpd-notify.sh - -option subnet 255.255.255.0 -option router 192.168.49.1 -option lease 864000 #10 days of seconds -option broadcast 192.168.49.255 diff --git a/files/common/p2p_supp.conf b/files/common/p2p_supp.conf deleted file mode 100755 index 5cd2582..0000000 --- a/files/common/p2p_supp.conf +++ /dev/null @@ -1,4 +0,0 @@ -##### p2p_supplicant configuration file template ##### -update_config=1 -eapol_version=1 -ap_scan=1 diff --git a/files/common/persistent-peer b/files/common/persistent-peer deleted file mode 100755 index e69de29..0000000 diff --git a/files/common/wfd-manager.conf b/files/common/wfd-manager.conf deleted file mode 100644 index b4c446c..0000000 --- a/files/common/wfd-manager.conf +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - diff --git a/files/common/wifi-direct-dhcp.sh b/files/common/wifi-direct-dhcp.sh deleted file mode 100755 index 56bc51f..0000000 --- a/files/common/wifi-direct-dhcp.sh +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/sh -INTERFACE_NAME="p2p-wlan0-0" -INTERFACE_PREFIX="p2p" -TARGET="REDWOOD" -DEFAULT_IP="192.168.49.1" -DEFAULT_NET="192.168.49.1/24" -DEFAULT_BRD="192.168.49.255" - -val=`/bin/uname -a | /bin/grep PQ | /usr/bin/wc -l` -if [ "${val}" -eq "1" ]; then - TARGET="PQ" -fi - -val=`/bin/uname -a | /bin/grep U1HD | /usr/bin/wc -l` -if [ "${val}" -eq "1" ]; then - INTERFACE_PREFIX="wl0" - TARGET="U1HD" -fi - -val=`/bin/uname -a | /bin/grep U1SLP | /usr/bin/wc -l` -if [ "${val}" -eq "1" ]; then - INTERFACE_PREFIX="wl0" - TARGET="U1SLP" -fi - -val=`/bin/uname -a | /bin/grep i686 | /usr/bin/wc -l` -if [ "${val}" -eq "1" ]; then - INTERFACE_PREFIX="eth" - TARGET="EMUL" -fi - -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 - - /usr/sbin/ip addr add ${DEFAULT_NET} brd ${DEFAULT_BRD} dev ${interface} - /usr/sbin/dhcpd /usr/etc/wifi-direct/dhcpd.${INTERFACE_PREFIX}.conf -f & - - route=`/bin/cat /usr/etc/wifi-direct/dhcpd.${INTERFACE_PREFIX}.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.${INTERFACE_PREFIX}.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/dhcp -i $interface -s /usr/etc/wifi-direct/udhcp_script.non-autoip & -} - - -stop_dhcp() -{ - /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 - - /usr/bin/pkill -x dhcp - /usr/bin/pkill -x dhcpd -# /sbin/ifconfig ${interface} 0.0.0.0 -} - -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") -stop_dhcp -start_dhcp_client -;; -"stop") -stop_dhcp -;; -"status") -status_dhcp -;; -*) -/bin/echo wifi-direct-dhcp.sh [server] [client] [stop] [status] -exit 1 -;; -esac - diff --git a/files/tv/dhcpd-notify.sh b/files/dhcpd-notify.sh similarity index 100% rename from files/tv/dhcpd-notify.sh rename to files/dhcpd-notify.sh diff --git a/files/bundle/dhcpd.wlan.conf b/files/dhcpd.conf old mode 100755 new mode 100644 similarity index 89% rename from files/bundle/dhcpd.wlan.conf rename to files/dhcpd.conf index b3c3bd3..7668a36 --- a/files/bundle/dhcpd.wlan.conf +++ b/files/dhcpd.conf @@ -1,6 +1,5 @@ start 192.168.49.20 #default: 192.168.0.20 end 192.168.49.40 #default: 192.168.0.254 -interface wlan0 #default: wlan0 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 diff --git a/files/bundle/p2p_supp.conf b/files/p2p_supp.conf similarity index 59% rename from files/bundle/p2p_supp.conf rename to files/p2p_supp.conf index f89deba..36f32ca 100644 --- a/files/bundle/p2p_supp.conf +++ b/files/p2p_supp.conf @@ -1,15 +1,13 @@ - ##### p2p_supplicant configuration file template ##### -update_config=1 ctrl_interface=/var/run/wpa_supplicant +update_config=1 eapol_version=1 ap_scan=1 p2p_listen_reg_class=81 p2p_listen_channel=1 p2p_oper_reg_class=81 p2p_oper_channel=1 -device_name=[TV]Tizen -device_type=7-0050F204-1 -config_methods=keypad virtual_push_button physical_display -persistent_reconnect=1 -p2p_no_group_iface=1 +device_name=Tizen +device_type=10-0050F204-5 +config_methods=push_button,keypad,display +driver_param=use_p2p_group_interface=0 diff --git a/files/common/p2p_supp.sh b/files/p2p_supp.sh similarity index 100% rename from files/common/p2p_supp.sh rename to files/p2p_supp.sh diff --git a/files/tv/dhcpd.p2p.conf b/files/tv/dhcpd.p2p.conf deleted file mode 100755 index 617c7b6..0000000 --- a/files/tv/dhcpd.p2p.conf +++ /dev/null @@ -1,11 +0,0 @@ -start 192.168.49.20 #default: 192.168.0.20 -end 192.168.49.40 #default: 192.168.0.254 -interface p2p0 #default: wlan0 -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 - -option subnet 255.255.255.0 -option router 192.168.49.1 -option lease 864000 #10 days of seconds -option broadcast 192.168.49.255 diff --git a/files/tv/p2p_supp.conf b/files/tv/p2p_supp.conf deleted file mode 100755 index 77b0c58..0000000 --- a/files/tv/p2p_supp.conf +++ /dev/null @@ -1,16 +0,0 @@ - -##### p2p_supplicant configuration file template ##### -update_config=1 -ctrl_interface=/var/run/wpa_supplicant -eapol_version=1 -ap_scan=1 -p2p_listen_reg_class=81 -p2p_listen_channel=1 -p2p_oper_reg_class=115 -p2p_oper_channel=48 -device_name=[TV]Tizen -device_type=7-0050F204-1 -config_methods=keypad virtual_push_button physical_display -persistent_reconnect=1 -p2p_no_group_iface=1 -p2p_go_ht40=1 diff --git a/files/tv/wifi-direct-dhcp.sh b/files/tv/wifi-direct-dhcp.sh deleted file mode 100755 index 0a116fa..0000000 --- a/files/tv/wifi-direct-dhcp.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/sh -INTERFACE_NAME="p2p0" -INTERFACE_PREFIX="p2p" -TARGET="TIZEN_TV" -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` -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 /var/lib/misc/udhcpd.leases - /bin/touch /var/lib/misc/udhcpd.leases - /sbin/ifconfig ${INTERFACE_NAME} ${DEFAULT_IP} up -# /usr/sbin/ip addr add ${DEFAULT_NET} brd ${DEFAULT_BRD} dev ${INTERFACE_NAME} - /usr/sbin/dhcpd /usr/etc/wifi-direct/dhcpd.${INTERFACE_PREFIX}.conf -f & - - route=`/bin/cat /usr/etc/wifi-direct/dhcpd.${INTERFACE_PREFIX}.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.${INTERFACE_PREFIX}.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 -i ${INTERFACE_NAME} -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 -# /sbin/ifconfig ${interface} 0.0.0.0 -} - -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 - diff --git a/files/common/udhcp_script.non-autoip b/files/udhcp_script.non-autoip similarity index 100% rename from files/common/udhcp_script.non-autoip rename to files/udhcp_script.non-autoip diff --git a/files/TM1/wifi-direct-dhcp.sh b/files/wifi-direct-dhcp.sh similarity index 73% rename from files/TM1/wifi-direct-dhcp.sh rename to files/wifi-direct-dhcp.sh index 0ba9c9a..d95428e 100644 --- a/files/TM1/wifi-direct-dhcp.sh +++ b/files/wifi-direct-dhcp.sh @@ -1,13 +1,17 @@ #!/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=`/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}." @@ -18,14 +22,16 @@ start_dhcp_server() 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 /usr/etc/wifi-direct/dhcpd.${INTERFACE_PREFIX}.conf -f & + /usr/sbin/dhcpd -S -i ${interface} /usr/etc/wifi-direct/dhcpd.conf -f & - route=`/bin/cat /usr/etc/wifi-direct/dhcpd.${INTERFACE_PREFIX}.conf | /bin/grep router | /bin/awk '{print $3}'` + 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.${INTERFACE_PREFIX}.conf | /bin/grep subnet | /bin/awk '{print $3}'` + 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" @@ -43,21 +49,30 @@ start_dhcp_client() echo "interface(${INTERFACE_PREFIX}) is not up" return 0 fi - /usr/bin/dhcp -i $interface -s /usr/etc/wifi-direct/udhcp_script.non-autoip & + + /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 & } -stop_dhcp() +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 - /sbin/ifconfig ${interface} 0.0.0.0 + 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() @@ -84,10 +99,12 @@ stop_dhcp start_dhcp_server ;; "client") +clean_vconfs stop_dhcp start_dhcp_client ;; "stop") +clean_vconfs stop_dhcp ;; "status") diff --git a/files/common/wifi-direct-server.sh b/files/wifi-direct-server.sh similarity index 100% rename from files/common/wifi-direct-server.sh rename to files/wifi-direct-server.sh diff --git a/include/wifi-direct-util.h b/include/wifi-direct-util.h index 5781809..9605ed6 100755 --- a/include/wifi-direct-util.h +++ b/include/wifi-direct-util.h @@ -88,11 +88,11 @@ int wfd_util_start_wifi_direct_popup(); int wfd_util_stop_wifi_direct_popup(); #endif /* TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT */ -int wfd_util_dhcps_start(); +int wfd_util_dhcps_start(char *ifname); int wfd_util_dhcps_wait_ip_leased(wfd_device_s *peer); -int wfd_util_dhcps_stop(); -int wfd_util_dhcpc_start(wfd_device_s *peer); -int wfd_util_dhcpc_stop(); +int wfd_util_dhcps_stop(char *ifname); +int wfd_util_dhcpc_start(char *ifname, wfd_device_s *peer); +int wfd_util_dhcpc_stop(char *ifname); int wfd_util_local_get_ip(char *ifname, unsigned char *ip_addr, int is_IPv6); int wfd_util_dhcpc_get_server_ip(unsigned char* ip_addr); #ifdef TIZEN_FEATURE_IP_OVER_EAPOL diff --git a/packaging/wifi-direct-manager.spec b/packaging/wifi-direct-manager.spec index f341259..5ee9d9d 100755 --- a/packaging/wifi-direct-manager.spec +++ b/packaging/wifi-direct-manager.spec @@ -1,6 +1,6 @@ Name: wifi-direct-manager Summary: Wi-Fi Direct manger -Version: 1.2.140 +Version: 1.2.141 Release: 1 Group: Network & Connectivity/Wireless License: Apache-2.0 @@ -150,7 +150,7 @@ chmod 755 /usr/sbin/p2p_supp.sh %license LICENSE %defattr(-,root,root,-) %{_bindir}/wfd-manager -/usr/etc/wifi-direct/dhcpd.*.conf +/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 diff --git a/src/wifi-direct-group.c b/src/wifi-direct-group.c index 4340342..3a64aee 100755 --- a/src/wifi-direct-group.c +++ b/src/wifi-direct-group.c @@ -93,7 +93,7 @@ wfd_group_s *wfd_create_group(void *data, wfd_oem_event_s *group_info) manager->group = group; manager->local->dev_role = group_info->dev_role; - wfd_util_dhcps_start(); + wfd_util_dhcps_start(group->ifname); WDS_LOGD("Role is Group Owner. DHCP Server started"); __WDS_LOG_FUNC_EXIT__; @@ -189,7 +189,7 @@ int wfd_group_complete(void *data, wfd_oem_event_s *group_info) } if (group->role == WFD_DEV_ROLE_GO) { - wfd_util_dhcps_start(); + wfd_util_dhcps_start(group->ifname); WDS_LOGD("Role is Group Owner. DHCP Server started"); } else { if(!peer) { @@ -212,7 +212,7 @@ int wfd_group_complete(void *data, wfd_oem_event_s *group_info) } if(peer->ip_type != WFD_IP_TYPE_OVER_EAPOL) #endif /* TIZEN_FEATURE_IP_OVER_EAPOL */ - wfd_util_dhcpc_start(peer); + wfd_util_dhcpc_start(group->ifname, peer); } __WDS_LOG_FUNC_EXIT__; @@ -242,10 +242,11 @@ int wfd_destroy_group(void *data, char *ifname) } manager->group = NULL; + wfd_util_ip_unset(group->ifname); if (group->role == WFD_DEV_ROLE_GO) - wfd_util_dhcps_stop(); + wfd_util_dhcps_stop(group->ifname); else - wfd_util_dhcpc_stop(); + wfd_util_dhcpc_stop(group->ifname); memset(manager->local->ip_addr, 0x0, IPADDR_LEN); temp = g_list_first(group->members); diff --git a/src/wifi-direct-util.c b/src/wifi-direct-util.c index 0a59522..abad70a 100755 --- a/src/wifi-direct-util.c +++ b/src/wifi-direct-util.c @@ -791,12 +791,13 @@ static gboolean _polling_ip(gpointer user_data) return FALSE; } -int wfd_util_dhcps_start() +int wfd_util_dhcps_start(char *ifname) { __WDS_LOG_FUNC_ENTER__; gboolean rv = FALSE; + char *const iface = ifname; const char *path = "/usr/bin/wifi-direct-dhcp.sh"; - char *const args[] = { "/usr/bin/wifi-direct-dhcp.sh", "server", NULL }; + char *const args[] = { "/usr/bin/wifi-direct-dhcp.sh", "server", iface, NULL }; char *const envs[] = { NULL }; wfd_manager_s *manager = wfd_get_manager(); @@ -842,12 +843,13 @@ int wfd_util_dhcps_wait_ip_leased(wfd_device_s *peer) return 0; } -int wfd_util_dhcps_stop() +int wfd_util_dhcps_stop(char *ifname) { __WDS_LOG_FUNC_ENTER__; gboolean rv = FALSE; + char *const iface = ifname; const char *path = "/usr/bin/wifi-direct-dhcp.sh"; - char *const args[] = { "/usr/bin/wifi-direct-dhcp.sh", "stop", NULL }; + char *const args[] = { "/usr/bin/wifi-direct-dhcp.sh", "stop", iface, NULL }; char *const envs[] = { NULL }; vconf_ignore_key_changed(VCONFKEY_DHCPS_IP_LEASE, _dhcps_ip_leased_cb); @@ -865,12 +867,13 @@ int wfd_util_dhcps_stop() return 0; } -int wfd_util_dhcpc_start(wfd_device_s *peer) +int wfd_util_dhcpc_start(char *ifname, wfd_device_s *peer) { __WDS_LOG_FUNC_ENTER__; gboolean rv = FALSE; + char *const iface = ifname; const char *path = "/usr/bin/wifi-direct-dhcp.sh"; - char *const args[] = { "/usr/bin/wifi-direct-dhcp.sh", "client", NULL }; + char *const args[] = { "/usr/bin/wifi-direct-dhcp.sh", "client", iface, NULL }; char *const envs[] = { NULL }; if (!peer) { @@ -891,12 +894,13 @@ int wfd_util_dhcpc_start(wfd_device_s *peer) return 0; } -int wfd_util_dhcpc_stop() +int wfd_util_dhcpc_stop(char *ifname) { __WDS_LOG_FUNC_ENTER__; gboolean rv = FALSE; + char *const iface = ifname; const char *path = "/usr/bin/wifi-direct-dhcp.sh"; - char *const args[] = { "/usr/bin/wifi-direct-dhcp.sh", "stop", NULL }; + char *const args[] = { "/usr/bin/wifi-direct-dhcp.sh", "stop", iface, NULL }; char *const envs[] = { NULL }; rv = wfd_util_execute_file(path, args, envs); -- 2.7.4