1 # wpa_supplicant 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 def test_wpas_ctrl_network(dev):
10 """wpa_supplicant ctrl_iface network set/get"""
11 id = dev[0].add_network()
13 tests = (("key_mgmt", "WPA-PSK WPA-EAP IEEE8021X NONE WPA-NONE FT-PSK FT-EAP WPA-PSK-SHA256 WPA-EAP-SHA256"),
14 ("pairwise", "CCMP-256 GCMP-256 CCMP GCMP TKIP"),
15 ("group", "CCMP-256 GCMP-256 CCMP GCMP TKIP WEP104 WEP40"),
16 ("auth_alg", "OPEN SHARED LEAP"),
17 ("scan_freq", "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15"),
18 ("freq_list", "2412 2417"),
20 ("bssid", "00:11:22:33:44:55"),
21 ("proto", "WPA RSN OSEN"),
23 ("go_p2p_dev_addr", "22:33:44:55:66:aa"),
24 ("p2p_client_list", "22:33:44:55:66:bb 02:11:22:33:44:55"))
26 dev[0].set_network_quoted(id, "ssid", "test")
27 for field, value in tests:
28 dev[0].set_network(id, field, value)
29 res = dev[0].get_network(id, field)
31 raise Exception("Unexpected response for '" + field + "': '" + res + "'")
33 q_tests = (("identity", "hello"),
34 ("anonymous_identity", "foo@nowhere.com"))
35 for field, value in q_tests:
36 dev[0].set_network_quoted(id, field, value)
37 res = dev[0].get_network(id, field)
38 if res != '"' + value + '"':
39 raise Exception("Unexpected quoted response for '" + field + "': '" + res + "'")
41 get_tests = (("foo", None), ("ssid", '"test"'))
42 for field, value in get_tests:
43 res = dev[0].get_network(id, field)
45 raise Exception("Unexpected response for '" + field + "': '" + res + "'")
47 if dev[0].get_network(id, "password"):
48 raise Exception("Unexpected response for 'password'")
49 dev[0].set_network_quoted(id, "password", "foo")
50 if dev[0].get_network(id, "password") != '*':
51 raise Exception("Unexpected response for 'password' (expected *)")
52 dev[0].set_network(id, "password", "hash:12345678901234567890123456789012")
53 if dev[0].get_network(id, "password") != '*':
54 raise Exception("Unexpected response for 'password' (expected *)")
55 dev[0].set_network(id, "password", "NULL")
56 if dev[0].get_network(id, "password"):
57 raise Exception("Unexpected response for 'password'")
58 if "FAIL" not in dev[0].request("SET_NETWORK " + str(id) + " password hash:12"):
59 raise Exception("Unexpected success for invalid password hash")
60 if "FAIL" not in dev[0].request("SET_NETWORK " + str(id) + " password hash:123456789012345678x0123456789012"):
61 raise Exception("Unexpected success for invalid password hash")
63 dev[0].set_network(id, "identity", "414243")
64 if dev[0].get_network(id, "identity") != '"ABC"':
65 raise Exception("Unexpected identity hex->text response")
67 dev[0].set_network(id, "identity", 'P"abc\ndef"')
68 if dev[0].get_network(id, "identity") != "6162630a646566":
69 raise Exception("Unexpected identity printf->hex response")
71 if "FAIL" not in dev[0].request("SET_NETWORK " + str(id) + ' identity P"foo'):
72 raise Exception("Unexpected success for invalid identity string")
74 if "FAIL" not in dev[0].request("SET_NETWORK " + str(id) + ' identity 12x3'):
75 raise Exception("Unexpected success for invalid identity string")
78 if "FAIL" in dev[0].request("SET_NETWORK " + str(id) + ' wep_key' + str(i) + ' aabbccddee'):
79 raise Exception("Unexpected wep_key set failure")
80 if dev[0].get_network(id, "wep_key" + str(i)) != '*':
81 raise Exception("Unexpected wep_key get failure")
83 if "FAIL" in dev[0].request("SET_NETWORK " + str(id) + ' psk_list P2P-00:11:22:33:44:55-0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'):
84 raise Exception("Unexpected failure for psk_list string")
86 if "FAIL" not in dev[0].request("SET_NETWORK " + str(id) + ' psk_list 00:11:x2:33:44:55-0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'):
87 raise Exception("Unexpected success for invalid psk_list string")
89 if "FAIL" not in dev[0].request("SET_NETWORK " + str(id) + ' psk_list P2P-00:11:x2:33:44:55-0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'):
90 raise Exception("Unexpected success for invalid psk_list string")
92 if "FAIL" not in dev[0].request("SET_NETWORK " + str(id) + ' psk_list P2P-00:11:22:33:44:55+0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'):
93 raise Exception("Unexpected success for invalid psk_list string")
95 if "FAIL" not in dev[0].request("SET_NETWORK " + str(id) + ' psk_list P2P-00:11:22:33:44:55-0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde'):
96 raise Exception("Unexpected success for invalid psk_list string")
98 if "FAIL" not in dev[0].request("SET_NETWORK " + str(id) + ' psk_list P2P-00:11:22:33:44:55-0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdex'):
99 raise Exception("Unexpected success for invalid psk_list string")
101 if dev[0].get_network(id, "psk_list"):
102 raise Exception("Unexpected psk_list get response")
104 if dev[0].list_networks()[0]['ssid'] != "test":
105 raise Exception("Unexpected ssid in LIST_NETWORKS")
106 dev[0].set_network(id, "ssid", "NULL")
107 if dev[0].list_networks()[0]['ssid'] != "":
108 raise Exception("Unexpected ssid in LIST_NETWORKS after clearing it")
110 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' ssid "0123456789abcdef0123456789abcdef0"'):
111 raise Exception("Too long SSID accepted")
112 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' scan_ssid qwerty'):
113 raise Exception("Invalid integer accepted")
114 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' scan_ssid 2'):
115 raise Exception("Too large integer accepted")
116 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' psk 12345678'):
117 raise Exception("Invalid PSK accepted")
118 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' psk "1234567"'):
119 raise Exception("Too short PSK accepted")
120 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' psk "1234567890123456789012345678901234567890123456789012345678901234"'):
121 raise Exception("Too long PSK accepted")
122 dev[0].set_network_quoted(id, "psk", "123456768");
123 dev[0].set_network_quoted(id, "psk", "123456789012345678901234567890123456789012345678901234567890123");
124 if dev[0].get_network(id, "psk") != '*':
125 raise Exception("Unexpected psk read result");
127 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' eap UNKNOWN'):
128 raise Exception("Unknown EAP method accepted")
130 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' password "foo'):
131 raise Exception("Invalid password accepted")
133 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' wep_key0 "foo'):
134 raise Exception("Invalid WEP key accepted")
135 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' wep_key0 "12345678901234567"'):
136 raise Exception("Too long WEP key accepted")
137 # too short WEP key is ignored
138 dev[0].set_network_quoted(id, "wep_key0", "1234")
139 dev[0].set_network_quoted(id, "wep_key1", "12345")
140 dev[0].set_network_quoted(id, "wep_key2", "1234567890123")
141 dev[0].set_network_quoted(id, "wep_key3", "1234567890123456")
143 dev[0].set_network(id, "go_p2p_dev_addr", "any")
144 if dev[0].get_network(id, "go_p2p_dev_addr") is not None:
145 raise Exception("Unexpected go_p2p_dev_addr value")
146 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' go_p2p_dev_addr 00:11:22:33:44'):
147 raise Exception("Invalid go_p2p_dev_addr accepted")
148 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' p2p_client_list 00:11:22:33:44'):
149 raise Exception("Invalid p2p_client_list accepted")
150 if "FAIL" in dev[0].request('SET_NETWORK ' + str(id) + ' p2p_client_list 00:11:22:33:44:55 00:1'):
151 raise Exception("p2p_client_list truncation workaround failed")
152 if dev[0].get_network(id, "p2p_client_list") != "00:11:22:33:44:55":
153 raise Exception("p2p_client_list truncation workaround did not work")
155 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' auth_alg '):
156 raise Exception("Empty auth_alg accepted")
157 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' auth_alg FOO'):
158 raise Exception("Invalid auth_alg accepted")
160 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' proto '):
161 raise Exception("Empty proto accepted")
162 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' proto FOO'):
163 raise Exception("Invalid proto accepted")
165 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' pairwise '):
166 raise Exception("Empty pairwise accepted")
167 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' pairwise FOO'):
168 raise Exception("Invalid pairwise accepted")
169 if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' pairwise WEP40'):
170 raise Exception("Invalid pairwise accepted")
172 if "OK" not in dev[0].request('BSSID ' + str(id) + ' 00:11:22:33:44:55'):
173 raise Exception("Unexpected BSSID failure")
174 if dev[0].request("GET_NETWORK 0 bssid") != '00:11:22:33:44:55':
175 raise Exception("BSSID command did not set network bssid")
176 if "OK" not in dev[0].request('BSSID ' + str(id) + ' 00:00:00:00:00:00'):
177 raise Exception("Unexpected BSSID failure")
178 if "FAIL" not in dev[0].request("GET_NETWORK 0 bssid"):
179 raise Exception("bssid claimed configured after clearing")
180 if "FAIL" not in dev[0].request('BSSID 123 00:11:22:33:44:55'):
181 raise Exception("Unexpected BSSID success")
182 if "FAIL" not in dev[0].request('BSSID ' + str(id) + ' 00:11:22:33:44'):
183 raise Exception("Unexpected BSSID success")
187 ev = dev.wait_event(["CRED-ADDED"])
189 raise Exception("Missing CRED-ADDED event")
190 if " " + str(id) not in ev:
191 raise Exception("CRED-ADDED event without matching id")
194 def set_cred(dev, id, field, value):
195 dev.set_cred(id, field, value)
196 ev = dev.wait_event(["CRED-MODIFIED"])
198 raise Exception("Missing CRED-MODIFIED event")
199 if " " + str(id) + " " not in ev:
200 raise Exception("CRED-MODIFIED event without matching id")
202 raise Exception("CRED-MODIFIED event without matching field")
204 def set_cred_quoted(dev, id, field, value):
205 dev.set_cred_quoted(id, field, value)
206 ev = dev.wait_event(["CRED-MODIFIED"])
208 raise Exception("Missing CRED-MODIFIED event")
209 if " " + str(id) + " " not in ev:
210 raise Exception("CRED-MODIFIED event without matching id")
212 raise Exception("CRED-MODIFIED event without matching field")
214 def remove_cred(dev, id):
216 ev = dev.wait_event(["CRED-REMOVED"])
218 raise Exception("Missing CRED-REMOVED event")
219 if " " + str(id) not in ev:
220 raise Exception("CRED-REMOVED event without matching id")
222 def test_wpas_ctrl_cred(dev):
223 """wpa_supplicant ctrl_iface cred set"""
224 id1 = add_cred(dev[0])
225 id = add_cred(dev[0])
226 id2 = add_cred(dev[0])
227 set_cred(dev[0], id, "temporary", "1")
228 set_cred(dev[0], id, "priority", "1")
229 set_cred(dev[0], id, "pcsc", "1")
230 set_cred_quoted(dev[0], id, "private_key_passwd", "test")
231 set_cred_quoted(dev[0], id, "domain_suffix_match", "test")
232 set_cred_quoted(dev[0], id, "phase1", "test")
233 set_cred_quoted(dev[0], id, "phase2", "test")
235 if "FAIL" not in dev[0].request("SET_CRED " + str(id) + " eap FOO"):
236 raise Exception("Unexpected success on unknown EAP method")
238 if "FAIL" not in dev[0].request("SET_CRED " + str(id) + " username 12xa"):
239 raise Exception("Unexpected success on invalid string")
241 for i in ("11", "1122", "112233445566778899aabbccddeeff00"):
242 if "FAIL" not in dev[0].request("SET_CRED " + str(id) + " roaming_consortium " + i):
243 raise Exception("Unexpected success on invalid roaming_consortium")
245 dev[0].set_cred(id, "excluded_ssid", "00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff")
246 if "FAIL" not in dev[0].request("SET_CRED " + str(id) + " excluded_ssid 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00"):
247 raise Exception("Unexpected success on invalid excluded_ssid")
249 if "FAIL" not in dev[0].request("SET_CRED " + str(id) + " foo 4142"):
250 raise Exception("Unexpected success on unknown field")
252 id3 = add_cred(dev[0])
253 id4 = add_cred(dev[0])
255 remove_cred(dev[0], id1)
256 remove_cred(dev[0], id3)
257 remove_cred(dev[0], id4)
258 remove_cred(dev[0], id2)
259 remove_cred(dev[0], id)
260 if "FAIL" not in dev[0].request("REMOVE_CRED 1"):
261 raise Exception("Unexpected success on invalid remove cred")
263 id = add_cred(dev[0])
264 values = [ ("temporary", "1", False),
265 ("temporary", "0", False),
266 ("pcsc", "1", False),
267 ("realm", "example.com", True),
268 ("username", "user@example.com", True),
269 ("password", "foo", True, "*"),
270 ("ca_cert", "ca.pem", True),
271 ("client_cert", "user.pem", True),
272 ("private_key", "key.pem", True),
273 ("private_key_passwd", "foo", True, "*"),
274 ("imsi", "310026-000000000", True),
275 ("milenage", "foo", True, "*"),
276 ("domain_suffix_match", "example.com", True),
277 ("domain", "example.com", True),
278 ("domain", "example.org", True, "example.com\nexample.org"),
279 ("roaming_consortium", "0123456789", False),
280 ("required_roaming_consortium", "456789", False),
281 ("eap", "TTLS", False),
282 ("phase1", "foo=bar1", True),
283 ("phase2", "foo=bar2", True),
284 ("excluded_ssid", "test", True),
285 ("excluded_ssid", "foo", True, "test\nfoo"),
286 ("roaming_partner", "example.com,0,4,*", True),
287 ("roaming_partner", "example.org,1,2,US", True,
288 "example.com,0,4,*\nexample.org,1,2,US"),
289 ("update_identifier", "4", False),
290 ("provisioning_sp", "sp.example.com", True),
291 ("sp_priority", "7", False),
292 ("min_dl_bandwidth_home", "100", False),
293 ("min_ul_bandwidth_home", "101", False),
294 ("min_dl_bandwidth_roaming", "102", False),
295 ("min_ul_bandwidth_roaming", "103", False),
296 ("max_bss_load", "57", False),
297 ("req_conn_capab", "6:22,80,443", False),
298 ("req_conn_capab", "17:500", False, "6:22,80,443\n17:500"),
299 ("req_conn_capab", "50", False, "6:22,80,443\n17:500\n50"),
300 ("ocsp", "1", False) ]
303 set_cred_quoted(dev[0], id, v[0], v[1])
305 set_cred(dev[0], id, v[0], v[1])
306 val = dev[0].get_cred(id, v[0])
312 raise Exception("Unexpected GET_CRED value for {}: {} != {}".format(v[0], val, expect))
313 remove_cred(dev[0], id)
315 def test_wpas_ctrl_pno(dev):
316 """wpa_supplicant ctrl_iface pno"""
317 if "FAIL" not in dev[0].request("SET pno 1"):
318 raise Exception("Unexpected success in enabling PNO without enabled network blocks")
319 id = dev[0].add_network()
320 dev[0].set_network_quoted(id, "ssid", "test")
321 dev[0].set_network(id, "key_mgmt", "NONE")
322 dev[0].request("ENABLE_NETWORK " + str(id) + " no-connect")
323 #mac80211_hwsim does not yet support PNO, so this fails
324 if "FAIL" not in dev[0].request("SET pno 1"):
325 raise Exception("Unexpected success in enabling PNO")
326 if "FAIL" not in dev[0].request("SET pno 1 freq=2000-3000,5180"):
327 raise Exception("Unexpected success in enabling PNO")
328 if "FAIL" not in dev[0].request("SET pno 1 freq=0-6000"):
329 raise Exception("Unexpected success in enabling PNO")
330 if "FAIL" in dev[0].request("SET pno 0"):
331 raise Exception("Unexpected failure in disabling PNO")
333 def test_wpas_ctrl_get(dev):
334 """wpa_supplicant ctrl_iface get"""
335 if "FAIL" in dev[0].request("GET version"):
336 raise Exception("Unexpected get failure for version")
337 if "FAIL" in dev[0].request("GET wifi_display"):
338 raise Exception("Unexpected get failure for wifi_display")
339 if "FAIL" not in dev[0].request("GET foo"):
340 raise Exception("Unexpected success on get command")
342 def test_wpas_ctrl_preauth(dev):
343 """wpa_supplicant ctrl_iface preauth"""
344 if "FAIL" not in dev[0].request("PREAUTH "):
345 raise Exception("Unexpected success on invalid PREAUTH")
346 if "FAIL" in dev[0].request("PREAUTH 00:11:22:33:44:55"):
347 raise Exception("Unexpected failure on PREAUTH")
349 def test_wpas_ctrl_stkstart(dev):
350 """wpa_supplicant ctrl_iface strkstart"""
351 if "FAIL" not in dev[0].request("STKSTART "):
352 raise Exception("Unexpected success on invalid STKSTART")
353 if "FAIL" not in dev[0].request("STKSTART 00:11:22:33:44:55"):
354 raise Exception("Unexpected success on STKSTART")
356 def test_wpas_ctrl_tdls_discover(dev):
357 """wpa_supplicant ctrl_iface tdls_discover"""
358 if "FAIL" not in dev[0].request("TDLS_DISCOVER "):
359 raise Exception("Unexpected success on invalid TDLS_DISCOVER")
360 if "FAIL" not in dev[0].request("TDLS_DISCOVER 00:11:22:33:44:55"):
361 raise Exception("Unexpected success on TDLS_DISCOVER")
363 def test_wpas_ctrl_addr(dev):
364 """wpa_supplicant ctrl_iface invalid address"""
365 if "FAIL" not in dev[0].request("TDLS_SETUP "):
366 raise Exception("Unexpected success on invalid TDLS_SETUP")
367 if "FAIL" not in dev[0].request("TDLS_TEARDOWN "):
368 raise Exception("Unexpected success on invalid TDLS_TEARDOWN")
369 if "FAIL" not in dev[0].request("FT_DS "):
370 raise Exception("Unexpected success on invalid FT_DS")
371 if "FAIL" not in dev[0].request("WPS_PBC 00:11:22:33:44"):
372 raise Exception("Unexpected success on invalid WPS_PBC")
373 if "FAIL" not in dev[0].request("WPS_PIN 00:11:22:33:44"):
374 raise Exception("Unexpected success on invalid WPS_PIN")
375 if "FAIL" not in dev[0].request("WPS_NFC 00:11:22:33:44"):
376 raise Exception("Unexpected success on invalid WPS_NFC")
377 if "FAIL" not in dev[0].request("WPS_REG 12345670 00:11:22:33:44"):
378 raise Exception("Unexpected success on invalid WPS_REG")
379 if "FAIL" not in dev[0].request("IBSS_RSN 00:11:22:33:44"):
380 raise Exception("Unexpected success on invalid IBSS_RSN")
382 def test_wpas_ctrl_config_parser(dev):
383 """wpa_supplicant ctrl_iface SET config parser"""
384 if "FAIL" not in dev[0].request("SET pbc_in_m1 qwerty"):
385 raise Exception("Non-number accepted as integer")
386 if "FAIL" not in dev[0].request("SET eapol_version 0"):
387 raise Exception("Out-of-range value accepted")
388 if "FAIL" not in dev[0].request("SET eapol_version 10"):
389 raise Exception("Out-of-range value accepted")
391 if "FAIL" not in dev[0].request("SET serial_number 0123456789abcdef0123456789abcdef0"):
392 raise Exception("Too long string accepted")
394 def test_wpas_ctrl_mib(dev):
395 """wpa_supplicant ctrl_iface MIB"""
396 mib = dev[0].get_mib()
397 if "dot11RSNAOptionImplemented" not in mib:
398 raise Exception("Missing MIB entry")
399 if mib["dot11RSNAOptionImplemented"] != "TRUE":
400 raise Exception("Unexpected dot11RSNAOptionImplemented value")
402 def test_wpas_ctrl_set_wps_params(dev):
403 """wpa_supplicant ctrl_iface SET config_methods"""
404 ts = [ "config_methods label virtual_display virtual_push_button keypad",
405 "device_type 1-0050F204-1",
406 "os_version 01020300",
407 "uuid 12345678-9abc-def0-1234-56789abcdef0" ]
409 if "OK" not in dev[2].request("SET " + t):
410 raise Exception("SET failed for: " + t)
412 def test_wpas_ctrl_level(dev):
413 """wpa_supplicant ctrl_iface LEVEL"""
415 if "FAIL" not in dev[2].request("LEVEL 3"):
416 raise Exception("Unexpected LEVEL success")
417 if "OK" not in dev[2].mon.request("LEVEL 2"):
418 raise Exception("Unexpected LEVEL failure")
419 dev[2].request("SCAN freq=2412")
420 ev = dev[2].wait_event(["State:"], timeout=5)
422 raise Exception("No debug message received")
423 dev[2].wait_event(["CTRL-EVENT-SCAN-RESULTS"], timeout=5)
425 dev[2].mon.request("LEVEL 3")
427 def test_wpas_ctrl_bssid_filter(dev, apdev):
428 """wpa_supplicant bssid_filter"""
430 if "OK" not in dev[2].request("SET bssid_filter " + apdev[0]['bssid']):
431 raise Exception("Failed to set bssid_filter")
432 params = { "ssid": "test" }
433 hostapd.add_ap(apdev[0]['ifname'], params)
434 hostapd.add_ap(apdev[1]['ifname'], params)
435 dev[2].scan(freq="2412")
436 bss = dev[2].get_bss(apdev[0]['bssid'])
438 raise Exception("Missing BSS data")
439 bss = dev[2].get_bss(apdev[1]['bssid'])
441 raise Exception("Unexpected BSS data")
442 dev[2].request("SET bssid_filter ")
443 dev[2].scan(freq="2412")
444 bss = dev[2].get_bss(apdev[0]['bssid'])
446 raise Exception("Missing BSS data")
447 bss = dev[2].get_bss(apdev[1]['bssid'])
449 raise Exception("Missing BSS data(2)")
451 if "FAIL" not in dev[2].request("SET bssid_filter 00:11:22:33:44:55 00:11:22:33:44"):
452 raise Exception("Unexpected success for invalid SET bssid_filter")
454 dev[2].request("SET bssid_filter ")
456 def test_wpas_ctrl_disallow_aps(dev, apdev):
457 """wpa_supplicant ctrl_iface disallow_aps"""
458 params = { "ssid": "test" }
459 hostapd.add_ap(apdev[0]['ifname'], params)
461 if "FAIL" not in dev[0].request("SET disallow_aps bssid "):
462 raise Exception("Unexpected success on invalid disallow_aps")
463 if "FAIL" not in dev[0].request("SET disallow_aps bssid 00:11:22:33:44"):
464 raise Exception("Unexpected success on invalid disallow_aps")
465 if "FAIL" not in dev[0].request("SET disallow_aps ssid 0"):
466 raise Exception("Unexpected success on invalid disallow_aps")
467 if "FAIL" not in dev[0].request("SET disallow_aps ssid 4q"):
468 raise Exception("Unexpected success on invalid disallow_aps")
469 if "FAIL" not in dev[0].request("SET disallow_aps bssid 00:11:22:33:44:55 ssid 112233 ssid 123"):
470 raise Exception("Unexpected success on invalid disallow_aps")
471 if "FAIL" not in dev[0].request("SET disallow_aps ssid 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f00"):
472 raise Exception("Unexpected success on invalid disallow_aps")
473 if "FAIL" not in dev[0].request("SET disallow_aps foo 112233445566"):
474 raise Exception("Unexpected success on invalid disallow_aps")
476 dev[0].connect("test", key_mgmt="NONE", scan_freq="2412")
477 hostapd.add_ap(apdev[1]['ifname'], params)
478 dev[0].dump_monitor()
479 if "OK" not in dev[0].request("SET disallow_aps bssid 00:11:22:33:44:55 bssid 00:22:33:44:55:66"):
480 raise Exception("Failed to set disallow_aps")
481 if "OK" not in dev[0].request("SET disallow_aps bssid " + apdev[0]['bssid']):
482 raise Exception("Failed to set disallow_aps")
483 ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
485 raise Exception("Reassociation timed out")
486 if apdev[1]['bssid'] not in ev:
487 raise Exception("Unexpected BSSID")
489 dev[0].dump_monitor()
490 if "OK" not in dev[0].request("SET disallow_aps ssid " + "test".encode("hex")):
491 raise Exception("Failed to set disallow_aps")
492 ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
494 raise Exception("Disconnection not seen")
495 ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
497 raise Exception("Unexpected reassociation")
499 def test_wpas_ctrl_blob(dev):
500 """wpa_supplicant ctrl_iface SET blob"""
501 if "FAIL" not in dev[0].request("SET blob foo"):
502 raise Exception("Unexpected SET success")
503 if "FAIL" not in dev[0].request("SET blob foo 0"):
504 raise Exception("Unexpected SET success")
505 if "FAIL" not in dev[0].request("SET blob foo 0q"):
506 raise Exception("Unexpected SET success")
507 if "OK" not in dev[0].request("SET blob foo 00"):
508 raise Exception("Unexpected SET failure")
509 if "OK" not in dev[0].request("SET blob foo 0011"):
510 raise Exception("Unexpected SET failure")
512 def test_wpas_ctrl_set_uapsd(dev):
513 """wpa_supplicant ctrl_iface SET uapsd"""
514 if "FAIL" not in dev[0].request("SET uapsd foo"):
515 raise Exception("Unexpected SET success")
516 if "FAIL" not in dev[0].request("SET uapsd 0,0,0"):
517 raise Exception("Unexpected SET success")
518 if "FAIL" not in dev[0].request("SET uapsd 0,0"):
519 raise Exception("Unexpected SET success")
520 if "FAIL" not in dev[0].request("SET uapsd 0"):
521 raise Exception("Unexpected SET success")
522 if "OK" not in dev[0].request("SET uapsd 1,1,1,1;1"):
523 raise Exception("Unexpected SET failure")
524 if "OK" not in dev[0].request("SET uapsd 0,0,0,0;0"):
525 raise Exception("Unexpected SET failure")
526 if "OK" not in dev[0].request("SET uapsd disable"):
527 raise Exception("Unexpected SET failure")
529 def test_wpas_ctrl_set(dev):
530 """wpa_supplicant ctrl_iface SET"""
532 "dot11RSNAConfigPMKLifetime 0",
533 "dot11RSNAConfigPMKReauthThreshold 101",
534 "dot11RSNAConfigSATimeout 0",
535 "wps_version_number -1",
536 "wps_version_number 256" ]
538 if "FAIL" not in dev[0].request("SET " + val):
539 raise Exception("Unexpected SET success for " + val)
541 vals = [ "EAPOL::heldPeriod 60",
542 "EAPOL::authPeriod 30",
543 "EAPOL::startPeriod 30",
545 "dot11RSNAConfigSATimeout 60",
549 if "OK" not in dev[0].request("SET " + val):
550 raise Exception("Unexpected SET failure for " + val)
552 def test_wpas_ctrl_get_capability(dev):
553 """wpa_supplicant ctrl_iface GET_CAPABILITY"""
554 res = dev[0].get_capability("eap")
555 if "TTLS" not in res:
556 raise Exception("Unexpected GET_CAPABILITY eap response: " + str(res))
558 res = dev[0].get_capability("pairwise")
559 if "CCMP" not in res:
560 raise Exception("Unexpected GET_CAPABILITY pairwise response: " + str(res))
562 res = dev[0].get_capability("group")
563 if "CCMP" not in res:
564 raise Exception("Unexpected GET_CAPABILITY group response: " + str(res))
566 res = dev[0].get_capability("key_mgmt")
567 if "WPA-PSK" not in res or "WPA-EAP" not in res:
568 raise Exception("Unexpected GET_CAPABILITY key_mgmt response: " + str(res))
570 res = dev[0].get_capability("proto")
571 if "WPA" not in res or "RSN" not in res:
572 raise Exception("Unexpected GET_CAPABILITY proto response: " + str(res))
574 res = dev[0].get_capability("auth_alg")
575 if "OPEN" not in res or "SHARED" not in res:
576 raise Exception("Unexpected GET_CAPABILITY auth_alg response: " + str(res))
578 res = dev[0].get_capability("modes")
579 if "IBSS" not in res or "AP" not in res:
580 raise Exception("Unexpected GET_CAPABILITY modes response: " + str(res))
582 res = dev[0].get_capability("channels")
583 if "8" not in res or "36" not in res:
584 raise Exception("Unexpected GET_CAPABILITY channels response: " + str(res))
586 res = dev[0].get_capability("freq")
587 if "2457" not in res or "5180" not in res:
588 raise Exception("Unexpected GET_CAPABILITY freq response: " + str(res))
590 res = dev[0].get_capability("tdls")
591 if "EXTERNAL" not in res[0]:
592 raise Exception("Unexpected GET_CAPABILITY tdls response: " + str(res))
594 if dev[0].get_capability("foo") is not None:
595 raise Exception("Unexpected GET_CAPABILITY foo response: " + str(res))
597 def test_wpas_ctrl_nfc_report_handover(dev):
598 """wpa_supplicant ctrl_iface NFC_REPORT_HANDOVER"""
609 if "FAIL" not in dev[0].request("NFC_REPORT_HANDOVER " + v):
610 raise Exception("Unexpected NFC_REPORT_HANDOVER success for " + v)
612 def get_blacklist(dev):
613 return dev.request("BLACKLIST").splitlines()
615 def test_wpas_ctrl_blacklist(dev):
616 """wpa_supplicant ctrl_iface BLACKLIST"""
617 if "OK" not in dev[0].request("BLACKLIST clear"):
618 raise Exception("BLACKLIST clear failed")
619 b = get_blacklist(dev[0])
621 raise Exception("Unexpected blacklist contents: " + str(b))
622 if "OK" not in dev[0].request("BLACKLIST 00:11:22:33:44:55"):
623 raise Exception("BLACKLIST add failed")
624 b = get_blacklist(dev[0])
625 if "00:11:22:33:44:55" not in b:
626 raise Exception("Unexpected blacklist contents: " + str(b))
627 if "OK" not in dev[0].request("BLACKLIST 00:11:22:33:44:56"):
628 raise Exception("BLACKLIST add failed")
629 b = get_blacklist(dev[0])
630 if "00:11:22:33:44:55" not in b or "00:11:22:33:44:56" not in b:
631 raise Exception("Unexpected blacklist contents: " + str(b))
632 if "OK" not in dev[0].request("BLACKLIST 00:11:22:33:44:56"):
633 raise Exception("BLACKLIST add failed")
634 b = get_blacklist(dev[0])
635 if "00:11:22:33:44:55" not in b or "00:11:22:33:44:56" not in b or len(b) != 2:
636 raise Exception("Unexpected blacklist contents: " + str(b))
638 if "OK" not in dev[0].request("BLACKLIST clear"):
639 raise Exception("BLACKLIST clear failed")
640 if dev[0].request("BLACKLIST") != "":
641 raise Exception("Unexpected blacklist contents")