From patchwork Fri Apr 27 12:26:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz.Markowski@tieto.com X-Patchwork-Id: 155471 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 0D91AB6FA0 for ; Fri, 27 Apr 2012 22:27:01 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 6DA1D9C1AB; Fri, 27 Apr 2012 08:26:58 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QtEC7a8gAvmj; Fri, 27 Apr 2012 08:26:58 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 5EF0C9C1AD; Fri, 27 Apr 2012 08:26:54 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id AE71B9C1AD for ; Fri, 27 Apr 2012 08:26:52 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id N8UBkfYPOBi7 for ; Fri, 27 Apr 2012 08:26:41 -0400 (EDT) Received: from ebb06.tieto.com (ebb06.tieto.com [131.207.168.38]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "ebb06.tieto.com", Issuer "VeriSign Class 3 Secure Server CA - G3" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 2B7369C1AB for ; Fri, 27 Apr 2012 08:26:40 -0400 (EDT) X-AuditID: 83cfa826-b7ce7ae000002a56-1b-4f9a907fcf3c Received: from FIHGA-EXHUB01.eu.tieto.com ( [131.207.136.34]) by ebb06.tieto.com (SMTP Mailer) with SMTP id 22.54.10838.F709A9F4; Fri, 27 Apr 2012 15:26:39 +0300 (EEST) Received: from EXMB02.eu.tieto.com ([169.254.1.176]) by FIHGA-EXHUB01.eu.tieto.com ([131.207.136.34]) with mapi; Fri, 27 Apr 2012 15:26:39 +0300 From: To: Date: Fri, 27 Apr 2012 15:26:38 +0300 Subject: [PATCH] Adds signal threshold option for auto-reconnect scenarios Thread-Topic: [PATCH] Adds signal threshold option for auto-reconnect scenarios Thread-Index: Ac0kb+8HA+LoNgxdSoCWQBArm7zk1A== Message-ID: <538FB72AA9C7314998FCE2FB41335C5A208413CE9C@EXMB02.eu.tieto.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 X-Brightmail-Tracker: AAAAAA== X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com 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