From 254cefcc96a994c70cf7caf2822d77224f7ca173 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 12 Jun 2020 15:21:39 -0500 Subject: [PATCH] station: Give network a connection failed hint Right now, if the connection fails, then network always thinks that the password should be re-asked. Loosen this to only do so if the connection failed at least in the handshake phase. If the connection failed due to Association / Authentication timeout, it is likely that something is wrong with the AP and it can't respond. --- src/network.c | 8 ++++---- src/network.h | 2 +- src/station.c | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/network.c b/src/network.c index 65a74378..70541b59 100644 --- a/src/network.c +++ b/src/network.c @@ -595,13 +595,13 @@ close_settings: return ret; } -void network_connect_failed(struct network *network) +void network_connect_failed(struct network *network, bool in_handshake) { /* - * Connection failed, if PSK try asking for the passphrase - * once more + * Connection failed during the handshake phase. If PSK try asking + * for the passphrase once more */ - if (network_get_security(network) == SECURITY_PSK) { + if (network_get_security(network) == SECURITY_PSK && in_handshake) { network->update_psk = false; network->ask_passphrase = true; } diff --git a/src/network.h b/src/network.h index fbb120a7..c008c04c 100644 --- a/src/network.h +++ b/src/network.h @@ -53,7 +53,7 @@ const struct network_info *network_get_info(const struct network *network); void network_set_info(struct network *network, struct network_info *info); int network_autoconnect(struct network *network, struct scan_bss *bss); -void network_connect_failed(struct network *network); +void network_connect_failed(struct network *network, bool in_handshake); bool network_bss_add(struct network *network, struct scan_bss *bss); bool network_bss_list_isempty(struct network *network); void network_bss_list_clear(struct network *network); diff --git a/src/station.c b/src/station.c index f0a0e810..80b6f07e 100644 --- a/src/station.c +++ b/src/station.c @@ -2343,7 +2343,11 @@ static void station_connect_cb(struct netdev *netdev, enum netdev_result result, if (result != NETDEV_RESULT_OK) { if (result != NETDEV_RESULT_ABORTED) { - network_connect_failed(station->connected_network); + bool in_handshake = + result == NETDEV_RESULT_HANDSHAKE_FAILED; + + network_connect_failed(station->connected_network, + in_handshake); station_disassociated(station); }