From patchwork Fri Apr 27 12:26:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Adds signal threshold option for auto-reconnect scenarios Date: Fri, 27 Apr 2012 02:26:38 -0000 From: Bartosz.Markowski@tieto.com X-Patchwork-Id: 155471 Message-Id: <538FB72AA9C7314998FCE2FB41335C5A208413CE9C@EXMB02.eu.tieto.com> To: When AP signal level is poor, and we lose connection due to e.g. beacon losses, there's a chance we will try to auto-reconnect to this AP right after and whole sequence will repeat multiple times. This patch adds an option for users to set signal level threshold in .conf file and skip auto-reconnect, at least until the signal pass this threshold. Signed-off-by: Bartosz Markowski --- wpa_supplicant/config.c | 4 +++- wpa_supplicant/config.h | 6 ++++++ wpa_supplicant/config_file.c | 2 ++ wpa_supplicant/events.c | 7 +++++++ 4 files changed, 18 insertions(+), 1 deletions(-) diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index c423bc3..669fe5c 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -2492,6 +2492,7 @@ struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface, config->bss_expiration_scan_count = DEFAULT_BSS_EXPIRATION_SCAN_COUNT; config->max_num_sta = DEFAULT_MAX_NUM_STA; config->access_network_type = DEFAULT_ACCESS_NETWORK_TYPE; + config->reauth_threshold = DEFAULT_REAUTH_THRESHOLD; if (ctrl_interface) config->ctrl_interface = os_strdup(ctrl_interface); @@ -2872,7 +2873,8 @@ static const struct global_parse_data global_fields[] = { { INT_RANGE(disassoc_low_ack, 0, 1), 0 }, { INT_RANGE(interworking, 0, 1), 0 }, { FUNC(hessid), 0 }, - { INT_RANGE(access_network_type, 0, 15), 0 } + { INT_RANGE(access_network_type, 0, 15), 0 }, + { INT(reauth_threshold), 0} }; #undef FUNC diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h index eca0d0f..eaa3808 100644 --- a/wpa_supplicant/config.h +++ b/wpa_supplicant/config.h @@ -23,6 +23,7 @@ #define DEFAULT_BSS_EXPIRATION_SCAN_COUNT 2 #define DEFAULT_MAX_NUM_STA 128 #define DEFAULT_ACCESS_NETWORK_TYPE 15 +#define DEFAULT_REAUTH_THRESHOLD 0 #include "config_ssid.h" #include "wps/wps.h" @@ -611,6 +612,11 @@ struct wpa_config { * Homogeneous ESS. This is used only if interworking is enabled. */ u8 hessid[ETH_ALEN]; + + /** + * reauth_threshold - Reauthentication signal threshold. + */ + int reauth_threshold; }; diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c index 3a4c35f..ce99dfe 100644 --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -845,6 +845,8 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config) fprintf(f, "access_network_type=%d\n", config->access_network_type); #endif /* CONFIG_INTERWORKING */ + if (config->reauth_threshold != DEFAULT_REAUTH_THRESHOLD) + fprintf(f, "reauth_threshold=%d", config->reauth_threshold); } #endif /* CONFIG_NO_CONFIG_WRITE */ diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index da9cf2b..21b4841 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -717,6 +717,13 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s, continue; } + if (wpa_s->reassociated_connection && + wpa_s->conf->reauth_threshold && + (bss->level < wpa_s->conf->reauth_threshold)) { + wpa_dbg(wpa_s, MSG_DEBUG, " skip - signal to low"); + continue; + } + #ifdef CONFIG_P2P /* * TODO: skip the AP if its P2P IE has Group Formation