From patchwork Mon Feb 15 14:53:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilan Peer X-Patchwork-Id: 582887 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B28E91402EC for ; Tue, 16 Feb 2016 00:01:22 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aVIku-0001RV-S7; Mon, 15 Feb 2016 12:59:56 +0000 Received: from mga04.intel.com ([192.55.52.120]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aVIk6-0007OL-20 for hostap@lists.infradead.org; Mon, 15 Feb 2016 12:59:21 +0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP; 15 Feb 2016 04:58:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,450,1449561600"; d="scan'208";a="746656233" Received: from unknown (HELO JED00377.ger.corp.intel.com) ([10.12.217.192]) by orsmga003.jf.intel.com with ESMTP; 15 Feb 2016 04:58:09 -0800 From: Ilan Peer To: hostap@lists.infradead.org Subject: [PATCH 08/26] MBO: Add MBO wnm notification request Date: Mon, 15 Feb 2016 16:53:27 +0200 Message-Id: <1455548043-22427-16-git-send-email-ilan.peer@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455548043-22427-1-git-send-email-ilan.peer@intel.com> References: <1455548043-22427-1-git-send-email-ilan.peer@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160215_045906_512447_FC311A54 X-CRM114-Status: GOOD ( 12.96 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [192.55.52.120 listed in wl.mailspike.net] -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] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Spinadel MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: David Spinadel Add WNM notification request in case of a change in np_chan list during connection. Signed-off-by: David Spinadel --- wpa_supplicant/mbo.c | 77 ++++++++++++++++++++++++++++++++++++--- wpa_supplicant/wpa_supplicant_i.h | 1 + 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/wpa_supplicant/mbo.c b/wpa_supplicant/mbo.c index f545034..1cfea44 100644 --- a/wpa_supplicant/mbo.c +++ b/wpa_supplicant/mbo.c @@ -95,15 +95,42 @@ static void wpas_mbo_np_chan_attr(struct wpa_supplicant *wpa_s, } -static void wpas_mbo_np_chan_attrs(struct wpa_supplicant *wpa_s, - struct wpabuf *mbo) +static void wpas_mbo_np_chan_subelem_hdr(struct wpabuf *mbo, u8 len) +{ + wpabuf_put_u8(mbo, WLAN_EID_VENDOR_SPECIFIC); + wpabuf_put_u8(mbo, len); /* Length */ + wpabuf_put_be24(mbo, OUI_WFA); + wpabuf_put_u8(mbo, MBO_ATTR_ID_NP_CHAN_REPORT); +} + + +static void wpas_mbo_np_chan_subelement(struct wpa_supplicant *wpa_s, + struct wpabuf *mbo, u8 start, u8 end) +{ + size_t size = end - start + 8; + + if (start == end) + return; + + if (size + 2 > wpabuf_tailroom(mbo)) + return; + + wpas_mbo_np_chan_subelem_hdr(mbo, size); + wpas_mbo_np_chan_attr_body(wpa_s, mbo, start, end); +} + +static void wpas_mbo_np_chan_attrs(struct wpa_supplicant *wpa_s, + struct wpabuf *mbo, int subelement) { u8 oper_class = 0, reason = 0, reason_detail = 0, preference = 0; u8 i, start = 0; - if (!wpa_s->np_chan || !wpa_s->np_chan_num) + if (!wpa_s->np_chan || !wpa_s->np_chan_num) { + if (subelement) + wpas_mbo_np_chan_subelem_hdr(mbo, 4); return; + } for (i = 0; i <= wpa_s->np_chan_num; i++) { if (i == wpa_s->np_chan_num || @@ -111,7 +138,11 @@ static void wpas_mbo_np_chan_attrs(struct wpa_supplicant *wpa_s, wpa_s->np_chan[i].reason != reason || wpa_s->np_chan[i].reason_detail != reason_detail || wpa_s->np_chan[i].preference != preference) { - wpas_mbo_np_chan_attr(wpa_s, mbo, start, i); + if (subelement) + wpas_mbo_np_chan_subelement(wpa_s, mbo, start, + i); + else + wpas_mbo_np_chan_attr(wpa_s, mbo, start, i); if (i == wpa_s->np_chan_num) return; @@ -143,7 +174,7 @@ int wpas_mbo_ie(struct wpa_supplicant *wpa_s, u8 *buf, size_t len) return 0; /* Add Non-preferred channels attribute */ - wpas_mbo_np_chan_attrs(wpa_s, mbo); + wpas_mbo_np_chan_attrs(wpa_s, mbo, 0); res = mbo_add_ie(buf, len, wpabuf_head_u8(mbo), wpabuf_len(mbo)); if (!res) @@ -154,6 +185,41 @@ int wpas_mbo_ie(struct wpa_supplicant *wpa_s, u8 *buf, size_t len) } +static void wpas_mbo_send_wnm_notification(struct wpa_supplicant *wpa_s) +{ + struct wpabuf *buf; + int res; + + /* Sending WNM request only in case of a change in non preferred channel + * during connection, if the AP supports MBO. + */ + if (wpa_s->wpa_state != WPA_COMPLETED || + !wpa_bss_get_vendor_ie_subtype(wpa_s->current_bss, OUI_WFA, + MBO_OUI_TYPE)) + return; + + buf = wpabuf_alloc(512); + if (!buf) + return; + + wpabuf_put_u8(buf, WLAN_ACTION_WNM); + wpabuf_put_u8(buf, WNM_NOTIFICATION_REQ); + wpabuf_put_u8(buf, ++wpa_s->mbo_wnm_token); + wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC); /* Type */ + + wpas_mbo_np_chan_attrs(wpa_s, buf, 1); + + res = wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid, + wpa_s->own_addr, wpa_s->bssid, + wpabuf_head(buf), wpabuf_len(buf), 0); + if (res < 0) + wpa_printf(MSG_DEBUG, + "Failed to send WNM req with non preferred channel list"); + + wpabuf_free(buf); +} + + static int wpa_np_chan_is_eq(struct wpa_mbo_np_channel *a, struct wpa_mbo_np_channel *b) { @@ -263,6 +329,7 @@ update: os_free(wpa_s->np_chan); wpa_s->np_chan = chans; wpa_s->np_chan_num = num; + wpas_mbo_send_wnm_notification(wpa_s); return 0; diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 9519fb6..e03b619 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1027,6 +1027,7 @@ struct wpa_supplicant { u8 preference; } *np_chan; size_t np_chan_num; + u8 mbo_wnm_token; #endif /* CONFIG_MBO */ };