From 39c304880b3d20a516dfac21fe812e2c260bcd8e Mon Sep 17 00:00:00 2001 From: "hyunuk.tak" Date: Fri, 8 Nov 2019 10:55:19 +0900 Subject: Deprecated all APIs Change-Id: Ia6065623b3198fe76e79b1890c69d00a4101ac20 Signed-off-by: hyunuk.tak --- CMakeLists.txt | 4 +- include/net_wifi_private.h | 83 +- include/wifi.h | 2 +- include/wifi_config_private.h | 70 -- include/wifi_dbus_private.h | 27 - packaging/capi-network-wifi.spec | 19 +- src/libnetwork.c | 1535 ------------------------------ src/net_wifi.c | 540 +---------- src/net_wifi_ap.c | 1484 +---------------------------- src/net_wifi_config.c | 806 +--------------- src/wifi_config.c | 721 --------------- src/wifi_dbus.c | 64 -- test/CMakeLists.txt | 25 - test/wifi_test.c | 1904 -------------------------------------- 14 files changed, 113 insertions(+), 7171 deletions(-) delete mode 100755 include/wifi_config_private.h delete mode 100755 include/wifi_dbus_private.h delete mode 100755 src/libnetwork.c delete mode 100755 src/wifi_config.c delete mode 100755 src/wifi_dbus.c delete mode 100755 test/CMakeLists.txt delete mode 100755 test/wifi_test.c diff --git a/CMakeLists.txt b/CMakeLists.txt index e36c92d..922f1a6 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ SET(LIBDIR ${PREFIX}/${LIB_PATH}) SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) -SET(dependents "dlog vconf capi-base-common capi-system-info glib-2.0 gio-2.0 gthread-2.0 network ") +SET(dependents "dlog ") SET(pc_dependents "capi-base-common") IF(TIZEN_DUALSIM_ENABLE) @@ -68,8 +68,6 @@ CONFIGURE_FILE( ) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB}/pkgconfig) -ADD_SUBDIRECTORY(test) - IF(UNIX) ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) diff --git a/include/net_wifi_private.h b/include/net_wifi_private.h index 1987bb9..ad65002 100755 --- a/include/net_wifi_private.h +++ b/include/net_wifi_private.h @@ -14,16 +14,15 @@ * limitations under the License. */ -#ifndef __NET_CONNECTION_PRIVATE_H__ -#define __NET_CONNECTION_PRIVATE_H__ +#ifndef __NET_WIFI_PRIVATE_H__ +#define __NET_WIFI_PRIVATE_H__ #include -#include -#include -#include +#include +#include +#include #include "wifi.h" -#include "wifi_dbus_private.h" #ifdef __cplusplus extern "C" { @@ -36,23 +35,6 @@ extern "C" { #define WIFI_ERROR 2 #define WIFI_WARN 3 -#define WIFI_FEATURE "http://tizen.org/feature/network.wifi" -#define WIFI_TDLS_FEATURE "http://tizen.org/feature/network.wifi.tdls" - -typedef enum { - WIFI_SUPPORTED_FEATURE_WIFI, - WIFI_SUPPORTED_FEATURE_WIFI_TDLS, - WIFI_SUPPORTED_FEATURE_MAX, -} wifi_supported_feature_e; - - -#define CHECK_FEATURE_SUPPORTED(...) \ - do { \ - int rv = _wifi_check_feature_supported(__VA_ARGS__, NULL); \ - if (rv != WIFI_ERROR_NONE) \ - return rv; \ - } while (0) - #define DEPRECATED_LOG(origin, substitution) \ do { \ LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed " \ @@ -87,61 +69,6 @@ typedef enum { } \ } while (0) -bool _wifi_is_init(void); - -int _wifi_libnet_init(void); -bool _wifi_libnet_deinit(void); -int _wifi_activate(wifi_activated_cb callback, gboolean wifi_picker_test, void *user_data); -int _wifi_deactivate(wifi_deactivated_cb callback, void *user_data); - -bool _wifi_libnet_check_ap_validity(wifi_ap_h ap_h); -void _wifi_libnet_add_to_ap_list(wifi_ap_h ap_h); -void _wifi_libnet_remove_from_ap_list(wifi_ap_h ap_h); -bool _wifi_libnet_check_profile_name_validity(const char *profile_name); - -int _wifi_libnet_get_wifi_device_state(wifi_device_state_e *device_state); -int _wifi_libnet_get_wifi_state(wifi_connection_state_e* connection_state); -int _wifi_libnet_get_intf_name(char** name); -int _wifi_libnet_scan_request(wifi_scan_finished_cb callback, void *user_data); -int _wifi_libnet_scan_specific_ap(const char *essid, wifi_scan_finished_cb callback, void *user_data); -int _wifi_libnet_get_connected_profile(wifi_ap_h *ap); -int _wifi_libnet_foreach_found_aps(wifi_found_ap_cb callback, void *user_data); -int _wifi_libnet_foreach_found_specific_aps(wifi_found_ap_cb callback, void *user_data); - -int _wifi_libnet_open_profile(wifi_ap_h ap_h, wifi_connected_cb callback, void *user_data); -int _wifi_libnet_close_profile(wifi_ap_h ap_h, wifi_disconnected_cb callback, void *user_data); -int _wifi_libnet_connect_with_wps_pbc(wifi_ap_h ap, - wifi_connected_cb callback, void *user_data); -int _wifi_libnet_connect_with_wps_pin(wifi_ap_h ap, const char *pin, - wifi_connected_cb callback, void *user_data); -int _wifi_libnet_forget_ap(wifi_ap_h ap); -int _wifi_libnet_get_hidden_aps(const char* essid, - wifi_security_type_e sec_type, const char *passphrase, - wifi_connected_cb callback, void* user_data); - -int _wifi_set_power_on_off_cb(wifi_device_state_changed_cb callback, void *user_data); -int _wifi_unset_power_on_off_cb(void); -int _wifi_set_background_scan_cb(wifi_scan_finished_cb callback, void *user_data); -int _wifi_unset_background_scan_cb(void); -int _wifi_set_connection_state_cb(wifi_connection_state_changed_cb callback, void *user_data); -int _wifi_unset_connection_state_cb(); - -int _wifi_update_ap_info(net_profile_info_t *ap_info); -wifi_connection_state_e _wifi_convert_to_ap_state(net_state_type_t state); - -guint _wifi_callback_add(GSourceFunc func, gpointer user_data); -void _wifi_callback_cleanup(void); - -int _wifi_libnet_check_get_privilege(); -int _wifi_libnet_check_profile_privilege(); - -bool __libnet_check_feature_supported(const char *key, wifi_supported_feature_e feature); -int _wifi_check_feature_supported(const char *feature_name, ...); - -int _wifi_dbus_init(void); -int _wifi_dbus_deinit(void); -wifi_dbus *_wifi_get_dbus_handle(void); - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/include/wifi.h b/include/wifi.h index 79c8e01..cd9a9c3 100755 --- a/include/wifi.h +++ b/include/wifi.h @@ -619,7 +619,7 @@ int wifi_scan_specific_ap(const char* essid, wifi_scan_finished_cb callback, voi int wifi_connect_specific_ap(const char* essid, wifi_security_type_e sec_type, const char *passphrase, wifi_connected_cb callback, - void* user_data); + void* user_data) TIZEN_DEPRECATED_API; /** * @deprecated Deprecated since 3.0. Use wifi_manager_get_connected_ap() instead. diff --git a/include/wifi_config_private.h b/include/wifi_config_private.h deleted file mode 100755 index 11fd883..0000000 --- a/include/wifi_config_private.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef __WIFI_CONFIG_H__ -#define __WIFI_CONFIG_H__ - -#include - -#include "wifi.h" -#include "wifi_dbus_private.h" - -#define WIFI_CONFIG_NAME "Name" -#define WIFI_CONFIG_SSID "SSID" -#define WIFI_CONFIG_PASSPHRASE "Passphrase" -#define WIFI_CONFIG_SECURITY_TYPE "Security" -#define WIFI_CONFIG_PROXYADDRESS "ProxyAddress" -#define WIFI_CONFIG_HIDDEN "Hidden" -#define WIFI_CONFIG_FAILURE "Failure" -#define WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY "AnonymousIdentity" -#define WIFI_CONFIG_EAP_CACERT "CACertFile" -#define WIFI_CONFIG_EAP_CLIENTCERT "ClientCertFile" -#define WIFI_CONFIG_EAP_PRIVATEKEY "PrivateKeyFile" -#define WIFI_CONFIG_EAP_IDENTITY "Identity" -#define WIFI_CONFIG_EAP_TYPE "EapType" -#define WIFI_CONFIG_EAP_AUTH_TYPE "EapAuthType" -#define WIFI_CONFIG_EAP_SUBJECT_MATCH "SubjectMatch" - -struct _wifi_eap_config { - gchar *ca_cert; - gchar *private_key; - gchar *client_cert; - gchar *anonymous_identity; - gchar *identity; - gchar *subject_match; - wifi_eap_type_e eap_type; - wifi_eap_auth_type_e eap_auth_type; -}; - -struct _wifi_config { - /* mandatory */ - gchar *name; - gchar *passphrase; - wifi_security_type_e security_type; - gboolean is_saved; - - /* optional field is set using wifi_config_set_field */ - gboolean is_hidden; - gchar *proxy_address; - wifi_address_family_e address_family; - struct _wifi_eap_config *eap_config; - wifi_error_e last_error; -}; - -gchar * wifi_config_get_config_id(const gchar *name, wifi_security_type_e security_type); -GSList *wifi_config_get_config_id_list(wifi_dbus *handle); - -int wifi_config_get_last_error(wifi_config_h config, wifi_error_e *last_error); - -int wifi_save_configurations(wifi_dbus *handle, const gchar *name, const gchar *passphrase, wifi_security_type_e security_type, const gchar *proxy_address, gboolean is_hidden); -int wifi_load_configurations(wifi_dbus *handle, const gchar *config_id, gchar **name, wifi_security_type_e *security_type, gchar **proxy_address, gboolean *is_hidden, wifi_error_e *last_error); -int wifi_remove_configurations(wifi_dbus *handle, const gchar *config_id); -int wifi_configuration_set_field(wifi_dbus *handle, const gchar *config_id, const gchar *key, const gchar *value); -int wifi_configuration_get_passphrase(wifi_dbus *handle, const gchar *config_id, gchar **passphrase); - -int wifi_save_eap_configurations(wifi_dbus *handle, const gchar *name, const gchar *passphrase, wifi_security_type_e security_type, const gchar *proxy_address, struct _wifi_eap_config *eap_config, gboolean is_hidden); -int wifi_load_eap_configurations(wifi_dbus *handle, const gchar *config_id, gchar **name, wifi_security_type_e *security_type, gchar **proxy_address, gboolean *is_hidden, struct _wifi_eap_config **eap_config, wifi_error_e *last_error); -wifi_eap_type_e wifi_eap_type_to_int(const gchar *type); -wifi_eap_auth_type_e wifi_eap_auth_type_to_int(const gchar *type); -gchar *wifi_eap_type_to_string(wifi_eap_type_e eap_type); -gchar *wifi_eap_auth_type_to_string(wifi_eap_auth_type_e eap_auth_type); - -#endif - diff --git a/include/wifi_dbus_private.h b/include/wifi_dbus_private.h deleted file mode 100755 index 5d41865..0000000 --- a/include/wifi_dbus_private.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef __WIFI_DBUS_H__ -#define __WIFI_DBUS_H__ - -#include - -#define DBUS_REPLY_TIMEOUT (120 * 1000) - -#define NETCONFIG_SERVICE "net.netconfig" -#define NETCONFIG_IWIFI "net.netconfig.wifi" -#define NETCONFIG_INETWORK "net.netconfig.network" -#define NETCONFIG_ISTATISTICS "net.netconfig.network_statistics" - -#define NETCONFIG_WIFI_PATH "/net/netconfig/wifi" -#define NETCONFIG_NETWORK_PATH "/net/netconfig/network" -#define NETCONFIG_STATISTICS_PATH "/net/netconfig/network_statistics" - -struct _wifi_dbus { - GDBusConnection *dbus_conn; - GCancellable *ca; -}; - -typedef struct _wifi_dbus wifi_dbus; - -int wifi_dbus_init(wifi_dbus **handle); -int wifi_dbus_deinit(wifi_dbus *handle); - -#endif diff --git a/packaging/capi-network-wifi.spec b/packaging/capi-network-wifi.spec index b6c8304..e4179ce 100755 --- a/packaging/capi-network-wifi.spec +++ b/packaging/capi-network-wifi.spec @@ -1,19 +1,12 @@ Name: capi-network-wifi Summary: Network Wi-Fi library in TIZEN C API -Version: 1.0.87 +Version: 1.0.88 Release: 1 Group: System/Network License: Apache-2.0 Source0: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(vconf) -BuildRequires: pkgconfig(network) -BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(gio-2.0) -BuildRequires: pkgconfig(gthread-2.0) -BuildRequires: pkgconfig(capi-base-common) -BuildRequires: pkgconfig(capi-system-info) Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig @@ -28,12 +21,6 @@ Requires: %{name} = %{version}-%{release} %description devel Network Wi-Fi library in Tizen C API (Development) -%package tool -Summary: Test Application for Wi-Fi Connection - -%description tool -Test Application for Wi-Fi Connection - %prep %setup -q @@ -63,12 +50,8 @@ make %{?_smp_mflags} %manifest capi-network-wifi.manifest %attr(644,-,-) %{_libdir}/libcapi-network-wifi.so.* %license LICENSE -%{_bindir}/wifi_test %files devel %{_includedir}/network/*.h %{_libdir}/pkgconfig/*.pc %{_libdir}/libcapi-network-wifi.so - -%files tool -%{_bindir}/wifi_test diff --git a/src/libnetwork.c b/src/libnetwork.c deleted file mode 100755 index be1359c..0000000 --- a/src/libnetwork.c +++ /dev/null @@ -1,1535 +0,0 @@ -/* - * 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 -#include -#include -#include - -#include "wifi_dbus_private.h" -#include "net_wifi_private.h" - -static __thread bool is_init = false; -static __thread GSList *ap_handle_list = NULL; - -struct _wifi_cb_s { - wifi_device_state_changed_cb device_state_cb; - void *device_state_user_data; - wifi_scan_finished_cb bg_scan_cb; - void *bg_scan_user_data; - wifi_scan_finished_cb scan_request_cb; - void *scan_request_user_data; - wifi_scan_finished_cb specific_scan_cb; - void *specific_scan_user_data; - wifi_connection_state_changed_cb connection_state_cb; - void *connection_state_user_data; - wifi_activated_cb activated_cb; - void *activated_user_data; - wifi_deactivated_cb deactivated_cb; - void *deactivated_user_data; - wifi_connected_cb connected_cb; - void *connected_user_data; - wifi_disconnected_cb disconnected_cb; - void *disconnected_user_data; -}; - -struct _profile_list_s { - int count; - net_profile_info_t *profiles; -}; - -struct _wifi_state_notify { - net_profile_info_t *ap_info; - wifi_connection_state_e state; -}; - -struct managed_idle_data { - GSourceFunc func; - gpointer user_data; - guint id; -}; - -static __thread struct _wifi_cb_s wifi_callbacks = { 0, }; -static __thread struct _profile_list_s profile_iterator = { 0, NULL }; -static __thread struct _profile_list_s specific_profile_iterator = {0, NULL}; -static __thread char specific_profile_essid[NET_WLAN_ESSID_LEN + 1] = { 0, }; -static __thread GSList *managed_idler_list = NULL; -static __thread bool wifi_is_feature_checked[WIFI_SUPPORTED_FEATURE_MAX] = {0, }; -static __thread bool wifi_feature_supported[WIFI_SUPPORTED_FEATURE_MAX] = {0, }; - -static __thread wifi_dbus *g_dbus_h = NULL; - -bool _wifi_is_init(void) -{ - return is_init; -} - -static void __wifi_set_init(bool tag) -{ - is_init = tag; -} - -//LCOV_EXCL_START -static wifi_error_e __libnet_convert_to_ap_error_type(net_err_t err_type) -{ - switch (err_type) { - case NET_ERR_NONE: - return WIFI_ERROR_NONE; - case NET_ERR_APP_ALREADY_REGISTERED: - return WIFI_ERROR_INVALID_OPERATION; - case NET_ERR_APP_NOT_REGISTERED: - return WIFI_ERROR_INVALID_OPERATION; - case NET_ERR_NO_ACTIVE_CONNECTIONS: - return WIFI_ERROR_NO_CONNECTION; - case NET_ERR_ACTIVE_CONNECTION_EXISTS: - return WIFI_ERROR_ALREADY_EXISTS; - case NET_ERR_CONNECTION_DHCP_FAILED: - return WIFI_ERROR_DHCP_FAILED; - case NET_ERR_CONNECTION_INVALID_KEY: - return WIFI_ERROR_INVALID_KEY; - case NET_ERR_IN_PROGRESS: - return WIFI_ERROR_NOW_IN_PROGRESS; - case NET_ERR_OPERATION_ABORTED: - return WIFI_ERROR_OPERATION_ABORTED; - case NET_ERR_TIME_OUT: - return WIFI_ERROR_NO_REPLY; - case NET_ERR_ACCESS_DENIED: - return WIFI_ERROR_PERMISSION_DENIED; - default: - return WIFI_ERROR_OPERATION_FAILED; - } -} - -static const char *__libnet_convert_ap_error_type_to_string(wifi_error_e err_type) -{ - switch (err_type) { - case WIFI_ERROR_NONE: - return "NONE"; - case WIFI_ERROR_INVALID_PARAMETER: - return "INVALID_PARAMETER"; - case WIFI_ERROR_OUT_OF_MEMORY: - return "OUT_OF_MEMORY"; - case WIFI_ERROR_INVALID_OPERATION: - return "INVALID_OPERATION"; - case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED: - return "ADDRESS_FAMILY_NOT_SUPPORTED"; - case WIFI_ERROR_OPERATION_FAILED: - return "OPERATION_FAILED"; - case WIFI_ERROR_NO_CONNECTION: - return "NO_CONNECTION"; - case WIFI_ERROR_NOW_IN_PROGRESS: - return "NOW_IN_PROGRESS"; - case WIFI_ERROR_ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case WIFI_ERROR_OPERATION_ABORTED: - return "OPERATION_ABORTED"; - case WIFI_ERROR_DHCP_FAILED: - return "DHCP_FAILED"; - case WIFI_ERROR_INVALID_KEY: - return "INVALID_KEY"; - case WIFI_ERROR_NO_REPLY: - return "NO_REPLY"; - case WIFI_ERROR_SECURITY_RESTRICTED: - return "SECURITY_RESTRICTED"; - case WIFI_ERROR_PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case WIFI_ERROR_NOT_SUPPORTED: - return "NOT_SUPPROTED"; - } - - return "UNKNOWN"; -} - -static const char *__libnet_convert_ap_state_to_string(wifi_connection_state_e state) -{ - switch (state) { - case WIFI_CONNECTION_STATE_FAILURE: - return "FAILURE"; - case WIFI_CONNECTION_STATE_DISCONNECTED: - return "DISCONNECTED"; - case WIFI_CONNECTION_STATE_ASSOCIATION: - return "ASSOCIATION"; - case WIFI_CONNECTION_STATE_CONFIGURATION: - return "CONFIGURATION"; - case WIFI_CONNECTION_STATE_CONNECTED: - return "CONNECTED"; - default: - return "UNKNOWN"; - } -} -//LCOV_EXCL_STOP - -static void __libnet_clear_profile_list(struct _profile_list_s *profile_list) -{ - if (profile_list->count > 0) - g_free(profile_list->profiles); - - profile_list->count = 0; - profile_list->profiles = NULL; -} - -static int __libnet_update_profile_iterator(void) -{ - int rv; - struct _profile_list_s wifi_profiles = { 0, NULL }; - - __libnet_clear_profile_list(&profile_iterator); - - rv = net_get_profile_list(NET_DEVICE_WIFI, &wifi_profiles.profiles, &wifi_profiles.count); - WIFI_LOG(WIFI_INFO, "Wi-Fi profile count: %d", wifi_profiles.count); - - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } - - if (wifi_profiles.count == 0) - return WIFI_ERROR_NONE; - - profile_iterator.count = wifi_profiles.count; - profile_iterator.profiles = wifi_profiles.profiles; - - return WIFI_ERROR_NONE; -} - -//LCOV_EXCL_START -static void __libnet_update_specific_profile_iterator(GSList *ap_list) -{ - int count = 0; - GSList *list = ap_list; - - for (count = 0; list; list = list->next) - count++; - - if (count == 0) { - WIFI_LOG(WIFI_INFO, "No hidden AP found\n"); - return; - } - - specific_profile_iterator.count = count; - specific_profile_iterator.profiles = g_try_new0(net_profile_info_t, count); - - list = ap_list; - for (count = 0; list; list = list->next) { - struct ssid_scan_bss_info_t *ap = (struct ssid_scan_bss_info_t *)list->data; - net_profile_info_t *profile = &specific_profile_iterator.profiles[count]; - - g_strlcpy(profile->ProfileInfo.Wlan.essid, ap->ssid, NET_WLAN_ESSID_LEN+1); - profile->ProfileInfo.Wlan.security_info.sec_mode = ap->security; - - count++; - } - - WIFI_LOG(WIFI_INFO, "Specific AP count : %d\n", count); -} -//LCOV_EXCL_STOP - -static void __libnet_convert_profile_info_to_wifi_info(net_wifi_connection_info_t *wifi_info, - net_profile_info_t *ap_info) -{ - g_strlcpy(wifi_info->essid, ap_info->ProfileInfo.Wlan.essid, NET_WLAN_ESSID_LEN+1); - wifi_info->wlan_mode = ap_info->ProfileInfo.Wlan.wlan_mode; - memcpy(&wifi_info->security_info, &ap_info->ProfileInfo.Wlan.security_info, sizeof(wlan_security_info_t)); - wifi_info->is_hidden = ap_info->ProfileInfo.Wlan.is_hidden; -} - -static int __libnet_connect_with_wifi_info(net_profile_info_t *ap_info) -{ - int rv; - net_wifi_connection_info_t wifi_info; - memset(&wifi_info, 0, sizeof(net_wifi_connection_info_t)); - - __libnet_convert_profile_info_to_wifi_info(&wifi_info, ap_info); - - rv = net_open_connection_with_wifi_info(&wifi_info); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); - return WIFI_ERROR_PERMISSION_DENIED; - } else if (rv != NET_ERR_NONE) - return WIFI_ERROR_OPERATION_FAILED; - - return WIFI_ERROR_NONE; -} - -//LCOV_EXCL_START -static gboolean __wifi_state_changed_cb(gpointer data) -{ - wifi_ap_h ap_info; - struct _wifi_state_notify *notify = (struct _wifi_state_notify *)data; - - if (notify == NULL) - return FALSE; - - ap_info = (wifi_ap_h)notify->ap_info; - - _wifi_libnet_add_to_ap_list(ap_info); - - if (wifi_callbacks.connection_state_cb != NULL) - wifi_callbacks.connection_state_cb(notify->state, ap_info, - wifi_callbacks.connection_state_user_data); - - _wifi_libnet_remove_from_ap_list(ap_info); - - g_free(notify); - - return FALSE; -} - -static void __libnet_state_changed_cb(char *profile_name, net_profile_info_t *profile_info, - wifi_connection_state_e state) -{ - guint id; - net_profile_info_t *ap_info = NULL; - struct _wifi_state_notify *notify = NULL; - - if (_wifi_is_init() != true) { - WIFI_LOG(WIFI_ERROR, "Application is not registered" - "If multi-threaded, thread integrity be broken."); - return; - } - - if (wifi_callbacks.connection_state_cb == NULL) - return; - - if (profile_name == NULL) - return; - - ap_info = g_try_malloc0(sizeof(net_profile_info_t)); - if (ap_info == NULL) { - WIFI_LOG(WIFI_ERROR, "Memory allocation error"); - return; - } - - if (profile_info) - memcpy(ap_info, profile_info, sizeof(net_profile_info_t)); - - notify = g_try_new0(struct _wifi_state_notify, 1); - if (notify == NULL) { - g_free(ap_info); - return; - } - - notify->ap_info = ap_info; - notify->state = state; - - id = _wifi_callback_add(__wifi_state_changed_cb, (gpointer)notify); - if (!id) - g_free(notify); -} - -static void __libnet_set_activated_cb(wifi_activated_cb user_cb, void *user_data) -{ - if (user_cb != NULL) { - wifi_callbacks.activated_cb = user_cb; - wifi_callbacks.activated_user_data = user_data; - } -} - -static gboolean __activated_cb_idle(gpointer data) -{ - wifi_error_e result = (wifi_error_e)data; - - if (wifi_callbacks.activated_cb != NULL) - wifi_callbacks.activated_cb(result, wifi_callbacks.activated_user_data); - - wifi_callbacks.activated_cb = NULL; - wifi_callbacks.activated_user_data = NULL; - - return FALSE; -} - -static void __libnet_set_deactivated_cb(wifi_deactivated_cb user_cb, void *user_data) -{ - if (user_cb != NULL) { - wifi_callbacks.deactivated_cb = user_cb; - wifi_callbacks.deactivated_user_data = user_data; - } -} - -static gboolean __deactivated_cb_idle(gpointer data) -{ - wifi_error_e result = (wifi_error_e)data; - - if (wifi_callbacks.deactivated_cb != NULL) - wifi_callbacks.deactivated_cb(result, wifi_callbacks.deactivated_user_data); - - wifi_callbacks.deactivated_cb = NULL; - wifi_callbacks.deactivated_user_data = NULL; - - return FALSE; -} - -static gboolean __device_state_cb_idle(gpointer data) -{ - wifi_device_state_e state = (wifi_device_state_e)data; - - if (wifi_callbacks.device_state_cb != NULL) - wifi_callbacks.device_state_cb(state, wifi_callbacks.device_state_user_data); - - return FALSE; -} - -static void __libnet_power_on_off_cb(net_event_info_t *event_cb) -{ - if (_wifi_is_init() != true) { - WIFI_LOG(WIFI_ERROR, "Application is not registered" - "If multi-threaded, thread integrity be broken."); - return; - } - - if (wifi_callbacks.device_state_cb == NULL && - wifi_callbacks.activated_cb == NULL && - wifi_callbacks.deactivated_cb == NULL) - return; - - wifi_error_e error_code = WIFI_ERROR_NONE; - wifi_device_state_e state = WIFI_DEVICE_STATE_DEACTIVATED; - net_wifi_state_t *wifi_state = (net_wifi_state_t *)event_cb->Data; - - if (event_cb->Error == NET_ERR_NONE && - event_cb->Datalength == sizeof(net_wifi_state_t)) { - if (*wifi_state == WIFI_ON) { - WIFI_LOG(WIFI_INFO, "Wi-Fi power on"); - state = WIFI_DEVICE_STATE_ACTIVATED; - } else if (*wifi_state == WIFI_OFF) { - WIFI_LOG(WIFI_INFO, "Wi-Fi power off"); - state = WIFI_DEVICE_STATE_DEACTIVATED; - __libnet_clear_profile_list(&profile_iterator); - } else { - WIFI_LOG(WIFI_ERROR, "Error Wi-Fi state %d", *wifi_state); - error_code = WIFI_ERROR_OPERATION_FAILED; - state = WIFI_DEVICE_STATE_DEACTIVATED; - } - } else { - WIFI_LOG(WIFI_ERROR, "Wi-Fi power request failed(%d)", event_cb->Error); - - if (event_cb->Error == NET_ERR_SECURITY_RESTRICTED) - error_code = WIFI_ERROR_SECURITY_RESTRICTED; - else - error_code = WIFI_ERROR_OPERATION_FAILED; - - state = WIFI_DEVICE_STATE_DEACTIVATED; - } - - if (wifi_callbacks.activated_cb != NULL) - _wifi_callback_add(__activated_cb_idle, (gpointer)error_code); - - if (wifi_callbacks.deactivated_cb != NULL) - _wifi_callback_add(__deactivated_cb_idle, (gpointer)error_code); - - if (wifi_callbacks.device_state_cb != NULL) - _wifi_callback_add(__device_state_cb_idle, (gpointer)state); -} - -static gboolean __scan_request_cb_idle(gpointer data) -{ - wifi_error_e error_code = (wifi_error_e)data; - - if (wifi_callbacks.scan_request_cb != NULL) - wifi_callbacks.scan_request_cb(error_code, wifi_callbacks.scan_request_user_data); - - wifi_callbacks.scan_request_cb = NULL; - wifi_callbacks.scan_request_user_data = NULL; - - return FALSE; -} - -static void __libnet_set_specific_scan_cb(wifi_scan_finished_cb user_cb, void *user_data) -{ - if (user_cb != NULL) { - wifi_callbacks.specific_scan_cb = user_cb; - wifi_callbacks.specific_scan_user_data = user_data; - } -} - -static gboolean __specific_scan_cb_idle(gpointer data) -{ - wifi_error_e error_code = (wifi_error_e)data; - - if (wifi_callbacks.specific_scan_cb != NULL) - wifi_callbacks.specific_scan_cb(error_code, wifi_callbacks.specific_scan_user_data); - - wifi_callbacks.specific_scan_cb = NULL; - wifi_callbacks.specific_scan_user_data = NULL; - - return FALSE; -} - -static gboolean __bgscan_cb_idle(gpointer data) -{ - wifi_error_e error_code = (wifi_error_e)data; - - if (wifi_callbacks.bg_scan_cb != NULL) - wifi_callbacks.bg_scan_cb(error_code, wifi_callbacks.bg_scan_user_data); - - return FALSE; -} - -static void __libnet_scan_cb(net_event_info_t *event_cb) -{ - wifi_error_e error_code = WIFI_ERROR_NONE; - - if (_wifi_is_init() != true) { - WIFI_LOG(WIFI_ERROR, "Application is not registered" - "If multi-threaded, thread integrity be broken."); - return; - } - - if (event_cb->Error != NET_ERR_NONE) { - WIFI_LOG(WIFI_ERROR, "Scan failed[%d]", event_cb->Error); - error_code = WIFI_ERROR_OPERATION_FAILED; - } - - if (wifi_callbacks.scan_request_cb != NULL) { - _wifi_callback_add(__scan_request_cb_idle, (gpointer)error_code); - return; - } - - if (wifi_callbacks.bg_scan_cb != NULL) - _wifi_callback_add(__bgscan_cb_idle, (gpointer)error_code); -} - -static void __libnet_specific_scan_cb(net_event_info_t *event_cb) -{ - wifi_error_e error_code = WIFI_ERROR_NONE; - - __libnet_clear_profile_list(&specific_profile_iterator); - - if (event_cb->Error != NET_ERR_NONE) { - WIFI_LOG(WIFI_ERROR, "Specific scan failed!, Error [%d]\n", event_cb->Error); - error_code = WIFI_ERROR_OPERATION_FAILED; - } else if (event_cb->Data) { - GSList *ap_list = (GSList *)event_cb->Data; - __libnet_update_specific_profile_iterator(ap_list); - } - - if (wifi_callbacks.specific_scan_cb != NULL) - _wifi_callback_add(__specific_scan_cb_idle, (gpointer)error_code); -} - -static void __libnet_set_connected_cb(wifi_connected_cb user_cb, void *user_data) -{ - if (user_cb != NULL) { - wifi_callbacks.connected_cb = user_cb; - wifi_callbacks.connected_user_data = user_data; - } -} - -static gboolean __connected_cb_idle(gpointer data) -{ - wifi_error_e result = (wifi_error_e)data; - - if (wifi_callbacks.connected_cb != NULL) - wifi_callbacks.connected_cb(result, wifi_callbacks.connected_user_data); - - wifi_callbacks.connected_cb = NULL; - wifi_callbacks.connected_user_data = NULL; - - return FALSE; -} - -static void __libnet_connected_cb(wifi_error_e result) -{ - if (_wifi_is_init() != true) { - WIFI_LOG(WIFI_ERROR, "Application is not registered" - "If multi-threaded, thread integrity be broken."); - return; - } - - if (wifi_callbacks.connected_cb != NULL) - _wifi_callback_add(__connected_cb_idle, (gpointer)result); -} - -static void __libnet_set_disconnected_cb(wifi_disconnected_cb user_cb, void *user_data) -{ - if (user_cb != NULL) { - wifi_callbacks.disconnected_cb = user_cb; - wifi_callbacks.disconnected_user_data = user_data; - } -} - -static gboolean __disconnected_cb_idle(gpointer data) -{ - wifi_error_e result = (wifi_error_e)data; - - if (wifi_callbacks.disconnected_cb != NULL) - wifi_callbacks.disconnected_cb(result, wifi_callbacks.disconnected_user_data); - - wifi_callbacks.disconnected_cb = NULL; - wifi_callbacks.disconnected_user_data = NULL; - - return FALSE; -} - -static void __libnet_disconnected_cb(wifi_error_e result) -{ - if (_wifi_is_init() != true) { - WIFI_LOG(WIFI_ERROR, "Application is not registered" - "If multi-threaded, thread integrity be broken."); - return; - } - - if (wifi_callbacks.disconnected_cb != NULL) - _wifi_callback_add(__disconnected_cb_idle, (gpointer)result); -} -//LCOV_EXCL_STOP - -static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data) -{ - bool is_requested = false; - net_profile_info_t *prof_info_p = NULL; - net_profile_info_t prof_info; - wifi_error_e result = WIFI_ERROR_NONE; - int i = 0; - bool is_profile_exists = false; - - switch (event_cb->Event) { - case NET_EVENT_OPEN_RSP: - case NET_EVENT_WIFI_WPS_RSP: - is_requested = true; - /* fall through */ - case NET_EVENT_OPEN_IND: - if ((_wifi_libnet_check_profile_name_validity(event_cb->ProfileName) != - true) && (event_cb->Error != - NET_ERR_CONNECTION_CONNECT_FAILED)) - return; - - result = __libnet_convert_to_ap_error_type(event_cb->Error); - WIFI_LOG(WIFI_INFO, "Connection open error %s", - __libnet_convert_ap_error_type_to_string(result)); - - if (is_requested) - __libnet_connected_cb(result); - - switch (event_cb->Error) { - case NET_ERR_NONE: - if (event_cb->Datalength == sizeof(net_profile_info_t)) - prof_info_p = (net_profile_info_t *)event_cb->Data; - - __libnet_state_changed_cb(event_cb->ProfileName, prof_info_p, - WIFI_CONNECTION_STATE_CONNECTED); - return; - case NET_ERR_ACTIVE_CONNECTION_EXISTS: - return; - default: - break; - } - - if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE) - __libnet_state_changed_cb(event_cb->ProfileName, &prof_info, - WIFI_CONNECTION_STATE_DISCONNECTED); - else - __libnet_state_changed_cb(event_cb->ProfileName, NULL, - WIFI_CONNECTION_STATE_DISCONNECTED); - - break; - case NET_EVENT_CLOSE_RSP: - is_requested = true; - /* fall through */ - case NET_EVENT_CLOSE_IND: - if (_wifi_libnet_check_profile_name_validity(event_cb->ProfileName) != true) - return; - - result = __libnet_convert_to_ap_error_type(event_cb->Error); - WIFI_LOG(WIFI_ERROR, "Connection close error %s", - __libnet_convert_ap_error_type_to_string(result)); - - if (is_requested) - __libnet_disconnected_cb(result); - - switch (event_cb->Error) { - case NET_ERR_NONE: - if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE) - __libnet_state_changed_cb(event_cb->ProfileName, &prof_info, - WIFI_CONNECTION_STATE_DISCONNECTED); - else - __libnet_state_changed_cb(event_cb->ProfileName, NULL, - WIFI_CONNECTION_STATE_DISCONNECTED); - return; - default: - break; - } - - break; - case NET_EVENT_NET_STATE_IND: - if (_wifi_libnet_check_profile_name_validity(event_cb->ProfileName) != true) - return; - - if (event_cb->Datalength != sizeof(net_state_type_t)) - return; - - net_state_type_t *profile_state = (net_state_type_t *)event_cb->Data; - wifi_connection_state_e ap_state = _wifi_convert_to_ap_state(*profile_state); - - WIFI_LOG(WIFI_INFO, "state: %s", __libnet_convert_ap_state_to_string(ap_state)); - SECURE_WIFI_LOG(WIFI_INFO, "profile name: %s", event_cb->ProfileName); - - if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE) - __libnet_state_changed_cb(event_cb->ProfileName, &prof_info, ap_state); - else if (ap_state == WIFI_CONNECTION_STATE_DISCONNECTED) { - for (i = 0; i < profile_iterator.count; i++) { - if (!g_strcmp0(event_cb->ProfileName, - profile_iterator.profiles[i].ProfileName)) { - is_profile_exists = true; - break; - } - } - - if (is_profile_exists == true) { - profile_iterator.profiles[i].ProfileState = *profile_state; - __libnet_state_changed_cb(event_cb->ProfileName, - &profile_iterator.profiles[i], ap_state); - } else - __libnet_state_changed_cb(event_cb->ProfileName, - NULL, ap_state); - } else - __libnet_state_changed_cb(event_cb->ProfileName, NULL, ap_state); - - break; - case NET_EVENT_WIFI_SCAN_RSP: - case NET_EVENT_WIFI_SCAN_IND: - __libnet_scan_cb(event_cb); - break; - case NET_EVENT_SPECIFIC_SCAN_RSP: - WIFI_LOG(WIFI_INFO, "Got Wi-Fi specific scan RSP\n"); - break; - case NET_EVENT_SPECIFIC_SCAN_IND: - WIFI_LOG(WIFI_INFO, "Got Wi-Fi specific scan IND\n"); - __libnet_specific_scan_cb(event_cb); - break; - case NET_EVENT_WIFI_POWER_RSP: - /* fall through */ - case NET_EVENT_WIFI_POWER_IND: - __libnet_power_on_off_cb(event_cb); - break; - default: - break; - } -} - -int _wifi_libnet_init(void) -{ - int rv; - - rv = net_register_client_ext((net_event_cb_t)__libnet_evt_cb, NET_DEVICE_WIFI, NULL); - if (rv != NET_ERR_NONE) - return rv; - - __wifi_set_init(true); - - return NET_ERR_NONE; -} - -bool _wifi_libnet_deinit(void) -{ - if (net_deregister_client_ext(NET_DEVICE_WIFI) != NET_ERR_NONE) - return false; - - __libnet_clear_profile_list(&profile_iterator); - g_slist_free_full(ap_handle_list, g_free); - ap_handle_list = NULL; - memset(&wifi_callbacks, 0, sizeof(struct _wifi_cb_s)); - - __wifi_set_init(false); - - return true; -} - -int _wifi_activate(wifi_activated_cb callback, gboolean wifi_picker_test, - void *user_data) -{ - int rv = NET_ERR_NONE; - - rv = net_wifi_power_on(wifi_picker_test); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } else if (rv == NET_ERR_INVALID_OPERATION) - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - else if (rv == NET_ERR_ALREADY_EXISTS) - return WIFI_ERROR_ALREADY_EXISTS; //LCOV_EXCL_LINE - else if (rv == NET_ERR_IN_PROGRESS) - return WIFI_ERROR_NOW_IN_PROGRESS; //LCOV_EXCL_LINE - else if (rv == NET_ERR_SECURITY_RESTRICTED) - return WIFI_ERROR_SECURITY_RESTRICTED; //LCOV_EXCL_LINE - else if (rv == NET_ERR_NONE) { - __libnet_set_activated_cb(callback, user_data); - return WIFI_ERROR_NONE; - } - - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE -} - -int _wifi_deactivate(wifi_deactivated_cb callback, void *user_data) -{ - int rv = NET_ERR_NONE; - - rv = net_wifi_power_off(); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } else if (rv == NET_ERR_INVALID_OPERATION) - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - else if (rv == NET_ERR_ALREADY_EXISTS) - return WIFI_ERROR_ALREADY_EXISTS; //LCOV_EXCL_LINE - else if (rv == NET_ERR_IN_PROGRESS) - return WIFI_ERROR_NOW_IN_PROGRESS; //LCOV_EXCL_LINE - else if (rv == NET_ERR_SECURITY_RESTRICTED) - return WIFI_ERROR_SECURITY_RESTRICTED; //LCOV_EXCL_LINE - else if (rv == NET_ERR_NONE) { - __libnet_set_deactivated_cb(callback, user_data); - return WIFI_ERROR_NONE; - } - - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE -} - -bool _wifi_libnet_check_ap_validity(wifi_ap_h ap_h) -{ - int i; - GSList *list = NULL; - - if (ap_h == NULL) - return false; - - for (list = ap_handle_list; list; list = list->next) - if (ap_h == list->data) return true; - - for (i = 0; i < profile_iterator.count; i++) - if (ap_h == &profile_iterator.profiles[i]) return true; - - for (i = 0; i < specific_profile_iterator.count; i++) - if (ap_h == &specific_profile_iterator.profiles[i]) return true; - - return false; -} - -void _wifi_libnet_add_to_ap_list(wifi_ap_h ap_h) -{ - ap_handle_list = g_slist_append(ap_handle_list, ap_h); -} - -void _wifi_libnet_remove_from_ap_list(wifi_ap_h ap_h) -{ - ap_handle_list = g_slist_remove(ap_handle_list, ap_h); - g_free(ap_h); -} - -bool _wifi_libnet_check_profile_name_validity(const char *profile_name) -{ - const char *profile_prefix = "/net/connman/service/wifi_"; - int i = 0; - - if (profile_name == NULL || - g_str_has_prefix(profile_name, profile_prefix) != TRUE) { - WIFI_LOG(WIFI_INFO, "The profile is a hidden or not a regular Wi-Fi profile"); - return false; - } - - while (profile_name[i] != '\0') { - if (isgraph(profile_name[i]) == 0) { - WIFI_LOG(WIFI_INFO, "Invalid format: %s", profile_name); //LCOV_EXCL_LINE - return false; //LCOV_EXCL_LINE - } - i++; - } - - return true; -} - -int _wifi_libnet_get_wifi_device_state(wifi_device_state_e *device_state) -{ - net_tech_info_t tech_info; - - int rv = NET_ERR_NONE; - rv = net_get_technology_properties(NET_DEVICE_WIFI, &tech_info); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } else if (rv != NET_ERR_NONE) { - WIFI_LOG(WIFI_ERROR, "Failed to get technology properties"); //LCOV_EXCL_LINE - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE - } - - if (tech_info.powered) - *device_state = WIFI_DEVICE_STATE_ACTIVATED; - else - *device_state = WIFI_DEVICE_STATE_DEACTIVATED; - - return WIFI_ERROR_NONE; -} - -int _wifi_libnet_get_wifi_state(wifi_connection_state_e *connection_state) -{ - int rv; - net_wifi_state_t wlan_state = 0; - - rv = net_get_wifi_state(&wlan_state); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } else if (rv != NET_ERR_NONE) { - WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE - } - - switch (wlan_state) { - //LCOV_EXCL_START - case WIFI_OFF: - case WIFI_ON: - *connection_state = WIFI_CONNECTION_STATE_DISCONNECTED; - break; - case WIFI_ASSOCIATION: - *connection_state = WIFI_CONNECTION_STATE_ASSOCIATION; - break; - case WIFI_CONFIGURATION: - *connection_state = WIFI_CONNECTION_STATE_CONFIGURATION; - break; - case WIFI_CONNECTED: - *connection_state = WIFI_CONNECTION_STATE_CONNECTED; - break; - case WIFI_DISCONNECTING: - *connection_state = WIFI_CONNECTION_STATE_CONNECTED; - break; - default: - WIFI_LOG(WIFI_ERROR, "Unknown state"); - return WIFI_ERROR_OPERATION_FAILED; - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; -} - -int _wifi_libnet_get_intf_name(char** name) -{ - int rv; - - if (profile_iterator.count == 0) { - rv = __libnet_update_profile_iterator(); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } - } - - if (profile_iterator.count == 0) { - WIFI_LOG(WIFI_ERROR, "There is no AP"); //LCOV_EXCL_LINE - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE - } - - *name = g_strdup(profile_iterator.profiles->ProfileInfo.Wlan.net_info.DevName); - if (*name == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; - - return WIFI_ERROR_NONE; -} - -int _wifi_libnet_scan_request(wifi_scan_finished_cb callback, void *user_data) -{ - int rv; - rv = net_scan_wifi(); - - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } else if (rv == NET_ERR_INVALID_OPERATION) - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - else if (rv == NET_ERR_NONE) { - wifi_callbacks.scan_request_cb = callback; - wifi_callbacks.scan_request_user_data = user_data; - return WIFI_ERROR_NONE; - } - - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE -} - -int _wifi_libnet_scan_specific_ap(const char *essid, - wifi_scan_finished_cb callback, void *user_data) -{ - int rv; - rv = net_specific_scan_wifi(essid); - - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } else if (rv == NET_ERR_INVALID_OPERATION) - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - else if (rv == NET_ERR_NONE) { - g_strlcpy(specific_profile_essid, essid, NET_WLAN_ESSID_LEN+1); - __libnet_set_specific_scan_cb(callback, user_data); - return WIFI_ERROR_NONE; - } - - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE -} - -int _wifi_libnet_get_connected_profile(wifi_ap_h *ap) -{ - int i, rv; - wifi_ap_h ap_h = NULL; - - rv = __libnet_update_profile_iterator(); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } - - for (i = 0; i < profile_iterator.count; i++) { - if (profile_iterator.profiles[i].ProfileState == NET_STATE_TYPE_ONLINE || - profile_iterator.profiles[i].ProfileState == NET_STATE_TYPE_READY) { - ap_h = (wifi_ap_h)(&profile_iterator.profiles[i]); - break; - } - } - - if (ap_h == NULL) { - WIFI_LOG(WIFI_ERROR, "There is no connected AP"); //LCOV_EXCL_LINE - return WIFI_ERROR_NO_CONNECTION; //LCOV_EXCL_LINE - } - - *ap = g_try_malloc0(sizeof(net_profile_info_t)); - if (*ap == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; - - memcpy(*ap, ap_h, sizeof(net_profile_info_t)); - - _wifi_libnet_add_to_ap_list(*ap); - - return WIFI_ERROR_NONE; -} - -int _wifi_libnet_foreach_found_aps(wifi_found_ap_cb callback, void *user_data) -{ - int i, rv; - - rv = __libnet_update_profile_iterator(); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } - - if (profile_iterator.count == 0) { - WIFI_LOG(WIFI_WARN, "There is no AP"); //LCOV_EXCL_LINE - return WIFI_ERROR_NONE; //LCOV_EXCL_LINE - } - - for (i = 0; i < profile_iterator.count; i++) { - if (profile_iterator.profiles[i].ProfileInfo.Wlan.is_hidden == TRUE) - continue; - - rv = callback((wifi_ap_h)(&profile_iterator.profiles[i]), user_data); - if (rv == false) break; - } - - return WIFI_ERROR_NONE; -} - -int _wifi_libnet_get_hidden_aps(const char* essid, - wifi_security_type_e sec_type, const char *passphrase, - wifi_connected_cb callback, void* user_data) -{ - int i, rv; - bool is_available = false; - wifi_security_type_e type = WIFI_SECURITY_TYPE_NONE; - net_profile_info_t *profile_info = NULL; - - rv = __libnet_update_profile_iterator(); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); - return WIFI_ERROR_PERMISSION_DENIED; - } - - if (profile_iterator.count == 0) { - WIFI_LOG(WIFI_WARN, "There is no AP"); - return WIFI_ERROR_NONE; - } - - for (i = 0; i < profile_iterator.count; i++) { - net_profile_info_t *ap = &profile_iterator.profiles[i]; - switch (ap->ProfileInfo.Wlan.security_info.sec_mode) { - case WLAN_SEC_MODE_WEP: - type = WIFI_SECURITY_TYPE_WEP; - break; - case WLAN_SEC_MODE_IEEE8021X: - type = WIFI_SECURITY_TYPE_EAP; - break; - case WLAN_SEC_MODE_WPA_PSK: - case WLAN_SEC_MODE_WPA2_PSK: - case WLAN_SEC_MODE_WPA_FT_PSK: - type = WIFI_SECURITY_TYPE_WPA_PSK; - break; - case WLAN_SEC_MODE_NONE: - default: - type = WIFI_SECURITY_TYPE_NONE; - break; - } - if (profile_iterator.profiles[i].ProfileInfo.Wlan.is_hidden == TRUE) { - if (type == sec_type) { - WIFI_LOG(WIFI_INFO, "hidden profile %s", - profile_iterator.profiles[i].ProfileName); - is_available = true; - profile_info = &profile_iterator.profiles[i]; - } - } else if (!g_strcmp0(profile_iterator.profiles[i].ProfileInfo.Wlan.essid, - essid) && type == sec_type) { - WIFI_LOG(WIFI_INFO, "AP %s not hidden", essid); - wifi_ap_set_passphrase((wifi_ap_h) (&profile_iterator.profiles[i]), - passphrase); - return _wifi_libnet_open_profile( - (wifi_ap_h)(&profile_iterator.profiles[i]), - callback, user_data); - } - } - - if (is_available == false) { - WIFI_LOG(WIFI_INFO, "No hidden profiles found"); - return WIFI_ERROR_INVALID_OPERATION; - } - - switch (profile_info->ProfileInfo.Wlan.security_info.sec_mode) { - case WLAN_SEC_MODE_WEP: - g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.wep.wepKey, - passphrase, NETPM_WLAN_MAX_WEP_KEY_LEN+1); - break; - case WLAN_SEC_MODE_WPA_PSK: - case WLAN_SEC_MODE_WPA2_PSK: - g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.psk.pskKey, - passphrase, NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN+1); - break; - case WLAN_SEC_MODE_NONE: - break; - case WLAN_SEC_MODE_IEEE8021X: - default: - WIFI_LOG(WIFI_INFO, "Invalid security type"); - return WIFI_ERROR_OPERATION_FAILED; - } - - g_strlcpy(profile_info->ProfileInfo.Wlan.essid, essid, NET_WLAN_ESSID_LEN+1); - - return _wifi_libnet_open_profile(profile_info, callback, user_data); -} - -int _wifi_libnet_foreach_found_specific_aps(wifi_found_ap_cb callback, void *user_data) -{ - int i, rv; - - if (specific_profile_iterator.count == 0) { - WIFI_LOG(WIFI_WARN, "There is no specific APs"); - - rv = __libnet_update_profile_iterator(); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } - - if (profile_iterator.count == 0) { - WIFI_LOG(WIFI_WARN, "There is no APs"); //LCOV_EXCL_LINE - return WIFI_ERROR_NONE; //LCOV_EXCL_LINE - } - - for (i = 0; i < profile_iterator.count; i++) { - if (!g_strcmp0(specific_profile_essid, - profile_iterator.profiles[i].ProfileInfo.Wlan.essid)) { - rv = callback((wifi_ap_h)(&profile_iterator.profiles[i]), user_data); - if (rv == false) break; - } - } - return WIFI_ERROR_NONE; - } - - for (i = 0; i < specific_profile_iterator.count; i++) { - rv = callback((wifi_ap_h)(&specific_profile_iterator.profiles[i]), user_data); - if (rv == false) break; - } - - return WIFI_ERROR_NONE; -} - -int _wifi_libnet_open_profile(wifi_ap_h ap_h, wifi_connected_cb callback, void *user_data) -{ - int rv; - bool valid_profile; - net_profile_info_t *ap_info = ap_h; - - valid_profile = - _wifi_libnet_check_profile_name_validity(ap_info->ProfileName); - - if (valid_profile == true && ap_info->Favourite) - rv = net_open_connection_with_profile(ap_info->ProfileName); - else if (valid_profile == true && - ap_info->ProfileInfo.Wlan.is_hidden != TRUE && - ap_info->ProfileInfo.Wlan.security_info.sec_mode == - WLAN_SEC_MODE_NONE) - rv = net_open_connection_with_profile(ap_info->ProfileName); - else - rv = __libnet_connect_with_wifi_info(ap_info); - - rv = __libnet_convert_to_ap_error_type(rv); - if (rv == WIFI_ERROR_NONE) - __libnet_set_connected_cb(callback, user_data); - - return rv; -} - -int _wifi_libnet_close_profile(wifi_ap_h ap_h, wifi_disconnected_cb callback, void *user_data) -{ - int rv; - net_profile_info_t *ap_info = ap_h; - - rv = net_close_connection(ap_info->ProfileName); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } else if (rv != NET_ERR_NONE) - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE - - __libnet_set_disconnected_cb(callback, user_data); - - return WIFI_ERROR_NONE; -} - -//LCOV_EXCL_START -int _wifi_libnet_connect_with_wps_pbc(wifi_ap_h ap_h, wifi_connected_cb callback, void *user_data) -{ - int rv; - net_profile_info_t *ap_info = ap_h; - net_wifi_wps_info_t wps_info; - memset(&wps_info, 0, sizeof(net_wifi_wps_info_t)); - - wps_info.type = WIFI_WPS_PBC; - - rv = net_wifi_enroll_wps(ap_info->ProfileName, &wps_info); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); - return WIFI_ERROR_PERMISSION_DENIED; - } else if (rv != NET_ERR_NONE) - return WIFI_ERROR_OPERATION_FAILED; - - __libnet_set_connected_cb(callback, user_data); - - return WIFI_ERROR_NONE; -} - -int _wifi_libnet_connect_with_wps_pin(wifi_ap_h ap_h, const char *pin, - wifi_connected_cb callback, void *user_data) -{ - int rv; - net_profile_info_t *ap_info = ap_h; - net_wifi_wps_info_t wps_info; - - if (ap_info == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - wps_info.type = WIFI_WPS_PIN; - g_strlcpy(wps_info.pin, pin, NET_WLAN_MAX_WPSPIN_LEN + 1); - - rv = net_wifi_enroll_wps(ap_info->ProfileName, &wps_info); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); - return WIFI_ERROR_PERMISSION_DENIED; - } else if (rv != NET_ERR_NONE) - return WIFI_ERROR_OPERATION_FAILED; - - __libnet_set_connected_cb(callback, user_data); - - return WIFI_ERROR_NONE; -} -//LCOV_EXCL_STOP - -int _wifi_libnet_forget_ap(wifi_ap_h ap) -{ - int rv = 0; - net_profile_info_t *ap_info = ap; - - if (ap_info == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE - } - - rv = net_delete_profile(ap_info->ProfileName); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } else if (rv != NET_ERR_NONE) - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE - - ap_info->Favourite = (char)FALSE; - - return WIFI_ERROR_NONE; -} - -int _wifi_set_power_on_off_cb(wifi_device_state_changed_cb callback, void *user_data) -{ - if (wifi_callbacks.device_state_cb != NULL) - return WIFI_ERROR_INVALID_OPERATION; - - wifi_callbacks.device_state_cb = callback; - wifi_callbacks.device_state_user_data = user_data; - - WIFI_LOG(WIFI_INFO, "Wi-Fi registered device state changed callback"); - - return WIFI_ERROR_NONE; -} - -int _wifi_unset_power_on_off_cb(void) -{ - if (wifi_callbacks.device_state_cb == NULL) - return WIFI_ERROR_INVALID_OPERATION; - - wifi_callbacks.device_state_cb = NULL; - wifi_callbacks.device_state_user_data = NULL; - - return WIFI_ERROR_NONE; -} - -int _wifi_set_background_scan_cb(wifi_scan_finished_cb callback, void *user_data) -{ - if (wifi_callbacks.bg_scan_cb != NULL) - return WIFI_ERROR_INVALID_OPERATION; - - wifi_callbacks.bg_scan_cb = callback; - wifi_callbacks.bg_scan_user_data = user_data; - - return WIFI_ERROR_NONE; -} - -int _wifi_unset_background_scan_cb(void) -{ - if (wifi_callbacks.bg_scan_cb == NULL) - return WIFI_ERROR_INVALID_OPERATION; - - wifi_callbacks.bg_scan_cb = NULL; - wifi_callbacks.bg_scan_user_data = NULL; - - return WIFI_ERROR_NONE; -} - -int _wifi_set_connection_state_cb(wifi_connection_state_changed_cb callback, void *user_data) -{ - if (wifi_callbacks.connection_state_cb != NULL) - return WIFI_ERROR_INVALID_OPERATION; - - wifi_callbacks.connection_state_cb = callback; - wifi_callbacks.connection_state_user_data = user_data; - - return WIFI_ERROR_NONE; -} - -int _wifi_unset_connection_state_cb() -{ - if (wifi_callbacks.connection_state_cb == NULL) - return WIFI_ERROR_INVALID_OPERATION; - - wifi_callbacks.connection_state_cb = NULL; - wifi_callbacks.connection_state_user_data = NULL; - - return WIFI_ERROR_NONE; -} - -int _wifi_update_ap_info(net_profile_info_t *ap_info) -{ - int rv = NET_ERR_NONE; - rv = net_modify_profile(ap_info->ProfileName, ap_info); - - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } else if (rv == NET_ERR_SECURITY_RESTRICTED) - return WIFI_ERROR_SECURITY_RESTRICTED; //LCOV_EXCL_LINE - else if (rv != NET_ERR_NONE) - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE - - return WIFI_ERROR_NONE; -} - -static void __wifi_idle_destroy_cb(gpointer data) -{ - if (!data) - return; - - managed_idler_list = g_slist_remove(managed_idler_list, data); - g_free(data); -} - -static gboolean __wifi_idle_cb(gpointer user_data) -{ - struct managed_idle_data *data = (struct managed_idle_data *)user_data; - - if (!data) - return FALSE; - - return data->func(data->user_data); -} - -guint _wifi_callback_add(GSourceFunc func, gpointer user_data) -{ - guint id; - struct managed_idle_data *data; - GMainContext *context; - GSource *src; - - if (!func) - return 0; - - data = g_try_new0(struct managed_idle_data, 1); - if (!data) - return 0; - - data->func = func; - data->user_data = user_data; - - context = g_main_context_get_thread_default(); - src = g_idle_source_new(); - g_source_set_callback(src, __wifi_idle_cb, data, __wifi_idle_destroy_cb); - id = g_source_attach(src, context); - g_source_unref(src); - - if (!id) { - g_free(data); - return id; - } - - data->id = id; - - managed_idler_list = g_slist_append(managed_idler_list, data); - - return id; -} - -void _wifi_callback_cleanup(void) -{ - GSList *cur = managed_idler_list; - GSource *src; - struct managed_idle_data *data; - - while (cur) { - //LCOV_EXCL_START - GSList *next = cur->next; - data = (struct managed_idle_data *)cur->data; - - src = g_main_context_find_source_by_id(g_main_context_default(), data->id); - if (src) { - g_source_destroy(src); - cur = managed_idler_list; - } else - cur = next; - //LCOV_EXCL_STOP - } - - g_slist_free(managed_idler_list); - managed_idler_list = NULL; -} - -int _wifi_libnet_check_get_privilege() -{ - int rv; - - rv = net_check_get_privilege(); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } else if (rv != NET_ERR_NONE) - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE - - return WIFI_ERROR_NONE; -} - -int _wifi_libnet_check_profile_privilege() -{ - int rv = net_check_profile_privilege(); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } else if (rv != NET_ERR_NONE) - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE - - return WIFI_ERROR_NONE; -} - -bool __libnet_check_feature_supported(const char *key, wifi_supported_feature_e feature) -{ - if (!wifi_is_feature_checked[feature]) { - if (system_info_get_platform_bool(key, &wifi_feature_supported[feature]) < 0) { - WIFI_LOG(WIFI_ERROR, "Error - Feature getting from System Info"); //LCOV_EXCL_LINE - set_last_result(WIFI_ERROR_OPERATION_FAILED); //LCOV_EXCL_LINE - return false; //LCOV_EXCL_LINE - } - wifi_is_feature_checked[feature] = true; - } - return wifi_feature_supported[feature]; -} - -int _wifi_check_feature_supported(const char *feature_name, ...) -{ - va_list list; - const char *key; - bool value = false; - bool feature_supported = false; - - va_start(list, feature_name); - key = feature_name; - while (1) { - if (strcmp(key, WIFI_FEATURE) == 0) - value = __libnet_check_feature_supported(key, WIFI_SUPPORTED_FEATURE_WIFI); - else if (strcmp(key, WIFI_TDLS_FEATURE) == 0) - value = __libnet_check_feature_supported(key, WIFI_SUPPORTED_FEATURE_WIFI_TDLS); - - feature_supported |= value; - key = va_arg(list, const char *); - if (!key) break; - } - if (!feature_supported) { - WIFI_LOG(WIFI_ERROR, "Error - Feature is not supported"); //LCOV_EXCL_LINE - set_last_result(WIFI_ERROR_NOT_SUPPORTED); //LCOV_EXCL_LINE - va_end(list); - return WIFI_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - - va_end(list); - set_last_result(WIFI_ERROR_NONE); - return WIFI_ERROR_NONE; -} - -int _wifi_dbus_init(void) -{ - int rv; - - rv = wifi_dbus_init(&g_dbus_h); - if (rv != NET_ERR_NONE) - return rv; //LCOV_EXCL_LINE - - return NET_ERR_NONE; -} - -int _wifi_dbus_deinit(void) -{ - wifi_dbus_deinit(g_dbus_h); - g_dbus_h = NULL; - - return NET_ERR_NONE; -} - -wifi_dbus *_wifi_get_dbus_handle(void) -{ - if (g_dbus_h == NULL) { - WIFI_LOG(WIFI_ERROR, "g_dbus_h is NULL"); //LCOV_EXCL_LINE - return NULL; //LCOV_EXCL_LINE - } - - return g_dbus_h; -} diff --git a/src/net_wifi.c b/src/net_wifi.c index 99abfed..9c139e3 100755 --- a/src/net_wifi.c +++ b/src/net_wifi.c @@ -14,673 +14,199 @@ * limitations under the License. */ -#include -#include -#include -#include -#include -#include -#include -#include - #include "net_wifi_private.h" -#define WIFI_MAC_ADD_LENGTH 17 -#define WIFI_MAC_ADD_PATH "/sys/class/net/wlan0/address" - -static __thread wifi_rssi_level_changed_cb rssi_level_changed_cb = NULL; -static __thread void *rssi_level_changed_user_data = NULL; -static int tv_profile = -1; // Unknown - -//LCOV_EXCL_START -static gboolean __rssi_level_changed_cb_idle(gpointer data) -{ - int rssi_level = 0; - - if (vconf_get_int(VCONFKEY_WIFI_STRENGTH, &rssi_level) != 0) - return FALSE; - - if (rssi_level_changed_cb != NULL) - rssi_level_changed_cb(rssi_level, rssi_level_changed_user_data); - - return FALSE; -} - -static void __rssi_level_changed_cb(keynode_t *node, void *user_data) -{ - if (_wifi_is_init() != true) { - WIFI_LOG(WIFI_ERROR, "Application is not registered" //LCOV_EXCL_LINE - "If multi-threaded, thread integrity be broken."); - return; - } - - if (rssi_level_changed_cb != NULL) - _wifi_callback_add(__rssi_level_changed_cb_idle, NULL); -} -//LCOV_EXCL_STOP - EXPORT_API int wifi_initialize(void) { - int rv; - DEPRECATED_LOG(__FUNCTION__, "wifi_manager_initialize"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_is_init() == true) { - WIFI_LOG(WIFI_ERROR, "Already initialized"); - return WIFI_ERROR_INVALID_OPERATION; - } - - rv = _wifi_libnet_init(); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } else if (rv != NET_ERR_NONE) { - WIFI_LOG(WIFI_ERROR, "Init failed[%d]", rv); //LCOV_EXCL_LINE - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE - } - - _wifi_dbus_init(); - - WIFI_LOG(WIFI_INFO, "Wi-Fi successfully initialized"); - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_deinitialize(void) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_deinitialize"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); - return WIFI_ERROR_INVALID_OPERATION; - } - - if (_wifi_libnet_deinit() == false) { - WIFI_LOG(WIFI_ERROR, "Deinit failed"); //LCOV_EXCL_LINE - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE - } - - wifi_unset_rssi_level_changed_cb(); - _wifi_callback_cleanup(); - - _wifi_dbus_deinit(); - - WIFI_LOG(WIFI_INFO, "Wi-Fi successfully de-initialized"); - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_activate(wifi_activated_cb callback, void* user_data) { - int rv; - DEPRECATED_LOG(__FUNCTION__, "wifi_manager_activate"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); - return WIFI_ERROR_INVALID_OPERATION; - } - - rv = _wifi_activate(callback, FALSE, user_data); - if (rv != WIFI_ERROR_NONE) - WIFI_LOG(WIFI_ERROR, "Failed to activate Wi-Fi[%d]", rv); //LCOV_EXCL_LINE - - return rv; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_activate_with_wifi_picker_tested( wifi_activated_cb callback, void* user_data) { - int rv; - DEPRECATED_LOG(__FUNCTION__, "wifi_manager_activate_with_wifi_picker_tested"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - rv = _wifi_activate(callback, TRUE, user_data); - if (rv != WIFI_ERROR_NONE) - WIFI_LOG(WIFI_ERROR, "Failed to activate Wi-Fi[%d]", rv); //LCOV_EXCL_LINE - - return rv; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_deactivate(wifi_deactivated_cb callback, void* user_data) { - int rv; - DEPRECATED_LOG(__FUNCTION__, "wifi_manager_deactivate"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - rv = _wifi_deactivate(callback, user_data); - if (rv != WIFI_ERROR_NONE) - WIFI_LOG(WIFI_ERROR, "Wi-Fi deactivation failed"); //LCOV_EXCL_LINE - - return rv; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_is_activated(bool* activated) { - int rv; - wifi_device_state_e device_state; - DEPRECATED_LOG(__FUNCTION__, "wifi_manager_is_activated"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (activated == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - rv = _wifi_libnet_get_wifi_device_state(&device_state); - if (rv == WIFI_ERROR_NONE) { - if (WIFI_DEVICE_STATE_DEACTIVATED == device_state) - *activated = false; - else - *activated = true; - } - - return rv; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_get_mac_address(char** mac_address) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_get_mac_address"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (mac_address == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - if (__builtin_expect(tv_profile == -1, 0)) { - char *profileName; - system_info_get_platform_string("http://tizen.org/feature/profile", &profileName); - if (*profileName == 't' || *profileName == 'T') - tv_profile = 1; - else - tv_profile = 0; - free(profileName); - } - if (tv_profile == 1) { - FILE *fp = NULL; - char buf[WIFI_MAC_ADD_LENGTH + 1]; - if (0 == access(WIFI_MAC_ADD_PATH, F_OK)) - fp = fopen(WIFI_MAC_ADD_PATH, "r"); - - if (fp == NULL) { - WIFI_LOG(WIFI_ERROR, "Failed to open file" //LCOV_EXCL_LINE - " %s\n", WIFI_MAC_ADD_PATH); - return WIFI_ERROR_OPERATION_FAILED; - } - - if (fgets(buf, sizeof(buf), fp) == NULL) { - WIFI_LOG(WIFI_ERROR, "Failed to get MAC" - " info from %s\n", WIFI_MAC_ADD_PATH); //LCOV_EXCL_LINE - fclose(fp); //LCOV_EXCL_LINE - return WIFI_ERROR_OPERATION_FAILED; - } - - WIFI_LOG(WIFI_INFO, "%s : %s\n", WIFI_MAC_ADD_PATH, buf); - - *mac_address = (char *)g_try_malloc0(WIFI_MAC_ADD_LENGTH + 1); - if (*mac_address == NULL) { - WIFI_LOG(WIFI_ERROR, "malloc() failed"); //LCOV_EXCL_LINE - fclose(fp); //LCOV_EXCL_LINE - return WIFI_ERROR_OUT_OF_MEMORY; - } - g_strlcpy(*mac_address, buf, WIFI_MAC_ADD_LENGTH + 1); - fclose(fp); - } else { - *mac_address = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS); - - if (*mac_address == NULL || strlen(*mac_address) == 0) { - WIFI_LOG(WIFI_ERROR, "Failed to get vconf" //LCOV_EXCL_LINE - " from %s", VCONFKEY_WIFI_BSSID_ADDRESS); - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE - } - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_get_network_interface_name(char** name) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_get_network_interface_name"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (name == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - return _wifi_libnet_get_intf_name(name); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_scan(wifi_scan_finished_cb callback, void* user_data) { - int rv; - DEPRECATED_LOG(__FUNCTION__, "wifi_manager_scan"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (callback == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - rv = _wifi_libnet_scan_request(callback, user_data); - if (rv != WIFI_ERROR_NONE) - WIFI_LOG(WIFI_ERROR, "Wi-Fi scan failed"); //LCOV_EXCL_LINE - - return rv; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_scan_specific_ap(const char* essid, wifi_scan_finished_cb callback, void* user_data) { - int rv; - DEPRECATED_LOG(__FUNCTION__, "wifi_manager_scan_specific_ap"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (essid == NULL || callback == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - rv = _wifi_libnet_scan_specific_ap(essid, callback, user_data); - if (rv != WIFI_ERROR_NONE) - WIFI_LOG(WIFI_ERROR, "Wi-Fi hidden scan failed.\n"); //LCOV_EXCL_LINE - - return rv; + return WIFI_ERROR_NOT_SUPPORTED; } - - EXPORT_API int wifi_get_connected_ap(wifi_ap_h *ap) { - int rv; - DEPRECATED_LOG(__FUNCTION__, "wifi_manager_get_connected_ap"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (ap == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - rv = _wifi_libnet_get_connected_profile(ap); - WIFI_LOG(WIFI_INFO, "Connected AP %p, rv %d", *ap, rv); - - return rv; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_foreach_found_aps(wifi_found_ap_cb callback, void* user_data) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_foreach_found_ap"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (callback == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - return _wifi_libnet_foreach_found_aps(callback, user_data); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_foreach_found_specific_aps(wifi_found_ap_cb callback, void* user_data) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_foreach_found_specific_ap"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (callback == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - return _wifi_libnet_foreach_found_specific_aps(callback, user_data); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_connect(wifi_ap_h ap, wifi_connected_cb callback, void* user_data) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_connect"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - if (_wifi_libnet_check_ap_validity(ap) == false) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - return _wifi_libnet_open_profile(ap, callback, user_data); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_connect_specific_ap(const char* essid, wifi_security_type_e sec_type, const char *passphrase, wifi_connected_cb callback, void* user_data) { - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); - return WIFI_ERROR_INVALID_OPERATION; - } - - if (essid == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - return _wifi_libnet_get_hidden_aps(essid, sec_type, passphrase, callback, - user_data); + DEPRECATED_LOG(__FUNCTION__, "wifi_manager_connect_hidden_ap"); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_disconnect(wifi_ap_h ap, wifi_disconnected_cb callback, void* user_data) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_disconnect"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - if (_wifi_libnet_check_ap_validity(ap) == false) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - return _wifi_libnet_close_profile(ap, callback, user_data); + return WIFI_ERROR_NOT_SUPPORTED; } -//LCOV_EXCL_START EXPORT_API int wifi_connect_by_wps_pbc(wifi_ap_h ap, wifi_connected_cb callback, void* user_data) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_connect_by_wps_pbc"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); - return WIFI_ERROR_INVALID_OPERATION; - } - - if (_wifi_libnet_check_ap_validity(ap) == false) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - return _wifi_libnet_connect_with_wps_pbc(ap, callback, user_data); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_connect_by_wps_pin(wifi_ap_h ap, const char *pin, wifi_connected_cb callback, void* user_data) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_connect_by_wps_pin"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); - return WIFI_ERROR_INVALID_OPERATION; - } - - if (_wifi_libnet_check_ap_validity(ap) == false) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - if (NULL == pin || 0 == strlen(pin) || strlen(pin) > NET_WLAN_MAX_WPSPIN_LEN) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - return _wifi_libnet_connect_with_wps_pin(ap, pin, callback, user_data); + return WIFI_ERROR_NOT_SUPPORTED; } -//LCOV_EXCL_STOP EXPORT_API int wifi_forget_ap(wifi_ap_h ap) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_forget_ap"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - if (_wifi_libnet_check_ap_validity(ap) == false) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - return _wifi_libnet_forget_ap(ap); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_get_connection_state(wifi_connection_state_e *connection_state) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_get_connection_state"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (connection_state == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - return _wifi_libnet_get_wifi_state(connection_state); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_set_device_state_changed_cb(wifi_device_state_changed_cb callback, void* user_data) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_set_device_state_changed_cb"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (callback == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - return _wifi_set_power_on_off_cb(callback, user_data); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_unset_device_state_changed_cb(void) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_unset_device_state_changed_cb"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - return _wifi_unset_power_on_off_cb(); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_set_background_scan_cb(wifi_scan_finished_cb callback, void* user_data) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_set_background_scan_cb"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (callback == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - return _wifi_set_background_scan_cb(callback, user_data); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_unset_background_scan_cb(void) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_unset_background_scan_cb"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - return _wifi_unset_background_scan_cb(); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_set_connection_state_changed_cb(wifi_connection_state_changed_cb callback, void* user_data) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_set_connection_state_changed_cb"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (callback == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - return _wifi_set_connection_state_cb(callback, user_data); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_unset_connection_state_changed_cb(void) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_unset_connection_state_changed_cb"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - return _wifi_unset_connection_state_cb(); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_set_rssi_level_changed_cb(wifi_rssi_level_changed_cb callback, void* user_data) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_set_rssi_level_changed_cb"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (callback == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - if (rssi_level_changed_cb == NULL) - vconf_notify_key_changed(VCONFKEY_WIFI_STRENGTH, __rssi_level_changed_cb, NULL); - else - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - - rssi_level_changed_cb = callback; - rssi_level_changed_user_data = user_data; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_unset_rssi_level_changed_cb(void) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_unset_rssi_level_changed_cb"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (rssi_level_changed_cb != NULL) - vconf_ignore_key_changed(VCONFKEY_WIFI_STRENGTH, __rssi_level_changed_cb); - else - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - - rssi_level_changed_cb = NULL; - rssi_level_changed_user_data = NULL; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } -//LCOV_EXCL_START EXPORT_API int wifi_tdls_disconnect(const char* peer_mac_addr) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_tdls_disconnect"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE); - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); - return WIFI_ERROR_INVALID_OPERATION; - } - - if (peer_mac_addr == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - int rv = 0; - rv = net_wifi_tdls_disconnect(peer_mac_addr); - - if (rv != NET_ERR_NONE) { - WIFI_LOG(WIFI_ERROR, "Failed to disconnect tdls"); - return WIFI_ERROR_OPERATION_FAILED; - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_tdls_get_connected_peer(char** peer_mac_addr) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_tdls_get_connected_peer"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE); - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); - return WIFI_ERROR_INVALID_OPERATION; - } - - if (peer_mac_addr == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - int rv = 0; - rv = net_wifi_tdls_connected_peer(peer_mac_addr); - - if (rv != NET_ERR_NONE) { - WIFI_LOG(WIFI_ERROR, "Failed to get connected peer"); - return WIFI_ERROR_OPERATION_FAILED; - } - - if (g_strcmp0(*peer_mac_addr, "00.00.00.00.00.00") == 0) { - g_free(*peer_mac_addr); - return WIFI_ERROR_NO_CONNECTION; - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_tdls_set_state_changed_cb(wifi_tdls_state_changed_cb callback, void* user_data) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_tdls_set_state_changed_cb"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE); - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_tdls_unset_state_changed_cb(void) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_tdls_unset_state_changed_cb"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE); - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } -//LCOV_EXCL_STOP diff --git a/src/net_wifi_ap.c b/src/net_wifi_ap.c index 2731f0d..bda88bf 100755 --- a/src/net_wifi_ap.c +++ b/src/net_wifi_ap.c @@ -14,1676 +14,284 @@ * limitations under the License. */ -#include -#include -#include -#include -#include -#include - #include "net_wifi_private.h" -#define MAX_PREFIX_LENGTH 6 - -static char *__ap_convert_ip_to_string(net_addr_t *ip_addr, wifi_address_family_e address_family) -{ - unsigned char *ipaddr = NULL; - char *ipstr = NULL; - - if (address_family == WIFI_ADDRESS_FAMILY_IPV4) { - ipaddr = (unsigned char *)&ip_addr->Data.Ipv4.s_addr; - ipstr = g_try_malloc0(INET_ADDRSTRLEN); - if (ipstr == NULL) - return NULL; - - inet_ntop(AF_INET, ipaddr, ipstr, INET_ADDRSTRLEN); - } else { - //LCOV_EXCL_START - ipaddr = (unsigned char *)&ip_addr->Data.Ipv6; - ipstr = g_try_malloc0(INET6_ADDRSTRLEN); - if (ipstr == NULL) - return NULL; - - inet_ntop(AF_INET6, ipaddr, ipstr, INET6_ADDRSTRLEN); - //LCOV_EXCL_STOP - } - return ipstr; -} - -static void __wifi_init_ap(net_profile_info_t *profile_info, const char *essid) -{ - profile_info->profile_type = NET_DEVICE_WIFI; - profile_info->ProfileState = NET_STATE_TYPE_IDLE; - profile_info->ProfileInfo.Wlan.net_info.IpConfigType = NET_IP_CONFIG_TYPE_OFF; - profile_info->ProfileInfo.Wlan.net_info.ProxyMethod = NET_PROXY_TYPE_DIRECT; - profile_info->ProfileInfo.Wlan.wlan_mode = NETPM_WLAN_CONNMODE_AUTO; - profile_info->ProfileInfo.Wlan.security_info.sec_mode = WLAN_SEC_MODE_NONE; - profile_info->ProfileInfo.Wlan.security_info.enc_mode = WLAN_ENC_MODE_NONE; - g_strlcpy(profile_info->ProfileInfo.Wlan.essid, essid, NET_WLAN_ESSID_LEN+1); -} - -static char *__wifi_create_profile_name(const char *ssid, const int net_mode, const int sec_mode) -{ - char *buf = NULL; - char *pbuf = NULL; - const char *hidden_str = "hidden"; - char buf_tmp[32] = { 0, }; - int i; - int ssid_len = 0; - int actual_len = 0; - const char *mode = "managed"; - char *g_sec = NULL; - - if (net_mode == NETPM_WLAN_CONNMODE_ADHOC) { - WIFI_LOG(WIFI_ERROR, "wlan_mode is adhoc"); //LCOV_EXCL_LINE - return NULL; //LCOV_EXCL_LINE - } - - switch (sec_mode) { - //LCOV_EXCL_START - case WLAN_SEC_MODE_NONE: - g_sec = "none"; - break; - case WLAN_SEC_MODE_WEP: - g_sec = "wep"; - break; - case WLAN_SEC_MODE_WPA_PSK: - case WLAN_SEC_MODE_WPA2_PSK: - g_sec = "psk"; - break; - case WLAN_SEC_MODE_IEEE8021X: - g_sec = "ieee8021x"; - break; - default: - WIFI_LOG(WIFI_ERROR, "Invalid security type"); - return NULL; - //LCOV_EXCL_STOP - } - - if (NULL != ssid) { - ssid_len = strlen(ssid); - actual_len = ssid_len * 2; - } else { - ssid_len = strlen(hidden_str); - actual_len = ssid_len; - } - - buf = g_try_malloc0(actual_len + strlen(mode) + strlen(g_sec) + 3); - if (buf == NULL) - return NULL; - - if (NULL != ssid) { - pbuf = buf; - - for (i = 0; i < ssid_len; i++) { - g_snprintf(pbuf, 3, "%02x", ssid[i]); - pbuf += 2; - } - } else - g_strlcat(buf, hidden_str, - actual_len + strlen(mode) + strlen(g_sec) + 3); - - g_snprintf(buf_tmp, 32, "_%s_%s", mode, g_sec); - g_strlcat(buf, buf_tmp, - actual_len + strlen(mode) + strlen(g_sec) + 3); - - WIFI_LOG(WIFI_INFO, "Profile name: %s", buf); - - return buf; -} - -static bool _wifi_set_profile_name_to_ap(net_profile_info_t *ap_info) -{ - char *profile_name = NULL; - - if (ap_info == NULL) { - WIFI_LOG(WIFI_ERROR, "profile_info is NULL"); //LCOV_EXCL_LINE - return false; //LCOV_EXCL_LINE - } - - profile_name = __wifi_create_profile_name( - ap_info->ProfileInfo.Wlan.is_hidden == TRUE ? - NULL : ap_info->ProfileInfo.Wlan.essid, - ap_info->ProfileInfo.Wlan.wlan_mode, - ap_info->ProfileInfo.Wlan.security_info.sec_mode); - if (profile_name == NULL) { - WIFI_LOG(WIFI_ERROR, "Failed to make a group name"); //LCOV_EXCL_LINE - return false; //LCOV_EXCL_LINE - } - - g_strlcpy(ap_info->ProfileInfo.Wlan.net_info.ProfileName, - profile_name, NET_PROFILE_NAME_LEN_MAX); - - g_free(profile_name); - - return true; -} - -wifi_connection_state_e _wifi_convert_to_ap_state(net_state_type_t state) -{ - wifi_connection_state_e ap_state; - - switch (state) { - case NET_STATE_TYPE_ONLINE: - case NET_STATE_TYPE_READY: - ap_state = WIFI_CONNECTION_STATE_CONNECTED; - break; - case NET_STATE_TYPE_FAILURE: - ap_state = WIFI_CONNECTION_STATE_FAILURE; - break; - case NET_STATE_TYPE_IDLE: - case NET_STATE_TYPE_DISCONNECT: - ap_state = WIFI_CONNECTION_STATE_DISCONNECTED; - break; - case NET_STATE_TYPE_ASSOCIATION: - ap_state = WIFI_CONNECTION_STATE_ASSOCIATION; - break; - case NET_STATE_TYPE_CONFIGURATION: - ap_state = WIFI_CONNECTION_STATE_CONFIGURATION; - break; - default: - ap_state = -1; - break; - } - - return ap_state; -} - /* Wi-Fi AP ******************************************************************/ EXPORT_API int wifi_ap_create(const char* essid, wifi_ap_h* ap) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_create"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (essid == NULL || ap == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *ap_info = g_try_malloc0(sizeof(net_profile_info_t)); - if (ap_info == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; - - __wifi_init_ap(ap_info, essid); - - _wifi_libnet_add_to_ap_list((wifi_ap_h)ap_info); - *ap = (wifi_ap_h)ap_info; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_hidden_create(const char* essid, wifi_ap_h* ap) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_hidden_create"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (essid == NULL || ap == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *ap_info = g_try_malloc0(sizeof(net_profile_info_t)); - if (ap_info == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE - - __wifi_init_ap(ap_info, essid); - ap_info->ProfileInfo.Wlan.is_hidden = TRUE; - - _wifi_libnet_add_to_ap_list((wifi_ap_h)ap_info); - *ap = (wifi_ap_h)ap_info; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_destroy(wifi_ap_h ap) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_destroy"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - _wifi_libnet_remove_from_ap_list(ap); - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_clone(wifi_ap_h* cloned_ap, wifi_ap_h origin) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_clone"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(origin) == false || cloned_ap == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *ap_info = g_try_malloc0(sizeof(net_profile_info_t)); - if (ap_info == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE - - memcpy(ap_info, origin, sizeof(net_profile_info_t)); - - _wifi_libnet_add_to_ap_list((wifi_ap_h)ap_info); - *cloned_ap = (wifi_ap_h)ap_info; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_refresh(wifi_ap_h ap) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_refresh"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - net_profile_info_t ap_info_local; - net_profile_info_t *ap_info = ap; - - if (_wifi_libnet_check_ap_validity(ap) == false) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - int rv = NET_ERR_NONE; - rv = net_get_profile_info(ap_info->ProfileName, &ap_info_local); - if (rv == NET_ERR_ACCESS_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } else if (rv != NET_ERR_NONE) { - WIFI_LOG(WIFI_ERROR, "Failed to getprofile_info"); //LCOV_EXCL_LINE - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE - } - - memcpy(ap, &ap_info_local, sizeof(net_profile_info_t)); - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } /* Wi-Fi network information *************************************************/ EXPORT_API int wifi_ap_get_essid(wifi_ap_h ap, char** essid) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_essid"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || essid == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - *essid = g_strdup(profile_info->ProfileInfo.Wlan.essid); - if (*essid == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_bssid(wifi_ap_h ap, char** bssid) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_bssid"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || bssid == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - *bssid = g_strdup(profile_info->ProfileInfo.Wlan.bssid); - if (*bssid == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_rssi(wifi_ap_h ap, int* rssi) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_rssi"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || rssi == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - *rssi = (int)(profile_info->ProfileInfo.Wlan.Strength - 120); - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_frequency(wifi_ap_h ap, int* frequency) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_frequency"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || frequency == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - *frequency = (int)profile_info->ProfileInfo.Wlan.frequency; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_max_speed(wifi_ap_h ap, int* max_speed) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_max_speed"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || max_speed == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - *max_speed = (int)profile_info->ProfileInfo.Wlan.max_rate / 1000000; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_is_favorite(wifi_ap_h ap, bool* favorite) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_is_favorite"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || favorite == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - - if (profile_info->Favourite) - *favorite = true; - else - *favorite = false; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_is_passpoint(wifi_ap_h ap, bool* passpoint) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_is_passpoint"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || passpoint == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - - if (profile_info->ProfileInfo.Wlan.passpoint) - *passpoint = true; - else - *passpoint = false; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_connection_state(wifi_ap_h ap, wifi_connection_state_e* state) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_connection_state"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || state == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - - *state = _wifi_convert_to_ap_state(profile_info->ProfileState); - - if (*state < 0) - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_ip_config_type(wifi_ap_h ap, wifi_address_family_e address_family, wifi_ip_config_type_e* type) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_ip_config_type"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - net_ip_config_type_t profileType ; - - if (_wifi_libnet_check_ap_validity(ap) == false || - (address_family != WIFI_ADDRESS_FAMILY_IPV4 && - address_family != WIFI_ADDRESS_FAMILY_IPV6) || - type == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - - if (address_family == WIFI_ADDRESS_FAMILY_IPV4) - profileType = profile_info->ProfileInfo.Wlan.net_info.IpConfigType ; - else - profileType = profile_info->ProfileInfo.Wlan.net_info.IpConfigType6 ; //LCOV_EXCL_LINE - - if (address_family == WIFI_ADDRESS_FAMILY_IPV4) { - switch (profileType) { - //LCOV_EXCL_START - case NET_IP_CONFIG_TYPE_STATIC: - *type = WIFI_IP_CONFIG_TYPE_STATIC; - break; - - case NET_IP_CONFIG_TYPE_DYNAMIC: - *type = WIFI_IP_CONFIG_TYPE_DYNAMIC; - break; - - case NET_IP_CONFIG_TYPE_AUTO_IP: - *type = WIFI_IP_CONFIG_TYPE_AUTO; - break; - - case NET_IP_CONFIG_TYPE_FIXED: - *type = WIFI_IP_CONFIG_TYPE_FIXED; - break; - - case NET_IP_CONFIG_TYPE_OFF: - *type = WIFI_IP_CONFIG_TYPE_NONE; - break; - - default: - return WIFI_ERROR_OPERATION_FAILED; - //LCOV_EXCL_STOP - } - } else { - //LCOV_EXCL_START - switch (profileType) { - case NET_IP_CONFIG_TYPE_STATIC: - *type = WIFI_IP_CONFIG_TYPE_STATIC; - break; - case NET_IP_CONFIG_TYPE_AUTO_IP: - *type = WIFI_IP_CONFIG_TYPE_AUTO; - break; - case NET_IP_CONFIG_TYPE_OFF: - *type = WIFI_IP_CONFIG_TYPE_NONE; - break; - default: - return WIFI_ERROR_OPERATION_FAILED; - } - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_set_ip_config_type(wifi_ap_h ap, wifi_address_family_e address_family, wifi_ip_config_type_e type) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_ip_config_type"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - net_ip_config_type_t *profileType = NULL; - - if (_wifi_libnet_check_ap_validity(ap) == false || - (address_family != WIFI_ADDRESS_FAMILY_IPV4 && - address_family != WIFI_ADDRESS_FAMILY_IPV6)) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - int rv = _wifi_libnet_check_get_privilege(); - if (rv == WIFI_ERROR_PERMISSION_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return rv; - } - - rv = _wifi_libnet_check_profile_privilege(); - if (rv == WIFI_ERROR_PERMISSION_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return rv; - } - - net_profile_info_t *profile_info = ap; - - if (address_family == WIFI_ADDRESS_FAMILY_IPV4) - profileType = &profile_info->ProfileInfo.Wlan.net_info.IpConfigType ; - else - profileType = &profile_info->ProfileInfo.Wlan.net_info.IpConfigType6 ; - - if (address_family == WIFI_ADDRESS_FAMILY_IPV4) { - switch (type) { - //LCOV_EXCL_START - case WIFI_IP_CONFIG_TYPE_STATIC: - *profileType = NET_IP_CONFIG_TYPE_STATIC; - profile_info->ProfileInfo.Wlan.net_info.IpAddr.Data.Ipv4.s_addr = 0; - profile_info->ProfileInfo.Wlan.net_info.SubnetMask.Data.Ipv4.s_addr = 0; - profile_info->ProfileInfo.Wlan.net_info.GatewayAddr.Data.Ipv4.s_addr = 0 ; - break; - - case WIFI_IP_CONFIG_TYPE_DYNAMIC: - *profileType = NET_IP_CONFIG_TYPE_DYNAMIC; - break; - - case WIFI_IP_CONFIG_TYPE_AUTO: - *profileType = NET_IP_CONFIG_TYPE_AUTO_IP; - break; - - case WIFI_IP_CONFIG_TYPE_FIXED: - *profileType = NET_IP_CONFIG_TYPE_FIXED; - break; - - case WIFI_IP_CONFIG_TYPE_NONE: - *profileType = NET_IP_CONFIG_TYPE_OFF; - break; - - default: - return WIFI_ERROR_INVALID_PARAMETER; - //LCOV_EXCL_STOP - } - } else { - //LCOV_EXCL_START - switch (type) { - case WIFI_IP_CONFIG_TYPE_STATIC: - *profileType = NET_IP_CONFIG_TYPE_STATIC; - inet_pton(AF_INET6, "::", &profile_info->ProfileInfo.Wlan.net_info.IpAddr6.Data.Ipv6); - profile_info->ProfileInfo.Wlan.net_info.PrefixLen6 = 0 ; - inet_pton(AF_INET6, "::", &profile_info->ProfileInfo.Wlan.net_info.GatewayAddr6.Data.Ipv6); - break; - case WIFI_IP_CONFIG_TYPE_AUTO: - *profileType = NET_IP_CONFIG_TYPE_AUTO_IP; - break; - case WIFI_IP_CONFIG_TYPE_NONE: - *profileType = NET_IP_CONFIG_TYPE_OFF; - break; - default: - return WIFI_ERROR_INVALID_PARAMETER; - } - //LCOV_EXCL_STOP - } - - if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false) - return WIFI_ERROR_NONE; - - return _wifi_update_ap_info(profile_info); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_ip_address(wifi_ap_h ap, wifi_address_family_e address_family, char** ip_address) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_ip_address"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || - (address_family != WIFI_ADDRESS_FAMILY_IPV4 && - address_family != WIFI_ADDRESS_FAMILY_IPV6) || - ip_address == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - if (address_family == WIFI_ADDRESS_FAMILY_IPV4) - *ip_address = __ap_convert_ip_to_string( - &profile_info->ProfileInfo.Wlan.net_info.IpAddr, - address_family); - else - *ip_address = __ap_convert_ip_to_string( - &profile_info->ProfileInfo.Wlan.net_info.IpAddr6, - address_family); - - if (*ip_address == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_set_ip_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* ip_address) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_ip_address"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || - (address_family != WIFI_ADDRESS_FAMILY_IPV4 && - address_family != WIFI_ADDRESS_FAMILY_IPV6)) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - int rv = _wifi_libnet_check_get_privilege(); - if (rv == WIFI_ERROR_PERMISSION_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return rv; - } - - rv = _wifi_libnet_check_profile_privilege(); - if (rv == WIFI_ERROR_PERMISSION_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return rv; - } - - net_profile_info_t *profile_info = ap; - - if (address_family == WIFI_ADDRESS_FAMILY_IPV4) { - if (ip_address == NULL) - profile_info->ProfileInfo.Wlan.net_info.IpAddr.Data.Ipv4.s_addr = 0; - else if (inet_aton(ip_address, - &(profile_info->ProfileInfo.Wlan.net_info.IpAddr.Data.Ipv4)) == 0) - return WIFI_ERROR_INVALID_PARAMETER; - } else { - //LCOV_EXCL_START - if (ip_address == NULL) - inet_pton(AF_INET6, "::", - &profile_info->ProfileInfo.Wlan.net_info.IpAddr6.Data.Ipv6); - else if (inet_pton(AF_INET6, ip_address, - &profile_info->ProfileInfo.Wlan.net_info.IpAddr6.Data.Ipv6) == 0) - return WIFI_ERROR_INVALID_PARAMETER; - //LCOV_EXCL_STOP - } - - if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false) - return WIFI_ERROR_NONE; - - return _wifi_update_ap_info(profile_info); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_subnet_mask(wifi_ap_h ap, wifi_address_family_e address_family, char** subnet_mask) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_subnet_mask"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - char* prefixlen; - - if (_wifi_libnet_check_ap_validity(ap) == false || - (address_family != WIFI_ADDRESS_FAMILY_IPV4 && - address_family != WIFI_ADDRESS_FAMILY_IPV6) || - subnet_mask == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - if (address_family == WIFI_ADDRESS_FAMILY_IPV4) - *subnet_mask = __ap_convert_ip_to_string( - &profile_info->ProfileInfo.Wlan.net_info.SubnetMask, - address_family); - else { - //LCOV_EXCL_START - prefixlen = g_try_malloc0(MAX_PREFIX_LENGTH); - if (prefixlen != NULL) { - snprintf(prefixlen, MAX_PREFIX_LENGTH, "%d", - profile_info->ProfileInfo.Wlan.net_info.PrefixLen6); - *subnet_mask = prefixlen; - } else - *subnet_mask = NULL; - //LCOV_EXCL_STOP - } - - if (*subnet_mask == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_set_subnet_mask(wifi_ap_h ap, wifi_address_family_e address_family, const char* subnet_mask) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_subnet_mask"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || - (address_family != WIFI_ADDRESS_FAMILY_IPV4 && - address_family != WIFI_ADDRESS_FAMILY_IPV6)) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - int rv = _wifi_libnet_check_get_privilege(); - if (rv == WIFI_ERROR_PERMISSION_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return rv; - } - - rv = _wifi_libnet_check_profile_privilege(); - if (rv == WIFI_ERROR_PERMISSION_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return rv; - } - - net_profile_info_t *profile_info = ap; - - /* Based on the family of address provided subnet mask should be set. - * For IPv6 address subnet mask is prefix length, an integer, while for - * Ipv6 address subnet mask is a ipv6 address. - */ - if (address_family == WIFI_ADDRESS_FAMILY_IPV6) { - //LCOV_EXCL_START - if (subnet_mask == NULL) - profile_info->ProfileInfo.Wlan.net_info.PrefixLen6 = 0; - else { - /* subnet mask provided as input parameter is a string - * while for IPv6 address subnet mask in prefix length - * which should be in integer form */ - profile_info->ProfileInfo.Wlan.net_info.PrefixLen6 = - atoi(subnet_mask) ; - } - //LCOV_EXCL_STOP - } else { - if (subnet_mask == NULL) - profile_info->ProfileInfo.Wlan.net_info.SubnetMask.Data.Ipv4.s_addr = 0; - else if (inet_pton(AF_INET, subnet_mask, - &(profile_info->ProfileInfo.Wlan.net_info.SubnetMask.Data.Ipv4)) < 1) - return WIFI_ERROR_INVALID_PARAMETER; - } - - - if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false) - return WIFI_ERROR_NONE; - - return _wifi_update_ap_info(profile_info); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_gateway_address(wifi_ap_h ap, wifi_address_family_e address_family, char** gateway_address) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_gateway_address"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || - (address_family != WIFI_ADDRESS_FAMILY_IPV4 && - address_family != WIFI_ADDRESS_FAMILY_IPV6) || - gateway_address == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - - /* Based on the family of address provided, gateway should be set. - * For IPv6 address gateway is of form GatewayAddr6 but for IPv4 - * gateway is of form GatewayAddr. - */ - if (address_family == WIFI_ADDRESS_FAMILY_IPV4) - *gateway_address = __ap_convert_ip_to_string( - &profile_info->ProfileInfo.Wlan.net_info.GatewayAddr, - address_family); - else - *gateway_address = __ap_convert_ip_to_string( //LCOV_EXCL_LINE - &profile_info->ProfileInfo.Wlan.net_info.GatewayAddr6, - address_family); - - if (*gateway_address == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_set_gateway_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* gateway_address) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_gateway_address"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || - (address_family != WIFI_ADDRESS_FAMILY_IPV4 && - address_family != WIFI_ADDRESS_FAMILY_IPV6)) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - int rv = _wifi_libnet_check_get_privilege(); - if (rv == WIFI_ERROR_PERMISSION_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return rv; - } - - rv = _wifi_libnet_check_profile_privilege(); - if (rv == WIFI_ERROR_PERMISSION_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return rv; - } - - net_profile_info_t *profile_info = ap; - if (address_family == WIFI_ADDRESS_FAMILY_IPV6) { - //LCOV_EXCL_START - if (gateway_address == NULL) - inet_pton(AF_INET6, "::", - &profile_info->ProfileInfo.Wlan.net_info.GatewayAddr6.Data.Ipv6); - else if (inet_pton(AF_INET6, gateway_address, - &profile_info->ProfileInfo.Wlan.net_info.GatewayAddr6.Data.Ipv6) < 1) - return WIFI_ERROR_INVALID_PARAMETER; - //LCOV_EXCL_STOP - } else { - if (gateway_address == NULL) - profile_info->ProfileInfo.Wlan.net_info.GatewayAddr.Data.Ipv4.s_addr = 0; - else if (inet_pton(AF_INET, gateway_address, - &profile_info->ProfileInfo.Wlan.net_info.GatewayAddr.Data.Ipv4) < 1) - return WIFI_ERROR_INVALID_PARAMETER; - } - - if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false) - return WIFI_ERROR_NONE; - - return _wifi_update_ap_info(profile_info); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_proxy_address(wifi_ap_h ap, wifi_address_family_e address_family, char** proxy_address) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_proxy_address"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || - (address_family != WIFI_ADDRESS_FAMILY_IPV4 && - address_family != WIFI_ADDRESS_FAMILY_IPV6) || - proxy_address == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - *proxy_address = g_strdup(profile_info->ProfileInfo.Wlan.net_info.ProxyAddr); - if (*proxy_address == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_set_proxy_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* proxy_address) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_proxy_address"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || - (address_family != WIFI_ADDRESS_FAMILY_IPV4 && - address_family != WIFI_ADDRESS_FAMILY_IPV6)) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - int rv = _wifi_libnet_check_get_privilege(); - if (rv == WIFI_ERROR_PERMISSION_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return rv; - } - - rv = _wifi_libnet_check_profile_privilege(); - if (rv == WIFI_ERROR_PERMISSION_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return rv; - } - - net_profile_info_t *profile_info = ap; - - if (proxy_address == NULL) - profile_info->ProfileInfo.Wlan.net_info.ProxyAddr[0] = '\0'; - else - g_strlcpy(profile_info->ProfileInfo.Wlan.net_info.ProxyAddr, - proxy_address, NET_PROXY_LEN_MAX+1); - - if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false) - return WIFI_ERROR_NONE; - - return _wifi_update_ap_info(profile_info); + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_proxy_type(wifi_ap_h ap, wifi_proxy_type_e* type) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_proxy_type"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || type == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - - switch (profile_info->ProfileInfo.Wlan.net_info.ProxyMethod) { - //LCOV_EXCL_START - case NET_PROXY_TYPE_DIRECT: - *type = WIFI_PROXY_TYPE_DIRECT; - break; - case NET_PROXY_TYPE_AUTO: - *type = WIFI_PROXY_TYPE_AUTO; - break; - case NET_PROXY_TYPE_MANUAL: - *type = WIFI_PROXY_TYPE_MANUAL; - break; - case NET_PROXY_TYPE_UNKNOWN: - *type = WIFI_PROXY_TYPE_DIRECT; - break; - default: - return WIFI_ERROR_OPERATION_FAILED; - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_set_proxy_type(wifi_ap_h ap, wifi_proxy_type_e proxy_type) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_proxy_type"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - int rv = _wifi_libnet_check_get_privilege(); - if (rv == WIFI_ERROR_PERMISSION_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return rv; - } - - rv = _wifi_libnet_check_profile_privilege(); - if (rv == WIFI_ERROR_PERMISSION_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return rv; - } - - net_profile_info_t *profile_info = ap; - - switch (proxy_type) { - //LCOV_EXCL_START - case WIFI_PROXY_TYPE_DIRECT: - profile_info->ProfileInfo.Wlan.net_info.ProxyMethod = NET_PROXY_TYPE_DIRECT; - break; - case WIFI_PROXY_TYPE_AUTO: - profile_info->ProfileInfo.Wlan.net_info.ProxyAddr[0] = '\0'; - profile_info->ProfileInfo.Wlan.net_info.ProxyMethod = NET_PROXY_TYPE_AUTO; - break; - case WIFI_PROXY_TYPE_MANUAL: - profile_info->ProfileInfo.Wlan.net_info.ProxyAddr[0] = '\0'; - profile_info->ProfileInfo.Wlan.net_info.ProxyMethod = NET_PROXY_TYPE_MANUAL; - break; - default: - return WIFI_ERROR_INVALID_PARAMETER; - //LCOV_EXCL_STOP - } - - if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false) - return WIFI_ERROR_NONE; - - rv = _wifi_update_ap_info(profile_info); - if (rv != NET_ERR_NONE && proxy_type == WIFI_PROXY_TYPE_MANUAL) { - g_strlcpy(profile_info->ProfileInfo.Wlan.net_info.ProxyAddr, "0.0.0.0:8080", 15); - rv = _wifi_update_ap_info(profile_info); - } - - return rv; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_dns_address(wifi_ap_h ap, int order, wifi_address_family_e address_family, char** dns_address) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_dns_address"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || - (address_family != WIFI_ADDRESS_FAMILY_IPV4 && - address_family != WIFI_ADDRESS_FAMILY_IPV6) || - dns_address == NULL || - order <= 0 || - order > NET_DNS_ADDR_MAX) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - - if (address_family == WIFI_ADDRESS_FAMILY_IPV4) - *dns_address = __ap_convert_ip_to_string( - &profile_info->ProfileInfo.Wlan.net_info.DnsAddr[order-1], - address_family); - else - *dns_address = __ap_convert_ip_to_string( //LCOV_EXCL_LINE - &profile_info->ProfileInfo.Wlan.net_info.DnsAddr6[order-1], - address_family); - - if (*dns_address == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_set_dns_address(wifi_ap_h ap, int order, wifi_address_family_e address_family, const char* dns_address) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_dns_address"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || - (address_family != WIFI_ADDRESS_FAMILY_IPV4 && - address_family != WIFI_ADDRESS_FAMILY_IPV6) || - order <= 0 || - order > NET_DNS_ADDR_MAX) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - int rv = _wifi_libnet_check_get_privilege(); - if (rv == WIFI_ERROR_PERMISSION_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return rv; - } - - rv = _wifi_libnet_check_profile_privilege(); - if (rv == WIFI_ERROR_PERMISSION_DENIED) { - WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE - return rv; - } - - net_profile_info_t *profile_info = ap; - - if (address_family == WIFI_ADDRESS_FAMILY_IPV6) { - //LCOV_EXCL_START - profile_info->ProfileInfo.Wlan.net_info.DnsAddr6[order-1].Type = - NET_ADDR_IPV6; - if (dns_address == NULL) - inet_pton(AF_INET6, "::", - &profile_info->ProfileInfo.Wlan.net_info.DnsAddr6[order-1].Data.Ipv6); - else if (inet_pton(AF_INET6, dns_address, - &profile_info->ProfileInfo.Wlan.net_info.DnsAddr6[order-1].Data.Ipv6) < 1) - return WIFI_ERROR_INVALID_PARAMETER; - - if (profile_info->ProfileInfo.Wlan.net_info.DnsCount6 < order) - profile_info->ProfileInfo.Wlan.net_info.DnsCount6 = order; - //LCOV_EXCL_STOP - } else { - profile_info->ProfileInfo.Wlan.net_info.DnsAddr[order-1].Type = - NET_ADDR_IPV4; - if (dns_address == NULL) - profile_info->ProfileInfo.Wlan.net_info.DnsAddr[order-1].Data.Ipv4.s_addr = 0; - else if (inet_pton(AF_INET, dns_address, - &(profile_info->ProfileInfo.Wlan.net_info.DnsAddr[order-1].Data.Ipv4)) < 1) - return WIFI_ERROR_INVALID_PARAMETER; - - if (profile_info->ProfileInfo.Wlan.net_info.DnsCount < order) - profile_info->ProfileInfo.Wlan.net_info.DnsCount = order; - } - - if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false) - return WIFI_ERROR_NONE; - - return _wifi_update_ap_info(profile_info); + return WIFI_ERROR_NOT_SUPPORTED; } /* Wi-Fi security information ************************************************/ EXPORT_API int wifi_ap_get_security_type(wifi_ap_h ap, wifi_security_type_e* type) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_security_type"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || type == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - - switch (profile_info->ProfileInfo.Wlan.security_info.sec_mode) { - //LCOV_EXCL_START - case WLAN_SEC_MODE_NONE: - *type = WIFI_SECURITY_TYPE_NONE; - break; - case WLAN_SEC_MODE_WEP: - *type = WIFI_SECURITY_TYPE_WEP; //LCOV_EXCL_LINE - break; - case WLAN_SEC_MODE_IEEE8021X: - *type = WIFI_SECURITY_TYPE_EAP; //LCOV_EXCL_LINE - break; - case WLAN_SEC_MODE_WPA_PSK: - *type = WIFI_SECURITY_TYPE_WPA_PSK; //LCOV_EXCL_LINE - break; - case WLAN_SEC_MODE_WPA2_PSK: - *type = WIFI_SECURITY_TYPE_WPA2_PSK; //LCOV_EXCL_LINE - break; - default: - return WIFI_ERROR_OPERATION_FAILED; - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_set_security_type(wifi_ap_h ap, wifi_security_type_e type) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_security_type"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - - switch (type) { - //LCOV_EXCL_START - case WIFI_SECURITY_TYPE_NONE: - profile_info->ProfileInfo.Wlan.security_info.sec_mode = WLAN_SEC_MODE_NONE; //LCOV_EXCL_LINE - break; - case WIFI_SECURITY_TYPE_WEP: - profile_info->ProfileInfo.Wlan.security_info.sec_mode = WLAN_SEC_MODE_WEP; //LCOV_EXCL_LINE - break; - case WIFI_SECURITY_TYPE_EAP: - profile_info->ProfileInfo.Wlan.security_info.sec_mode = WLAN_SEC_MODE_IEEE8021X; - break; - case WIFI_SECURITY_TYPE_WPA_PSK: - profile_info->ProfileInfo.Wlan.security_info.sec_mode = WLAN_SEC_MODE_WPA_PSK; //LCOV_EXCL_LINE - break; - case WIFI_SECURITY_TYPE_WPA2_PSK: - profile_info->ProfileInfo.Wlan.security_info.sec_mode = WLAN_SEC_MODE_WPA2_PSK; - break; - default: - return WIFI_ERROR_INVALID_PARAMETER; - //LCOV_EXCL_STOP - } - - _wifi_set_profile_name_to_ap(profile_info); - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_encryption_type(wifi_ap_h ap, wifi_encryption_type_e* type) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_encryption_type"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || type == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - - switch (profile_info->ProfileInfo.Wlan.security_info.enc_mode) { - //LCOV_EXCL_START - case WLAN_ENC_MODE_NONE: - *type = WIFI_ENCRYPTION_TYPE_NONE; - break; - case WLAN_ENC_MODE_WEP: - *type = WIFI_ENCRYPTION_TYPE_WEP; //LCOV_EXCL_LINE - break; - case WLAN_ENC_MODE_TKIP: - *type = WIFI_ENCRYPTION_TYPE_TKIP; //LCOV_EXCL_LINE - break; - case WLAN_ENC_MODE_AES: - *type = WIFI_ENCRYPTION_TYPE_AES; //LCOV_EXCL_LINE - break; - case WLAN_ENC_MODE_TKIP_AES_MIXED: - *type = WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED; //LCOV_EXCL_LINE - break; - default: - return WIFI_ERROR_OPERATION_FAILED; - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_set_encryption_type(wifi_ap_h ap, wifi_encryption_type_e type) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_encryption_type"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - - switch (type) { - //LCOV_EXCL_START - case WIFI_ENCRYPTION_TYPE_NONE: - profile_info->ProfileInfo.Wlan.security_info.enc_mode = WLAN_ENC_MODE_NONE; //LCOV_EXCL_LINE - break; - case WIFI_ENCRYPTION_TYPE_WEP: - profile_info->ProfileInfo.Wlan.security_info.enc_mode = WLAN_ENC_MODE_WEP; //LCOV_EXCL_LINE - break; - case WIFI_ENCRYPTION_TYPE_TKIP: - profile_info->ProfileInfo.Wlan.security_info.enc_mode = WLAN_ENC_MODE_TKIP; //LCOV_EXCL_LINE - break; - case WIFI_ENCRYPTION_TYPE_AES: - profile_info->ProfileInfo.Wlan.security_info.enc_mode = WLAN_ENC_MODE_AES; - break; - case WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED: - profile_info->ProfileInfo.Wlan.security_info.enc_mode = WLAN_ENC_MODE_TKIP_AES_MIXED; //LCOV_EXCL_LINE - break; - default: - return WIFI_ERROR_INVALID_PARAMETER; - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_is_passphrase_required(wifi_ap_h ap, bool* required) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_is_passphrase_required"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || required == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - - if (profile_info->Favourite) { - *required = false; - return WIFI_ERROR_NONE; - } - - switch (profile_info->ProfileInfo.Wlan.security_info.sec_mode) { - //LCOV_EXCL_START - case WLAN_SEC_MODE_NONE: - *required = false; - break; - case WLAN_SEC_MODE_WEP: - case WLAN_SEC_MODE_IEEE8021X: - case WLAN_SEC_MODE_WPA_PSK: - case WLAN_SEC_MODE_WPA2_PSK: - *required = true; - break; - default: - return WIFI_ERROR_OPERATION_FAILED; - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_set_passphrase(wifi_ap_h ap, const char* passphrase) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_passphrase"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || passphrase == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - - switch (profile_info->ProfileInfo.Wlan.security_info.sec_mode) { - //LCOV_EXCL_START - case WLAN_SEC_MODE_WEP: - g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.wep.wepKey, - passphrase, NETPM_WLAN_MAX_WEP_KEY_LEN+1); - break; - case WLAN_SEC_MODE_WPA_PSK: - case WLAN_SEC_MODE_WPA2_PSK: - g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.psk.pskKey, - passphrase, NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN+1); - break; - case WLAN_SEC_MODE_NONE: - case WLAN_SEC_MODE_IEEE8021X: - default: - return WIFI_ERROR_OPERATION_FAILED; - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_is_wps_supported(wifi_ap_h ap, bool* supported) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_is_wps_supported"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || supported == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - - if (profile_info->ProfileInfo.Wlan.security_info.wps_support) - *supported = true; - else - *supported = false; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } /* Wi-Fi EAP *****************************************************************/ EXPORT_API int wifi_ap_set_eap_passphrase(wifi_ap_h ap, const char* user_name, const char* password) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_eap_passphrase"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || (user_name == NULL && password == NULL)) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) - return WIFI_ERROR_INVALID_OPERATION; - - if (user_name) - g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.username, - user_name, NETPM_WLAN_USERNAME_LEN+1); - - if (password) - g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.password, - password, NETPM_WLAN_PASSWORD_LEN+1); - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_eap_passphrase(wifi_ap_h ap, char** user_name, bool* is_password_set) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_eap_passphrase"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || user_name == NULL || is_password_set == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) - return WIFI_ERROR_INVALID_OPERATION; - - *user_name = g_strdup(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.username); - if (*user_name == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; - - if (strlen(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.password) > 0) - *is_password_set = true; - else - *is_password_set = false; - - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_eap_ca_cert_file(wifi_ap_h ap, char** file) { - net_profile_info_t *profile_info = NULL; - DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_eap_ca_cert_file"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - profile_info = (net_profile_info_t *)ap; - if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) - return WIFI_ERROR_INVALID_OPERATION; - - *file = g_strdup(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.ca_cert_filename); - if (*file == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_set_eap_ca_cert_file(wifi_ap_h ap, const char* file) { - net_profile_info_t *profile_info = NULL; - DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_eap_ca_cert_file"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - profile_info = (net_profile_info_t *)ap; - if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) - return WIFI_ERROR_INVALID_OPERATION; - - g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.ca_cert_filename, - file, NETPM_WLAN_CA_CERT_FILENAME_LEN+1); - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_eap_client_cert_file(wifi_ap_h ap, char** file) { - net_profile_info_t *profile_info = NULL; - DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_eap_client_cert_file"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - profile_info = (net_profile_info_t *)ap; - if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) - return WIFI_ERROR_INVALID_OPERATION; - - *file = g_strdup(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.client_cert_filename); - if (*file == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_set_eap_client_cert_file(wifi_ap_h ap, const char* file) { - net_profile_info_t *profile_info = NULL; - DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_eap_client_cert_file"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - profile_info = (net_profile_info_t *)ap; - if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) - return WIFI_ERROR_INVALID_OPERATION; - - g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.client_cert_filename, - file, NETPM_WLAN_CLIENT_CERT_FILENAME_LEN+1); - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_eap_private_key_file(wifi_ap_h ap, char** file) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_eap_private_key_file"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) - return WIFI_ERROR_INVALID_OPERATION; - - *file = g_strdup(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.private_key_filename); - if (*file == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_set_eap_private_key_info(wifi_ap_h ap, const char* file, const char* password) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_eap_private_key_info"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || file == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) - return WIFI_ERROR_INVALID_OPERATION; - - g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.private_key_filename, - file, NETPM_WLAN_PRIVATE_KEY_FILENAME_LEN+1); - - if (password) { - g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.eap.private_key_passwd, - password, NETPM_WLAN_PRIVATE_KEY_PASSWD_LEN+1); - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_eap_type(wifi_ap_h ap, wifi_eap_type_e* type) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_eap_type"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || type == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) - return WIFI_ERROR_INVALID_OPERATION; - - switch (profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_type) { - //LCOV_EXCL_START - case WLAN_SEC_EAP_TYPE_PEAP: - *type = WIFI_EAP_TYPE_PEAP; - break; - case WLAN_SEC_EAP_TYPE_TLS: - *type = WIFI_EAP_TYPE_TLS; - break; - case WLAN_SEC_EAP_TYPE_TTLS: - *type = WIFI_EAP_TYPE_TTLS; - break; - case WLAN_SEC_EAP_TYPE_SIM: - *type = WIFI_EAP_TYPE_SIM; - break; - case WLAN_SEC_EAP_TYPE_AKA: - *type = WIFI_EAP_TYPE_AKA; - break; - default: - return WIFI_ERROR_OPERATION_FAILED; - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_set_eap_type(wifi_ap_h ap, wifi_eap_type_e type) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_eap_type"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) - return WIFI_ERROR_INVALID_OPERATION; - - switch (type) { - //LCOV_EXCL_START - case WIFI_EAP_TYPE_PEAP: - profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_type = WLAN_SEC_EAP_TYPE_PEAP; - break; - case WIFI_EAP_TYPE_TLS: - profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_type = WLAN_SEC_EAP_TYPE_TLS; - break; - case WIFI_EAP_TYPE_TTLS: - profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_type = WLAN_SEC_EAP_TYPE_TTLS; - break; - case WIFI_EAP_TYPE_SIM: - profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_type = WLAN_SEC_EAP_TYPE_SIM; - break; - case WIFI_EAP_TYPE_AKA: - profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_type = WLAN_SEC_EAP_TYPE_AKA; - break; - default: - return WIFI_ERROR_INVALID_PARAMETER; - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_get_eap_auth_type(wifi_ap_h ap, wifi_eap_auth_type_e* type) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_eap_auth_type"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false || type == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) - return WIFI_ERROR_INVALID_OPERATION; - - switch (profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_auth) { - //LCOV_EXCL_START - case WLAN_SEC_EAP_AUTH_NONE: - *type = WIFI_EAP_AUTH_TYPE_NONE; - break; - case WLAN_SEC_EAP_AUTH_PAP: - *type = WIFI_EAP_AUTH_TYPE_PAP; - break; - case WLAN_SEC_EAP_AUTH_MSCHAP: - *type = WIFI_EAP_AUTH_TYPE_MSCHAP; - break; - case WLAN_SEC_EAP_AUTH_MSCHAPV2: - *type = WIFI_EAP_AUTH_TYPE_MSCHAPV2; - break; - case WLAN_SEC_EAP_AUTH_GTC: - *type = WIFI_EAP_AUTH_TYPE_GTC; - break; - case WLAN_SEC_EAP_AUTH_MD5: - *type = WIFI_EAP_AUTH_TYPE_MD5; - break; - default: - return WIFI_ERROR_OPERATION_FAILED; - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_ap_set_eap_auth_type(wifi_ap_h ap, wifi_eap_auth_type_e type) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_eap_auth_type"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - if (_wifi_libnet_check_ap_validity(ap) == false) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = ap; - if (profile_info->ProfileInfo.Wlan.security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) - return WIFI_ERROR_INVALID_OPERATION; - - switch (type) { - //LCOV_EXCL_START - case WIFI_EAP_AUTH_TYPE_NONE: - profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_NONE; - break; - case WIFI_EAP_AUTH_TYPE_PAP: - profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_PAP; - break; - case WIFI_EAP_AUTH_TYPE_MSCHAP: - profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_MSCHAP; - break; - case WIFI_EAP_AUTH_TYPE_MSCHAPV2: - profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_MSCHAPV2; - break; - case WIFI_EAP_AUTH_TYPE_GTC: - profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_GTC; - break; - case WIFI_EAP_AUTH_TYPE_MD5: - profile_info->ProfileInfo.Wlan.security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_MD5; - break; - default: - return WIFI_ERROR_INVALID_PARAMETER; - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } diff --git a/src/net_wifi_config.c b/src/net_wifi_config.c index dce0cdc..03f9c76 100755 --- a/src/net_wifi_config.c +++ b/src/net_wifi_config.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include "wifi.h" -#include "wifi_config_private.h" #include "net_wifi_private.h" /** @@ -24,364 +22,49 @@ EXPORT_API int wifi_config_create(const char *name, const char *passphrase, wifi_security_type_e security_type, wifi_config_h *config) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_create"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = NULL; - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - if (config == NULL || name == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - h = g_new0(struct _wifi_config, 1); - if (h == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; - - h->name = g_strdup(name); - h->passphrase = g_strdup(passphrase); - h->security_type = security_type; - h->is_saved = FALSE; - h->is_hidden = FALSE; - h->proxy_address = NULL; - h->address_family = WIFI_ADDRESS_FAMILY_IPV4; - h->eap_config = NULL; - - if (security_type == WIFI_SECURITY_TYPE_EAP) { - h->eap_config = g_new0(struct _wifi_eap_config, 1); - if (h->eap_config == NULL) { - g_free(h->name); //LCOV_EXCL_LINE - g_free(h->passphrase); //LCOV_EXCL_LINE - g_free(h); //LCOV_EXCL_LINE - return WIFI_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE - } - - h->eap_config->ca_cert = NULL; - h->eap_config->client_cert = NULL; - h->eap_config->private_key = NULL; - h->eap_config->anonymous_identity = NULL; - h->eap_config->identity = NULL; - h->eap_config->subject_match = NULL; - h->eap_config->eap_type = -1; - h->eap_config->eap_auth_type = WIFI_EAP_AUTH_TYPE_NONE; - } - - *config = (wifi_config_h)h; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_clone(wifi_config_h origin, wifi_config_h *cloned_config) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_clone"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = NULL; - struct _wifi_config *config = NULL; - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - if (origin == NULL || cloned_config == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - config = (struct _wifi_config *)origin; - - h = g_new0(struct _wifi_config, 1); - if (h == NULL) - return WIFI_ERROR_OUT_OF_MEMORY; - - h->name = g_strdup(config->name); - h->passphrase = g_strdup(config->passphrase); - h->security_type = config->security_type; - h->is_saved = config->is_saved; - h->is_hidden = config->is_hidden; - h->proxy_address = g_strdup(config->proxy_address); - h->address_family = config->address_family; - - if (config->eap_config) { - h->eap_config = g_new0(struct _wifi_eap_config, 1); - if (h->eap_config == NULL) { - g_free(h->name); //LCOV_EXCL_LINE - g_free(h->passphrase); //LCOV_EXCL_LINE - g_free(h->proxy_address); //LCOV_EXCL_LINE - g_free(h); //LCOV_EXCL_LINE - return WIFI_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE - } - - h->eap_config->ca_cert = g_strdup(config->eap_config->ca_cert); - h->eap_config->client_cert = g_strdup(config->eap_config->client_cert); - h->eap_config->private_key = g_strdup(config->eap_config->private_key); - h->eap_config->anonymous_identity = g_strdup(config->eap_config->anonymous_identity); - h->eap_config->identity = g_strdup(config->eap_config->identity); - h->eap_config->subject_match = g_strdup(config->eap_config->subject_match); - h->eap_config->eap_type = config->eap_config->eap_type; - h->eap_config->eap_auth_type = config->eap_config->eap_auth_type; - } - - *cloned_config = (wifi_config_h)h; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_destroy(wifi_config_h config) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_destroy"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - if (config == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - g_free(h->name); - g_free(h->passphrase); - g_free(h->proxy_address); - if (h->eap_config) { - g_free(h->eap_config->ca_cert); - g_free(h->eap_config->client_cert); - g_free(h->eap_config->private_key); - g_free(h->eap_config->anonymous_identity); - g_free(h->eap_config->identity); - g_free(h->eap_config->subject_match); - g_free(h->eap_config); - } - g_free(h); - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_save_configuration(wifi_config_h config) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_save"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - int ret = WIFI_ERROR_NONE; - wifi_dbus *dbus_h = NULL; - struct _wifi_config *h = (struct _wifi_config *)config; - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - if (config == NULL || h->name == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - dbus_h = _wifi_get_dbus_handle(); - if (dbus_h == NULL) { - WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - if (h->security_type == WIFI_SECURITY_TYPE_EAP) { - ret = wifi_save_eap_configurations(dbus_h, h->name, h->passphrase, h->security_type, h->proxy_address, h->eap_config, h->is_hidden); - if (ret != WIFI_ERROR_NONE) - WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_eap_configurations"); //LCOV_EXCL_LINE - } else { - ret = wifi_save_configurations(dbus_h, h->name, h->passphrase, h->security_type, h->proxy_address, h->is_hidden); - if (ret != WIFI_ERROR_NONE) - WIFI_LOG(WIFI_ERROR, "Fail to save configurations [%d]", ret); //LCOV_EXCL_LINE - } - - h->is_saved = TRUE; - - return ret; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_remove(wifi_config_h config) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_remove"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - int ret = WIFI_ERROR_NONE; - struct _wifi_config *h = (struct _wifi_config *)config; - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - if (config == NULL || h->name == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE - } - - if (h->is_saved == TRUE) { - wifi_dbus *dbus_h = NULL; - gchar *config_id = NULL; - - dbus_h = _wifi_get_dbus_handle(); - if (dbus_h == NULL) { - WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection"); - return WIFI_ERROR_INVALID_OPERATION; - } - - config_id = wifi_config_get_config_id(h->name, h->security_type); - - ret = wifi_remove_configurations(dbus_h, config_id); - if (ret != WIFI_ERROR_NONE) - WIFI_LOG(WIFI_ERROR, "Fail to remove configurations [%d]", ret); - - g_free(config_id); - } - - return ret; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_foreach_configuration(wifi_config_list_cb callback, void *user_data) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_foreach_configuration"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - int ret = WIFI_ERROR_NONE; - wifi_dbus *dbus_h = NULL; - GSList *config_ids = NULL; - GSList *temp = NULL; - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - if (callback == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - dbus_h = _wifi_get_dbus_handle(); - if (dbus_h == NULL) { - WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - config_ids = wifi_config_get_config_id_list(dbus_h); - if (config_ids == NULL) { - WIFI_LOG(WIFI_ERROR, "Fail to wifi_get_config_id_list"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - temp = config_ids; - - while (temp) { - bool rv = 1; - struct _wifi_config *h; - gchar *id = temp->data; - - h = g_new0(struct _wifi_config, 1); - if (h == NULL) { - ret = WIFI_ERROR_OUT_OF_MEMORY; - break; - } - - if (g_str_has_suffix(id, "ieee8021x") == TRUE) { - h->eap_config = g_new0(struct _wifi_eap_config, 1); - if (h->eap_config == NULL) { - ret = WIFI_ERROR_OUT_OF_MEMORY; - g_free(h); - break; - } - ret = wifi_load_eap_configurations(dbus_h, id, &h->name, - &h->security_type, &h->proxy_address, &h->is_hidden, &h->eap_config, &h->last_error); - } else { - ret = wifi_load_configurations(dbus_h, id, &h->name, - &h->security_type, &h->proxy_address, &h->is_hidden, &h->last_error); - } - - if (ret != WIFI_ERROR_NONE) { - WIFI_LOG(WIFI_ERROR, "Fail to load configurations [%d]", ret); //LCOV_EXCL_LINE - } else { - h->address_family = WIFI_ADDRESS_FAMILY_IPV4; - h->is_saved = TRUE; - rv = callback((wifi_config_h)h, user_data); - } - - g_free(h->name); - g_free(h->proxy_address); - if (h->eap_config) { - g_free(h->eap_config->ca_cert); - g_free(h->eap_config->client_cert); - g_free(h->eap_config->private_key); - g_free(h->eap_config->anonymous_identity); - g_free(h->eap_config->identity); - g_free(h->eap_config->subject_match); - g_free(h->eap_config); - } - g_free(h); - h = NULL; - - if (rv == false) - break; - - temp = temp->next; - } - - g_slist_free_full(config_ids, g_free); - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_get_name(wifi_config_h config, char **name) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_name"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - if (config == NULL || name == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - if (h->name != NULL) - *name = g_strdup(h->name); - else - *name = NULL; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_get_security_type(wifi_config_h config, wifi_security_type_e *security_type) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_security_type"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - if (config == NULL || security_type == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - *security_type = h->security_type; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } /** @@ -390,544 +73,107 @@ EXPORT_API int wifi_config_get_security_type(wifi_config_h config, wifi_security EXPORT_API int wifi_config_set_proxy_address(wifi_config_h config, wifi_address_family_e address_family, const char *proxy_address) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_proxy_address"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - int ret = WIFI_ERROR_NONE; - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - if (config == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - if ((address_family != WIFI_ADDRESS_FAMILY_IPV4 && address_family != WIFI_ADDRESS_FAMILY_IPV6)) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE - } - - if (address_family == WIFI_ADDRESS_FAMILY_IPV6) { - WIFI_LOG(WIFI_ERROR, "Not supported yet"); //LCOV_EXCL_LINE - return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - - h->address_family = address_family; - h->proxy_address = g_strdup(proxy_address); - - if (h->is_saved == TRUE) { - //LCOV_EXCL_START - wifi_dbus *dbus_h = NULL; - gchar *config_id = NULL; - - dbus_h = _wifi_get_dbus_handle(); - if (dbus_h == NULL) { - WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection"); - return WIFI_ERROR_INVALID_OPERATION; - } - - config_id = wifi_config_get_config_id(h->name, h->security_type); - - ret = wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_PROXYADDRESS, proxy_address); - if (ret != WIFI_ERROR_NONE) - WIFI_LOG(WIFI_ERROR, "Fail to set proxy address [%d]", ret); - - g_free(config_id); - //LCOV_EXCL_STOP - } - - return ret; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_get_proxy_address(wifi_config_h config, wifi_address_family_e *address_family, char **proxy_address) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_proxy_address"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - if (config == NULL || address_family == NULL || proxy_address == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - *address_family = h->address_family; - *proxy_address = g_strdup(h->proxy_address); - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_set_hidden_ap_property(wifi_config_h config, bool hidden) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_hidden_ap_property"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - int ret = WIFI_ERROR_NONE; - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - if (config == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - h->is_hidden = hidden; - - if (h->is_saved == TRUE) { - //LCOV_EXCL_START - wifi_dbus *dbus_h = NULL; - char *config_id = NULL; - char *hidden_str = NULL; - - dbus_h = _wifi_get_dbus_handle(); - if (dbus_h == NULL) { - WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection"); - return WIFI_ERROR_INVALID_OPERATION; - } - - config_id = wifi_config_get_config_id(h->name, h->security_type); - - if (h->is_hidden == TRUE) - hidden_str = g_strdup("TRUE"); - else - hidden_str = g_strdup("FALSE"); - - ret = wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_HIDDEN, hidden_str); - if (ret != WIFI_ERROR_NONE) - WIFI_LOG(WIFI_ERROR, "Fail to set hidden [%d]", ret); - - g_free(hidden_str); - g_free(config_id); - //LCOV_EXCL_STOP - } - - return ret; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_get_hidden_ap_property(wifi_config_h config, bool *hidden) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_hidden_ap_property"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE - } - - if (config == NULL || hidden == NULL) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - *hidden = h->is_hidden; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_get_eap_anonymous_identity(wifi_config_h config, char** anonymous_identity) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_anonymous_identity"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (h->eap_config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (anonymous_identity == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - - *anonymous_identity = g_strdup(h->eap_config->anonymous_identity); - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_set_eap_anonymous_identity(wifi_config_h config, const char* anonymous_identity) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_anonymous_identity"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (h->eap_config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - - h->eap_config->anonymous_identity = g_strdup(anonymous_identity); - - if (h->is_saved == TRUE) { - //LCOV_EXCL_START - wifi_dbus *dbus_h = NULL; - gchar *config_id = NULL; - - dbus_h = _wifi_get_dbus_handle(); - if (dbus_h == NULL) { - WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection"); - return WIFI_ERROR_INVALID_OPERATION; - } - - config_id = wifi_config_get_config_id(h->name, h->security_type); - - wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY, anonymous_identity); - - g_free(config_id); - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_get_eap_ca_cert_file(wifi_config_h config, char** ca_cert) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_ca_cert_file"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (h->eap_config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (ca_cert == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - - *ca_cert = g_strdup(h->eap_config->ca_cert); - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_set_eap_ca_cert_file(wifi_config_h config, const char* ca_cert) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_ca_cert_file"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (h->eap_config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - - h->eap_config->ca_cert = g_strdup(ca_cert); - - if (h->is_saved == TRUE) { - //LCOV_EXCL_START - wifi_dbus *dbus_h = NULL; - gchar *config_id = NULL; - - dbus_h = _wifi_get_dbus_handle(); - if (dbus_h == NULL) { - WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection"); - return WIFI_ERROR_INVALID_OPERATION; - } - - config_id = wifi_config_get_config_id(h->name, h->security_type); - - wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_CACERT, ca_cert); - - g_free(config_id); - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_get_eap_client_cert_file(wifi_config_h config, char** client_cert) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_client_cert_file"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (h->eap_config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (client_cert == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - - *client_cert = g_strdup(h->eap_config->client_cert); - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_set_eap_client_cert_file(wifi_config_h config, const char* private_key, const char* client_cert) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_client_cert_file"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (h->eap_config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - - h->eap_config->private_key = g_strdup(private_key); - h->eap_config->client_cert = g_strdup(client_cert); - - if (h->is_saved == TRUE) { - //LCOV_EXCL_START - wifi_dbus *dbus_h = NULL; - gchar *config_id = NULL; - - dbus_h = _wifi_get_dbus_handle(); - if (dbus_h == NULL) { - WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection"); - return WIFI_ERROR_INVALID_OPERATION; - } - - config_id = wifi_config_get_config_id(h->name, h->security_type); - - wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_CLIENTCERT, client_cert); - wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_PRIVATEKEY, private_key); - - g_free(config_id); - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_get_eap_identity(wifi_config_h config, char** identity) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_identity"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (h->eap_config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (identity == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - - *identity = g_strdup(h->eap_config->identity); - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_set_eap_identity(wifi_config_h config, const char* identity) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_identity"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (h->eap_config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - - h->eap_config->identity = g_strdup(identity); - - if (h->is_saved == TRUE) { - //LCOV_EXCL_START - wifi_dbus *dbus_h = NULL; - gchar *config_id = NULL; - - dbus_h = _wifi_get_dbus_handle(); - if (dbus_h == NULL) { - WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection"); - return WIFI_ERROR_INVALID_OPERATION; - } - - config_id = wifi_config_get_config_id(h->name, h->security_type); - - wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_IDENTITY, identity); - - g_free(config_id); - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_get_eap_type(wifi_config_h config, wifi_eap_type_e *eap_type) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_type"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (h->eap_config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (eap_type == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - - *eap_type = h->eap_config->eap_type; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_set_eap_type(wifi_config_h config, wifi_eap_type_e eap_type) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_type"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (h->eap_config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - - h->eap_config->eap_type = eap_type; - - if (h->is_saved == TRUE) { - //LCOV_EXCL_START - wifi_dbus *dbus_h = NULL; - gchar *config_id = NULL; - gchar *value = NULL; - - dbus_h = _wifi_get_dbus_handle(); - if (dbus_h == NULL) { - WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection"); - return WIFI_ERROR_INVALID_OPERATION; - } - - config_id = wifi_config_get_config_id(h->name, h->security_type); - - value = wifi_eap_type_to_string(eap_type); - - wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_TYPE, value); - - g_free(config_id); - g_free(value); - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_get_eap_auth_type(wifi_config_h config, wifi_eap_auth_type_e* eap_auth_type) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_auth_type"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (h->eap_config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (eap_auth_type == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - - *eap_auth_type = h->eap_config->eap_auth_type; - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_set_eap_auth_type(wifi_config_h config, wifi_eap_auth_type_e eap_auth_type) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_auth_type"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (h->eap_config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - - h->eap_config->eap_auth_type = eap_auth_type; - - if (h->is_saved == TRUE) { - //LCOV_EXCL_START - wifi_dbus *dbus_h = NULL; - gchar *config_id = NULL; - gchar *value = NULL; - - dbus_h = _wifi_get_dbus_handle(); - if (dbus_h == NULL) { - WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection"); - return WIFI_ERROR_INVALID_OPERATION; - } - - config_id = wifi_config_get_config_id(h->name, h->security_type); - - value = wifi_eap_auth_type_to_string(eap_auth_type); - - wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_AUTH_TYPE, value); - - g_free(config_id); - g_free(value); - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_get_eap_subject_match(wifi_config_h config, char** subject_match) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_subject_match"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (h->eap_config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (subject_match == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - - *subject_match = g_strdup(h->eap_config->subject_match); - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } EXPORT_API int wifi_config_set_eap_subject_match(wifi_config_h config, const char* subject_match) { DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_subject_match"); - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - if (h->eap_config == NULL) - return WIFI_ERROR_INVALID_PARAMETER; - - h->eap_config->subject_match = g_strdup(subject_match); - - if (h->is_saved == TRUE) { - //LCOV_EXCL_START - wifi_dbus *dbus_h = NULL; - gchar *config_id = NULL; - - dbus_h = _wifi_get_dbus_handle(); - if (dbus_h == NULL) { - WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection"); - return WIFI_ERROR_INVALID_OPERATION; - } - - config_id = wifi_config_get_config_id(h->name, h->security_type); - - wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_SUBJECT_MATCH, subject_match); - - g_free(config_id); - //LCOV_EXCL_STOP - } - - return WIFI_ERROR_NONE; + return WIFI_ERROR_NOT_SUPPORTED; } diff --git a/src/wifi_config.c b/src/wifi_config.c deleted file mode 100755 index 462260e..0000000 --- a/src/wifi_config.c +++ /dev/null @@ -1,721 +0,0 @@ -/* - * 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 -#include - -#include "wifi.h" -#include "wifi_dbus_private.h" -#include "wifi_config_private.h" -#include "net_wifi_private.h" - -#define WIFI_SECURITY_NONE "none" -#define WIFI_SECURITY_WEP "wep" -#define WIFI_SECURITY_WPA_PSK "psk" -#define WIFI_SECURITY_EAP "ieee8021x" - -//LCOV_EXCL_START -static wifi_error_e _wifi_error_to_enum(const gchar *error) -{ - if (NULL != strstr(error, "NoReply")) - return WIFI_ERROR_NO_REPLY; - else if (NULL != strstr(error, "Failed")) - return WIFI_ERROR_INVALID_OPERATION; - else if (NULL != strstr(error, "UnknownMethod")) - return WIFI_ERROR_INVALID_OPERATION; - else if (NULL != strstr(error, "InvalidArguments")) - return WIFI_ERROR_INVALID_PARAMETER; - else if (NULL != strstr(error, "AccessDenied")) - return WIFI_ERROR_PERMISSION_DENIED; - else if (NULL != strstr(error, "PermissionDenied")) - return WIFI_ERROR_PERMISSION_DENIED; - else if (NULL != strstr(error, "PassphraseRequired")) - return WIFI_ERROR_INVALID_OPERATION; - else if (NULL != strstr(error, "NotRegistered")) - return WIFI_ERROR_INVALID_OPERATION; - else if (NULL != strstr(error, "NotUnique")) - return WIFI_ERROR_INVALID_OPERATION; - else if (NULL != strstr(error, "NotSupported")) - return WIFI_ERROR_NOT_SUPPORTED; - else if (NULL != strstr(error, "NotImplemented")) - return WIFI_ERROR_NOT_SUPPORTED; - else if (NULL != strstr(error, "NotFound")) - return WIFI_ERROR_NOT_SUPPORTED; - else if (NULL != strstr(error, "NoCarrier")) - return WIFI_ERROR_NOT_SUPPORTED; - else if (NULL != strstr(error, "InProgress")) - return WIFI_ERROR_NOW_IN_PROGRESS; - else if (NULL != strstr(error, "AlreadyExists")) - return WIFI_ERROR_INVALID_OPERATION; - else if (NULL != strstr(error, "AlreadyEnabled")) - return WIFI_ERROR_INVALID_OPERATION; - else if (NULL != strstr(error, "AlreadyDisabled")) - return WIFI_ERROR_INVALID_OPERATION; - else if (NULL != strstr(error, "AlreadyConnected")) - return WIFI_ERROR_ALREADY_EXISTS; - else if (NULL != strstr(error, "NotConnected")) - return WIFI_ERROR_NO_CONNECTION; - else if (NULL != strstr(error, "OperationAborted")) - return WIFI_ERROR_OPERATION_FAILED; - else if (NULL != strstr(error, "OperationTimeout")) - return WIFI_ERROR_OPERATION_FAILED; - else if (NULL != strstr(error, "InvalidService")) - return WIFI_ERROR_INVALID_OPERATION; - else if (NULL != strstr(error, "InvalidProperty")) - return WIFI_ERROR_INVALID_OPERATION; - return WIFI_ERROR_INVALID_OPERATION; -} - -static wifi_error_e _wifi_last_error_to_enum(const gchar *last_error) -{ - wifi_error_e ret = WIFI_ERROR_OPERATION_FAILED; - - if (g_strcmp0(last_error, "ERROR_NONE") == 0) { - ret = WIFI_ERROR_NONE; - } else if (g_strcmp0(last_error, "invalid-key") == 0) { - ret = WIFI_ERROR_INVALID_KEY; - } else if (g_strcmp0(last_error, "dhcp-failed") == 0) { - ret = WIFI_ERROR_DHCP_FAILED; - } else { - WIFI_LOG(WIFI_ERROR, "Not supported error type (%s)", last_error); - ret = WIFI_ERROR_NONE; - } - - return ret; -} -//LCOV_EXCL_STOP - -static gchar *_wifi_change_name_to_hexadecimal(const gchar *name) -{ - GString *string; - gint i = 0; - gint length = 0; - gchar *hex = NULL; - - if (name == NULL) - return NULL; - - length = strlen(name); - - string = g_string_sized_new((gsize)(length * 2)); - if (string == NULL) - return NULL; - - for (i = 0; i < length; i++) - g_string_append_printf(string, "%02x", name[i]); - - hex = g_strdup_printf("%s", string->str); - g_string_free(string, TRUE); - - return hex; -} - -//LCOV_EXCL_START -gchar *wifi_eap_type_to_string(wifi_eap_type_e eap_type) -{ - gchar *type = NULL; - - switch (eap_type) { - case WIFI_EAP_TYPE_PEAP: - type = g_strdup("PEAP"); - break; - case WIFI_EAP_TYPE_TLS: - type = g_strdup("TLS"); - break; - case WIFI_EAP_TYPE_TTLS: - type = g_strdup("TTLS"); - break; - case WIFI_EAP_TYPE_SIM: - type = g_strdup("SIM"); - break; - case WIFI_EAP_TYPE_AKA: - type = g_strdup("AKA"); - break; - } - return type; -} - -gchar *wifi_eap_auth_type_to_string(wifi_eap_auth_type_e eap_auth_type) -{ - gchar *type = NULL; - - switch (eap_auth_type) { - case WIFI_EAP_AUTH_TYPE_PAP: - type = g_strdup("PAP"); - break; - case WIFI_EAP_AUTH_TYPE_MSCHAP: - type = g_strdup("MSCHAP"); - break; - case WIFI_EAP_AUTH_TYPE_MSCHAPV2: - type = g_strdup("MSCHAPV2"); - break; - case WIFI_EAP_AUTH_TYPE_GTC: - type = g_strdup("GTC"); - break; - case WIFI_EAP_AUTH_TYPE_MD5: - type = g_strdup("MD5"); - break; - default: - case WIFI_EAP_AUTH_TYPE_NONE: - type = NULL; - break; - } - return type; -} - -wifi_eap_type_e wifi_eap_type_to_int(const gchar *type) -{ - wifi_eap_type_e ret = -1; - - if (type == NULL) - return ret; - - if (g_strcmp0(type, "PEAP") == 0) - ret = WIFI_EAP_TYPE_PEAP; - else if (g_strcmp0(type, "TLS") == 0) - ret = WIFI_EAP_TYPE_TLS; - else if (g_strcmp0(type, "TTLS") == 0) - ret = WIFI_EAP_TYPE_TTLS; - else if (g_strcmp0(type, "SIM") == 0) - ret = WIFI_EAP_TYPE_SIM; - else if (g_strcmp0(type, "AKA") == 0) - ret = WIFI_EAP_TYPE_AKA; - else - WIFI_LOG(WIFI_ERROR, "Not supported type (%s)", type); - - return ret; -} - -wifi_eap_auth_type_e wifi_eap_auth_type_to_int(const gchar *type) -{ - wifi_eap_auth_type_e ret = WIFI_EAP_AUTH_TYPE_NONE; - - if (type == NULL) - return ret; - - if (g_strcmp0(type, "PAP") == 0) - ret = WIFI_EAP_AUTH_TYPE_PAP; - else if (g_strcmp0(type, "MSCHAP") == 0) - ret = WIFI_EAP_AUTH_TYPE_MSCHAP; - else if (g_strcmp0(type, "MSCHAPV2") == 0) - ret = WIFI_EAP_AUTH_TYPE_MSCHAPV2; - else if (g_strcmp0(type, "GTC") == 0) - ret = WIFI_EAP_AUTH_TYPE_GTC; - else if (g_strcmp0(type, "MD5") == 0) - ret = WIFI_EAP_AUTH_TYPE_MD5; - else - WIFI_LOG(WIFI_ERROR, "Not supported type (%s)", type); - - return ret; -} - -static wifi_security_type_e _wifi_security_type_to_int(const gchar *type) -{ - wifi_security_type_e ret = WIFI_SECURITY_TYPE_NONE; - - if (type == NULL) - return ret; - - if (g_strcmp0(type, WIFI_SECURITY_NONE) == 0) - ret = WIFI_SECURITY_TYPE_NONE; - else if (g_strcmp0(type, WIFI_SECURITY_WEP) == 0) - ret = WIFI_SECURITY_TYPE_WEP; - else if (g_strcmp0(type, WIFI_SECURITY_WPA_PSK) == 0) - ret = WIFI_SECURITY_TYPE_WPA_PSK; - else if (g_strcmp0(type, WIFI_SECURITY_EAP) == 0) - ret = WIFI_SECURITY_TYPE_EAP; - else - WIFI_LOG(WIFI_ERROR, "Not supported type (%s)", type); - - return ret; -} - -static gchar *_wifi_security_type_to_string(wifi_security_type_e security_type) -{ - switch (security_type) { - case WIFI_SECURITY_TYPE_NONE: - return WIFI_SECURITY_NONE; - - case WIFI_SECURITY_TYPE_WEP: - return WIFI_SECURITY_WEP; - - case WIFI_SECURITY_TYPE_WPA_PSK: - case WIFI_SECURITY_TYPE_WPA2_PSK: - return WIFI_SECURITY_WPA_PSK; - - case WIFI_SECURITY_TYPE_EAP: - return WIFI_SECURITY_EAP; - - default: - return NULL; - } -} - -int wifi_config_get_last_error(wifi_config_h config, wifi_error_e *last_error) -{ - CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - - struct _wifi_config *h = (struct _wifi_config *)config; - - if (_wifi_is_init() == false) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); - return WIFI_ERROR_INVALID_OPERATION; - } - - if (config == NULL || last_error == NULL) { - WIFI_LOG(WIFI_ERROR, "Not initialized"); - return WIFI_ERROR_INVALID_PARAMETER; - } - - *last_error = h->last_error; - - return WIFI_ERROR_NONE; -} -//LCOV_EXCL_STOP - -gchar *wifi_config_get_config_id(const gchar *name, wifi_security_type_e security_type) -{ - gchar *config_id = NULL; - gchar *ssid = NULL; - gchar *type = NULL; - - ssid = _wifi_change_name_to_hexadecimal(name); - type = g_strdup(_wifi_security_type_to_string(security_type)); - config_id = g_strdup_printf("%s_managed_%s", ssid, type); - - g_free(ssid); - g_free(type); - - return config_id; -} - -GSList *wifi_config_get_config_id_list(wifi_dbus *handle) -{ - GError *error = NULL; - GVariant *result = NULL; - GVariantIter *iter = NULL; - GSList *list = NULL; - gchar *config_id = NULL; - - result = g_dbus_connection_call_sync(handle->dbus_conn, - NETCONFIG_SERVICE, - NETCONFIG_WIFI_PATH, - NETCONFIG_IWIFI, - "GetConfigIds", - g_variant_new("()"), - NULL, G_DBUS_CALL_FLAGS_NONE, - DBUS_REPLY_TIMEOUT, handle->ca, - &error); - - if (error) { - WIFI_LOG(WIFI_ERROR, "Fail to GetConfigId [%d: %s]", error->code, error->message); //LCOV_EXCL_LINE - g_error_free(error); //LCOV_EXCL_LINE - return NULL; //LCOV_EXCL_LINE - } - - g_variant_get(result, "(as)", &iter); - while (g_variant_iter_loop(iter, "s", &config_id)) - list = g_slist_append(list, g_strdup(config_id)); - - g_variant_iter_free(iter); - g_variant_unref(result); - - - return list; -} - -int wifi_save_configurations(wifi_dbus *handle, const gchar *name, const gchar *passphrase, wifi_security_type_e security_type, const gchar *proxy_address, gboolean is_hidden) -{ - wifi_error_e ret = WIFI_ERROR_NONE; - GError *error = NULL; - GVariant *result = NULL; - GVariant *params = NULL; - GVariantBuilder *b = NULL; - gchar *config_id = NULL; - gchar *ssid = NULL; - - if (security_type != WIFI_SECURITY_TYPE_NONE) { - if (passphrase == NULL) { - WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_configurations [secu_type is not NONE[%d] but passphrase is NULL]", security_type); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE - } else { - if (strlen(passphrase) == 0) { - WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_configurations passphrase length is 0"); //LCOV_EXCL_LINE - return WIFI_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE - } - } - } - - config_id = wifi_config_get_config_id(name, security_type); - ssid = _wifi_change_name_to_hexadecimal(name); - - b = g_variant_builder_new(G_VARIANT_TYPE("a{sv}")); - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_NAME, g_variant_new_string(name)); - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_SSID, g_variant_new_string(ssid)); - if (passphrase != NULL) - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PASSPHRASE, g_variant_new_string(passphrase)); - if (proxy_address != NULL) - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PROXYADDRESS, g_variant_new_string(proxy_address)); - if (is_hidden == TRUE) - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_HIDDEN, g_variant_new_string("TRUE")); - - params = g_variant_new("(s@a{sv})", config_id, g_variant_builder_end(b)); - g_variant_builder_unref(b); - g_free(config_id); - - result = g_dbus_connection_call_sync(handle->dbus_conn, - NETCONFIG_SERVICE, - NETCONFIG_WIFI_PATH, - NETCONFIG_IWIFI, - "SaveConfiguration", - params, - NULL, G_DBUS_CALL_FLAGS_NONE, - DBUS_REPLY_TIMEOUT, handle->ca, - &error); - - if (error) { - WIFI_LOG(WIFI_ERROR, "Fail to SaveConfiguration [%d: %s]", error->code, error->message); //LCOV_EXCL_LINE - ret = _wifi_error_to_enum(error->message); //LCOV_EXCL_LINE - g_error_free(error); //LCOV_EXCL_LINE - } - - if (result != NULL) - g_variant_unref(result); - - return ret; -} - -int wifi_load_configurations(wifi_dbus *handle, const gchar *config_id, gchar **name, wifi_security_type_e *security_type, gchar **proxy_address, gboolean *is_hidden, wifi_error_e *last_error) -{ - GError *error = NULL; - GVariant *result = NULL; - wifi_error_e ret = WIFI_ERROR_NONE; - - result = g_dbus_connection_call_sync(handle->dbus_conn, - NETCONFIG_SERVICE, - NETCONFIG_WIFI_PATH, - NETCONFIG_IWIFI, - "LoadConfiguration", - g_variant_new("(s)", config_id), - NULL, G_DBUS_CALL_FLAGS_NONE, - DBUS_REPLY_TIMEOUT, handle->ca, - &error); - - if (error) { - WIFI_LOG(WIFI_ERROR, "Fail to LoadConfiguration [%d: %s]", error->code, error->message); //LCOV_EXCL_LINE - ret = _wifi_error_to_enum(error->message); //LCOV_EXCL_LINE - g_error_free(error); //LCOV_EXCL_LINE - return ret; //LCOV_EXCL_LINE - } - - if (result) { - GVariantIter *iter; - gchar *field; - GVariant *value; - - g_variant_get(result, "(a{sv})", &iter); - while (g_variant_iter_loop(iter, "{sv}", &field, &value)) { - if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) { - if (g_strcmp0(field, WIFI_CONFIG_NAME) == 0) { - *name = g_strdup(g_variant_get_string(value, NULL)); - } else if (g_strcmp0(field, WIFI_CONFIG_SECURITY_TYPE) == 0) { - *security_type = _wifi_security_type_to_int(g_variant_get_string(value, NULL)); - } else if (g_strcmp0(field, WIFI_CONFIG_HIDDEN) == 0) { - const gchar *r_hidden = g_variant_get_string(value, NULL); - if (g_strcmp0(r_hidden, "TRUE") == 0) - *is_hidden = TRUE; - else - *is_hidden = FALSE; - } else if (g_strcmp0(field, WIFI_CONFIG_PROXYADDRESS) == 0) { - const gchar *r_proxy_address = g_variant_get_string(value, NULL); - if (g_strcmp0(r_proxy_address, "NONE") == 0) - *proxy_address = NULL; - else - *proxy_address = g_strdup(r_proxy_address); - } else if (g_strcmp0(field, WIFI_CONFIG_FAILURE) == 0) { - *last_error = _wifi_last_error_to_enum(g_variant_get_string(value, NULL)); - } - } - } - - g_variant_iter_free(iter); - g_variant_unref(result); - } - - return WIFI_ERROR_NONE; -} - -int wifi_remove_configurations(wifi_dbus *handle, const gchar *config_id) -{ - wifi_error_e ret = WIFI_ERROR_NONE; - GError *error = NULL; - GVariant *result = NULL; - - result = g_dbus_connection_call_sync(handle->dbus_conn, - NETCONFIG_SERVICE, - NETCONFIG_WIFI_PATH, - NETCONFIG_IWIFI, - "RemoveConfiguration", - g_variant_new("(s)", config_id), - NULL, G_DBUS_CALL_FLAGS_NONE, - DBUS_REPLY_TIMEOUT, handle->ca, - &error); - - if (error) { - WIFI_LOG(WIFI_ERROR, "Fail to RemoveConfiguration [%d: %s]", error->code, error->message); - ret = _wifi_error_to_enum(error->message); - g_error_free(error); - } - - if (result != NULL) - g_variant_unref(result); - - return ret; -} - -//LCOV_EXCL_START -int wifi_save_eap_configurations(wifi_dbus *handle, const gchar *name, const gchar *passphrase, wifi_security_type_e security_type, const gchar *proxy_address, struct _wifi_eap_config *eap_config, gboolean is_hidden) -{ - wifi_error_e ret = WIFI_ERROR_NONE; - GError *error = NULL; - GVariant *result = NULL; - GVariant *params = NULL; - GVariantBuilder *b = NULL; - gchar *config_id = NULL; - gchar *ssid = NULL; - - if (security_type != WIFI_SECURITY_TYPE_EAP) { - WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_configurations [secu_type is not EAP[%d]]", security_type); - return WIFI_ERROR_INVALID_PARAMETER; - } - - if (security_type != WIFI_SECURITY_TYPE_NONE) { - if (passphrase == NULL) { - WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_configurations [secu_type is not NONE[%d] but passphrase is NULL]", security_type); - return WIFI_ERROR_INVALID_PARAMETER; - } else { - if (strlen(passphrase) == 0) { - WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_configurations passphrase length is 0"); - return WIFI_ERROR_INVALID_PARAMETER; - } - } - } - - config_id = wifi_config_get_config_id(name, security_type); - ssid = _wifi_change_name_to_hexadecimal(name); - - b = g_variant_builder_new(G_VARIANT_TYPE("a{sv}")); - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_NAME, g_variant_new_string(name)); - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_SSID, g_variant_new_string(ssid)); - if (passphrase != NULL) - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PASSPHRASE, g_variant_new_string(passphrase)); - if (proxy_address != NULL) - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PROXYADDRESS, g_variant_new_string(proxy_address)); - if (is_hidden == TRUE) - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_HIDDEN, g_variant_new_string("TRUE")); - - if (eap_config != NULL) { - gchar* auth_type = NULL; - gchar* eap_type = NULL; - if (eap_config->anonymous_identity != NULL) - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY, g_variant_new_string(eap_config->anonymous_identity)); - if (eap_config->ca_cert != NULL) - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_CACERT, g_variant_new_string(eap_config->ca_cert)); - if (eap_config->client_cert != NULL) - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_CLIENTCERT, g_variant_new_string(eap_config->client_cert)); - if (eap_config->private_key != NULL) - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_PRIVATEKEY, g_variant_new_string(eap_config->private_key)); - if (eap_config->identity != NULL) - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_IDENTITY, g_variant_new_string(eap_config->identity)); - if (eap_config->subject_match != NULL) - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_SUBJECT_MATCH, g_variant_new_string(eap_config->subject_match)); - - auth_type = wifi_eap_auth_type_to_string(eap_config->eap_auth_type); - if (auth_type != NULL) - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_AUTH_TYPE, g_variant_new_string(auth_type)); - - eap_type = wifi_eap_type_to_string(eap_config->eap_type); - if (eap_type != NULL) - g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_TYPE, g_variant_new_string(eap_type)); - - g_free(auth_type); - g_free(eap_type); - } - - params = g_variant_new("(s@a{sv})", config_id, g_variant_builder_end(b)); - g_variant_builder_unref(b); - g_free(config_id); - - result = g_dbus_connection_call_sync(handle->dbus_conn, - NETCONFIG_SERVICE, - NETCONFIG_WIFI_PATH, - NETCONFIG_IWIFI, - "SaveEapConfiguration", - params, - NULL, G_DBUS_CALL_FLAGS_NONE, - DBUS_REPLY_TIMEOUT, handle->ca, - &error); - - if (error) { - WIFI_LOG(WIFI_ERROR, "Fail to SaveEapConfiguration [%d: %s]", error->code, error->message); - ret = _wifi_error_to_enum(error->message); - g_error_free(error); - } - - if (result != NULL) - g_variant_unref(result); - - return ret; -} - -int wifi_load_eap_configurations(wifi_dbus *handle, const gchar *config_id, gchar **name, wifi_security_type_e *security_type, gchar **proxy_address, gboolean *is_hidden, struct _wifi_eap_config **eap_config, wifi_error_e *last_error) -{ - GError *error = NULL; - GVariant *result = NULL; - - result = g_dbus_connection_call_sync(handle->dbus_conn, - NETCONFIG_SERVICE, - NETCONFIG_WIFI_PATH, - NETCONFIG_IWIFI, - "LoadEapConfiguration", - g_variant_new("(s)", config_id), - NULL, G_DBUS_CALL_FLAGS_NONE, - DBUS_REPLY_TIMEOUT, handle->ca, - &error); - - if (result) { - GVariantIter *iter; - gchar *field; - GVariant *value; - - g_variant_get(result, "(a{sv})", &iter); - while (g_variant_iter_loop(iter, "{sv}", &field, &value)) { - if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) { - if (g_strcmp0(field, WIFI_CONFIG_NAME) == 0) { - *name = g_strdup(g_variant_get_string(value, NULL)); - } else if (g_strcmp0(field, WIFI_CONFIG_SECURITY_TYPE) == 0) { - *security_type = _wifi_security_type_to_int(g_variant_get_string(value, NULL)); - } else if (g_strcmp0(field, WIFI_CONFIG_HIDDEN) == 0) { - const gchar *r_hidden = g_variant_get_string(value, NULL); - if (g_strcmp0(r_hidden, "TRUE") == 0) - *is_hidden = TRUE; - else - *is_hidden = FALSE; - } else if (g_strcmp0(field, WIFI_CONFIG_PROXYADDRESS) == 0) { - const gchar *r_proxy_address = g_variant_get_string(value, NULL); - if (g_strcmp0(r_proxy_address, "NONE") == 0) - *proxy_address = NULL; - else - *proxy_address = g_strdup(r_proxy_address); - } else if (g_strcmp0(field, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY) == 0) { - const gchar *anonymous_identity = g_variant_get_string(value, NULL); - (*eap_config)->anonymous_identity = g_strdup(anonymous_identity); - } else if (g_strcmp0(field, WIFI_CONFIG_EAP_CACERT) == 0) { - const gchar *ca_cert = g_variant_get_string(value, NULL); - (*eap_config)->ca_cert = g_strdup(ca_cert); - } else if (g_strcmp0(field, WIFI_CONFIG_EAP_CLIENTCERT) == 0) { - const gchar *client_cert = g_variant_get_string(value, NULL); - (*eap_config)->client_cert = g_strdup(client_cert); - } else if (g_strcmp0(field, WIFI_CONFIG_EAP_PRIVATEKEY) == 0) { - const gchar *private_key = g_variant_get_string(value, NULL); - (*eap_config)->private_key = g_strdup(private_key); - } else if (g_strcmp0(field, WIFI_CONFIG_EAP_IDENTITY) == 0) { - const gchar *identity = g_variant_get_string(value, NULL); - (*eap_config)->identity = g_strdup(identity); - } else if (g_strcmp0(field, WIFI_CONFIG_EAP_TYPE) == 0) { - const gchar *eap_type = g_variant_get_string(value, NULL); - (*eap_config)->eap_type = wifi_eap_type_to_int(eap_type); - } else if (g_strcmp0(field, WIFI_CONFIG_EAP_AUTH_TYPE) == 0) { - const gchar *auth_type = g_variant_get_string(value, NULL); - (*eap_config)->eap_auth_type = wifi_eap_auth_type_to_int(auth_type); - } else if (g_strcmp0(field, WIFI_CONFIG_EAP_SUBJECT_MATCH) == 0) { - const gchar *subject_match = g_variant_get_string(value, NULL); - (*eap_config)->subject_match = g_strdup(subject_match); - } else if (g_strcmp0(field, WIFI_CONFIG_FAILURE) == 0) { - *last_error = _wifi_last_error_to_enum(g_variant_get_string(value, NULL)); - } - } - } - g_variant_iter_free(iter); - g_variant_unref(result); - } - - return WIFI_ERROR_NONE; -} - -int wifi_configuration_set_field(wifi_dbus *handle, const gchar *config_id, const gchar *key, const gchar *value) -{ - wifi_error_e ret = WIFI_ERROR_NONE; - GError *error = NULL; - GVariant *result = NULL; - - result = g_dbus_connection_call_sync(handle->dbus_conn, - NETCONFIG_SERVICE, - NETCONFIG_WIFI_PATH, - NETCONFIG_IWIFI, - "SetConfigField", - g_variant_new("(sss)", config_id, key, value), - NULL, G_DBUS_CALL_FLAGS_NONE, - DBUS_REPLY_TIMEOUT, handle->ca, - &error); - - if (error) { - WIFI_LOG(WIFI_ERROR, "Fail to SetConfigField [%d: %s]", error->code, error->message); - ret = _wifi_error_to_enum(error->message); - g_error_free(error); - } - - if (result != NULL) - g_variant_unref(result); - - return ret; -} - -int wifi_configuration_get_passphrase(wifi_dbus *handle, const gchar *config_id, gchar **passphrase) -{ - wifi_error_e ret = WIFI_ERROR_NONE; - GError *error = NULL; - GVariant *result = NULL; - gchar *val = NULL; - - result = g_dbus_connection_call_sync(handle->dbus_conn, - NETCONFIG_SERVICE, - NETCONFIG_WIFI_PATH, - NETCONFIG_IWIFI, - "GetConfigPassphrase", - g_variant_new("(s)", config_id), - NULL, G_DBUS_CALL_FLAGS_NONE, - DBUS_REPLY_TIMEOUT, handle->ca, - &error); - - if (error) { - WIFI_LOG(WIFI_ERROR, "Fail to GetConfigPassphrase [%d: %s]", error->code, error->message); - ret = _wifi_error_to_enum(error->message); - g_error_free(error); - return ret; - } - - if (result != NULL) { - g_variant_get(result, "(s)", &val); - g_variant_unref(result); - } - - *passphrase = g_strdup(val); - g_free(val); - - return ret; -} -//LCOV_EXCL_STOP diff --git a/src/wifi_dbus.c b/src/wifi_dbus.c deleted file mode 100755 index 7deba78..0000000 --- a/src/wifi_dbus.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 - -#include "wifi.h" -#include "wifi_dbus_private.h" -#include "net_wifi_private.h" - -int wifi_dbus_init(wifi_dbus **handle) -{ - struct _wifi_dbus *h; - GError *error = NULL; - - h = g_new0(struct _wifi_dbus, 1); - if (!h) { - WIFI_LOG(WIFI_ERROR, "_wifi_dbus alloc error"); //LCOV_EXCL_LINE - return WIFI_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE - } - -#if !GLIB_CHECK_VERSION(2, 36, 0) - g_type_init(); -#endif - - h->dbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); - if (!h->dbus_conn) { - WIFI_LOG(WIFI_ERROR, "dbus connection get failed: %s", error->message); //LCOV_EXCL_LINE - g_error_free(error); //LCOV_EXCL_LINE - g_free(h); //LCOV_EXCL_LINE - return WIFI_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE - } - h->ca = g_cancellable_new(); - - *handle = (wifi_dbus *)h; - - return WIFI_ERROR_NONE; -} - -int wifi_dbus_deinit(wifi_dbus *handle) -{ - g_return_val_if_fail(handle != NULL, WIFI_ERROR_INVALID_PARAMETER); - - g_cancellable_cancel(handle->ca); - g_object_unref(handle->ca); - g_object_unref(handle->dbus_conn); - - memset(handle, 0, sizeof(struct _wifi_dbus)); - g_free(handle); - - return WIFI_ERROR_NONE; -} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100755 index a251e5f..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -PROJECT(wifi_test C) - -SET(fw_test "${fw_name}-test") - -SET(dependents "capi-base-common glib-2.0 network") -SET(pc_dependents "capi-base-common") - -INCLUDE(FindPkgConfig) -pkg_check_modules(${fw_test} REQUIRED ${dependents}) -FOREACH(flag ${${fw_test}_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE") -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") - -aux_source_directory(. sources) -FOREACH(src ${sources}) - GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) - MESSAGE("${src_name}") - ADD_EXECUTABLE(${src_name} ${src}) - TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS}) -ENDFOREACH() - -INSTALL(TARGETS wifi_test RUNTIME DESTINATION bin/) diff --git a/test/wifi_test.c b/test/wifi_test.c deleted file mode 100755 index faf85c8..0000000 --- a/test/wifi_test.c +++ /dev/null @@ -1,1904 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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" - -gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data); - -static const char *__test_convert_error_to_string(wifi_error_e err_type) -{ - switch (err_type) { - case WIFI_ERROR_NONE: - return "NONE"; - case WIFI_ERROR_INVALID_PARAMETER: - return "INVALID_PARAMETER"; - case WIFI_ERROR_OUT_OF_MEMORY: - return "OUT_OF_MEMORY"; - case WIFI_ERROR_INVALID_OPERATION: - return "INVALID_OPERATION"; - case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED: - return "ADDRESS_FAMILY_NOT_SUPPORTED"; - case WIFI_ERROR_OPERATION_FAILED: - return "OPERATION_FAILED"; - case WIFI_ERROR_NO_CONNECTION: - return "NO_CONNECTION"; - case WIFI_ERROR_NOW_IN_PROGRESS: - return "NOW_IN_PROGRESS"; - case WIFI_ERROR_ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case WIFI_ERROR_OPERATION_ABORTED: - return "OPERATION_ABORTED"; - case WIFI_ERROR_DHCP_FAILED: - return "DHCP_FAILED"; - case WIFI_ERROR_INVALID_KEY: - return "INVALID_KEY"; - case WIFI_ERROR_NO_REPLY: - return "NO_REPLY"; - case WIFI_ERROR_SECURITY_RESTRICTED: - return "SECURITY_RESTRICTED"; - case WIFI_ERROR_PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case WIFI_ERROR_NOT_SUPPORTED: - return "NOT_SUPPORTED"; - } - - return "UNKNOWN"; -} - -static void __test_device_state_callback(wifi_device_state_e state, void* user_data) -{ - printf("Device state changed callback"); - - if (state == WIFI_DEVICE_STATE_ACTIVATED) - printf(", state : Activated\n"); - else - printf(", state : Deactivated\n"); -} - -static void __test_bg_scan_completed_callback(wifi_error_e error_code, void* user_data) -{ - printf("Background Scan Completed, error code : %s\n", - __test_convert_error_to_string(error_code)); -} - -static void __test_scan_request_callback(wifi_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_connection_state_callback(wifi_connection_state_e state, wifi_ap_h ap, void* user_data) -{ - int rv = 0; - char *ap_name = NULL; - - printf("Connection state changed callback"); - - switch (state) { - case WIFI_CONNECTION_STATE_CONNECTED: - printf(", state : Connected"); - break; - case WIFI_CONNECTION_STATE_ASSOCIATION: - printf(", state : Association"); - break; - case WIFI_CONNECTION_STATE_CONFIGURATION: - printf(", state : Configuration"); - break; - case WIFI_CONNECTION_STATE_DISCONNECTED: - printf(", state : Disconnected"); - break; - case WIFI_CONNECTION_STATE_FAILURE: - printf(", state : Failure"); - break; - default: - printf(", state : Unknown"); - } - - rv = wifi_ap_get_essid(ap, &ap_name); - if (rv != WIFI_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_error_e result, void* user_data) -{ - if (result == WIFI_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_error_e result, void* user_data) -{ - if (result == WIFI_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_error_e result, void* user_data) -{ - if (result == WIFI_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_error_e result, void* user_data) -{ - if (result == WIFI_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_rssi_level_e rssi_level, void* user_data) -{ - printf("RSSI level changed callback, level = %d\n", rssi_level); -} - -static const char* __test_print_state(wifi_connection_state_e state) -{ - switch (state) { - case WIFI_CONNECTION_STATE_FAILURE: - return "Failure"; - case WIFI_CONNECTION_STATE_DISCONNECTED: - return "Disconnected"; - case WIFI_CONNECTION_STATE_ASSOCIATION: - return "Association"; - case WIFI_CONNECTION_STATE_CONNECTED: - return "Connected"; - case WIFI_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_ap_h ap, void *user_data) -{ - int rv = 0; - char *ap_name = NULL; - wifi_connection_state_e state; - - rv = wifi_ap_get_essid(ap, &ap_name); - if (rv != WIFI_ERROR_NONE) { - printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv)); - return false; - } - - rv = wifi_ap_get_connection_state(ap, &state); - if (rv != WIFI_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; -} - -static bool __test_found_connect_ap_callback(wifi_ap_h ap, void *user_data) -{ - int rv = 0; - char *ap_name = NULL; - char *ap_name_part = (char*)user_data; - - rv = wifi_ap_get_essid(ap, &ap_name); - if (rv != WIFI_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)) { - bool required = false; - - if (wifi_ap_is_passphrase_required(ap, &required) == WIFI_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_ap_set_passphrase(ap, passphrase); - if (rv != WIFI_ERROR_NONE) { - printf("Fail to set passphrase : %s\n", __test_convert_error_to_string(rv)); - g_free(ap_name); - return false; - } - } - - rv = wifi_connect(ap, __test_connected_callback, NULL); - if (rv != WIFI_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_ap_h ap, void *user_data) -{ - int rv = 0; - char *ap_name = NULL; - char *ap_name_part = (char*)user_data; - - rv = wifi_ap_get_essid(ap, &ap_name); - if (rv != WIFI_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_connect_by_wps_pbc(ap, __test_connected_callback, NULL); - break; - case 2: - printf("Input PIN code :\n"); - rv = scanf("%31s", pin); - rv = wifi_connect_by_wps_pin(ap, pin, __test_connected_callback, NULL); - break; - default: - printf("Invalid input!\n"); - g_free(ap_name); - return false; - } - - if (rv != WIFI_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_ap_h ap, void *user_data) -{ - int rv = 0; - char *ap_name = NULL; - char *ap_name_part = (char*)user_data; - - rv = wifi_ap_get_essid(ap, &ap_name); - if (rv != WIFI_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_disconnect(ap, __test_disconnected_callback, NULL); - if (rv != WIFI_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_ap_h ap, void *user_data) -{ - int rv = 0; - char *ap_name = NULL; - char *ap_name_part = (char*)user_data; - - rv = wifi_ap_get_essid(ap, &ap_name); - if (rv != WIFI_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_forget_ap(ap); - if (rv != WIFI_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_ap_h ap, void *user_data) -{ - int rv = 0; - char *ap_name = NULL; - char *ap_name_part = (char*)user_data; - - rv = wifi_ap_get_essid(ap, &ap_name); - if (rv != WIFI_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_security_type_e type; - - if (wifi_ap_get_security_type(ap, &type) == WIFI_ERROR_NONE) - printf("Security type : %d\n", type); - else - printf("Fail to get Security type\n"); - - if (type != WIFI_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_ap_set_eap_passphrase(ap, input_str1, input_str2); - if (rv != WIFI_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_ap_get_eap_passphrase(ap, &inputed_name, &is_pass_set); - if (rv != WIFI_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"); - - printf("Input certificate file:\n"); - rv = scanf("%99s", input_str1); - - rv = wifi_ap_set_eap_ca_cert_file(ap, input_str1); - if (rv != WIFI_ERROR_NONE) { - printf("Fail to set eap certificatefile : %s\n", __test_convert_error_to_string(rv)); - g_free(ap_name); - return false; - } - - int input_int; - printf("Input EAP type:\n"); - printf("0 -> WIFI_EAP_TYPE_PEAP\n"); - printf("1 -> WIFI_EAP_TYPE_TLS\n"); - printf("2 -> WIFI_EAP_TYPE_TTLS\n"); - printf("3 -> WIFI_EAP_TYPE_SIM\n"); - printf("4 -> WIFI_EAP_TYPE_AKA\n"); - rv = scanf("%d", &input_int); - - rv = wifi_ap_set_eap_type(ap, input_int); - if (rv != WIFI_ERROR_NONE) { - printf("Fail to set eap type : %s\n", __test_convert_error_to_string(rv)); - g_free(ap_name); - return false; - } - - printf("Input EAP authentication type:\n"); - printf("0 -> WIFI_EAP_AUTH_TYPE_NONE\n"); - printf("1 -> WIFI_EAP_AUTH_TYPE_PAP\n"); - printf("2 -> WIFI_EAP_AUTH_TYPE_MSCHAP\n"); - printf("3 -> WIFI_EAP_AUTH_TYPE_MSCHAPV2\n"); - printf("4 -> WIFI_EAP_AUTH_TYPE_GTC\n"); - printf("5 -> WIFI_EAP_AUTH_TYPE_MD5\n"); - rv = scanf("%d", &input_int); - - rv = wifi_ap_set_eap_auth_type(ap, input_int); - if (rv != WIFI_ERROR_NONE) { - printf("Fail to set eap auth type : %s\n", __test_convert_error_to_string(rv)); - g_free(ap_name); - return false; - } - - rv = wifi_connect(ap, __test_connected_callback, NULL); - if (rv != WIFI_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_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_found_change_ip_method_callback(wifi_ap_h ap, void *user_data) -{ - int rv; - char *ap_name; - char *ap_name_part = (char*)user_data; - - rv = wifi_ap_get_essid(ap, &ap_name); - if (rv != WIFI_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_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) { - 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"); - return false; - } - - switch (method) { - case 1: - type = WIFI_IP_CONFIG_TYPE_DYNAMIC; - break; - case 2: - type = WIFI_IP_CONFIG_TYPE_STATIC; - break; - case 3: - type = WIFI_IP_CONFIG_TYPE_AUTO; - break; - default: - printf("Invalid input!\n"); - g_free(ap_name); - return false; - } - - rv = wifi_ap_set_ip_config_type(ap, address_type, type); - if (rv != WIFI_ERROR_NONE) - printf("Fail to set ip method type[%s]\n", __test_convert_error_to_string(rv)); - - if (type == WIFI_IP_CONFIG_TYPE_STATIC) { - char ip_addr[16]; - - printf("Input new ip address (x:skip, 0:clear) :\n"); - rv = scanf("%15s", ip_addr); - if (rv > 0) { - switch (ip_addr[0]) { - case 'x': - rv = WIFI_ERROR_NONE; - break; - case '0': - rv = wifi_ap_set_ip_address(ap, address_type, NULL); - break; - default: - rv = wifi_ap_set_ip_address(ap, address_type, ip_addr); - } - - if (rv != WIFI_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("%15s", ip_addr); - if (rv > 0) { - switch (ip_addr[0]) { - case 'x': - rv = WIFI_ERROR_NONE; - break; - case '0': - rv = wifi_ap_set_subnet_mask(ap, address_type, NULL); - break; - default: - rv = wifi_ap_set_subnet_mask(ap, address_type, ip_addr); - } - - if (rv != WIFI_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("%15s", ip_addr); - if (rv > 0) { - switch (ip_addr[0]) { - case 'x': - rv = WIFI_ERROR_NONE; - break; - case '0': - rv = wifi_ap_set_gateway_address(ap, address_type, NULL); - break; - default: - rv = wifi_ap_set_gateway_address(ap, address_type, ip_addr); - } - - if (rv != WIFI_ERROR_NONE) - printf("Fail to set gateway address[%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_ap_h ap, void *user_data) -{ - int rv, address_type; - char *ap_name; - char *ap_name_part = (char*)user_data; - - rv = wifi_ap_get_essid(ap, &ap_name); - if (rv != WIFI_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_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"); - return false; - } - - switch (method) { - case 1: - type = WIFI_PROXY_TYPE_DIRECT; - break; - case 2: - type = WIFI_PROXY_TYPE_MANUAL; - break; - case 3: - type = WIFI_PROXY_TYPE_AUTO; - break; - default: - printf("Invalid input!\n"); - g_free(ap_name); - return false; - } - - rv = wifi_ap_set_proxy_type(ap, type); - if (rv != WIFI_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_ERROR_NONE; - break; - case '0': - rv = wifi_ap_set_proxy_address(ap, address_type, NULL); - break; - default: - rv = wifi_ap_set_proxy_address(ap, address_type, proxy_addr); - } - - if (rv != WIFI_ERROR_NONE) - printf("Fail to set proxy address[%s]\n", __test_convert_error_to_string(rv)); - } - - g_free(ap_name); - return false; - } - - g_free(ap_name); - return true; -} - -static bool __test_found_print_ap_info_callback(wifi_ap_h ap, void *user_data) -{ - int rv, address_type = 0; - char *ap_name; - char *str_value; - int int_value; - wifi_connection_state_e conn_state; - wifi_ip_config_type_e ip_type; - wifi_proxy_type_e proxy_type; - wifi_security_type_e sec_type; - wifi_encryption_type_e enc_type; - wifi_eap_type_e eap_type; - wifi_eap_auth_type_e eap_auth_type; - bool bool_value; - char *ap_name_part = (char*)user_data; - - rv = wifi_ap_get_essid(ap, &ap_name); - if (rv != WIFI_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_ap_get_bssid(ap, &str_value) == WIFI_ERROR_NONE) { - printf("BSSID : %s\n", str_value); - g_free(str_value); - } else - printf("Fail to get BSSID\n"); - - if (wifi_ap_get_rssi(ap, &int_value) == WIFI_ERROR_NONE) - printf("RSSI : %d\n", int_value); - else - printf("Fail to get RSSI\n"); - - if (wifi_ap_get_frequency(ap, &int_value) == WIFI_ERROR_NONE) - printf("Frequency : %d\n", int_value); - else - printf("Fail to get Frequency\n"); - - if (wifi_ap_get_max_speed(ap, &int_value) == WIFI_ERROR_NONE) - printf("Max speed : %d\n", int_value); - else - printf("Fail to get Max speed\n"); - - if (wifi_ap_is_favorite(ap, &bool_value) == WIFI_ERROR_NONE) - printf("Favorite : %s\n", bool_value ? "TRUE" : "FALSE"); - else - printf("Fail to get Favorite\n"); - - /* Network info */ - if (wifi_ap_get_connection_state(ap, &conn_state) == WIFI_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 false; - } - - if (wifi_ap_get_ip_config_type(ap, address_type, &ip_type) == WIFI_ERROR_NONE) - printf("IP config type : %d\n", ip_type); - else - printf("Fail to get IP config type\n"); - - if (wifi_ap_get_ip_address(ap, address_type, &str_value) == WIFI_ERROR_NONE) { - printf("IP : %s\n", str_value); - g_free(str_value); - } else - printf("Fail to get IP\n"); - - if (wifi_ap_get_subnet_mask(ap, address_type, &str_value) == WIFI_ERROR_NONE) { - printf("Subnet mask : %s\n", str_value); - g_free(str_value); - } else - printf("Fail to get Subnet mask\n"); - - if (wifi_ap_get_gateway_address(ap, address_type, &str_value) == WIFI_ERROR_NONE) { - printf("Gateway : %s\n", str_value); - g_free(str_value); - } else - printf("Fail to get Gateway\n"); - - if (wifi_ap_get_proxy_type(ap, &proxy_type) == WIFI_ERROR_NONE) - printf("Proxy type : %d\n", proxy_type); - else - printf("Fail to get Proxy type\n"); - - if (wifi_ap_get_proxy_address(ap, address_type, &str_value) == WIFI_ERROR_NONE) { - printf("Proxy : %s\n", str_value); - g_free(str_value); - } else - printf("Fail to get Proxy\n"); - - if (wifi_ap_get_dns_address(ap, 1, address_type, &str_value) == WIFI_ERROR_NONE) { - printf("DNS1 : %s\n", str_value); - g_free(str_value); - } else - printf("Fail to get DNS1\n"); - - if (wifi_ap_get_dns_address(ap, 2, address_type, &str_value) == WIFI_ERROR_NONE) { - printf("DNS2 : %s\n", str_value); - g_free(str_value); - } else - printf("Fail to get DNS2\n"); - - /* Security info */ - if (wifi_ap_get_security_type(ap, &sec_type) == WIFI_ERROR_NONE) - printf("Security type : %d\n", sec_type); - else - printf("Fail to get Security type\n"); - - if (wifi_ap_get_encryption_type(ap, &enc_type) == WIFI_ERROR_NONE) - printf("Encryption type : %d\n", enc_type); - else - printf("Fail to get Encryption type\n"); - - if (wifi_ap_is_passphrase_required(ap, &bool_value) == WIFI_ERROR_NONE) - printf("Passphrase required : %s\n", bool_value ? "TRUE" : "FALSE"); - else - printf("Fail to get Passphrase required\n"); - - if (wifi_ap_is_wps_supported(ap, &bool_value) == WIFI_ERROR_NONE) - printf("WPS supported : %s\n", bool_value ? "TRUE" : "FALSE"); - else - printf("Fail to get WPS supported\n"); - - if (sec_type != WIFI_SECURITY_TYPE_EAP) { - g_free(ap_name); - return false; - } - - /* EAP info */ - if (wifi_ap_get_eap_type(ap, &eap_type) == WIFI_ERROR_NONE) - printf("EAP type : %d\n", eap_type); - else - printf("Fail to get EAP type\n"); - - if (wifi_ap_get_eap_auth_type(ap, &eap_auth_type) == WIFI_ERROR_NONE) - printf("EAP auth type : %d\n", eap_auth_type); - else - printf("Fail to get EAP auth type\n"); - - if (wifi_ap_get_eap_passphrase(ap, &str_value, &bool_value) == WIFI_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_ap_get_eap_ca_cert_file(ap, &str_value) == WIFI_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_ap_get_eap_client_cert_file(ap, &str_value) == WIFI_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_ap_get_eap_private_key_file(ap, &str_value) == WIFI_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_config_h config, void *user_data) -{ - gchar *name = NULL; - wifi_security_type_e security_type; - - wifi_config_get_name(config, &name); - wifi_config_get_security_type(config, &security_type); - - printf("Name[%s] ", name); - printf("Security type[%d] ", security_type); - if (security_type == WIFI_SECURITY_TYPE_EAP) { - wifi_eap_type_e eap_type; - wifi_eap_auth_type_e eap_auth_type; - wifi_config_get_eap_type(config, &eap_type); - printf("Eap type[%d] ", eap_type); - wifi_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_config_h config, void *user_data) -{ - - struct _wifi_conf *c = (struct _wifi_conf *)user_data; - gchar *name = NULL; - wifi_security_type_e security_type; - - wifi_config_get_name(config, &name); - wifi_config_get_security_type(config, &security_type); - - if (strncmp(name, c->name, sizeof(c->name)) == 0 && security_type == c->type) { - int rv = wifi_config_remove(config); - if (rv != WIFI_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_aps_callback(wifi_ap_h ap, void *user_data) -{ - printf("Found specific ap Completed\n"); - - int rv; - char *ap_name = NULL; - wifi_security_type_e security_type = WIFI_SECURITY_TYPE_NONE; - - rv = wifi_ap_get_essid(ap, &ap_name); - if (rv != WIFI_ERROR_NONE) { - printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv)); - return -1; - } - printf("[AP name] : %s\n", ap_name); - - rv = wifi_ap_get_security_type(ap, &security_type); - if (rv == WIFI_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_SECURITY_TYPE_WEP: - case WIFI_SECURITY_TYPE_WPA_PSK: - case WIFI_SECURITY_TYPE_WPA2_PSK: - { - char passphrase[100]; - printf("Input passphrase for %s : ", ap_name); - rv = scanf("%99s", passphrase); - - rv = wifi_ap_set_passphrase(ap, passphrase); - if (rv != WIFI_ERROR_NONE) { - printf("Fail to set passphrase : %s\n", __test_convert_error_to_string(rv)); - g_free(ap_name); - return false; - } - } - break; - case WIFI_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_ap_set_eap_passphrase(ap, input_str1, input_str2); - if (rv != WIFI_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_ap_get_eap_passphrase(ap, &inputed_name, &is_pass_set); - if (rv != WIFI_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_SECURITY_TYPE_NONE: - default: - break; - } - - rv = wifi_connect(ap, __test_connected_callback, NULL); - if (rv != WIFI_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_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_ERROR_NONE) - return; - - rv = wifi_foreach_found_specific_aps(__test_found_specific_aps_callback, user_data); - if (rv != WIFI_ERROR_NONE) { - printf("Fail to get specific AP(can't get AP list) [%s]\n", __test_convert_error_to_string(rv)); - return; - } -} - -int test_wifi_init(void) -{ - int rv = wifi_initialize(); - - if (rv == WIFI_ERROR_NONE) { - wifi_set_device_state_changed_cb(__test_device_state_callback, NULL); - wifi_set_background_scan_cb(__test_bg_scan_completed_callback, NULL); - wifi_set_connection_state_changed_cb(__test_connection_state_callback, NULL); - wifi_set_rssi_level_changed_cb(__test_rssi_level_callback, NULL); - } else { - printf("Wifi init failed [%s]\n", __test_convert_error_to_string(rv)); - return -1; - } - - printf("Wifi init succeeded\n"); - return 1; -} - -int test_wifi_deinit(void) -{ - int rv = 0; - - rv = wifi_deinitialize(); - - if (rv != WIFI_ERROR_NONE) { - printf("Wifi deinit failed [%s]\n", __test_convert_error_to_string(rv)); - return -1; - } - - printf("Wifi deinit succeeded\n"); - return 1; -} - -int test_wifi_activate(void) -{ - int rv = 0; - - bool state = false; - - rv = wifi_is_activated(&state); - - if (state != true) { - rv = wifi_activate(__test_activated_callback, NULL); - - if (rv != WIFI_ERROR_NONE) { - printf("Fail to activate Wi-Fi device [%s]", __test_convert_error_to_string(rv)); - return -1; - } - } else { - __test_activated_callback(WIFI_ERROR_NONE, NULL); - } - - return 1; -} - -int test_wifi_deactivate(void) -{ - int rv = 0; - bool state = false; - - rv = wifi_is_activated(&state); - - if (state == true) { - rv = wifi_deactivate(__test_deactivated_callback, NULL); - - if (rv != WIFI_ERROR_NONE) { - printf("Fail to deactivate Wi-Fi device [%s]\n", __test_convert_error_to_string(rv)); - return -1; - } - } else { - __test_deactivated_callback(WIFI_ERROR_NONE, NULL); - } - - return 1; -} - -int test_is_activated(void) -{ - int rv = 0; - bool state = false; - - rv = wifi_is_activated(&state); - - if (rv != WIFI_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_get_connection_state(void) -{ - int rv = 0; - wifi_connection_state_e connection_state; - - rv = wifi_get_connection_state(&connection_state); - - if (rv != WIFI_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_CONNECTION_STATE_ASSOCIATION: - printf("Association\n"); - break; - case WIFI_CONNECTION_STATE_CONNECTED: - printf("Connected\n"); - break; - case WIFI_CONNECTION_STATE_CONFIGURATION: - printf("Configuration\n"); - break; - case WIFI_CONNECTION_STATE_DISCONNECTED: - printf("Disconnected\n"); - break; - default: - printf("Unknown\n"); - } - - return 1; -} - -int test_get_mac_address(void) -{ - int rv = 0; - char *mac_addr = NULL; - - rv = wifi_get_mac_address(&mac_addr); - - if (rv != WIFI_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); - g_free(mac_addr); - - return 1; -} - -int test_get_interface_name(void) -{ - int rv = 0; - char *if_name = NULL; - - rv = wifi_get_network_interface_name(&if_name); - - if (rv != WIFI_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); - g_free(if_name); - - return 1; -} - -int test_scan_request(void) -{ - int rv = 0; - - rv = wifi_scan(__test_scan_request_callback, NULL); - - if (rv != WIFI_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_get_connected_ap(void) -{ - int rv = 0; - char *ap_name = NULL; - wifi_ap_h ap_h; - - rv = wifi_get_connected_ap(&ap_h); - if (rv != WIFI_ERROR_NONE) { - printf("Fail to get connected AP [%s]\n", __test_convert_error_to_string(rv)); - return -1; - } - - rv = wifi_ap_get_essid(ap_h, &ap_name); - if (rv != WIFI_ERROR_NONE) { - printf("Fail to get essid [%s]\n", __test_convert_error_to_string(rv)); - wifi_ap_destroy(ap_h); - return -1; - } - - printf("Connected AP : %s\n", ap_name); - g_free(ap_name); - wifi_ap_destroy(ap_h); - - return 1; -} - -int test_foreach_found_aps(void) -{ - int rv = 0; - - rv = wifi_foreach_found_aps(__test_found_ap_callback, NULL); - if (rv != WIFI_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_connect_ap(void) -{ - int rv = 0; - char ap_name[33]; - bool state = false; - - wifi_is_activated(&state); - if (state == false) - return -1; - - printf("Input a part of AP name to connect : "); - rv = scanf("%32s", ap_name); - - rv = wifi_foreach_found_aps(__test_found_connect_ap_callback, ap_name); - if (rv != WIFI_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_connect_specific_ap(void) -{ - int rv; - char ap_name[33]; - - printf("Input a part of specific AP name to connect : "); - rv = scanf("%32s", ap_name); - if (rv <= 0) - return -1; - - rv = wifi_scan_specific_ap(ap_name, __test_scan_specific_ap_callback, NULL); - - if (rv != WIFI_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_disconnect_ap(void) -{ - int rv = 0; - char ap_name[33]; - bool state = false; - - wifi_is_activated(&state); - if (state == false) - return -1; - - printf("Input a part of AP name to disconnect : "); - rv = scanf("%32s", ap_name); - - rv = wifi_foreach_found_aps(__test_found_disconnect_ap_callback, ap_name); - if (rv != WIFI_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_connect_wps(void) -{ - int rv = 0; - char ap_name[33]; - bool state = false; - - wifi_is_activated(&state); - if (state == false) - return -1; - - printf("Input a part of AP name to connect by wps : "); - rv = scanf("%32s", ap_name); - - rv = wifi_foreach_found_aps(__test_found_connect_wps_callback, ap_name); - if (rv != WIFI_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_forget_ap(void) -{ - int rv = 0; - char ap_name[33]; - bool state = false; - - wifi_is_activated(&state); - if (state == false) - return -1; - - printf("Input a part of AP name to forget : "); - rv = scanf("%32s", ap_name); - - rv = wifi_foreach_found_aps(__test_found_forget_ap_callback, ap_name); - if (rv != WIFI_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_connect_eap_ap(void) -{ - int rv = 0; - char ap_name[33]; - bool state = false; - - wifi_is_activated(&state); - if (state == false) - return -1; - - printf("Input a part of AP name to connect : "); - rv = scanf("%32s", ap_name); - - rv = wifi_foreach_found_aps(__test_found_eap_ap_callback, ap_name); - if (rv != WIFI_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_set_ip_method(void) -{ - int rv; - char ap_name[33]; - bool state; - - rv = wifi_is_activated(&state); - if (rv != WIFI_ERROR_NONE || state == false) - return -1; - - printf("Input a part of AP name to change IP method : "); - rv = scanf("%32s", ap_name); - if (rv <= 0) - return -1; - - rv = wifi_foreach_found_aps(__test_found_change_ip_method_callback, ap_name); - if (rv != WIFI_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_set_proxy_method(void) -{ - int rv; - char ap_name[33]; - bool state; - - rv = wifi_is_activated(&state); - if (rv != WIFI_ERROR_NONE || state == false) - return -1; - - printf("Input a part of AP name to change Proxy method : "); - rv = scanf("%32s", ap_name); - if (rv <= 0) - return -1; - - rv = wifi_foreach_found_aps(__test_found_change_proxy_method_callback, ap_name); - if (rv != WIFI_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_get_ap_info(void) -{ - int rv; - char ap_name[33]; - bool state; - - rv = wifi_is_activated(&state); - if (rv != WIFI_ERROR_NONE || state == false) - return -1; - - printf("Input a part of AP name to get detailed info : "); - rv = scanf("%32s", ap_name); - if (rv <= 0) - return -1; - - rv = wifi_foreach_found_aps(__test_found_print_ap_info_callback, ap_name); - if (rv != WIFI_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_load_configuration(void) -{ - int rv; - - rv = wifi_config_foreach_configuration(_test_config_list_cb, NULL); - if (rv != WIFI_ERROR_NONE) { - printf("Fail to get configurations [%s]\n", __test_convert_error_to_string(rv)); - return -1; - } - - return 1; -} - -int test_save_configuration(void) -{ - int rv; - char name[33] = { 0, }; - char passphrase[100] = { 0, }; - int type = 0; - wifi_config_h config; - - printf("Input AP configuration\n"); - printf("Name : "); - rv = scanf("%32s", 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_config_create(name, passphrase, type, &config); - if (rv != WIFI_ERROR_NONE) - return -1; - - rv = wifi_config_save_configuration(config); - if (rv != WIFI_ERROR_NONE) - return -1; - - rv = wifi_config_destroy(config); - if (rv != WIFI_ERROR_NONE) - return -1; - - return 1; -} - -int test_remove_configuration(void) -{ - int rv; - struct _wifi_conf c; - - printf("Input AP configuration\n"); - printf("Name : "); - rv = scanf("%32s", 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_config_foreach_configuration(_test_config_list_cb_for_remove, &c); - if (rv != WIFI_ERROR_NONE) { - printf("Fail to get configurations [%s]\n", __test_convert_error_to_string(rv)); - return -1; - } - - return 1; -} - -int test_set_configuration_proxy_and_hidden(void) -{ - int rv; - char name[33] = { 0, }; - char passphrase[100] = { 0, }; - int type = 0; - char proxy[100] = { 0, }; - int hidden = 0; - wifi_config_h config; - - printf("Input AP configuration\n"); - printf("Name : "); - rv = scanf("%32s", 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; - - printf("Proxy(server:port) : "); - rv = scanf("%99s", proxy); - if (rv <= 0) - return -1; - - printf("Hidden(1:Hidden) : "); - rv = scanf("%d", &hidden); - if (rv <= 0) - return -1; - - rv = wifi_config_create(name, passphrase, type, &config); - if (rv != WIFI_ERROR_NONE) - return -1; - - rv = wifi_config_save_configuration(config); - if (rv != WIFI_ERROR_NONE) { - wifi_config_destroy(config); - return -1; - } - - rv = wifi_config_set_proxy_address(config, WIFI_ADDRESS_FAMILY_IPV4, proxy); - if (rv != WIFI_ERROR_NONE) { - wifi_config_destroy(config); - return -1; - } - - if (hidden == 1) - rv = wifi_config_set_hidden_ap_property(config, TRUE); - else - rv = wifi_config_set_hidden_ap_property(config, FALSE); - if (rv != WIFI_ERROR_NONE) { - wifi_config_destroy(config); - return -1; - } - - rv = wifi_config_destroy(config); - if (rv != WIFI_ERROR_NONE) - return -1; - - return 1; -} - -int test_set_eap_configuration(void) -{ - int rv; - char name[33] = { 0, }; - char passphrase[100] = { 0, }; - int type = WIFI_SECURITY_TYPE_EAP; - wifi_config_h config; - - printf("Input EAP configuration\n"); - printf("Name : "); - rv = scanf("%32s", name); - if (rv <= 0) - return -1; - - printf("Passphrase : "); - rv = scanf("%99s", passphrase); - if (rv <= 0) - return -1; - - rv = wifi_config_create(name, passphrase, type, &config); - if (rv != WIFI_ERROR_NONE) - return -1; - - rv = wifi_config_save_configuration(config); - if (rv != WIFI_ERROR_NONE) - return -1; - - rv = wifi_config_set_eap_type(config, WIFI_EAP_TYPE_TLS); - if (rv != WIFI_ERROR_NONE) - return -1; - - rv = wifi_config_set_eap_auth_type(config, WIFI_EAP_AUTH_TYPE_MD5); - if (rv != WIFI_ERROR_NONE) - return -1; - - rv = wifi_config_destroy(config); - if (rv != WIFI_ERROR_NONE) - return -1; - - return 1; -} - -int test_wifi_tdls_disconnect(void) -{ - int rv = 0; - - char peer_mac[18]; - printf("Enter Mac_address: "); - if (scanf(" %17s", peer_mac) < 1) - return -1; - - if (strlen(peer_mac) > 17) { - printf("Wrong Mac_address\n"); - return -1; - } - - rv = wifi_tdls_disconnect(peer_mac); - if (rv != WIFI_ERROR_NONE) { - printf("test_wifi_tdls_disconnect() is failed [%s]\n", __test_convert_error_to_string(rv)); - return -1; - } - return 1; -} - -int test_wifi_tdls_get_connected_peer(void) -{ - int rv = 0; - char *mac_addr = NULL; - - rv = wifi_tdls_get_connected_peer(&mac_addr); - if (rv != WIFI_ERROR_NONE) { - printf("wifi_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_connect_specific_ap(void) -{ - int rv = 0; - char ap_name[33]; - char passphrase[65]; - bool state = false; - int sec_type; - - wifi_is_activated(&state); - if (state == false) - return -1; - - printf("Input hidden AP name to connect : "); - rv = scanf("%32s", 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_connect_specific_ap(ap_name, sec_type, passphrase, - __test_connected_callback, NULL); - if (rv != WIFI_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; -} - -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_deinitialize(); - - if (rv != WIFI_ERROR_NONE) - printf("Fail to deinitialize.\n"); - - exit(1); - } - - if (a[0] == '\n' || a[0] == '\r') { - printf("\n\n Network Connection API Test App\n\n"); - printf("Options..\n"); - 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 - Set configuration proxy and hidden\n"); - printf("p - Set EAP configuration\n"); - printf("q - TDLS TearDown\n"); - printf("r - TDLS Get Connected Peer\n"); - printf("s - Connect to Hidden AP\n"); - printf(LOG_RED "0 - Exit \n" LOG_END); - - printf("ENTER - Show options menu.......\n"); - } - - switch (a[0]) { - case '1': - rv = test_wifi_init(); - break; - case '2': - rv = test_wifi_deinit(); - break; - case '3': - rv = test_wifi_activate(); - break; - case '4': - rv = test_wifi_deactivate(); - break; - case '5': - rv = test_is_activated(); - break; - case '6': - rv = test_get_connection_state(); - break; - case '7': - rv = test_get_mac_address(); - break; - case '8': - rv = test_get_interface_name(); - break; - case '9': - rv = test_scan_request(); - break; - case 'a': - rv = test_get_connected_ap(); - break; - case 'b': - rv = test_foreach_found_aps(); - break; - case 'c': - rv = test_connect_ap(); - break; - case 'd': - rv = test_disconnect_ap(); - break; - case 'e': - rv = test_connect_wps(); - break; - case 'f': - rv = test_forget_ap(); - break; - case 'g': - rv = test_connect_eap_ap(); - break; - case 'h': - rv = test_set_ip_method(); - break; - case 'i': - rv = test_set_proxy_method(); - break; - case 'j': - rv = test_get_ap_info(); - break; - case 'k': - rv = test_connect_specific_ap(); - break; - case 'l': - rv = test_load_configuration(); - break; - case 'm': - rv = test_save_configuration(); - break; - case 'n': - rv = test_remove_configuration(); - break; - case 'o': - rv = test_set_configuration_proxy_and_hidden(); - break; - case 'p': - rv = test_set_eap_configuration(); - break; - case 'q': - rv = test_wifi_tdls_disconnect(); - break; - case 'r': - rv = test_wifi_tdls_get_connected_peer(); - break; - case 's': - rv = test_wifi_connect_specific_ap(); - break; - default: - break; - } - - if (rv == 1) - printf("Operation succeeded!\n"); - else - printf("Operation failed!\n"); - - return TRUE; -} - -- cgit v1.2.3