Add set/get values implementation and test file for that 43/125843/2
authorJiung Yu <jiung.yu@samsung.com>
Wed, 19 Apr 2017 05:46:35 +0000 (14:46 +0900)
committerJiung Yu <jiung.yu@samsung.com>
Wed, 19 Apr 2017 07:21:24 +0000 (16:21 +0900)
Change-Id: I72d414213066d1b533b3cea1cec372ed237a302b
Signed-off-by: Yu jiung <jiung.yu@samsung.com>
14 files changed:
CMakeLists.txt
asp-test.manifest [new file with mode: 0755]
packaging/capi-network-asp.spec
pkgconfig/CMakeLists.txt [new file with mode: 0755]
pkgconfig/asp.pc.in [new file with mode: 0755]
src/CMakeLists.txt [new file with mode: 0755]
src/asp-client.c [new file with mode: 0644]
src/asp-dbus.c [new file with mode: 0644]
src/include/asp-client.h [new file with mode: 0755]
src/include/asp-dbus.h [new file with mode: 0755]
src/include/asp-log.h [new file with mode: 0755]
src/include/asp-util.h [new file with mode: 0755]
test/CMakeLists.txt [new file with mode: 0755]
test/asp-test.c [new file with mode: 0644]

index 84e7537..65b33ec 100755 (executable)
@@ -55,3 +55,6 @@ SET(TARGET_ASP_TEST "asp-test")
 
 
 ADD_SUBDIRECTORY(include)
+ADD_SUBDIRECTORY(src)
+ADD_SUBDIRECTORY(pkgconfig)
+ADD_SUBDIRECTORY(test)
diff --git a/asp-test.manifest b/asp-test.manifest
new file mode 100755 (executable)
index 0000000..50eefc9
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
\ No newline at end of file
index bd20e08..f2aeec7 100755 (executable)
@@ -1,4 +1,4 @@
-%define file_transfer_test yes
+%define file_transfer_test no
 
 Name:       capi-network-asp
 Summary:    An Application Service Platform(ASP) libraries in Native API
@@ -91,7 +91,14 @@ rm -rf %{buildroot}
 %manifest capi-network-asp.manifest
 %license LICENSE
 %defattr(-,root,root,-)
+%{_libdir}/*.so*
 
 %files devel
 %defattr(-,root,root,-)
+%{_libdir}/pkgconfig/*.pc
 %{_includedir}/asp/*.h
+%{_libdir}/*.so
+
+%files test
+%manifest asp-test.manifest
+%attr(755,root,root) %{_bindir}/asp-test
diff --git a/pkgconfig/CMakeLists.txt b/pkgconfig/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..d41df87
--- /dev/null
@@ -0,0 +1,24 @@
+# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+# @file        CMakeLists.txt
+#
+
+CONFIGURE_FILE(asp.pc.in asp.pc @ONLY)
+
+INSTALL(FILES
+    ${CMAKE_BINARY_DIR}/pkgconfig/asp.pc
+    DESTINATION
+    ${LIB_DIR}/pkgconfig
+    )
diff --git a/pkgconfig/asp.pc.in b/pkgconfig/asp.pc.in
new file mode 100755 (executable)
index 0000000..f643d4e
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}
+libdir=@LIB_DIR@
+includedir=${prefix}/include
+
+Name: asp
+Description: asp package
+Version: @VERSION@
+Requires: capi-base-common
+Libs: -L${libdir} -lasp
+Cflags: -I${includedir}/asp
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..50b66b2
--- /dev/null
@@ -0,0 +1,45 @@
+# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+# @file        CMakeLists.txt
+#
+SET(ASP_PATH ${PROJECT_SOURCE_DIR}/src)
+
+INCLUDE_DIRECTORIES(
+    ${CMAKE_SOURCE_DIR}/include
+    ${ASP_PATH}/include
+    )
+
+SET(ASP_SOURCES
+    ${ASP_PATH}/asp-client.c
+    ${ASP_PATH}/asp-dbus.c
+    )
+
+ADD_DEFINITIONS("-fvisibility=default")
+
+ADD_LIBRARY(${TARGET_ASP} SHARED ${ASP_SOURCES})
+
+SET_TARGET_PROPERTIES(
+    ${TARGET_ASP}
+    PROPERTIES
+        SOVERSION ${MAJORVER}
+        VERSION ${FULLVER}
+    )
+
+TARGET_LINK_LIBRARIES(${TARGET_ASP}
+    ${ASP_DEPS_LIBRARIES}
+    dl
+    )
+
+INSTALL(TARGETS ${TARGET_ASP} DESTINATION ${LIB_DIR})
diff --git a/src/asp-client.c b/src/asp-client.c
new file mode 100644 (file)
index 0000000..135b5dd
--- /dev/null
@@ -0,0 +1,3260 @@
+/*
+ * Application Service Platform(ASP)
+ *
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file implements Application Service Platform(ASP) user library.
+ *
+ * @file        asp-client.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <string.h>
+#include <sys/un.h>
+#include <sys/wait.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <signal.h>
+#include <linux/unistd.h>
+#include <sys/poll.h>
+#include <pthread.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+#include <system_info.h>
+
+/*****************************************************************************
+ *  Application Service Platform(ASP) library headers
+ *****************************************************************************/
+#include "asp.h"
+
+#include "asp-client.h"
+#include "asp-dbus.h"
+#include "asp-log.h"
+#include "asp-util.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+static __thread asp_client_info_s g_client_info = {
+       .is_registered = FALSE,
+
+       .seek_search_result_cb = NULL,
+       .advert_status_changed_cb = NULL,
+       .session_request_cb = NULL,
+       .session_config_request_cb = NULL,
+       .session_connect_status_cb = NULL,
+       .session_status_cb = NULL,
+       .session_port_status_cb = NULL,
+
+       .user_data_for_cb_seek_search_result = NULL,
+       .user_data_for_cb_advert_status_changed = NULL,
+       .user_data_for_cb_session_request = NULL,
+       .user_data_for_cb_session_config_request = NULL,
+       .user_data_for_cb_session_connect_status = NULL,
+       .user_data_for_cb_session_status = NULL,
+       .user_data_for_cb_session_port_status = NULL
+};
+
+static __thread GList *asp_adverts = NULL;
+static __thread GList *asp_seeks = NULL;
+static __thread GList *asp_sessions = NULL;
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+static int _txt_to_mac(char *txt, unsigned char *mac)
+{
+       int i = 0;
+
+       for (;;) {
+               mac[i++] = (char)strtoul(txt, &txt, 16);
+               if (i == MACADDR_LEN || !*txt++)
+                       break;
+       }
+
+       if (i != MACADDR_LEN)
+               return -1;
+
+       ASP_LOGD("Converted MAC address [" MACSECSTR "]",
+                                       MAC2SECSTR(mac));
+       return 0;
+}
+
+static int __asp_err_string_to_enum(const char *error)
+{
+       if (NULL != strstr(error, "NoReply"))
+               return ASP_ERROR_COMMUNICATION_FAILED;
+       else if (NULL != strstr(error, "PermissionDenied"))
+               return ASP_ERROR_PERMISSION_DENIED;
+       else if (NULL != strstr(error, "MEM_ERR"))
+               return ASP_ERROR_OUT_OF_MEMORY;
+       else if (NULL != strstr(error, "INVALID_PARAM"))
+               return ASP_ERROR_INVALID_PARAMETER;
+       else if (NULL != strstr(error, "OPER_FAILED"))
+               return ASP_ERROR_OPERATION_FAILED;
+       else if (NULL != strstr(error, "NO_SERVICE"))
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       else if (NULL != strstr(error, "NO_SESSION"))
+               return ASP_ERROR_SESSION_NOT_FOUND;
+       else
+               return ASP_ERROR_OPERATION_FAILED;
+}
+
+static char* __asp_create_service_info_from_g_variant(GVariant *variant)
+{
+       GVariantIter *iter = NULL;
+       GVariant* var = NULL;
+       gchar *key = NULL;
+       gchar *value = NULL;
+       gchar *info = NULL;
+       int offset = 0;
+       int len = 0;
+       gsize value_len = 0;
+
+       info = (gchar*)g_try_malloc0(ASP_SERVICE_INFO_MAX_LEN + 1);
+       if (!info)
+               return NULL;
+
+       g_variant_get(variant, "a{sv}", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               value = g_variant_dup_string(var, &value_len);
+               len = strlen(key) + value_len + 2;
+               snprintf(info + offset, len + 1, "%s=%s,", key, value);
+               offset += len;
+               g_free(value);
+       }
+
+       return info;
+}
+
+void asp_process_seek_search_result(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters)
+{
+       __ASP_LOG_FUNC_START__;
+
+       asp_client_info_s *client = &g_client_info;
+
+       GVariantIter *iter = NULL;
+       GVariant *var = NULL;
+       const char *key = NULL;
+       const char *str = NULL;
+       unsigned int search_id = 0;
+       const char *service_mac = NULL;
+       unsigned int advertisement_id = 0;
+       unsigned int config_method = 0;
+       char *instance_name = NULL;
+       char *service_info = NULL;
+       unsigned char status = 0;
+       int error_code = ASP_ERROR_NONE;
+
+       if (!client->seek_search_result_cb) {
+               ASP_LOGE("search_result_cb is NULL!!");
+               return;
+       }
+
+       if (!parameters) {
+               __ASP_LOG_FUNC_END__;
+               return;
+       }
+
+       g_variant_get(parameters, "(a{sv})", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               if (!g_strcmp0(key, "search_id")) {
+                       g_variant_get(var, "u", &search_id);
+               } else if (!g_strcmp0(key, "service_mac")) {
+                       g_variant_get(var, "&s", &str);
+                       service_mac = g_strndup(str, MACSTR_LEN);
+               } else if (!g_strcmp0(key, "adv_id")) {
+                       g_variant_get(var, "u", &advertisement_id);
+               } else if (!g_strcmp0(key, "config_method")) {
+                       g_variant_get(var, "u", &config_method);
+               } else if (!g_strcmp0(key, "instance_name")) {
+                       g_variant_get(var, "&s", &str);
+                       instance_name = g_strdup(str);
+               } else if (!g_strcmp0(key, "service_info")) {
+                       service_info = __asp_create_service_info_from_g_variant(var);
+                       ASP_LOGD("Service Info: %s", service_info);
+               } else if (!g_strcmp0(key, "service_status")) {
+                       g_variant_get(var, "y", &status);
+               }  else {
+                       ;/* Do Nothing */
+               }
+       }
+
+       //TODO :client->search_result_cb
+       g_variant_iter_free(iter);
+
+       __ASP_LOG_FUNC_END__;
+       return;
+}
+
+void asp_process_advert_status_changed(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters)
+{
+       __ASP_LOG_FUNC_START__;
+
+       asp_client_info_s *client = &g_client_info;
+       unsigned int advertisement_id = 0;
+       unsigned char status = 0;
+       int reason = 0;
+
+       if (!client->advert_status_changed_cb) {
+               ASP_LOGE("search_result_cb is NULL!!");
+               return;
+       }
+
+       if (!parameters) {
+               __ASP_LOG_FUNC_END__;
+               return;
+       }
+
+       g_variant_get(parameters, "(uyi)", &advertisement_id, &status, &reason);
+
+       //TODO :client->advert_status_changed_cb
+
+       __ASP_LOG_FUNC_END__;
+       return;
+}
+
+int __handle_session_request(unsigned int adv_id, char *session_mac,
+               unsigned int session_id, char *session_info)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+       asp_client_session_s *session = NULL;
+       GList *temp = NULL;
+       int res = 0;
+
+       for (temp = g_list_first(asp_adverts);
+                       temp != NULL; temp = g_list_next(temp)) {
+               service = temp->data;
+               if (service != NULL && service->adv_id == adv_id)
+                       break;
+               service = NULL;
+       }
+
+       if (service == NULL) {
+               ASP_LOGD("No matched local service");
+               __ASP_LOG_FUNC_END__;
+               return -1;
+       }
+
+       if (service->auto_accept == FALSE) {
+               ASP_LOGD("Don't accept request automatically");
+               __ASP_LOG_FUNC_END__;
+               return 0;
+
+       }
+
+       ASP_LOGD("Process auto accept service");
+
+       temp = NULL;
+       for (temp = g_list_first(asp_sessions);
+                       temp != NULL; temp = g_list_next(temp)) {
+               session = temp->data;
+               if (session != NULL && session->session_id == session_id &&
+                               memcmp(session->session_mac, session_mac, MACSTR_LEN) == 0)
+                       break;
+               session = NULL;
+       }
+
+       if (session == NULL) {
+               //TODO :asp_get_session
+               //res = asp_get_session(session_mac, session_id, (void **)&session);
+               if (res < 0) {
+                       ASP_LOGE("asp_get_session failed");
+                       __ASP_LOG_FUNC_END__;
+                       return -1;
+               }
+
+               if (session_info)
+                       session->session_information = g_strdup(session_info);
+               asp_sessions = g_list_prepend(asp_sessions, session);
+       }
+
+       //TODO :asp_confirm_session
+       //asp_confirm_session(session, TRUE, NULL);
+       ASP_LOGD("asp_confirm_session");
+       __ASP_LOG_FUNC_END__;
+               return -1;
+}
+
+void asp_process_session_request(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters)
+{
+       __ASP_LOG_FUNC_START__;
+
+       asp_client_info_s *client = &g_client_info;
+
+       GVariantIter *iter = NULL;
+       GVariant *var = NULL;
+       const char *key = NULL;
+       const char *str = NULL;
+       unsigned int adv_id = 0;
+       char *session_mac = NULL;
+       char * device_name = NULL;
+       unsigned int session_id = 0;
+       char *session_info = NULL;
+       gboolean get_network_config_pin = FALSE;
+       char *network_config_pin = NULL;
+       int error_code = ASP_ERROR_NONE;
+
+       if (!client->session_request_cb) {
+               ASP_LOGE("session_request_cb is NULL!!");
+               return;
+       }
+
+       if (!parameters) {
+               ASP_LOGE("parameters is NULL!!");
+               __ASP_LOG_FUNC_END__;
+               return;
+       }
+
+       g_variant_get(parameters, "(a{sv})", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               if (!g_strcmp0(key, "adv_id")) {
+                       g_variant_get(var, "u", &adv_id);
+               } else if (!g_strcmp0(key, "session_id")) {
+                       g_variant_get(var, "u", &session_id);
+               }  else if (!g_strcmp0(key, "session_mac")) {
+                       g_variant_get(var, "&s", &str);
+                       session_mac = g_strndup(str, MACSTR_LEN);
+               } else if (!g_strcmp0(key, "device_name")) {
+                       g_variant_get(var, "&s", &str);
+                       device_name = g_strdup(str);
+               } else if (!g_strcmp0(key, "session_info")) {
+                       g_variant_get(var, "&s", &str);
+                       session_info = g_strdup(str);
+               } else if (!g_strcmp0(key, "get_pin")) {
+                       g_variant_get(var, "b", &get_network_config_pin);
+               } else if (!g_strcmp0(key, "pin")) {
+                       g_variant_get(var, "&s", &str);
+                       network_config_pin = g_strdup(str);
+               }  else {
+                       ;/* Do Nothing */
+               }
+       }
+
+       if (__handle_session_request(adv_id, session_mac,
+                       session_id, session_info) == 0) {
+               //TODO :client->session_request_cb
+       } else {
+               g_free(session_mac);
+               g_free(session_info);
+               g_free(device_name);
+               g_free(network_config_pin);
+       }
+       g_variant_iter_free(iter);
+
+       __ASP_LOG_FUNC_END__;
+       return;
+}
+
+void asp_process_session_config_request(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters)
+{
+       __ASP_LOG_FUNC_START__;
+
+       asp_client_info_s *client = &g_client_info;
+
+       GVariantIter *iter = NULL;
+       GVariant *var = NULL;
+       const char *key = NULL;
+       const char *str = NULL;
+       unsigned int session_id = 0;
+       gboolean get_pin = false;
+       const char *config_pin = NULL;
+       int error_code = ASP_ERROR_NONE;
+
+       if (!client->session_config_request_cb) {
+               ASP_LOGE("session_config_request_cb is NULL!!");
+               return;
+       }
+
+       if (!parameters) {
+               __ASP_LOG_FUNC_END__;
+               return;
+       }
+
+       g_variant_get(parameters, "(a{sv})", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               if (!g_strcmp0(key, "session_id")) {
+                       g_variant_get(var, "u", &session_id);
+               } else if (!g_strcmp0(key, "get_pin")) {
+                       g_variant_get(var, "b", &get_pin);
+               } else if (!g_strcmp0(key, "pin")) {
+                       g_variant_get(var, "&s", &str);
+                       config_pin = g_strdup(str);
+               } else {
+                       ;/* Do Nothing */
+               }
+       }
+
+       //TODO :client->session_config_request_cb
+       g_variant_iter_free(iter);
+
+       __ASP_LOG_FUNC_END__;
+       return;
+}
+
+void asp_process_session_connect_status(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters)
+{
+       __ASP_LOG_FUNC_START__;
+
+       asp_client_info_s *client = &g_client_info;
+
+       GVariantIter *iter = NULL;
+       GVariant *var = NULL;
+       const char *key = NULL;
+       const char *str = NULL;
+       const char *session_mac = NULL;
+       unsigned int session_id = 0;
+       int status = 0;
+       char *deferred_resp = NULL;
+       int error_code = ASP_ERROR_NONE;
+
+       if (!client->session_connect_status_cb) {
+               ASP_LOGE("connect_status_cb is NULL!!");
+               return;
+       }
+
+       if (!parameters) {
+               __ASP_LOG_FUNC_END__;
+               return;
+       }
+
+       g_variant_get(parameters, "(a{sv})", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               if (!g_strcmp0(key, "session_id")) {
+                       g_variant_get(var, "u", &session_id);
+               }  else if (!g_strcmp0(key, "session_mac")) {
+                       g_variant_get(var, "&s", &str);
+                       session_mac = g_strndup(str, MACSTR_LEN);
+               } else if (!g_strcmp0(key, "status")) {
+                       g_variant_get(var, "i", &status);
+               } else if (!g_strcmp0(key, "deferred_resp")) {
+                       g_variant_get(var, "&s", &str);
+                       deferred_resp = g_strdup(str);
+               }  else {
+                       ;/* Do Nothing */
+               }
+       }
+
+       //TODO :client->session_connect_status_cb
+       g_variant_iter_free(iter);
+
+       __ASP_LOG_FUNC_END__;
+       return;
+}
+
+void asp_process_session_status(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters)
+{
+       __ASP_LOG_FUNC_START__;
+
+       asp_client_info_s *client = &g_client_info;
+
+       GVariantIter *iter = NULL;
+       GVariant *var = NULL;
+       const char *key = NULL;
+       const char *str = NULL;
+       const char *session_mac = NULL;
+       unsigned int session_id = 0;
+       int state = 0;
+       int status = 0;
+       char *requested_info = NULL;
+       int error_code = ASP_ERROR_NONE;
+
+       if (!client->session_status_cb) {
+               ASP_LOGE("session_status_cb is NULL!!");
+               return;
+       }
+
+       if (!parameters) {
+               __ASP_LOG_FUNC_END__;
+               return;
+       }
+
+       g_variant_get(parameters, "(a{sv})", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               if (!g_strcmp0(key, "session_id")) {
+                       g_variant_get(var, "u", &session_id);
+               }  else if (!g_strcmp0(key, "session_mac")) {
+                       g_variant_get(var, "&s", &str);
+                       session_mac = g_strndup(str, MACSTR_LEN);
+               } else if (!g_strcmp0(key, "state")) {
+                       g_variant_get(var, "i", &state);
+               } else if (!g_strcmp0(key, "status")) {
+                       g_variant_get(var, "i", &status);
+               }  else if (!g_strcmp0(key, "requested_info")) {
+                       g_variant_get(var, "&s", &str);
+                       requested_info = g_strdup(str);
+               }  else {
+                       ;/* Do Nothing */
+               }
+       }
+
+       //TODO :client->session_status_cb
+
+       __ASP_LOG_FUNC_END__;
+       return;
+}
+
+void asp_process_session_port_status(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters)
+{
+       __ASP_LOG_FUNC_START__;
+
+       asp_client_info_s *client = &g_client_info;
+
+       GVariantIter *iter = NULL;
+       GVariant *var = NULL;
+       const char *key = NULL;
+       const char *str = NULL;
+       const char *session_mac = NULL;
+       const char *ip_address = NULL;
+       unsigned int session_id = 0;
+       int port = 0;
+       int proto = 0;
+       int status = 0;
+       int error_code = ASP_ERROR_NONE;
+
+       if (!client->session_port_status_cb) {
+               ASP_LOGE("port_status_cb is NULL!!");
+               return;
+       }
+
+       if (!parameters) {
+               __ASP_LOG_FUNC_END__;
+               return;
+       }
+
+       g_variant_get(parameters, "(a{sv})", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               if (!g_strcmp0(key, "session_id")) {
+                       g_variant_get(var, "u", &session_id);
+               }  else if (!g_strcmp0(key, "session_mac")) {
+                       g_variant_get(var, "&s", &str);
+                       session_mac = g_strndup(str, MACSTR_LEN);
+               } else if (!g_strcmp0(key, "ip_address")) {
+                       g_variant_get(var, "&s", &ip_address);
+               }  else if (!g_strcmp0(key, "port")) {
+                       g_variant_get(var, "i", &port);
+               } else if (!g_strcmp0(key, "proto")) {
+                       g_variant_get(var, "i", &proto);
+               } else if (!g_strcmp0(key, "status")) {
+                       g_variant_get(var, "i", &status);
+               } else {
+                       ;/* Do Nothing */
+               }
+       }
+
+       //TODO :client->session_port_status_cb
+
+       __ASP_LOG_FUNC_END__;
+       return;
+}
+
+int asp_initialize(void)
+{
+       __ASP_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == TRUE) {
+               ASP_LOGW("Warning!!! Already registered\nUpdate user data and callback!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_ALREADY_INITIALIZED;
+       }
+
+       if (asp_dbus_init() == FALSE) {
+               ASP_LOGW("Failed to initialize dbus");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_OPERATION_FAILED;
+       }
+
+       g_client_info.is_registered = TRUE;
+
+       /* Initialize callbacks */
+       g_client_info.seek_search_result_cb = NULL;
+       g_client_info.advert_status_changed_cb = NULL;
+
+       g_client_info.session_request_cb = NULL;
+       g_client_info.session_config_request_cb = NULL;
+       g_client_info.session_connect_status_cb = NULL;
+       g_client_info.session_status_cb = NULL;
+       g_client_info.session_port_status_cb = NULL;
+
+       g_client_info.user_data_for_cb_seek_search_result = NULL;
+       g_client_info.user_data_for_cb_advert_status_changed = NULL;
+
+       g_client_info.user_data_for_cb_session_request = NULL;
+       g_client_info.user_data_for_cb_session_config_request = NULL;
+       g_client_info.user_data_for_cb_session_connect_status = NULL;
+       g_client_info.user_data_for_cb_session_status = NULL;
+       g_client_info.user_data_for_cb_session_port_status = NULL;
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_deinitialize(void)
+{
+       __ASP_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is already deregistered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       asp_dbus_deinit();
+
+       g_client_info.seek_search_result_cb = NULL;
+       g_client_info.advert_status_changed_cb = NULL;
+
+       g_client_info.session_request_cb = NULL;
+       g_client_info.session_config_request_cb = NULL;
+       g_client_info.session_connect_status_cb = NULL;
+       g_client_info.session_status_cb = NULL;
+       g_client_info.session_port_status_cb = NULL;
+
+       g_client_info.user_data_for_cb_seek_search_result = NULL;
+       g_client_info.user_data_for_cb_advert_status_changed = NULL;
+
+       g_client_info.user_data_for_cb_session_request = NULL;
+       g_client_info.user_data_for_cb_session_config_request = NULL;
+       g_client_info.user_data_for_cb_session_connect_status = NULL;
+       g_client_info.user_data_for_cb_session_status = NULL;
+       g_client_info.user_data_for_cb_session_port_status = NULL;
+
+       g_client_info.is_registered = FALSE;
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+int asp_seek_set_search_result_cb(asp_seek_search_result_cb cb, void *user_data)
+{
+       __ASP_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (!cb) {
+               ASP_LOGE("Invalid parameter");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is not initialized.");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       g_client_info.seek_search_result_cb = cb;
+       g_client_info.user_data_for_cb_seek_search_result = user_data;
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_seek_unset_search_result_cb(void)
+{
+       __ASP_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is not initialized.\n");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       g_client_info.seek_search_result_cb = NULL;
+       g_client_info.user_data_for_cb_seek_search_result = NULL;
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_advert_set_status_changed_cb(asp_advert_status_changed_cb cb, void *user_data)
+{
+       __ASP_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (!cb) {
+               ASP_LOGE("Invalid parameter");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is not initialized.");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       g_client_info.advert_status_changed_cb = cb;
+       g_client_info.user_data_for_cb_advert_status_changed = user_data;
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_advert_unset_status_changed_cb(void)
+{
+       __ASP_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is not initialized.\n");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       g_client_info.advert_status_changed_cb = NULL;
+       g_client_info.user_data_for_cb_advert_status_changed = NULL;
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_session_set_request_cb(asp_session_request_cb cb, void *user_data)
+{
+       __ASP_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (!cb) {
+               ASP_LOGE("Invalid parameter");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is not initialized.");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       g_client_info.session_request_cb = cb;
+       g_client_info.user_data_for_cb_session_request = user_data;
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_session_unset_request_cb(void)
+{
+       __ASP_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is not initialized.\n");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       g_client_info.session_request_cb = NULL;
+       g_client_info.user_data_for_cb_session_request = NULL;
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_session_set_config_request_cb(asp_session_config_request_cb cb, void *user_data)
+{
+       __ASP_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (!cb) {
+               ASP_LOGE("Invalid parameter");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is not initialized.");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       g_client_info.session_config_request_cb = cb;
+       g_client_info.user_data_for_cb_session_config_request = user_data;
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_session_unset_config_request_cb(void)
+{
+       __ASP_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is not initialized.\n");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       g_client_info.session_config_request_cb = NULL;
+       g_client_info.user_data_for_cb_session_config_request = NULL;
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_session_set_connect_status_cb(asp_session_connect_status_cb cb, void *user_data)
+{
+       __ASP_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (!cb) {
+               ASP_LOGE("Invalid parameter");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is not initialized.");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       g_client_info.session_connect_status_cb = cb;
+       g_client_info.user_data_for_cb_session_connect_status = user_data;
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+
+int asp_session_unset_connect_status_cb(void)
+{
+       __ASP_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is not initialized.\n");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       g_client_info.session_connect_status_cb = NULL;
+       g_client_info.user_data_for_cb_session_connect_status = NULL;
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_session_set_status_cb(asp_session_status_cb cb, void *user_data)
+{
+       __ASP_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (!cb) {
+               ASP_LOGE("Invalid parameter");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is not initialized.");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       g_client_info.session_status_cb = cb;
+       g_client_info.user_data_for_cb_session_status = user_data;
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+
+int asp_session_unset_status_cb(void)
+{
+       __ASP_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is not initialized.\n");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       g_client_info.session_status_cb = NULL;
+       g_client_info.user_data_for_cb_session_status = NULL;
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_session_set_port_status_cb(asp_session_port_status_cb cb, void *user_data)
+{
+       __ASP_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (!cb) {
+               ASP_LOGE("Invalid parameter");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is not initialized.");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       g_client_info.session_port_status_cb = cb;
+       g_client_info.user_data_for_cb_session_port_status = user_data;
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_session_unset_port_status_cb(void)
+{
+       __ASP_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is not initialized.\n");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       g_client_info.session_port_status_cb = NULL;
+       g_client_info.user_data_for_cb_session_port_status = NULL;
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+typedef void (*free_func)(void *);
+
+static void __free_advert(void *advert)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+
+       service = (asp_client_advert_s *)advert;
+       if (service == NULL) {
+               ASP_LOGE("invalid parameter");
+               __ASP_LOG_FUNC_END__;
+               return;
+       }
+
+       g_free(service->instance_name);
+       g_free(service->serivce_name);
+       g_free(service->service_type);
+       g_free(service->rsp_info);
+       g_hash_table_destroy(service->service_info_map);
+       g_free(service);
+       service = NULL;
+       __ASP_LOG_FUNC_END__;
+       return;
+}
+
+static void __free_seek(void *seek)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_seek_s *service = NULL;
+
+       service = (asp_client_seek_s *)seek;
+       if (service == NULL) {
+               ASP_LOGE("invalid parameter");
+               __ASP_LOG_FUNC_END__;
+               return;
+       }
+
+       g_free(service->serivce_name);
+       g_free(service->service_type);
+       g_free(service->rsp_info);
+       g_hash_table_destroy(service->service_info_map);
+       g_free(service);
+       service = NULL;
+       __ASP_LOG_FUNC_END__;
+       return;
+}
+
+static void __free_session(void *session)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_session_s *service = NULL;
+
+       service = (asp_client_session_s *)session;
+       if (service == NULL) {
+               ASP_LOGE("invalid parameter");
+               __ASP_LOG_FUNC_END__;
+               return;
+       }
+
+       g_free(service->session_information);
+       g_free(service->deferred_session_response);
+       g_free(service);
+       service = NULL;
+       __ASP_LOG_FUNC_END__;
+       return;
+}
+
+static asp_client_advert_s *__get_advert(void *handle)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+       GList *temp = NULL;
+
+       if (asp_adverts == NULL) {
+               __ASP_LOG_FUNC_END__;
+               return NULL;
+       }
+
+       ASP_LOGD("service [%p]", handle);
+
+       temp = g_list_first(asp_adverts);
+       for (temp = g_list_first(asp_adverts); temp != NULL; temp = g_list_next(temp)) {
+               service = temp->data;
+
+               ASP_LOGD("temp [%p]", service);
+               if (service != NULL && service == handle)
+                       break;
+               service = NULL;
+       }
+       __ASP_LOG_FUNC_END__;
+       return service;
+}
+
+static asp_client_seek_s *__get_seek(void *handle)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_seek_s *service = NULL;
+       GList *temp = NULL;
+
+       if (asp_seeks == NULL) {
+               __ASP_LOG_FUNC_END__;
+               return NULL;
+       }
+
+       ASP_LOGD("service [%p]", handle);
+
+       temp = g_list_first(asp_seeks);
+       for (temp = g_list_first(asp_seeks); temp != NULL; temp = g_list_next(temp)) {
+               service = temp->data;
+
+               ASP_LOGD("temp [%p]", service);
+               if (service != NULL && service == handle)
+                       break;
+               service = NULL;
+       }
+       __ASP_LOG_FUNC_END__;
+       return service;
+}
+
+static asp_client_session_s *__get_session(void *handle)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_session_s *service = NULL;
+       GList *temp = NULL;
+
+       if (asp_sessions == NULL) {
+
+               __ASP_LOG_FUNC_END__;
+               return NULL;
+       }
+
+       ASP_LOGD("service [%p]", handle);
+
+       temp = g_list_first(asp_sessions);
+       for (temp = g_list_first(asp_sessions); temp != NULL; temp = g_list_next(temp)) {
+               service = temp->data;
+
+               ASP_LOGD("temp [%p]", service);
+               if (service != NULL && service == handle)
+                       break;
+               service = NULL;
+       }
+       __ASP_LOG_FUNC_END__;
+       return service;
+}
+
+static int __remove_advert(void *handle)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+       service = __get_advert(handle);
+
+       if (service == NULL) {
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_OPERATION_FAILED;
+       } else {
+               asp_adverts = g_list_remove(asp_adverts, handle);
+               __free_advert(service);
+       }
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+static int __remove_seek(void *handle)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_seek_s *service = NULL;
+       service = __get_seek(handle);
+
+       if (service == NULL) {
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_OPERATION_FAILED;
+       } else {
+               asp_seeks = g_list_remove(asp_seeks, handle);
+               __free_seek(service);
+       }
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+static int __remove_session(void *handle)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_session_s *service = NULL;
+       service = __get_session(handle);
+
+       if (service == NULL) {
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_OPERATION_FAILED;
+       } else {
+               asp_sessions = g_list_remove(asp_sessions, handle);
+               __free_session(service);
+       }
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+
+int asp_advert_create(char *instance_name, asp_advert_service_h *adv_service)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+       int res = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!adv_service) {
+               ASP_LOGE("NULL Param [handle]!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service = (asp_client_advert_s *)g_try_malloc0(sizeof(asp_client_advert_s));
+       if (!service) {
+               ASP_LOGE("malloc() failed!!!.");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_OUT_OF_MEMORY;
+       }
+       ASP_LOGD("service [%p]", service);
+
+       if (instance_name) {
+               ASP_LOGD("instance_name = [%s]", instance_name);
+               service->instance_name = g_strdup(instance_name);
+               if (!service->instance_name) {
+                       ASP_LOGE("malloc() failed!!!.");
+                       __ASP_LOG_FUNC_END__;
+                       g_free(service);
+                       return ASP_ERROR_OUT_OF_MEMORY;
+               }
+       }
+       asp_adverts = g_list_prepend(asp_adverts, service);
+
+       /* TODO : consider the case if target arch is 64bit. */
+       /* TODO : Make asp enable support for other methods. */
+       /* Default : ASP */
+       service->auto_accept = 0;
+       service->config_method = 1;
+       service->status = 0;
+       service->role = 1;
+       service->service_info_map = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+       service->adv_id = (unsigned int)service & 0xffffffff;
+       *adv_service = (asp_advert_service_h)service;
+       ASP_LOGD("asp_advert_create() SUCCESS");
+
+       ASP_LOGD("advert handler [%p]", *adv_service);
+       __ASP_LOG_FUNC_END__;
+       return res;
+}
+
+int asp_advert_destroy(asp_advert_service_h adv_service)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+       int res = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!adv_service) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", adv_service);
+
+       service = __get_advert((void *)adv_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+
+       g_hash_table_remove_all(service->service_info_map);
+       res = __remove_advert((void *)service);
+       if (res != ASP_ERROR_NONE) {
+               __ASP_LOG_FUNC_END__;
+               return res;
+       }
+
+       ASP_LOGD("asp_destory_advertise_handle() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+
+int asp_advert_set_service_type(asp_advert_service_h adv_service,
+        char *service_type)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+       char *type = NULL;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!adv_service || !service_type) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", adv_service);
+
+       service = __get_advert((void *)adv_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+       type = g_strdup(service_type);
+       if (!type) {
+               ASP_LOGE("malloc() failed!!!.");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_OPERATION_FAILED;
+       }
+       g_free(service->service_type);
+       service->service_type = type;
+
+       ASP_LOGD("asp_advert_set_service_type() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_advert_set_auto_accept(asp_advert_service_h adv_service,
+                               bool auto_accept)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!adv_service) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", adv_service);
+
+       service = __get_advert((void *)adv_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+       service->auto_accept = auto_accept;
+
+       ASP_LOGD("asp_advert_set_auto_accept() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_advert_add_info(asp_advert_service_h adv_service,
+                            const char *key, const char *value)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!adv_service || !key) {
+               ASP_LOGE("NULL value!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", adv_service);
+
+       service = __get_advert((void *)adv_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+       /* TODO: add advertised info */
+       g_hash_table_replace(service->service_info_map, g_strdup(key), g_strdup(value));
+
+       ASP_LOGD("asp_advert_add_info() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_advert_get_info(asp_advert_service_h adv_service, const char *key,
+                        int *length, char **value)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+       char *ret_val = NULL;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!adv_service || !key) {
+               ASP_LOGE("NULL value!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", adv_service);
+
+       service = __get_advert((void *)adv_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+       /* TODO: get advertised info */
+       ret_val = g_hash_table_lookup(service->service_info_map, key);
+       if (ret_val == NULL) {
+               ASP_LOGD("value is NULL");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NONE;
+       }
+
+       *value = g_strdup(ret_val);
+       *length = strlen(ret_val);
+
+       ASP_LOGD("asp_advert_get_info() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_advert_remove_info(asp_advert_service_h adv_service, const char *key)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!adv_service || !key) {
+               ASP_LOGE("NULL value!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", adv_service);
+
+       service = __get_advert((void *)adv_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+       /* TODO: remove advertised info */
+       g_hash_table_remove(service->service_info_map, key);
+
+       ASP_LOGD("asp_advert_remove_info() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_advert_set_status(asp_advert_service_h adv_service,
+                          unsigned char status)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!adv_service) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", adv_service);
+
+       service = __get_advert((void *)adv_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+       service->status = status;
+
+       ASP_LOGD("asp_advert_set_status() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_advert_set_discovery_tech(asp_advert_service_h adv_service, int discovery_tech)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+       if (!((discovery_tech & ASP_DISCOVERY_TECH_P2P) |
+                       (discovery_tech & ASP_DISCOVERY_TECH_NFC) |
+                       (discovery_tech & ASP_DISCOVERY_TECH_BLE) |
+                       (discovery_tech & ASP_DISCOVERY_TECH_INFRA) |
+                       (discovery_tech & ASP_DISCOVERY_TECH_NAN))) {
+               ASP_LOGE("invalid parameter!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!adv_service) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", adv_service);
+
+       service = __get_advert((void *)adv_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+       service->discovery_tech = discovery_tech;
+
+       ASP_LOGD("asp_advert_set_discovery_tech() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_advert_set_preferred_connection(asp_advert_service_h adv_service,
+                                        unsigned char preferred_connection)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!adv_service) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", adv_service);
+
+       service = __get_advert((void *)adv_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+       service->preferred_connection = preferred_connection;
+
+       ASP_LOGD("asp_advert_set_preferred_connection() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_advert_set_p2p_role_scheme(asp_advert_service_h adv_service,
+                                   asp_advert_p2p_role_scheme_e role)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!adv_service) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", adv_service);
+
+       service = __get_advert((void *)adv_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+       service->role = role;
+
+       ASP_LOGD("asp_advert_set_p2p_role_scheme() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_advert_get_p2p_role_scheme(asp_advert_service_h adv_service,
+                                   asp_advert_p2p_role_scheme_e *role)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!adv_service || !role) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", adv_service);
+
+       service = __get_advert((void *)adv_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+       *role = service->role;
+
+       ASP_LOGD("asp_advert_get_p2p_role_scheme() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+
+int asp_advert_set_p2p_config_method(asp_advert_service_h adv_service,
+                                     asp_wps_type_e config_method)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!adv_service) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       if (config_method > ASP_WPS_TYPE_PIN_KEYPAD) {
+               ASP_LOGE("config_method is larger than expected");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", adv_service);
+
+       service = __get_advert((void *)adv_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+       service->config_method = config_method;
+
+       ASP_LOGD("asp_advert_set_p2p_config_method() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_advert_get_p2p_config_method(asp_advert_service_h adv_service,
+                                     asp_wps_type_e *config_method)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!adv_service || !config_method) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       ASP_LOGD("service [%p]", adv_service);
+
+       service = __get_advert((void *)adv_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+
+       *config_method = service->config_method;
+
+       ASP_LOGD("asp_advert_get_p2p_config_method() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_advert_set_p2p_response(asp_advert_service_h adv_service,
+                                char *rsp_info, int length)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+       char *info = NULL;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+       /* TODO fit the rsp info for length */
+       if (length <= 0 || length > 144) {
+               ASP_LOGE("invalid length!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!adv_service || !rsp_info) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", adv_service);
+
+       service = __get_advert((void *)adv_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+
+       info = g_strdup(rsp_info);
+       if (!info) {
+               ASP_LOGE("malloc() failed!!!.");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_OPERATION_FAILED;
+       }
+       g_free(service->rsp_info);
+       service->rsp_info = info;
+
+       ASP_LOGD("asp_advert_set_p2p_response() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+
+static GVariant* __g_hash_keys_to_g_variant(GHashTable *hash)
+{
+       GVariantBuilder builder;
+
+       __ASP_LOG_FUNC_START__;
+       g_variant_builder_init(&builder, G_VARIANT_TYPE("as"));
+/*     g_variant_builder_open(&builder, G_VARIANT_TYPE("a{sv}")); */
+
+       GHashTableIter iter;
+       gpointer key, value;
+
+       g_hash_table_iter_init(&iter, hash);
+       while (g_hash_table_iter_next(&iter, &key, &value)) {
+
+               ASP_LOGE("key [%s]", key);
+               g_variant_builder_add(&builder, "s", key);
+       }
+
+/*     g_variant_builder_close(&builder); */
+       __ASP_LOG_FUNC_END__;
+       return g_variant_builder_end(&builder);
+}
+
+static GVariant* __g_hash_table_to_g_variant(GHashTable *hash)
+{
+       GVariantBuilder builder;
+
+       __ASP_LOG_FUNC_START__;
+       g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
+
+       GHashTableIter iter;
+       gpointer key, value;
+
+       g_hash_table_iter_init(&iter, hash);
+       while (g_hash_table_iter_next(&iter, &key, &value))
+               g_variant_builder_add(&builder, "{sv}", key, g_variant_new_string(value));
+
+       __ASP_LOG_FUNC_END__;
+       return g_variant_builder_end(&builder);
+}
+
+int asp_advert_start_advertising(asp_advert_service_h adv_service)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+       GVariantBuilder *builder = NULL;
+       GVariant *params = NULL;
+       GError *error = NULL;
+       GVariant *reply = NULL;
+       int ret = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!adv_service) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", adv_service);
+
+       service = __get_advert((void *)adv_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "adv_id", g_variant_new("u", service->adv_id));
+       g_variant_builder_add(builder, "{sv}", "discovery_tech", g_variant_new("i", service->discovery_tech));
+       g_variant_builder_add(builder, "{sv}", "preferred_connection", g_variant_new("y", service->preferred_connection));
+       g_variant_builder_add(builder, "{sv}", "auto_accept", g_variant_new("i", service->auto_accept));
+       g_variant_builder_add(builder, "{sv}", "status", g_variant_new("y", service->status));
+       g_variant_builder_add(builder, "{sv}", "role", g_variant_new("y", service->role));
+       g_variant_builder_add(builder, "{sv}", "config_method", g_variant_new("u", service->config_method));
+
+       if (service->instance_name)     /* This can be NULL if this is ASP 1.0 service */
+               g_variant_builder_add(builder, "{sv}", "instance_name", g_variant_new("s", service->instance_name));
+       if (service->service_type)      /* This can be NULL if Instance name is UUID */
+               g_variant_builder_add(builder, "{sv}", "service_type", g_variant_new("s", service->service_type));
+       if (g_hash_table_size(service->service_info_map) > 0)
+               g_variant_builder_add(builder, "{sv}", "service_info", __g_hash_table_to_g_variant(service->service_info_map));
+       if (service->rsp_info)
+               g_variant_builder_add(builder, "{sv}", "rsp_info", g_variant_new("s", service->rsp_info));
+       params = g_variant_new("(a{sv})", builder);
+       g_variant_builder_unref(builder);
+       ASP_LOGI("service type (%s) adv ID (%u)", service->service_type, service->adv_id);
+
+       reply = asp_dbus_method_call_sync(ASP_DAEMON_SERVICE_INTERFACE,
+                                                 "AdvertiseService", params, &error);
+       if (error != NULL) {
+               ASP_LOGE("asp_dbus_method_call_sync() failed."
+                               "error [%d: %s]", error->code, error->message);
+               ret = __asp_err_string_to_enum(error->message);
+               g_error_free(error);
+               __ASP_LOG_FUNC_END__;
+               return ret;
+       }
+
+       g_variant_get(reply, "(i)", &ret);
+       g_variant_unref(reply);
+
+       ASP_LOGD("%s() return : [%d]", __func__, ret);
+
+       __ASP_LOG_FUNC_END__;
+       return ret;
+}
+
+int asp_advert_stop_advertising(asp_advert_service_h adv_service)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+       GVariant *params = NULL;
+       GError *error = NULL;
+       GVariant *reply = NULL;
+       int ret = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!adv_service) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", adv_service);
+
+       service = __get_advert((void *)adv_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+
+       params = g_variant_new("(ui)", service->adv_id, service->discovery_tech);
+       reply = asp_dbus_method_call_sync(ASP_DAEMON_SERVICE_INTERFACE,
+                                                 "CancelAdvertiseService", params, &error);
+       if (error != NULL) {
+               ASP_LOGE("asp_dbus_method_call_sync() failed."
+                               "error [%d: %s]", error->code, error->message);
+               ret = __asp_err_string_to_enum(error->message);
+               g_error_free(error);
+               __ASP_LOG_FUNC_END__;
+               return ret;
+       }
+
+       g_variant_get(reply, "(i)", &ret);
+       g_variant_unref(reply);
+
+       ASP_LOGD("%s() return : [%d]", __func__, ret);
+
+       __ASP_LOG_FUNC_END__;
+       return ret;
+}
+
+int asp_advert_change_service_status(asp_advert_service_h adv_service,
+                                     unsigned char status)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_advert_s *service = NULL;
+       GVariantBuilder *builder = NULL;
+       GVariant *params = NULL;
+       GError *error = NULL;
+       GVariant *reply = NULL;
+       int ret = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!adv_service) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", adv_service);
+
+       service = __get_advert((void *)adv_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "adv_id", g_variant_new("u", service->adv_id));
+       g_variant_builder_add(builder, "{sv}", "auto_accept", g_variant_new("i", service->auto_accept));
+       service->status = status;
+       g_variant_builder_add(builder, "{sv}", "status", g_variant_new("y", service->status));
+       g_variant_builder_add(builder, "{sv}", "role", g_variant_new("y", service->role));
+       g_variant_builder_add(builder, "{sv}", "config_method", g_variant_new("u", service->config_method));
+
+       if (service->instance_name)     /* This can be NULL if this is ASP 1.0 service */
+               g_variant_builder_add(builder, "{sv}", "instance_name", g_variant_new("s", service->instance_name));
+       if (service->service_type)      /* This can be NULL if Instance name is UUID */
+               g_variant_builder_add(builder, "{sv}", "service_type", g_variant_new("s", service->service_type));
+       if (g_hash_table_size(service->service_info_map) > 0)
+               g_variant_builder_add(builder, "{sv}", "service_info", __g_hash_keys_to_g_variant(service->service_info_map));
+       if (service->rsp_info)
+               g_variant_builder_add(builder, "{sv}", "rsp_info", g_variant_new("s", service->rsp_info));
+
+       params = g_variant_new("(a{sv})", builder);
+       g_variant_builder_unref(builder);
+       ASP_LOGI("service type (%s) adv ID (%u)", service->service_type, service->adv_id);
+
+       reply = asp_dbus_method_call_sync(ASP_DAEMON_SERVICE_INTERFACE,
+                                                 "ServiceChangeStatus", params, &error);
+       if (error != NULL) {
+               ASP_LOGE("asp_dbus_method_call_sync() failed."
+                               "error [%d: %s]", error->code, error->message);
+               ret = __asp_err_string_to_enum(error->message);
+               g_error_free(error);
+               __ASP_LOG_FUNC_END__;
+               return ret;
+       }
+
+       g_variant_get(reply, "(i)", &ret);
+       g_variant_unref(reply);
+
+       ASP_LOGD("%s() return : [%d]", __func__, ret);
+
+       __ASP_LOG_FUNC_END__;
+       return ret;
+}
+
+int asp_seek_create(char *service_type, asp_seek_service_h *seek_service)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_seek_s *service = NULL;
+       int res = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!service_type || strlen(service_type) == 0) {
+               ASP_LOGE("NULL Param [service_type]!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service_type = [%s]", service_type);
+
+       if (!seek_service) {
+               ASP_LOGE("NULL Param [handle]!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service = (asp_client_seek_s *)g_try_malloc0(sizeof(asp_client_seek_s));
+       if (!service) {
+               ASP_LOGE("malloc() failed!!!.");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_OUT_OF_MEMORY;
+       }
+       ASP_LOGD("service [%p]", service);
+
+       service->service_type = g_strdup(service_type);
+       if (!service->service_type) {
+               ASP_LOGE("malloc() failed!!!.");
+               g_free(service);
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_OUT_OF_MEMORY;
+       }
+
+       service->service_info_map = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+       asp_seeks = g_list_prepend(asp_seeks, service);
+
+       *seek_service = (asp_seek_service_h)service;
+       ASP_LOGD("asp_create_seek_handle() SUCCESS");
+
+       ASP_LOGD("seek handler [%p]", *seek_service);
+       __ASP_LOG_FUNC_END__;
+       return res;
+}
+
+int asp_seek_destroy(asp_seek_service_h seek_service)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_seek_s *service = NULL;
+       int res = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!seek_service) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", seek_service);
+
+       service = __get_seek((void *)seek_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+
+       g_hash_table_remove_all(service->service_info_map);
+       res = __remove_seek((void *)service);
+       if (res != ASP_ERROR_NONE) {
+               __ASP_LOG_FUNC_END__;
+               return res;
+       }
+
+       ASP_LOGD("asp_seek_destroy() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_seek_add_info(asp_seek_service_h seek_service, const char *key)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_seek_s *service = NULL;
+       int res = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!seek_service) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", seek_service);
+
+       service = __get_seek((void *)seek_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+
+       g_hash_table_replace(service->service_info_map, g_strdup(key), NULL);
+
+       ASP_LOGD("service info [%d]", g_hash_table_size(service->service_info_map));
+       ASP_LOGD("asp_add_seek_info() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return res;
+
+}
+
+int asp_seek_remove_info(asp_seek_service_h seek_service, const char *key)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_seek_s *service = NULL;
+       int res = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!seek_service) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", seek_service);
+
+       service = __get_seek((void *)seek_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+
+       /* TODO: remove seek info */
+       g_hash_table_remove(service->service_info_map, key);
+
+       ASP_LOGD("asp_remove_seek_info() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return res;
+
+}
+
+int asp_seek_set_discovery_tech(asp_seek_service_h seek_service, int discovery_tech)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_seek_s *service = NULL;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+       if (!((discovery_tech & ASP_DISCOVERY_TECH_P2P) |
+                       (discovery_tech & ASP_DISCOVERY_TECH_NFC) |
+                       (discovery_tech & ASP_DISCOVERY_TECH_BLE) |
+                       (discovery_tech & ASP_DISCOVERY_TECH_INFRA) |
+                       (discovery_tech & ASP_DISCOVERY_TECH_NAN))) {
+               ASP_LOGE("invalid parameter!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!seek_service) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", seek_service);
+
+       service = __get_seek((void *)seek_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+       service->discovery_tech = discovery_tech;
+
+       ASP_LOGD("asp_set_seeking_tech() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+int asp_seek_set_preferred_connection(asp_seek_service_h seek_service,
+                                      unsigned char preferred_connection)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_seek_s *service = NULL;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!seek_service) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", seek_service);
+
+       service = __get_seek((void *)seek_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+       service->preferred_connection = preferred_connection;
+
+       ASP_LOGD("asp_set_seeking_preferred_connection() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+
+int asp_seek_start(asp_seek_service_h seek_service)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_seek_s *service = NULL;
+       GVariantBuilder *builder = NULL;
+       GVariant *params = NULL;
+       GError *error = NULL;
+       GVariant *reply = NULL;
+       int ret = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!seek_service) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", seek_service);
+
+       service = __get_seek((void *)seek_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SERVICE_NOT_FOUND;
+       }
+
+       ASP_LOGD("service info [%d]", g_hash_table_size(service->service_info_map));
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "discovery_tech", g_variant_new("i", service->discovery_tech));
+       g_variant_builder_add(builder, "{sv}", "preferred_connection", g_variant_new("y", service->preferred_connection));
+       g_variant_builder_add(builder, "{sv}", "service_type", g_variant_new("s", service->service_type));
+       if (g_hash_table_size(service->service_info_map) > 0) {
+               ASP_LOGE("Service info");
+               g_variant_builder_add(builder, "{sv}", "service_info", __g_hash_keys_to_g_variant(service->service_info_map));
+       }
+
+       params = g_variant_new("(a{sv})", builder);
+       g_variant_builder_unref(builder);
+       ASP_LOGI("service name (%s)", service->serivce_name);
+
+       reply = asp_dbus_method_call_sync(ASP_DAEMON_SERVICE_INTERFACE,
+                                                 "SeekService", params, &error);
+       if (error != NULL) {
+               ASP_LOGE("asp_dbus_method_call_sync() failed."
+                               "error [%d: %s]", error->code, error->message);
+               ret = __asp_err_string_to_enum(error->message);
+               g_error_free(error);
+               __ASP_LOG_FUNC_END__;
+               return ret;
+       }
+
+       g_variant_get(reply, "(it)", &ret, &(service->search_id));
+       g_variant_unref(reply);
+
+       ASP_LOGD("%s() return : [%d]", __func__, ret);
+
+       __ASP_LOG_FUNC_END__;
+       return ret;
+}
+
+int asp_seek_stop(asp_seek_service_h seek_service)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_seek_s *service = NULL;
+       GVariant *params = NULL;
+       GError *error = NULL;
+       GVariant *reply = NULL;
+       int ret = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!seek_service) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service = __get_seek((void *)seek_service);
+       if (service == NULL) {
+               ASP_LOGE("Service NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_OPERATION_FAILED;
+       }
+       ASP_LOGD("service_type = [%s]", service->service_type);
+
+       params = g_variant_new("(ti)", service->search_id, service->discovery_tech);
+       reply = asp_dbus_method_call_sync(ASP_DAEMON_SERVICE_INTERFACE,
+                                                 "CancelSeekService", params, &error);
+       if (error != NULL) {
+               ASP_LOGE("asp_dbus_method_call_sync() failed."
+                               "error [%d: %s]", error->code, error->message);
+               ret = __asp_err_string_to_enum(error->message);
+               g_error_free(error);
+               __ASP_LOG_FUNC_END__;
+               return ret;
+       }
+
+       g_variant_get(reply, "(i)", &ret);
+       g_variant_unref(reply);
+
+       ASP_LOGD("%s() return : [%d]", __func__, ret);
+
+       __ASP_LOG_FUNC_END__;
+       return ret;
+}
+
+int asp_session_create(char *service_mac, unsigned int adv_id, asp_session_h* session)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_session_s *service = NULL;
+       int res = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!service_mac || strlen(service_mac) != (MACSTR_LEN -1)) {
+               ASP_LOGE("Invalid Param [service_mac]!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       if (adv_id == 0 || !session) {
+               ASP_LOGE("NULL Param [session]!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service = (asp_client_session_s *)g_try_malloc0(sizeof(asp_client_session_s));
+       if (!service) {
+               ASP_LOGE("malloc() failed!!!.");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_OUT_OF_MEMORY;
+       }
+       ASP_LOGD("service [%p]", service);
+
+       service->advertisement_id = adv_id;
+       g_strlcpy(service->service_mac, service_mac, MACSTR_LEN);
+
+       asp_sessions = g_list_prepend(asp_sessions, service);
+
+       /* Session ID will be generated by asp-manager */
+       *session = (asp_session_h)service;
+       ASP_LOGD("asp_session_create() SUCCESS");
+
+       ASP_LOGD("service [%p]", *session);
+       __ASP_LOG_FUNC_END__;
+       return res;
+}
+
+int asp_session_destroy(asp_session_h session)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_session_s *service = NULL;
+       int res = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!session) {
+               ASP_LOGE("NULL handler!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", session);
+
+       service = __get_session((void *)session);
+       if (service == NULL) {
+               ASP_LOGE("Session NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SESSION_NOT_FOUND;
+       }
+
+       res = __remove_session((void *)service);
+       if (res != ASP_ERROR_NONE) {
+               __ASP_LOG_FUNC_END__;
+               return res;
+       }
+
+       ASP_LOGD("asp_session_destroy() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return ASP_ERROR_NONE;
+}
+
+
+int asp_session_get_mac(asp_session_h session, char **session_mac)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_session_s *service = NULL;
+       int res = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!session || !session_mac) {
+               ASP_LOGE("Invalid parameter!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", session);
+
+       service = __get_session((void *)session);
+       if (service == NULL) {
+               ASP_LOGE("Session NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SESSION_NOT_FOUND;
+       }
+
+       *session_mac = g_strndup(service->session_mac, MACSTR_LEN - 1);
+       if (*session_mac == NULL) {
+               ASP_LOGE("g_strndup failed");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_OPERATION_FAILED;
+       }
+
+       ASP_LOGD("asp_session_get_mac() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return res;
+}
+
+
+int asp_session_get_id(asp_session_h session, unsigned int *session_id)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_session_s *service = NULL;
+       int res = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!session || !session_id) {
+               ASP_LOGE("Invalid parameter!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+       ASP_LOGD("service [%p]", session);
+
+       service = __get_session((void *)session);
+       if (service == NULL) {
+               ASP_LOGE("Session NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SESSION_NOT_FOUND;
+       }
+
+       *session_id = service->session_id;
+
+       ASP_LOGD("asp_session_get_id() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return res;
+}
+
+int asp_session_set_info(asp_session_h session, char *service_info)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_session_s *service = NULL;
+       int res = ASP_ERROR_NONE;
+       char *info = NULL;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!service_info || !session) {
+               ASP_LOGE("NULL Param!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service = __get_session((void *)session);
+       if (service == NULL) {
+               ASP_LOGE("Session NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SESSION_NOT_FOUND;
+       }
+
+       info = g_strdup(service_info);
+       if (!info) {
+               ASP_LOGE("malloc() failed!!!.");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_OPERATION_FAILED;
+       }
+       g_free(service->session_information);
+       service->session_information = info;
+
+       ASP_LOGD("asp_session_set_info() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return res;
+}
+
+int asp_session_get_info(asp_session_h session, char **service_info)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_session_s *service = NULL;
+       int res = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!session || !service_info) {
+               ASP_LOGE("NULL Param!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service = __get_session((void *)session);
+       if (service == NULL) {
+               ASP_LOGE("Session NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SESSION_NOT_FOUND;
+       }
+
+       if (service->session_information)
+               *service_info = g_strdup(service->session_information);
+
+       ASP_LOGD("asp_session_get_info() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return res;
+}
+
+int asp_session_set_p2p_role_scheme(asp_session_h session,
+                                    asp_advert_p2p_role_scheme_e role)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_session_s *service = NULL;
+       int res = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!role || !session) {
+               ASP_LOGE("Invalid parameters");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service = __get_session((void *)session);
+       if (service == NULL) {
+               ASP_LOGE("Session NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SESSION_NOT_FOUND;
+       }
+
+       service->network_role = role;
+
+       ASP_LOGD("asp_session_set_p2p_role_scheme() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return res;
+}
+
+int asp_session_get_p2p_role_scheme(asp_session_h session,
+                                    asp_advert_p2p_role_scheme_e *role)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_session_s *service = NULL;
+       int res = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!role || !session) {
+               ASP_LOGE("Invalid parameters");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service = __get_session((void *)session);
+       if (service == NULL) {
+               ASP_LOGE("Session NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SESSION_NOT_FOUND;
+       }
+
+       *role = service->network_role;
+
+       ASP_LOGD("asp_session_get_p2p_role_scheme() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return res;
+}
+
+int asp_session_set_p2p_config_method(asp_session_h session,
+                                      asp_wps_type_e config_method)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_session_s *service = NULL;
+       int res = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!session) {
+               ASP_LOGE("Invalid parameter");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service = __get_session((void *)session);
+       if (service == NULL) {
+               ASP_LOGE("Session NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SESSION_NOT_FOUND;
+       }
+
+       if (config_method < ASP_WPS_TYPE_DEFAULT ||
+                       config_method > ASP_WPS_TYPE_PIN_KEYPAD) {
+               ASP_LOGE("network_config is invalid");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service->network_config = config_method;
+
+       ASP_LOGD("asp_session_set_p2p_config_method() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return res;
+}
+
+int asp_session_get_p2p_config_method(asp_session_h session,
+                                      asp_wps_type_e *config_method)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_session_s *service = NULL;
+       int res = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!config_method || !session) {
+               ASP_LOGE("Invalid parameters");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service = __get_session((void *)session);
+       if (service == NULL) {
+               ASP_LOGE("Session NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SESSION_NOT_FOUND;
+       }
+
+       *config_method = service->network_config;
+
+       ASP_LOGD("asp_session_get_p2p_config_method() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return res;
+}
+
+int asp_session_get_close_status(asp_session_h session, int *status)
+{
+       __ASP_LOG_FUNC_START__;
+       asp_client_session_s *service = NULL;
+       int res = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!status || !session) {
+               ASP_LOGE("Invalid parameters");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service = __get_session((void *)session);
+       if (service == NULL) {
+               ASP_LOGE("Session NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SESSION_NOT_FOUND;
+       }
+
+       *status = service->state;
+
+       ASP_LOGD("asp_session_get_close_status() SUCCESS");
+
+       __ASP_LOG_FUNC_END__;
+       return res;
+}
+int asp_session_connect(asp_session_h session)
+{
+       __ASP_LOG_FUNC_START__;
+       GVariantBuilder *builder = NULL;
+       GVariant *params = NULL;
+       GError *error = NULL;
+       GVariant *reply = NULL;
+       asp_client_session_s *service = NULL;
+       const char *str = NULL;
+       int ret = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!session) {
+               ASP_LOGE("NULL Param!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service = __get_session((void *)session);
+       if (service == NULL) {
+               ASP_LOGE("Session NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SESSION_NOT_FOUND;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "service_mac", g_variant_new("s", service->service_mac));
+       g_variant_builder_add(builder, "{sv}", "adv_id", g_variant_new("u", service->advertisement_id));
+       g_variant_builder_add(builder, "{sv}", "role", g_variant_new("y", service->network_config));
+       g_variant_builder_add(builder, "{sv}", "config_method", g_variant_new("u", service->network_config));
+       if (service->session_information)
+               g_variant_builder_add(builder, "{sv}", "session _info", g_variant_new("s", service->session_information));
+
+       params = g_variant_new("(a{sv})", builder);
+       g_variant_builder_unref(builder);
+
+       reply = asp_dbus_method_call_sync(ASP_DAEMON_SESSION_INTERFACE,
+                                                 "ConnectSession", params, &error);
+       if (error != NULL) {
+               ASP_LOGE("asp_dbus_method_call_sync() failed."
+                               "error [%d: %s]", error->code, error->message);
+               ret = __asp_err_string_to_enum(error->message);
+               g_error_free(error);
+               __ASP_LOG_FUNC_END__;
+               return ret;
+       }
+
+       g_variant_get(reply, "(iu&s)", &ret, &(service->session_id), &str);
+       if (str != NULL)
+               memcpy(service->session_mac, str, strlen(str));
+       g_variant_unref(reply);
+
+       ASP_LOGD("%s() return : [%d]", __func__, ret);
+
+       __ASP_LOG_FUNC_END__;
+       return ret;
+}
+
+int asp_session_confirm(asp_session_h session, bool confirmed, char *pin)
+{
+       __ASP_LOG_FUNC_START__;
+       GVariantBuilder *builder = NULL;
+       GVariant *params = NULL;
+       GError *error = NULL;
+       GVariant *reply = NULL;
+       asp_client_session_s *service = NULL;
+       int ret = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!session) {
+               ASP_LOGE("NULL Param!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service = __get_session((void *)session);
+       if (service == NULL) {
+               ASP_LOGE("Session NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SESSION_NOT_FOUND;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "session_mac", g_variant_new("s", service->session_mac));
+       g_variant_builder_add(builder, "{sv}", "session_id", g_variant_new("u", service->session_id));
+       g_variant_builder_add(builder, "{sv}", "confirmed", g_variant_new("i", confirmed));
+       if (pin)
+               g_variant_builder_add(builder, "{sv}", "pin", g_variant_new("s", pin));
+       params = g_variant_new("(a{sv})", builder);
+       reply = asp_dbus_method_call_sync(ASP_DAEMON_SESSION_INTERFACE,
+                                                 "ConfirmSession", params, &error);
+       if (error != NULL) {
+               ASP_LOGE("asp_dbus_method_call_sync() failed."
+                               "error [%d: %s]", error->code, error->message);
+               ret = __asp_err_string_to_enum(error->message);
+               g_error_free(error);
+               __ASP_LOG_FUNC_END__;
+               return ret;
+       }
+
+       g_variant_get(reply, "(i)", &ret);
+       g_variant_unref(reply);
+
+       ASP_LOGD("%s() return : [%d]", __func__, ret);
+
+       __ASP_LOG_FUNC_END__;
+       return ret;
+}
+
+int asp_session_get_handle(char *session_mac, unsigned int session_id,
+                           asp_session_h *session)
+
+{
+       __ASP_LOG_FUNC_START__;
+       GVariant *params = NULL;
+       GVariantIter *iter = NULL;
+       GError *error = NULL;
+       GVariant *reply = NULL;
+       asp_client_session_s *service = NULL;
+       char *key = NULL;
+       GVariant *var = NULL;
+       int ret = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!session_mac || !session) {
+               ASP_LOGE("NULL Param!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       params = g_variant_new("(su)", session_mac, session_id);
+       reply = asp_dbus_method_call_sync(ASP_DAEMON_SESSION_INTERFACE,
+                                                 "GetSession", params, &error);
+       if (error != NULL) {
+               ASP_LOGE("asp_dbus_method_call_sync() failed."
+                               "error [%d: %s]", error->code, error->message);
+               ret = __asp_err_string_to_enum(error->message);
+               g_error_free(error);
+               __ASP_LOG_FUNC_END__;
+               return ret;
+       }
+
+       if (!reply) {
+               ASP_LOGE("reply is NULL!!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_OPERATION_FAILED;
+       }
+
+       service = (asp_client_session_s *)g_try_malloc0(sizeof(asp_client_session_s));
+       if (!service) {
+               ASP_LOGE("malloc() failed!!!.");
+               g_variant_unref(reply);
+               return ASP_ERROR_OUT_OF_MEMORY;
+       }
+       ASP_LOGD("service [%p]", service);
+       g_strlcpy(service->session_mac, session_mac, MACSTR_LEN);
+       service->session_id = session_id;
+
+       g_variant_get(reply, "(ia{sv})", &ret, &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               if (!g_strcmp0(key, "adv_id")) {
+                       g_variant_get(var, "u", &(service->advertisement_id));
+/*
+               } else if (!g_strcmp0(key, "session_id")) {
+                       g_variant_get(var, "u", &(service->session_id));
+               } else if (!g_strcmp0(key, "session_mac")) {
+                       g_variant_get(var, "&s", &str);
+                       g_strlcpy(service->session_mac, str, MACSTR_LEN);
+               } else if (!g_strcmp0(key, "state")) {
+                       g_variant_get(var, "i", &(service->state));
+               }  else if (!g_strcmp0(key, "session_info")) {
+                       g_variant_get(var, "&s", &str);
+*/
+               } else {
+                       /* TODO: additional params. */
+                       ;/* Do Nothing */
+               }
+       }
+       g_variant_unref(reply);
+
+       ASP_LOGD("%s() return : [%d]", __func__, ret);
+       *session = service;
+       asp_sessions = g_list_prepend(asp_sessions, service);
+
+       __ASP_LOG_FUNC_END__;
+       return ret;
+}
+
+int asp_session_set_state_ready(asp_session_h session)
+
+{
+       __ASP_LOG_FUNC_START__;
+       GVariant *params = NULL;
+       GError *error = NULL;
+       GVariant *reply = NULL;
+       asp_client_session_s *service = NULL;
+       int ret = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!session) {
+               ASP_LOGE("NULL Param!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service = __get_session((void *)session);
+       if (service == NULL) {
+               ASP_LOGE("Session NOT registered");
+               return ASP_ERROR_SESSION_NOT_FOUND;
+       }
+
+       params = g_variant_new("(su)", service->session_mac, service->session_id);
+       reply = asp_dbus_method_call_sync(ASP_DAEMON_SESSION_INTERFACE,
+                                                 "SetSessionReady", params, &error);
+       if (error != NULL) {
+               ASP_LOGE("asp_dbus_method_call_sync() failed."
+                               "error [%d: %s]", error->code, error->message);
+               ret = __asp_err_string_to_enum(error->message);
+               g_error_free(error);
+               __ASP_LOG_FUNC_END__;
+               return ret;
+       }
+
+       g_variant_get(reply, "(i)", &ret);
+       g_variant_unref(reply);
+
+       ASP_LOGD("%s() return : [%d]", __func__, ret);
+
+       __ASP_LOG_FUNC_END__;
+       return ret;
+}
+
+int asp_session_close(asp_session_h session)
+
+{
+       __ASP_LOG_FUNC_START__;
+       GVariant *params = NULL;
+       GError *error = NULL;
+       GVariant *reply = NULL;
+       asp_client_session_s *service = NULL;
+       int ret = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!session) {
+               ASP_LOGE("NULL Param!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service = __get_session((void *)session);
+       if (service == NULL) {
+               ASP_LOGE("Session NOT registered");
+               return ASP_ERROR_SESSION_NOT_FOUND;
+       }
+
+       params = g_variant_new("(su)", service->session_mac, service->session_id);
+       reply = asp_dbus_method_call_sync(ASP_DAEMON_SESSION_INTERFACE,
+                                                 "CloseSession", params, &error);
+       if (error != NULL) {
+               ASP_LOGE("asp_dbus_method_call_sync() failed."
+                               "error [%d: %s]", error->code, error->message);
+               ret = __asp_err_string_to_enum(error->message);
+               g_error_free(error);
+               __ASP_LOG_FUNC_END__;
+               return ret;
+       }
+
+       g_variant_get(reply, "(i)", &ret);
+       g_variant_unref(reply);
+
+       ASP_LOGD("%s() return : [%d]", __func__, ret);
+
+       __ASP_LOG_FUNC_END__;
+       return ret;
+}
+
+int asp_session_bind_port(asp_session_h session, char *ip_address,
+                          int port, int proto)
+{
+       __ASP_LOG_FUNC_START__;
+       GVariantBuilder *builder = NULL;
+       GVariant *params = NULL;
+       GError *error = NULL;
+       GVariant *reply = NULL;
+       asp_client_session_s *service = NULL;
+       int ret = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!session || !ip_address) {
+               ASP_LOGE("NULL Param!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service = __get_session((void *)session);
+       if (service == NULL) {
+               ASP_LOGE("Session NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SESSION_NOT_FOUND;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "session_mac", g_variant_new("s", service->session_mac));
+       g_variant_builder_add(builder, "{sv}", "session_id", g_variant_new("u", service->session_id));
+       g_variant_builder_add(builder, "{sv}", "ip_address", g_variant_new("s", ip_address));
+       g_variant_builder_add(builder, "{sv}", "port", g_variant_new("i", port));
+       g_variant_builder_add(builder, "{sv}", "proto", g_variant_new("i", proto));
+       params = g_variant_new("(a{sv})", builder);
+       reply = asp_dbus_method_call_sync(ASP_DAEMON_SESSION_INTERFACE,
+                                                 "BoundPort", params, &error);
+       if (error != NULL) {
+               ASP_LOGE("asp_dbus_method_call_sync() failed."
+                               "error [%d: %s]", error->code, error->message);
+               ret = __asp_err_string_to_enum(error->message);
+               g_error_free(error);
+               __ASP_LOG_FUNC_END__;
+               return ret;
+       }
+
+       g_variant_get(reply, "(i)", &ret);
+       g_variant_unref(reply);
+
+       ASP_LOGD("%s() return : [%d]", __func__, ret);
+
+       __ASP_LOG_FUNC_END__;
+       return ret;
+}
+
+int asp_session_release_port(asp_session_h session, char *ip_address,
+                             int port, int proto)
+{
+       __ASP_LOG_FUNC_START__;
+       GVariantBuilder *builder = NULL;
+       GVariant *params = NULL;
+       GError *error = NULL;
+       GVariant *reply = NULL;
+       asp_client_session_s *service = NULL;
+       int ret = ASP_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_ASP);
+
+       if (g_client_info.is_registered == false) {
+               ASP_LOGE("Client is NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!session || !ip_address) {
+               ASP_LOGE("NULL Param!");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_INVALID_PARAMETER;
+       }
+
+       service = __get_session((void *)session);
+       if (service == NULL) {
+               ASP_LOGE("Session NOT registered");
+               __ASP_LOG_FUNC_END__;
+               return ASP_ERROR_SESSION_NOT_FOUND;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "session_mac", g_variant_new("s", service->session_mac));
+       g_variant_builder_add(builder, "{sv}", "session_id", g_variant_new("u", service->session_id));
+       g_variant_builder_add(builder, "{sv}", "ip_address", g_variant_new("s", ip_address));
+       g_variant_builder_add(builder, "{sv}", "port", g_variant_new("i", port));
+       g_variant_builder_add(builder, "{sv}", "proto", g_variant_new("i", proto));
+       params = g_variant_new("(a{sv})", builder);
+       reply = asp_dbus_method_call_sync(ASP_DAEMON_SESSION_INTERFACE,
+                                                 "ReleasePort", params, &error);
+       if (error != NULL) {
+               ASP_LOGE("asp_dbus_method_call_sync() failed."
+                               "error [%d: %s]", error->code, error->message);
+               ret = __asp_err_string_to_enum(error->message);
+               g_error_free(error);
+               __ASP_LOG_FUNC_END__;
+               return ret;
+       }
+
+       g_variant_get(reply, "(i)", &ret);
+       g_variant_unref(reply);
+
+       ASP_LOGD("%s() return : [%d]", __func__, ret);
+
+       __ASP_LOG_FUNC_END__;
+       return ret;
+}
diff --git a/src/asp-dbus.c b/src/asp-dbus.c
new file mode 100644 (file)
index 0000000..7a08e6e
--- /dev/null
@@ -0,0 +1,193 @@
+/*
+ * Application Service Platform(ASP)
+ *
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file implements asp dbus utility functions.
+ *
+ * @file        asp-dbus.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include "asp.h"
+
+#include "asp-dbus.h"
+#include "asp-log.h"
+#include "asp-util.h"
+#include "asp-client.h"
+
+const char *service_path = ASP_DAEMON_SERVICE_PATH;
+const char *session_path = ASP_DAEMON_SESSION_PATH;
+
+typedef struct {
+       GDBusConnection *connection;
+       guint signal_subscribe_id;
+} gdbus_connection_data;
+
+static gdbus_connection_data gdbus_conn = {NULL, 0};
+
+static struct {
+       const char *interface;
+       const char *member;
+       void (*function) (GDBusConnection *connection,
+                         const gchar *object_path,
+                         GVariant *parameters);
+} asp_dbus_signal_map[] = {
+               {
+                               ASP_DAEMON_SERVICE_INTERFACE,
+                               "SearchResult",
+                               asp_process_seek_search_result
+               },
+               {
+                               ASP_DAEMON_SERVICE_INTERFACE,
+                               "AdvertiseStatusChanged",
+                               asp_process_advert_status_changed
+               },
+               {
+                               ASP_DAEMON_SESSION_INTERFACE,
+                               "SessionRequest",
+                               asp_process_session_request
+               },
+               {
+                               ASP_DAEMON_SESSION_INTERFACE,
+                               "SessionConfigRequest",
+                               asp_process_session_config_request
+               },
+               {
+                               ASP_DAEMON_SESSION_INTERFACE,
+                               "ConnectStatus",
+                               asp_process_session_connect_status
+               },
+               {
+                               ASP_DAEMON_SESSION_INTERFACE,
+                               "SessionStatus",
+                               asp_process_session_status
+               },
+               {
+                               ASP_DAEMON_SESSION_INTERFACE,
+                               "PortStatus",
+                               asp_process_session_port_status
+               },
+               {
+                               NULL,
+                               NULL,
+                               NULL
+               }
+};
+
+static void _asp_dbus_signal_cb(GDBusConnection *connection,
+                                       const gchar *sender, const gchar *object_path,
+                                       const gchar *interface, const gchar *signal,
+                                       GVariant *parameters, gpointer user_data)
+{
+       int i = 0;
+
+       ASP_LOGD("Signal Name [%s]", signal);
+       DBUS_DEBUG_VARIANT(parameters);
+
+       for (i = 0; asp_dbus_signal_map[i].member != NULL; i++) {
+               if (!g_strcmp0(signal, asp_dbus_signal_map[i].member) &&
+                   !g_strcmp0(interface, asp_dbus_signal_map[i].interface) &&
+                   asp_dbus_signal_map[i].function != NULL) {
+                       asp_dbus_signal_map[i].function(connection, object_path, parameters);
+                       break;
+               }
+       }
+}
+
+GVariant *asp_dbus_method_call_sync_debug(const char* interface_name,
+                                                 const char* method,
+                                                 GVariant *params,
+                                                 GError **error,
+                                                 const char *calling_func)
+{
+       GVariant *reply = NULL;
+       const char *object_path = NULL;
+
+       if (gdbus_conn.connection == NULL) {
+               ASP_LOGE("GDBusconnection is NULL");
+               return reply;
+       }
+
+       ASP_LOGD("[%s][%s.%s]", calling_func, interface_name, method);
+       DBUS_DEBUG_VARIANT(params);
+
+       if (g_strcmp0(ASP_DAEMON_SERVICE_INTERFACE, interface_name) == 0)
+               object_path = service_path;
+       else
+               object_path = session_path;
+
+       reply = g_dbus_connection_call_sync(gdbus_conn.connection,
+                       ASP_DAEMON_SERVICE, /* bus name */
+                       object_path, /* object path */
+                       interface_name, /* interface name */
+                       method, /* method name */
+                       params, /* GVariant *params */
+                       NULL, /* reply_type */
+                       G_DBUS_CALL_FLAGS_NONE, /* flags */
+                       ASP_DBUS_REPLY_TIMEOUT_SYNC, /* timeout */
+                       NULL, /* cancellable */
+                       error); /* error */
+       DBUS_DEBUG_VARIANT(reply);
+       return reply;
+}
+
+gboolean asp_dbus_init(void)
+{
+       GError *Error = NULL;
+       GDBusConnection *connection = NULL;
+
+       connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &Error);
+       if (connection == NULL) {
+               ASP_LOGE("Failed to get connection, Error[%s]", Error->message);
+               g_error_free(Error);
+               return FALSE;
+       }
+
+       gdbus_conn.connection = connection;
+
+       /* subscribe signal handler */
+       gdbus_conn.signal_subscribe_id = g_dbus_connection_signal_subscribe(connection,
+
+                       ASP_DAEMON_SERVICE, /* bus name */
+                       NULL, /* interface */
+                       NULL, /* member */
+                       NULL, /* object_path */
+                       NULL, /* arg0 */
+                       G_DBUS_SIGNAL_FLAGS_NONE,
+                       _asp_dbus_signal_cb,
+                       NULL,
+                       NULL);
+       ASP_LOGD("Subscribed dbus signals [%d]", gdbus_conn.signal_subscribe_id);
+       return TRUE;
+}
+
+void asp_dbus_deinit(void)
+{
+       if (gdbus_conn.connection == NULL)
+               return;
+
+       /* unsubscribe signal handler */
+       g_dbus_connection_signal_unsubscribe(gdbus_conn.connection, gdbus_conn.signal_subscribe_id);
+       gdbus_conn.signal_subscribe_id = 0;
+
+       /* unref gdbus connection */
+       g_object_unref(gdbus_conn.connection);
+       gdbus_conn.connection = NULL;
+}
diff --git a/src/include/asp-client.h b/src/include/asp-client.h
new file mode 100755 (executable)
index 0000000..2abeb43
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * Application Service Platform(ASP)
+ *
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        asp-client.h
+ * @author      Yu Jiung (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __ASP_CLIENT_H__
+#define __ASP_CLIENT_H__
+
+#include <glib.h>
+
+#define MACADDR_LEN 6
+#define MACSTR_LEN 18
+#define ASP_SERVICE_INFO_MAX_LEN 200
+
+/**
+ * Application Service Platform(ASP) advertise data structure
+ */
+typedef struct {
+       unsigned int adv_id;
+       long long unsigned search_id;
+       int auto_accept;
+       int discovery_tech;
+       unsigned char preferred_connection;
+
+       unsigned char status;
+       unsigned char role;
+       unsigned int config_method;
+       unsigned char tran_id;
+
+       char *instance_name;
+       char *serivce_name;
+       char *service_type;
+       GHashTable *service_info_map;
+       char *rsp_info;
+} asp_client_advert_s;
+
+/**
+ * Application Service Platform(ASP) seek data structure
+ */
+typedef struct {
+       unsigned int adv_id;
+       long long unsigned search_id;
+       int auto_accept;
+       int discovery_tech;
+       unsigned char preferred_connection;
+
+       unsigned char status;
+       unsigned char role;
+       unsigned int config_method;
+       unsigned char tran_id;
+
+       char *serivce_name;
+       char *service_type;
+       GHashTable *service_info_map;
+       char *rsp_info;
+} asp_client_seek_s;
+
+/**
+ * Application Service Platform(ASP) session data structure
+ */
+typedef struct {
+       char session_mac[MACSTR_LEN]; /* the MAC address of the P2P device that generated the session ID */
+       unsigned int session_id;
+       char service_mac[MACSTR_LEN];
+       unsigned int advertisement_id;
+       int network_config;
+       int network_role;
+       int port;
+       int state;
+       int persist;
+       char *session_information;
+
+       /* session information for each local setting */
+       int service_role;
+       int is_incomming;
+       unsigned char local_ip[4];
+       char *deferred_session_response;
+} asp_client_session_s;
+
+typedef struct {
+       bool is_registered;
+
+       asp_seek_search_result_cb seek_search_result_cb;
+       asp_advert_status_changed_cb advert_status_changed_cb;
+
+       asp_session_request_cb session_request_cb;
+       asp_session_config_request_cb session_config_request_cb;
+       asp_session_connect_status_cb session_connect_status_cb;
+       asp_session_status_cb session_status_cb;
+       asp_session_port_status_cb session_port_status_cb;
+
+       void *user_data_for_cb_seek_search_result;
+       void *user_data_for_cb_advert_status_changed;
+
+       void *user_data_for_cb_session_request;
+       void *user_data_for_cb_session_config_request;
+       void *user_data_for_cb_session_connect_status;
+       void *user_data_for_cb_session_status;
+       void *user_data_for_cb_session_port_status;
+} asp_client_info_s;
+
+void asp_process_seek_search_result(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters);
+void asp_process_advert_status_changed(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters);
+
+void asp_process_session_request(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters);
+void asp_process_session_config_request(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters);
+void asp_process_session_connect_status(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters);
+void asp_process_session_status(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters);
+void asp_process_session_port_status(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters);
+
+#endif /** __ASP_CLIENT_H__ */
diff --git a/src/include/asp-dbus.h b/src/include/asp-dbus.h
new file mode 100755 (executable)
index 0000000..013df35
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Application Service Platform(ASP)
+ *
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares Application Service Platform DBus utility functions.
+ *
+ * @file        asp-dbus.h
+ * @author      Jiung Yu (jiung.yu.com)
+ * @version     0.1
+ */
+
+#ifndef __ASP_DBUS_H__
+#define __ASP_DBUS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <gio/gio.h>
+
+#define ASP_DAEMON_SERVICE "net.asp"
+#define ASP_DAEMON_PATH "/net/asp"
+#define ASP_DAEMON_SERVICE_PATH ASP_DAEMON_PATH "/service"
+#define ASP_DAEMON_SESSION_PATH ASP_DAEMON_PATH "/session"
+#define ASP_DAEMON_INTERFACE ASP_DAEMON_SERVICE
+#define ASP_DAEMON_SERVICE_INTERFACE ASP_DAEMON_SERVICE ".service"
+#define ASP_DAEMON_SESSION_INTERFACE ASP_DAEMON_SERVICE ".session"
+
+#define ASP_DBUS_REPLY_TIMEOUT_SYNC 5 * 1000
+#define DBUS_OBJECT_PATH_MAX 150
+
+#define asp_dbus_method_call_sync(interface_name, method, params, error) \
+       asp_dbus_method_call_sync_debug(interface_name, method, params, error, __func__)
+
+#define DBUS_DEBUG_VARIANT(parameters) \
+       do {\
+               gchar *parameters_debug_str = NULL;\
+               if (parameters)\
+                       parameters_debug_str = g_variant_print(parameters, TRUE);\
+                       ASP_LOGD("signal params [%s]", parameters_debug_str ? parameters_debug_str : "NULL");\
+               g_free(parameters_debug_str);\
+       } while (0)
+
+gboolean asp_dbus_is_pending_call_used(void);
+
+gboolean asp_dbus_init(void);
+
+void asp_dbus_deinit(void);
+
+GVariant *asp_dbus_method_call_sync_debug(const char* interface_name,
+                                                 const char* method,
+                                                 GVariant *params,
+                                                 GError **error,
+                                                 const char *calling_func);
+
+int asp_dbus_unpack_ay(unsigned char *dst, GVariant *src, int size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ASP_DBUS_H__ */
diff --git a/src/include/asp-log.h b/src/include/asp-log.h
new file mode 100755 (executable)
index 0000000..09c2aff
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Application Service Platform(ASP)
+ *
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares macros for logging.
+ *
+ * @file        asp-log.h
+ * @author      Jiung Yu (jiung.yu.com)
+ * @version     0.1
+ */
+
+#ifndef __ASP_LOG_H__
+#define __ASP_LOG_H__
+
+#ifdef USE_DLOG
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "CAPI_NETWORK_ASP"
+
+#define ASP_LOGV(format, args...) LOGV(format, ##args)
+#define ASP_LOGD(format, args...) LOGD(format, ##args)
+#define ASP_LOGI(format, args...) LOGI(format, ##args)
+#define ASP_LOGW(format, args...) LOGW(format, ##args)
+#define ASP_LOGE(format, args...) LOGE(format, ##args)
+#define ASP_LOGF(format, args...) LOGF(format, ##args)
+
+#define ASP_SECLOGI(format, args...) SECURE_LOG(LOG_INFO, LOG_TAG, format, ##args)
+#define ASP_SECLOGD(format, args...) SECURE_LOG(LOG_DEBUG, LOG_TAG, format, ##args)
+
+#define __ASP_LOG_FUNC_START__ LOGV("Enter")
+#define __ASP_LOG_FUNC_END__ LOGV("Quit")
+
+#else /** _DLOG_UTIL */
+
+#define ASP_LOGV(format, args...)
+#define ASP_LOGD(format, args...)
+#define ASP_LOGI(format, args...)
+#define ASP_LOGW(format, args...)
+#define ASP_LOGE(format, args...)
+#define ASP_LOGF(format, args...)
+
+#define __ASP_LOG_FUNC_START__
+#define __ASP_LOG_FUNC_END__
+
+#define ASP_SECLOGI(format, args...)
+#define ASP_SECLOGD(format, args...)
+
+#endif /** _DLOG_UTIL */
+#endif /** __ASP_LOG_H__ */
diff --git a/src/include/asp-util.h b/src/include/asp-util.h
new file mode 100755 (executable)
index 0000000..e5dd6ff
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Application Service Platform(ASP)
+ *
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares macros for usefuls.
+ *
+ * @file        asp-util.h
+ * @author      Jiung Yu (jiung.yu.com)
+ * @version     0.1
+ */
+
+#ifndef __ASP_UTIL_H__
+#define __ASP_UTIL_H__
+
+#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
+#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
+#define IP2STR(a) (a)[0], (a)[1], (a)[2], (a)[3]
+#define IPSTR "%d.%d.%d.%d"
+#define MAC2SECSTR(a) (a)[0], (a)[4], (a)[5]
+#define MACSECSTR "%02x:%02x:%02x"
+#define IP2SECSTR(a) (a)[0], (a)[3]
+#define IPSECSTR "%d..%d"
+
+#define MACSTR_LEN 18
+#define MACADDR_LEN 6
+#define IP_LEN 6
+#define IPSTR_LEN 16
+#define WPS_PIN_LEN 8
+
+#define TIZEN_FEATURE_P2PS "tizen.org/feature/network.asp"
+
+#if 0
+#define CHECK_FEATURE_SUPPORTED(feature_name)\
+       do {\
+               bool feature_supported = FALSE;\
+               if (!system_info_get_platform_bool(feature_name, &feature_supported)) {\
+                       if (feature_supported == FALSE) {\
+                               LOGE("%s feature is disabled", feature_name);\
+                               return P2PS_ERROR_NOT_SUPPORTED;\
+                       } \
+               } else {\
+                       LOGE("Error - Feature getting from System Info");\
+                       return P2PS_ERROR_OPERATION_FAILED;\
+               } \
+       } while (0)
+
+#else
+#define CHECK_FEATURE_SUPPORTED(feature_name)
+#endif
+
+#endif /** __ASP_UTIL_H__ */
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..41c5ed5
--- /dev/null
@@ -0,0 +1,40 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(asp-test C)
+
+IF(FILE_TRANSFER_TEST)
+       SET(ASP_TEST_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/file_transfer/include)
+       SET(FILE_TRANSFER_REQUIRED_PKGS libxml-2.0 libsoup-2.4 gssdp-1.0 gupnp-1.0 libtzplatform-config)
+       ADD_DEFINITIONS(-DFILE_TRANSFER_TEST)
+       aux_source_directory(./file_transfer sources)
+ENDIF(FILE_TRANSFER_TEST)
+
+SET(ASP_TEST_INCLUDE_DIR ${ASP_TEST_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../include)
+INCLUDE_DIRECTORIES(${ASP_TEST_INCLUDE_DIR})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(TARGET_ASP_TEST REQUIRED capi-base-common glib-2.0 ${FILE_TRANSFER_REQUIRED_PKGS})
+FOREACH(flag ${TARGET_ASP_TEST_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+       MESSAGE(${flag})
+ENDFOREACH()
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE")
+
+aux_source_directory(. sources)
+FOREACH(src ${sources})
+       GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
+       MESSAGE("${src_name}")
+       SET(ASP_TEST_SRCS ${ASP_TEST_SRCS} ${src})
+ENDFOREACH()
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${ASP_TEST_SRCS})
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${TARGET_ASP} ${TARGET_ASP_TEST_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${BIN_DIR})
+
+IF(FILE_TRANSFER_TEST)
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/files/device.xml.in ${CMAKE_SOURCE_DIR}/files/device.xml @ONLY)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/device.xml DESTINATION ${TZ_SYS_RO_ETC}/file-transfer)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/FileTransfer1.xml DESTINATION ${TZ_SYS_RO_ETC}/file-transfer)
+ENDIF(FILE_TRANSFER_TEST)
+
diff --git a/test/asp-test.c b/test/asp-test.c
new file mode 100644 (file)
index 0000000..79dcde9
--- /dev/null
@@ -0,0 +1,1828 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <time.h>
+#include <assert.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <asp.h>
+
+
+#define RESET_COLOR "\e[m"
+#define MAKE_RED "\e[31m"
+#define MAKE_GREEN "\e[32m"
+
+#define __FUNC_ENTER__ printf("%s() entering...\n", __func__)
+#define __FUNC_EXIT__ printf("%s() leaving...\n", __func__)
+
+#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
+#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
+
+#define MAX_ADVERTISE 255
+#define MAX_SEEK 255
+#define MAX_SESSION 255
+
+static const char *print_error(int err_type)
+{
+       switch (err_type) {
+       case ASP_ERROR_NONE:
+               return "NONE";
+       case ASP_ERROR_NOT_PERMITTED:
+               return "NOT_PERMITTED";
+       case ASP_ERROR_OUT_OF_MEMORY:
+               return "OUT_OF_MEMORY";
+       case ASP_ERROR_PERMISSION_DENIED:
+               return "PERMISSION_DENIED";
+       case ASP_ERROR_RESOURCE_BUSY:
+               return "RESOURCE_BUSY";
+       case ASP_ERROR_INVALID_PARAMETER:
+               return "INVALID_PARAMETER";
+       case ASP_ERROR_CONNECTION_TIME_OUT:
+               return "CONNECTION_TIME_OUT";
+       case ASP_ERROR_NOT_SUPPORTED:
+               return "NOT_SUPPORTED";
+       case ASP_ERROR_NOT_INITIALIZED:
+               return "NOT_INITIALIZED";
+       case ASP_ERROR_ALREADY_INITIALIZED:
+               return "ALREADY_INITIALIZED";
+       case ASP_ERROR_COMMUNICATION_FAILED:
+               return "COMMUNICATION_FAILED";
+       case ASP_ERROR_OPERATION_FAILED:
+               return "ASP_ERROR_OPERATION_FAILED";
+       case ASP_ERROR_IN_PROGRESS:
+               return "IN_PROGRESS";
+       case ASP_ERROR_SERVICE_NOT_FOUND:
+               return "SERVICE_NOT_FOUND";
+       case ASP_ERROR_SESSION_NOT_FOUND:
+               return "SESSION_NOT_FOUND";
+       case ASP_ERROR_NETWORK_ROLE_REJECTED:
+               return "NETWORK_ROLE_REJECTED";
+       default:
+               return "UNKNOWN";
+       }
+}
+
+static const char* print_advert_status_reason(asp_advert_status_reason_e reason)
+{
+       switch (reason) {
+       case ASP_ADVERT_STATUS_REASON_SUCCESS:
+               return "ASP_ADVERT_STATUS_REASON_SUCCESS";
+       case ASP_ADVERT_STATUS_REASON_SERVICE_DUPLICATED:
+               return "ASP_ADVERT_STATUS_REASON_SERVICE_DUPLICATED";
+       case ASP_ADVERT_STATUS_REASON_OTHER_FAILURE:
+               return "ASP_ADVERT_STATUS_REASON_OTHER_FAILURE";
+       default:
+               return"UNKNOWN";
+       }
+}
+
+static const char* print_p2p_role_scheme(asp_advert_p2p_role_scheme_e role)
+{
+       switch (role) {
+       case ASP_ADVERT_P2P_ROLE_SCHEME_ANY:
+               return "ASP_ADVERT_P2P_ROLE_SCHEME_ANY";
+       case ASP_ADVERT_P2P_ROLE_SCHEME_GO:
+               return "ASP_ADVERT_P2P_ROLE_SCHEME_GO";
+       case ASP_ADVERT_P2P_ROLE_SCHEME_GC:
+               return "ASP_ADVERT_P2P_ROLE_SCHEME_GC";
+       default:
+               return"UNKNOWN";
+       }
+}
+
+static const char* print_session_connect_status(int status)
+{
+       switch (status) {
+       case ASP_CONNECT_STATUS_NETWORK_ROLE_REJECTED:
+               return "ASP_CONNECT_STATUS_NETWORK_ROLE_REJECTED";
+       case ASP_CONNECT_STATUS_CONNECTION_LIMIT_REACHED:
+               return "ASP_CONNECT_STATUS_CONNECTION_LIMIT_REACHED";
+       case ASP_CONNECT_STATUS_REQUEST_SENT:
+               return "ASP_CONNECT_STATUS_REQUEST_SENT";
+       case ASP_CONNECT_STATUS_REQUEST_RECEIVED:
+               return "ASP_CONNECT_STATUS_REQUEST_RECEIVED";
+       case ASP_CONNECT_STATUS_REQUEST_DEFERRED:
+               return "ASP_CONNECT_STATUS_REQUEST_DEFERRED";
+       case ASP_CONNECT_STATUS_REQUEST_ACCEPTED:
+               return "ASP_CONNECT_STATUS_REQUEST_ACCEPTED";
+       case ASP_CONNECT_STATUS_REQUEST_FAILED:
+               return "ASP_CONNECT_STATUS_REQUEST_FAILED";
+       case ASP_CONNECT_STATUS_GROUP_FORMATION_STARTED:
+               return "ASP_CONNECT_STATUS_GROUP_FORMATION_STARTED";
+       case ASP_CONNECT_STATUS_GROUP_FORMATION_COMPLETED:
+               return "ASP_CONNECT_STATUS_GROUP_FORMATION_COMPLETED";
+       case ASP_CONNECT_STATUS_GROUP_FORMATION_FAILED:
+               return "ASP_CONNECT_STATUS_GROUP_FORMATION_FAILED";
+       default:
+               return"UNKNOWN";
+       }
+}
+
+static const char* print_session_state(int session_state)
+{
+       switch (session_state) {
+       case ASP_SESSION_STATE_ERROR:
+               return "ASP_SESSION_STATE_ERROR";
+       case ASP_SESSION_STATE_CLOSED:
+               return "ASP_SESSION_STATE_CLOSED";
+       case ASP_SESSION_STATE_INITIATED:
+               return "ASP_SESSION_STATE_INITIATED";
+       case ASP_SESSION_STATE_REQUESTED:
+               return "ASP_SESSION_STATE_REQUESTED";
+       case ASP_SESSION_STATE_OPEN:
+               return "ASP_SESSION_STATE_OPEN";
+       default:
+               return"UNKNOWN";
+       }
+}
+
+static const char* print_session_close_state(int state)
+{
+       switch (state) {
+       case ASP_SESSION_CLOSE_OK:
+               return "ASP_SESSION_CLOSE_OK";
+       case ASP_SESSION_CLOSE_DISASSOCIATED:
+               return "ASP_SESSION_CLOSE_DISASSOCIATED";
+       case ASP_SESSION_CLOSE_LOCAL_CLOSE:
+               return "ASP_SESSION_CLOSE_LOCAL_CLOSE";
+       case ASP_SESSION_CLOSE_REMOTE_CLOSE:
+               return "ASP_SESSION_CLOSE_REMOTE_CLOSE";
+       case ASP_SESSION_CLOSE_SYSTEM_FAILURE:
+               return "ASP_SESSION_CLOSE_SYSTEM_FAILURE";
+       case ASP_SESSION_CLOSE_NO_RESPONSE:
+               return "ASP_SESSION_CLOSE_NO_RESPONSE";
+       default:
+               return"UNKNOWN";
+       }
+}
+
+static const char* print_port_status(int status)
+{
+       switch (status) {
+       case ASP_PORT_STATUS_LOCAL_PORT_ALLOWED:
+               return "ASP_PORT_STATUS_LOCAL_PORT_ALLOWED";
+       case ASP_PORT_STATUS_LOCAL_PORT_BLOCKED:
+               return "ASP_PORT_STATUS_LOCAL_PORT_BLOCKED";
+       case ASP_PORT_STATUS_FAILURE:
+               return "ASP_PORT_STATUS_FAILURE";
+       case ASP_PORT_STATUS_REMOTE_PORT_ALLOWED:
+               return "ASP_PORT_STATUS_REMOTE_PORT_ALLOWED";
+
+       default:
+               return"UNKNOWN";
+       }
+}
+
+static const char* print_service_status(int status)
+{
+       switch (status) {
+       case ASP_SERVICE_STATUS_NOT_ADVERTISED:
+               return "ASP_SERVICE_STATUS_NOT_ADVERTISED";
+       case ASP_SERVICE_STATUS_ADVERTISED:
+               return "ASP_SERVICE_STATUS_ADVERTISED";
+
+       default:
+               return"UNKNOWN";
+       }
+}
+
+enum {
+       CMD_QUIT,
+       CMD_FULL_MENU,
+
+       CMD_INITIALIZE,
+       CMD_DEINITIALIZE,
+
+       CMD_SEEK_SET_SEARCH_RESULT_CB,
+       CMD_SEEK_UNSET_SEARCH_RESULT_CB,
+       CMD_ADVERT_SET_STATUS_CHANGED_CB,
+       CMD_ADVERT_UNSET_STATUS_CHANGED_CB,
+       CMD_SESSION_SET_REQUEST_CB,
+       CMD_SESSION_UNSET_REQUST_CB,
+       CMD_SESSION_SET_CONFIG_REQUEST_CB,
+       CMD_SESSION_UNSET_CONFIG_REQUEST_CB,
+       CMD_SESSION_SET_CONNECT_STATUS_CB,
+       CMD_SESSION_UNSET_CONNECT_STATUS_CB,
+       CMD_SESSION_SET_STATUS_CB,
+       CMD_SESSION_UNSET_STATUS_CB,
+       CMD_SESSION_SET_PORT_STATUS_CB,
+       CMD_SESSION_UNSET_PORT_STATUS_CB,
+
+       CMD_ADVERT_CREATE,
+       CMD_ADVERT_DESTROY,
+
+       CMD_ADVERT_SET_SERVICE_TYPE,
+       CMD_ADVERT_SET_AUTO_ACCEPT,
+       CMD_ADVERT_ADD_INFO,
+       CMD_ADVERT_GET_INFO,
+       CMD_ADVERT_REMOVE_INFO,
+       CMD_ADVERT_SET_STATUS,
+       CMD_ADVERT_SET_DISCOVERY_TECH,
+       CMD_ADVERT_SET_PREF_CONN,
+       CMD_ADVERT_SET_P2P_ROLE,
+       CMD_ADVERT_GET_P2P_ROLE,
+       CMD_ADVERT_SET_P2P_CONFIG,
+       CMD_ADVERT_GET_P2P_CONFIG,
+       CMD_ADVERT_SET_P2P_RSP,
+
+       CMD_ADVERT_START,
+       CMD_ADVERT_STOP,
+       CMD_ADVERT_CHANGE,
+
+       CMD_SEEK_CREATE,
+       CMD_SEEK_DESTROY,
+
+       CMD_SEEK_ADD_INFO,
+       CMD_SEEK_REMOVE_INFO,
+       CMD_SEEK_SET_DISCOVERY_TECH,
+       CMD_SEEK_SET_PREF_CONN,
+
+       CMD_SEEK_START,
+       CMD_SEEK_STOP,
+
+       CMD_SESSION_CREATE,
+       CMD_SESSION_DESTROY,
+
+       CMD_SESSION_GET_MAC,
+       CMD_SESSION_GET_ID,
+
+       CMD_SESSION_SET_INFO,
+       CMD_SESSION_GET_INFO,
+
+       CMD_SESSION_SET_P2P_ROLE_SCHEME,
+       CMD_SESSION_GET_P2P_ROLE_SCHEME,
+
+       CMD_SESSION_SET_P2P_CONFIG_METHOD,
+       CMD_SESSION_GET_P2P_CONFIG_METHOD,
+
+       CMD_SESSION_GET_CLOSE_STATUS,
+
+       CMD_SESSION_CONNECT,
+       CMD_SESSOIN_CONFIRM,
+       CMD_SESSION_GET_HANDLE,
+       CMD_SESSION_SET_STATE_READY,
+       CMD_SESSION_CLOSE,
+       CMD_SESSION_BIND_PORT,
+       CMD_SESSION_RELEASE_PORT,
+
+       CMD_INVALID = 255,
+};
+
+typedef struct {
+       int cmd;
+       char* menu_str;
+} menu_str_s;
+
+menu_str_s g_menu_str[] = {
+               { CMD_QUIT, "CMD_QUIT" },
+               { CMD_FULL_MENU, "CMD_FULL_MENU" },
+               { CMD_INITIALIZE, "CMD_INITIALIZE" },
+               { CMD_DEINITIALIZE, "CMD_DEINITIALIZE" },
+
+               {CMD_SEEK_SET_SEARCH_RESULT_CB, "CMD_SEEK_SET_SEARCH_RESULT_CB"},
+               {CMD_SEEK_UNSET_SEARCH_RESULT_CB, "CMD_SEEK_UNSET_SEARCH_RESULT_CB"},
+               {CMD_ADVERT_SET_STATUS_CHANGED_CB, "CMD_ADVERT_SET_STATUS_CHANGED_CB"},
+               {CMD_ADVERT_UNSET_STATUS_CHANGED_CB, "CMD_ADVERT_UNSET_STATUS_CHANGED_CB"},
+               {CMD_SESSION_SET_REQUEST_CB, "CMD_SESSION_SET_REQUEST_CB"},
+               {CMD_SESSION_UNSET_REQUST_CB, "CMD_SESSION_UNSET_REQUST_CB"},
+               {CMD_SESSION_SET_CONFIG_REQUEST_CB, "CMD_SESSION_SET_CONFIG_REQUEST_CB"},
+               {CMD_SESSION_UNSET_CONFIG_REQUEST_CB, "CMD_SESSION_UNSET_CONFIG_REQUEST_CB"},
+               {CMD_SESSION_SET_CONNECT_STATUS_CB, "CMD_SESSION_SET_CONNECT_STATUS_CB"},
+               {CMD_SESSION_UNSET_CONNECT_STATUS_CB, "CMD_SESSION_UNSET_CONNECT_STATUS_CB"},
+               {CMD_SESSION_SET_STATUS_CB, "CMD_SESSION_SET_STATUS_CB"},
+               {CMD_SESSION_UNSET_STATUS_CB, "CMD_SESSION_UNSET_STATUS_CB"},
+               {CMD_SESSION_SET_PORT_STATUS_CB, "CMD_SESSION_SET_PORT_STATUS_CB"},
+               {CMD_SESSION_UNSET_PORT_STATUS_CB, "CMD_SESSION_UNSET_PORT_STATUS_CB"},
+
+               {CMD_ADVERT_CREATE, "CMD_ADVERT_CREATE"},
+               {CMD_ADVERT_DESTROY, "CMD_ADVERT_DESTROY"},
+
+               {CMD_ADVERT_SET_SERVICE_TYPE, "CMD_ADVERT_SET_SERVICE_TYPE"},
+               {CMD_ADVERT_SET_AUTO_ACCEPT, "CMD_ADVERT_SET_AUTO_ACCEPT"},
+               {CMD_ADVERT_ADD_INFO, "CMD_ADVERT_ADD_INFO"},
+               {CMD_ADVERT_GET_INFO, "CMD_ADVERT_GET_INFO"},
+               {CMD_ADVERT_REMOVE_INFO, "CMD_ADVERT_REMOVE_INFO"},
+               {CMD_ADVERT_SET_STATUS, "CMD_ADVERT_SET_STATUS"},
+               {CMD_ADVERT_SET_DISCOVERY_TECH, "CMD_ADVERT_SET_DISCOVERY_TECH"},
+               {CMD_ADVERT_SET_PREF_CONN, "CMD_ADVERT_SET_PREF_CONN"},
+               {CMD_ADVERT_SET_P2P_ROLE, "CMD_ADVERT_SET_P2P_ROLE"},
+               {CMD_ADVERT_GET_P2P_ROLE, "CMD_ADVERT_GET_P2P_ROLE"},
+               {CMD_ADVERT_SET_P2P_CONFIG, "CMD_ADVERT_SET_P2P_CONFIG"},
+               {CMD_ADVERT_GET_P2P_CONFIG, "CMD_ADVERT_GET_P2P_CONFIG"},
+               {CMD_ADVERT_SET_P2P_RSP, "CMD_ADVERT_SET_P2P_RSP"},
+
+               {CMD_ADVERT_START, "CMD_ADVERT_START"},
+               {CMD_ADVERT_STOP, "CMD_ADVERT_STOP"},
+               {CMD_ADVERT_CHANGE, "CMD_ADVERT_CHANGE"},
+
+               {CMD_SEEK_CREATE, "CMD_SEEK_CREATE"},
+               {CMD_SEEK_DESTROY, "CMD_SEEK_DESTROY"},
+
+               {CMD_SEEK_ADD_INFO, "CMD_SEEK_ADD_INFO"},
+               {CMD_SEEK_REMOVE_INFO, "CMD_SEEK_REMOVE_INFO"},
+               {CMD_SEEK_SET_DISCOVERY_TECH, "CMD_SEEK_SET_DISCOVERY_TECH"},
+               {CMD_SEEK_SET_PREF_CONN, "CMD_SEEK_SET_PREF_CONN"},
+
+               {CMD_SEEK_START, "CMD_SEEK_START"},
+               {CMD_SEEK_STOP, "CMD_SEEK_STOP"},
+
+               {CMD_SESSION_CREATE, "CMD_SESSION_CREATE"},
+               {CMD_SESSION_DESTROY, "CMD_SESSION_DESTROY"},
+
+               {CMD_SESSION_GET_MAC, "CMD_SESSION_GET_MAC"},
+               {CMD_SESSION_GET_ID, "CMD_SESSION_GET_ID"},
+
+               {CMD_SESSION_SET_INFO, "CMD_SESSION_SET_INFO"},
+               {CMD_SESSION_GET_INFO, "CMD_SESSION_GET_INFO"},
+
+               {CMD_SESSION_SET_P2P_ROLE_SCHEME, "CMD_SESSION_SET_P2P_ROLE_SCHEME"},
+               {CMD_SESSION_GET_P2P_ROLE_SCHEME, "CMD_SESSION_GET_P2P_ROLE_SCHEME"},
+
+               {CMD_SESSION_SET_P2P_CONFIG_METHOD, "CMD_SESSION_SET_P2P_CONFIG_METHOD"},
+               {CMD_SESSION_GET_P2P_CONFIG_METHOD, "CMD_SESSION_GET_P2P_CONFIG_METHOD"},
+
+               {CMD_SESSION_GET_CLOSE_STATUS, "CMD_SESSION_GET_CLOSE_STATUS"},
+
+               {CMD_SESSION_CONNECT, "CMD_SESSION_CONNECT"},
+               {CMD_SESSOIN_CONFIRM, "CMD_SESSOIN_CONFIRM"},
+               {CMD_SESSION_GET_HANDLE, "CMD_SESSION_GET_HANDLE"},
+               {CMD_SESSION_SET_STATE_READY, "CMD_SESSION_SET_STATE_READY"},
+               {CMD_SESSION_CLOSE, "CMD_SESSION_CLOSE"},
+               {CMD_SESSION_BIND_PORT, "CMD_SESSION_BIND_PORT"},
+               {CMD_SESSION_RELEASE_PORT, "CMD_SESSION_RELEASE_PORT"},
+
+               { -1, NULL }, };
+
+struct appdata {
+       GMainLoop* main_loop;
+};
+
+struct appdata* g_test_appdata;
+
+static asp_advert_service_h local_advert = NULL;
+static asp_seek_service_h local_seek = NULL;
+static asp_session_h local_session = NULL;
+
+struct appdata* get_appdata()
+{
+       return g_test_appdata;
+}
+
+void set_appdata(struct appdata* p)
+{
+       g_test_appdata = p;
+}
+
+static inline void prt_help(const char *cmd)
+{
+       printf("%s -t [dest ID]\n", cmd);
+       printf("   -u [my ID]\n");
+       printf("   -p [passwd]\n");
+       printf("   -a [alias]\n");
+}
+
+static int get_param(int argc, char **argv, struct appdata *ad)
+{
+       printf("Parsing argument...\n");
+       int opt;
+       while ((opt = getopt(argc, argv, "t:u:p:a:")) != -1) {
+               printf("Parsing argument...:%c\n", opt);
+               switch (opt) {
+               case 't':
+               default:
+                       prt_help(argv[0]);
+                       return -1;
+               }
+       }
+
+       printf("Argument: \n");
+
+       return 0;
+}
+
+void usage()
+{
+       printf("Call Test Program\n");
+       printf(" %d: quit\n", CMD_QUIT);
+       printf(" %d: Full menu\n", CMD_FULL_MENU);
+}
+
+char* cmd_transform(char*str)
+{
+       int i, j;
+       int len;
+       static char static_buffer[255];
+
+       if (str == NULL)
+               return "";
+
+       len = strlen(str);
+       if (len == 0)
+               return "";
+
+       /* remove "CMD_" */
+       /* lower char */
+       /* replance "_" to space */
+       for (i = 0, j = 4; i < len; i++, j++) {
+
+               if (str[j] >= 'A' && str[j] <= 'Z')
+                       static_buffer[i] = str[j] + 'a' - 'A';
+               else if (str[j] == '_')
+                       static_buffer[i] = ' ';
+               else
+                       static_buffer[i] = str[j];
+       }
+       static_buffer[j] = '\0';
+
+       return static_buffer;
+}
+
+void usage_full()
+{
+       int i;
+       printf("Call Test Program\n");
+
+       for (i = 0; g_menu_str[i].cmd != -1; i++) {
+               if (i%3 == 0)
+                       printf("\n");
+               if (i == 2 || i == 4 || i == 6 || i == 12 || i == 17 ||
+                               i == 20 || i == 24 || i == 26 || i == 28 || i == 36)
+                       printf(MAKE_GREEN);
+               printf(" %02d: %-32s ", g_menu_str[i].cmd,
+                               cmd_transform(g_menu_str[i].menu_str));
+               if (i == 2 || i == 4 || i == 6 || i == 12 || i == 17 ||
+                               i == 20 || i == 24 || i == 26 || i == 28 || i == 36)
+                       printf(RESET_COLOR);
+
+       }
+       printf("\n");
+}
+
+int is_digit(const char* str)
+{
+       int len;
+       int i;
+
+       if (str == NULL)
+               return -1;
+
+       if (strlen(str) == 0)
+               return -1;
+
+       len = strlen(str);
+       for (i = 0; i < len; i++)       {
+               if (str[i] < '0' || str[i] > '9')
+                       return -2;
+       }
+
+       return 0;
+}
+
+void seek_search_result_cb(int error_code,
+                           asp_seek_service_h seek_service,
+                           const char *service_mac,
+                           unsigned int adv_id,
+                           asp_wps_type_e config_method,
+                           const char *instance_name,
+                           const char *service_info,
+                           int info_size,
+                           unsigned char status,
+                           void *user_data)
+{
+       return;
+}
+
+void advert_status_changed_cb(asp_advert_service_h adv_service,
+                              asp_service_status_e status,
+                              asp_advert_status_reason_e reason,
+                              void *user_data)
+{
+       return;
+}
+
+void session_request_cb(int error_code,
+                        asp_advert_service_h adv_service,
+                        asp_session_h session,
+                        const char *device_name,
+                        const char *info,
+                        int info_size,
+                        bool get_network_config_pin,
+                        const char *network_config_pin,
+                        void *user_data)
+{
+       return;
+}
+
+void session_config_request_cb(int error_code,
+                               asp_session_h session,
+                               bool get_pin,
+                               const char *config_pin,
+                               void *user_data)
+{
+       return;
+}
+
+void session_connect_status_cb(int error_code,
+                               asp_session_h session,
+                               asp_connect_status_e status,
+                               const char *deferred_resp,
+                               int resp_size,
+                               void *user_data)
+{
+       return;
+}
+
+void session_status_cb(int error_code,
+                       asp_session_h session,
+                       asp_session_state_e state,
+                       const char *additional_info,
+                       void *user_data)
+{
+       return;
+}
+
+void session_port_status_cb(int error_code,
+                            asp_session_h session,
+                            const char *ip_address,
+                            int port,
+                            int proto,
+                            asp_port_status_e status,
+                            void *user_data)
+{
+       return;
+}
+
+int init_asp_client(struct appdata *ad)
+{
+       __FUNC_ENTER__;
+       int ret;
+
+       ret = asp_initialize();
+       printf("asp_initialize() result=[%d]\n", ret);
+
+       ret = asp_seek_set_search_result_cb(seek_search_result_cb, (void*)ad);
+       printf("asp_seek_set_search_result_cb result=[%d]\n", ret);
+
+       ret = asp_advert_set_status_changed_cb(advert_status_changed_cb, (void*)ad);
+       printf("asp_advert_set_status_changed_cb result=[%d]\n", ret);
+
+       ret = asp_session_set_request_cb(session_request_cb, (void*)ad);
+       printf("asp_session_set_request_cb result=[%d]\n", ret);
+
+       ret = asp_session_set_config_request_cb(session_config_request_cb, (void*)ad);
+       printf("asp_session_set_config_request_cb result=[%d]\n", ret);
+
+       ret = asp_session_set_connect_status_cb(session_connect_status_cb, (void*)ad);
+       printf("asp_session_set_connect_status_cb result=[%d]\n", ret);
+
+       ret = asp_session_set_status_cb(session_status_cb, (void*)ad);
+       printf("asp_session_set_status_cb result=[%d]\n", ret);
+
+       ret = asp_session_set_port_status_cb(session_port_status_cb, (void*)ad);
+       printf("asp_session_set_port_status_cb result=[%d]\n", ret);
+
+       __FUNC_EXIT__;
+       return ret;
+}
+
+void test_full_menu()
+{
+       usage_full();
+
+       return;
+}
+
+void test_quit()
+{
+       struct appdata *ad = get_appdata(ad);
+
+       printf("Bye\n");
+       g_main_loop_quit(ad->main_loop);
+
+       return;
+}
+
+void test_init()
+{
+       struct appdata *ad = get_appdata(ad);
+       int ret = 0;
+
+       ret = init_asp_client(ad);
+       printf("init_asp_client() result=[%d]\n", ret);
+
+       return;
+}
+
+void test_deinit()
+{
+       int ret = 0;
+
+       ret = asp_deinitialize();
+       printf("asp_deinitialize() result=[%d]\n", ret);
+}
+
+void test_asp_seek_set_search_result_cb()
+{
+       struct appdata *ad = get_appdata(ad);
+       int ret = 0;
+
+       ret = asp_seek_set_search_result_cb(seek_search_result_cb, ad);
+       printf("asp_seek_set_search_result_cb() result=[%d]\n", ret);
+
+       return;
+
+}
+void test_asp_seek_unset_search_result_cb()
+{
+       int ret = 0;
+
+       ret = asp_seek_unset_search_result_cb();
+       printf("asp_seek_unset_search_result_cb() result=[%d]\n", ret);
+
+       return;
+}
+
+void test_asp_advert_set_status_changed_cb()
+{
+       struct appdata *ad = get_appdata(ad);
+       int ret = 0;
+
+       ret = asp_advert_set_status_changed_cb(advert_status_changed_cb, ad);
+       printf("asp_advert_unset_status_changed_cb() result=[%d]\n", ret);
+
+       return;
+}
+
+void test_asp_advert_unset_status_changed_cb()
+{
+       int ret = 0;
+
+       ret = asp_advert_unset_status_changed_cb();
+       printf("asp_advert_unset_status_changed_cb() result=[%d]\n", ret);
+
+       return;
+}
+
+void test_asp_session_set_request_cb()
+{
+       struct appdata *ad = get_appdata(ad);
+       int ret = 0;
+
+       ret = asp_session_set_request_cb(session_request_cb, ad);
+       printf("asp_session_set_request_cb() result=[%d]\n", ret);
+
+       return;
+}
+
+void test_asp_session_unset_request_cb()
+{
+       int ret = 0;
+
+       ret = asp_session_unset_request_cb();
+       printf("asp_session_unset_request_cb() result=[%d]\n", ret);
+
+       return;
+}
+
+void test_asp_session_set_config_request_cb()
+{
+       struct appdata *ad = get_appdata(ad);
+       int ret = 0;
+
+       ret = asp_session_set_config_request_cb(session_config_request_cb, ad);
+       printf("asp_session_set_config_request_cb() result=[%d]\n", ret);
+
+       return;
+}
+
+void test_asp_session_unset_config_request_cb()
+{
+       int ret = 0;
+
+       ret = asp_session_unset_config_request_cb();
+       printf("asp_session_unset_config_request_cb() result=[%d]\n", ret);
+
+       return;
+}
+
+void test_asp_session_set_connect_status_cb()
+{
+       struct appdata *ad = get_appdata(ad);
+       int ret = 0;
+
+       ret = asp_session_set_connect_status_cb(session_connect_status_cb, ad);
+       printf("asp_session_set_connect_status_cb() result=[%d]\n", ret);
+
+       return;
+}
+
+void test_asp_session_unset_connect_status_cb()
+{
+       int ret = 0;
+
+       ret = asp_session_unset_connect_status_cb();
+       printf("asp_session_unset_connect_status_cb() result=[%d]\n", ret);
+
+       return;
+}
+
+void test_asp_session_set_status_cb()
+{
+       struct appdata *ad = get_appdata(ad);
+       int ret = 0;
+
+       ret = asp_session_set_status_cb(session_status_cb, ad);
+       printf("asp_session_set_status_cb() result=[%d]\n", ret);
+
+       return;
+}
+
+void test_asp_session_unset_status_cb()
+{
+       int ret = 0;
+
+       ret = asp_session_unset_status_cb();
+       printf("asp_session_unset_status_cb() result=[%d]\n", ret);
+
+       return;
+}
+
+void test_asp_session_set_port_status_cb()
+{
+       struct appdata *ad = get_appdata(ad);
+       int ret = 0;
+
+       ret = asp_session_set_port_status_cb(session_port_status_cb, ad);
+       printf("asp_session_set_port_status_cb() result=[%d]\n", ret);
+
+       return;
+}
+
+void test_asp_session_unset_port_status_cb()
+{
+       int ret = 0;
+
+       ret = asp_session_unset_connect_status_cb();
+       printf("asp_session_unset_connect_status_cb() result=[%d]\n", ret);
+
+       return;
+}
+
+void test_asp_advert_create()
+{
+       char instance_name[64] = {0, };
+       int ret = 0;
+
+       printf("Input instance :\n");
+       if (scanf(" %64[^\n]s", instance_name) < 0)
+               return;
+
+       if (strlen(instance_name) <= 0) {
+               printf("invalid instance_name !!\n");
+               return;
+       }
+
+       printf("instance_name: [%s]\n", instance_name);
+       ret = asp_advert_create(instance_name, &local_advert);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_advert_create"RESET_COLOR"\n");
+               printf("local_advert [%p]\n", local_advert);
+       } else {
+               printf(MAKE_RED"asp_advert_create : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_advert_destroy()
+{
+       int ret = 0;
+
+       ret = asp_advert_destroy(local_advert);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_advert_destroy"RESET_COLOR"\n");
+               local_advert = NULL;
+       } else {
+               printf(MAKE_RED"asp_advert_destroy : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_advert_set_service_type()
+{
+               char service_type[256] = {0, };
+               int ret = 0;
+
+               printf("Input advertise_type :\n");
+               if (scanf(" %256[^\n]s", service_type) < 0)
+                       return;
+
+               if (strlen(service_type) <= 0) {
+                       printf("invalid advertise_type !!\n");
+                       return;
+               }
+
+               printf("service_type: [%s]\n", service_type);
+               ret = asp_advert_set_service_type(local_advert, service_type);
+               if (ret == ASP_ERROR_NONE) {
+                       printf(MAKE_GREEN"asp_advert_set_service_type"RESET_COLOR"\n");;
+               } else {
+                       printf(MAKE_RED"asp_advert_set_service_type : %s ", print_error(ret));
+                       printf(RESET_COLOR"\n");
+               }
+
+               return;
+}
+
+void test_asp_advert_set_auto_accept()
+{
+       int auto_accept = 0;
+       int ret = 0;
+
+       printf("Enter ASP service auto accept : \n");
+       if (scanf("%d", &auto_accept) < 0)
+               return;
+
+       ret = asp_advert_set_auto_accept(local_advert, auto_accept);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_advert_set_auto_accept"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_advert_set_auto_accept : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_advert_add_info()
+{
+       char key[256] = {0, };
+       char value[256] = {0, };
+       int ret = 0;
+
+       printf("Enter ASP service information key :\n");
+       if (scanf(" %256[^\n]s", key) < 0)
+               return;
+       printf("Enter ASP service information value :\n");
+       if (scanf(" %256[^\n]s", value) < 0)
+               return;
+
+       ret = asp_advert_add_info(local_advert, key, value);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_advert_add_info"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_advert_add_info : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_advert_get_info()
+{
+       int length = 0;
+       char key[256] = {0, };
+       char *value = NULL;
+       int ret = 0;
+
+       printf("Enter ASP service information key :\n");
+       if (scanf(" %256[^\n]s", key) < 0)
+               return;
+
+       ret = asp_advert_get_info(local_advert, key,
+                       &length, &value);
+       if (ret == ASP_ERROR_NONE) {
+               if(value != NULL)
+                       printf(MAKE_GREEN"value [%s]"RESET_COLOR"\n", value);
+               printf(MAKE_GREEN"asp_advert_get_info"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_advert_get_info : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_advert_remove_info()
+{
+       char key[256] = {0, };
+       int ret = 0;
+
+       printf("Enter ASP service information key :\n");
+       if (scanf(" %256[^\n]s", key) < 0)
+               return;
+
+       ret = asp_advert_remove_info(local_advert, key);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_advert_remove_info"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_advert_remove_info : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_advert_set_status()
+{
+       unsigned char status = 0;
+       int ret = 0;
+
+       printf("Enter ASP service status : \n");
+       printf("1 = available to use\n");
+       printf("0 = not available to use\n");
+       if (scanf("%hhu", &status) < 0)
+               return;
+
+       ret = asp_advert_set_status(local_advert, status);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_advert_set_status"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_advert_set_status : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_advert_set_discovery_tech()
+{
+       int tech = 0;
+       int ret = 0;
+
+       printf("Enter ASP advertising tech : \n");
+       printf("Please enter logical OR value of below techs\n");
+       printf("ASP_DISCOVERY_TECH_P2P = 0x01\n");
+       printf("ASP_DISCOVERY_TECH_BLE = 0x02\n");
+       printf("ASP_DISCOVERY_TECH_NFC = 0x04\n");
+       printf("ASP_DISCOVERY_TECH_INFRA = 0x08\n");
+       printf("ASP_DISCOVERY_TECH_NAN = 0x10\n");
+       if (scanf("%d", &tech) < 0)
+               return;
+
+       ret = asp_advert_set_discovery_tech(local_advert, tech);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_advert_set_discovery_tech"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_advert_set_discovery_tech : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_advert_set_preferred_connection()
+{
+       unsigned char pref = 0;
+       int ret = 0;
+
+       printf("Enter ASP advertising preferred connection : \n");
+       if (scanf("%hhu", &pref) < 0)
+               return;
+
+       ret = asp_advert_set_preferred_connection(local_advert, pref);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_advert_set_preferred_connection"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_advert_set_preferred_connection : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_advert_set_p2p_role_scheme()
+{
+       unsigned char role = 0;
+       int ret = 0;
+
+       printf("Enter ASP p2p service role : ");
+       printf("0 = Don't care\n");
+       printf("1 = The receiving interface shall be the GO\n");
+       if (scanf("%hhu", &role) < 0)
+               return;
+
+       ret = asp_advert_set_p2p_role_scheme(local_advert, role);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_advert_set_p2p_role_scheme"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_advert_set_p2p_role_scheme : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_advert_get_p2p_role_scheme()
+{
+       asp_advert_p2p_role_scheme_e role = 0;
+       int ret = 0;
+
+
+       ret = asp_advert_get_p2p_role_scheme(local_advert, &role);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_advert_get_p2p_role_scheme"RESET_COLOR"\n");
+               printf(MAKE_GREEN"role [%d]"RESET_COLOR"\n", (int)role);
+       } else {
+               printf(MAKE_RED"asp_advert_get_p2p_role_scheme : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_advert_set_p2p_config_method()
+{
+       unsigned int config_method = 0;
+       int ret = 0;
+
+       printf("Enter ASP service p2p config method : \n");
+       printf("1 = P2Ps default configuration or WSC PIN\n");
+       printf("2 = WSC PIN method both display and keypad\n");
+       printf("3 = WSC PIN method only display\n");
+       printf("4 = WSC PIN method only keypad\n");
+       if (scanf(" %d", &config_method) < 0)
+               return;
+
+       ret = asp_advert_set_p2p_config_method(local_advert, config_method);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_advert_set_p2p_config_method"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_advert_set_p2p_config_method : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_advert_get_p2p_config_method()
+{
+       unsigned int config_method = 0;
+       int ret = 0;
+
+       ret = asp_advert_get_p2p_config_method(local_advert, &config_method);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_advert_get_p2p_config_method [%u] "RESET_COLOR"\n", config_method);
+       } else {
+               printf(MAKE_RED"asp_advert_get_p2p_config_method : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_advert_set_p2p_response()
+{
+       char service_rsp[256] = {0, };
+       int ret = 0;
+
+       printf("Input service_rsp :\n");
+       if (scanf(" %256[^\n]s", service_rsp) < 0)
+               return;
+
+       if (strlen(service_rsp) <= 0)
+               return;
+
+       printf("service_info: [%s]\n", service_rsp);
+       ret = asp_advert_set_p2p_response(local_advert, service_rsp, strlen(service_rsp));
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_advert_set_p2p_response"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_advert_set_p2p_response : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_advert_start_advertising()
+{
+       int ret = 0;
+
+       ret = asp_advert_start_advertising(local_advert);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_advert_start_advertising"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_advert_start_advertising : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_advert_stop_advertising()
+{
+       int ret = 0;
+
+       ret = asp_advert_stop_advertising(local_advert);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_advert_start_advertising"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_advert_start_advertising : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_advert_change_service_status()
+{
+       unsigned char status = 0;
+       int ret = 0;
+
+       ret = asp_advert_change_service_status(local_advert, status);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_advert_change_service_status"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_advert_change_service_status : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_seek_create()
+{
+       char service_type[64] = {0, };
+       int ret = 0;
+
+       printf("Input service_type :\n");
+       if (scanf(" %64[^\n]s", service_type) < 0)
+        return;
+
+       if (strlen(service_type) <= 0)
+               return;
+
+       printf("service_type: [%s]\n", service_type);
+       ret = asp_seek_create(service_type, &local_seek);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_seek_create"RESET_COLOR"\n");
+               printf("seek handle [%p]\n", local_seek);
+       } else {
+               printf(MAKE_RED"asp_seek_create : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_seek_destroy()
+{
+       int ret = 0;
+
+       ret = asp_seek_destroy(local_seek);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_seek_destroy"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_seek_destroy : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_seek_add_info()
+{
+       char key[256] = {0, };
+       int ret = 0;
+
+       printf("Enter ASP service information key :\n");
+       if (scanf(" %256[^\n]s", key) < 0)
+               return;
+
+       ret = asp_seek_add_info(local_seek, key);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_seek_add_info"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_seek_add_info : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_seek_remove_info()
+{
+       char key[256] = {0, };
+       int ret = 0;
+
+       printf("Enter ASP service information key :\n");
+       if (scanf(" %256[^\n]s", key) < 0)
+               return;
+
+       ret= asp_seek_remove_info(local_seek, key);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_seek_remove_info"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_seek_remove_info : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_seek_set_discovery_tech()
+{
+       int tech = 0;
+       int ret = 0;
+
+       printf("Enter ASP seeking tech : \n");
+       printf("Please enter logical OR value of below techs\n");
+       printf("ASP_DISCOVERY_TECH_P2P = 0x01\n");
+       printf("ASP_DISCOVERY_TECH_BLE = 0x02\n");
+       printf("ASP_DISCOVERY_TECH_NFC = 0x04\n");
+       printf("ASP_DISCOVERY_TECH_INFRA = 0x08\n");
+       printf("ASP_DISCOVERY_TECH_NAN = 0x10\n");
+       if (scanf("%d", &tech) < 0)
+               return;
+
+       ret = asp_seek_set_discovery_tech(local_seek, tech);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_seek_set_discovery_tech"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_seek_set_discovery_tech : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_seek_set_preferred_connection()
+{
+       unsigned char pref = 0;
+       int ret = 0;
+
+       printf("Enter ASP seeking preferred connection : \n");
+       if (scanf("%hhu", &pref) < 0)
+               return;
+
+       ret = asp_seek_set_preferred_connection(local_seek, pref);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_seek_set_preferred_connection"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_seek_set_preferred_connection : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_seek_start()
+{
+       int ret = 0;
+
+       ret = asp_seek_start(local_seek);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_seek_start"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_seek_start : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_seek_stop()
+{
+       int ret = 0;
+
+       ret = asp_seek_stop(local_seek);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_seek_stop"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_seek_stop : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_session_create()
+{
+       int ret = 0;
+
+       char *mac_addr = NULL;
+       unsigned int adv_id = 0;
+
+       printf("\nEnter advertise id: ");
+       if (scanf("%u", &adv_id) < 1)
+               return;
+
+       printf("\nEnter target address: ");
+       if (scanf("%18ms", &mac_addr) < 1)
+               return;
+
+       ret = asp_session_create(mac_addr, adv_id, &local_session);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_create"RESET_COLOR"\n");
+               printf("session id [%p]", local_session);
+       } else {
+               printf(MAKE_RED"asp_session_create : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_session_destroy()
+{
+       int ret = 0;
+
+       ret = asp_session_destroy(local_session);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_destroy"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_session_destroy : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_session_get_mac()
+{
+       char *session_mac = NULL;
+       int ret = 0;
+
+       ret = asp_session_get_mac(local_session, &session_mac);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_get_mac"RESET_COLOR"\n");
+               printf("session_mac [%s]", session_mac);
+       } else {
+               printf(MAKE_RED"asp_session_get_mac : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_session_get_id()
+{
+       unsigned int session_id = 0;
+       int ret = 0;
+
+       ret = asp_session_get_id(local_session, &session_id);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_get_id"RESET_COLOR"\n");
+               printf("session_info [%u]", session_id);
+       } else {
+               printf(MAKE_RED"asp_session_get_id : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_session_set_info()
+{
+       char *session_info = NULL;
+       int ret = 0;
+
+       printf("\nEnter session_info: ");
+       if (scanf("%128ms", &session_info) < 1)
+               return;
+
+       ret = asp_session_set_info(local_session, session_info);
+       g_free(session_info);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_set_info"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_session_set_info : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_session_get_info()
+{
+       char *session_info = NULL;
+       int ret = 0;
+
+       ret = asp_session_get_info(local_session, &session_info);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_get_info"RESET_COLOR"\n");
+               printf("session_info [%s]", session_info);
+       } else {
+               printf(MAKE_RED"asp_session_get_info : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_session_set_p2p_role_scheme()
+{
+       int role = ASP_ADVERT_P2P_ROLE_SCHEME_ANY;
+       int ret = 0;
+
+       printf("\nEnter network role: ");
+       printf("\n0 = Don't care");
+       printf("\n1 = shall be the GO\n");
+       if (scanf("%d", &role) < 1)
+               return;
+
+       ret = asp_session_set_p2p_role_scheme(local_session,
+                       (asp_advert_p2p_role_scheme_e)role);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_set_p2p_role_scheme"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_session_set_p2p_role_scheme : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_session_get_p2p_role_scheme()
+{
+       asp_advert_p2p_role_scheme_e role;
+       int ret = 0;
+
+       ret = asp_session_get_p2p_role_scheme(local_session, &role);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_get_p2p_role_scheme"RESET_COLOR"\n");
+               printf("network role [%u]", role);
+       } else {
+               printf(MAKE_RED"asp_session_get_p2p_role_scheme : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_session_set_p2p_config_method()
+{
+       int config_method = ASP_WPS_TYPE_NONE;
+       int ret = 0;
+
+       printf("\nEnter network config: ");
+       printf("\n1 = P2Ps default configuration or WSC PIN\n");
+       printf("\n2 = WSC PIN method only\n");
+       if (scanf("%d", &config_method) < 1)
+               return;
+
+       ret = asp_session_set_p2p_config_method(local_session,
+                       (asp_wps_type_e)config_method);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_set_p2p_config_method"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_session_set_p2p_config_method : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_session_get_p2p_config_method()
+{
+       asp_wps_type_e config_method = 0;
+       int ret = 0;
+
+       ret = asp_session_get_p2p_config_method(local_session, &config_method);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_get_p2p_config_method"RESET_COLOR"\n");
+               printf("network config [%d]", config_method);
+       } else {
+               printf(MAKE_RED"asp_session_get_p2p_config_method : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_session_get_close_status()
+{
+       int status = 0;
+       int ret = 0;
+
+       ret = asp_session_get_close_status(local_session, &status);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_get_close_status"RESET_COLOR"\n");
+               printf("close status [%d]", status);
+       } else {
+               printf(MAKE_RED"asp_session_get_close_status : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_session_connect()
+{
+       int ret = 0;
+
+       ret = asp_session_connect(local_session);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_connect"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_session_connect : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+       return;
+}
+
+void test_asp_session_confirm()
+{
+       int confirmed = 0;
+       int ret = 0;
+
+       printf("\nEnter confirm : ");
+       if (scanf("%d", &confirmed) < 1)
+               return;
+
+       ret = asp_session_confirm(local_session, confirmed, NULL);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_confirm"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_session_confirm : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_session_get_handle()
+{
+       char *mac_addr = NULL;
+       unsigned int session_id = 0;
+       int ret = 0;
+
+
+       printf("\nEnter target address: ");
+       if (scanf("%17ms", &mac_addr) < 1)
+               return;
+
+       printf("\nEnter session id: ");
+       if (scanf("%u", &session_id) < 1)
+               return;
+
+       ret = asp_session_get_handle(mac_addr, session_id, &local_session);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_get_handle"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_session_get_handle : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_session_set_state_ready()
+{
+       int ret = 0;
+
+       ret = asp_session_set_state_ready(local_session);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_set_state_ready"RESET_COLOR"\n");
+               local_session = NULL;
+       } else {
+               printf(MAKE_RED"asp_session_set_state_ready : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_session_close()
+{
+       int ret = 0;
+
+       ret = asp_session_close(local_session);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_close"RESET_COLOR"\n");
+               local_session = NULL;
+       } else {
+               printf(MAKE_RED"asp_session_close : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_session_bind_port()
+{
+       int ret = 0;
+
+       char *ip_address = NULL;
+       int port = 0;
+       int proto = 0;
+
+       printf("\nEnter IP address: ");
+       if (scanf("%17ms", &ip_address) < 1)
+               return;
+
+       printf("\nEnter port: ");
+       if (scanf("%i", &port) < 1)
+               return;
+
+       printf("\nEnter proto: ");
+       if (scanf("%i", &proto) < 1)
+               return;
+
+       ret = asp_session_bind_port(local_session, ip_address, port, proto);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_bind_port"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_session_bind_port : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_asp_session_release_port()
+{
+       int ret = 0;
+
+       char *ip_address = NULL;
+       int port = 0;
+       int proto = 0;
+
+       printf("\nEnter IP address: ");
+       if (scanf("%17ms", &ip_address) < 1)
+               return;
+
+       printf("\nEnter port: ");
+       if (scanf("%i", &port) < 1)
+               return;
+
+       printf("\nEnter proto: ");
+       if (scanf("%i", &proto) < 1)
+               return;
+
+       ret = asp_session_release_port(local_session, ip_address, port, proto);
+       if (ret == ASP_ERROR_NONE) {
+               printf(MAKE_GREEN"asp_session_release_port"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"asp_session_release_port : %s ", print_error(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+typedef void (*test_func)(void);
+
+typedef struct {
+       int cmd;
+       test_func func;
+} menu_func_s;
+
+menu_func_s g_menu_func[] = {
+               {CMD_QUIT, test_quit },
+               {CMD_FULL_MENU, test_full_menu},
+               {CMD_INITIALIZE, test_init },
+               {CMD_DEINITIALIZE, test_deinit},
+
+               {CMD_SEEK_SET_SEARCH_RESULT_CB, test_asp_seek_set_search_result_cb},
+               {CMD_SEEK_UNSET_SEARCH_RESULT_CB, test_asp_seek_unset_search_result_cb},
+               {CMD_ADVERT_SET_STATUS_CHANGED_CB, test_asp_advert_set_status_changed_cb},
+               {CMD_ADVERT_UNSET_STATUS_CHANGED_CB, test_asp_advert_unset_status_changed_cb},
+               {CMD_SESSION_SET_REQUEST_CB, test_asp_session_set_request_cb},
+               {CMD_SESSION_UNSET_REQUST_CB, test_asp_session_unset_request_cb},
+               {CMD_SESSION_SET_CONFIG_REQUEST_CB, test_asp_session_set_config_request_cb},
+               {CMD_SESSION_UNSET_CONFIG_REQUEST_CB, test_asp_session_unset_config_request_cb},
+               {CMD_SESSION_SET_CONNECT_STATUS_CB, test_asp_session_set_connect_status_cb},
+               {CMD_SESSION_UNSET_CONNECT_STATUS_CB, test_asp_session_unset_connect_status_cb},
+               {CMD_SESSION_SET_STATUS_CB, test_asp_session_set_status_cb},
+               {CMD_SESSION_UNSET_STATUS_CB, test_asp_session_unset_status_cb},
+               {CMD_SESSION_SET_PORT_STATUS_CB, test_asp_session_set_port_status_cb},
+               {CMD_SESSION_UNSET_PORT_STATUS_CB, test_asp_session_unset_port_status_cb},
+
+               {CMD_ADVERT_CREATE, test_asp_advert_create},
+               {CMD_ADVERT_DESTROY, test_asp_advert_destroy},
+
+               {CMD_ADVERT_SET_SERVICE_TYPE, test_asp_advert_set_service_type},
+               {CMD_ADVERT_SET_AUTO_ACCEPT, test_asp_advert_set_auto_accept},
+               {CMD_ADVERT_ADD_INFO, test_asp_advert_add_info},
+               {CMD_ADVERT_GET_INFO, test_asp_advert_get_info},
+               {CMD_ADVERT_REMOVE_INFO, test_asp_advert_remove_info},
+               {CMD_ADVERT_SET_STATUS, test_asp_advert_set_status},
+               {CMD_ADVERT_SET_DISCOVERY_TECH, test_asp_advert_set_discovery_tech},
+               {CMD_ADVERT_SET_PREF_CONN, test_asp_advert_set_preferred_connection},
+               {CMD_ADVERT_SET_P2P_ROLE, test_asp_advert_set_p2p_role_scheme},
+               {CMD_ADVERT_GET_P2P_ROLE, test_asp_advert_get_p2p_role_scheme},
+               {CMD_ADVERT_SET_P2P_CONFIG, test_asp_advert_set_p2p_config_method},
+               {CMD_ADVERT_GET_P2P_CONFIG, test_asp_advert_get_p2p_config_method},
+               {CMD_ADVERT_SET_P2P_RSP, test_asp_advert_set_p2p_response},
+
+               {CMD_ADVERT_START, test_asp_advert_start_advertising},
+               {CMD_ADVERT_STOP, test_asp_advert_stop_advertising},
+               {CMD_ADVERT_CHANGE, test_asp_advert_change_service_status},
+
+               {CMD_SEEK_CREATE, test_asp_seek_create},
+               {CMD_SEEK_DESTROY, test_asp_seek_destroy},
+
+               {CMD_SEEK_ADD_INFO, test_asp_seek_add_info},
+               {CMD_SEEK_REMOVE_INFO, test_asp_seek_remove_info},
+               {CMD_SEEK_SET_DISCOVERY_TECH, test_asp_seek_set_discovery_tech},
+               {CMD_SEEK_SET_PREF_CONN, test_asp_seek_set_preferred_connection},
+
+               {CMD_SEEK_START, test_asp_seek_start},
+               {CMD_SEEK_STOP, test_asp_seek_stop},
+
+               {CMD_SESSION_CREATE, test_asp_session_create},
+               {CMD_SESSION_DESTROY, test_asp_session_destroy},
+
+               {CMD_SESSION_GET_MAC, test_asp_session_get_mac},
+               {CMD_SESSION_GET_ID, test_asp_session_get_id},
+
+               {CMD_SESSION_SET_INFO, test_asp_session_set_info},
+               {CMD_SESSION_GET_INFO, test_asp_session_get_info},
+
+               {CMD_SESSION_SET_P2P_ROLE_SCHEME, test_asp_session_set_p2p_role_scheme},
+               {CMD_SESSION_GET_P2P_ROLE_SCHEME, test_asp_session_get_p2p_role_scheme},
+
+               {CMD_SESSION_SET_P2P_CONFIG_METHOD, test_asp_session_set_p2p_config_method},
+               {CMD_SESSION_GET_P2P_CONFIG_METHOD, test_asp_session_get_p2p_config_method},
+
+               {CMD_SESSION_GET_CLOSE_STATUS, test_asp_session_get_close_status},
+
+               {CMD_SESSION_CONNECT, test_asp_session_connect},
+               {CMD_SESSOIN_CONFIRM, test_asp_session_confirm},
+               {CMD_SESSION_GET_HANDLE, test_asp_session_get_handle},
+               {CMD_SESSION_SET_STATE_READY, test_asp_session_set_state_ready},
+               {CMD_SESSION_CLOSE, test_asp_session_close},
+               {CMD_SESSION_BIND_PORT, test_asp_session_bind_port},
+               {CMD_SESSION_RELEASE_PORT, test_asp_session_release_port},
+
+               { -1, NULL }, };
+
+void process_input(const char *input, gpointer user_data)
+{
+       int cmd = -1;
+
+       cmd = strtol(input, NULL, 0);
+       if (is_digit(input) < 0 || strlen(input) == 0 || errno == ERANGE || errno
+                       == EINVAL)
+               cmd = CMD_INVALID;
+
+       printf("cmd=[%d]\n", cmd);
+       g_menu_func[cmd].func();
+}
+
+static gboolean test_terminal_read_std_input(GIOChannel * source,
+               GIOCondition condition, gpointer user_data)
+{
+       int fd = 0;
+
+       static char buf[1024];
+       int n;
+
+       errno = 0;
+       n = read(fd, buf, 1024);
+
+       buf[n - 1] = '\0'; /* remove new line... */
+       if (n == 0)
+               printf("Error: read() from stdin returns 0.\n");
+       else if (n < 0)
+               printf("input: read, err\n");
+       else
+               printf("\n\n");
+
+       process_input(buf, user_data);
+
+       return TRUE;
+}
+
+int main(int argc, char **argv)
+{
+       GMainLoop *main_loop;
+
+       struct appdata *ad = NULL;
+
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+       g_type_init();
+#endif
+
+       main_loop = g_main_loop_new(NULL, FALSE);
+
+       ad = (struct appdata*)malloc(sizeof(struct appdata));
+
+       set_appdata(ad);
+       ad->main_loop = main_loop;
+
+       int r = get_param(argc, argv, ad);
+       if (r)
+               return -1;
+
+
+       int std_input_fd = 0;
+       GIOChannel *gio2 = g_io_channel_unix_new(std_input_fd);
+       g_io_add_watch(gio2, G_IO_IN, (GIOFunc) test_terminal_read_std_input, ad);
+       g_io_channel_unref(gio2);
+
+       usage_full();
+
+       g_main_loop_run(main_loop);
+
+       return 0;
+}