From patchwork Wed Aug 22 13:46:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Otcheretianski X-Patchwork-Id: 960875 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=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cq/dFRqQ"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::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 41wN9338Vwz9s3x for ; Wed, 22 Aug 2018 19:51:19 +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=LimeJyz7FqBUARy3XIW/0oaIdHA0ZtZtL/9TKjn0N1I=; b=cq/ dFRqQkF5SgQrr37lCLU3TWqq/H9yS3i9FOskLrWm55TNc8wjbYFELS45RLyXUKlSFxsrFezReT23h EXzON/6PxDB3v53ausrrBEBGY07C1aop9MxNcoADeSDpB7Y1M2La03qw4Du3g0Ley01nb3rSVTCm5 ro3+eCRYTa7RcNNEkfJICvBQ3s5qOBtADCmgavpn1+TVjkZJ1Vbh/XX48K4Al6HEdQWrfjTB6tVu1 +3l2tMa0Gc+NJ/nFgCn1wKaS3vw7pY88LPAon1y6KeBLlT2G3n2fLJm2WOrSTaT+Jkd6MXAcJyc6y 4lYHjhpWwitWxc6waOliBZCKq1niTLw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsPn8-00031L-Ap; Wed, 22 Aug 2018 09:51:06 +0000 Received: from mga17.intel.com ([192.55.52.151]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsPn1-0002wf-RV for hostap@lists.infradead.org; Wed, 22 Aug 2018 09:51:01 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Aug 2018 02:50:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,273,1531810800"; d="scan'208";a="83930236" Received: from unknown (HELO andrei-XPS-12-9Q33.ger.corp.intel.com) ([10.12.217.183]) by orsmga001.jf.intel.com with ESMTP; 22 Aug 2018 02:50:51 -0700 From: Andrei Otcheretianski To: hostap@lists.infradead.org Subject: [PATCH 3/5] RRM: Beacon report: Add support for last frame indication subelemet Date: Wed, 22 Aug 2018 16:46:19 +0300 Message-Id: <1534945581-27527-3-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-20180822_025059_905385_6631CDDA X-CRM114-Status: GOOD ( 17.57 ) X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- 2.4 DATE_IN_FUTURE_03_06 Date: is 3 to 6 hours after Received: date -0.0 SPF_PASS SPF: sender matches SPF record -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [192.55.52.151 listed in list.dnswl.org] 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: Avraham Stern MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Avraham Stern IEEE P802.11 - "Enhancement to Beacon Report" adds the Last Beacon Report Indication subelement to beacon request and beacon report elements. Add the Last Beacon Report Indication subelement to all beacon report elements if the beacon request indicated that this subelement is required. Signed-off-by: Avraham Stern --- src/common/ieee802_11_defs.h | 5 +++ wpa_supplicant/rrm.c | 71 ++++++++++++++++++++++++++++++++++++--- wpa_supplicant/wpa_supplicant_i.h | 1 + 3 files changed, 73 insertions(+), 4 deletions(-) diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h index c840b2e..4a7a803 100644 --- a/src/common/ieee802_11_defs.h +++ b/src/common/ieee802_11_defs.h @@ -1835,6 +1835,7 @@ enum beacon_report_mode { #define WLAN_BEACON_REQUEST_SUBELEM_DETAIL 2 /* Reporting Detail */ #define WLAN_BEACON_REQUEST_SUBELEM_REQUEST 10 #define WLAN_BEACON_REQUEST_SUBELEM_AP_CHANNEL 51 /* AP Channel Report */ +#define WLAN_BEACON_REQUEST_SUBELEM_LAST_INDICATION 164 #define WLAN_BEACON_REQUEST_SUBELEM_VENDOR 221 /* @@ -1886,12 +1887,16 @@ struct rrm_measurement_beacon_report { /* IEEE Std 802.11-2016, Table 9-112 - Beacon report Subelement IDs */ #define WLAN_BEACON_REPORT_SUBELEM_FRAME_BODY 1 #define WLAN_BEACON_REPORT_SUBELEM_FRAME_BODY_FRAGMENT_ID 2 +#define WLAN_BEACON_REPORT_SUBELEM_LAST_INDICATION 164 #define WLAN_BEACON_REPORT_SUBELEM_VENDOR 221 /* IEEE P802.11 - Beacon Report fragmentation */ #define REPORTED_FRAME_BODY_SUBELEM_LEN 4 #define REPORTED_FRAME_BODY_MORE_FRAGMENTS BIT(7) +/* IEEE P802.11 - Enhancement to Beacon Report */ +#define BEACON_REPORT_LAST_INDICATION_SUBELEM_LEN 3 + /* IEEE Std 802.11ad-2012 - Multi-band element */ struct multi_band_ie { u8 eid; /* WLAN_EID_MULTI_BAND */ diff --git a/wpa_supplicant/rrm.c b/wpa_supplicant/rrm.c index a001181..ff598fa 100644 --- a/wpa_supplicant/rrm.c +++ b/wpa_supplicant/rrm.c @@ -392,6 +392,45 @@ static void wpas_rrm_send_msr_report_mpdu(struct wpa_supplicant *wpa_s, } +static int wpas_rrm_beacon_rep_update_last_frame(const u8 *pos, size_t len) +{ + struct rrm_measurement_report_element *msr_rep; + const u8 *end = pos + len; + const u8 *msr_rep_end; + + while (end - pos >= (int)sizeof(*msr_rep)) { + msr_rep = (void *)pos; + msr_rep_end = pos + msr_rep->len + 2; + + if (msr_rep->eid != WLAN_EID_MEASURE_REPORT) { + /* should not happen. This indicates a bug */ + wpa_printf(MSG_ERROR, + "RRM: non measurement report element in measurement report frame"); + return -1; + } + + if (msr_rep->type == MEASURE_TYPE_BEACON) { + struct rrm_measurement_beacon_report *rep = + (void *)msr_rep->variable; + u8 *subelem = rep->variable; + + while (subelem + 2 < msr_rep_end && + subelem[0] != + WLAN_BEACON_REPORT_SUBELEM_LAST_INDICATION) + subelem += 2 + subelem[1]; + + if (subelem + + BEACON_REPORT_LAST_INDICATION_SUBELEM_LEN <= end) + subelem[2] = 1; + } + + pos += pos[1] + 2; + } + + return 0; +} + + static void wpas_rrm_send_msr_report(struct wpa_supplicant *wpa_s, struct wpabuf *buf) { @@ -403,6 +442,9 @@ static void wpas_rrm_send_msr_report(struct wpa_supplicant *wpa_s, while (len) { int send_len = (len > MPDU_REPORT_LEN) ? next - pos : len; + if (send_len == len) + wpas_rrm_beacon_rep_update_last_frame(pos, len); + if (send_len == len || (send_len + next[1] + 2) > MPDU_REPORT_LEN) { wpas_rrm_send_msr_report_mpdu(wpa_s, pos, send_len); @@ -796,12 +838,14 @@ static int wpas_add_beacon_rep_elem(struct beacon_rep_data *data, { int ret; u8 *buf, *pos; + u32 subelems_len = REPORTED_FRAME_BODY_SUBELEM_LEN + + (data->last_indication ? + BEACON_REPORT_LAST_INDICATION_SUBELEM_LEN : 0); /* Maximum element length: beacon report element + reported frame body * subelement + all IEs of the reported beacon + reported frame body * fragment ID subelement */ - buf = os_malloc(sizeof(*rep) + 14 + *ie_len + - REPORTED_FRAME_BODY_SUBELEM_LEN); + buf = os_malloc(sizeof(*rep) + 14 + *ie_len + subelems_len); if (!buf) return -1; @@ -832,11 +876,20 @@ static int wpas_add_beacon_rep_elem(struct beacon_rep_data *data, else pos[3] &= ~REPORTED_FRAME_BODY_MORE_FRAGMENTS; + pos += REPORTED_FRAME_BODY_SUBELEM_LEN; + + if (data->last_indication) { + pos[0] = WLAN_BEACON_REPORT_SUBELEM_LAST_INDICATION; + pos[1] = 1; + + /* this field will be updated later if this is the last frame */ + pos[2] = 0; + } + ret = wpas_rrm_report_elem(wpa_buf, data->token, MEASUREMENT_REPORT_MODE_ACCEPT, MEASURE_TYPE_BEACON, buf, - ret + sizeof(*rep) + - REPORTED_FRAME_BODY_SUBELEM_LEN); + ret + sizeof(*rep) + subelems_len); out: os_free(buf); return ret; @@ -1051,6 +1104,16 @@ static int wpas_rm_handle_beacon_req_subelem(struct wpa_supplicant *wpa_s, case WLAN_BEACON_REQUEST_SUBELEM_AP_CHANNEL: /* Skip - it will be processed when freqs are added */ break; + case WLAN_BEACON_REQUEST_SUBELEM_LAST_INDICATION: + if (slen != 1) { + wpa_printf(MSG_DEBUG, + "Invalid request subelement length: %u", + slen); + return -1; + } + + data->last_indication = subelem[0]; + break; default: wpa_printf(MSG_DEBUG, "Beacon request: Unknown subelement id %u", sid); diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 2b0dca0..6092471 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -461,6 +461,7 @@ struct beacon_rep_data { u8 bssid[ETH_ALEN]; enum beacon_report_detail report_detail; struct bitfield *eids; + int last_indication; };