Add API to flush BSS
[platform/core/connectivity/net-config.git] / src / wifi-extension.c
1 /*
2  * Network Extension Module
3  *
4  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <unistd.h>
23 #include <errno.h>
24 #include <vconf.h>
25 #include <vconf-keys.h>
26
27 #include "log.h"
28 #include "util.h"
29 #include "neterror.h"
30 #include "netdbus.h"
31 #include "netsupplicant.h"
32 #include "wifi-state.h"
33 #include "wifi-extension.h"
34
35
36 gboolean handle_flush_bss(Wifi *wifi, GDBusMethodInvocation *context)
37 {
38         DBG("Wi-Fi flush bss");
39
40         g_return_val_if_fail(wifi != NULL, FALSE);
41
42         GDBusConnection *connection = NULL;
43         const char *if_path = NULL;
44
45         if_path = netconfig_wifi_get_supplicant_interface();
46         if (if_path == NULL) {
47                 netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailFlushBss");
48                 DBG("Fail to get wpa_supplicant DBus path");
49                 return FALSE;
50         }
51
52         connection = netdbus_get_connection();
53         if (connection == NULL) {
54                 netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailFlushBss");
55                 ERR("Failed to get netdbus connection");
56                 return FALSE;
57         }
58
59
60         g_dbus_connection_call(connection,
61                         SUPPLICANT_SERVICE,
62                         if_path,
63                         SUPPLICANT_INTERFACE ".Interface",
64                         "FlushBSS",
65                         g_variant_new("(u)", 0),
66                         NULL,
67                         G_DBUS_CALL_FLAGS_NONE,
68                         10 * 1000,
69                         netdbus_get_cancellable(),
70                         NULL,
71                         NULL);
72
73         wifi_complete_flush_bss(wifi, context);
74         return TRUE;
75 }