]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Beacon request - active scan mode and NO_IR channel
authorJouni Malinen <j@w1.fi>
Sat, 9 Apr 2022 16:17:00 +0000 (19:17 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 9 Apr 2022 16:17:00 +0000 (19:17 +0300)
Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/test_rrm.py

index 5a65a506e32294a6ee36dfe111bfabef63676825..67b21e306bf285a326ec6c0c4fe1d84d10b24273 100644 (file)
@@ -815,6 +815,11 @@ class BeaconReport:
 
         return txt
 
+def build_beacon_request(opclass=81, chan=0, rand_int=0, duration=0, mode=0,
+                         bssid="FF:FF:FF:FF:FF:FF"):
+    req = struct.pack("<BBHHB", opclass, chan, rand_int, duration, mode)
+    return binascii.hexlify(req).decode() + bssid.replace(':', '')
+
 def run_req_beacon(hapd, addr, request):
     token = hapd.request("REQ_BEACON " + addr + " " + request)
     if "FAIL" in token:
@@ -1471,6 +1476,29 @@ def test_rrm_beacon_req_active_ap_channels(dev, apdev):
             if report.opclass != 81 or report.channel != 11:
                 raise Exception("Incorrect opclass/channel for AP1")
 
+@remote_compatible
+def test_rrm_beacon_req_active_no_ir(dev, apdev):
+    """Beacon request - active scan mode and NO_IR channel"""
+    params = {"ssid": "rrm", "rrm_beacon_report": "1"}
+    hapd = hostapd.add_ap(apdev[0], params)
+
+    dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412")
+    addr = dev[0].own_addr()
+
+    req = build_beacon_request(opclass=118, chan=52, duration=100, mode=1)
+    token = run_req_beacon(hapd, addr, req)
+    ev = hapd.wait_event(["BEACON-RESP-RX"], timeout=10)
+    if ev is None:
+        raise Exception("Beacon report response not received")
+    fields = ev.split(' ')
+    if fields[2] != token:
+        raise Exception("Unexpected token value in response (expected %s): %s" % (token, fields[2]))
+    mode = int(fields[3], base=16)
+    if mode & 0x04:
+        raise Exception("Beacon request refused")
+    report = BeaconReport(binascii.unhexlify(fields[4]))
+    logger.info("Beacon report: " + str(report))
+
 @remote_compatible
 def test_rrm_beacon_req_passive_ap_channels(dev, apdev):
     """Beacon request - passive scan mode with AP Channel Report subelement"""