]> git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_hapd_ctrl.py
tests: Update FT test cases for new RRB message format
[thirdparty/hostap.git] / tests / hwsim / test_hapd_ctrl.py
1 # hostapd control interface
2 # Copyright (c) 2014, Qualcomm Atheros, Inc.
3 #
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
6
7 from remotehost import remote_compatible
8 import hostapd
9 import hwsim_utils
10 from utils import skip_with_fips, alloc_fail, fail_test, HwsimSkip
11
12 @remote_compatible
13 def test_hapd_ctrl_status(dev, apdev):
14 """hostapd ctrl_iface STATUS commands"""
15 ssid = "hapd-ctrl"
16 bssid = apdev[0]['bssid']
17 params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
18 hapd = hostapd.add_ap(apdev[0], params)
19 status = hapd.get_status()
20 driver = hapd.get_driver_status()
21
22 if status['bss[0]'] != apdev[0]['ifname']:
23 raise Exception("Unexpected bss[0]")
24 if status['ssid[0]'] != ssid:
25 raise Exception("Unexpected ssid[0]")
26 if status['bssid[0]'] != bssid:
27 raise Exception("Unexpected bssid[0]")
28 if status['freq'] != "2412":
29 raise Exception("Unexpected freq")
30
31 if driver['beacon_set'] != "1":
32 raise Exception("Unexpected beacon_set")
33 if driver['addr'] != bssid:
34 raise Exception("Unexpected addr")
35
36 @remote_compatible
37 def test_hapd_ctrl_p2p_manager(dev, apdev):
38 """hostapd as P2P Device manager"""
39 ssid = "hapd-p2p-mgr"
40 passphrase = "12345678"
41 params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
42 params['manage_p2p'] = '1'
43 params['allow_cross_connection'] = '0'
44 hapd = hostapd.add_ap(apdev[0], params)
45 dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
46 addr = dev[0].own_addr()
47 if "OK" not in hapd.request("DEAUTHENTICATE " + addr + " p2p=2"):
48 raise Exception("DEAUTHENTICATE command failed")
49 dev[0].wait_disconnected(timeout=5)
50 dev[0].wait_connected(timeout=10, error="Re-connection timed out")
51
52 if "OK" not in hapd.request("DISASSOCIATE " + addr + " p2p=2"):
53 raise Exception("DISASSOCIATE command failed")
54 dev[0].wait_disconnected(timeout=5)
55 dev[0].wait_connected(timeout=10, error="Re-connection timed out")
56
57 @remote_compatible
58 def test_hapd_ctrl_sta(dev, apdev):
59 """hostapd and STA ctrl_iface commands"""
60 ssid = "hapd-ctrl-sta"
61 passphrase = "12345678"
62 params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
63 hapd = hostapd.add_ap(apdev[0], params)
64 dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
65 addr = dev[0].own_addr()
66 if "FAIL" in hapd.request("STA " + addr):
67 raise Exception("Unexpected STA failure")
68 if "FAIL" not in hapd.request("STA " + addr + " eapol"):
69 raise Exception("Unexpected STA-eapol success")
70 if "FAIL" not in hapd.request("STA " + addr + " foo"):
71 raise Exception("Unexpected STA-foo success")
72 if "FAIL" not in hapd.request("STA 00:11:22:33:44"):
73 raise Exception("Unexpected STA success")
74 if "FAIL" not in hapd.request("STA 00:11:22:33:44:55"):
75 raise Exception("Unexpected STA success")
76
77 if len(hapd.request("STA-NEXT " + addr).splitlines()) > 0:
78 raise Exception("Unexpected STA-NEXT result")
79 if "FAIL" not in hapd.request("STA-NEXT 00:11:22:33:44"):
80 raise Exception("Unexpected STA-NEXT success")
81
82 @remote_compatible
83 def test_hapd_ctrl_disconnect(dev, apdev):
84 """hostapd and disconnection ctrl_iface commands"""
85 ssid = "hapd-ctrl"
86 passphrase = "12345678"
87 params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
88 hapd = hostapd.add_ap(apdev[0], params)
89 dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
90 addr = dev[0].p2p_dev_addr()
91
92 if "FAIL" not in hapd.request("DEAUTHENTICATE 00:11:22:33:44"):
93 raise Exception("Unexpected DEAUTHENTICATE success")
94
95 if "OK" not in hapd.request("DEAUTHENTICATE ff:ff:ff:ff:ff:ff"):
96 raise Exception("Unexpected DEAUTHENTICATE failure")
97 dev[0].wait_disconnected(timeout=5)
98 dev[0].wait_connected(timeout=10, error="Re-connection timed out")
99
100 if "FAIL" not in hapd.request("DISASSOCIATE 00:11:22:33:44"):
101 raise Exception("Unexpected DISASSOCIATE success")
102
103 if "OK" not in hapd.request("DISASSOCIATE ff:ff:ff:ff:ff:ff"):
104 raise Exception("Unexpected DISASSOCIATE failure")
105 dev[0].wait_disconnected(timeout=5)
106 dev[0].wait_connected(timeout=10, error="Re-connection timed out")
107
108 @remote_compatible
109 def test_hapd_ctrl_chan_switch(dev, apdev):
110 """hostapd and CHAN_SWITCH ctrl_iface command"""
111 ssid = "hapd-ctrl"
112 params = { "ssid": ssid }
113 hapd = hostapd.add_ap(apdev[0], params)
114 if "FAIL" not in hapd.request("CHAN_SWITCH "):
115 raise Exception("Unexpected CHAN_SWITCH success")
116 if "FAIL" not in hapd.request("CHAN_SWITCH qwerty 2422"):
117 raise Exception("Unexpected CHAN_SWITCH success")
118 if "FAIL" not in hapd.request("CHAN_SWITCH 5 qwerty"):
119 raise Exception("Unexpected CHAN_SWITCH success")
120 if "FAIL" not in hapd.request("CHAN_SWITCH 0 2432 center_freq1=123 center_freq2=234 bandwidth=1000 sec_channel_offset=20 ht vht"):
121 raise Exception("Unexpected CHAN_SWITCH success")
122
123 @remote_compatible
124 def test_hapd_ctrl_level(dev, apdev):
125 """hostapd and LEVEL ctrl_iface command"""
126 ssid = "hapd-ctrl"
127 params = { "ssid": ssid }
128 hapd = hostapd.add_ap(apdev[0], params)
129 if "FAIL" not in hapd.request("LEVEL 0"):
130 raise Exception("Unexpected LEVEL success on non-monitor interface")
131
132 @remote_compatible
133 def test_hapd_ctrl_new_sta(dev, apdev):
134 """hostapd and NEW_STA ctrl_iface command"""
135 ssid = "hapd-ctrl"
136 params = { "ssid": ssid }
137 hapd = hostapd.add_ap(apdev[0], params)
138 if "FAIL" not in hapd.request("NEW_STA 00:11:22:33:44"):
139 raise Exception("Unexpected NEW_STA success")
140 if "OK" not in hapd.request("NEW_STA 00:11:22:33:44:55"):
141 raise Exception("Unexpected NEW_STA failure")
142 if "AUTHORIZED" not in hapd.request("STA 00:11:22:33:44:55"):
143 raise Exception("Unexpected NEW_STA STA status")
144 if "OK" not in hapd.request("NEW_STA 00:11:22:33:44:55"):
145 raise Exception("Unexpected NEW_STA failure")
146 with alloc_fail(hapd, 1, "ap_sta_add;hostapd_ctrl_iface_new_sta"):
147 if "FAIL" not in hapd.request("NEW_STA 00:11:22:33:44:66"):
148 raise Exception("Unexpected NEW_STA success during OOM")
149
150 @remote_compatible
151 def test_hapd_ctrl_get(dev, apdev):
152 """hostapd and GET ctrl_iface command"""
153 ssid = "hapd-ctrl"
154 params = { "ssid": ssid }
155 hapd = hostapd.add_ap(apdev[0], params)
156 if "FAIL" not in hapd.request("GET foo"):
157 raise Exception("Unexpected GET success")
158 if "FAIL" in hapd.request("GET version"):
159 raise Exception("Unexpected GET version failure")
160
161 @remote_compatible
162 def test_hapd_ctrl_unknown(dev, apdev):
163 """hostapd and unknown ctrl_iface command"""
164 ssid = "hapd-ctrl"
165 params = { "ssid": ssid }
166 hapd = hostapd.add_ap(apdev[0], params)
167 if "UNKNOWN COMMAND" not in hapd.request("FOO"):
168 raise Exception("Unexpected response")
169
170 @remote_compatible
171 def test_hapd_ctrl_hs20_wnm_notif(dev, apdev):
172 """hostapd and HS20_WNM_NOTIF ctrl_iface command"""
173 ssid = "hapd-ctrl"
174 params = { "ssid": ssid }
175 hapd = hostapd.add_ap(apdev[0], params)
176 if "FAIL" not in hapd.request("HS20_WNM_NOTIF 00:11:22:33:44 http://example.com/"):
177 raise Exception("Unexpected HS20_WNM_NOTIF success")
178 if "FAIL" not in hapd.request("HS20_WNM_NOTIF 00:11:22:33:44:55http://example.com/"):
179 raise Exception("Unexpected HS20_WNM_NOTIF success")
180
181 @remote_compatible
182 def test_hapd_ctrl_hs20_deauth_req(dev, apdev):
183 """hostapd and HS20_DEAUTH_REQ ctrl_iface command"""
184 ssid = "hapd-ctrl"
185 params = { "ssid": ssid }
186 hapd = hostapd.add_ap(apdev[0], params)
187 if "FAIL" not in hapd.request("HS20_DEAUTH_REQ 00:11:22:33:44 1 120 http://example.com/"):
188 raise Exception("Unexpected HS20_DEAUTH_REQ success")
189 if "FAIL" not in hapd.request("HS20_DEAUTH_REQ 00:11:22:33:44:55"):
190 raise Exception("Unexpected HS20_DEAUTH_REQ success")
191 if "FAIL" not in hapd.request("HS20_DEAUTH_REQ 00:11:22:33:44:55 1"):
192 raise Exception("Unexpected HS20_DEAUTH_REQ success")
193
194 @remote_compatible
195 def test_hapd_ctrl_disassoc_imminent(dev, apdev):
196 """hostapd and DISASSOC_IMMINENT ctrl_iface command"""
197 ssid = "hapd-ctrl"
198 params = { "ssid": ssid }
199 hapd = hostapd.add_ap(apdev[0], params)
200 if "FAIL" not in hapd.request("DISASSOC_IMMINENT 00:11:22:33:44"):
201 raise Exception("Unexpected DISASSOC_IMMINENT success")
202 if "FAIL" not in hapd.request("DISASSOC_IMMINENT 00:11:22:33:44:55"):
203 raise Exception("Unexpected DISASSOC_IMMINENT success")
204 if "FAIL" not in hapd.request("DISASSOC_IMMINENT 00:11:22:33:44:55 2"):
205 raise Exception("Unexpected DISASSOC_IMMINENT success")
206 dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
207 addr = dev[0].p2p_interface_addr()
208 if "OK" not in hapd.request("DISASSOC_IMMINENT " + addr + " 2"):
209 raise Exception("Unexpected DISASSOC_IMMINENT failure")
210 ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], 15)
211 if ev is None:
212 raise Exception("Scan timed out")
213
214 @remote_compatible
215 def test_hapd_ctrl_ess_disassoc(dev, apdev):
216 """hostapd and ESS_DISASSOC ctrl_iface command"""
217 ssid = "hapd-ctrl"
218 params = { "ssid": ssid }
219 hapd = hostapd.add_ap(apdev[0], params)
220 if "FAIL" not in hapd.request("ESS_DISASSOC 00:11:22:33:44"):
221 raise Exception("Unexpected ESS_DISASSOCT success")
222 if "FAIL" not in hapd.request("ESS_DISASSOC 00:11:22:33:44:55"):
223 raise Exception("Unexpected ESS_DISASSOC success")
224 dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
225 addr = dev[0].p2p_interface_addr()
226 if "FAIL" not in hapd.request("ESS_DISASSOC " + addr):
227 raise Exception("Unexpected ESS_DISASSOC success")
228 if "FAIL" not in hapd.request("ESS_DISASSOC " + addr + " -1"):
229 raise Exception("Unexpected ESS_DISASSOC success")
230 if "FAIL" not in hapd.request("ESS_DISASSOC " + addr + " 1"):
231 raise Exception("Unexpected ESS_DISASSOC success")
232 if "OK" not in hapd.request("ESS_DISASSOC " + addr + " 20 http://example.com/"):
233 raise Exception("Unexpected ESS_DISASSOC failure")
234 ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], 15)
235 if ev is None:
236 raise Exception("Scan timed out")
237
238 def test_hapd_ctrl_set_deny_mac_file(dev, apdev):
239 """hostapd and SET deny_mac_file ctrl_iface command"""
240 ssid = "hapd-ctrl"
241 params = { "ssid": ssid }
242 hapd = hostapd.add_ap(apdev[0], params)
243 dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
244 dev[1].connect(ssid, key_mgmt="NONE", scan_freq="2412")
245 if "OK" not in hapd.request("SET deny_mac_file hostapd.macaddr"):
246 raise Exception("Unexpected SET failure")
247 dev[0].wait_disconnected(timeout=15)
248 ev = dev[1].wait_event(["CTRL-EVENT-DISCONNECTED"], 1)
249 if ev is not None:
250 raise Exception("Unexpected disconnection")
251
252 def test_hapd_ctrl_set_accept_mac_file(dev, apdev):
253 """hostapd and SET accept_mac_file ctrl_iface command"""
254 ssid = "hapd-ctrl"
255 params = { "ssid": ssid }
256 hapd = hostapd.add_ap(apdev[0], params)
257 dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
258 dev[1].connect(ssid, key_mgmt="NONE", scan_freq="2412")
259 hapd.request("SET macaddr_acl 1")
260 if "OK" not in hapd.request("SET accept_mac_file hostapd.macaddr"):
261 raise Exception("Unexpected SET failure")
262 dev[1].wait_disconnected(timeout=15)
263 ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], 1)
264 if ev is not None:
265 raise Exception("Unexpected disconnection")
266
267 def test_hapd_ctrl_set_accept_mac_file_vlan(dev, apdev):
268 """hostapd and SET accept_mac_file ctrl_iface command (VLAN ID)"""
269 ssid = "hapd-ctrl"
270 params = { "ssid": ssid }
271 hapd = hostapd.add_ap(apdev[0], params)
272 dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
273 dev[1].connect(ssid, key_mgmt="NONE", scan_freq="2412")
274 hapd.request("SET macaddr_acl 1")
275 if "OK" not in hapd.request("SET accept_mac_file hostapd.accept"):
276 raise Exception("Unexpected SET failure")
277 dev[1].wait_disconnected(timeout=15)
278 dev[0].wait_disconnected(timeout=15)
279
280 @remote_compatible
281 def test_hapd_ctrl_set_error_cases(dev, apdev):
282 """hostapd and SET error cases"""
283 ssid = "hapd-ctrl"
284 params = { "ssid": ssid }
285 hapd = hostapd.add_ap(apdev[0], params)
286 errors = [ "wpa_key_mgmt FOO",
287 "wpa_key_mgmt WPA-PSK \t FOO",
288 "wpa_key_mgmt \t ",
289 "wpa_pairwise FOO",
290 "wpa_pairwise \t ",
291 'wep_key0 "',
292 'wep_key0 "abcde',
293 "wep_key0 1",
294 "wep_key0 12q3456789",
295 "wep_key_len_broadcast 20",
296 "wep_rekey_period -1",
297 "wep_default_key 4",
298 "r0kh 02:00:00:00:03:0q nas1.w1.fi 100102030405060708090a0b0c0d0e0f100102030405060708090a0b0c0d0e0f",
299 "r0kh 02:00:00:00:03:00 12345678901234567890123456789012345678901234567890.nas1.w1.fi 100102030405060708090a0b0c0d0e0f100102030405060708090a0b0c0d0e0f",
300 "r0kh 02:00:00:00:03:00 nas1.w1.fi 100q02030405060708090a0b0c0d0e0f100q02030405060708090a0b0c0d0e0f",
301 "r1kh 02:00:00:00:04:q0 00:01:02:03:04:06 200102030405060708090a0b0c0d0e0f200102030405060708090a0b0c0d0e0f",
302 "r1kh 02:00:00:00:04:00 00:01:02:03:04:q6 200102030405060708090a0b0c0d0e0f200102030405060708090a0b0c0d0e0f",
303 "r1kh 02:00:00:00:04:00 00:01:02:03:04:06 2q0102030405060708090a0b0c0d0e0f2q0102030405060708090a0b0c0d0e0f",
304 "roaming_consortium 1",
305 "roaming_consortium 12",
306 "roaming_consortium 112233445566778899aabbccddeeff00",
307 'venue_name P"engExample venue"',
308 'venue_name P"engExample venue',
309 "venue_name engExample venue",
310 "venue_name e:Example venue",
311 "venue_name eng1:Example venue",
312 "venue_name eng:Example venue 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
313 "anqp_3gpp_cell_net abc",
314 "anqp_3gpp_cell_net ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;",
315 "anqp_3gpp_cell_net 244",
316 "anqp_3gpp_cell_net 24,123",
317 "anqp_3gpp_cell_net 244,1",
318 "anqp_3gpp_cell_net 244,1234",
319 "nai_realm 0",
320 "nai_realm 0,1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.nas1.w1.fi",
321 "nai_realm 0,example.org,1,2,3,4,5,6,7,8",
322 "nai_realm 0,example.org,1[1:1][2:2][3:3][4:4][5:5]",
323 "nai_realm 0,example.org,1[1]",
324 "nai_realm 0,example.org,1[1:1",
325 "nai_realm 0,a.example.org;b.example.org;c.example.org;d.example.org;e.example.org;f.example.org;g.example.org;h.example.org;i.example.org;j.example.org;k.example.org",
326 "qos_map_set 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60",
327 "qos_map_set 53,2,22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,255,300",
328 "qos_map_set 53,2,22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,255,-1",
329 "qos_map_set 53,2,22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,255,255,1",
330 "qos_map_set 1",
331 "qos_map_set 1,2",
332 "hs20_conn_capab 1",
333 "hs20_conn_capab 6:22",
334 "hs20_wan_metrics 0q:8000:1000:80:240:3000",
335 "hs20_wan_metrics 01",
336 "hs20_wan_metrics 01:8000",
337 "hs20_wan_metrics 01:8000:1000",
338 "hs20_wan_metrics 01:8000:1000:80",
339 "hs20_wan_metrics 01:8000:1000:80:240",
340 "hs20_oper_friendly_name eng1:Example",
341 "hs20_icon 32",
342 "hs20_icon 32:32",
343 "hs20_icon 32:32:eng",
344 "hs20_icon 32:32:eng:image/png",
345 "hs20_icon 32:32:eng:image/png:icon32",
346 "hs20_icon 32:32:eng:image/png:123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890:/tmp/icon32.png",
347 "hs20_icon 32:32:eng:image/png:name:/tmp/123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.png",
348 "osu_ssid ",
349 "osu_ssid P",
350 'osu_ssid P"abc',
351 'osu_ssid "1234567890123456789012345678901234567890"',
352 "osu_friendly_name eng:Example",
353 "osu_nai anonymous@example.com",
354 "osu_method_list 1 0",
355 "osu_icon foo",
356 "osu_service_desc eng:Example services",
357 "ssid 1234567890123456789012345678901234567890",
358 "pac_opaque_encr_key 123456",
359 "eap_fast_a_id 12345",
360 "eap_fast_a_id 12345q",
361 "own_ip_addr foo",
362 "auth_server_addr foo2",
363 "auth_server_shared_secret ",
364 "acct_server_addr foo3",
365 "acct_server_shared_secret ",
366 "radius_auth_req_attr 123::",
367 "radius_acct_req_attr 123::",
368 "radius_das_client 192.168.1.123",
369 "radius_das_client 192.168.1.1a foo",
370 "auth_algs 0",
371 "max_num_sta -1",
372 "max_num_sta 1000000",
373 "wpa_passphrase 1234567",
374 "wpa_passphrase 1234567890123456789012345678901234567890123456789012345678901234",
375 "wpa_psk 1234567890123456789012345678901234567890123456789012345678901234a",
376 "wpa_psk 12345678901234567890123456789012345678901234567890123456789012",
377 "wpa_psk_radius 123",
378 "wpa_pairwise NONE",
379 "wpa_pairwise WEP40",
380 "wpa_pairwise WEP104",
381 "rsn_pairwise NONE",
382 "rsn_pairwise WEP40",
383 "rsn_pairwise WEP104",
384 "mobility_domain 01",
385 "r1_key_holder 0011223344",
386 "ctrl_interface_group nosuchgrouphere",
387 "hw_mode foo",
388 "wps_rf_bands foo",
389 "beacon_int 0",
390 "beacon_int 65536",
391 "acs_num_scans 0",
392 "acs_num_scans 101",
393 "rts_threshold -2",
394 "rts_threshold 65536",
395 "fragm_threshold -2",
396 "fragm_threshold 2347",
397 "send_probe_response -1",
398 "send_probe_response 2",
399 "vlan_naming -1",
400 "vlan_naming 10000000",
401 "group_mgmt_cipher FOO",
402 "assoc_sa_query_max_timeout 0",
403 "assoc_sa_query_retry_timeout 0",
404 "wps_state -1",
405 "wps_state 3",
406 "uuid FOO",
407 "device_name 1234567890123456789012345678901234567890",
408 "manufacturer 1234567890123456789012345678901234567890123456789012345678901234567890",
409 "model_name 1234567890123456789012345678901234567890",
410 "model_number 1234567890123456789012345678901234567890",
411 "serial_number 1234567890123456789012345678901234567890",
412 "device_type FOO",
413 "os_version 1",
414 "ap_settings /tmp/does/not/exist/ap-settings.foo",
415 "wps_nfc_dev_pw_id 4",
416 "wps_nfc_dev_pw_id 100000",
417 "time_zone A",
418 "access_network_type -1",
419 "access_network_type 16",
420 "hessid 00:11:22:33:44",
421 "network_auth_type 0q",
422 "ipaddr_type_availability 1q",
423 "hs20_operating_class 0",
424 "hs20_operating_class 0q",
425 "bss_load_test ",
426 "bss_load_test 12",
427 "bss_load_test 12:80",
428 "vendor_elements 0",
429 "vendor_elements 0q",
430 "assocresp_elements 0",
431 "assocresp_elements 0q",
432 "local_pwr_constraint -1",
433 "local_pwr_constraint 256",
434 "wmm_ac_bk_cwmin -1",
435 "wmm_ac_be_cwmin 16",
436 "wmm_ac_vi_cwmax -1",
437 "wmm_ac_vo_cwmax 16",
438 "wmm_ac_foo_cwmax 6",
439 "wmm_ac_bk_aifs 0",
440 "wmm_ac_bk_aifs 256",
441 "wmm_ac_bk_txop_limit -1",
442 "wmm_ac_bk_txop_limit 65536",
443 "wmm_ac_bk_acm -1",
444 "wmm_ac_bk_acm 2",
445 "wmm_ac_bk_foo 2",
446 "tx_queue_foo_aifs 3",
447 "tx_queue_data3_cwmin 4",
448 "tx_queue_data3_cwmax 4",
449 "tx_queue_data3_aifs -4",
450 "tx_queue_data3_foo 1" ]
451 for e in errors:
452 if "FAIL" not in hapd.request("SET " + e):
453 raise Exception("Unexpected SET success: '%s'" % e)
454
455 if "OK" not in hapd.request("SET osu_server_uri https://example.com/"):
456 raise Exception("Unexpected SET osu_server_uri failure")
457 if "OK" not in hapd.request("SET osu_friendly_name eng:Example"):
458 raise Exception("Unexpected SET osu_friendly_name failure")
459
460 errors = [ "osu_friendly_name eng1:Example",
461 "osu_service_desc eng1:Example services" ]
462 for e in errors:
463 if "FAIL" not in hapd.request("SET " + e):
464 raise Exception("Unexpected SET success: '%s'" % e)
465
466 no_err = [ "wps_nfc_dh_pubkey 0",
467 "wps_nfc_dh_privkey 0q",
468 "wps_nfc_dev_pw 012",
469 "manage_p2p 0",
470 "disassoc_low_ack 0",
471 "network_auth_type 01",
472 "tdls_prohibit 0",
473 "tdls_prohibit_chan_switch 0" ]
474 for e in no_err:
475 if "OK" not in hapd.request("SET " + e):
476 raise Exception("Unexpected SET failure: '%s'" % e)
477
478 @remote_compatible
479 def test_hapd_ctrl_global(dev, apdev):
480 """hostapd and GET ctrl_iface command"""
481 ssid = "hapd-ctrl"
482 params = { "ssid": ssid }
483 ifname = apdev[0]['ifname']
484 hapd = hostapd.add_ap(apdev[0], params)
485 hapd_global = hostapd.HostapdGlobal(apdev[0])
486 res = hapd_global.request("IFNAME=" + ifname + " PING")
487 if "PONG" not in res:
488 raise Exception("Could not ping hostapd interface " + ifname + " via global control interface")
489 res = hapd_global.request("IFNAME=" + ifname + " GET version")
490 if "FAIL" in res:
491 raise Exception("Could not get hostapd version for " + ifname + " via global control interface")
492 res = hapd_global.request("IFNAME=no-such-ifname GET version")
493 if "FAIL-NO-IFNAME-MATCH" not in res:
494 raise Exception("Invalid ifname not reported")
495 res = hapd_global.request("INTERFACES")
496 if "FAIL" in res:
497 raise Exception("INTERFACES command failed")
498 if apdev[0]['ifname'] not in res.splitlines():
499 raise Exception("AP interface missing from INTERFACES")
500 res = hapd_global.request("INTERFACES ctrl")
501 if "FAIL" in res:
502 raise Exception("INTERFACES ctrl command failed")
503 if apdev[0]['ifname'] + " ctrl_iface=" not in res:
504 raise Exception("AP interface missing from INTERFACES ctrl")
505
506 if "FAIL" not in hapd_global.request("DETACH"):
507 raise Exception("DETACH succeeded unexpectedly")
508
509 def dup_network(hapd_global, src, dst, param):
510 res = hapd_global.request("DUP_NETWORK %s %s %s" % (src, dst, param))
511 if "OK" not in res:
512 raise Exception("Could not dup %s param from %s to %s" % (param, src,
513 dst))
514
515 def test_hapd_dup_network_global_wpa2(dev, apdev):
516 """hostapd and DUP_NETWORK command (WPA2)"""
517 passphrase="12345678"
518 src_ssid = "hapd-ctrl-src"
519 dst_ssid = "hapd-ctrl-dst"
520
521 src_params = hostapd.wpa2_params(ssid=src_ssid, passphrase=passphrase)
522 src_ifname = apdev[0]['ifname']
523 src_hapd = hostapd.add_ap(apdev[0], src_params)
524
525 dst_params = { "ssid": dst_ssid }
526 dst_ifname = apdev[1]['ifname']
527 dst_hapd = hostapd.add_ap(apdev[1], dst_params, no_enable=True)
528
529 hapd_global = hostapd.HostapdGlobal()
530
531 for param in [ "wpa", "wpa_passphrase", "wpa_key_mgmt", "rsn_pairwise" ]:
532 dup_network(hapd_global, src_ifname, dst_ifname, param)
533
534 dst_hapd.enable()
535
536 dev[0].connect(dst_ssid, psk=passphrase, proto="RSN", pairwise="CCMP",
537 scan_freq="2412")
538 addr = dev[0].own_addr()
539 if "FAIL" in dst_hapd.request("STA " + addr):
540 raise Exception("Could not connect using duplicated wpa params")
541
542 tests = [ "a",
543 "no-such-ifname no-such-ifname",
544 src_ifname + " no-such-ifname",
545 src_ifname + " no-such-ifname no-such-param",
546 src_ifname + " " + dst_ifname + " no-such-param" ]
547 for t in tests:
548 if "FAIL" not in hapd_global.request("DUP_NETWORK " + t):
549 raise Exception("Invalid DUP_NETWORK accepted: " + t)
550 with alloc_fail(src_hapd, 1, "hostapd_ctrl_iface_dup_param"):
551 if "FAIL" not in hapd_global.request("DUP_NETWORK %s %s wpa" % (src_ifname, dst_ifname)):
552 raise Exception("DUP_NETWORK accepted during OOM")
553
554 def test_hapd_dup_network_global_wpa(dev, apdev):
555 """hostapd and DUP_NETWORK command (WPA)"""
556 skip_with_fips(dev[0])
557 psk = '602e323e077bc63bd80307ef4745b754b0ae0a925c2638ecd13a794b9527b9e6'
558 src_ssid = "hapd-ctrl-src"
559 dst_ssid = "hapd-ctrl-dst"
560
561 src_params = hostapd.wpa_params(ssid=src_ssid)
562 src_params['wpa_psk'] = psk
563 src_ifname = apdev[0]['ifname']
564 src_hapd = hostapd.add_ap(apdev[0], src_params)
565
566 dst_params = { "ssid": dst_ssid }
567 dst_ifname = apdev[1]['ifname']
568 dst_hapd = hostapd.add_ap(apdev[1], dst_params, no_enable=True)
569
570 hapd_global = hostapd.HostapdGlobal()
571
572 for param in [ "wpa", "wpa_psk", "wpa_key_mgmt", "wpa_pairwise" ]:
573 dup_network(hapd_global, src_ifname, dst_ifname, param)
574
575 dst_hapd.enable()
576
577 dev[0].connect(dst_ssid, raw_psk=psk, proto="WPA", pairwise="TKIP",
578 scan_freq="2412")
579 addr = dev[0].own_addr()
580 if "FAIL" in dst_hapd.request("STA " + addr):
581 raise Exception("Could not connect using duplicated wpa params")
582
583 @remote_compatible
584 def test_hapd_ctrl_log_level(dev, apdev):
585 """hostapd ctrl_iface LOG_LEVEL"""
586 hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
587 level = hapd.request("LOG_LEVEL")
588 if "Current level: MSGDUMP" not in level:
589 raise Exception("Unexpected debug level(1): " + level)
590 if "Timestamp: 1" not in level:
591 raise Exception("Unexpected timestamp(1): " + level)
592
593 if "OK" not in hapd.request("LOG_LEVEL MSGDUMP 0"):
594 raise Exception("LOG_LEVEL failed")
595 level = hapd.request("LOG_LEVEL")
596 if "Current level: MSGDUMP" not in level:
597 raise Exception("Unexpected debug level(2): " + level)
598 if "Timestamp: 0" not in level:
599 raise Exception("Unexpected timestamp(2): " + level)
600
601 if "OK" not in hapd.request("LOG_LEVEL MSGDUMP 1"):
602 raise Exception("LOG_LEVEL failed")
603 level = hapd.request("LOG_LEVEL")
604 if "Current level: MSGDUMP" not in level:
605 raise Exception("Unexpected debug level(3): " + level)
606 if "Timestamp: 1" not in level:
607 raise Exception("Unexpected timestamp(3): " + level)
608
609 if "FAIL" not in hapd.request("LOG_LEVEL FOO"):
610 raise Exception("Invalid LOG_LEVEL accepted")
611
612 for lev in [ "EXCESSIVE", "MSGDUMP", "DEBUG", "INFO", "WARNING", "ERROR" ]:
613 if "OK" not in hapd.request("LOG_LEVEL " + lev):
614 raise Exception("LOG_LEVEL failed for " + lev)
615 level = hapd.request("LOG_LEVEL")
616 if "Current level: " + lev not in level:
617 raise Exception("Unexpected debug level: " + level)
618
619 if "OK" not in hapd.request("LOG_LEVEL MSGDUMP 1"):
620 raise Exception("LOG_LEVEL failed")
621 level = hapd.request("LOG_LEVEL")
622 if "Current level: MSGDUMP" not in level:
623 raise Exception("Unexpected debug level(3): " + level)
624 if "Timestamp: 1" not in level:
625 raise Exception("Unexpected timestamp(3): " + level)
626
627 @remote_compatible
628 def test_hapd_ctrl_disconnect_no_tx(dev, apdev):
629 """hostapd disconnecting STA without transmitting Deauth/Disassoc"""
630 ssid = "hapd-test"
631 passphrase = "12345678"
632 params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
633 hapd = hostapd.add_ap(apdev[0], params)
634 bssid = apdev[0]['bssid']
635 dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
636 addr0 = dev[0].own_addr()
637 dev[1].connect(ssid, psk=passphrase, scan_freq="2412")
638 addr1 = dev[1].own_addr()
639
640 # Disconnect the STA without sending out Deauthentication frame
641 if "OK" not in hapd.request("DEAUTHENTICATE " + addr0 + " tx=0"):
642 raise Exception("DEAUTHENTICATE command failed")
643 # Force disconnection due to AP receiving a frame from not-asssociated STA
644 dev[0].request("DATA_TEST_CONFIG 1")
645 dev[0].request("DATA_TEST_TX " + bssid + " " + addr0)
646 ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
647 dev[0].request("DATA_TEST_CONFIG 0")
648 if ev is None:
649 raise Exception("Disconnection event not seen after TX attempt")
650 if "reason=7" not in ev:
651 raise Exception("Unexpected disconnection reason: " + ev)
652
653 # Disconnect the STA without sending out Disassociation frame
654 if "OK" not in hapd.request("DISASSOCIATE " + addr1 + " tx=0"):
655 raise Exception("DISASSOCIATE command failed")
656 # Force disconnection due to AP receiving a frame from not-asssociated STA
657 dev[1].request("DATA_TEST_CONFIG 1")
658 dev[1].request("DATA_TEST_TX " + bssid + " " + addr1)
659 ev = dev[1].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
660 dev[1].request("DATA_TEST_CONFIG 0")
661 if ev is None:
662 raise Exception("Disconnection event not seen after TX attempt")
663 if "reason=7" not in ev:
664 raise Exception("Unexpected disconnection reason: " + ev)
665
666 def test_hapd_ctrl_mib(dev, apdev):
667 """hostapd and MIB ctrl_iface command with open network"""
668 ssid = "hapd-ctrl"
669 params = { "ssid": ssid }
670 hapd = hostapd.add_ap(apdev[0], params)
671
672 mib = hapd.request("MIB")
673 if len(mib) != 0:
674 raise Exception("Unexpected MIB response: " + mib)
675
676 mib = hapd.request("MIB radius_server")
677 if len(mib) != 0:
678 raise Exception("Unexpected 'MIB radius_server' response: " + mib)
679
680 if "FAIL" not in hapd.request("MIB foo"):
681 raise Exception("'MIB foo' succeeded")
682
683 dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
684
685 mib = hapd.request("MIB")
686 if "FAIL" in mib:
687 raise Exception("Unexpected MIB response: " + mib)
688
689 mib = hapd.request("MIB radius_server")
690 if len(mib) != 0:
691 raise Exception("Unexpected 'MIB radius_server' response: " + mib)
692
693 if "FAIL" not in hapd.request("MIB foo"):
694 raise Exception("'MIB foo' succeeded")
695
696 def test_hapd_ctrl_not_yet_fully_enabled(dev, apdev):
697 """hostapd and ctrl_iface commands when BSS not yet fully enabled"""
698 ssid = "hapd-ctrl"
699 params = { "ssid": ssid }
700 hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
701
702 if not hapd.ping():
703 raise Exception("PING failed")
704 if "FAIL" in hapd.request("MIB"):
705 raise Exception("MIB failed")
706 if len(hapd.request("MIB radius_server")) != 0:
707 raise Exception("Unexpected 'MIB radius_server' response")
708 if "state=UNINITIALIZED" not in hapd.request("STATUS"):
709 raise Exception("Unexpected STATUS response")
710 if "FAIL" not in hapd.request("STATUS-DRIVER"):
711 raise Exception("Unexpected response to STATUS-DRIVER")
712 if len(hapd.request("STA-FIRST")) != 0:
713 raise Exception("Unexpected response to STA-FIRST")
714 if "FAIL" not in hapd.request("STA ff:ff:ff:ff:ff:ff"):
715 raise Exception("Unexpected response to STA")
716 cmds = [ "NEW_STA 02:ff:ff:ff:ff:ff",
717 "DEAUTHENTICATE 02:ff:ff:ff:ff:ff",
718 "DEAUTHENTICATE 02:ff:ff:ff:ff:ff test=0",
719 "DEAUTHENTICATE 02:ff:ff:ff:ff:ff p2p=0",
720 "DEAUTHENTICATE 02:ff:ff:ff:ff:ff tx=0",
721 "DISASSOCIATE 02:ff:ff:ff:ff:ff",
722 "DISASSOCIATE 02:ff:ff:ff:ff:ff test=0",
723 "DISASSOCIATE 02:ff:ff:ff:ff:ff p2p=0",
724 "DISASSOCIATE 02:ff:ff:ff:ff:ff tx=0",
725 "SA_QUERY 02:ff:ff:ff:ff:ff",
726 "WPS_PIN any 12345670",
727 "WPS_PBC",
728 "WPS_CANCEL",
729 "WPS_AP_PIN random",
730 "WPS_AP_PIN disable",
731 "WPS_CHECK_PIN 123456789",
732 "WPS_GET_STATUS",
733 "WPS_NFC_TAG_READ 00",
734 "WPS_NFC_CONFIG_TOKEN NDEF",
735 "WPS_NFC_TOKEN WPS",
736 "NFC_GET_HANDOVER_SEL NDEF WPS-CR",
737 "NFC_REPORT_HANDOVER RESP WPS 00 00",
738 "SET_QOS_MAP_SET 22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55",
739 "SEND_QOS_MAP_CONF 02:ff:ff:ff:ff:ff",
740 "HS20_WNM_NOTIF 02:ff:ff:ff:ff:ff https://example.com/",
741 "HS20_DEAUTH_REQ 02:ff:ff:ff:ff:ff 1 120 https://example.com/",
742 "DISASSOC_IMMINENT 02:ff:ff:ff:ff:ff 10",
743 "ESS_DISASSOC 02:ff:ff:ff:ff:ff 10 https://example.com/",
744 "BSS_TM_REQ 02:ff:ff:ff:ff:ff",
745 "GET_CONFIG",
746 "RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1",
747 "CHAN_SWITCH 5 5200 ht sec_channel_offset=-1 bandwidth=40",
748 "TRACK_STA_LIST",
749 "PMKSA",
750 "PMKSA_FLUSH",
751 "SET_NEIGHBOR 00:11:22:33:44:55 ssid=\"test1\"",
752 "REMOVE_NEIGHBOR 00:11:22:33:44:55 ssid=\"test1\"",
753 "REQ_LCI 00:11:22:33:44:55",
754 "REQ_RANGE 00:11:22:33:44:55",
755 "DRIVER_FLAGS",
756 "STOP_AP" ]
757 for cmd in cmds:
758 hapd.request(cmd)
759
760 def test_hapd_ctrl_set(dev, apdev):
761 """hostapd and SET ctrl_iface command"""
762 ssid = "hapd-ctrl"
763 params = { "ssid": ssid }
764 hapd = hostapd.add_ap(apdev[0], params)
765 tests = [ "foo",
766 "wps_version_number 300",
767 "gas_frag_limit 0",
768 "mbo_assoc_disallow 0" ]
769 for t in tests:
770 if "FAIL" not in hapd.request("SET " + t):
771 raise Exception("Invalid SET command accepted: " + t)
772
773 def test_hapd_ctrl_radar(dev, apdev):
774 """hostapd and RADAR ctrl_iface command"""
775 ssid = "hapd-ctrl"
776 params = { "ssid": ssid }
777 hapd = hostapd.add_ap(apdev[0], params)
778
779 tests = [ "foo", "foo bar" ]
780 for t in tests:
781 if "FAIL" not in hapd.request("RADAR " + t):
782 raise Exception("Invalid RADAR command accepted: " + t)
783
784 tests = [ "DETECTED freq=2412 chan_offset=12 cf1=1234 cf2=2345",
785 "CAC-FINISHED freq=2412",
786 "CAC-ABORTED freq=2412",
787 "NOP-FINISHED freq=2412" ]
788 for t in tests:
789 hapd.request("RADAR " + t)
790
791 def test_hapd_ctrl_ext_io_errors(dev, apdev):
792 """hostapd and external I/O errors"""
793 ssid = "hapd-ctrl"
794 params = { "ssid": ssid }
795 hapd = hostapd.add_ap(apdev[0], params)
796 tests = [ "MGMT_TX 1",
797 "MGMT_TX 1q",
798 "MGMT_RX_PROCESS freq=2412",
799 "EAPOL_RX foo",
800 "EAPOL_RX 00:11:22:33:44:55 1",
801 "EAPOL_RX 00:11:22:33:44:55 1q" ]
802 for t in tests:
803 if "FAIL" not in hapd.request(t):
804 raise Exception("Invalid command accepted: " + t)
805 with alloc_fail(hapd, 1, "=hostapd_ctrl_iface_mgmt_tx"):
806 if "FAIL" not in hapd.request("MGMT_TX 12"):
807 raise Exception("MGMT_TX accepted during OOM")
808 with alloc_fail(hapd, 1, "=hostapd_ctrl_iface_eapol_rx"):
809 if "FAIL" not in hapd.request("EAPOL_RX 00:11:22:33:44:55 11"):
810 raise Exception("EAPOL_RX accepted during OOM")
811
812 hapd.set("ext_mgmt_frame_handling", "1")
813 tests = [ "MGMT_RX_PROCESS freq=2412",
814 "MGMT_RX_PROCESS freq=2412 ssi_signal=0",
815 "MGMT_RX_PROCESS freq=2412 frame=1",
816 "MGMT_RX_PROCESS freq=2412 frame=1q" ]
817 for t in tests:
818 if "FAIL" not in hapd.request(t):
819 raise Exception("Invalid command accepted: " + t)
820 with alloc_fail(hapd, 1, "=hostapd_ctrl_iface_mgmt_rx_process"):
821 if "FAIL" not in hapd.request("MGMT_RX_PROCESS freq=2412 frame=11"):
822 raise Exception("MGMT_RX_PROCESS accepted during OOM")
823 hapd.set("ext_mgmt_frame_handling", "0")
824
825 if "OK" not in hapd.request("DATA_TEST_CONFIG 1"):
826 raise Exception("Failed to enable l2_test")
827 if "OK" not in hapd.request("DATA_TEST_CONFIG 1"):
828 raise Exception("Failed to enable l2_test(2)")
829 tests = [ "DATA_TEST_TX foo",
830 "DATA_TEST_TX 00:11:22:33:44:55 foo",
831 "DATA_TEST_TX 00:11:22:33:44:55 00:11:22:33:44:55 -1",
832 "DATA_TEST_TX 00:11:22:33:44:55 00:11:22:33:44:55 256" ]
833 for t in tests:
834 if "FAIL" not in hapd.request(t):
835 raise Exception("Invalid command accepted: " + t)
836 if "OK" not in hapd.request("DATA_TEST_CONFIG 0"):
837 raise Exception("Failed to disable l2_test")
838 tests = [ "DATA_TEST_TX 00:11:22:33:44:55 00:11:22:33:44:55 0",
839 "DATA_TEST_FRAME ifname=foo",
840 "DATA_TEST_FRAME 1",
841 "DATA_TEST_FRAME 11",
842 "DATA_TEST_FRAME 112233445566778899aabbccddeefq" ]
843 for t in tests:
844 if "FAIL" not in hapd.request(t):
845 raise Exception("Invalid command accepted: " + t)
846 with alloc_fail(hapd, 1, "=hostapd_ctrl_iface_data_test_frame"):
847 if "FAIL" not in hapd.request("DATA_TEST_FRAME 112233445566778899aabbccddeeff"):
848 raise Exception("DATA_TEST_FRAME accepted during OOM")
849
850 def test_hapd_ctrl_vendor_errors(dev, apdev):
851 """hostapd and VENDOR errors"""
852 ssid = "hapd-ctrl"
853 params = { "ssid": ssid }
854 hapd = hostapd.add_ap(apdev[0], params)
855 tests = [ "q",
856 "10q",
857 "10 10q",
858 "10 10 123q",
859 "10 10" ]
860 for t in tests:
861 if "FAIL" not in hapd.request("VENDOR " + t):
862 raise Exception("Invalid VENDOR command accepted: " + t)
863 with alloc_fail(hapd, 1, "=hostapd_ctrl_iface_vendor"):
864 if "FAIL" not in hapd.request("VENDOR 10 10 10"):
865 raise Exception("VENDOR accepted during OOM")
866 with alloc_fail(hapd, 1, "wpabuf_alloc;hostapd_ctrl_iface_vendor"):
867 if "FAIL" not in hapd.request("VENDOR 10 10"):
868 raise Exception("VENDOR accepted during OOM")
869
870 def test_hapd_ctrl_eapol_reauth_errors(dev, apdev):
871 """hostapd and EAPOL_REAUTH errors"""
872 ssid = "hapd-ctrl"
873 params = { "ssid": ssid }
874 hapd = hostapd.add_ap(apdev[0], params)
875 tests = [ "foo",
876 "11:22:33:44:55:66" ]
877 for t in tests:
878 if "FAIL" not in hapd.request("EAPOL_REAUTH " + t):
879 raise Exception("Invalid EAPOL_REAUTH command accepted: " + t)
880
881 def test_hapd_ctrl_eapol_relog(dev, apdev):
882 """hostapd and RELOG"""
883 ssid = "hapd-ctrl"
884 params = { "ssid": ssid }
885 hapd = hostapd.add_ap(apdev[0], params)
886 if "OK" not in hapd.request("RELOG"):
887 raise Exception("RELOG failed")
888
889 def test_hapd_ctrl_poll_sta_errors(dev, apdev):
890 """hostapd and POLL_STA errors"""
891 ssid = "hapd-ctrl"
892 params = { "ssid": ssid }
893 hapd = hostapd.add_ap(apdev[0], params)
894 tests = [ "foo",
895 "11:22:33:44:55:66" ]
896 for t in tests:
897 if "FAIL" not in hapd.request("POLL_STA " + t):
898 raise Exception("Invalid POLL_STA command accepted: " + t)
899
900 def test_hapd_ctrl_update_beacon(dev, apdev):
901 """hostapd and UPDATE_BEACON"""
902 ssid = "hapd-ctrl"
903 params = { "ssid": ssid }
904 hapd = hostapd.add_ap(apdev[0], params)
905 if "OK" not in hapd.request("UPDATE_BEACON"):
906 raise Exception("UPDATE_BEACON failed")
907 with fail_test(hapd, 1, "ieee802_11_set_beacon"):
908 if "FAIL" not in hapd.request("UPDATE_BEACON"):
909 raise Exception("UPDATE_BEACON succeeded unexpectedly")
910 dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
911
912 def test_hapd_ctrl_test_fail(dev, apdev):
913 """hostapd and TEST_ALLOC_FAIL/TEST_FAIL"""
914 ssid = "hapd-ctrl"
915 params = { "ssid": ssid }
916 hapd = hostapd.add_ap(apdev[0], params)
917 if "OK" not in hapd.request("TEST_ALLOC_FAIL 1:unknownfunc"):
918 raise HwsimSkip("TEST_ALLOC_FAIL not supported")
919 if "OK" not in hapd.request("TEST_ALLOC_FAIL "):
920 raise Exception("TEST_ALLOC_FAIL clearing failed")
921 if "OK" not in hapd.request("TEST_FAIL "):
922 raise Exception("TEST_FAIL clearing failed")