3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-21 11:52:34 +01:00

network: Disconnect from known network in Forget()

Note that the autoconnect_list may still contain the network.  Currently
only the top entry from the list is ever used and only on
new_scan_results(), i.e. at the same time the list is being created.
If at some point it becomes part of actual device state it needs to also
be reset when a network is being forgotten.
This commit is contained in:
Andrew Zaborowski 2016-07-02 16:42:33 +02:00 committed by Denis Kenzior
parent a2771d22f4
commit fe6485147c
2 changed files with 23 additions and 12 deletions

View File

@ -115,11 +115,6 @@ static struct l_dbus_message *forget_network(struct l_dbus *dbus,
if (!security_from_str(strtype, &security))
return dbus_error_invalid_args(message);
/*
* TODO: Disconnect from the network if currently connected or
* connecting.
*/
if (!network_info_forget_known(ssid, security))
return dbus_error_failed(message);

View File

@ -778,6 +778,17 @@ bool network_info_add_known(const char *ssid, enum security security)
return true;
}
static void network_info_check_device(struct device *device, void *user_data)
{
struct network_info *info = user_data;
struct network *network;
network = device_get_connected_network(device);
if (network && network->info == info)
device_disconnect(device);
}
bool network_info_forget_known(const char *ssid, enum security security)
{
struct network_info *network, search;
@ -789,15 +800,20 @@ bool network_info_forget_known(const char *ssid, enum security security)
if (!network)
return false;
if (network->seen_count) {
memset(&network->connected_time, 0, sizeof(struct timespec));
network->is_known = false;
l_queue_push_tail(networks, network);
} else
if (!network->seen_count) {
network_info_free(network);
return true;
}
memset(&network->connected_time, 0, sizeof(struct timespec));
network->is_known = false;
l_queue_push_tail(networks, network);
__iwd_device_foreach(network_info_check_device, network);
return true;
}