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()
14 from tshark import run_tshark
16 def test_mbo_assoc_disallow(dev, apdev, params):
17 hapd1 = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "MBO", "mbo": "1" })
18 hapd2 = hostapd.add_ap(apdev[1]['ifname'], { "ssid": "MBO", "mbo": "1" })
20 logger.debug("Set mbo_assoc_disallow with invalid value")
21 if "FAIL" not in hapd1.request("SET mbo_assoc_disallow 2"):
22 raise Exception("Set mbo_assoc_disallow for AP1 succeeded unexpectedly with value 2")
24 logger.debug("Disallow associations to AP1 and allow association to AP2")
25 if "OK" not in hapd1.request("SET mbo_assoc_disallow 1"):
26 raise Exception("Failed to set mbo_assoc_disallow for AP1")
27 if "OK" not in hapd2.request("SET mbo_assoc_disallow 0"):
28 raise Exception("Failed to set mbo_assoc_disallow for AP2")
30 dev[0].connect("MBO", key_mgmt="NONE", scan_freq="2412")
32 out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
33 "wlan.fc.type == 0 && wlan.fc.type_subtype == 0x00",
35 if "Destination address: " + hapd1.own_addr() in out:
36 raise Exception("Association request sent to disallowed AP")
38 timestamp = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
39 "wlan.fc.type_subtype == 0x00",
40 display=['frame.time'], wait=False)
42 logger.debug("Allow associations to AP1 and disallow assications to AP2")
43 if "OK" not in hapd1.request("SET mbo_assoc_disallow 0"):
44 raise Exception("Failed to set mbo_assoc_disallow for AP1")
45 if "OK" not in hapd2.request("SET mbo_assoc_disallow 1"):
46 raise Exception("Failed to set mbo_assoc_disallow for AP2")
48 dev[0].request("DISCONNECT")
49 dev[0].wait_disconnected()
51 # Force new scan, so the assoc_disallowed indication is updated */
52 dev[0].request("FLUSH")
54 dev[0].connect("MBO", key_mgmt="NONE", scan_freq="2412")
56 filter = 'wlan.fc.type == 0 && wlan.fc.type_subtype == 0x00 && frame.time > "' + timestamp.rstrip() + '"'
57 out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
59 if "Destination address: " + hapd2.own_addr() in out:
60 raise Exception("Association request sent to disallowed AP 2")
62 def test_mbo_cell_capa_update(dev, apdev):
63 """MBO cellular data capability update"""
65 params = { 'ssid': ssid, 'mbo': '1' }
66 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
67 bssid = apdev[0]['bssid']
68 if "OK" not in dev[0].request("SET mbo_cell_capa 1"):
69 raise Exception("Failed to set STA as cellular data capable")
71 dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
73 addr = dev[0].own_addr()
74 sta = hapd.get_sta(addr)
75 if 'mbo_cell_capa' not in sta or sta['mbo_cell_capa'] != '1':
76 raise Exception("mbo_cell_capa missing after association")
78 if "OK" not in dev[0].request("SET mbo_cell_capa 3"):
79 raise Exception("Failed to set STA as cellular data not-capable")
82 sta = hapd.get_sta(addr)
83 if 'mbo_cell_capa' not in sta:
84 raise Exception("mbo_cell_capa missing after update")
85 if sta['mbo_cell_capa'] != '3':
86 raise Exception("mbo_cell_capa not updated properly")