2 # Copyright (c) 2016, Intel Deutschland GmbH
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
8 logger = logging.getLogger()
13 from tshark import run_tshark
15 def test_mbo_assoc_disallow(dev, apdev, params):
16 hapd1 = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "MBO", "mbo": "1" })
17 hapd2 = hostapd.add_ap(apdev[1]['ifname'], { "ssid": "MBO", "mbo": "1" })
19 logger.debug("Set mbo_assoc_disallow with invalid value")
20 if "FAIL" not in hapd1.request("SET mbo_assoc_disallow 2"):
21 raise Exception("Set mbo_assoc_disallow for AP1 succeeded unexpectedly with value 2")
23 logger.debug("Disallow associations to AP1 and allow association to AP2")
24 if "OK" not in hapd1.request("SET mbo_assoc_disallow 1"):
25 raise Exception("Failed to set mbo_assoc_disallow for AP1")
26 if "OK" not in hapd2.request("SET mbo_assoc_disallow 0"):
27 raise Exception("Failed to set mbo_assoc_disallow for AP2")
29 dev[0].connect("MBO", key_mgmt="NONE", scan_freq="2412")
31 out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
32 "wlan.fc.type == 0 && wlan.fc.type_subtype == 0x00",
34 if "Destination address: " + hapd1.own_addr() in out:
35 raise Exception("Association request sent to disallowed AP")
37 timestamp = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
38 "wlan.fc.type_subtype == 0x00",
39 display=['frame.time'], wait=False)
41 logger.debug("Allow associations to AP1 and disallow assications to AP2")
42 if "OK" not in hapd1.request("SET mbo_assoc_disallow 0"):
43 raise Exception("Failed to set mbo_assoc_disallow for AP1")
44 if "OK" not in hapd2.request("SET mbo_assoc_disallow 1"):
45 raise Exception("Failed to set mbo_assoc_disallow for AP2")
47 dev[0].request("DISCONNECT")
48 dev[0].wait_disconnected()
50 # Force new scan, so the assoc_disallowed indication is updated */
51 dev[0].request("FLUSH")
53 dev[0].connect("MBO", key_mgmt="NONE", scan_freq="2412")
55 filter = 'wlan.fc.type == 0 && wlan.fc.type_subtype == 0x00 && frame.time > "' + timestamp.rstrip() + '"'
56 out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
58 if "Destination address: " + hapd2.own_addr() in out:
59 raise Exception("Association request sent to disallowed AP 2")