INSTALL(FILES ${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
ADD_SUBDIRECTORY(tools/manager-tool)
+ADD_SUBDIRECTORY(tools/manager-test)
ADD_SUBDIRECTORY(tools/connection-tool)
IF(BUILD_GTESTS)
--- /dev/null
+SET(WIFI_MANAGER_TEST "wifi_manager_test")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
+
+FILE(GLOB WIFI_MANAGER_TEST_SRCS wman*.c)
+ADD_EXECUTABLE(${WIFI_MANAGER_TEST} ${WIFI_MANAGER_TEST_SRCS})
+TARGET_LINK_LIBRARIES(${WIFI_MANAGER_TEST} ${PROJECT_NAME})
+SET_TARGET_PROPERTIES(${WIFI_MANAGER_TEST} PROPERTIES POSITION_INDEPENDENT_CODE ON)
+INSTALL(TARGETS ${WIFI_MANAGER_TEST} DESTINATION ${BIN_INSTALL_DIR})
--- /dev/null
+/*
+ * Copyright (c) 2012-2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "wman_test_ap.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <wifi-manager.h>
+#include "wman_test_common.h"
+#include "wman_test_extension.h"
+
+int wman_test_get_connected_ap(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ wifi_manager_ap_h ap_h;
+
+ rv = wifi_manager_get_connected_ap(wifi, &ap_h);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get connected AP [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ rv = wifi_manager_ap_get_essid(ap_h, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get essid [%s]\n", wman_test_strerror(rv));
+ wifi_manager_ap_destroy(ap_h);
+ return -1;
+ }
+
+ printf("Connected AP : %s\n", ap_name);
+ free(ap_name);
+ wifi_manager_ap_destroy(ap_h);
+
+ return 1;
+}
+
+static const char* __test_print_state(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";
+}
+
+static bool __test_found_ap_cb(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ wifi_manager_connection_state_e state;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", wman_test_strerror(rv));
+ return false;
+ }
+
+ rv = wifi_manager_ap_get_connection_state(ap, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get State [%s]\n", wman_test_strerror(rv));
+ free(ap_name);
+ return false;
+ }
+
+ printf("AP name : %s, state : %s\n", ap_name, __test_print_state(state));
+ free(ap_name);
+
+ return true;
+}
+
+int wman_test_foreach_found_ap(wifi_manager_h wifi)
+{
+ int rv = 0;
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_ap_cb, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP list [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Get AP list finished\n");
+
+ return 1;
+}
+
+static bool __test_found_connect_ap_cb(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ struct wman_public_info *data = user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", wman_test_strerror(rv));
+ return false;
+ }
+
+ if (wman_test_compare_ap_name(ap_name, data->name)) {
+ bool required = false;
+ data->is_found = true;
+
+ if (wifi_manager_ap_is_passphrase_required(ap, &required) == WIFI_MANAGER_ERROR_NONE)
+ printf("Passphrase required : %s\n", required ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get Passphrase required\n");
+
+ if (required) {
+ char passphrase[100];
+ printf("Input passphrase for %s : ", ap_name);
+ rv = scanf(" %99s", passphrase);
+
+ rv = wifi_manager_ap_set_passphrase(ap, passphrase);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set passphrase : %s\n", wman_test_strerror(rv));
+ free(ap_name);
+ return false;
+ }
+ }
+
+ rv = wifi_manager_connect(data->wifi, ap, wman_test_connected_cb, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to connection request [%s] : %s\n", ap_name, wman_test_strerror(rv));
+ else
+ printf("Success to connection request [%s]\n", ap_name);
+
+ free(ap_name);
+ return false;
+ }
+
+ free(ap_name);
+ return true;
+}
+
+int wman_test_connect(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+ struct wman_public_info data = {wifi, ap_name};
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to connect : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+ data.is_found = false;
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_connect_ap_cb, &data);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to connect (can't get AP list) [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ if (!data.is_found) {
+ printf("%s is not found\n", ap_name);
+ return -1;
+ }
+ printf("Connection step finished\n");
+ return 1;
+}
+
+static void __test_disconnected_cb(wifi_manager_error_e result, void* user_data)
+{
+ if (result == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi Disconnection Succeeded\n");
+ else
+ printf("Wi-Fi Disconnection Failed! error : %s\n", wman_test_strerror(result));
+}
+
+static bool __test_found_disconnect_ap_cb(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part;
+ struct wman_public_info *data = user_data;
+
+ ap_name_part = data->name;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", wman_test_strerror(rv));
+ return false;
+ }
+
+ if (wman_test_compare_ap_name(ap_name, ap_name_part)) {
+ rv = wifi_manager_disconnect(data->wifi, ap, __test_disconnected_cb, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to disconnection reqeust %s : [%s]\n", ap_name, wman_test_strerror(rv));
+ else
+ printf("Success to disconnection request %s\n", ap_name);
+
+ free(ap_name);
+ return false;
+ }
+
+ free(ap_name);
+ return true;
+}
+
+int wman_test_disconnect(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+ struct wman_public_info data = {wifi, ap_name};
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to disconnect : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_disconnect_ap_cb, &data);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to disconnect (can't get AP list) [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Disconnection step finished\n");
+ return 1;
+}
+
+static bool __test_found_connect_wps_cb(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part;
+ struct wman_public_info *data = user_data;
+
+ ap_name_part = data->name;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", wman_test_strerror(rv));
+ return false;
+ }
+
+ if (wman_test_compare_ap_name(ap_name, ap_name_part)) {
+ int user_sel;
+ char pin[32] = {0,};
+
+ printf("%s - Input WPS method (1:PBC, 2:PIN) :\n", ap_name);
+ rv = scanf(" %9d", &user_sel);
+
+ switch (user_sel) {
+ case 1:
+ rv = wifi_manager_connect_by_wps_pbc(data->wifi, ap, wman_test_connected_cb, NULL);
+ break;
+ case 2:
+ printf("Input PIN code :\n");
+ rv = scanf("%31s", pin);
+ rv = wifi_manager_connect_by_wps_pin(data->wifi, ap, pin, wman_test_connected_cb, NULL);
+ break;
+ default:
+ printf("Invalid input!\n");
+ free(ap_name);
+ return false;
+ }
+
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to connection request [%s] : %s\n", ap_name, wman_test_strerror(rv));
+ else
+ printf("Success to connection request [%s]\n", ap_name);
+
+ free(ap_name);
+ return false;
+ }
+
+ free(ap_name);
+ return true;
+}
+
+int wman_test_connect_wps(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+ struct wman_public_info data = {wifi, ap_name};
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to connect by wps : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_connect_wps_cb, &data);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to connect (can't get AP list) [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Connection step finished\n");
+ return 1;
+}
+
+static bool __test_found_forget_ap_cb(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part;
+ struct wman_public_info *data = user_data;
+
+ ap_name_part = data->name;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", wman_test_strerror(rv));
+ return false;
+ }
+
+ if (wman_test_compare_ap_name(ap_name, ap_name_part)) {
+ rv = wifi_manager_forget_ap(data->wifi, ap);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to forget [%s] : %s\n", ap_name, wman_test_strerror(rv));
+ else
+ printf("Success to forget [%s]\n", ap_name);
+
+ free(ap_name);
+ return false;
+ }
+
+ free(ap_name);
+ return true;
+}
+
+int wman_test_forget_ap(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+ struct wman_public_info data = {wifi, ap_name};
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to forget : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_forget_ap_cb, &data);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to forget (can't get AP list) [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Forget AP finished\n");
+
+ return 1;
+}
+
+static bool __test_found_eap_ap_cb(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part;
+ struct wman_public_info *data = user_data;
+
+ ap_name_part = data->name;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", wman_test_strerror(rv));
+ return false;
+ }
+
+ if (wman_test_compare_ap_name(ap_name, ap_name_part)) {
+ wifi_manager_security_type_e type;
+
+ if (wifi_manager_ap_get_security_type(ap, &type) == WIFI_MANAGER_ERROR_NONE)
+ printf("Security type : %d\n", type);
+ else
+ printf("Fail to get Security type\n");
+
+ if (type != WIFI_MANAGER_SECURITY_TYPE_EAP) {
+ free(ap_name);
+ return false;
+ }
+
+ char input_str1[100];
+ printf("Input user name for %s : ", ap_name);
+ rv = scanf(" %99s", input_str1);
+
+ char input_str2[100];
+ printf("Input password for %s : ", ap_name);
+ rv = scanf("%99s", input_str2);
+
+ rv = wifi_manager_ap_set_eap_passphrase(ap, input_str1, input_str2);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set eap passphrase : %s\n", wman_test_strerror(rv));
+ free(ap_name);
+ return false;
+ }
+
+ char *inputed_name = NULL;
+ bool is_pass_set;
+ rv = wifi_manager_ap_get_eap_passphrase(ap, &inputed_name, &is_pass_set);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get eap passphrase : %s\n", wman_test_strerror(rv));
+ free(ap_name);
+ return false;
+ }
+
+ printf("name : %s, is password set : %s\n", inputed_name, is_pass_set ? "TRUE" : "FALSE");
+
+ int input_int;
+ printf("Input EAP type:\n");
+ printf("0 -> WIFI_MANAGER_EAP_TYPE_PEAP\n");
+ printf("1 -> WIFI_MANAGER_EAP_TYPE_TLS\n");
+ printf("2 -> WIFI_MANAGER_EAP_TYPE_TTLS\n");
+ printf("3 -> WIFI_MANAGER_EAP_TYPE_SIM\n");
+ printf("4 -> WIFI_MANAGER_EAP_TYPE_AKA\n");
+ printf("5 -> WIFI_MANAGER_EAP_TYPE_AKA_PRIME\n");
+ printf("6 -> WIFI_MANAGER_EAP_TYPE_FAST\n");
+ printf("7 -> WIFI_MANAGER_EAP_TYPE_PWD\n");
+ rv = scanf("%d", &input_int);
+
+ rv = wifi_manager_ap_set_eap_type(ap, input_int);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set eap type : %s\n", wman_test_strerror(rv));
+ free(ap_name);
+ free(inputed_name);
+ return false;
+ }
+
+ if (input_int == 0 || input_int == 1 || input_int == 2) {
+ printf("Input certificate file:\n");
+ rv = scanf("%99s", input_str1);
+
+ rv = wifi_manager_ap_set_eap_ca_cert_file(ap, input_str1);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set eap certificatefile : %s\n", wman_test_strerror(rv));
+ free(ap_name);
+ free(inputed_name);
+ return false;
+ }
+ }
+
+ printf("Input EAP authentication type:\n");
+ printf("0 -> WIFI_MANAGER_EAP_AUTH_TYPE_NONE\n");
+ printf("1 -> WIFI_MANAGER_EAP_AUTH_TYPE_PAP\n");
+ printf("2 -> WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAP\n");
+ printf("3 -> WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAPV2\n");
+ printf("4 -> WIFI_MANAGER_EAP_AUTH_TYPE_GTC\n");
+ printf("5 -> WIFI_MANAGER_EAP_AUTH_TYPE_MD5\n");
+ rv = scanf("%d", &input_int);
+
+ rv = wifi_manager_ap_set_eap_auth_type(ap, input_int);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set eap auth type : %s\n", wman_test_strerror(rv));
+ free(ap_name);
+ free(inputed_name);
+ return false;
+ }
+
+ rv = wifi_manager_connect(data->wifi, ap, wman_test_connected_cb, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to connection request [%s] : %s\n", ap_name, wman_test_strerror(rv));
+ else
+ printf("Success to connection request [%s]\n", ap_name);
+
+ free(ap_name);
+ free(inputed_name);
+ return false;
+ }
+
+ free(ap_name);
+ return true;
+}
+
+int wman_test_connect_eap_ap(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+ struct wman_public_info data = {wifi, ap_name};
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to connect : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_eap_ap_cb, &data);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to connect (can't get AP list) [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Connection step finished\n");
+ return 1;
+}
+
+static inline int __test_found_change_ip_method_cb_ip_static(wifi_manager_ap_h ap, int address_type)
+{
+ int rv;
+ int dns_type;
+ int prefix_len;
+ char ip_addr[40];
+
+ printf("Input new ip address (x:skip, 0:clear) :\n");
+ rv = scanf("%39s", ip_addr);
+ if (rv > 0) {
+ switch (ip_addr[0]) {
+ case 'x':
+ rv = WIFI_MANAGER_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_manager_ap_set_ip_address(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_ap_set_ip_address(ap, address_type, ip_addr);
+ }
+
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to set ip address[%s]\n", wman_test_strerror(rv));
+ }
+
+ printf("Input new subnet mask (x:skip, 0:clear) :\n");
+ rv = scanf("%39s", ip_addr);
+ if (rv > 0) {
+ switch (ip_addr[0]) {
+ case 'x':
+ rv = WIFI_MANAGER_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_manager_ap_set_subnet_mask(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_ap_set_subnet_mask(ap, address_type, ip_addr);
+ }
+
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to set subnet mask[%s]\n", wman_test_strerror(rv));
+ }
+
+ printf("Input new prefix length (x:skip) :\n");
+ rv = scanf("%d", &prefix_len);
+ if (rv > 0) {
+ if (prefix_len == 'x')
+ rv = WIFI_MANAGER_ERROR_NONE;
+ else
+ rv = wifi_manager_ap_set_prefix_length(ap, address_type, prefix_len);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to set subnet mask[%s]\n", wman_test_strerror(rv));
+ }
+
+ printf("Input new gateway address (x:skip, 0:clear) :\n");
+ rv = scanf("%39s", ip_addr);
+ if (rv > 0) {
+ switch (ip_addr[0]) {
+ case 'x':
+ rv = WIFI_MANAGER_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_manager_ap_set_gateway_address(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_ap_set_gateway_address(ap, address_type, ip_addr);
+ }
+
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to set gateway address[%s]\n", wman_test_strerror(rv));
+ }
+
+ rv = test_get_user_int("Input DNS config type (0:STATIC, 1:DYNAMIC)"
+ "- (Enter for skip) : ", &dns_type);
+ if (rv == false) {
+ printf("Invalid input!!\n");
+ return -1;
+ }
+ switch (dns_type) {
+ case 0:
+ rv = wifi_manager_ap_set_dns_config_type(ap,
+ address_type, WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC);
+ if (rv == WIFI_MANAGER_ERROR_NONE) {
+ printf("Input DNS1 address (x: skip, 0: clear) : \n");
+ if (address_type == WIFI_MANAGER_ADDRESS_FAMILY_IPV4)
+ rv = scanf("%15s", ip_addr);
+ else
+ rv = scanf("%39s", ip_addr);
+ if (rv > 0) {
+ switch (ip_addr[0]) {
+ case 'x':
+ rv = WIFI_MANAGER_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_manager_ap_set_dns_address(ap,
+ 1, address_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_ap_set_dns_address(ap,
+ 1, address_type, ip_addr);
+ break;
+ }
+ }
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ return -1;
+ }
+
+ printf("Input DNS2 address (x: skip, 0: clear) : \n");
+ if (address_type == WIFI_MANAGER_ADDRESS_FAMILY_IPV4)
+ rv = scanf("%15s", ip_addr);
+ else
+ rv = scanf("%39s", ip_addr);
+ if (rv > 0) {
+ switch (ip_addr[0]) {
+ case 'x':
+ rv = WIFI_MANAGER_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_manager_ap_set_dns_address(ap,
+ 2, address_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_ap_set_dns_address(ap,
+ 2, address_type, ip_addr);
+ break;
+ }
+ }
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ return -1;
+ }
+ }
+ break;
+ case 1:
+ rv = wifi_manager_ap_set_dns_config_type(ap,
+ address_type, WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ return -1;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+static bool __test_found_change_ip_method_cb(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv;
+ char *ap_name;
+ char *ap_name_part;
+ struct wman_public_info *data = user_data;
+
+ ap_name_part = data->name;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", wman_test_strerror(rv));
+ return false;
+ }
+
+ bool same = wman_test_compare_ap_name(ap_name, ap_name_part);
+ if (false == same) {
+ free(ap_name);
+ return true;
+ }
+ wifi_manager_ip_config_type_e type;
+ int method;
+ int address_type;
+
+ printf("Input new method type (1:dhcp, 2:manual, 3:auto) :\n");
+ rv = scanf(" %9d", &method);
+ if (rv <= 0) {
+ free(ap_name);
+ return false;
+ }
+
+ rv = test_get_user_int("Input Address type to get"
+ "(0:IPV4, 1:IPV6):", &address_type);
+
+ if (rv == false || (address_type != 0 && address_type != 1)) {
+ printf("Invalid input!!\n");
+ free(ap_name);
+ return false;
+ }
+
+ switch (method) {
+ case 1:
+ type = WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC;
+ break;
+ case 2:
+ type = WIFI_MANAGER_IP_CONFIG_TYPE_STATIC;
+ break;
+ case 3:
+ type = WIFI_MANAGER_IP_CONFIG_TYPE_AUTO;
+ break;
+ default:
+ printf("Invalid input!\n");
+ free(ap_name);
+ return false;
+ }
+
+ rv = wifi_manager_ap_set_ip_config_type(ap, address_type, type);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to set ip method type[%s]\n", wman_test_strerror(rv));
+
+ if (type == WIFI_MANAGER_IP_CONFIG_TYPE_STATIC) {
+ if (__test_found_change_ip_method_cb_ip_static(ap, address_type) < 0) {
+ free(ap_name);
+ return false;
+ }
+ }
+
+ rv = wifi_manager_update_ap(data->wifi, ap);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to update ap info[%s]\n", wman_test_strerror(rv));
+
+ free(ap_name);
+ return false;
+}
+
+int wman_test_set_ip_method(wifi_manager_h wifi)
+{
+ int rv;
+ bool state;
+ char ap_name[33];
+ struct wman_public_info data = {wifi, ap_name};
+
+ rv = wifi_manager_is_activated(wifi, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE || state == false)
+ return -1;
+
+ printf("Input a part of AP name to change IP method : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_change_ip_method_cb, &data);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to change (can't get AP list) [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("IP method changing finished\n");
+ return 1;
+}
+
+static bool __test_found_change_proxy_method_cb(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv;
+ int address_type;
+ char *ap_name;
+ char *ap_name_part;
+ struct wman_public_info *data = user_data;
+
+ ap_name_part = data->name;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", wman_test_strerror(rv));
+ return false;
+ }
+
+ printf("name %s, user input name %s\n", ap_name, ap_name_part);
+ if (wman_test_compare_ap_name(ap_name, ap_name_part)) {
+ wifi_manager_proxy_type_e type;
+ char proxy_addr[65];
+ int method;
+
+ printf("Input new method type (1:direct, 2:manual, 3:auto) :\n");
+ rv = scanf(" %9d", &method);
+ if (rv <= 0) {
+ free(ap_name);
+ return false;
+ }
+
+ rv = test_get_user_int("Input Address type to get"
+ "(0:IPV4, 1:IPV6):", &address_type);
+
+ if (rv == false || (address_type != 0 && address_type != 1)) {
+ printf("Invalid input!!\n");
+ free(ap_name);
+ return false;
+ }
+
+ switch (method) {
+ case 1:
+ type = WIFI_MANAGER_PROXY_TYPE_DIRECT;
+ break;
+ case 2:
+ type = WIFI_MANAGER_PROXY_TYPE_MANUAL;
+ break;
+ case 3:
+ type = WIFI_MANAGER_PROXY_TYPE_AUTO;
+ break;
+ default:
+ printf("Invalid input!\n");
+ free(ap_name);
+ return false;
+ }
+
+ rv = wifi_manager_ap_set_proxy_type(ap, type);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to set proxy method type[%s]\n", wman_test_strerror(rv));
+
+ printf("Input new proxy address (x:skip, 0:clear) :\n");
+ rv = scanf("%64s", proxy_addr);
+
+ if (rv > 0) {
+ switch (proxy_addr[0]) {
+ case 'x':
+ rv = WIFI_MANAGER_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_manager_ap_set_proxy_address(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_ap_set_proxy_address(ap, address_type, proxy_addr);
+ }
+
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to set proxy address[%s]\n", wman_test_strerror(rv));
+ }
+
+ rv = wifi_manager_update_ap(data->wifi, ap);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to update ap info[%s]\n", wman_test_strerror(rv));
+
+ free(ap_name);
+ return false;
+ }
+
+ free(ap_name);
+ return true;
+}
+
+int wman_test_set_proxy_method(wifi_manager_h wifi)
+{
+ int rv;
+ bool state;
+ char ap_name[33];
+ struct wman_public_info data = {wifi, ap_name};
+
+ rv = wifi_manager_is_activated(wifi, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE || state == false)
+ return -1;
+
+ printf("Input a part of AP name to change Proxy method : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_change_proxy_method_cb, &data);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to change (can't get AP list) [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Proxy method changing finished\n");
+ return 1;
+}
+
+static bool __test_ipv6_address_cb(char *ipv6_address, void *user_data)
+{
+ printf("IPv6 address: %s\n", ipv6_address);
+ return true;
+}
+
+static inline int __test_found_print_ap_network_info_cb(wifi_manager_ap_h ap)
+{
+ int rv;
+ int int_value;
+ int address_type = 0;
+ char *str_value;
+ wifi_manager_connection_state_e conn_state;
+
+ if (wifi_manager_ap_get_connection_state(ap, &conn_state) == WIFI_MANAGER_ERROR_NONE)
+ printf("Connection State : %d\n", conn_state);
+ else
+ printf("Fail to get Connection State\n");
+
+ rv = test_get_user_int("Input Address type to get(0:IPV4, 1:IPV6):", &address_type);
+ if (rv == false || (address_type != 0 && address_type != 1)) {
+ printf("Invalid input!!\n");
+ return -1;
+ }
+
+ wifi_manager_ip_config_type_e ip_type;
+ if (wifi_manager_ap_get_ip_config_type(ap, address_type, &ip_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("IP config type : %d\n", ip_type);
+ else
+ printf("Fail to get IP config type\n");
+
+ if (wifi_manager_ap_get_ip_address(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("IP : %s\n", str_value);
+ free(str_value);
+ } else {
+ printf("Fail to get IP : %s\n", str_value);
+ free(str_value);
+ }
+
+ if (address_type == WIFI_MANAGER_ADDRESS_FAMILY_IPV6) {
+ if (wifi_manager_ap_foreach_ipv6_address(ap, __test_ipv6_address_cb, NULL)
+ != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to get multiple IPv6 address\n");
+ }
+
+ if (wifi_manager_ap_get_subnet_mask(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("Subnet mask : %s\n", str_value);
+ free(str_value);
+ } else
+ printf("Fail to get Subnet mask\n");
+
+ if (wifi_manager_ap_get_prefix_length(ap, address_type, &int_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("Prefix length : %d\n", int_value);
+ else
+ printf("Fail to get Subnet mask\n");
+
+ if (wifi_manager_ap_get_gateway_address(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("Gateway : %s\n", str_value);
+ free(str_value);
+ } else
+ printf("Fail to get Gateway\n");
+
+ if (address_type == 0) {
+ if (wifi_manager_ap_get_dhcp_server_address(ap, address_type, &str_value) ==
+ WIFI_MANAGER_ERROR_NONE) {
+ printf("DHCP Server : %s\n", str_value);
+ free(str_value);
+ } else
+ printf("Fail to get DHCP Server\n");
+ if (wifi_manager_ap_get_dhcp_lease_duration(ap, address_type, &int_value) ==
+ WIFI_MANAGER_ERROR_NONE) {
+ printf("DHCP Lease duration : %d\n", int_value);
+ } else
+ printf("Fail to get DHCP lease duration\n");
+ }
+
+ wifi_manager_proxy_type_e proxy_type;
+ if (wifi_manager_ap_get_proxy_type(ap, &proxy_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("Proxy type : %d\n", proxy_type);
+ else
+ printf("Fail to get Proxy type\n");
+
+ if (wifi_manager_ap_get_proxy_address(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("Proxy : %s\n", str_value);
+ free(str_value);
+ } else
+ printf("Fail to get Proxy\n");
+
+ wifi_manager_dns_config_type_e dns_type;
+ if (wifi_manager_ap_get_dns_config_type(ap, address_type, &dns_type) == WIFI_MANAGER_ERROR_NONE) {
+ if (dns_type == WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC)
+ printf("DNS config type : STATIC\n");
+ else if (dns_type == WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC)
+ printf("DNS config type : DYNAMIC\n");
+ else
+ printf("DNS config type : %d\n", dns_type);
+ } else
+ printf("Fail to get DNS config type\n");
+
+ if (wifi_manager_ap_get_dns_address(ap, 1, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("DNS1 : %s\n", str_value);
+ free(str_value);
+ } else
+ printf("Fail to get DNS1\n");
+
+ if (wifi_manager_ap_get_dns_address(ap, 2, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("DNS2 : %s\n", str_value);
+ free(str_value);
+ } else
+ printf("Fail to get DNS2\n");
+
+ return 0;
+}
+
+static inline int __test_found_print_ap_security_info_cb(wifi_manager_ap_h ap)
+{
+ bool bool_value;
+ char *str_value;
+ wifi_manager_security_type_e sec_type;
+ wifi_manager_encryption_type_e enc_type;
+
+ if (wifi_manager_ap_get_security_type(ap, &sec_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("Security type : %d\n", sec_type);
+ else
+ printf("Fail to get Security type\n");
+
+ if (wifi_manager_ap_get_encryption_type(ap, &enc_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("Encryption type : %d\n", enc_type);
+ else
+ printf("Fail to get Encryption type\n");
+
+ if (wifi_manager_ap_is_passphrase_required(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("Passphrase required : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get Passphrase required\n");
+
+ if (wifi_manager_ap_is_wps_supported(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("WPS supported : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get WPS supported\n");
+
+ if (wifi_manager_ap_is_passpoint(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("Passpoint enabled : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get passpoint state\n");
+
+ if (wifi_manager_ap_get_countrycode(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ if (str_value) {
+ printf("Country Code : %s\n", str_value);
+ free(str_value);
+ } else
+ printf("Country code is NULL\n");
+ } else
+ printf("Fail to get Country code\n");
+
+ return sec_type;
+}
+
+static inline void __test_found_print_ap_EAP_info_cb(wifi_manager_ap_h ap)
+{
+ bool bool_value;
+ char *str_value;
+ wifi_manager_eap_type_e eap_type;
+ wifi_manager_eap_auth_type_e eap_auth_type;
+
+ if (wifi_manager_ap_get_eap_type(ap, &eap_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("EAP type : %d\n", eap_type);
+ else
+ printf("Fail to get EAP type\n");
+
+ if (wifi_manager_ap_get_eap_auth_type(ap, &eap_auth_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("EAP auth type : %d\n", eap_auth_type);
+ else
+ printf("Fail to get EAP auth type\n");
+
+ if (wifi_manager_ap_get_eap_passphrase(ap, &str_value, &bool_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("EAP user name : %s\n", str_value);
+ printf("EAP is password setted : %s\n", bool_value ? "TRUE" : "FALSE");
+ free(str_value);
+ } else
+ printf("Fail to get EAP passphrase(user name/password)\n");
+
+ if (wifi_manager_ap_get_eap_ca_cert_file(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("EAP ca cert file : %s\n", str_value);
+ free(str_value);
+ } else
+ printf("Fail to get EAP ca cert file\n");
+
+ if (wifi_manager_ap_get_eap_client_cert_file(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("EAP client cert file : %s\n", str_value);
+ free(str_value);
+ } else
+ printf("Fail to get EAP client cert file\n");
+
+ if (wifi_manager_ap_get_eap_private_key_file(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("EAP private key file : %s\n", str_value);
+ free(str_value);
+ } else
+ printf("Fail to get EAP private key file\n");
+}
+
+static bool __test_found_bssid_list_cb(const char *bssid, int rssi, int freq, void *user_data)
+{
+ printf("-> BSSID : %s, RSSI : %d, Frequency : %d\n", bssid, rssi, freq);
+ return true;
+}
+
+static inline void __test_found_print_ap_basic_info_cb(wifi_manager_ap_h ap)
+{
+ int int_value;
+ bool bool_value;
+ char *str_value;
+ wifi_manager_rssi_level_e rssi_level;
+
+ if (wifi_manager_ap_get_bssid(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("BSSID : %s\n", str_value);
+ free(str_value);
+ } else
+ printf("Fail to get BSSID\n");
+
+ if (wifi_manager_foreach_found_bssid(ap, __test_found_bssid_list_cb, NULL) != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to get BSSID list data\n");
+
+ if (wifi_manager_ap_get_rssi(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("RSSI : %d\n", int_value);
+ else
+ printf("Fail to get RSSI\n");
+
+ if (wifi_manager_ap_get_rssi_level(ap, &rssi_level) == WIFI_MANAGER_ERROR_NONE)
+ printf("RSSI level : %d\n", rssi_level);
+ else
+ printf("Fail to get RSSI level\n");
+
+ // extension API
+ wman_test_print_connection_mode(ap);
+
+ if (wifi_manager_ap_get_frequency(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("Frequency : %d\n", int_value);
+ else
+ printf("Fail to get Frequency\n");
+
+ if (wifi_manager_ap_foreach_vsie(ap, __test_vendor_specific_cb, NULL)
+ != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to get vsie\n");
+
+ if (wifi_manager_ap_get_max_speed(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("Max speed : %d\n", int_value);
+ else
+ printf("Fail to get Max speed\n");
+
+ if (wifi_manager_ap_is_favorite(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("Favorite : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get Favorite\n");
+
+ if (wifi_manager_ap_is_hidden(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("Hidden Status : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get hidden status\n");
+
+ wifi_manager_disconnect_reason_e disconnect_reason;
+ if (wifi_manager_ap_get_disconnect_reason(ap, &disconnect_reason)
+ == WIFI_MANAGER_ERROR_NONE)
+ printf("Disconnect reason : %d\n", disconnect_reason);
+ else
+ printf("Fail to get disconnect reason\n");
+
+ wifi_manager_assoc_status_code_e status_code;
+ if (wifi_manager_ap_get_assoc_status_code(ap, &status_code)
+ == WIFI_MANAGER_ERROR_NONE)
+ printf("Association Status Code : %d\n", status_code);
+ else
+ printf("Fail to get association status code\n");
+
+ if (wifi_manager_ap_get_error_state(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("error state of AP : %s\n", wman_test_strerror(int_value));
+ else
+ printf("Fail to get error state of AP\n");
+}
+
+static bool __test_found_print_ap_info_cb(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv;
+ char *ap_name;
+ wifi_manager_security_type_e sec_type;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", wman_test_strerror(rv));
+ return false;
+ }
+
+ printf("name %s, user input name %s\n", ap_name, ap_name_part);
+ if (wman_test_compare_ap_name(ap_name, ap_name_part)) {
+ /* Basic info */
+ printf("ESSID : %s\n", ap_name);
+ __test_found_print_ap_basic_info_cb(ap);
+
+ /* Network info */
+ if (__test_found_print_ap_network_info_cb(ap) < 0) {
+ free(ap_name);
+ return false;
+ }
+
+ /* Security info */
+ sec_type = __test_found_print_ap_security_info_cb(ap);
+ if (sec_type != WIFI_MANAGER_SECURITY_TYPE_EAP) {
+ free(ap_name);
+ return false;
+ }
+
+ /* EAP info */
+ __test_found_print_ap_EAP_info_cb(ap);
+
+ free(ap_name);
+ return false;
+ }
+
+ free(ap_name);
+ return true;
+}
+
+int wman_test_get_ap_info(wifi_manager_h wifi)
+{
+ int rv;
+ char ap_name[33];
+ bool state;
+
+ rv = wifi_manager_is_activated(wifi, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE || state == false)
+ return -1;
+
+ printf("Input a part of AP name to get detailed info : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_print_ap_info_cb, ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP info (can't get AP list) [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("AP info printing finished\n");
+ return 1;
+}
+
+static bool __test_found_specific_ap_cb(wifi_manager_ap_h ap, void *user_data)
+{
+ printf("Found specific ap Completed\n");
+
+ int rv;
+ char *ap_name = NULL;
+ wifi_manager_h wifi = user_data;
+ wifi_manager_security_type_e security_type = WIFI_MANAGER_SECURITY_TYPE_NONE;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+ printf("[AP name] : %s\n", ap_name);
+
+ rv = wifi_manager_ap_get_security_type(ap, &security_type);
+ if (rv == WIFI_MANAGER_ERROR_NONE)
+ printf("[Security type] : %d\n", security_type);
+ else {
+ printf("Fail to get Security type\n");
+ free(ap_name);
+ return false;
+ }
+
+ switch (security_type) {
+ case WIFI_MANAGER_SECURITY_TYPE_WEP:
+ case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
+ case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
+ case WIFI_MANAGER_SECURITY_TYPE_SAE:
+ {
+ char passphrase[100];
+ printf("Input passphrase for %s : ", ap_name);
+ rv = scanf(" %99s", passphrase);
+
+ rv = wifi_manager_ap_set_passphrase(ap, passphrase);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set passphrase : %s\n", wman_test_strerror(rv));
+ free(ap_name);
+ return false;
+ }
+ }
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_EAP:
+ {
+ char input_str1[100];
+ printf("Input user name for %s : ", ap_name);
+ rv = scanf(" %99s", input_str1);
+
+ char input_str2[100];
+ printf("Input password for %s : ", ap_name);
+ rv = scanf("%99s", input_str2);
+
+ rv = wifi_manager_ap_set_eap_passphrase(ap, input_str1, input_str2);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set eap passphrase : %s\n", wman_test_strerror(rv));
+ free(ap_name);
+ return false;
+ }
+
+ char *inputed_name = NULL;
+ bool is_pass_set;
+ rv = wifi_manager_ap_get_eap_passphrase(ap, &inputed_name, &is_pass_set);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get eap passphrase : %s\n", wman_test_strerror(rv));
+ free(ap_name);
+ return false;
+ }
+
+ printf("name : %s, is password set : %s\n", inputed_name, is_pass_set ? "TRUE" : "FALSE");
+ free(inputed_name);
+ }
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_NONE:
+ case WIFI_MANAGER_SECURITY_TYPE_OWE:
+ default:
+ break;
+ }
+
+ rv = wifi_manager_connect(wifi, ap, wman_test_connected_cb, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to connection request [%s] : %s\n", ap_name, wman_test_strerror(rv));
+ else
+ printf("Success to connection request [%s]\n", ap_name);
+
+ free(ap_name);
+ return true;
+}
+
+static void __test_scan_specific_ap_cb(wifi_manager_error_e error_code, void* user_data)
+{
+ int rv;
+ wifi_manager_h wifi = user_data;
+
+ printf("Specific scan Completed from scan request, error code : %s\n",
+ wman_test_strerror(error_code));
+
+ if (error_code != WIFI_MANAGER_ERROR_NONE)
+ return;
+
+ rv = wifi_manager_foreach_found_specific_ap(wifi, __test_found_specific_ap_cb, user_data);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get specific AP(can't get AP list) [%s]\n", wman_test_strerror(rv));
+ return;
+ }
+}
+
+int wman_test_connect_specific_ap(wifi_manager_h wifi)
+{
+ int rv;
+ char ap_name[33];
+
+ printf("Input a part of specific AP name to connect : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_scan_specific_ap(wifi, ap_name, __test_scan_specific_ap_cb, wifi);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Scan request failed [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Scan specific AP request succeeded\n");
+ return 1;
+}
+
+int wman_test_connect_hidden_ap(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char ap_name[33];
+ char passphrase[65];
+ bool state = false;
+ int sec_type;
+
+ rv = wifi_manager_is_activated(wifi, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE || state == false)
+ return -1;
+
+ printf("Input hidden AP name to connect : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+ printf("Input Security Type :\n");
+ printf("0 -> WIFI_SECURITY_TYPE_NONE\n");
+ printf("1 -> WIFI_SECURITY_TYPE_WEP\n");
+ printf("2 -> WIFI_SECURITY_TYPE_WPA_PSK/WIFI_SECURITY_TYPE_WPA2_PSK\n");
+
+ rv = scanf(" %d", &sec_type);
+ if (sec_type == 1 || sec_type == 2) {
+ printf("Input hidden AP passphrase : ");
+ rv = scanf("%64s", passphrase);
+ }
+
+ rv = wifi_manager_connect_hidden_ap(wifi, ap_name, sec_type, passphrase,
+ wman_test_connected_cb, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to connect to hidden AP [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Hidden Connection step finished\n");
+ return 1;
+}
+
+static bool __test_get_bssid_scan_list(wifi_manager_ap_h ap, void *user_data)
+{
+ char *bssid;
+ char *essid;
+ int rssi;
+
+ if (wifi_manager_ap_get_bssid(ap, &bssid) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get bssid for ap\n");
+ return false;
+ }
+
+ if (wifi_manager_ap_get_essid(ap, &essid) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get essid for ap\n");
+ free(bssid);
+ return false;
+ }
+
+ if (wifi_manager_ap_get_rssi(ap, &rssi) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get rssi for ap\n");
+ free(bssid);
+ free(essid);
+ return false;
+ }
+
+ printf("bssid : %s, essid : %s, rssi : %d\n",
+ bssid, essid, rssi);
+
+ free(bssid);
+ free(essid);
+ return true;
+}
+
+static int __test_foreach_bssid_scan(wifi_manager_h wifi)
+{
+ int rv;
+
+ rv = wifi_manager_foreach_found_bssid_ap(wifi,
+ __test_get_bssid_scan_list, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get wps scan list [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+static void __test_bssid_scan_request_cb(wifi_manager_error_e error_code, void *user_data)
+{
+ wifi_manager_h wifi = user_data;
+ printf("BSSID Scan Completed, error code : %s\n", wman_test_strerror(error_code));
+
+ if (error_code == WIFI_MANAGER_ERROR_NONE)
+ __test_foreach_bssid_scan(wifi);
+}
+
+int wman_test_bssid_scan(wifi_manager_h wifi)
+{
+ int rv = 0;
+ rv = wifi_manager_bssid_scan(wifi, __test_bssid_scan_request_cb, wifi);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to request bssid scan [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("BSSID Scan request succeeded\n");
+ return 1;
+}
+
+static void __test_multi_scan_cb(wifi_manager_error_e error_code, void* user_data)
+{
+ printf("Multi scan Completed, error code : %s\n", wman_test_strerror(error_code));
+}
+
+int wman_test_specific_ap_start_multi_scan(wifi_manager_h wifi)
+{
+ int rv = 0, scan_type, num = 0;
+ char ssid[32 + 1];
+ int freq;
+ int i = 0;
+ wifi_manager_specific_scan_h specific_scan = NULL;
+
+ rv = wifi_manager_specific_scan_create(wifi, &specific_scan);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to create specific scan handle [%s]", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Specific Scan handle created [%p]\n", specific_scan);
+
+ rv = test_get_user_int("Input multi scan type"
+ "(0:SSID, 1:Freq, 2: SSID & Freq):", &scan_type);
+
+ if (rv == false || (scan_type != 0 && scan_type != 1 && scan_type != 2)) {
+ printf("Invalid input!!\n");
+ return false;
+ }
+
+ if (scan_type == 0 || scan_type == 1) {
+ rv = test_get_user_int("No. of specific ssid/freq for multi scan",
+ &num);
+ if (rv == false || (num <= 0) || (num > 4)) {
+ printf("Invalid input!!\n");
+ return false;
+ }
+
+ if (scan_type == 0) { /** multi ssid scan */
+ for (i = 0; i < num; i++) {
+ printf("Input ssid[%d]:\n", i);
+ rv = scanf(" %32[^\n]s", ssid);
+
+ rv = wifi_manager_specific_scan_set_ssid(specific_scan, ssid);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to set ssid [%s]", wman_test_strerror(rv));
+ return -1;
+ }
+ }
+ } else { /** multi frequency scan */
+ for (i = 0; i < num; i++) {
+ printf("Input freq[%d]:\n", i);
+ rv = scanf(" %d", &freq);
+ rv = wifi_manager_specific_scan_set_freq(specific_scan, freq);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to set freq [%s]", wman_test_strerror(rv));
+ return -1;
+ }
+ }
+ }
+ } else { /** SSID & frequency mixed scan */
+ rv = test_get_user_int("No. of ssid&freq for dual parameter multi scan",
+ &num);
+ if (rv == false || (num <= 0) || (num > 4)) {
+ printf("Invalid input!!\n");
+ return false;
+ }
+
+ for (i = 0; i < num; i++) {
+ printf("Input ssid:\n");
+ rv = scanf(" %32[^\n]s", ssid);
+
+ rv = wifi_manager_specific_scan_set_ssid(specific_scan, ssid);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to set ssid [%s]", wman_test_strerror(rv));
+ return -1;
+ }
+ printf("Input freq:\n");
+ rv = scanf(" %d", &freq);
+
+ rv = wifi_manager_specific_scan_set_freq(specific_scan, freq);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to set freq [%s]", wman_test_strerror(rv));
+ return -1;
+ }
+ }
+ }
+
+ rv = wifi_manager_specific_ap_start_multi_scan(wifi, specific_scan,
+ __test_multi_scan_cb, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to start multi scan[%s]", wman_test_strerror(rv));
+ return -1;
+ }
+ printf("Specific Multi Scan requested\n");
+
+ rv = wifi_manager_specific_scan_destroy(wifi, specific_scan);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to destroy specific scan handle [%s]", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Specific Scan handle destroyed\n");
+
+ return 1;
+}
+
+static void __test_forget_ap_finished_cb(wifi_manager_error_e result, void *user_data)
+{
+ printf("Forget AP callback %s, error: [%s]\n",
+ (result == WIFI_MANAGER_ERROR_NONE) ? "succeeded" : "failed",
+ wman_test_strerror(result));
+}
+
+static bool __test_found_forget_ap_async_cb(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ struct wman_public_info *data = user_data;
+
+ wifi_manager_h wifi = data->wifi;
+ char *ap_name_part = data->name;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", wman_test_strerror(rv));
+ return false;
+ }
+
+ if (wman_test_compare_ap_name(ap_name, ap_name_part)) {
+ rv = wifi_manager_forget_ap_async(wifi, ap,
+ __test_forget_ap_finished_cb, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to forget [%s] : %s\n", ap_name, wman_test_strerror(rv));
+ else
+ printf("Success to forget [%s]\n", ap_name);
+
+ free(ap_name);
+ return false;
+ }
+
+ free(ap_name);
+ return true;
+}
+
+int wman_test_forget_ap_async(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+ struct wman_public_info data = {wifi, ap_name};
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to forget : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_forget_ap_async_cb, &data);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to forget (can't get AP list) [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Forget AP async finished\n");
+
+ return 1;
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <wifi-manager.h>
+
+int wman_test_get_connected_ap(wifi_manager_h wifi);
+int wman_test_foreach_found_ap(wifi_manager_h wifi);
+int wman_test_connect(wifi_manager_h wifi);
+int wman_test_disconnect(wifi_manager_h wifi);
+int wman_test_connect_wps(wifi_manager_h wifi);
+int wman_test_forget_ap(wifi_manager_h wifi);
+int wman_test_connect_eap_ap(wifi_manager_h wifi);
+int wman_test_set_ip_method(wifi_manager_h wifi);
+int wman_test_set_proxy_method(wifi_manager_h wifi);
+int wman_test_get_ap_info(wifi_manager_h wifi);
+int wman_test_connect_specific_ap(wifi_manager_h wifi);
+int wman_test_connect_hidden_ap(wifi_manager_h wifi);
+int wman_test_bssid_scan(wifi_manager_h wifi);
+int wman_test_specific_ap_start_multi_scan(wifi_manager_h wifi);
+int wman_test_forget_ap_async(wifi_manager_h wifi);
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "wman_test_common.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <wifi-manager.h>
+
+const char *wman_test_strerror(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_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_OUT_OF_RANGE:
+ return "OUT_OF_RANGE";
+ 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_PIN_MISSING:
+ return "PIN_MISSING";
+ 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";
+ case WIFI_MANAGER_ERROR_PERMISSION_DENIED:
+ return "PERMISSION_DENIED";
+ case WIFI_MANAGER_ERROR_OFFLINE:
+ return "OFFLINE";
+ case WIFI_MANAGER_ERROR_INVALID_GATEWAY:
+ return "INVALID_GATEWAY";
+ case WIFI_MANAGER_ERROR_NOT_SUPPORTED:
+ return "NOT_SUPPORTED";
+ case WIFI_MANAGER_ERROR_NOT_INITIALIZED:
+ return "NOT_INITIALIZED";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+bool wman_test_compare_ap_name(const char *ap_name, const char *ap_name_part)
+{
+ int ap_name_len = strlen(ap_name);
+ int ap_name_part_len = strlen(ap_name_part);
+
+ if (strncmp(ap_name, ap_name_part,
+ ap_name_len > ap_name_part_len ? ap_name_len : ap_name_part_len) == 0)
+ return true;
+ else
+ return false;
+}
+
+void wman_test_connected_cb(wifi_manager_error_e result, void* user_data)
+{
+ if (result == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi Connection Succeeded\n");
+ else
+ printf("Wi-Fi Connection Failed! error : %s\n", wman_test_strerror(result));
+}
+
+bool test_get_user_int(const char *msg, int *num)
+{
+ if (msg == NULL || num == NULL)
+ return false;
+
+ int rv;
+ char buf[32] = {0,};
+ printf("%s\n", msg);
+ rv = read(0, buf, 32);
+
+ if (rv < 0 || *buf == 0 || *buf == '\n' || *buf == '\r')
+ return false;
+
+ *num = atoi(buf);
+ return true;
+}
+
+bool test_get_user_string(const char *msg, char *buf, int buf_size)
+{
+ if (msg == NULL || buf == NULL || buf_size < 2)
+ return false;
+
+ int rv;
+ printf("%s\n", msg);
+ memset(buf, 0, buf_size);
+ rv = read(0, buf, buf_size - 1);
+
+ if (rv < 0 || buf[0] == '\0' || buf[0] == '\n' || buf[0] == '\r') {
+ buf[0] = '\0';
+ return false;
+ }
+
+ buf[rv - 1] = '\0';
+ return true;
+}
+
+static inline int __test_convert_byte_to_txt(const unsigned char *src, char **dst, int src_len)
+{
+ int dst_length = 0;
+ int i = 0;
+ char *buf = NULL;
+
+ if (src_len <= 0) {
+ printf("Invalid source length\n");
+ return -1;
+ }
+
+ *dst = malloc((2 * src_len) + 1);
+ if (!(*dst)) {
+ printf("failed to allocate memory to buffer\n");
+ return -1;
+ }
+
+ buf = (*dst);
+
+ for (i = 0; i < src_len; i++) {
+ snprintf(buf, 3, "%02x", src[i]);
+ buf += 2;
+ dst_length += 2;
+ }
+
+ return dst_length;
+}
+
+bool __test_vendor_specific_cb(unsigned char *vsie_bytes, int vsie_len, void *user_data)
+{
+ if (!vsie_bytes)
+ return false;
+
+ char *vsie = NULL;
+ int buf_len = __test_convert_byte_to_txt(vsie_bytes, &vsie, vsie_len);
+ if (buf_len > 0)
+ printf("vsie_len: %d, vsie: %s\n", vsie_len, vsie);
+
+ free(vsie);
+
+ return true;
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <wifi-manager.h>
+
+struct wman_public_info {
+ wifi_manager_h wifi;
+ char *name;
+ int type;
+ bool is_found;
+};
+
+const char *wman_test_strerror(wifi_manager_error_e err_type);
+bool wman_test_compare_ap_name(const char *ap_name, const char *ap_name_part);
+void wman_test_connected_cb(wifi_manager_error_e result, void* user_data);
+bool test_get_user_int(const char *msg, int *num);
+bool test_get_user_string(const char *msg, char *buf, int buf_size);
+bool __test_vendor_specific_cb(unsigned char *vsie_bytes, int vsie_len, void *user_data);
--- /dev/null
+/*
+ * Copyright (c) 2012-2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "wman_test_config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <wifi-manager.h>
+#include "wman_test_common.h"
+
+static bool __test_config_list_cb(const wifi_manager_config_h config, void *user_data)
+{
+ char *name = NULL;
+ wifi_manager_security_type_e security_type;
+
+ wifi_manager_config_get_name(config, &name);
+ wifi_manager_config_get_security_type(config, &security_type);
+
+ printf("Name[%s] ", name);
+ printf("Security type[%d] ", security_type);
+ if (security_type == WIFI_MANAGER_SECURITY_TYPE_EAP) {
+ wifi_manager_eap_type_e eap_type;
+ wifi_manager_eap_auth_type_e eap_auth_type;
+ wifi_manager_config_get_eap_type(config, &eap_type);
+ printf("Eap type[%d] ", eap_type);
+ wifi_manager_config_get_eap_auth_type(config, &eap_auth_type);
+ printf("Eap auth type[%d]", eap_auth_type);
+ }
+ printf("\n");
+ free(name);
+
+ return true;
+}
+
+int wman_test_config_load_configuration(wifi_manager_h wifi)
+{
+ int rv;
+
+ rv = wifi_manager_config_foreach_configuration(wifi, __test_config_list_cb, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+
+ return 1;
+}
+
+static inline int __test_config_save_is_update(wifi_manager_config_h config)
+{
+ int rv;
+ int addr_type = 0;
+ char ip_addr[40] = {0};
+ rv = test_get_user_int("Input Address type(0:IPV4, 1:IPV6):", &addr_type);
+
+ if (rv == false || (addr_type != 0 && addr_type != 1)) {
+ printf("Invalid input!!\n");
+ return -1;
+ }
+ rv = wifi_manager_config_set_ip_config_type(config, addr_type, WIFI_MANAGER_IP_CONFIG_TYPE_STATIC);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set ip method type[%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Input new ip address (x:skip, 0:clear) :\n");
+ rv = scanf("%39s", ip_addr);
+ if (rv > 0) {
+ switch (ip_addr[0]) {
+ case 'x':
+ rv = WIFI_MANAGER_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_manager_config_set_ip_address(config, addr_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_config_set_ip_address(config, addr_type, ip_addr);
+ }
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set ip address[%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+ }
+
+ if (addr_type == 0) {
+ printf("Input new subnet mask (x:skip, 0:clear) :\n");
+ rv = scanf("%39s", ip_addr);
+ if (rv > 0) {
+ switch (ip_addr[0]) {
+ case 'x':
+ rv = WIFI_MANAGER_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_manager_config_set_subnet_mask(config, addr_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_config_set_subnet_mask(config, addr_type, ip_addr);
+ }
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set subnet mask[%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+ }
+ } else {
+ printf("Input new prefix length (x:skip) :\n");
+ int prefix_len;
+ rv = scanf("%d", &prefix_len);
+ if (rv > 0) {
+ if (prefix_len == 'x')
+ rv = WIFI_MANAGER_ERROR_NONE;
+ else
+ rv = wifi_manager_config_set_prefix_length(config, addr_type,
+ prefix_len);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set prefix length[%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+ }
+ }
+
+ printf("Input new gateway address (x:skip, 0:clear) :\n");
+ rv = scanf("%39s", ip_addr);
+ if (rv > 0) {
+ switch (ip_addr[0]) {
+ case 'x':
+ rv = WIFI_MANAGER_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_manager_config_set_gateway_address(config, addr_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_config_set_gateway_address(config, addr_type, ip_addr);
+ }
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set gateway address[%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+ }
+
+ rv = wifi_manager_config_set_dns_config_type(config, addr_type,
+ WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return 0;
+
+ printf("Input DNS1 address (x: skip, 0: clear) : \n");
+ if (addr_type == WIFI_MANAGER_ADDRESS_FAMILY_IPV4)
+ rv = scanf("%15s", ip_addr);
+ else
+ rv = scanf("%39s", ip_addr);
+ if (rv > 0) {
+ switch (ip_addr[0]) {
+ case 'x':
+ rv = WIFI_MANAGER_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_manager_config_set_dns_address(config, 1, addr_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_config_set_dns_address(config, 1, addr_type, ip_addr);
+ }
+ }
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set DNS1 address[%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Input DNS2 address (x: skip, 0: clear) : \n");
+ if (addr_type == WIFI_MANAGER_ADDRESS_FAMILY_IPV4)
+ rv = scanf("%15s", ip_addr);
+ else
+ rv = scanf("%39s", ip_addr);
+ if (rv > 0) {
+ switch (ip_addr[0]) {
+ case 'x':
+ rv = WIFI_MANAGER_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_manager_config_set_dns_address(config, 2, addr_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_config_set_dns_address(config, 2, addr_type, ip_addr);
+ }
+ }
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set DNS2 address[%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ return 0;
+}
+
+static int __test_config_save_eap(wifi_manager_config_h config)
+{
+ int rv;
+ char anonymous[100] = {0,};
+ char ca_cert[100] = {0,};
+ char private_key[100] = {0,};
+ char private_key_password[100] = {0,};
+ char client_cert[100] = {0,};
+ char eap_identity[100] = {0,};
+ int eap_type;
+ int eap_auth_type;
+ char subject_match[100] = {0,};
+
+ if (test_get_user_string("EAP Anonymous Identity - (Enter for skip): ", anonymous, 99)) {
+ rv = wifi_manager_config_set_eap_anonymous_identity(config, anonymous);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_string("EAP ca cert file - (Enter for skip): ", ca_cert, 99)) {
+ rv = wifi_manager_config_set_eap_ca_cert_file(config, ca_cert);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_string("EAP private key - (Enter for skip): ", private_key, 99) &&
+ test_get_user_string("EAP client cert file - (Enter for skip): ", client_cert, 99)) {
+ rv = wifi_manager_config_set_eap_client_cert_file(config, private_key, client_cert);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_string("EAP identity - (Enter for skip): ", eap_identity, 99)) {
+ rv = wifi_manager_config_set_eap_identity(config, eap_identity);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_int("EAP type (PEAP(0), TLS(1), TTLS(2), SIM(3), AKA(4)) - (Enter for skip): ", &eap_type)) {
+ rv = wifi_manager_config_set_eap_type(config, eap_type);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+
+ if (eap_type == 1) {
+ if (test_get_user_string("EAP private key file - ", private_key, 99) &&
+ test_get_user_string("EAP private-key password - ", private_key_password, 99)) {
+ rv = wifi_manager_config_set_eap_private_key_info(config, private_key, private_key_password);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+ }
+ }
+
+ if (test_get_user_int("EAP auth type (None(0), PAP(1), MSCHAP(2), MSCHAPv2(3), GTC(4), MD5(5)) - (Enter for skip): ", &eap_auth_type)) {
+ rv = wifi_manager_config_set_eap_auth_type(config, eap_auth_type);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_string("EAP subject match - (Enter for skip): ", subject_match, 99)) {
+ rv = wifi_manager_config_set_eap_subject_match(config, subject_match);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+ return 0;
+}
+
+int wman_test_config_save(wifi_manager_h wifi)
+{
+ int rv;
+ char name[33] = {0,};
+ char passphrase[100] = {0,};
+ int type = 0;
+ char proxy[100] = {0,};
+ int hidden = 0;
+ wifi_manager_config_h config;
+ int ip_update = 0;
+
+ printf("Input AP configuration\n");
+ printf("Name : ");
+ rv = scanf(" %32[^\n]s", name);
+ if (rv <= 0)
+ return -1;
+
+ printf("Passphrase : ");
+ rv = scanf(" %99s", passphrase);
+ if (rv <= 0)
+ return -1;
+
+ printf("Security type(None(0), WEP(1), WPA-PSK(2), EAP(4)) : ");
+ rv = scanf("%d", &type);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_config_create(wifi, name, passphrase, type, &config);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+
+ rv = test_get_user_int("Update IP details (0:No, 1:Yes):", &ip_update);
+ if (rv == false || (ip_update != 0 && ip_update != 1)) {
+ printf("Invalid input!!\n");
+ return -1;
+ }
+
+ if (ip_update == 1)
+ if (__test_config_save_is_update(config) < 0)
+ return -1;
+
+ if (test_get_user_string("Proxy(server:port) - (Enter for skip): ", proxy, 99)) {
+ rv = wifi_manager_config_set_proxy_address(config,
+ WIFI_MANAGER_ADDRESS_FAMILY_IPV4, proxy);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_int("Hidden(1:Hidden) - (Enter for skip): ", &hidden)) {
+ if (hidden == 1)
+ rv = wifi_manager_config_set_hidden_ap_property(config, true);
+ else
+ rv = wifi_manager_config_set_hidden_ap_property(config, false);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (type == WIFI_MANAGER_SECURITY_TYPE_EAP)
+ if (__test_config_save_eap(config) < 0)
+ return -1;
+
+ rv = wifi_manager_config_save(wifi, config);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+
+ rv = wifi_manager_config_destroy(config);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+
+ return 1;
+}
+
+static bool __test_config_list_cb_for_remove(const wifi_manager_config_h config, void *user_data)
+{
+ char *name = NULL;
+ struct wman_public_info *data = user_data;
+ wifi_manager_security_type_e security_type;
+
+ wifi_manager_config_get_name(config, &name);
+ wifi_manager_config_get_security_type(config, &security_type);
+
+ if (wman_test_compare_ap_name(name, data->name) && security_type == data->type) {
+ int rv = wifi_manager_config_remove(data->wifi, config);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to remove configurations [%s]\n", wman_test_strerror(rv));
+ else
+ printf("Success to remove configuration [%s]\n", name);
+ free(name);
+ return false;
+ }
+
+ free(name);
+
+ return true;
+}
+
+int wman_test_config_remove(wifi_manager_h wifi)
+{
+ int rv;
+ char name[33];
+ struct wman_public_info data = {wifi, name};
+
+ printf("Input AP configuration\n");
+ printf("Name : ");
+ rv = scanf(" %32[^\n]s", name);
+ if (rv <= 0)
+ return -1;
+
+ printf("Security type(None(0), WEP(1), WPA-PSK(2), EAP(4) : ");
+ rv = scanf(" %d", &data.type);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_config_foreach_configuration(wifi, __test_config_list_cb_for_remove, &data);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get configurations [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ return 1;
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <wifi-manager.h>
+
+int wman_test_config_load_configuration(wifi_manager_h wifi);
+int wman_test_config_save(wifi_manager_h wifi);
+int wman_test_config_remove(wifi_manager_h wifi);
--- /dev/null
+/*
+ * Copyright (c) 2012-2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "wman_test_extension.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <wifi-manager.h>
+#include <wifi-manager-extension.h>
+#include "wman_test_common.h"
+
+int wman_test_set_autoscan_state(wifi_manager_h wifi)
+{
+ int autoscan = 0;
+ int rv = 0;
+
+ printf("Input enable/disable for autoscan (0:enable, 1:disable) :\n");
+ rv = scanf(" %9d", &autoscan);
+
+ if (rv <= 0) {
+ printf("Invalid input!\n");
+ return -1;
+ }
+
+ switch (autoscan) {
+ case 0:
+ rv = wifi_manager_set_autoscan(wifi, true);
+ break;
+
+ case 1:
+ rv = wifi_manager_set_autoscan(wifi, false);
+ break;
+
+ default:
+ printf("Invalid input!\n");
+ return -1;
+ }
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("failed to set autoscan [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+int wman_test_set_autoscan_mode(wifi_manager_h wifi)
+{
+ int mode = 0;
+ int rv = 0;
+
+ printf("Input autoscan mode (0:exponential, 1:periodic) :\n");
+ rv = scanf(" %9d", &mode);
+
+ if (rv <= 0) {
+ printf("Invalid input!\n");
+ return -1;
+ }
+
+ rv = wifi_manager_set_autoscan_mode(wifi, mode);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("failed to set autoscan mode [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+int wman_test_get_autoscan_state(wifi_manager_h wifi)
+{
+ int rv = 0;
+ bool autoscan = false;
+
+ rv = wifi_manager_get_autoscan(wifi, &autoscan);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get auto scan state [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Auto scan state (0:enable, 1:disable) : %d\n", autoscan);
+ return 1;
+}
+
+int wman_test_get_autoscan_mode(wifi_manager_h wifi)
+{
+ int rv = 0;
+ wifi_manager_autoscan_mode_e autoscan_mode;
+
+ rv = wifi_manager_get_autoscan_mode(wifi, &autoscan_mode);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get auto scan mode [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Auto Scan Mode (0:exponential, 1:periodic) : %d\n", autoscan_mode);
+ return 1;
+}
+
+int wman_test_flush_bss(wifi_manager_h wifi)
+{
+ int rv;
+
+ rv = wifi_manager_flush_bss(wifi);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to flush bss rv = %d\n", rv);
+ return -1;
+ }
+
+ printf("Request to flush bss\n");
+ return 1;
+}
+
+int wman_test_set_auto_connect(wifi_manager_h wifi)
+{
+ int rv;
+ int mode;
+
+ printf("Auto connect mode (1:enable, 0:disable) : ");
+ rv = scanf(" %d", &mode);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_set_auto_connect(wifi, mode);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set auto connect mode, rv = %d\n", rv);
+ }
+
+ printf("Request to set auto connect mode\n");
+ return 1;
+}
+
+int wman_test_get_auto_connect(wifi_manager_h wifi)
+{
+ int rv;
+ int mode;
+
+ rv = wifi_manager_get_auto_connect(wifi, &mode);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get auto connect mode, rv = %d\n", rv);
+ return 1;
+ }
+
+ printf("Request to get auto connect mode = %d (1:enable, 0:disable)\n", mode);
+ return 1;
+}
+
+static bool __test_found_set_autoconnect_ap_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0, enable;
+ char *ap_name = NULL;
+ bool autoconnect = false;
+ char *ap_name_part = (char *)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("[Wi-Fi] Fail to get AP name [%s]\n", wman_test_strerror(rv));
+ return false;
+ }
+
+ if (wman_test_compare_ap_name(ap_name, ap_name_part)) {
+ printf("[Wi-Fi] Input command number (enable[1], disable[0]) : ");
+ rv = scanf(" %9d", &enable);
+ if (rv <= 0) {
+ free(ap_name);
+ return false;
+ }
+
+ if (enable != 0)
+ autoconnect = true;
+
+ rv = wifi_manager_ap_set_auto_connect(ap, autoconnect);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to set [%s] : %s\n", ap_name, wman_test_strerror(rv));
+ else
+ printf("Success to set [%s]\n", ap_name);
+
+ free(ap_name);
+ return false;
+ }
+
+ free(ap_name);
+
+ return true;
+}
+
+int wman_test_set_ap_auto_connect(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("[Wi-Fi] Input a part of AP name to set : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_set_autoconnect_ap_callback, ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("[Wi-Fi] Fail to set up (can't get AP list) [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("[Wi-Fi] Set up finished\n");
+ return 1;
+}
+
+static bool __test_found_get_autoconnect_ap_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ bool autoconnect = false;
+ char *ap_name = NULL;
+ char *ap_name_part = user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("[Wi-Fi] Fail to get AP name [%s]\n", wman_test_strerror(rv));
+ return false;
+ }
+
+ if (wman_test_compare_ap_name(ap_name, ap_name_part)) {
+ rv = wifi_manager_ap_get_auto_connect(ap, &autoconnect);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to get [%s] : %s\n", ap_name, wman_test_strerror(rv));
+ else
+ printf("Success to get : [%s]\n", autoconnect ? "TRUE" : "FALSE");
+ free(ap_name);
+ return false;
+ }
+
+ free(ap_name);
+
+ return true;
+}
+
+int wman_test_get_ap_auto_connect(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("[Wi-Fi] Input a part of AP name to get : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_get_autoconnect_ap_callback, ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("[Wi-Fi] Fail to get up (can't get AP list) [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("[Wi-Fi] Get up finished\n");
+ return 1;
+}
+
+int wman_test_set_ip_conflict_period(wifi_manager_h wifi)
+{
+ int rv = 0;
+ int initial_interval;
+
+ printf("Enter initial interval for ARP ping\n");
+ rv = scanf(" %d", &initial_interval);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_set_ip_conflict_period(wifi, initial_interval);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set ip conflict detection period [%s]\n",
+ wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Succesfully set the ip conflict detect period!\n");
+ return 1;
+}
+
+int wman_test_get_ip_conflict_period(wifi_manager_h wifi)
+{
+ int rv = 0;
+ unsigned int initial_time;
+
+ rv = wifi_manager_get_ip_conflict_period(wifi, &initial_time);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get ip conflict time period [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Initial time = %d seconds!\n", initial_time);
+ printf("Succesfully get the ip conflict detect period!\n");
+ return 1;
+}
+
+static bool __test_get_netlink_scan_list(wifi_manager_ap_h ap, void *user_data)
+{
+ char *bssid = NULL;
+ char *essid = NULL;
+ int freq;
+ int rssi;
+ wifi_manager_security_type_e sec_type;
+ wifi_manager_encryption_type_e enc_type;
+
+ if (wifi_manager_ap_get_bssid(ap, &bssid) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get bssid for ap\n");
+ free(bssid);
+ return false;
+ }
+
+
+ if (wifi_manager_ap_get_essid(ap, &essid) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get essid for ap\n");
+ free(bssid);
+ free(essid);
+ return false;
+ }
+
+ if (wifi_manager_ap_get_frequency(ap, &freq) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get Frequency\n");
+ free(bssid);
+ free(essid);
+ return false;
+ }
+
+ if (wifi_manager_ap_get_rssi(ap, &rssi) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get rssi for ap\n");
+ free(bssid);
+ free(essid);
+ return false;
+ }
+
+ if (wifi_manager_ap_get_security_type(ap, &sec_type) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get security type for ap\n");
+ free(bssid);
+ free(essid);
+ return false;
+ }
+
+ if (wifi_manager_ap_get_encryption_type(ap, &enc_type) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get encryption type for ap\n");
+ free(bssid);
+ free(essid);
+ return false;
+ }
+
+ printf("%s, %d, %d, %s\n", bssid, freq, rssi, essid);
+ printf("Security type : ");
+ switch (sec_type) {
+ case WIFI_MANAGER_SECURITY_TYPE_NONE:
+ printf("NONE, ");
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_WEP:
+ printf("WEP, ");
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
+ printf("WPAPSK, ");
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
+ printf("WPA2PSK, ");
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_EAP:
+ printf("EAP, ");
+ break;
+ default:
+ break;
+ }
+ printf("Encryption type : ");
+ switch (enc_type) {
+ case WIFI_MANAGER_ENCRYPTION_TYPE_NONE:
+ printf("NONE\n");
+ break;
+ case WIFI_MANAGER_ENCRYPTION_TYPE_WEP:
+ printf("WEP\n");
+ break;
+ case WIFI_MANAGER_ENCRYPTION_TYPE_TKIP:
+ printf("TKIP\n");
+ break;
+ case WIFI_MANAGER_ENCRYPTION_TYPE_AES:
+ printf("CCMP\n");
+ break;
+ case WIFI_MANAGER_ENCRYPTION_TYPE_TKIP_AES_MIXED:
+ printf("Mixed\n");
+ break;
+ default:
+ break;
+ }
+
+ if (wifi_manager_ap_foreach_vsie(ap, __test_vendor_specific_cb, NULL) != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to get vsie\n");
+
+ free(bssid);
+ free(essid);
+ return true;
+}
+
+static inline int __test_foreach_netlink_scan(wifi_manager_h wifi)
+{
+ int rv;
+
+ rv = wifi_manager_foreach_found_netlink_scan_ap(wifi,
+ __test_get_netlink_scan_list, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get netlink scan list [%s]\n",
+ wman_test_strerror(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+static void __test_netlink_scan_request_callback(wifi_manager_error_e error_code, void *user_data)
+{
+ wifi_manager_h wifi = user_data;
+
+ printf("Netlink Scan Completed, error code : %s\n",
+ wman_test_strerror(error_code));
+
+ if (error_code == WIFI_MANAGER_ERROR_NONE)
+ __test_foreach_netlink_scan(wifi);
+}
+
+int wman_test_netlink_scan(wifi_manager_h wifi)
+{
+ int rv = 0, scan_type = -1, add_vsie = -1;
+ int ret = 1;
+ char ssid[32 + 1];
+ char vsie[255];
+ wifi_manager_netlink_scan_h netlink_scan = NULL;
+
+ rv = wifi_manager_netlink_scan_create(wifi, &netlink_scan);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to create netlink scan handle [%s]", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Netlink Scan handle created [%p]\n", netlink_scan);
+
+ rv = test_get_user_int("Input netlink scan type"
+ "(0:Normal, 1:Specific AP):", &scan_type);
+ if (rv == false || (scan_type != 0 && scan_type != 1)) {
+ printf("Invalid input!!\n");
+ ret = -1;
+ goto out;
+ }
+
+ if (scan_type == 1) {
+ int i, num;
+ rv = test_get_user_int("Input number of ssid:", &num);
+ if (rv == false || num <= 0) {
+ printf("Invalid input!!\n");
+ ret = -1;
+ goto out;
+ }
+
+ for (i = 0; i < num; i++) {
+ printf("Input ssid:\n");
+ rv = scanf(" %32[^\n]s", ssid);
+
+ rv = wifi_manager_netlink_scan_set_ssid(netlink_scan, ssid);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to set ssid [%s]", wman_test_strerror(rv));
+ ret = -1;
+ goto out;
+ }
+ }
+ }
+
+ rv = test_get_user_int("Add vsie option"
+ "(0:No, 1:Yes):", &add_vsie);
+ if (rv == false || (add_vsie != 0 && add_vsie != 1)) {
+ printf("Invalid input!!\n");
+ ret = -1;
+ goto out;
+ }
+
+ if (add_vsie) {
+ printf("Input vsie:\n");
+ rv = scanf(" %250s", vsie);
+
+ rv = wifi_manager_netlink_scan_set_vsie(netlink_scan, vsie);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to set vsie [%s]", wman_test_strerror(rv));
+ ret = -1;
+ goto out;
+ }
+ }
+
+ rv = wifi_manager_netlink_scan(wifi, netlink_scan, __test_netlink_scan_request_callback, wifi);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to request netlink scan [%s]\n", wman_test_strerror(rv));
+ ret = -1;
+ goto out;
+ }
+
+ printf("netlink Scan request succeeded\n");
+
+out:
+ rv = wifi_manager_netlink_scan_destroy(wifi, netlink_scan);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to destroy netlink scan handle [%s]", wman_test_strerror(rv));
+ return -1;
+ }
+
+ return ret;
+}
+
+int wman_test_get_passpoint_state(wifi_manager_h wifi)
+{
+ int rv;
+ int enabled;
+
+ rv = wifi_manager_get_passpoint(wifi, &enabled);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get passpoint state, rv = %d\n", rv);
+ return 1;
+ }
+
+ printf("current passpoint sate(0:off, 1:on) = [%d]\n", enabled);
+ return 1;
+}
+
+int wman_test_set_passpoint_enable(wifi_manager_h wifi)
+{
+ int rv;
+ int enable;
+
+ printf("Enter passpoint on/off(0:off, 1:on) : \n");
+ rv = scanf(" %d", &enable);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_set_passpoint(wifi, enable);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set passpoint, rv = %d\n", rv);
+ }
+
+ printf("Request to set passpoint\n");
+ return 1;
+}
+
+static const char *__test_convert_connection_mode_to_string(wifi_manager_connection_mode_e mode)
+{
+ switch (mode) {
+ case WIFI_MANAGER_CONNECTION_MODE_80211_B:
+ return "802.11b";
+ case WIFI_MANAGER_CONNECTION_MODE_80211_G:
+ return "802.11g";
+ case WIFI_MANAGER_CONNECTION_MODE_80211_N:
+ return "802.11n";
+ case WIFI_MANAGER_CONNECTION_MODE_80211_A:
+ return "802.11a";
+ case WIFI_MANAGER_CONNECTION_MODE_80211_AC:
+ return "802.11ac";
+ case WIFI_MANAGER_CONNECTION_MODE_UNKNOWN:
+ return "Uknown";
+ default:
+ return "Uknown";
+ }
+}
+
+int wman_test_get_connection_mode(wifi_manager_h wifi)
+{
+ int rv, int_value;
+ wifi_manager_connection_mode_e mode;
+ char *ap_name = NULL;
+ wifi_manager_ap_h ap_h;
+
+ rv = wifi_manager_get_connected_ap(wifi, &ap_h);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get connected AP [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ rv = wifi_manager_ap_get_essid(ap_h, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get essid [%s]\n", wman_test_strerror(rv));
+ wifi_manager_ap_destroy(ap_h);
+ return -1;
+ }
+
+ rv = wifi_manager_ap_get_max_speed(ap_h, &int_value);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get max speed[%s]\n", wman_test_strerror(rv));
+ free(ap_name);
+ wifi_manager_ap_destroy(ap_h);
+ return -1;
+ }
+
+ rv = wifi_manager_get_connection_mode(wifi, &mode);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get connection mode[%s]\n", wman_test_strerror(rv));
+ free(ap_name);
+ wifi_manager_ap_destroy(ap_h);
+ return -1;
+ }
+
+ printf("Connected AP : %s\n", ap_name);
+ printf("Connection mode : %s\n", __test_convert_connection_mode_to_string(mode));
+ printf("Link speed : %d\n", int_value);
+ free(ap_name);
+ wifi_manager_ap_destroy(ap_h);
+ return 1;
+}
+
+int wman_test_get_5ghz_band_supported(wifi_manager_h wifi)
+{
+ int rv;
+ bool supported;
+
+ rv = wifi_manager_is_5ghz_band_supported(wifi, &supported);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get 5ghz supported, rv = %d\n", rv);
+ return 1;
+ }
+
+ printf("Is 5Ghz supported = [%s]\n", supported ? "yes" : "no");
+ return 1;
+}
+
+int wman_test_set_mac_policy(wifi_manager_h wifi)
+{
+ int rv;
+ unsigned int policy = 0;
+
+ printf("Enter mac policy (0/1/2): ");
+ rv = scanf(" %u", &policy);
+
+ rv = wifi_manager_set_mac_policy(wifi, policy);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set mac policy, rv = %d\n", rv);
+ return 1;
+ }
+
+ printf("Success to set mac policy\n");
+ return 1;
+}
+
+int wman_test_set_preassoc_mac_policy(wifi_manager_h wifi)
+{
+ int rv;
+ unsigned int policy = 0;
+
+ printf("Enter mac policy (0/1/2): ");
+ rv = scanf(" %u", &policy);
+
+ rv = wifi_manager_set_preassoc_mac_policy(wifi, policy);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set preassoc mac policy, rv = %d\n", rv);
+ return 1;
+ }
+
+ printf("Success to set preassoc mac policy\n");
+ return 1;
+}
+
+int wman_test_set_random_mac_lifetime(wifi_manager_h wifi)
+{
+ int rv;
+ unsigned int lifetime = 0;
+
+ printf("Enter mac policy (> 0): ");
+ rv = scanf(" %u", &lifetime);
+
+ rv = wifi_manager_set_random_mac_lifetime(wifi, lifetime);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set random mac lifetime, rv = %d\n", rv);
+ return 1;
+ }
+
+ printf("Success to set random mac lifetime\n");
+ return 1;
+}
+
+int wman_test_get_mac_policies(wifi_manager_h wifi)
+{
+ int rv;
+ unsigned int mac_policy = 0;
+ unsigned int preassoc_mac_policy = 0;
+ unsigned int random_mac_lifetime = 0;
+
+ rv = wifi_manager_get_mac_policy(wifi, &mac_policy);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to get mac policy, rv = %d\n", rv);
+
+ rv = wifi_manager_get_preassoc_mac_policy(wifi, &preassoc_mac_policy);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to get preassoc mac policy, rv = %d\n", rv);
+
+ rv = wifi_manager_get_random_mac_lifetime(wifi, &random_mac_lifetime);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to get random mac lifetime, rv = %d\n", rv);
+
+ printf("Success to get mac policies: "
+ "[Mac Policy : %u], [Preassoc Mac Policy : %u], [Random Mac lifetime : %u]\n",
+ mac_policy, preassoc_mac_policy, random_mac_lifetime);
+ return 1;
+}
+
+int wman_test_set_country_code(wifi_manager_h wifi)
+{
+ int rv;
+ char country[3];
+
+ printf("Enter alpha2 country code (e.g. IN, JP, KR, US)\n");
+ rv = scanf("%2s", country);
+
+ rv = wifi_manager_set_country_code(wifi, (const char *)country);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set country code[%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+int wman_test_get_country_code(wifi_manager_h wifi)
+{
+ int rv;
+ char *country = NULL;
+
+ rv = wifi_manager_get_country_code(wifi, &country);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get country code[%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+ printf("Country code: %s\n", country);
+ free(country);
+
+ return 1;
+}
+
+void wman_test_print_connection_mode(wifi_manager_ap_h ap)
+{
+ wifi_manager_connection_mode_e mode;
+
+ if (wifi_manager_ap_get_connection_mode(ap, &mode) == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi operation mode: %d\n", mode);
+ else
+ printf("Fail to get operation mode\n");
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <wifi-manager.h>
+
+int wman_test_set_autoscan_state(wifi_manager_h wifi);
+int wman_test_set_autoscan_mode(wifi_manager_h wifi);
+int wman_test_get_autoscan_state(wifi_manager_h wifi);
+int wman_test_get_autoscan_mode(wifi_manager_h wifi);
+int wman_test_flush_bss(wifi_manager_h wifi);
+int wman_test_set_auto_connect(wifi_manager_h wifi);
+int wman_test_get_auto_connect(wifi_manager_h wifi);
+int wman_test_set_ap_auto_connect(wifi_manager_h wifi);
+int wman_test_get_ap_auto_connect(wifi_manager_h wifi);
+int wman_test_set_ip_conflict_period(wifi_manager_h wifi);
+int wman_test_get_ip_conflict_period(wifi_manager_h wifi);
+int wman_test_netlink_scan(wifi_manager_h wifi);
+int wman_test_get_passpoint_state(wifi_manager_h wifi);
+int wman_test_set_passpoint_enable(wifi_manager_h wifi);
+int wman_test_get_connection_mode(wifi_manager_h wifi);
+int wman_test_get_5ghz_band_supported(wifi_manager_h wifi);
+int wman_test_set_mac_policy(wifi_manager_h wifi);
+int wman_test_set_preassoc_mac_policy(wifi_manager_h wifi);
+int wman_test_set_random_mac_lifetime(wifi_manager_h wifi);
+int wman_test_get_mac_policies(wifi_manager_h wifi);
+int wman_test_set_country_code(wifi_manager_h wifi);
+int wman_test_get_country_code(wifi_manager_h wifi);
+void wman_test_print_connection_mode(wifi_manager_ap_h ap);
--- /dev/null
+/*
+ * Copyright (c) 2012-2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <wifi-manager.h>
+#include <wifi-manager-extension.h>
+
+#include "wman_test_common.h"
+#include "wman_test_ap.h"
+#include "wman_test_misc.h"
+#include "wman_test_config.h"
+#include "wman_test_extension.h"
+
+#define LOG_RED "\033[0;31m"
+#define LOG_GREEN "\033[0;32m"
+#define LOG_BROWN "\033[0;33m"
+#define LOG_BLUE "\033[0;34m"
+#define LOG_END "\033[0;m"
+
+static wifi_manager_h wifi = NULL;
+static wifi_manager_h wifi2 = NULL;
+
+static void __test_device_state_callback(wifi_manager_device_state_e state, void* user_data)
+{
+ printf("[%s] Device state changed callback", (char *)user_data);
+
+ if (state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED)
+ printf(", state : Activated\n");
+ else
+ printf(", state : Deactivated\n");
+}
+
+static void __test_scan_changed_callback(wifi_manager_scan_state_e state, void* user_data)
+{
+ printf("Scan changed, scan state : %d\n", state);
+}
+
+static void __test_bg_scan_completed_callback(wifi_manager_error_e error_code, void* user_data)
+{
+ printf("[%s] Background Scan Completed, error code : %s\n",
+ (char *)user_data, wman_test_strerror(error_code));
+}
+
+static void __test_ip_conflict_callback(char *mac, wifi_manager_ip_conflict_state_e state, void *user_data)
+{
+ if (state == WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_DETECTED)
+ printf("[%s] Ip conflict detected : %s\n", (char *)user_data, mac);
+ else if (state == WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED)
+ printf("Ip conflict removed\n");
+ else
+ printf("Ip conflict state unknown\n");
+}
+
+static void __test_connection_state_callback(wifi_manager_connection_state_e state, wifi_manager_ap_h ap, void* user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+
+ printf("[%s] Connection state changed callback", (char *)user_data);
+
+ switch (state) {
+ case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
+ printf(", state : Connected");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION:
+ printf(", state : Association");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION:
+ printf(", state : Configuration");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED:
+ printf(", state : Disconnected");
+ break;
+ default:
+ printf(", state : Unknown");
+ }
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf(", Fail to get AP name [%s]\n", wman_test_strerror(rv));
+ else {
+ printf(", AP name : %s\n", ap_name);
+ free(ap_name);
+ }
+}
+
+static void __test_rssi_level_callback(wifi_manager_rssi_level_e rssi_level, void* user_data)
+{
+ printf("[%s] RSSI level changed callback, level = %d\n", (char *)user_data, rssi_level);
+}
+
+static void __test_tdls_discover_callback(wifi_manager_tdls_discovery_state_e state, char *peer_mac_add, void *user_data)
+{
+ printf("[%s] TDLS discover callback", (char *)user_data);
+
+ printf(", Peer Mac Address [%s], state :%d\n", peer_mac_add, state);
+ if (state == WIFI_MANAGER_TDLS_DISCOVERY_STATE_ONGOING)
+ printf(", Discovery is ongoing");
+ else
+ printf(", Discovery is finished");
+}
+
+static void __test_get_wifi_module_state_callback(wifi_manager_module_state_e state, void *user_data)
+{
+ printf("Wi-Fi Module State Changed callback : %d", state);
+
+ if (state == WIFI_MANAGER_MODULE_STATE_ATTACHED)
+ printf(", Wi-Fi Module Attached\n");
+ else
+ printf(", Wi-Fi Module Detached\n");
+}
+
+static void __test_tdls_state_callback(wifi_manager_tdls_state_e state, char *peer_mac_add, void *user_data)
+{
+ printf("[%s] TDLS state changed callback", (char *)user_data);
+
+ if (state == WIFI_MANAGER_TDLS_STATE_CONNECTED)
+ printf(", state : TDLS Connected, Peer Mac Address [%s]\n", peer_mac_add);
+ else
+ printf(", state : TDLS Disconnected, Peer Mac Address [%s]\n", peer_mac_add);
+}
+
+int wman_test_init(void)
+{
+ int rv = wifi_manager_initialize(&wifi);
+
+ if (rv == WIFI_MANAGER_ERROR_NONE) {
+ wifi_manager_set_device_state_changed_cb(wifi, __test_device_state_callback, "1");
+ wifi_manager_set_scan_state_changed_cb(wifi, __test_scan_changed_callback, "1");
+ wifi_manager_set_background_scan_cb(wifi, __test_bg_scan_completed_callback, "1");
+ wifi_manager_set_ip_conflict_cb(wifi, __test_ip_conflict_callback, "1");
+ wifi_manager_set_connection_state_changed_cb(wifi, __test_connection_state_callback, "1");
+ wifi_manager_set_rssi_level_changed_cb(wifi, __test_rssi_level_callback, "1");
+ wifi_manager_tdls_set_state_changed_cb(wifi, __test_tdls_state_callback, "1");
+ wifi_manager_tdls_set_discovered_cb(wifi, __test_tdls_discover_callback, "1");
+ wifi_manager_set_module_state_changed_cb(wifi, __test_get_wifi_module_state_callback, "1");
+
+ } else {
+ printf("[1] Wifi init failed [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ rv = wifi_manager_initialize(&wifi2);
+
+ if (rv == WIFI_MANAGER_ERROR_NONE) {
+ wifi_manager_set_device_state_changed_cb(wifi2, __test_device_state_callback, "2");
+ wifi_manager_set_background_scan_cb(wifi2, __test_bg_scan_completed_callback, "2");
+ wifi_manager_set_connection_state_changed_cb(wifi2, __test_connection_state_callback, "2");
+ wifi_manager_set_rssi_level_changed_cb(wifi2, __test_rssi_level_callback, "2");
+ wifi_manager_tdls_set_state_changed_cb(wifi2, __test_tdls_state_callback, "2");
+ wifi_manager_tdls_set_discovered_cb(wifi, __test_tdls_discover_callback, "2");
+ wifi_manager_set_module_state_changed_cb(wifi, __test_get_wifi_module_state_callback, "2");
+ } else {
+ printf("[2] Wifi init failed [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Wifi init succeeded\n");
+ return 1;
+}
+
+int wman_test_deinit(void)
+{
+ int rv = wifi_manager_deinitialize(wifi);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("[1] Wifi deinit failed [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ rv = wifi_manager_deinitialize(wifi2);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("[2] Wifi deinit failed [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Wifi deinit succeeded\n");
+ return 1;
+}
+
+gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
+{
+ int rv;
+ char a[10];
+
+ printf("Event received from stdin\n");
+
+ rv = read(0, a, 10);
+
+ if (rv <= 0 || a[0] == '0') {
+ rv = wifi_manager_deinitialize(wifi);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to deinitialize.\n");
+
+ exit(1);
+ }
+
+ if (a[0] == '\n' || a[0] == '\r') {
+/* Public API */
+ printf("\n\n Network Connection API Test App\n\n");
+ printf("Options..\n");
+ printf(LOG_BLUE "[Public APIs]\n" LOG_END);
+ printf(LOG_GREEN "1 - Wi-Fi init and set callbacks\n" LOG_END);
+ printf("2 - Wi-Fi deinit(unset callbacks automatically)\n");
+ printf(LOG_GREEN "3 - Activate Wi-Fi device\n" LOG_END);
+ printf("4 - Deactivate Wi-Fi device\n");
+ printf("5 - Is Wi-Fi activated?\n");
+ printf("6 - Get connection state\n");
+ printf("7 - Get MAC address\n");
+ printf("8 - Get Wi-Fi interface name\n");
+ printf(LOG_GREEN "9 - Scan request\n" LOG_END);
+ printf("a - Get Connected AP\n");
+ printf("b - Get AP list\n");
+ printf(LOG_GREEN "c - Connect\n" LOG_END);
+ printf("d - Disconnect\n");
+ printf("e - Connect by wps pbc\n");
+ printf("f - Forget an AP\n");
+ printf("g - Set & connect EAP\n");
+ printf("h - Set IP method type\n");
+ printf("i - Set Proxy method type\n");
+ printf("j - Get Ap info\n");
+ printf("k - Connect Specific AP\n");
+ printf("l - Load configuration\n");
+ printf("m - Save configuration\n");
+ printf("n - Remove configuration\n");
+ printf("o - TDLS Discover\n");
+ printf("p - TDLS Connect\n");
+ printf("q - TDLS Connected peer\n");
+ printf("r - TDLS Disconnect\n");
+ printf("s - Connect Hidden AP\n");
+ printf("t - Connect WPS PBC without SSID\n");
+ printf("u - Connect WPS PIN without SSID\n");
+ printf("v - Cancel WPS Request\n");
+ printf("w - Get wifi scanning state\n");
+ printf("x - Enable TDLS Channel Switch Request\n");
+ printf("y - Disable TDLS Channel Switch Request\n");
+ printf("z - Get Wi-Fi Module State\n");
+ printf("A - BSSID Scan (Wi-Fi Position System Scan)\n");
+ printf("B - Multi Scan (Multi Frequency & Multi SSID)\n");
+ printf("C - Add VSIE\n");
+ printf("D - Get VSIE\n");
+ printf("E - Remove VSIE\n");
+ printf("F - Set IP conflict detection mode\n");
+ printf("G - Get IP conflict detection mode\n");
+ printf("H - Get IP conflict state\n");
+ printf("I - Get generated PIN number\n");
+ printf("J - Forget an AP(async)\n");
+/* Extension APIs */
+ printf(LOG_BLUE "[Extension API]\n" LOG_END);
+ printf("K - Set Enable or Disable Auto Scan\n");
+ printf("L - Set Mode of Auto Scan\n");
+ printf("M - Get Enable or Disable Auto Scan\n");
+ printf("N - Get Mode of Auto Scan\n");
+ printf("O - Flush BSS\n");
+ printf("P - Set enable or disable auto connect\n");
+ printf("Q - Get enable or disable auto connect\n");
+ printf("R - Set enable or disable of Wi-Fi profile auto-connect\n");
+ printf("S - Get enable or disable of Wi-Fi profile auto-connect\n");
+ printf("T - Set the IP conflict detection period\n");
+ printf("U - Get the IP conflict detection period\n");
+ printf("V - Netlink Scan Normal/Specific-AP\n");
+ printf("W - Get passpoint state\n");
+ printf("X - Set passpoint on/off\n");
+ printf("Y - Get Access Point Hardware Mode\n");
+ printf("Z - Get 5Ghz supported\n");
+ printf("! - Set mac policy\n");
+ printf("@ - Set preassoc mac policy\n");
+ printf("# - Set random mac lifetime\n");
+ printf("$ - Get mac policies\n");
+ printf("^ - Set country code\n");
+ printf("& - Get country code\n");
+ printf(LOG_RED "0 - Exit \n" LOG_END);
+
+ printf("ENTER - Show options menu.......\n");
+ }
+
+ switch (a[0]) {
+/* Public API */
+ case '1':
+ rv = wman_test_init();
+ break;
+ case '2':
+ rv = wman_test_deinit();
+ break;
+ case '3':
+ rv = wman_test_activate(wifi);
+ break;
+ case '4':
+ rv = wman_test_deactivate(wifi);
+ break;
+ case '5':
+ rv = wman_test_is_activated(wifi);
+ break;
+ case '6':
+ rv = wman_test_get_connection_state(wifi);
+ break;
+ case '7':
+ rv = wman_test_get_mac_address(wifi);
+ break;
+ case '8':
+ rv = wman_test_get_interface_name(wifi);
+ break;
+ case '9':
+ rv = wman_test_scan(wifi);
+ break;
+ case 'a':
+ rv = wman_test_get_connected_ap(wifi);
+ break;
+ case 'b':
+ rv = wman_test_foreach_found_ap(wifi);
+ break;
+ case 'c':
+ rv = wman_test_connect(wifi);
+ break;
+ case 'd':
+ rv = wman_test_disconnect(wifi);
+ break;
+ case 'e':
+ rv = wman_test_connect_wps(wifi);
+ break;
+ case 'f':
+ rv = wman_test_forget_ap(wifi);
+ break;
+ case 'g':
+ rv = wman_test_connect_eap_ap(wifi);
+ break;
+ case 'h':
+ rv = wman_test_set_ip_method(wifi);
+ break;
+ case 'i':
+ rv = wman_test_set_proxy_method(wifi);
+ break;
+ case 'j':
+ rv = wman_test_get_ap_info(wifi);
+ break;
+ case 'k':
+ rv = wman_test_connect_specific_ap(wifi);
+ break;
+ case 'l':
+ rv = wman_test_config_load_configuration(wifi);
+ break;
+ case 'm':
+ rv = wman_test_config_save(wifi);
+ break;
+ case 'n':
+ rv = wman_test_config_remove(wifi);
+ break;
+ case 'o':
+ rv = wman_test_tdls_discover(wifi);
+ break;
+ case 'p':
+ rv = wman_test_tdls_connect(wifi);
+ break;
+ case 'q':
+ rv = wman_test_tdls_get_connected_peer(wifi);
+ break;
+ case 'r':
+ rv = wman_test_tdls_disconnect(wifi);
+ break;
+ case 's':
+ rv = wman_test_connect_hidden_ap(wifi);
+ break;
+ case 't':
+ rv = wman_test_connect_wps_pbc_without_ssid(wifi);
+ break;
+ case 'u':
+ rv = wman_test_connect_wps_pin_without_ssid(wifi);
+ break;
+ case 'v':
+ rv = wman_test_cancel_wps(wifi);
+ break;
+ case 'w':
+ rv = wman_test_get_scan_state(wifi);
+ break;
+ case 'x':
+ rv = wman_test_tdls_enable_channel_switch(wifi);
+ break;
+ case 'y':
+ rv = wman_test_tdls_disable_channel_switch(wifi);
+ break;
+ case 'z':
+ rv = wman_test_get_module_state(wifi);
+ break;
+ case 'A':
+ rv = wman_test_bssid_scan(wifi);
+ break;
+ case 'B':
+ rv = wman_test_specific_ap_start_multi_scan(wifi);
+ break;
+ case 'C':
+ rv = wman_test_add_vsie(wifi);
+ break;
+ case 'D':
+ rv = wman_test_get_vsie(wifi);
+ break;
+ case 'E':
+ rv = wman_test_remove_vsie(wifi);
+ break;
+ case 'F':
+ rv = wman_test_set_ip_conflict_detect_enable(wifi);
+ break;
+ case 'G':
+ rv = wman_test_ip_conflict_detect_is_enabled(wifi);
+ break;
+ case 'H':
+ rv = wman_test_get_ip_conflict_state(wifi);
+ break;
+ case 'I':
+ rv = wman_test_get_wps_generated_pin(wifi);
+ break;
+ case 'J':
+ rv = wman_test_forget_ap_async(wifi);
+ break;
+
+/* Extension APIs */
+ case 'K':
+ rv = wman_test_set_autoscan_state(wifi);
+ break;
+ case 'L':
+ rv = wman_test_set_autoscan_mode(wifi);
+ break;
+ case 'M':
+ rv = wman_test_get_autoscan_state(wifi);
+ break;
+ case 'N':
+ rv = wman_test_get_autoscan_mode(wifi);
+ break;
+ case 'O':
+ rv = wman_test_flush_bss(wifi);
+ break;
+ case 'P':
+ rv = wman_test_set_auto_connect(wifi);
+ break;
+ case 'Q':
+ rv = wman_test_get_auto_connect(wifi);
+ break;
+ case 'R':
+ rv = wman_test_set_ap_auto_connect(wifi);
+ break;
+ case 'S':
+ rv = wman_test_get_ap_auto_connect(wifi);
+ break;
+ case 'T':
+ rv = wman_test_set_ip_conflict_period(wifi);
+ break;
+ case 'U':
+ rv = wman_test_get_ip_conflict_period(wifi);
+ break;
+ case 'V':
+ rv = wman_test_netlink_scan(wifi);
+ break;
+ case 'W':
+ rv = wman_test_get_passpoint_state(wifi);
+ break;
+ case 'X':
+ rv = wman_test_set_passpoint_enable(wifi);
+ break;
+ case 'Y':
+ rv = wman_test_get_connection_mode(wifi);
+ break;
+ case 'Z':
+ rv = wman_test_get_5ghz_band_supported(wifi);
+ break;
+ case '!':
+ rv = wman_test_set_mac_policy(wifi);
+ break;
+ case '@':
+ rv = wman_test_set_preassoc_mac_policy(wifi);
+ break;
+ case '#':
+ rv = wman_test_set_random_mac_lifetime(wifi);
+ break;
+ case '$':
+ rv = wman_test_get_mac_policies(wifi);
+ break;
+ case '^':
+ rv = wman_test_set_country_code(wifi);
+ break;
+ case '&':
+ rv = wman_test_get_country_code(wifi);
+ break;
+ default:
+ break;
+ }
+
+ if (rv == 1)
+ printf("Operation succeeded!\n");
+ else
+ printf("Operation failed!\n");
+
+ return TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GMainLoop *mainloop;
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
+#endif
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ GIOChannel *channel = g_io_channel_unix_new(0);
+ g_io_add_watch(channel, (G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL), test_thread, NULL);
+
+ printf("Test Thread created...\n");
+
+ g_main_loop_run(mainloop);
+
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012-2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "wman_test_misc.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wifi-manager.h>
+#include "wman_test_common.h"
+
+#define MAC_ADDR_LEN 17
+
+static void __test_activated_cb(wifi_manager_error_e result, void* user_data)
+{
+ if (result == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi Activation Succeeded\n");
+ else
+ printf("Wi-Fi Activation Failed! error : %s\n", wman_test_strerror(result));
+}
+
+int wman_test_activate(wifi_manager_h wifi)
+{
+ int rv = 0;
+
+ rv = wifi_manager_activate(wifi, __test_activated_cb, NULL);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to activate Wi-Fi device [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Success to activate Wi-Fi device\n");
+
+ return 1;
+}
+
+static void __test_deactivated_cb(wifi_manager_error_e result, void* user_data)
+{
+ if (result == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi Deactivation Succeeded\n");
+ else
+ printf("Wi-Fi Deactivation Failed! error : %s\n", wman_test_strerror(result));
+}
+
+int wman_test_deactivate(wifi_manager_h wifi)
+{
+ int rv = 0;
+
+ rv = wifi_manager_deactivate(wifi, __test_deactivated_cb, NULL);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to deactivate Wi-Fi device [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Success to deactivate Wi-Fi device\n");
+
+ return 1;
+}
+
+
+int wman_test_is_activated(wifi_manager_h wifi)
+{
+ int rv = 0;
+ bool state = false;
+
+ rv = wifi_manager_is_activated(wifi, &state);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get Wi-Fi device state [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Success to get Wi-Fi device state : %s\n", (state) ? "TRUE" : "FALSE");
+
+ return 1;
+}
+
+int wman_test_get_connection_state(wifi_manager_h wifi)
+{
+ int rv = 0;
+ wifi_manager_connection_state_e connection_state;
+
+ rv = wifi_manager_get_connection_state(wifi, &connection_state);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get connection state [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Success to get connection state : ");
+ switch (connection_state) {
+ case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION:
+ printf("Association\n");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
+ printf("Connected\n");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION:
+ printf("Configuration\n");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED:
+ printf("Disconnected\n");
+ break;
+ default:
+ printf("Unknown\n");
+ }
+
+ return 1;
+}
+
+int wman_test_get_mac_address(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char *mac_addr = NULL;
+
+ rv = wifi_manager_get_mac_address(wifi, &mac_addr);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get MAC address [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("MAC address : %s\n", mac_addr);
+ free(mac_addr);
+
+ return 1;
+}
+
+int wman_test_get_interface_name(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char *if_name = NULL;
+
+ rv = wifi_manager_get_network_interface_name(wifi, &if_name);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get Interface name [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Interface name : %s\n", if_name);
+ free(if_name);
+
+ return 1;
+}
+
+static void __test_scan_request_cb(wifi_manager_error_e error_code, void* user_data)
+{
+ if (user_data != NULL)
+ printf("user_data : %s\n", (char *)user_data);
+
+ printf("Scan Completed from scan request, error code : %s\n",
+ wman_test_strerror(error_code));
+}
+
+int wman_test_scan(wifi_manager_h wifi)
+{
+ int rv = 0;
+
+ rv = wifi_manager_scan(wifi, __test_scan_request_cb, NULL);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Scan request failed [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Scan request succeeded\n");
+
+ return 1;
+}
+
+int wman_test_tdls_discover(wifi_manager_h wifi)
+{
+ int rv = 0;
+
+ char peer_mac[MAC_ADDR_LEN + 1];
+ printf("Enter Mac_address: ");
+ if (scanf(" %17s", peer_mac) < 1)
+ return -1;
+
+ if (strlen(peer_mac) < MAC_ADDR_LEN) {
+ printf("Wrong Mac_address\n");
+ return -1;
+ }
+
+ rv = wifi_manager_tdls_start_discovery(wifi, peer_mac);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("test_wifi_tdls_discover() is failed [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+ return 1;
+}
+
+int wman_test_tdls_connect(wifi_manager_h wifi)
+{
+ int rv = 0;
+
+ char peer_mac[MAC_ADDR_LEN + 1];
+ printf("Enter Mac_address: ");
+ if (scanf(" %17s", peer_mac) < 1)
+ return -1;
+
+ if (strlen(peer_mac) < MAC_ADDR_LEN) {
+ printf("Wrong Mac_address\n");
+ return -1;
+ }
+
+ rv = wifi_manager_tdls_connect(wifi, peer_mac);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("test_wifi_tdls_connect() is failed [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+ return 1;
+}
+
+int wman_test_tdls_get_connected_peer(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char *mac_addr = NULL;
+
+ rv = wifi_manager_tdls_get_connected_peer(wifi, &mac_addr);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("wifi_manager_tdls_get_connected_peer() is failed [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+ printf("Peer Mac address is [%s]\n", mac_addr);
+ free(mac_addr);
+ return 1;
+}
+
+int wman_test_tdls_disconnect(wifi_manager_h wifi)
+{
+ int rv = 0;
+
+ char peer_mac[MAC_ADDR_LEN + 1];
+ printf("Enter Mac_address: ");
+ if (scanf(" %17s", peer_mac) < 1)
+ return -1;
+
+ if (strlen(peer_mac) < MAC_ADDR_LEN) {
+ printf("Wrong Mac_address\n");
+ return -1;
+ }
+
+ rv = wifi_manager_tdls_disconnect(wifi, peer_mac);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("test_wifi_tdls_disconnect() is failed [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+ return 1;
+}
+
+static void __test_wps_pbc_connected_cb(wifi_manager_error_e result, void* user_data)
+{
+ if (result == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi WPS PBC Connection Succeeded\n");
+ else
+ printf("Wi-Fi WPS PBC Connection Failed! error : %s\n",
+ wman_test_strerror(result));
+}
+
+int wman_test_connect_wps_pbc_without_ssid(wifi_manager_h wifi)
+{
+ int rv;
+ rv = wifi_manager_connect_by_wps_pbc_without_ssid(wifi, __test_wps_pbc_connected_cb, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to WPS connection request : %s\n", wman_test_strerror(rv));
+ else
+ printf("Success to WPS connection request \n");
+ return 1;
+}
+
+static void __test_wps_pin_connected_cb(wifi_manager_error_e result, void* user_data)
+{
+ if (result == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi WPS PIN Connection Succeeded\n");
+ else
+ printf("Wi-Fi WPS PIN Connection Failed! error : %s\n",
+ wman_test_strerror(result));
+}
+
+int wman_test_connect_wps_pin_without_ssid(wifi_manager_h wifi)
+{
+ int rv;
+ char pin[9];
+
+ printf("Input pin to wps pin connect : ");
+
+ rv = scanf(" %8s", pin);
+ if (rv <= 0)
+ return -1;
+
+ if ((strlen(pin) != 4) &&
+ (strlen(pin) != 8)) {
+ printf("Wrong pin number (4 or 8)\n");
+ return -1;
+ }
+
+ rv = wifi_manager_connect_by_wps_pin_without_ssid(wifi, pin, __test_wps_pin_connected_cb, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to WPS connection request : %s\n", wman_test_strerror(rv));
+ else
+ printf("Success to WPS connection request \n");
+ return 1;
+}
+
+int wman_test_cancel_wps(wifi_manager_h wifi)
+{
+ int rv;
+ rv = wifi_manager_cancel_wps(wifi);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to WPS cancel request : %s\n", wman_test_strerror(rv));
+ else
+ printf("Success to WPS cancel request \n");
+ return 1;
+}
+
+int wman_test_get_scan_state(wifi_manager_h wifi)
+{
+ int rv = 0;
+ wifi_manager_scan_state_e scan_state = -1;
+
+ rv = wifi_manager_get_scan_state(wifi, &scan_state);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get scan state [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Scan state [%d]\n", scan_state);
+
+ return 1;
+}
+
+int wman_test_tdls_enable_channel_switch(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char peer_mac[MAC_ADDR_LEN + 1];
+ int freq;
+ printf("Enter Mac_address: ");
+ if (scanf(" %17s", peer_mac) < 1)
+ return -1;
+ if (strlen(peer_mac) < MAC_ADDR_LEN) {
+ printf("Wrong Mac_address\n");
+ return -1;
+ }
+ printf("Enter Peer Frequency:\n");
+ rv = scanf("%9d", &freq);
+ if (rv <= 0) {
+ printf("Invalid input!\n");
+ return -1;
+ }
+ rv = wifi_manager_tdls_enable_channel_switching(wifi, peer_mac, freq);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("wman_test_tdls_channel_switch() is failed [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+ return 1;
+}
+
+int wman_test_tdls_disable_channel_switch(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char peer_mac[MAC_ADDR_LEN + 1];
+ printf("Enter Mac_address: ");
+ if (scanf(" %17s", peer_mac) < 1)
+ return -1;
+ if (strlen(peer_mac) < MAC_ADDR_LEN) {
+ printf("Wrong Mac_address\n");
+ return -1;
+ }
+ rv = wifi_manager_tdls_disable_channel_switching(wifi, peer_mac);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("wman_test_tdls_cancle_channel_switch() is failed [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+ return 1;
+}
+
+int wman_test_get_module_state(wifi_manager_h wifi)
+{
+ int rv = 0;
+ wifi_manager_module_state_e module_state;
+
+ rv = wifi_manager_get_module_state(wifi, &module_state);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get wifi module state [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Success to get WiFI Module state : ");
+ switch (module_state) {
+ case WIFI_MANAGER_MODULE_STATE_ATTACHED:
+ printf("Wi-Fi Module Attached \n");
+ break;
+ case WIFI_MANAGER_MODULE_STATE_DETACHED:
+ printf("Wi-Fi Module Detached\n");
+ break;
+ default:
+ printf("Unknown\n");
+ }
+
+ return 1;
+}
+
+int wman_test_add_vsie(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char *vsie = NULL;
+ unsigned int frame_id;
+
+ printf("Input frame_id:\n");
+ if (scanf(" %2u", &frame_id) < 1)
+ return -1;
+
+ printf("Input vsie:\n");
+ if (scanf(" %100ms", &vsie) < 1)
+ return -1;
+
+ if (strlen(vsie) <= 0)
+ printf("invalid vsie !!\n");
+ else
+ printf("vsie: [%s]\n", vsie);
+
+ if ((strlen(vsie) > 0)) {
+ rv = wifi_manager_add_vsie(wifi, frame_id, vsie);
+ printf("wifi_manager_add_vsie() ret=[%d]\n", rv);
+
+ free(vsie);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to add vsie [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+ }
+
+ return 1;
+}
+
+int wman_test_get_vsie(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char *vsie = NULL;
+ unsigned int frame_id;
+
+ printf("Input frame_id:\n");
+ if (scanf(" %2u", &frame_id) < 1)
+ return -1;
+
+ rv = wifi_manager_get_vsie(wifi, frame_id, &vsie);
+
+ printf("Received vsie [%s]\n", vsie ? vsie : "NULL");
+ free(vsie);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get vsie [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+int wman_test_remove_vsie(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char *vsie = NULL;
+ unsigned int frame_id;
+
+ printf("Input frame_id:\n");
+ if (scanf(" %2u", &frame_id) < 1)
+ return -1;
+
+ printf("Input vsie:\n");
+ if (scanf(" %100ms", &vsie) < 1)
+ return -1;
+
+ if (strlen(vsie) <= 0)
+ printf("invalid vsie !!\n");
+ else
+ printf("vsie: [%s]\n", vsie);
+
+ if ((strlen(vsie) > 0)) {
+ rv = wifi_manager_remove_vsie(wifi, frame_id, vsie);
+ printf("wifi_manager_remove_vsie() ret=[%d]\n", rv);
+
+ free(vsie);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to remove vsie [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+ }
+
+ return 1;
+}
+
+int wman_test_set_ip_conflict_detect_enable(wifi_manager_h wifi)
+{
+ int rv = 0;
+ int choice;
+ bool state = false;
+
+ printf("Input '1'(enable)/'0'(disable) for ip conflict detection : ");
+ rv = scanf(" %d", &choice);
+ if (choice == 1)
+ state = true;
+ else if (choice == 0)
+ state = false;
+ else
+ return -1;
+
+ rv = wifi_manager_set_ip_conflict_detect_enable(wifi, state);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set ip conflict detection state [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("Succesfully set the ip conflict detection !\n");
+ return 1;
+}
+
+int wman_test_ip_conflict_detect_is_enabled(wifi_manager_h wifi)
+{
+ int rv = 0;
+ bool state = false;
+
+ rv = wifi_manager_ip_conflict_detect_is_enabled(wifi, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get ip conflict detection state [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ printf("IP conflict detection is %s\n", state ? "enabled" : "disabled");
+ printf("Succesfully get the ip conflict detection !\n");
+ return 1;
+}
+
+int wman_test_get_ip_conflict_state(wifi_manager_h wifi)
+{
+ int rv = 0;
+ wifi_manager_ip_conflict_state_e state;
+
+ rv = wifi_manager_get_ip_conflict_state(wifi, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get ip conflict state [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ switch (state) {
+ case WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_DETECTED:
+ printf("IP Conflict present\n");
+ break;
+ case WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED:
+ printf("IP Conflict absent\n");
+ break;
+ case WIFI_MANAGER_IP_CONFLICT_STATE_UNKNOWN:
+ printf("IP Conflict state is unknown\n");
+ break;
+ default:
+ printf("Unhandled state\n");
+ break;
+ }
+
+ printf("Succesfully get the ip conflict state!\n");
+ return 1;
+}
+
+int wman_test_get_wps_generated_pin(wifi_manager_h wifi)
+{
+ int rv = 0;
+ char *wps_pin = NULL;
+
+ rv = wifi_manager_get_wps_generated_pin(wifi, &wps_pin);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("wifi_manager_get_wps_generated_pin() is failed [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+ printf("Generaged pin number is [%s]\n", wps_pin);
+ free(wps_pin);
+ return 1;
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <wifi-manager.h>
+
+int wman_test_activate(wifi_manager_h wifi);
+int wman_test_deactivate(wifi_manager_h wifi);
+int wman_test_is_activated(wifi_manager_h wifi);
+int wman_test_get_connection_state(wifi_manager_h wifi);
+int wman_test_get_mac_address(wifi_manager_h wifi);
+int wman_test_get_interface_name(wifi_manager_h wifi);
+int wman_test_scan(wifi_manager_h wifi);
+int wman_test_tdls_discover(wifi_manager_h wifi);
+int wman_test_tdls_connect(wifi_manager_h wifi);
+int wman_test_tdls_get_connected_peer(wifi_manager_h wifi);
+int wman_test_tdls_disconnect(wifi_manager_h wifi);
+int wman_test_connect_wps_pbc_without_ssid(wifi_manager_h wifi);
+int wman_test_connect_wps_pin_without_ssid(wifi_manager_h wifi);
+int wman_test_cancel_wps(wifi_manager_h wifi);
+int wman_test_get_scan_state(wifi_manager_h wifi);
+int wman_test_tdls_enable_channel_switch(wifi_manager_h wifi);
+int wman_test_tdls_disable_channel_switch(wifi_manager_h wifi);
+int wman_test_get_module_state(wifi_manager_h wifi);
+int wman_test_add_vsie(wifi_manager_h wifi);
+int wman_test_get_vsie(wifi_manager_h wifi);
+int wman_test_remove_vsie(wifi_manager_h wifi);
+int wman_test_set_ip_conflict_detect_enable(wifi_manager_h wifi);
+int wman_test_ip_conflict_detect_is_enabled(wifi_manager_h wifi);
+int wman_test_get_ip_conflict_state(wifi_manager_h wifi);
+int wman_test_get_wps_generated_pin(wifi_manager_h wifi);
ADD_EXECUTABLE(${WIFI_MGR_TOOL} ${MGR_TOOL_SRCS})
TARGET_LINK_LIBRARIES(${WIFI_MGR_TOOL} ${PROJECT_NAME})
SET_TARGET_PROPERTIES(${WIFI_MGR_TOOL} PROPERTIES POSITION_INDEPENDENT_CODE ON)
-
-SET(wifi_manager_test_src
- wifi_manager_test.c
-)
-
-ADD_EXECUTABLE(wifi_manager_test ${wifi_manager_test_src})
-TARGET_LINK_LIBRARIES(wifi_manager_test ${PROJECT_NAME})
-
INSTALL(TARGETS ${WIFI_MGR_TOOL} DESTINATION ${BIN_INSTALL_DIR})
-INSTALL(TARGETS wifi_manager_test DESTINATION ${BIN_INSTALL_DIR})
+++ /dev/null
-/*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <netdb.h>
-#include <sys/socket.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/un.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <signal.h>
-#include <assert.h>
-#include <wifi-manager.h>
-#include <wifi-manager-extension.h>
-#include <tizen_error.h>
-
-
-#define LOG_RED "\033[0;31m"
-#define LOG_GREEN "\033[0;32m"
-#define LOG_BROWN "\033[0;33m"
-#define LOG_BLUE "\033[0;34m"
-#define LOG_END "\033[0;m"
-
-#define MAC_ADDR_LEN 17
-
-wifi_manager_h wifi = NULL;
-wifi_manager_h wifi2 = NULL;
-
-gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data);
-int test_wifi_manager_foreach_bssid_scan(void);
-int test_wifi_manager_foreach_netlink_scan(void);
-
-static const char *__test_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_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_OUT_OF_RANGE:
- return "OUT_OF_RANGE";
- 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_PIN_MISSING:
- return "PIN_MISSING";
- 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";
- case WIFI_MANAGER_ERROR_PERMISSION_DENIED:
- return "PERMISSION_DENIED";
- case WIFI_MANAGER_ERROR_OFFLINE:
- return "OFFLINE";
- case WIFI_MANAGER_ERROR_INVALID_GATEWAY:
- return "INVALID_GATEWAY";
- case WIFI_MANAGER_ERROR_NOT_SUPPORTED:
- return "NOT_SUPPORTED";
- case WIFI_MANAGER_ERROR_NOT_INITIALIZED:
- return "NOT_INITIALIZED";
- default:
- return "UNKNOWN";
- }
-}
-
-static const char *__test_convert_connection_mode_to_string(wifi_manager_connection_mode_e mode)
-{
- switch (mode) {
- case WIFI_MANAGER_CONNECTION_MODE_80211_B:
- return "802.11b";
- case WIFI_MANAGER_CONNECTION_MODE_80211_G:
- return "802.11g";
- case WIFI_MANAGER_CONNECTION_MODE_80211_N:
- return "802.11n";
- case WIFI_MANAGER_CONNECTION_MODE_80211_A:
- return "802.11a";
- case WIFI_MANAGER_CONNECTION_MODE_80211_AC:
- return "802.11ac";
- case WIFI_MANAGER_CONNECTION_MODE_UNKNOWN:
- return "Uknown";
- default:
- return "Uknown";
- }
-}
-
-static void __test_device_state_callback(wifi_manager_device_state_e state, void* user_data)
-{
- printf("[%s] Device state changed callback", (char *)user_data);
-
- if (state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED)
- printf(", state : Activated\n");
- else
- printf(", state : Deactivated\n");
-}
-
-static void __test_scan_changed_callback(wifi_manager_scan_state_e state, void* user_data)
-{
- printf("Scan changed, scan state : %d\n", state);
-}
-
-static void __test_bg_scan_completed_callback(wifi_manager_error_e error_code, void* user_data)
-{
- printf("[%s] Background Scan Completed, error code : %s\n",
- (char *)user_data, __test_convert_error_to_string(error_code));
-}
-
-static void __test_ip_conflict_callback(char *mac, wifi_manager_ip_conflict_state_e state, void *user_data)
-{
- if (state == WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_DETECTED)
- printf("[%s] Ip conflict detected : %s\n", (char *)user_data, mac);
- else if (state == WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED)
- printf("Ip conflict removed\n");
- else
- printf("Ip conflict state unknown\n");
-}
-
-static void __test_scan_request_callback(wifi_manager_error_e error_code, void* user_data)
-{
- if (user_data != NULL)
- printf("user_data : %s\n", (char *)user_data);
-
- printf("Scan Completed from scan request, error code : %s\n",
- __test_convert_error_to_string(error_code));
-}
-
-static void __test_bssid_scan_request_callback(wifi_manager_error_e error_code, void *user_data)
-{
- printf("BSSID Scan Completed, error code : %s\n",
- __test_convert_error_to_string(error_code));
-
- if (error_code == WIFI_MANAGER_ERROR_NONE)
- test_wifi_manager_foreach_bssid_scan();
-}
-
-static void __test_netlink_scan_request_callback(wifi_manager_error_e error_code, void *user_data)
-{
- printf("Netlink Scan Completed, error code : %s\n",
- __test_convert_error_to_string(error_code));
-
- if (error_code == WIFI_MANAGER_ERROR_NONE)
- test_wifi_manager_foreach_netlink_scan();
-}
-
-static void __test_connection_state_callback(wifi_manager_connection_state_e state, wifi_manager_ap_h ap, void* user_data)
-{
- int rv = 0;
- char *ap_name = NULL;
-
- printf("[%s] Connection state changed callback", (char *)user_data);
-
- switch (state) {
- case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
- printf(", state : Connected");
- break;
- case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION:
- printf(", state : Association");
- break;
- case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION:
- printf(", state : Configuration");
- break;
- case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED:
- printf(", state : Disconnected");
- break;
- default:
- printf(", state : Unknown");
- }
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf(", Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- else {
- printf(", AP name : %s\n", ap_name);
- g_free(ap_name);
- }
-}
-
-static void __test_activated_callback(wifi_manager_error_e result, void* user_data)
-{
- if (result == WIFI_MANAGER_ERROR_NONE)
- printf("Wi-Fi Activation Succeeded\n");
- else
- printf("Wi-Fi Activation Failed! error : %s\n", __test_convert_error_to_string(result));
-}
-
-static void __test_deactivated_callback(wifi_manager_error_e result, void* user_data)
-{
- if (result == WIFI_MANAGER_ERROR_NONE)
- printf("Wi-Fi Deactivation Succeeded\n");
- else
- printf("Wi-Fi Deactivation Failed! error : %s\n", __test_convert_error_to_string(result));
-}
-
-static void __test_connected_callback(wifi_manager_error_e result, void* user_data)
-{
- if (result == WIFI_MANAGER_ERROR_NONE)
- printf("Wi-Fi Connection Succeeded\n");
- else
- printf("Wi-Fi Connection Failed! error : %s\n", __test_convert_error_to_string(result));
-}
-
-static void __test_disconnected_callback(wifi_manager_error_e result, void* user_data)
-{
- if (result == WIFI_MANAGER_ERROR_NONE)
- printf("Wi-Fi Disconnection Succeeded\n");
- else
- printf("Wi-Fi Disconnection Failed! error : %s\n", __test_convert_error_to_string(result));
-}
-
-static void __test_rssi_level_callback(wifi_manager_rssi_level_e rssi_level, void* user_data)
-{
- printf("[%s] RSSI level changed callback, level = %d\n", (char *)user_data, rssi_level);
-}
-
-static void __test_tdls_discover_callback(wifi_manager_tdls_discovery_state_e state, char *peer_mac_add, void *user_data)
-{
- printf("[%s] TDLS discover callback", (char *)user_data);
-
- printf(", Peer Mac Address [%s], state :%d\n", peer_mac_add, state);
- if (state == WIFI_MANAGER_TDLS_DISCOVERY_STATE_ONGOING)
- printf(", Discovery is ongoing");
- else
- printf(", Discovery is finished");
-}
-
-static void __test_get_wifi_module_state_callback(wifi_manager_module_state_e state, void *user_data)
-{
- printf("Wi-Fi Module State Changed callback : %d", state);
-
- if (state == WIFI_MANAGER_MODULE_STATE_ATTACHED)
- printf(", Wi-Fi Module Attached\n");
- else
- printf(", Wi-Fi Module Detached\n");
-}
-
-static void __test_tdls_state_callback(wifi_manager_tdls_state_e state, char *peer_mac_add, void *user_data)
-{
- printf("[%s] TDLS state changed callback", (char *)user_data);
-
- if (state == WIFI_MANAGER_TDLS_STATE_CONNECTED)
- printf(", state : TDLS Connected, Peer Mac Address [%s]\n", peer_mac_add);
- else
- printf(", state : TDLS Disconnected, Peer Mac Address [%s]\n", peer_mac_add);
-}
-
-static const char* __test_print_state(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";
-}
-
-static bool __test_compare_ap_name(const char *ap_name, const char *ap_name_part)
-{
- int ap_name_len = strlen(ap_name);
- int ap_name_part_len = strlen(ap_name_part);
-
- if (strncmp(ap_name, ap_name_part,
- ap_name_len > ap_name_part_len ? ap_name_len : ap_name_part_len) == 0)
- return true;
- else
- return false;
-}
-
-static bool __test_found_ap_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0;
- char *ap_name = NULL;
- wifi_manager_connection_state_e state;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- rv = wifi_manager_ap_get_connection_state(ap, &state);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get State [%s]\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- return false;
- }
-
- printf("AP name : %s, state : %s\n", ap_name, __test_print_state(state));
- g_free(ap_name);
-
- return true;
-}
-
-struct _ap_data {
- char ap_name[33];
- bool is_found;
-};
-
-static bool __test_found_connect_ap_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0;
- char *ap_name = NULL;
- struct _ap_data *data = (struct _ap_data*)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, data->ap_name)) {
- bool required = false;
- data->is_found = true;
-
- if (wifi_manager_ap_is_passphrase_required(ap, &required) == WIFI_MANAGER_ERROR_NONE)
- printf("Passphrase required : %s\n", required ? "TRUE" : "FALSE");
- else
- printf("Fail to get Passphrase required\n");
-
- if (required) {
- char passphrase[100];
- printf("Input passphrase for %s : ", ap_name);
- rv = scanf(" %99s", passphrase);
-
- rv = wifi_manager_ap_set_passphrase(ap, passphrase);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set passphrase : %s\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- return false;
- }
- }
-
- rv = wifi_manager_connect(wifi, ap, __test_connected_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to connection request [%s]\n", ap_name);
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static bool __test_found_connect_wps_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0;
- char *ap_name = NULL;
- char *ap_name_part = (char*)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- int user_sel;
- char pin[32] = {0,};
-
- printf("%s - Input WPS method (1:PBC, 2:PIN) :\n", ap_name);
- rv = scanf(" %9d", &user_sel);
-
- switch (user_sel) {
- case 1:
- rv = wifi_manager_connect_by_wps_pbc(wifi, ap, __test_connected_callback, NULL);
- break;
- case 2:
- printf("Input PIN code :\n");
- rv = scanf("%31s", pin);
- rv = wifi_manager_connect_by_wps_pin(wifi, ap, pin, __test_connected_callback, NULL);
- break;
- default:
- printf("Invalid input!\n");
- g_free(ap_name);
- return false;
- }
-
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to connection request [%s]\n", ap_name);
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static bool __test_found_disconnect_ap_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0;
- char *ap_name = NULL;
- char *ap_name_part = (char*)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- rv = wifi_manager_disconnect(wifi, ap, __test_disconnected_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to disconnection reqeust %s : [%s]\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to disconnection request %s\n", ap_name);
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static bool __test_found_forget_ap_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0;
- char *ap_name = NULL;
- char *ap_name_part = (char*)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- rv = wifi_manager_forget_ap(wifi, ap);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to forget [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to forget [%s]\n", ap_name);
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static void __test_forget_ap_finished_cb(wifi_manager_error_e result, void *user_data)
-{
- printf("Forget AP callback %s, error: [%s]\n",
- (result == WIFI_MANAGER_ERROR_NONE) ? "succeeded" : "failed",
- __test_convert_error_to_string(result));
-}
-
-static bool __test_found_forget_ap_async_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0;
- char *ap_name = NULL;
- char *ap_name_part = (char*)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- rv = wifi_manager_forget_ap_async(wifi, ap,
- __test_forget_ap_finished_cb, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to forget [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to forget [%s]\n", ap_name);
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static bool __test_found_eap_ap_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0;
- char *ap_name = NULL;
- char *ap_name_part = (char*)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- wifi_manager_security_type_e type;
-
- if (wifi_manager_ap_get_security_type(ap, &type) == WIFI_MANAGER_ERROR_NONE)
- printf("Security type : %d\n", type);
- else
- printf("Fail to get Security type\n");
-
- if (type != WIFI_MANAGER_SECURITY_TYPE_EAP) {
- g_free(ap_name);
- return false;
- }
-
- char input_str1[100];
- printf("Input user name for %s : ", ap_name);
- rv = scanf(" %99s", input_str1);
-
- char input_str2[100];
- printf("Input password for %s : ", ap_name);
- rv = scanf("%99s", input_str2);
-
- rv = wifi_manager_ap_set_eap_passphrase(ap, input_str1, input_str2);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set eap passphrase : %s\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- return false;
- }
-
- char *inputed_name = NULL;
- bool is_pass_set;
- rv = wifi_manager_ap_get_eap_passphrase(ap, &inputed_name, &is_pass_set);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get eap passphrase : %s\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- return false;
- }
-
- printf("name : %s, is password set : %s\n", inputed_name, is_pass_set ? "TRUE" : "FALSE");
-
- int input_int;
- printf("Input EAP type:\n");
- printf("0 -> WIFI_MANAGER_EAP_TYPE_PEAP\n");
- printf("1 -> WIFI_MANAGER_EAP_TYPE_TLS\n");
- printf("2 -> WIFI_MANAGER_EAP_TYPE_TTLS\n");
- printf("3 -> WIFI_MANAGER_EAP_TYPE_SIM\n");
- printf("4 -> WIFI_MANAGER_EAP_TYPE_AKA\n");
- printf("5 -> WIFI_MANAGER_EAP_TYPE_AKA_PRIME\n");
- printf("6 -> WIFI_MANAGER_EAP_TYPE_FAST\n");
- printf("7 -> WIFI_MANAGER_EAP_TYPE_PWD\n");
- rv = scanf("%d", &input_int);
-
- rv = wifi_manager_ap_set_eap_type(ap, input_int);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set eap type : %s\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- g_free(inputed_name);
- return false;
- }
-
- if (input_int == 0 || input_int == 1 || input_int == 2) {
- printf("Input certificate file:\n");
- rv = scanf("%99s", input_str1);
-
- rv = wifi_manager_ap_set_eap_ca_cert_file(ap, input_str1);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set eap certificatefile : %s\n",
- __test_convert_error_to_string(rv));
- g_free(ap_name);
- g_free(inputed_name);
- return false;
- }
- }
-
- printf("Input EAP authentication type:\n");
- printf("0 -> WIFI_MANAGER_EAP_AUTH_TYPE_NONE\n");
- printf("1 -> WIFI_MANAGER_EAP_AUTH_TYPE_PAP\n");
- printf("2 -> WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAP\n");
- printf("3 -> WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAPV2\n");
- printf("4 -> WIFI_MANAGER_EAP_AUTH_TYPE_GTC\n");
- printf("5 -> WIFI_MANAGER_EAP_AUTH_TYPE_MD5\n");
- rv = scanf("%d", &input_int);
-
- rv = wifi_manager_ap_set_eap_auth_type(ap, input_int);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set eap auth type : %s\n",
- __test_convert_error_to_string(rv));
- g_free(ap_name);
- g_free(inputed_name);
- return false;
- }
-
- rv = wifi_manager_connect(wifi, ap, __test_connected_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to connection request [%s]\n", ap_name);
-
- g_free(ap_name);
- g_free(inputed_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static bool __test_found_set_autoconnect_ap_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0, enable;
- char *ap_name = NULL;
- bool autoconnect = false;
- char *ap_name_part = (char *)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("[Wi-Fi] Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- printf("[Wi-Fi] Input command number (enable[1], disable[0]) : ");
- rv = scanf(" %9d", &enable);
- if (rv <= 0) {
- g_free(ap_name);
- return false;
- }
-
- if (enable != 0)
- autoconnect = true;
-
- rv = wifi_manager_ap_set_auto_connect(ap, autoconnect);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to set [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to set [%s]\n", ap_name);
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
-
- return true;
-}
-
-static bool __test_found_get_autoconnect_ap_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0;
- bool autoconnect = false;
- char *ap_name = NULL;
- char *ap_name_part = (char *)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("[Wi-Fi] Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- rv = wifi_manager_ap_get_auto_connect(ap, &autoconnect);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to get [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to get : [%s]\n", autoconnect ? "TRUE" : "FALSE");
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
-
- return true;
-}
-
-static bool test_get_user_int(const char *msg, int *num)
-{
- if (msg == NULL || num == NULL)
- return false;
-
- int rv;
- char buf[32] = {0,};
- printf("%s\n", msg);
- rv = read(0, buf, 32);
-
- if (rv < 0 || *buf == 0 || *buf == '\n' || *buf == '\r')
- return false;
-
- *num = atoi(buf);
- return true;
-}
-
-static bool test_get_user_string(const char *msg, char *buf, int buf_size)
-{
- if (msg == NULL || buf == NULL || buf_size < 2)
- return false;
-
- int rv;
- printf("%s\n", msg);
- memset(buf, 0, buf_size);
- rv = read(0, buf, buf_size - 1);
-
- if (rv < 0 || buf[0] == '\0' || buf[0] == '\n' || buf[0] == '\r') {
- buf[0] = '\0';
- return false;
- }
-
- buf[rv-1] = '\0';
- return true;
-}
-
-static bool __test_found_change_ip_method_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv;
- char *ap_name;
- char *ap_name_part = (char*)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- wifi_manager_ip_config_type_e type;
- int method;
- int address_type;
- int dns_type;
- int prefix_len;
-
- printf("Input new method type (1:dhcp, 2:manual, 3:auto) :\n");
- rv = scanf(" %9d", &method);
- if (rv <= 0) {
- g_free(ap_name);
- return false;
- }
-
- rv = test_get_user_int("Input Address type to get"
- "(0:IPV4, 1:IPV6):", &address_type);
-
- if (rv == false || (address_type != 0 && address_type != 1)) {
- printf("Invalid input!!\n");
- g_free(ap_name);
- return false;
- }
-
- switch (method) {
- case 1:
- type = WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC;
- break;
- case 2:
- type = WIFI_MANAGER_IP_CONFIG_TYPE_STATIC;
- break;
- case 3:
- type = WIFI_MANAGER_IP_CONFIG_TYPE_AUTO;
- break;
- default:
- printf("Invalid input!\n");
- g_free(ap_name);
- return false;
- }
-
- rv = wifi_manager_ap_set_ip_config_type(ap, address_type, type);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to set ip method type[%s]\n", __test_convert_error_to_string(rv));
-
- if (type == WIFI_MANAGER_IP_CONFIG_TYPE_STATIC) {
- char ip_addr[40];
-
- printf("Input new ip address (x:skip, 0:clear) :\n");
- rv = scanf("%39s", ip_addr);
- if (rv > 0) {
- switch (ip_addr[0]) {
- case 'x':
- rv = WIFI_MANAGER_ERROR_NONE;
- break;
- case '0':
- rv = wifi_manager_ap_set_ip_address(ap, address_type, NULL);
- break;
- default:
- rv = wifi_manager_ap_set_ip_address(ap, address_type, ip_addr);
- }
-
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to set ip address[%s]\n",
- __test_convert_error_to_string(rv));
- }
-
- printf("Input new subnet mask (x:skip, 0:clear) :\n");
- rv = scanf("%39s", ip_addr);
- if (rv > 0) {
- switch (ip_addr[0]) {
- case 'x':
- rv = WIFI_MANAGER_ERROR_NONE;
- break;
- case '0':
- rv = wifi_manager_ap_set_subnet_mask(ap, address_type, NULL);
- break;
- default:
- rv = wifi_manager_ap_set_subnet_mask(ap, address_type, ip_addr);
- }
-
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to set subnet mask[%s]\n",
- __test_convert_error_to_string(rv));
- }
-
- printf("Input new prefix length (x:skip) :\n");
- rv = scanf("%d", &prefix_len);
- if (rv > 0) {
- if (prefix_len == 'x')
- rv = WIFI_MANAGER_ERROR_NONE;
- else
- rv = wifi_manager_ap_set_prefix_length(ap, address_type, prefix_len);
-
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to set subnet mask[%s]\n",
- __test_convert_error_to_string(rv));
- }
-
- printf("Input new gateway address (x:skip, 0:clear) :\n");
- rv = scanf("%39s", ip_addr);
- if (rv > 0) {
- switch (ip_addr[0]) {
- case 'x':
- rv = WIFI_MANAGER_ERROR_NONE;
- break;
- case '0':
- rv = wifi_manager_ap_set_gateway_address(ap, address_type, NULL);
- break;
- default:
- rv = wifi_manager_ap_set_gateway_address(ap, address_type, ip_addr);
- }
-
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to set gateway address[%s]\n",
- __test_convert_error_to_string(rv));
- }
-
- rv = test_get_user_int("Input DNS config type (0:STATIC, 1:DYNAMIC)"
- "- (Enter for skip) : ", &dns_type);
- if (rv == false) {
- printf("Invalid input!!\n");
- g_free(ap_name);
- return false;
- }
- switch (dns_type) {
- case 0:
- rv = wifi_manager_ap_set_dns_config_type(ap,
- address_type, WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC);
- if (rv == WIFI_MANAGER_ERROR_NONE) {
- printf("Input DNS1 address (x: skip, 0: clear) : \n");
- if (address_type == WIFI_MANAGER_ADDRESS_FAMILY_IPV4)
- rv = scanf("%15s", ip_addr);
- else
- rv = scanf("%39s", ip_addr);
- if (rv > 0) {
- switch (ip_addr[0]) {
- case 'x':
- rv = WIFI_MANAGER_ERROR_NONE;
- break;
- case '0':
- rv = wifi_manager_ap_set_dns_address(ap,
- 1, address_type, NULL);
- break;
- default:
- rv = wifi_manager_ap_set_dns_address(ap,
- 1, address_type, ip_addr);
- break;
- }
- }
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- g_free(ap_name);
- return false;
- }
-
- printf("Input DNS2 address (x: skip, 0: clear) : \n");
- if (address_type == WIFI_MANAGER_ADDRESS_FAMILY_IPV4)
- rv = scanf("%15s", ip_addr);
- else
- rv = scanf("%39s", ip_addr);
- if (rv > 0) {
- switch (ip_addr[0]) {
- case 'x':
- rv = WIFI_MANAGER_ERROR_NONE;
- break;
- case '0':
- rv = wifi_manager_ap_set_dns_address(ap,
- 2, address_type, NULL);
- break;
- default:
- rv = wifi_manager_ap_set_dns_address(ap,
- 2, address_type, ip_addr);
- break;
- }
- }
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- g_free(ap_name);
- return false;
- }
- }
- break;
- case 1:
- rv = wifi_manager_ap_set_dns_config_type(ap,
- address_type, WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- g_free(ap_name);
- return false;
- }
- break;
- }
- }
-
- rv = wifi_manager_update_ap(wifi, ap);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to update ap info[%s]\n",
- __test_convert_error_to_string(rv));
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static bool __test_found_change_proxy_method_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv, address_type;
- char *ap_name;
- char *ap_name_part = (char*)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- printf("ap_name %s, user input name %s\n", ap_name, ap_name_part);
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- wifi_manager_proxy_type_e type;
- char proxy_addr[65];
- int method;
-
- printf("Input new method type (1:direct, 2:manual, 3:auto) :\n");
- rv = scanf(" %9d", &method);
- if (rv <= 0) {
- g_free(ap_name);
- return false;
- }
-
- rv = test_get_user_int("Input Address type to get"
- "(0:IPV4, 1:IPV6):", &address_type);
-
- if (rv == false || (address_type != 0 && address_type != 1)) {
- printf("Invalid input!!\n");
- g_free(ap_name);
- return false;
- }
-
- switch (method) {
- case 1:
- type = WIFI_MANAGER_PROXY_TYPE_DIRECT;
- break;
- case 2:
- type = WIFI_MANAGER_PROXY_TYPE_MANUAL;
- break;
- case 3:
- type = WIFI_MANAGER_PROXY_TYPE_AUTO;
- break;
- default:
- printf("Invalid input!\n");
- g_free(ap_name);
- return false;
- }
-
- rv = wifi_manager_ap_set_proxy_type(ap, type);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to set proxy method type[%s]\n", __test_convert_error_to_string(rv));
-
- printf("Input new proxy address (x:skip, 0:clear) :\n");
- rv = scanf("%64s", proxy_addr);
-
- if (rv > 0) {
- switch (proxy_addr[0]) {
- case 'x':
- rv = WIFI_MANAGER_ERROR_NONE;
- break;
- case '0':
- rv = wifi_manager_ap_set_proxy_address(ap, address_type, NULL);
- break;
- default:
- rv = wifi_manager_ap_set_proxy_address(ap, address_type, proxy_addr);
- }
-
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to set proxy address[%s]\n", __test_convert_error_to_string(rv));
- }
-
- rv = wifi_manager_update_ap(wifi, ap);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to update ap info[%s]\n",
- __test_convert_error_to_string(rv));
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static bool __test_ipv6_address_callback(char *ipv6_address, void *user_data)
-{
- printf("IPv6 address: %s\n", ipv6_address);
- return true;
-}
-
-static int __test_convert_byte_to_txt(const unsigned char *src, char **dst, int src_len)
-{
- int dst_length = 0;
- int i = 0;
- char *buf = NULL;
-
- if (src_len <= 0) {
- printf("Invalid source length\n");
- return -1;
- }
-
- *dst = (char *)malloc((2*src_len)+1);
- if (!(*dst)) {
- printf("failed to allocate memory to buffer\n");
- return -1;
- }
-
- buf = (*dst);
-
- for (i = 0; i < src_len; i++) {
- snprintf(buf, 3, "%02x", src[i]);
- buf += 2;
- dst_length += 2;
- }
-
- return dst_length;
-}
-
-static bool __test_vendor_specific_callback(unsigned char *vsie_bytes, int vsie_len, void *user_data)
-{
- if (!vsie_bytes)
- return false;
-
- char *vsie = NULL;
- int buf_len = __test_convert_byte_to_txt(vsie_bytes, &vsie, vsie_len);
- if (buf_len > 0)
- printf("vsie_len: %d, vsie: %s\n", vsie_len, vsie);
-
- if (vsie)
- free(vsie);
-
- return true;
-}
-
-static bool __test_found_bssid_list_callback(const char *bssid, int rssi, int freq, void *user_data)
-{
- printf("-> BSSID : %s, RSSI : %d, Frequency : %d\n", bssid, rssi, freq);
- return true;
-}
-
-static bool __test_found_print_ap_info_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv, address_type = 0;
- char *ap_name;
- char *str_value;
- int int_value;
- wifi_manager_connection_state_e conn_state;
- wifi_manager_ip_config_type_e ip_type;
- wifi_manager_proxy_type_e proxy_type;
- wifi_manager_security_type_e sec_type;
- wifi_manager_encryption_type_e enc_type;
- wifi_manager_eap_type_e eap_type;
- wifi_manager_eap_auth_type_e eap_auth_type;
- wifi_manager_dns_config_type_e dns_type;
- bool bool_value;
- char *ap_name_part = (char*)user_data;
- wifi_manager_disconnect_reason_e disconnect_reason;
- wifi_manager_assoc_status_code_e status_code;
- wifi_manager_rssi_level_e rssi_level;
- bool is_hidden;
- wifi_manager_connection_mode_e mode;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- printf("ap_name %s, user input name %s\n", ap_name, ap_name_part);
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- /* Basic info */
- printf("ESSID : %s\n", ap_name);
-
- if (wifi_manager_ap_get_bssid(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("BSSID : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get BSSID\n");
-
- if (wifi_manager_foreach_found_bssid(ap, __test_found_bssid_list_callback, NULL) != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to get BSSID list data\n");
-
- if (wifi_manager_ap_get_rssi(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
- printf("RSSI : %d\n", int_value);
- else
- printf("Fail to get RSSI\n");
-
- if (wifi_manager_ap_get_rssi_level(ap, &rssi_level) == WIFI_MANAGER_ERROR_NONE)
- printf("RSSI level : %d\n", rssi_level);
- else
- printf("Fail to get RSSI level\n");
-
- if (wifi_manager_ap_get_connection_mode(ap, &mode) == WIFI_MANAGER_ERROR_NONE)
- printf("Wi-Fi operation mode: %d\n", mode);
- else
- printf("Fail to get operation mode\n");
-
- if (wifi_manager_ap_get_frequency(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
- printf("Frequency : %d\n", int_value);
- else
- printf("Fail to get Frequency\n");
-
- if (wifi_manager_ap_foreach_vsie(ap, __test_vendor_specific_callback, NULL)
- != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to get vsie\n");
-
- if (wifi_manager_ap_get_max_speed(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
- printf("Max speed : %d\n", int_value);
- else
- printf("Fail to get Max speed\n");
-
- if (wifi_manager_ap_is_favorite(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
- printf("Favorite : %s\n", bool_value ? "TRUE" : "FALSE");
- else
- printf("Fail to get Favorite\n");
-
- if (wifi_manager_ap_is_hidden(ap, &is_hidden) == WIFI_MANAGER_ERROR_NONE)
- printf("Hidden Status : %s\n", is_hidden ? "TRUE" : "FALSE");
- else
- printf("Fail to get hidden status\n");
-
- if (wifi_manager_ap_get_disconnect_reason(ap, &disconnect_reason)
- == WIFI_MANAGER_ERROR_NONE)
- printf("Disconnect reason : %d\n", disconnect_reason);
- else
- printf("Fail to get disconnect reason\n");
-
- if (wifi_manager_ap_get_assoc_status_code(ap, &status_code)
- == WIFI_MANAGER_ERROR_NONE)
- printf("Association Status Code : %d\n", status_code);
- else
- printf("Fail to get association status code\n");
-
- if (wifi_manager_ap_get_error_state(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
- printf("error state of AP : %s\n", __test_convert_error_to_string(int_value));
- else
- printf("Fail to get error state of AP\n");
-
- /* Network info */
- if (wifi_manager_ap_get_connection_state(ap, &conn_state) == WIFI_MANAGER_ERROR_NONE)
- printf("Connection State : %d\n", conn_state);
- else
- printf("Fail to get Connection State\n");
-
- rv = test_get_user_int("Input Address type to get"
- "(0:IPV4, 1:IPV6):", &address_type);
-
- if (rv == false || (address_type != 0 && address_type != 1)) {
- printf("Invalid input!!\n");
- g_free(ap_name);
- return false;
- }
-
- if (wifi_manager_ap_get_ip_config_type(ap, address_type, &ip_type) == WIFI_MANAGER_ERROR_NONE)
- printf("IP config type : %d\n", ip_type);
- else
- printf("Fail to get IP config type\n");
-
- if (wifi_manager_ap_get_ip_address(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("IP : %s\n", str_value);
- g_free(str_value);
- } else {
- printf("Fail to get IP : %s\n", str_value);
- g_free(str_value);
- }
-
- if (address_type == WIFI_MANAGER_ADDRESS_FAMILY_IPV6) {
- if (wifi_manager_ap_foreach_ipv6_address(ap, __test_ipv6_address_callback, NULL)
- != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to get multiple IPv6 address\n");
- }
-
- if (wifi_manager_ap_get_subnet_mask(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("Subnet mask : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get Subnet mask\n");
-
- if (wifi_manager_ap_get_prefix_length(ap, address_type, &int_value) == WIFI_MANAGER_ERROR_NONE)
- printf("Prefix length : %d\n", int_value);
- else
- printf("Fail to get Subnet mask\n");
-
- if (wifi_manager_ap_get_gateway_address(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("Gateway : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get Gateway\n");
-
- if (address_type == 0) {
- if (wifi_manager_ap_get_dhcp_server_address(ap, address_type, &str_value) ==
- WIFI_MANAGER_ERROR_NONE) {
- printf("DHCP Server : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get DHCP Server\n");
- if (wifi_manager_ap_get_dhcp_lease_duration(ap, address_type, &int_value) ==
- WIFI_MANAGER_ERROR_NONE) {
- printf("DHCP Lease duration : %d\n", int_value);
- } else
- printf("Fail to get DHCP lease duration\n");
- }
-
- if (wifi_manager_ap_get_proxy_type(ap, &proxy_type) == WIFI_MANAGER_ERROR_NONE)
- printf("Proxy type : %d\n", proxy_type);
- else
- printf("Fail to get Proxy type\n");
-
- if (wifi_manager_ap_get_proxy_address(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("Proxy : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get Proxy\n");
-
- if (wifi_manager_ap_get_dns_config_type(ap, address_type, &dns_type) == WIFI_MANAGER_ERROR_NONE) {
- if (dns_type == WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC)
- printf("DNS config type : STATIC\n");
- else if (dns_type == WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC)
- printf("DNS config type : DYNAMIC\n");
- else
- printf("DNS config type : %d\n", dns_type);
- } else
- printf("Fail to get DNS config type\n");
-
- if (wifi_manager_ap_get_dns_address(ap, 1, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("DNS1 : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get DNS1\n");
-
- if (wifi_manager_ap_get_dns_address(ap, 2, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("DNS2 : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get DNS2\n");
-
- /* Security info */
- if (wifi_manager_ap_get_security_type(ap, &sec_type) == WIFI_MANAGER_ERROR_NONE)
- printf("Security type : %d\n", sec_type);
- else
- printf("Fail to get Security type\n");
-
- if (wifi_manager_ap_get_encryption_type(ap, &enc_type) == WIFI_MANAGER_ERROR_NONE)
- printf("Encryption type : %d\n", enc_type);
- else
- printf("Fail to get Encryption type\n");
-
- if (wifi_manager_ap_is_passphrase_required(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
- printf("Passphrase required : %s\n", bool_value ? "TRUE" : "FALSE");
- else
- printf("Fail to get Passphrase required\n");
-
- if (wifi_manager_ap_is_wps_supported(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
- printf("WPS supported : %s\n", bool_value ? "TRUE" : "FALSE");
- else
- printf("Fail to get WPS supported\n");
-
- if (wifi_manager_ap_is_passpoint(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
- printf("Passpoint enabled : %s\n", bool_value ? "TRUE" : "FALSE");
- else
- printf("Fail to get passpoint state\n");
-
- if (wifi_manager_ap_get_countrycode(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- if (str_value) {
- printf("Country Code : %s\n", str_value);
- free(str_value);
- } else
- printf("Country code is NULL\n");
- } else
- printf("Fail to get Country code\n");
-
- if (sec_type != WIFI_MANAGER_SECURITY_TYPE_EAP) {
- g_free(ap_name);
- return false;
- }
-
- /* EAP info */
- if (wifi_manager_ap_get_eap_type(ap, &eap_type) == WIFI_MANAGER_ERROR_NONE)
- printf("EAP type : %d\n", eap_type);
- else
- printf("Fail to get EAP type\n");
-
- if (wifi_manager_ap_get_eap_auth_type(ap, &eap_auth_type) == WIFI_MANAGER_ERROR_NONE)
- printf("EAP auth type : %d\n", eap_auth_type);
- else
- printf("Fail to get EAP auth type\n");
-
- if (wifi_manager_ap_get_eap_passphrase(ap, &str_value, &bool_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("EAP user name : %s\n", str_value);
- printf("EAP is password setted : %s\n", bool_value ? "TRUE" : "FALSE");
- g_free(str_value);
- } else
- printf("Fail to get EAP passphrase(user name/password)\n");
-
- if (wifi_manager_ap_get_eap_ca_cert_file(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("EAP ca cert file : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get EAP ca cert file\n");
-
- if (wifi_manager_ap_get_eap_client_cert_file(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("EAP client cert file : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get EAP client cert file\n");
-
- if (wifi_manager_ap_get_eap_private_key_file(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("EAP private key file : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get EAP private key file\n");
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static bool _test_config_list_cb(const wifi_manager_config_h config, void *user_data)
-{
- gchar *name = NULL;
- wifi_manager_security_type_e security_type;
-
- wifi_manager_config_get_name(config, &name);
- wifi_manager_config_get_security_type(config, &security_type);
-
- printf("Name[%s] ", name);
- printf("Security type[%d] ", security_type);
- if (security_type == WIFI_MANAGER_SECURITY_TYPE_EAP) {
- wifi_manager_eap_type_e eap_type;
- wifi_manager_eap_auth_type_e eap_auth_type;
- wifi_manager_config_get_eap_type(config, &eap_type);
- printf("Eap type[%d] ", eap_type);
- wifi_manager_config_get_eap_auth_type(config, &eap_auth_type);
- printf("Eap auth type[%d]", eap_auth_type);
- }
- printf("\n");
-
- g_free(name);
-
- return true;
-}
-
-struct _wifi_conf {
- char name[33];
- int type;
-};
-static bool _test_config_list_cb_for_remove(const wifi_manager_config_h config, void *user_data)
-{
-
- struct _wifi_conf *c = (struct _wifi_conf *)user_data;
- gchar *name = NULL;
- wifi_manager_security_type_e security_type;
-
- wifi_manager_config_get_name(config, &name);
- wifi_manager_config_get_security_type(config, &security_type);
-
- if (__test_compare_ap_name(name, c->name) && security_type == (wifi_manager_security_type_e) c->type) {
- int rv = wifi_manager_config_remove(wifi, config);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to remove configurations [%s]\n", __test_convert_error_to_string(rv));
- else
- printf("Success to remove configuration [%s]\n", name);
- g_free(name);
- return false;
- }
-
- g_free(name);
-
- return true;
-}
-
-static bool __test_found_specific_ap_callback(wifi_manager_ap_h ap, void *user_data)
-{
- printf("Found specific ap Completed\n");
-
- int rv;
- char *ap_name = NULL;
- wifi_manager_security_type_e security_type = WIFI_MANAGER_SECURITY_TYPE_NONE;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
- printf("[AP name] : %s\n", ap_name);
-
- rv = wifi_manager_ap_get_security_type(ap, &security_type);
- if (rv == WIFI_MANAGER_ERROR_NONE)
- printf("[Security type] : %d\n", security_type);
- else {
- printf("Fail to get Security type\n");
- g_free(ap_name);
- return false;
- }
-
- switch (security_type) {
- case WIFI_MANAGER_SECURITY_TYPE_WEP:
- case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
- case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
- case WIFI_MANAGER_SECURITY_TYPE_SAE:
- {
- char passphrase[100];
- printf("Input passphrase for %s : ", ap_name);
- rv = scanf(" %99s", passphrase);
-
- rv = wifi_manager_ap_set_passphrase(ap, passphrase);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set passphrase : %s\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- return false;
- }
- }
- break;
- case WIFI_MANAGER_SECURITY_TYPE_EAP:
- {
- char input_str1[100];
- printf("Input user name for %s : ", ap_name);
- rv = scanf(" %99s", input_str1);
-
- char input_str2[100];
- printf("Input password for %s : ", ap_name);
- rv = scanf("%99s", input_str2);
-
- rv = wifi_manager_ap_set_eap_passphrase(ap, input_str1, input_str2);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set eap passphrase : %s\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- return false;
- }
-
- char *inputed_name = NULL;
- bool is_pass_set;
- rv = wifi_manager_ap_get_eap_passphrase(ap, &inputed_name, &is_pass_set);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get eap passphrase : %s\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- return false;
- }
-
- printf("name : %s, is password set : %s\n", inputed_name, is_pass_set ? "TRUE" : "FALSE");
- g_free(inputed_name);
- }
- break;
- case WIFI_MANAGER_SECURITY_TYPE_NONE:
- case WIFI_MANAGER_SECURITY_TYPE_OWE:
- default:
- break;
- }
-
- rv = wifi_manager_connect(wifi, ap, __test_connected_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to connection request [%s]\n", ap_name);
-
- g_free(ap_name);
- return true;
-}
-
-static void __test_scan_specific_ap_callback(wifi_manager_error_e error_code, void* user_data)
-{
- int rv;
-
- printf("Specific scan Completed from scan request, error code : %s\n",
- __test_convert_error_to_string(error_code));
-
- if (error_code != WIFI_MANAGER_ERROR_NONE)
- return;
-
- rv = wifi_manager_foreach_found_specific_ap(wifi, __test_found_specific_ap_callback, user_data);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get specific AP(can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return;
- }
-}
-
-static void __test_multi_scan_callback(wifi_manager_error_e error_code, void* user_data)
-{
- printf("Multi scan Completed, error code : %s\n",
- __test_convert_error_to_string(error_code));
-}
-
-int test_wifi_manager_init(void)
-{
- int rv = wifi_manager_initialize(&wifi);
-
- if (rv == WIFI_MANAGER_ERROR_NONE) {
- wifi_manager_set_device_state_changed_cb(wifi, __test_device_state_callback, "1");
- wifi_manager_set_scan_state_changed_cb(wifi, __test_scan_changed_callback, "1");
- wifi_manager_set_background_scan_cb(wifi, __test_bg_scan_completed_callback, "1");
- wifi_manager_set_ip_conflict_cb(wifi, __test_ip_conflict_callback, "1");
- wifi_manager_set_connection_state_changed_cb(wifi, __test_connection_state_callback, "1");
- wifi_manager_set_rssi_level_changed_cb(wifi, __test_rssi_level_callback, "1");
- wifi_manager_tdls_set_state_changed_cb(wifi, __test_tdls_state_callback, "1");
- wifi_manager_tdls_set_discovered_cb(wifi, __test_tdls_discover_callback, "1");
- wifi_manager_set_module_state_changed_cb(wifi, __test_get_wifi_module_state_callback, "1");
-
- } else {
- printf("[1] Wifi init failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- rv = wifi_manager_initialize(&wifi2);
-
- if (rv == WIFI_MANAGER_ERROR_NONE) {
- wifi_manager_set_device_state_changed_cb(wifi2, __test_device_state_callback, "2");
- wifi_manager_set_background_scan_cb(wifi2, __test_bg_scan_completed_callback, "2");
- wifi_manager_set_connection_state_changed_cb(wifi2, __test_connection_state_callback, "2");
- wifi_manager_set_rssi_level_changed_cb(wifi2, __test_rssi_level_callback, "2");
- wifi_manager_tdls_set_state_changed_cb(wifi2, __test_tdls_state_callback, "2");
- wifi_manager_tdls_set_discovered_cb(wifi, __test_tdls_discover_callback, "2");
- wifi_manager_set_module_state_changed_cb(wifi, __test_get_wifi_module_state_callback, "2");
- } else {
- printf("[2] Wifi init failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Wifi init succeeded\n");
- return 1;
-}
-
-int test_wifi_manager_deinit(void)
-{
- int rv = wifi_manager_deinitialize(wifi);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("[1] Wifi deinit failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- rv = wifi_manager_deinitialize(wifi2);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("[2] Wifi deinit failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Wifi deinit succeeded\n");
- return 1;
-}
-
-int test_wifi_manager_activate(void)
-{
- int rv = 0;
-
- rv = wifi_manager_activate(wifi, __test_activated_callback, NULL);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to activate Wi-Fi device [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Success to activate Wi-Fi device\n");
-
- return 1;
-}
-
-int test_wifi_manager_deactivate(void)
-{
- int rv = 0;
-
- rv = wifi_manager_deactivate(wifi, __test_deactivated_callback, NULL);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to deactivate Wi-Fi device [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Success to deactivate Wi-Fi device\n");
-
- return 1;
-}
-
-int test_wifi_manager_is_activated(void)
-{
- int rv = 0;
- bool state = false;
-
- rv = wifi_manager_is_activated(wifi, &state);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get Wi-Fi device state [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Success to get Wi-Fi device state : %s\n", (state) ? "TRUE" : "FALSE");
-
- return 1;
-}
-
-int test_wifi_manager_get_connection_state(void)
-{
- int rv = 0;
- wifi_manager_connection_state_e connection_state;
-
- rv = wifi_manager_get_connection_state(wifi, &connection_state);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get connection state [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Success to get connection state : ");
- switch (connection_state) {
- case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION:
- printf("Association\n");
- break;
- case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
- printf("Connected\n");
- break;
- case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION:
- printf("Configuration\n");
- break;
- case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED:
- printf("Disconnected\n");
- break;
- default:
- printf("Unknown\n");
- }
-
- return 1;
-}
-
-int test_wifi_manager_get_mac_address(void)
-{
- int rv = 0;
- char *mac_addr = NULL;
-
- rv = wifi_manager_get_mac_address(wifi, &mac_addr);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get MAC address [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("MAC address : %s\n", mac_addr);
- free(mac_addr);
-
- return 1;
-}
-
-int test_wifi_manager_get_interface_name(void)
-{
- int rv = 0;
- char *if_name = NULL;
-
- rv = wifi_manager_get_network_interface_name(wifi, &if_name);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get Interface name [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Interface name : %s\n", if_name);
- free(if_name);
-
- return 1;
-}
-
-int test_wifi_manager_scan(void)
-{
- int rv = 0;
-
- rv = wifi_manager_scan(wifi, __test_scan_request_callback, NULL);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Scan request failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Scan request succeeded\n");
-
- return 1;
-}
-
-int test_wifi_manager_get_connected_ap(void)
-{
- int rv = 0;
- char *ap_name = NULL;
- wifi_manager_ap_h ap_h;
-
- rv = wifi_manager_get_connected_ap(wifi, &ap_h);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get connected AP [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- rv = wifi_manager_ap_get_essid(ap_h, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get essid [%s]\n", __test_convert_error_to_string(rv));
- wifi_manager_ap_destroy(ap_h);
- return -1;
- }
-
- printf("Connected AP : %s\n", ap_name);
- g_free(ap_name);
- wifi_manager_ap_destroy(ap_h);
-
- return 1;
-}
-
-int test_wifi_manager_foreach_found_ap(void)
-{
- int rv = 0;
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_ap_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP list [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Get AP list finished\n");
-
- return 1;
-}
-
-int test_wifi_manager_connect(void)
-{
- int rv = 0;
- struct _ap_data data;
- bool state = false;
-
- wifi_manager_is_activated(wifi, &state);
- if (state == false)
- return -1;
-
- printf("Input a part of AP name to connect : ");
- rv = scanf(" %32[^\n]s", data.ap_name);
- data.is_found = false;
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_connect_ap_callback, (void*)&data);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to connect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- if (!data.is_found) {
- printf("%s is not found\n", data.ap_name);
- return -1;
- }
- printf("Connection step finished\n");
- return 1;
-}
-
-int test_wifi_manager_set_ip_conflict_detect_enable()
-{
- int rv = 0;
- int choice;
- bool state = false;
-
- printf("Input '1'(enable)/'0'(disable) for ip conflict detection : ");
- rv = scanf(" %d", &choice);
- if (choice == 1)
- state = true;
- else if (choice == 0)
- state = false;
- else
- return -1;
-
- rv = wifi_manager_set_ip_conflict_detect_enable(wifi, state);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set ip conflict detection state [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Successfully set the ip conflict detection !\n");
- return 1;
-}
-
-int test_wifi_manager_ip_conflict_detect_is_enabled()
-{
- int rv = 0;
- bool state = false;
-
- rv = wifi_manager_ip_conflict_detect_is_enabled(wifi, &state);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get ip conflict detection state [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("IP conflict detection is %s\n", state ? "enabled" : "disabled");
- printf("Successfully get the ip conflict detection !\n");
- return 1;
-}
-
-int test_wifi_manager_get_ip_conflict_state()
-{
- int rv = 0;
- wifi_manager_ip_conflict_state_e state;
-
- rv = wifi_manager_get_ip_conflict_state(wifi, &state);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get ip conflict state [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- switch (state) {
- case WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_DETECTED:
- printf("IP Conflict present\n");
- break;
- case WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED:
- printf("IP Conflict absent\n");
- break;
- case WIFI_MANAGER_IP_CONFLICT_STATE_UNKNOWN:
- printf("IP Conflict state is unknown\n");
- break;
- default:
- printf("Unhandled state\n");
- break;
- }
-
- printf("Successfully get the ip conflict state!\n");
- return 1;
-}
-
-int test_wifi_manager_get_ip_conflict_period()
-{
- int rv = 0;
- unsigned int initial_time;
-
- rv = wifi_manager_get_ip_conflict_period(wifi, &initial_time);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get ip conflict time period [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Initial time = %u seconds!\n", initial_time);
- printf("Successfully get the ip conflict detect period!\n");
- return 1;
-}
-
-int test_wifi_manager_set_ip_conflict_period()
-{
- int rv = 0;
- int initial_interval;
-
- printf("Enter initial interval for ARP ping\n");
- rv = scanf(" %d", &initial_interval);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_set_ip_conflict_period(wifi, initial_interval);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set ip conflict detection period [%s]\n",
- __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Successfully set the ip conflict detect period!\n");
- return 1;
-}
-
-int test_wifi_manager_connect_specific_ap(void)
-{
- int rv;
- char ap_name[33];
-
- printf("Input a part of specific AP name to connect : ");
- rv = scanf(" %32[^\n]s", ap_name);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_scan_specific_ap(wifi, ap_name, __test_scan_specific_ap_callback, NULL);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Scan request failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Scan specific AP request succeeded\n");
- return 1;
-}
-
-int test_wifi_manager_disconnect(void)
-{
- int rv = 0;
- char ap_name[33];
- bool state = false;
-
- wifi_manager_is_activated(wifi, &state);
- if (state == false)
- return -1;
-
- printf("Input a part of AP name to disconnect : ");
- rv = scanf(" %32[^\n]s", ap_name);
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_disconnect_ap_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to disconnect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Disconnection step finished\n");
- return 1;
-}
-
-int test_wifi_manager_connect_wps(void)
-{
- int rv = 0;
- char ap_name[33];
- bool state = false;
-
- wifi_manager_is_activated(wifi, &state);
- if (state == false)
- return -1;
-
- printf("Input a part of AP name to connect by wps : ");
- rv = scanf(" %32[^\n]s", ap_name);
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_connect_wps_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to connect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Connection step finished\n");
- return 1;
-}
-
-int test_wifi_manager_forget_ap(void)
-{
- int rv = 0;
- char ap_name[33];
- bool state = false;
-
- wifi_manager_is_activated(wifi, &state);
- if (state == false)
- return -1;
-
- printf("Input a part of AP name to forget : ");
- rv = scanf(" %32[^\n]s", ap_name);
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_forget_ap_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to forget (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Forget AP finished\n");
-
- return 1;
-}
-
-int test_wifi_manager_connect_eap_ap(void)
-{
- int rv = 0;
- char ap_name[33];
- bool state = false;
-
- wifi_manager_is_activated(wifi, &state);
- if (state == false)
- return -1;
-
- printf("Input a part of AP name to connect : ");
- rv = scanf(" %32[^\n]s", ap_name);
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_eap_ap_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to connect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Connection step finished\n");
- return 1;
-}
-
-int test_wifi_manager_set_ip_method(void)
-{
- int rv;
- char ap_name[33];
- bool state;
-
- rv = wifi_manager_is_activated(wifi, &state);
- if (rv != WIFI_MANAGER_ERROR_NONE || state == false)
- return -1;
-
- printf("Input a part of AP name to change IP method : ");
- rv = scanf(" %32[^\n]s", ap_name);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_change_ip_method_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to change (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("IP method changing finished\n");
- return 1;
-}
-
-int test_wifi_manager_set_proxy_method(void)
-{
- int rv;
- char ap_name[33];
- bool state;
-
- rv = wifi_manager_is_activated(wifi, &state);
- if (rv != WIFI_MANAGER_ERROR_NONE || state == false)
- return -1;
-
- printf("Input a part of AP name to change Proxy method : ");
- rv = scanf(" %32[^\n]s", ap_name);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_change_proxy_method_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to change (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Proxy method changing finished\n");
- return 1;
-}
-
-int test_wifi_manager_get_ap_info(void)
-{
- int rv;
- char ap_name[33];
- bool state;
-
- rv = wifi_manager_is_activated(wifi, &state);
- if (rv != WIFI_MANAGER_ERROR_NONE || state == false)
- return -1;
-
- printf("Input a part of AP name to get detailed info : ");
- rv = scanf(" %32[^\n]s", ap_name);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_print_ap_info_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP info (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("AP info printing finished\n");
- return 1;
-}
-
-int test_wifi_manager_config_load_configuration(void)
-{
- int rv;
-
- rv = wifi_manager_config_foreach_configuration(wifi, _test_config_list_cb, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
-
- return 1;
-}
-
-int test_wifi_manager_config_save(void)
-{
- int rv;
- char name[33] = { 0, };
- char passphrase[100] = { 0, };
- int type = 0;
- char proxy[100] = { 0, };
- int hidden = 0;
- int address_type = 0;
- char ip_addr[40] = { 0, };
- int prefix_len;
- wifi_manager_config_h config;
- int ip_update = 0;
-
- printf("Input AP configuration\n");
- printf("Name : ");
- rv = scanf(" %32[^\n]s", name);
- if (rv <= 0)
- return -1;
-
- printf("Passphrase : ");
- rv = scanf(" %99s", passphrase);
- if (rv <= 0)
- return -1;
-
- printf("Security type(None(0), WEP(1), WPA-PSK(2), EAP(4)) : ");
- rv = scanf("%d", &type);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_config_create(wifi, name, passphrase, type, &config);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
-
- rv = test_get_user_int("Update IP details (0:No, 1:Yes):", &ip_update);
- if (rv == false || (ip_update != 0 && ip_update != 1)) {
- printf("Invalid input!!\n");
- return -1;
- }
-
- if (ip_update == 1) {
- rv = test_get_user_int("Input Address type "
- "(0:IPV4, 1:IPV6):", &address_type);
-
- if (rv == false || (address_type != 0 && address_type != 1)) {
- printf("Invalid input!!\n");
- return -1;
- }
- rv = wifi_manager_config_set_ip_config_type(config, address_type,
- WIFI_MANAGER_IP_CONFIG_TYPE_STATIC);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set ip method type[%s]\n",
- __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Input new ip address (x:skip, 0:clear) :\n");
- rv = scanf("%39s", ip_addr);
- if (rv > 0) {
- switch (ip_addr[0]) {
- case 'x':
- rv = WIFI_MANAGER_ERROR_NONE;
- break;
- case '0':
- rv = wifi_manager_config_set_ip_address(config, address_type,
- NULL);
- break;
- default:
- rv = wifi_manager_config_set_ip_address(config, address_type,
- ip_addr);
- }
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set ip address[%s]\n",
- __test_convert_error_to_string(rv));
- return -1;
- }
- }
-
- if (address_type == 0) {
- printf("Input new subnet mask (x:skip, 0:clear) :\n");
- rv = scanf("%39s", ip_addr);
- if (rv > 0) {
- switch (ip_addr[0]) {
- case 'x':
- rv = WIFI_MANAGER_ERROR_NONE;
- break;
- case '0':
- rv = wifi_manager_config_set_subnet_mask(config, address_type,
- NULL);
- break;
- default:
- rv = wifi_manager_config_set_subnet_mask(config, address_type,
- ip_addr);
- }
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set subnet mask[%s]\n",
- __test_convert_error_to_string(rv));
- return -1;
- }
- }
- } else {
- printf("Input new prefix length (x:skip) :\n");
- rv = scanf("%d", &prefix_len);
- if (rv > 0) {
- if (prefix_len == 'x')
- rv = WIFI_MANAGER_ERROR_NONE;
- else
- rv = wifi_manager_config_set_prefix_length(config, address_type, prefix_len);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set prefix length[%s]\n",
- __test_convert_error_to_string(rv));
- return -1;
- }
- }
- }
-
- printf("Input new gateway address (x:skip, 0:clear) :\n");
- rv = scanf("%39s", ip_addr);
- if (rv > 0) {
- switch (ip_addr[0]) {
- case 'x':
- rv = WIFI_MANAGER_ERROR_NONE;
- break;
- case '0':
- rv = wifi_manager_config_set_gateway_address(config,
- address_type, NULL);
- break;
- default:
- rv = wifi_manager_config_set_gateway_address(config,
- address_type, ip_addr);
- }
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set gateway address[%s]\n",
- __test_convert_error_to_string(rv));
- return -1;
- }
- }
-
- rv = wifi_manager_config_set_dns_config_type(config,
- address_type, WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC);
- if (rv == WIFI_MANAGER_ERROR_NONE) {
- printf("Input DNS1 address (x: skip, 0: clear) : \n");
- if (address_type == WIFI_MANAGER_ADDRESS_FAMILY_IPV4)
- rv = scanf("%15s", ip_addr);
- else
- rv = scanf("%39s", ip_addr);
- if (rv > 0) {
- switch (ip_addr[0]) {
- case 'x':
- rv = WIFI_MANAGER_ERROR_NONE;
- break;
- case '0':
- rv = wifi_manager_config_set_dns_address(config,
- 1, address_type, NULL);
- break;
- default:
- rv = wifi_manager_config_set_dns_address(config,
- 1, address_type,
- ip_addr);
- }
- }
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set DNS1 address[%s]\n",
- __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Input DNS2 address (x: skip, 0: clear) : \n");
- if (address_type == WIFI_MANAGER_ADDRESS_FAMILY_IPV4)
- rv = scanf("%15s", ip_addr);
- else
- rv = scanf("%39s", ip_addr);
- if (rv > 0) {
- switch (ip_addr[0]) {
- case 'x':
- rv = WIFI_MANAGER_ERROR_NONE;
- break;
- case '0':
- rv = wifi_manager_config_set_dns_address(config,
- 2, address_type, NULL);
- break;
- default:
- rv = wifi_manager_config_set_dns_address(config,
- 2, address_type,
- ip_addr);
- }
- }
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set DNS2 address[%s]\n",
- __test_convert_error_to_string(rv));
- return -1;
- }
- }
- }
-
- if (test_get_user_string("Proxy(server:port) - (Enter for skip): ", proxy, 99)) {
- rv = wifi_manager_config_set_proxy_address(config,
- WIFI_MANAGER_ADDRESS_FAMILY_IPV4, proxy);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
-
- if (test_get_user_int("Hidden(1:Hidden) - (Enter for skip): ", &hidden)) {
- if (hidden == 1)
- rv = wifi_manager_config_set_hidden_ap_property(config, TRUE);
- else
- rv = wifi_manager_config_set_hidden_ap_property(config, FALSE);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
-
- if (type == WIFI_MANAGER_SECURITY_TYPE_EAP) {
- char anonymous[100] = { 0, };
- char ca_cert[100] = { 0, };
- char private_key[100] = { 0, };
- char private_key_password[100] = { 0, };
- char client_cert[100] = { 0, };
- char eap_identity[100] = { 0, };
- int eap_type;
- int eap_auth_type;
- char subject_match[100] = { 0, };
-
- if (test_get_user_string("EAP Anonymous Identity - (Enter for skip): ", anonymous, 99)) {
- rv = wifi_manager_config_set_eap_anonymous_identity(config, anonymous);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
-
- if (test_get_user_string("EAP ca cert file - (Enter for skip): ", ca_cert, 99)) {
- rv = wifi_manager_config_set_eap_ca_cert_file(config, ca_cert);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
-
- if (test_get_user_string("EAP private key - (Enter for skip): ", private_key, 99) &&
- test_get_user_string("EAP client cert file - (Enter for skip): ", client_cert, 99)) {
- rv = wifi_manager_config_set_eap_client_cert_file(config, private_key, client_cert);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
-
- if (test_get_user_string("EAP identity - (Enter for skip): ", eap_identity, 99)) {
- rv = wifi_manager_config_set_eap_identity(config, eap_identity);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
-
- if (test_get_user_int("EAP type (PEAP(0), TLS(1), TTLS(2), SIM(3), AKA(4)) - (Enter for skip): ", &eap_type)) {
- rv = wifi_manager_config_set_eap_type(config, eap_type);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
-
- if (eap_type == 1) {
- if (test_get_user_string("EAP private key file - ", private_key, 99) &&
- test_get_user_string("EAP private-key password - ", private_key_password, 99)) {
- rv = wifi_manager_config_set_eap_private_key_info(config, private_key, private_key_password);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
- }
- }
-
- if (test_get_user_int("EAP auth type (None(0), PAP(1), MSCHAP(2), MSCHAPv2(3), GTC(4), MD5(5)) - (Enter for skip): ", &eap_auth_type)) {
- rv = wifi_manager_config_set_eap_auth_type(config, eap_auth_type);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
-
- if (test_get_user_string("EAP subject match - (Enter for skip): ", subject_match, 99)) {
- rv = wifi_manager_config_set_eap_subject_match(config, subject_match);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
- }
-
- rv = wifi_manager_config_save(wifi, config);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
-
- rv = wifi_manager_config_destroy(config);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
-
- return 1;
-}
-
-int test_wifi_manager_config_remove(void)
-{
- int rv;
- struct _wifi_conf c;
-
- printf("Input AP configuration\n");
- printf("Name : ");
- rv = scanf(" %32[^\n]s", c.name);
- if (rv <= 0)
- return -1;
-
- printf("Security type(None(0), WEP(1), WPA-PSK(2), EAP(4) : ");
- rv = scanf(" %d", &c.type);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_config_foreach_configuration(wifi, _test_config_list_cb_for_remove, &c);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get configurations [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- return 1;
-}
-
-int test_wifi_manager_tdls_discover()
-{
- int rv = 0;
-
- char peer_mac[MAC_ADDR_LEN + 1];
- printf("Enter Mac_address: ");
- if (scanf(" %17s", peer_mac) < 1)
- return -1;
-
- if (strlen(peer_mac) < MAC_ADDR_LEN) {
- printf("Wrong Mac_address\n");
- return -1;
- }
-
- rv = wifi_manager_tdls_start_discovery(wifi, peer_mac);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("test_wifi_tdls_discover() is failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- return 1;
-}
-
-int test_wifi_manager_tdls_connect()
-{
- int rv = 0;
-
- char peer_mac[MAC_ADDR_LEN + 1];
- printf("Enter Mac_address: ");
- if (scanf(" %17s", peer_mac) < 1)
- return -1;
-
- if (strlen(peer_mac) < MAC_ADDR_LEN) {
- printf("Wrong Mac_address\n");
- return -1;
- }
-
- rv = wifi_manager_tdls_connect(wifi, peer_mac);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("test_wifi_tdls_connect() is failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- return 1;
-
-}
-
-int test_wifi_manager_tdls_get_connected_peer(void)
-{
- int rv = 0;
- char *mac_addr = NULL;
-
- rv = wifi_manager_tdls_get_connected_peer(wifi, &mac_addr);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("wifi_manager_tdls_get_connected_peer() is failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- printf("Peer Mac address is [%s]\n", mac_addr);
- g_free(mac_addr);
- return 1;
-}
-
-int test_wifi_manager_tdls_disconnect(void)
-{
- int rv = 0;
-
- char peer_mac[MAC_ADDR_LEN + 1];
- printf("Enter Mac_address: ");
- if (scanf(" %17s", peer_mac) < 1)
- return -1;
-
- if (strlen(peer_mac) < MAC_ADDR_LEN) {
- printf("Wrong Mac_address\n");
- return -1;
- }
-
- rv = wifi_manager_tdls_disconnect(wifi, peer_mac);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("test_wifi_tdls_disconnect() is failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- return 1;
-}
-int test_wifi_manager_tdls_enable_channel_switch(void)
-{
- int rv = 0;
- char peer_mac[MAC_ADDR_LEN + 1];
- int freq;
- printf("Enter Mac_address: ");
- if (scanf(" %17s", peer_mac) < 1)
- return -1;
- if (strlen(peer_mac) < MAC_ADDR_LEN) {
- printf("Wrong Mac_address\n");
- return -1;
- }
- printf("Enter Peer Frequency:\n");
- rv = scanf("%9d", &freq);
- if (rv <= 0) {
- printf("Invalid input!\n");
- return -1;
- }
- rv = wifi_manager_tdls_enable_channel_switching(wifi, peer_mac, freq);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("test_wifi_manager_tdls_channel_switch() is failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- return 1;
-}
-int test_wifi_manager_tdls_disable_channel_switch(void)
-{
- int rv = 0;
- char peer_mac[MAC_ADDR_LEN + 1];
- printf("Enter Mac_address: ");
- if (scanf(" %17s", peer_mac) < 1)
- return -1;
- if (strlen(peer_mac) < MAC_ADDR_LEN) {
- printf("Wrong Mac_address\n");
- return -1;
- }
- rv = wifi_manager_tdls_disable_channel_switching(wifi, peer_mac);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("test_wifi_manager_tdls_cancle_channel_switch() is failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- return 1;
-}
-int test_wifi_manager_get_module_state(void)
-{
- int rv = 0;
- wifi_manager_module_state_e module_state;
-
- rv = wifi_manager_get_module_state(wifi, &module_state);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get wifi module state [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Success to get WiFI Module state : ");
- switch (module_state) {
- case WIFI_MANAGER_MODULE_STATE_ATTACHED:
- printf("Wi-Fi Module Attached \n");
- break;
- case WIFI_MANAGER_MODULE_STATE_DETACHED:
- printf("Wi-Fi Module Detached\n");
- break;
- default:
- printf("Unknown\n");
- }
-
- return 1;
-}
-
-
-int test_wifi_manager_connect_hidden_ap(void)
-{
- int rv = 0;
- char ap_name[33];
- char passphrase[65];
- bool state = false;
- int sec_type;
-
- rv = wifi_manager_is_activated(wifi, &state);
- if (rv != WIFI_MANAGER_ERROR_NONE || state == false)
- return -1;
-
- printf("Input hidden AP name to connect : ");
- rv = scanf(" %32[^\n]s", ap_name);
- printf("Input Security Type :\n");
- printf("0 -> WIFI_SECURITY_TYPE_NONE\n");
- printf("1 -> WIFI_SECURITY_TYPE_WEP\n");
- printf("2 -> WIFI_SECURITY_TYPE_WPA_PSK/WIFI_SECURITY_TYPE_WPA2_PSK\n");
-
- rv = scanf(" %d", &sec_type);
- if (sec_type == 1 || sec_type == 2) {
- printf("Input hidden AP passphrase : ");
- rv = scanf("%64s", passphrase);
- }
-
- rv = wifi_manager_connect_hidden_ap(wifi, ap_name, sec_type, passphrase,
- __test_connected_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to connect to hidden AP [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Hidden Connection step finished\n");
- return 1;
-}
-
-static void __test_wifi_manager_wps_pbc_connected_callback(wifi_manager_error_e result, void* user_data)
-{
- if (result == WIFI_MANAGER_ERROR_NONE)
- printf("Wi-Fi WPS PBC Connection Succeeded\n");
- else
- printf("Wi-Fi WPS PBC Connection Failed! error : %s\n",
- __test_convert_error_to_string(result));
-}
-
-static void __test_wifi_manager_wps_pin_connected_callback(wifi_manager_error_e result, void* user_data)
-{
- if (result == WIFI_MANAGER_ERROR_NONE)
- printf("Wi-Fi WPS PIN Connection Succeeded\n");
- else
- printf("Wi-Fi WPS PIN Connection Failed! error : %s\n",
- __test_convert_error_to_string(result));
-}
-
-int test_wifi_manager_connect_wps_pbc_without_ssid(void)
-{
- int rv;
- rv = wifi_manager_connect_by_wps_pbc_without_ssid(wifi, __test_wifi_manager_wps_pbc_connected_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to WPS connection request : %s\n", __test_convert_error_to_string(rv));
- else
- printf("Success to WPS connection request \n");
- return 1;
-}
-
-int test_wifi_manager_connect_wps_pin_without_ssid(void)
-{
- int rv;
- char pin[9];
-
- printf("Input pin to wps pin connect : ");
-
- rv = scanf(" %8s", pin);
- if (rv <= 0)
- return -1;
-
- if ((strlen(pin) != 4) &&
- (strlen(pin) != 8)) {
- printf("Wrong pin number (4 or 8)\n");
- return -1;
- }
-
- rv = wifi_manager_connect_by_wps_pin_without_ssid(wifi, pin, __test_wifi_manager_wps_pin_connected_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to WPS connection request : %s\n", __test_convert_error_to_string(rv));
- else
- printf("Success to WPS connection request \n");
- return 1;
-}
-
-int test_wifi_manager_cancel_wps(void)
-{
- int rv;
- rv = wifi_manager_cancel_wps(wifi);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to WPS cancel request : %s\n", __test_convert_error_to_string(rv));
- else
- printf("Success to WPS cancel request \n");
- return 1;
-}
-
-int test_wifi_manager_get_wps_generated_pin(void)
-{
- int rv = 0;
- char *wps_pin = NULL;
-
- rv = wifi_manager_get_wps_generated_pin(wifi, &wps_pin);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("wifi_manager_get_wps_generated_pin() is failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- printf("Generaged pin number is [%s]\n", wps_pin);
- g_free(wps_pin);
- return 1;
-}
-
-int test_wifi_manager_forget_ap_async(void)
-{
- int rv = 0;
- char ap_name[33];
- bool state = false;
-
- wifi_manager_is_activated(wifi, &state);
- if (state == false)
- return -1;
-
- printf("Input a part of AP name to forget : ");
- rv = scanf(" %32[^\n]s", ap_name);
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_forget_ap_async_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to forget (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Forget AP async finished\n");
-
- return 1;
-}
-
-int test_wifi_manager_set_autoscan_state(void)
-{
- int autoscan = 0;
- int rv = 0;
-
- printf("Input enable/disable for autoscan (0:enable, 1:disable) :\n");
- rv = scanf(" %9d", &autoscan);
-
- if (rv <= 0) {
- printf("Invalid input!\n");
- return -1;
- }
-
- switch (autoscan) {
- case 0:
- rv = wifi_manager_set_autoscan(wifi, true);
- break;
-
- case 1:
- rv = wifi_manager_set_autoscan(wifi, false);
- break;
-
- default:
- printf("Invalid input!\n");
- return -1;
- }
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("failed to set autoscan [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- return 1;
-}
-
-int test_wifi_manager_set_autoscan_mode(void)
-{
- int mode = 0;
- int rv = 0;
-
- printf("Input autoscan mode (0:exponential, 1:periodic) :\n");
- rv = scanf(" %9d", &mode);
-
- if (rv <= 0) {
- printf("Invalid input!\n");
- return -1;
- }
-
- rv = wifi_manager_set_autoscan_mode(wifi, mode);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("failed to set autoscan mode [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- return 1;
-}
-
-int test_wifi_manager_get_autoscan_state(void)
-{
- int rv = 0;
- bool autoscan = FALSE;
-
- rv = wifi_manager_get_autoscan(wifi, &autoscan);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get auto scan state [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Auto scan state (0:enable, 1:disable) : %d\n", autoscan);
- return 1;
-}
-
-int test_wifi_manager_get_autoscan_mode(void)
-{
- int rv = 0;
- wifi_manager_autoscan_mode_e autoscan_mode;
-
- rv = wifi_manager_get_autoscan_mode(wifi, &autoscan_mode);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get auto scan mode [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Auto Scan Mode (0:exponential, 1:periodic) : %d\n", autoscan_mode);
- return 1;
-}
-
-static bool __test_get_bssid_scan_list(wifi_manager_ap_h ap, void *user_data)
-{
- char *bssid;
- char *essid;
- int rssi;
-
- if (wifi_manager_ap_get_bssid(ap, &bssid) != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get bssid for ap\n");
- return false;
- }
-
- if (wifi_manager_ap_get_essid(ap, &essid) != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get essid for ap\n");
- g_free(bssid);
- return false;
- }
-
- if (wifi_manager_ap_get_rssi(ap, &rssi) != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get rssi for ap\n");
- g_free(bssid);
- g_free(essid);
- return false;
- }
-
- printf("bssid : %s, essid : %s, rssi : %d\n",
- bssid, essid, rssi);
-
- g_free(bssid);
- g_free(essid);
- return true;
-}
-
-int test_wifi_manager_foreach_bssid_scan(void)
-{
- int rv;
-
- rv = wifi_manager_foreach_found_bssid_ap(wifi,
- __test_get_bssid_scan_list, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get wps scan list [%s]\n",
- __test_convert_error_to_string(rv));
- return -1;
- }
-
- return 1;
-}
-
-int test_wifi_manager_bssid_scan(void)
-{
- int rv = 0;
- rv = wifi_manager_bssid_scan(wifi, __test_bssid_scan_request_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to request bssid scan [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("BSSID Scan request succeeded\n");
- return 1;
-}
-
-static bool __test_get_netlink_scan_list(wifi_manager_ap_h ap, void *user_data)
-{
- char *bssid = NULL;
- char *essid = NULL;
- int freq;
- int rssi;
- wifi_manager_security_type_e sec_type;
- wifi_manager_encryption_type_e enc_type;
-
- if (wifi_manager_ap_get_bssid(ap, &bssid) != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get bssid for ap\n");
- g_free(bssid);
- return false;
- }
-
-
- if (wifi_manager_ap_get_essid(ap, &essid) != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get essid for ap\n");
- g_free(bssid);
- g_free(essid);
- return false;
- }
-
- if (wifi_manager_ap_get_frequency(ap, &freq) != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get Frequency\n");
- g_free(bssid);
- g_free(essid);
- return false;
- }
-
- if (wifi_manager_ap_get_rssi(ap, &rssi) != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get rssi for ap\n");
- g_free(bssid);
- g_free(essid);
- return false;
- }
-
- if (wifi_manager_ap_get_security_type(ap, &sec_type) != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get security type for ap\n");
- g_free(bssid);
- g_free(essid);
- return false;
- }
-
- if (wifi_manager_ap_get_encryption_type(ap, &enc_type) != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get encryption type for ap\n");
- g_free(bssid);
- g_free(essid);
- return false;
- }
-
- printf("%s, %d, %d, %s\n", bssid, freq, rssi, essid);
- printf("Security type : ");
- switch (sec_type) {
- case WIFI_MANAGER_SECURITY_TYPE_NONE:
- printf("NONE, ");
- break;
- case WIFI_MANAGER_SECURITY_TYPE_WEP:
- printf("WEP, ");
- break;
- case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
- printf("WPAPSK, ");
- break;
- case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
- printf("WPA2PSK, ");
- break;
- case WIFI_MANAGER_SECURITY_TYPE_EAP:
- printf("EAP, ");
- break;
- default:
- break;
- }
- printf("Encryption type : ");
- switch (enc_type) {
- case WIFI_MANAGER_ENCRYPTION_TYPE_NONE:
- printf("NONE\n");
- break;
- case WIFI_MANAGER_ENCRYPTION_TYPE_WEP:
- printf("WEP\n");
- break;
- case WIFI_MANAGER_ENCRYPTION_TYPE_TKIP:
- printf("TKIP\n");
- break;
- case WIFI_MANAGER_ENCRYPTION_TYPE_AES:
- printf("CCMP\n");
- break;
- case WIFI_MANAGER_ENCRYPTION_TYPE_TKIP_AES_MIXED:
- printf("Mixed\n");
- break;
- default:
- break;
- }
-
- if (wifi_manager_ap_foreach_vsie(ap, __test_vendor_specific_callback, NULL) != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to get vsie\n");
-
- g_free(bssid);
- g_free(essid);
- return true;
-}
-
-int test_wifi_manager_foreach_netlink_scan(void)
-{
- int rv;
-
- rv = wifi_manager_foreach_found_netlink_scan_ap(wifi,
- __test_get_netlink_scan_list, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get netlink scan list [%s]\n",
- __test_convert_error_to_string(rv));
- return -1;
- }
-
- return 1;
-}
-
-int test_wifi_manager_netlink_scan(void)
-{
- int rv = 0, scan_type = -1, add_vsie = -1;
- int ret = 1;
- char ssid[32+1];
- char vsie[255];
- wifi_manager_netlink_scan_h netlink_scan = NULL;
-
- rv = wifi_manager_netlink_scan_create(wifi, &netlink_scan);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to create netlink scan handle [%s]", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Netlink Scan handle created [%p]\n", netlink_scan);
-
- rv = test_get_user_int("Input netlink scan type"
- "(0:Normal, 1:Specific AP):", &scan_type);
- if (rv == false || (scan_type != 0 && scan_type != 1)) {
- printf("Invalid input!!\n");
- ret = -1;
- goto out;
- }
-
- if (scan_type == 1) {
- int i, num;
- rv = test_get_user_int("Input number of ssid:", &num);
- if (rv == false || num <= 0) {
- printf("Invalid input!!\n");
- ret = -1;
- goto out;
- }
-
- for (i = 0; i < num; i++) {
- printf("Input ssid:\n");
- rv = scanf(" %32[^\n]s", ssid);
-
- rv = wifi_manager_netlink_scan_set_ssid(netlink_scan, ssid);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to set ssid [%s]", __test_convert_error_to_string(rv));
- ret = -1;
- goto out;
- }
- }
- }
-
- rv = test_get_user_int("Add vsie option"
- "(0:No, 1:Yes):", &add_vsie);
- if (rv == false || (add_vsie != 0 && add_vsie != 1)) {
- printf("Invalid input!!\n");
- ret = -1;
- goto out;
- }
-
- if (add_vsie) {
- printf("Input vsie:\n");
- rv = scanf(" %250s", vsie);
-
- rv = wifi_manager_netlink_scan_set_vsie(netlink_scan, vsie);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to set vsie [%s]", __test_convert_error_to_string(rv));
- ret = -1;
- goto out;
- }
- }
-
- rv = wifi_manager_netlink_scan(wifi, netlink_scan, __test_netlink_scan_request_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to request netlink scan [%s]\n", __test_convert_error_to_string(rv));
- ret = -1;
- goto out;
- }
-
- printf("netlink Scan request succeeded\n");
-
-out:
- rv = wifi_manager_netlink_scan_destroy(wifi, netlink_scan);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to destroy netlink scan handle [%s]", __test_convert_error_to_string(rv));
- return -1;
- }
-
- return ret;
-}
-
-int test_wifi_manager_get_scan_state(void)
-{
- int rv = 0;
- wifi_manager_scan_state_e scan_state = -1;
-
- rv = wifi_manager_get_scan_state(wifi, &scan_state);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get scan state [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Scan state [%d]\n", scan_state);
-
- return 1;
-}
-
-int test_wifi_manager_add_vsie(void)
-{
- int rv = 0;
- char *vsie = NULL;
- unsigned int frame_id;
-
- printf("Input frame_id:\n");
- if (scanf(" %2u", &frame_id) < 1)
- return -1;
-
- printf("Input vsie:\n");
- if (scanf(" %100ms", &vsie) < 1)
- return -1;
-
- if (strlen(vsie) == 0)
- printf("invalid vsie !!\n");
- else
- printf("vsie: [%s]\n", vsie);
-
- if ((strlen(vsie) > 0)) {
- rv = wifi_manager_add_vsie(wifi, frame_id, vsie);
- printf("wifi_manager_add_vsie() ret=[%d]\n", rv);
-
- g_free(vsie);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to add vsie [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- }
-
- return 1;
-}
-
-int test_wifi_manager_get_vsie(void)
-{
- int rv = 0;
- char *vsie = NULL;
- unsigned int frame_id;
-
- printf("Input frame_id:\n");
- if (scanf(" %2u", &frame_id) < 1)
- return -1;
-
- rv = wifi_manager_get_vsie(wifi, frame_id, &vsie);
- printf("Received vsie [%s]\n", vsie ? vsie : "NULL");
-
- g_free(vsie);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get vsie [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- return 1;
-}
-
-int test_wifi_manager_remove_vsie(void)
-{
- int rv = 0;
- char *vsie = NULL;
- unsigned int frame_id;
-
- printf("Input frame_id:\n");
- if (scanf(" %2u", &frame_id) < 1)
- return -1;
-
- printf("Input vsie:\n");
- if (scanf(" %100ms", &vsie) < 1)
- return -1;
-
- if (strlen(vsie) == 0)
- printf("invalid vsie !!\n");
- else
- printf("vsie: [%s]\n", vsie);
-
- if ((strlen(vsie) > 0)) {
- rv = wifi_manager_remove_vsie(wifi, frame_id, vsie);
- printf("wifi_manager_remove_vsie() ret=[%d]\n", rv);
-
- g_free(vsie);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to remove vsie [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- }
-
- return 1;
-}
-
-int test_wifi_manager_specific_ap_start_multi_scan(void)
-{
- int rv = 0, scan_type, num = 0;
- char ssid[32 + 1];
- int freq;
- int i = 0;
- wifi_manager_specific_scan_h specific_scan = NULL;
-
- rv = wifi_manager_specific_scan_create(wifi, &specific_scan);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to create specific scan handle [%s]", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Specific Scan handle created [%p]\n", specific_scan);
-
- rv = test_get_user_int("Input multi scan type"
- "(0:SSID, 1:Freq, 2: SSID & Freq):", &scan_type);
-
- if (rv == false || (scan_type != 0 && scan_type != 1 && scan_type != 2)) {
- printf("Invalid input!!\n");
- return false;
- }
-
- if (scan_type == 0 || scan_type == 1) {
- rv = test_get_user_int("No. of specific ssid/freq for multi scan",
- &num);
- if (rv == false || (num <= 0) || (num > 4)) {
- printf("Invalid input!!\n");
- return false;
- }
-
- if (scan_type == 0) { /** multi ssid scan */
- for (i = 0; i < num; i++) {
- printf("Input ssid[%d]:\n", i);
- rv = scanf(" %32[^\n]s", ssid);
-
- rv = wifi_manager_specific_scan_set_ssid(specific_scan, ssid);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to set ssid [%s]", __test_convert_error_to_string(rv));
- return -1;
- }
- }
- } else { /** multi frequency scan */
- for (i = 0; i < num; i++) {
- printf("Input freq[%d]:\n", i);
- rv = scanf(" %d", &freq);
- rv = wifi_manager_specific_scan_set_freq(specific_scan, freq);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to set freq [%s]", __test_convert_error_to_string(rv));
- return -1;
- }
- }
- }
- } else { /** SSID & frequency mixed scan */
- rv = test_get_user_int("No. of ssid&freq for dual parameter multi scan",
- &num);
- if (rv == false || (num <= 0) || (num > 4)) {
- printf("Invalid input!!\n");
- return false;
- }
-
- for (i = 0; i < num; i++) {
- printf("Input ssid:\n");
- rv = scanf(" %32[^\n]s", ssid);
-
- rv = wifi_manager_specific_scan_set_ssid(specific_scan, ssid);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to set ssid [%s]", __test_convert_error_to_string(rv));
- return -1;
- }
- printf("Input freq:\n");
- rv = scanf(" %d", &freq);
-
- rv = wifi_manager_specific_scan_set_freq(specific_scan, freq);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to set freq [%s]", __test_convert_error_to_string(rv));
- return -1;
- }
- }
- }
-
- rv = wifi_manager_specific_ap_start_multi_scan(wifi, specific_scan,
- __test_multi_scan_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to start multi scan[%s]", __test_convert_error_to_string(rv));
- return -1;
- }
- printf("Specific Multi Scan requested\n");
-
- rv = wifi_manager_specific_scan_destroy(wifi, specific_scan);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to destroy specific scan handle [%s]", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Specific Scan handle destroyed\n");
-
- return 1;
-}
-
-int test_wifi_manager_flush_bss(void)
-{
- int rv;
-
- rv = wifi_manager_flush_bss(wifi);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to flush bss rv = %d\n", rv);
- return -1;
- }
-
- printf("Request to flush bss\n");
- return 1;
-}
-
-int test_wifi_manager_set_auto_connect(void)
-{
- int rv;
- int mode;
-
- printf("Auto connect mode (1:enable, 0:disable) : ");
- rv = scanf(" %d", &mode);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_set_auto_connect(wifi, mode);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set auto connect mode, rv = %d\n", rv);
- }
-
- printf("Request to set auto connect mode\n");
- return 1;
-}
-
-int test_wifi_manager_get_auto_connect(void)
-{
- int rv;
- int mode;
-
- rv = wifi_manager_get_auto_connect(wifi, &mode);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get auto connect mode, rv = %d\n", rv);
- return 1;
- }
-
- printf("Request to get auto connect mode = %d (1:enable, 0:disable)\n", mode);
- return 1;
-}
-
-int test_wifi_manager_set_ap_auto_connect(void)
-{
- int rv = 0;
- char ap_name[33];
- bool state = false;
-
- wifi_manager_is_activated(wifi, &state);
- if (state == false)
- return -1;
-
- printf("[Wi-Fi] Input a part of AP name to set : ");
- rv = scanf(" %32[^\n]s", ap_name);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_set_autoconnect_ap_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("[Wi-Fi] Fail to set up (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("[Wi-Fi] Set up finished\n");
- return 1;
-}
-
-int test_wifi_manager_get_ap_auto_connect(void)
-{
- int rv = 0;
- char ap_name[33];
- bool state = false;
-
- wifi_manager_is_activated(wifi, &state);
- if (state == false)
- return -1;
-
- printf("[Wi-Fi] Input a part of AP name to get : ");
- rv = scanf(" %32[^\n]s", ap_name);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_get_autoconnect_ap_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("[Wi-Fi] Fail to get up (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("[Wi-Fi] Get up finished\n");
- return 1;
-}
-
-int test_wifi_manager_set_passpoint_enable(void)
-{
- int rv;
- int enable;
-
- printf("Enter passpoint on/off(0:off, 1:on) : \n");
- rv = scanf(" %d", &enable);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_set_passpoint(wifi, enable);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set passpoint, rv = %d\n", rv);
- }
-
- printf("Request to set passpoint\n");
- return 1;
-}
-
-int test_wifi_manager_get_passpoint_state(void)
-{
- int rv;
- int enabled;
-
- rv = wifi_manager_get_passpoint(wifi, &enabled);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get passpoint state, rv = %d\n", rv);
- return 1;
- }
-
- printf("current passpoint sate(0:off, 1:on) = [%d]\n", enabled);
- return 1;
-}
-
-int test_wifi_manager_get_5ghz_band_supported(void)
-{
- int rv;
- bool supported;
-
- rv = wifi_manager_is_5ghz_band_supported(wifi, &supported);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get 5ghz supported, rv = %d\n", rv);
- return 1;
- }
-
- printf("Is 5Ghz supported = [%s]\n", supported ? "yes" : "no");
- return 1;
-}
-
-int test_wifi_manager_set_mac_policy(void)
-{
- int rv;
- unsigned int policy = 0;
-
- printf("Enter mac policy (0/1/2): ");
- rv = scanf(" %u", &policy);
-
- rv = wifi_manager_set_mac_policy(wifi, policy);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set mac policy, rv = %d\n", rv);
- return 1;
- }
-
- printf("Success to set mac policy\n");
- return 1;
-}
-
-int test_wifi_manager_set_preassoc_mac_policy(void)
-{
- int rv;
- unsigned int policy = 0;
-
- printf("Enter mac policy (0/1/2): ");
- rv = scanf(" %u", &policy);
-
- rv = wifi_manager_set_preassoc_mac_policy(wifi, policy);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set preassoc mac policy, rv = %d\n", rv);
- return 1;
- }
-
- printf("Success to set preassoc mac policy\n");
- return 1;
-}
-
-int test_wifi_manager_set_random_mac_lifetime(void)
-{
- int rv;
- unsigned int lifetime = 0;
-
- printf("Enter mac policy (> 0): ");
- rv = scanf(" %u", &lifetime);
-
- rv = wifi_manager_set_random_mac_lifetime(wifi, lifetime);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set random mac lifetime, rv = %d\n", rv);
- return 1;
- }
-
- printf("Success to set random mac lifetime\n");
- return 1;
-}
-
-int test_wifi_manager_get_mac_policies(void)
-{
- int rv;
- unsigned int mac_policy = 0;
- unsigned int preassoc_mac_policy = 0;
- unsigned int random_mac_lifetime = 0;
-
- rv = wifi_manager_get_mac_policy(wifi, &mac_policy);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to get mac policy, rv = %d\n", rv);
-
- rv = wifi_manager_get_preassoc_mac_policy(wifi, &preassoc_mac_policy);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to get preassoc mac policy, rv = %d\n", rv);
-
- rv = wifi_manager_get_random_mac_lifetime(wifi, &random_mac_lifetime);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to get random mac lifetime, rv = %d\n", rv);
-
- printf("Success to get mac policies: "
- "[Mac Policy : %u], [Preassoc Mac Policy : %u], [Random Mac lifetime : %u]\n",
- mac_policy, preassoc_mac_policy, random_mac_lifetime);
- return 1;
-}
-
-int test_wifi_manager_get_connection_mode(void)
-{
- int rv, int_value;
- wifi_manager_connection_mode_e mode;
- char *ap_name = NULL;
- wifi_manager_ap_h ap_h;
-
- rv = wifi_manager_get_connected_ap(wifi, &ap_h);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get connected AP [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- rv = wifi_manager_ap_get_essid(ap_h, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get essid [%s]\n", __test_convert_error_to_string(rv));
- wifi_manager_ap_destroy(ap_h);
- return -1;
- }
-
- rv = wifi_manager_ap_get_max_speed(ap_h, &int_value);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get max speed[%s]\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- wifi_manager_ap_destroy(ap_h);
- return -1;
- }
-
- rv = wifi_manager_get_connection_mode(wifi, &mode);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get connection mode[%s]\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- wifi_manager_ap_destroy(ap_h);
- return -1;
- }
-
- printf("Connected AP : %s\n", ap_name);
- printf("Connection mode : %s\n", __test_convert_connection_mode_to_string(mode));
- printf("Link speed : %d\n", int_value);
- g_free(ap_name);
- wifi_manager_ap_destroy(ap_h);
- return 1;
-}
-
-int test_wifi_manager_set_country_code(void)
-{
- int rv;
- char country[3];
-
- printf("Enter alpha2 country code (e.g. IN, JP, KR, US)\n");
- rv = scanf("%2s", country);
-
- rv = wifi_manager_set_country_code(wifi, (const char *)country);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set country code[%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- return 1;
-}
-
-int test_wifi_manager_get_country_code(void)
-{
- int rv;
- char *country = NULL;
-
- rv = wifi_manager_get_country_code(wifi, &country);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get country code[%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- printf("Country code: %s\n", country);
- free(country);
-
- return 1;
-}
-
-int main(int argc, char **argv)
-{
- GMainLoop *mainloop;
-#if !GLIB_CHECK_VERSION(2, 36, 0)
- g_type_init();
-#endif
- mainloop = g_main_loop_new(NULL, FALSE);
-
- GIOChannel *channel = g_io_channel_unix_new(0);
- g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread, NULL);
-
- printf("Test Thread created...\n");
-
- g_main_loop_run(mainloop);
-
- return 0;
-}
-
-gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
-{
- int rv;
- char a[10];
-
- printf("Event received from stdin\n");
-
- rv = read(0, a, 10);
-
- if (rv <= 0 || a[0] == '0') {
- rv = wifi_manager_deinitialize(wifi);
-
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to deinitialize.\n");
-
- exit(1);
- }
-
- if (a[0] == '\n' || a[0] == '\r') {
-/* Public API */
- printf("\n\n Network Connection API Test App\n\n");
- printf("Options..\n");
- printf(LOG_BLUE "[Public APIs]\n" LOG_END);
- printf(LOG_GREEN "1 - Wi-Fi init and set callbacks\n" LOG_END);
- printf("2 - Wi-Fi deinit(unset callbacks automatically)\n");
- printf(LOG_GREEN "3 - Activate Wi-Fi device\n" LOG_END);
- printf("4 - Deactivate Wi-Fi device\n");
- printf("5 - Is Wi-Fi activated?\n");
- printf("6 - Get connection state\n");
- printf("7 - Get MAC address\n");
- printf("8 - Get Wi-Fi interface name\n");
- printf(LOG_GREEN "9 - Scan request\n" LOG_END);
- printf("a - Get Connected AP\n");
- printf("b - Get AP list\n");
- printf(LOG_GREEN "c - Connect\n" LOG_END);
- printf("d - Disconnect\n");
- printf("e - Connect by wps pbc\n");
- printf("f - Forget an AP\n");
- printf("g - Set & connect EAP\n");
- printf("h - Set IP method type\n");
- printf("i - Set Proxy method type\n");
- printf("j - Get Ap info\n");
- printf("k - Connect Specific AP\n");
- printf("l - Load configuration\n");
- printf("m - Save configuration\n");
- printf("n - Remove configuration\n");
- printf("o - TDLS Discover\n");
- printf("p - TDLS Connect\n");
- printf("q - TDLS Connected peer\n");
- printf("r - TDLS Disconnect\n");
- printf("s - Connect Hidden AP\n");
- printf("t - Connect WPS PBC without SSID\n");
- printf("u - Connect WPS PIN without SSID\n");
- printf("v - Cancel WPS Request\n");
- printf("w - Get wifi scanning state\n");
- printf("x - Enable TDLS Channel Switch Request\n");
- printf("y - Disable TDLS Channel Switch Request\n");
- printf("z - Get Wi-Fi Module State\n");
- printf("A - BSSID Scan (Wi-Fi Position System Scan)\n");
- printf("B - Multi Scan (Multi Frequency & Multi SSID)\n");
- printf("C - Add VSIE\n");
- printf("D - Get VSIE\n");
- printf("E - Remove VSIE\n");
- printf("F - Set IP conflict detection mode\n");
- printf("G - Get IP conflict detection mode\n");
- printf("H - Get IP conflict state\n");
- printf("I - Get generated PIN number\n");
- printf("J - Forget an AP(async)\n");
-/* Extension APIs */
- printf(LOG_BLUE "[Extension API]\n" LOG_END);
- printf("K - Set Enable or Disable Auto Scan\n");
- printf("L - Set Mode of Auto Scan\n");
- printf("M - Get Enable or Disable Auto Scan\n");
- printf("N - Get Mode of Auto Scan\n");
- printf("O - Flush BSS\n");
- printf("P - Set enable or disable auto connect\n");
- printf("Q - Get enable or disable auto connect\n");
- printf("R - Set enable or disable of Wi-Fi profile auto-connect\n");
- printf("S - Get enable or disable of Wi-Fi profile auto-connect\n");
- printf("T - Set the IP conflict detection period\n");
- printf("U - Get the IP conflict detection period\n");
- printf("V - Netlink Scan Normal/Specific-AP\n");
- printf("W - Get passpoint state\n");
- printf("X - Set passpoint on/off\n");
- printf("Y - Get Access Point Hardware Mode\n");
- printf("Z - Get 5Ghz supported\n");
- printf("! - Set mac policy\n");
- printf("@ - Set preassoc mac policy\n");
- printf("# - Set random mac lifetime\n");
- printf("$ - Get mac policies\n");
- printf("^ - Set country code\n");
- printf("& - Get country code\n");
- printf(LOG_RED "0 - Exit \n" LOG_END);
-
- printf("ENTER - Show options menu.......\n");
- }
-
- switch (a[0]) {
-/* Public API */
- case '1':
- rv = test_wifi_manager_init();
- break;
- case '2':
- rv = test_wifi_manager_deinit();
- break;
- case '3':
- rv = test_wifi_manager_activate();
- break;
- case '4':
- rv = test_wifi_manager_deactivate();
- break;
- case '5':
- rv = test_wifi_manager_is_activated();
- break;
- case '6':
- rv = test_wifi_manager_get_connection_state();
- break;
- case '7':
- rv = test_wifi_manager_get_mac_address();
- break;
- case '8':
- rv = test_wifi_manager_get_interface_name();
- break;
- case '9':
- rv = test_wifi_manager_scan();
- break;
- case 'a':
- rv = test_wifi_manager_get_connected_ap();
- break;
- case 'b':
- rv = test_wifi_manager_foreach_found_ap();
- break;
- case 'c':
- rv = test_wifi_manager_connect();
- break;
- case 'd':
- rv = test_wifi_manager_disconnect();
- break;
- case 'e':
- rv = test_wifi_manager_connect_wps();
- break;
- case 'f':
- rv = test_wifi_manager_forget_ap();
- break;
- case 'g':
- rv = test_wifi_manager_connect_eap_ap();
- break;
- case 'h':
- rv = test_wifi_manager_set_ip_method();
- break;
- case 'i':
- rv = test_wifi_manager_set_proxy_method();
- break;
- case 'j':
- rv = test_wifi_manager_get_ap_info();
- break;
- case 'k':
- rv = test_wifi_manager_connect_specific_ap();
- break;
- case 'l':
- rv = test_wifi_manager_config_load_configuration();
- break;
- case 'm':
- rv = test_wifi_manager_config_save();
- break;
- case 'n':
- rv = test_wifi_manager_config_remove();
- break;
- case 'o':
- rv = test_wifi_manager_tdls_discover();
- break;
- case 'p':
- rv = test_wifi_manager_tdls_connect();
- break;
- case 'q':
- rv = test_wifi_manager_tdls_get_connected_peer();
- break;
- case 'r':
- rv = test_wifi_manager_tdls_disconnect();
- break;
- case 's':
- rv = test_wifi_manager_connect_hidden_ap();
- break;
- case 't':
- rv = test_wifi_manager_connect_wps_pbc_without_ssid();
- break;
- case 'u':
- rv = test_wifi_manager_connect_wps_pin_without_ssid();
- break;
- case 'v':
- rv = test_wifi_manager_cancel_wps();
- break;
- case 'w':
- rv = test_wifi_manager_get_scan_state();
- break;
- case 'x':
- rv = test_wifi_manager_tdls_enable_channel_switch();
- break;
- case 'y':
- rv = test_wifi_manager_tdls_disable_channel_switch();
- break;
- case 'z':
- rv = test_wifi_manager_get_module_state();
- break;
- case 'A':
- rv = test_wifi_manager_bssid_scan();
- break;
- case 'B':
- rv = test_wifi_manager_specific_ap_start_multi_scan();
- break;
- case 'C':
- rv = test_wifi_manager_add_vsie();
- break;
- case 'D':
- rv = test_wifi_manager_get_vsie();
- break;
- case 'E':
- rv = test_wifi_manager_remove_vsie();
- break;
- case 'F':
- rv = test_wifi_manager_set_ip_conflict_detect_enable();
- break;
- case 'G':
- rv = test_wifi_manager_ip_conflict_detect_is_enabled();
- break;
- case 'H':
- rv = test_wifi_manager_get_ip_conflict_state();
- break;
- case 'I':
- rv = test_wifi_manager_get_wps_generated_pin();
- break;
- case 'J':
- rv = test_wifi_manager_forget_ap_async();
- break;
-
-/* Extension APIs */
- case 'K':
- rv = test_wifi_manager_set_autoscan_state();
- break;
- case 'L':
- rv = test_wifi_manager_set_autoscan_mode();
- break;
- case 'M':
- rv = test_wifi_manager_get_autoscan_state();
- break;
- case 'N':
- rv = test_wifi_manager_get_autoscan_mode();
- break;
- case 'O':
- rv = test_wifi_manager_flush_bss();
- break;
- case 'P':
- rv = test_wifi_manager_set_auto_connect();
- break;
- case 'Q':
- rv = test_wifi_manager_get_auto_connect();
- break;
- case 'R':
- rv = test_wifi_manager_set_ap_auto_connect();
- break;
- case 'S':
- rv = test_wifi_manager_get_ap_auto_connect();
- break;
- case 'T':
- rv = test_wifi_manager_set_ip_conflict_period();
- break;
- case 'U':
- rv = test_wifi_manager_get_ip_conflict_period();
- break;
- case 'V':
- rv = test_wifi_manager_netlink_scan();
- break;
- case 'W':
- rv = test_wifi_manager_get_passpoint_state();
- break;
- case 'X':
- rv = test_wifi_manager_set_passpoint_enable();
- break;
- case 'Y':
- rv = test_wifi_manager_get_connection_mode();
- break;
- case 'Z':
- rv = test_wifi_manager_get_5ghz_band_supported();
- break;
- case '!':
- rv = test_wifi_manager_set_mac_policy();
- break;
- case '@':
- rv = test_wifi_manager_set_preassoc_mac_policy();
- break;
- case '#':
- rv = test_wifi_manager_set_random_mac_lifetime();
- break;
- case '$':
- rv = test_wifi_manager_get_mac_policies();
- break;
- case '^':
- rv = test_wifi_manager_set_country_code();
- break;
- case '&':
- rv = test_wifi_manager_get_country_code();
- break;
- default:
- break;
- }
-
- if (rv == 1)
- printf("Operation succeeded!\n");
- else
- printf("Operation failed!\n");
-
- return TRUE;
-}