g_free 'field' and 'value' if you break out of a while loop.
[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, TRUE);
41
42         GDBusConnection *connection = NULL;
43         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 TRUE;
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                 g_free(if_path);
57                 return TRUE;
58         }
59
60
61         g_dbus_connection_call(connection,
62                         SUPPLICANT_SERVICE,
63                         if_path,
64                         SUPPLICANT_INTERFACE ".Interface",
65                         "FlushBSS",
66                         g_variant_new("(u)", 0),
67                         NULL,
68                         G_DBUS_CALL_FLAGS_NONE,
69                         10 * 1000,
70                         netdbus_get_cancellable(),
71                         NULL,
72                         NULL);
73
74         g_free(if_path);
75         wifi_complete_flush_bss(wifi, context);
76         return TRUE;
77 }