[wfd-manager]: Sync-up with Tizen 2.4 Profile 47/43447/1 accepted/tizen/mobile/20150715.064243 accepted/tizen/tv/20150715.064254 accepted/tizen/wearable/20150715.064258 submit/tizen/20150715.062148
authorManeesh Jain <maneesh.jain@samsung.com>
Thu, 9 Jul 2015 09:58:17 +0000 (15:28 +0530)
committerManeesh Jain <maneesh.jain@samsung.com>
Thu, 9 Jul 2015 09:59:46 +0000 (15:29 +0530)
Change-Id: I73971e3389521ce54d109c3851e9869997c11cf5
Signed-off-by: Maneesh Jain <maneesh.jain@samsung.com>
33 files changed:
CMakeLists.txt
files/common/ccode.conf [moved from files/ccode.conf with 100% similarity, mode: 0755]
files/common/dhcpd-notify.sh [moved from files/dhcpd-notify.sh with 100% similarity, mode: 0755]
files/common/dhcpd.p2p.conf [moved from files/dhcpd.p2p.conf with 80% similarity, mode: 0755]
files/common/p2p_supp.conf [new file with mode: 0755]
files/common/p2p_supp.sh [moved from files/p2p_supp.sh with 52% similarity, mode: 0755]
files/common/p2p_supplicant [new file with mode: 0755]
files/common/persistent-peer [moved from files/persistent-peer with 100% similarity, mode: 0755]
files/common/udhcp_script.non-autoip [moved from files/udhcp_script.non-autoip with 100% similarity, mode: 0755]
files/common/wifi-direct-dhcp.sh [moved from files/wifi-direct-dhcp.sh with 85% similarity, mode: 0755]
files/common/wifi-direct-server.sh [moved from files/wifi-direct-server.sh with 100% similarity, mode: 0755]
files/p2p_supp.conf [deleted file]
files/tv/dhcpd-notify.sh [new file with mode: 0755]
files/tv/dhcpd.p2p.conf [new file with mode: 0755]
files/tv/p2p_supp.conf [moved from files/p2p_supp_tv.conf with 63% similarity, mode: 0755]
files/tv/wifi-direct-dhcp.sh [new file with mode: 0755]
include/wifi-direct-group.h [changed mode: 0644->0755]
include/wifi-direct-ipc.h [changed mode: 0644->0755]
include/wifi-direct-manager.h
include/wifi-direct-util.h
oem/wifi-direct-oem.h [changed mode: 0644->0755]
packaging/wifi-direct-manager.spec
plugin/wpasupplicant/ctrl_iface_dbus/dbus/wfd-plugin-supplicant-dbus.h [changed mode: 0644->0755]
plugin/wpasupplicant/ctrl_iface_dbus/include/wfd-plugin-wpasupplicant.h
plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c
plugin/wpasupplicant/ctrl_iface_sock/include/wfd-plugin-wpasupplicant.h
plugin/wpasupplicant/ctrl_iface_sock/wfd-plugin-wpasupplicant.c [changed mode: 0644->0755]
src/wifi-direct-client.c
src/wifi-direct-event.c [changed mode: 0644->0755]
src/wifi-direct-group.c [changed mode: 0644->0755]
src/wifi-direct-manager.c [changed mode: 0644->0755]
src/wifi-direct-service.c [changed mode: 0644->0755]
src/wifi-direct-util.c

index 0625b9b..8a0ba17 100755 (executable)
@@ -8,7 +8,7 @@ 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 capi-appfw-application vconf ${MDM_REQUIRED_PKGS})
+pkg_check_modules(pkgs REQUIRED capi-network-wifi-direct glib-2.0 gio-2.0 gobject-2.0 dlog capi-appfw-application vconf  ${MDM_REQUIRED_PKGS})
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
@@ -40,6 +40,10 @@ IF(TIZEN_WLAN_CONCURRENT_ENABLE)
        ADD_DEFINITIONS(-DTIZEN_WLAN_CONCURRENT_ENABLE)
 ENDIF(TIZEN_WLAN_CONCURRENT_ENABLE)
 
+IF(TIZEN_MOBILE)
+       ADD_DEFINITIONS(-DTIZEN_MOBILE)
+ENDIF(TIZEN_MOBILE)
+
 IF(TIZEN_TV)
        ADD_DEFINITIONS(-DTIZEN_TV)
 ENDIF(TIZEN_TV)
@@ -68,24 +72,25 @@ 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/dhcpd.p2p.conf DESTINATION etc/wifi-direct)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/udhcp_script.non-autoip DESTINATION etc/wifi-direct)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/dhcpd-notify.sh DESTINATION bin)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/wifi-direct-server.sh DESTINATION bin)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/wifi-direct-dhcp.sh DESTINATION bin)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/p2p_supp.sh DESTINATION sbin)
-#INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/p2p_supplicant DESTINATION sbin)
+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/persistent-peer DESTINATION /opt/etc)
 IF(TIZEN_TV)
-       INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/p2p_supp_tv.conf DESTINATION etc/wifi-direct)
-       INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/p2p_supp_tv.conf DESTINATION /opt/etc)
+       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/dhcpd-notify.sh DESTINATION bin)
+       INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/tv/wifi-direct-dhcp.sh DESTINATION bin)
 ELSE(TIZEN_TV)
-       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/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/dhcpd-notify.sh DESTINATION bin)
+       INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/common/wifi-direct-dhcp.sh DESTINATION bin)
 ENDIF(TIZEN_TV)
 
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/ccode.conf DESTINATION etc/wifi-direct)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/persistent-peer DESTINATION /opt/etc)
-
 IF("${ARCH}" MATCHES "^arm.*|.*86.*")
 IF(CTRL_IFACE_DBUS)
        ADD_SUBDIRECTORY(plugin/wpasupplicant/ctrl_iface_dbus)
old mode 100644 (file)
new mode 100755 (executable)
similarity index 100%
rename from files/ccode.conf
rename to files/common/ccode.conf
old mode 100644 (file)
new mode 100755 (executable)
similarity index 100%
rename from files/dhcpd-notify.sh
rename to files/common/dhcpd-notify.sh
old mode 100644 (file)
new mode 100755 (executable)
similarity index 80%
rename from files/dhcpd.p2p.conf
rename to files/common/dhcpd.p2p.conf
index 41545ac..042b08f
@@ -1,7 +1,6 @@
 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
-interface      wlan0           #default: wlan0
+interface      p2p-wlan0-0             #default: wlan0
 max_leases     20                      #default: 254
 notify_file     /usr/bin/dhcpd-notify.sh
 
diff --git a/files/common/p2p_supp.conf b/files/common/p2p_supp.conf
new file mode 100755 (executable)
index 0000000..5cd2582
--- /dev/null
@@ -0,0 +1,4 @@
+##### p2p_supplicant configuration file template #####
+update_config=1
+eapol_version=1
+ap_scan=1
old mode 100644 (file)
new mode 100755 (executable)
similarity index 52%
rename from files/p2p_supp.sh
rename to files/common/p2p_supp.sh
index d185d28..e03cac6
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+PROGRAM="/usr/sbin/wpa_supplicant"
+
 start()
 {
        HARDWARE_MODEL=`/bin/grep Hardware /proc/cpuinfo | /bin/awk "{print \\$3}"`
@@ -13,9 +15,9 @@ start()
        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_tv.conf -g/var/run/wpa_global  -f/opt/usr/data/network/p2p_supplicant.log
+               /usr/sbin/wpa_supplicant -t -B -ddd -Dnl80211 -ip2p0 -c/opt/etc/p2p_supp.conf -g/var/run/wpa_global  -f/opt/usr/data/network/wpa_supplicant.log
         else
-               /usr/sbin/p2p_supplicant -t -B -C/var/run/wpa_supplicant -ddd -Dnl80211 -iwlan0 -c/opt/etc/p2p_supp.conf -f/opt/usr/data/network/p2p_supplicant.log
+               /usr/sbin/wpa_supplicant -t -B -C/var/run/wpa_supplicant -ddd -Dnl80211 -iwlan0 -c/opt/etc/p2p_supp.conf -f/opt/usr/data/network/wpa_supplicant.log
        fi
  }
 
@@ -27,25 +29,24 @@ start_p2p0()
                echo "File not exist. Reinstall: /opt/etc/p2p_supp.conf"
                 /bin/cp /usr/etc/wifi-direct/p2p_supp.conf /opt/etc/
        fi
-       /usr/sbin/p2p_supplicant -t -B -ddd -Dnl80211 -ip2p0 -c/opt/etc/p2p_supp.conf -f/opt/usr/data/network/p2p_supplicant.log
+       /usr/sbin/wpa_supplicant -t -B -ddd -Dnl80211 -ip2p0 -c/opt/etc/p2p_supp.conf -f/opt/usr/data/network/wpa_supplicant.log
 }
 
 start_dbus()
 {
-       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"
+       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/opt/usr/data/network/wpa_supplicant.log
        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 -u -ddd -Dnl80211 -ip2p0 -c/opt/etc/p2p_supp_tv.conf -f/opt/usr/data/network/p2p_supplicant.log
-        else
-               /usr/sbin/p2p_supplicant -t -B -u -ddd -Dnl80211 -iwlan0 -c/opt/etc/p2p_supp.conf -f/opt/usr/data/network/p2p_supplicant.log
+               echo "${program} is already running"
        fi
 }
 
diff --git a/files/common/p2p_supplicant b/files/common/p2p_supplicant
new file mode 100755 (executable)
index 0000000..6bf97f2
Binary files /dev/null and b/files/common/p2p_supplicant differ
old mode 100644 (file)
new mode 100755 (executable)
similarity index 100%
rename from files/persistent-peer
rename to files/common/persistent-peer
old mode 100644 (file)
new mode 100755 (executable)
similarity index 100%
rename from files/udhcp_script.non-autoip
rename to files/common/udhcp_script.non-autoip
old mode 100644 (file)
new mode 100755 (executable)
similarity index 85%
rename from files/wifi-direct-dhcp.sh
rename to files/common/wifi-direct-dhcp.sh
index 68d6eb3..9737c35
@@ -1,7 +1,5 @@
 #!/bin/sh
-#INTERFACE_NAME="p2p-wlan0-0"
-#INTERFACE_PREFIX="p2p"
-INTERFACE_NAME="wlan0"
+INTERFACE_NAME="p2p-wlan0-0"
 INTERFACE_PREFIX="p2p"
 TARGET="REDWOOD"
 DEFAULT_IP="192.168.49.1"
@@ -31,9 +29,8 @@ if [ "${val}" -eq "1" ]; then
        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=`/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}."
 
@@ -44,8 +41,8 @@ start_dhcp_server()
                return 0
         fi
 
-       /sbin/ifconfig ${interface} ${DEFAULT_IP} up
-       /usr/bin/udhcpd /usr/etc/wifi-direct/dhcpd.${INTERFACE_PREFIX}.conf -f &
+       /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
@@ -69,7 +66,7 @@ start_dhcp_client()
                 echo "interface(${INTERFACE_PREFIX}) is not up"
                return 0
         fi
-       /usr/bin/udhcpc -i $interface -s /usr/etc/wifi-direct/udhcp_script.non-autoip &
+       /usr/bin/dhcp -i $interface -s /usr/etc/wifi-direct/udhcp_script.non-autoip &
 }
 
 
@@ -80,9 +77,9 @@ stop_dhcp()
        /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/killall /usr/bin/udhcpc
-       /usr/bin/killall /usr/bin/udhcpd
-       /sbin/ifconfig ${interface} 0.0.0.0
+       /usr/bin/killall /usr/bin/dhcp
+       /usr/bin/killall /usr/sbin/dhcpd
+#      /sbin/ifconfig ${interface} 0.0.0.0
 }
 
 is_running()
@@ -98,8 +95,8 @@ is_running()
 
 status_dhcp()
 {
-       is_running /usr/bin/udhcpc
-       is_running /usr/bin/udhcpd
+       is_running /usr/bin/dhcp
+       is_running /usr/sbin/dhcpd
 }
 
 
old mode 100644 (file)
new mode 100755 (executable)
similarity index 100%
rename from files/wifi-direct-server.sh
rename to files/common/wifi-direct-server.sh
diff --git a/files/p2p_supp.conf b/files/p2p_supp.conf
deleted file mode 100644 (file)
index bb4e500..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-##### p2p_supplicant configuration file template #####
-update_config=1
-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=Tizen
-device_type=10-0050F204-5
-config_methods=push_button
-persistent_reconnect=1
-p2p_no_group_iface=1
\ No newline at end of file
diff --git a/files/tv/dhcpd-notify.sh b/files/tv/dhcpd-notify.sh
new file mode 100755 (executable)
index 0000000..e6c0afe
--- /dev/null
@@ -0,0 +1,7 @@
+#!/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/tv/dhcpd.p2p.conf b/files/tv/dhcpd.p2p.conf
new file mode 100755 (executable)
index 0000000..617c7b6
--- /dev/null
@@ -0,0 +1,11 @@
+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
old mode 100644 (file)
new mode 100755 (executable)
similarity index 63%
rename from files/p2p_supp_tv.conf
rename to files/tv/p2p_supp.conf
index f7fee0e..77b0c58
@@ -8,8 +8,9 @@ p2p_listen_reg_class=81
 p2p_listen_channel=1
 p2p_oper_reg_class=115
 p2p_oper_channel=48
-device_name=Tizen-TV
-device_type=10-0050F204-5
-config_methods=display keypad push_button
+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
new file mode 100755 (executable)
index 0000000..49da350
--- /dev/null
@@ -0,0 +1,101 @@
+#!/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
+
+       /usr/sbin/ip addr add ${DEFAULT_NET} brd ${DEFAULT_BRD} dev ${interface}
+       /usr/bin/udhcpd /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/udhcpc -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/killall /usr/bin/udhcpc
+       /usr/bin/killall /usr/bin/udhcpd
+#      /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/udhcpc
+       is_running /usr/bin/udhcpd
+}
+
+
+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
+
old mode 100644 (file)
new mode 100755 (executable)
index 27c1271..4ec0620
@@ -47,7 +47,7 @@ typedef struct {
        int freq;               // MHz
        GList *members;
        int member_count;
-       char passphrase[PASSPHRASE_LEN +1];
+       char passphrase[PASSPHRASE_LEN_MAX + 1];
 } wfd_group_s;
 
 
old mode 100644 (file)
new mode 100755 (executable)
index b9878d3..ed32270
@@ -116,7 +116,7 @@ typedef enum
        WIFI_DIRECT_CMD_GET_OPERATING_CHANNEL,
        WIFI_DIRECT_CMD_ACTIVATE_PERSISTENT_GROUP,
        WIFI_DIRECT_CMD_DEACTIVATE_PERSISTENT_GROUP,
-       WIFI_DIRECT_CMD_IS_PERSISTENT_GROUP,
+       WIFI_DIRECT_CMD_IS_PERSISTENT_GROUP_ACTIVATED,
        WIFI_DIRECT_CMD_GET_PERSISTENT_GROUP_INFO,      // 50
        WIFI_DIRECT_CMD_REMOVE_PERSISTENT_GROUP,
        WIFI_DIRECT_CMD_GET_DEVICE_NAME,
index f4d788b..51726c7 100755 (executable)
 #ifndef __WIFI_DIRECT_MANAGER_H__
 #define __WIFI_DIRECT_MANAGER_H__
 
-#if 0
 #define DEFAULT_DEVICE_NAME "Tizen_Device"
 #define DEFAULT_IFNAME "p2p0"
-#define GROUP_IFNAME "p2p-wlan0-0"
-#endif
-
 #if defined TIZEN_TV
-       #define GROUP_IFNAME "p2p0"
-       #define DEFAULT_IFNAME "p2p0"
-       #define DEFAULT_DEVICE_NAME "TIZEN-TV-ODROID"
-
+#      define GROUP_IFNAME "p2p0"
 #else
-       #define DEFAULT_IFNAME "wlan0"
-       #define GROUP_IFNAME "p2p-wlan0-0"
-       #define DEFAULT_DEVICE_NAME "JWSCOM"
-
+#      define GROUP_IFNAME "p2p-wlan0-0"
 #endif
 
 
@@ -56,7 +46,8 @@
 #define IPADDR_LEN 4
 #define IPSTR_LEN 16
 #define PINSTR_LEN 8
-#define PASSPHRASE_LEN 64
+#define PASSPHRASE_LEN_MAX 63
+#define PASSPHRASE_LEN_MIN 8
 
 #if 0
 typedef enum {
@@ -95,8 +86,8 @@ typedef enum {
 } wfd_peer_state_e;
 
 typedef enum {
-       WFD_IP_TYPE_DYNAMIC,
-       WFD_IP_TYPE_STATIC,
+       WFD_IP_TYPE_DYNAMIC = 0x0,
+       WFD_IP_TYPE_OVER_EAPOL = 0x1,
 } wfd_ip_type_e;
 
 #ifdef TIZEN_FEATURE_WIFI_DISPLAY
@@ -143,7 +134,7 @@ typedef struct {
        int group_flags;
        int wps_mode;
 
-       char passphrase[PASSPHRASE_LEN +1];
+       char passphrase[PASSPHRASE_LEN_MAX + 1];
 
 #ifdef TIZEN_FEATURE_WIFI_DISPLAY
        wfd_display_s display;
@@ -155,6 +146,10 @@ typedef struct {
 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
 
        unsigned char ip_addr[IPADDR_LEN];
+
+       int ip_type;
+       unsigned char client_ip_addr[IPADDR_LEN];
+       unsigned char go_ip_addr[IPADDR_LEN];
 } wfd_device_s;
 
 typedef struct {
index d8fd124..91e718a 100755 (executable)
 
 #ifndef __WIFI_DIRECT_UTIL_H__
 #define __WIFI_DIRECT_UTIL_H__
-#if 0
+
 #if !defined TIZEN_TV
 #define DEFAULT_MAC_FILE_PATH "/opt/etc/.mac.info"
 #else
 #define DEFAULT_MAC_FILE_PATH "/sys/class/net/p2p0/address"
 #endif
-#endif
-#define DEFAULT_MAC_FILE_PATH "/sys/class/net/wlan0/address"
 #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]
@@ -120,4 +118,12 @@ int wfd_util_dhcpc_get_ip(char *ifname, unsigned char *ip_addr, int is_IPv6);
 int wfd_util_dhcpc_get_server_ip(unsigned char* ip_addr);
 int wfd_util_get_local_ip(unsigned char* ip_addr);
 
+#ifdef CTRL_IFACE_DBUS
+#ifdef TIZEN_VENDOR_ATH
+int wfd_util_static_ip_unset(const char *ifname);
+#endif /* TIZEN_VENDOR_ATH */
+/*TODO: ODROID Image does not have support libnl-2.0*/
+//int wfd_util_ip_over_eap_assign(wfd_device_s *peer, const char *ifname);
+//int wfd_util_ip_over_eap_lease(wfd_device_s *peer);
+#endif /* CTRL_IFACE_DBUS */
 #endif /* __WIFI_DIRECT_UTIL_H__ */
old mode 100644 (file)
new mode 100755 (executable)
index e924173..ca004c9
@@ -179,8 +179,11 @@ typedef struct {
 } wfd_oem_conn_data_s;
 
 typedef struct {
+       unsigned char sa[OEM_MACADDR_LEN];
        unsigned char go_dev_addr[OEM_MACADDR_LEN];
        unsigned char bssid[OEM_MACADDR_LEN];
+       int persistent_id;
+       int oper_freq;
        int listen;
        int status;
 } wfd_oem_invite_data_s;
@@ -190,6 +193,9 @@ typedef struct {
        int freq;
        char pass[OEM_PASS_PHRASE_LEN+1];
        unsigned char go_dev_addr[OEM_MACADDR_LEN];
+       unsigned char ip_addr[OEM_IPADDR_LEN];
+       unsigned char ip_addr_mask[OEM_IPADDR_LEN];
+       unsigned char ip_addr_go[OEM_IPADDR_LEN];
 } wfd_oem_group_data_s;
 
 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
@@ -215,6 +221,7 @@ typedef struct {
        int event_id;
        unsigned char dev_addr[OEM_MACADDR_LEN];        // device address
        unsigned char intf_addr[OEM_MACADDR_LEN];
+       unsigned char ip_addr_peer[OEM_IPADDR_LEN];
        int wps_mode;
        char wps_pin[OEM_PINSTR_LEN+1]; // just for DISPLAY
        char ifname[OEM_IFACE_NAME_LEN+1];
index 70cb5fd..4cbd944 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          wifi-direct-manager
 Summary:       Wi-Fi Direct manger
-Version:       1.2.84
+Version:       1.2.85
 Release:       1
 Group:      Network & Connectivity/Wireless
 License:    Apache-2.0
@@ -9,8 +9,9 @@ BuildRequires:  pkgconfig(capi-network-wifi-direct)
 BuildRequires: pkgconfig(gio-2.0)
 BuildRequires: pkgconfig(dlog)
 BuildRequires: pkgconfig(vconf)
-#BuildRequires:        pkgconfig(dbus-1)
-#BuildRequires:        pkgconfig(security-server)
+#BuildRequires:  pkgconfig(libnl-1)
+BuildRequires: pkgconfig(dbus-1)
+BuildRequires: pkgconfig(security-server)
 BuildRequires: pkgconfig(capi-appfw-application)
 BuildRequires: cmake
 #BuildRequires:  model-build-features
@@ -71,14 +72,13 @@ cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DARCHITECTURE=$ARCH \
         -DCTRL_IFACE_DBUS=1 \
 %else
 %if "%{profile}" == "tv"
+       -DTIZEN_FEATURE_SERVICE_DISCOVERY=1 \
+       -DTIZEN_FEATURE_WIFI_DISPLAY=1 \
+       -DCTRL_IFACE_DBUS=1 \
        -DTIZEN_TV=1 \
-        -DCTRL_IFACE_DBUS=1 \
 %endif
 %endif
 %endif
--DTIZEN_FEATURE_SERVICE_DISCOVERY=1 \
--DTIZEN_FEATURE_WIFI_DISPLAY=1 \
--DCTRL_IFACE_DBUS=1 \
 -DCMAKE_LIB_DIR=%{_libdir}
 
 make %{?_smp_mflags}
@@ -128,13 +128,8 @@ chmod 666 /var/lib/misc/udhcpd.leases
 %{_bindir}/wfd-manager
 /usr/etc/wifi-direct/dhcpd.p2p.conf
 /usr/etc/wifi-direct/udhcp_script.non-autoip
-%if "%{profile}" == "tv"
-/usr/etc/wifi-direct/p2p_supp_tv.conf
-/opt/etc/p2p_supp_tv.conf
-%else
 /usr/etc/wifi-direct/p2p_supp.conf
 /opt/etc/p2p_supp.conf
-%endif
 /usr/etc/wifi-direct/ccode.conf
 /opt/etc/persistent-peer
 %{_bindir}/dhcpd-notify.sh
old mode 100644 (file)
new mode 100755 (executable)
index 32d2607..2fd0851
@@ -12,8 +12,8 @@
 
 #define SUPPLICANT_IFACE SUPPLICANT_INTERFACE ".Interface"
 #define SUPPLICANT_NETWORK SUPPLICANT_INTERFACE ".Network"
-#define SUPPLICNAT_WPS SUPPLICANT_IFACE ".WPS"
-#define SUPPLICNAT_P2PDEVICE SUPPLICANT_IFACE ".P2PDevice"
+#define SUPPLICANT_WPS SUPPLICANT_IFACE ".WPS"
+#define SUPPLICANT_P2PDEVICE SUPPLICANT_IFACE ".P2PDevice"
 #define SUPPLICANT_P2P_PEER SUPPLICANT_INTERFACE ".Peer"
 #define SUPPLICANT_P2P_GROUP SUPPLICANT_INTERFACE ".Group"
 #define SUPPLICANT_P2P_PERSISTENTGROUP SUPPLICANT_INTERFACE ".PersistentGroup"
index 7d610ef..a5f612b 100755 (executable)
 #define IPSTR "%d.%d.%d.%d"
 #define MAC2SECSTR(a) (a)[0], (a)[4], (a)[5]
 #define MACSECSTR "%02x:%02x:%02x"
+#define ISZEROMACADDR(a) !(a[0] | a[1] | a[2] | a[3] | a[4] | a[5])
 #define IP2SECSTR(a) (a)[0], (a)[3]
 #define IPSECSTR "%d..%d"
 #define OBJECT_PATH_MAX 150
 
 #if !defined TIZEN_TV
 #define DEFAULT_MAC_FILE_PATH "/opt/etc/.mac.info"
+#define CONF_FILE_PATH "/etc/wpa_supplicant/wpa_supplicant.conf"
 #else
 #define DEFAULT_MAC_FILE_PATH "/sys/class/net/p2p0/address"
+#define CONF_FILE_PATH "/opt/etc/p2p_supp.conf"
 #endif
-#define CONF_FILE_PATH "/usr/etc/wifi-direct/p2p_supp.conf"
+
 
 #if defined TIZEN_TV
 /*For TIZEN TV Platform*/
 #define COMMON_IFACE_NAME "p2p0"
 #define GROUP_IFACE_NAME "p2p0"
 #define GROUP_IFACE_PREFIX "p2p"
+#define PRIMARY_DEVICE_TYPE "\x00\x07\x00\x50\xf2\x04\x00\x01"
+#define DEFAULT_DEVICE_NAME "[TV]Tizen"
+#define DEFAULT_GO_INTENT 7
+#define DEFAULT_PERSISTENT_RECONNECT 1
+#define DEFAULT_LISTEN_REG_CLASS 81
+#define DEFAULT_LISTEN_CHANNEL 1
+#define DEFAULT_OPER_REG_CLASS 115
+#define DEFAULT_OPER_CHANNEL 48
+#define DEFAULT_CONFIG_METHOD "keypad virtual_push_button physical_display"
+#define DEFAULT_NO_GROUP_IFACE 1
 #else /*TIZEN_TV*/
 #define COMMON_IFACE_NAME "wlan0"
 #define GROUP_IFACE_NAME "p2p-wlan0-0"
 #define GROUP_IFACE_PREFIX "p2p-wlan0-"
+#define PRIMARY_DEVICE_TYPE "\x00\x0a\x00\x50\xf2\x04\x00\x05"
+#define DEFAULT_DEVICE_NAME "Tizen"
+#define DEFAULT_GO_INTENT 7
+#define DEFAULT_PERSISTENT_RECONNECT 1
+#define DEFAULT_LISTEN_REG_CLASS 81
+#define DEFAULT_LISTEN_CHANNEL 1
+#define DEFAULT_OPER_REG_CLASS 81
+#define DEFAULT_OPER_CHANNEL 1
+#define DEFAULT_CONFIG_METHOD "push_button"
+#define DEFAULT_NO_GROUP_IFACE 0
 #endif /*TIZEN_TV*/
 
+#define DEFAULT_IP_GO "\xc0\xa8\x31\x01"
+#define DEFAULT_IP_MASK "\xff\xff\xff\x00"
+#define DEFAULT_IP_START "\xc0\xa8\x31\x33"
+#define DEFAULT_IP_END "\xc0\xa8\x31\x64"
+
 #define WS_POLL_TIMEOUT 5000
 #define WS_CONN_RETRY_COUNT 10
 #define WS_PINSTR_LEN 8
index 0dcfcae..2836f76 100755 (executable)
@@ -260,48 +260,6 @@ static int __ws_hex_to_txt(char *src, int length, char *dest)
        return 0;
 }
 
-gboolean _ws_util_execute_file(const char *file_path,
-       char *const args[], char *const envs[])
-{
-       pid_t pid = 0;
-       int rv = 0;
-       errno = 0;
-       register unsigned int index = 0;
-
-       while (args[index] != NULL) {
-               WDP_LOGD("[%s]", args[index]);
-               index++;
-       }
-
-       if (!(pid = fork())) {
-               WDP_LOGD("pid(%d), ppid(%d)", getpid(), getppid());
-               WDP_LOGD("Inside child, exec (%s) command", file_path);
-
-               errno = 0;
-               if (execve(file_path, args, envs) == -1) {
-                       WDP_LOGE("Fail to execute command (%s)", strerror(errno));
-                       exit(1);
-               }
-       } else if (pid > 0) {
-               if (waitpid(pid, &rv, 0) == -1)
-                       WDP_LOGD("wait pid (%u) rv (%d)", pid, rv);
-               if (WIFEXITED(rv)) {
-                       WDP_LOGD("exited, rv=%d", WEXITSTATUS(rv));
-               } else if (WIFSIGNALED(rv)) {
-                       WDP_LOGD("killed by signal %d", WTERMSIG(rv));
-               } else if (WIFSTOPPED(rv)) {
-                       WDP_LOGD("stopped by signal %d", WSTOPSIG(rv));
-               } else if (WIFCONTINUED(rv)) {
-                       WDP_LOGD("continued");
-               }
-
-               return TRUE;
-       }
-
-       WDP_LOGE("failed to fork (%s)", strerror(errno));
-       return FALSE;
-}
-
 static int __ws_segment_to_service(char *segment, wfd_oem_new_service_s **service)
 {
        wfd_oem_new_service_s *serv_tmp = NULL;
@@ -318,7 +276,7 @@ static int __ws_segment_to_service(char *segment, wfd_oem_new_service_s **servic
        ptr = segment;
        WDP_LOGD("Segment: %s", segment);
 
-       serv_tmp = (wfd_oem_new_service_s*) calloc(1, sizeof(wfd_oem_new_service_s));
+       serv_tmp = (wfd_oem_new_service_s*) g_try_malloc0(sizeof(wfd_oem_new_service_s));
        if (!serv_tmp) {
                WDP_LOGE("Failed to allocate memory for service");
                return -1;
@@ -348,14 +306,16 @@ static int __ws_segment_to_service(char *segment, wfd_oem_new_service_s **servic
                        ptr +=2;
                        if (len) {
                                temp = (char*) calloc(1, len+2);
-                               temp[0] = '.';
-                               for (i=0; i<len; i++) {
-                                       temp[i+1] = (char) __ws_hex_to_num(ptr, 2);
-                                       ptr += 2;
+                               if (temp) {
+                                       temp[0] = '.';
+                                       for (i=0; i<len; i++) {
+                                               temp[i+1] = (char) __ws_hex_to_num(ptr, 2);
+                                               ptr += 2;
+                                       }
+                                       strncat(query, temp, len+1);
+                                       g_free(temp);
+                                       temp = NULL;
                                }
-                               strncat(query, temp, len+1);
-                               free(temp);
-                               temp = NULL;
                        }
                }
 
@@ -385,15 +345,17 @@ static int __ws_segment_to_service(char *segment, wfd_oem_new_service_s **servic
                        len = __ws_hex_to_num(ptr, 2);
                        ptr += 2;
                        if (len) {
-                               temp = (char*) calloc(1, len+2);
-                               temp[0] = '.';
-                               for (i=0; i<len; i++) {
-                                       temp[i+1] = (char) __ws_hex_to_num(ptr, 2);
-                                       ptr += 2;
+                               temp = (char*) g_try_malloc0(len+2);
+                               if (temp) {
+                                       temp[0] = '.';
+                                       for (i=0; i<len; i++) {
+                                               temp[i+1] = (char) __ws_hex_to_num(ptr, 2);
+                                               ptr += 2;
+                                       }
+                                       strncat(rdata, temp, len+1);
+                                       g_free(temp);
+                                       temp = NULL;
                                }
-                               strncat(rdata, temp, len+1);
-                               free(temp);
-                               temp = NULL;
                        }
                }
                serv_tmp->data.bonjour.rdata = strdup(rdata + 1);
@@ -416,7 +378,7 @@ static int __ws_segment_to_service(char *segment, wfd_oem_new_service_s **servic
        } else {
                WDP_LOGE("Not supported yet. Only bonjour and samsung vendor service supproted [%d]",
                                        serv_tmp->protocol);
-               free(serv_tmp);
+               g_free(serv_tmp);
                return -1;
        }
 
@@ -437,13 +399,13 @@ static void __ws_path_to_addr(char *peer_path,
 
        g_variant_get(parameter, "(o)", &path);
        g_strlcpy(peer_path, path, DBUS_OBJECT_PATH_MAX);
-       WDP_LOGE("Retrive Added path [%s]", peer_path);
+       WDP_LOGD("Retrive Added path [%s]", peer_path);
 
        loc = strrchr(peer_path,'/');
        __ws_mac_compact_to_normal(loc + 1, peer_dev);
 
        __ws_txt_to_mac(peer_dev, dev_addr);
-       WDP_LOGE("peer mac [" MACSTR "]", MAC2STR(dev_addr));
+       WDP_LOGD("peer mac [" MACSTR "]", MAC2STR(dev_addr));
 
        return;
        __WDP_LOG_FUNC_EXIT__;
@@ -523,45 +485,37 @@ static void _supplicant_signal_cb(GDBusConnection *connection,
 
        if (!g_strcmp0(signal,"InterfaceAdded")) {
                WDP_LOGD("InterfaceAdded");
+
+       } else if (!g_strcmp0(signal,"InterfaceRemoved")) {
+               WDP_LOGD("InterfaceRemoved");
                static char interface_path[DBUS_OBJECT_PATH_MAX] = {'\0',};
                const char *path = NULL;
-               GVariantIter *iter = NULL;
-               const char *ifname = NULL;
-
-               g_variant_get(parameters, "(oa{sv})", &path, &iter);
 
+               g_variant_get(parameters, "(o)", &path);
                g_strlcpy(interface_path, path, DBUS_OBJECT_PATH_MAX);
-               WDP_LOGD("Retrive Added path [%s]", interface_path);
 
-               if (iter != NULL) {
-                       gchar *key = NULL;
-                       GVariant *value = NULL;
+               WDP_LOGD("Retrive removed path [%s]", interface_path);
 
-                       while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
-                               CHECK_KEY_VALUE(key, value);
+               if (!g_strcmp0(g_pd->group_iface_path, interface_path)) {
 
-                               if (!g_strcmp0(key,"Ifname")) {
-                                       g_variant_get(value, "s", &ifname);
-                                       WDP_LOGD("Retrive added interface [%s]", ifname);
-                                       if(!g_strcmp0(ifname, GROUP_IFACE_NAME))
-                                               g_strlcpy(g_pd->group_iface_path, path, DBUS_OBJECT_PATH_MAX);
-                               }
-                       }
-                       g_variant_iter_free(iter);
+                       WDP_LOGD("p2p group interface removed");
+                       memset(g_pd->group_iface_path, 0x0, DBUS_OBJECT_PATH_MAX);
                }
+#if defined(TIZEN_WLAN_CONCURRENT_ENABLE) && defined(TIZEN_MOBILE)
+               else if (!g_strcmp0(g_pd->iface_path, interface_path)) {
 
-       } else if (!g_strcmp0(signal,"InterfaceRemoved")) {
-               WDP_LOGE("InterfaceRemoved");
-               static char interface_path[DBUS_OBJECT_PATH_MAX] = {'\0',};
-               const char *path = NULL;
+                       WDP_LOGD("p2p interface removed");
+                       wfd_oem_event_s event;
 
-               g_variant_get(parameters, "(o)", &path);
-               g_strlcpy(interface_path, path, DBUS_OBJECT_PATH_MAX);
+                       ws_deactivate(1);
 
-               WDP_LOGD("Retrive removed path [%s]", interface_path);
-               if (!g_strcmp0(g_pd->group_iface_path, interface_path))
-                       memset(g_pd->group_iface_path, 0x0, DBUS_OBJECT_PATH_MAX);
+                       memset(&event, 0x0, sizeof(wfd_oem_event_s));
+                       event.event_id = WFD_OEM_EVENT_DEACTIVATED;
+                       g_pd->callback(g_pd->user_data, &event);
 
+                       memset(g_pd->iface_path, 0x0, DBUS_OBJECT_PATH_MAX);
+               }
+#endif /* TIZEN_WLAN_CONCURRENT_ENABLE && TIZEN_MOBILE */
        } else if(!g_strcmp0(signal,"PropertiesChanged")){
                WDP_LOGD("PropertiesChanged");
        }
@@ -642,9 +596,17 @@ static void __ws_get_peer_property(const char *key, GVariant *value, void *user_
        } else if (g_strcmp0(key, "InterfacedAddress") == 0) {
 
                if (__ws_unpack_ay(peer->intf_addr, value, WS_MACADDR_LEN))
-                       WDP_LOGE("[" MACSTR "]", MAC2STR(peer->intf_addr));
+                       WDP_LOGD("[" MACSTR "]", MAC2STR(peer->intf_addr));
+
+       } else if (g_strcmp0(key, "GODeviceAddress") == 0) {
+
+               if (__ws_unpack_ay(peer->go_dev_addr, value, WS_MACADDR_LEN))
+                       WDP_LOGD("[" MACSTR "]", MAC2STR(peer->go_dev_addr));
 
-       }  else {
+               if(!ISZEROMACADDR(peer->go_dev_addr))
+                       peer->dev_role = WFD_OEM_DEV_ROLE_GC;
+
+       } else {
                WDP_LOGE("Unknown value");
        }
        __WDP_LOG_FUNC_EXIT__;
@@ -722,14 +684,24 @@ static void __ws_peer_property(const char *key, GVariant *value, void *user_data
        } else if (g_strcmp0(key, "DeviceAddress") == 0) {
 
                if (__ws_unpack_ay(peer->p2p_dev_addr, value, WS_MACADDR_LEN))
-                       WDP_LOGE("[" MACSTR "]", MAC2STR(peer->p2p_dev_addr));
+                       WDP_LOGD("[" MACSTR "]", MAC2STR(peer->p2p_dev_addr));
 
        } else if (g_strcmp0(key, "InterfacedAddress") == 0) {
 
                if (__ws_unpack_ay(peer->p2p_intf_addr, value, WS_MACADDR_LEN))
-                       WDP_LOGE("[" MACSTR "]", MAC2STR(peer->p2p_intf_addr));
+                       WDP_LOGD("[" MACSTR "]", MAC2STR(peer->p2p_intf_addr));
+
+       } else if (g_strcmp0(key, "GODeviceAddress") == 0) {
 
-       }  else {
+               unsigned char go_dev_addr[OEM_MACADDR_LEN];
+               if (__ws_unpack_ay(go_dev_addr, value, WS_MACADDR_LEN))
+                       WDP_LOGD("[" MACSTR "]", MAC2STR(go_dev_addr));
+               WDP_LOGD("[" MACSTR "]", MAC2STR(go_dev_addr));
+
+               if(!ISZEROMACADDR(go_dev_addr))
+                       peer->dev_role = WFD_OEM_DEV_ROLE_GC;
+
+       } else {
                WDP_LOGE("Unknown value");
        }
        __WDP_LOG_FUNC_EXIT__;
@@ -749,7 +721,7 @@ void __ws_interface_property(const char *key, GVariant *value, void *user_data)
 
                g_variant_get(value, "s", &ifname);
                g_strlcpy(event->ifname, ifname, OEM_IFACE_NAME_LEN+1);
-               WDP_LOGE("Ifname [%s]", event->ifname);
+               WDP_LOGD("Ifname [%s]", event->ifname);
 
        }
 
@@ -803,7 +775,7 @@ void __ws_group_property(const char *key, GVariant *value, void *user_data)
        } else if (g_strcmp0(key, "BSSID") == 0) {
 
                if (__ws_unpack_ay(group->go_dev_addr, value, WS_MACADDR_LEN))
-                       WDP_LOGE("[" MACSTR "]", MAC2STR(group->go_dev_addr));
+                       WDP_LOGD("[" MACSTR "]", MAC2STR(group->go_dev_addr));
 
        } else {
                WDP_LOGE("Unknown value");
@@ -811,6 +783,42 @@ void __ws_group_property(const char *key, GVariant *value, void *user_data)
        __WDP_LOG_FUNC_EXIT__;
 }
 
+void __ws_extract_invitation_details(const char *key, GVariant *value, void *user_data)
+{
+       __WDP_LOG_FUNC_ENTER__;
+       wfd_oem_event_s *event = (wfd_oem_event_s *)user_data;
+       if(!event || !event->edata)
+               return;
+
+       wfd_oem_invite_data_s *invitation = (wfd_oem_invite_data_s *)event->edata;
+
+       CHECK_KEY_VALUE(key, value);
+
+       if (g_strcmp0(key, "sa") == 0) {
+               if (__ws_unpack_ay(invitation->sa, value, WS_MACADDR_LEN))
+                       WDP_LOGD("[" MACSTR "]", MAC2STR(invitation->sa));
+
+       } else if (g_strcmp0(key, "go_dev_add") == 0) {
+               if (__ws_unpack_ay(invitation->go_dev_addr, value, WS_MACADDR_LEN))
+                                       WDP_LOGD("[" MACSTR "]", MAC2STR(invitation->go_dev_addr));
+
+       } else if (g_strcmp0(key, "bssid") == 0) {
+               if (__ws_unpack_ay(invitation->bssid, value, WS_MACADDR_LEN))
+                                       WDP_LOGD("[" MACSTR "]", MAC2STR(invitation->bssid));
+
+       } else if (g_strcmp0(key, "persistent_id") == 0) {
+               g_variant_get(value, "i", &(invitation->persistent_id));
+               WDP_LOGD("persistent id [%d]", invitation->persistent_id);
+
+       } else if (g_strcmp0(key, "oper_freq") == 0) {
+               g_variant_get(value, "i", &(invitation->oper_freq));
+               WDP_LOGD("oper freq [%d]", invitation->oper_freq);
+       } else {
+               WDP_LOGE("Unknown value");
+       }
+       __WDP_LOG_FUNC_EXIT__;
+}
+
 void __ws_extract_group_details(const char *key, GVariant *value, void *user_data)
 {
 
@@ -819,6 +827,8 @@ void __ws_extract_group_details(const char *key, GVariant *value, void *user_dat
        if(!event || !event->edata)
                return;
 
+       wfd_oem_group_data_s *group = (wfd_oem_group_data_s *)event->edata;
+
        CHECK_KEY_VALUE(key, value);
 
        if (g_strcmp0(key, "interface_object") == 0) {
@@ -843,6 +853,21 @@ void __ws_extract_group_details(const char *key, GVariant *value, void *user_dat
                else if (!strncmp(role, "client", 6))
                        event->dev_role = WFD_OEM_DEV_ROLE_GC;
 
+       } else if (g_strcmp0(key, "IpAddr") == 0) {
+
+               if (__ws_unpack_ay(group->ip_addr, value, OEM_IPADDR_LEN))
+                       WDP_LOGD("[" IPSTR "]", IP2STR(group->ip_addr));
+
+       } else if (g_strcmp0(key, "IpAddrMask") == 0) {
+
+               if (__ws_unpack_ay(group->ip_addr_mask, value, OEM_IPADDR_LEN))
+                       WDP_LOGD("[" IPSTR "]", IP2STR(group->ip_addr_mask));
+
+       } else if (g_strcmp0(key, "IpAddrGo") == 0) {
+
+               if (__ws_unpack_ay(group->ip_addr_go, value, OEM_IPADDR_LEN))
+                       WDP_LOGD("[" IPSTR "]", IP2STR(group->ip_addr_go));
+
        } else if (g_strcmp0(key, "group_object") == 0) {
                static char group_path[DBUS_OBJECT_PATH_MAX] = {'\0',};
                const char *g_path;
@@ -901,10 +926,11 @@ void __ws_extract_gonegsuccess_details(const char *key, GVariant *value, void *u
 {
        __WDP_LOG_FUNC_ENTER__;
        wfd_oem_event_s *event = (wfd_oem_event_s *)user_data;
-       wfd_oem_conn_data_s *edata = (wfd_oem_conn_data_s *)event->edata;
-       if(!event || !edata)
+       if(!event || !event->edata)
                return;
 
+       wfd_oem_conn_data_s *edata = (wfd_oem_conn_data_s *)event->edata;
+
        CHECK_KEY_VALUE(key, value);
 
        if (g_strcmp0(key, "peer_object") == 0) {
@@ -955,6 +981,7 @@ void __ws_extract_gonegsuccess_details(const char *key, GVariant *value, void *u
        __WDP_LOG_FUNC_EXIT__;
 }
 
+#ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
 void __ws_extract_peer_service(wfd_oem_event_s *data, unsigned char *service_hex, int tlvs_len)
 {
        GList *services = NULL;
@@ -1025,6 +1052,7 @@ void __ws_extract_servicediscoveryresponse_details(const char *key, GVariant *va
 
        __WDP_LOG_FUNC_EXIT__;
 }
+#endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
 
 static void _ws_process_device_found(GDBusConnection *connection,
                const gchar *object_path, GVariant *parameters)
@@ -1180,7 +1208,7 @@ static void _ws_process_prov_disc_resp_display_pin(GDBusConnection *connection,
        WDP_LOGD("peer mac [" MACSTR "]", MAC2STR(event.dev_addr));
 
        g_strlcpy(event.wps_pin, pin, WS_PINSTR_LEN + 1);
-       WDP_LOGE("Retrive pin [%s]", event.wps_pin);
+       WDP_LOGD("Retrive pin [%s]", event.wps_pin);
 
        dbus_property_get_all(peer_path, g_pd->g_dbus, SUPPLICANT_P2P_PEER,
                        __ws_peer_property, event.edata);
@@ -1488,7 +1516,6 @@ static void _ws_process_go_neg_request(GDBusConnection *connection,
                __WDP_LOG_FUNC_EXIT__;
                return;
        }
-
        memset(&event, 0x0, sizeof(wfd_oem_event_s));
 
        event.edata = (void*) edata;
@@ -1527,6 +1554,44 @@ static void _ws_process_go_neg_request(GDBusConnection *connection,
 
        __WDP_LOG_FUNC_EXIT__;
 }
+static void _ws_process_invitation_received(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters)
+{
+       __WDP_LOG_FUNC_ENTER__;
+       GVariantIter *iter = NULL;
+       wfd_oem_event_s event;
+       wfd_oem_invite_data_s *edata = NULL;
+
+       edata = (wfd_oem_invite_data_s *) g_try_malloc0(sizeof(wfd_oem_invite_data_s));
+       if (!edata) {
+               WDP_LOGF("Failed to allocate memory for event. [%s]",
+                               strerror(errno));
+               __WDP_LOG_FUNC_EXIT__;
+               return;
+       }
+       memset(&event, 0x0, sizeof(wfd_oem_event_s));
+
+       event.edata = (void*) edata;
+       event.edata_type = WFD_OEM_EDATA_TYPE_INVITE;
+       event.event_id = WFD_OEM_EVENT_INVITATION_REQ;
+
+       if (parameters != NULL) {
+               g_variant_get(parameters, "(a{sv})", &iter);
+
+               if (iter != NULL) {
+                       dbus_property_foreach(iter, __ws_extract_invitation_details, &event);
+                       g_variant_iter_free(iter);
+               }
+       } else {
+               WDP_LOGE("No properties");
+       }
+       memcpy(&(event.dev_addr), edata->sa, OEM_MACADDR_LEN);
+
+       g_pd->callback(g_pd->user_data, &event);
+       g_free(event.edata);
+
+       __WDP_LOG_FUNC_EXIT__;
+}
 
 static void _ws_process_invitation_result(GDBusConnection *connection,
                const gchar *object_path, GVariant *parameters)
@@ -1559,6 +1624,7 @@ static void _ws_process_group_finished(GDBusConnection *connection,
        __WDP_LOG_FUNC_EXIT__;
 }
 
+#ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
 static void _ws_process_service_discovery_response(GDBusConnection *connection,
                const gchar *object_path, GVariant *parameters)
 {
@@ -1588,6 +1654,7 @@ static void _ws_process_service_discovery_response(GDBusConnection *connection,
 
        __WDP_LOG_FUNC_EXIT__;
 }
+#endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
 
 static void _ws_process_persistent_group_added(GDBusConnection *connection,
                const gchar *object_path, GVariant *parameters)
@@ -1624,6 +1691,7 @@ static void _ws_process_wps_failed(GDBusConnection *connection,
        memset(&event, 0x0, sizeof(wfd_oem_event_s));
 
        event.event_id = WFD_OEM_EVENT_WPS_FAIL;
+       event.edata_type = WFD_OEM_EDATA_TYPE_NONE;
 
        g_variant_get(parameters, "(sa{sv})", &name, &iter);
 
@@ -1645,6 +1713,22 @@ static void _ws_process_wps_failed(GDBusConnection *connection,
        __WDP_LOG_FUNC_EXIT__;
 }
 
+static void _ws_process_group_formation_failure(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters)
+{
+       __WDP_LOG_FUNC_ENTER__;
+       wfd_oem_event_s event;
+
+       memset(&event, 0x0, sizeof(wfd_oem_event_s));
+
+       event.event_id = WFD_OEM_EVENT_WPS_FAIL;
+       event.edata_type = WFD_OEM_EDATA_TYPE_NONE;
+
+       g_pd->callback(g_pd->user_data, &event);
+
+       __WDP_LOG_FUNC_EXIT__;
+}
+
 static struct {
        const char *interface;
        const char *member;
@@ -1652,106 +1736,118 @@ static struct {
                        GVariant *parameters);
 } ws_p2pdevice_signal_map[] = {
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
                "DeviceFound",
                _ws_process_device_found
        },
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
                "DeviceLost",
                _ws_process_device_lost
        },
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
                "FindStopped",
                _ws_process_find_stoppped
        },
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
                "ProvisionDiscoveryRequestDisplayPin",
                _ws_process_prov_disc_req_display_pin
        },
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
                "ProvisionDiscoveryResponseDisplayPin",
                _ws_process_prov_disc_resp_display_pin
        },
        {
-                       SUPPLICNAT_P2PDEVICE,
+                       SUPPLICANT_P2PDEVICE,
                "ProvisionDiscoveryRequestEnterPin",
                _ws_process_prov_disc_req_enter_pin
        },
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
                "ProvisionDiscoveryResponseEnterPin",
                _ws_process_prov_disc_resp_enter_pin
        },
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
                "ProvisionDiscoveryPBCRequest",
                _ws_process_prov_disc_pbc_req
        },
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
                "ProvisionDiscoveryPBCResponse",
                _ws_process_prov_disc_pbc_resp
        },
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
                "ProvisionDiscoveryFailure",
                _ws_process_prov_disc_failure
        },
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
                "GroupStarted",
                _ws_process_group_started
        },
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
                "GONegotiationSuccess",
                _ws_process_go_neg_success
        },
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
                "GONegotiationFailure",
                _ws_process_go_neg_failure
        },
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
                "GONegotiationRequest",
                _ws_process_go_neg_request
        },
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
+               "InvitationReceived",
+               _ws_process_invitation_received
+       },
+       {
+               SUPPLICANT_P2PDEVICE,
                "InvitationResult",
                _ws_process_invitation_result
        },
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
                "GroupFinished",
                _ws_process_group_finished
        },
+#ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
                "ServiceDiscoveryResponse",
                _ws_process_service_discovery_response
        },
+#endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
                "PersistentGroupAdded",
                _ws_process_persistent_group_added
        },
        {
-               SUPPLICNAT_P2PDEVICE,
+               SUPPLICANT_P2PDEVICE,
                "PersistentGroupRemoved",
                _ws_process_persistent_group_removed
        },
        {
-               SUPPLICNAT_P2PDEVICE,
-               "WpsFailed ",
+               SUPPLICANT_P2PDEVICE,
+               "WpsFailed",
                _ws_process_wps_failed
        },
        {
+               SUPPLICANT_P2PDEVICE,
+               "GroupFormationFailure",
+               _ws_process_group_formation_failure
+       },
+       {
                NULL,
                NULL,
                NULL
@@ -1773,6 +1869,37 @@ static void _p2pdevice_signal_cb(GDBusConnection *connection,
 }
 
 
+static void __ws_parse_peer_joined(char *peer_path,
+               unsigned char *dev_addr, unsigned char *ip_addr, GVariant *parameter)
+{
+       __WDP_LOG_FUNC_ENTER__;
+
+       GVariantIter *iter;
+       static unsigned char peer_dev[WS_MACSTR_LEN] = {'\0',};
+       const char *path = NULL;
+       char *loc = NULL;
+       int i = 0;
+
+       g_variant_get(parameter, "(oay)", &path, &iter);
+       g_strlcpy(peer_path, path, DBUS_OBJECT_PATH_MAX);
+       WDP_LOGD("Retrive Added path [%s]", peer_path);
+
+       loc = strrchr(peer_path,'/');
+       __ws_mac_compact_to_normal(loc + 1, peer_dev);
+
+       __ws_txt_to_mac(peer_dev, dev_addr);
+       WDP_LOGD("peer mac [" MACSTR "]", MAC2STR(dev_addr));
+
+       for(i = 0; i < OEM_IPADDR_LEN; i++)
+               g_variant_iter_loop (iter, "y", &ip_addr[i]);
+
+       WDP_LOGD("peer ip [" IPSTR "]", IP2STR(ip_addr));
+
+       return;
+       __WDP_LOG_FUNC_EXIT__;
+}
+
+
 static void _group_signal_cb(GDBusConnection *connection,
                const gchar *sender, const gchar *object_path, const gchar *interface,
                const gchar *signal, GVariant *parameters, gpointer user_data)
@@ -1799,7 +1926,7 @@ static void _group_signal_cb(GDBusConnection *connection,
                        event.edata_type = WFD_OEM_EDATA_TYPE_DEVICE;
                        event.event_id = WFD_OEM_EVENT_STA_CONNECTED;
 
-                       __ws_path_to_addr(peer_path, event.dev_addr, parameters);
+                       __ws_parse_peer_joined(peer_path, event.dev_addr, event.ip_addr_peer, parameters);
 
                        dbus_property_get_all(peer_path, g_pd->g_dbus, SUPPLICANT_P2P_PEER,
                                                __ws_peer_property, event.edata);
@@ -1843,7 +1970,7 @@ static void __register_p2pdevice_signal(GVariant *value, void *user_data)
        pd_data->p2pdevice_sub_id = g_dbus_connection_signal_subscribe(
                pd_data->g_dbus,
                SUPPLICANT_SERVICE, /* bus name */
-               SUPPLICNAT_P2PDEVICE, /* interface */
+               SUPPLICANT_P2PDEVICE, /* interface */
                NULL, /* member */
                NULL, /* object path */
                NULL, /* arg0 */
@@ -1873,11 +2000,9 @@ static int _ws_create_interface(const char *iface_name)
 
        builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
        g_variant_builder_add(builder, "{sv}", "Ifname", g_variant_new_string(iface_name));
-       g_variant_builder_add(builder, "{sv}", "Driver", g_variant_new_string("nl80211"));
        g_variant_builder_add(builder, "{sv}", "ConfigFile", g_variant_new_string(CONF_FILE_PATH));
        params.params = g_variant_new("(a{sv})", builder);
        g_variant_builder_unref(builder);
-
        res = dbus_method_call(&params, SUPPLICANT_INTERFACE, __register_p2pdevice_signal, NULL);
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -1988,7 +2113,6 @@ static int _ws_init_dbus_connection(void)
                G_DBUS_SIGNAL_FLAGS_NONE,
                _supplicant_signal_cb,
                NULL, NULL);
-
        if(_ws_get_interface(COMMON_IFACE_NAME) < 0)
                res = _ws_create_interface(COMMON_IFACE_NAME);
 
@@ -2014,6 +2138,11 @@ static int _ws_deinit_dbus_connection(void)
                g_dbus_connection_signal_unsubscribe(g_dbus, g_pd->p2pdevice_sub_id);
                g_dbus_connection_signal_unsubscribe(g_dbus, g_pd->group_sub_id);
        }
+       g_pd->group_iface_sub_id = 0;
+       g_pd->p2pdevice_sub_id = 0;
+       g_pd->group_sub_id = 0;
+       memset(g_pd->group_iface_path, 0x0, DBUS_OBJECT_PATH_MAX);
+       memset(g_pd->iface_path, 0x0, DBUS_OBJECT_PATH_MAX);
 
        g_object_unref(g_dbus);
        return 0;
@@ -2047,6 +2176,7 @@ static int _ws_reset_plugin(ws_dbus_plugin_data_s *g_pd)
                ws_deactivate(g_pd->concurrent);
 
        g_free(g_pd);
+       g_pd = NULL;
 
        __WDP_LOG_FUNC_EXIT__;
        return 0;
@@ -2125,7 +2255,49 @@ int ws_deinit()
        __WDP_LOG_FUNC_EXIT__;
        return 0;
 }
-#if 0
+
+gboolean _ws_util_execute_file(const char *file_path,
+       char *const args[], char *const envs[])
+{
+       pid_t pid = 0;
+       int rv = 0;
+       errno = 0;
+       register unsigned int index = 0;
+
+       while (args[index] != NULL) {
+               WDP_LOGD("[%s]", args[index]);
+               index++;
+       }
+
+       if (!(pid = fork())) {
+               WDP_LOGD("pid(%d), ppid(%d)", getpid(), getppid());
+               WDP_LOGD("Inside child, exec (%s) command", file_path);
+
+               errno = 0;
+               if (execve(file_path, args, envs) == -1) {
+                       WDP_LOGE("Fail to execute command (%s)", strerror(errno));
+                       exit(1);
+               }
+       } else if (pid > 0) {
+               if (waitpid(pid, &rv, 0) == -1)
+                       WDP_LOGD("wait pid (%u) rv (%d)", pid, rv);
+               if (WIFEXITED(rv)) {
+                       WDP_LOGD("exited, rv=%d", WEXITSTATUS(rv));
+               } else if (WIFSIGNALED(rv)) {
+                       WDP_LOGD("killed by signal %d", WTERMSIG(rv));
+               } else if (WIFSTOPPED(rv)) {
+                       WDP_LOGD("stopped by signal %d", WSTOPSIG(rv));
+               } else if (WIFCONTINUED(rv)) {
+                       WDP_LOGD("continued");
+               }
+
+               return TRUE;
+       }
+
+       WDP_LOGE("failed to fork (%s)", strerror(errno));
+       return FALSE;
+}
+
 static int __ws_p2p_firmware_start(void)
 {
        GError *error = NULL;
@@ -2234,6 +2406,7 @@ static int __ws_p2p_firmware_stop(void)
        return 0;
 }
 
+
 static int __ws_p2p_supplicant_start(void)
 {
        gboolean rv = FALSE;
@@ -2251,43 +2424,7 @@ static int __ws_p2p_supplicant_start(void)
        WDP_LOGI("Successfully started p2p_supp.sh");
        return 0;
 }
-#endif
-
-static int __ws_if_up(void)
-{
-       gboolean rv = FALSE;
-       const char *path = "/usr/sbin/ifconfig";
-       char *const args[] = { "/usr/sbin/ifconfig", COMMON_IFACE_NAME, "up", NULL };
-       char *const envs[] = { NULL };
-
-       rv = _ws_util_execute_file(path, args, envs);
-
-       if (rv != TRUE) {
-               WDP_LOGE("Failed to start if down");
-               return -1;
-       }
-
-       WDP_LOGI("Successfully if up");
-       return 0;
-}
 
-static int __ws_if_down(void)
-{
-       gboolean rv = FALSE;
-       const char *path = "/usr/sbin/ifconfig";
-       char *const args[] = { "/usr/sbin/ifconfig", COMMON_IFACE_NAME, "down", NULL };
-       char *const envs[] = { NULL };
-
-       rv = _ws_util_execute_file(path, args, envs);
-
-       if (rv != TRUE) {
-               WDP_LOGE("Failed to start if down");
-               return -1;
-       }
-
-       WDP_LOGI("Successfully if down");
-       return 0;
-}
 
 static int __ws_p2p_supplicant_stop(void)
 {
@@ -2306,7 +2443,6 @@ static int __ws_p2p_supplicant_stop(void)
        WDP_LOGI("Successfully stopped p2p_supp.sh");
        return 0;
 }
-
 #if 0
 static int __ws_p2p_on(void)
 {
@@ -2403,15 +2539,176 @@ static int __ws_p2p_off(void)
 }
 #endif
 
+int __ws_init_p2pdevice()
+{
+       __WDP_LOG_FUNC_ENTER__;
+       GDBusConnection *g_dbus = NULL;
+
+       GVariant *value = NULL;
+       GVariant *param = NULL;
+       GVariantBuilder *builder = NULL;
+       GVariantBuilder *type_builder = NULL;
+       dbus_method_param_s params;
+
+       const char *primary_device_type = PRIMARY_DEVICE_TYPE;
+       const char *ip_addr_go = DEFAULT_IP_GO;
+       const char *ip_addr_mask = DEFAULT_IP_MASK;
+       const char *ip_addr_start = DEFAULT_IP_START;
+       const char *ip_addr_end = DEFAULT_IP_END;
+       int i = 0;
+       int res = 0;
+
+       for(i = 0; i < WS_DEVTYPE_LEN; i++)
+               WDP_LOGD("device type[%02x]", primary_device_type[i]);
+
+       g_dbus = g_pd->g_dbus;
+       if (!g_dbus) {
+               WDP_LOGE("DBus connection is NULL");
+               return -1;
+       }
+       memset(&params, 0x0, sizeof(dbus_method_param_s));
+
+       dbus_set_method_param(&params, DBUS_PROPERTIES_METHOD_SET, g_pd->iface_path,
+                        g_dbus);
+
+       builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
+       g_variant_builder_add (builder, "{sv}", "DeviceName",
+                                       g_variant_new_string(DEFAULT_DEVICE_NAME));
+
+       g_variant_builder_add (builder, "{sv}", "GOIntent",
+                                       g_variant_new_uint32(DEFAULT_GO_INTENT));
+
+       g_variant_builder_add (builder, "{sv}", "PersistentReconnect",
+                                       g_variant_new_boolean(DEFAULT_PERSISTENT_RECONNECT));
+
+       g_variant_builder_add (builder, "{sv}", "ListenRegClass",
+                                       g_variant_new_uint32(DEFAULT_LISTEN_REG_CLASS));
+
+       g_variant_builder_add (builder, "{sv}", "ListenChannel",
+                                       g_variant_new_uint32(DEFAULT_LISTEN_CHANNEL));
+
+       g_variant_builder_add (builder, "{sv}", "OperRegClass",
+                                       g_variant_new_uint32(DEFAULT_OPER_REG_CLASS));
+
+       g_variant_builder_add (builder, "{sv}", "OperChannel",
+                                       g_variant_new_uint32(DEFAULT_OPER_CHANNEL));
+
+       g_variant_builder_add (builder, "{sv}", "SsidPostfix",
+                                       g_variant_new_string(DEFAULT_DEVICE_NAME));
+
+       g_variant_builder_add (builder, "{sv}", "NoGroupIface",
+                                       g_variant_new_boolean(DEFAULT_NO_GROUP_IFACE));
+
+       type_builder = g_variant_builder_new (G_VARIANT_TYPE ("ay"));
+       for(i = 0; i < WS_DEVTYPE_LEN; i++)
+               g_variant_builder_add(type_builder, "y", primary_device_type[i]);
+       g_variant_builder_add (builder, "{sv}", "PrimaryDeviceType",
+                       g_variant_new ("ay", type_builder));
+       g_variant_builder_unref (type_builder);
+
+       type_builder = g_variant_builder_new (G_VARIANT_TYPE ("ay"));
+       for(i = 0; i < OEM_IPADDR_LEN; i++)
+               g_variant_builder_add(type_builder, "y", ip_addr_go[i]);
+       g_variant_builder_add (builder, "{sv}", "IpAddrGO",
+                       g_variant_new ("ay", type_builder));
+       g_variant_builder_unref (type_builder);
+
+       type_builder = g_variant_builder_new (G_VARIANT_TYPE ("ay"));
+       for(i = 0; i < OEM_IPADDR_LEN; i++)
+               g_variant_builder_add(type_builder, "y", ip_addr_mask[i]);
+       g_variant_builder_add (builder, "{sv}", "IpAddrMask",
+                       g_variant_new ("ay", type_builder));
+       g_variant_builder_unref (type_builder);
+
+       type_builder = g_variant_builder_new (G_VARIANT_TYPE ("ay"));
+       for(i = 0; i < OEM_IPADDR_LEN; i++)
+               g_variant_builder_add(type_builder, "y", ip_addr_start[i]);
+       g_variant_builder_add (builder, "{sv}", "IpAddrStart",
+                       g_variant_new ("ay", type_builder));
+       g_variant_builder_unref (type_builder);
+
+       type_builder = g_variant_builder_new (G_VARIANT_TYPE ("ay"));
+       for(i = 0; i < OEM_IPADDR_LEN; i++)
+               g_variant_builder_add(type_builder, "y", ip_addr_end[i]);
+       g_variant_builder_add (builder, "{sv}", "IpAddrEnd",
+                       g_variant_new ("ay", type_builder));
+       g_variant_builder_unref (type_builder);
+
+       value = g_variant_new ("a{sv}", builder);
+       g_variant_builder_unref (builder);
+
+       param = g_variant_new("(ssv)", SUPPLICANT_P2PDEVICE, "P2PDeviceConfig", value);
+       WDP_LOGD("init param [%s]", g_variant_print(param,TRUE));
+
+       params.params = param;
+
+       res = dbus_method_call(&params, DBUS_PROPERTIES_INTERFACE, NULL, NULL);
+       g_variant_unref(value);
+       g_variant_unref(param);
+       if (res < 0)
+               WDP_LOGE("Failed to send command to wpa_supplicant");
+       else
+               WDP_LOGE("Succeeded to initialize p2pdevice");
+       __WDP_LOG_FUNC_EXIT__;
+       return res;
+}
+
+int __ws_set_config_methods()
+{
+       __WDP_LOG_FUNC_ENTER__;
+       GDBusConnection *g_dbus = NULL;
+
+       GVariant *value = NULL;
+       GVariant *param = NULL;
+
+       dbus_method_param_s params;
+       int res = 0;
+
+       g_dbus = g_pd->g_dbus;
+       if (!g_dbus) {
+               WDP_LOGE("DBus connection is NULL");
+               return -1;
+       }
+       memset(&params, 0x0, sizeof(dbus_method_param_s));
+
+       dbus_set_method_param(&params, DBUS_PROPERTIES_METHOD_SET, g_pd->iface_path,
+                        g_dbus);
+
+       value = g_variant_new_string(DEFAULT_CONFIG_METHOD);
+
+       param = g_variant_new("(ssv)", SUPPLICANT_WPS, "ConfigMethods", value);
+       params.params = param;
+
+       res = dbus_method_call(&params, DBUS_PROPERTIES_INTERFACE, NULL, NULL);
+       g_variant_unref(value);
+       g_variant_unref(param);
+       if (res < 0)
+               WDP_LOGE("Failed to send command to wpa_supplicant");
+       else
+               WDP_LOGD("Succeeded to set config method(%s)", DEFAULT_CONFIG_METHOD);
+
+       __WDP_LOG_FUNC_EXIT__;
+       return res;
+}
+
 int ws_activate(int concurrent)
 {
        __WDP_LOG_FUNC_ENTER__;
        int res = 0;
        int retry_count = 0;
 
+       res = __ws_p2p_supplicant_start();
+       if (res < 0) {
+               res = __ws_p2p_supplicant_stop();
+               WDP_LOGI("P2P supplicant stopped with error %d", res);
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
        while (retry_count < WS_CONN_RETRY_COUNT) {
                /* load wlan driver */
-               res = __ws_if_up();
+               if(concurrent == 0)
+                       res = __ws_p2p_firmware_start();
                if (res < 0) {
                        WDP_LOGE("Failed to load driver [ret=%d]", res);
                        return -1;
@@ -2420,6 +2717,7 @@ int ws_activate(int concurrent)
 
                if (__ws_check_net_interface(COMMON_IFACE_NAME) < 0) {
                        usleep(150000); // wait for 150ms
+                       concurrent = 0;
                        retry_count++;
                        WDP_LOGE("interface is not up: retry, %d", retry_count);
                } else {
@@ -2444,13 +2742,15 @@ int ws_activate(int concurrent)
        if (res < 0) {
                res = __ws_p2p_supplicant_stop();
                WDP_LOGI("[/usr/sbin/p2p_supp.sh stop] returns %d", res);
-               res = __ws_if_down();
+               res = __ws_p2p_firmware_stop();
                WDP_LOGI("P2P firmware stopped with error %d", res);
                __WDP_LOG_FUNC_EXIT__;
                return -1;
        }
 
        g_pd->activated = TRUE;
+       __ws_init_p2pdevice();
+       __ws_set_config_methods();
 
        __WDP_LOG_FUNC_EXIT__;
        return 0;
@@ -2472,11 +2772,13 @@ int ws_deactivate(int concurrent)
 
        _ws_deinit_dbus_connection();
 
-       res = __ws_p2p_supplicant_stop();
-       WDP_LOGI("[/usr/sbin/p2p_supp.sh stop] returns %d", res);
+       if(concurrent == 0) {
+               res = __ws_p2p_supplicant_stop();
+               WDP_LOGI("[/usr/sbin/p2p_supp.sh stop] returns %d", res);
 
-       res = __ws_if_down();
-       WDP_LOGI("P2P firmware stopped with error %d", res);
+               res = __ws_p2p_firmware_stop();
+               WDP_LOGI("P2P firmware stopped with error %d", res);
+       }
        g_pd->activated = FALSE;
 
        __WDP_LOG_FUNC_EXIT__;
@@ -2500,7 +2802,7 @@ static int _ws_flush()
        dbus_set_method_param(&params, "Flush", g_pd->iface_path, g_dbus);
        params.params = NULL;
 
-       res = dbus_method_call(&params, SUPPLICNAT_P2PDEVICE, NULL, NULL);
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
        else
@@ -2527,7 +2829,7 @@ static int _ws_cancel()
        dbus_set_method_param(&params, "Cancel", g_pd->iface_path , g_dbus);
        params.params = NULL;
 
-       res = dbus_method_call(&params, SUPPLICNAT_P2PDEVICE, NULL, NULL);
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
        else
@@ -2593,7 +2895,7 @@ int ws_start_scan(wfd_oem_scan_param_s *param)
        params.params = value;
 
        WDP_LOGD("params [%s]", g_variant_print(value, TRUE));
-       res = dbus_method_call(&params, SUPPLICNAT_P2PDEVICE, NULL, NULL);
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
        g_variant_unref(value);
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -2632,7 +2934,7 @@ int ws_restart_scan(int freq)
        params.params = value;
 
        WDP_LOGD("params [%s]", g_variant_print(value, TRUE));
-       res = dbus_method_call(&params, SUPPLICNAT_P2PDEVICE, NULL, NULL);
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
        g_variant_unref(value);
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -2660,7 +2962,7 @@ int ws_stop_scan()
        dbus_set_method_param(&params, "StopFind", g_pd->iface_path, g_dbus);
        params.params = NULL;
 
-       res = dbus_method_call(&params, SUPPLICNAT_P2PDEVICE, NULL, NULL);
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
        if (res < 0)
                        WDP_LOGE("Failed to send command to wpa_supplicant");
        else
@@ -2772,7 +3074,7 @@ int ws_prov_disc_req(unsigned char *peer_addr, wfd_oem_wps_mode_e wps_mode, int
 
        params.params = value;
 
-       res = dbus_method_call(&params, SUPPLICNAT_P2PDEVICE, NULL, NULL);
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
        g_variant_unref(value);
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -2834,7 +3136,7 @@ int ws_connect(unsigned char *peer_addr, wfd_oem_conn_param_s *param)
 
        params.params = value;
 
-       res = dbus_method_call(&params, SUPPLICNAT_P2PDEVICE, NULL, NULL);
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
        g_variant_unref(value);
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -2876,7 +3178,7 @@ int ws_disconnect(unsigned char *peer_addr)
 
        params.params = value;
 
-       res = dbus_method_call(&params, SUPPLICNAT_P2PDEVICE, NULL, NULL);
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
        g_variant_unref(value);
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -2918,7 +3220,7 @@ int ws_reject_connection(unsigned char *peer_addr)
 
        params.params = value;
 
-       res = dbus_method_call(&params, SUPPLICNAT_P2PDEVICE, NULL, NULL);
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
        g_variant_unref(value);
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -2971,6 +3273,20 @@ int ws_get_supported_wps_mode()
        return 0;
 }
 
+static void __store_group_iface_path(GVariant *value, void *user_data) {
+       __WDP_LOG_FUNC_ENTER__;
+       ws_dbus_plugin_data_s * pd_data;
+       const char *path = NULL;
+
+       pd_data = (ws_dbus_plugin_data_s *) g_pd;
+
+       g_variant_get(value, "(o)", &path);
+       g_strlcpy(pd_data->group_iface_path, path, DBUS_OBJECT_PATH_MAX);
+
+       WDP_LOGD("group object path [%s]", pd_data->group_iface_path);
+       /* subscribe interface p2p signal */
+}
+
 int ws_create_group(int persistent, int freq, const char *passphrase)
 {
        __WDP_LOG_FUNC_ENTER__;
@@ -2992,12 +3308,19 @@ int ws_create_group(int persistent, int freq, const char *passphrase)
        builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}") );
 
        if (persistent)
-               g_variant_builder_add (builder, "{sv}", "persistent", g_variant_new_boolean(TRUE));
-
-       if(freq)
-               g_variant_builder_add (builder, "{sv}", "frequency", g_variant_new_int32(freq));
+               g_variant_builder_add(builder, "{sv}", "persistent",
+                               g_variant_new_boolean(TRUE));
        else
-               g_variant_builder_add (builder, "{sv}", "frequency", g_variant_new_int32(2));
+               g_variant_builder_add(builder, "{sv}", "persistent",
+                               g_variant_new_boolean(FALSE));
+
+       if (passphrase && strlen(passphrase) > 0)
+               g_variant_builder_add(builder, "{sv}", "passphrase",
+                               g_variant_new_string(passphrase));
+
+       if (freq)
+               g_variant_builder_add(builder, "{sv}", "frequency",
+                               g_variant_new_int32(freq));
 
        value = g_variant_new ("(a{sv})", builder);
        g_variant_builder_unref (builder);
@@ -3006,7 +3329,8 @@ int ws_create_group(int persistent, int freq, const char *passphrase)
 
        params.params = value;
 
-       res = dbus_method_call(&params, SUPPLICNAT_P2PDEVICE, NULL, NULL);
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE,
+                       __store_group_iface_path, g_pd);
        g_variant_unref(value);
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -3033,12 +3357,18 @@ int ws_destroy_group(const char *ifname)
                WDP_LOGE("DBus connection is NULL");
                return -1;
        }
+
+       if (g_pd->group_iface_path[0] == 0) {
+               WDP_LOGE("group iface path is NULL");
+               return -1;
+       }
+
        memset(&params, 0x0, sizeof(dbus_method_param_s));
 
        dbus_set_method_param(&params, "Disconnect", g_pd->group_iface_path, g_dbus);
        params.params = NULL;
 
-       res = dbus_method_call(&params, SUPPLICNAT_P2PDEVICE, NULL, NULL);
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
        if (res < 0) {
                        WDP_LOGE("Failed to send command to wpa_supplicant");
                        __WDP_LOG_FUNC_EXIT__;
@@ -3088,7 +3418,7 @@ int ws_invite(unsigned char *peer_addr, wfd_oem_invite_param_s *param)
 
                params.params = value;
 
-               res = dbus_method_call(&params, SUPPLICNAT_P2PDEVICE, NULL, NULL);
+               res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
                g_variant_unref(value);
                if (res < 0)
                        WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -3149,7 +3479,7 @@ int ws_wps_start(unsigned char *peer_addr, int wps_mode, const char *pin)
 
        params.params = value;
 
-       res = dbus_method_call(&params, SUPPLICNAT_WPS, NULL, NULL);
+       res = dbus_method_call(&params, SUPPLICANT_WPS, NULL, NULL);
        g_variant_unref(params.params);
 
        if (peer_addr != NULL)
@@ -3190,7 +3520,7 @@ int ws_wps_cancel()
        dbus_set_method_param(&params, "Cancel", g_pd->group_iface_path, g_dbus);
        params.params = NULL;
 
-       res = dbus_method_call(&params, SUPPLICNAT_WPS, NULL, NULL);
+       res = dbus_method_call(&params, SUPPLICANT_WPS, NULL, NULL);
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
        else
@@ -3241,7 +3571,7 @@ int ws_set_dev_name(char *dev_name)
        value = g_variant_new ("a{sv}", builder);
        g_variant_builder_unref (builder);
 
-       param = g_variant_new("(ssv)", SUPPLICNAT_P2PDEVICE,
+       param = g_variant_new("(ssv)", SUPPLICANT_P2PDEVICE,
                                "P2PDeviceConfig", value);
        WDP_LOGE("param [%s]", g_variant_print(param,TRUE));
 
@@ -3303,7 +3633,7 @@ int ws_get_go_intent(int *go_intent)
                return -1;
        }
 
-       param = g_variant_new("(ss)", SUPPLICNAT_P2PDEVICE, "P2PDeviceConfig");
+       param = g_variant_new("(ss)", SUPPLICANT_P2PDEVICE, "P2PDeviceConfig");
        WDP_LOGE("param [%s]", g_variant_print(param,TRUE));
 
        reply = g_dbus_connection_call_sync (
@@ -3379,7 +3709,7 @@ int ws_set_go_intent(int go_intent)
        value = g_variant_new ("a{sv}", builder);
        g_variant_builder_unref (builder);
 
-       param = g_variant_new("(ssv)", SUPPLICNAT_P2PDEVICE, "P2PDeviceConfig", value);
+       param = g_variant_new("(ssv)", SUPPLICANT_P2PDEVICE, "P2PDeviceConfig", value);
        WDP_LOGE("param [%s]", g_variant_print(param,TRUE));
 
        params.params = param;
@@ -3528,7 +3858,7 @@ int ws_get_persistent_groups(wfd_oem_persistent_group_s **groups, int *group_cou
                WDP_LOGE("DBus connection is NULL");
                return -1;
        }
-       dbus_property_get_all(g_pd->iface_path, g_dbus, SUPPLICNAT_P2PDEVICE, __ws_extract_p2pdevice_details, &networks[0]);
+       dbus_property_get_all(g_pd->iface_path, g_dbus, SUPPLICANT_P2PDEVICE, __ws_extract_p2pdevice_details, &networks[0]);
 
        cnt = networks[0].total;
 
@@ -3539,7 +3869,20 @@ int ws_get_persistent_groups(wfd_oem_persistent_group_s **groups, int *group_cou
                return -1;
        }
 
+       if(cnt == 0) {
+               WDP_LOGE("Persistent group count zero");
+               *group_count = 0;
+               *groups = NULL;
+               __WDP_LOG_FUNC_EXIT__;
+               return 0;
+       }
+
        wfd_persistent_groups = (wfd_oem_persistent_group_s*) g_try_malloc0(cnt * sizeof(wfd_oem_persistent_group_s));
+       if (wfd_persistent_groups == NULL) {
+               WDP_LOGE("Failed to allocate memory for wfd_persistent_groups ");
+               return -1;
+       }
+
        for(i = 0; i < cnt; i++) {
                WDP_LOGD("----persistent group [%d]----", i);
                WDP_LOGD("network_id=%d", networks[i].network_id);
@@ -3573,7 +3916,7 @@ int ws_remove_persistent_group(char *ssid, unsigned char *bssid)
                WDP_LOGE("DBus connection is NULL");
                return -1;
        }
-       dbus_property_get_all(g_pd->iface_path, g_dbus, SUPPLICNAT_P2PDEVICE, __ws_extract_p2pdevice_details, networks);
+       dbus_property_get_all(g_pd->iface_path, g_dbus, SUPPLICANT_P2PDEVICE, __ws_extract_p2pdevice_details, networks);
 
        cnt = networks[0].total;
 
@@ -3605,7 +3948,7 @@ int ws_remove_persistent_group(char *ssid, unsigned char *bssid)
                        params.params = g_variant_new ("(o)", networks[i].persistent_path);
 
                        WDP_LOGD("params [%s]", g_variant_print(params.params, TRUE));
-                       res = dbus_method_call(&params, SUPPLICNAT_P2PDEVICE, NULL, NULL);
+                       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
                        if (res < 0) {
                                WDP_LOGE("Failed to send command to wpa_supplicant");
                                __WDP_LOG_FUNC_EXIT__;
@@ -3652,7 +3995,7 @@ int ws_set_persistent_reconnect(unsigned char *bssid, int reconnect)
        value = g_variant_new ("a{sv}", builder);
        g_variant_builder_unref (builder);
 
-       param = g_variant_new("(ssv)", SUPPLICNAT_P2PDEVICE, "P2PDeviceConfig", value);
+       param = g_variant_new("(ssv)", SUPPLICANT_P2PDEVICE, "P2PDeviceConfig", value);
        WDP_LOGE("param [%s]", g_variant_print(param,TRUE));
 
        params.params = param;
@@ -3959,7 +4302,7 @@ int ws_start_service_discovery(unsigned char *mac_addr, int service_type)
 
        params.params = value;
 
-       res = dbus_method_call(&params, SUPPLICNAT_P2PDEVICE, __add_service_query, mac_addr);
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, __add_service_query, mac_addr);
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
        else
@@ -4029,7 +4372,7 @@ int ws_cancel_service_discovery(unsigned char *mac_addr, int service_type)
 
        params.params = g_variant_new ("(t)", strtoul(query_id, NULL, 16));
 
-       res = dbus_method_call(&params, SUPPLICNAT_P2PDEVICE, NULL, NULL);
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
        else
@@ -4089,7 +4432,7 @@ int ws_serv_add(wfd_oem_new_service_s *service)
 
        params.params = value;
 
-       res = dbus_method_call(&params, SUPPLICNAT_P2PDEVICE, NULL, NULL);
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
        else
@@ -4145,7 +4488,7 @@ int ws_serv_del(wfd_oem_new_service_s *service)
 
        params.params = value;
 
-       res = dbus_method_call(&params, SUPPLICNAT_P2PDEVICE, NULL, NULL);
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
        else
index c11b5d4..3310db4 100755 (executable)
@@ -299,6 +299,8 @@ typedef enum {
        WS_INVITE_INFO_GO_DEV_ADDR,     // go_dev_addr=
        WS_INVITE_INFO_BSSID,           // bssid=
        WS_INVITE_INFO_LISTEN,  // listen=
+       WS_INVITE_INFO_FREQ,                    // op_freq=
+       WS_INVITE_INFO_PERSISTENT_ID, // persistent_id=
        WS_INVITE_INFO_STATUS,  // status=
 
        WS_INVITE_INFO_LIMIT,
old mode 100644 (file)
new mode 100755 (executable)
index 49ea883..2474101
@@ -125,6 +125,8 @@ ws_string_s ws_invite_info_strs[] = {
        {"go_dev_addr", WS_INVITE_INFO_GO_DEV_ADDR},
        {"bssid", WS_INVITE_INFO_BSSID},
        {"listen", WS_INVITE_INFO_LISTEN},
+       {"op_freq", WS_INVITE_INFO_FREQ},
+       {"persistent_id", WS_INVITE_INFO_PERSISTENT_ID},
        {"status", WS_INVITE_INFO_STATUS},
        {"", WS_INVITE_INFO_LIMIT},
        };
@@ -298,7 +300,7 @@ static int _ws_hex_to_num(char *src, int len)
                return -1;
        }
 
-       temp = (char*) calloc(1, len+1);
+       temp = (char*) g_try_malloc0(len + 1);
        if (!temp) {
                WDP_LOGE("Failed to allocate memory");
                return -1;
@@ -757,7 +759,7 @@ static int _connect_to_supplicant(char *ifname, ws_sock_data_s **sock_data)
        }
 
        errno = 0;
-       sock = (ws_sock_data_s*) calloc(1, sizeof(ws_sock_data_s));
+       sock = (ws_sock_data_s*) g_try_malloc0(sizeof(ws_sock_data_s));
        if (!sock) {
                WDP_LOGE("Failed to allocate memory for socket data", strerror(errno));
                __WDP_LOG_FUNC_EXIT__;
@@ -767,9 +769,9 @@ static int _connect_to_supplicant(char *ifname, ws_sock_data_s **sock_data)
        snprintf(ctrl_path, sizeof(ctrl_path), "/tmp/%s_control", ifname);
        snprintf(mon_path, sizeof(mon_path), "/tmp/%s_monitor", ifname);
        if (strncmp(ifname, GROUP_IFACE_NAME, 11))
-               snprintf(suppl_path, sizeof(suppl_path), SUPPL_IFACE_PATH "%s", ifname);
+               g_snprintf(suppl_path, sizeof(suppl_path), SUPPL_IFACE_PATH "%s", ifname);
        else
-               snprintf(suppl_path, sizeof(suppl_path), SUPPL_GROUP_IFACE_PATH "%s", ifname);
+               g_snprintf(suppl_path, sizeof(suppl_path), SUPPL_GROUP_IFACE_PATH "%s", ifname);
 
 
        for(i = 0; i < WS_CONN_RETRY_COUNT; i++) {
@@ -868,7 +870,7 @@ static int _disconnect_from_supplicant(char *ifname, ws_sock_data_s *sock_data)
        }
 
        // detach monitor interface
-       snprintf(cmd, sizeof(cmd), WS_CMD_DETACH);
+       g_snprintf(cmd, sizeof(cmd), WS_CMD_DETACH);
        res = _ws_send_cmd(sock_data->mon_sock, cmd, reply, sizeof(reply));
        if (res < 0) {
                WDP_LOGE("Failed to send command to wpa_supplicant. Keep going to close socket.");
@@ -887,7 +889,7 @@ static int _disconnect_from_supplicant(char *ifname, ws_sock_data_s *sock_data)
        sock_data->gsource = 0;
 
        // close control interface
-       snprintf(ctrl_path, sizeof(ctrl_path), "/tmp/%s_control", ifname);
+       g_snprintf(ctrl_path, sizeof(ctrl_path), "/tmp/%s_control", ifname);
        snprintf(mon_path, sizeof(mon_path), "/tmp/%s_monitor", ifname);
 
        if (sock_data->ctrl_sock >= SOCK_FD_MIN)
@@ -969,7 +971,11 @@ static int _extract_word(const char *data, char **value)
        }
 
        if (i > 0) {
-               *value = (char*) calloc(1, i+1);
+               *value = (char*) g_try_malloc0(i + 1);
+               if(!(*value)) {
+                       WDP_LOGE("Failed to allocate memory for value");
+                       return -1;
+               }
                strncpy(*value, data, i);
                (*value)[i] = '\0';
                WDP_LOGV("Extracted word: %s", *value);
@@ -1009,7 +1015,11 @@ static int _extract_value_str(const char *data, const char *key, char **value)
        }
 
        if (i > 0) {
-               *value = (char*) calloc(1, i+1);
+               *value = (char*) g_try_malloc0(i + 1);
+               if(!(*value)) {
+                       WDP_LOGE("Failed to allocate memory for value");
+                       return -1;
+               }
                strncpy(*value, tmp_str, i);
                (*value)[i] = '\0';
                WDP_LOGV("Extracted string: %s", *value);
@@ -1042,7 +1052,11 @@ static int _extract_peer_value_str(const char *data, const char *key, char **val
        }
 
        if (i > 0) {
-               *value = (char*) calloc(1, i+1);
+               *value = (char*) g_try_malloc0(i + 1);
+               if(!(*value)) {
+                       WDP_LOGE("Failed to allocate memory for value");
+                       return -1;
+               }
                strncpy(*value, tmp_str, i);
                (*value)[i] = '\0';
                WDP_LOGV("Extracted string: %s", *value);
@@ -1348,7 +1362,7 @@ static wfd_oem_dev_data_s *_convert_msg_to_dev_info(char *msg)
        }
 
        errno = 0;
-       edata = (wfd_oem_dev_data_s*) calloc(1, sizeof(wfd_oem_dev_data_s));
+       edata = (wfd_oem_dev_data_s*) g_try_malloc0(sizeof(wfd_oem_dev_data_s));
        if (!edata) {
                WDP_LOGE("Failed to allocate memory for device information [%s]", strerror(errno));
                return NULL;
@@ -1451,7 +1465,7 @@ static wfd_oem_conn_data_s *_convert_msg_to_conn_info(char *msg)
        }
 
        errno = 0;
-       edata = (wfd_oem_conn_data_s*) calloc(1, sizeof(wfd_oem_conn_data_s));
+       edata = (wfd_oem_conn_data_s*) g_try_malloc0(sizeof(wfd_oem_conn_data_s));
        if (!edata) {
                WDP_LOGE("Failed to allocate memory for connection information [%s]", strerror(errno));
                return NULL;
@@ -1518,7 +1532,7 @@ static wfd_oem_invite_data_s *_convert_msg_to_invite_info(char *msg)
        }
 
        errno = 0;
-       edata = (wfd_oem_invite_data_s*) calloc(1, sizeof(wfd_oem_invite_data_s));
+       edata = (wfd_oem_invite_data_s*) g_try_malloc0(sizeof(wfd_oem_invite_data_s));
        if (!edata) {
                WDP_LOGE("Failed to allocate memory for invite information [%s]", strerror(errno));
                return NULL;
@@ -1584,7 +1598,7 @@ static wfd_oem_group_data_s *_convert_msg_to_group_info(char *msg)
        }
 
        errno = 0;
-       edata = (wfd_oem_group_data_s*) calloc(1, sizeof(wfd_oem_group_data_s));
+       edata = (wfd_oem_group_data_s*) g_try_malloc0(sizeof(wfd_oem_group_data_s));
        if (!edata) {
                WDP_LOGE("Failed to allocate memory for group information [%s]", strerror(errno));
                return NULL;
@@ -1593,15 +1607,15 @@ static wfd_oem_group_data_s *_convert_msg_to_group_info(char *msg)
        for (i = 0; i < info_cnt; i++) {
                switch (infos[i].index) {
                case WS_GROUP_INFO_SSID:
-                       strncpy(edata->ssid, infos[i].string, OEM_DEV_NAME_LEN);
-                       edata->ssid[OEM_DEV_NAME_LEN] = '\0';
+                       g_strlcpy(edata->ssid, infos[i].string, OEM_DEV_NAME_LEN + 1);
+                       WDP_LOGD("ssid [%s]", edata->ssid);
                        break;
                case WS_GROUP_INFO_FREQ:
                        edata->freq = atoi(infos[i].string);
                        break;
                case WS_GROUP_INFO_PASS:
-                       strncpy(edata->pass, infos[i].string, OEM_PASS_PHRASE_LEN);
-                       edata->pass[OEM_PASS_PHRASE_LEN] = '\0';
+                       g_strlcpy(edata->pass, infos[i].string, OEM_PASS_PHRASE_LEN + 1);
+                       WDP_LOGD("passphrase [%s]", edata->pass);
                        break;
                case WS_GROUP_INFO_GO_DEV_ADDR:
                        res = _ws_txt_to_mac(infos[i].string, edata->go_dev_addr);
@@ -1612,8 +1626,7 @@ static wfd_oem_group_data_s *_convert_msg_to_group_info(char *msg)
                        WDP_LOGE("Unknown parameter [%d:%s]", infos[i].index, infos[i].string);
                        break;
                }
-               if (infos[i].string)
-                       free(infos[i].string);
+               g_free(infos[i].string);
        }
 
        __WDP_LOG_FUNC_EXIT__;
@@ -1637,7 +1650,7 @@ static int _ws_segment_to_service(char *segment, wfd_oem_new_service_s **service
        ptr = segment;
        WDP_LOGD("Segment: %s", segment);
 
-       serv_tmp = (wfd_oem_new_service_s*) calloc(1, sizeof(wfd_oem_new_service_s));
+       serv_tmp = (wfd_oem_new_service_s*) g_try_malloc0(sizeof(wfd_oem_new_service_s));
        if (!serv_tmp) {
                WDP_LOGE("Failed to allocate memory for service");
                return -1;
@@ -1651,7 +1664,7 @@ static int _ws_segment_to_service(char *segment, wfd_oem_new_service_s **service
 
        if (serv_tmp->status != 0) {
                WDP_LOGE("Service status is not success");
-               free(serv_tmp);
+               g_free(serv_tmp);
                return -1;
        }
 
@@ -1666,14 +1679,19 @@ static int _ws_segment_to_service(char *segment, wfd_oem_new_service_s **service
                        len = _ws_hex_to_num(ptr, 2);
                        ptr +=2;
                        if (len) {
-                               temp = (char*) calloc(1, len+2);
+                               temp = (char*) g_try_malloc0(len + 2);
+                               if (!temp) {
+                                       WDP_LOGE("Failed to allocate memory for temp");
+                                       g_free(serv_tmp);
+                                       return -1;
+                               }
                                temp[0] = '.';
                                for (i=0; i<len; i++) {
                                        temp[i+1] = (char) _ws_hex_to_num(ptr, 2);
                                        ptr += 2;
                                }
                                strncat(query, temp, len+1);
-                               free(temp);
+                               g_free(temp);
                                temp = NULL;
                        }
                }
@@ -1704,14 +1722,19 @@ static int _ws_segment_to_service(char *segment, wfd_oem_new_service_s **service
                        len = _ws_hex_to_num(ptr, 2);
                        ptr += 2;
                        if (len) {
-                               temp = (char*) calloc(1, len+2);
+                               temp = (char*) g_try_malloc0(len + 2);
+                               if (!temp) {
+                                       WDP_LOGE("Failed to allocate memory for temp");
+                                       g_free(serv_tmp);
+                                       return -1;
+                               }
                                temp[0] = '.';
                                for (i=0; i<len; i++) {
                                        temp[i+1] = (char) _ws_hex_to_num(ptr, 2);
                                        ptr += 2;
                                }
                                strncat(rdata, temp, len+1);
-                               free(temp);
+                               g_free(temp);
                                temp = NULL;
                        }
                }
@@ -1725,9 +1748,20 @@ static int _ws_segment_to_service(char *segment, wfd_oem_new_service_s **service
                        WDP_LOGD("\tSAMSUNG_BT_ADDR");
                        ptr += 16;
                        serv_tmp->protocol = WFD_OEM_SERVICE_TYPE_BT_ADDR;
-                       serv_tmp->data.vendor.data1 = (char*) calloc(1, 9);
+                       serv_tmp->data.vendor.data1 = (char*) g_try_malloc0(9);
+                       if (!serv_tmp->data.vendor.data1) {
+                               WDP_LOGE("Failed to allocate memory for data.vendor.data1");
+                               g_free(serv_tmp);
+                               return -1;
+                       }
                        g_strlcpy(serv_tmp->data.vendor.data1, "0000f00b", 9);
-                       serv_tmp->data.vendor.data2 = (char*) calloc(1, 18);
+                       serv_tmp->data.vendor.data2 = (char*) g_try_malloc0(18);
+                       if (!serv_tmp->data.vendor.data2) {
+                               WDP_LOGE("Failed to allocate memory for data.vendor.data2");
+                               g_free(serv_tmp->data.vendor.data1);
+                               g_free(serv_tmp);
+                               return -1;
+                       }
                        _ws_hex_to_txt(ptr, 0, serv_tmp->data.vendor.data2);
                }
                WDP_LOGD("Info1: %s", serv_tmp->data.vendor.data1);
@@ -1735,7 +1769,7 @@ static int _ws_segment_to_service(char *segment, wfd_oem_new_service_s **service
        } else {
                WDP_LOGE("Not supported yet. Only bonjour and samsung vendor service supproted [%d]",
                                        serv_tmp->protocol);
-               free(serv_tmp);
+               g_free(serv_tmp);
                return -1;
        }
 
@@ -1759,7 +1793,7 @@ static int _parsing_event_info(char *ifname, char *msg, wfd_oem_event_s *data)
        }
        WDP_SECLOGD("Event message [%s]", msg);
 
-       // parsing event string
+       /* parsing event string */
        for(i = 0; ws_event_strs[i].index < WS_EVENT_LIMIT; i++) {
                if (!strncmp(ws_event_strs[i].string, msg, strlen(ws_event_strs[i].string))) {
                        break;
@@ -1774,7 +1808,7 @@ static int _parsing_event_info(char *ifname, char *msg, wfd_oem_event_s *data)
        data->event_id = ws_event_strs[i].index;
        WDP_LOGD("Event ID [%d]", data->event_id);
 
-       // parsing event info
+       /* parsing event info */
        info_str = msg + strlen(ws_event_strs[i].string) + 1;
        if (!strlen(info_str)) {
                WDP_LOGD("Nothing to parse anymore");
@@ -1842,7 +1876,7 @@ static int _parsing_event_info(char *ifname, char *msg, wfd_oem_event_s *data)
                        }
                        _ws_txt_to_mac(temp_mac, data->dev_addr);
                        if (temp_mac)
-                               free(temp_mac);
+                               g_free(temp_mac);
                        data->edata_type = WFD_OEM_EDATA_TYPE_NONE;
                }
                break;
@@ -1907,7 +1941,7 @@ static int _parsing_event_info(char *ifname, char *msg, wfd_oem_event_s *data)
                        }
                        _ws_txt_to_mac(temp_mac, data->intf_addr);
                        if (temp_mac)
-                               free(temp_mac);
+                               g_free(temp_mac);
                        data->edata_type = WFD_OEM_EDATA_TYPE_NONE;
                }
                break;
@@ -1940,7 +1974,7 @@ static int _parsing_event_info(char *ifname, char *msg, wfd_oem_event_s *data)
                        }
                        _ws_txt_to_mac(temp_mac, data->dev_addr);
                        if (temp_mac)
-                               free(temp_mac);
+                               g_free(temp_mac);
                        data->edata_type = WFD_OEM_EDATA_TYPE_NONE;
                }
                break;
@@ -1952,12 +1986,12 @@ static int _parsing_event_info(char *ifname, char *msg, wfd_oem_event_s *data)
                        if (res == 17/*(OEM_MACSTR_LEN-1)*/) {
                                _ws_txt_to_mac(peer_addr_str, data->dev_addr);
                                if (peer_addr_str)
-                                       free(peer_addr_str);
+                                       g_free(peer_addr_str);
                        } else if (res < 0) {
                                WDP_LOGE("Failed to extract source address");
                        } else {
                                WDP_LOGE("Wrong source address");
-                               free(peer_addr_str);
+                               g_free(peer_addr_str);
                        }
 
                        if (!strlen(info_str)) {
@@ -1988,8 +2022,7 @@ static int _parsing_event_info(char *ifname, char *msg, wfd_oem_event_s *data)
                                WDP_LOGE("Failed to extract event param string");
                        } else if (res == 0) {
                                WDP_LOGE("Nothing extracted");
-                               if (ifname_str)
-                                       free(ifname_str);
+                               g_free(ifname_str);
                        } else {
                                if (!ifname_str) {
                                        WDP_LOGE("Parsing error(interface name)");
@@ -1999,8 +2032,7 @@ static int _parsing_event_info(char *ifname, char *msg, wfd_oem_event_s *data)
                                data->ifname[OEM_IFACE_NAME_LEN] = '\0';
 
                                info_str += strlen(ifname_str) + 1;
-                               if (ifname_str)
-                                       free(ifname_str);
+                               g_free(ifname_str);
                        }
 
                        char *dev_role_str = NULL;
@@ -2009,8 +2041,7 @@ static int _parsing_event_info(char *ifname, char *msg, wfd_oem_event_s *data)
                                WDP_LOGE("Failed to extract event param string");
                        } else if (res == 0) {
                                WDP_LOGE("Nothing extracted");
-                               if (dev_role_str)
-                                       free(dev_role_str);
+                               g_free(dev_role_str);
                        } else {
                                if (!dev_role_str) {
                                        WDP_LOGE("Parsing error(device role)");
@@ -2024,8 +2055,7 @@ static int _parsing_event_info(char *ifname, char *msg, wfd_oem_event_s *data)
                                        WDP_LOGE("Unknown device role [%s]", dev_role_str);
 
                                info_str += strlen(dev_role_str) + 1;
-                               if (dev_role_str)
-                                       free(dev_role_str);
+                               g_free(dev_role_str);
                        }
 
                        if (!strlen(info_str)) {
@@ -2056,7 +2086,7 @@ static int _parsing_event_info(char *ifname, char *msg, wfd_oem_event_s *data)
 
                        _ws_txt_to_mac(info_str, data->dev_addr);
                        info_str += OEM_MACSTR_LEN;
-                       snprintf(mac_addr, OEM_MACSTR_LEN, MACSTR, MAC2STR(data->dev_addr));
+                       g_snprintf(mac_addr, OEM_MACSTR_LEN, MACSTR, MAC2STR(data->dev_addr));
 
                        _extract_word(info_str, &up_indic);
                        if (up_indic) {
@@ -2078,19 +2108,23 @@ static int _parsing_event_info(char *ifname, char *msg, wfd_oem_event_s *data)
                                len = strtoul(seglen_str, NULL, 16);
                                if (len == 0)
                                        break;
-                               segment = (char*) calloc(1, len*2+1);
+                               segment = (char*) g_try_malloc0(len * 2 + 1);
+                               if (!segment) {
+                                       WDP_LOGE("Failed to allocate memory for segment");
+                                       return -1;
+                               }
                                memcpy(segment, ptr+4, len*2);
                                ptr = ptr + 4 + len*2;
                                res = _ws_segment_to_service(segment, &new_service);
                                if (res < 0) {
                                        WDP_LOGE("Failed to convert segment as service instance");
-                                       free(segment);
+                                       g_free(segment);
                                        segment = NULL;
                                        continue;
                                }
                                services = g_list_append(services, new_service);
                                count++;
-                               free(segment);
+                               g_free(segment);
                                segment = NULL;
                        }
                        data->edata_type = WFD_OEM_EDATA_TYPE_NEW_SERVICE;
@@ -2119,7 +2153,7 @@ static gboolean ws_event_handler(GIOChannel *source,
        char *pos = NULL;
        char *param = NULL;
        int event_id = -1;
-       wfd_oem_event_s *event = NULL;
+       wfd_oem_event_s event;
        int res = 0;
 
        if (!sd) {
@@ -2135,11 +2169,7 @@ static gboolean ws_event_handler(GIOChannel *source,
        }
 
        errno = 0;
-       event = (wfd_oem_event_s*) calloc(1, sizeof(wfd_oem_event_s));
-       if (!event) {
-               WDP_LOGE("Failed to allocate memory for event. [%s]", strerror(errno));
-               return FALSE;
-       }
+       memset(&event, 0, sizeof(wfd_oem_event_s));
 
        if (!strncmp(msg, "IFNAME", 6)) {
                pos = strchr(msg, ' ');
@@ -2148,10 +2178,9 @@ static gboolean ws_event_handler(GIOChannel *source,
                param = &msg[3];
        }
 
-       res = _parsing_event_info(sd->ifname, param, event);
+       res = _parsing_event_info(sd->ifname, param, &event);
        if (res < 0) {
                WDP_LOGE("Failed to parse event string");
-               free(event);
                return FALSE;
        }
 
@@ -2160,7 +2189,7 @@ static gboolean ws_event_handler(GIOChannel *source,
        }
 
        /* Converting WS event to OEM event */
-       switch (event->event_id) {
+       switch (event.event_id) {
        case WS_EVENT_DEVICE_FOUND:
                event_id = WFD_OEM_EVENT_PEER_FOUND;
                break;
@@ -2174,32 +2203,32 @@ static gboolean ws_event_handler(GIOChannel *source,
                event_id = WFD_OEM_EVENT_PROV_DISC_REQ;
                break;
        case WS_EVENT_PROV_DISC_PBC_RESP:
-               if (!memcmp(event->dev_addr, g_pd_out, OEM_MACADDR_LEN)) {
+               if (!memcmp(event.dev_addr, g_pd_out, OEM_MACADDR_LEN)) {
                        event_id = WFD_OEM_EVENT_PROV_DISC_RESP;
                        memset(g_pd_out, 0x0, OEM_MACADDR_LEN);
                } else {
-                       WDP_LOGE("Invalid peer mac address[" MACSTR "]", MAC2STR(event->dev_addr));
+                       WDP_LOGE("Invalid peer mac address[" MACSTR "]", MAC2STR(event.dev_addr));
                        goto done;
                }
                break;
        case WS_EVENT_PROV_DISC_SHOW_PIN:
        case WS_EVENT_PROV_DISC_ENTER_PIN:
-               if (!memcmp(event->dev_addr, g_pd_out, OEM_MACADDR_LEN)) {
+               if (!memcmp(event.dev_addr, g_pd_out, OEM_MACADDR_LEN)) {
                        event_id = WFD_OEM_EVENT_PROV_DISC_RESP;
                        memset(g_pd_out, 0x0, OEM_MACADDR_LEN);
                        WDP_LOGD("Peer mac address verified");
                } else if (!memcmp(g_pd_out, null_mac, OEM_MACADDR_LEN)) {
                        event_id = WFD_OEM_EVENT_PROV_DISC_REQ;
-                       WDP_LOGD("      PD request from peer[" MACSTR "]", MAC2STR(event->dev_addr));
+                       WDP_LOGD("      PD request from peer[" MACSTR "]", MAC2STR(event.dev_addr));
                } else {
-                       WDP_LOGE("Invalid peer mac address[" MACSTR "]", MAC2STR(event->dev_addr));
+                       WDP_LOGE("Invalid peer mac address[" MACSTR "]", MAC2STR(event.dev_addr));
                        goto done;
                }
 
                break;
        case WS_EVENT_PROV_DISC_FAILURE:
                event_id = WFD_OEM_EVENT_PROV_DISC_FAIL;
-               if (!memcmp(event->dev_addr, g_pd_out, OEM_MACADDR_LEN)) {
+               if (!memcmp(event.dev_addr, g_pd_out, OEM_MACADDR_LEN)) {
                        memset(g_pd_out, 0x0, OEM_MACADDR_LEN);
                        WDP_LOGD("Peer mac address verified, but PD failed");
                }
@@ -2224,7 +2253,7 @@ static gboolean ws_event_handler(GIOChannel *source,
                // TODO: connect to supplicant via group interface
                break;
        case WS_EVENT_CONNECTED:
-               if (!memcmp(event->intf_addr, null_mac, OEM_MACADDR_LEN))
+               if (!memcmp(event.intf_addr, null_mac, OEM_MACADDR_LEN))
                        goto done;
                event_id = WFD_OEM_EVENT_CONNECTED;
                break;
@@ -2257,7 +2286,7 @@ static gboolean ws_event_handler(GIOChannel *source,
                event_id = WFD_OEM_EVENT_INVITATION_RES;
                break;
        case WS_EVENT_DISCONNECTED:
-               if (!memcmp(event->intf_addr, null_mac, OEM_MACADDR_LEN))
+               if (!memcmp(event.intf_addr, null_mac, OEM_MACADDR_LEN))
                        goto done;
                event_id = WFD_OEM_EVENT_DISCONNECTED;
                break;
@@ -2273,23 +2302,22 @@ static gboolean ws_event_handler(GIOChannel *source,
                break;
 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
        default:
-               WDP_LOGD("Unknown event [%d]", event->event_id);
+               WDP_LOGD("Unknown event [%d]", event.event_id);
                goto done;
                break;
        }
-       event->event_id = event_id;
-       g_pd->callback(g_pd->user_data, event);
+       event.event_id = event_id;
+       g_pd->callback(g_pd->user_data, &event);
 
 done:
-       if (event->edata) {
+       if (event.edata) {
 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
-               if (event->edata_type == WFD_OEM_EDATA_TYPE_NEW_SERVICE)
-                       g_list_free((GList*) event->edata);
+               if (event.edata_type == WFD_OEM_EDATA_TYPE_NEW_SERVICE)
+                       g_list_free((GList*) event.edata);
                else
 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
-               free(event->edata);
+               g_free(event.edata);
        }
-       free(event);
 
        __WDP_LOG_FUNC_EXIT__;
        return TRUE;
@@ -2308,7 +2336,7 @@ static int _ws_reset_plugin(ws_plugin_data_s *pd)
        if (pd->activated)
                ws_deactivate(g_pd->concurrent);
 
-       free(pd);
+       g_free(pd);
 
        __WDP_LOG_FUNC_EXIT__;
        return 0;
@@ -2332,8 +2360,7 @@ static int __ws_check_net_interface(char* if_name)
        }
 
        memset(&ifr, 0, sizeof(ifr));
-       strncpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name));
-       ifr.ifr_name[IFNAMSIZ-1] = '\0';
+       g_strlcpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name) + 1);
 
        if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
                close(fd);
@@ -2361,7 +2388,7 @@ int ws_init(wfd_oem_event_cb callback, void *user_data)
                _ws_reset_plugin(g_pd);
 
        errno = 0;
-       g_pd = (ws_plugin_data_s*) calloc(1, sizeof(ws_plugin_data_s));
+       g_pd = (ws_plugin_data_s*) g_try_malloc0(sizeof(ws_plugin_data_s));
        if (!g_pd) {
                WDP_LOGE("Failed to allocate memory for plugin data. [%s]", strerror(errno));
                return -1;
@@ -2694,7 +2721,7 @@ static int _ws_update_local_dev_addr()
                goto failed;
        }
 
-       free(mac_str);
+       g_free(mac_str);
 
        return 0;
 
@@ -2896,28 +2923,28 @@ int ws_start_scan(wfd_oem_scan_param_s *param)
                _ws_flush();
 
        if (param->scan_time)
-               snprintf(time_str, 4, " %d", param->scan_time);
+               g_snprintf(time_str, 4, " %d", param->scan_time);
 
        if (param->scan_type == WFD_OEM_SCAN_TYPE_SOCIAL)
-               snprintf(type_str, 20, " type=social");
+               g_snprintf(type_str, 20, " type=social");
        else if (param->scan_type == WFD_OEM_SCAN_TYPE_SPECIFIC &&
                        param->freq > 0)
-               snprintf(type_str, 20, " freq=%d", param->freq);
+               g_snprintf(type_str, 20, " freq=%d", param->freq);
        else if (param->scan_type == WFD_OEM_SCAN_TYPE_CHANNEL1)
-               snprintf(type_str, 20, " type=specific1");
+               g_snprintf(type_str, 20, " type=specific1");
        else if (param->scan_type == WFD_OEM_SCAN_TYPE_CHANNEL6)
-               snprintf(type_str, 20, " type=specific6");
+               g_snprintf(type_str, 20, " type=specific6");
        else if (param->scan_type == WFD_OEM_SCAN_TYPE_CHANNEL11)
-               snprintf(type_str, 20, " type=specific11");
+               g_snprintf(type_str, 20, " type=specific11");
        else if (param->scan_type == WFD_OEM_SCAN_TYPE_GO_FREQ)
-               snprintf(type_str, 20, " type=frequency");
+               g_snprintf(type_str, 20, " type=frequency");
 
        if (param->scan_mode == WFD_OEM_SCAN_MODE_ACTIVE)
-               snprintf(cmd, sizeof(cmd), WS_CMD_P2P_FIND "%s%s",
+               g_snprintf(cmd, sizeof(cmd), WS_CMD_P2P_FIND "%s%s",
                                        (param->scan_time > 0) ? time_str : "",
                                        (param->scan_type) ? type_str : "");
        else
-               snprintf(cmd, sizeof(cmd), WS_CMD_P2P_LISTEN);
+               g_snprintf(cmd, sizeof(cmd), WS_CMD_P2P_LISTEN);
 
        res = _ws_send_cmd(sock->ctrl_sock, cmd, reply, sizeof(reply));
        if (res < 0) {
@@ -3006,7 +3033,7 @@ int ws_get_scan_result(GList **peers, int *peer_count)
                return -1;
        }
 
-       snprintf(cmd, sizeof(cmd), WS_CMD_P2P_PEER_FIRST);
+       g_snprintf(cmd, sizeof(cmd), WS_CMD_P2P_PEER_FIRST);
        res = _ws_send_cmd(sock->ctrl_sock, cmd, reply, sizeof(reply));
        if (res < 0) {
                        WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -3021,12 +3048,16 @@ int ws_get_scan_result(GList **peers, int *peer_count)
        }
        WDP_LOGD("Succeeded to get first peer info");
 
-       peer = (wfd_oem_device_s *) calloc(1, sizeof(wfd_oem_device_s));
+       peer = (wfd_oem_device_s *) g_try_malloc0(sizeof(wfd_oem_device_s));
+       if (!peer) {
+               WDP_LOGF("Failed to allocate memory for peer.");
+               return -1;
+       }
 
        res = _parsing_peer_info(reply, peer);
        if (res < 0) {
                        WDP_LOGE("Failed to parsing peer info");
-                       free(peer);
+                       g_free(peer);
                        __WDP_LOG_FUNC_EXIT__;
                        return -1;
        }
@@ -3034,7 +3065,7 @@ int ws_get_scan_result(GList **peers, int *peer_count)
        *peers = g_list_prepend(*peers, peer);
 
        do {
-               snprintf(cmd, sizeof(cmd), WS_CMD_P2P_PEER_NEXT MACSTR, MAC2STR(peer->dev_addr));
+               g_snprintf(cmd, sizeof(cmd), WS_CMD_P2P_PEER_NEXT MACSTR, MAC2STR(peer->dev_addr));
                res = _ws_send_cmd(sock->ctrl_sock, cmd, reply, sizeof(reply));
                if (res < 0) {
                                WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -3047,12 +3078,16 @@ int ws_get_scan_result(GList **peers, int *peer_count)
                }
                WDP_LOGD("Succeeded to get first peer info");
 
-               peer = (wfd_oem_device_s *) calloc(1, sizeof(wfd_oem_device_s));
+               peer = (wfd_oem_device_s *) g_try_malloc0(sizeof(wfd_oem_device_s));
+               if (!peer) {
+                       WDP_LOGF("Failed to allocate memory for peer");
+                       break;
+               }
 
                res = _parsing_peer_info(reply, peer);
                if (res < 0) {
                        WDP_LOGE("Failed to parsing peer info");
-                       free(peer);
+                       g_free(peer);
                        break;
                }
 
@@ -3082,7 +3117,7 @@ int ws_get_peer_info(unsigned char *peer_addr, wfd_oem_device_s **peer)
                return -1;
        }
 
-       snprintf(cmd, sizeof(cmd), WS_CMD_P2P_PEER MACSTR, MAC2STR(peer_addr));
+       g_snprintf(cmd, sizeof(cmd), WS_CMD_P2P_PEER MACSTR, MAC2STR(peer_addr));
        res = _ws_send_cmd(sock->ctrl_sock, cmd, reply, sizeof(reply));
        if (res < 0) {
                        WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -3097,12 +3132,16 @@ int ws_get_peer_info(unsigned char *peer_addr, wfd_oem_device_s **peer)
        }
        WDP_LOGD("Succeeded to get peer info [" MACSECSTR "]", MAC2SECSTR(peer_addr));
 
-       ws_dev = (wfd_oem_device_s*) calloc(1, sizeof(wfd_oem_device_s));
+       ws_dev = (wfd_oem_device_s*) g_try_malloc0(sizeof(wfd_oem_device_s));
+       if (!ws_dev) {
+               WDP_LOGF("Failed to allocate memory for device");
+               return -1;
+       }
 
        res = _parsing_peer_info(reply, ws_dev);
        if (res < 0) {
                WDP_LOGE("Failed to parsing peer info");
-               free(ws_dev);
+               g_free(ws_dev);
                __WDP_LOG_FUNC_EXIT__;
                return -1;
        }
@@ -3125,7 +3164,7 @@ int ws_prov_disc_req(unsigned char *peer_addr, wfd_oem_wps_mode_e wps_mode, int
                return -1;
        }
 
-       snprintf(cmd, sizeof(cmd), WS_CMD_P2P_PROV_DISC MACSTR "%s",
+       g_snprintf(cmd, sizeof(cmd), WS_CMD_P2P_PROV_DISC MACSTR "%s",
                                        MAC2STR(peer_addr), _ws_wps_to_txt(wps_mode));
 
        if (join)
@@ -3172,11 +3211,11 @@ int ws_connect(unsigned char *peer_addr, wfd_oem_conn_param_s *param)
        }
 
        if (param->wps_pin[0] != '\0')
-               snprintf(cmd, sizeof(cmd), WS_CMD_P2P_CONNECT MACSTR " %s%s" ,
+               g_snprintf(cmd, sizeof(cmd), WS_CMD_P2P_CONNECT MACSTR " %s%s" ,
                                                        MAC2STR(peer_addr), param->wps_pin,
                                                        _ws_wps_to_txt(param->wps_mode));
        else
-               snprintf(cmd, sizeof(cmd), WS_CMD_P2P_CONNECT MACSTR "%s",
+               g_snprintf(cmd, sizeof(cmd), WS_CMD_P2P_CONNECT MACSTR "%s",
                                                        MAC2STR(peer_addr),
                                                        _ws_wps_to_txt(param->wps_mode));
 
@@ -3189,7 +3228,7 @@ int ws_connect(unsigned char *peer_addr, wfd_oem_conn_param_s *param)
                strncat(cmd, WS_STR_PERSISTENT, 11);
 
        if (param->freq > 0) {
-               snprintf(freq_str, sizeof(freq_str), WS_STR_FREQ "%d", param->freq);
+               g_snprintf(freq_str, sizeof(freq_str), WS_STR_FREQ "%d", param->freq);
                strncat(cmd, freq_str, sizeof(freq_str));
        }
 
@@ -3233,7 +3272,7 @@ int ws_disconnect(unsigned char *peer_addr)
 
        WDP_LOGD("Peer address is [" MACSECSTR "]. Disconnect selected peer", MAC2SECSTR(peer_addr));
 
-       snprintf(cmd, sizeof(cmd), WS_CMD_DISCONNECT MACSTR " %s", MAC2STR(peer_addr), GROUP_IFACE_NAME);
+       g_snprintf(cmd, sizeof(cmd), WS_CMD_DISCONNECT MACSTR " %s", MAC2STR(peer_addr), GROUP_IFACE_NAME);
        res = _ws_send_cmd(sock->ctrl_sock, cmd, reply, sizeof(reply));
        if (res < 0) {
                WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -3265,7 +3304,7 @@ int ws_reject_connection(unsigned char *peer_addr)
                return -1;
        }
 
-       snprintf(cmd, sizeof(cmd), WS_CMD_P2P_CONNECT MACSTR "%s userReject", MAC2STR(peer_addr), WS_STR_PBC);
+       g_snprintf(cmd, sizeof(cmd), WS_CMD_P2P_CONNECT MACSTR "%s userReject", MAC2STR(peer_addr), WS_STR_PBC);
        res = _ws_send_cmd(sock->ctrl_sock, cmd, reply, sizeof(reply));
        if (res < 0) {
                        WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -3345,15 +3384,15 @@ int ws_create_group(int persistent, int freq, const char *passphrase)
        } else {
                if (passphrase[0] != '\0') {
 
-                       snprintf(cmd, sizeof(cmd), WS_CMD_P2P_GROUP_ADD " passphrase=%s", passphrase);
+                       g_snprintf(cmd, sizeof(cmd), WS_CMD_P2P_GROUP_ADD " passphrase=%s", passphrase);
 
                }else{
-                       snprintf(cmd, sizeof(cmd), WS_CMD_P2P_GROUP_ADD);
+                       g_snprintf(cmd, sizeof(cmd), WS_CMD_P2P_GROUP_ADD);
                }
        }
 
        if (freq > 0) {
-               snprintf(freq_str, sizeof(freq_str), WS_STR_FREQ "%d", freq);
+               g_snprintf(freq_str, sizeof(freq_str), WS_STR_FREQ "%d", freq);
                strncat(cmd, freq_str, sizeof(freq_str));
        } else {
                strncat(cmd, WS_STR_FREQ_2G, 8);
@@ -3439,11 +3478,11 @@ int ws_invite(unsigned char *peer_addr, wfd_oem_invite_param_s *param)
                                MAC2SECSTR(peer_addr), MAC2SECSTR(param->go_dev_addr));
 
        if (param->net_id)
-               snprintf(cmd, sizeof(cmd), WS_CMD_P2P_INVITE "persistent=%d peer=" MACSTR " go_dev_addr=" MACSTR,
+               g_snprintf(cmd, sizeof(cmd), WS_CMD_P2P_INVITE "persistent=%d peer=" MACSTR " go_dev_addr=" MACSTR,
                                                                param->net_id, MAC2STR(peer_addr),
                                                                MAC2STR(param->go_dev_addr));
        else
-               snprintf(cmd, sizeof(cmd), WS_CMD_P2P_INVITE "group=%s peer=" MACSTR " go_dev_addr=" MACSTR,
+               g_snprintf(cmd, sizeof(cmd), WS_CMD_P2P_INVITE "group=%s peer=" MACSTR " go_dev_addr=" MACSTR,
                                                                param->ifname, MAC2STR(peer_addr),
                                                                MAC2STR(param->go_dev_addr));
 
@@ -3485,9 +3524,9 @@ int ws_wps_start(unsigned char *peer_addr, int wps_mode, const char *pin)
        }
 
        if (wps_mode == WFD_OEM_WPS_MODE_PBC)
-               snprintf(cmd, sizeof(cmd), WS_CMD_WPS_PBC "p2p_dev_addr=" MACSTR, MAC2STR(peer_addr));
+               g_snprintf(cmd, sizeof(cmd), WS_CMD_WPS_PBC "p2p_dev_addr=" MACSTR, MAC2STR(peer_addr));
        else
-               snprintf(cmd, sizeof(cmd), WS_CMD_WPS_PIN MACSTR " %s", MAC2STR(peer_addr), pin);
+               g_snprintf(cmd, sizeof(cmd), WS_CMD_WPS_PIN MACSTR " %s", MAC2STR(peer_addr), pin);
 
        res = _ws_send_cmd(sock->ctrl_sock, cmd,reply, sizeof(reply));
        if (res < 0) {
@@ -3526,10 +3565,10 @@ int ws_enrollee_start(unsigned char *peer_addr, int wps_mode, const char *pin)
        }
 
        if (wps_mode == WFD_OEM_WPS_MODE_PBC)
-               snprintf(cmd, sizeof(cmd), WS_CMD_WPS_ENROLLEE MACSTR "%s",
+               g_snprintf(cmd, sizeof(cmd), WS_CMD_WPS_ENROLLEE MACSTR "%s",
                                        MAC2STR(peer_addr), _ws_wps_to_txt(wps_mode));
        else
-               snprintf(cmd, sizeof(cmd), WS_CMD_WPS_ENROLLEE MACSTR " %s%s",
+               g_snprintf(cmd, sizeof(cmd), WS_CMD_WPS_ENROLLEE MACSTR " %s%s",
                                        MAC2STR(peer_addr), pin, _ws_wps_to_txt(wps_mode));
 
        res = _ws_send_cmd(sock->ctrl_sock, cmd,reply, sizeof(reply));
@@ -3607,7 +3646,7 @@ int ws_set_dev_name(char *dev_name)
                return -1;
        }
 
-       snprintf(cmd, sizeof(cmd), WS_CMD_SET "device_name %s", dev_name);
+       g_snprintf(cmd, sizeof(cmd), WS_CMD_SET "device_name %s", dev_name);
        res = _ws_send_cmd(sock->ctrl_sock, cmd, (char*) reply, sizeof(reply));
        if (res < 0) {
                WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -3689,7 +3728,7 @@ int ws_get_go_intent(int *go_intent)
                return -1;
        }
 
-       snprintf(cmd, sizeof(cmd), WS_CMD_GET "p2p_go_intent");
+       g_snprintf(cmd, sizeof(cmd), WS_CMD_GET "p2p_go_intent");
        res = _ws_send_cmd(sock->ctrl_sock, cmd, (char*) reply, sizeof(reply));
        if (res < 0) {
                WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -3724,7 +3763,7 @@ int ws_set_go_intent(int go_intent)
                return -1;
        }
 
-       snprintf(cmd, sizeof(cmd), WS_CMD_SET "p2p_go_intent %d", go_intent);
+       g_snprintf(cmd, sizeof(cmd), WS_CMD_SET "p2p_go_intent %d", go_intent);
 
        res = _ws_send_cmd(sock->ctrl_sock, cmd, (char*) reply, sizeof(reply));
        if (res < 0) {
@@ -3757,7 +3796,7 @@ int ws_set_country(char *ccode)
                return -1;
        }
 
-       snprintf(cmd, sizeof(cmd), WS_CMD_SET "country %s", ccode);
+       g_snprintf(cmd, sizeof(cmd), WS_CMD_SET "country %s", ccode);
 
        res = _ws_send_cmd(sock->ctrl_sock, cmd, (char*) reply, sizeof(reply));
        if (res < 0) {
@@ -3796,7 +3835,7 @@ int _parsing_networks(char* buf, ws_network_info_s networks[], int *network_cnt)
                res = _extract_word(ptr, &tmp_str);
                if (res > 0) {
                        networks[count].network_id = atoi(tmp_str);
-                       free(tmp_str);
+                       g_free(tmp_str);
                        tmp_str = NULL;
                        ptr += res;
                }
@@ -3814,7 +3853,7 @@ int _parsing_networks(char* buf, ws_network_info_s networks[], int *network_cnt)
                res = _extract_word(ptr, &tmp_str);
                if (res > 0) {
                        _ws_txt_to_mac(tmp_str, networks[count].bssid);
-                       free(tmp_str);
+                       g_free(tmp_str);
                        tmp_str = NULL;
                        ptr += res;
                }
@@ -3830,7 +3869,7 @@ int _parsing_networks(char* buf, ws_network_info_s networks[], int *network_cnt)
                                networks[count].flags |= WFD_OEM_NETFLAG_TEMP_DISABLED;
                        if (strstr(tmp_str, "P2P-PERSISTENT"))
                                networks[count].flags |= WFD_OEM_NETFLAG_P2P_PERSISTENT;
-                       free(tmp_str);
+                       g_free(tmp_str);
                        tmp_str = NULL;
                        ptr += res;
                }
@@ -3894,7 +3933,20 @@ int ws_get_persistent_groups(wfd_oem_persistent_group_s **groups, int *group_cou
                return -1;
        }
 
-       wfd_persistent_groups = (wfd_oem_persistent_group_s*) calloc(1, cnt * sizeof(wfd_oem_persistent_group_s));
+       if(cnt == 0) {
+               *group_count = cnt;
+               *groups = wfd_persistent_groups;
+
+               __WDP_LOG_FUNC_EXIT__;
+               return 0;
+       }
+
+       wfd_persistent_groups = (wfd_oem_persistent_group_s*) g_try_malloc0(cnt * sizeof(wfd_oem_persistent_group_s));
+       if (wfd_persistent_groups == NULL) {
+               WDP_LOGE("Failed to allocate memory for wfd_persistent_groups ");
+               return -1;
+       }
+
        for(i = 0; i < cnt; i++) {
                WDP_LOGD("----persistent group [%d]----", i);
                WDP_LOGD("network_id=%d", networks[i].network_id);
@@ -3903,7 +3955,7 @@ int ws_get_persistent_groups(wfd_oem_persistent_group_s **groups, int *group_cou
                WDP_LOGD("flags=%x", networks[i].flags);
 
                wfd_persistent_groups[i].network_id = networks[i].network_id;
-               strncpy(wfd_persistent_groups[i].ssid, networks[i].ssid, WS_SSID_LEN);
+               g_strlcpy(wfd_persistent_groups[i].ssid, networks[i].ssid, OEM_DEV_NAME_LEN + 1);
                wfd_persistent_groups[i].ssid[WS_SSID_LEN] = '\0';
                memcpy(wfd_persistent_groups[i].go_mac_address, networks[i].bssid, WS_MACADDR_LEN);
        }
@@ -3969,7 +4021,7 @@ int ws_remove_persistent_group(char *ssid, unsigned char *bssid)
                        memset(cmd, 0x0, sizeof(cmd));
                        memset(reply, 0x0, sizeof(reply));
 
-                       snprintf(cmd, sizeof(cmd), WS_CMD_REMOVE_NETWORK " %d", networks[i].network_id);
+                       g_snprintf(cmd, sizeof(cmd), WS_CMD_REMOVE_NETWORK " %d", networks[i].network_id);
                        res = _ws_send_cmd(sock->ctrl_sock, cmd, (char*) reply, sizeof(reply));
                        if (res < 0) {
                                WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -4010,7 +4062,7 @@ int ws_set_persistent_reconnect(unsigned char *bssid, int reconnect)
                return -1;
        }
 
-       snprintf(cmd, sizeof(cmd), WS_CMD_SET "persistent_reconnect %d", reconnect);
+       g_snprintf(cmd, sizeof(cmd), WS_CMD_SET "persistent_reconnect %d", reconnect);
        res = _ws_send_cmd(sock->ctrl_sock, cmd, (char*) reply, sizeof(reply));
        if (res < 0) {
                WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -4050,7 +4102,11 @@ int ws_start_service_discovery(unsigned char *mac_addr, int service_type)
        memset(reply, 0x00, WS_REPLY_LEN);
 
        query[1] += OEM_SERVICE_TYPE_LEN /2;
-       service = (wfd_oem_service_s*) calloc(1, sizeof(wfd_oem_service_s));
+       service = (wfd_oem_service_s*) g_try_malloc0(sizeof(wfd_oem_service_s));
+       if (!service) {
+               WDP_LOGE("Failed to allocate memory for service");
+               return -1;
+       }
        if (!service) {
                WDP_LOGE("Failed to allocate memory for service");
                return -1;
@@ -4058,44 +4114,38 @@ int ws_start_service_discovery(unsigned char *mac_addr, int service_type)
 
        if (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
                mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0) {
-               snprintf(mac_str, OEM_MACSTR_LEN , "%s", SERV_BROADCAST_ADDRESS);
+               g_snprintf(mac_str, OEM_MACSTR_LEN , "%s", SERV_BROADCAST_ADDRESS);
        } else {
-               snprintf(mac_str, OEM_MACSTR_LEN, MACSTR, MAC2STR(mac_addr));
+               g_snprintf(mac_str, OEM_MACSTR_LEN, MACSTR, MAC2STR(mac_addr));
        }
 
        switch(service_type) {
                case WFD_OEM_SERVICE_TYPE_ALL:
-                       snprintf(cmd, sizeof(cmd), WS_CMD_SERV_DISC_REQ " %s %s", mac_str, SERV_DISC_REQ_ALL);
-                       strncpy(service->service_type, SERV_DISC_REQ_ALL, OEM_SERVICE_TYPE_LEN);
-                       service->service_type[OEM_SERVICE_TYPE_LEN] = '\0';
+                       g_snprintf(cmd, sizeof(cmd), WS_CMD_SERV_DISC_REQ " %s %s", mac_str, SERV_DISC_REQ_ALL);
+                       g_strlcpy(service->service_type, SERV_DISC_REQ_ALL, OEM_SERVICE_TYPE_LEN + 1);
                break;
                case WFD_OEM_SERVICE_TYPE_BONJOUR:
-                       snprintf(cmd, sizeof(cmd), WS_CMD_SERV_DISC_REQ " %s %s", mac_str, SERV_DISC_REQ_BONJOUR);
-                       strncpy(service->service_type, SERV_DISC_REQ_BONJOUR, OEM_SERVICE_TYPE_LEN);
-                       service->service_type[OEM_SERVICE_TYPE_LEN] = '\0';
+                       g_snprintf(cmd, sizeof(cmd), WS_CMD_SERV_DISC_REQ " %s %s", mac_str, SERV_DISC_REQ_BONJOUR);
+                       g_strlcpy(service->service_type, SERV_DISC_REQ_BONJOUR, OEM_SERVICE_TYPE_LEN + 1);
                break;
                case WFD_OEM_SERVICE_TYPE_UPNP:
-                       snprintf(cmd, sizeof(cmd), WS_CMD_SERV_DISC_REQ " %s %s", mac_str, SERV_DISC_REQ_UPNP);
-                       strncpy(service->service_type, SERV_DISC_REQ_UPNP, OEM_SERVICE_TYPE_LEN);
-                       service->service_type[OEM_SERVICE_TYPE_LEN] = '\0';
+                       g_snprintf(cmd, sizeof(cmd), WS_CMD_SERV_DISC_REQ " %s %s", mac_str, SERV_DISC_REQ_UPNP);
+                       g_strlcpy(service->service_type, SERV_DISC_REQ_UPNP, OEM_SERVICE_TYPE_LEN + 1);
                break;
                case WFD_OEM_SERVICE_TYPE_BT_ADDR:
                        strncat(query, SERVICE_TYPE_BT_ADDR, OEM_SERVICE_TYPE_LEN);
-                       snprintf(cmd, sizeof(cmd), WS_CMD_SERV_DISC_REQ " %s %s", mac_str, query);
-                       strncpy(service->service_type, SERVICE_TYPE_BT_ADDR, OEM_SERVICE_TYPE_LEN);
-                       service->service_type[OEM_SERVICE_TYPE_LEN] = '\0';
+                       g_snprintf(cmd, sizeof(cmd), WS_CMD_SERV_DISC_REQ " %s %s", mac_str, query);
+                       g_strlcpy(service->service_type, SERVICE_TYPE_BT_ADDR, OEM_SERVICE_TYPE_LEN + 1);
                        break;
                case WFD_OEM_SERVICE_TYPE_CONTACT_INFO:
                        strncat(query, SERVICE_TYPE_CONTACT_INFO, OEM_SERVICE_TYPE_LEN);
-                       snprintf(cmd, sizeof(cmd), WS_CMD_SERV_DISC_REQ " %s %s", mac_str, query);
-                       strncpy(service->service_type, SERVICE_TYPE_CONTACT_INFO, OEM_SERVICE_TYPE_LEN);
-                       service->service_type[OEM_SERVICE_TYPE_LEN] = '\0';
+                       g_snprintf(cmd, sizeof(cmd), WS_CMD_SERV_DISC_REQ " %s %s", mac_str, query);
+                       g_strlcpy(service->service_type, SERVICE_TYPE_CONTACT_INFO, OEM_SERVICE_TYPE_LEN + 1);
                        break;
                default:
                        WDP_LOGE("Invalid Service type");
                        __WDP_LOG_FUNC_EXIT__;
-                       if (service)
-                               free(service);
+                       g_free(service);
                        return -1;
        }
 
@@ -4103,32 +4153,27 @@ int ws_start_service_discovery(unsigned char *mac_addr, int service_type)
        if (res < 0) {
                WDP_LOGE("Failed to send command to wpa_supplicant");
                __WDP_LOG_FUNC_EXIT__;
-               if (service)
-                       free(service);
+               g_free(service);
                return -1;
        }
 
        if (strstr(reply, "FAIL")) {
                WDP_LOGE("Failed to start service discovery");
                __WDP_LOG_FUNC_EXIT__;
-               if (service)
-                       free(service);
+               g_free(service);
                return -1;
        }
        WDP_LOGD("Succeeded to start service discovery");
 
-       strncpy(service->dev_addr, mac_str, OEM_MACSTR_LEN - 1);
-       service->dev_addr[OEM_MACSTR_LEN - 1] = '\0';
+       g_strlcpy(service->dev_addr, mac_str, OEM_MACSTR_LEN);
        WDP_LOGD("query id :[0x%s]",reply);
-       strncpy(service->query_id, reply, OEM_QUERY_ID_LEN);
-       service->query_id[OEM_QUERY_ID_LEN] = '\0';
+       g_strlcpy(service->query_id, reply, OEM_QUERY_ID_LEN + 1);
 
        res = _check_service_query_exists(service);
-       if(res) {
-               free(service);
-       } else {
+       if(res)
+               g_free(service);
+       else
                service_list = g_list_append(service_list, service);
-       }
 
        __WDP_LOG_FUNC_EXIT__;
        return 0;
@@ -4156,26 +4201,26 @@ int ws_cancel_service_discovery(unsigned char *mac_addr, int service_type)
 
        if (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
                mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0) {
-               snprintf(mac_str, OEM_MACSTR_LEN , "%s", SERV_BROADCAST_ADDRESS);
+               g_snprintf(mac_str, OEM_MACSTR_LEN , "%s", SERV_BROADCAST_ADDRESS);
        } else {
-               snprintf(mac_str, OEM_MACSTR_LEN, MACSTR, MAC2STR(mac_addr));
+               g_snprintf(mac_str, OEM_MACSTR_LEN, MACSTR, MAC2STR(mac_addr));
        }
 
        switch(service_type) {
                case WFD_OEM_SERVICE_TYPE_ALL:
-                       strncpy(s_type, SERV_DISC_REQ_ALL, OEM_SERVICE_TYPE_LEN);
+                       g_strlcpy(s_type, SERV_DISC_REQ_ALL, OEM_SERVICE_TYPE_LEN + 1);
                break;
                case WFD_OEM_SERVICE_TYPE_BONJOUR:
-                       strncpy(s_type, SERV_DISC_REQ_BONJOUR, OEM_SERVICE_TYPE_LEN);
+                       g_strlcpy(s_type, SERV_DISC_REQ_BONJOUR, OEM_SERVICE_TYPE_LEN + 1);
                break;
                case WFD_OEM_SERVICE_TYPE_UPNP:
-                       strncpy(s_type, SERV_DISC_REQ_UPNP, OEM_SERVICE_TYPE_LEN);
+                       g_strlcpy(s_type, SERV_DISC_REQ_UPNP, OEM_SERVICE_TYPE_LEN + 1);
                break;
                case WFD_OEM_SERVICE_TYPE_BT_ADDR:
-                       strncpy(s_type, SERVICE_TYPE_BT_ADDR, OEM_SERVICE_TYPE_LEN);
+                       g_strlcpy(s_type, SERVICE_TYPE_BT_ADDR, OEM_SERVICE_TYPE_LEN + 1);
                        break;
                case WFD_OEM_SERVICE_TYPE_CONTACT_INFO:
-                       strncpy(s_type, SERVICE_TYPE_CONTACT_INFO, OEM_SERVICE_TYPE_LEN);
+                       g_strlcpy(s_type, SERVICE_TYPE_CONTACT_INFO, OEM_SERVICE_TYPE_LEN + 1);
                        break;
                default:
                        __WDP_LOG_FUNC_EXIT__;
@@ -4190,7 +4235,7 @@ int ws_cancel_service_discovery(unsigned char *mac_addr, int service_type)
        if (NULL == data)
                return -1;
 
-       snprintf(cmd, sizeof(cmd), WS_CMD_SERV_DISC_CANCEL " %s", query_id);
+       g_snprintf(cmd, sizeof(cmd), WS_CMD_SERV_DISC_CANCEL " %s", query_id);
        res = _ws_send_cmd(sock->ctrl_sock, cmd, (char*) reply, sizeof(reply));
        if (res < 0) {
                WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -4206,7 +4251,7 @@ int ws_cancel_service_discovery(unsigned char *mac_addr, int service_type)
        WDP_LOGD("Succeeded to cancel service discovery");
 
        service_list = g_list_remove(service_list, data);
-       free(data);
+       g_free(data);
 
        __WDP_LOG_FUNC_EXIT__;
        return 0;
@@ -4281,12 +4326,12 @@ int _convert_bonjour_to_hex(char *query, char *rdata, char **hex)
        strncat(hex_value, "c027", 4);
 
        tot_len = strlen(hex_key) + strlen(hex_value);
-       result_str = (char*) calloc(1, tot_len+2);
+       result_str = (char*) g_try_malloc0(tot_len+2);
        if (!result_str) {
                WDP_LOGE("Failed to allocate memory for result string");
                return -1;
        }
-       snprintf(result_str, tot_len+2, "%s %s", hex_key, hex_value);
+       g_snprintf(result_str, tot_len+2, "%s %s", hex_key, hex_value);
 
        *hex = result_str;
 
@@ -4323,7 +4368,7 @@ int ws_serv_add(wfd_oem_new_service_s *service)
                        }
 
                        WDP_LOGD("Converted Hexadecimal string [%s]", hex);
-                       snprintf(cmd, sizeof(cmd), WS_CMD_SERVICE_ADD " bonjour %s", hex);
+                       g_snprintf(cmd, sizeof(cmd), WS_CMD_SERVICE_ADD " bonjour %s", hex);
                        g_free(hex);
 
                }
@@ -4332,7 +4377,7 @@ int ws_serv_add(wfd_oem_new_service_s *service)
                {
                        WDP_LOGD("Service type: WFD_OEM_SERVICE_TYPE_UPNP");
 
-                       snprintf(cmd, sizeof(cmd), WS_CMD_SERVICE_ADD " upnp %s %s",
+                       g_snprintf(cmd, sizeof(cmd), WS_CMD_SERVICE_ADD " upnp %s %s",
                                        service->data.upnp.version, service->data.upnp.service);
                }
                break;
@@ -4386,7 +4431,7 @@ int ws_serv_del(wfd_oem_new_service_s *service)
                        }
 
                        WDP_LOGD("Converted Hexadecimal string [%s]", hex_key);
-                       snprintf(cmd, sizeof(cmd), WS_CMD_SERVICE_DEL " bonjour %s", hex_key);
+                       g_snprintf(cmd, sizeof(cmd), WS_CMD_SERVICE_DEL " bonjour %s", hex_key);
                        g_free(hex_key);
                }
                break;
@@ -4394,7 +4439,7 @@ int ws_serv_del(wfd_oem_new_service_s *service)
                {
                        WDP_LOGD("Service type: WFD_OEM_SERVICE_TYPE_UPNP");
 
-                       snprintf(cmd, sizeof(cmd), WS_CMD_SERVICE_DEL " upnp %s %s",
+                       g_snprintf(cmd, sizeof(cmd), WS_CMD_SERVICE_DEL " upnp %s %s",
                                        service->data.upnp.version, service->data.upnp.service);
                }
                break;
@@ -4445,7 +4490,7 @@ int ws_miracast_init(int enable)
                return -1;
        }
 
-       snprintf(cmd, sizeof(cmd), WS_CMD_SET "wifi_display %d", enable);
+       g_snprintf(cmd, sizeof(cmd), WS_CMD_SET "wifi_display %d", enable);
 
        res = _ws_send_cmd(sock->ctrl_sock, cmd, (char*) reply, sizeof(reply));
        if (res < 0) {
@@ -4466,7 +4511,7 @@ int ws_miracast_init(int enable)
                memset(cmd, 0x0, 80);
                memset(reply, 0x0, WS_REPLY_LEN);
 
-               snprintf(cmd, sizeof(cmd), WS_CMD_SUBELEM_SET "%d %04x%04x%04x%04x",
+               g_snprintf(cmd, sizeof(cmd), WS_CMD_SUBELEM_SET "%d %04x%04x%04x%04x",
                                                                WFD_SUBELM_ID_DEV_INFO, length, dev_info, ctrl_port, max_tput);
                res = _ws_send_cmd(sock->ctrl_sock, cmd, (char*) reply, sizeof(reply));
                if (res < 0) {
@@ -4506,7 +4551,7 @@ int ws_miracast_init(int enable)
                memset(cmd, 0x0, 80);
                memset(reply, 0x0, WS_REPLY_LEN);
 
-               snprintf(cmd, sizeof(cmd), WS_CMD_SUBELEM_SET "%d %04x%02x",
+               g_snprintf(cmd, sizeof(cmd), WS_CMD_SUBELEM_SET "%d %04x%02x",
                                                                WFD_SUBELM_ID_CUPLED_SYNC_INFO, 0x01, cpled_sink_status);
                res = _ws_send_cmd(sock->ctrl_sock, cmd, (char*) reply, sizeof(reply));
                if (res < 0) {
@@ -4527,7 +4572,7 @@ int ws_miracast_init(int enable)
                memset(cmd, 0x0, 80);
                memset(reply, 0x0, WS_REPLY_LEN);
 
-               snprintf(cmd, sizeof(cmd), WS_CMD_SUBELEM_SET "%d %04x%04x",
+               g_snprintf(cmd, sizeof(cmd), WS_CMD_SUBELEM_SET "%d %04x%04x",
                                                                WFD_SUBELM_ID_EXT_CAPAB, 0x02, 0x00);
                res = _ws_send_cmd(sock->ctrl_sock, cmd, (char*) reply, sizeof(reply));
                if (res < 0) {
@@ -4573,7 +4618,7 @@ int ws_set_display(wfd_oem_display_s *wifi_display)
        device_info+= (wifi_display->hdcp_support)<<8;
        device_info+= (wifi_display->availablity)<<4;                                           //for availability bit
 
-       snprintf(cmd, sizeof(cmd), WS_CMD_SUBELEM_SET "%d %04x%04x%04x%04x",
+       g_snprintf(cmd, sizeof(cmd), WS_CMD_SUBELEM_SET "%d %04x%04x%04x%04x",
                                                        WFD_SUBELM_ID_DEV_INFO, WFD_SUBELEM_LEN_DEV_INFO,
                                                        device_info, wifi_display->port, wifi_display->max_tput);
 
index a43caa4..f0b0fb8 100755 (executable)
@@ -168,8 +168,8 @@ char *wfd_server_print_cmd(wifi_direct_cmd_e cmd)
                return "WIFI_DIRECT_CMD_ACTIVATE_PERSISTENT_GROUP";
        case WIFI_DIRECT_CMD_DEACTIVATE_PERSISTENT_GROUP:
                return "WIFI_DIRECT_CMD_DEACTIVATE_PERSISTENT_GROUP";
-       case WIFI_DIRECT_CMD_IS_PERSISTENT_GROUP:
-               return "WIFI_DIRECT_CMD_IS_PERSISTENT_GROUP";
+       case WIFI_DIRECT_CMD_IS_PERSISTENT_GROUP_ACTIVATED:
+               return "WIFI_DIRECT_CMD_IS_PERSISTENT_GROUP_ACTIVATED";
        case WIFI_DIRECT_CMD_GET_PERSISTENT_GROUP_INFO:
                return "WIFI_DIRECT_CMD_GET_PERSISTENT_GROUP_INFO";
        case WIFI_DIRECT_CMD_REMOVE_PERSISTENT_GROUP:
@@ -477,7 +477,7 @@ Ignore the check for now*/
                GIOChannel *gio = NULL;
                gio = g_io_channel_unix_new(sock);
                client->gsource_id = g_io_add_watch(gio, G_IO_IN | G_IO_ERR | G_IO_HUP,
-                                                       (GIOFunc) wfd_client_process_request, (gpointer) (void *)(intptr_t)sock);
+                                                       (GIOFunc) wfd_client_process_request, (gpointer)(void *)(intptr_t)sock);
                g_io_channel_unref(gio);
 
                manager->clients = g_list_prepend(manager->clients, (gpointer) client);
@@ -578,7 +578,7 @@ static int _wfd_deregister_client(void *data, int client_id)
        if (client->ssock >= SOCK_FD_MIN)
                close(client->ssock);
        client->ssock = -1;
-       g_idle_add((GSourceFunc) _wfd_remove_event_source, (gpointer) (void *)(intptr_t)client->gsource_id);
+       g_idle_add((GSourceFunc) _wfd_remove_event_source, (gpointer)(void *)(intptr_t) client->gsource_id);
        client->gsource_id = 0;
 
        g_free(client);
@@ -779,6 +779,7 @@ static int _wfd_check_client_privilege(int client_sock, int cmd)
        case WIFI_DIRECT_CMD_DESTROY_GROUP:
        case WIFI_DIRECT_CMD_ACTIVATE_PERSISTENT_GROUP:
        case WIFI_DIRECT_CMD_DEACTIVATE_PERSISTENT_GROUP:
+       case WIFI_DIRECT_CMD_IS_PERSISTENT_GROUP_ACTIVATED:
        case WIFI_DIRECT_CMD_REMOVE_PERSISTENT_GROUP:
        case WIFI_DIRECT_CMD_SET_GO_INTENT:
        case WIFI_DIRECT_CMD_GENERATE_WPS_PIN:
@@ -839,7 +840,6 @@ static int _wfd_check_client_privilege(int client_sock, int cmd)
        case WIFI_DIRECT_CMD_IS_GROUPOWNER:
        case WIFI_DIRECT_CMD_IS_AUTONOMOUS_GROUP:
        case WIFI_DIRECT_CMD_IS_AUTOCONNECTION_MODE:
-       case WIFI_DIRECT_CMD_IS_PERSISTENT_GROUP:
        case WIFI_DIRECT_CMD_GET_PEER_INFO:
        case WIFI_DIRECT_CMD_GET_PASSPHRASE:
 #ifdef TIZEN_FEATURE_WIFI_DISPLAY
@@ -1418,7 +1418,7 @@ static gboolean wfd_client_process_request(GIOChannel *source,
                                rsp.result = WIFI_DIRECT_ERROR_OPERATION_FAILED;
                        }
 
-                       memset(manager->local->passphrase, 0x0, PASSPHRASE_LEN);
+                       memset(manager->local->passphrase, 0x0, PASSPHRASE_LEN_MAX + 1);
                }
                break;
        case WIFI_DIRECT_CMD_DESTROY_GROUP:
@@ -1453,28 +1453,18 @@ static gboolean wfd_client_process_request(GIOChannel *source,
                {
                        wfd_device_s *local = manager->local;
                        rsp.param1 = local->dev_role == WFD_DEV_ROLE_GO;
+                       WDS_LOGI("Is group owner : [%s]", rsp.param1 ? "Yes" : "No");
                }
                break;
        case WIFI_DIRECT_CMD_IS_AUTONOMOUS_GROUP:
                {
-                       wfd_group_s *group = manager->group;
-                       if (!group) {
-                               WDS_LOGE("Group not exist");
-                               rsp.result = WIFI_DIRECT_ERROR_NOT_PERMITTED;
-                               break;
-                       }
-                       rsp.param1 = group->flags & WFD_GROUP_FLAG_AUTONOMOUS;
-               }
-               break;
-       case WIFI_DIRECT_CMD_IS_PERSISTENT_GROUP:
-               {
-                       wfd_group_s *group = manager->group;
-                       if (!group) {
-                               WDS_LOGE("Group not exist");
+                       if ((rsp.param1 = wfd_group_is_autonomous(manager->group)) < 0) {
+                               rsp.param1 = FALSE;
                                rsp.result = WIFI_DIRECT_ERROR_NOT_PERMITTED;
                                break;
                        }
-                       rsp.param1 = group->flags & WFD_GROUP_FLAG_PERSISTENT;
+
+                       WDS_LOGI("Is autonomous group : [%s]", rsp.param1 ? "Yes" : "No");
                }
                break;
        case WIFI_DIRECT_CMD_GET_OPERATING_CHANNEL:
@@ -1524,6 +1514,12 @@ static gboolean wfd_client_process_request(GIOChannel *source,
                        manager->local->group_flags &= ~(WFD_GROUP_FLAG_PERSISTENT);
                }
                break;
+       case WIFI_DIRECT_CMD_IS_PERSISTENT_GROUP_ACTIVATED:
+               {
+                       rsp.param1 = ((manager->local->group_flags & WFD_GROUP_FLAG_PERSISTENT) == WFD_GROUP_FLAG_PERSISTENT);
+                       WDS_LOGI("Is persistent group : [%s]", rsp.param1 ? "Yes" : "No");
+               }
+               break;
        case WIFI_DIRECT_CMD_REMOVE_PERSISTENT_GROUP:   // group
                {
                        wfd_persistent_group_info_s persistent_group;
@@ -1605,6 +1601,7 @@ static gboolean wfd_client_process_request(GIOChannel *source,
                        rsp.result = WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
                g_snprintf(rsp.param2, IPSTR_LEN, IPSTR, IP2STR(ip_addr));
+               WDS_LOGI("IP addr : [%s]", rsp.param2);
                break;
        case WIFI_DIRECT_CMD_GET_GO_INTENT:     // manager (sync)
                res = wfd_manager_get_go_intent(&rsp.param1);
@@ -1649,11 +1646,13 @@ static gboolean wfd_client_process_request(GIOChannel *source,
                }
                break;
        case WIFI_DIRECT_CMD_IS_DISCOVERABLE:
-               if (manager->state == WIFI_DIRECT_STATE_DISCOVERING
-                               || wfd_group_is_autonomous(manager->group) == 1)
+               if (manager->state == WIFI_DIRECT_STATE_DISCOVERING ||
+                               wfd_group_is_autonomous(manager->group) == TRUE)
                        rsp.param1 = TRUE;
                else
                        rsp.param1 = FALSE;
+
+               WDS_LOGI("Is discoverable : [%s]", rsp.param1 ? "Yes" : "No");
                break;
        case WIFI_DIRECT_CMD_GET_SUPPORTED_WPS_MODE:    // manager (sync)
                res = wfd_local_get_supported_wps_mode(&rsp.param1);
@@ -1762,16 +1761,18 @@ static gboolean wfd_client_process_request(GIOChannel *source,
                break;
        case WIFI_DIRECT_CMD_SET_PASSPHRASE:
                {
-                       char passphrase[PASSPHRASE_LEN + 1] = {0,};
+                       char passphrase[PASSPHRASE_LEN_MAX + 1] = {0,};
+                       int passphrase_len = 0;
                        wfd_group_s *group = manager->group;
+
                        if (group) {
                                WDS_LOGE("Group already exists");
                                rsp.result = WIFI_DIRECT_ERROR_NOT_PERMITTED;
-                               _wfd_read_from_client(sock, passphrase, PASSPHRASE_LEN);
+                               _wfd_read_from_client(sock, passphrase, PASSPHRASE_LEN_MAX + 1);
                                break;
                        }
 
-                       res = _wfd_read_from_client(sock, manager->local->passphrase, PASSPHRASE_LEN);
+                       res = _wfd_read_from_client(sock, passphrase, PASSPHRASE_LEN_MAX + 1);
                        if (res == -2) {
                                WDS_LOGE("Client socket Hanged up");
                                _wfd_deregister_client(manager, sock);
@@ -1780,8 +1781,17 @@ static gboolean wfd_client_process_request(GIOChannel *source,
                                WDS_LOGE("Failed to read socket [%d]", sock);
                                return TRUE;
                        }
-                       manager->local->passphrase[PASSPHRASE_LEN] = '\0';
-                       WDS_LOGD("Passphrase string [%s]", manager->local->passphrase);
+                       passphrase[PASSPHRASE_LEN_MAX] = '\0';
+                       passphrase_len = strlen(passphrase);
+
+                       if (passphrase_len < PASSPHRASE_LEN_MIN || passphrase_len > PASSPHRASE_LEN_MAX) {
+                               WDS_LOGE("Passphrase length incorrect [%s]:[%d]", passphrase, passphrase_len);
+                               rsp.result = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+                               break;
+                       }
+
+                       g_strlcpy(manager->local->passphrase, passphrase, PASSPHRASE_LEN_MAX + 1);
+                       WDS_LOGI("Passphrase string [%s]", manager->local->passphrase);
                }
                break;
        case WIFI_DIRECT_CMD_GET_PASSPHRASE:
@@ -1797,8 +1807,8 @@ static gboolean wfd_client_process_request(GIOChannel *source,
                                rsp.result = WIFI_DIRECT_ERROR_NOT_PERMITTED;
                                break;
                        }
-                       g_strlcpy(rsp.param2, group->passphrase, PASSPHRASE_LEN + 1);
-                       WDS_LOGD("group->pass : [%s]", group->passphrase);
+                       g_strlcpy(rsp.param2, group->passphrase, PASSPHRASE_LEN_MAX + 1);
+                       WDS_LOGI("group->pass : [%s]", group->passphrase);
                }
                break;
 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
@@ -1915,7 +1925,8 @@ static gboolean wfd_client_process_request(GIOChannel *source,
 
                        int miracast_enable = req.data.int1;
                        WDS_LOGD("Miracast enable [%d]", miracast_enable);
-
+/* TODO*/
+#if 0
                        res = wfd_oem_miracast_init(manager->oem_ops, miracast_enable);
                        if (res < 0) {
                                WDS_LOGE("Failed to initialize miracast");
@@ -1932,7 +1943,6 @@ static gboolean wfd_client_process_request(GIOChannel *source,
                                } else {
                                        memset(&(manager->local->display), 0x0, sizeof(wfd_display_type_e));
                                }
-#if 0
                                int screen_mirroring_status;
                                if (vconf_get_int(VCONFKEY_SCREEN_MIRRORING_STATE, &screen_mirroring_status) < 0)
                                        WDS_LOGE("Failed to get vconf VCONFKEY_SCREEN_MIRRORING_STATE\n");
@@ -1966,8 +1976,9 @@ static gboolean wfd_client_process_request(GIOChannel *source,
                                                        WDS_LOGE("Failed to get vconf VCONFKEY_SCREEN_MIRRORING_STATE\n");
                                        }
                                }
-#endif
+
                        }
+       #endif
                }
                break;
        case WIFI_DIRECT_CMD_INIT_DISPLAY:
old mode 100644 (file)
new mode 100755 (executable)
index abbc253..01d9d56
@@ -201,7 +201,8 @@ int wfd_process_event(void *user_data, void *data)
 
                res = _wfd_event_update_peer(manager, edata);
                peer = wfd_peer_find_by_dev_addr(manager, event->dev_addr);
-               peer->state = WFD_PEER_STATE_CONNECTING;
+               if (peer)
+                       peer->state = WFD_PEER_STATE_CONNECTING;
 #else /* CTRL_IFACE_DBUS */
                peer = wfd_peer_find_by_dev_addr(manager, event->dev_addr);
                if (!peer) {
@@ -443,8 +444,19 @@ int wfd_process_event(void *user_data, void *data)
                        wfd_client_send_event(manager, &noti);
 #ifdef CTRL_IFACE_DBUS
                        wfd_update_peer(manager, peer);
+                       if (event->ip_addr_peer[3]) {
+                               peer->ip_type = WFD_IP_TYPE_OVER_EAPOL;
+                               memcpy(peer->client_ip_addr, event->ip_addr_peer, IPADDR_LEN);
+                               WDS_LOGE("Peer's client IP [" IPSTR "]", IP2STR((char*) &peer->client_ip_addr));
+                               memcpy(peer->go_ip_addr, manager->local->ip_addr, IPADDR_LEN);
+                               WDS_LOGE("Peer's GO IP [" IPSTR "]", IP2STR((char*) &peer->go_ip_addr));
+                       }
+                       if(peer->ip_type == WFD_IP_TYPE_OVER_EAPOL) {
+                               /*TODO: ODROID Image does not have support libnl-2.0*/
+                               //wfd_util_ip_over_eap_lease(peer);
+                       }
+                       else
 #endif /* CTRL_IFACE_DBUS */
-
                        wfd_util_dhcps_wait_ip_leased(peer);
                        wfd_destroy_session(manager);
                }
@@ -490,7 +502,12 @@ int wfd_process_event(void *user_data, void *data)
                        noti.error = WIFI_DIRECT_ERROR_NONE;
                        g_snprintf(noti.param1, MACSTR_LEN, MACSTR, MAC2STR(peer_addr));
                        /* If there is no member, GO should be destroyed */
+#ifdef TIZEN_TV
+                       /* If GO is Auto GO, then it should not be removed when no member left */
+                       if (!group->member_count && (wfd_group_is_autonomous(group) == FALSE)) {
+#else /* TIZEN_TV */
                        if (!group->member_count) {
+#endif /* TIZEN_TV */
                                wfd_oem_destroy_group(manager->oem_ops, group->ifname);
                                wfd_destroy_group(manager, group->ifname);
                        }
@@ -535,6 +552,7 @@ int wfd_process_event(void *user_data, void *data)
        case WFD_OEM_EVENT_GROUP_CREATED:
        {
                wfd_group_s *group = (wfd_group_s*) manager->group;
+               wfd_session_s *session = (wfd_session_s*)manager->session;
 #ifdef CTRL_IFACE_DBUS
                if(event->dev_role == WFD_DEV_ROLE_GC && !group) {
 
@@ -548,7 +566,7 @@ int wfd_process_event(void *user_data, void *data)
 #endif /* CTRL_IFACE_DBUS */
 
                if (!group) {
-                       if (!manager->session) {
+                       if (!session) {
                                WDS_LOGE("Unexpected Event. Group should be removed(Client)");
                                wfd_oem_destroy_group(manager->oem_ops, event->ifname);
                                break;
@@ -560,7 +578,7 @@ int wfd_process_event(void *user_data, void *data)
                                break;
                        }
                } else {
-                       if (!manager->session && !(group->flags & WFD_GROUP_FLAG_AUTONOMOUS)) {
+                       if (!session && !(group->flags & WFD_GROUP_FLAG_AUTONOMOUS)) {
                                WDS_LOGE("Unexpected Event. Group should be removed(Owner)");
                                wfd_oem_destroy_group(manager->oem_ops, group->ifname);
                                break;
@@ -577,7 +595,12 @@ int wfd_process_event(void *user_data, void *data)
                wifi_direct_client_noti_s noti;
                memset(&noti, 0x0, sizeof(wifi_direct_client_noti_s));
                if (group->role == WFD_DEV_ROLE_GC) {
-#ifndef CTRL_IFACE_DBUS
+#ifdef CTRL_IFACE_DBUS
+                       if(session->peer->ip_type == WFD_IP_TYPE_OVER_EAPOL) {
+                               /*TODO: ODROID Image does not have support libnl-2.0*/
+                               //wfd_util_ip_over_eap_assign(session->peer, event->ifname);
+                               }
+#else /* CTRL_IFACE_DBUS */
                        wfd_destroy_session(manager);
 #endif /* CTRL_IFACE_DBUS */
                        wfd_peer_clear_all(manager);
@@ -654,15 +677,12 @@ int wfd_process_event(void *user_data, void *data)
                snprintf(noti.param1, MACSTR_LEN, MACSTR, MAC2STR(peer_addr));
                wfd_client_send_event(manager, &noti);
 
-               if (manager->local->dev_role == WFD_DEV_ROLE_GO) {
-                       wfd_state_set(manager, WIFI_DIRECT_STATE_GROUP_OWNER);
-                       wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_GROUP_OWNER);
-               } else {
-                       wfd_state_set(manager, WIFI_DIRECT_STATE_ACTIVATED);
-                       wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_ACTIVATED);
-               }
+               wfd_state_set(manager, WIFI_DIRECT_STATE_ACTIVATED);
+               wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_ACTIVATED);
 
+               wfd_destroy_group(manager, GROUP_IFNAME);
                wfd_destroy_session(manager);
+               manager->local->dev_role = WFD_DEV_ROLE_NONE;
        }
        break;
        case WFD_OEM_EVENT_PROV_DISC_FAIL:
@@ -702,8 +722,16 @@ int wfd_process_event(void *user_data, void *data)
                wfd_client_send_event(manager, &noti);
 
                if (manager->local->dev_role == WFD_DEV_ROLE_GO) {
-                       wfd_state_set(manager, WIFI_DIRECT_STATE_GROUP_OWNER);
-                       wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_GROUP_OWNER);
+                       wfd_group_s *group = (wfd_group_s*) manager->group;
+                       if (group && !group->member_count && (wfd_group_is_autonomous(group) == FALSE)) {
+                               wfd_destroy_group(manager, GROUP_IFNAME);
+
+                               wfd_state_set(manager, WIFI_DIRECT_STATE_ACTIVATED);
+                               wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_ACTIVATED);
+                       } else {
+                               wfd_state_set(manager, WIFI_DIRECT_STATE_GROUP_OWNER);
+                               wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_GROUP_OWNER);
+                       }
                } else {
                        wfd_state_set(manager, WIFI_DIRECT_STATE_ACTIVATED);
                        wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_ACTIVATED);
old mode 100644 (file)
new mode 100755 (executable)
index ea92764..a2e5f3b
@@ -49,9 +49,15 @@ wfd_group_s *wfd_create_group(void *data, wfd_oem_event_s *group_info)
        __WDS_LOG_FUNC_ENTER__;
        wfd_group_s *group = NULL;
        wfd_manager_s *manager = (wfd_manager_s*) data;
+
+       if (!manager || !group_info) {
+               WDS_LOGE("Invalid parameter");
+               __WDS_LOG_FUNC_EXIT__;
+               return NULL;
+       }
        wfd_oem_group_data_s *edata = (wfd_oem_group_data_s *)group_info->edata;
 
-       if (!manager || !group_info || !edata) {
+       if (!edata) {
                WDS_LOGE("Invalid parameter");
                __WDS_LOG_FUNC_EXIT__;
                return NULL;
@@ -79,8 +85,8 @@ wfd_group_s *wfd_create_group(void *data, wfd_oem_event_s *group_info)
        group->pending = 0;
 
        g_strlcpy(group->ssid, edata->ssid, DEV_NAME_LEN + 1);
-       g_strlcpy(group->passphrase, edata->pass, PASSPHRASE_LEN +1);
-       memset(manager->local->passphrase, 0x0, PASSPHRASE_LEN +1);
+       g_strlcpy(group->passphrase, edata->pass, PASSPHRASE_LEN_MAX + 1);
+       memset(manager->local->passphrase, 0x0, PASSPHRASE_LEN_MAX + 1);
        group->freq = edata->freq;
 
        manager->group = group;
@@ -132,12 +138,18 @@ int wfd_group_complete(void *data, wfd_oem_event_s *group_info)
 {
        __WDS_LOG_FUNC_ENTER__;
        wfd_manager_s *manager = (wfd_manager_s*) data;
-       wfd_oem_group_data_s *edata = (wfd_oem_group_data_s *)group_info->edata;
        wfd_session_s *session = NULL;
        wfd_group_s *group = NULL;
        wfd_device_s *peer = NULL;
 
-       if (!manager || !group_info || !edata) {
+       if (!manager || !group_info) {
+               WDS_LOGE("Invalid parameter");
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+       wfd_oem_group_data_s *edata = (wfd_oem_group_data_s *)group_info->edata;
+
+       if (!edata) {
                WDS_LOGE("Invalid parameter");
                __WDS_LOG_FUNC_EXIT__;
                return -1;
@@ -161,8 +173,8 @@ int wfd_group_complete(void *data, wfd_oem_event_s *group_info)
        group->pending = 0;
 
        g_strlcpy(group->ssid, edata->ssid, DEV_NAME_LEN + 1);
-       g_strlcpy(group->passphrase, edata->pass, PASSPHRASE_LEN +1);
-       memset(manager->local->passphrase, 0x0, PASSPHRASE_LEN +1);
+       g_strlcpy(group->passphrase, edata->pass, PASSPHRASE_LEN_MAX + 1);
+       memset(manager->local->passphrase, 0x0, PASSPHRASE_LEN_MAX + 1);
        group->freq = edata->freq;
 
        manager->local->dev_role = group_info->dev_role;
@@ -181,11 +193,21 @@ int wfd_group_complete(void *data, wfd_oem_event_s *group_info)
        } else {
 #ifdef CTRL_IFACE_DBUS
                WDS_LOGD("Role is Group Client.complete session and add peer to member");
-               memcpy(peer->intf_addr, group->go_dev_addr, MACADDR_LEN);
-               wfd_group_add_member(group, peer->dev_addr);
-               session->state = SESSION_STATE_COMPLETED;
-               /* memcpy(peer->intf_addr, event->intf_addr, MACADDR_LEN); */
-               peer->state = WFD_PEER_STATE_CONNECTED;
+               if (peer) {
+                       memcpy(peer->intf_addr, group->go_dev_addr, MACADDR_LEN);
+                       wfd_group_add_member(group, peer->dev_addr);
+                       session->state = SESSION_STATE_COMPLETED;
+                       /* memcpy(peer->intf_addr, event->intf_addr, MACADDR_LEN); */
+                       peer->state = WFD_PEER_STATE_CONNECTED;
+                       if(edata->ip_addr[3] && edata->ip_addr_go[3]) {
+                               peer->ip_type = WFD_IP_TYPE_OVER_EAPOL;
+                               memcpy(peer->client_ip_addr, edata->ip_addr, IPADDR_LEN);
+                               WDS_LOGE("Peer's client IP [" IPSTR "]", IP2STR((char*) &peer->client_ip_addr));
+                               memcpy(peer->go_ip_addr, edata->ip_addr_go, IPADDR_LEN);
+                               WDS_LOGE("Peer's GO IP [" IPSTR "]", IP2STR((char*) &peer->go_ip_addr));
+                       }
+               }
+               if(peer->ip_type != WFD_IP_TYPE_OVER_EAPOL)
 #endif /* CTRL_IFACE_DBUS */
                wfd_util_dhcpc_start(peer);
        }
@@ -272,7 +294,7 @@ int wfd_group_is_autonomous(wfd_group_s *group)
        }
 
        __WDS_LOG_FUNC_EXIT__;
-       return group->flags & WFD_GROUP_FLAG_AUTONOMOUS;;
+       return ((group->flags & WFD_GROUP_FLAG_AUTONOMOUS) == WFD_GROUP_FLAG_AUTONOMOUS);
 }
 
 #if 0
old mode 100644 (file)
new mode 100755 (executable)
index 7b54689..f383b72
@@ -506,7 +506,6 @@ int wfd_manager_local_config_set(wfd_manager_s *manager)
 int wfd_manager_activate(wfd_manager_s *manager)
 {
        __WDS_LOG_FUNC_ENTER__;
-       int concurrent = 0;
        int prev_state = 0;
        int res = 0;
 
@@ -522,21 +521,29 @@ int wfd_manager_activate(wfd_manager_s *manager)
 
        wfd_state_get(manager, &prev_state);
        wfd_state_set(manager, WIFI_DIRECT_STATE_ACTIVATING);
-
-#if 0 /* No need to check wifi state. Net-config will check and proceed driver loading */
-       concurrent = wfd_util_check_wifi_state();
-       if (concurrent < 0) {
+#if defined(TIZEN_WLAN_CONCURRENT_ENABLE) && defined(TIZEN_MOBILE)
+       res = wfd_util_check_wifi_state();
+       if (res < 0) {
                WDS_LOGE("Failed to get wifi state");
-               concurrent = 0;
-       }
-#endif
-
-       res = wfd_oem_activate(manager->oem_ops, concurrent);
+               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+       } else if (res == 0) {
+#endif /* TIZEN_WLAN_CONCURRENT_ENABLE && TIZEN_MOBILE */
+       res = wfd_oem_activate(manager->oem_ops, 0);
        if (res < 0) {
                WDS_LOGE("Failed to activate");
                wfd_state_set(manager, prev_state);
                return WIFI_DIRECT_ERROR_OPERATION_FAILED;
        }
+#if defined(TIZEN_WLAN_CONCURRENT_ENABLE) && defined(TIZEN_MOBILE)
+       } else {
+               res = wfd_oem_activate(manager->oem_ops, res);
+               if (res < 0) {
+                       WDS_LOGE("Failed to activate");
+                       wfd_state_set(manager, prev_state);
+                       return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+               }
+       }
+#endif /* TIZEN_WLAN_CONCURRENT_ENABLE && TIZEN_MOBILE */
        WDS_LOGE("Succeeded to activate");
 
        wfd_state_set(manager, WIFI_DIRECT_STATE_ACTIVATED);
@@ -564,7 +571,6 @@ int wfd_manager_activate(wfd_manager_s *manager)
 int wfd_manager_deactivate(wfd_manager_s *manager)
 {
        __WDS_LOG_FUNC_ENTER__;
-       int concurrent = 0;
        int prev_state = 0;
        int res = 0;
 
@@ -581,12 +587,6 @@ int wfd_manager_deactivate(wfd_manager_s *manager)
        wfd_state_get(manager, &prev_state);
        wfd_state_set(manager, WIFI_DIRECT_STATE_DEACTIVATING);
 
-       concurrent = wfd_util_check_wifi_state();
-       if (concurrent < 0) {
-               WDS_LOGE("Failed to get wifi state");
-               concurrent = 0;
-       }
-
 #ifdef TIZEN_FEATURE_WIFI_DISPLAY
        res = wfd_oem_miracast_init(manager->oem_ops, false);
        if (res < 0)
@@ -597,12 +597,31 @@ int wfd_manager_deactivate(wfd_manager_s *manager)
        if (res < 0)
                WDS_LOGE("Failed to destroy group before deactivation");
 
-       res = wfd_oem_deactivate(manager->oem_ops, concurrent);
+#if defined(TIZEN_WLAN_CONCURRENT_ENABLE) && defined(TIZEN_MOBILE)
+       res = wfd_util_check_wifi_state();
        if (res < 0) {
-               WDS_LOGE("Failed to deactivate");
-               wfd_state_set(manager, prev_state);
+               WDS_LOGE("Failed to get wifi state");
                return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+       } else if (res == 0) {
+#endif /* TIZEN_WLAN_CONCURRENT_ENABLE && TIZEN_MOBILE */
+               res = wfd_oem_deactivate(manager->oem_ops, 0);
+               if (res < 0) {
+                       WDS_LOGE("Failed to deactivate");
+                       wfd_state_set(manager, prev_state);
+                       return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+               }
+#if defined(TIZEN_WLAN_CONCURRENT_ENABLE) && defined(TIZEN_MOBILE)
+       } else {
+               // FIXME: We should do something to stop p2p feature of Driver
+               res = wfd_oem_deactivate(manager->oem_ops, res);
+               if (res < 0) {
+                       WDS_LOGE("Failed to deactivate");
+                       wfd_state_set(manager, prev_state);
+                       return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+               }
+               WDS_LOGE("Do not need to deactivate Wi-Fi");
        }
+#endif /* TIZEN_WLAN_CONCURRENT_ENABLE && TIZEN_MOBILE */
        WDS_LOGE("Succeeded to deactivate");
 
        wfd_state_set(manager, WIFI_DIRECT_STATE_DEACTIVATED);
@@ -758,7 +777,7 @@ int wfd_manager_cancel_connection(wfd_manager_s *manager, unsigned char *peer_ad
        group = (wfd_group_s*) manager->group;
        if (group) {
                wfd_group_remove_member(group, peer_addr);
-               if (!group->member_count) {
+               if ((wfd_group_is_autonomous(manager->group) != TRUE) && !group->member_count) {
                        wfd_oem_destroy_group(manager->oem_ops, group->ifname);
                        wfd_destroy_group(manager, group->ifname);
                } else {
old mode 100644 (file)
new mode 100755 (executable)
index 05a9d2d..cd59dcc 100755 (executable)
 #include "wifi-direct-util.h"
 #include "wifi-direct-oem.h"
 #ifdef CTRL_IFACE_DBUS
+#include "wifi-direct-group.h"
 #include "wifi-direct-session.h"
 #endif /* CTRL_IFACE_DBUS */
 
+#ifdef CTRL_IFACE_DBUS
+#include <linux/unistd.h>
+#include <asm/types.h>
+#include <linux/netlink.h>
+#include <linux/rtnetlink.h>
+
+#endif /* CTRL_IFACE_DBUS */
+
 static int _txt_to_mac(char *txt, unsigned char *mac)
 {
        int i = 0;
@@ -351,8 +360,8 @@ int wfd_util_check_wifi_state()
        int wifi_state = 0;
        int res = 0;
 
-       /* vconf key and value (vconf-keys.h)
-#define VCONFKEY_WIFI_STATE "memory/wifi/state"
+/* vconf key and value (vconf-keys.h)
+#define VCONFKEY_WIFI_STATE    "memory/wifi/state"
 enum {
         VCONFKEY_WIFI_OFF = 0x00,
         VCONFKEY_WIFI_UNCONNECTED,
@@ -360,8 +369,7 @@ enum {
         VCONFKEY_WIFI_TRANSFER,
         VCONFKEY_WIFI_STATE_MAX
 };
-        */
-
+*/
        res = vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
        if (res < 0) {
                WDS_LOGE("Failed to get vconf value [%s]", VCONFKEY_WIFI_STATE);
@@ -751,7 +759,7 @@ int wfd_util_dhcps_start()
         * As we are GO so IP should be updated
         * before sending Group Created Event
         */
-       vconf_set_str(VCONFKEY_IFNAME, GROUP_IFNAME     );
+       vconf_set_str(VCONFKEY_IFNAME, GROUP_IFNAME);
        vconf_set_str(VCONFKEY_LOCAL_IP, "192.168.49.1");
        vconf_set_str(VCONFKEY_SUBNET_MASK, "255.255.255.0");
        vconf_set_str(VCONFKEY_GATEWAY, "192.168.49.1");
@@ -966,3 +974,379 @@ int wfd_util_get_local_ip(unsigned char* ip_addr)
        __WDS_LOG_FUNC_EXIT__;
        return 0;
 }
+
+#ifdef CTRL_IFACE_DBUS
+
+/*TODO: ODROID Image does not have support libnl-2.0 */
+#if 0
+static int _wfd_util_set_vconf_for_static_ip(const char *ifname, char *static_ip)
+{
+       __WDS_LOG_FUNC_ENTER__;
+
+       if (!ifname || !static_ip)
+               return -1;
+
+       vconf_set_str(VCONFKEY_IFNAME, ifname);
+       vconf_set_str(VCONFKEY_LOCAL_IP, static_ip);
+       vconf_set_str(VCONFKEY_SUBNET_MASK, "255.255.255.0");
+       vconf_set_str(VCONFKEY_GATEWAY, "192.168.49.1");
+
+       __WDS_LOG_FUNC_EXIT__;
+
+       return 0;
+}
+
+int _wfd_util_set_static_arp(const char *ifname, unsigned char *peer_ip, unsigned char *peer_mac)
+{
+       __WDS_LOG_FUNC_ENTER__;
+
+       struct nl_sock *sock;
+       struct rtnl_neigh *neigh;
+       struct nl_addr *ip_addr;
+       struct nl_addr *mac_addr;
+
+       char ip_str[IPSTR_LEN] = {0, };
+       char mac_str[MACSTR_LEN] = {0, };
+       int if_index = 0;
+       int res = 0;
+
+       if (!ifname || !peer_ip || !peer_mac) {
+               WDS_LOGE("Invalid parameter");
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+       snprintf(ip_str, IPSTR_LEN, IPSTR, IP2STR(peer_ip));
+       snprintf(mac_str, MACSTR_LEN, MACSTR, MAC2STR(peer_mac));
+
+       WDS_LOGE("ifname : [%s] peer ip : [%s] peer mac : [%s]", ifname, ip_str, mac_str);
+
+       /* Get index of interface */
+       if_index = if_nametoindex(ifname);
+       if(if_index < 0) {
+               WDS_LOGE("Failed to get interface index.");
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       sock = nl_socket_alloc();
+       if (!sock) {
+               WDS_LOGE("Failed to create netlink socket.");
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       res = nl_connect(sock, NETLINK_ROUTE);
+       if (res < 0) {
+               WDS_LOGE("Failed to connect netlink socket. [%s]", nl_geterror(res));
+               nl_socket_free(sock);
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       neigh = rtnl_neigh_alloc();
+       if(!neigh) {
+               WDS_LOGE("Failed to create neigh. [%s]");
+               nl_socket_free(sock);
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       if(nl_addr_parse(ip_str, rtnl_neigh_get_family(neigh), &ip_addr) < 0) {
+               WDS_LOGE("Failed to parse ip addr.");
+               nl_socket_free(sock);
+               rtnl_neigh_put(neigh);
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       if(nl_addr_parse(mac_str, AF_UNSPEC, &mac_addr) < 0) {
+               WDS_LOGE("Failed to parse mac addr.");
+               nl_socket_free(sock);
+               rtnl_neigh_put(neigh);
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       rtnl_neigh_set_dst(neigh, ip_addr);
+       rtnl_neigh_set_lladdr(neigh, mac_addr);
+       rtnl_neigh_set_ifindex(neigh, if_index);
+       rtnl_neigh_set_state(neigh, rtnl_neigh_str2state("reachable"));
+
+       res = rtnl_neigh_add(sock, neigh, NLM_F_CREATE);
+       if(res < 0) {
+               WDS_LOGE("Failed to add neigh. [%s]\n", nl_geterror(res));
+       }
+
+       WDS_LOGE("Set static ARP as reachable success!");
+       nl_socket_free(sock);
+       rtnl_neigh_put(neigh);
+       __WDS_LOG_FUNC_EXIT__;
+       return res;
+}
+
+
+static int _wfd_util_static_ip_set(const char *ifname, unsigned char *static_ip)
+{
+       __WDS_LOG_FUNC_ENTER__;
+
+       int res = 0;
+       unsigned char ip_addr[IPADDR_LEN];
+       char ip_str[IPSTR_LEN] = {0, };
+
+       int if_index;
+       int nl_sock = -1;
+       struct sockaddr_nl dst_addr;
+
+       struct {
+               struct nlmsghdr     nh;
+               struct ifaddrmsg    ifa;
+               char            attrbuf[1024];
+       } req;
+       struct rtattr *rta;
+       struct iovec iov;
+       struct msghdr nl_msg;
+
+       if (!ifname || !static_ip) {
+               WDS_LOGE("Invalid parameter");
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       /* Get index of interface */
+       if_index = if_nametoindex(ifname);
+       if(if_index < 0) {
+               WDS_LOGE("Failed to get interface index. [%s]", strerror(errno));
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       WDS_LOGD("Creating a Netlink Socket");
+       nl_sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
+       if (nl_sock < 0) {
+               WDS_LOGE("Failed to create socket. [%s]", strerror(errno));
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       memset(&dst_addr, 0, sizeof(dst_addr));
+       dst_addr.nl_family =  AF_NETLINK;
+       dst_addr.nl_pid = 0;
+
+       memset(&req, 0, sizeof(req));
+       req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg));
+       req.nh.nlmsg_type = RTM_NEWADDR;
+       req.nh.nlmsg_flags = NLM_F_CREATE | NLM_F_EXCL | NLM_F_REQUEST;
+
+       req.ifa.ifa_family = AF_INET;
+       req.ifa.ifa_prefixlen = 24;
+       req.ifa.ifa_flags = IFA_F_PERMANENT;
+       req.ifa.ifa_scope = 0;
+       req.ifa.ifa_index = if_index;
+
+       rta = (struct rtattr *)(req.attrbuf);
+       rta->rta_type = IFA_LOCAL;
+       rta->rta_len = RTA_LENGTH(IPADDR_LEN);
+       memcpy(RTA_DATA(rta), static_ip, IPADDR_LEN);
+       req.nh.nlmsg_len = NLMSG_ALIGN(req.nh.nlmsg_len) + rta->rta_len;
+
+       rta = (struct rtattr *)(req.attrbuf + rta->rta_len);
+       rta->rta_type = IFA_BROADCAST;
+       rta->rta_len = RTA_LENGTH(IPADDR_LEN);
+       memcpy(ip_addr, static_ip, IPADDR_LEN);
+       ip_addr[3] =0xff;
+       memcpy(RTA_DATA(rta), ip_addr, IPADDR_LEN);
+       req.nh.nlmsg_len += rta->rta_len;
+
+       memset(&iov, 0, sizeof(iov));
+       iov.iov_base = &req;
+       iov.iov_len = req.nh.nlmsg_len;
+
+       memset(&nl_msg, 0, sizeof(nl_msg));
+       nl_msg.msg_name = (void *)&dst_addr;
+       nl_msg.msg_namelen = sizeof(dst_addr);
+       nl_msg.msg_iov = &iov;
+       nl_msg.msg_iovlen = 1;
+
+       res = sendmsg(nl_sock, &nl_msg, 0);
+       if (res < 0) {
+               WDS_LOGE("Failed to sendmsg. [%s]", strerror(errno));
+       } else {
+               WDS_LOGD("Succed to sendmsg. [%d]", res);
+       }
+
+       close(nl_sock);
+       WDS_LOGE("Succeeded to set local(client) IP [" IPSTR "] for iface[%s]",
+                               IP2STR(static_ip), ifname);
+
+       snprintf(ip_str, IPSTR_LEN, IPSTR, IP2STR(static_ip));
+       _wfd_util_set_vconf_for_static_ip(ifname, ip_str);
+
+       __WDS_LOG_FUNC_EXIT__;
+       return res;
+}
+
+#ifdef TIZEN_VENDOR_ATH
+int wfd_util_static_ip_unset(const char *ifname)
+{
+       __WDS_LOG_FUNC_ENTER__;
+
+
+       int res = 0;
+       unsigned char ip_addr[IPADDR_LEN];
+       char error_buf[MAX_SIZE_ERROR_BUFFER] = {};
+
+       int if_index;
+       int nl_sock = -1;
+       struct sockaddr_nl dst_addr;
+
+       struct {
+               struct nlmsghdr     nh;
+               struct ifaddrmsg    ifa;
+               char            attrbuf[1024];
+       } req;
+       struct rtattr *rta;
+       struct iovec iov;
+       struct msghdr nl_msg;
+
+       if (!ifname) {
+               WDS_LOGE("Invalid parameter");
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       res = wfd_util_dhcpc_get_ip(ifname, ip_addr, 0);
+       if (res < 0) {
+               WDS_LOGE("Failed to get local IP for interface %s", ifname);
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+       WDS_LOGE("Succeeded to get local(client) IP [" IPSTR "] for iface[%s]",
+                       IP2STR(ip_addr), ifname);
+
+       if_index = if_nametoindex(ifname);
+       if(if_index < 0) {
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+               WDS_LOGE("Failed to get interface index. [%s]", error_buf);
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       WDS_LOGD("Creating a Netlink Socket");
+       nl_sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
+       if (nl_sock < 0) {
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+               WDS_LOGE("Failed to create socket. [%s]", error_buf);
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       WDS_LOGD("Set dst socket address to kernel");
+       memset(&dst_addr, 0, sizeof(dst_addr));
+       dst_addr.nl_family =  AF_NETLINK;
+       dst_addr.nl_pid = 0;
+
+       memset(&req, 0, sizeof(req));
+       req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg));
+       req.nh.nlmsg_type = RTM_DELADDR;
+       req.nh.nlmsg_flags = NLM_F_REQUEST;
+
+       req.ifa.ifa_family = AF_INET;
+       req.ifa.ifa_prefixlen = 32;
+       req.ifa.ifa_flags = IFA_F_PERMANENT;
+       req.ifa.ifa_scope = 0;
+       req.ifa.ifa_index = if_index;
+
+       rta = (struct rtattr *)(req.attrbuf);
+       rta->rta_type = IFA_LOCAL;
+       rta->rta_len = RTA_LENGTH(IPADDR_LEN);
+       memcpy(RTA_DATA(rta), ip_addr, IPADDR_LEN);
+       req.nh.nlmsg_len = NLMSG_ALIGN(req.nh.nlmsg_len) + rta->rta_len;
+
+       memset(&iov, 0, sizeof(iov));
+       iov.iov_base = &req;
+       iov.iov_len = req.nh.nlmsg_len;
+
+       memset(&nl_msg, 0, sizeof(nl_msg));
+       nl_msg.msg_name = (void *)&dst_addr;
+       nl_msg.msg_namelen = sizeof(dst_addr);
+       nl_msg.msg_iov = &iov;
+       nl_msg.msg_iovlen = 1;
+
+       res = sendmsg(nl_sock, &nl_msg, 0);
+       if (res < 0) {
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+               WDS_LOGE("Failed to sendmsg. [%s]", error_buf);
+       } else {
+               WDS_LOGD("Succeed to sendmsg. [%d]", res);
+       }
+
+       close(nl_sock);
+
+       __WDS_LOG_FUNC_EXIT__;
+       return res;
+}
+#endif /* TIZEN_VENDOR_ATH */
+
+
+int wfd_util_ip_over_eap_assign(wfd_device_s *peer, const char *ifname)
+{
+       __WDS_LOG_FUNC_ENTER__;
+       wfd_manager_s *manager = wfd_get_manager();
+       char ip_str[IPSTR_LEN] = {0, };
+       if (!peer) {
+               WDS_LOGE("Invalid paramater");
+               return -1;
+       }
+
+       _wfd_util_static_ip_set(ifname, peer->client_ip_addr);
+       memcpy(peer->ip_addr, peer->go_ip_addr, IPADDR_LEN);
+       _wfd_util_set_static_arp(ifname, peer->ip_addr, peer->intf_addr);
+
+       wfd_destroy_session(manager);
+
+       g_snprintf(ip_str, IPSTR_LEN, IPSTR, IP2STR(peer->ip_addr));
+       _connect_remote_device(ip_str);
+
+       wfd_state_set(manager, WIFI_DIRECT_STATE_CONNECTED);
+       wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_CONNECTED);
+
+       wifi_direct_client_noti_s noti;
+       memset(&noti, 0x0, sizeof(wifi_direct_client_noti_s));
+       noti.event = WIFI_DIRECT_CLI_EVENT_CONNECTION_RSP;
+       noti.error = WIFI_DIRECT_ERROR_NONE;
+       snprintf(noti.param1, MACSTR_LEN, MACSTR, MAC2STR(peer->dev_addr));
+       wfd_client_send_event(manager, &noti);
+
+       __WDS_LOG_FUNC_EXIT__;
+       return 0;
+}
+
+int wfd_util_ip_over_eap_lease(wfd_device_s *peer)
+{
+       __WDS_LOG_FUNC_ENTER__;
+       wfd_manager_s *manager = wfd_get_manager();
+       wfd_group_s *group = (wfd_group_s*)manager->group;
+
+       if (!peer || !group) {
+               WDS_LOGE("Invalid paramater");
+               return -1;
+       }
+
+       memcpy(peer->ip_addr, peer->client_ip_addr, IPADDR_LEN);
+       _wfd_util_set_static_arp(group->ifname, peer->ip_addr, peer->intf_addr);
+
+       wifi_direct_client_noti_s noti;
+       memset(&noti, 0x0, sizeof(wifi_direct_client_noti_s));
+       noti.event = WIFI_DIRECT_CLI_EVENT_IP_LEASED_IND;
+       noti.error = WIFI_DIRECT_ERROR_NONE;
+       snprintf(noti.param1, MACSTR_LEN, MACSTR, MAC2STR(peer->dev_addr));
+       snprintf(noti.param2, IPSTR_LEN, IPSTR, IP2STR(peer->ip_addr));
+       wfd_client_send_event(manager, &noti);
+
+       __WDS_LOG_FUNC_EXIT__;
+       return 0;
+}
+#endif
+
+
+#endif /* CTRL_IFACE_DBUS */