From patchwork Mon Aug 21 16:43:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Otcheretianski X-Patchwork-Id: 804024 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nS0IFT0g"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xbZhV0TWnz9ryQ for ; Mon, 21 Aug 2017 23:45:46 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=U3MHAu+7AmouxRhWj95vXH4g7PbqQtQ+ON/ONzxHD+g=; b=nS0 IFT0gR5qMrqO3/bEPXQIstpiMd97iVB4qgkpSuBJECmaKkDcblCGejEsFEqJW7XKYESwyBLzfbPMR mtZm0YNPOzq7lVFJEbqHRC//p45ybc124B0iQ55PM3drsbfVpz3GIvWqQY89ln7OGs5bQ4hn4NQV9 eJzb96Eo4BSks+cfXaoR8gvM1n1gglfH+1zJ0v3AGuvx1x0Xn0Vb2j5cJ2zGAvb4yCwO53tke7xNI 3Litwj2lkMjpUNahySc3rezM6z9NCBH2eHC7yYA8WEiYfFkyH5mpq9X1cRkzna72qB67lZ6bGqHJT niTu5HQBiFo4HTGeXTkF4weVGvWpo7Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1djn1E-0000gN-9X; Mon, 21 Aug 2017 13:45:28 +0000 Received: from mga04.intel.com ([192.55.52.120]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1djn0x-0007fA-KH for hostap@lists.infradead.org; Mon, 21 Aug 2017 13:45:19 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Aug 2017 06:44:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,409,1498546800"; d="scan'208";a="126528792" Received: from unknown (HELO andrei-XPS-12-9Q33.ger.corp.intel.com) ([10.12.217.183]) by orsmga002.jf.intel.com with ESMTP; 21 Aug 2017 06:44:45 -0700 From: Andrei Otcheretianski To: hostap@lists.infradead.org Subject: [PATCH 2/4] hostapd: add RSSI based association rejection support Date: Mon, 21 Aug 2017 19:43:53 +0300 Message-Id: <1503333835-15264-2-git-send-email-andrei.otcheretianski@intel.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170821_064511_893530_77F12102 X-CRM114-Status: GOOD ( 13.47 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [192.55.52.120 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Beni Lev MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Beni Lev An AP might reject a STA association request due to low RSSI. In such case, the AP informs the STA the desired RSSI improvement and a retry timeout. The STA might retry to associate even if the RSSI hasn't improved if the retry timeout expired. Signed-off-by: Beni Lev --- hostapd/config_file.c | 4 ++++ hostapd/hostapd.conf | 9 +++++++++ src/ap/ap_config.c | 3 +++ src/ap/ap_config.h | 3 +++ src/ap/ieee802_11.c | 25 +++++++++++++++++++------ src/ap/ieee802_11.h | 3 +++ src/ap/ieee802_11_shared.c | 14 ++++++++++++++ 7 files changed, 55 insertions(+), 6 deletions(-) diff --git a/hostapd/config_file.c b/hostapd/config_file.c index cc799d4..4062569 100644 --- a/hostapd/config_file.c +++ b/hostapd/config_file.c @@ -3740,6 +3740,10 @@ static int hostapd_config_fill(struct hostapd_config *conf, } else if (os_strcmp(buf, "dpp_csign_expiry") == 0) { bss->dpp_csign_expiry = strtol(pos, NULL, 0); #endif /* CONFIG_DPP */ + } else if (os_strcmp(buf, "rssi_reject_assoc_rssi") == 0) { + conf->rssi_reject_assoc_rssi = atoi(pos); + } else if (os_strcmp(buf, "rssi_reject_assoc_timeout") == 0) { + conf->rssi_reject_assoc_timeout = atoi(pos); } else { wpa_printf(MSG_ERROR, "Line %d: unknown configuration item '%s'", diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf index 7ad3206..63a47f3 100644 --- a/hostapd/hostapd.conf +++ b/hostapd/hostapd.conf @@ -2225,3 +2225,12 @@ own_ip_addr=127.0.0.1 #bss=wlan0_1 #bssid=00:13:10:95:fe:0b # ... + +# RSSI based assocition rejection settings +# +# Reject STA association if RSSI is below given threshold(in dBm) +#rssi_reject_assoc_rssi=-75 +# +# Assoc retry delay in seconds allowed by the STA if RSSI has not met the +# threshold. (default=30) +#rssi_reject_assoc_timeout=60 diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c index 07a13f8..eb4e293 100644 --- a/src/ap/ap_config.c +++ b/src/ap/ap_config.c @@ -219,6 +219,9 @@ struct hostapd_config * hostapd_config_defaults(void) * environments for the current frequency band in the country. */ conf->country[2] = ' '; + conf->rssi_reject_assoc_rssi = 0; + conf->rssi_reject_assoc_timeout = 30; + return conf; } diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h index 8e5ff52..514aaf5 100644 --- a/src/ap/ap_config.h +++ b/src/ap/ap_config.h @@ -785,6 +785,9 @@ struct hostapd_config { struct he_phy_capabilities_info he_phy_capab; struct he_operation he_op; #endif /* CONFIG_IEEE80211AX */ + + int rssi_reject_assoc_rssi; + int rssi_reject_assoc_timeout; }; diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index 7999611..6f51214 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -2576,7 +2576,7 @@ static int add_associated_sta(struct hostapd_data *hapd, static u16 send_assoc_resp(struct hostapd_data *hapd, struct sta_info *sta, const u8 *addr, u16 status_code, int reassoc, - const u8 *ies, size_t ies_len) + const u8 *ies, size_t ies_len, int rssi) { int send_len; u8 *buf; @@ -2621,6 +2621,13 @@ static u16 send_assoc_resp(struct hostapd_data *hapd, struct sta_info *sta, /* Extended supported rates */ p = hostapd_eid_ext_supp_rates(hapd, p); + if (status_code == WLAN_STATUS_DENIED_POOR_CHANNEL_CONDITIONS) { + int delta = hapd->iconf->rssi_reject_assoc_rssi - rssi; + + p = hostapd_eid_mbo_rssi_assoc_rej(hapd, p, buf + buflen - p, + delta); + } + #ifdef CONFIG_IEEE80211R_AP if (sta && status_code == WLAN_STATUS_SUCCESS) { /* IEEE 802.11r: Mobility Domain Information, Fast BSS @@ -2820,7 +2827,7 @@ void fils_hlp_finish_assoc(struct hostapd_data *hapd, struct sta_info *sta) reply_res = send_assoc_resp(hapd, sta, sta->addr, WLAN_STATUS_SUCCESS, sta->fils_pending_assoc_is_reassoc, sta->fils_pending_assoc_req, - sta->fils_pending_assoc_req_len); + sta->fils_pending_assoc_req_len, 0); os_free(sta->fils_pending_assoc_req); sta->fils_pending_assoc_req = NULL; sta->fils_pending_assoc_req_len = 0; @@ -2860,7 +2867,7 @@ void fils_hlp_timeout(void *eloop_ctx, void *eloop_data) static void handle_assoc(struct hostapd_data *hapd, const struct ieee80211_mgmt *mgmt, size_t len, - int reassoc) + int reassoc, int rssi) { u16 capab_info, listen_interval, seq_ctrl, fc; u16 resp = WLAN_STATUS_SUCCESS, reply_res; @@ -2931,6 +2938,12 @@ static void handle_assoc(struct hostapd_data *hapd, } sta = ap_get_sta(hapd, mgmt->sa); + + if (hapd->iconf->rssi_reject_assoc_rssi && + rssi < hapd->iconf->rssi_reject_assoc_rssi) { + resp = WLAN_STATUS_DENIED_POOR_CHANNEL_CONDITIONS; + goto fail; + } #ifdef CONFIG_IEEE80211R_AP if (sta && sta->auth_alg == WLAN_AUTH_FT && (sta->flags & WLAN_STA_AUTH) == 0) { @@ -3218,7 +3231,7 @@ static void handle_assoc(struct hostapd_data *hapd, #endif /* CONFIG_FILS */ reply_res = send_assoc_resp(hapd, sta, mgmt->sa, resp, reassoc, pos, - left); + left, rssi); os_free(tmp); /* @@ -3652,12 +3665,12 @@ int ieee802_11_mgmt(struct hostapd_data *hapd, const u8 *buf, size_t len, break; case WLAN_FC_STYPE_ASSOC_REQ: wpa_printf(MSG_DEBUG, "mgmt::assoc_req"); - handle_assoc(hapd, mgmt, len, 0); + handle_assoc(hapd, mgmt, len, 0, fi->ssi_signal); ret = 1; break; case WLAN_FC_STYPE_REASSOC_REQ: wpa_printf(MSG_DEBUG, "mgmt::reassoc_req"); - handle_assoc(hapd, mgmt, len, 1); + handle_assoc(hapd, mgmt, len, 1, fi->ssi_signal); ret = 1; break; case WLAN_FC_STYPE_DISASSOC: diff --git a/src/ap/ieee802_11.h b/src/ap/ieee802_11.h index 0653fb2..97cfdaf 100644 --- a/src/ap/ieee802_11.h +++ b/src/ap/ieee802_11.h @@ -112,6 +112,9 @@ static inline void sae_clear_retransmit_timer(struct hostapd_data *hapd, } #endif /* CONFIG_SAE */ +u8 * hostapd_eid_mbo_rssi_assoc_rej(struct hostapd_data *hapd, u8 *eid, + size_t len, int delta); + #ifdef CONFIG_MBO u8 * hostapd_eid_mbo(struct hostapd_data *hapd, u8 *eid, size_t len); diff --git a/src/ap/ieee802_11_shared.c b/src/ap/ieee802_11_shared.c index 902f64f..66fb4ef 100644 --- a/src/ap/ieee802_11_shared.c +++ b/src/ap/ieee802_11_shared.c @@ -539,6 +539,20 @@ u8 * hostapd_eid_bss_max_idle_period(struct hostapd_data *hapd, u8 *eid) return pos; } +u8 * hostapd_eid_mbo_rssi_assoc_rej(struct hostapd_data *hapd, u8 *eid, + size_t len, int delta) +{ + u8 mbo[4]; + + mbo[0] = OCE_ATTR_ID_RSSI_BASED_ASSOC_REJECT; + mbo[1] = 2; + /* Delta RSSI */ + mbo[2] = delta; + /* Retry delay */ + mbo[3] = hapd->iconf->rssi_reject_assoc_timeout; + + return eid + mbo_add_ie(eid, len, mbo, 4); +} #ifdef CONFIG_MBO