libwifi-direct refactoring 11/11111/2 accepted/tizen/ivi/stable accepted/tizen/mobile accepted/tizen_3.0.2014.q3_common accepted/tizen_3.0.m14.3_ivi accepted/tizen_3.0_ivi accepted/tizen_generic accepted/tizen_ivi tizen_3.0.2014.q3_common tizen_3.0.2014.q4_common tizen_3.0.2015.q1_common tizen_3.0.m14.2_ivi tizen_3.0.m14.3_ivi tizen_3.0_ivi accepted/tizen/20131210.210107 accepted/tizen/mobile/20131216.220415 submit/tizen/20131210.024240 submit/tizen_mobile/20141120.000000 tizen_3.0.2014.q3_common_release tizen_3.0.m14.2_ivi_release tizen_3.0.m14.3_ivi_release tizen_3.0_ivi_release
authorJiung Yu <jiung.yu@samsung.com>
Fri, 18 Oct 2013 12:07:32 +0000 (21:07 +0900)
committerJiung Yu <jiung.yu@samsung.com>
Fri, 18 Oct 2013 12:13:10 +0000 (21:13 +0900)
Change-Id: If7926334b4749076cc40f8ea886d6c2c3f8dd3bf
Signed-off-by: Yu jiung <jiung.yu@samsung.com>
18 files changed:
.cproject [new file with mode: 0644]
.project [new file with mode: 0644]
CMakeLists.txt
debian/changelog [deleted file]
debian/compat [deleted file]
debian/control [deleted file]
debian/libwifi-direct-dev.install.in [deleted file]
debian/libwifi-direct.install.in [deleted file]
debian/rules [deleted file]
include/wifi-direct-internal.h
include/wifi-direct.h
libwifi-direct.manifest [new file with mode: 0644]
packaging/libwifi-direct.changes
packaging/libwifi-direct.spec
src/include/wifi-direct-client-proxy.h
src/wifi-direct-client-proxy.c
src/wifi-direct-utils.c
src/wifi-direct.pc.in

diff --git a/.cproject b/.cproject
new file mode 100644 (file)
index 0000000..eeadd44
--- /dev/null
+++ b/.cproject
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+       <storageModule moduleId="org.eclipse.cdt.core.settings">
+               <cconfiguration id="0.868183535">
+                       <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.868183535" moduleId="org.eclipse.cdt.core.settings" name="Default">
+                               <externalSettings/>
+                               <extensions>
+                                       <extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                               </extensions>
+                       </storageModule>
+                       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+                               <configuration buildProperties="" description="" id="0.868183535" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
+                                       <folderInfo id="0.868183535." name="/" resourcePath="">
+                                               <toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.559292780" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
+                                                       <targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.559292780.52151421" name=""/>
+                                                       <builder id="org.eclipse.cdt.build.core.settings.default.builder.2024671060" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
+                                                       <tool id="org.eclipse.cdt.build.core.settings.holder.libs.1133591055" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
+                                                       <tool id="org.eclipse.cdt.build.core.settings.holder.81317164" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
+                                                               <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1111715345" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+                                                       </tool>
+                                                       <tool id="org.eclipse.cdt.build.core.settings.holder.1393382836" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
+                                                               <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1356676214" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+                                                       </tool>
+                                                       <tool id="org.eclipse.cdt.build.core.settings.holder.223759123" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
+                                                               <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.305382816" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
+                                                       </tool>
+                                               </toolChain>
+                                       </folderInfo>
+                               </configuration>
+                       </storageModule>
+                       <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+               </cconfiguration>
+       </storageModule>
+       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+               <project id="libwifi-direct.null.203364375" name="libwifi-direct"/>
+       </storageModule>
+       <storageModule moduleId="scannerConfiguration">
+               <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+               <scannerConfigBuildInfo instanceId="0.684608643">
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+               </scannerConfigBuildInfo>
+               <scannerConfigBuildInfo instanceId="0.868183535">
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+               </scannerConfigBuildInfo>
+       </storageModule>
+</cproject>
diff --git a/.project b/.project
new file mode 100644 (file)
index 0000000..9b45fec
--- /dev/null
+++ b/.project
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>libwifi-direct</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+                       <triggers>clean,full,incremental,</triggers>
+                       <arguments>
+                               <dictionary>
+                                       <key>?name?</key>
+                                       <value></value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.append_environment</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
+                                       <value>all</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.buildArguments</key>
+                                       <value></value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.buildCommand</key>
+                                       <value>make</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
+                                       <value>clean</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.contents</key>
+                                       <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+                                       <value>false</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.enableFullBuild</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
+                                       <value>all</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.stopOnError</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+                                       <value>true</value>
+                               </dictionary>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+                       <triggers>full,incremental,</triggers>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.tizen.nativecpp.apichecker.core.builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.cdt.core.cnature</nature>
+               <nature>org.eclipse.cdt.core.ccnature</nature>
+               <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+               <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+               <nature>org.tizen.nativecpp.apichecker.core.tizenCppNature</nature>
+       </natures>
+</projectDescription>
index f4ac205..702526d 100644 (file)
@@ -4,6 +4,7 @@ PROJECT(libwifi-direct C)
 #SET(PREFIX $(CMAKE_INSTALL_PREFIX))
 SET(prefix "/usr")
 SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
 SET(INCLUDEDIR "\${prefix}/include")
 
 ADD_SUBDIRECTORY(src)
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644 (file)
index 958603f..0000000
+++ /dev/null
@@ -1,352 +0,0 @@
-libwifi-direct (0.3.7) unstable; urgency=low
-
-  * Prevent issue fixed
-  * Git : rsa/framework/connectivity/libwifi-direct
-  * Tag : libwifi-direct_0.3.7
-
- -- Gibyoung Kim <lastkgb.kim@samsung.com>  Mon, 6 May 2013 17:19:50 +0900
-
-libwifi-direct (0.3.6) unstable; urgency=low
-
-  * Boilerplate updated
-  * Git : rsa/framework/connectivity/libwifi-direct
-  * Tag : libwifi-direct_0.3.6
-
- -- Gibyoung Kim <lastkgb.kim@samsung.com>  Thu, 2 May 2013 18:05:32 +0900
-
-libwifi-direct (0.3.5) unstable; urgency=low
-
-  * Prevent issue resolved
-  * Git : rsa/framework/connectivity/libwifi-direct
-  * Tag : libwifi-direct_0.3.5
-
- -- Gibyoung Kim <lastkgb.kim@samsung.com>  Tue, 23 Apr 2013 23:11:42 +0900
-
-libwifi-direct (0.3.4) unstable; urgency=low
-
-  * Fix bug of invitation behavior
-  * Git : rsa/framework/connectivity/libwifi-direct
-  * Tag : libwifi-direct_0.3.4
-
- -- Gibyoung Kim <lastkgb.kim@samsung.com>  Sun, 3 Jan 2013 02:53:04 +0900
-
-libwifi-direct (0.3.3) unstable; urgency=low
-
-  * Package Update
-  * Git : rsa/framework/connectivity/libwifi-direct
-  * Tag : libwifi-direct_0.3.3
-
- -- Gibyoung Kim <lastkgb.kim@samsung.com>  Fri, 25 Jan 2013 21:09:15 +0900
-
-libwifi-direct (0.3.2) unstable; urgency=low
-
-  * DLog macro is changed
-  * Git : rsa/framework/connectivity/libwifi-direct
-  * Tag : libwifi-direct_0.3.2
-
- -- Gibyoung Kim <lastkgb.kim@samsung.com>  Tue, 18 Dec 2012 20:00:45 +0900
-
-libwifi-direct (0.3.1) unstable; urgency=low
-
-  * Implementation of wifi_direct_get_device_name / wifi_direct_set_device_name
-  * Implementation of persistent mode
-  * Git : rsa/framework/connectivity/libwifi-direct
-  * Tag : libwifi-direct_0.3.1
-
- -- Gibyoung Kim <lastkgb.kim@samsung.com>  Tue, 11 Dec 2012 17:52:11 +0900
-
-libwifi-direct (0.3.0) unstable; urgency=low
-
-  * Update from private
-  * Git : rsa/framework/connectivity/libwifi-direct
-  * Tag : libwifi-direct_0.3.0
-
- -- Gibyoung Kim <lastkgb.kim@samsung.com>  Fri, 23 Nov 2012 22:26:45 +0900
-
-libwifi-direct (0.2.15) unstable; urgency=low
-
-  * Install vconf keys with -i option
-  * Git : rsa/framework/connectivity/libwifi-direct
-  * Tag : libwifi-direct_0.2.15
-
- -- Dongwook Lee <dwmax.lee@samsung.com>  Fri, 07 Sep 2012 19:38:12 +0900
-
-libwifi-direct (0.2.14) unstable; urgency=low
-
-  * changed writing option of vconftool to solve get ip address problerm.
-  * Git : rsa/framework/connectivity/libwifi-direct
-  * Tag : libwifi-direct_0.2.14
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Fri, 07 Sep 2012 11:08:12 +0900
-
-libwifi-direct (0.2.13) unstable; urgency=low
-
-  * modified the activation problerm (changed plugin so)
-  * Git : rsa/framework/connectivity/libwifi-direct
-  * Tag : libwifi-direct_0.2.13
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Mon, 03 Sep 2012 12:33:33 +0900
-
-libwifi-direct (0.2.12) unstable; urgency=low
-
-  * modified the activation problerm
-  * Git : rsa/framework/connectivity/libwifi-direct
-  * Tag : libwifi-direct_0.2.12
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Fri, 31 Aug 2012 18:03:23 +0900
-
-libwifi-direct (0.2.11) unstable; urgency=low
-
-  * Fix emulator build errro.
-  * Git : rsa/framework/connectivity/libwifi-direct
-  * Tag : libwifi-direct_0.2.11
-
- -- Dongwook Lee <dwmax.lee@samsung.com>  Wed, 29 Aug 2012 17:48:39 +0900
-
-libwifi-direct (0.2.10) unstable; urgency=low
-
-  * changed the binary of wifi-direct-manager.
-  * Git : rsa/framework/connectivity/libwifi-direct
-  * Tag : libwifi-direct_0.2.10
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Tue, 28 Aug 2012 17:46:39 +0900
-
-libwifi-direct (0.2.9) unstable; urgency=low
-
-  * modified to loading binary of wifi-direct-manager when installing package.
-  * Git : framework/connectivity/libwifi-direct
-  * Tag : libwifi-direct_0.2.9
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Fri, 24 Aug 2012 18:45:19 +0900
-
-libwifi-direct (0.2.8) unstable; urgency=low
-
-  * tagging "tizen_build"
-  * Git : framework/connectivity/libwifi-direct
-  * Tag : libwifi-direct_0.2.8
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Mon, 13 Aug 2012 15:37:09 +0900
-
-libwifi-direct (0.2.7) unstable; urgency=low
-
-  * stripped package
-  * Git : slp/pkgs/l/libwifi-direct
-  * Tag : libwifi-direct_0.2.7
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Mon, 16 Jul 2012 13:08:38 +0900
-
-libwifi-direct (0.2.5) unstable; urgency=low
-
-  * applied new APIs.
-  * Git : slp/pkgs/l/libwifi-direct
-  * Tag : libwifi-direct_0.2.5
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Fri, 01 Jun 2012 15:20:07 +0900
-
-libwifi-direct (0.2.4) unstable; urgency=low
-
-  * package version update
-  * Git : slp/pkgs/l/libwifi-direct
-  * Tag : libwifi-direct_0.2.4
-
- -- Dongwook Lee <dwmax.lee@samsung.com>  Thu, 24 May 2012 02:05:08 +0900
-
-libwifi-direct (0.2.3) unstable; urgency=low
-
-  * IP lease (DHCP) event is added.
-  * Git : slp/pkgs/l/libwifi-direct
-  * Tag : libwifi-direct_0.2.3
-
- -- Dongwook Lee <dwmax.lee@samsung.com>  Mon, 21 May 2012 11:46:18 +0900
-
-libwifi-direct (0.2.2) unstable; urgency=low
-
-  * package update
-  * Git : slp/pkgs/l/libwifi-direct
-  * Tag : libwifi-direct_0.2.2
-
- -- Dongwook Lee <dwmax.lee@samsung.com>  Sat, 19 May 2012 01:39:34 +0900
-
-libwifi-direct (0.2.1) unstable; urgency=low
-
-  * added new APIs for bada
-  * Git : slp/pkgs/l/libwifi-direct
-  * Tag : libwifi-direct_0.2.1
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Wed, 09 May 2012 13:39:38 +0900
-
-libwifi-direct (0.2.0) unstable; urgency=low
-
-  * Wi-Fi Direct Library initial upload
-  * Git : slp/pkgs/l/libwifi-direct
-  * Tag : libwifi-direct_0.2.0
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Mon, 23 Apr 2012 11:49:23 +0900
-
-wifi-direct (0.1.8) unstable; urgency=low
-
-  * fixed i386 build break
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.1.8
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Thu, 19 Apr 2012 23:03:05 +0900
-
-wifi-direct (0.1.7) unstable; urgency=low
-
-  * fixed i386 build break
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.1.7
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Thu, 19 Apr 2012 22:51:36 +0900
-
-wifi-direct (0.1.6) unstable; urgency=low
-
-  * modified the defect of displaying popup
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.1.6
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Thu, 19 Apr 2012 22:28:09 +0900
-
-wifi-direct (0.1.5) unstable; urgency=low
-
-  * modified spec file / modified the foreach API
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.1.5
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Thu, 29 Mar 2012 15:20:25 +0900
-
-wifi-direct (0.1.4) unstable; urgency=low
-
-  * Check socket fd is writable to avoid accessing a closed socket fd.
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.1.4
-
- -- Dongwook Lee <dwmax.lee@samsung.com>  Tue, 20 Mar 2012 13:14:25 +0900
-
-wifi-direct (0.1.3) unstable; urgency=low
-
-  * applied the changed dbus interface name of SONET
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.1.3
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Tue, 20 Mar 2012 09:57:15 +0900
-
-wifi-direct (0.1.2) unstable; urgency=low
-
-  * fixed build dependancy problerm
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.1.2
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Fri, 16 Mar 2012 13:41:24 +0900
-
-wifi-direct (0.1.1) unstable; urgency=low
-
-  * Applied C API style (Phase 2)
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.1.1
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Wed, 14 Mar 2012 13:57:03 +0900
-
-wifi-direct (0.1.0) unstable; urgency=low
-
-  * Applied C API style (Phase 2)
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.1.0
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Wed, 14 Mar 2012 13:03:46 +0900
-
-wifi-direct (0.0.11) unstable; urgency=low
-
-  * changed connection callback function / changed deactivation oem to excute wifi-direct drive off
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.0.11
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Tue, 28 Feb 2012 16:40:34 +0900
-
-wifi-direct (0.0.10) unstable; urgency=low
-
-  * added launching system popup application / fixed disconnection defect
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.0.10
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Tue, 21 Feb 2012 17:29:54 +0900
-
-wifi-direct (0.0.9) unstable; urgency=low
-
-  * fixed i386 build error
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.0.9
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Thu, 16 Feb 2012 21:47:42 +0900
-
-wifi-direct (0.0.8) unstable; urgency=low
-
-  * Applied C API style
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.0.8
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Thu, 16 Feb 2012 13:57:02 +0900
-
-wifi-direct (0.0.7) unstable; urgency=low
-
-  * Rollback to wifi-direct_0.0.6 + sonet dbus name change(com.samsung.sonet->net.sonet)
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.0.7
-
- -- Dongwook Lee <dwmax.lee@samsung.com>>  Fri, 10 Feb 2012 10:15:01 +0900
-
-wifi-direct (0.0.6) unstable; urgency=low
-
-  * Fixed S1-1045 (wl0.1 default interface issue) / updated doxygen
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.0.6
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Wed, 01 Feb 2012 19:12:44 +0900
-
-wifi-direct (0.0.5) unstable; urgency=low
-
-  * Fixed i386 build error issue
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.0.5
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Thu, 19 Jan 2012 14:28:15 +0900
-
-wifi-direct (0.0.4) unstable; urgency=low
-
-  * Fixed i386 build error issue
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.0.4
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Thu, 19 Jan 2012 14:15:44 +0900
-
-wifi-direct (0.0.3) unstable; urgency=low
-
-  * Fixed i386 build error issue
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.0.3
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Tue, 17 Jan 2012 00:01:17 +0900
-
-wifi-direct (0.0.2) unstable; urgency=low
-
-  * Fixed uploading issue
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.0.2
-
- -- Taeksu Shin <taeksu.shin@samsung.com>  Mon, 16 Jan 2012 23:39:22 +0900
-
-wifi-direct (0.0.1) unstable; urgency=low
-
-  * Applied new release
-  * Git : slp/pkgs/w/wifi-direct
-  * Tag : wifi-direct_0.0.1
-
- -- Sungsik Jang <sungsik.jang@samsung.com>  Mon, 16 Jan 2012 21:42:30 +0900
-
-wifi-direct (0.0.1) unstable; urgency=low
-
-  * debian/changelog
-
- -- Misun Kim <ms0123.kim@samsung.com>  Tue, 22 Feb 2011 16:54:20 +0900
-
-
diff --git a/debian/compat b/debian/compat
deleted file mode 100644 (file)
index 7ed6ff8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/debian/control b/debian/control
deleted file mode 100644 (file)
index bb6ba23..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-Source: libwifi-direct
-Section: net
-Priority: extra
-Maintainer: Dongwook Lee <dwmax.lee@samsung.com>, Sungsik Jang <sungsik.jang@samsung.com>
-Uploaders: Dongwook Lee <dwmax.lee@samsung.com> Sungsik Jang <sungsik.jang@samsung.com>, Taeksu Shin <taeksu.shin@samsung.com>
-Build-Depends: debhelper (>= 5), autotools-dev, libslp-setting-dev, libglib2.0-dev, dlog-dev, libdbus-glib-1-dev
-Standards-Version: 3.7.2
-
-Package: libwifi-direct
-Section: libs
-Architecture: any 
-Depends: ${shlibs:Depends}, ${misc:Depends},  libslp-setting-0, libglib2.0-0 
-Description: wifi direct library (Shared Library)
-
-Package: libwifi-direct-dev
-Section: libs
-Architecture: any 
-Depends: libwifi-direct (= ${Source-Version}), libslp-setting-dev, libglib2.0-dev
-Description: wifi direct (Development)
-
diff --git a/debian/libwifi-direct-dev.install.in b/debian/libwifi-direct-dev.install.in
deleted file mode 100644 (file)
index 7689c5c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-@PREFIX@/include/wifi-direct/*.h
-@PREFIX@/lib/*.la
-@PREFIX@/lib/pkgconfig/wifi-direct.pc
diff --git a/debian/libwifi-direct.install.in b/debian/libwifi-direct.install.in
deleted file mode 100644 (file)
index 43ae715..0000000
+++ /dev/null
@@ -1 +0,0 @@
-@PREFIX@/lib/libwifi*.so*
diff --git a/debian/rules b/debian/rules
deleted file mode 100755 (executable)
index 20f4d76..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-CFLAGS ?= -Wall -g
-CXXFLAGS ?=  -Wall -g
-LDFLAGS ?= 
-PREFIX ?= /usr
-DATADIR ?= /opt
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
-       CFLAGS += -O0
-       CXXFLAGS += -O0
-else
-       CFLAGS += -O2
-       CXXFLAGS += -O2
-endif
-
-CFLAGS += -DX1SETTING -D_DLOG_UTIL
-#LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
-LDFLAGS += -Wl,--rpath=$(PREFIX)/lib
-
-
-configure: configure-stamp
-configure-stamp:
-       dh_testdir
-       # Add here commands to configure the package.
-       CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" cmake . -DCMAKE_INSTALL_PREFIX=$(PREFIX)
-
-       touch configure-stamp
-
-build: build-stamp
-
-build-stamp: configure-stamp 
-       dh_testdir
-
-       # Add here commands to compile the package.
-       $(MAKE) -j5
-
-       dpkg-architecture
-       echo "deb-arch = ${DEB_BUILD_ARCH}"
-               
-       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
-               cat $$f > $${f%.in}; \
-               sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
-               sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
-        done
-       
-       touch $@
-
-clean:
-       dh_testdir
-       dh_testroot
-       rm -f build-stamp configure-stamp
-
-       # Add here commands to clean up after the build process.
-       -$(MAKE) clean
-       rm -rf CMakeCache.txt
-       rm -rf CMakeFiles
-       rm -rf cmake_install.cmake
-       rm -rf Makefile
-       rm -rf install_manifest.txt
-       
-       rm -rf data/CMakeCache.txt
-       rm -rf data/CMakeFiles
-       rm -rf data/cmake_install.cmake
-       rm -rf data/install_manifest.txt
-       rm -rf data/Makefile
-       
-       rm -rf data/po/CMakeCache.txt
-       rm -rf data/po/CMakeFiles
-       rm -rf data/po/cmake_install.cmake
-       rm -rf data/po/install_manifest.txt
-       rm -rf data/po/Makefile
-       rm -rf data/po/*.mo
-
-       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
-               rm -f $${f%.in}; \
-       done
-
-       dh_clean 
-
-install: build
-       dh_testdir
-       dh_testroot
-       dh_clean -k 
-       dh_installdirs
-
-       # Add here commands to install the package into debian/wavplayer.
-       $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
-       dh_testdir
-       dh_testroot
-       dh_installchangelogs 
-       dh_installdocs
-       dh_installexamples
-       dh_install --sourcedir=debian/tmp
-#      dh_installmenu
-#      dh_installdebconf       
-#      dh_installlogrotate
-#      dh_installemacsen
-#      dh_installpam
-#      dh_installmime
-#      dh_python
-#      dh_installinit
-#      dh_installcron
-#      dh_installinfo
-       dh_installman
-       dh_link
-#      dh_strip --dbg-package=
-       dh_compress
-       dh_fixperms
-#      dh_perl
-       dh_makeshlibs
-       dh_installdeb
-       dh_shlibdeps
-       dh_gencontrol
-       dh_md5sums
-       dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
index 0f4a6d0..1042c96 100644 (file)
@@ -57,6 +57,7 @@ typedef unsigned int ipv4_addr_t;
 
 #define IPSTR "%d.%d.%d.%d"
 
+#define WIFI_DIRECT_WPA_LEN 8
 #define WIFI_DIRECT_MAX_SSID_LEN 32
 #define WIFI_DIRECT_MAX_DEVICE_NAME_LEN 32
 #define WIFI_DIRECT_WPS_PIN_LEN 8
@@ -80,6 +81,7 @@ typedef enum
        WIFI_DIRECT_CMD_GET_DISCOVERY_RESULT,
        WIFI_DIRECT_CMD_GET_LINK_STATUS,
        WIFI_DIRECT_CMD_CONNECT,
+
        WIFI_DIRECT_CMD_DISCONNECT_ALL,
        WIFI_DIRECT_CMD_CREATE_GROUP,
        WIFI_DIRECT_CMD_IS_GROUPOWNER,
@@ -90,21 +92,29 @@ typedef enum
        WIFI_DIRECT_CMD_SET_CONFIG,
        WIFI_DIRECT_CMD_SEND_PROVISION_DISCOVERY_REQ,
        WIFI_DIRECT_CMD_SEND_CONNECT_REQ,
+
        WIFI_DIRECT_CMD_ACTIVATE_PUSHBUTTON,
        WIFI_DIRECT_CMD_SET_WPS_PIN,
        WIFI_DIRECT_CMD_GET_WPS_PIN,
        WIFI_DIRECT_CMD_GENERATE_WPS_PIN,
        WIFI_DIRECT_CMD_GET_INCOMMING_PEER_INFO,
        WIFI_DIRECT_CMD_SET_WPA,
+       WIFI_DIRECT_CMD_GET_PASSPHRASE,
        WIFI_DIRECT_CMD_GET_SUPPORTED_WPS_MODE,
-       WIFI_DIRECT_CMD_SET_CURRENT_WPS_MODE,
+       WIFI_DIRECT_CMD_GET_LOCAL_WPS_MODE,
+       WIFI_DIRECT_CMD_SET_REQ_WPS_MODE,       //30
+
+       WIFI_DIRECT_CMD_GET_REQ_WPS_MODE,
        WIFI_DIRECT_CMD_GET_CONNECTED_PEERS_INFO,
        WIFI_DIRECT_CMD_CANCEL_GROUP,
+       WIFI_DIRECT_CMD_CANCEL_CONNECTION,
+       WIFI_DIRECT_CMD_REJECT_CONNECTION,
        WIFI_DIRECT_CMD_DISCONNECT,
        WIFI_DIRECT_CMD_SET_GO_INTENT,
        WIFI_DIRECT_CMD_GET_GO_INTENT,
        WIFI_DIRECT_CMD_GET_DEVICE_MAC,
        WIFI_DIRECT_CMD_IS_AUTONOMOUS_GROUP,
+
        WIFI_DIRECT_CMD_SET_MAX_CLIENT,
        WIFI_DIRECT_CMD_GET_MAX_CLIENT,
        WIFI_DIRECT_CMD_SET_AUTOCONNECTION_MODE,
@@ -115,9 +125,12 @@ typedef enum
        WIFI_DIRECT_CMD_ACTIVATE_PERSISTENT_GROUP,
        WIFI_DIRECT_CMD_DEACTIVATE_PERSISTENT_GROUP,
        WIFI_DIRECT_CMD_IS_PERSISTENT_GROUP,
+
        WIFI_DIRECT_CMD_GET_PERSISTENT_GROUP_INFO,
+
        WIFI_DIRECT_CMD_REMOVE_PERSISTENT_GROUP,
        WIFI_DIRECT_CMD_GET_DEVICE_NAME,
+
        WIFI_DIRECT_CMD_SET_DEVICE_NAME,
 
        WIFI_DIRECT_CMD_SET_OEM_LOGLEVEL,
@@ -165,6 +178,7 @@ typedef struct
        char device_name[WIFI_DIRECT_MAX_DEVICE_NAME_LEN + 1];
        int channel;
        wifi_direct_wps_type_e wps_config;
+       wifi_direct_wps_type_e req_wps_config;
        int max_clients;
        bool hide_SSID;
        int group_owner_intent;
@@ -221,12 +235,9 @@ typedef struct
 
 typedef struct
 {
-       bool listen_only;
-       int timeout;
-
-       int peer_index;
+       int int1;
+       int int2;
        unsigned char mac_addr[6];
-
 } wifi_direct_client_request_data_s;
 
 
index c62c899..95d500d 100644 (file)
@@ -116,7 +116,7 @@ typedef enum
  */
 typedef enum
 {
-       WIFI_DIRECT_SECONDARY_DEVICE_TYPE_COMPUTER_PC = 1,                              /**< */
+       WIFI_DIRECT_SECONDARY_DEVICE_TYPE_COMPUTER_PC = 1,                      /**< */
        WIFI_DIRECT_SECONDARY_DEVICE_TYPE_COMPUTER_SERVER = 2,          /**< */
        WIFI_DIRECT_SECONDARY_DEVICE_TYPE_COMPUTER_MEDIA_CTR = 3,       /**< */
        WIFI_DIRECT_SECONDARY_DEVICE_TYPE_COMPUTER_UMPC = 4,            /**< */
@@ -196,7 +196,6 @@ typedef enum
        WIFI_DIRECT_PRIMARY_DEVICE_TYPE_OTHER = 255                     /**< */
 } wifi_direct_primary_device_type_e;
 
-
 /**
 * @brief Enumeration for Wi-Fi WPS type
 */
@@ -306,8 +305,6 @@ typedef void (*wifi_direct_connection_state_changed_cb) (int error_code,
                                                                                                                 const char *mac_address,
                                                                                                                 void *user_data);
 
-
-
 /**
 * @brief Called when IP address of client is assigned when your device is group owner.
 * @param[in] mac_address  The MAC address of connection peer
@@ -2067,6 +2064,57 @@ int wifi_direct_get_secondary_device_type(wifi_direct_secondary_device_type_e *t
 int wifi_direct_accept_connection(char *mac_address);
 
 
+/*****************************************************************************************/
+/* wifi_direct_get_passphrase API function prototype
+ * int wifi_direct_get_passphrase(char** passphrase)
+ */
+/**
+ * \brief If a client create Group (Soft AP), this API shall get wpa password. \n
+ * @param passphrase              Pointer to store wpa password. Application must free this memory.
+ *
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \warning
+ *  None
+ *
+ *
+ * \return Return Type (int) \n
+ * - WIFI_DIRECT_ERROR_NONE on success \n
+ * - WIFI_DIRECT_ERROR_OPERATION_FAILED for "Unkown error" \n
+ * - WIFI_DIRECT_ERROR_OUT_OF_MEMORY for "Out of memory" \n
+ * - WIFI_DIRECT_ERROR_COMMUNICATION_FAILED for "I/O error" \n
+ * - WIFI_DIRECT_ERROR_NOT_PERMITTED for "Operation not permitted" \n
+ * - WIFI_DIRECT_ERROR_INVALID_PARAMETER for "Invalid function parameter" \n
+ * - WIFI_DIRECT_ERROR_RESOURCE_BUSY for "Device or resource busy" \n
+ * - WIFI_DIRECT_ERROR_STRANGE_CLIENT for "Invalid Client" \n
+ *
+ * \par Prospective Clients:
+ * External Apps.
+ *
+ * \code
+ *
+ * #include <wifi-direct.h>
+ *
+ * void foo()
+ * {
+ * int  result;
+ * char* wpa = NULL;
+ *
+ * result=wifi_direct_get_passphrase(&wpa);
+ *
+ * if(result == WIFI_DIRECT_ERROR_NONE)........//getting wpa passphrase is successful
+ *
+ * free(wpa); // Application should free the memory
+ *
+ *\endcode
+ *
+ *\remarks None.
+ *
+ ******************************************************************************/
+int wifi_direct_get_passphrase(char **passphrase);
+
 
 /*****************************************************************************************/
 /* wifi_direct_set_wpa_passphrase API function prototype
@@ -2410,21 +2458,31 @@ typedef bool(*wifi_direct_supported_wps_type_cb)(wifi_direct_wps_type_e type, vo
 int wifi_direct_foreach_supported_wps_types(wifi_direct_supported_wps_type_cb callback, void *user_data);
 
 /**
- * @brief Sets the WPS(Wi-Fi Protected Setup) type.
+ * @brief Gets the WPS(Wi-Fi Protected Setup) type.
+ * @param[out] type  The type of WPS
+ * @retval #WIFI_DIRECT_ERROR_NONE  Successful
+ * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @see wifi_direct_foreach_supported_wps_types()
+ */
+int wifi_direct_get_local_wps_type(wifi_direct_wps_type_e *type);
+
+/**
+ * @brief Sets the requested WPS(Wi-Fi Protected Setup) type.
  * @param[in] type  The type of WPS
  * @retval #WIFI_DIRECT_ERROR_NONE  Successful
  * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
  * @see wifi_direct_foreach_supported_wps_types()
  */
-int wifi_direct_set_wps_type(wifi_direct_wps_type_e type);
+int wifi_direct_set_req_wps_type(wifi_direct_wps_type_e type);
+
 /**
- * @brief Gets the WPS(Wi-Fi Protected Setup) type.
+ * @brief Gets the requested WPS(Wi-Fi Protected Setup) type.
  * @param[out] type  The type of WPS
  * @retval #WIFI_DIRECT_ERROR_NONE  Successful
  * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER  Invalid parameter
  * @see wifi_direct_foreach_supported_wps_types()
  */
-int wifi_direct_get_wps_type(wifi_direct_wps_type_e *type);
+int wifi_direct_get_req_wps_type(wifi_direct_wps_type_e *type);
 
 /**
 * @brief Sets the intent of a group owner.
diff --git a/libwifi-direct.manifest b/libwifi-direct.manifest
new file mode 100644 (file)
index 0000000..97e8c31
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
index 8759bfe..528ab43 100644 (file)
@@ -1,3 +1,70 @@
-* Tue May 28 2013 Baptiste DURAND <baptiste.durand@eurogiciel.fr> accepted/tizen/20130520.101028@920a701
-- Fix spec file according to rpmlint rules
-- Fix for 64 bits compatibility
+* Tue, 15 Oct 2013 Jiung Yu <jiung.yu@samsung.com> (1.0.0)
+  - add CMD_SET_REQ_WPS_MODE CMD_GET_REQ_WPS_MODE
+
+* Mon, 23 Sep 2013 Jiung Yu <jiung.yu@samsung.com> (0.3.10)
+  - Add wifi_direct_get_passphrase API
+
+* Mon, 29 Jul 2013 Jiung Yu <jiung.yu@samsung.com> (0.3.9)
+  - Modifying IPC parameter
+
+* Fri, 14 Jun 2013 Gibyoung Kim <lastkgb.kim@samsung.com> (0.3.8)
+  - Code cleaning
+
+* Mon, 6 May 2013 Gibyoung Kim <lastkgb.kim@samsung.com> (0.3.7)
+  - Prevent issue fixed
+
+* Thu, 2 May 2013 Gibyoung Kim <lastkgb.kim@samsung.com> (0.3.6)
+  - Boilerplate updated
+
+* Tue, 23 Apr 2013 Gibyoung Kim <lastkgb.kim@samsung.com> (0.3.5)
+  - Prevent issue resolved
+
+* Sun, 3 Jan 2013 Gibyoung Kim <lastkgb.kim@samsung.com> (0.3.4)
+  - Fix bug of invitation behavior
+
+* Fri, 25 Jan 2013 Gibyoung Kim <lastkgb.kim@samsung.com> (0.3.3)
+  - Package Update
+
+* Tue, 18 Dec 2012 Gibyoung Kim <lastkgb.kim@samsung.com> (0.3.2)
+  - DLog macro is changed
+
+* Tue, 11 Dec 2012 Gibyoung Kim <lastkgb.kim@samsung.com> (0.3.1)
+  - Implementation of wifi_direct_get_device_name / wifi_direct_set_device_name
+  - Implementation of persistent mode
+
+* Fri, 23 Nov 2012 Gibyoung Kim <lastkgb.kim@samsung.com> (0.3.0)
+  - Update from private
+
+* Changes before version 0.3.0
+  - Install vconf keys with -i option
+  - changed writing option of vconftool to solve get ip address problerm.
+  - modified the activation problerm (changed plugin so)
+  - modified the activation problerm
+  - Fix emulator build errro.
+  - changed the binary of wifi-direct-manager.
+  - modified to loading binary of wifi-direct-manager when installing package.
+  - tagging "tizen_build"
+  - stripped package
+  - applied new APIs.
+  - package version update
+  - IP lease (DHCP) event is added.
+  - package update
+  - added new APIs for bada
+  - Wi-Fi Direct Library initial upload
+  - fixed i386 build break
+  - modified the defect of displaying popup
+  - modified spec file / modified the foreach API
+  - Check socket fd is writable to avoid accessing a closed socket fd.
+  - applied the changed dbus interface name of SONET
+  - fixed build dependancy problerm
+  - Applied C API style (Phase 2)
+  - changed connection callback function / changed deactivation oem to excute wifi-direct drive off
+  - added launching system popup application / fixed disconnection defect
+  - fixed i386 build error
+  - Applied C API style
+  - Rollback to wifi-direct_0.0.6 + sonet dbus name change(com.samsung.sonet->net.sonet)
+  - Fixed S1-1045 (wl0.1 default interface issue) / updated doxygen
+  - Fixed i386 build error issue
+  - Fixed uploading issue
+  - Applied new release
+  - debian/changelog
index abb31c0..2381775 100644 (file)
@@ -1,8 +1,8 @@
 Name:       libwifi-direct
-Summary:    Wifi direct library
-Version:    0.3.7
+Summary:    Wifi Direct Library
+Version:    1.0.0
 Release:    1
-Group:      Connectivity/Wireless
+Group:      Network & Connectivity/Wireless 
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1001:    libwifi-direct.manifest
@@ -15,12 +15,12 @@ BuildRequires:  gettext-devel
 wifi direct library (Shared Library)
 
 %package devel 
-Summary:    Wifi direct library (Shared Library) (Developement)
+Summary:    Wifi Direct Library (Shared Library) (Development)
 Group:      Development/Libraries
 Requires:   %{name} = %{version}-%{release}
 
 %description devel
-wifi direct library (Shared Library) (Developement)
+wifi direct library (Shared Library) (Development)
 
 %prep
 %setup -q
index 12c8d43..0668515 100644 (file)
 
 #endif /** _DLOG_UTIL */
 
+#define SOCK_FD_MIN 3
+#define MACSTR_LEN 18
+#define MACADDR_LEN 6
+#define IPSTR_LEN 16
+#define WFD_SOCK_FILE_PATH "/tmp/wfd_client_socket"
+#define WFD_LAUNCH_SERVER_DBUS "dbus-send --system --print-reply --dest=net.netconfig /net/netconfig/wifi net.netconfig.wifi.LaunchDirect"
+
 typedef struct
 {
        bool is_registered;
index 3955d13..da15efb 100644 (file)
@@ -141,15 +141,15 @@ static char *__wfd_print_event(wfd_client_event_e event)
 {
        switch (event)
        {
+       case WIFI_DIRECT_CLI_EVENT_INVALID:
+               return "WIFI_DIRECT_CLI_EVENT_INVALID";
+               break;
        case WIFI_DIRECT_CLI_EVENT_ACTIVATION:
                return "ACTIVATION";
                break;
        case WIFI_DIRECT_CLI_EVENT_DEACTIVATION:
                return "DEACTIVATION";
                break;
-       case WIFI_DIRECT_CLI_EVENT_INVALID:
-               return "WIFI_DIRECT_CLI_EVENT_INVALID";
-               break;
        case WIFI_DIRECT_CLI_EVENT_DISCOVER_START:
                return "WIFI_DIRECT_CLI_EVENT_DISCOVER_START";
                break;
@@ -165,29 +165,27 @@ static char *__wfd_print_event(wfd_client_event_e event)
        case WIFI_DIRECT_CLI_EVENT_DISCOVER_FOUND_PEERS:
                return "WIFI_DIRECT_CLI_EVENT_DISCOVER_FOUND_PEERS";
                break;
-
-       case WIFI_DIRECT_CLI_EVENT_CONNECTION_REQ:
-               return "WIFI_DIRECT_CLI_EVENT_CONNECTION_REQ";
-               break;
-
        case WIFI_DIRECT_CLI_EVENT_CONNECTION_START:
                return "WIFI_DIRECT_CLI_EVENT_CONNECTION_START";
                break;
-
+       case WIFI_DIRECT_CLI_EVENT_CONNECTION_REQ:
+               return "WIFI_DIRECT_CLI_EVENT_CONNECTION_REQ";
+               break;
        case WIFI_DIRECT_CLI_EVENT_CONNECTION_RSP:
                return "WIFI_DIRECT_CLI_EVENT_CONNECTION_RSP";
                break;
        case WIFI_DIRECT_CLI_EVENT_CONNECTION_WPS_REQ:
                return "WIFI_DIRECT_CLI_EVENT_CONNECTION_WPS_REQ";
                break;
-
        case WIFI_DIRECT_CLI_EVENT_DISCONNECTION_RSP:
                return "WIFI_DIRECT_CLI_EVENT_DISCONNECTION_RSP";
                break;
        case WIFI_DIRECT_CLI_EVENT_DISCONNECTION_IND:
                return "WIFI_DIRECT_CLI_EVENT_DISCONNECTION_IND";
                break;
-
+       case WIFI_DIRECT_CLI_EVENT_DISASSOCIATION_IND:
+               return "WIFI_DIRECT_CLI_EVENT_DISASSOCIATION_IND";
+               break;
        case WIFI_DIRECT_CLI_EVENT_GROUP_CREATE_RSP:
                return "WIFI_DIRECT_CLI_EVENT_GROUP_CREATE_RSP";
                break;
@@ -197,7 +195,9 @@ static char *__wfd_print_event(wfd_client_event_e event)
        case WIFI_DIRECT_CLI_EVENT_IP_LEASED_IND:
                return "WIFI_DIRECT_CLI_EVENT_IP_LEASED_IND";
                break;
-
+       case WIFI_DIRECT_CLI_EVENT_INVITATION_REQ:
+               return "WIFI_DIRECT_CLI_EVENT_INVITATION_REQ";
+               break;
        default:
                return "WIFI_DIRECT_CLI_EVENT_unknown";
                break;
@@ -208,24 +208,32 @@ static char *__wfd_print_error(wifi_direct_error_e error)
 {
        switch (error)
        {
-       case WIFI_DIRECT_ERROR_OPERATION_FAILED:
-               return "WIFI_DIRECT_ERROR_OPERATION_FAILED";
-       case WIFI_DIRECT_ERROR_OUT_OF_MEMORY:
-               return "WIFI_DIRECT_ERROR_OUT_OF_MEMORY";
-       case WIFI_DIRECT_ERROR_COMMUNICATION_FAILED:
-               return "WIFI_DIRECT_ERROR_COMMUNICATION_FAILED";
+       case WIFI_DIRECT_ERROR_NONE:
+               return "WIFI_DIRECT_ERROR_NONE";
        case WIFI_DIRECT_ERROR_NOT_PERMITTED:
                return "WIFI_DIRECT_ERROR_NOT_PERMITTED";
+       case WIFI_DIRECT_ERROR_OUT_OF_MEMORY:
+               return "WIFI_DIRECT_ERROR_OUT_OF_MEMORY";
+       case WIFI_DIRECT_ERROR_RESOURCE_BUSY:
+               return "WIFI_DIRECT_ERROR_RESOURCE_BUSY";
        case WIFI_DIRECT_ERROR_INVALID_PARAMETER:
                return "WIFI_DIRECT_ERROR_INVALID_PARAMETER";
        case WIFI_DIRECT_ERROR_NOT_INITIALIZED:
                return "WIFI_DIRECT_ERROR_NOT_INITIALIZED";
+       case WIFI_DIRECT_ERROR_COMMUNICATION_FAILED:
+               return "WIFI_DIRECT_ERROR_COMMUNICATION_FAILED";
+       case WIFI_DIRECT_ERROR_WIFI_USED:
+               return "WIFI_DIRECT_ERROR_WIFI_USED";
+       case WIFI_DIRECT_ERROR_MOBILE_AP_USED:
+               return "WIFI_DIRECT_ERROR_MOBILE_AP_USED";
+       case WIFI_DIRECT_ERROR_CONNECTION_FAILED:
+               return "WIFI_DIRECT_ERROR_CONNECTION_FAILED";
+       case WIFI_DIRECT_ERROR_AUTH_FAILED:
+               return "WIFI_DIRECT_ERROR_AUTH_FAILED";
+       case WIFI_DIRECT_ERROR_OPERATION_FAILED:
+               return "WIFI_DIRECT_ERROR_OPERATION_FAILED";
        case WIFI_DIRECT_ERROR_TOO_MANY_CLIENT:
                return "WIFI_DIRECT_ERROR_TOO_MANY_CLIENT";
-       case WIFI_DIRECT_ERROR_RESOURCE_BUSY:
-               return "WIFI_DIRECT_ERROR_RESOURCE_BUSY";
-       case WIFI_DIRECT_ERROR_NONE:
-               return "WIFI_DIRECT_ERROR_NONE";
        default:
                WDC_LOGE("Invalid error value: [%d]", error);
                return "Invalid error";
@@ -245,31 +253,30 @@ static int __wfd_convert_client_event(wfd_client_event_e event)
                return WIFI_DIRECT_DEVICE_STATE_DEACTIVATED;
                break;
 
-       case WIFI_DIRECT_CLI_EVENT_DISCOVER_START:
-               return WIFI_DIRECT_DISCOVERY_STARTED;
-               break;
        case WIFI_DIRECT_CLI_EVENT_DISCOVER_START_LISTEN_ONLY:
                return WIFI_DIRECT_ONLY_LISTEN_STARTED;
                break;
-       case WIFI_DIRECT_CLI_EVENT_DISCOVER_END:
-               return WIFI_DIRECT_DISCOVERY_FINISHED;
+       case WIFI_DIRECT_CLI_EVENT_DISCOVER_START:
+               return WIFI_DIRECT_DISCOVERY_STARTED;
                break;
        case WIFI_DIRECT_CLI_EVENT_DISCOVER_FOUND_PEERS:
                return WIFI_DIRECT_DISCOVERY_FOUND;
                break;
-
-       case WIFI_DIRECT_CLI_EVENT_CONNECTION_START:
-               return WIFI_DIRECT_CONNECTION_IN_PROGRESS;
+       case WIFI_DIRECT_CLI_EVENT_DISCOVER_END:
+               return WIFI_DIRECT_DISCOVERY_FINISHED;
                break;
        case WIFI_DIRECT_CLI_EVENT_CONNECTION_REQ:
                return WIFI_DIRECT_CONNECTION_REQ;
                break;
-       case WIFI_DIRECT_CLI_EVENT_CONNECTION_RSP:
-               return WIFI_DIRECT_CONNECTION_RSP;
-               break;
        case WIFI_DIRECT_CLI_EVENT_CONNECTION_WPS_REQ:
                return WIFI_DIRECT_CONNECTION_WPS_REQ;
                break;
+       case WIFI_DIRECT_CLI_EVENT_CONNECTION_START:
+               return WIFI_DIRECT_CONNECTION_IN_PROGRESS;
+               break;
+       case WIFI_DIRECT_CLI_EVENT_CONNECTION_RSP:
+               return WIFI_DIRECT_CONNECTION_RSP;
+               break;
        case WIFI_DIRECT_CLI_EVENT_DISCONNECTION_RSP:
                return WIFI_DIRECT_DISCONNECTION_RSP;
                break;
@@ -297,7 +304,7 @@ static int __wfd_convert_client_event(wfd_client_event_e event)
        return -1;
 }
 
-static gboolean __wfd_client_process_event(GIOChannel * source,
+static gboolean __wfd_client_process_event(GIOChannel *source,
                                                                                   GIOCondition condition,
                                                                                   gpointer data)
 {
@@ -308,23 +315,21 @@ static gboolean __wfd_client_process_event(GIOChannel * source,
        wifi_direct_error_e error = WIFI_DIRECT_ERROR_NONE;
        char param1[64] = { 0, };
        char param2[64] = { 0, };
+       int res = 0;
 
        memset(&client_noti, 0, sizeof(wifi_direct_client_noti_s));
 
        // 1.Read socket
-       if (__wfd_client_read_socket(sockfd, (char *) &client_noti,
-                 sizeof(wifi_direct_client_noti_s)) <= 0)
-       {
+       res = __wfd_client_read_socket(sockfd, (char*) &client_noti,
+                                                               sizeof(wifi_direct_client_noti_s));
+       if (res <= 0) {
                WDC_LOGE("Error!!! Reading Async Event[%d]", sockfd);
-               //close(sockfd);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return false;
        }
-
-       WDC_LOGD( "Received Event is [%d,%s], error[%d]\n",
-                                  client_noti.event, __wfd_print_event(client_noti.event),
-                                  client_noti.error);
+       WDC_LOGD( "Received Event is [%d,%s], error[%d]", client_noti.event,
+                                       __wfd_print_event(client_noti.event), client_noti.error);
 
        event = client_noti.event;
        error = client_noti.error;
@@ -333,18 +338,16 @@ static gboolean __wfd_client_process_event(GIOChannel * source,
 
 
        // 2. dispatch event
-
-       switch (event)
-       {
+       switch (event) {
        case WIFI_DIRECT_CLI_EVENT_ACTIVATION:
        case WIFI_DIRECT_CLI_EVENT_DEACTIVATION:
-               if (client->activation_cb != NULL)
-                       client->activation_cb(error,
-                                                                 (wifi_direct_device_state_e)
-                                                                 __wfd_convert_client_event(event),
-                                                                 client->user_data_for_cb_activation);
-               else
+               if (!client->activation_cb) {
                        WDC_LOGE("activation_cb is NULL!!");
+                       break;
+               }
+               client->activation_cb(error, 
+                                       (wifi_direct_device_state_e) __wfd_convert_client_event(event),
+                                       client->user_data_for_cb_activation);
                break;
 
        case WIFI_DIRECT_CLI_EVENT_DISCOVER_START:
@@ -352,13 +355,13 @@ static gboolean __wfd_client_process_event(GIOChannel * source,
        case WIFI_DIRECT_CLI_EVENT_DISCOVER_START_SEARCH_LISTEN:
        case WIFI_DIRECT_CLI_EVENT_DISCOVER_END:
        case WIFI_DIRECT_CLI_EVENT_DISCOVER_FOUND_PEERS:
-               if (client->discover_cb != NULL)
-                       client->discover_cb(error,
-                                                               (wifi_direct_discovery_state_e)
-                                                               __wfd_convert_client_event(event),
-                                                               client->user_data_for_cb_discover);
-               else
+               if (!client->discover_cb) {
                        WDC_LOGE("discover_cb is NULL!!");
+                       break;
+               }
+               client->discover_cb(error,
+                                       (wifi_direct_discovery_state_e) __wfd_convert_client_event(event),
+                                       client->user_data_for_cb_discover);
                break;
 
        case WIFI_DIRECT_CLI_EVENT_CONNECTION_START:
@@ -371,35 +374,31 @@ static gboolean __wfd_client_process_event(GIOChannel * source,
        case WIFI_DIRECT_CLI_EVENT_GROUP_CREATE_RSP:
        case WIFI_DIRECT_CLI_EVENT_GROUP_DESTROY_RSP:
        case WIFI_DIRECT_CLI_EVENT_INVITATION_REQ:
-               if (client->connection_cb != NULL)
-                       client->connection_cb(error,
-                                         (wifi_direct_connection_state_e)
-                                         __wfd_convert_client_event(event), param1,
-                                         client->user_data_for_cb_connection);
-               else
+               if (!client->connection_cb) {
                        WDC_LOGE("connection_cb is NULL!!");
+                       break;
+               }
+               client->connection_cb(error,
+                                       (wifi_direct_connection_state_e) __wfd_convert_client_event(event),
+                                       param1, client->user_data_for_cb_connection);
                break;
 
        // ToDo:  Handling IP lease event...
        case WIFI_DIRECT_CLI_EVENT_IP_LEASED_IND:
-               if (client->ip_assigned_cb != NULL)
-               {
-                       char* ifname = NULL;
-                       ifname = vconf_get_str(VCONFKEY_IFNAME);
-
-                       if (ifname == NULL)
-                               WDC_LOGD("vconf (%s) value is NULL!!!", VCONFKEY_IFNAME);
-                       else
-                               WDC_LOGD("VCONFKEY_IFNAME(%s) : %s", VCONFKEY_IFNAME, ifname);
-
-                               client->ip_assigned_cb(param1,
-                                                                 param2,
-                                                                 ifname,
-                                                                 client->user_data_for_cb_ip_assigned);
-
-               }
-               else
+               if (!client->ip_assigned_cb) {
                        WDC_LOGE("ip_assigned_cb is NULL!!");
+                       break;
+               }
+               char *ifname = NULL;
+               ifname = vconf_get_str(VCONFKEY_IFNAME);
+               if (!ifname) {
+                       WDC_LOGD("vconf (%s) value is NULL!!!", VCONFKEY_IFNAME);
+                       break;
+               }
+               WDC_LOGD("VCONFKEY_IFNAME(%s) : %s", VCONFKEY_IFNAME, ifname);
+               client->ip_assigned_cb(param1, param2, ifname,
+                                       client->user_data_for_cb_ip_assigned);
+               free(ifname);
                break;
 
        default:
@@ -411,179 +410,91 @@ static gboolean __wfd_client_process_event(GIOChannel * source,
        return TRUE;
 }
 
-static wifi_direct_error_e __wfd_client_send_request(int sockfd, void *req_data, int dataLength)
-{
-       int retval = 0;
-
-       __WDC_LOG_FUNC_START__;
-
-       if (sockfd > 0)
-       {
-               WDC_LOGD("Write [%d] bytes to socket [%d].", dataLength, sockfd);
-               errno = 0;
-               retval = write(sockfd, (char *) req_data, dataLength);
-
-               if (retval <= 0)
-               {
-                       WDC_LOGE("Error!!! writing to the socket. Error = %s", strerror(errno));
-                       __WDC_LOG_FUNC_END__;
-                       return WIFI_DIRECT_ERROR_NONE;
-               }
-
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NONE;
-       }
-
-       WDC_LOGE("Error!!! Invalid sockfd [%d]", sockfd);
-       __WDC_LOG_FUNC_END__;
-       return WIFI_DIRECT_ERROR_NONE;
-}
-
-static wifi_direct_error_e __wfd_client_async_event_init(int clientid)
+static int __wfd_client_send_request(int sockfd, void *req_data, int data_len)
 {
-       int len = 0;
-       int sockfd = 0;
-       struct sockaddr_un servAddr;
-       char *path = "/tmp/wfd_client_socket";
-
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       int wbytes = 0;
 
-       errno = 0;
-       if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
-       {
-               WDC_LOGE("Error!!! creating async socket. Error = [%s].", strerror(errno));
+       if (sockfd < SOCK_FD_MIN || !req_data || data_len <= 0) {
+               WDC_LOGE("Invalid parameter");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+               return -1;
        }
 
-       WDC_LOGD("Created async socket [%d]", sockfd);
-
-       memset(&servAddr, 0, sizeof(servAddr));
-       servAddr.sun_family = AF_UNIX;
-       strcpy(servAddr.sun_path, path);
-       len = sizeof(servAddr.sun_family) + strlen(path);
-
-       WDC_LOGD("Connecting to server socket to register async socket [%d]", sockfd);
+       // TODO: check socket is writable
+       WDC_LOGD("Write [%d] bytes to socket [%d].", data_len, sockfd);
        errno = 0;
-       if ((connect(sockfd, (struct sockaddr *) &servAddr, len)) < 0)
-       {
-               WDC_LOGE("Error!!! connecting to server socket. Error = [%s].", strerror(errno));
-               close(sockfd);
+       wbytes = write(sockfd, (char*) req_data, data_len);
+       if (wbytes <= 0) {
+               WDC_LOGE("Error!!! writing to the socket. Error = %s", strerror(errno));
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               wifi_direct_client_request_s req;
-               int result = WIFI_DIRECT_ERROR_NONE;
-
-               memset(&req, 0, sizeof(wifi_direct_client_request_s));
-
-               req.cmd = WIFI_DIRECT_CMD_INIT_ASYNC_SOCKET;
-               req.client_id = clientid;
-
-               result =
-                       __wfd_client_send_request(sockfd, &req, sizeof(wifi_direct_client_request_s));
-
-               if (result != WIFI_DIRECT_ERROR_NONE)
-               {
-                       WDC_LOGE("Error!!! writing to socket, Errno = %s", strerror(errno));
-                       WDC_LOGE("Error!!! [%s]", __wfd_print_error(result));
-                       close(sockfd);
-                       __WDC_LOG_FUNC_END__;
-                       return result;
-               }
-
-               client_info->async_sockfd = sockfd;
-
-               WDC_LOGE("Async socket is created= %d", sockfd);
-
+               return -1;
        }
 
-       return (sockfd);
+       __WDC_LOG_FUNC_END__;
+       return 0;
 }
 
-
 static int __wfd_client_read_socket(int sockfd, char *dataptr, int datalen)
 {
-       int pollret = 0;
+       __WDC_LOG_FUNC_START__;
        struct pollfd pollfd;
-       int timeout = 60000; /** for 60 sec */
-       int retval = 0;
+       int rbytes = 0;
        int total_data_recd = 0;
+       int res = 0;
 
-       __WDC_LOG_FUNC_START__;
-
-       if (sockfd <= 0)
-       {
+       if (sockfd < SOCK_FD_MIN) {
                WDC_LOGE("Error!!! Invalid socket FD [%d]", sockfd);
                __WDC_LOG_FUNC_END__;
                return -1;
        }
 
-       if ((dataptr == NULL) || (datalen <= 0))
-       {
+       if (!dataptr || datalen <= 0) {
                WDC_LOGE("Error!!! Invalid parameter");
                __WDC_LOG_FUNC_END__;
                return -1;
        }
 
-       WDC_LOGE("@@@@@@@ len = %d  @@@@@@@@@@@", datalen);
-
        pollfd.fd = sockfd;
-       pollfd.events = POLLIN | POLLERR | POLLHUP;
-       pollret = poll(&pollfd, 1, timeout);
-
-       WDC_LOGE("POLL ret = %d", pollret);
-
-       if (pollret > 0)
-       {
-               if (pollfd.revents == POLLIN)
-               {
-                       WDC_LOGE("POLLIN");
+       pollfd.events = POLLIN | POLLERR | POLLHUP | POLLNVAL;
+       res = poll(&pollfd, 1, 10000);
 
-                       while (datalen)
-                       {
+       if (res > 0) {
+               if (pollfd.revents & POLLERR) {
+                       WDC_LOGF("Error! POLLERR from socket[%d]", sockfd);
+                       __WDC_LOG_FUNC_END__;
+                       return -1;
+               } else if (pollfd.revents & POLLHUP) {
+                       WDC_LOGF("Error! POLLHUP from socket[%d]", sockfd);
+                       __WDC_LOG_FUNC_END__;
+                       return -1;
+               } else if (pollfd.revents & POLLNVAL) {
+                       WDC_LOGF("Error! POLLNVAL from socket[%d]", sockfd);
+                       __WDC_LOG_FUNC_END__;
+                       return -1;
+               } else if (pollfd.revents & POLLIN) {
+                       WDC_LOGD("POLLIN from socket [%d]", sockfd);
+                       while (datalen) {
                                errno = 0;
-                               retval = read(sockfd, (char *) dataptr, datalen);
-                               WDC_LOGE("sockfd %d retval %d", sockfd,
-                                                          retval);
-                               if (retval <= 0)
-                               {
+                               rbytes = read(sockfd, (char*) dataptr, datalen);
+                               WDC_LOGE("sockfd=%d, read bytes=%d", sockfd, rbytes);
+                               if (rbytes <= 0) {
                                        WDC_LOGE("Error!!! reading data, error [%s]", strerror(errno));
                                        __WDC_LOG_FUNC_END__;
-                                       return retval;
+                                       return rbytes;
                                }
-                               total_data_recd += retval;
-                               dataptr += retval;
-                               datalen -= retval;
+                               total_data_recd += rbytes;
+                               dataptr += rbytes;
+                               datalen -= rbytes;
                        }
                        __WDC_LOG_FUNC_END__;
                        return total_data_recd;
                }
-               else if (pollfd.revents & POLLHUP)
-               {
-                       WDC_LOGE("POLLHUP");
-                       __WDC_LOG_FUNC_END__;
-                       return 0;
-               }
-               else if (pollfd.revents & POLLERR)
-               {
-                       WDC_LOGE("POLLERR");
-                       __WDC_LOG_FUNC_END__;
-                       return 0;
-               }
-       }
-       else if (pollret == 0)
-       {
+       } else if (res == 0) {
                WDC_LOGE("POLLing timeout");
                __WDC_LOG_FUNC_END__;
-               return 0;
-       }
-       else
-       {
+               return -1;
+       } else {
                WDC_LOGE("Polling unknown error");
                __WDC_LOG_FUNC_END__;
                return -1;
@@ -593,40 +504,27 @@ static int __wfd_client_read_socket(int sockfd, char *dataptr, int datalen)
 }
 
 
-static int __wfd_client_read_more_data(int sockfd, void *pData, int Datalen)
+static int __wfd_client_read_more_data(int sockfd, char *dataptr, int datalen)
 {
-       int retval = 0;
-
        __WDC_LOG_FUNC_START__;
+       int rbytes = 0;
 
-       if (sockfd < 0)
-       {
-               WDC_LOGE("Error!!! Inavlid argument passed");
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
-       }
-
-       if (pData == NULL)
-       {
-               WDC_LOGE("Error!!! Inavlid argument passed");
+       if (sockfd < SOCK_FD_MIN) {
+               WDC_LOGE("Error!!! Invalid socket FD [%d]", sockfd);
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       if (Datalen <= 0)
-       {
-               WDC_LOGE("Error!!! Inavlid argument passed");
+       if (!dataptr || datalen <= 0) {
+               WDC_LOGE("Error!!! Invalid parameter");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       /** Initialising the structure variable */
-       memset(pData, 0, Datalen);
        errno = 0;
-       retval = __wfd_client_read_socket(sockfd, (char *) pData, Datalen);
-       if (retval <= 0)
-       {
-               WDC_LOGE("Error!!! reading response from CM. errno = [%d]", errno);
+       rbytes = __wfd_client_read_socket(sockfd, (char*) dataptr, datalen);
+       if (rbytes <= 0) {
+               WDC_LOGE("Error!!! reading response from CM.[%s]", strerror(errno));
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_OPERATION_FAILED;
        }
@@ -635,7 +533,7 @@ static int __wfd_client_read_more_data(int sockfd, void *pData, int Datalen)
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-void __wfd_client_print_entry_list(wfd_discovery_entry_s * list, int num)
+void __wfd_client_print_entry_list(wfd_discovery_entry_s *list, int num)
 {
        int i = 0;
 
@@ -651,7 +549,7 @@ void __wfd_client_print_entry_list(wfd_discovery_entry_s * list, int num)
        WDC_LOGD("------------------------------------------");
 }
 
-void __wfd_client_print_connected_peer_info(wfd_connected_peer_info_s * list, int num)
+void __wfd_client_print_connected_peer_info(wfd_connected_peer_info_s *list, int num)
 {
        int i = 0;
 
@@ -672,7 +570,7 @@ void __wfd_client_print_connected_peer_info(wfd_connected_peer_info_s * list, in
 }
 
 
-void __wfd_client_print_persistent_group_info(wfd_persistent_group_info_s * list, int num)
+void __wfd_client_print_persistent_group_info(wfd_persistent_group_info_s *list, int num)
 {
        int i = 0;
 
@@ -688,188 +586,199 @@ void __wfd_client_print_persistent_group_info(wfd_persistent_group_info_s * list
 }
 
 
-
-void __wfd_client_print_config_data(wfd_config_data_s * config)
+void __wfd_client_print_config_data(wfd_config_data_s *config)
 {
        if (config == NULL)
                return;
 
-       WDC_LOGD("Operating channel = [%d]\n", config->channel);
-       WDC_LOGD("WPS method = [%d, %s]\n", config->wps_config,
+       WDC_LOGD("Operating channel = [%d]", config->channel);
+       WDC_LOGD("WPS method = [%d, %s]", config->wps_config,
                                (config->wps_config == WIFI_DIRECT_WPS_TYPE_PBC) ? 
-                                               "Pushbutton" : (config-> wps_config == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY)
+                                               "Pushbutton" : (config->wps_config == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY)
                                                        ? "Display" : "Keypad");
 
-       WDC_LOGD("Max client = [%d]\n", config->max_clients);
-       WDC_LOGD("grp_owner_intent = [%d]\n", config->group_owner_intent);
-       WDC_LOGD("hide-SSID = [%d]\n", config->hide_SSID);
-       WDC_LOGD("want_persistent_group = [%d]\n", config->want_persistent_group);
-       WDC_LOGD("auto_connection = [%d]\n", config->auto_connection);
-       WDC_LOGD("primary_dev_type = [%d]\n", config->primary_dev_type);
-       WDC_LOGD("secondary_dev_type = [%d]\n",
-                                  config->secondary_dev_type);
+       WDC_LOGD("Max client = [%d]", config->max_clients);
+       WDC_LOGD("grp_owner_intent = [%d]", config->group_owner_intent);
+       WDC_LOGD("hide-SSID = [%d]", config->hide_SSID);
+       WDC_LOGD("want_persistent_group = [%d]", config->want_persistent_group);
+       WDC_LOGD("auto_connection = [%d]", config->auto_connection);
+       WDC_LOGD("primary_dev_type = [%d]", config->primary_dev_type);
+       WDC_LOGD("secondary_dev_type = [%d]", config->secondary_dev_type);
+}
+
+
+static int __wfd_client_async_event_init(int clientid)
+{
+       __WDC_LOG_FUNC_START__;
+       int sockfd = 0;
+       struct sockaddr_un saddr;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       int res = 0;
+
+       errno = 0;
+       sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
+       if (sockfd < 0) {
+               WDC_LOGE("Failed to async socket[%s]", strerror(errno));
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+       }
+       WDC_LOGD("Succeeded to create async socket[%d]", sockfd);
+
+       memset(&saddr, 0, sizeof(saddr));
+       saddr.sun_family = AF_UNIX;
+       snprintf(saddr.sun_path, sizeof(saddr.sun_path), WFD_SOCK_FILE_PATH);
+
+       WDC_LOGD("Connecting to server socket to register async socket [%d]", sockfd);
+       errno = 0;
+       res = connect(sockfd, (struct sockaddr *) &saddr, sizeof(saddr));
+       if (res < 0) {
+               WDC_LOGE("Error!!! connecting to server socket. Error = [%s].", strerror(errno));
+               close(sockfd);
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+       }
+
+       memset(&req, 0, sizeof(wifi_direct_client_request_s));
+
+       req.cmd = WIFI_DIRECT_CMD_INIT_ASYNC_SOCKET;
+       req.client_id = clientid;
+
+       res = __wfd_client_send_request(sockfd, &req, sizeof(wifi_direct_client_request_s));
+       if (res < WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Failed to write to socket[%s]", strerror(errno));
+               WDC_LOGE("Error!!! [%s]", __wfd_print_error(res));
+               close(sockfd);
+               __WDC_LOG_FUNC_END__;
+               return res;
+       }
+       client_info->async_sockfd = sockfd;
 
+       WDC_LOGE("Async socket is created= %d", sockfd);
+
+       return sockfd;
 }
 
 
 int wifi_direct_initialize(void)
 {
-       struct sockaddr_un servAddr;
-       char *path = "/tmp/wfd_client_socket";
+       __WDC_LOG_FUNC_START__;
+       struct sockaddr_un saddr;
        wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s resp;
+       int status = WIFI_DIRECT_ERROR_NONE;
+       int retry_count = 2;
        int sockfd = 0;
-       int len = 0;
-       int ret = 0;
-
-       __WDC_LOG_FUNC_START__;
+       int res = 0;
 
-       if (client_info->is_registered == TRUE)
-       {
-               WDC_LOGE("Warning!!! Already registered\nUpdate user data and callback!");
+       if (client_info->is_registered == TRUE) {
+               WDC_LOGW("Warning!!! Already registered\nUpdate user data and callback!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NONE;
        }
 
        errno = 0;
        sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
-       if (sockfd < 3)
-       {
-               WDC_LOGE("Error!!! creating sync socket. Error = [%s].", strerror(errno));
+       if (sockfd < SOCK_FD_MIN) {
+               WDC_LOGE("Error!!! creating sync socket[%s]", strerror(errno));
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
-
        WDC_LOGD("Created sync socket [%d]", sockfd);
 
-       memset(&servAddr, 0, sizeof(servAddr));
-       servAddr.sun_family = AF_UNIX;
-       strcpy(servAddr.sun_path, path);
-       len = sizeof(servAddr.sun_family) + strlen(path);
+       memset(&saddr, 0, sizeof(saddr));
+       saddr.sun_family = AF_UNIX;
+       snprintf(saddr.sun_path, sizeof(saddr.sun_path), WFD_SOCK_FILE_PATH);
 
        WDC_LOGD("Connecting to server socket to register sync socket [%d]", sockfd);
-
-       int retry_count = 2;
-       while (retry_count > 0)
-       {
+       while (retry_count > 0) {
                errno = 0;
-               ret = connect(sockfd, (struct sockaddr *) &servAddr, len);
-               if (!ret) {
+               res = connect(sockfd, (struct sockaddr*) &saddr, sizeof(saddr));
+               if (!res){
                        WDC_LOGD("Succeeded to connect to server socket");
                        break;
                }
+
                WDC_LOGD("Launching wfd-server..\n");
-               ret = system("dbus-send --system --print-reply --dest=net.netconfig /net/netconfig/wifi net.netconfig.wifi.LaunchDirect");
-               if (ret == -1)
-                       WDC_LOGE("Error!!! sending dbus msg Error = [%s]", strerror(errno));
+               res = system(WFD_LAUNCH_SERVER_DBUS);
+               if (res == -1)
+                       WDC_LOGE("Failed to send dbus msg[%s]", strerror(errno));
                retry_count--;
-               usleep(100000); /* wait a few seconds before retrying the next socket connection */
+
+               /* wait a little before retrying the next socket connection */
+               usleep(100000);
        }
 
-       if (ret < 0)
-       {
-               WDC_LOGE("Error!!! connecting to server socket. Error = [%d] %s.\n",
-                                          errno, strerror(errno));
-               if (sockfd > 2)
+       if (res < 0) {
+               WDC_LOGE("Failed to connect to server[%s]", strerror(errno));
+               if (sockfd > SOCK_FD_MIN)
                        close(sockfd);
-
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
-       else
-       {
-               wifi_direct_client_request_s req;
-               wifi_direct_client_response_s resp;
-
-               int status = WIFI_DIRECT_ERROR_NONE;
 
-               memset(&req, 0, sizeof(wifi_direct_client_request_s));
-               memset(&resp, 0, sizeof(wifi_direct_client_response_s));
+       memset(&req, 0, sizeof(wifi_direct_client_request_s));
+       memset(&resp, 0, sizeof(wifi_direct_client_response_s));
 
-               req.cmd = WIFI_DIRECT_CMD_REGISTER;
-               req.client_id = gettid();
-               WDC_LOGD("Client ID = %d\n", req.client_id);
+       req.cmd = WIFI_DIRECT_CMD_REGISTER;
+       req.client_id = gettid();
+       WDC_LOGD("Client ID = %d", req.client_id);
 
-               status = __wfd_client_send_request(sockfd, &req, sizeof(wifi_direct_client_request_s));
+       status = __wfd_client_send_request(sockfd, &req, sizeof(wifi_direct_client_request_s));
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! [%s]", __wfd_print_error(status));
+               if (sockfd > SOCK_FD_MIN)
+                       close(sockfd);
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+       }
 
-               if (status != WIFI_DIRECT_ERROR_NONE)
-               {
-                       WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-                       WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-                       if (sockfd > 2)
+       status = __wfd_client_read_socket(sockfd, (char*) &resp, sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Failed to read socket, status=%d[%s]", status, strerror(errno));
+               if (sockfd > SOCK_FD_MIN)
+                       close(sockfd);
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+       } else {
+               if (resp.cmd == WIFI_DIRECT_CMD_REGISTER) {
+                       if (resp.result == WIFI_DIRECT_ERROR_NONE) {
+                               client_info->sync_sockfd = sockfd;
+                               client_info->client_id = resp.client_id;
+                               client_info->is_registered = TRUE;
+                       } else {
+                               WDC_LOGE("Failed to register. result = %d", resp.result);
+                               if (sockfd > SOCK_FD_MIN)
+                                       close(sockfd);
+                               __WDC_LOG_FUNC_END__;
+                               return resp.result;
+                       }
+               } else {
+                       WDC_LOGE("Invalid response from server. cmd = %d", resp.cmd);
+                       if (sockfd > 0)
                                close(sockfd);
                        __WDC_LOG_FUNC_END__;
                        return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
                }
+       }
 
-               /*Get client id */
-               if ((status = __wfd_client_read_socket(sockfd, (char *) &resp,
-                       sizeof(wifi_direct_client_response_s))) <= 0)
-               {
-                       WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-                       if (sockfd > 2)
-                               close(sockfd);
-                       __WDC_LOG_FUNC_END__;
-                       return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-               }
-               else
-               {
-                       if (resp.cmd == WIFI_DIRECT_CMD_REGISTER)
-                       {
-                               if (resp.result == WIFI_DIRECT_ERROR_NONE)
-                               {
-                                       WDC_LOGD("Client ID received = %d \n",
-                                                                  resp.client_id);
-                                       WDC_LOGD("Connected sync socket %d to the wifi direct server socket\n",
-                                                                  sockfd);
-                                       client_info->sync_sockfd = sockfd;
-                                       client_info->client_id = resp.client_id;
-                                       client_info->is_registered = TRUE;
-                               }
-                               else
-                               {
-                                       WDC_LOGE("Error!!! Client Register = %d\n", resp.result);
-                                       if (sockfd > 2)
-                                               close(sockfd);
-                                       __WDC_LOG_FUNC_END__;
-                                       return resp.result;
-                               }
-
-                               int async_sockfd = -1;
-                               /* Send request for establishing async communication channel */
-                               async_sockfd = __wfd_client_async_event_init(client_info->client_id);
-                               if (async_sockfd == WIFI_DIRECT_ERROR_COMMUNICATION_FAILED)
-                               {
-                                       WDC_LOGE("Error!!! creating Async Socket \n");
-                                       if (sockfd > 2)
-                                               close(sockfd);
-                                       __wfd_reset_control();
-                                       __WDC_LOG_FUNC_END__;
-                                       return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-                               }
-
-                               client_info->async_sockfd = async_sockfd;
-                       }
-                       else
-                       {
-                               WDC_LOGE("Error!!! Invalid Response received from wfd Server. cmd = %d \n",
-                                                          resp.cmd);
-                               if (sockfd > 2)
-                                       close(sockfd);
-                               __WDC_LOG_FUNC_END__;
-                               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-                       }
-               }
-       }
+       int async_sockfd = -1;
+       async_sockfd = __wfd_client_async_event_init(client_info->client_id);
+       if (async_sockfd < 0) {
+               WDC_LOGE("Failed to create async socket \n");
+               if (sockfd > 0)
+                       close(sockfd);
+               __wfd_reset_control();
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+       }
+       client_info->async_sockfd = async_sockfd;
 
        GIOChannel *gio = g_io_channel_unix_new(client_info->async_sockfd);
-
-       int g_source_id =
-               g_io_add_watch(gio, G_IO_IN | G_IO_ERR | G_IO_HUP,
-                                          (GIOFunc) __wfd_client_process_event, NULL);
-
+       int g_source_id = g_io_add_watch(gio, G_IO_IN | G_IO_ERR | G_IO_HUP,
+                                                       (GIOFunc) __wfd_client_process_event, NULL);
        g_io_channel_unref(gio);
 
-       WDC_LOGD("Scoket is successfully registered to g_main_loop.\n");
-
        client_info->g_source_id = g_source_id;
 
        // Initialize callbacks
@@ -886,17 +795,13 @@ int wifi_direct_initialize(void)
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-
-
 int wifi_direct_deinitialize(void)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
 
-       if (client_info->is_registered == false)
-       {
-               WDC_LOGE("Client is already deregistered.\n");
+       if (client_info->is_registered == false) {
+               WDC_LOGE("Client is already deregistered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_OPERATION_FAILED;
        }
@@ -912,7 +817,6 @@ int wifi_direct_deinitialize(void)
 
        wifi_direct_client_request_s req;
        wifi_direct_client_response_s rsp;
-
        int status = WIFI_DIRECT_ERROR_NONE;
 
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
@@ -921,87 +825,51 @@ int wifi_direct_deinitialize(void)
        req.cmd = WIFI_DIRECT_CMD_DEREGISTER;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
+       if (status < 0) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                client_info->sync_sockfd = -1;
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       //
-       // Deinit protocol: Send the deregister cmd and wait for socket close...
-       //
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGD( "Deinit Successfull\n");
-
-               if (client_info->g_source_id > 0)
-                       g_source_remove(client_info->g_source_id);
-               client_info->g_source_id = -1;
-
-               close(client_info->sync_sockfd);
-               client_info->sync_sockfd = -1;
-               __wfd_reset_control();
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NONE;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_DEREGISTER)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
-                               WDC_LOGE("Error!!! Result received = %d\n", rsp.result);
-                               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(rsp.result));
-                       } else {
-                               WDC_LOGD("Deinit Successfull\n");
-
-                               if (client_info->g_source_id > 0)
-                                       g_source_remove(client_info->g_source_id);
-                               client_info->g_source_id = -1;
-
-                               close(client_info->sync_sockfd);
-                               client_info->sync_sockfd = -1;
-                               __wfd_reset_control();
-                               __WDC_LOG_FUNC_END__;
-                               return WIFI_DIRECT_ERROR_NONE;
-                       }
-               }
-
-               WDC_LOGE("Error.. Something wrong...!!!\n");
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGD("Failed to deinitialize. But continue deinitialization");
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_DEREGISTER) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                       else
+                               WDC_LOGD("Deinit Successfull");
+               } else {
+                       WDC_LOGE("Error.. Something wrong...!!!");
+               }
        }
 
        __wfd_reset_control();
-
        __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 
-int wifi_direct_set_device_state_changed_cb(wifi_direct_device_state_changed_cb
-                                                                                       cb, void *user_data)
+int wifi_direct_set_device_state_changed_cb(wifi_direct_device_state_changed_cb cb,
+                                                                                               void *user_data)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
 
-       if (NULL == cb)
-       {
-               WDC_LOGE("Callback is NULL.\n");
+       if (!cb) {
+               WDC_LOGE("Invalid parameter");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       if (client_info->is_registered == false)
-       {
-               WDC_LOGE("Client is not initialized.\n");
+       if (client_info->is_registered == false) {
+               WDC_LOGE("Client is not initialized.");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
@@ -1009,18 +877,17 @@ int wifi_direct_set_device_state_changed_cb(wifi_direct_device_state_changed_cb
        client_info->activation_cb = cb;
        client_info->user_data_for_cb_activation = user_data;
 
+       __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 
 int wifi_direct_unset_device_state_changed_cb(void)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
 
-       if (client_info->is_registered == false)
-       {
+       if (client_info->is_registered == false) {
                WDC_LOGE("Client is not initialized.\n");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
@@ -1029,27 +896,25 @@ int wifi_direct_unset_device_state_changed_cb(void)
        client_info->activation_cb = NULL;
        client_info->user_data_for_cb_activation = NULL;
 
+       __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 
 int
-wifi_direct_set_discovery_state_changed_cb
-(wifi_direct_discovery_state_chagned_cb cb, void *user_data)
+wifi_direct_set_discovery_state_changed_cb(wifi_direct_discovery_state_chagned_cb cb,
+                                                                                               void *user_data)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
 
-       if (NULL == cb)
-       {
+       if (!cb) {
                WDC_LOGE("Callback is NULL.\n");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       if (client_info->is_registered == false)
-       {
+       if (client_info->is_registered == false) {
                WDC_LOGE("Client is not initialized.\n");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
@@ -1058,18 +923,17 @@ wifi_direct_set_discovery_state_changed_cb
        client_info->discover_cb = cb;
        client_info->user_data_for_cb_discover = user_data;
 
+       __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 
 int wifi_direct_unset_discovery_state_changed_cb(void)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
 
-       if (client_info->is_registered == false)
-       {
+       if (client_info->is_registered == false) {
                WDC_LOGE("Client is not initialized.\n");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
@@ -1078,27 +942,24 @@ int wifi_direct_unset_discovery_state_changed_cb(void)
        client_info->discover_cb = NULL;
        client_info->user_data_for_cb_discover = NULL;
 
+       __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 
-int
-wifi_direct_set_connection_state_changed_cb
-(wifi_direct_connection_state_changed_cb cb, void *user_data)
+int wifi_direct_set_connection_state_changed_cb(wifi_direct_connection_state_changed_cb cb,
+                                                                                               void *user_data)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
 
-       if (NULL == cb)
-       {
+       if (!cb) {
                WDC_LOGE("Callback is NULL.\n");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       if (client_info->is_registered == false)
-       {
+       if (client_info->is_registered == false) {
                WDC_LOGE("Client is not initialized.\n");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
@@ -1114,13 +975,11 @@ wifi_direct_set_connection_state_changed_cb
 
 int wifi_direct_unset_connection_state_changed_cb(void)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
 
-       if (client_info->is_registered == false)
-       {
-               WDC_LOGE("Client is not initialized.\n");
+       if (client_info->is_registered == false) {
+               WDC_LOGE("Client is not initialized");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
@@ -1133,22 +992,20 @@ int wifi_direct_unset_connection_state_changed_cb(void)
 }
 
 
-int wifi_direct_set_client_ip_address_assigned_cb(wifi_direct_client_ip_address_assigned_cb cb, void* user_data)
+int wifi_direct_set_client_ip_address_assigned_cb(wifi_direct_client_ip_address_assigned_cb cb,
+                                                                                               void* user_data)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
 
-       if (NULL == cb)
-       {
-               WDC_LOGE("Callback is NULL.\n");
+       if (!cb) {
+               WDC_LOGE("Callback is NULL");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       if (client_info->is_registered == false)
-       {
-               WDC_LOGE("Client is not initialized.\n");
+       if (client_info->is_registered == false) {
+               WDC_LOGE("Client is not initialized");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
@@ -1162,13 +1019,11 @@ int wifi_direct_set_client_ip_address_assigned_cb(wifi_direct_client_ip_address_
 
 int wifi_direct_unset_client_ip_address_assigned_cb(void)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
 
-       if (client_info->is_registered == false)
-       {
-               WDC_LOGE("Client is not initialized.\n");
+       if (client_info->is_registered == false) {
+               WDC_LOGE("Client is not initialized");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
@@ -1183,76 +1038,55 @@ int wifi_direct_unset_client_ip_address_assigned_cb(void)
 
 int wifi_direct_activate(void)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_ACTIVATE;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n",
-                                          __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_ACTIVATE)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGE("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_ACTIVATE) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGE("Activating device is successfull.\n");
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_activate() SUCCESS");
 
        __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
@@ -1260,77 +1094,55 @@ int wifi_direct_activate(void)
 
 int wifi_direct_deactivate(void)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_DEACTIVATE;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n",
-                                          __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_DEACTIVATE)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_DEACTIVATE) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
                                WDC_LOGE("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGE("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+                               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGE("Device Deactivated! \n");
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_deactivate() SUCCESS \n");
 
        __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
@@ -1338,1611 +1150,1200 @@ int wifi_direct_deactivate(void)
 
 int wifi_direct_start_discovery(bool listen_only, int timeout)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if (timeout < 0)
-       {
-               WDC_LOGE("Nagative value. Param [timeout]!\n");
+       if (timeout < 0) {
+               WDC_LOGE("Nagative value. Param [timeout]!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_START_DISCOVERY;
        req.client_id = client_info->client_id;
-       req.data.listen_only = listen_only;
-       req.data.timeout = timeout;
-
-       WDC_LOGE("listen only (%d) timeout (%d) \n",
+       req.data.int1 = listen_only;
+       req.data.int2 = timeout;
+       WDC_LOGE("listen only (%d) timeout (%d)",
                                   listen_only, timeout);
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_START_DISCOVERY)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGE("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGE("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_START_DISCOVERY) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGE("wifi_direct_start_discovery() SUCCESS \n");
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_start_discovery() SUCCESS");
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 int wifi_direct_cancel_discovery(void)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_CANCEL_DISCOVERY;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n",
-                                          strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n",
-                                          __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n",
-                                          status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_CANCEL_DISCOVERY)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGE("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGE("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_CANCEL_DISCOVERY) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGE("wifi_direct_cancel_discovery() SUCCESS \n");
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_cancel_discovery() SUCCESS");
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-
-int wifi_direct_foreach_discovered_peers(wifi_direct_discovered_peer_cb callback, void *user_data)
+int wifi_direct_foreach_discovered_peers(wifi_direct_discovered_peer_cb cb,
+                                                                                               void *user_data)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
+       int i;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if (callback == NULL)
-       {
-               WDC_LOGE("NULL Param [callback]!\n");
+       if (!cb) {
+               WDC_LOGE("NULL Param [callback]!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-       int i;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_GET_DISCOVERY_RESULT;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n",
-                                          strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n",
-                                          __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n",
-                                          status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_GET_DISCOVERY_RESULT)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGE("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(rsp.result));
-                               __WDC_LOG_FUNC_END__;
-                               return rsp.result;
-                       }
-                       else
-                       {
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_GET_DISCOVERY_RESULT) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
+                               __WDC_LOG_FUNC_END__;
+                               return rsp.result;
+                       } else {
                                int num = rsp.param1;
                                int status = 0;
                                wfd_discovery_entry_s *buff = NULL;
 
-                               WDC_LOGD("Num of found peers = %d \n",
-                                                          (int) rsp.param1);
+                               WDC_LOGD("Num of found peers = %d", (int) rsp.param1);
 
-                               if (num > 0)
-                               {
-                                       buff =
-                                               (wfd_discovery_entry_s *) malloc(num * sizeof (wfd_discovery_entry_s));
-                                       if (buff == NULL)
-                                       {
-                                               WDC_LOGE("malloc() failed!!!.\n");
+                               if (num > 0) {
+                                       buff = (wfd_discovery_entry_s*) malloc(num * sizeof (wfd_discovery_entry_s));
+                                       if (!buff) {
+                                               WDC_LOGE("malloc() failed!!!");
                                                return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                                        }
 
-                                       status =
-                                               __wfd_client_read_more_data(client_info->sync_sockfd,
-                                                                                       buff,
-                                                                                       num *
-                                                                                       sizeof
-                                                                                       (wfd_discovery_entry_s));
-                                       if (status != WIFI_DIRECT_ERROR_NONE)
-                                       {
-                                               if (NULL != buff)
+                                       status = __wfd_client_read_more_data(client_info->sync_sockfd,
+                                                                                       (char*) buff, num * sizeof(wfd_discovery_entry_s));
+                                       if (status != WIFI_DIRECT_ERROR_NONE) {
+                                               if (buff)
                                                        free(buff);
-                                               //peer_list = NULL;
-                                               WDC_LOGE("socket read error.\n");
+                                               WDC_LOGE("socket read error");
                                                return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                                        }
                                }
 
                                __wfd_client_print_entry_list(buff, num);
-
-                               WDC_LOGD("wifi_direct_foreach_discovered_peers() SUCCESS\n");
-
+                               WDC_LOGD("wifi_direct_foreach_discovered_peers() SUCCESS");
 
                                wifi_direct_discovered_peer_info_s *peer_list;
 
-                               for (i = 0; i < num; i++)
-                               {
+                               for (i = 0; i < num; i++) {
                                        peer_list = (wifi_direct_discovered_peer_info_s *) calloc(1, sizeof(wifi_direct_discovered_peer_info_s));
                                        peer_list->is_group_owner = buff[i].is_group_owner;
                                        peer_list->device_name = strdup(buff[i].device_name);
-                                       peer_list->mac_address = (char *) calloc(1, 18);
-                                       snprintf(peer_list->mac_address, 18, MACSTR, MAC2STR(buff[i].mac_address));
+                                       peer_list->mac_address = (char*) calloc(1, MACSTR_LEN);
+                                       snprintf(peer_list->mac_address, MACSTR_LEN, MACSTR, MAC2STR(buff[i].mac_address));
                                        peer_list->channel = buff[i].channel;
                                        peer_list->is_connected = buff[i].is_connected;
                                        peer_list->is_persistent_group_owner = buff[i].is_persistent_go;
-                                       peer_list->interface_address = (char *) calloc(1, 18);
-                                       snprintf(peer_list->interface_address, 18, MACSTR, MAC2STR(buff[i].intf_mac_address));
+                                       peer_list->interface_address = (char*) calloc(1, MACSTR_LEN);
+                                       snprintf(peer_list->interface_address, MACSTR_LEN, MACSTR, MAC2STR(buff[i].intf_mac_address));
                                        peer_list->supported_wps_types= buff[i].wps_cfg_methods;
                                        peer_list->primary_device_type = buff[i].category;
                                        peer_list->secondary_device_type = buff[i].subcategory;
 
-                                       if (!callback(peer_list, user_data))
+                                       if (!cb(peer_list, user_data))
                                                break;
                                }
 
-                               if (NULL != buff)
+                               if (buff)
                                        free(buff);
 
                        }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-
 int wifi_direct_connect(const char *mac_address)
 {
+       __WDC_LOG_FUNC_START__;
        wifi_direct_client_info_s *client_info = __wfd_get_control();
        unsigned char la_mac_addr[6];
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       __WDC_LOG_FUNC_START__;
-
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if (mac_address == NULL)
-       {
-               WDC_LOGE("mac_addr is NULL.\n");
+       if (!mac_address) {
+               WDC_LOGE("mac_addr is NULL");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_CONNECT;
        req.client_id = client_info->client_id;
-
        macaddr_atoe(mac_address, la_mac_addr);
+       memcpy(req.data.mac_addr, la_mac_addr, MACADDR_LEN);
 
-       req.data.mac_addr[0] = la_mac_addr[0];
-       req.data.mac_addr[1] = la_mac_addr[1];
-       req.data.mac_addr[2] = la_mac_addr[2];
-       req.data.mac_addr[3] = la_mac_addr[3];
-       req.data.mac_addr[4] = la_mac_addr[4];
-       req.data.mac_addr[5] = la_mac_addr[5];
-
-
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n",
-                                          strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n",
-                                          __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n",
-                                          status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_CONNECT)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGE("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGE("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_CONNECT) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("wifi_direct_connect() SUCCESS \n");
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_connect() SUCCESS");
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 
 int wifi_direct_disconnect_all(void)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_DISCONNECT_ALL;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_DISCONNECT_ALL)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGE("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGE("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_DISCONNECT_ALL) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGE("wifi_direct_disconnect_all() SUCCESS \n");
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGE("wifi_direct_disconnect_all() SUCCESS");
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 
 int wifi_direct_disconnect(const char *mac_address)
 {
+       __WDC_LOG_FUNC_START__;
        wifi_direct_client_info_s *client_info = __wfd_get_control();
        unsigned char la_mac_addr[6];
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       __WDC_LOG_FUNC_START__;
-
-       if (mac_address == NULL)
-       {
-               WDC_LOGE("mac_address is NULL.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if (!mac_address) {
+               WDC_LOGE("mac_address is NULL");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_DISCONNECT;
        req.client_id = client_info->client_id;
-
        macaddr_atoe(mac_address, la_mac_addr);
+       memcpy(req.data.mac_addr, la_mac_addr, 6);
 
-       req.data.mac_addr[0] = la_mac_addr[0];
-       req.data.mac_addr[1] = la_mac_addr[1];
-       req.data.mac_addr[2] = la_mac_addr[2];
-       req.data.mac_addr[3] = la_mac_addr[3];
-       req.data.mac_addr[4] = la_mac_addr[4];
-       req.data.mac_addr[5] = la_mac_addr[5];
-
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n",
-                                          status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_DISCONNECT)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGE("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_DISCONNECT) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGE("wifi_direct_disconnect() SUCCESS \n");
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGE("wifi_direct_disconnect() SUCCESS");
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 
 }
 
-
-
 int wifi_direct_accept_connection(char *mac_address)
 {
+       __WDC_LOG_FUNC_START__;
        wifi_direct_client_info_s *client_info = __wfd_get_control();
        unsigned char la_mac_addr[6];
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       __WDC_LOG_FUNC_START__;
-
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if (mac_address == NULL)
-       {
-               WDC_LOGE("mac_addr is NULL.\n");
+       if (!mac_address) {
+               WDC_LOGE("mac_addr is NULL");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_SEND_CONNECT_REQ;
        req.client_id = client_info->client_id;
-
        macaddr_atoe(mac_address, la_mac_addr);
+       memcpy(req.data.mac_addr, la_mac_addr, 6);
 
-       req.data.mac_addr[0] = la_mac_addr[0];
-       req.data.mac_addr[1] = la_mac_addr[1];
-       req.data.mac_addr[2] = la_mac_addr[2];
-       req.data.mac_addr[3] = la_mac_addr[3];
-       req.data.mac_addr[4] = la_mac_addr[4];
-       req.data.mac_addr[5] = la_mac_addr[5];
-
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n",
-                                          strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n",
-                                          __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n",
-                                          status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_SEND_CONNECT_REQ)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGE("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGE("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_SEND_CONNECT_REQ) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGE("wifi_direct_connect() SUCCESS \n");
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGE("wifi_direct_connect() SUCCESS \n");
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-
-int wifi_direct_foreach_connected_peers(wifi_direct_connected_peer_cb callback, void *user_data)
+int wifi_direct_reject_connection(char *mac_address)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       unsigned char la_mac_addr[6];
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if (callback == NULL)
-       {
-               WDC_LOGE("NULL Param [callback]!\n");
+       if (!mac_address) {
+               WDC_LOGE("mac_addr is NULL");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-       int i;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
-       req.cmd = WIFI_DIRECT_CMD_GET_CONNECTED_PEERS_INFO;
+       req.cmd = WIFI_DIRECT_CMD_REJECT_CONNECTION;
        req.client_id = client_info->client_id;
+       macaddr_atoe(mac_address, la_mac_addr);
+       memcpy(req.data.mac_addr, la_mac_addr, 6);
 
        status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status = __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                               sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n",
-                                          status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_GET_CONNECTED_PEERS_INFO)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGE("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_SEND_CONNECT_REQ) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-
-                               int num = rsp.param1;
-                               int status = 0;
-                               wfd_connected_peer_info_s *buff = NULL;
-
-                               WDC_LOGD("Num of connected peers = %d \n",
-                                                          (int) rsp.param1);
-
-                               if (num > 0)
-                               {
-                                       buff =
-                                               (wfd_connected_peer_info_s *) malloc(num *
-                                                                                                                        sizeof
-                                                                                                                        (wfd_connected_peer_info_s));
-                                       if (buff == NULL)
-                                       {
-                                               WDC_LOGE("malloc() failed!!!.\n");
-                                               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-                                       }
-
-                                       status =
-                                               __wfd_client_read_more_data(client_info->sync_sockfd,
-                                                                                                       buff,
-                                                                                                       num *
-                                                                                                       sizeof
-                                                                                                       (wfd_connected_peer_info_s));
-                                       if (status != WIFI_DIRECT_ERROR_NONE)
-                                       {
-                                               if (NULL != buff)
-                                                       free(buff);
-                                               WDC_LOGE("socket read error.\n");
-                                               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-                                       }
-
-                                       __wfd_client_print_connected_peer_info(buff, num);
-
-                                       WDC_LOGD("wifi_direct_foreach_connected_peers() SUCCESS\n");
-
-                                       wifi_direct_connected_peer_info_s *peer_list = NULL;
-
-                                       for (i = 0; i < num; i++)
-                                       {
-                                               peer_list = (wifi_direct_connected_peer_info_s *) calloc(1, sizeof(wifi_direct_connected_peer_info_s));
-                                               peer_list->device_name = strdup(buff[i].device_name);
-                                               peer_list->ip_address= (char *) calloc(1, 16);
-                                               snprintf(peer_list->ip_address, 16, IPSTR, IP2STR(buff[i].ip_address));
-                                               peer_list->mac_address = (char *) calloc(1, 18);
-                                               snprintf(peer_list->mac_address, 18, MACSTR, MAC2STR(buff[i].mac_address));
-                                               peer_list->interface_address = (char *) calloc(1, 18);
-                                               snprintf(peer_list->interface_address, 18, MACSTR, MAC2STR(buff[i].intf_mac_address));
-                                               peer_list->p2p_supported = buff[i].is_p2p;
-                                               peer_list->primary_device_type = buff[i].category;
-                                               peer_list->channel = buff[i].channel;
-
-                                               if (!callback(peer_list, user_data))
-                                                       break;
-                                       }
-                               } else {
-                                       callback(NULL, user_data);
-                               }
-
-                               if (NULL != buff)
-                                       free(buff);
-
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGE("wifi_direct_connect() SUCCESS \n");
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-
-int wifi_direct_create_group(void)
+int wifi_direct_foreach_connected_peers(wifi_direct_connected_peer_cb cb,
+                                                                                               void *user_data)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
+       int i;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
+       if (!cb) {
+               WDC_LOGE("NULL Param [callback]!");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+       }
 
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
-       req.cmd = WIFI_DIRECT_CMD_CREATE_GROUP;
+       req.cmd = WIFI_DIRECT_CMD_GET_CONNECTED_PEERS_INFO;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
-                                                                 sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
+                                                                       sizeof(wifi_direct_client_request_s));
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n",
-                                          status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                               sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_CREATE_GROUP)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGE("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(rsp.result));
-                               __WDC_LOG_FUNC_END__;
-                               return rsp.result;
-                       }
-                       else
-                       {
-                               WDC_LOGE("wifi_direct_create_group() SUCCESS \n");
-                       }
+
+       if (rsp.cmd != WIFI_DIRECT_CMD_GET_CONNECTED_PEERS_INFO) {
+               WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
+               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+       }
+
+       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
+               __WDC_LOG_FUNC_END__;
+               return rsp.result;
+       }
+
+       int num = rsp.param1;
+       wfd_connected_peer_info_s *buff = NULL;
+
+       WDC_LOGD("Num of connected peers = %d", (int) rsp.param1);
+
+       if (num > 0) {
+               buff = (wfd_connected_peer_info_s*) malloc(num * sizeof(wfd_connected_peer_info_s));
+               if (!buff) {
+                       WDC_LOGF("malloc() failed!!!");
+                       return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n", rsp.cmd);
+
+               status = __wfd_client_read_more_data(client_info->sync_sockfd, (char*) buff,
+                                                                                       num * sizeof(wfd_connected_peer_info_s));
+               if (status != WIFI_DIRECT_ERROR_NONE) {
+                       free(buff);
+                       WDC_LOGE("socket read error");
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
+
+               __wfd_client_print_connected_peer_info(buff, num);
+               WDC_LOGD("wifi_direct_foreach_connected_peers() SUCCESS");
+
+               wifi_direct_connected_peer_info_s *peer_list = NULL;
+
+               for (i = 0; i < num; i++)
+               {
+                       peer_list = (wifi_direct_connected_peer_info_s *) calloc(1, sizeof(wifi_direct_connected_peer_info_s));
+                       peer_list->device_name = strdup(buff[i].device_name);
+                       peer_list->ip_address= (char*) calloc(1, IPSTR_LEN);
+                       snprintf(peer_list->ip_address, IPSTR_LEN, IPSTR, IP2STR(buff[i].ip_address));
+                       peer_list->mac_address = (char*) calloc(1, MACSTR_LEN);
+                       snprintf(peer_list->mac_address, MACSTR_LEN, MACSTR, MAC2STR(buff[i].mac_address));
+                       peer_list->interface_address = (char*) calloc(1, MACSTR_LEN);
+                       snprintf(peer_list->interface_address, MACSTR_LEN, MACSTR, MAC2STR(buff[i].intf_mac_address));
+                       peer_list->p2p_supported = buff[i].is_p2p;
+                       peer_list->primary_device_type = buff[i].category;
+                       peer_list->channel = buff[i].channel;
+
+                       if (!cb(peer_list, user_data))
+                               break;
+               }
+               if (buff)
+                       free(buff);
        }
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 
-int wifi_direct_destroy_group(void)
+int wifi_direct_create_group(void)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
+       memset(&req, 0, sizeof(wifi_direct_client_request_s));
+       memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
+
+       req.cmd = WIFI_DIRECT_CMD_CREATE_GROUP;
+       req.client_id = client_info->client_id;
+
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
+                                                                 sizeof(wifi_direct_client_request_s));
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
+               __wfd_reset_control();
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+       }
+
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s)); 
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
+               __wfd_reset_control();
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_CREATE_GROUP) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
+                               __WDC_LOG_FUNC_END__;
+                               return rsp.result;
+                       }
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n", rsp.cmd);
+                       return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+               }
+       }
+       WDC_LOGE("wifi_direct_create_group() SUCCESS \n");
+
+       __WDC_LOG_FUNC_END__;
+       return WIFI_DIRECT_ERROR_NONE;
+}
+
+
+int wifi_direct_destroy_group(void)
+{
+       __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
        wifi_direct_client_request_s req;
        wifi_direct_client_response_s rsp;
-
        int status = WIFI_DIRECT_ERROR_NONE;
 
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+       }
+
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_CANCEL_GROUP;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                client_info->sync_sockfd = -1;
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n",
-                                          status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_CANCEL_GROUP)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGE("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_CANCEL_GROUP){
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGE("wifi_direct_destroy_group() SUCCESS \n");
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGE("wifi_direct_destroy_group() SUCCESS");
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 
-int wifi_direct_is_group_owner(bool * owner)
+int wifi_direct_is_group_owner(bool *owner)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if (owner == NULL)
-       {
-               WDC_LOGE("NULL Param [owner]!\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if (!owner) {
+               WDC_LOGE("NULL Param [owner]!");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_IS_GROUPOWNER;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_IS_GROUPOWNER)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d \n",
-                                                          rsp.result);
-                               WDC_LOGD("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_IS_GROUPOWNER) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("wifi_direct_is_group_owner() %s SUCCESS \n", rsp.param2);
-                               *owner = (bool) rsp.param1;
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_is_group_owner() SUCCESS");
+       *owner = (bool) rsp.param1;
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
-
 }
 
-
-int wifi_direct_is_autonomous_group(bool * autonomous_group)
+int wifi_direct_is_autonomous_group(bool *autonomous_group)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if (autonomous_group == NULL)
-       {
-               WDC_LOGE("NULL Param [autonomous_group]!\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if (!autonomous_group) {
+               WDC_LOGE("NULL Param [autonomous_group]!\n");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_IS_AUTONOMOUS_GROUP;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n",
-                                          status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_IS_AUTONOMOUS_GROUP)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGD("Error!!! [%s]\n", __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_IS_AUTONOMOUS_GROUP) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("wifi_direct_is_autonomous_group() %s SUCCESS \n", rsp.param2);
-                               *autonomous_group = (bool) rsp.param1;
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_is_autonomous_group() SUCCESS");
+       *autonomous_group = (bool) rsp.param1;
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
-
 }
 
 
 int wifi_direct_set_group_owner_intent(int intent)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if (intent < 0 || intent > 15)
-       {
-               WDC_LOGE("Invalid Param : intent[%d]\n", intent);
+       if (intent < 0 || intent > 15) {
+               WDC_LOGE("Invalid Param : intent[%d]", intent);
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_SET_GO_INTENT;
        req.client_id = client_info->client_id;
+       req.data.int1 = intent;
 
-       status =__wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
-               __wfd_reset_control();
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-
-       WDC_LOGD("writing msg hdr is success!\n");
-
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &intent,
-                                                                 sizeof(int));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_SET_GO_INTENT)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d \n",
-                                                          rsp.result);
-                               WDC_LOGD("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_SET_GO_INTENT) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_set_group_owner_intent() SUCCESS");
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-
 int wifi_direct_get_group_owner_intent(int* intent)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_GET_GO_INTENT;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_GET_GO_INTENT)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d \n",
-                                                          rsp.result);
-                               WDC_LOGD("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_GET_GO_INTENT) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("int wifi_direct_get_group_owner_intent() intent[%d] SUCCESS \n", rsp.param1);
-                               *intent = rsp.param1;
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n", rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("int wifi_direct_get_group_owner_intent() intent[%d] SUCCESS", rsp.param1);
+       *intent = rsp.param1;
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 int wifi_direct_set_max_clients(int max)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
-
        WDC_LOGD("max client [%d]\n", max);
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_SET_MAX_CLIENT;
        req.client_id = client_info->client_id;
+       req.data.int1 = max;
 
        status =__wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
-               __wfd_reset_control();
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-
-       WDC_LOGD("writing msg hdr is success!\n");
-
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &max,
-                                                                 sizeof(int));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_SET_MAX_CLIENT)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d \n",
-                                                          rsp.result);
-                               WDC_LOGD("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_SET_MAX_CLIENT) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("int wifi_direct_get_group_owner_intent() SUCCESS");
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 int wifi_direct_get_max_clients(int* max)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_GET_MAX_CLIENT;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_GET_MAX_CLIENT)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d \n",
-                                                          rsp.result);
-                               WDC_LOGD("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_GET_MAX_CLIENT) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("int wifi_direct_get_max_clients() max_client[%d] SUCCESS \n", rsp.param1);
-                               *max = rsp.param1;
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("int wifi_direct_get_max_clients() max_client[%d] SUCCESS", rsp.param1);
+       *max = rsp.param1;
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-
 /* Deprecated */
 int wifi_direct_get_own_group_channel(int* channel)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int ret = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int ret = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_GET_OWN_GROUP_CHANNEL;
        req.client_id = client_info->client_id;
 
-       ret =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       ret = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (ret != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n",
-                                          __wfd_print_error(ret));
-               client_info->sync_sockfd = -1;
+       if (ret != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(ret));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((ret =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", ret, strerror(errno));
-               client_info->sync_sockfd = -1;
+       ret = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (ret <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", ret);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_GET_OWN_GROUP_CHANNEL)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d \n",
-                                                          rsp.result);
-                               WDC_LOGD("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_GET_OWN_GROUP_CHANNEL) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("channel = [%d]\n",
-                                                          (int) rsp.param1);
-                               *channel = rsp.param1;
-                       }
-               }
-               else
-               {
+               } else {
                        WDC_LOGE("Error!!! Invalid resp cmd = %d\n", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("channel = [%d]\n", (int) rsp.param1);
+       *channel = rsp.param1;
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 
 }
@@ -2950,22 +2351,24 @@ int wifi_direct_get_own_group_channel(int* channel)
 
 int wifi_direct_get_operating_channel(int* channel)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int ret = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int ret = WIFI_DIRECT_ERROR_NONE;
+       if (!channel) {
+               WDC_LOGE("NULL Param [channel]!\n");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+       }
 
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
@@ -2973,52 +2376,37 @@ int wifi_direct_get_operating_channel(int* channel)
        req.cmd = WIFI_DIRECT_CMD_GET_OWN_GROUP_CHANNEL;
        req.client_id = client_info->client_id;
 
-       ret =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       ret = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (ret != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(ret));
-               client_info->sync_sockfd = -1;
+       if (ret != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(ret));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((ret =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", ret, strerror(errno));
-               client_info->sync_sockfd = -1;
+       ret = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (ret <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", ret);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_GET_OWN_GROUP_CHANNEL)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGD("Error!!! [%s]\n", __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_GET_OWN_GROUP_CHANNEL) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("channel = [%d]\n", (int) rsp.param1);
-                               *channel = rsp.param1;
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n", rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("channel = [%d]", (int) rsp.param1);
+       *channel = rsp.param1;
 
        __WDC_LOG_FUNC_END__;
 
@@ -3027,825 +2415,703 @@ int wifi_direct_get_operating_channel(int* channel)
 }
 
 
-int wifi_direct_set_wpa_passphrase(char *passphrase)
+int wifi_direct_get_passphrase(char** passphrase)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       char la_passphrase[WIFI_DIRECT_WPA_LEN+1] = {0,};
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered.");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if (NULL == passphrase)
-       {
-               WDC_LOGE("NULL Param [passphrase]!\n");
+       if(!passphrase){
+               WDC_LOGE("NULL Param [passphrase]!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       WDC_LOGE("passphrase = [%s]\n", passphrase);
+       memset(&req, 0, sizeof(wifi_direct_client_request_s));
+       memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
+
+       req.cmd = WIFI_DIRECT_CMD_GET_PASSPHRASE;
+       req.client_id = client_info->client_id;
+
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
+                                                                 sizeof(wifi_direct_client_request_s));
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
+               __wfd_reset_control();
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+       }
+
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
+               __wfd_reset_control();
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_GET_PASSPHRASE) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
+                               __WDC_LOG_FUNC_END__;
+                               return rsp.result;
+                       }
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
+                       return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+               }
+       }
 
+       WDC_LOGD("wifi_direct_get_wpa_passphrase() SUCCESS");
+       strncpy(la_passphrase, rsp.param2, WIFI_DIRECT_WPA_LEN);
+       la_passphrase[WIFI_DIRECT_WPA_LEN] = '\0';
+       *passphrase = strdup(la_passphrase);
+
+       __WDC_LOG_FUNC_END__;
+       return WIFI_DIRECT_ERROR_NONE;
+}
+
+int wifi_direct_set_wpa_passphrase(char *passphrase)
+{
+       __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
        wifi_direct_client_request_s req;
        wifi_direct_client_response_s rsp;
-
        int status = WIFI_DIRECT_ERROR_NONE;
 
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered.");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!passphrase) {
+               WDC_LOGE("NULL Param [passphrase]!");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+       }
+       WDC_LOGD("passphrase = [%s]", passphrase);
+
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_SET_WPA;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
+       WDC_LOGD("writing msg hdr is success!");
 
-       WDC_LOGD("writing msg hdr is success!\n");
-
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, passphrase, 64);
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_send_request(client_info->sync_sockfd, passphrase, 64);
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_SET_WPA)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGE("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_SET_WPA) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n", rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-
 int wifi_direct_activate_pushbutton(void)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
-
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
-       }
-
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
        wifi_direct_client_request_s req;
        wifi_direct_client_response_s rsp;
-
        int status = WIFI_DIRECT_ERROR_NONE;
 
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+       }
+
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_ACTIVATE_PUSHBUTTON;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n",
-                                          status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_ACTIVATE_PUSHBUTTON)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d \n",
-                                                          rsp.result);
-                               WDC_LOGD("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_ACTIVATE_PUSHBUTTON) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("wifi_direct_activate_pushbutton() SUCCESS");
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_activate_pushbutton() SUCCESS");
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-
 int wifi_direct_set_wps_pin(char *pin)
 {
-
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if (NULL == pin)
-       {
-               WDC_LOGE("NULL Param [pin]!\n");
+       if (!pin) {
+               WDC_LOGE("NULL Param [pin]!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
        WDC_LOGE("pin = [%s]\n", pin);
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_SET_WPS_PIN;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
-
        WDC_LOGD("writing msg hdr is success!\n");
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, pin,
+       status = __wfd_client_send_request(client_info->sync_sockfd, pin,
                                                                  WIFI_DIRECT_WPS_PIN_LEN);
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE( "Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
+               __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_SET_WPS_PIN)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d \n",
-                                                          rsp.result);
-                               WDC_LOGD("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_SET_WPS_PIN) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 
 int wifi_direct_get_wps_pin(char **pin)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
-
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
-       }
-
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
        wifi_direct_client_request_s req;
        wifi_direct_client_response_s rsp;
        char la_pin[WIFI_DIRECT_WPS_PIN_LEN + 1] = { 0, };
-
        int status = WIFI_DIRECT_ERROR_NONE;
 
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+       }
+
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_GET_WPS_PIN;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_GET_WPS_PIN)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d \n",
-                                                          rsp.result);
-                               WDC_LOGD("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_GET_WPS_PIN) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("wifi_direct_get_wps_pin() SUCCESS");
-                               snprintf(la_pin, WIFI_DIRECT_WPS_PIN_LEN+1, rsp.param2);
-                               *pin = strdup(la_pin);
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_get_wps_pin() SUCCESS");
+       strncpy(la_pin, rsp.param2, WIFI_DIRECT_WPS_PIN_LEN);
+       la_pin[WIFI_DIRECT_WPS_PIN_LEN] = '\0';
+       *pin = strdup(la_pin);
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-
 int wifi_direct_generate_wps_pin(void)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_GENERATE_WPS_PIN;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_GENERATE_WPS_PIN)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d",
-                                                          rsp.result);
-                               WDC_LOGD("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_GENERATE_WPS_PIN) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("wifi_direct_generate_wps_pin() SUCCESS");
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_generate_wps_pin() SUCCESS");
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 
 int wifi_direct_get_supported_wps_mode(int *wps_mode)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int ret = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int ret = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_GET_SUPPORTED_WPS_MODE;
        req.client_id = client_info->client_id;
 
-       ret =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       ret = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (ret != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(ret));
-               client_info->sync_sockfd = -1;
+       if (ret != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(ret));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((ret =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
+       ret = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (ret <= 0)
        {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", ret, strerror(errno));
-               client_info->sync_sockfd = -1;
+               WDC_LOGE("Error!!! reading socket, status = %d", ret);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_GET_SUPPORTED_WPS_MODE)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d \n",
-                                                          rsp.result);
-                               WDC_LOGD("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_GET_SUPPORTED_WPS_MODE) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("Supported wps config = [%d]\n",
-                                                          (int) rsp.param1);
-                               *wps_mode = rsp.param1;
-                       }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("Supported wps config = [%d]", (int) rsp.param1);
+       *wps_mode = rsp.param1;
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
-
 }
 
-
-int wifi_direct_foreach_supported_wps_types(wifi_direct_supported_wps_type_cb callback, void* user_data)
+int wifi_direct_foreach_supported_wps_types(wifi_direct_supported_wps_type_cb cb, void* user_data)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int ret = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if (callback == NULL)
-       {
-               WDC_LOGE("NULL Param [callback]!\n");
+       if (!cb) {
+               WDC_LOGE("NULL Param [callback]!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int ret = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_GET_SUPPORTED_WPS_MODE;
        req.client_id = client_info->client_id;
 
-       ret =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       ret = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (ret != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(ret));
-               client_info->sync_sockfd = -1;
+       if (ret != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(ret));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((ret =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE(
-                                          "Error!!! reading socket, status = %d errno = %s\n", ret,
-                                          strerror(errno));
-               client_info->sync_sockfd = -1;
+       ret = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (ret <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", ret);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_GET_SUPPORTED_WPS_MODE)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d \n",
-                                                          rsp.result);
-                               WDC_LOGD("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_GET_SUPPORTED_WPS_MODE) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD( "Supported wps config = [%d]\n",
-                                                          (int) rsp.param1);
-                               int wps_mode;
-                               bool result = TRUE;
-                               
-                               wps_mode = rsp.param1;
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
+                       return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+               }
+       }
+       WDC_LOGD("Supported wps config = [%d]", (int) rsp.param1);
+
+       int wps_mode;
+       bool result = TRUE;
+       
+       wps_mode = rsp.param1;
+       if (wps_mode & WIFI_DIRECT_WPS_TYPE_PBC)
+               result = cb(WIFI_DIRECT_WPS_TYPE_PBC, user_data);
+       if ((result == true) && (wps_mode & WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY))
+               result = cb(WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY, user_data);
+       if ((result == true) && (wps_mode & WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD))
+               result = cb(WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD, user_data);
+
+       __WDC_LOG_FUNC_END__;
+       return WIFI_DIRECT_ERROR_NONE;
+}
 
-                               if (wps_mode & WIFI_DIRECT_WPS_TYPE_PBC)
-                                       result = callback(WIFI_DIRECT_WPS_TYPE_PBC, user_data);
+int wifi_direct_get_local_wps_type(wifi_direct_wps_type_e* type)
+{
+       __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
+
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+       }
+
+       if (type == NULL) {
+               WDC_LOGE("NULL Param [type]!\n");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+       }
+
+       memset(&req, 0, sizeof(wifi_direct_client_request_s));
+       memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
-                               if ((result == true) && (wps_mode & WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY))
-                                       result = callback(WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY, user_data);
+       req.cmd = WIFI_DIRECT_CMD_GET_LOCAL_WPS_MODE;
+       req.client_id = client_info->client_id;
 
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
+                                                                 sizeof(wifi_direct_client_request_s));
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
+               __wfd_reset_control();
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+       }
 
-                               if ((result == true) && (wps_mode & WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD))
-                                       result = callback(WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD, user_data);
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
+               __wfd_reset_control();
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_GET_LOCAL_WPS_MODE) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
+                               __WDC_LOG_FUNC_END__;
+                               return rsp.result;
                        }
                }
                else
                {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       *type = rsp.param1;
+       WDC_LOGD("wifi_direct_get_local_wps_type() SUCCESS");
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
-
 }
 
-
-int wifi_direct_set_wps_type(wifi_direct_wps_type_e type)
+int wifi_direct_set_req_wps_type(wifi_direct_wps_type_e type)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if (type == WIFI_DIRECT_WPS_TYPE_PBC
-               || type == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY
-               || type == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD)
-       {
-               WDC_LOGD("Param wps_mode [%d]\n", type);
-       }
-       else
-       {
-               WDC_LOGE("Invalid Param [wps_mode]!\n");
+       if (type == WIFI_DIRECT_WPS_TYPE_PBC ||
+                       type == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY ||
+                       type == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) {
+               WDC_LOGD("Param wps_mode [%d]", type);
+       } else {
+               WDC_LOGE("Invalid Param [wps_mode]!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
-       req.cmd = WIFI_DIRECT_CMD_SET_CURRENT_WPS_MODE;
+       req.cmd = WIFI_DIRECT_CMD_SET_REQ_WPS_MODE;
        req.client_id = client_info->client_id;
+       req.data.int1 = type;
 
        status =__wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
-               __wfd_reset_control();
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-
-       WDC_LOGD("writing msg hdr is success!\n");
-
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &type,
-                                                                 sizeof(wifi_direct_wps_type_e));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_SET_CURRENT_WPS_MODE)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d \n",
-                                                          rsp.result);
-                               WDC_LOGD("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_SET_REQ_WPS_MODE) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-int wifi_direct_get_wps_type(wifi_direct_wps_type_e* type)
+int wifi_direct_get_req_wps_type(wifi_direct_wps_type_e* type)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if (type == NULL)
-       {
+       if (type == NULL) {
                WDC_LOGE("NULL Param [type]!\n");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-       wfd_config_data_s ls_config;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
-       req.cmd = WIFI_DIRECT_CMD_GET_CONFIG;
+       req.cmd = WIFI_DIRECT_CMD_GET_REQ_WPS_MODE;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n",
-                                          __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_GET_CONFIG)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGE("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(rsp.result));
+       }else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_GET_REQ_WPS_MODE) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               int status = 0;
-
-                               WDC_LOGD("Link status = %d \n",
-                                                          (int) rsp.param1);
-
-                               status =
-                                       __wfd_client_read_more_data(client_info->sync_sockfd,
-                                                                                               &ls_config,
-                                                                                               sizeof(wfd_config_data_s));
-                               if (status != WIFI_DIRECT_ERROR_NONE)
-                               {
-                                       WDC_LOGE("socket read error.");
-                                       return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-                               }
-
-                               __wfd_client_print_config_data(&ls_config);
-
-                               *type = ls_config.wps_config;
-
-                               WDC_LOGD("wifi_direct_get_wps_type() SUCCESS");
-                       }
                }
                else
                {
@@ -3853,40 +3119,35 @@ int wifi_direct_get_wps_type(wifi_direct_wps_type_e* type)
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       *type = rsp.param1;
+       WDC_LOGD("wifi_direct_get_req_wps_type() SUCCESS");
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 /* DPRECATED */
 int wifi_direct_set_ssid(const char *ssid)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if (NULL == ssid)
-       {
-               WDC_LOGE("NULL Param [ssid]!\n");
+       if (!ssid) {
+               WDC_LOGE("NULL Param [ssid]!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
-
-       WDC_LOGE("ssid = [%s]\n", ssid);
-
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
+       WDC_LOGE("ssid = [%s]", ssid);
 
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
@@ -3894,284 +3155,203 @@ int wifi_direct_set_ssid(const char *ssid)
        req.cmd = WIFI_DIRECT_CMD_SET_SSID;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n",
-                                          strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n",
-                                          __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
-
        WDC_LOGD("writing msg hdr is success!");
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, ssid,
+       status = __wfd_client_send_request(client_info->sync_sockfd, (void*) ssid,
                                                                  WIFI_DIRECT_MAX_SSID_LEN);
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE(
-                                          "Error!!! writing to socket, Errno = %s\n",
-                                          strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n",
-                                          __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_SET_SSID)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGE("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGE("Error!!! [%s]\n",  __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_SET_SSID) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 int wifi_direct_get_ssid(char **ssid)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       char la_ssid[WIFI_DIRECT_MAX_SSID_LEN + 1] = { 0, };
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if (NULL == ssid)
-       {
-               WDC_LOGE("NULL Param [ssid]!\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if (!ssid) {
+               WDC_LOGE("NULL Param [ssid]!");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-       char la_ssid[WIFI_DIRECT_MAX_SSID_LEN + 1] = { 0, };
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_GET_SSID;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n",
-                                          __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_GET_SSID)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d \n",
-                                                          rsp.result);
-                               WDC_LOGD("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_GET_SSID) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("wifi_direct_get_ssid() %s SUCCESS \n",
-                                                          rsp.param2);
-                               snprintf(la_ssid, WIFI_DIRECT_MAX_SSID_LEN+1, rsp.param2);
-                               *ssid = strdup(la_ssid);
-                       }
-
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_get_ssid() %s SUCCESS", rsp.param2);
+       strncpy(la_ssid, rsp.param2, WIFI_DIRECT_MAX_SSID_LEN);
+       la_ssid[WIFI_DIRECT_MAX_SSID_LEN] = '\0';
+       *ssid = strdup(la_ssid);
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-int wifi_direct_get_device_name(char** device_name)
+int wifi_direct_get_device_name(char **device_name)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       char la_device_name[WIFI_DIRECT_MAX_DEVICE_NAME_LEN + 1] = { 0, };
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if (NULL == device_name)
-       {
-               WDC_LOGE("NULL Param [device_name]!\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if (!device_name) {
+               WDC_LOGE("NULL Param [device_name]!");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-       char la_device_name[WIFI_DIRECT_MAX_DEVICE_NAME_LEN + 1] = { 0, };
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_GET_DEVICE_NAME;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s", strerror(errno));
-               WDC_LOGE("Error!!! [%s]", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_GET_DEVICE_NAME)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d \n",
-                                                          rsp.result);
-                               WDC_LOGD("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_GET_DEVICE_NAME) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("wifi_direct_get_device_name() %s SUCCESS \n", rsp.param2);
-                               snprintf(la_device_name, WIFI_DIRECT_MAX_DEVICE_NAME_LEN+1, rsp.param2);
-                               *device_name = strdup(la_device_name);
-                       }
-
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_get_device_name() %s SUCCESS \n", rsp.param2);
+       strncpy(la_device_name, rsp.param2, WIFI_DIRECT_MAX_DEVICE_NAME_LEN);
+       la_device_name[WIFI_DIRECT_MAX_DEVICE_NAME_LEN] = '\0';
+       *device_name = strdup(la_device_name);
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-
 int wifi_direct_set_device_name(const char *device_name)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if (NULL == device_name)
-       {
-               WDC_LOGE("NULL Param [device_name]!\n");
+       if (!device_name) {
+               WDC_LOGE("NULL Param [device_name]!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
-
-       WDC_LOGE("device_name = [%s]\n", device_name);
-
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
+       WDC_LOGE("device_name = [%s]", device_name);
 
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
@@ -4179,393 +3359,275 @@ int wifi_direct_set_device_name(const char *device_name)
        req.cmd = WIFI_DIRECT_CMD_SET_DEVICE_NAME;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n",
-                                          __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
-
        WDC_LOGD( "writing msg hdr is success!\n");
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, device_name,
+       status = __wfd_client_send_request(client_info->sync_sockfd, (void*) device_name,
                                                                  WIFI_DIRECT_MAX_DEVICE_NAME_LEN);
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s\n", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_SET_DEVICE_NAME)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGE("Error!!! Result received = %d \n", rsp.result);
-                               WDC_LOGE("Error!!! [%s]\n",
-                                                          __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_SET_DEVICE_NAME) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGE("Error!!! Result received = %d", rsp.result);
+                               WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-               }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d\n",
-                                                  rsp.cmd);
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-
-int wifi_direct_get_network_interface_name(char** name)
+int wifi_direct_get_network_interface_name(char **name)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_state_e status = 0;
+       char *get_str = NULL;
+       int result;
 
-       if (NULL == name)
-       {
-               WDC_LOGE("NULL Param [name]!\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if (!name) {
+               WDC_LOGE("NULL Param [name]!\n");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_state_e status = 0;
-       int result;
        result = wifi_direct_get_state(&status);
        WDC_LOGD("wifi_direct_get_state() state=[%d], result=[%d]\n", status, result);
 
-       if( status < WIFI_DIRECT_STATE_CONNECTED)
-       {
+       if (status < WIFI_DIRECT_STATE_CONNECTED) {
                WDC_LOGE("Device is not connected!\n");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_PERMITTED;
        }
 
-       char* get_str = NULL;
        get_str = vconf_get_str(VCONFKEY_IFNAME);
-
-       if (get_str == NULL)
-       {
+       if (!get_str) {
                WDC_LOGD( "vconf (%s) value is NULL!!!\n", VCONFKEY_IFNAME);
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_PERMITTED;
        }
-       else
-       {
-               WDC_LOGD( "VCONFKEY_IFNAME(%s) : %s\n", VCONFKEY_IFNAME, get_str);
-
-               char *temp_ifname = NULL;
-               temp_ifname = strdup(get_str);
-               if (NULL == temp_ifname)
-               {
-                       WDC_LOGE("Failed to allocate memory for ifname.\n");
-                       return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
-               }
-
-               *name = temp_ifname;
-       }
+       WDC_LOGD( "VCONFKEY_IFNAME(%s) : %s\n", VCONFKEY_IFNAME, get_str);
+       *name = strdup(get_str);
+       free(get_str);
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-
-
 int wifi_direct_get_ip_address(char **ip_address)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_state_e state = 0;
+       char *get_str = NULL;
+       int result;
 
-       if (NULL == ip_address)
-       {
-               WDC_LOGE("NULL Param [ip_address]!\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if (!ip_address) {
+               WDC_LOGE("NULL Param [ip_address]!\n");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_state_e state = 0;
-       int result;
        result = wifi_direct_get_state(&state);
-       WDC_LOGD( "wifi_direct_get_state() state=[%d], result=[%d]\n", state, result);
-
-       if( state < WIFI_DIRECT_STATE_CONNECTED)
-       {
-               WDC_LOGE("Device is not connected!\n");
+       WDC_LOGD( "wifi_direct_get_state() state=[%d], result=[%d]", state, result);
+       if( state < WIFI_DIRECT_STATE_CONNECTED) {
+               WDC_LOGE("Device is not connected!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_PERMITTED;
        }
 
-       char* get_str = NULL;
        get_str = vconf_get_str(VCONFKEY_LOCAL_IP);
-
-       if (get_str == NULL)
+       if (!get_str)
        {
-               WDC_LOGD("vconf (%s) value is NULL!!!\n", VCONFKEY_LOCAL_IP);
+               WDC_LOGD("vconf (%s) value is NULL!!!", VCONFKEY_LOCAL_IP);
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_PERMITTED;
        }
-       else
-       {
-               WDC_LOGD("VCONFKEY_LOCAL_IP(%s) : %s\n", VCONFKEY_LOCAL_IP, get_str);
-
-               char *temp_ip = NULL;
-               temp_ip = strdup(get_str);
-               if (NULL == temp_ip)
-               {
-                       WDC_LOGE("Failed to allocate memory for local ip address.\n");
-                       return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
-               }
-
-               *ip_address = temp_ip;
-       }
-
+       WDC_LOGD("VCONFKEY_LOCAL_IP(%s) : %s", VCONFKEY_LOCAL_IP, get_str);
+       *ip_address = strdup(get_str);
+       free(get_str);
 
        __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-
-int wifi_direct_get_subnet_mask(char** subnet_mask)
+int wifi_direct_get_subnet_mask(char **subnet_mask)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_state_e status = 0;
+       char *get_str = NULL;
+       int result;
 
-       if (NULL == subnet_mask)
-       {
-               WDC_LOGE("NULL Param [subnet_mask]!\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if (!subnet_mask) {
+               WDC_LOGE("NULL Param [subnet_mask]!");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_state_e status = 0;
-       int result;
        result = wifi_direct_get_state(&status);
-       WDC_LOGD("wifi_direct_get_state() state=[%d], result=[%d]\n", status, result);
-
-       if( status < WIFI_DIRECT_STATE_CONNECTED)
-       {
-               WDC_LOGE("Device is not connected!\n");
+       WDC_LOGD("wifi_direct_get_state() state=[%d], result=[%d]", status, result);
+       if( status < WIFI_DIRECT_STATE_CONNECTED) {
+               WDC_LOGE("Device is not connected!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_PERMITTED;
        }
 
-
-       char* get_str = NULL;
        get_str = vconf_get_str(VCONFKEY_SUBNET_MASK);
-
-       if (get_str == NULL)
-       {
-               WDC_LOGD("vconf (%s) value is NULL!!!\n", VCONFKEY_SUBNET_MASK);
+       if (!get_str) {
+               WDC_LOGD("vconf (%s) value is NULL!!!", VCONFKEY_SUBNET_MASK);
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_PERMITTED;
        }
-       else
-       {
-               WDC_LOGD("VCONFKEY_SUBNET_MASK(%s) : %s", VCONFKEY_SUBNET_MASK, get_str);
-
-               char *temp_subnetmask = NULL;
-               temp_subnetmask = strdup(get_str);
-               if (NULL == temp_subnetmask)
-               {
-                       WDC_LOGE("Failed to allocate memory for subnet mask.\n");
-                       return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
-               }
-
-               *subnet_mask = temp_subnetmask;
-       }
+       WDC_LOGD("VCONFKEY_SUBNET_MASK(%s) : %s", VCONFKEY_SUBNET_MASK, get_str);
+       *subnet_mask = strdup(get_str);
+       free(get_str);
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-
-int wifi_direct_get_gateway_address(char** gateway_address)
+int wifi_direct_get_gateway_address(char **gateway_address)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_state_e status = 0;
+       char *get_str = NULL;
+       int result;
 
-       if (NULL == gateway_address)
-       {
-               WDC_LOGE("NULL Param [gateway_address]!\n");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.\n");
+       if (!gateway_address) {
+               WDC_LOGE("NULL Param [gateway_address]!");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_state_e status = 0;
-       int result;
        result = wifi_direct_get_state(&status);
-       WDC_LOGD("wifi_direct_get_state() state=[%d], result=[%d]\n", status, result);
+       WDC_LOGD("wifi_direct_get_state() state=[%d], result=[%d]", status, result);
 
-       if( status < WIFI_DIRECT_STATE_CONNECTED)
-       {
-               WDC_LOGE("Device is not connected!\n");
+       if(status < WIFI_DIRECT_STATE_CONNECTED) {
+               WDC_LOGE("Device is not connected!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_PERMITTED;
        }
 
-       char* get_str = NULL;
        get_str = vconf_get_str(VCONFKEY_GATEWAY);
-
-       if (get_str == NULL)
-       {
-               WDC_LOGD("vconf (%s) value is NULL!!!\n", VCONFKEY_GATEWAY);
+       if (!get_str) {
+               WDC_LOGD("vconf (%s) value is NULL!!!", VCONFKEY_GATEWAY);
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_PERMITTED;
        }
-       else
-       {
-               WDC_LOGD("VCONFKEY_GATEWAY(%s) : %s", VCONFKEY_GATEWAY, get_str);
-
-               char *temp_gateway = NULL;
-               temp_gateway = strdup(get_str);
-               if (NULL == temp_gateway)
-               {
-                       WDC_LOGE("Failed to allocate memory for gateway address.");
-                       return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
-               }
-
-               *gateway_address = temp_gateway;
-       }
+       WDC_LOGD("VCONFKEY_GATEWAY(%s) : %s", VCONFKEY_GATEWAY, get_str);
+       *gateway_address = strdup(get_str);
+       free(get_str);
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-
 int wifi_direct_get_mac_address(char **mac_address)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       int fd;
+       int n;
+       char mac_info[MACSTR_LEN];
+       unsigned char la_mac_addr[6];
 
-       if (NULL == mac_address)
-       {
-               WDC_LOGE("NULL Param [mac_address]!");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGD("Client is NOT registered.");
+       if (!mac_address) {
+               WDC_LOGE("NULL Param [mac_address]!");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       int fd;
-       int n;
-       char mac_info[18];
-       unsigned char la_mac_addr[6];
-
        memset(mac_info, 0, sizeof(mac_info));
 
        fd = open(WIFI_DIRECT_MAC_ADDRESS_INFO_FILE, O_RDONLY);
-       if (fd < 3)
-       {
+       if (fd == -1) {
                WDC_LOGE("[.mac.info] file open failed.");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_OPERATION_FAILED;
        }
 
-       n = read(fd, mac_info, 18);
-       if(n < 0)
-       {
+       n = read(fd, mac_info, MACSTR_LEN);
+       if(n < 0) {
                WDC_LOGE("[.mac.info] file read failed.");
                if (fd > 0)
                        close(fd);
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_OPERATION_FAILED;
        }
-
+       mac_info[17] = '\0';
        WDC_LOGD("mac_address = [%s]", mac_info);
 
        memset(la_mac_addr, 0, sizeof(la_mac_addr));
        macaddr_atoe(mac_info, la_mac_addr);
        la_mac_addr[0] |= 0x02;
 
-       char *temp_mac = NULL;
-       temp_mac = (char *) calloc(1, 18);
-       if (NULL == temp_mac)
-       {
-               WDC_LOGE("Failed to allocate memory for MAC address");
-               if (fd > 2)
-                       close(fd);
-               return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
-       }
-
-       snprintf(temp_mac, 18, MACSTR, MAC2STR(la_mac_addr));
+       *mac_address = (char*) calloc(1, MACSTR_LEN);
+       snprintf(*mac_address, MACSTR_LEN, MACSTR, MAC2STR(la_mac_addr));
 
-       *mac_address = temp_mac;
-
-       if (fd > 2)
+       if (fd > 0)
                close(fd);
 
        __WDC_LOG_FUNC_END__;
@@ -4573,497 +3635,367 @@ int wifi_direct_get_mac_address(char **mac_address)
 }
 
 
-int wifi_direct_get_state(wifi_direct_state_e * state)
+int wifi_direct_get_state(wifi_direct_state_e *state)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int ret = WIFI_DIRECT_ERROR_NONE;
 
-       if (NULL == state)
-       {
+       if (!state) {
                WDC_LOGE("NULL Param [state]!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int ret = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_GET_LINK_STATUS;
        req.client_id = client_info->client_id;
 
-       ret =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       ret = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (ret != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s", strerror(errno));
-               WDC_LOGE("Error!!! [%s]", __wfd_print_error(ret));
-               client_info->sync_sockfd = -1;
+       if (ret != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(ret));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((ret =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s", ret,
-                                          strerror(errno));
-               client_info->sync_sockfd = -1;
+       ret = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (ret <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", ret);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_GET_LINK_STATUS)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
-                               WDC_LOGD("Error!!! Result received = %d %s", rsp.result, __wfd_print_error(rsp.result));
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_GET_LINK_STATUS) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
+                               WDC_LOGD("Error!!! Result received = %d[%s]", rsp.result, __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("Link Status = %d", (int) rsp.param1);
-                               *state = (wifi_direct_state_e) rsp.param1;
-
-                               /* for CAPI : there is no WIFI_DIRECT_STATE_GROUP_OWNER type in CAPI */
-                               if(*state == WIFI_DIRECT_STATE_GROUP_OWNER)
-                                       *state = WIFI_DIRECT_STATE_CONNECTED;
-
-                       }
-               }
-               else
-               {
+               } else {
                        WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("Link Status = %d", (int) rsp.param1);
+       *state = (wifi_direct_state_e) rsp.param1;
 
-       __WDC_LOG_FUNC_END__;
+       /* for CAPI : there is no WIFI_DIRECT_STATE_GROUP_OWNER type in CAPI */
+       if(*state == WIFI_DIRECT_STATE_GROUP_OWNER)
+               *state = WIFI_DIRECT_STATE_CONNECTED;
 
+       __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 
 int wifi_direct_is_discoverable(bool* discoverable)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if (discoverable == NULL)
-       {
-               WDC_LOGE("NULL Param [discoverable]!");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.");
+       if (!discoverable) {
+               WDC_LOGE("NULL Param [discoverable]!");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_IS_DISCOVERABLE;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s", strerror(errno));
-               WDC_LOGE("Error!!! [%s]", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_IS_DISCOVERABLE)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_IS_DISCOVERABLE) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
                                WDC_LOGD("Error!!! Result received = %d", rsp.result);
                                WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("wifi_direct_is_discoverable() %s SUCCESS", rsp.param2);
-                               *discoverable = (bool) rsp.param1;
-                       }
-               }
-               else
-               {
+               } else {
                        WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_is_discoverable() SUCCESS");
+       *discoverable = (bool) rsp.param1;
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
-
 }
 
-
 int wifi_direct_is_listening_only(bool* listen_only)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if (listen_only == NULL)
-       {
-               WDC_LOGE("NULL Param [listen_only]!");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.");
+       if (!listen_only) {
+               WDC_LOGE("NULL Param [listen_only]!");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_IS_LISTENING_ONLY;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s", strerror(errno));
-               WDC_LOGE("Error!!! [%s]", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_IS_LISTENING_ONLY)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_IS_LISTENING_ONLY)       {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
                                WDC_LOGD("Error!!! Result received = %d", rsp.result);
                                WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("wifi_direct_is_listening_only() %s SUCCESS", rsp.param2);
-                               *listen_only = (bool) rsp.param1;
-                       }
-               }
-               else
-               {
+               } else {
                        WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_is_listening_only() SUCCESS");
+       *listen_only = (bool) rsp.param1;
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
-
 }
 
 
 int wifi_direct_get_primary_device_type(wifi_direct_primary_device_type_e* type)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
 
-       if (NULL == type)
-       {
+       if (!type) {
                WDC_LOGE("NULL Param [type]!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
        WDC_LOGD("Current primary_dev_type [%d]", WIFI_DIRECT_PRIMARY_DEVICE_TYPE_TELEPHONE);
-
-       *type = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_TELEPHONE;      // Telephone
+       *type = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_TELEPHONE;
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 int wifi_direct_get_secondary_device_type(wifi_direct_secondary_device_type_e* type)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
 
-       if (NULL == type)
-       {
-               WDC_LOGE("NULL Param [type]!");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.");
+       if (NULL == type) {
+               WDC_LOGE("NULL Param [type]!");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-
        WDC_LOGD("Current second_dev_type [%d]", WIFI_DIRECT_SECONDARY_DEVICE_TYPE_PHONE_SM_DUAL);
-
        *type = WIFI_DIRECT_SECONDARY_DEVICE_TYPE_PHONE_SM_DUAL;        // smart phone dual mode (wifi and cellular)
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 int wifi_direct_set_autoconnection_mode(bool mode)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
-       req.cmd = WIFI_DIRECT_CMD_SET_AUTOCONNECTION_MODE;
-       req.client_id = client_info->client_id;
-
-       status =__wfd_client_send_request(client_info->sync_sockfd, &req,
-                                                                 sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n",
-                                          __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
-               __wfd_reset_control();
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-
-       WDC_LOGD("writing msg hdr is success!");
+       req.cmd = WIFI_DIRECT_CMD_SET_AUTOCONNECTION_MODE;
+       req.client_id = client_info->client_id;
+       req.data.int1 = mode;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &mode,
-                                                                 sizeof(bool));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s", strerror(errno));
-               WDC_LOGE("Error!!! [%s]", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       status =__wfd_client_send_request(client_info->sync_sockfd, &req,
+                                                                 sizeof(wifi_direct_client_request_s));
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
+       WDC_LOGD("writing msg hdr is success!");
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_SET_AUTOCONNECTION_MODE)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_SET_AUTOCONNECTION_MODE) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
                                WDC_LOGD("Error!!! Result received = %d", rsp.result);
                                WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-               }
-               else
-               {
+               } else {
                        WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-int wifi_direct_is_autoconnection_mode(boolmode)
+int wifi_direct_is_autoconnection_mode(bool *mode)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if (mode == NULL)
-       {
-               WDC_LOGE("NULL Param [mode]!");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.");
+       if (!mode) {
+               WDC_LOGE("NULL Param [mode]!");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_IS_AUTOCONNECTION_MODE;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s", strerror(errno));
-               WDC_LOGE("Error!!! [%s]", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_IS_AUTOCONNECTION_MODE)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_IS_AUTOCONNECTION_MODE) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
                                WDC_LOGD("Error!!! Result received = %d", rsp.result);
                                WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("wifi_direct_is_autoconnection_mode() %s SUCCESS", rsp.param2);
-                               *mode = (bool) rsp.param1;
-                       }
-               }
-               else
-               {
+               } else {
                        WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_is_autoconnection_mode() SUCCESS");
+       *mode = (bool) rsp.param1;
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 
 }
@@ -5071,23 +4003,19 @@ int wifi_direct_is_autoconnection_mode(bool* mode)
 
 int wifi_direct_set_persistent_group_enabled(bool enabled)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
@@ -5095,49 +4023,33 @@ int wifi_direct_set_persistent_group_enabled(bool enabled)
                req.cmd = WIFI_DIRECT_CMD_ACTIVATE_PERSISTENT_GROUP;
        else
                req.cmd = WIFI_DIRECT_CMD_DEACTIVATE_PERSISTENT_GROUP;
-
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s", strerror(errno));
-               WDC_LOGE("Error!!! [%s]",
-                                          __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
+       } else {
                if (rsp.cmd == WIFI_DIRECT_CMD_ACTIVATE_PERSISTENT_GROUP
-                       || rsp.cmd == WIFI_DIRECT_CMD_DEACTIVATE_PERSISTENT_GROUP)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
+                       || rsp.cmd == WIFI_DIRECT_CMD_DEACTIVATE_PERSISTENT_GROUP) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
                                WDC_LOGD( "Error!!! Result received = %d", rsp.result);
                                WDC_LOGD( "Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("wifi_direct_set_persistent_group_enabled() SUCCESS");
-                       }
                }
                else
                {
@@ -5145,420 +4057,323 @@ int wifi_direct_set_persistent_group_enabled(bool enabled)
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_set_persistent_group_enabled() SUCCESS");
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 
-int wifi_direct_is_persistent_group_enabled(boolenabled)
+int wifi_direct_is_persistent_group_enabled(bool *enabled)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if (enabled == NULL)
-       {
-               WDC_LOGE("NULL Param [enabled]!");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.");
+       if (!enabled) {
+               WDC_LOGE("NULL Param [enabled]!");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_IS_PERSISTENT_GROUP;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s", strerror(errno));
-               WDC_LOGE("Error!!! [%s]\n",
-                                          __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_IS_PERSISTENT_GROUP)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_IS_PERSISTENT_GROUP) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
                                WDC_LOGD("Error!!! Result received = %d", rsp.result);
                                WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-                               WDC_LOGD("wifi_direct_is_persistent_group_enabled() %s SUCCESS", rsp.param2);
-                               *enabled = (bool) rsp.param1;
-                       }
-               }
-               else
-               {
+               } else {
                        WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
+       WDC_LOGD("wifi_direct_is_persistent_group_enabled() SUCCESS");
+       *enabled = (bool) rsp.param1;
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
-
 }
 
-int wifi_direct_foreach_persistent_groups(wifi_direct_persistent_group_cb callback, void* user_data)
+int wifi_direct_foreach_persistent_groups(wifi_direct_persistent_group_cb cb,
+                                                                                               void* user_data)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int res = WIFI_DIRECT_ERROR_NONE;
+       int i;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if (callback == NULL)
-       {
+       if (!cb) {
                WDC_LOGE("NULL Param [callback]!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-       int i;
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_GET_PERSISTENT_GROUP_INFO;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       res = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s", strerror(errno));
-               WDC_LOGE("Error!!! [%s]", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (res != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(res));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       res = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (res <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", res);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_GET_PERSISTENT_GROUP_INFO)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_GET_PERSISTENT_GROUP_INFO) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
                                WDC_LOGE("Error!!! Result received = %d", rsp.result);
                                WDC_LOGE("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-                       else
-                       {
-
-                               int num = rsp.param1;
-                               int status = 0;
-                               wfd_persistent_group_info_s *buff = NULL;
-
-                               WDC_LOGD("Num of persistent groups = %d", (int) rsp.param1);
-
-                               if (num > 0)
-                               {
-                                       buff = (wfd_persistent_group_info_s *) malloc(num * sizeof(wfd_persistent_group_info_s));
-                                       if (buff == NULL)
-                                       {
-                                               WDC_LOGE("malloc() failed!!!.");
-                                               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-                                       }
-
-                                       status =
-                                               __wfd_client_read_more_data(client_info->sync_sockfd,
-                                                                                                       buff,
-                                                                                                       num *
-                                                                                                       sizeof
-                                                                                                       (wfd_persistent_group_info_s));
-                                       if (status != WIFI_DIRECT_ERROR_NONE)
-                                       {
-                                               if (NULL != buff)
-                                                       free(buff);
-                                               WDC_LOGE("socket read error.");
-                                               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-                                       }
-                               }
+               } else {
+                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
+                       return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+               }
+       }
 
-                               __wfd_client_print_persistent_group_info(buff, num);
+       int num = rsp.param1;
+       wfd_persistent_group_info_s *buff = NULL;
 
-                               WDC_LOGD("wifi_direct_foreach_persistent_groups() SUCCESS");
+       WDC_LOGD("Num of persistent groups = %d", (int) rsp.param1);
 
-                               char* ssid;
-                               char* go_mac_address;
+       if (num > 0) {
+               buff = (wfd_persistent_group_info_s *) malloc(num * sizeof(wfd_persistent_group_info_s));
+               if (!buff) {
+                       WDC_LOGE("malloc() failed!!!.");
+                       return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+               }
 
-                               for (i = 0; i < num; i++)
-                               {
-                                       ssid = strdup(buff[i].ssid);
-                                       go_mac_address = (char *) calloc(1, 18);
-                                       snprintf(go_mac_address, 18, MACSTR, MAC2STR(buff[i].go_mac_address));
+               res = __wfd_client_read_more_data(client_info->sync_sockfd, (char*) buff,
+                                                                               num * sizeof(wfd_persistent_group_info_s));
+               if (res != WIFI_DIRECT_ERROR_NONE){
+                       free(buff);
+                       WDC_LOGE("socket read error.");
+                       return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+               }
+       }
 
-                                       if (!callback(go_mac_address, ssid, user_data))
-                                               break;
-                               }
+       __wfd_client_print_persistent_group_info(buff, num);
+       WDC_LOGD("wifi_direct_foreach_persistent_groups() SUCCESS");
 
-                               if (NULL != buff)
-                                       free(buff);
+       char *ssid;
+       char *go_mac_address;
 
-                       }
+       for (i = 0; i < num; i++) {
+               ssid = strdup(buff[i].ssid);
+               if (!ssid) {
+                       WDC_LOGD("Failed to copy ssid");
+                       break;
                }
-               else
-               {
-                       WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
-                       return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+               go_mac_address = (char*) calloc(1, MACSTR_LEN);
+               if (!go_mac_address) {
+                       WDC_LOGD("Failed to allocate memory for GO MAC address");
+                       free(ssid);
+                       return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
                }
+               snprintf(go_mac_address, MACSTR_LEN, MACSTR, MAC2STR(buff[i].go_mac_address));
+
+               res = cb(go_mac_address, ssid, user_data);
+               free(ssid);
+               ssid = NULL;
+               free(go_mac_address);
+               go_mac_address = NULL;
+               if (!res)
+                       break;
        }
 
-       __WDC_LOG_FUNC_END__;
+       if (buff)
+               free(buff);
 
+       __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
 }
 
-int wifi_direct_remove_persistent_group(const char* mac_address, const char* ssid)
+int wifi_direct_remove_persistent_group(const char *mac_address, const char *ssid)
 {
        __WDC_LOG_FUNC_START__;
-
        wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       wfd_persistent_group_info_s persistent_group_info;
+       int status = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if ( NULL== mac_address )
-       {
-               WDC_LOGE("NULL Param [mac_address]!");
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
-       }
-
-       if ( NULL== ssid )
-       {
-               WDC_LOGE("NULL Param [ssid]!");
+       if (!mac_address || !ssid) {
+               WDC_LOGE("NULL Param");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-       wfd_persistent_group_info_s persistent_group_info;
-       unsigned char la_mac_addr[6];
-
-       int status = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_REMOVE_PERSISTENT_GROUP;
        req.client_id = client_info->client_id;
 
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s", strerror(errno));
-               WDC_LOGE("Error!!! [%s]", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
-
        WDC_LOGD("writing msg hdr is success!");
 
-       strncpy(persistent_group_info.ssid, ssid, strlen(ssid));
-       persistent_group_info.ssid[WIFI_DIRECT_MAX_SSID_LEN] = '\0';
+       strncpy(persistent_group_info.ssid, ssid, WIFI_DIRECT_MAX_SSID_LEN);
+       persistent_group_info.ssid[WIFI_DIRECT_MAX_SSID_LEN] ='\0';
+       macaddr_atoe(mac_address, persistent_group_info.go_mac_address);
 
-       memset(la_mac_addr, 0, sizeof(la_mac_addr));
-       macaddr_atoe(mac_address, la_mac_addr);
-       persistent_group_info.go_mac_address[0] = la_mac_addr[0];
-       persistent_group_info.go_mac_address[1] = la_mac_addr[1];
-       persistent_group_info.go_mac_address[2] = la_mac_addr[2];
-       persistent_group_info.go_mac_address[3] = la_mac_addr[3];
-       persistent_group_info.go_mac_address[4] = la_mac_addr[4];
-       persistent_group_info.go_mac_address[5] = la_mac_addr[5];
-
-       status =
-               __wfd_client_send_request(client_info->sync_sockfd, &persistent_group_info,
+       status = __wfd_client_send_request(client_info->sync_sockfd, &persistent_group_info,
                                                                  sizeof(wfd_persistent_group_info_s));
-       if (status != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s", strerror(errno));
-               WDC_LOGE("Error!!! [%s]", __wfd_print_error(status));
-               client_info->sync_sockfd = -1;
+       if (status != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(status));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((status =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s\n", status, strerror(errno));
-               client_info->sync_sockfd = -1;
+       status = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (status <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", status);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_REMOVE_PERSISTENT_GROUP)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_REMOVE_PERSISTENT_GROUP) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
                                WDC_LOGD("Error!!! Result received = %d", rsp.result);
                                WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-               }
-               else
-               {
+               } else {
                        WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
 
 int wifi_direct_set_p2poem_loglevel(int increase_log_level)
 {
-       wifi_direct_client_info_s *client_info = __wfd_get_control();
-
        __WDC_LOG_FUNC_START__;
+       wifi_direct_client_info_s *client_info = __wfd_get_control();
+       wifi_direct_client_request_s req;
+       wifi_direct_client_response_s rsp;
+       int ret = WIFI_DIRECT_ERROR_NONE;
 
-       if ((client_info->is_registered == false)
-               || (client_info->client_id == WFD_INVALID_ID))
-       {
-               WDC_LOGE("Client is NOT registered.");
+       if ((client_info->is_registered == false) ||
+                       (client_info->client_id == WFD_INVALID_ID)) {
+               WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-
-       int ret = WIFI_DIRECT_ERROR_NONE;
-
        memset(&req, 0, sizeof(wifi_direct_client_request_s));
        memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
 
        req.cmd = WIFI_DIRECT_CMD_SET_OEM_LOGLEVEL;
        req.client_id = client_info->client_id;
        if (increase_log_level == 0)
-               req.data.listen_only = false;
+               req.data.int1 = false;
        else
-               req.data.listen_only = true;
+               req.data.int1 = true;
 
-       ret =
-               __wfd_client_send_request(client_info->sync_sockfd, &req,
+       ret = __wfd_client_send_request(client_info->sync_sockfd, &req,
                                                                  sizeof(wifi_direct_client_request_s));
-       if (ret != WIFI_DIRECT_ERROR_NONE)
-       {
-               WDC_LOGE("Error!!! writing to socket, Errno = %s", strerror(errno));
-               WDC_LOGE("Error!!! [%s]", __wfd_print_error(ret));
-               client_info->sync_sockfd = -1;
+       if (ret != WIFI_DIRECT_ERROR_NONE) {
+               WDC_LOGE("Error!!! writing to socket[%s]", __wfd_print_error(ret));
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
        }
 
-       if ((ret =
-                __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
-                                                                 sizeof(wifi_direct_client_response_s))) <= 0)
-       {
-               WDC_LOGE("Error!!! reading socket, status = %d errno = %s", ret, strerror(errno));
-               client_info->sync_sockfd = -1;
+       ret = __wfd_client_read_socket(client_info->sync_sockfd, (char*) &rsp,
+                                                                 sizeof(wifi_direct_client_response_s));
+       if (ret <= 0) {
+               WDC_LOGE("Error!!! reading socket, status = %d", ret);
                __wfd_reset_control();
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
-       }
-       else
-       {
-               if (rsp.cmd == WIFI_DIRECT_CMD_SET_OEM_LOGLEVEL)
-               {
-                       if (rsp.result != WIFI_DIRECT_ERROR_NONE)
-                       {
+       } else {
+               if (rsp.cmd == WIFI_DIRECT_CMD_SET_OEM_LOGLEVEL) {
+                       if (rsp.result != WIFI_DIRECT_ERROR_NONE) {
                                WDC_LOGD("Error!!! Result received = %d", rsp.result);
                                WDC_LOGD("Error!!! [%s]", __wfd_print_error(rsp.result));
                                __WDC_LOG_FUNC_END__;
                                return rsp.result;
                        }
-               }
-               else
-               {
+               } else {
                        WDC_LOGE("Error!!! Invalid resp cmd = %d", rsp.cmd);
                        return WIFI_DIRECT_ERROR_OPERATION_FAILED;
                }
        }
 
        __WDC_LOG_FUNC_END__;
-
        return WIFI_DIRECT_ERROR_NONE;
 }
index eb9735b..b6c2e30 100644 (file)
 #include <errno.h>
 #include <sys/time.h>
 
-#define _GNU_SOURCE            
+#define _GNU_SOURCE
 #include <unistd.h>
-#include <sys/syscall.h>               
+#include <sys/syscall.h>
 
 #include "wifi-direct.h"
 #include "wifi-direct-client-proxy.h"
 #include "wifi-direct-internal.h"
 
-#if 0
-int wfd_gettid()
-{
-#ifdef __NR_gettid
-       return syscall(__NR_gettid);
-#else
-       WDC_LOGE("__NR_gettid is not defined, please include linux/unistd.h ");
-       return -1;
-#endif
-}
-
-char *wfd_trim_path(const char *filewithpath)
-{
-       static char *filename[100];
-       char *strptr = NULL;
-       int start = 0;
-       const char *space = "                                        ";
-       int len = strlen(filewithpath);
-
-       if (len > 20) {
-               strptr = (char *) filewithpath + (len - 20);
-               start = 0;
-       } else if (len < 20) {
-               strptr = (char *) filewithpath;
-               start = 20 - len;
-       }
-       strncpy((char *) filename, space, strlen(space));
-       strncpy((char *) filename + start, strptr, 50);
-
-       return (char *) filename;
-}
-
-char *wfd_debug_print(char *file, int line, char *format, ...)
-{
-       static char buffer_internal[512];
-       char prefix_buffer[64];
-       char *prefix;
-       va_list args;
-       char buf[512];
-       int header_max = 35;
-
-       va_start(args, format);
-       vsnprintf(buf, 512, format, args);
-       va_end(args);
-
-       snprintf(prefix_buffer, 64, "[%s:%d,%d]", file, line, wfd_gettid());
-       int len = strlen(prefix_buffer);
-       if (len > header_max) {
-               prefix = prefix_buffer + (len - header_max);
-       } else {
-               prefix = prefix_buffer;
-       }
-
-       snprintf(buffer_internal, 512, "%s%s", prefix, buf);
-
-       return buffer_internal;
-}
-#endif
 
 char *wfd_print_state(wifi_direct_state_e s)
 {
index 971fb6a..cc614a4 100755 (executable)
@@ -1,6 +1,6 @@
 prefix=@prefix@
 exec_prefix=@prefix@
-libdir=@LIB_INSTALL_DIR@
+libdir=@prefix@/lib
 includedir=@prefix@/include
 
 Name: wifi-direct