1 # hostapd control interface
2 # Copyright (c) 2014, Qualcomm Atheros, Inc.
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
9 from utils import skip_with_fips
11 def test_hapd_ctrl_status(dev, apdev):
12 """hostapd ctrl_iface STATUS commands"""
14 bssid = apdev[0]['bssid']
15 params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
16 hapd = hostapd.add_ap(apdev[0], params)
17 status = hapd.get_status()
18 driver = hapd.get_driver_status()
20 if status['bss[0]'] != apdev[0]['ifname']:
21 raise Exception("Unexpected bss[0]")
22 if status['ssid[0]'] != ssid:
23 raise Exception("Unexpected ssid[0]")
24 if status['bssid[0]'] != bssid:
25 raise Exception("Unexpected bssid[0]")
26 if status['freq'] != "2412":
27 raise Exception("Unexpected freq")
29 if driver['beacon_set'] != "1":
30 raise Exception("Unexpected beacon_set")
31 if driver['addr'] != bssid:
32 raise Exception("Unexpected addr")
34 def test_hapd_ctrl_p2p_manager(dev, apdev):
35 """hostapd as P2P Device manager"""
37 passphrase = "12345678"
38 params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
39 params['manage_p2p'] = '1'
40 params['allow_cross_connection'] = '0'
41 hapd = hostapd.add_ap(apdev[0], params)
42 dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
43 addr = dev[0].own_addr()
44 if "OK" not in hapd.request("DEAUTHENTICATE " + addr + " p2p=2"):
45 raise Exception("DEAUTHENTICATE command failed")
46 dev[0].wait_disconnected(timeout=5)
47 dev[0].wait_connected(timeout=10, error="Re-connection timed out")
49 if "OK" not in hapd.request("DISASSOCIATE " + addr + " p2p=2"):
50 raise Exception("DISASSOCIATE command failed")
51 dev[0].wait_disconnected(timeout=5)
52 dev[0].wait_connected(timeout=10, error="Re-connection timed out")
54 def test_hapd_ctrl_sta(dev, apdev):
55 """hostapd and STA ctrl_iface commands"""
56 ssid = "hapd-ctrl-sta"
57 passphrase = "12345678"
58 params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
59 hapd = hostapd.add_ap(apdev[0], params)
60 dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
61 addr = dev[0].own_addr()
62 if "FAIL" in hapd.request("STA " + addr):
63 raise Exception("Unexpected STA failure")
64 if "FAIL" not in hapd.request("STA " + addr + " eapol"):
65 raise Exception("Unexpected STA-eapol success")
66 if "FAIL" not in hapd.request("STA 00:11:22:33:44"):
67 raise Exception("Unexpected STA success")
68 if "FAIL" not in hapd.request("STA 00:11:22:33:44:55"):
69 raise Exception("Unexpected STA success")
71 if len(hapd.request("STA-NEXT " + addr).splitlines()) > 0:
72 raise Exception("Unexpected STA-NEXT result")
73 if "FAIL" not in hapd.request("STA-NEXT 00:11:22:33:44"):
74 raise Exception("Unexpected STA-NEXT success")
76 def test_hapd_ctrl_disconnect(dev, apdev):
77 """hostapd and disconnection ctrl_iface commands"""
79 passphrase = "12345678"
80 params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
81 hapd = hostapd.add_ap(apdev[0], params)
82 dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
83 addr = dev[0].p2p_dev_addr()
85 if "FAIL" not in hapd.request("DEAUTHENTICATE 00:11:22:33:44"):
86 raise Exception("Unexpected DEAUTHENTICATE success")
88 if "OK" not in hapd.request("DEAUTHENTICATE ff:ff:ff:ff:ff:ff"):
89 raise Exception("Unexpected DEAUTHENTICATE failure")
90 dev[0].wait_disconnected(timeout=5)
91 dev[0].wait_connected(timeout=10, error="Re-connection timed out")
93 if "FAIL" not in hapd.request("DISASSOCIATE 00:11:22:33:44"):
94 raise Exception("Unexpected DISASSOCIATE success")
96 if "OK" not in hapd.request("DISASSOCIATE ff:ff:ff:ff:ff:ff"):
97 raise Exception("Unexpected DISASSOCIATE failure")
98 dev[0].wait_disconnected(timeout=5)
99 dev[0].wait_connected(timeout=10, error="Re-connection timed out")
101 def test_hapd_ctrl_chan_switch(dev, apdev):
102 """hostapd and CHAN_SWITCH ctrl_iface command"""
104 params = { "ssid": ssid }
105 hapd = hostapd.add_ap(apdev[0], params)
106 if "FAIL" not in hapd.request("CHAN_SWITCH "):
107 raise Exception("Unexpected CHAN_SWITCH success")
108 if "FAIL" not in hapd.request("CHAN_SWITCH qwerty 2422"):
109 raise Exception("Unexpected CHAN_SWITCH success")
110 if "FAIL" not in hapd.request("CHAN_SWITCH 5 qwerty"):
111 raise Exception("Unexpected CHAN_SWITCH success")
112 if "FAIL" not in hapd.request("CHAN_SWITCH 0 2432 center_freq1=123 center_freq2=234 bandwidth=1000 sec_channel_offset=20 ht vht"):
113 raise Exception("Unexpected CHAN_SWITCH success")
115 def test_hapd_ctrl_level(dev, apdev):
116 """hostapd and LEVEL ctrl_iface command"""
118 params = { "ssid": ssid }
119 hapd = hostapd.add_ap(apdev[0], params)
120 if "FAIL" not in hapd.request("LEVEL 0"):
121 raise Exception("Unexpected LEVEL success on non-monitor interface")
123 def test_hapd_ctrl_new_sta(dev, apdev):
124 """hostapd and NEW_STA ctrl_iface command"""
126 params = { "ssid": ssid }
127 hapd = hostapd.add_ap(apdev[0], params)
128 if "FAIL" not in hapd.request("NEW_STA 00:11:22:33:44"):
129 raise Exception("Unexpected NEW_STA success")
130 if "OK" not in hapd.request("NEW_STA 00:11:22:33:44:55"):
131 raise Exception("Unexpected NEW_STA failure")
132 if "AUTHORIZED" not in hapd.request("STA 00:11:22:33:44:55"):
133 raise Exception("Unexpected NEW_STA STA status")
135 def test_hapd_ctrl_get(dev, apdev):
136 """hostapd and GET ctrl_iface command"""
138 params = { "ssid": ssid }
139 hapd = hostapd.add_ap(apdev[0], params)
140 if "FAIL" not in hapd.request("GET foo"):
141 raise Exception("Unexpected GET success")
142 if "FAIL" in hapd.request("GET version"):
143 raise Exception("Unexpected GET version failure")
145 def test_hapd_ctrl_unknown(dev, apdev):
146 """hostapd and unknown ctrl_iface command"""
148 params = { "ssid": ssid }
149 hapd = hostapd.add_ap(apdev[0], params)
150 if "UNKNOWN COMMAND" not in hapd.request("FOO"):
151 raise Exception("Unexpected response")
153 def test_hapd_ctrl_hs20_wnm_notif(dev, apdev):
154 """hostapd and HS20_WNM_NOTIF ctrl_iface command"""
156 params = { "ssid": ssid }
157 hapd = hostapd.add_ap(apdev[0], params)
158 if "FAIL" not in hapd.request("HS20_WNM_NOTIF 00:11:22:33:44 http://example.com/"):
159 raise Exception("Unexpected HS20_WNM_NOTIF success")
160 if "FAIL" not in hapd.request("HS20_WNM_NOTIF 00:11:22:33:44:55http://example.com/"):
161 raise Exception("Unexpected HS20_WNM_NOTIF success")
163 def test_hapd_ctrl_hs20_deauth_req(dev, apdev):
164 """hostapd and HS20_DEAUTH_REQ ctrl_iface command"""
166 params = { "ssid": ssid }
167 hapd = hostapd.add_ap(apdev[0], params)
168 if "FAIL" not in hapd.request("HS20_DEAUTH_REQ 00:11:22:33:44 1 120 http://example.com/"):
169 raise Exception("Unexpected HS20_DEAUTH_REQ success")
170 if "FAIL" not in hapd.request("HS20_DEAUTH_REQ 00:11:22:33:44:55"):
171 raise Exception("Unexpected HS20_DEAUTH_REQ success")
172 if "FAIL" not in hapd.request("HS20_DEAUTH_REQ 00:11:22:33:44:55 1"):
173 raise Exception("Unexpected HS20_DEAUTH_REQ success")
175 def test_hapd_ctrl_disassoc_imminent(dev, apdev):
176 """hostapd and DISASSOC_IMMINENT ctrl_iface command"""
178 params = { "ssid": ssid }
179 hapd = hostapd.add_ap(apdev[0], params)
180 if "FAIL" not in hapd.request("DISASSOC_IMMINENT 00:11:22:33:44"):
181 raise Exception("Unexpected DISASSOC_IMMINENT success")
182 if "FAIL" not in hapd.request("DISASSOC_IMMINENT 00:11:22:33:44:55"):
183 raise Exception("Unexpected DISASSOC_IMMINENT success")
184 if "FAIL" not in hapd.request("DISASSOC_IMMINENT 00:11:22:33:44:55 2"):
185 raise Exception("Unexpected DISASSOC_IMMINENT success")
186 dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
187 addr = dev[0].p2p_interface_addr()
188 if "OK" not in hapd.request("DISASSOC_IMMINENT " + addr + " 2"):
189 raise Exception("Unexpected DISASSOC_IMMINENT failure")
190 ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], 15)
192 raise Exception("Scan timed out")
194 def test_hapd_ctrl_ess_disassoc(dev, apdev):
195 """hostapd and ESS_DISASSOC ctrl_iface command"""
197 params = { "ssid": ssid }
198 hapd = hostapd.add_ap(apdev[0], params)
199 if "FAIL" not in hapd.request("ESS_DISASSOC 00:11:22:33:44"):
200 raise Exception("Unexpected ESS_DISASSOCT success")
201 if "FAIL" not in hapd.request("ESS_DISASSOC 00:11:22:33:44:55"):
202 raise Exception("Unexpected ESS_DISASSOC success")
203 dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
204 addr = dev[0].p2p_interface_addr()
205 if "FAIL" not in hapd.request("ESS_DISASSOC " + addr):
206 raise Exception("Unexpected ESS_DISASSOC success")
207 if "FAIL" not in hapd.request("ESS_DISASSOC " + addr + " -1"):
208 raise Exception("Unexpected ESS_DISASSOC success")
209 if "FAIL" not in hapd.request("ESS_DISASSOC " + addr + " 1"):
210 raise Exception("Unexpected ESS_DISASSOC success")
211 if "OK" not in hapd.request("ESS_DISASSOC " + addr + " 20 http://example.com/"):
212 raise Exception("Unexpected ESS_DISASSOC failure")
213 ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], 15)
215 raise Exception("Scan timed out")
217 def test_hapd_ctrl_set_deny_mac_file(dev, apdev):
218 """hostapd and SET deny_mac_file ctrl_iface command"""
220 params = { "ssid": ssid }
221 hapd = hostapd.add_ap(apdev[0], params)
222 dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
223 dev[1].connect(ssid, key_mgmt="NONE", scan_freq="2412")
224 if "OK" not in hapd.request("SET deny_mac_file hostapd.macaddr"):
225 raise Exception("Unexpected SET failure")
226 dev[0].wait_disconnected(timeout=15)
227 ev = dev[1].wait_event(["CTRL-EVENT-DISCONNECTED"], 1)
229 raise Exception("Unexpected disconnection")
231 def test_hapd_ctrl_set_accept_mac_file(dev, apdev):
232 """hostapd and SET accept_mac_file ctrl_iface command"""
234 params = { "ssid": ssid }
235 hapd = hostapd.add_ap(apdev[0], params)
236 dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
237 dev[1].connect(ssid, key_mgmt="NONE", scan_freq="2412")
238 hapd.request("SET macaddr_acl 1")
239 if "OK" not in hapd.request("SET accept_mac_file hostapd.macaddr"):
240 raise Exception("Unexpected SET failure")
241 dev[1].wait_disconnected(timeout=15)
242 ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], 1)
244 raise Exception("Unexpected disconnection")
246 def test_hapd_ctrl_set_error_cases(dev, apdev):
247 """hostapd and SET error cases"""
249 params = { "ssid": ssid }
250 hapd = hostapd.add_ap(apdev[0], params)
251 errors = [ "wpa_key_mgmt FOO",
252 "wpa_key_mgmt WPA-PSK \t FOO",
259 "wep_key0 12q3456789",
260 "wep_key_len_broadcast 20",
261 "wep_rekey_period -1",
263 "r0kh 02:00:00:00:03:0q nas1.w1.fi 100102030405060708090a0b0c0d0e0f",
264 "r0kh 02:00:00:00:03:00 12345678901234567890123456789012345678901234567890.nas1.w1.fi 100102030405060708090a0b0c0d0e0f",
265 "r0kh 02:00:00:00:03:00 nas1.w1.fi 100q02030405060708090a0b0c0d0e0f",
266 "r1kh 02:00:00:00:04:q0 00:01:02:03:04:06 200102030405060708090a0b0c0d0e0f",
267 "r1kh 02:00:00:00:04:00 00:01:02:03:04:q6 200102030405060708090a0b0c0d0e0f",
268 "r1kh 02:00:00:00:04:00 00:01:02:03:04:06 2q0102030405060708090a0b0c0d0e0f",
269 "roaming_consortium 1",
270 "roaming_consortium 12",
271 "roaming_consortium 112233445566778899aabbccddeeff00",
272 'venue_name P"engExample venue"',
273 'venue_name P"engExample venue',
274 "venue_name engExample venue",
275 "venue_name e:Example venue",
276 "venue_name eng1:Example venue",
277 "venue_name eng:Example venue 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
278 "anqp_3gpp_cell_net abc",
279 "anqp_3gpp_cell_net ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;",
280 "anqp_3gpp_cell_net 244",
281 "anqp_3gpp_cell_net 24,123",
282 "anqp_3gpp_cell_net 244,1",
283 "anqp_3gpp_cell_net 244,1234",
285 "nai_realm 0,1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.nas1.w1.fi",
286 "nai_realm 0,example.org,1,2,3,4,5,6,7,8",
287 "nai_realm 0,example.org,1[1:1][2:2][3:3][4:4][5:5]",
288 "nai_realm 0,example.org,1[1]",
289 "nai_realm 0,example.org,1[1:1",
290 "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",
291 "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",
292 "qos_map_set 53,2,22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,255,300",
293 "qos_map_set 53,2,22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,255,-1",
294 "qos_map_set 53,2,22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,255,255,1",
298 "hs20_conn_capab 6:22",
299 "hs20_wan_metrics 0q:8000:1000:80:240:3000",
300 "hs20_wan_metrics 01",
301 "hs20_wan_metrics 01:8000",
302 "hs20_wan_metrics 01:8000:1000",
303 "hs20_wan_metrics 01:8000:1000:80",
304 "hs20_wan_metrics 01:8000:1000:80:240",
305 "hs20_oper_friendly_name eng1:Example",
308 "hs20_icon 32:32:eng",
309 "hs20_icon 32:32:eng:image/png",
310 "hs20_icon 32:32:eng:image/png:icon32",
311 "hs20_icon 32:32:eng:image/png:123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890:/tmp/icon32.png",
312 "hs20_icon 32:32:eng:image/png:name:/tmp/123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.png",
316 'osu_ssid "1234567890123456789012345678901234567890"',
317 "osu_friendly_name eng:Example",
318 "osu_nai anonymous@example.com",
319 "osu_method_list 1 0",
321 "osu_service_desc eng:Example services",
322 "ssid 1234567890123456789012345678901234567890",
323 "pac_opaque_encr_key 123456",
324 "eap_fast_a_id 12345",
325 "eap_fast_a_id 12345q",
327 "auth_server_addr foo2",
328 "auth_server_shared_secret ",
329 "acct_server_addr foo3",
330 "acct_server_shared_secret ",
331 "radius_auth_req_attr 123::",
332 "radius_acct_req_attr 123::",
333 "radius_das_client 192.168.1.123",
334 "radius_das_client 192.168.1.1a foo",
337 "max_num_sta 1000000",
338 "wpa_passphrase 1234567",
339 "wpa_passphrase 1234567890123456789012345678901234567890123456789012345678901234",
340 "wpa_psk 1234567890123456789012345678901234567890123456789012345678901234a",
341 "wpa_psk 12345678901234567890123456789012345678901234567890123456789012",
342 "wpa_psk_radius 123",
344 "wpa_pairwise WEP40",
345 "wpa_pairwise WEP104",
347 "rsn_pairwise WEP40",
348 "rsn_pairwise WEP104",
349 "mobility_domain 01",
350 "r1_key_holder 0011223344",
351 "ctrl_interface_group nosuchgrouphere",
359 "rts_threshold 65536",
360 "fragm_threshold -2",
361 "fragm_threshold 2347",
362 "send_probe_response -1",
363 "send_probe_response 2",
365 "vlan_naming 10000000",
366 "group_mgmt_cipher FOO",
367 "assoc_sa_query_max_timeout 0",
368 "assoc_sa_query_retry_timeout 0",
372 "device_name 1234567890123456789012345678901234567890",
373 "manufacturer 1234567890123456789012345678901234567890123456789012345678901234567890",
374 "model_name 1234567890123456789012345678901234567890",
375 "model_number 1234567890123456789012345678901234567890",
376 "serial_number 1234567890123456789012345678901234567890",
379 "ap_settings /tmp/does/not/exist/ap-settings.foo",
380 "wps_nfc_dev_pw_id 4",
381 "wps_nfc_dev_pw_id 100000",
383 "access_network_type -1",
384 "access_network_type 16",
385 "hessid 00:11:22:33:44",
386 "network_auth_type 0q",
387 "ipaddr_type_availability 1q",
388 "hs20_operating_class 0",
389 "hs20_operating_class 0q",
392 "bss_load_test 12:80",
394 "vendor_elements 0q",
395 "local_pwr_constraint -1",
396 "local_pwr_constraint 256",
397 "wmm_ac_bk_cwmin -1",
398 "wmm_ac_be_cwmin 16",
399 "wmm_ac_vi_cwmax -1",
400 "wmm_ac_vo_cwmax 16",
401 "wmm_ac_foo_cwmax 6",
403 "wmm_ac_bk_aifs 256",
404 "wmm_ac_bk_txop_limit -1",
405 "wmm_ac_bk_txop_limit 65536",
409 "tx_queue_foo_aifs 3",
410 "tx_queue_data3_cwmin 4",
411 "tx_queue_data3_cwmax 4",
412 "tx_queue_data3_aifs -4",
413 "tx_queue_data3_foo 1" ]
415 if "FAIL" not in hapd.request("SET " + e):
416 raise Exception("Unexpected SET success: '%s'" % e)
418 if "OK" not in hapd.request("SET osu_server_uri https://example.com/"):
419 raise Exception("Unexpected SET osu_server_uri failure")
420 if "OK" not in hapd.request("SET osu_friendly_name eng:Example"):
421 raise Exception("Unexpected SET osu_friendly_name failure")
423 errors = [ "osu_friendly_name eng1:Example",
424 "osu_service_desc eng1:Example services" ]
426 if "FAIL" not in hapd.request("SET " + e):
427 raise Exception("Unexpected SET success: '%s'" % e)
429 no_err = [ "wps_nfc_dh_pubkey 0",
430 "wps_nfc_dh_privkey 0q",
431 "wps_nfc_dev_pw 012",
433 "disassoc_low_ack 0",
434 "network_auth_type 01",
436 "tdls_prohibit_chan_switch 0" ]
438 if "OK" not in hapd.request("SET " + e):
439 raise Exception("Unexpected SET failure: '%s'" % e)
441 def test_hapd_ctrl_global(dev, apdev):
442 """hostapd and GET ctrl_iface command"""
444 params = { "ssid": ssid }
445 ifname = apdev[0]['ifname']
446 hapd = hostapd.add_ap(apdev[0], params)
447 hapd_global = hostapd.HostapdGlobal()
448 res = hapd_global.request("IFNAME=" + ifname + " PING")
449 if "PONG" not in res:
450 raise Exception("Could not ping hostapd interface " + ifname + " via global control interface")
451 res = hapd_global.request("IFNAME=" + ifname + " GET version")
453 raise Exception("Could not get hostapd version for " + ifname + " via global control interface")
455 def dup_network(hapd_global, src, dst, param):
456 res = hapd_global.request("DUP_NETWORK %s %s %s" % (src, dst, param))
458 raise Exception("Could not dup %s param from %s to %s" % (param, src,
461 def test_hapd_dup_network_global_wpa2(dev, apdev):
462 """hostapd and DUP_NETWORK command (WPA2"""
463 passphrase="12345678"
464 src_ssid = "hapd-ctrl-src"
465 dst_ssid = "hapd-ctrl-dst"
467 src_params = hostapd.wpa2_params(ssid=src_ssid, passphrase=passphrase)
468 src_ifname = apdev[0]['ifname']
469 src_hapd = hostapd.add_ap(apdev[0], src_params)
471 dst_params = { "ssid": dst_ssid }
472 dst_ifname = apdev[1]['ifname']
473 dst_hapd = hostapd.add_ap(apdev[1], dst_params, no_enable=True)
475 hapd_global = hostapd.HostapdGlobal()
477 for param in [ "wpa", "wpa_passphrase", "wpa_key_mgmt", "rsn_pairwise" ]:
478 dup_network(hapd_global, src_ifname, dst_ifname, param)
482 dev[0].connect(dst_ssid, psk=passphrase, proto="RSN", pairwise="CCMP",
484 addr = dev[0].own_addr()
485 if "FAIL" in dst_hapd.request("STA " + addr):
486 raise Exception("Could not connect using duplicated wpa params")
488 def test_hapd_dup_network_global_wpa(dev, apdev):
489 """hostapd and DUP_NETWORK command (WPA)"""
490 skip_with_fips(dev[0])
491 psk = '602e323e077bc63bd80307ef4745b754b0ae0a925c2638ecd13a794b9527b9e6'
492 src_ssid = "hapd-ctrl-src"
493 dst_ssid = "hapd-ctrl-dst"
495 src_params = hostapd.wpa_params(ssid=src_ssid)
496 src_params['wpa_psk'] = psk
497 src_ifname = apdev[0]['ifname']
498 src_hapd = hostapd.add_ap(apdev[0], src_params)
500 dst_params = { "ssid": dst_ssid }
501 dst_ifname = apdev[1]['ifname']
502 dst_hapd = hostapd.add_ap(apdev[1], dst_params, no_enable=True)
504 hapd_global = hostapd.HostapdGlobal()
506 for param in [ "wpa", "wpa_psk", "wpa_key_mgmt", "wpa_pairwise" ]:
507 dup_network(hapd_global, src_ifname, dst_ifname, param)
511 dev[0].connect(dst_ssid, raw_psk=psk, proto="WPA", pairwise="TKIP",
513 addr = dev[0].own_addr()
514 if "FAIL" in dst_hapd.request("STA " + addr):
515 raise Exception("Could not connect using duplicated wpa params")
517 def test_hapd_ctrl_log_level(dev, apdev):
518 """hostapd ctrl_iface LOG_LEVEL"""
519 hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
520 level = hapd.request("LOG_LEVEL")
521 if "Current level: MSGDUMP" not in level:
522 raise Exception("Unexpected debug level(1): " + level)
523 if "Timestamp: 1" not in level:
524 raise Exception("Unexpected timestamp(1): " + level)
526 if "OK" not in hapd.request("LOG_LEVEL MSGDUMP 0"):
527 raise Exception("LOG_LEVEL failed")
528 level = hapd.request("LOG_LEVEL")
529 if "Current level: MSGDUMP" not in level:
530 raise Exception("Unexpected debug level(2): " + level)
531 if "Timestamp: 0" not in level:
532 raise Exception("Unexpected timestamp(2): " + level)
534 if "OK" not in hapd.request("LOG_LEVEL MSGDUMP 1"):
535 raise Exception("LOG_LEVEL failed")
536 level = hapd.request("LOG_LEVEL")
537 if "Current level: MSGDUMP" not in level:
538 raise Exception("Unexpected debug level(3): " + level)
539 if "Timestamp: 1" not in level:
540 raise Exception("Unexpected timestamp(3): " + level)
542 if "FAIL" not in hapd.request("LOG_LEVEL FOO"):
543 raise Exception("Invalid LOG_LEVEL accepted")
545 for lev in [ "EXCESSIVE", "MSGDUMP", "DEBUG", "INFO", "WARNING", "ERROR" ]:
546 if "OK" not in hapd.request("LOG_LEVEL " + lev):
547 raise Exception("LOG_LEVEL failed for " + lev)
548 level = hapd.request("LOG_LEVEL")
549 if "Current level: " + lev not in level:
550 raise Exception("Unexpected debug level: " + level)
552 if "OK" not in hapd.request("LOG_LEVEL MSGDUMP 1"):
553 raise Exception("LOG_LEVEL failed")
554 level = hapd.request("LOG_LEVEL")
555 if "Current level: MSGDUMP" not in level:
556 raise Exception("Unexpected debug level(3): " + level)
557 if "Timestamp: 1" not in level:
558 raise Exception("Unexpected timestamp(3): " + level)
560 def test_hapd_ctrl_disconnect_no_tx(dev, apdev):
561 """hostapd disconnecting STA without transmitting Deauth/Disassoc"""
563 passphrase = "12345678"
564 params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
565 hapd = hostapd.add_ap(apdev[0], params)
566 bssid = apdev[0]['bssid']
567 dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
568 addr0 = dev[0].own_addr()
569 dev[1].connect(ssid, psk=passphrase, scan_freq="2412")
570 addr1 = dev[1].own_addr()
572 # Disconnect the STA without sending out Deauthentication frame
573 if "OK" not in hapd.request("DEAUTHENTICATE " + addr0 + " tx=0"):
574 raise Exception("DEAUTHENTICATE command failed")
575 # Force disconnection due to AP receiving a frame from not-asssociated STA
576 dev[0].request("DATA_TEST_CONFIG 1")
577 dev[0].request("DATA_TEST_TX " + bssid + " " + addr0)
578 ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
579 dev[0].request("DATA_TEST_CONFIG 0")
581 raise Exception("Disconnection event not seen after TX attempt")
582 if "reason=7" not in ev:
583 raise Exception("Unexpected disconnection reason: " + ev)
585 # Disconnect the STA without sending out Disassociation frame
586 if "OK" not in hapd.request("DISASSOCIATE " + addr1 + " tx=0"):
587 raise Exception("DISASSOCIATE command failed")
588 # Force disconnection due to AP receiving a frame from not-asssociated STA
589 dev[1].request("DATA_TEST_CONFIG 1")
590 dev[1].request("DATA_TEST_TX " + bssid + " " + addr1)
591 ev = dev[1].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
592 dev[1].request("DATA_TEST_CONFIG 0")
594 raise Exception("Disconnection event not seen after TX attempt")
595 if "reason=7" not in ev:
596 raise Exception("Unexpected disconnection reason: " + ev)