Added tool application 20/166120/3 accepted/tizen/unified/20180112.073216 submit/tizen/20180112.015821
authorhyunuktak <hyunuk.tak@samsung.com>
Mon, 8 Jan 2018 04:25:24 +0000 (13:25 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Mon, 8 Jan 2018 05:38:43 +0000 (14:38 +0900)
Change-Id: I82c59b6b673a80fa9e0a59857c73e8338be967b4
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
37 files changed:
CMakeLists.txt
packaging/capi-network-wifi-manager.spec
tool/CMakeLists.txt [new file with mode: 0755]
tool/wifi_mgr_extension.c [new file with mode: 0755]
tool/wifi_mgr_extension.h [new file with mode: 0755]
tool/wifi_mgr_extension_autoconnect.c [new file with mode: 0755]
tool/wifi_mgr_extension_autoconnect.h [new file with mode: 0755]
tool/wifi_mgr_extension_autoscan.c [new file with mode: 0755]
tool/wifi_mgr_extension_autoscan.h [new file with mode: 0755]
tool/wifi_mgr_extension_bss.c [new file with mode: 0755]
tool/wifi_mgr_extension_bss.h [new file with mode: 0755]
tool/wifi_mgr_extension_ipconflict.c [new file with mode: 0755]
tool/wifi_mgr_extension_ipconflict.h [new file with mode: 0755]
tool/wifi_mgr_extension_netlinkscan.c [new file with mode: 0755]
tool/wifi_mgr_extension_netlinkscan.h [new file with mode: 0755]
tool/wifi_mgr_menu.c [new file with mode: 0755]
tool/wifi_mgr_menu.h [new file with mode: 0755]
tool/wifi_mgr_public.c [new file with mode: 0755]
tool/wifi_mgr_public.h [new file with mode: 0755]
tool/wifi_mgr_public_config.c [new file with mode: 0755]
tool/wifi_mgr_public_config.h [new file with mode: 0755]
tool/wifi_mgr_public_connect.c [new file with mode: 0755]
tool/wifi_mgr_public_connect.h [new file with mode: 0755]
tool/wifi_mgr_public_get.c [new file with mode: 0755]
tool/wifi_mgr_public_get.h [new file with mode: 0755]
tool/wifi_mgr_public_ipconflict.c [new file with mode: 0755]
tool/wifi_mgr_public_ipconflict.h [new file with mode: 0755]
tool/wifi_mgr_public_scan.c [new file with mode: 0755]
tool/wifi_mgr_public_scan.h [new file with mode: 0755]
tool/wifi_mgr_public_set.c [new file with mode: 0755]
tool/wifi_mgr_public_set.h [new file with mode: 0755]
tool/wifi_mgr_public_tdls.c [new file with mode: 0755]
tool/wifi_mgr_public_tdls.h [new file with mode: 0755]
tool/wifi_mgr_public_vsie.c [new file with mode: 0755]
tool/wifi_mgr_public_vsie.h [new file with mode: 0755]
tool/wifi_mgr_tool.c [new file with mode: 0755]
tool/wifi_mgr_tool.h [new file with mode: 0755]

index 8651bfc..aa4c9c2 100755 (executable)
@@ -66,6 +66,7 @@ CONFIGURE_FILE(
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB}/pkgconfig)
 
 ADD_SUBDIRECTORY(test)
+ADD_SUBDIRECTORY(tool)
 
 IF(UNIX)
 
index 565dc3f..6d111ac 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          capi-network-wifi-manager
 Summary:       Network Wi-Fi library in TIZEN C API
-Version:       1.0.26
+Version:       1.0.27
 Release:       1
 Group:         System/Network
 License:       Apache-2.0
@@ -43,6 +43,7 @@ export CFLAGS+=' -Wno-unused-local-typedefs'
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 cmake -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
       -DLIB_INSTALL_DIR=%{_libdir} -DINCLUDE_INSTALL_DIR=%{_includedir} \
+      -DBIN_DIR=%{_bindir} \
        -DLIB_PATH=%{_lib} \
        .
 
@@ -69,3 +70,4 @@ make %{?_smp_mflags}
 
 %files tool
 %{_bindir}/wifi_manager_test
+%{_bindir}/wifi_mgr_tool
diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..a2d657a
--- /dev/null
@@ -0,0 +1,42 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(wifi_mgr_tool C)
+
+SET(dependents "capi-base-common glib-2.0")
+
+SET(WIFI_MGR_TOOL_INCLUDE_DIR ${WIFI_MGR_TOOL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../include)
+INCLUDE_DIRECTORIES(${WIFI_MGR_TOOL_INCLUDE_DIR})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PROJECT_NAME} REQUIRED ${dependents})
+FOREACH(flag ${${PROJECT_NAME}_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+       MESSAGE(${flag})
+ENDFOREACH()
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+SET(wifi_mgr_tool_src
+       wifi_mgr_tool.c
+       wifi_mgr_menu.c
+       wifi_mgr_public.c
+       wifi_mgr_public_scan.c
+       wifi_mgr_public_connect.c
+       wifi_mgr_public_get.c
+       wifi_mgr_public_set.c
+       wifi_mgr_public_config.c
+       wifi_mgr_public_tdls.c
+       wifi_mgr_public_vsie.c
+       wifi_mgr_public_ipconflict.c
+       wifi_mgr_extension.c
+       wifi_mgr_extension_autoscan.c
+       wifi_mgr_extension_autoconnect.c
+       wifi_mgr_extension_bss.c
+       wifi_mgr_extension_ipconflict.c
+       wifi_mgr_extension_netlinkscan.c
+)
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${wifi_mgr_tool_src})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${fw_name} ${${PROJECT_NAME}_LDFLAGS})
+
+INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${BIN_DIR})
diff --git a/tool/wifi_mgr_extension.c b/tool/wifi_mgr_extension.c
new file mode 100755 (executable)
index 0000000..1e2b44e
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "wifi_mgr_tool.h"
+#include "wifi_mgr_menu.h"
+#include "wifi_mgr_extension.h"
+
+extern wifi_manager_h g_wifi_h;
+extern wifi_manager_h g_wifi2_h;
+
+extern struct menu_data menu_extension_autoscan[];
+extern struct menu_data menu_extension_autoconnect[];
+extern struct menu_data menu_extension_bss[];
+extern struct menu_data menu_extension_ipconflict[];
+extern struct menu_data menu_extension_netlinkscan[];
+
+struct menu_data menu_extension[] = {
+       { "1", "[Auto scan]", menu_extension_autoscan, NULL, NULL},
+       { "2", "[Auto connect]", menu_extension_autoconnect, NULL, NULL},
+       { "3", "[Bss]", menu_extension_bss, NULL, NULL},
+       { "4", "[IP conflict]", menu_extension_ipconflict, NULL, NULL},
+       { "5", "[Netlink scan]", menu_extension_netlinkscan, NULL, NULL},
+       { NULL, NULL, },
+};
diff --git a/tool/wifi_mgr_extension.h b/tool/wifi_mgr_extension.h
new file mode 100755 (executable)
index 0000000..cb8d4f6
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_EXTENSION_H__
+#define __WIFI_MGR_EXTENSION_H__
+
+#endif /** __WIFI_MGR_EXTENSION_H__ */
diff --git a/tool/wifi_mgr_extension_autoconnect.c b/tool/wifi_mgr_extension_autoconnect.c
new file mode 100755 (executable)
index 0000000..a70c6a7
--- /dev/null
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "wifi_mgr_tool.h"
+#include "wifi_mgr_menu.h"
+#include "wifi_mgr_extension_autoconnect.h"
+
+extern wifi_manager_h g_wifi_h;
+extern wifi_manager_h g_wifi2_h;
+extern wifi_manager_device_state_e g_device_state;
+
+static char g_ssid[MENU_DATA_SIZE] = "dnet2";
+static char g_autoconnect_mode[MENU_DATA_SIZE] = "0";
+static char g_autoconnect_state[MENU_DATA_SIZE] = "0";
+
+static bool __test_extension_found_ap_cb(wifi_manager_ap_h ap, void *user_data)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       char *essid = NULL;
+       wifi_manager_connection_state_e state;
+       int rssi = 0;
+       bool autoconnect = FALSE;
+       int autoconn_state = (int)strtol((char *)g_autoconnect_state, NULL, 10);
+       int cb_type = (int)strtol((char *)user_data, NULL, 10);
+
+       ret = wifi_manager_ap_get_essid(ap, &essid);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get essid for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_connection_state(ap, &state);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get connection state for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_rssi(ap, &rssi);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get rssi for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       switch (cb_type) {
+       case 0: /* get */
+               if (test_wifi_mgr_compare_string(essid, g_ssid)) {
+                       msg("AP name " LOG_CYAN "[%s]" LOG_END ", State [%s], Rssi [%d]", essid,
+                               test_wifi_mgr_conn_state_to_string(state), rssi);
+
+                       ret = wifi_manager_ap_get_auto_connect(ap, &autoconnect);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("Succeeded to get autoconnect state " LOG_CYAN "[%s]" LOG_END,
+                                       (autoconnect == TRUE) ? "TRUE" : "FALSE");
+                       else
+                               msg("Failed to get autoconnect state " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+               }
+               break;
+       case 1: /* set */
+               if (test_wifi_mgr_compare_string(essid, g_ssid)) {
+                       msg("AP name " LOG_CYAN "[%s]" LOG_END ", State [%s], Rssi [%d]", essid,
+                               test_wifi_mgr_conn_state_to_string(state), rssi);
+
+                       ret = wifi_manager_ap_set_auto_connect(ap, autoconn_state);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg(LOG_GREEN "Succeeded to set autoconnect state" LOG_END);
+                       else
+                               msg("Failed to set autoconnect state " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+               }
+               break;
+       default:
+               break;
+       }
+
+       FREE(essid);
+       return TRUE;
+}
+
+static int _test_extension_autoconnect_get_mode(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       int mode = 0;
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       ret = wifi_manager_get_auto_connect(g_wifi_h, &mode);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to get autoconnect mode " LOG_CYAN "[%s]" LOG_END,
+                       (mode == 0) ? "Disable" : "Enable");
+       else
+               msg("Failed to get autoconnect mode " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_extension_autoconnect_set_mode(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       int mode = (int)strtol((char *)g_autoconnect_mode, NULL, 10);
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       if (mode < 0 || mode > 1) {
+               msg("Invalid parameter " LOG_RED "[autoconnect mode]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = wifi_manager_set_auto_connect(g_wifi_h, mode);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to set autoconnect mode" LOG_END);
+       else
+               msg("Failed to set autoconnect mode " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_extension_autoconnect_get_state_for_ap(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_foreach_found_ap(g_wifi_h, __test_extension_found_ap_cb, "0");
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Get AP list finished" LOG_END);
+       else
+               msg("Failed to get AP list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_extension_autoconnect_set_state_for_ap(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       int state = (int)strtol((char *)g_autoconnect_state, NULL, 10);
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       if (state < 0 || state > 1) {
+               msg("Invalid parameter " LOG_RED "[autoconnect state]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_foreach_found_ap(g_wifi_h, __test_extension_found_ap_cb, "1");
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Get AP list finished" LOG_END);
+       else
+               msg("Failed to get AP list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+struct menu_data menu_extension_autoconnect[] = {
+       { "0", LOG_LIGHTGREEN "[SSID]" LOG_END, NULL, NULL, g_ssid},
+       { "1", "[Mode] (0.Disable/1.Enable)", NULL, NULL, g_autoconnect_mode},
+       { "2", "[State] for AP (0.Disable/1.Enable)", NULL, NULL, g_autoconnect_state},
+       { "3", "[Get] mode", NULL, _test_extension_autoconnect_get_mode, NULL},
+       { "4", "[Set] mode", NULL, _test_extension_autoconnect_set_mode, NULL},
+       { "5", "[Get] state for AP", NULL, _test_extension_autoconnect_get_state_for_ap, NULL},
+       { "6", "[Set] state for AP", NULL, _test_extension_autoconnect_set_state_for_ap, NULL},
+       { NULL, NULL, },
+};
diff --git a/tool/wifi_mgr_extension_autoconnect.h b/tool/wifi_mgr_extension_autoconnect.h
new file mode 100755 (executable)
index 0000000..b302e6e
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_EXTENSION_AUTOCONNECT_H__
+#define __WIFI_MGR_EXTENSION_AUTOCONNECT_H__
+
+#endif /** __WIFI_MGR_EXTENSION_AUTOCONNECT_H__ */
diff --git a/tool/wifi_mgr_extension_autoscan.c b/tool/wifi_mgr_extension_autoscan.c
new file mode 100755 (executable)
index 0000000..209960f
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "wifi_mgr_tool.h"
+#include "wifi_mgr_menu.h"
+#include "wifi_mgr_extension_autoscan.h"
+
+extern wifi_manager_h g_wifi_h;
+extern wifi_manager_h g_wifi2_h;
+extern wifi_manager_device_state_e g_device_state;
+
+static char g_autoscan_state[MENU_DATA_SIZE] = "0";
+static char g_autoscan_mode[MENU_DATA_SIZE] = "0";
+
+static int _test_extension_autoscan_get_state(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       bool autoscan = FALSE;
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       ret = wifi_manager_get_autoscan(g_wifi_h, &autoscan);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to get autoscan state " LOG_CYAN "[%s]" LOG_END,
+                       (autoscan == FALSE) ? "Disabled" : "Enabled");
+       else
+               msg("Failed to get autoscan state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_extension_autoscan_get_mode(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_autoscan_mode_e autoscan_mode = WIFI_MANAGER_AUTOSCAN_MODE_EXPONENTIAL;
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       ret = wifi_manager_get_autoscan_mode(g_wifi_h, &autoscan_mode);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to get autoscan mode " LOG_CYAN "[%s]" LOG_END,
+                       test_wifi_mgr_autoscan_mode_to_string(autoscan_mode));
+       else
+               msg("Failed to get autoscan mode " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_extension_autoscan_set_state(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       int autoscan_state = (int)strtol((char *)g_autoscan_state, NULL, 10);
+       bool state = FALSE;
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       if (autoscan_state < 0 || autoscan_state > 1) {
+               msg("Invalid parameter " LOG_RED "[autoscan state]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       state = (autoscan_state == 0) ? TRUE : FALSE;
+       ret = wifi_manager_set_autoscan(g_wifi_h, state);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to set autoscan state" LOG_END);
+       else
+               msg("Failed to set autoscan state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_extension_autoscan_set_mode(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       int autoscan_mode = (int)strtol((char *)g_autoscan_mode, NULL, 10);
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       if (autoscan_mode < 0 || autoscan_mode > 1) {
+               msg("Invalid parameter " LOG_RED "[autoscan mode]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = wifi_manager_set_autoscan_mode(g_wifi_h, autoscan_mode);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to set autoscan mode" LOG_END);
+       else
+               msg("Failed to set autoscan mode " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+struct menu_data menu_extension_autoscan[] = {
+       { "1", "[State] (0.Disable/1.Enable)", NULL, NULL, g_autoscan_state},
+       { "2", "[Mode] (0.Exponential/1.Periodic)", NULL, NULL, g_autoscan_mode},
+       { "3", "[Get] state", NULL, _test_extension_autoscan_get_state, NULL},
+       { "4", "[Set] state", NULL, _test_extension_autoscan_set_state, NULL},
+       { "5", "[Get] mode", NULL, _test_extension_autoscan_get_mode, NULL},
+       { "6", "[Set] mode", NULL, _test_extension_autoscan_set_mode, NULL},
+       { NULL, NULL, },
+};
diff --git a/tool/wifi_mgr_extension_autoscan.h b/tool/wifi_mgr_extension_autoscan.h
new file mode 100755 (executable)
index 0000000..87011ab
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_EXTENSION_AUTOSCAN_H__
+#define __WIFI_MGR_EXTENSION_AUTOSCAN_H__
+
+#endif /** __WIFI_MGR_EXTENSION_AUTOSCAN_H__ */
diff --git a/tool/wifi_mgr_extension_bss.c b/tool/wifi_mgr_extension_bss.c
new file mode 100755 (executable)
index 0000000..4a6d85f
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "wifi_mgr_tool.h"
+#include "wifi_mgr_menu.h"
+#include "wifi_mgr_extension_bss.h"
+
+extern wifi_manager_h g_wifi_h;
+extern wifi_manager_h g_wifi2_h;
+
+static int _test_extension_bss_flush(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       ret = wifi_manager_flush_bss(g_wifi_h);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to flush bss" LOG_END);
+       else
+               msg("Failed to flush bss " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+struct menu_data menu_extension_bss[] = {
+       { "1", "[Flush]", NULL, _test_extension_bss_flush, NULL},
+       { NULL, NULL, },
+};
diff --git a/tool/wifi_mgr_extension_bss.h b/tool/wifi_mgr_extension_bss.h
new file mode 100755 (executable)
index 0000000..3a592da
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_EXTENSION_BSS_H__
+#define __WIFI_MGR_EXTENSION_BSS_H__
+
+#endif /** __WIFI_MGR_EXTENSION_BSS_H__ */
diff --git a/tool/wifi_mgr_extension_ipconflict.c b/tool/wifi_mgr_extension_ipconflict.c
new file mode 100755 (executable)
index 0000000..f5838fe
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "wifi_mgr_tool.h"
+#include "wifi_mgr_menu.h"
+#include "wifi_mgr_extension_ipconflict.h"
+
+extern wifi_manager_h g_wifi_h;
+extern wifi_manager_h g_wifi2_h;
+
+static char g_period[MENU_DATA_SIZE] = "0";
+
+static int _test_extension_ipconflict_get_period(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       unsigned int period = 0;
+
+       ret = wifi_manager_get_ip_conflict_period(g_wifi_h, &period);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to get ip conflict period " LOG_CYAN "[%d]" LOG_END,
+                       period);
+       else
+               msg("Failed to get ip conflict period " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_extension_ipconflict_set_period(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       int period = (int)strtol((char *)g_period, NULL, 10);
+
+       if (period < 0) {
+               msg("Invalid parameter " LOG_RED "[period]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = wifi_manager_set_ip_conflict_period(g_wifi_h, period);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to get ip conflict period" LOG_END);
+       else
+               msg("Failed to get ip conflict period " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+struct menu_data menu_extension_ipconflict[] = {
+       { "1", "[Period] interval for ARP ping", NULL, NULL, g_period},
+       { "2", "[Get] period", NULL, _test_extension_ipconflict_get_period, NULL},
+       { "3", "[Set] period", NULL, _test_extension_ipconflict_set_period, NULL},
+       { NULL, NULL, },
+};
diff --git a/tool/wifi_mgr_extension_ipconflict.h b/tool/wifi_mgr_extension_ipconflict.h
new file mode 100755 (executable)
index 0000000..24f8789
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_EXTENSION_IPCONFLICT_H__
+#define __WIFI_MGR_EXTENSION_IPCONFLICT_H__
+
+#endif /** __WIFI_MGR_EXTENSION_IPCONFLICT_H__ */
diff --git a/tool/wifi_mgr_extension_netlinkscan.c b/tool/wifi_mgr_extension_netlinkscan.c
new file mode 100755 (executable)
index 0000000..a3ac61d
--- /dev/null
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "wifi_mgr_tool.h"
+#include "wifi_mgr_menu.h"
+#include "wifi_mgr_extension_netlinkscan.h"
+
+extern wifi_manager_h g_wifi_h;
+extern wifi_manager_h g_wifi2_h;
+
+static char g_ssid[MENU_DATA_SIZE] = "dnet2";
+static char g_vsie[MENU_DATA_SIZE] = "x";
+
+static bool __test_extension_found_ap_cb(wifi_manager_ap_h ap, void *user_data)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       char *bssid = NULL;
+       char *essid = NULL;
+       int rssi = 0;
+
+       ret = wifi_manager_ap_get_bssid(ap, &bssid);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get bssid for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_essid(ap, &essid);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get essid for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(bssid);
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_rssi(ap, &rssi);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get rssi for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(bssid);
+               FREE(essid);
+               return FALSE;
+       }
+
+       msg("Bssid [%s], Essid " LOG_CYAN "[%s]" LOG_END ", Rssi [%d]", bssid, essid, rssi);
+
+       FREE(bssid);
+       FREE(essid);
+       return TRUE;
+}
+
+static int __test_extension_foreach_netlink_scan(void)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_foreach_found_netlink_scan_ap(g_wifi_h,
+                       __test_extension_found_ap_cb, NULL);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Get bssid scan list finished" LOG_END);
+       else
+               msg("Failed to get bssid scan list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static void __test_extension_scan_request_cb(wifi_manager_error_e error_code, void *user_data)
+{
+       msg(HR_SINGLE);
+
+       msg("Netlink scan completed , error code " LOG_GREEN "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(error_code));
+
+       msg(HR_SINGLE);
+
+       if (error_code == WIFI_MANAGER_ERROR_NONE)
+               __test_extension_foreach_netlink_scan();
+}
+
+static void __test_extension_found_specific_ap_cb(wifi_manager_error_e error_code, void *user_data)
+{
+       msg(HR_SINGLE);
+
+       msg("Netlink specific scan completed , error code " LOG_GREEN "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(error_code));
+
+       msg(HR_SINGLE);
+
+       if (error_code == WIFI_MANAGER_ERROR_NONE)
+               __test_extension_foreach_netlink_scan();
+}
+
+static int _test_extension_netlinkscan_scan(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_netlink_scan_h netlink_scan_h = NULL;
+
+       ret = wifi_manager_netlink_scan_create(g_wifi_h, &netlink_scan_h);
+       if (ret == WIFI_MANAGER_ERROR_NONE) {
+               msg("Succeeded to create netlink scan handle");
+       } else {
+               msg("Failed to create netlink scan handle " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               return ret;
+       }
+
+       switch (g_vsie[0]) {
+       case 'x': /* Skip */
+               ret = WIFI_MANAGER_ERROR_NONE;
+               break;
+       default:
+               ret = wifi_manager_netlink_scan_set_vsie(netlink_scan_h, g_vsie);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Succeeded to set netlink scan VSIE " LOG_CYAN "[%s]" LOG_END, g_vsie);
+               else
+                       msg("Failed to set netlink scan VSIE " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+               break;
+       }
+
+       ret = wifi_manager_netlink_scan(g_wifi_h, netlink_scan_h,
+                       __test_extension_scan_request_cb, NULL);
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to request netlink scan");
+       else
+               msg("Failed to request netlink scan " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       ret = wifi_manager_netlink_scan_destroy(g_wifi_h, netlink_scan_h);
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to destroy netlink scan handle");
+       else
+               msg("Failed to destroy netlink scan handle " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       return ret;
+}
+
+static int _test_extension_netlinkscan_specific_scan(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_netlink_scan_h netlink_scan_h = NULL;
+
+       ret = wifi_manager_netlink_scan_create(g_wifi_h, &netlink_scan_h);
+       if (ret == WIFI_MANAGER_ERROR_NONE) {
+               msg("Succeeded to create netlink scan handle");
+       } else {
+               msg("Failed to create netlink scan handle " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               return ret;
+       }
+
+       ret = wifi_manager_netlink_scan_set_ssid(netlink_scan_h, g_ssid);
+       if (ret == WIFI_MANAGER_ERROR_NONE) {
+               msg("Succeeded to set netlink scan ssid " LOG_CYAN "[%s]" LOG_END, g_ssid);
+       } else {
+               msg("Failed to set netlink scan ssid " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               return ret;
+       }
+
+       switch (g_vsie[0]) {
+       case 'x': /* Skip */
+               ret = WIFI_MANAGER_ERROR_NONE;
+               break;
+       default:
+               ret = wifi_manager_netlink_scan_set_vsie(netlink_scan_h, g_vsie);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Succeeded to set netlink scan VSIE " LOG_CYAN "[%s]" LOG_END, g_vsie);
+               else
+                       msg("Failed to set netlink scan VSIE " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+               break;
+       }
+
+       ret = wifi_manager_netlink_scan(g_wifi_h, g_ssid,
+                       __test_extension_found_specific_ap_cb, NULL);
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to request netlink specific scan");
+       else
+               msg("Failed to request netlink specific scan " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       ret = wifi_manager_netlink_scan_destroy(g_wifi_h, netlink_scan_h);
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to destroy netlink scan handle");
+       else
+               msg("Failed to destroy netlink scan handle " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       return ret;
+}
+
+struct menu_data menu_extension_netlinkscan[] = {
+       { "0", LOG_LIGHTGREEN "[SSID]" LOG_END, NULL, NULL, g_ssid},
+       { "1", "[VSIE] (x.Skip)", NULL, NULL, g_vsie},
+       { "2", "[Scan]", NULL, _test_extension_netlinkscan_scan, NULL},
+       { "3", "[Scan specific AP]", NULL, _test_extension_netlinkscan_specific_scan, NULL},
+       { NULL, NULL, },
+};
diff --git a/tool/wifi_mgr_extension_netlinkscan.h b/tool/wifi_mgr_extension_netlinkscan.h
new file mode 100755 (executable)
index 0000000..cbdd9e4
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_EXTENSION_NETLINKSCAN_H__
+#define __WIFI_MGR_EXTENSION_NETLINKSCAN_H__
+
+#endif /** __WIFI_MGR_EXTENSION_NETLINKSCAN_H__ */
diff --git a/tool/wifi_mgr_menu.c b/tool/wifi_mgr_menu.c
new file mode 100755 (executable)
index 0000000..65e31b2
--- /dev/null
@@ -0,0 +1,374 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <glib.h>
+#include <asm/unistd.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include "wifi_mgr_menu.h"
+
+#define DEFAULT_MENU_MENU      "m"
+#define DEFAULT_MENU_PREV      "p"
+#define DEFAULT_MENU_QUIT      "q"
+#define DEFAULT_MENU_NONE      "-"
+#define TAB_SPACE     "  "
+
+struct menu_manager {
+       GQueue *stack;
+       GQueue *title_stack;
+
+       struct menu_data *menu;
+
+       char *buf;
+
+       void *user_data;
+       GMainLoop *mainloop;
+};
+
+
+char key_buffer[MENU_DATA_SIZE];
+int flag_pid_display = 1;
+
+
+static void _show_prompt(void)
+{
+       msgn("(%5d) >> ", get_tid());
+}
+
+static void _show_reserved_menu(void)
+{
+       msg(LOG_DARKGRAY HR_SINGLE2 LOG_END);
+       msg(LOG_DARKGRAY " [ " LOG_END "%s" LOG_DARKGRAY
+                       " ] " LOG_END "Previous Menu " , DEFAULT_MENU_PREV);
+       msg(LOG_DARKGRAY " [ " LOG_END "%s" LOG_DARKGRAY
+                       " ] " LOG_END "Show Menu " , DEFAULT_MENU_MENU);
+       msg(LOG_DARKGRAY " [ " LOG_END "%s" LOG_DARKGRAY
+                       " ] " LOG_END "Quit " , DEFAULT_MENU_QUIT);
+}
+
+static void _show_input_ok(void)
+{
+       msg("OK.");
+}
+
+static void _show_menu(MManager *m, struct menu_data menu[])
+{
+       int i = 0;
+       int len = 0;
+       struct menu_data *item;
+       char title_buf[256] = { 0, };
+
+       if (!menu)
+               return;
+
+       msg("");
+       msg(HR_DOUBLE);
+
+       len = g_queue_get_length(m->title_stack);
+       msgn(LOG_YELLOW " Main");
+       if (len > 0) {
+               for (i = 0; i < len; i++) {
+                       msgn(LOG_END " >> " LOG_YELLOW "%s",
+                                       (char *)g_queue_peek_nth(m->title_stack, i));
+               }
+       }
+       msg(LOG_END);
+       msg(HR_SINGLE);
+
+       hide_pid();
+       i = 0;
+
+       while (1) {
+               item = menu + i;
+               if (item->key == NULL)
+                       break;
+
+               if (!g_strcmp0(item->key, "-")) {
+                       msgn("       ");
+               } else if (!g_strcmp0(item->key, "_")) {
+                       msg(LOG_DARKGRAY HR_SINGLE2 LOG_END);
+
+                       if (item->callback)
+                               item->callback(m, item);
+
+                       i++;
+
+                       continue;
+               } else if (!g_strcmp0(item->key, "*")) {
+                       msg(" %s", item->title);
+                       if (item->callback)
+                               item->callback(m, item);
+               } else {
+                       msgn(LOG_DARKGRAY " [" LOG_END "%3s"
+                                       LOG_DARKGRAY "] " LOG_END,      item->key);
+               }
+
+               memset(title_buf, 0, 256);
+               if (item->title) {
+                       snprintf(title_buf, MAX_TITLE, "%s", item->title);
+
+                       if (strlen(item->title) >= MAX_TITLE) {
+                               title_buf[MAX_TITLE - 2] = '.';
+                               title_buf[MAX_TITLE - 1] = '.';
+                       }
+               }
+
+               if (item->data) {
+                       msg("%s " LOG_LIGHTBLUE "(%s)" LOG_END,
+                                       title_buf, item->data);
+               } else if (!g_strcmp0(item->key, "*")) {
+                       /* none */
+               } else {
+                       msg("%s", title_buf);
+               }
+
+               if (item->sub_menu)
+                       msg("\e[1A\e[%dC >", (int)POS_MORE);
+
+               i++;
+       }
+
+       show_pid();
+
+       _show_reserved_menu();
+
+       msg(HR_DOUBLE);
+
+       _show_prompt();
+}
+
+static void _show_item_data_input_msg(struct menu_data *item)
+{
+       msg("");
+       msg(HR_DOUBLE);
+       msg(" Input [%s] data ", item->title);
+       msg(HR_SINGLE);
+       msg(" current = [%s]", item->data);
+       msgn(" new >> ");
+}
+
+static void _move_menu(MManager *mm, struct menu_data menu[], char *key)
+{
+       struct menu_data *item;
+       int i = 0;
+
+       if (!mm->menu)
+               return;
+
+       if (!g_strcmp0(DEFAULT_MENU_PREV, key)) {
+               if (g_queue_get_length(mm->stack) > 0) {
+                       mm->menu = g_queue_pop_tail(mm->stack);
+                       g_queue_pop_tail(mm->title_stack);
+               }
+
+               _show_menu(mm, mm->menu);
+               mm->buf = key_buffer;
+
+               return;
+       } else if (!g_strcmp0(DEFAULT_MENU_MENU, key)) {
+               _show_menu(mm, mm->menu);
+               return;
+       } else if (!g_strcmp0(DEFAULT_MENU_QUIT, key)) {
+               g_main_loop_quit(mm->mainloop);
+               return;
+       } else if (!g_strcmp0(DEFAULT_MENU_NONE, key)) {
+               _show_prompt();
+               return;
+       }
+
+       while (1) {
+               int ret = RET_SUCCESS;
+               item = menu + i;
+               if (item->key == NULL)
+                       break;
+
+               if (!g_strcmp0(item->key, key)) {
+                       if (item->callback) {
+                               ret = item->callback(mm, item);
+                               _show_prompt();
+                       }
+
+                       if (RET_SUCCESS == ret) {
+                               if (item->sub_menu) {
+                                       g_queue_push_tail(mm->stack, mm->menu);
+                                       g_queue_push_tail(mm->title_stack, (gpointer *)item->title);
+
+                                       mm->menu = item->sub_menu;
+                                       _show_menu(mm, mm->menu);
+                                       mm->buf = key_buffer;
+                               }
+
+                               if (item->data) {
+                                       _show_item_data_input_msg(item);
+                                       mm->buf = item->data;
+                               }
+                       }
+
+                       return;
+               }
+
+               i++;
+       }
+
+       _show_prompt();
+}
+
+MManager *menu_manager_new(struct menu_data items[], GMainLoop *mainloop)
+{
+       MManager *mm;
+
+       mm = calloc(sizeof(struct menu_manager), 1);
+       if (!mm)
+               return NULL;
+
+       mm->stack = g_queue_new();
+       mm->title_stack = g_queue_new();
+       mm->menu = items;
+       mm->mainloop = mainloop;
+
+       return mm;
+}
+
+int menu_manager_run(MManager *mm)
+{
+       _show_menu(mm, mm->menu);
+
+       mm->buf = key_buffer;
+
+       return 0;
+}
+
+int menu_manager_set_user_data(MManager *mm, void *user_data)
+{
+       if (!mm)
+               return -1;
+
+       mm->user_data = user_data;
+
+       return 0;
+}
+
+void *menu_manager_ref_user_data(MManager *mm)
+{
+       if (!mm)
+               return NULL;
+
+       return mm->user_data;
+}
+
+gboolean on_menu_manager_keyboard(GIOChannel *src, GIOCondition con,
+               gpointer data)
+{
+       MManager *mm = data;
+       char local_buf[MENU_DATA_SIZE + 1] = { 0, };
+
+       if (fgets(local_buf, MENU_DATA_SIZE, stdin) == NULL)
+               return TRUE;
+
+       if (strlen(local_buf) > 0) {
+               if (local_buf[strlen(local_buf) - 1] == '\n')
+                       local_buf[strlen(local_buf) - 1] = '\0';
+       }
+
+       if (mm->buf == key_buffer) {
+               if (strlen(local_buf) < 1) {
+                       _show_prompt();
+                       return TRUE;
+               }
+
+               _move_menu(mm, mm->menu, local_buf);
+       } else {
+               if (mm->buf) {
+                       memset(mm->buf, 0, MENU_DATA_SIZE);
+                       memcpy(mm->buf, local_buf, MENU_DATA_SIZE);
+                       _show_input_ok();
+               }
+               mm->buf = key_buffer;
+               _move_menu(mm, mm->menu, (char *)DEFAULT_MENU_MENU);
+       }
+
+       return TRUE;
+}
+
+pid_t get_tid()
+{
+       return syscall(__NR_gettid);
+}
+
+void hide_pid()
+{
+       flag_pid_display = 0;
+}
+
+void show_pid()
+{
+       flag_pid_display = 1;
+}
+
+int is_pid_show()
+{
+       return flag_pid_display;
+}
+
+static void _hex_dump(const char *pad, int size, const void *data)
+{
+       char buf[255] = {0, };
+       char hex[4] = {0, };
+       int i;
+       unsigned char *p;
+
+       if (size <= 0) {
+               msg("%sno data", pad);
+               return;
+       }
+       p = (unsigned char *)data;
+
+       snprintf(buf, 255, "%s%04X: ", pad, 0);
+       for (i = 0; i < size; i++) {
+               snprintf(hex, 4, "%02X ", p[i]);
+               strncat(buf, hex, 255 - strlen(buf) - 1);
+
+               if ((i + 1) % 8 == 0) {
+                       if ((i + 1) % 16 == 0) {
+                               msg("%s", buf);
+                               memset(buf, 0, 255);
+                               snprintf(buf, 255, "%s%04X: ", pad, i + 1);
+                       } else {
+                               strncat(buf, TAB_SPACE, 255 - strlen(buf) - 1);
+                       }
+               }
+       }
+
+       msg("%s", buf);
+}
+
+void menu_print_dump(int data_len, void *data)
+{
+       if (!data)
+               return;
+
+       msg("");
+       msg("  \tlen=%d", data_len);
+       _hex_dump("        ", data_len, data);
+
+       msg("");
+}
+
diff --git a/tool/wifi_mgr_menu.h b/tool/wifi_mgr_menu.h
new file mode 100755 (executable)
index 0000000..b1f6dd2
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_MENU_H__
+#define __WIFI_MGR_MENU_H__
+
+__BEGIN_DECLS
+
+#define LOG_END                        "\e[0m"
+
+#define LOG_BLACK                      "\e[0;30m"
+#define LOG_RED                                "\e[0;31m"
+#define LOG_GREEN                      "\e[0;32m"
+#define LOG_BROWN                      "\e[0;33m"
+#define LOG_BLUE                       "\e[0;34m"
+#define LOG_MAGENTA                    "\e[0;35m"
+#define LOG_CYAN                       "\e[0;36m"
+#define LOG_LIGHTGRAY          "\e[0;37m"
+
+#define LOG_DARKGRAY           "\e[1;30m"
+#define LOG_LIGHTRED           "\e[1;31m"
+#define LOG_LIGHTGREEN         "\e[1;32m"
+#define LOG_YELLOW                     "\e[1;33m"
+#define LOG_LIGHTBLUE          "\e[1;34m"
+#define LOG_LIGHTMAGENTA       "\e[1;35m"
+#define LOG_LIGHTCYAN          "\e[1;36m"
+#define LOG_WHITE                      "\e[1;37m"
+
+
+#define msg(fmt,args...)       do { fprintf(stdout, fmt "\n", ##args); \
+               fflush(stdout); } while (0)
+#define msgn(fmt,args...)      do { fprintf(stdout, fmt, ##args); \
+               fflush(stdout); } while (0)
+
+/* Bold (green) */
+#define msgb(fmt,args...)  do { fprintf(stdout, LOG_LIGHTGREEN fmt \
+               LOG_END "\n", ##args); fflush(stdout); } while (0)
+
+/* Property message */
+#define msgp(fmt,args...) do { fprintf(stdout, LOG_LIGHTMAGENTA fmt \
+               LOG_END "\n", ##args); fflush(stdout); } while (0)
+
+#define msgt(n,fmt,args...) do { fprintf(stdout, "\e[%dC" fmt "\n", \
+               3 + ((n) * 2), ##args); fflush(stdout); } while (0)
+
+#define pmsg(fmt,args...) do { \
+       if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
+       fprintf(stdout, fmt "\n", ##args); fflush(stdout); } while (0)
+
+#define pmsgb(fmt,args...) do { \
+       if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
+       fprintf(stdout, LOG_LIGHTGREEN fmt \
+                       LOG_END "\n", ##args); fflush(stdout); } while (0)
+
+#define pmsgt(n,fmt,args...) do { \
+       if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
+       fprintf(stdout, "\e[%dC" fmt "\n", \
+                       3 + ((n) * 2), ##args); fflush(stdout); } while (0)
+
+#define MENU_DATA_SIZE 255
+
+
+
+/*
+ * Horizontal Line - width: 65
+ *                                     .12345678901234567890123456789012345678901234567890.
+ */
+#define HR_SINGLE      "----------------------------------------" \
+                                       "-------------------------"
+#define HR_DOUBLE      "========================================" \
+                                       "========================="
+#define HR_SINGLE2     " ---------------------------------------" \
+                                       "------------------------ "
+
+#define MAX_WIDTH      strlen (HR_SINGLE)
+#define MAX_TITLE      ((MAX_WIDTH) - 10)
+#define POS_MORE       ((MAX_WIDTH) - 3)
+#define RET_SUCCESS 0
+#define RET_FAILURE -1
+
+typedef struct menu_manager MManager;
+
+struct menu_data {
+       const char *key;
+       const char *title;
+       struct menu_data *sub_menu;
+       int (*callback)(MManager *mm, struct menu_data *menu);
+       char *data;
+};
+
+MManager* menu_manager_new(struct menu_data items[], GMainLoop *mainloop);
+int       menu_manager_run(MManager *mm);
+int       menu_manager_set_user_data(MManager *mm, void *user_data);
+void*     menu_manager_ref_user_data(MManager *mm);
+
+gboolean  on_menu_manager_keyboard(GIOChannel *src, GIOCondition con,
+               gpointer data);
+
+pid_t     get_tid ();
+void      hide_pid ();
+void      show_pid ();
+int       is_pid_show ();
+void      menu_print_dump(int data_len, void *data);
+
+__END_DECLS
+
+#endif /* __WIFI_MGR_MENU_H__ */
diff --git a/tool/wifi_mgr_public.c b/tool/wifi_mgr_public.c
new file mode 100755 (executable)
index 0000000..abee5ee
--- /dev/null
@@ -0,0 +1,332 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "wifi_mgr_tool.h"
+#include "wifi_mgr_menu.h"
+#include "wifi_mgr_public.h"
+
+extern wifi_manager_h g_wifi_h;
+extern wifi_manager_h g_wifi2_h;
+extern wifi_manager_device_state_e g_device_state;
+
+static char g_ssid[MENU_DATA_SIZE] = "dnet2";
+
+extern struct menu_data menu_public_scan[];
+extern struct menu_data menu_public_connect[];
+extern struct menu_data menu_public_get[];
+extern struct menu_data menu_public_set[];
+extern struct menu_data menu_public_config[];
+extern struct menu_data menu_public_tdls[];
+extern struct menu_data menu_public_vsie[];
+extern struct menu_data menu_public_ipconflict[];
+
+static void __test_public_activated_cb(wifi_manager_error_e result, void* user_data)
+{
+       msg(HR_SINGLE);
+
+       if (result == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to activate Wi-Fi" LOG_END);
+       else
+               msg("Failed to activate Wi-Fi error " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(result));
+
+       msg(HR_SINGLE);
+}
+
+static void __test_public_deactivated_cb(wifi_manager_error_e result, void* user_data)
+{
+       msg(HR_SINGLE);
+
+       if (result == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to deactivate Wi-Fi" LOG_END);
+       else
+               msg("Failed to deactivate Wi-Fi error " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(result));
+
+       msg(HR_SINGLE);
+}
+
+static void __test_public_disconnected_cb(wifi_manager_error_e result, void* user_data)
+{
+       msg(HR_SINGLE);
+
+       if (result == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to disconnect Wi-Fi" LOG_END);
+       else
+               msg("Failed to disconnect Wi-Fi error " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(result));
+
+       msg(HR_SINGLE);
+}
+
+static bool __test_public_found_ap_cb(wifi_manager_ap_h ap, void *user_data)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       char *essid = NULL;
+       wifi_manager_connection_state_e state;
+       int rssi = 0;
+       int cb_type = (int)strtol((char *)user_data, NULL, 10);
+
+       ret = wifi_manager_ap_get_essid(ap, &essid);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get essid for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_connection_state(ap, &state);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get connection state for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_rssi(ap, &rssi);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get rssi for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       switch (cb_type) {
+       case 0: /* scan */
+               msg("AP name " LOG_CYAN "[%s]" LOG_END ", State [%s], Rssi [%d]", essid,
+                       test_wifi_mgr_conn_state_to_string(state), rssi);
+               break;
+       case 1: /* disconnect */
+               if (test_wifi_mgr_compare_string(essid, g_ssid)) {
+                       msg("AP name " LOG_CYAN "[%s]" LOG_END ", State [%s], Rssi [%d]", essid,
+                               test_wifi_mgr_conn_state_to_string(state), rssi);
+
+                       ret = wifi_manager_disconnect(g_wifi_h, ap, __test_public_disconnected_cb, NULL);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("Succeeded to request Wi-Fi disconnection");
+                       else
+                               msg("Failed to request Wi-Fi disconnection " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+               }
+               break;
+       case 2: /* forget */
+               if (test_wifi_mgr_compare_string(essid, g_ssid)) {
+                       msg("AP name " LOG_CYAN "[%s]" LOG_END ", State [%s], Rssi [%d]", essid,
+                               test_wifi_mgr_conn_state_to_string(state), rssi);
+
+                       ret = wifi_manager_forget_ap(g_wifi_h, ap);
+
+                       msg(HR_SINGLE);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg(LOG_GREEN "Succeeded to forget Wi-Fi" LOG_END);
+                       else
+                               msg("Failed to forget Wi-Fi " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       msg(HR_SINGLE);
+               }
+               break;
+       default:
+               break;
+       }
+
+       FREE(essid);
+       return TRUE;
+}
+
+static int _test_public_activate(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       ret = wifi_manager_activate(g_wifi_h, __test_public_activated_cb, NULL);
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to request activation Wi-Fi device");
+       else
+               msg("Failed to request activation Wi-Fi device " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       return ret;
+}
+
+static int _test_public_deactivate(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       ret = wifi_manager_deactivate(g_wifi_h, __test_public_deactivated_cb, NULL);
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to request deactivation Wi-Fi device");
+       else
+               msg("Failed to request deactivation Wi-Fi device " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       return ret;
+}
+
+static int _test_public_is_activated(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       bool state = FALSE;
+
+       ret = wifi_manager_is_activated(g_wifi_h, &state);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to get Wi-Fi device state " LOG_CYAN "[%s]" LOG_END,
+                       (state) ? "TRUE" : "FALSE");
+       else
+               msg("Failed to get Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_foreach_found_ap(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_foreach_found_ap(g_wifi_h, __test_public_found_ap_cb, "0");
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Get AP list finished" LOG_END);
+       else
+               msg("Failed to get AP list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_get_connected_ap(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_ap_h ap_h = NULL;
+       char *essid = NULL;
+
+       ret = wifi_manager_get_connected_ap(g_wifi_h, &ap_h);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE) {
+               msg(LOG_GREEN "Succeeded to get connected AP" LOG_END);
+       } else {
+               msg("Failed to get connected AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               return ret;
+       }
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_ap_get_essid(ap_h, &essid);
+       if (ret == WIFI_MANAGER_ERROR_NONE) {
+               msg("Succeeded to get essid for AP " LOG_CYAN "[%s]" LOG_END, essid);
+       } else {
+               msg("Failed to get essid for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+       }
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_disconnect_ap(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_foreach_found_ap(g_wifi_h, __test_public_found_ap_cb, "1");
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Get AP list finished" LOG_END);
+       else
+               msg("Failed to get AP list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_forget_ap(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_foreach_found_ap(g_wifi_h, __test_public_found_ap_cb, "2");
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Get AP list finished" LOG_END);
+       else
+               msg("Failed to get AP list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+struct menu_data menu_public[] = {
+       { "0", LOG_LIGHTGREEN "[SSID]" LOG_END, NULL, NULL, g_ssid},
+       { "1", LOG_LIGHTBLUE "[Activate]" LOG_END, NULL, _test_public_activate, NULL},
+       { "2", LOG_LIGHTMAGENTA "[Deactivate]" LOG_END, NULL, _test_public_deactivate, NULL},
+       { "3", "[Is Wi-Fi activated?]", NULL, _test_public_is_activated, NULL},
+       { "4", "[Scan]", menu_public_scan, NULL, NULL},
+       { "5", "[Get AP list]", NULL, _test_public_foreach_found_ap, NULL},
+       { "6", LOG_LIGHTBLUE "[Connect]" LOG_END, menu_public_connect, NULL, NULL},
+       { "7", "[Get connected AP]", NULL, _test_public_get_connected_ap, NULL},
+       { "8", LOG_LIGHTMAGENTA "[Disconnect]" LOG_END, NULL, _test_public_disconnect_ap, NULL},
+       { "9", LOG_LIGHTMAGENTA "[Forget]" LOG_END, NULL, _test_public_forget_ap, NULL},
+       { "g", LOG_LIGHTBLUE "[Get]" LOG_END, menu_public_get, NULL, NULL},
+       { "s", LOG_LIGHTBLUE "[Set]" LOG_END, menu_public_set, NULL, NULL},
+       { "c", "[Config]", menu_public_config, NULL, NULL},
+       { "t", "[TDLS]", menu_public_tdls, NULL, NULL},
+       { "v", "[VSIE]", menu_public_vsie, NULL, NULL},
+       { "i", "[IP Conflict]", menu_public_ipconflict, NULL, NULL},
+       { NULL, NULL, },
+};
diff --git a/tool/wifi_mgr_public.h b/tool/wifi_mgr_public.h
new file mode 100755 (executable)
index 0000000..34804e7
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_PUBLIC_H__
+#define __WIFI_MGR_PUBLIC_H__
+
+#endif /** __WIFI_MGR_PUBLIC_H__ */
diff --git a/tool/wifi_mgr_public_config.c b/tool/wifi_mgr_public_config.c
new file mode 100755 (executable)
index 0000000..da6abcb
--- /dev/null
@@ -0,0 +1,425 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "wifi_mgr_tool.h"
+#include "wifi_mgr_menu.h"
+#include "wifi_mgr_public_config.h"
+
+extern wifi_manager_h g_wifi_h;
+extern wifi_manager_h g_wifi2_h;
+
+static char g_name[MENU_DATA_SIZE] = "dnet2";
+static char g_passphrase[MENU_DATA_SIZE] = "passphrase";
+static char g_security[MENU_DATA_SIZE] = "0";
+static char g_proxy[MENU_DATA_SIZE] = "x";
+static char g_hidden[MENU_DATA_SIZE] = "x";
+static char g_eap_identity[MENU_DATA_SIZE] = "x";
+static char g_eap_anonymous_identity[MENU_DATA_SIZE] = "x";
+static char g_eap_type[MENU_DATA_SIZE] = "x";
+static char g_eap_auth_type[MENU_DATA_SIZE] = "x";
+static char g_eap_ca_cert_file[MENU_DATA_SIZE] = "x";
+static char g_eap_private_key[MENU_DATA_SIZE] = "x";
+static char g_eap_client_cert_file[MENU_DATA_SIZE] = "x";
+static char g_eap_subject_match[MENU_DATA_SIZE] = "x";
+
+static bool __test_public_config_list_cb(const wifi_manager_config_h config, void *user_data)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       char *name = NULL;
+       wifi_manager_security_type_e security_type = WIFI_MANAGER_SECURITY_TYPE_NONE;
+       wifi_manager_eap_type_e eap_type = WIFI_MANAGER_EAP_TYPE_PEAP;
+       wifi_manager_eap_auth_type_e eap_auth_type = WIFI_MANAGER_EAP_AUTH_TYPE_NONE;
+       int cb_type = (int)strtol((char *)user_data, NULL, 10);
+       wifi_manager_security_type_e security = (int)strtol((char *)g_security, NULL, 10);
+
+       ret = wifi_manager_config_get_name(config, &name);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get name for config " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               return FALSE;
+       }
+
+       ret = wifi_manager_config_get_security_type(config, &security_type);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get security type for config " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(name);
+               return FALSE;
+       }
+
+       if (security_type == WIFI_MANAGER_SECURITY_TYPE_EAP) {
+               ret = wifi_manager_config_get_eap_type(config, &eap_type);
+               if (ret != WIFI_MANAGER_ERROR_NONE) {
+                       msg("Failed to get EAP type for config " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+                       FREE(name);
+                       return FALSE;
+               }
+
+               ret = wifi_manager_config_get_eap_auth_type(config, &eap_auth_type);
+               if (ret != WIFI_MANAGER_ERROR_NONE) {
+                       msg("Failed to get EAP auth type for config " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+                       FREE(name);
+                       return FALSE;
+               }
+       }
+
+       switch (cb_type) {
+       case 0:
+               msgn("Name " LOG_CYAN "[%s]" LOG_END ", Security type [%s]", name,
+                       test_wifi_mgr_sec_type_to_string(security_type));
+
+               if (security_type == WIFI_MANAGER_SECURITY_TYPE_EAP)
+                       msg(", EAP type [%s], EAP auth type [%s]",
+                               test_wifi_mgr_eap_type_to_string(eap_type),
+                               test_wifi_mgr_eap_auth_type_to_string(eap_auth_type));
+               else
+                       msg("");
+               break;
+       case 1:
+               if (test_wifi_mgr_compare_string(name, g_name) &&
+                       security_type == security) {
+                       msg("Name " LOG_CYAN "[%s]" LOG_END ", Security type [%s]", name,
+                               test_wifi_mgr_sec_type_to_string(security_type));
+
+                       ret = wifi_manager_config_remove(g_wifi_h, config);
+
+                       msg(HR_SINGLE);
+
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg(LOG_GREEN "Succeeded to remove config" LOG_END);
+                       else
+                               msg("Failed to remove config " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+               }
+               break;
+       default:
+               break;
+       }
+
+       FREE(name);
+       return TRUE;
+}
+
+static int _test_public_config_load(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_config_foreach_configuration(g_wifi_h,
+                       __test_public_config_list_cb, "0");
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Load config list finished" LOG_END);
+       else
+               msg("Fail to load config list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_config_save(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_config_h config = NULL;
+       wifi_manager_security_type_e security_type = (int)strtol(g_security, NULL, 10);
+       wifi_manager_eap_type_e eap_type = WIFI_MANAGER_EAP_TYPE_PEAP;
+       wifi_manager_eap_auth_type_e eap_auth_type = WIFI_MANAGER_EAP_AUTH_TYPE_NONE;
+
+       if (security_type > WIFI_MANAGER_SECURITY_TYPE_EAP) {
+               msg("Invalid parameter " LOG_RED "[security type]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_config_create(g_wifi_h, g_name, g_passphrase, security_type, &config);
+       if (ret == WIFI_MANAGER_ERROR_NONE) {
+               msg("Succeeded to create config " LOG_CYAN "[%s:%s]" LOG_END,
+                       g_name, test_wifi_mgr_sec_type_to_string(security_type));
+       } else {
+               msg("Failed to create config " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               msg(HR_SINGLE);
+               return ret;
+       }
+
+       /* Proxy */
+       switch (g_proxy[0]) {
+       case 'x': /* Skip */
+               ret = WIFI_MANAGER_ERROR_NONE;
+               break;
+       default:
+               ret = wifi_manager_config_set_proxy_address(config, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, g_proxy);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Succeeded to set proxy address " LOG_CYAN "[%s]" LOG_END, g_proxy);
+               else
+                       msg("Failed to set proxy address " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+               break;
+       }
+
+       /* Hidden property */
+       switch (g_hidden[0]) {
+       case 'x': /* Skip */
+               ret = WIFI_MANAGER_ERROR_NONE;
+               break;
+       case '0':
+       case '1':
+               ret = wifi_manager_config_set_hidden_ap_property(config,
+                               (g_hidden[0] == '0') ? FALSE : TRUE);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Succeeded to set hidden property " LOG_CYAN "[%s]" LOG_END,
+                               (g_hidden[0] == '0') ? "FALSE" : "TRUE");
+               else
+                       msg("Failed to set hidden property " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+               break;
+       default:
+               msg("Invalid parameter " LOG_RED "[hidden property]" LOG_END);
+               break;
+       }
+
+       /* EAP */
+       if (security_type == WIFI_MANAGER_SECURITY_TYPE_EAP) {
+               /* EAP identity */
+               switch (g_eap_identity[0]) {
+               case 'x': /* Skip */
+                       ret = WIFI_MANAGER_ERROR_NONE;
+                       break;
+               default:
+                       ret = wifi_manager_config_set_eap_identity(config, g_eap_identity);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("Succeeded to set EAP identity " LOG_CYAN "[%s]" LOG_END, g_eap_identity);
+                       else
+                               msg("Failed to set EAP identity " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       break;
+               }
+
+               /* EAP anonymous identity */
+               switch (g_eap_anonymous_identity[0]) {
+               case 'x': /* Skip */
+                       ret = WIFI_MANAGER_ERROR_NONE;
+                       break;
+               default:
+                       ret = wifi_manager_config_set_eap_anonymous_identity(config, g_eap_anonymous_identity);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("Succeeded to set EAP anonymous identity " LOG_CYAN "[%s]" LOG_END,
+                                       g_eap_anonymous_identity);
+                       else
+                               msg("Failed to set EAP anonymous identity " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       break;
+               }
+
+               /* EAP type */
+               switch (g_eap_type[0]) {
+               case 'x': /* Skip */
+                       ret = WIFI_MANAGER_ERROR_NONE;
+                       break;
+               case '0':
+               case '1':
+               case '2':
+               case '3':
+               case '4':
+                       eap_type = (int)strtol(g_eap_type, NULL, 10);
+                       ret = wifi_manager_config_set_eap_type(config, eap_type);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("Succeeded to set EAP type " LOG_CYAN "[%s]" LOG_END,
+                                       test_wifi_mgr_eap_type_to_string(eap_type));
+                       else
+                               msg("Failed to set EAP type " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       break;
+               default:
+                       break;
+               }
+
+               /* EAP auth type */
+               switch (g_eap_auth_type[0]) {
+               case 'x': /* Skip */
+                       ret = WIFI_MANAGER_ERROR_NONE;
+                       break;
+               case '0':
+               case '1':
+               case '2':
+               case '3':
+               case '4':
+               case '5':
+                       eap_auth_type = (int)strtol(g_eap_auth_type, NULL, 10);
+                       ret = wifi_manager_config_set_eap_auth_type(config, eap_auth_type);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("Succeeded to set EAP auth type " LOG_CYAN "[%s]" LOG_END,
+                                       test_wifi_mgr_eap_auth_type_to_string(eap_auth_type));
+                       else
+                               msg("Failed to set EAP auth type " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       break;
+               default:
+                       break;
+               }
+
+               /* EAP ca cert file */
+               switch (g_eap_ca_cert_file[0]) {
+               case 'x': /* Skip */
+                       ret = WIFI_MANAGER_ERROR_NONE;
+                       break;
+               default:
+                       ret = wifi_manager_config_set_eap_ca_cert_file(config, g_eap_ca_cert_file);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("Succeeded to set EAP ca cert file " LOG_CYAN "[%s]" LOG_END,
+                                       g_eap_ca_cert_file);
+                       else
+                               msg("Failed to set EAP ca cert file " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       break;
+               }
+
+               /* EAP client cert file */
+               switch (g_eap_private_key[0]) {
+               case 'x': /* Skip */
+                       ret = WIFI_MANAGER_ERROR_NONE;
+                       break;
+               default:
+                       {
+                               switch (g_eap_client_cert_file[0]) {
+                               case 'x': /* Skip */
+                                       ret = WIFI_MANAGER_ERROR_NONE;
+                                       break;
+                               default:
+                                       ret = wifi_manager_config_set_eap_client_cert_file(config,
+                                                       g_eap_private_key, g_eap_client_cert_file);
+                                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                                               msg("Succeeded to set EAP client cert file " LOG_CYAN "[%s:%s]" LOG_END,
+                                                       g_eap_private_key, g_eap_client_cert_file);
+                                       else
+                                               msg("Failed to set EAP client cert file " LOG_RED "[%s]" LOG_END,
+                                                       test_wifi_mgr_convert_error_to_string(ret));
+                                       break;
+                               }
+                       }
+               }
+
+               /* EAP subject match */
+               switch (g_eap_subject_match[0]) {
+               case 'x': /* Skip */
+                       ret = WIFI_MANAGER_ERROR_NONE;
+                       break;
+               default:
+                       ret = wifi_manager_config_set_eap_subject_match(config, g_eap_subject_match);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("Succeeded to set EAP subject match " LOG_CYAN "[%s]" LOG_END, g_eap_subject_match);
+                       else
+                               msg("Failed to set EAP subject match " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       break;
+               }
+       }
+
+       ret = wifi_manager_config_save(g_wifi_h, config);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to save config" LOG_END);
+       else
+               msg("Fail to save config " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_config_destroy(config);
+       if (ret != WIFI_MANAGER_ERROR_NONE)
+               msg("Fail to destroy config " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       return ret;
+}
+
+static int _test_public_config_remove(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_config_foreach_configuration(g_wifi_h,
+                       __test_public_config_list_cb, "1");
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Load config list finished" LOG_END);
+       else
+               msg("Fail to load config list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+struct menu_data menu_public_config_save_eap[] = {
+       { "1", "[Identity] (x.Skip)", NULL, NULL, g_eap_identity},
+       { "2", "[Anonymous Identity] (x.Skip)", NULL, NULL, g_eap_anonymous_identity},
+       { "3", "[Type] (0.PEAP/1.TLS/2.TTLS/3.SIM/4.AKA/x.Skip)", NULL, NULL, g_eap_type},
+       { "4", "[Auth Type] (0.None/1.PAP/2.MSCHAP/3.MSCHAPv2/4.GTC/5.MD5/x.Skip)", NULL, NULL, g_eap_auth_type},
+       { "5", "[Ca cert file] (x.Skip)", NULL, NULL, g_eap_ca_cert_file},
+       { "6", "[Private Key] (x.Skip)", NULL, NULL, g_eap_private_key},
+       { "7", "[Client cert file] (x.Skip)", NULL, NULL, g_eap_client_cert_file},
+       { "8", "[Subject match] (x.Skip)", NULL, NULL, g_eap_subject_match},
+       { NULL, NULL, },
+};
+
+struct menu_data menu_public_config_save[] = {
+       { "1", "[Name]", NULL, NULL, g_name},
+       { "2", "[Passphrase]", NULL, NULL, g_passphrase},
+       { "3", "[Security type] (0.None/1.WEP/2.WPA/3.WPA2/4.EAP)", NULL, NULL, g_security},
+       { "4", "[Proxy] server:port (x.Skip)", NULL, NULL, g_proxy},
+       { "5", "[Hidden] (0.False/1.True/x.Skip)", NULL, NULL, g_hidden},
+       { "6", "[EAP] ", menu_public_config_save_eap, NULL, NULL},
+       { "s", LOG_LIGHTBLUE "[Save]" LOG_END, NULL, _test_public_config_save, NULL},
+       { NULL, NULL, },
+};
+
+struct menu_data menu_public_config_remove[] = {
+       { "1", "[Name]", NULL, NULL, g_name},
+       { "2", "[Security type] (0.None/1.WEP/2.WPA/3.WPA2/4.EAP)", NULL, NULL, g_security},
+       { "r", LOG_LIGHTMAGENTA "[Remove]" LOG_END, NULL, _test_public_config_remove, NULL},
+       { NULL, NULL, },
+};
+
+struct menu_data menu_public_config[] = {
+       { "1", LOG_LIGHTBLUE "[Load]" LOG_END, NULL, _test_public_config_load, NULL},
+       { "2", LOG_LIGHTBLUE "[Save]" LOG_END, menu_public_config_save, NULL, NULL},
+       { "3", LOG_LIGHTMAGENTA "[Remove]" LOG_END, menu_public_config_remove, NULL, NULL},
+       { NULL, NULL, },
+};
diff --git a/tool/wifi_mgr_public_config.h b/tool/wifi_mgr_public_config.h
new file mode 100755 (executable)
index 0000000..cb15ab0
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_PUBLIC_CONFIG_H__
+#define __WIFI_MGR_PUBLIC_CONFIG_H__
+
+#endif /** __WIFI_MGR_PUBLIC_CONFIG_H__ */
diff --git a/tool/wifi_mgr_public_connect.c b/tool/wifi_mgr_public_connect.c
new file mode 100755 (executable)
index 0000000..78e4d06
--- /dev/null
@@ -0,0 +1,742 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "wifi_mgr_tool.h"
+#include "wifi_mgr_menu.h"
+#include "wifi_mgr_public_connect.h"
+
+extern wifi_manager_h g_wifi_h;
+extern wifi_manager_h g_wifi2_h;
+extern wifi_manager_device_state_e g_device_state;
+
+static char g_ssid[MENU_DATA_SIZE] = "dnet2";
+static char g_passphrase[MENU_DATA_SIZE] = "passphrase";
+static char g_security[MENU_DATA_SIZE] = "0";
+static char g_username[MENU_DATA_SIZE] = "username";
+static char g_eap_type[MENU_DATA_SIZE] = "0";
+static char g_certificate[MENU_DATA_SIZE] = "certificate";
+static char g_auth_type[MENU_DATA_SIZE] = "0";
+static char g_wps_pin[MENU_DATA_SIZE] = "1234";
+
+static void __test_public_connected_cb(wifi_manager_error_e result, void* user_data)
+{
+       msg(HR_SINGLE);
+
+       if (result == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to connect Wi-Fi" LOG_END);
+       else
+               msg("Failed to connect Wi-Fi error " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(result));
+
+       msg(HR_SINGLE);
+}
+
+static bool __test_public_connect_found_ap_cb(wifi_manager_ap_h ap, void *user_data)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       char *essid = NULL;
+       wifi_manager_connection_state_e state = WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED;
+       int rssi = 0;
+
+       ret = wifi_manager_ap_get_essid(ap, &essid);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get essid for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_connection_state(ap, &state);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get connection state for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_rssi(ap, &rssi);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get rssi for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       if (test_wifi_mgr_compare_string(essid, g_ssid)) {
+               bool required = FALSE;
+
+               ret = wifi_manager_ap_is_passphrase_required(ap, &required);
+               if (ret == WIFI_MANAGER_ERROR_NONE) {
+                       msg("Passphrase required " LOG_GREEN "[%s]" LOG_END, required ? "TRUE" : "FALSE");
+               } else {
+                       msg("Failed to get passphrase required " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+                       FREE(essid);
+                       return FALSE;
+               }
+
+               if (required) {
+                       ret = wifi_manager_ap_set_passphrase(ap, g_passphrase);
+                       if (ret == WIFI_MANAGER_ERROR_NONE) {
+                               msg("Succeeded to set passphrase");
+                       } else {
+                               msg("Failed to set passphrase " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                               FREE(essid);
+                               return FALSE;
+                       }
+               }
+
+               msg("AP name " LOG_CYAN "[%s]" LOG_END ", State [%s], Rssi [%d]", essid,
+                       test_wifi_mgr_conn_state_to_string(state), rssi);
+
+               ret = wifi_manager_connect(g_wifi_h, ap, __test_public_connected_cb, NULL);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Succeeded to request Wi-Fi connection");
+               else
+                       msg("Failed to request Wi-Fi connection " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               FREE(essid);
+               return FALSE;
+       }
+
+       FREE(essid);
+       return TRUE;
+}
+
+static bool __test_public_connect_found_specific_ap_cb(wifi_manager_ap_h ap,
+                               void *user_data)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       char *essid = NULL;
+       wifi_manager_security_type_e security = WIFI_MANAGER_SECURITY_TYPE_NONE;
+       wifi_manager_security_type_e type = (int)strtol(g_security, NULL, 10);
+       wifi_manager_connection_state_e state = WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED;
+       int rssi = 0;
+
+       ret = wifi_manager_ap_get_essid(ap, &essid);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get essid for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_security_type(ap, &security);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get security type for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_connection_state(ap, &state);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get connection state for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_rssi(ap, &rssi);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get rssi for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       switch (security) {
+       case WIFI_MANAGER_SECURITY_TYPE_WEP:
+       case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
+       case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
+               ret = wifi_manager_ap_set_passphrase(ap, g_passphrase);
+               if (ret == WIFI_MANAGER_ERROR_NONE) {
+                       msg("Succeeded to set passphrase");
+               } else {
+                       msg("Failed to set passphrase " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+                       FREE(essid);
+                       return FALSE;
+               }
+               break;
+       case WIFI_MANAGER_SECURITY_TYPE_EAP:
+               {
+                       char *username = NULL;
+                       bool is_pass_set = FALSE;
+
+                       ret = wifi_manager_ap_set_eap_passphrase(ap, g_username, g_passphrase);
+                       if (ret == WIFI_MANAGER_ERROR_NONE) {
+                               msg("Succeeded to set EAP passphrase");
+                       } else {
+                               msg("Failed to set EAP passphrase " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                               FREE(essid);
+                               return FALSE;
+                       }
+
+                       ret = wifi_manager_ap_get_eap_passphrase(ap, &username, &is_pass_set);
+                       if (ret == WIFI_MANAGER_ERROR_NONE) {
+                               msg("Succeeded to get EAP passphrase [%s:%s]", username,
+                                       (is_pass_set ? "TRUE" : "FALSE"));
+                               FREE(username);
+                       } else {
+                               msg("Failed to get EAP passphrase " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                               FREE(essid);
+                               return FALSE;
+                       }
+               }
+               break;
+       case WIFI_MANAGER_SECURITY_TYPE_NONE:
+       default:
+               break;
+       }
+
+       msg("AP name " LOG_CYAN "[%s]" LOG_END ", Security [%s], State [%s], Rssi [%d]", essid,
+                       test_wifi_mgr_sec_type_to_string(security),
+                       test_wifi_mgr_conn_state_to_string(state), rssi);
+
+       if (security != type) {
+               FREE(essid);
+               return TRUE;
+       }
+
+       ret = wifi_manager_connect(g_wifi_h, ap, __test_public_connected_cb, NULL);
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to request specific Wi-Fi connection");
+       else
+               msg("Failed to request specific Wi-Fi connection " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       FREE(essid);
+       return FALSE;
+}
+
+static bool __test_public_connect_found_eap_ap_cb(wifi_manager_ap_h ap,
+                               void *user_data)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       char *essid = NULL;
+       wifi_manager_security_type_e security = WIFI_MANAGER_SECURITY_TYPE_NONE;
+       wifi_manager_eap_type_e eap_type = (int)strtol(g_eap_type, NULL, 10);
+       wifi_manager_eap_auth_type_e auth_type = (int)strtol(g_auth_type, NULL, 10);
+       wifi_manager_connection_state_e state = WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED;
+       int rssi = 0;
+       char *username = NULL;
+       bool is_pass_set = FALSE;
+
+       ret = wifi_manager_ap_get_essid(ap, &essid);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get essid for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_connection_state(ap, &state);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get connection state for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_rssi(ap, &rssi);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get rssi for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       if (test_wifi_mgr_compare_string(essid, g_ssid)) {
+               ret = wifi_manager_ap_get_security_type(ap, &security);
+               if (ret != WIFI_MANAGER_ERROR_NONE) {
+                       msg("Failed to get security type for AP " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+                       FREE(essid);
+                       return FALSE;
+               }
+
+               msg("AP name " LOG_CYAN "[%s]" LOG_END ", Security [%s], State [%s], Rssi [%d]", essid,
+                       test_wifi_mgr_sec_type_to_string(security),
+                       test_wifi_mgr_conn_state_to_string(state), rssi);
+
+               if (security != WIFI_MANAGER_SECURITY_TYPE_EAP) {
+                       FREE(essid);
+                       return FALSE;
+               }
+
+               ret = wifi_manager_ap_set_eap_passphrase(ap, g_username, g_passphrase);
+               if (ret == WIFI_MANAGER_ERROR_NONE) {
+                       msg("Succeeded to set EAP passphrase");
+               } else {
+                       msg("Failed to set EAP passphrase " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+                       FREE(essid);
+                       return FALSE;
+               }
+
+               ret = wifi_manager_ap_get_eap_passphrase(ap, &username, &is_pass_set);
+               if (ret == WIFI_MANAGER_ERROR_NONE) {
+                       msg("Succeeded to get EAP passphrase [%s:%s]", username,
+                               (is_pass_set ? "TRUE" : "FALSE"));
+                       FREE(username);
+               } else {
+                       msg("Failed to get EAP passphrase " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+                       FREE(essid);
+                       return FALSE;
+               }
+
+               ret = wifi_manager_ap_set_eap_type(ap, eap_type);
+               if (ret != WIFI_MANAGER_ERROR_NONE) {
+                       msg("Failed to set EAP type " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+                       FREE(essid);
+                       return FALSE;
+               }
+
+               if (eap_type == WIFI_MANAGER_EAP_TYPE_PEAP ||
+                       eap_type == WIFI_MANAGER_EAP_TYPE_TLS ||
+                       eap_type == WIFI_MANAGER_EAP_TYPE_TTLS) {
+                       ret = wifi_manager_ap_set_eap_ca_cert_file(ap, g_certificate);
+                       if (ret != WIFI_MANAGER_ERROR_NONE) {
+                               msg("Failed to set EAP certificate file " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                               FREE(essid);
+                               return FALSE;
+                       }
+
+                       ret = wifi_manager_ap_set_eap_auth_type(ap, auth_type);
+                       if (ret != WIFI_MANAGER_ERROR_NONE) {
+                               msg("Failed to set EAP auth type " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                               FREE(essid);
+                               return FALSE;
+                       }
+               }
+
+               ret = wifi_manager_connect(g_wifi_h, ap, __test_public_connected_cb, NULL);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Succeeded to request EAP Wi-Fi connection");
+               else
+                       msg("Failed to request EAP Wi-Fi connection " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+       }
+
+       FREE(essid);
+       return TRUE;
+}
+
+static bool __test_public_connect_found_wps_cb(wifi_manager_ap_h ap,
+                               void *user_data)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       char *essid = NULL;
+       wifi_manager_connection_state_e state = WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED;
+       int rssi = 0;
+       int wps_type = (int)strtol((char *)user_data, NULL, 10);
+
+       ret = wifi_manager_ap_get_essid(ap, &essid);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get essid for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_connection_state(ap, &state);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get connection state for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_rssi(ap, &rssi);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get rssi for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       if (test_wifi_mgr_compare_string(essid, g_ssid)) {
+               msg("AP name " LOG_CYAN "[%s]" LOG_END ", State [%s], Rssi [%d]", essid,
+                       test_wifi_mgr_conn_state_to_string(state), rssi);
+
+               switch (wps_type) {
+               case 1:
+                       ret = wifi_manager_connect_by_wps_pbc(g_wifi_h, ap,
+                                       __test_public_connected_cb, NULL);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("Succeeded to request WPS PBC Wi-Fi connection");
+                       else
+                               msg("Failed to request WPS PBC Wi-Fi connection " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       break;
+               case 2:
+                       ret = wifi_manager_connect_by_wps_pin(g_wifi_h, ap, g_wps_pin,
+                                       __test_public_connected_cb, NULL);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("Succeeded to request WPS PIN Wi-Fi connection");
+                       else
+                               msg("Failed to request WPS PIN Wi-Fi connection " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       break;
+               default:
+                       break;
+               }
+
+               FREE(essid);
+               return FALSE;
+       }
+
+       FREE(essid);
+       return TRUE;
+}
+
+static int __test_public_foreach_specific_scan(void)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       ret = wifi_manager_foreach_found_specific_ap(g_wifi_h, __test_public_connect_found_specific_ap_cb, NULL);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Get specific AP list finished" LOG_END);
+       else
+               msg("Failed to get specific AP list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       return ret;
+}
+
+static void __test_public_specific_scan_request_cb(wifi_manager_error_e error_code,
+                               void* user_data)
+{
+       msg(HR_SINGLE);
+
+       msg("Specific scan completed , error code " LOG_GREEN "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(error_code));
+
+       msg(HR_SINGLE);
+
+       if (error_code == WIFI_MANAGER_ERROR_NONE)
+               __test_public_foreach_specific_scan();
+
+       msg(HR_SINGLE);
+}
+
+static int _test_public_connect_ap(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_foreach_found_ap(g_wifi_h, __test_public_connect_found_ap_cb, NULL);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Get AP list finished" LOG_END);
+       else
+               msg("Failed to get AP list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_connect_specific_ap(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_security_type_e type = (int)strtol(g_security, NULL, 10);
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       if (type > WIFI_MANAGER_SECURITY_TYPE_EAP) {
+               msg("Invalid parameter " LOG_RED "[security type]" LOG_END);
+               return ret;
+       }
+
+       ret = wifi_manager_scan_specific_ap(g_wifi_h, g_ssid,
+                       __test_public_specific_scan_request_cb, NULL);
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to request specific scan");
+       else
+               msg("Failed to request specific scan " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       return ret;
+}
+
+static int _test_public_connect_hidden_ap(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_security_type_e type = (int)strtol(g_security, NULL, 10);
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       if (type > WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK) {
+               msg("Invalid parameter " LOG_RED "[Security type]" LOG_END);
+               return ret;
+       }
+
+       ret = wifi_manager_connect_hidden_ap(g_wifi_h, g_ssid, type, g_passphrase,
+                       __test_public_connected_cb, NULL);
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to request hidden Wi-Fi connection");
+       else
+               msg("Failed to request hidden Wi-Fi connection " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       return ret;
+}
+
+static int _test_public_connect_eap_ap(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_eap_type_e eap_type = (int)strtol(g_eap_type, NULL, 10);
+       wifi_manager_eap_auth_type_e auth_type = (int)strtol(g_auth_type, NULL, 10);
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       if (eap_type > WIFI_MANAGER_EAP_TYPE_AKA) {
+               msg("Invalid parameter " LOG_RED "[EAP type]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       if (auth_type > WIFI_MANAGER_EAP_AUTH_TYPE_MD5) {
+               msg("Invalid parameter " LOG_RED "[EAP auth type]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_foreach_found_ap(g_wifi_h, __test_public_connect_found_eap_ap_cb, NULL);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Get EAP AP list finished" LOG_END);
+       else
+               msg("Failed to get EAP AP list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_connect_wps_pbc(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_foreach_found_ap(g_wifi_h, __test_public_connect_found_wps_cb, "1");
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Get WPS PBC AP list finished" LOG_END);
+       else
+               msg("Failed to get WPS PBC AP list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_connect_wps_pin(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_foreach_found_ap(g_wifi_h, __test_public_connect_found_wps_cb, "2");
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Get WPS PIN AP list finished" LOG_END);
+       else
+               msg("Failed to get WPS PIN AP list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_connect_wps_pbc_without_ssid(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       ret = wifi_manager_connect_by_wps_pbc_without_ssid(g_wifi_h,
+                       __test_public_connected_cb, NULL);
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to request WPS PBC connection without ssid");
+       else
+               msg("Failed to request WPS PBC connection without ssid " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       return ret;
+}
+
+static int _test_public_connect_wps_pin_without_ssid(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       ret = wifi_manager_connect_by_wps_pin_without_ssid(g_wifi_h, g_wps_pin,
+                       __test_public_connected_cb, NULL);
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to request WPS PIN connection without ssid");
+       else
+               msg("Failed to request WPS PIN connection without ssid " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       return ret;
+}
+
+static int _test_public_connect_wps_cancel(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       ret = wifi_manager_cancel_wps(g_wifi_h);
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to request WPS cancel");
+       else
+               msg("Failed to request WPS cancel " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       return ret;
+}
+
+struct menu_data menu_public_connect_ap[] = {
+       { "1", "[SSID]", NULL, NULL, g_ssid},
+       { "2", "[Passphrase]", NULL, NULL, g_passphrase},
+       { "c", LOG_LIGHTBLUE "[Connect]" LOG_END, NULL, _test_public_connect_ap, NULL},
+       { NULL, NULL, },
+};
+
+struct menu_data menu_public_connect_specific_ap[] = {
+       { "1", "[SSID]", NULL, NULL, g_ssid},
+       { "2", "[Passphrase]", NULL, NULL, g_passphrase},
+       { "3", "[Security] (0.NONE/1.WEP/2.WPA/3.WPA2/4.EAP)", NULL, NULL, g_security},
+       { "4", "[User name] for EAP", NULL, NULL, g_username},
+       { "c", LOG_LIGHTBLUE "[Connect]" LOG_END, NULL, _test_public_connect_specific_ap, NULL},
+       { NULL, NULL, },
+};
+
+struct menu_data menu_public_connect_hidden_ap[] = {
+       { "1", "[SSID]", NULL, NULL, g_ssid},
+       { "2", "[Passphrase]", NULL, NULL, g_passphrase},
+       { "3", "[Security] (0.NONE/1.WEP/2.WPA/3.WPA2)", NULL, NULL, g_security},
+       { "c", LOG_LIGHTBLUE "[Connect]" LOG_END, NULL, _test_public_connect_hidden_ap, NULL},
+       { NULL, NULL, },
+};
+
+struct menu_data menu_public_connect_eap_ap[] = {
+       { "1", "[SSID]", NULL, NULL, g_ssid},
+       { "2", "[Passphrase]", NULL, NULL, g_passphrase},
+       { "3", "[User name]", NULL, NULL, g_username},
+       { "4", "[EAP type] (0.PEAP/1.TLS/2.TTLS/3.SIM/4.AKA)", NULL, NULL, g_eap_type},
+       { "5", "[Certificate file]", NULL, NULL, g_certificate},
+       { "6", "[Auth type] (0.NONE/1.PAP/2.MSCHAP/3.MSCHAPv2/4.GTC/5.MD5)", NULL, NULL, g_auth_type},
+       { "c", LOG_LIGHTBLUE "[Connect]" LOG_END, NULL, _test_public_connect_eap_ap, NULL},
+       { NULL, NULL, },
+};
+
+struct menu_data menu_public_connect_wps[] = {
+       { "1", "[SSID]", NULL, NULL, g_ssid},
+       { "2", "[PIN code]", NULL, NULL, g_wps_pin},
+       { "3", "[PBC]", NULL, _test_public_connect_wps_pbc, NULL},
+       { "4", "[PIN]", NULL, _test_public_connect_wps_pin, NULL},
+       { "5", "[PBC] without ssid", NULL, _test_public_connect_wps_pbc_without_ssid, NULL},
+       { "6", "[PIN] without ssid", NULL, _test_public_connect_wps_pin_without_ssid, NULL},
+       { "7", "[Cancel]", NULL, _test_public_connect_wps_cancel, NULL},
+       { NULL, NULL, },
+};
+
+struct menu_data menu_public_connect[] = {
+       { "1", LOG_LIGHTBLUE "[Connect]" LOG_END, menu_public_connect_ap, NULL, NULL},
+       { "2", "[Specific AP]", menu_public_connect_specific_ap, NULL, NULL},
+       { "3", "[Hidden AP]", menu_public_connect_hidden_ap, NULL, NULL},
+       { "4", "[EAP]", menu_public_connect_eap_ap, NULL, NULL},
+       { "5", "[WPS]", menu_public_connect_wps, NULL, NULL},
+       { NULL, NULL, },
+};
diff --git a/tool/wifi_mgr_public_connect.h b/tool/wifi_mgr_public_connect.h
new file mode 100755 (executable)
index 0000000..d1c456e
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_PUBLIC_CONNECT_H__
+#define __WIFI_MGR_PUBLIC_CONNECT_H__
+
+#endif /** __WIFI_MGR_PUBLIC_CONNECT_H__ */
diff --git a/tool/wifi_mgr_public_get.c b/tool/wifi_mgr_public_get.c
new file mode 100755 (executable)
index 0000000..aa278ce
--- /dev/null
@@ -0,0 +1,523 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "wifi_mgr_tool.h"
+#include "wifi_mgr_menu.h"
+#include "wifi_mgr_public_get.h"
+
+extern wifi_manager_h g_wifi_h;
+extern wifi_manager_h g_wifi2_h;
+
+static char g_ssid[MENU_DATA_SIZE] = "dnet2";
+
+static bool __test_public_ipv6_address_cb(char *ipv6_address, void *user_data)
+{
+       msg("IPv6 address [%s]", ipv6_address);
+       return true;
+}
+
+static bool __test_public_found_ap_cb(wifi_manager_ap_h ap, void *user_data)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       char *essid = NULL;
+       char *str_value = NULL;
+       int i = 0;
+       int int_value = 0;
+       bool bool_value = FALSE;
+       wifi_manager_rssi_level_e rssi_level = WIFI_MANAGER_RSSI_LEVEL_0;
+       wifi_manager_disconnect_reason_e disconnect_reason = WIFI_REASON_UNSPECIFIED;
+       wifi_manager_assoc_status_code_e status_code = WLAN_STATUS_SUCCESS;
+       wifi_manager_connection_state_e conn_state = WIFI_MANAGER_CONNECTION_STATE_FAILURE;
+       wifi_manager_ip_config_type_e ip_type = WIFI_MANAGER_IP_CONFIG_TYPE_NONE;
+       wifi_manager_proxy_type_e proxy_type = WIFI_MANAGER_PROXY_TYPE_DIRECT;
+       wifi_manager_dns_config_type_e dns_type = WIFI_MANAGER_DNS_CONFIG_TYPE_NONE;
+       wifi_manager_security_type_e sec_type = WIFI_MANAGER_SECURITY_TYPE_NONE;
+       wifi_manager_encryption_type_e enc_type = WIFI_MANAGER_ENCRYPTION_TYPE_NONE;
+       wifi_manager_eap_type_e eap_type = WIFI_MANAGER_EAP_TYPE_PEAP;
+       wifi_manager_eap_auth_type_e eap_auth_type = WIFI_MANAGER_EAP_AUTH_TYPE_NONE;
+
+       ret = wifi_manager_ap_get_essid(ap, &essid);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get essid for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               return FALSE;
+       }
+
+       if (test_wifi_mgr_compare_string(essid, g_ssid)) {
+               /* ESSID */
+               msg("ESSID " LOG_CYAN "[%s]" LOG_END, essid);
+               FREE(essid);
+
+               /* BSSID */
+               ret = wifi_manager_ap_get_bssid(ap, &str_value);
+               if (ret == WIFI_MANAGER_ERROR_NONE) {
+                       msg("BSSID [%s]", str_value);
+                       FREE(str_value);
+               } else {
+                       msg("Failed to get bssid for AP " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+               }
+
+               /* RSSI */
+               ret = wifi_manager_ap_get_rssi(ap, &int_value);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("RSSI [%d]", int_value);
+               else
+                       msg("Failed to get rssi for AP " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               /* RSSI level */
+               ret = wifi_manager_ap_get_rssi_level(ap, &rssi_level);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("RSSI level [%d]", rssi_level);
+               else
+                       msg("Failed to get rssi level for AP " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               /* Frequency */
+               ret = wifi_manager_ap_get_frequency(ap, &int_value);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Frequency [%d]", int_value);
+               else
+                       msg("Failed to get frequency for AP " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               /* Max speed */
+               ret = wifi_manager_ap_get_max_speed(ap, &int_value);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Max speed [%d]", int_value);
+               else
+                       msg("Failed to get max speed for AP " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               /* Favorite */
+               ret = wifi_manager_ap_is_favorite(ap, &bool_value);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Favorite [%s]", bool_value ? "TRUE" : "FALSE");
+               else
+                       msg("Failed to get favorite for AP " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               /* Disconnect reason */
+               ret = wifi_manager_ap_get_disconnect_reason(ap, &disconnect_reason);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Disconnect reason [%d]", disconnect_reason);
+               else
+                       msg("Failed to get disconnect reason for AP " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               /* Association status code */
+               ret = wifi_manager_ap_get_assoc_status_code(ap, &status_code);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Association status code [%d]", status_code);
+               else
+                       msg("Failed to get association status code for AP " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               /* Connection state */
+               ret = wifi_manager_ap_get_connection_state(ap, &conn_state);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Connection state [%s]",
+                               test_wifi_mgr_conn_state_to_string(conn_state));
+               else
+                       msg("Failed to get connection state for AP " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               /* Error state */
+               ret = wifi_manager_ap_get_error_state(ap, &int_value);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Error state [%d]", int_value);
+               else
+                       msg("Failed to get error state for AP " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               /* VSIE */
+               ret = wifi_manager_ap_get_vsie(ap, &str_value, &int_value);
+               if (ret == WIFI_MANAGER_ERROR_NONE) {
+                       msg("VSIE len [%d] vendor element [%s]", int_value, str_value);
+                       FREE(str_value);
+               } else {
+                       msg("Failed to get VSIE for AP " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+               }
+
+               for (i = 0; i < 2; ++i) {
+                       /* IP config type */
+                       ret = wifi_manager_ap_get_ip_config_type(ap, i, &ip_type);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("IP config type [%s]",
+                                       test_wifi_mgr_ip_config_type_to_string(ip_type));
+                       else
+                               msg("Failed to get IP config type for AP " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+
+                       /* Error state */
+                       ret = wifi_manager_ap_get_ip_address(ap, i, &str_value);
+                       if (ret == WIFI_MANAGER_ERROR_NONE) {
+                               msg("IP address [%s]", str_value);
+                               FREE(str_value);
+                       } else {
+                               msg("Failed to get IP address for AP " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       }
+
+                       if (i == WIFI_MANAGER_ADDRESS_FAMILY_IPV6) {
+                               /* multiple IPv6 address */
+                               ret = wifi_manager_ap_foreach_ipv6_address(ap,
+                                               __test_public_ipv6_address_cb, NULL);
+                               if (ret != WIFI_MANAGER_ERROR_NONE)
+                                       msg("Failed to get multiple IPv6 address for AP " LOG_RED "[%s]" LOG_END,
+                                               test_wifi_mgr_convert_error_to_string(ret));
+                       }
+
+                       /* Subnet mask */
+                       ret = wifi_manager_ap_get_subnet_mask(ap, i, &str_value);
+                       if (ret == WIFI_MANAGER_ERROR_NONE) {
+                               msg("Subnet mask [%s]", str_value);
+                               FREE(str_value);
+                       } else {
+                               msg("Failed to get subnet mask for AP " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       }
+
+                       /* Prefix length */
+                       ret = wifi_manager_ap_get_prefix_length(ap, i, &int_value);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("Prefix length [%d]", int_value);
+                       else
+                               msg("Failed to get prefix length for AP " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+
+                       /* Gateway address */
+                       ret = wifi_manager_ap_get_gateway_address(ap, i, &str_value);
+                       if (ret == WIFI_MANAGER_ERROR_NONE) {
+                               msg("Gateway address [%s]", str_value);
+                               FREE(str_value);
+                       } else {
+                               msg("Failed to get gateway address for AP " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       }
+
+                       if (i == WIFI_MANAGER_ADDRESS_FAMILY_IPV4) {
+                               /* DHCP server address */
+                               ret = wifi_manager_ap_get_dhcp_server_address(ap, i, &str_value);
+                               if (ret == WIFI_MANAGER_ERROR_NONE) {
+                                       msg("DHCP server address [%s]", str_value);
+                                       FREE(str_value);
+                               } else {
+                                       msg("Failed to get DHCP server address for AP " LOG_RED "[%s]" LOG_END,
+                                               test_wifi_mgr_convert_error_to_string(ret));
+                               }
+
+                               /* DHCP lease duration */
+                               ret = wifi_manager_ap_get_dhcp_lease_duration(ap, i, &int_value);
+                               if (ret == WIFI_MANAGER_ERROR_NONE)
+                                       msg("DHCP lease duration [%s]", str_value);
+                               else
+                                       msg("Failed to get DHCP lease duration for AP " LOG_RED "[%s]" LOG_END,
+                                               test_wifi_mgr_convert_error_to_string(ret));
+                       }
+
+                       /* Proxy type */
+                       ret = wifi_manager_ap_get_proxy_type(ap, &proxy_type);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("Proxy type [%s]", test_wifi_mgr_proxy_type_to_string(proxy_type));
+                       else
+                               msg("Failed to get proxy type for AP " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+
+                       /* Proxy address */
+                       ret = wifi_manager_ap_get_proxy_address(ap, i, &str_value);
+                       if (ret == WIFI_MANAGER_ERROR_NONE) {
+                               msg("Proxy address [%s]", str_value);
+                               FREE(str_value);
+                       } else {
+                               msg("Failed to get proxy address for AP " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       }
+
+                       /* DNS config type */
+                       ret = wifi_manager_ap_get_dns_config_type(ap, i, &dns_type);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("DNS config type [%s]", test_wifi_mgr_dns_config_type_to_string(dns_type));
+                       else
+                               msg("Failed to get DNS config type for AP " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+
+                       /* DNS1 address */
+                       ret = wifi_manager_ap_get_dns_address(ap, 1, i, &str_value);
+                       if (ret == WIFI_MANAGER_ERROR_NONE) {
+                               msg("DNS1 address [%s]", str_value);
+                               FREE(str_value);
+                       } else {
+                               msg("Failed to get DNS1 address for AP " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       }
+
+                       /* DNS2 address */
+                       ret = wifi_manager_ap_get_dns_address(ap, 2, i, &str_value);
+                       if (ret == WIFI_MANAGER_ERROR_NONE) {
+                               msg("DNS2 address [%s]", str_value);
+                               FREE(str_value);
+                       } else {
+                               msg("Failed to get DNS2 address for AP " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       }
+               }
+
+               /* Security type */
+               ret = wifi_manager_ap_get_security_type(ap, &sec_type);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Security type [%s]", test_wifi_mgr_sec_type_to_string(sec_type));
+               else
+                       msg("Failed to get security type for AP " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               /* Encryption type */
+               ret = wifi_manager_ap_get_encryption_type(ap, &enc_type);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Encryption type [%s]", test_wifi_mgr_encryption_type_to_string(enc_type));
+               else
+                       msg("Failed to get encryption type for AP " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               /* Passphrase required */
+               ret = wifi_manager_ap_is_passphrase_required(ap, &bool_value);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Passphrase required [%s]", bool_value ? "TRUE" : "FALSE");
+               else
+                       msg("Failed to get passphrase required for AP " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               /* WPS supported */
+               ret = wifi_manager_ap_is_wps_supported(ap, &bool_value);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("WPS supported [%s]", bool_value ? "TRUE" : "FALSE");
+               else
+                       msg("Failed to get WPS supported for AP " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               if (sec_type == WIFI_MANAGER_SECURITY_TYPE_EAP) {
+                       /* EAP type */
+                       ret = wifi_manager_ap_get_eap_type(ap, &eap_type);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("EAP type [%s]", test_wifi_mgr_eap_type_to_string(eap_type));
+                       else
+                               msg("Failed to get EAP type for AP " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+
+                       /* EAP auth type */
+                       ret = wifi_manager_ap_get_eap_auth_type(ap, &eap_auth_type);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("EAP auth type [%s]", test_wifi_mgr_eap_auth_type_to_string(eap_auth_type));
+                       else
+                               msg("Failed to get EAP auth type for AP " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+
+                       /* EAP passphrase */
+                       ret = wifi_manager_ap_get_eap_passphrase(ap, &str_value, &bool_value);
+                       if (ret == WIFI_MANAGER_ERROR_NONE) {
+                               msg("EAP user name [%s]", str_value);
+                               msg("EAP is password setted [%s]", bool_value ? "TRUE" : "FALSE");
+                               FREE(str_value);
+                       } else {
+                               msg("Failed to get EAP passphrase for AP " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       }
+
+                       /* EAP ca cert file */
+                       ret = wifi_manager_ap_get_eap_ca_cert_file(ap, &str_value);
+                       if (ret == WIFI_MANAGER_ERROR_NONE) {
+                               msg("EAP ca cert file [%s]", str_value);
+                               FREE(str_value);
+                       } else {
+                               msg("Failed to get EAP ca cert file for AP " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       }
+
+                       /* EAP client cert file */
+                       ret = wifi_manager_ap_get_eap_client_cert_file(ap, &str_value);
+                       if (ret == WIFI_MANAGER_ERROR_NONE) {
+                               msg("EAP client cert file [%s]", str_value);
+                               FREE(str_value);
+                       } else {
+                               msg("Failed to get EAP client cert file for AP " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       }
+
+                       /* EAP private key file */
+                       ret = wifi_manager_ap_get_eap_private_key_file(ap, &str_value);
+                       if (ret == WIFI_MANAGER_ERROR_NONE) {
+                               msg("EAP private key file [%s]", str_value);
+                               FREE(str_value);
+                       } else {
+                               msg("Failed to get EAP private key file for AP " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       }
+               }
+
+               return FALSE;
+       }
+
+       FREE(essid);
+       return TRUE;
+}
+
+static int _test_public_get_ap_info(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_foreach_found_ap(g_wifi_h, __test_public_found_ap_cb, NULL);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Get AP list finished" LOG_END);
+       else
+               msg("Fail to get AP list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_get_connection_state(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_connection_state_e conn_state = WIFI_MANAGER_CONNECTION_STATE_FAILURE;
+
+       ret = wifi_manager_get_connection_state(g_wifi_h, &conn_state);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to get connection state " LOG_CYAN "[%s]" LOG_END,
+                       test_wifi_mgr_conn_state_to_string(conn_state));
+       else
+               msg("Fail to get connection state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_get_mac_address(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       char *mac_addr = NULL;
+
+       ret = wifi_manager_get_mac_address(g_wifi_h, &mac_addr);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to get MAC address " LOG_CYAN "[%s]" LOG_END, mac_addr);
+       else
+               msg("Fail to get MAC address " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       FREE(mac_addr);
+       return ret;
+}
+
+static int _test_public_get_interface_name(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       char *if_name = NULL;
+
+       ret = wifi_manager_get_network_interface_name(g_wifi_h, &if_name);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to get interface name " LOG_CYAN "[%s]" LOG_END, if_name);
+       else
+               msg("Fail to get interface name " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       FREE(if_name);
+       return ret;
+}
+
+static int _test_public_get_scan_state(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_scan_state_e scan_state = WIFI_MANAGER_SCAN_STATE_NOT_SCANNING;
+
+       ret = wifi_manager_get_scan_state(g_wifi_h, &scan_state);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to get scan state " LOG_CYAN "[%s]" LOG_END,
+                       test_wifi_mgr_scan_state_to_string(scan_state));
+       else
+               msg("Fail to get scan state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_get_module_state(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_module_state_e module_state = WIFI_MANAGER_MODULE_STATE_DETACHED;
+
+       ret = wifi_manager_get_module_state(g_wifi_h, &module_state);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg("Succeeded to get module state " LOG_CYAN "[%s]" LOG_END,
+                       test_wifi_mgr_module_state_to_string(module_state));
+       else
+               msg("Fail to get module state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+struct menu_data menu_public_get[] = {
+       { "0", LOG_LIGHTGREEN "[SSID]" LOG_END, NULL, NULL, g_ssid},
+       { "1", LOG_LIGHTBLUE "[AP info]" LOG_END, NULL, _test_public_get_ap_info, NULL},
+       { "2", "[Connection state]", NULL, _test_public_get_connection_state, NULL},
+       { "3", "[MAC address]", NULL, _test_public_get_mac_address, NULL},
+       { "4", "[Interface name]", NULL, _test_public_get_interface_name, NULL},
+       { "5", "[Scan state]", NULL, _test_public_get_scan_state, NULL},
+       { "6", "[Module state]", NULL, _test_public_get_module_state, NULL},
+       { NULL, NULL, },
+};
diff --git a/tool/wifi_mgr_public_get.h b/tool/wifi_mgr_public_get.h
new file mode 100755 (executable)
index 0000000..9e6080c
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_PUBLIC_GET_H__
+#define __WIFI_MGR_PUBLIC_GET_H__
+
+#endif /** __WIFI_MGR_PUBLIC_GET_H__ */
diff --git a/tool/wifi_mgr_public_ipconflict.c b/tool/wifi_mgr_public_ipconflict.c
new file mode 100755 (executable)
index 0000000..360ad40
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "wifi_mgr_tool.h"
+#include "wifi_mgr_menu.h"
+#include "wifi_mgr_public_ipconflict.h"
+
+extern wifi_manager_h g_wifi_h;
+extern wifi_manager_h g_wifi2_h;
+
+static char g_detection[MENU_DATA_SIZE] = "0";
+
+static int _test_public_ipconflict_get_state(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_ip_conflict_state_e state = WIFI_MANAGER_IP_CONFLICT_STATE_UNKNOWN;
+
+       ret = wifi_manager_get_ip_conflict_state(g_wifi_h, &state);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to get IP conflict state " LOG_CYAN "[%s]" LOG_END,
+                       test_wifi_mgr_ipconflict_state_to_string(state));
+       else
+               msg("Failed to get IP conflict state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_ipconflict_get_detect_mode(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       bool state = FALSE;
+
+       ret = wifi_manager_ip_conflict_detect_is_enabled(g_wifi_h, &state);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to get IP conflict detection state " LOG_CYAN "[%s]" LOG_END,
+                       (state == TRUE) ? "Enabled" : "Disabled");
+       else
+               msg("Failed to get IP conflict detection state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_ipconflict_set_detect_mode(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       int detection = (int)strtol((char *)g_detection, NULL, 10);
+       bool state = FALSE;
+
+       if (detection < 0 || detection > 1) {
+               msg("Invalid parameter " LOG_RED "[detection]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       state = (detection == 0) ? FALSE : TRUE;
+       ret = wifi_manager_set_ip_conflict_detect_enable(g_wifi_h, state);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to set IP conflict detection state" LOG_END);
+       else
+               msg("Failed to set IP conflict detection state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+struct menu_data menu_public_ipconflict[] = {
+       { "0", "[Detection] (0.Disable/1.Enable)", NULL, NULL, g_detection},
+       { "1", "[Get] state", NULL, _test_public_ipconflict_get_state, NULL},
+       { "2", "[Get] detection mode", NULL, _test_public_ipconflict_get_detect_mode, NULL},
+       { "3", "[Set] detection mode", NULL, _test_public_ipconflict_set_detect_mode, NULL},
+       { NULL, NULL, },
+};
diff --git a/tool/wifi_mgr_public_ipconflict.h b/tool/wifi_mgr_public_ipconflict.h
new file mode 100755 (executable)
index 0000000..3d3043e
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_PUBLIC_IPCONFLICT_H__
+#define __WIFI_MGR_PUBLIC_IPCONFLICT_H__
+
+#endif /** __WIFI_MGR_PUBLIC_IPCONFLICT_H__ */
diff --git a/tool/wifi_mgr_public_scan.c b/tool/wifi_mgr_public_scan.c
new file mode 100755 (executable)
index 0000000..b2eb882
--- /dev/null
@@ -0,0 +1,315 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "wifi_mgr_tool.h"
+#include "wifi_mgr_menu.h"
+#include "wifi_mgr_public_scan.h"
+
+extern wifi_manager_h g_wifi_h;
+extern wifi_manager_h g_wifi2_h;
+
+static wifi_manager_specific_scan_h g_specific_scan = NULL;
+static int g_specific_scan_cnt = 0;
+
+static char g_ssid[MENU_DATA_SIZE] = "dnet2";
+static char g_frequency[MENU_DATA_SIZE] = "0";
+
+static bool __test_public_found_ap_cb(wifi_manager_ap_h ap, void *user_data)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       char *essid = NULL;
+       wifi_manager_connection_state_e state;
+       int rssi = 0;
+
+       ret = wifi_manager_ap_get_essid(ap, &essid);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get essid for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_connection_state(ap, &state);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get connection state for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_rssi(ap, &rssi);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get rssi for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       msg("AP name " LOG_CYAN "[%s]" LOG_END ", State [%s], Rssi [%d]", essid,
+               test_wifi_mgr_conn_state_to_string(state), rssi);
+
+       FREE(essid);
+       return TRUE;
+}
+
+static int __test_public_foreach_scan(void)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_foreach_found_ap(g_wifi_h, __test_public_found_ap_cb, NULL);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Get AP list finished" LOG_END);
+       else
+               msg("Failed to get AP list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static void __test_public_scan_request_cb(wifi_manager_error_e error_code, void* user_data)
+{
+       msg(HR_SINGLE);
+
+       msg("Scan completed , error code " LOG_GREEN "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(error_code));
+
+       msg(HR_SINGLE);
+
+       if (error_code == WIFI_MANAGER_ERROR_NONE)
+               __test_public_foreach_scan();
+}
+
+static bool __test_public_found_bssid_ap_cb(wifi_manager_ap_h ap, void *user_data)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       char *bssid = NULL;
+       char *essid = NULL;
+       int rssi = 0;
+
+       ret = wifi_manager_ap_get_bssid(ap, &bssid);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get bssid for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_essid(ap, &essid);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get essid for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(bssid);
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_rssi(ap, &rssi);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get rssi for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(bssid);
+               FREE(essid);
+               return FALSE;
+       }
+
+       msg("Bssid [%s], Essid " LOG_CYAN "[%s]" LOG_END ", Rssi [%d]", bssid, essid, rssi);
+
+       FREE(bssid);
+       FREE(essid);
+       return TRUE;
+}
+
+static int __test_public_foreach_bssid_scan(void)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_foreach_found_bssid_ap(g_wifi_h,
+                       __test_public_found_bssid_ap_cb, NULL);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Get bssid scan list finished" LOG_END);
+       else
+               msg("Failed to get bssid scan list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static void __test_public_bssid_scan_request_cb(wifi_manager_error_e error_code, void* user_data)
+{
+       msg(HR_SINGLE);
+
+       msg("Bssid scan completed, error code " LOG_GREEN "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(error_code));
+
+       msg(HR_SINGLE);
+
+       if (error_code == WIFI_MANAGER_ERROR_NONE)
+               __test_public_foreach_bssid_scan();
+}
+
+static void __test_public_multi_scan_cb(wifi_manager_error_e error_code, void* user_data)
+{
+       msg(HR_SINGLE);
+
+       msg("Multi scan completed, error code " LOG_GREEN "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(error_code));
+
+       msg(HR_SINGLE);
+}
+
+static int _test_public_scan(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       ret = wifi_manager_scan(g_wifi_h, __test_public_scan_request_cb, NULL);
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to request scan" LOG_END);
+       else
+               msg("Failed to request scan " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       return ret;
+}
+
+static int _test_public_bssid_scan(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       ret = wifi_manager_bssid_scan(g_wifi_h, __test_public_bssid_scan_request_cb, NULL);
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to request bssid scan" LOG_END);
+       else
+               msg("Failed to request bssid scan " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       return ret;
+}
+
+static int _test_public_multi_scan_init(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       if (g_specific_scan)
+               wifi_manager_specific_scan_destroy(g_wifi_h, g_specific_scan);
+
+       g_specific_scan_cnt = 0;
+
+       ret = wifi_manager_specific_scan_create(g_wifi_h, &g_specific_scan);
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to create specific scan handle [%p]" LOG_END, g_specific_scan);
+       else
+               msg("Failed to create specific scan handle " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       return ret;
+}
+
+static int _test_public_multi_scan_ssid_set(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       ret = wifi_manager_specific_scan_set_ssid(g_specific_scan, g_ssid);
+       if (ret == WIFI_MANAGER_ERROR_NONE) {
+               g_specific_scan_cnt++;
+               msg(LOG_GREEN "Succeeded to set specific scan ssid [%d]" LOG_END, g_specific_scan_cnt);
+       } else {
+               msg("Failed to set specific scan ssid " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+       }
+
+       return ret;
+}
+
+static int _test_public_multi_scan_freq_set(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       int freq = (int)strtol(g_frequency, NULL, 10);
+
+       ret = wifi_manager_specific_scan_set_freq(g_specific_scan, freq);
+       if (ret == WIFI_MANAGER_ERROR_NONE) {
+               g_specific_scan_cnt++;
+               msg(LOG_GREEN "Succeeded to set specific scan freq [%d]" LOG_END, g_specific_scan_cnt);
+       } else {
+               msg("Failed to set specific scan freq " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+       }
+
+       return ret;
+}
+
+static int _test_public_multi_scan(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       ret = wifi_manager_specific_ap_start_multi_scan(g_wifi_h, g_specific_scan,
+                       __test_public_multi_scan_cb, NULL);
+       if (ret == WIFI_MANAGER_ERROR_NONE) {
+               g_specific_scan_cnt++;
+               msg(LOG_GREEN "Succeeded to request multi scan [%d]" LOG_END, g_specific_scan_cnt);
+       } else {
+               msg("Failed to request multi scan " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+       }
+
+       return ret;
+}
+
+struct menu_data menu_public_scan_multi_ssid[] = {
+       { "1", "[SSID]", NULL, NULL, g_ssid},
+       { "2", "[Set]", NULL, _test_public_multi_scan_ssid_set, NULL},
+       { "3", "[Scan]", NULL, _test_public_multi_scan, NULL},
+       { NULL, NULL, },
+};
+
+struct menu_data menu_public_scan_multi_freq[] = {
+       { "1", "[Freq]", NULL, NULL, g_frequency},
+       { "2", "[Set]", NULL, _test_public_multi_scan_freq_set, NULL},
+       { "3", "[Scan]", NULL, _test_public_multi_scan, NULL},
+       { NULL, NULL, },
+};
+
+struct menu_data menu_public_scan_multi[] = {
+       { "1", "[SSID]", menu_public_scan_multi_ssid, _test_public_multi_scan_init, NULL},
+       { "2", "[Freq]", menu_public_scan_multi_freq, _test_public_multi_scan_init, NULL},
+       { NULL, NULL, },
+};
+
+struct menu_data menu_public_scan[] = {
+       { "1", LOG_LIGHTBLUE "[Scan]" LOG_END, NULL, _test_public_scan, NULL},
+       { "2", "[BSSID scan]", NULL, _test_public_bssid_scan, NULL},
+       { "3", "[Multi scan]", menu_public_scan_multi, NULL, NULL},
+       { NULL, NULL, },
+};
diff --git a/tool/wifi_mgr_public_scan.h b/tool/wifi_mgr_public_scan.h
new file mode 100755 (executable)
index 0000000..3641c63
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_PUBLIC_SCAN_H__
+#define __WIFI_MGR_PUBLIC_SCAN_H__
+
+#endif /** __WIFI_MGR_PUBLIC_SCAN_H__ */
diff --git a/tool/wifi_mgr_public_set.c b/tool/wifi_mgr_public_set.c
new file mode 100755 (executable)
index 0000000..a3a0dd8
--- /dev/null
@@ -0,0 +1,465 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "wifi_mgr_tool.h"
+#include "wifi_mgr_menu.h"
+#include "wifi_mgr_public_set.h"
+
+extern wifi_manager_h g_wifi_h;
+extern wifi_manager_h g_wifi2_h;
+extern wifi_manager_device_state_e g_device_state;
+
+static char g_ssid[MENU_DATA_SIZE] = "dnet2";
+static char g_ip_config_type[MENU_DATA_SIZE] = "1";
+static char g_ip_address_type[MENU_DATA_SIZE] = "0";
+static char g_ip_address[MENU_DATA_SIZE] = "192.168.0.123";
+static char g_subnet_mask[MENU_DATA_SIZE] = "255.255.255.0";
+static char g_prefix_length[MENU_DATA_SIZE] = "24";
+static char g_gateway_address[MENU_DATA_SIZE] = "192.168.0.1";
+static char g_dns_type[MENU_DATA_SIZE] = "1";
+static char g_dns1_address[MENU_DATA_SIZE] = "192.168.0.1";
+static char g_dns2_address[MENU_DATA_SIZE] = "0";
+static char g_proxy_type[MENU_DATA_SIZE] = "0";
+static char g_proxy_address_type[MENU_DATA_SIZE] = "0";
+static char g_proxy_address[MENU_DATA_SIZE] = "0";
+
+static bool __test_public_found_ip_method_cb(wifi_manager_ap_h ap, void *user_data)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       char *essid = NULL;
+       wifi_manager_connection_state_e state = WIFI_MANAGER_CONNECTION_STATE_FAILURE;
+       wifi_manager_ip_config_type_e config_type = (int)strtol(g_ip_config_type, NULL, 10);
+       wifi_manager_address_family_e address_type = (int)strtol(g_ip_address_type, NULL, 10);
+       wifi_manager_dns_config_type_e dns_type = (int)strtol(g_dns_type, NULL, 10);
+       int rssi = 0;
+
+       ret = wifi_manager_ap_get_essid(ap, &essid);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get essid for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_connection_state(ap, &state);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get connection state for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_rssi(ap, &rssi);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get rssi for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       if (test_wifi_mgr_compare_string(essid, g_ssid)) {
+               msg("AP name " LOG_CYAN "[%s]" LOG_END ", State [%s], Rssi [%d]", essid,
+                       test_wifi_mgr_conn_state_to_string(state), rssi);
+
+               msg(HR_SINGLE);
+
+               /* IP config type */
+               ret = wifi_manager_ap_set_ip_config_type(ap, address_type, config_type);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Succeeded to set ip config type " LOG_CYAN "[%s]" LOG_END,
+                               test_wifi_mgr_ip_config_type_to_string(config_type));
+               else
+                       msg("Failed to set ip config type " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               if (config_type == WIFI_MANAGER_IP_CONFIG_TYPE_STATIC) {
+                       /* IP address */
+                       switch (g_ip_address[0]) {
+                       case 'x': /* Skip */
+                               ret = WIFI_MANAGER_ERROR_NONE;
+                               break;
+                       case '0': /* Clear */
+                               ret = wifi_manager_ap_set_ip_address(ap, address_type, NULL);
+                               if (ret == WIFI_MANAGER_ERROR_NONE)
+                                       msg("Succeeded to clear ip address");
+                               else
+                                       msg("Failed to clear ip address " LOG_RED "[%s]" LOG_END,
+                                               test_wifi_mgr_convert_error_to_string(ret));
+                               break;
+                       default:
+                               ret = wifi_manager_ap_set_ip_address(ap, address_type, g_ip_address);
+                               if (ret == WIFI_MANAGER_ERROR_NONE)
+                                       msg("Succeeded to set ip address " LOG_CYAN "[%s]" LOG_END, g_ip_address);
+                               else
+                                       msg("Failed to set ip address " LOG_RED "[%s]" LOG_END,
+                                               test_wifi_mgr_convert_error_to_string(ret));
+                               break;
+                       }
+
+                       /* Subnet mask */
+                       switch (g_subnet_mask[0]) {
+                       case 'x': /* Skip */
+                               ret = WIFI_MANAGER_ERROR_NONE;
+                               break;
+                       case '0': /* Clear */
+                               ret = wifi_manager_ap_set_subnet_mask(ap, address_type, NULL);
+                               if (ret == WIFI_MANAGER_ERROR_NONE)
+                                       msg("Succeeded to clear subnet mask");
+                               else
+                                       msg("Failed to clear subnet mask " LOG_RED "[%s]" LOG_END,
+                                               test_wifi_mgr_convert_error_to_string(ret));
+                               break;
+                       default:
+                               ret = wifi_manager_ap_set_subnet_mask(ap, address_type, g_subnet_mask);
+                               if (ret == WIFI_MANAGER_ERROR_NONE)
+                                       msg("Succeeded to set subnet mask " LOG_CYAN "[%s]" LOG_END, g_subnet_mask);
+                               else
+                                       msg("Failed to set subnet mask " LOG_RED "[%s]" LOG_END,
+                                               test_wifi_mgr_convert_error_to_string(ret));
+                               break;
+                       }
+
+                       /* Prefix length */
+                       if (g_prefix_length[0] == 'x') {
+                               ret = WIFI_MANAGER_ERROR_NONE;
+                       } else {
+                               int prefix_len = (int)strtol(g_prefix_length, NULL, 10);
+                               ret = wifi_manager_ap_set_prefix_length(ap, address_type, prefix_len);
+                               if (ret == WIFI_MANAGER_ERROR_NONE)
+                                       msg("Succeeded to set prefix length " LOG_CYAN "[%d]" LOG_END, prefix_len);
+                               else
+                                       msg("Failed to set prefix length " LOG_RED "[%s]" LOG_END,
+                                               test_wifi_mgr_convert_error_to_string(ret));
+                       }
+
+                       /* Gateway address */
+                       switch (g_gateway_address[0]) {
+                       case 'x': /* Skip */
+                               ret = WIFI_MANAGER_ERROR_NONE;
+                               break;
+                       case '0': /* Clear */
+                               ret = wifi_manager_ap_set_gateway_address(ap, address_type, NULL);
+                               if (ret == WIFI_MANAGER_ERROR_NONE)
+                                       msg("Succeeded to clear gateway address");
+                               else
+                                       msg("Failed to clear prefix length " LOG_RED "[%s]" LOG_END,
+                                               test_wifi_mgr_convert_error_to_string(ret));
+                               break;
+                       default:
+                               ret = wifi_manager_ap_set_gateway_address(ap, address_type, g_gateway_address);
+                               if (ret == WIFI_MANAGER_ERROR_NONE)
+                                       msg("Succeeded to set gateway address " LOG_CYAN "[%s]" LOG_END, g_gateway_address);
+                               else
+                                       msg("Failed to set gateway address " LOG_RED "[%s]" LOG_END,
+                                               test_wifi_mgr_convert_error_to_string(ret));
+                               break;
+                       }
+
+                       /* DNS config type / address */
+                       switch (dns_type) {
+                       case WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC:
+                               ret = wifi_manager_ap_set_dns_config_type(ap, address_type, dns_type);
+                               if (ret == WIFI_MANAGER_ERROR_NONE) {
+                                       msg("Succeeded to set DNS config type " LOG_CYAN "[%s]" LOG_END,
+                                               test_wifi_mgr_dns_config_type_to_string(dns_type));
+
+                                       switch (g_dns1_address[0]) {
+                                       case 'x': /* Skip */
+                                               ret = WIFI_MANAGER_ERROR_NONE;
+                                               break;
+                                       case '0': /* Clear */
+                                               ret = wifi_manager_ap_set_dns_address(ap, 1, address_type, NULL);
+                                               if (ret == WIFI_MANAGER_ERROR_NONE)
+                                                       msg("Succeeded to clear DNS1 address");
+                                               else
+                                                       msg("Failed to clear DNS1 address " LOG_RED "[%s]" LOG_END,
+                                                               test_wifi_mgr_convert_error_to_string(ret));
+                                               break;
+                                       default:
+                                               ret = wifi_manager_ap_set_dns_address(ap, 1, address_type, g_dns1_address);
+                                               if (ret == WIFI_MANAGER_ERROR_NONE)
+                                                       msg("Succeeded to set DNS1 address " LOG_CYAN "[%s]" LOG_END, g_dns1_address);
+                                               else
+                                                       msg("Failed to set DNS1 address " LOG_RED "[%s]" LOG_END,
+                                                               test_wifi_mgr_convert_error_to_string(ret));
+                                               break;
+                                       }
+
+                                       if (ret != WIFI_MANAGER_ERROR_NONE)
+                                               msg("Failed to set DNS1 address " LOG_RED "[%s]" LOG_END,
+                                                       test_wifi_mgr_convert_error_to_string(ret));
+
+                                       switch (g_dns2_address[0]) {
+                                       case 'x': /* Skip */
+                                               ret = WIFI_MANAGER_ERROR_NONE;
+                                               break;
+                                       case '0': /* Clear */
+                                               ret = wifi_manager_ap_set_dns_address(ap, 2, address_type, NULL);
+                                               if (ret == WIFI_MANAGER_ERROR_NONE)
+                                                       msg("Succeeded to clear DNS2 address");
+                                               else
+                                                       msg("Failed to clear DNS2 address " LOG_RED "[%s]" LOG_END,
+                                                               test_wifi_mgr_convert_error_to_string(ret));
+                                               break;
+                                       default:
+                                               ret = wifi_manager_ap_set_dns_address(ap, 2, address_type, g_dns2_address);
+                                               if (ret == WIFI_MANAGER_ERROR_NONE)
+                                                       msg("Succeeded to set DNS2 address " LOG_CYAN "[%s]" LOG_END, g_dns2_address);
+                                               else
+                                                       msg("Failed to set DNS2 address " LOG_RED "[%s]" LOG_END,
+                                                               test_wifi_mgr_convert_error_to_string(ret));
+                                               break;
+                                       }
+
+                                       if (ret != WIFI_MANAGER_ERROR_NONE)
+                                               msg("Failed to set DNS2 address " LOG_RED "[%s]" LOG_END,
+                                                       test_wifi_mgr_convert_error_to_string(ret));
+                               } else {
+                                       msg("Failed to set DNS config type " LOG_RED "[%s]" LOG_END,
+                                               test_wifi_mgr_convert_error_to_string(ret));
+                               }
+                               break;
+                       case WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC:
+                               ret = wifi_manager_ap_set_dns_config_type(ap, address_type, dns_type);
+                               if (ret == WIFI_MANAGER_ERROR_NONE)
+                                       msg("Succeeded to set dns config type " LOG_CYAN "[%s]" LOG_END,
+                                               test_wifi_mgr_dns_config_type_to_string(dns_type));
+                               else
+                                       msg("Failed to set DNS config type " LOG_RED "[%s]" LOG_END,
+                                               test_wifi_mgr_convert_error_to_string(ret));
+                               break;
+                       default:
+                               break;
+                       }
+               }
+
+               msg(HR_SINGLE);
+
+               ret = wifi_manager_update_ap(g_wifi_h, ap);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Succeeded to update IP method " LOG_CYAN "[%s]" LOG_END, essid);
+               else
+                       msg("Failed to update IP method " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               FREE(essid);
+               return FALSE;
+       }
+
+       FREE(essid);
+       return TRUE;
+}
+
+static bool __test_public_found_proxy_method_cb(wifi_manager_ap_h ap, void *user_data)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       char *essid = NULL;
+       wifi_manager_connection_state_e state = WIFI_MANAGER_CONNECTION_STATE_FAILURE;
+       wifi_manager_proxy_type_e type = (int)strtol(g_proxy_type, NULL, 10);
+       wifi_manager_address_family_e address_type = (int)strtol(g_proxy_address_type, NULL, 10);
+       int rssi = 0;
+
+       ret = wifi_manager_ap_get_essid(ap, &essid);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get essid for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_connection_state(ap, &state);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get connection state for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       ret = wifi_manager_ap_get_rssi(ap, &rssi);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg("Failed to get rssi for AP " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+               FREE(essid);
+               return FALSE;
+       }
+
+       if (test_wifi_mgr_compare_string(essid, g_ssid)) {
+               msg("AP name " LOG_CYAN "[%s]" LOG_END ", State [%s], Rssi [%d]", essid,
+                       test_wifi_mgr_conn_state_to_string(state), rssi);
+
+               msg(HR_SINGLE);
+
+               /* Proxy type */
+               ret = wifi_manager_ap_set_proxy_type(ap, type);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Succeeded to set proxy type " LOG_CYAN "[%s]" LOG_END,
+                               test_wifi_mgr_proxy_type_to_string(type));
+               else
+                       msg("Failed to set proxy type " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               /* Proxy address */
+               switch (g_proxy_address[0]) {
+               case 'x': /* Skip */
+                       ret = WIFI_MANAGER_ERROR_NONE;
+                       break;
+               case '0': /* Clear */
+                       ret = wifi_manager_ap_set_proxy_address(ap, address_type, NULL);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("Succeeded to clear proxy address");
+                       else
+                               msg("Failed to clear proxy address " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       break;
+               default:
+                       ret = wifi_manager_ap_set_proxy_address(ap, address_type, g_proxy_address);
+                       if (ret == WIFI_MANAGER_ERROR_NONE)
+                               msg("Succeeded to set proxy address " LOG_CYAN "[%s]" LOG_END, g_proxy_address);
+                       else
+                               msg("Failed to set proxy address " LOG_RED "[%s]" LOG_END,
+                                       test_wifi_mgr_convert_error_to_string(ret));
+                       break;
+               }
+
+               msg(HR_SINGLE);
+
+               ret = wifi_manager_update_ap(g_wifi_h, ap);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg("Succeeded to update Proxy method " LOG_CYAN "[%s]" LOG_END, essid);
+               else
+                       msg("Failed to update Proxy method " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+
+               FREE(essid);
+               return FALSE;
+       }
+
+       FREE(essid);
+       return TRUE;
+}
+
+static int _test_public_update_ip_method(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_ip_config_type_e config_type = (int)strtol(g_ip_config_type, NULL, 10);
+       wifi_manager_address_family_e address_type = (int)strtol(g_ip_address_type, NULL, 10);
+       wifi_manager_dns_config_type_e dns_type = (int)strtol(g_dns_type, NULL, 10);
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       if (config_type < WIFI_MANAGER_IP_CONFIG_TYPE_STATIC ||
+               config_type > WIFI_MANAGER_IP_CONFIG_TYPE_FIXED ||
+               (address_type != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
+               address_type != WIFI_MANAGER_ADDRESS_FAMILY_IPV6) ||
+               dns_type < WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC ||
+               dns_type > WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC) {
+               msg("Invalid parameter " LOG_RED "[config|address|dns type]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_foreach_found_ap(g_wifi_h, __test_public_found_ip_method_cb, NULL);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Get AP list finished" LOG_END);
+       else
+               msg("Fail to get AP list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_update_proxy_method(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_proxy_type_e type = (int)strtol(g_proxy_type, NULL, 10);
+       wifi_manager_address_family_e address_type = (int)strtol(g_proxy_address_type, NULL, 10);
+
+       if (g_device_state != WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
+               msg("Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+               return ret;
+       }
+
+       if (type > WIFI_MANAGER_PROXY_TYPE_MANUAL ||
+               (address_type != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
+               address_type != WIFI_MANAGER_ADDRESS_FAMILY_IPV6)) {
+               msg("Invalid parameter " LOG_RED "[method|address type]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       msg(HR_SINGLE);
+
+       ret = wifi_manager_foreach_found_ap(g_wifi_h, __test_public_found_proxy_method_cb, NULL);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Get AP list finished" LOG_END);
+       else
+               msg("Fail to get AP list " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+struct menu_data menu_public_set_ip[] = {
+       { "0", "[SSID]", NULL, NULL, g_ssid},
+       { "1", "[IP config type] (1.Static/2.Dynamic/3.Auto/4.Fixed)", NULL, NULL, g_ip_config_type},
+       { "2", "[IP Address type] (0.IPv4/1.IPv6)", NULL, NULL, g_ip_address_type},
+       { "3", "[IP address] (0.Clear/x.Skip)", NULL, NULL, g_ip_address},
+       { "4", "[Subnet mask] (0.Clear/x.Skip)", NULL, NULL, g_subnet_mask},
+       { "5", "[Prefix length] (x.Skip)", NULL, NULL, g_prefix_length},
+       { "6", "[Gateway address] (0.Clear/x.Skip)", NULL, NULL, g_gateway_address},
+       { "7", "[DNS config type] (1.Static/2.Dynamic)", NULL, NULL, g_dns_type},
+       { "8", "[DNS1 address] (0.Clear/x.Skip)", NULL, NULL, g_dns1_address},
+       { "9", "[DNS2 address] (0.Clear/x.Skip)", NULL, NULL, g_dns2_address},
+       { "u", LOG_LIGHTBLUE "[Update]" LOG_END, NULL, _test_public_update_ip_method, NULL},
+       { NULL, NULL, },
+};
+
+struct menu_data menu_public_set_proxy[] = {
+       { "0", "[SSID]", NULL, NULL, g_ssid},
+       { "1", "[Proxy type] (0.Direct/1.Auto/2.Manual)", NULL, NULL, g_proxy_type},
+       { "2", "[Proxy Address type] (0.IPv4/1.IPv6)", NULL, NULL, g_proxy_address_type},
+       { "3", "[Proxy address] (0.Clear/x.Skip)", NULL, NULL, g_proxy_address},
+       { "u", LOG_LIGHTBLUE "[Update]" LOG_END, NULL, _test_public_update_proxy_method, NULL},
+       { NULL, NULL, },
+};
+
+struct menu_data menu_public_set[] = {
+       { "1", LOG_LIGHTBLUE "[IP method]" LOG_END, menu_public_set_ip, NULL, NULL},
+       { "2", "[Proxy method]", menu_public_set_proxy, NULL, NULL},
+       { NULL, NULL, },
+};
diff --git a/tool/wifi_mgr_public_set.h b/tool/wifi_mgr_public_set.h
new file mode 100755 (executable)
index 0000000..f3fadbe
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_PUBLIC_SET_H__
+#define __WIFI_MGR_PUBLIC_SET_H__
+
+#endif /** __WIFI_MGR_PUBLIC_SET_H__ */
diff --git a/tool/wifi_mgr_public_tdls.c b/tool/wifi_mgr_public_tdls.c
new file mode 100755 (executable)
index 0000000..814fafe
--- /dev/null
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "wifi_mgr_tool.h"
+#include "wifi_mgr_menu.h"
+#include "wifi_mgr_public_tdls.h"
+
+#define MACADDRLEN 17
+
+extern wifi_manager_h g_wifi_h;
+extern wifi_manager_h g_wifi2_h;
+
+static char g_mac_address[MENU_DATA_SIZE] = "00:12:36:96:61:01";
+static char g_frequency[MENU_DATA_SIZE] = "1";
+
+static int _test_public_tdls_discover(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       if (strlen(g_mac_address) > MACADDRLEN) {
+               msg("Invalid parameter " LOG_RED "[MAC address]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = wifi_manager_tdls_start_discovery(g_wifi_h, g_mac_address);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to start TDLS discover" LOG_END);
+       else
+               msg("Failed to start TDLS discover " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_tdls_connect(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       if (strlen(g_mac_address) > MACADDRLEN) {
+               msg("Invalid parameter " LOG_RED "[MAC address]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = wifi_manager_tdls_connect(g_wifi_h, g_mac_address);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to connect TDLS" LOG_END);
+       else
+               msg("Failed to connect TDLS " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_tdls_get_connected_peer(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       char *mac_address = NULL;
+
+       ret = wifi_manager_tdls_get_connected_peer(g_wifi_h, &mac_address);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE) {
+               msg(LOG_GREEN "Succeeded to get TDLS connected peer " LOG_CYAN "[%s]" LOG_END,
+                       mac_address);
+               FREE(mac_address);
+       } else {
+               msg("Failed to get TDLS connected peer " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+       }
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_tdls_disconnect(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       if (strlen(g_mac_address) > MACADDRLEN) {
+               msg("Invalid parameter " LOG_RED "[MAC address]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = wifi_manager_tdls_disconnect(g_wifi_h, g_mac_address);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to disconnect TDLS" LOG_END);
+       else
+               msg("Failed to disconnect TDLS " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_tdls_enable_channel_switch(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       int frequency = (int)strtol((char *)g_frequency, NULL, 10);
+
+       if (strlen(g_mac_address) > MACADDRLEN) {
+               msg("Invalid parameter " LOG_RED "[MAC address]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = wifi_manager_tdls_enable_channel_switching(g_wifi_h, g_mac_address, frequency);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to enable TDLS channel switch" LOG_END);
+       else
+               msg("Failed to enable TDLS channel switch " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_tdls_disable_channel_switch(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       if (strlen(g_mac_address) > MACADDRLEN) {
+               msg("Invalid parameter " LOG_RED "[MAC address]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = wifi_manager_tdls_disable_channel_switching(g_wifi_h, g_mac_address);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to disable TDLS channel switch" LOG_END);
+       else
+               msg("Failed to disable TDLS channel switch " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+struct menu_data menu_public_tdls[] = {
+       { "0", LOG_LIGHTGREEN "[MAC address]" LOG_END, NULL, NULL, g_mac_address},
+       { "1", "[Frequency]", NULL, NULL, g_frequency},
+       { "2", LOG_LIGHTBLUE "[Discover]" LOG_END, NULL, _test_public_tdls_discover, NULL},
+       { "3", LOG_LIGHTBLUE "[Connect]" LOG_END, NULL, _test_public_tdls_connect, NULL},
+       { "4", "[Get] connected peer", NULL, _test_public_tdls_get_connected_peer, NULL},
+       { "5", LOG_LIGHTMAGENTA "[Disconnect]" LOG_END, NULL, _test_public_tdls_disconnect, NULL},
+       { "6", "[Enable] channel switch", NULL, _test_public_tdls_enable_channel_switch, NULL},
+       { "7", "[Disable] channel switch", NULL, _test_public_tdls_disable_channel_switch, NULL},
+       { NULL, NULL, },
+};
diff --git a/tool/wifi_mgr_public_tdls.h b/tool/wifi_mgr_public_tdls.h
new file mode 100755 (executable)
index 0000000..61ba6d5
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_PUBLIC_TDLS_H__
+#define __WIFI_MGR_PUBLIC_TDLS_H__
+
+#endif /** __WIFI_MGR_PUBLIC_TDLS_H__ */
diff --git a/tool/wifi_mgr_public_vsie.c b/tool/wifi_mgr_public_vsie.c
new file mode 100755 (executable)
index 0000000..c6be989
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "wifi_mgr_tool.h"
+#include "wifi_mgr_menu.h"
+#include "wifi_mgr_public_vsie.h"
+
+extern wifi_manager_h g_wifi_h;
+extern wifi_manager_h g_wifi2_h;
+
+static char g_frame_id[MENU_DATA_SIZE] = "0";
+static char g_vsie[MENU_DATA_SIZE] = "vsie data";
+
+static int _test_public_vsie_add(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       int frame_id = (int)strtol((char *)g_frame_id, NULL, 10);
+
+       if (frame_id < WIFI_MANAGER_VSIE_FRAME_PROBE_REQ ||
+               frame_id > WIFI_MANAGER_VSIE_FRAME_ACTION) {
+               msg("Invalid parameter " LOG_RED "[frame ID]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       if (strlen(g_vsie) <= 0) {
+               msg("Invalid parameter " LOG_RED "[VSIE data]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = wifi_manager_add_vsie(g_wifi_h, frame_id, g_vsie);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to add VSIE" LOG_END);
+       else
+               msg("Failed to add VSIE " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_vsie_get(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       int frame_id = (int)strtol((char *)g_frame_id, NULL, 10);
+       char *vsie = NULL;
+
+       if (frame_id < WIFI_MANAGER_VSIE_FRAME_PROBE_REQ ||
+               frame_id > WIFI_MANAGER_VSIE_FRAME_ACTION) {
+               msg("Invalid parameter " LOG_RED "[frame ID]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = wifi_manager_get_vsie(g_wifi_h, frame_id, &vsie);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE) {
+               msg(LOG_GREEN "Succeeded to get VSIE " LOG_CYAN "[%s]" LOG_END,
+                       vsie);
+               FREE(vsie);
+       } else {
+               msg("Failed to get VSIE " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+       }
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+static int _test_public_vsie_remove(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       int frame_id = (int)strtol((char *)g_frame_id, NULL, 10);
+
+       if (frame_id < WIFI_MANAGER_VSIE_FRAME_PROBE_REQ ||
+               frame_id > WIFI_MANAGER_VSIE_FRAME_ACTION) {
+               msg("Invalid parameter " LOG_RED "[frame ID]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       if (strlen(g_vsie) <= 0) {
+               msg("Invalid parameter " LOG_RED "[VSIE data]" LOG_END);
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = wifi_manager_remove_vsie(g_wifi_h, frame_id, g_vsie);
+
+       msg(HR_SINGLE);
+
+       if (ret == WIFI_MANAGER_ERROR_NONE)
+               msg(LOG_GREEN "Succeeded to remove VSIE" LOG_END);
+       else
+               msg("Failed to remove VSIE " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+
+       msg(HR_SINGLE);
+
+       return ret;
+}
+
+struct menu_data menu_public_vsie[] = {
+       { "0", "[VSIE data]", NULL, NULL, g_vsie},
+       { "1", "[Frame ID] (0.Probe/1.Assoc/2.Re-assoc/3.Auth/4.Action)", NULL, NULL, g_frame_id},
+       { "2", "[Add]", NULL, _test_public_vsie_add, NULL},
+       { "3", "[Get]", NULL, _test_public_vsie_get, NULL},
+       { "4", "[Remove]", NULL, _test_public_vsie_remove, NULL},
+       { NULL, NULL, },
+};
diff --git a/tool/wifi_mgr_public_vsie.h b/tool/wifi_mgr_public_vsie.h
new file mode 100755 (executable)
index 0000000..6205c8b
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_PUBLIC_VSIE_H__
+#define __WIFI_MGR_PUBLIC_VSIE_H__
+
+#endif /** __WIFI_MGR_PUBLIC_VSIE_H__ */
diff --git a/tool/wifi_mgr_tool.c b/tool/wifi_mgr_tool.c
new file mode 100755 (executable)
index 0000000..8602a0d
--- /dev/null
@@ -0,0 +1,528 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "wifi_mgr_tool.h"
+#include "wifi_mgr_menu.h"
+#include "wifi_mgr_public.h"
+#include "wifi_mgr_extension.h"
+
+wifi_manager_h g_wifi_h = NULL;
+wifi_manager_h g_wifi2_h = NULL;
+wifi_manager_device_state_e g_device_state = WIFI_MANAGER_DEVICE_STATE_DEACTIVATED;
+
+extern struct menu_data menu_public[];
+extern struct menu_data menu_extension[];
+
+static struct menu_data menu_main[] = {
+       { "1", LOG_LIGHTBLUE "[Public]" LOG_END, menu_public, NULL, NULL},
+       { "2", LOG_LIGHTMAGENTA "[Extension]" LOG_END, menu_extension, NULL, NULL},
+       { NULL, NULL, },
+};
+
+static void __test_device_state_cb(wifi_manager_device_state_e state, void *user_data)
+{
+       g_device_state = state;
+
+       msg("[%s] Device state changed callback, State [%s]",
+               (char *)user_data, test_wifi_mgr_device_state_to_string(g_device_state));
+}
+
+static void __test_scan_changed_cb(wifi_manager_scan_state_e state, void* user_data)
+{
+       msg("[%s] Scan changed, Scan state [%s]", (char *)user_data,
+                       test_wifi_mgr_scan_state_to_string(state));
+}
+
+static void __test_connection_state_cb(wifi_manager_connection_state_e state,
+                       wifi_manager_ap_h ap, void* user_data)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       char *ap_name = NULL;
+
+       msgn("[%s] Connection state changed callback, State [%s]",
+               (char *)user_data, test_wifi_mgr_conn_state_to_string(state));
+
+       ret = wifi_manager_ap_get_essid(ap, &ap_name);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               msg(", " LOG_RED "Failed to get AP name [%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+       } else {
+               msg(", AP name " LOG_CYAN "[%s]" LOG_END, ap_name);
+               FREE(ap_name);
+       }
+}
+
+static void __test_rssi_level_cb(wifi_manager_rssi_level_e rssi_level, void* user_data)
+{
+       msg("[%s] RSSI level changed callback, level [%d]", (char *)user_data, rssi_level);
+}
+
+static void __test_bg_scan_completed_cb(wifi_manager_error_e error_code, void* user_data)
+{
+       msg("[%s] Background scan completed, error code [%s]",
+                       (char *)user_data, test_wifi_mgr_convert_error_to_string(error_code));
+}
+
+static void __test_ip_conflict_cb(char *mac, wifi_manager_ip_conflict_state_e state, void *user_data)
+{
+       msgn("[%s] Ip conflict", (char *)user_data);
+
+       if (state == WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_DETECTED)
+               msg(" detected [%s]", mac);
+       else if (state == WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED)
+               msg(" removed");
+       else
+               msg(" state unknown");
+}
+
+static void __test_get_wifi_module_state_cb(wifi_manager_module_state_e state, void *user_data)
+{
+       msgn("[%s] Wi-Fi module state changed callback", (char *)user_data);
+       msg(", Wi-Fi module [%s]", test_wifi_mgr_module_state_to_string(state));
+}
+
+static void __test_tdls_state_cb(wifi_manager_tdls_state_e state, char *peer_mac_add, void *user_data)
+{
+       msgn("[%s] TDLS state changed callback", (char *)user_data);
+
+       if (state == WIFI_MANAGER_TDLS_STATE_CONNECTED)
+               msg(", state : TDLS connected, Peer MAC address [%s]", peer_mac_add);
+       else
+               msg(", state : TDLS disconnected, Peer MAC address [%s]", peer_mac_add);
+}
+
+static void __test_tdls_discover_cb(wifi_manager_tdls_discovery_state_e state,
+                       char *peer_mac_add, void *user_data)
+{
+       msgn("[%s] TDLS discover callback", (char *)user_data);
+
+       msgn(", Peer MAC address [%s], state [%d]", peer_mac_add, state);
+       if (state == WIFI_MANAGER_TDLS_DISCOVERY_STATE_ONGOING)
+               msg(", Discovery is ongoing");
+       else
+               msg(", Discovery is finished");
+}
+
+static int _test_wifi_mgr_initialize(MManager *mm, struct menu_data *menu)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       bool state = FALSE;
+
+       if (!g_wifi_h) {
+               ret = wifi_manager_initialize(&g_wifi_h);
+               if (ret == WIFI_MANAGER_ERROR_NONE) {
+                       wifi_manager_set_device_state_changed_cb(g_wifi_h, __test_device_state_cb, "1");
+                       wifi_manager_set_scan_state_changed_cb(g_wifi_h, __test_scan_changed_cb, "1");
+                       wifi_manager_set_connection_state_changed_cb(g_wifi_h, __test_connection_state_cb, "1");
+                       wifi_manager_set_rssi_level_changed_cb(g_wifi_h, __test_rssi_level_cb, "1");
+                       wifi_manager_set_background_scan_cb(g_wifi_h, __test_bg_scan_completed_cb, "1");
+                       wifi_manager_set_ip_conflict_cb(g_wifi_h, __test_ip_conflict_cb, "1");
+                       wifi_manager_set_module_state_changed_cb(g_wifi_h, __test_get_wifi_module_state_cb, "1");
+
+                       wifi_manager_tdls_set_state_changed_cb(g_wifi_h, __test_tdls_state_cb, "1");
+                       wifi_manager_tdls_set_discovered_cb(g_wifi_h, __test_tdls_discover_cb, "1");
+
+                       msg(LOG_GREEN "Success to initialize wifi [1] handle [%p]" LOG_END, g_wifi_h);
+               } else {
+                       msg("Failed to initialize wifi handle " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+               }
+       }
+
+       if (!g_wifi2_h) {
+               ret = wifi_manager_initialize(&g_wifi2_h);
+               if (ret == WIFI_MANAGER_ERROR_NONE) {
+                       wifi_manager_set_device_state_changed_cb(g_wifi2_h, __test_device_state_cb, "2");
+                       wifi_manager_set_scan_state_changed_cb(g_wifi2_h, __test_scan_changed_cb, "2");
+                       wifi_manager_set_connection_state_changed_cb(g_wifi2_h, __test_connection_state_cb, "2");
+                       wifi_manager_set_rssi_level_changed_cb(g_wifi2_h, __test_rssi_level_cb, "2");
+                       wifi_manager_set_background_scan_cb(g_wifi2_h, __test_bg_scan_completed_cb, "2");
+                       wifi_manager_set_ip_conflict_cb(g_wifi2_h, __test_ip_conflict_cb, "2");
+                       wifi_manager_set_module_state_changed_cb(g_wifi2_h, __test_get_wifi_module_state_cb, "2");
+
+                       wifi_manager_tdls_set_state_changed_cb(g_wifi2_h, __test_tdls_state_cb, "2");
+                       wifi_manager_tdls_set_discovered_cb(g_wifi2_h, __test_tdls_discover_cb, "2");
+
+                       msg(LOG_GREEN "Success to initialize wifi [2] handle [%p]" LOG_END, g_wifi2_h);
+               } else {
+                       msg("Failed to initialize wifi [2] handle " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+               }
+       }
+
+       ret = wifi_manager_is_activated(g_wifi_h, &state);
+       if (ret == WIFI_MANAGER_ERROR_NONE) {
+               g_device_state = state;
+               msg("Wi-Fi device state " LOG_CYAN "[%s]" LOG_END,
+                       test_wifi_mgr_device_state_to_string(g_device_state));
+       } else {
+               msg("Failed to get Wi-Fi device state " LOG_RED "[%s]" LOG_END,
+                       test_wifi_mgr_convert_error_to_string(ret));
+       }
+
+       return ret;
+}
+
+static int _test_wifi_mgr_deinitialize(void)
+{
+       int ret = WIFI_MANAGER_ERROR_NONE;
+
+       if (g_wifi_h) {
+               ret = wifi_manager_deinitialize(g_wifi_h);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg(LOG_GREEN "Succeeded to deinitialize wifi handle" LOG_END);
+               else
+                       msg("Failed to deinitialize wifi [1] handle " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+       }
+
+       if (g_wifi2_h) {
+               ret = wifi_manager_deinitialize(g_wifi2_h);
+               if (ret == WIFI_MANAGER_ERROR_NONE)
+                       msg(LOG_GREEN "Succeeded to deinitialize wifi2 handle" LOG_END);
+               else
+                       msg("Failed to deinitialize wifi [2] handle " LOG_RED "[%s]" LOG_END,
+                               test_wifi_mgr_convert_error_to_string(ret));
+       }
+
+       return ret;
+}
+
+static gboolean _test_wifi_mgr_create_init_menu(struct menu_data init_menu[1])
+{
+       init_menu[0].key = "1";
+       init_menu[0].title = LOG_YELLOW "Wifi Mgr Init" LOG_END;
+       init_menu[0].sub_menu = menu_main;
+       init_menu[0].callback = _test_wifi_mgr_initialize;
+       init_menu[0].data = NULL;
+
+       return TRUE;
+}
+
+bool test_wifi_mgr_compare_string(const char *str, const char *part)
+{
+       int str_len = strlen(str);
+       int part_len = strlen(part);
+
+       if (strncmp(str, part, MAX(str_len, part_len)) == 0)
+               return TRUE;
+       else
+               return FALSE;
+}
+
+const char *test_wifi_mgr_autoscan_mode_to_string(wifi_manager_autoscan_mode_e state)
+{
+       switch (state) {
+       case WIFI_MANAGER_AUTOSCAN_MODE_EXPONENTIAL:
+               return "Exponential";
+       case WIFI_MANAGER_AUTOSCAN_MODE_PERIODIC:
+               return "Periodic";
+       }
+
+       return "Unknown";
+}
+
+const char *test_wifi_mgr_ipconflict_state_to_string(wifi_manager_ip_conflict_state_e state)
+{
+       switch (state) {
+       case WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED:
+               return "Absent";
+       case WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_DETECTED:
+               return "Present";
+       default:
+               break;
+       }
+
+       return "Unknown";
+}
+
+const char *test_wifi_mgr_device_state_to_string(wifi_manager_device_state_e state)
+{
+       switch (state) {
+       case WIFI_MANAGER_DEVICE_STATE_DEACTIVATED:
+               return "Deactivated";
+       case WIFI_MANAGER_DEVICE_STATE_ACTIVATED:
+               return "Activated";
+       }
+
+       return "Unknown";
+}
+
+const char *test_wifi_mgr_module_state_to_string(wifi_manager_module_state_e state)
+{
+       switch (state) {
+       case WIFI_MANAGER_MODULE_STATE_DETACHED:
+               return "Detached";
+       case WIFI_MANAGER_MODULE_STATE_ATTACHED:
+               return "Attached";
+       }
+
+       return "Unknown";
+}
+
+const char *test_wifi_mgr_scan_state_to_string(wifi_manager_scan_state_e state)
+{
+       switch (state) {
+       case WIFI_MANAGER_SCAN_STATE_NOT_SCANNING:
+               return "Not scanning";
+       case WIFI_MANAGER_SCAN_STATE_SCANNING:
+               return "Scanning";
+       }
+
+       return "Unknown";
+}
+
+const char *test_wifi_mgr_eap_auth_type_to_string(wifi_manager_eap_auth_type_e type)
+{
+       switch (type) {
+       case WIFI_MANAGER_EAP_AUTH_TYPE_NONE:
+               return "None";
+       case WIFI_MANAGER_EAP_AUTH_TYPE_PAP:
+               return "PAP";
+       case WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAP:
+               return "MSCHAP";
+       case WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAPV2:
+               return "MSCHAPv2";
+       case WIFI_MANAGER_EAP_AUTH_TYPE_GTC:
+               return "GTC";
+       case WIFI_MANAGER_EAP_AUTH_TYPE_MD5:
+               return "MD5";
+       }
+
+       return "Unknown";
+}
+
+const char *test_wifi_mgr_eap_type_to_string(wifi_manager_eap_type_e type)
+{
+       switch (type) {
+       case WIFI_MANAGER_EAP_TYPE_PEAP:
+               return "PEAP";
+       case WIFI_MANAGER_EAP_TYPE_TLS:
+               return "TLS";
+       case WIFI_MANAGER_EAP_TYPE_TTLS:
+               return "TTLS";
+       case WIFI_MANAGER_EAP_TYPE_SIM:
+               return "SIM";
+       case WIFI_MANAGER_EAP_TYPE_AKA:
+               return "AKA";
+       }
+
+       return "Unknown";
+}
+
+const char *test_wifi_mgr_encryption_type_to_string(wifi_manager_encryption_type_e type)
+{
+       switch (type) {
+       case WIFI_MANAGER_ENCRYPTION_TYPE_NONE:
+               return "None";
+       case WIFI_MANAGER_ENCRYPTION_TYPE_WEP:
+               return "WEP";
+       case WIFI_MANAGER_ENCRYPTION_TYPE_TKIP:
+               return "TKIP";
+       case WIFI_MANAGER_ENCRYPTION_TYPE_AES:
+               return "AES";
+       case WIFI_MANAGER_ENCRYPTION_TYPE_TKIP_AES_MIXED:
+               return "TKIP AES MIXED";
+       }
+
+       return "Unknown";
+}
+
+const char *test_wifi_mgr_dns_config_type_to_string(wifi_manager_dns_config_type_e type)
+{
+       switch (type) {
+       case WIFI_MANAGER_DNS_CONFIG_TYPE_NONE:
+               return "None";
+       case WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC:
+               return "Static";
+       case WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC:
+               return "Dynamic";
+       }
+
+       return "Unknown";
+}
+
+const char *test_wifi_mgr_proxy_type_to_string(wifi_manager_proxy_type_e type)
+{
+       switch (type) {
+       case WIFI_MANAGER_PROXY_TYPE_DIRECT:
+               return "Direct";
+       case WIFI_MANAGER_PROXY_TYPE_AUTO:
+               return "Auto";
+       case WIFI_MANAGER_PROXY_TYPE_MANUAL:
+               return "Manual";
+       }
+
+       return "Unknown";
+}
+
+const char *test_wifi_mgr_ip_config_type_to_string(wifi_manager_ip_config_type_e type)
+{
+       switch (type) {
+       case WIFI_MANAGER_IP_CONFIG_TYPE_NONE:
+               return "None";
+       case WIFI_MANAGER_IP_CONFIG_TYPE_STATIC:
+               return "Static";
+       case WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC:
+               return "Dynamic";
+       case WIFI_MANAGER_IP_CONFIG_TYPE_AUTO:
+               return "Auto";
+       case WIFI_MANAGER_IP_CONFIG_TYPE_FIXED:
+               return "Fixed";
+       }
+
+       return "Unknown";
+}
+
+const char *test_wifi_mgr_sec_type_to_string(wifi_manager_security_type_e type)
+{
+       switch (type) {
+       case WIFI_MANAGER_SECURITY_TYPE_NONE:
+               return "None";
+       case WIFI_MANAGER_SECURITY_TYPE_WEP:
+               return "WEP";
+       case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
+               return "WPA";
+       case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
+               return "WPA2";
+       case WIFI_MANAGER_SECURITY_TYPE_EAP:
+               return "EAP";
+       }
+
+       return "Unknown";
+}
+
+const char *test_wifi_mgr_conn_state_to_string(wifi_manager_connection_state_e state)
+{
+       switch (state) {
+       case WIFI_MANAGER_CONNECTION_STATE_FAILURE:
+               return "Failure";
+       case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED:
+               return "Disconnected";
+       case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION:
+               return "Association";
+       case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
+               return "Connected";
+       case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION:
+               return "Configuration";
+       }
+
+       return "Unknown";
+}
+
+const char *test_wifi_mgr_convert_error_to_string(wifi_manager_error_e err_type)
+{
+       switch (err_type) {
+       case WIFI_MANAGER_ERROR_NONE:
+               return "NONE";
+       case WIFI_MANAGER_ERROR_INVALID_PARAMETER:
+               return "INVALID_PARAMETER";
+       case WIFI_MANAGER_ERROR_OUT_OF_MEMORY:
+               return "OUT_OF_MEMORY";
+       case WIFI_MANAGER_ERROR_INVALID_OPERATION:
+               return "INVALID_OPERATION";
+       case WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+               return "ADDRESS_FAMILY_NOT_SUPPORTED";
+       case WIFI_MANAGER_ERROR_OPERATION_FAILED:
+               return "OPERATION_FAILED";
+       case WIFI_MANAGER_ERROR_NO_CONNECTION:
+               return "NO_CONNECTION";
+       case WIFI_MANAGER_ERROR_NOW_IN_PROGRESS:
+               return "NOW_IN_PROGRESS";
+       case WIFI_MANAGER_ERROR_ALREADY_EXISTS:
+               return "ALREADY_EXISTS";
+       case WIFI_MANAGER_ERROR_OPERATION_ABORTED:
+               return "OPERATION_ABORTED";
+       case WIFI_MANAGER_ERROR_DHCP_FAILED:
+               return "DHCP_FAILED";
+       case WIFI_MANAGER_ERROR_INVALID_KEY:
+               return "INVALID_KEY";
+       case WIFI_MANAGER_ERROR_OUT_OF_RANGE:
+               return "OUT_OF_RANGE";
+       case WIFI_MANAGER_ERROR_PIN_MISSING:
+               return "PIN_MISSING";
+       case WIFI_MANAGER_ERROR_CONNECT_FAILED:
+               return "CONNECT_FAILED";
+       case WIFI_MANAGER_ERROR_LOGIN_FAILED:
+               return "LOGIN_FAILED";
+       case WIFI_MANAGER_ERROR_AUTHENTICATION_FAILED:
+               return "AUTH_FAILED";
+       case WIFI_MANAGER_ERROR_NO_REPLY:
+               return "NO_REPLY";
+       case WIFI_MANAGER_ERROR_SECURITY_RESTRICTED:
+               return "SECURITY_RESTRICTED";
+       case WIFI_MANAGER_ERROR_ALREADY_INITIALIZED:
+               return "ALREADY_INITIALIZED";
+       case WIFI_MANAGER_ERROR_PERMISSION_DENIED:
+               return "PERMISSION_DENIED";
+       case WIFI_MANAGER_ERROR_NOT_SUPPORTED:
+               return "NOT_SUPPORTED";
+       case WIFI_MANAGER_ERROR_WPS_OVERLAP:
+               return "WPS_OVERLAP";
+       case WIFI_MANAGER_ERROR_WPS_TIMEOUT:
+               return "WPS_TIMEOUT";
+       case WIFI_MANAGER_ERROR_WPS_WEP_PROHIBITED:
+               return "WPS_WEP_PROHIBITED";
+       default:
+               return "UNKNOWN";
+       }
+}
+
+int main(int arg, char **argv)
+{
+       GMainLoop *mainloop = NULL;
+       GIOChannel *channel = g_io_channel_unix_new(STDIN_FILENO);
+       MManager *manager;
+       struct menu_data init_menu[1+1] = { {NULL, NULL, } };
+
+#if !GLIB_CHECK_VERSION(2, 35, 0)
+       g_type_init();
+#endif
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       msg("");
+       msg(LOG_GREEN "* Wifi Manager Tool " LOG_END);
+       msg("* Build On: %s  %s", __DATE__, __TIME__);
+
+       if (_test_wifi_mgr_create_init_menu(init_menu) == FALSE)
+               goto OUT;
+
+       manager = menu_manager_new(init_menu, mainloop);
+       if (!manager)
+               goto OUT;
+
+       menu_manager_run(manager);
+
+       g_io_add_watch(channel, (G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL),
+                       on_menu_manager_keyboard, manager);
+       g_main_loop_run(mainloop);
+
+OUT:
+       _test_wifi_mgr_deinitialize();
+       g_main_loop_unref(mainloop);
+       msg("******* Bye bye *******");
+
+       return 0;
+}
diff --git a/tool/wifi_mgr_tool.h b/tool/wifi_mgr_tool.h
new file mode 100755 (executable)
index 0000000..35cf118
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_TOOL_H__
+#define __WIFI_MGR_TOOL_H__
+
+#include <glib.h>
+#include <wifi-manager.h>
+#include <wifi-manager-extension.h>
+
+#define MALLOC0(t, n) ((t*) g_try_malloc0((n) * sizeof(t)))
+#define FREE(p) do { \
+       if (p) { \
+               g_free(p); \
+               p = NULL; \
+       } \
+} while (0)
+
+bool test_wifi_mgr_compare_string(const char *str, const char *part);
+const char *test_wifi_mgr_autoscan_mode_to_string(wifi_manager_autoscan_mode_e state);
+const char *test_wifi_mgr_ipconflict_state_to_string(wifi_manager_ip_conflict_state_e state);
+const char *test_wifi_mgr_device_state_to_string(wifi_manager_device_state_e state);
+const char *test_wifi_mgr_module_state_to_string(wifi_manager_module_state_e state);
+const char *test_wifi_mgr_scan_state_to_string(wifi_manager_scan_state_e state);
+const char *test_wifi_mgr_eap_auth_type_to_string(wifi_manager_eap_auth_type_e type);
+const char *test_wifi_mgr_eap_type_to_string(wifi_manager_eap_type_e type);
+const char *test_wifi_mgr_encryption_type_to_string(wifi_manager_encryption_type_e type);
+const char *test_wifi_mgr_dns_config_type_to_string(wifi_manager_dns_config_type_e type);
+const char *test_wifi_mgr_proxy_type_to_string(wifi_manager_proxy_type_e type);
+const char *test_wifi_mgr_ip_config_type_to_string(wifi_manager_ip_config_type_e type);
+const char *test_wifi_mgr_sec_type_to_string(wifi_manager_security_type_e type);
+const char *test_wifi_mgr_conn_state_to_string(wifi_manager_connection_state_e state);
+const char *test_wifi_mgr_convert_error_to_string(wifi_manager_error_e err_type);
+
+#endif /* __WIFI_MGR_TOOL_H__ */