From patchwork Wed Aug 22 13:46:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Otcheretianski X-Patchwork-Id: 960876 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="dAH5Rnpt"; 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 41wN966h2fz9s3x for ; Wed, 22 Aug 2018 19:51:22 +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=fpcaxgmhiXGqcqoC9+guTkAb7MVzhM0jjrrUvAWaaLw=; b=dAH 5RnptfXPzryzj0Ktr2Gbl8HDrmdibxbQgntIyo8Bzh2chDPwFMpLGjM8gLjagNT002VSRVSzpbWT4 t2zEjCrBW9EFEECTp3ndMVA2G298pfhFKUaBEPk8UFJPJ8n2GVuUh3qB+iZ6g+oK7kmdhCuHW4jPb oQTNrB7i1yAnmUKPVMFjHcBhQtLI9G3/iB8s1ZoQyfKE7+ACeWkTUPUe2bVm1r3jczPWW+grLLNXG IddoCfyaPKkIOXrsijJrBEUNnFsbLp639eLxbURCZ+SUhhabiWSt/7AzzMRXNzvPHYBvpz0mZ9uHB NuTxRSI1XI374yACottJnNB6kIVGwyg==; 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 1fsPnE-00039x-5U; Wed, 22 Aug 2018 09:51:12 +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-0002wW-Rr for hostap@lists.infradead.org; Wed, 22 Aug 2018 09:51:02 +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:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,273,1531810800"; d="scan'208";a="83930225" 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:49 -0700 From: Andrei Otcheretianski To: hostap@lists.infradead.org Subject: [PATCH 2/5] tests: Beacon report frame body fragmentation Date: Wed, 22 Aug 2018 16:46:18 +0300 Message-Id: <1534945581-27527-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-20180822_025059_911273_60A248E1 X-CRM114-Status: GOOD ( 10.73 ) 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.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [192.55.52.151 listed in list.dnswl.org] 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 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 Verify that when the frame body subelement causes the measurement report element to exceed the maximum element size, the beacon report is fragmented and the frame body fragment ID subelement is added with the correct fragment number. Signed-off-by: Avraham Stern --- tests/hwsim/test_rrm.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tests/hwsim/test_rrm.py b/tests/hwsim/test_rrm.py index eb1b67b..ffd647b 100644 --- a/tests/hwsim/test_rrm.py +++ b/tests/hwsim/test_rrm.py @@ -705,6 +705,7 @@ class BeaconReport: report = report[5:] self.subelems = report self.frame_body = None + self.frame_body_fragment_id = None while len(report) >= 2: eid,elen = struct.unpack('BB', report[0:2]) report = report[2:] @@ -719,11 +720,15 @@ class BeaconReport: # 2 = all fixed fields and all elements # Fixed fields: Timestamp[8] BeaconInt[2] CapabInfo[2] self.frame_body = report[0:elen] + if eid == 2: + self.frame_body_fragment_id = report[0:elen] report = report[elen:] def __str__(self): txt = "opclass={} channel={} start={} duration={} frame_info={} rcpi={} rsni={} bssid={} antenna_id={} parent_tsf={}".format(self.opclass, self.channel, self.start, self.duration, self.frame_info, self.rcpi, self.rsni, self.bssid_str, self.antenna_id, self.parent_tsf) if self.frame_body: txt += " frame_body=" + binascii.hexlify(self.frame_body) + if self.frame_body_fragment_id: + txt += " fragment_id=" + binascii.hexlify(self.frame_body_fragment_id) return txt def run_req_beacon(hapd, addr, request): @@ -786,6 +791,52 @@ def test_rrm_beacon_req_table(dev, apdev): if len(report.frame_body) <= 12: raise Exception("Too short Reported Frame Body subelement") +def test_rrm_beacon_req_frame_body_fragmentation(dev, apdev): + """Beacon request - beacon table mode - frame body fragmentation""" + params = { "ssid": "rrm", "rrm_beacon_report": "1" } + + hapd = hostapd.add_ap(apdev[0], params) + hapd.set('vendor_elements', ("dd051122330203dd0400137400dd04001374ffdd0511" + "22330203dd0400137400dd04001374ffdd051122330203dd0400137400dd04001" + "374ffdd051122330203dd0400137400dd04001374ffdd051122330203dd040013" + "7400dd04001374ffdd051122330203dd0400137400dd04001374ffdd051122330" + "203dd0400137400dd04001374ffdd051122330203dd0400137400dd04001374ff" + "dd051122330203dd0400137400dd04001374ff")) + + dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") + addr = dev[0].own_addr() + + token = run_req_beacon(hapd, addr, "51000000000002ffffffffffff") + + # 2 beacon reports elements are expected because of fragmentation + for i in range(0, 2): + ev = hapd.wait_event(["BEACON-RESP-RX"], timeout=10) + if ev is None: + raise Exception("Beacon report %d response not received" % i) + fields = ev.split(' ') + if fields[1] != addr: + raise Exception("Unexpected STA address in beacon report response: " + fields[1]) + if fields[2] != token: + raise Exception("Unexpected dialog token in beacon report response: " + fields[2] + " (expected " + token + ")") + if fields[3] != "00": + raise Exception("Unexpected measurement report mode") + + report = BeaconReport(binascii.unhexlify(fields[4])) + logger.info("Received beacon report: " + str(report)) + + # Default reporting detail is 2, i.e., all fixed fields and elements. + if not report.frame_body_fragment_id: + raise Exception("Reported Frame Body Fragment ID subelement missing") + fragment_id = binascii.hexlify(report.frame_body_fragment_id) + frag_number = int(fragment_id[2:], 16) & int(0x7f) + if frag_number != i: + raise Exception("Incorrect fragment number: %d" % frag_number) + more_frags = int(fragment_id[2:], 16) >> 7 + if i == 0 and more_frags != 1: + raise Exception("more fragments bit is not set on first fragment") + if i == 1 and more_frags != 0: + raise Exception("more fragments bit is set on last fragment") + @remote_compatible def test_rrm_beacon_req_table_detail(dev, apdev): """Beacon request - beacon table mode - reporting detail"""