From: Maneesh Jain Date: Fri, 21 Apr 2017 04:33:50 +0000 (+0530) Subject: TDLS: Implement TDLS Channel Switch Feature X-Git-Tag: submit/tizen/20170421.072430^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0b0d6dce5b0813d51e4e4bb847805bffdf0ec1aa;p=platform%2Fcore%2Fapi%2Fwifi-manager.git TDLS: Implement TDLS Channel Switch Feature Following CAPI's added to support this. a./ wifi_manager_tdls_enable_channel_switching() b./ wifi_manager_tdls_disable_channel_switching() Change-Id: I87d19d6771381592c1f7df271de58093c3c0ced6 Signed-off-by: Maneesh Jain --- diff --git a/include/network_dbus.h b/include/network_dbus.h index 1439013..6e6d3c2 100755 --- a/include/network_dbus.h +++ b/include/network_dbus.h @@ -119,6 +119,8 @@ int _net_dbus_tdls_disconnect(const char* peer_mac_addr); int _net_dbus_tdls_connected_peer(char** peer_mac_addr); int _net_dbus_tdls_connect(const char *peer_mac_addr); int _net_dbus_tdls_discover(); +int _net_dbus_tdls_enable_channel_switch(const char* peer_mac_addr, int freq); +int _net_dbus_tdls_disable_channel_switch(const char* peer_mac_addr); int _net_dbus_config_get_id_list(GSList **list); int _net_dbus_config_set_field(const gchar *config_id, const gchar *key, const gchar *value); diff --git a/include/network_interface.h b/include/network_interface.h index 6059c5b..16509cb 100755 --- a/include/network_interface.h +++ b/include/network_interface.h @@ -249,6 +249,8 @@ int net_wifi_tdls_disconnect(const char* peer_mac_addr); int net_wifi_tdls_connected_peer(char** peer_mac_addr); int net_wifi_tdls_connect(const char* peer_mac_addr); int net_wifi_tdls_discover(const char* peer_mac_addr); +int net_wifi_tdls_enable_channel_switch(const char* peer_mac_addr, int freq); +int net_wifi_tdls_disbale_channel_switch(const char* peer_mac_addr); int net_get_device_policy_wifi(void); int net_get_device_policy_wifi_profile(void); diff --git a/src/network_dbus.c b/src/network_dbus.c index 265e841..3cff691 100755 --- a/src/network_dbus.c +++ b/src/network_dbus.c @@ -2178,6 +2178,79 @@ int _net_dbus_tdls_discover(const char *peer_mac_addr) return Error; } +int _net_dbus_tdls_enable_channel_switch(const char* peer_mac_addr, int freq) +{ + __NETWORK_FUNC_ENTER__; + + net_err_e Error = NET_ERR_NONE; + GVariant *message = NULL; + GVariant *params = NULL; + gint32 ret = -1; + + params = g_variant_new("(si)", peer_mac_addr, freq); + + message = _net_invoke_dbus_method( + NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH, + NETCONFIG_WIFI_INTERFACE, "TdlsChannelSwitch", params, &Error); + + if (message == NULL) { + WIFI_LOG(WIFI_ERROR, "Failed to Enable TDLS Channel Switch Request\n"); + __NETWORK_FUNC_EXIT__; + return Error; + } + + g_variant_get(message, "(i)", &ret); + + WIFI_LOG(WIFI_INFO, "Status [%d]\n", ret); + + if (ret == 0) + Error = NET_ERR_NONE; + else + Error = NET_ERR_UNKNOWN; + + g_variant_unref(message); + __NETWORK_FUNC_EXIT__; + + return Error; +} + +int _net_dbus_tdls_disable_channel_switch(const char* peer_mac_addr) +{ + __NETWORK_FUNC_ENTER__; + + net_err_e Error = NET_ERR_NONE; + GVariant *message = NULL; + GVariant *params = NULL; + gint32 ret = -1; + + params = g_variant_new("(s)", peer_mac_addr); + + message = _net_invoke_dbus_method( + NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH, + NETCONFIG_WIFI_INTERFACE, "TdlsCancelChannelSwitch", params, &Error); + + if (message == NULL) { + WIFI_LOG(WIFI_ERROR, "Failed to Disable TDLS Channel Switch Request\n"); + __NETWORK_FUNC_EXIT__; + return Error; + } + + g_variant_get(message, "(i)", &ret); + + WIFI_LOG(WIFI_INFO, "Status [%d]\n", ret); + + if (ret == 0) + Error = NET_ERR_NONE; + else + Error = NET_ERR_UNKNOWN; + + g_variant_unref(message); + __NETWORK_FUNC_EXIT__; + + return Error; +} + + int _net_dbus_config_get_id_list(GSList **list) { diff --git a/src/network_interface.c b/src/network_interface.c index ea896b1..d13bc89 100755 --- a/src/network_interface.c +++ b/src/network_interface.c @@ -2127,6 +2127,63 @@ int net_wifi_tdls_connected_peer(char** peer_mac_addr) } +int net_wifi_tdls_enable_channel_switch(const char* peer_mac_addr, int freq) +{ + __NETWORK_FUNC_ENTER__; + + net_err_e Error = NET_ERR_NONE; + + if (peer_mac_addr == NULL || freq < 0) { + WIFI_LOG(WIFI_ERROR, "invalid parameter\n"); + __NETWORK_FUNC_EXIT__; + return NET_ERR_INVALID_PARAM; + } + + if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) { + WIFI_LOG(WIFI_ERROR, "Application is not registered\n"); + __NETWORK_FUNC_EXIT__; + return NET_ERR_APP_NOT_REGISTERED; + } + + Error = _net_dbus_tdls_enable_channel_switch(peer_mac_addr, freq); + if (Error != NET_ERR_NONE) + WIFI_LOG(WIFI_ERROR, "net_wifi_tdls_enable_channel_switch failed\n"); + + __NETWORK_FUNC_EXIT__; + return Error; + +} + +int net_wifi_tdls_disbale_channel_switch(const char* peer_mac_addr) +{ + __NETWORK_FUNC_ENTER__; + + net_err_e Error = NET_ERR_NONE; + + if (peer_mac_addr == NULL) { + WIFI_LOG(WIFI_ERROR, "invalid parameter\n"); + __NETWORK_FUNC_EXIT__; + return NET_ERR_INVALID_PARAM; + } + + if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) { + WIFI_LOG(WIFI_ERROR, "Application is not registered\n"); + __NETWORK_FUNC_EXIT__; + return NET_ERR_APP_NOT_REGISTERED; + } + + Error = _net_dbus_tdls_disable_channel_switch(peer_mac_addr); + + if (Error != NET_ERR_NONE) + WIFI_LOG(WIFI_ERROR, "net_wifi_tdls_disbale_channel_switch failed\n"); + + + __NETWORK_FUNC_EXIT__; + return Error; + +} + + int net_wifi_tdls_connect(const char* peer_mac_addr) { __NETWORK_FUNC_ENTER__; diff --git a/src/wifi_tdls.c b/src/wifi_tdls.c index 96be368..0102cef 100755 --- a/src/wifi_tdls.c +++ b/src/wifi_tdls.c @@ -195,8 +195,52 @@ EXPORT_API int wifi_manager_tdls_unset_state_changed_cb(wifi_manager_h wifi) WIFI_LOG(WIFI_ERROR, "Invalid parameter"); return WIFI_MANAGER_ERROR_INVALID_PARAMETER; } + return __wifi_set_tdls_connection_state_changed_cb(wifi, NULL, NULL); +} + +EXPORT_API int wifi_manager_tdls_enable_channel_switching(wifi_manager_h wifi, + const char *peer_mac_addr, int freq) +{ + CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); + CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE); + + if (peer_mac_addr == NULL || !(__wifi_check_handle_validity(wifi)) + || freq < 0) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); + return WIFI_MANAGER_ERROR_INVALID_PARAMETER; + } + int rv = 0; + + rv = net_wifi_tdls_enable_channel_switch(peer_mac_addr, freq); + + if (rv != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, "Failed to enable TDLS Channel Switching Request"); + return WIFI_MANAGER_ERROR_OPERATION_FAILED; + } + return WIFI_MANAGER_ERROR_NONE; +} + +EXPORT_API int wifi_manager_tdls_disable_channel_switching(wifi_manager_h wifi, + const char *peer_mac_addr) +{ + CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); + CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE); + + if (peer_mac_addr == NULL || !(__wifi_check_handle_validity(wifi))) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); + return WIFI_MANAGER_ERROR_INVALID_PARAMETER; + } + + int rv = 0; + + rv = net_wifi_tdls_disbale_channel_switch(peer_mac_addr); + if (rv != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, "Failed to disable TDLS channel switching request"); + return WIFI_MANAGER_ERROR_OPERATION_FAILED; + } + + return WIFI_MANAGER_ERROR_NONE; - return __wifi_set_tdls_connection_state_changed_cb(wifi, NULL, NULL);; } //LCOV_EXCL_STOP diff --git a/test/wifi_manager_test.c b/test/wifi_manager_test.c index 3bb86e5..e54cbc8 100755 --- a/test/wifi_manager_test.c +++ b/test/wifi_manager_test.c @@ -1901,6 +1901,49 @@ int test_wifi_manager_tdls_disconnect(void) } return 1; } +int test_wifi_manager_tdls_enable_channel_switch(void) +{ + int rv = 0; + char peer_mac[18]; + int freq; + printf("Enter Mac_address: "); + if (scanf(" %17s", peer_mac) < 1) + return -1; + if (strlen(peer_mac) > 17) { + printf("Wrong Mac_address\n"); + return -1; + } + printf("Enter Peer Frequency:\n"); + rv = scanf("%9d", &freq); + if (rv <= 0) { + printf("Invalid input!\n"); + return -1; + } + rv = wifi_manager_tdls_enable_channel_switching(wifi, peer_mac, freq); + if (rv != WIFI_MANAGER_ERROR_NONE) { + printf("test_wifi_manager_tdls_channel_switch() is failed [%s]\n", __test_convert_error_to_string(rv)); + return -1; + } + return 1; +} +int test_wifi_manager_tdls_disable_channel_switch(void) +{ + int rv = 0; + char peer_mac[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_manager_tdls_disable_channel_switching(wifi, peer_mac); + if (rv != WIFI_MANAGER_ERROR_NONE) { + printf("test_wifi_manager_tdls_cancle_channel_switch() is failed [%s]\n", __test_convert_error_to_string(rv)); + return -1; + } + return 1; +} int test_wifi_manager_connect_hidden_ap(void) { @@ -2186,6 +2229,8 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) printf("y - Get wifi scanning state\n"); printf("z - Get Auto Scan Enable-Disable\n"); printf("A - Get Auto Scan Mode\n"); + printf("B - Enable TDLS Channel Switch Request\n"); + printf("C - Disable TDLS Channel Switch Request\n"); printf(LOG_RED "0 - Exit \n" LOG_END); printf("ENTER - Show options menu.......\n"); @@ -2302,6 +2347,12 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) case 'A': rv = test_wifi_manager_get_autoscan_mode(); break; + case 'B': + rv = test_wifi_manager_tdls_enable_channel_switch(); + break; + case 'C': + rv = test_wifi_manager_tdls_disable_channel_switch(); + break; default: break; }