gsupplicant: Remove network from wpa_s when disconnecting
authorKalle Valo <kalle.valo@canonical.com>
Wed, 27 Oct 2010 18:49:31 +0000 (21:49 +0300)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 2 Nov 2010 11:40:06 +0000 (12:40 +0100)
gsupplicant adds networks to wpasupplicant but never removes them. So
after a time wpasupplicant will contain a lot of disabled networks. This
doesn't seem to create any problems, but it's still better to make sure
that wpasupplicant configuration is clean.

gsupplicant/supplicant.c

index a2501b9..2a1021f 100644 (file)
@@ -2344,7 +2344,7 @@ int g_supplicant_interface_connect(GSupplicantInterface *interface,
        return -EINPROGRESS;
 }
 
-static void interface_disconnect_result(const char *error,
+static void network_remove_result(const char *error,
                                DBusMessageIter *iter, void *user_data)
 {
        struct interface_data *data = user_data;
@@ -2361,6 +2361,42 @@ static void interface_disconnect_result(const char *error,
        dbus_free(data);
 }
 
+static void network_remove_params(DBusMessageIter *iter, void *user_data)
+{
+       struct interface_data *data = user_data;
+       const char *path = data->interface->network_path;
+
+       SUPPLICANT_DBG("path %s", path);
+
+       dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path);
+}
+
+static int network_remove(struct interface_data *data)
+{
+       GSupplicantInterface *interface = data->interface;
+
+       SUPPLICANT_DBG("");
+
+       return supplicant_dbus_method_call(interface->path,
+                       SUPPLICANT_INTERFACE ".Interface", "RemoveNetwork",
+                       network_remove_params, network_remove_result, data);
+}
+
+static void interface_disconnect_result(const char *error,
+                               DBusMessageIter *iter, void *user_data)
+{
+       struct interface_data *data = user_data;
+
+       SUPPLICANT_DBG("");
+
+       if (error != NULL && data->callback != NULL) {
+               data->callback(-EIO, data->interface, data->user_data);
+               return;
+       }
+
+       network_remove(data);
+}
+
 int g_supplicant_interface_disconnect(GSupplicantInterface *interface,
                                        GSupplicantInterfaceCallback callback,
                                                        void *user_data)