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")
88 def test_mbo_cell_capa_update_pmf(dev, apdev):
89 """MBO cellular data capability update with PMF required"""
91 passphrase = "12345678"
92 params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
93 params["wpa_key_mgmt"] = "WPA-PSK-SHA256";
94 params["ieee80211w"] = "2";
96 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
97 bssid = apdev[0]['bssid']
98 if "OK" not in dev[0].request("SET mbo_cell_capa 1"):
99 raise Exception("Failed to set STA as cellular data capable")
101 dev[0].connect(ssid, psk=passphrase, key_mgmt="WPA-PSK-SHA256",
102 proto="WPA2", ieee80211w="2", scan_freq="2412")
104 addr = dev[0].own_addr()
105 sta = hapd.get_sta(addr)
106 if 'mbo_cell_capa' not in sta or sta['mbo_cell_capa'] != '1':
107 raise Exception("mbo_cell_capa missing after association")
109 if "OK" not in dev[0].request("SET mbo_cell_capa 3"):
110 raise Exception("Failed to set STA as cellular data not-capable")
113 sta = hapd.get_sta(addr)
114 if 'mbo_cell_capa' not in sta:
115 raise Exception("mbo_cell_capa missing after update")
116 if sta['mbo_cell_capa'] != '3':
117 raise Exception("mbo_cell_capa not updated properly")
119 def test_mbo_non_pref_chan(dev, apdev):
120 """MBO non-preferred channel list"""
121 ssid = "test-wnm-mbo"
122 params = { 'ssid': ssid, 'mbo': '1' }
123 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
124 bssid = apdev[0]['bssid']
125 if "OK" not in dev[0].request("SET non_pref_chan 81:7:200:3"):
126 raise Exception("Failed to set non-preferred channel list")
127 if "OK" not in dev[0].request("SET non_pref_chan 81:7:200:1:123 81:9:100:2"):
128 raise Exception("Failed to set non-preferred channel list")
130 dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
132 addr = dev[0].own_addr()
133 sta = hapd.get_sta(addr)
134 logger.debug("STA: " + str(sta))
135 if 'non_pref_chan[0]' not in sta:
136 raise Exception("Missing non_pref_chan[0] value (assoc)")
137 if sta['non_pref_chan[0]'] != '81:200:1:123:7':
138 raise Exception("Unexpected non_pref_chan[0] value (assoc)")
139 if 'non_pref_chan[1]' not in sta:
140 raise Exception("Missing non_pref_chan[1] value (assoc)")
141 if sta['non_pref_chan[1]'] != '81:100:2:0:9':
142 raise Exception("Unexpected non_pref_chan[1] value (assoc)")
143 if 'non_pref_chan[2]' in sta:
144 raise Exception("Unexpected non_pref_chan[2] value (assoc)")
146 if "OK" not in dev[0].request("SET non_pref_chan 81:9:100:2"):
147 raise Exception("Failed to update non-preferred channel list")
149 sta = hapd.get_sta(addr)
150 logger.debug("STA: " + str(sta))
151 if 'non_pref_chan[0]' not in sta:
152 raise Exception("Missing non_pref_chan[0] value (update 1)")
153 if sta['non_pref_chan[0]'] != '81:100:2:0:9':
154 raise Exception("Unexpected non_pref_chan[0] value (update 1)")
155 if 'non_pref_chan[1]' in sta:
156 raise Exception("Unexpected non_pref_chan[2] value (update 1)")
158 if "OK" not in dev[0].request("SET non_pref_chan 81:9:100:2 81:10:100:2 81:8:100:2 81:7:100:1:123 81:5:100:1:124"):
159 raise Exception("Failed to update non-preferred channel list")
161 sta = hapd.get_sta(addr)
162 logger.debug("STA: " + str(sta))
163 if 'non_pref_chan[0]' not in sta:
164 raise Exception("Missing non_pref_chan[0] value (update 2)")
165 if sta['non_pref_chan[0]'] != '81:100:1:123:7':
166 raise Exception("Unexpected non_pref_chan[0] value (update 2)")
167 if 'non_pref_chan[1]' not in sta:
168 raise Exception("Missing non_pref_chan[1] value (update 2)")
169 if sta['non_pref_chan[1]'] != '81:100:1:124:5':
170 raise Exception("Unexpected non_pref_chan[1] value (update 2)")
171 if 'non_pref_chan[2]' not in sta:
172 raise Exception("Missing non_pref_chan[2] value (update 2)")
173 if sta['non_pref_chan[2]'] != '81:100:2:0:9,10,8':
174 raise Exception("Unexpected non_pref_chan[2] value (update 2)")
175 if 'non_pref_chan[3]' in sta:
176 raise Exception("Unexpected non_pref_chan[3] value (update 2)")
178 if "OK" not in dev[0].request("SET non_pref_chan 81:5:90:2 82:14:91:2"):
179 raise Exception("Failed to update non-preferred channel list")
181 sta = hapd.get_sta(addr)
182 logger.debug("STA: " + str(sta))
183 if 'non_pref_chan[0]' not in sta:
184 raise Exception("Missing non_pref_chan[0] value (update 3)")
185 if sta['non_pref_chan[0]'] != '81:90:2:0:5':
186 raise Exception("Unexpected non_pref_chan[0] value (update 3)")
187 if 'non_pref_chan[1]' not in sta:
188 raise Exception("Missing non_pref_chan[1] value (update 3)")
189 if sta['non_pref_chan[1]'] != '82:91:2:0:14':
190 raise Exception("Unexpected non_pref_chan[1] value (update 3)")
191 if 'non_pref_chan[2]' in sta:
192 raise Exception("Unexpected non_pref_chan[2] value (update 3)")
194 if "OK" not in dev[0].request("SET non_pref_chan "):
195 raise Exception("Failed to update non-preferred channel list")
197 sta = hapd.get_sta(addr)
198 logger.debug("STA: " + str(sta))
199 if 'non_pref_chan[0]' in sta:
200 raise Exception("Unexpected non_pref_chan[0] value (update 4)")