[wifi-direct-manager]Sync with Tizen 2.4 release and update patches 18/51818/2 accepted/tizen/mobile/20151120.070613 accepted/tizen/tv/20151120.070621 accepted/tizen/wearable/20151120.070633 submit/tizen/20151120.002212
authorYu Jiung <jiung.yu@samsung.com>
Mon, 16 Nov 2015 10:01:22 +0000 (19:01 +0900)
committerYu Jiung <jiung.yu@samsung.com>
Mon, 16 Nov 2015 10:08:12 +0000 (19:08 +0900)
Description: This patch also adds below fixes,

1. Clear peer list when group is destroyed
2. Ignore PD request and GO negotiation request when in GC
3. Fix parsing service discovery peer device address
4. Send disconnected event when GC gets the group destroy event
5. Fix some service discovery code for DBus interface
6. Add support for TM1 device

Change-Id: I6c15e0ddf0780e9509b3cac8fe9770b3f6caba2e

21 files changed:
CMakeLists.txt
files/TM1/dhcpd.p2p.conf [new file with mode: 0644]
files/TM1/p2p_supp.conf [new file with mode: 0644]
files/TM1/wifi-direct-dhcp.sh [new file with mode: 0644]
files/common/p2p_supp.sh
files/common/p2p_supplicant [deleted file]
include/wifi-direct-manager.h
include/wifi-direct-service.h
include/wifi-direct-util.h
oem/wifi-direct-oem.h
packaging/wifi-direct-manager.spec
plugin/wpasupplicant/ctrl_iface_dbus/dbus/wfd-plugin-supplicant-dbus.c
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
src/wifi-direct-client.c
src/wifi-direct-event.c
src/wifi-direct-manager.c
src/wifi-direct-service.c
src/wifi-direct-util.c

index 2534a27..75121fb 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 libnl-2.0 capi-appfw-application vconf cynara-client cynara-creds-socket cynara-session ${MDM_REQUIRED_PKGS})
+pkg_check_modules(pkgs REQUIRED capi-network-wifi-direct glib-2.0 gio-2.0 gobject-2.0 dlog libnl-2.0 capi-appfw-application vconf cynara-client cynara-creds-socket cynara-session aul${MDM_REQUIRED_PKGS})
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
@@ -26,10 +26,15 @@ SET(ARCH "${ARCHITECTURE}")
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 ADD_DEFINITIONS("-DUSE_DLOG")
 
+IF(TIZEN_WLAN_BOARD_SPRD)
+       ADD_DEFINITIONS(-DTIZEN_WLAN_BOARD_SPRD)
+ENDIF(TIZEN_WLAN_BOARD_SPRD)
 IF(TIZEN_TETHERING_ENABLE)
        ADD_DEFINITIONS(-DTIZEN_TETHERING_ENABLE)
 ENDIF(TIZEN_TETHERING_ENABLE)
-
+IF(TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT)
+       ADD_DEFINITIONS(-DTIZEN_FEATURE_DEFAULT_CONNECTION_AGENT)
+ENDIF(TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT)
 IF(TIZEN_FEATURE_SERVICE_DISCOVERY)
        ADD_DEFINITIONS(-DTIZEN_FEATURE_SERVICE_DISCOVERY)
 ENDIF(TIZEN_FEATURE_SERVICE_DISCOVERY)
@@ -93,11 +98,18 @@ IF(TIZEN_WIFI_MODULE_BUNDLE)
        INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/bundle/dhcpd-notify.sh DESTINATION bin)
        INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/bundle/wifi-direct-dhcp.sh DESTINATION bin)
 ELSE(TIZEN_WIFI_MODULE_BUNDLE)
+       INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/common/dhcpd-notify.sh DESTINATION bin)
+IF(TIZEN_WLAN_BOARD_SPRD)
+       INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/TM1/p2p_supp.conf DESTINATION etc/wifi-direct)
+       INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/TM1/p2p_supp.conf DESTINATION /opt/etc)
+       INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/TM1/dhcpd.p2p.conf DESTINATION etc/wifi-direct)
+       INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/TM1/wifi-direct-dhcp.sh DESTINATION bin)
+ELSE(TIZEN_WLAN_BOARD_SPRD)
        INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/common/p2p_supp.conf DESTINATION etc/wifi-direct)
        INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/common/p2p_supp.conf DESTINATION /opt/etc)
        INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/common/dhcpd.p2p.conf DESTINATION etc/wifi-direct)
-       INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/common/dhcpd-notify.sh DESTINATION bin)
        INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/common/wifi-direct-dhcp.sh DESTINATION bin)
+ENDIF(TIZEN_WLAN_BOARD_SPRD)
 ENDIF(TIZEN_WIFI_MODULE_BUNDLE)
 
 IF("${ARCH}" MATCHES "^arm.*|.*86.*")
diff --git a/files/TM1/dhcpd.p2p.conf b/files/TM1/dhcpd.p2p.conf
new file mode 100644 (file)
index 0000000..91de9f7
--- /dev/null
@@ -0,0 +1,10 @@
+start           192.168.49.20             #default: 192.168.0.20
+end             192.168.49.40             #default: 192.168.0.254
+interface       p2p0                      #default: wlan0
+max_leases      20                        #default: 254
+notify_file     /usr/bin/dhcpd-notify.sh
+
+option          subnet     255.255.255.0
+option          router     192.168.49.1
+option          lease      864000         #10 days of seconds
+option          broadcast  192.168.49.255
diff --git a/files/TM1/p2p_supp.conf b/files/TM1/p2p_supp.conf
new file mode 100644 (file)
index 0000000..5cd2582
--- /dev/null
@@ -0,0 +1,4 @@
+##### p2p_supplicant configuration file template #####
+update_config=1
+eapol_version=1
+ap_scan=1
diff --git a/files/TM1/wifi-direct-dhcp.sh b/files/TM1/wifi-direct-dhcp.sh
new file mode 100644 (file)
index 0000000..0ba9c9a
--- /dev/null
@@ -0,0 +1,101 @@
+#!/bin/sh
+INTERFACE_NAME="p2p0"
+INTERFACE_PREFIX="p2p"
+TARGET="TM1"
+DEFAULT_IP="192.168.49.1"
+DEFAULT_NET="192.168.49.1/24"
+DEFAULT_BRD="192.168.49.255"
+
+interface=`/sbin/ifconfig|/bin/grep ^${INTERFACE_NAME}|/usr/bin/cut -d" " -f1`
+#interface=`/sbin/ifconfig|/bin/grep ^${INTERFACE_NAME}|/usr/bin/cut -d":" -f1`
+#interface=`/usr/sbin/ip link|/bin/grep ^${INTERFACE_NAME}|/usr/bin/cut -d":" -f2`
+echo "Target is ${TARGET} and interface ${INTERFACE_PREFIX}: ${interface}."
+
+start_dhcp_server()
+{
+       if [ "X${interface}" == "X" ]; then
+               echo "interface(${INTERFACE_PREFIX}) is not up"
+               return 0
+       fi
+
+       /usr/sbin/ip addr add ${DEFAULT_NET} brd ${DEFAULT_BRD} dev ${interface}
+       /usr/sbin/dhcpd /usr/etc/wifi-direct/dhcpd.${INTERFACE_PREFIX}.conf -f &
+
+       route=`/bin/cat /usr/etc/wifi-direct/dhcpd.${INTERFACE_PREFIX}.conf | /bin/grep router | /bin/awk '{print $3}'`
+       if [ -z $route ]; then
+               route="192.168.49.1"
+       fi
+       subnet=`/bin/cat /usr/etc/wifi-direct/dhcpd.${INTERFACE_PREFIX}.conf | /bin/grep subnet | /bin/awk '{print $3}'`
+
+       if [ -z $subnet ]; then
+               subnet="255.255.255.0"
+       fi
+
+       /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_ifname ${interface} -f
+       /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_subnet_mask ${subnet} -f
+       /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_gateway ${route} -f
+       /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_local_ip ${DEFAULT_IP} -f
+}
+
+start_dhcp_client()
+{
+       if [ "X${interface}" == "X" ]; then
+               echo "interface(${INTERFACE_PREFIX}) is not up"
+               return 0
+       fi
+       /usr/bin/dhcp -i $interface -s /usr/etc/wifi-direct/udhcp_script.non-autoip &
+}
+
+
+stop_dhcp()
+{
+       /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_ifname "" -f
+       /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_subnet_mask "" -f
+       /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_gateway "" -f
+       /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/p2p_local_ip "" -f
+       /usr/bin/vconftool set -t string memory/private/wifi_direct_manager/dhcpc_server_ip "0.0.0.0" -f
+
+       /usr/bin/pkill -x dhcp
+       /usr/bin/pkill -x dhcpd
+       /sbin/ifconfig ${interface} 0.0.0.0
+}
+
+is_running()
+{
+       program=$1
+       run=`/bin/ps -eo comm|/bin/grep ${program}`
+       if [ "X${run}" == "X" ]; then
+               echo "${program} is not running"
+       else
+               echo "${program} is already running"
+       fi
+}
+
+status_dhcp()
+{
+       is_running /usr/bin/dhcp
+       is_running /usr/sbin/dhcpd
+}
+
+
+case $1 in
+"server")
+stop_dhcp
+start_dhcp_server
+;;
+"client")
+stop_dhcp
+start_dhcp_client
+;;
+"stop")
+stop_dhcp
+;;
+"status")
+status_dhcp
+;;
+*)
+/bin/echo wifi-direct-dhcp.sh [server] [client] [stop] [status]
+exit 1
+;;
+esac
+
index 41efda3..3393616 100755 (executable)
@@ -52,7 +52,7 @@ start_dbus()
 
 stop()
 {
-       /usr/bin/killall wpa_supplicant
+       /usr/bin/pkill -x wpa_supplicant
 }
 
 case $1 in
diff --git a/files/common/p2p_supplicant b/files/common/p2p_supplicant
deleted file mode 100755 (executable)
index 6bf97f2..0000000
Binary files a/files/common/p2p_supplicant and /dev/null differ
index b8195de..b42b9e4 100755 (executable)
 #define DEFAULT_DEVICE_NAME "Tizen_Device"
 
 #if defined TIZEN_MOBILE
+#if defined TIZEN_WLAN_BOARD_SPRD
+#define DEFAULT_IFNAME "p2p0"
+#define GROUP_IFNAME "p2p0"
+#else /* TIZEN_WLAN_BOARD_SPRD */
 #define DEFAULT_IFNAME "wlan0"
 #define GROUP_IFNAME "p2p-wlan0-0"
+#endif /* TIZEN_WLAN_BOARD_SPRD */
 #endif
 
 #if defined TIZEN_WIFI_MODULE_BUNDLE
index 6f84c03..13a129f 100644 (file)
@@ -76,8 +76,8 @@ typedef struct {
 } wfd_service_s;
 
 
-int wfd_service_add(GList **services, int type, char *data, int *service_id);
-int wfd_service_del(GList *services, int service_id);
+int wfd_service_add(int type, char *data, int *service_id);
+int wfd_service_del(int service_id);
 #if 0
 int wfd_service_disc_req(unsigned char *addr, int type, char *data);
 int wfd_service_disc_cancel(int handle);
index 3716f94..6315c27 100755 (executable)
@@ -115,7 +115,12 @@ unsigned int wfd_util_static_ip_convert_order(unsigned int net_ip);
 #endif
 int wfd_util_set_wifi_direct_state(int state);
 int wfd_util_get_local_dev_mac(unsigned char *dev_mac);
+
+#ifdef TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT
 int wfd_util_start_wifi_direct_popup();
+int wfd_util_stop_wifi_direct_popup();
+#endif /* TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT */
+
 int wfd_util_dhcps_start();
 int wfd_util_dhcps_wait_ip_leased(wfd_device_s *peer);
 int wfd_util_dhcps_stop();
@@ -126,9 +131,9 @@ 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
+#ifdef TIZEN_WLAN_BOARD_SPRD
 int wfd_util_static_ip_unset(const char *ifname);
-#endif /* TIZEN_VENDOR_ATH */
+#endif /* TIZEN_WLAN_BOARD_SPRD */
 /*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);
index dd7eb06..ebd4879 100755 (executable)
@@ -324,8 +324,6 @@ typedef enum {
        WFD_OEM_SERVICE_TYPE_UPNP,
        WFD_OEM_SERVICE_TYPE_WS_DISCOVERY,
        WFD_OEM_SERVICE_TYPE_WIFI_DISPLAY,
-       WFD_OEM_SERVICE_TYPE_BT_ADDR,
-       WFD_OEM_SERVICE_TYPE_CONTACT_INFO,
        WFD_OEM_SERVICE_TYPE_VENDOR = 0xff,
 } wfd_oem_service_type_e;
 
index 6c303c6..b692619 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          wifi-direct-manager
 Summary:       Wi-Fi Direct manger
-Version:       1.2.102
+Version:       1.2.103
 Release:       1
 Group:      Network & Connectivity/Wireless
 License:    Apache-2.0
@@ -11,6 +11,7 @@ BuildRequires:        pkgconfig(dlog)
 BuildRequires: pkgconfig(vconf)
 BuildRequires:  pkgconfig(libnl-2.0)
 BuildRequires: pkgconfig(dbus-1)
+BuildRequires: pkgconfig(aul)
 BuildRequires: pkgconfig(cynara-client)
 BuildRequires: pkgconfig(cynara-creds-socket)
 BuildRequires: pkgconfig(cynara-session)
@@ -69,9 +70,13 @@ cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DARCHITECTURE=$ARCH \
         -DTIZEN_FEATURE_WIFI_DISPLAY=0 \
 %else
 %if "%{profile}" == "mobile"
+%if "%{?tizen_target_name}" == "Z300H"
+       -DTIZEN_WLAN_BOARD_SPRD=1 \
+%endif
         -DTIZEN_FEATURE_SERVICE_DISCOVERY=1 \
         -DTIZEN_WLAN_CONCURRENT_ENABLE=1 \
         -DTIZEN_FEATURE_WIFI_DISPLAY=1 \
+        -DTIZEN_FEATURE_DEFAULT_CONNECTION_AGENT=0 \
         -DCTRL_IFACE_DBUS=1 \
         -DTIZEN_MOBILE=1 \
 %else
index 2671659..264ef33 100755 (executable)
@@ -91,12 +91,12 @@ void dbus_property_foreach(GVariantIter *iter,
 
                if (key) {
                        if (strcmp(key, "Properties") == 0) {
-                               WDP_LOGE("Properties");
+                               WDP_LOGD("Properties");
                                GVariantIter *iter_raw = NULL;
                                g_variant_get(value, "a{sv}", &iter_raw);
                                dbus_property_foreach(iter_raw, function, user_data);
                        } else if (function) {
-                               WDP_LOGE("function");
+                               WDP_LOGD("function");
                                function(key, value, user_data);
                        }
                        WDP_LOGE("do nothing");
@@ -175,7 +175,7 @@ int dbus_property_get_all(const char *path, GDBusConnection *connection,
                }
                g_variant_unref(reply);
        } else{
-               WDP_LOGE("No properties");
+               WDP_LOGD("No properties");
        }
        if(function)
                function(NULL, NULL, user_data);
index 78c9e12..2ad2935 100755 (executable)
 
 #if defined TIZEN_MOBILE
 #define COMMON_IFACE_NAME "wlan0"
+#if defined TIZEN_WLAN_BOARD_SPRD
+#define P2P_IFACE_NAME "p2p0"
+#define GROUP_IFACE_NAME "p2p0"
+#define GROUP_IFACE_PREFIX "p2p"
+#else /* TIZEN_WLAN_BOARD_SPRD */
 #define GROUP_IFACE_NAME "p2p-wlan0-0"
 #define GROUP_IFACE_PREFIX "p2p-wlan0-"
+#endif /* TIZEN_WLAN_BOARD_SPRD */
 #define PRIMARY_DEVICE_TYPE "\x00\x0a\x00\x50\xf2\x04\x00\x05"
 #define DEFAULT_DEVICE_NAME "Tizen"
 #define DEFAULT_GO_INTENT 7
@@ -67,7 +73,7 @@
 #define DEFAULT_LISTEN_CHANNEL 1
 #define DEFAULT_OPER_REG_CLASS 81
 #define DEFAULT_OPER_CHANNEL 1
-#define DEFAULT_CONFIG_METHOD "push_button"
+#define DEFAULT_CONFIG_METHOD "display push_button keypad"
 #define DEFAULT_NO_GROUP_IFACE 0
 #endif
 
 #define WS_MAX_SERVICE_LEN 1024
 #define SERVICE_QUERY_LEN 4
 
-#define SERVICE_TYPE_BT_ADDR "0000f00b"
 #define SERVICE_TYPE_ALL "0000f00c"
-#define SERVICE_TYPE_CONTACT_INFO "0000f00d"
 #define SERV_BROADCAST_ADDRESS "00:00:00:00:00:00"
 
 #define WS_QTYPE_PTR 0x0c
index b168b59..4476cdd 100755 (executable)
@@ -225,42 +225,6 @@ static int __ws_hex_to_num(char *src, int len)
        return num;
 }
 
-static int __ws_hex_to_txt(char *src, int length, char *dest)
-{
-       // TODO: check it is good to change dest parameter as double pointer.
-       // It could be better to allocate memory for dest parameter here.
-       char *temp = NULL;
-       char *ptr = NULL;
-       int len = 0;
-       int i = 0;
-
-       if (!src || length < 0 || !dest) {
-               WDP_LOGE("Invalid parameter");
-               return -1;
-       }
-
-       // TODO: flush destination memory
-
-       ptr = src;
-       temp = dest;
-
-       if (!length)
-               len = strlen(src);
-       else
-               len = length;
-
-       for (i=0; i<len/2 && *ptr!=0; i++) {
-               temp[i] = (char) __ws_hex_to_num(ptr, 2);
-               if (temp[i] < 0) {
-                       WDP_LOGE("Failed to convert hexa string to num");
-                       return -1;
-               }
-               ptr += 2;
-       }
-
-       return 0;
-}
-
 static int __ws_segment_to_service(char *segment, wfd_oem_new_service_s **service)
 {
        wfd_oem_new_service_s *serv_tmp = NULL;
@@ -363,21 +327,8 @@ static int __ws_segment_to_service(char *segment, wfd_oem_new_service_s **servic
 
                WDP_LOGD("Query: %s", serv_tmp->data.bonjour.query);
                WDP_LOGD("RData: %s", serv_tmp->data.bonjour.rdata);
-       } else if (serv_tmp->protocol == WFD_OEM_SERVICE_TYPE_VENDOR) {
-               WDP_LOGD("===== Vendor specific service =====");
-               if (!strncmp(ptr, "0000f00b", 8)) {
-                       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);
-                       g_strlcpy(serv_tmp->data.vendor.data1, "0000f00b", 9);
-                       serv_tmp->data.vendor.data2 = (char*) calloc(1, 18);
-                       __ws_hex_to_txt(ptr, 0, serv_tmp->data.vendor.data2);
-               }
-               WDP_LOGD("Info1: %s", serv_tmp->data.vendor.data1);
-               WDP_LOGD("Info2: %s", serv_tmp->data.vendor.data2);
        } else {
-               WDP_LOGE("Not supported yet. Only bonjour and samsung vendor service supproted [%d]",
+               WDP_LOGE("Not supported yet. Only bonjour service supproted [%d]",
                                        serv_tmp->protocol);
                g_free(serv_tmp);
                return -1;
@@ -392,6 +343,8 @@ static int __ws_segment_to_service(char *segment, wfd_oem_new_service_s **servic
 static void __ws_path_to_addr(char *peer_path,
                unsigned char *dev_addr, GVariant *parameter)
 {
+       __WDP_LOG_FUNC_ENTER__;
+
        static unsigned char peer_dev[WS_MACSTR_LEN] = {'\0',};
        const char *path = NULL;
        char *loc = NULL;
@@ -401,11 +354,13 @@ static void __ws_path_to_addr(char *peer_path,
        WDP_LOGD("Retrive Added path [%s]", peer_path);
 
        loc = strrchr(peer_path,'/');
-       __ws_mac_compact_to_normal(loc + 1, peer_dev);
+       if(loc != NULL)
+               __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));
 
+       __WDP_LOG_FUNC_EXIT__;
        return;
 }
 
@@ -483,9 +438,9 @@ static void _supplicant_signal_cb(GDBusConnection *connection,
        DEBUG_SIGNAL(sender, object_path, interface, signal, parameters);
 #endif /* TIZEN_DEBUG_DBUS_VALUE */
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        if (!g_strcmp0(signal,"InterfaceAdded")) {
@@ -528,6 +483,8 @@ static void _supplicant_signal_cb(GDBusConnection *connection,
 
 static void __ws_get_peer_property(const char *key, GVariant *value, void *user_data)
 {
+       __WDP_LOG_FUNC_ENTER__;
+
        wfd_oem_device_s *peer = (wfd_oem_device_s *)user_data;
        if(!peer) {
                __WDP_LOG_FUNC_EXIT__;
@@ -614,12 +571,15 @@ static void __ws_get_peer_property(const char *key, GVariant *value, void *user_
        } else {
                WDP_LOGE("Unknown value");
        }
+       __WDP_LOG_FUNC_EXIT__;
        return;
 }
 
 static void __ws_peer_property(const char *key, GVariant *value, void *user_data)
 {
+       __WDP_LOG_FUNC_ENTER__;
        if(!user_data) {
+               __WDP_LOG_FUNC_EXIT__;
                return;
        }
 
@@ -706,6 +666,7 @@ static void __ws_peer_property(const char *key, GVariant *value, void *user_data
        } else {
                WDP_LOGE("Unknown value");
        }
+       __WDP_LOG_FUNC_EXIT__;
        return;
 }
 
@@ -725,11 +686,13 @@ void __ws_interface_property(const char *key, GVariant *value, void *user_data)
                WDP_LOGD("Ifname [%s]", event->ifname);
 
        }
+       __WDP_LOG_FUNC_EXIT__;
        return;
 }
 
 void __ws_group_property(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;
@@ -779,11 +742,13 @@ void __ws_group_property(const char *key, GVariant *value, void *user_data)
        } else {
                WDP_LOGE("Unknown value");
        }
+       __WDP_LOG_FUNC_EXIT__;
        return;
 }
 
 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;
@@ -814,18 +779,20 @@ void __ws_extract_invitation_details(const char *key, GVariant *value, void *use
        } else {
                WDP_LOGE("Unknown value");
        }
+       __WDP_LOG_FUNC_EXIT__;
        return;
 }
 
 void __ws_extract_group_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;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        wfd_oem_group_data_s *group = (wfd_oem_group_data_s *)event->edata;
@@ -891,11 +858,13 @@ void __ws_extract_group_details(const char *key, GVariant *value, void *user_dat
                                _group_signal_cb,
                                NULL, NULL);
        }
+       __WDP_LOG_FUNC_EXIT__;
        return;
 }
 
 void __ws_extract_gonegfailaure_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;
@@ -919,11 +888,13 @@ void __ws_extract_gonegfailaure_details(const char *key, GVariant *value, void *
                WDP_LOGD("Retrive status [%d]", status);
                conn->status = status;
        }
+       __WDP_LOG_FUNC_EXIT__;
        return;
 }
 
 void __ws_extract_gonegsuccess_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;
@@ -952,8 +923,8 @@ void __ws_extract_gonegsuccess_details(const char *key, GVariant *value, void *u
                unsigned char ssid[WS_SSID_LEN +1] = {0,};
 
                __ws_unpack_ay(ssid, value, WS_SSID_LEN);
-                       memcpy(edata->ssid, ssid, WS_SSID_LEN+1);
-                       WDP_LOGD("ssid [%s]", edata->ssid);
+               memcpy(edata->ssid, ssid, WS_SSID_LEN+1);
+               WDP_LOGD("ssid [%s]", edata->ssid);
 
        } else if (g_strcmp0(key, "peer_device_addr") == 0) {
 
@@ -977,6 +948,7 @@ void __ws_extract_gonegsuccess_details(const char *key, GVariant *value, void *u
        } else if (g_strcmp0(key, "peer_config_timeout") == 0) {
 
        }
+       __WDP_LOG_FUNC_EXIT__;
        return;
 }
 
@@ -1026,8 +998,19 @@ void __ws_extract_servicediscoveryresponse_details(const char *key, GVariant *va
        CHECK_KEY_VALUE(key, value);
 #endif /* TIZEN_DEBUG_DBUS_VALUE */
        if (g_strcmp0(key, "peer_object") == 0) {
-               static char peer_path[DBUS_OBJECT_PATH_MAX] = {'\0',};
-               __ws_path_to_addr(peer_path, event->dev_addr, value);
+               static unsigned char peer_dev[WS_MACSTR_LEN] = {'\0',};
+               const char *path = NULL;
+               char *loc = NULL;
+
+               g_variant_get(value, "o", &path);
+               if(path == NULL)
+                       return;
+
+               WDP_LOGD("Retrive Added path [%s]", path);
+               loc = strrchr(path,'/');
+               if(loc != NULL)
+                       __ws_mac_compact_to_normal(loc + 1, peer_dev);
+               __ws_txt_to_mac(peer_dev, event->dev_addr);
 
        } else if (g_strcmp0(key, "update_indicator")) {
 
@@ -1053,6 +1036,71 @@ void __ws_extract_servicediscoveryresponse_details(const char *key, GVariant *va
 }
 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
 
+static int _ws_flush()
+{
+       __WDP_LOG_FUNC_ENTER__;
+       GDBusConnection *g_dbus = NULL;
+       dbus_method_param_s params;
+       int res = 0;
+
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return -1;
+        }
+
+       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, "Flush", g_pd->iface_path, g_dbus);
+       params.params = NULL;
+
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
+       if (res < 0)
+               WDP_LOGE("Failed to send command to wpa_supplicant");
+       else
+               WDP_LOGD("Succeeded to flush");
+
+       __WDP_LOG_FUNC_EXIT__;
+       return 0;
+}
+
+static int _ws_cancel()
+{
+       __WDP_LOG_FUNC_ENTER__;
+       GDBusConnection *g_dbus = NULL;
+       dbus_method_param_s params;
+       int res = 0;
+
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return -1;
+        }
+
+
+       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, "Cancel", g_pd->iface_path , g_dbus);
+       params.params = NULL;
+
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
+       if (res < 0)
+               WDP_LOGE("Failed to send command to wpa_supplicant");
+       else
+               WDP_LOGD("Succeeded to cancel");
+
+       __WDP_LOG_FUNC_EXIT__;
+       return 0;
+}
+
 static void _ws_process_device_found(GDBusConnection *connection,
                const gchar *object_path, GVariant *parameters)
 {
@@ -1061,9 +1109,9 @@ static void _ws_process_device_found(GDBusConnection *connection,
        wfd_oem_dev_data_s *edata = NULL;
        static char peer_path[DBUS_OBJECT_PATH_MAX] = {'\0',};
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        edata = (wfd_oem_dev_data_s *) g_try_malloc0(sizeof(wfd_oem_dev_data_s));
@@ -1097,9 +1145,9 @@ static void _ws_process_device_lost(GDBusConnection *connection,
        wfd_oem_event_s event;
        static char peer_path[DBUS_OBJECT_PATH_MAX] = {'\0',};
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        memset(&event, 0x0, sizeof(wfd_oem_event_s));
@@ -1120,9 +1168,9 @@ static void _ws_process_find_stoppped(GDBusConnection *connection,
        __WDP_LOG_FUNC_ENTER__;
        wfd_oem_event_s event;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        memset(&event, 0x0, sizeof(wfd_oem_event_s));
@@ -1149,9 +1197,9 @@ static void _ws_process_prov_disc_req_display_pin(GDBusConnection *connection,
        const char *pin = NULL;
        char *loc = NULL;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        edata = (wfd_oem_dev_data_s *) g_try_malloc0(sizeof(wfd_oem_dev_data_s));
@@ -1203,9 +1251,9 @@ static void _ws_process_prov_disc_resp_display_pin(GDBusConnection *connection,
        const char *pin = NULL;
        char *loc = NULL;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        edata = (wfd_oem_dev_data_s *) g_try_malloc0(sizeof(wfd_oem_dev_data_s));
@@ -1251,9 +1299,9 @@ static void _ws_process_prov_disc_req_enter_pin(GDBusConnection *connection,
        wfd_oem_dev_data_s *edata = NULL;
        static char peer_path[DBUS_OBJECT_PATH_MAX] = {'\0',};
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        edata = (wfd_oem_dev_data_s *) g_try_malloc0(sizeof(wfd_oem_dev_data_s));
@@ -1289,9 +1337,9 @@ static void _ws_process_prov_disc_resp_enter_pin(GDBusConnection *connection,
        wfd_oem_dev_data_s *edata = NULL;
        static char peer_path[DBUS_OBJECT_PATH_MAX] = {'\0',};
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        edata = (wfd_oem_dev_data_s *) g_try_malloc0(sizeof(wfd_oem_dev_data_s));
@@ -1327,9 +1375,9 @@ static void _ws_process_prov_disc_pbc_req(GDBusConnection *connection,
        wfd_oem_dev_data_s *edata = NULL;
        static char peer_path[DBUS_OBJECT_PATH_MAX] = {'\0',};
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        edata = (wfd_oem_dev_data_s *) g_try_malloc0(sizeof(wfd_oem_dev_data_s));
@@ -1365,9 +1413,9 @@ static void _ws_process_prov_disc_pbc_resp(GDBusConnection *connection,
        wfd_oem_dev_data_s *edata = NULL;
        static char peer_path[DBUS_OBJECT_PATH_MAX] = {'\0',};
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        edata = (wfd_oem_dev_data_s *) g_try_malloc0(sizeof(wfd_oem_dev_data_s));
@@ -1406,9 +1454,9 @@ static void _ws_process_prov_disc_failure(GDBusConnection *connection,
        int prov_status = 0;
        char *loc = NULL;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        memset(&event, 0x0, sizeof(wfd_oem_event_s));
@@ -1477,9 +1525,9 @@ static void _ws_process_go_neg_success(GDBusConnection *connection,
        wfd_oem_event_s event;
        wfd_oem_conn_data_s *edata = NULL;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        edata = (wfd_oem_conn_data_s*)calloc(1, sizeof(wfd_oem_conn_data_s));
@@ -1563,9 +1611,9 @@ static void _ws_process_go_neg_request(GDBusConnection *connection,
 
        int dev_pwd_id = 0;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        edata = (wfd_oem_dev_data_s *) g_try_malloc0(sizeof(wfd_oem_dev_data_s));
@@ -1621,9 +1669,9 @@ static void _ws_process_invitation_received(GDBusConnection *connection,
        wfd_oem_event_s event;
        wfd_oem_invite_data_s *edata = NULL;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        edata = (wfd_oem_invite_data_s *) g_try_malloc0(sizeof(wfd_oem_invite_data_s));
@@ -1675,9 +1723,9 @@ static void _ws_process_group_finished(GDBusConnection *connection,
        __WDP_LOG_FUNC_ENTER__;
        wfd_oem_event_s event;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        memset(&event, 0x0, sizeof(wfd_oem_event_s));
@@ -1687,6 +1735,7 @@ static void _ws_process_group_finished(GDBusConnection *connection,
 
        g_dbus_connection_signal_unsubscribe(g_pd->g_dbus, g_pd->group_sub_id);
        memset(g_pd->group_iface_path, 0x0, DBUS_OBJECT_PATH_MAX);
+       _ws_flush();
 
        g_pd->callback(g_pd->user_data, &event);
 
@@ -1701,9 +1750,9 @@ static void _ws_process_service_discovery_response(GDBusConnection *connection,
        GVariantIter *iter = NULL;
        wfd_oem_event_s event;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        memset(&event, 0x0, sizeof(wfd_oem_event_s));
@@ -1762,9 +1811,9 @@ static void _ws_process_wps_failed(GDBusConnection *connection,
        wfd_oem_event_s event;
        const char *name = NULL;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        memset(&event, 0x0, sizeof(wfd_oem_event_s));
@@ -1800,9 +1849,9 @@ static void _ws_process_group_formation_failure(GDBusConnection *connection,
        __WDP_LOG_FUNC_ENTER__;
        wfd_oem_event_s event;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        memset(&event, 0x0, sizeof(wfd_oem_event_s));
@@ -1996,9 +2045,9 @@ static void _group_signal_cb(GDBusConnection *connection,
        DEBUG_SIGNAL(sender, object_path, interface, signal, parameters);
 #endif /* TIZEN_DEBUG_DBUS_VALUE */
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        if(!g_strcmp0(signal,"PeerJoined")){
@@ -2053,9 +2102,9 @@ static void __register_p2pdevice_signal(GVariant *value, void *user_data)
        static char interface_path[DBUS_OBJECT_PATH_MAX] = {'\0',};
        const char *path = NULL;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        pd_data = (ws_dbus_plugin_data_s *)g_pd;
@@ -2089,9 +2138,9 @@ static int _ws_create_interface(const char *iface_name, handle_reply function, v
 
        int res = 0;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return -1;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return -1;
         }
 
        g_dbus = g_pd->g_dbus;
@@ -2125,9 +2174,9 @@ static int _ws_get_interface(const char *iface_name, handle_reply function, void
        dbus_method_param_s params;
        int res = 0;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return -1;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return -1;
         }
 
        g_dbus = g_pd->g_dbus;
@@ -2156,7 +2205,7 @@ static int _ws_get_interface(const char *iface_name, handle_reply function, void
        return res;
 }
 
-#if 0
+#if defined (TIZEN_MOBILE) && (TIZEN_WLAN_BOARD_SPRD)
 static void __ws_remove_interface(GVariant *value, void *user_data)
 {
        __WDP_LOG_FUNC_ENTER__;
@@ -2166,9 +2215,9 @@ static void __ws_remove_interface(GVariant *value, void *user_data)
        static char interface_path[DBUS_OBJECT_PATH_MAX] = {'\0',};
        int res = 0;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return;
         }
 
        g_dbus = g_pd->g_dbus;
@@ -2195,7 +2244,7 @@ static void __ws_remove_interface(GVariant *value, void *user_data)
        __WDP_LOG_FUNC_EXIT__;
        return;
 }
-#endif
+#endif /* (TIZEN_MOBILE) && (TIZEN_WLAN_BOARD_SPRD) */
 
 static int _ws_init_dbus_connection(void)
 {
@@ -2204,9 +2253,9 @@ static int _ws_init_dbus_connection(void)
        GError *error = NULL;
        int res = 0;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return -1;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return -1;
         }
 
        conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
@@ -2235,8 +2284,15 @@ static int _ws_init_dbus_connection(void)
                G_DBUS_SIGNAL_FLAGS_NONE,
                _supplicant_signal_cb,
                NULL, NULL);
+#if defined (TIZEN_MOBILE) && (TIZEN_WLAN_BOARD_SPRD)
+       if(_ws_get_interface(COMMON_IFACE_NAME, NULL, NULL) < 0)
+               _ws_create_interface(COMMON_IFACE_NAME, NULL, NULL);
+       if(_ws_get_interface(P2P_IFACE_NAME, __register_p2pdevice_signal, NULL) < 0)
+               res = _ws_create_interface(P2P_IFACE_NAME, __register_p2pdevice_signal, NULL);
+#else /* (TIZEN_MOBILE) && (TIZEN_WLAN_BOARD_SPRD) */
        if(_ws_get_interface(COMMON_IFACE_NAME, __register_p2pdevice_signal, NULL) < 0)
                res = _ws_create_interface(COMMON_IFACE_NAME, __register_p2pdevice_signal, NULL);
+#endif /* (TIZEN_MOBILE) && (TIZEN_WLAN_BOARD_SPRD) */
 
        if (res < 0)
                        WDP_LOGE("Failed to subscribe interface signal");
@@ -2251,9 +2307,9 @@ static int _ws_deinit_dbus_connection(void)
 {
        GDBusConnection *g_dbus = NULL;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_plugin_data_s is not created yet");
-                return -1;
+    if(!g_pd) {
+        WDP_LOGE("ws_plugin_data_s is not created yet");
+        return -1;
         }
 
        g_dbus = g_pd->g_dbus;
@@ -2348,6 +2404,7 @@ static int __ws_check_net_interface(char* if_name)
        return 0;
 }
 #endif
+
 int ws_init(wfd_oem_event_cb callback, void *user_data)
 {
        __WDP_LOG_FUNC_ENTER__;
@@ -2424,6 +2481,7 @@ gboolean _ws_util_execute_file(const char *file_path,
        WDP_LOGE("failed to fork (%s)", strerror(errno));
        return FALSE;
 }
+
 #if 0
 static int __ws_p2p_firmware_start(void)
 {
@@ -2536,7 +2594,7 @@ static int __ws_p2p_firmware_stop(void)
 
 static int __ws_p2p_supplicant_start(void)
 {
-       gboolean rv;
+       gboolean rv = FALSE;
        const char *path = "/usr/sbin/p2p_supp.sh";
        char *const args[] = { "/usr/sbin/p2p_supp.sh", "start_dbus", NULL };
        char *const envs[] = { NULL };
@@ -2555,7 +2613,7 @@ static int __ws_p2p_supplicant_start(void)
 
 static int __ws_p2p_supplicant_stop(void)
 {
-       gboolean rv;
+       gboolean rv = FALSE;
        const char *path = "/usr/sbin/p2p_supp.sh";
        char *const args[] = { "/usr/sbin/p2p_supp.sh", "stop", NULL };
        char *const envs[] = { NULL };
@@ -2685,9 +2743,9 @@ int __ws_init_p2pdevice()
        int i = 0;
        int res = 0;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return -1;
+       if(!g_pd) {
+               WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+               return -1;
         }
 
        for(i = 0; i < WS_DEVTYPE_LEN; i++)
@@ -2780,7 +2838,7 @@ int __ws_init_p2pdevice()
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
        else
-               WDP_LOGE("Succeeded to initialize p2pdevice");
+               WDP_LOGD("Succeeded to initialize p2pdevice");
        __WDP_LOG_FUNC_EXIT__;
        return res;
 }
@@ -2796,10 +2854,10 @@ int __ws_set_config_methods()
        dbus_method_param_s params;
        int res = 0;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return -1;
-        }
+       if(!g_pd) {
+               WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+               return -1;
+       }
 
        g_dbus = g_pd->g_dbus;
        if (!g_dbus) {
@@ -2832,9 +2890,9 @@ int ws_activate(int concurrent)
        int res = 0;
        int retry_count = 0;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return -1;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return -1;
         }
 
        res = __ws_p2p_supplicant_start();
@@ -2903,9 +2961,9 @@ int ws_deactivate(int concurrent)
        __WDP_LOG_FUNC_ENTER__;
        int res = 0;
 
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return -1;
+    if(!g_pd) {
+        WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+        return -1;
         }
 
        if (!g_pd->activated) {
@@ -2916,6 +2974,12 @@ int ws_deactivate(int concurrent)
        ws_stop_scan();
 
        g_pd->concurrent = concurrent;
+#if defined (TIZEN_MOBILE) && (TIZEN_WLAN_BOARD_SPRD)
+       _ws_get_interface(P2P_IFACE_NAME, __ws_remove_interface, NULL);
+       if(concurrent == 0)
+               _ws_get_interface(COMMON_IFACE_NAME, __ws_remove_interface, NULL);
+#endif /* (TIZEN_MOBILE) && (TIZEN_WLAN_BOARD_SPRD) */
+
        _ws_deinit_dbus_connection();
 
        if(concurrent == 0) {
@@ -2932,70 +2996,6 @@ int ws_deactivate(int concurrent)
        return 0;
 }
 
-static int _ws_flush()
-{
-       __WDP_LOG_FUNC_ENTER__;
-       GDBusConnection *g_dbus = NULL;
-       dbus_method_param_s params;
-       int res = 0;
-
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return -1;
-        }
-
-       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, "Flush", g_pd->iface_path, g_dbus);
-       params.params = NULL;
-
-       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
-       if (res < 0)
-               WDP_LOGE("Failed to send command to wpa_supplicant");
-       else
-               WDP_LOGD("Succeeded to flush");
-
-       __WDP_LOG_FUNC_EXIT__;
-       return 0;
-}
-
-static int _ws_cancel()
-{
-       __WDP_LOG_FUNC_ENTER__;
-       GDBusConnection *g_dbus = NULL;
-       dbus_method_param_s params;
-       int res = 0;
-
-        if(!g_pd) {
-                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
-                return -1;
-        }
-
-       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, "Cancel", g_pd->iface_path , g_dbus);
-       params.params = NULL;
-
-       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE, NULL, NULL);
-       if (res < 0)
-               WDP_LOGE("Failed to send command to wpa_supplicant");
-       else
-               WDP_LOGD("Succeeded to cancel");
-
-       __WDP_LOG_FUNC_EXIT__;
-       return 0;
-}
-
 #if 0
 static gboolean _retry_start_scan(gpointer data)
 {
@@ -4669,12 +4669,6 @@ int ws_cancel_service_discovery(unsigned char *mac_addr, int service_type)
                case WFD_OEM_SERVICE_TYPE_UPNP:
                        strncpy(s_type, SERV_DISC_REQ_UPNP, OEM_SERVICE_TYPE_LEN);
                break;
-               case WFD_OEM_SERVICE_TYPE_BT_ADDR:
-                       strncpy(s_type, SERVICE_TYPE_BT_ADDR, OEM_SERVICE_TYPE_LEN);
-                       break;
-               case WFD_OEM_SERVICE_TYPE_CONTACT_INFO:
-                       strncpy(s_type, SERVICE_TYPE_CONTACT_INFO, OEM_SERVICE_TYPE_LEN);
-                       break;
                default:
                        __WDP_LOG_FUNC_EXIT__;
                        WDP_LOGE("Invalid Service type");
index 969ab4e..c6df598 100755 (executable)
 #define WS_SCAN_RETRY_COUNT 10
 
 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
-#define BT_ADDR_PATH "/csa/bluetooth/.bd_addr"
 
 #define SERV_DISC_REQ_ALL "02000001"
 #define SERV_DISC_REQ_BONJOUR "02000101"
 #define SERV_DISC_REQ_UPNP "02000201"
 
-#define SAMSUNG_VENDOR_OUI "0000f0"
-#define SAMSUNG_SERVICE_BT "0b"
-#define SAMSUNG_SERVICE_CONTACT "0d"
 #define SAMSUNG_SERVICE_ALL "0c"
 
-#define SERVICE_TYPE_BT_ADDR "0000f00b"
-#define SERVICE_TYPE_ALL "0000f00c"
-#define SERVICE_TYPE_CONTACT_INFO "0000f00d"
 #define SERVICE_TYPE_LEN 8
 #define SERV_BROADCAST_ADDRESS "00:00:00:00:00:00"
 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
index 2eae5c0..3da4f73 100755 (executable)
@@ -1210,6 +1210,10 @@ static int _parsing_peer_info(char *msg, wfd_oem_device_s *peer)
                        info_cnt++;
                }
        }
+       if (info_cnt == 0) {
+               WDP_LOGD("Device info ids have no valid information");
+               return -1;
+       }
 
        for (i = 0; i < info_cnt; i++) {
                switch (infos[i].index){
@@ -1409,10 +1413,11 @@ static wfd_oem_dev_data_s *_convert_msg_to_dev_info(char *msg)
                                edata->group_flags = WFD_OEM_GROUP_FLAG_PERSISTENT_GROUP;
                        break;
                case WS_DEV_INFO_P2P_GO_ADDR:
-                       edata->dev_role = WFD_OEM_DEV_ROLE_GC;
                        res = _ws_txt_to_mac(infos[i].string, edata->p2p_go_addr);
                        if (res < 0)
                                memset(edata->p2p_go_addr, 0x00, OEM_MACADDR_LEN);
+                       if (memcmp(edata->p2p_go_addr, null_mac, OEM_MACADDR_LEN))
+                               edata->dev_role = WFD_OEM_DEV_ROLE_GC;
                        break;
 #ifdef TIZEN_FEATURE_WIFI_DISPLAY
                case WS_DEV_INFO_WFD_DEV_INFO:
@@ -1745,30 +1750,8 @@ static int _ws_segment_to_service(char *segment, wfd_oem_new_service_s **service
                WDP_LOGD("RData: %s", serv_tmp->data.bonjour.rdata);
        } else if (serv_tmp->protocol == WFD_OEM_SERVICE_TYPE_VENDOR) {
                WDP_LOGD("===== Vendor specific service =====");
-               if (!strncmp(ptr, "0000f00b", 8)) {
-                       WDP_LOGD("\tSAMSUNG_BT_ADDR");
-                       ptr += 16;
-                       serv_tmp->protocol = WFD_OEM_SERVICE_TYPE_BT_ADDR;
-                       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*) 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);
-               WDP_LOGD("Info2: %s", serv_tmp->data.vendor.data2);
        } else {
-               WDP_LOGE("Not supported yet. Only bonjour and samsung vendor service supproted [%d]",
+               WDP_LOGE("Not supported yet. Only bonjour service supproted [%d]",
                                        serv_tmp->protocol);
                g_free(serv_tmp);
                return -1;
@@ -1935,14 +1918,26 @@ static int _parsing_event_info(char *ifname, char *msg, wfd_oem_event_s *data)
                {
                        /* Interface address of connected peer will come up */
                        char *temp_mac = NULL;
+                       char *intf = NULL;
+                       res = _extract_value_str(info_str, "ifname", &intf);
+                       if (res < 0) {
+                               WDP_LOGE("Failed to extract interface name");
+                               break;
+                       }
+                       if (intf) {
+                               strcpy(data->ifname, intf);
+                               free(intf);
+                       }
+                       WDP_LOGD("Connected event from interface: %s", data->ifname);
                        res = _extract_value_str(info_str, "to", &temp_mac);
                        if (res < 0) {
                                WDP_LOGE("Failed to extract interface address");
                                break;
                        }
-                       _ws_txt_to_mac(temp_mac, data->intf_addr);
-                       if (temp_mac)
+                       if (temp_mac) {
+                               _ws_txt_to_mac(temp_mac, data->intf_addr);
                                g_free(temp_mac);
+                       }
                        data->edata_type = WFD_OEM_EDATA_TYPE_NONE;
                }
                break;
@@ -2084,12 +2079,16 @@ static int _parsing_event_info(char *ifname, char *msg, wfd_oem_event_s *data)
                        char mac_addr[OEM_MACSTR_LEN] ={0, };
                        char *up_indic = NULL;
                        int len = 0;
+                       int ret = 0;
 
                        _ws_txt_to_mac(info_str, data->dev_addr);
                        info_str += OEM_MACSTR_LEN;
                        g_snprintf(mac_addr, OEM_MACSTR_LEN, MACSTR, MAC2STR(data->dev_addr));
 
-                       _extract_word(info_str, &up_indic);
+                       ret = _extract_word(info_str, &up_indic);
+                       if (ret < 0) {
+                               WDP_LOGE("_extract_word is failed");
+                       }
                        if (up_indic) {
                                WDP_LOGD("Update indicator: %s", up_indic);
                                info_str += strlen(up_indic) + 1;
@@ -2278,6 +2277,7 @@ static gboolean ws_event_handler(GIOChannel *source,
                                // goto done;
                        }
                        g_pd->group = NULL;
+                       _ws_flush();
                }
                break;
        case WS_EVENT_INVITATION_RECEIVED:
@@ -4171,16 +4171,6 @@ int ws_start_service_discovery(unsigned char *mac_addr, int service_type)
                        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);
-                       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);
-                       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__;
@@ -4255,12 +4245,6 @@ int ws_cancel_service_discovery(unsigned char *mac_addr, int service_type)
                case WFD_OEM_SERVICE_TYPE_UPNP:
                        g_strlcpy(s_type, SERV_DISC_REQ_UPNP, OEM_SERVICE_TYPE_LEN + 1);
                break;
-               case WFD_OEM_SERVICE_TYPE_BT_ADDR:
-                       g_strlcpy(s_type, SERVICE_TYPE_BT_ADDR, OEM_SERVICE_TYPE_LEN + 1);
-                       break;
-               case WFD_OEM_SERVICE_TYPE_CONTACT_INFO:
-                       g_strlcpy(s_type, SERVICE_TYPE_CONTACT_INFO, OEM_SERVICE_TYPE_LEN + 1);
-                       break;
                default:
                        __WDP_LOG_FUNC_EXIT__;
                        WDP_LOGE("Invalid Service type");
@@ -4296,10 +4280,9 @@ int ws_cancel_service_discovery(unsigned char *mac_addr, int service_type)
        return 0;
 }
 
-int _convert_bonjour_to_hex(char *query, char *rdata, char **hex)
+int _convert_bonjour_query_to_hex(char *query, char **hex)
 {
        char hex_key[256] = {0, };;
-       char hex_value[256] = {0, };;
        char *token = NULL;
        char *temp = NULL;
        int len = 0;
@@ -4307,15 +4290,22 @@ int _convert_bonjour_to_hex(char *query, char *rdata, char **hex)
        int i = 0;
        char temp_str[256] = {0, };
        char *result_str = NULL;
+       char *str_query = NULL;
 
        if (!query || !hex) {
                WDP_LOGE("Invalid parameter");
                return -1;
        }
 
-       token = strtok_r(query, ".", &temp);
+       str_query = strdup(query);
+       if (!str_query) {
+               WDP_LOGE("Memory allocation failed");
+               return -1;
+       }
+
+       token = strtok_r(str_query, ".", &temp);
        while (token) {
-               if (!strcmp(token, "local")) {
+               if (!strcmp(token, "local") || !strcmp(token, "_tcp") || !strcmp(token, "_udp")) {
                        WDP_LOGD("Query conversion done");
                        break;
                }
@@ -4332,21 +4322,85 @@ int _convert_bonjour_to_hex(char *query, char *rdata, char **hex)
                token = strtok_r(NULL, ".", &temp);
        }
 
-       if (token && strstr(token, "local")) {
+       if (token && strstr(token, "_tcp")) {
+               token = strtok_r(NULL, ".", &temp);
+               if (token && strstr(token, "local")) {
+                       strncat(hex_key, "c00c", 4);
+                       strncat(hex_key, "000c", 4);
+                       strncat(hex_key, "01", 2);
+                       goto next;
+               }
+       } else if (token && strstr(token, "_udp")) {
+               token = strtok_r(NULL, ".", &temp);
+               if (token && strstr(token, "local")) {
+                       strncat(hex_key, "c01c", 4);
+                       strncat(hex_key, "000c", 4);
+                       strncat(hex_key, "01", 2);
+                       goto next;
+               }
+       } else if (token && strstr(token, "local")) {
                strncat(hex_key, "c011", 4);
                strncat(hex_key, "000c", 4);
                strncat(hex_key, "01", 2);
-       } else {
-               strncat(hex_key, "c011", 4);
-               strncat(hex_key, "0010", 4);
-               strncat(hex_key, "01", 2);
+               goto next;
+       }
+
+       strncat(hex_key, "c00c", 4);
+       strncat(hex_key, "0010", 4);
+       strncat(hex_key, "01", 2);
+
+next:
+       g_free(str_query);
+
+       tot_len = strlen(hex_key);
+       result_str = (char*) calloc(1, tot_len+1);
+       if (!result_str) {
+               WDP_LOGE("Failed to allocate memory for result string");
+               return -1;
+       }
+       sprintf(result_str, "%s", hex_key);
+
+       *hex = result_str;
+
+       return 0;
+}
+
+
+int _convert_bonjour_to_hex(char *query, char *rdata,
+                                               wfd_oem_bonjour_rdata_type_e rdata_type, char **hex)
+{
+       char *hex_key = NULL;
+       char hex_value[256] = {0, };
+       char *token = NULL;
+       char *temp = NULL;
+       int len = 0;
+       int tot_len = 0;
+       int i = 0;
+       char temp_str[256] = {0, };
+       char *result_str = NULL;
+       char *str_rdata = NULL;
+
+       if (!query || !hex) {
+               WDP_LOGE("Invalid parameter");
+               return -1;
+       }
+
+       if (_convert_bonjour_query_to_hex(query, &hex_key) < 0 || !hex_key) {
+               WDP_LOGE("_convert_bonjour_query_to_hex failed");
+               return -1;
        }
 
        if (!rdata || !strlen(rdata)) {
                WDP_LOGD("RDATA is NULL");
                strncat(hex_value, "00", 2);
        } else {
-               token = strtok_r(rdata, ".", &temp);
+               str_rdata = strdup(rdata);
+               if (!str_rdata) {
+                       WDP_LOGE("Memory allocation failed");
+                       g_free(hex_key);
+                       return -1;
+               }
+               token = strtok_r(str_rdata, ".", &temp);
                while (token) {
                        WDP_LOGD("Token: %s", token);
                        len = strlen(token);
@@ -4360,20 +4414,25 @@ int _convert_bonjour_to_hex(char *query, char *rdata, char **hex)
 
                        token = strtok_r(NULL, ".", &temp);
                }
+               g_free(str_rdata);
        }
 
-       strncat(hex_value, "c027", 4);
+       if (rdata_type == WFD_OEM_BONJOUR_RDATA_PTR)
+               strncat(hex_value, "c027", 4);
 
        tot_len = strlen(hex_key) + strlen(hex_value);
        result_str = (char*) g_try_malloc0(tot_len+2);
        if (!result_str) {
                WDP_LOGE("Failed to allocate memory for result string");
+               g_free(hex_key);
                return -1;
        }
        g_snprintf(result_str, tot_len+2, "%s %s", hex_key, hex_value);
 
        *hex = result_str;
 
+       g_free(hex_key);
+
        return 0;
 }
 
@@ -4400,7 +4459,9 @@ int ws_serv_add(wfd_oem_new_service_s *service)
 
                        res = _convert_bonjour_to_hex(service->data.bonjour.query,
                                                                    service->data.bonjour.rdata,
+                                                                   service->data.bonjour.rdata_type,
                                                                    &hex);
+
                        if (res < 0) {
                                WDP_LOGE("Failed to convert Key string as hex string");
                                return -1;
@@ -4463,7 +4524,7 @@ int ws_serv_del(wfd_oem_new_service_s *service)
                        WDP_LOGD("Service type: WFD_OEM_SERVICE_TYPE_BONJOUR, Data: %s", service);
                        char *hex_key = NULL;
 
-                       res = _convert_bonjour_to_hex(service->data.bonjour.query, NULL, &hex_key);
+                       res = _convert_bonjour_query_to_hex(service->data.bonjour.query, &hex_key);
                        if (res != 0) {
                                WDP_LOGE("Failed to convert Key string as hex string");
                                return -1;
@@ -4496,11 +4557,11 @@ int ws_serv_del(wfd_oem_new_service_s *service)
        }
 
        if (strstr(reply, "FAIL")) {
-               WDP_LOGE("Failed to add service");
+               WDP_LOGE("Failed to delete service");
                __WDP_LOG_FUNC_EXIT__;
                return -1;
        }
-       WDP_LOGD("Succeeded to add service");
+       WDP_LOGD("Succeeded to del service");
 
        __WDP_LOG_FUNC_EXIT__;
        return 0;
index 4dae071..64f1269 100755 (executable)
@@ -1025,9 +1025,11 @@ static gboolean wfd_client_process_request(GIOChannel *source,
                                rsp.result = WIFI_DIRECT_ERROR_OPERATION_FAILED;
                                break;
                        }
-                       WDS_LOGE("Succeeded to start scan");
-                       wfd_state_set(manager, WIFI_DIRECT_STATE_DISCOVERING);
-                       wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_DISCOVERING);
+                       WDS_LOGD("Succeeded to start scan");
+                       if (manager->local->dev_role != WFD_DEV_ROLE_GO) {
+                               wfd_state_set(manager, WIFI_DIRECT_STATE_DISCOVERING);
+                               wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_DISCOVERING);
+                       }
 
                        noti = (wifi_direct_client_noti_s*) g_try_malloc0(sizeof(wifi_direct_client_noti_s));
                        if (req.data.int1) {
@@ -1081,9 +1083,11 @@ static gboolean wfd_client_process_request(GIOChannel *source,
                                rsp.result = WIFI_DIRECT_ERROR_OPERATION_FAILED;
                                break;
                        }
-                       WDS_LOGE("Succeeded to start specific scan");
-                       wfd_state_set(manager, WIFI_DIRECT_STATE_DISCOVERING);
-                       wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_DISCOVERING);
+                       WDS_LOGD("Succeeded to start specific scan");
+                       if (manager->local->dev_role != WFD_DEV_ROLE_GO) {
+                               wfd_state_set(manager, WIFI_DIRECT_STATE_DISCOVERING);
+                               wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_DISCOVERING);
+                       }
 
                        noti = (wifi_direct_client_noti_s*) g_try_malloc0(sizeof(wifi_direct_client_noti_s));
                        if (channel == WIFI_DIRECT_DISCOVERY_FULL_SCAN)
@@ -1864,7 +1868,7 @@ static gboolean wfd_client_process_request(GIOChannel *source,
                                break;
                        }
 
-                       res = wfd_service_add(&(manager->local->services), service_type, info_str, &rsp.param1);
+                       res = wfd_service_add(service_type, info_str, &rsp.param1);
                        if (res < 0) {
                                WDS_LOGE("Failed to add service");
                                rsp.result = WIFI_DIRECT_ERROR_OPERATION_FAILED;
@@ -1884,7 +1888,7 @@ static gboolean wfd_client_process_request(GIOChannel *source,
                                break;
                        }
 
-                       res = wfd_service_del(manager->local->services, service_id);
+                       res = wfd_service_del(service_id);
                        if (res < 0) {
                                WDS_LOGE("Failed to delete service");
                                rsp.result = WIFI_DIRECT_ERROR_OPERATION_FAILED;
index d7a252c..a8a292d 100644 (file)
@@ -153,6 +153,9 @@ static int _wfd_event_update_peer(wfd_manager_s *manager, wfd_oem_dev_data_s *da
        wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_DEACTIVATED);
        manager->req_wps_mode = WFD_WPS_MODE_PBC;
 
+#ifdef TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT
+       wfd_util_stop_wifi_direct_popup();
+#endif /* TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT */
        __WDS_LOG_FUNC_EXIT__;
        return;
  }
@@ -271,6 +274,13 @@ static int _wfd_event_update_peer(wfd_manager_s *manager, wfd_oem_dev_data_s *da
                return;
        }
 
+       wfd_group_s *group = (wfd_group_s*) manager->group;
+       if (group && group->role == WFD_DEV_ROLE_GC &&
+                                               event->event_id == WFD_OEM_EVENT_PROV_DISC_REQ) {
+               WDS_LOGD("Device has GC role - ignore this provision request");
+               return;
+       }
+
 #ifdef CTRL_IFACE_DBUS
        wfd_oem_dev_data_s *edata = NULL;
 
@@ -431,6 +441,12 @@ static int _wfd_event_update_peer(wfd_manager_s *manager, wfd_oem_dev_data_s *da
                return;
        }
 
+       wfd_group_s *group = (wfd_group_s*) manager->group;
+       if (group && group->role == WFD_DEV_ROLE_GC) {
+               WDS_LOGD("Device has GC role - ignore this go neg request");
+               return;
+       }
+
 #ifdef CTRL_IFACE_DBUS
        wfd_oem_dev_data_s *edata = NULL;
 
@@ -524,7 +540,12 @@ static int _wfd_event_update_peer(wfd_manager_s *manager, wfd_oem_dev_data_s *da
        }
 
        edata = (wfd_oem_conn_data_s*) event->edata;
-       if (edata && edata->status < 0 && session->connecting_120) {
+       if (!edata) {
+               WDS_LOGE("Invalid p2p connection data");
+               return;
+        }
+
+       if (edata->status < 0 && session->connecting_120) {
                if (session->retry_gsrc) {
                        g_source_remove(session->retry_gsrc);
                        session->retry_gsrc = 0;
@@ -842,6 +863,11 @@ static int _wfd_event_update_peer(wfd_manager_s *manager, wfd_oem_dev_data_s *da
                if(peer_addr != NULL)
                        g_snprintf(noti.param1, MACSTR_LEN, MACSTR, MAC2STR(peer_addr));
        } else if (manager->state >= WIFI_DIRECT_STATE_CONNECTED) {
+#if defined (CTRL_IFACE_DBUS)
+               if(manager->local->dev_role != WFD_DEV_ROLE_GO)
+                       noti.event = WIFI_DIRECT_CLI_EVENT_DISCONNECTION_RSP;
+               else
+#endif
                noti.event = WIFI_DIRECT_CLI_EVENT_GROUP_DESTROY_RSP;
                noti.error = WIFI_DIRECT_ERROR_NONE;
        } else {
@@ -1061,6 +1087,7 @@ static int _wfd_event_update_peer(wfd_manager_s *manager, wfd_oem_dev_data_s *da
 #endif /* TIZEN_TV */
                        wfd_oem_destroy_group(manager->oem_ops, group->ifname);
                        wfd_destroy_group(manager, group->ifname);
+                       wfd_peer_clear_all(manager);
                }
        } else if (manager->state == WIFI_DIRECT_STATE_DISCONNECTING) {
                noti.event = WIFI_DIRECT_CLI_EVENT_DISCONNECTION_RSP;
@@ -1285,11 +1312,6 @@ static int _wfd_event_update_peer(wfd_manager_s *manager, wfd_oem_dev_data_s *da
                                g_snprintf(noti.param2, 256, "%s|%s", service->data.bonjour.query, service->data.bonjour.rdata);
                                WDS_LOGD("Found service: [%d: %s] - [" MACSECSTR "]", service->protocol,
                                                        service->data.bonjour.query, MAC2SECSTR(event->dev_addr));
-                       } else if (service->protocol == WFD_OEM_SERVICE_TYPE_BT_ADDR) {
-                               g_snprintf(noti.param1, MACSTR_LEN, MACSTR, MAC2STR(event->dev_addr));
-                               g_snprintf(noti.param2, MACSTR_LEN, "%s", service->data.vendor.data2);
-                               WDS_LOGD("Found service: [%d: %s] - [" MACSECSTR "]", service->protocol,
-                                                       service->data.vendor.data2, MAC2SECSTR(event->dev_addr));
                        } else {
                                WDS_LOGD("Found service is not supported");
                                goto next;
@@ -1311,14 +1333,7 @@ next:
                        noti.type = edata->type;
                        g_snprintf(noti.param1, MACSTR_LEN, MACSTR, MAC2STR(event->dev_addr));
                        switch(edata->type) {
-                               case WFD_OEM_SERVICE_TYPE_BT_ADDR:
-                                       g_snprintf(noti.param2, MACSTR_LEN, MACSTR, MAC2STR(edata->data));
-                                       return;
-                               case WFD_OEM_SERVICE_TYPE_CONTACT_INFO:
-                                       g_snprintf(noti.param2, MACSTR_LEN, "%s", edata->value);
-                                       return;
-                               default:
-                                       WDS_LOGE("Unknown type [type ID: %d]", edata->type);
+                               WDS_LOGE("Unknown type [type ID: %d]", edata->type);
                        }
                }
                wfd_client_send_event(manager, &noti);
index 7a73c93..018d792 100755 (executable)
@@ -550,8 +550,9 @@ int wfd_manager_activate(wfd_manager_s *manager)
 
        wfd_manager_local_config_set(manager);
        wfd_util_set_country();
-
+#ifdef TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT
        wfd_util_start_wifi_direct_popup();
+#endif /* TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT */
 
        res = wfd_util_get_local_dev_mac(manager->local->dev_addr);
        if (res < 0) {
@@ -633,6 +634,9 @@ int wfd_manager_deactivate(wfd_manager_s *manager)
        wfd_peer_clear_all(manager);
        wfd_local_reset_data(manager);
 
+#ifdef TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT
+       wfd_util_stop_wifi_direct_popup();
+#endif /* TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT */
        __WDS_LOG_FUNC_EXIT__;
        return WIFI_DIRECT_ERROR_NONE;
 }
@@ -786,7 +790,8 @@ int wfd_manager_cancel_connection(wfd_manager_s *manager, unsigned char *peer_ad
 
        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);
+               if (group && group->member_count > 0)
+                       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);
index 2c1dd72..a1f6c23 100755 (executable)
@@ -12,7 +12,7 @@
 #include "wifi-direct-util.h"
 
 
-int wfd_service_add(GList **services, int type, char *info_str, int *service_id)
+int wfd_service_add(int type, char *info_str, int *service_id)
 {
        __WDS_LOG_FUNC_ENTER__;
        wfd_manager_s *manager = wfd_get_manager();
@@ -40,7 +40,7 @@ int wfd_service_add(GList **services, int type, char *info_str, int *service_id)
        }
 
        service->type = type;
-       service->id = (intptr_t) &service;
+       service->id = (intptr_t) service;
 
        info1 = g_strndup(info_str, strlen(info_str));
        if(info1 == NULL) {
@@ -75,7 +75,6 @@ int wfd_service_add(GList **services, int type, char *info_str, int *service_id)
                break;
                case WIFI_DIRECT_SERVICE_TYPE_WS_DISCOVERY:
                case WIFI_DIRECT_SERVICE_TYPE_WIFI_DISPLAY:
-               case WIFI_DIRECT_SERVICE_TYPE_BT_ADDR:
                        WDS_LOGE("Not supported yet");
                        g_free(info1);
                        g_free(service);
@@ -108,14 +107,14 @@ int wfd_service_add(GList **services, int type, char *info_str, int *service_id)
 //     free(oem_service);
 
        service->str_ptr = info1;
-       *services = g_list_prepend(*services, service);
+       manager->local->services = g_list_prepend(manager->local->services, service);
        *service_id = service->id;
 
        __WDS_LOG_FUNC_EXIT__;
        return 0;
 }
 
-int wfd_service_del(GList *services, int service_id)
+int wfd_service_del(int service_id)
 {
        __WDS_LOG_FUNC_ENTER__;
        wfd_manager_s *manager = wfd_get_manager();
@@ -123,12 +122,12 @@ int wfd_service_del(GList *services, int service_id)
        wfd_service_s *service = NULL;
        int res = 0;
 
-       if (!services) {
-               WDS_LOGE("Invalid parameter");
+       if (!manager->local->services) {
+               WDS_LOGE("No services to delete");
                return -1;
        }
 
-       temp = g_list_first(services);
+       temp = g_list_first(manager->local->services);
        while (temp) {
                service = (wfd_service_s*) temp->data;
                if (service->id == service_id) {
@@ -150,7 +149,7 @@ int wfd_service_del(GList *services, int service_id)
                return -1;
        }
 
-       services = g_list_remove(services, service);
+       manager->local->services = g_list_remove(manager->local->services, service);
 
        g_free(service->str_ptr);
        g_free(service);
index e4edff3..1043a94 100755 (executable)
 #include <glib.h>
 
 #include <vconf.h>
+#if defined(TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT)
 #include <app_control.h>
+#include <aul.h>
+#endif
 #include <wifi-direct.h>
 
 #include "wifi-direct-ipc.h"
@@ -553,43 +556,69 @@ int wfd_util_get_local_dev_mac(unsigned char *dev_mac)
        return 0;
 }
 
+#ifdef TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT
 int wfd_util_start_wifi_direct_popup()
 {
        __WDS_LOG_FUNC_ENTER__;
 
-       app_control_h control = NULL;
-       if (APP_CONTROL_ERROR_NONE != app_control_create(&control)) {
-               WDS_LOGE("App control create Failed !");
+       app_control_h popup_control = NULL;
+       if (APP_CONTROL_ERROR_NONE != app_control_create(&popup_control)
+               || NULL == popup_control) {
+               WDS_LOGE("App control operation Failed !");
                return -1;
        }
-       if (APP_CONTROL_ERROR_NONE != app_control_set_operation(control,
+       if (APP_CONTROL_ERROR_NONE != app_control_set_operation(popup_control,
                APP_CONTROL_OPERATION_DEFAULT)) {
-               WDS_LOGE("App control set operation Failed !");
-               app_control_destroy(control);
+               WDS_LOGE("App control operation Failed !");
+               app_control_destroy(popup_control);
                return -1;
        }
-       if (APP_CONTROL_ERROR_NONE != app_control_set_app_id(control,
+       if (APP_CONTROL_ERROR_NONE != app_control_set_app_id(popup_control,
                "org.tizen.wifi-direct-popup")) {
-               WDS_LOGE("App control set app id Failed !");
-               app_control_destroy(control);
+               WDS_LOGE("App control operation Failed !");
+               app_control_destroy(popup_control);
                return -1;
        }
        if (APP_CONTROL_ERROR_NONE !=
-               app_control_send_launch_request(control, NULL, NULL)) {
-               WDS_LOGE("App control send launch request Failed !");
+               app_control_send_launch_request(popup_control, NULL, NULL)) {
+               WDS_LOGE("App control operation Failed !");
+               app_control_destroy(popup_control);
                return -1;
        }
 
-       app_control_destroy(control);
+       app_control_destroy(popup_control);
+
        WDS_LOGD("Succeeded to launch wifi-direct-popup");
        __WDS_LOG_FUNC_EXIT__;
        return 0;
 }
 
+int wfd_util_stop_wifi_direct_popup()
+{
+       __WDS_LOG_FUNC_ENTER__;
+
+       int pid = aul_app_get_pid("org.tizen.wifi-direct-popup");
+       if (pid > 0) {
+               if (aul_terminate_pid(pid) != AUL_R_OK) {
+                       WDS_LOGD("Failed to destroy wifi-direct-popup pid[%d]", pid);
+                       return -1;
+               } else {
+                       WDS_LOGD("Succeeded to destroy wifi-direct-popup");
+               }
+       } else {
+               WDS_LOGD("Wifi-direct-popup not running");
+       }
+
+       __WDS_LOG_FUNC_EXIT__;
+       return 0;
+}
+#endif /* TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT */
+
 int _connect_remote_device(char *ip_str)
 {
        int sock;
        int flags;
+       int res = 0;
        struct sockaddr_in remo_addr;
 
        errno = 0;
@@ -600,7 +629,13 @@ int _connect_remote_device(char *ip_str)
        }
 
        flags = fcntl(sock, F_GETFL, 0);
-       fcntl(sock, F_SETFL, flags | O_NONBLOCK);
+       res = fcntl(sock, F_SETFL, flags | O_NONBLOCK);
+       if (res < 0) {
+               WDS_LOGE("File descriptor create failed");
+               close(sock);
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
 
        memset(&remo_addr, 0x0, sizeof(remo_addr));
        remo_addr.sin_family = AF_INET;
@@ -608,7 +643,14 @@ int _connect_remote_device(char *ip_str)
        remo_addr.sin_port = htons(9999);
 
        errno = 0;
-       connect(sock, (struct sockaddr*) &remo_addr, sizeof(remo_addr));
+       res = connect(sock, (struct sockaddr*) &remo_addr, sizeof(remo_addr));
+       if (res < 0) {
+               WDS_LOGE("Failed to connect to server socket [%s]", strerror(errno));
+               close(sock);
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
        WDS_SECLOGD("Status of connection to remote device[%s] - (%s)", ip_str, strerror(errno));
 
        close(sock);