From d372d59bea3e66e6638e184060769f768ea7204e Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Mon, 1 Feb 2021 11:33:12 -0600 Subject: [PATCH] station: Allow ConnectHiddenNetwork to be retried In the case that ConnectHiddenNetwork scans successfully, but fails for some other reason, the network object is left in the scan results until it expires. This will prevent subsequent attempts to use ConnectHiddenNetwork with a .NotHidden error. Fix that by checking whether a found network is hidden, and if so, allow the request to proceed. --- src/station.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/station.c b/src/station.c index 2abde50c..76d1d43d 100644 --- a/src/station.c +++ b/src/station.c @@ -2674,6 +2674,7 @@ static struct l_dbus_message *station_dbus_connect_hidden_network( .randomize_mac_addr_hint = true, }; const char *ssid; + struct network *network; l_debug(""); @@ -2690,9 +2691,32 @@ static struct l_dbus_message *station_dbus_connect_hidden_network( known_networks_find(ssid, SECURITY_NONE)) return dbus_error_already_provisioned(message); - if (station_network_find(station, ssid, SECURITY_PSK) || - station_network_find(station, ssid, SECURITY_NONE)) - return dbus_error_not_hidden(message); + network = station_network_find(station, ssid, SECURITY_PSK); + if (!network) + network = station_network_find(station, ssid, SECURITY_NONE); + + /* + * This checks for a corner case where the hidden network was already + * found and is in our scan results, but the initial connection failed. + * For example, the password was given incorrectly. In this case the + * entry will also be found on the hidden bss list. + */ + if (network) { + const struct l_queue_entry *entry = + l_queue_get_entries(station->hidden_bss_list_sorted); + struct scan_bss *target = network_bss_select(network, true); + + for (; entry; entry = entry->next) { + struct scan_bss *bss = entry->data; + + if (!scan_bss_addr_eq(target, bss)) + continue; + + /* We can skip the scan and try to connect right away */ + return network_connect_new_hidden_network(network, + message); + } + } params.ssid = ssid;