Add API to flush BSS 35/148835/1 accepted/tizen/unified/20170913.071026 submit/tizen/20170911.125730
authortaesub kim <taesub.kim@samsung.com>
Mon, 11 Sep 2017 04:34:16 +0000 (13:34 +0900)
committertaesub kim <taesub.kim@samsung.com>
Mon, 11 Sep 2017 04:34:19 +0000 (13:34 +0900)
Change-Id: I26a2ba518b5bbda07ba5597eb9f55df851df1159
Signed-off-by: Taesub Kim <taesub.kim@samsung.com>
include/network_dbus.h
include/network_interface.h
include/wifi_internal.h
include/wifi_manager_extension.h
src/network_dbus.c
src/network_interface.c
src/wifi_internal.c
src/wifi_manager.c
test/wifi_manager_test.c

index 2d82d1f..bce8821 100755 (executable)
@@ -148,6 +148,8 @@ int _net_dbus_add_vsie(unsigned int frame_id, const char *vsie_str);
 int _net_dbus_get_vsie(unsigned int frame_id, char **vsie_str);
 int _net_dbus_remove_vsie(unsigned int frame_id, const char *vsie_str);
 int _net_dbus_get_vsie_list(GSList **vsie_list);
+int _net_dbus_flush_bss(void);
+
 
 #ifdef __cplusplus
 }
index 0a818e4..2bae8a5 100755 (executable)
@@ -256,6 +256,7 @@ int net_wifi_add_vsie(unsigned int frame_id, const char *vsie_str);
 int net_wifi_get_vsie(unsigned int frame_id, char **vsie_str);
 int net_wifi_remove_vsie(unsigned int frame_id, const char *vsie_str);
 int net_wifi_get_vsie_list(GSList **vsie_list);
+int net_wifi_flush_bss(void);
 
 int net_wifi_cancel_wps(void);
 
index 161f98f..8d160c1 100755 (executable)
@@ -290,6 +290,7 @@ int _wifi_get_vsie(wifi_manager_h wifi,
 int _wifi_remove_vsie(wifi_manager_h wifi,
                wifi_manager_vsie_frames_e frame_id, const char *vsie_str);
 int _wifi_get_vsie_list(wifi_manager_vsie_list_cb callback, void *user_data);
+int _wifi_flush_bss(void);
 
 /* WIFI Privilege Check */
 int _wifi_check_get_privilege();
index 75fe71c..f103414 100755 (executable)
@@ -271,6 +271,16 @@ int wifi_manager_get_vsie_list(wifi_manager_h wifi,
                wifi_manager_vsie_list_cb callback, void *user_data);
 
 /**
+ * @brief Flush BSS
+ * @since_tizen 4.0
+ * @return 0 on success, otherwise negative error value.
+ * @retval #WIFI_ERROR_NONE  Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #WIFI_ERROR_INVALID_OPERATION  Invalid operation
+ */
+int wifi_manager_flush_bss(wifi_manager_h wifi);
+
+/**
 * @}
 */
 
index 1aa88bb..135a65e 100755 (executable)
@@ -828,11 +828,9 @@ int _net_dbus_set_bgscan_mode(net_wifi_background_scan_mode_e mode)
        GVariant *message = NULL;
        GVariant *params;
 
-       char path[CONNMAN_MAX_BUFLEN] = NETCONFIG_WIFI_PATH;
-
        params = g_variant_new("(u)", mode);
 
-       message = _net_invoke_dbus_method(NETCONFIG_SERVICE, path,
+       message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
                        NETCONFIG_WIFI_INTERFACE, "SetBgscan", params, &Error);
 
        if (Error != NET_ERR_NONE)
@@ -2007,6 +2005,28 @@ int _net_dbus_get_vsie_list(GSList **vsie_list)
        return Error;
 }
 
+int _net_dbus_flush_bss(void)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_e Error = NET_ERR_NONE;
+       GVariant *message = NULL;
+
+       message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+                       NETCONFIG_WIFI_INTERFACE, "FlushBss", NULL, &Error);
+
+       if (message == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Failed to flush bss");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       g_variant_unref(message);
+       WIFI_LOG(WIFI_INFO, "Successfully flush bss\n");
+
+       return Error;
+}
+
 static void __net_wps_cancel_reply(GObject *source_object,
                GAsyncResult *res, gpointer user_data)
 {
@@ -2799,9 +2819,7 @@ int _net_dbus_resume_bgscan(void)
        net_err_e Error = NET_ERR_NONE;
        GVariant *message = NULL;
 
-       char path[CONNMAN_MAX_BUFLEN] = NETCONFIG_WIFI_PATH;
-
-       message = _net_invoke_dbus_method(NETCONFIG_SERVICE, path,
+       message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
                        NETCONFIG_WIFI_INTERFACE, "ResumeBgscan", NULL, &Error);
 
        if (Error != NET_ERR_NONE)
@@ -2821,9 +2839,7 @@ int _net_dbus_pause_bgscan(void)
        net_err_e Error = NET_ERR_NONE;
        GVariant *message = NULL;
 
-       char path[CONNMAN_MAX_BUFLEN] = NETCONFIG_WIFI_PATH;
-
-       message = _net_invoke_dbus_method(NETCONFIG_SERVICE, path,
+       message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
                        NETCONFIG_WIFI_INTERFACE, "PauseBgscan", NULL, &Error);
 
        if (Error != NET_ERR_NONE)
index f30eee6..5b5881e 100755 (executable)
@@ -1739,6 +1739,30 @@ int net_wifi_get_vsie_list(GSList **vsie_list)
 }
 //LCOV_EXCL_STOP
 
+EXPORT_API int net_wifi_flush_bss(void)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_e Error = NET_ERR_NONE;
+
+       if (NetworkInfo.ref_count < 1) {
+               WIFI_LOG(WIFI_ERROR, "Application is not registered");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       Error = _net_dbus_flush_bss();
+       if (Error != NET_ERR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to flush bss. Error [%s]\n",
+                               _net_print_error(Error));
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
 int net_open_connection_with_wifi_info(const net_wifi_connection_info_s *wifi_info)
 {
        __NETWORK_FUNC_ENTER__;
index 6746e52..28d8bad 100755 (executable)
@@ -1756,6 +1756,20 @@ int _wifi_get_vsie_list(wifi_manager_vsie_list_cb callback, void *user_data)
 }
 //LCOV_EXCL_STOP
 
+int _wifi_flush_bss(void)
+{
+       int rv;
+
+       rv = net_wifi_flush_bss();
+
+       if (rv != NET_ERR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to flush bss");
+               return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+       }
+
+       return WIFI_MANAGER_ERROR_NONE;
+}
+
 int _wifi_get_connected_profile(wifi_manager_ap_h *ap)
 {
        int rv;
index 77366b8..19894b2 100755 (executable)
@@ -1011,6 +1011,27 @@ EXPORT_API int wifi_manager_get_vsie_list(wifi_manager_h wifi,
 
        return _wifi_get_vsie_list(callback, user_data);
 }
+
+EXPORT_API int wifi_manager_flush_bss(wifi_manager_h wifi)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+       WIFI_LOG(WIFI_INFO, "[App-->TizenMW] bss flush request");
+
+       int rv;
+
+       if (!(__wifi_check_handle_validity(wifi))) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+       }
+
+       rv = _wifi_flush_bss();
+
+       if (rv != WIFI_MANAGER_ERROR_NONE)
+               WIFI_LOG(WIFI_ERROR, "[App<--TizenMW] Error!! bss flush Request failed. rv[%d]\n", rv);
+
+       return rv;
+
+}
 //LCOV_EXCL_STOP
 
 EXPORT_API int wifi_manager_specific_scan_create(wifi_manager_h wifi,
index 574e092..5a5d196 100755 (executable)
@@ -2460,6 +2460,21 @@ int test_wifi_manager_specific_ap_start_multi_scan(void)
        return 1;
 }
 
+int test_wifi_manager_flush_bss(void)
+{
+       int rv;
+
+       rv = wifi_manager_flush_bss(wifi);
+
+       if (rv != WIFI_MANAGER_ERROR_NONE) {
+               printf("Fail to flush bss rv = %d\n", rv);
+               return -1;
+       }
+
+       printf("Request to flush bss\n");
+       return 1;
+}
+
 int main(int argc, char **argv)
 {
        GMainLoop *mainloop;
@@ -2545,6 +2560,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                printf("G   - Get VSIE\n");
                printf("H   - Remove VSIE\n");
                printf("I   - Start Multi Scan\n");
+               printf("J   - Flush BSS\n");
                printf(LOG_RED "0   - Exit \n" LOG_END);
 
                printf("ENTER  - Show options menu.......\n");
@@ -2685,6 +2701,9 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        case 'I':
                rv = test_wifi_manager_specific_ap_start_multi_scan();
                break;
+       case 'J':
+               rv = test_wifi_manager_flush_bss();
+               break;
        default:
                break;
        }