]>
git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_ap_wps.py
2 # Copyright (c) 2013-2014, Jouni Malinen <j@w1.fi>
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
10 logger
= logging
.getLogger()
16 def test_ap_wps_init(dev
, apdev
):
17 """Initial AP configuration with first WPS Enrollee"""
19 hostapd
.add_ap(apdev
[0]['ifname'],
20 { "ssid": ssid
, "eap_server": "1", "wps_state": "1" })
21 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
22 logger
.info("WPS provisioning step")
23 hapd
.request("WPS_PBC")
24 if "PBC Status: Active" not in hapd
.request("WPS_GET_STATUS"):
25 raise Exception("PBC status not shown correctly")
27 dev
[0].request("WPS_PBC")
28 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=30)
30 raise Exception("Association with the AP timed out")
31 status
= dev
[0].get_status()
32 if status
['wpa_state'] != 'COMPLETED' or status
['bssid'] != apdev
[0]['bssid']:
33 raise Exception("Not fully connected")
34 if status
['ssid'] != ssid
:
35 raise Exception("Unexpected SSID")
36 if status
['pairwise_cipher'] != 'CCMP':
37 raise Exception("Unexpected encryption configuration")
38 if status
['key_mgmt'] != 'WPA2-PSK':
39 raise Exception("Unexpected key_mgmt")
41 status
= hapd
.request("WPS_GET_STATUS")
42 if "PBC Status: Disabled" not in status
:
43 raise Exception("PBC status not shown correctly")
44 if "Last WPS result: Success" not in status
:
45 raise Exception("Last WPS result not shown correctly")
46 if "Peer Address: " + dev
[0].p2p_interface_addr() not in status
:
47 raise Exception("Peer address not shown correctly")
48 conf
= hapd
.request("GET_CONFIG")
49 if "wps_state=configured" not in conf
:
50 raise Exception("AP not in WPS configured state")
51 if "rsn_pairwise_cipher=CCMP TKIP" not in conf
:
52 raise Exception("Unexpected rsn_pairwise_cipher")
53 if "wpa_pairwise_cipher=CCMP TKIP" not in conf
:
54 raise Exception("Unexpected wpa_pairwise_cipher")
55 if "group_cipher=TKIP" not in conf
:
56 raise Exception("Unexpected group_cipher")
58 def test_ap_wps_init_2ap_pbc(dev
, apdev
):
59 """Initial two-radio AP configuration with first WPS PBC Enrollee"""
61 params
= { "ssid": ssid
, "eap_server": "1", "wps_state": "1" }
62 hostapd
.add_ap(apdev
[0]['ifname'], params
)
63 hostapd
.add_ap(apdev
[1]['ifname'], params
)
64 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
65 logger
.info("WPS provisioning step")
66 hapd
.request("WPS_PBC")
67 dev
[0].scan(freq
="2412")
68 bss
= dev
[0].get_bss(apdev
[0]['bssid'])
69 if "[WPS-PBC]" not in bss
['flags']:
70 raise Exception("WPS-PBC flag missing from AP1")
71 bss
= dev
[0].get_bss(apdev
[1]['bssid'])
72 if "[WPS-PBC]" not in bss
['flags']:
73 raise Exception("WPS-PBC flag missing from AP2")
75 dev
[0].request("WPS_PBC")
76 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=30)
78 raise Exception("Association with the AP timed out")
80 dev
[1].scan(freq
="2412")
81 bss
= dev
[1].get_bss(apdev
[0]['bssid'])
82 if "[WPS-PBC]" in bss
['flags']:
83 raise Exception("WPS-PBC flag not cleared from AP1")
84 bss
= dev
[1].get_bss(apdev
[1]['bssid'])
85 if "[WPS-PBC]" in bss
['flags']:
86 raise Exception("WPS-PBC flag bit ckeared from AP2")
88 def test_ap_wps_init_2ap_pin(dev
, apdev
):
89 """Initial two-radio AP configuration with first WPS PIN Enrollee"""
91 params
= { "ssid": ssid
, "eap_server": "1", "wps_state": "1" }
92 hostapd
.add_ap(apdev
[0]['ifname'], params
)
93 hostapd
.add_ap(apdev
[1]['ifname'], params
)
94 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
95 logger
.info("WPS provisioning step")
96 pin
= dev
[0].wps_read_pin()
97 hapd
.request("WPS_PIN any " + pin
)
98 dev
[0].scan(freq
="2412")
99 bss
= dev
[0].get_bss(apdev
[0]['bssid'])
100 if "[WPS-AUTH]" not in bss
['flags']:
101 raise Exception("WPS-AUTH flag missing from AP1")
102 bss
= dev
[0].get_bss(apdev
[1]['bssid'])
103 if "[WPS-AUTH]" not in bss
['flags']:
104 raise Exception("WPS-AUTH flag missing from AP2")
105 dev
[0].dump_monitor()
106 dev
[0].request("WPS_PIN any " + pin
)
107 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=30)
109 raise Exception("Association with the AP timed out")
111 dev
[1].scan(freq
="2412")
112 bss
= dev
[1].get_bss(apdev
[0]['bssid'])
113 if "[WPS-AUTH]" in bss
['flags']:
114 raise Exception("WPS-AUTH flag not cleared from AP1")
115 bss
= dev
[1].get_bss(apdev
[1]['bssid'])
116 if "[WPS-AUTH]" in bss
['flags']:
117 raise Exception("WPS-AUTH flag bit ckeared from AP2")
119 def test_ap_wps_init_through_wps_config(dev
, apdev
):
120 """Initial AP configuration using wps_config command"""
121 ssid
= "test-wps-init-config"
122 hostapd
.add_ap(apdev
[0]['ifname'],
123 { "ssid": ssid
, "eap_server": "1", "wps_state": "1" })
124 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
125 if "FAIL" in hapd
.request("WPS_CONFIG " + ssid
.encode("hex") + " WPA2PSK CCMP " + "12345678".encode("hex")):
126 raise Exception("WPS_CONFIG command failed")
127 dev
[0].connect(ssid
, psk
="12345678", scan_freq
="2412", proto
="WPA2",
128 pairwise
="CCMP", group
="CCMP")
130 def test_ap_wps_conf(dev
, apdev
):
131 """WPS PBC provisioning with configured AP"""
132 ssid
= "test-wps-conf"
133 hostapd
.add_ap(apdev
[0]['ifname'],
134 { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
135 "wpa_passphrase": "12345678", "wpa": "2",
136 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"})
137 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
138 logger
.info("WPS provisioning step")
139 hapd
.request("WPS_PBC")
140 dev
[0].dump_monitor()
141 dev
[0].request("WPS_PBC")
142 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=30)
144 raise Exception("Association with the AP timed out")
145 status
= dev
[0].get_status()
146 if status
['wpa_state'] != 'COMPLETED':
147 raise Exception("Not fully connected")
148 if status
['bssid'] != apdev
[0]['bssid']:
149 raise Exception("Unexpected BSSID")
150 if status
['ssid'] != ssid
:
151 raise Exception("Unexpected SSID")
152 if status
['pairwise_cipher'] != 'CCMP' or status
['group_cipher'] != 'CCMP':
153 raise Exception("Unexpected encryption configuration")
154 if status
['key_mgmt'] != 'WPA2-PSK':
155 raise Exception("Unexpected key_mgmt")
157 sta
= hapd
.get_sta(dev
[0].p2p_interface_addr())
158 if 'wpsDeviceName' not in sta
or sta
['wpsDeviceName'] != "Device A":
159 raise Exception("Device name not available in STA command")
161 def test_ap_wps_twice(dev
, apdev
):
162 """WPS provisioning with twice to change passphrase"""
163 ssid
= "test-wps-twice"
164 params
= { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
165 "wpa_passphrase": "12345678", "wpa": "2",
166 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" }
167 hostapd
.add_ap(apdev
[0]['ifname'], params
)
168 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
169 logger
.info("WPS provisioning step")
170 hapd
.request("WPS_PBC")
171 dev
[0].dump_monitor()
172 dev
[0].request("WPS_PBC")
173 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=30)
175 raise Exception("Association with the AP timed out")
176 dev
[0].request("DISCONNECT")
178 logger
.info("Restart AP with different passphrase and re-run WPS")
179 hapd_global
= hostapd
.HostapdGlobal()
180 hapd_global
.remove(apdev
[0]['ifname'])
181 params
['wpa_passphrase'] = 'another passphrase'
182 hostapd
.add_ap(apdev
[0]['ifname'], params
)
183 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
184 logger
.info("WPS provisioning step")
185 hapd
.request("WPS_PBC")
186 dev
[0].dump_monitor()
187 dev
[0].request("WPS_PBC")
188 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=30)
190 raise Exception("Association with the AP timed out")
191 networks
= dev
[0].list_networks()
192 if len(networks
) > 1:
193 raise Exception("Unexpected duplicated network block present")
195 def test_ap_wps_incorrect_pin(dev
, apdev
):
196 """WPS PIN provisioning with incorrect PIN"""
197 ssid
= "test-wps-incorrect-pin"
198 hostapd
.add_ap(apdev
[0]['ifname'],
199 { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
200 "wpa_passphrase": "12345678", "wpa": "2",
201 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"})
202 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
204 logger
.info("WPS provisioning attempt 1")
205 hapd
.request("WPS_PIN any 12345670")
206 dev
[0].dump_monitor()
207 dev
[0].request("WPS_PIN any 55554444")
208 ev
= dev
[0].wait_event(["WPS-FAIL"], timeout
=30)
210 raise Exception("WPS operation timed out")
211 if "config_error=18" not in ev
:
212 raise Exception("Incorrect config_error reported")
213 if "msg=8" not in ev
:
214 raise Exception("PIN error detected on incorrect message")
215 ev
= dev
[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
217 raise Exception("Timeout on disconnection event")
218 dev
[0].request("WPS_CANCEL")
219 # if a scan was in progress, wait for it to complete before trying WPS again
220 ev
= dev
[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], 5)
222 status
= hapd
.request("WPS_GET_STATUS")
223 if "Last WPS result: Failed" not in status
:
224 raise Exception("WPS failure result not shown correctly")
226 logger
.info("WPS provisioning attempt 2")
227 hapd
.request("WPS_PIN any 12345670")
228 dev
[0].dump_monitor()
229 dev
[0].request("WPS_PIN any 12344444")
230 ev
= dev
[0].wait_event(["WPS-FAIL"], timeout
=30)
232 raise Exception("WPS operation timed out")
233 if "config_error=18" not in ev
:
234 raise Exception("Incorrect config_error reported")
235 if "msg=10" not in ev
:
236 raise Exception("PIN error detected on incorrect message")
237 ev
= dev
[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
239 raise Exception("Timeout on disconnection event")
241 def test_ap_wps_conf_pin(dev
, apdev
):
242 """WPS PIN provisioning with configured AP"""
243 ssid
= "test-wps-conf-pin"
244 hostapd
.add_ap(apdev
[0]['ifname'],
245 { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
246 "wpa_passphrase": "12345678", "wpa": "2",
247 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"})
248 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
249 logger
.info("WPS provisioning step")
250 pin
= dev
[0].wps_read_pin()
251 hapd
.request("WPS_PIN any " + pin
)
252 dev
[0].dump_monitor()
253 dev
[0].request("WPS_PIN any " + pin
)
254 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=30)
256 raise Exception("Association with the AP timed out")
257 status
= dev
[0].get_status()
258 if status
['wpa_state'] != 'COMPLETED' or status
['bssid'] != apdev
[0]['bssid']:
259 raise Exception("Not fully connected")
260 if status
['ssid'] != ssid
:
261 raise Exception("Unexpected SSID")
262 if status
['pairwise_cipher'] != 'CCMP' or status
['group_cipher'] != 'CCMP':
263 raise Exception("Unexpected encryption configuration")
264 if status
['key_mgmt'] != 'WPA2-PSK':
265 raise Exception("Unexpected key_mgmt")
267 dev
[1].scan(freq
="2412")
268 bss
= dev
[1].get_bss(apdev
[0]['bssid'])
269 if "[WPS-AUTH]" in bss
['flags']:
270 raise Exception("WPS-AUTH flag not cleared")
271 logger
.info("Try to connect from another station using the same PIN")
272 dev
[1].request("WPS_PIN any " + pin
)
273 ev
= dev
[1].wait_event(["WPS-M2D","CTRL-EVENT-CONNECTED"], timeout
=30)
275 raise Exception("Operation timed out")
276 if "WPS-M2D" not in ev
:
277 raise Exception("Unexpected WPS operation started")
279 def test_ap_wps_conf_pin_2sta(dev
, apdev
):
280 """Two stations trying to use WPS PIN at the same time"""
281 ssid
= "test-wps-conf-pin2"
282 hostapd
.add_ap(apdev
[0]['ifname'],
283 { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
284 "wpa_passphrase": "12345678", "wpa": "2",
285 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"})
286 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
287 logger
.info("WPS provisioning step")
290 hapd
.request("WPS_PIN " + dev
[0].get_status_field("uuid") + " " + pin
)
291 hapd
.request("WPS_PIN " + dev
[1].get_status_field("uuid") + " " + pin
)
292 dev
[0].dump_monitor()
293 dev
[1].dump_monitor()
294 dev
[0].request("WPS_PIN any " + pin
)
295 dev
[1].request("WPS_PIN any " + pin
)
296 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=30)
298 raise Exception("Association with the AP timed out")
299 ev
= dev
[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=30)
301 raise Exception("Association with the AP timed out")
303 def test_ap_wps_reg_connect(dev
, apdev
):
304 """WPS registrar using AP PIN to connect"""
305 ssid
= "test-wps-reg-ap-pin"
307 hostapd
.add_ap(apdev
[0]['ifname'],
308 { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
309 "wpa_passphrase": "12345678", "wpa": "2",
310 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
312 logger
.info("WPS provisioning step")
313 dev
[0].dump_monitor()
314 dev
[0].wps_reg(apdev
[0]['bssid'], appin
)
315 status
= dev
[0].get_status()
316 if status
['wpa_state'] != 'COMPLETED' or status
['bssid'] != apdev
[0]['bssid']:
317 raise Exception("Not fully connected")
318 if status
['ssid'] != ssid
:
319 raise Exception("Unexpected SSID")
320 if status
['pairwise_cipher'] != 'CCMP' or status
['group_cipher'] != 'CCMP':
321 raise Exception("Unexpected encryption configuration")
322 if status
['key_mgmt'] != 'WPA2-PSK':
323 raise Exception("Unexpected key_mgmt")
325 def check_wps_reg_failure(dev
, ap
, appin
):
326 dev
.request("WPS_REG " + ap
['bssid'] + " " + appin
)
327 ev
= dev
.wait_event(["WPS-SUCCESS", "WPS-FAIL"], timeout
=15)
329 raise Exception("WPS operation timed out")
330 if "WPS-SUCCESS" in ev
:
331 raise Exception("WPS operation succeeded unexpectedly")
332 if "config_error=15" not in ev
:
333 raise Exception("WPS setup locked state was not reported correctly")
335 def test_ap_wps_random_ap_pin(dev
, apdev
):
336 """WPS registrar using random AP PIN"""
337 ssid
= "test-wps-reg-random-ap-pin"
338 ap_uuid
= "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"
339 hostapd
.add_ap(apdev
[0]['ifname'],
340 { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
341 "wpa_passphrase": "12345678", "wpa": "2",
342 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
343 "device_name": "Wireless AP", "manufacturer": "Company",
344 "model_name": "WAP", "model_number": "123",
345 "serial_number": "12345", "device_type": "6-0050F204-1",
346 "os_version": "01020300",
347 "config_methods": "label push_button",
348 "uuid": ap_uuid
, "upnp_iface": "lo" })
349 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
350 appin
= hapd
.request("WPS_AP_PIN random")
352 raise Exception("Could not generate random AP PIN")
353 if appin
not in hapd
.request("WPS_AP_PIN get"):
354 raise Exception("Could not fetch current AP PIN")
355 logger
.info("WPS provisioning step")
356 dev
[0].wps_reg(apdev
[0]['bssid'], appin
)
358 hapd
.request("WPS_AP_PIN disable")
359 logger
.info("WPS provisioning step with AP PIN disabled")
360 check_wps_reg_failure(dev
[1], apdev
[0], appin
)
362 logger
.info("WPS provisioning step with AP PIN reset")
364 hapd
.request("WPS_AP_PIN set " + appin
)
365 dev
[1].wps_reg(apdev
[0]['bssid'], appin
)
366 dev
[0].request("REMOVE_NETWORK all")
367 dev
[1].request("REMOVE_NETWORK all")
368 dev
[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
369 dev
[1].wait_event(["CTRL-EVENT-DISCONNECTED"])
371 logger
.info("WPS provisioning step after AP PIN timeout")
372 hapd
.request("WPS_AP_PIN disable")
373 appin
= hapd
.request("WPS_AP_PIN random 1")
375 if "FAIL" not in hapd
.request("WPS_AP_PIN get"):
376 raise Exception("AP PIN unexpectedly still enabled")
377 check_wps_reg_failure(dev
[0], apdev
[0], appin
)
379 logger
.info("WPS provisioning step after AP PIN timeout(2)")
380 hapd
.request("WPS_AP_PIN disable")
382 hapd
.request("WPS_AP_PIN set " + appin
+ " 1")
384 if "FAIL" not in hapd
.request("WPS_AP_PIN get"):
385 raise Exception("AP PIN unexpectedly still enabled")
386 check_wps_reg_failure(dev
[1], apdev
[0], appin
)
388 def test_ap_wps_reg_config(dev
, apdev
):
389 """WPS registrar configuring and AP using AP PIN"""
390 ssid
= "test-wps-init-ap-pin"
392 hostapd
.add_ap(apdev
[0]['ifname'],
393 { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
395 logger
.info("WPS configuration step")
396 dev
[0].dump_monitor()
397 new_ssid
= "wps-new-ssid"
398 new_passphrase
= "1234567890"
399 dev
[0].wps_reg(apdev
[0]['bssid'], appin
, new_ssid
, "WPA2PSK", "CCMP",
401 status
= dev
[0].get_status()
402 if status
['wpa_state'] != 'COMPLETED' or status
['bssid'] != apdev
[0]['bssid']:
403 raise Exception("Not fully connected")
404 if status
['ssid'] != new_ssid
:
405 raise Exception("Unexpected SSID")
406 if status
['pairwise_cipher'] != 'CCMP' or status
['group_cipher'] != 'CCMP':
407 raise Exception("Unexpected encryption configuration")
408 if status
['key_mgmt'] != 'WPA2-PSK':
409 raise Exception("Unexpected key_mgmt")
411 def test_ap_wps_reg_config_tkip(dev
, apdev
):
412 """WPS registrar configuring AP to use TKIP and AP upgrading to TKIP+CCMP"""
413 ssid
= "test-wps-init-ap"
415 hostapd
.add_ap(apdev
[0]['ifname'],
416 { "ssid": ssid
, "eap_server": "1", "wps_state": "1",
418 logger
.info("WPS configuration step")
419 dev
[0].request("SET wps_version_number 0x10")
420 dev
[0].dump_monitor()
421 new_ssid
= "wps-new-ssid-with-tkip"
422 new_passphrase
= "1234567890"
423 dev
[0].wps_reg(apdev
[0]['bssid'], appin
, new_ssid
, "WPAPSK", "TKIP",
425 logger
.info("Re-connect to verify WPA2 mixed mode")
426 dev
[0].request("DISCONNECT")
428 dev
[0].set_network(id, "pairwise", "CCMP")
429 dev
[0].set_network(id, "proto", "RSN")
430 dev
[0].connect_network(id)
431 status
= dev
[0].get_status()
432 if status
['wpa_state'] != 'COMPLETED' or status
['bssid'] != apdev
[0]['bssid']:
433 raise Exception("Not fully connected")
434 if status
['ssid'] != new_ssid
:
435 raise Exception("Unexpected SSID")
436 if status
['pairwise_cipher'] != 'CCMP' or status
['group_cipher'] != 'TKIP':
437 raise Exception("Unexpected encryption configuration")
438 if status
['key_mgmt'] != 'WPA2-PSK':
439 raise Exception("Unexpected key_mgmt")
441 def test_ap_wps_setup_locked(dev
, apdev
):
442 """WPS registrar locking up AP setup on AP PIN failures"""
443 ssid
= "test-wps-incorrect-ap-pin"
445 hostapd
.add_ap(apdev
[0]['ifname'],
446 { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
447 "wpa_passphrase": "12345678", "wpa": "2",
448 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
450 new_ssid
= "wps-new-ssid-test"
451 new_passphrase
= "1234567890"
453 ap_setup_locked
=False
454 for pin
in ["55554444", "1234", "12345678", "00000000", "11111111"]:
455 dev
[0].dump_monitor()
456 logger
.info("Try incorrect AP PIN - attempt " + pin
)
457 dev
[0].wps_reg(apdev
[0]['bssid'], pin
, new_ssid
, "WPA2PSK",
458 "CCMP", new_passphrase
, no_wait
=True)
459 ev
= dev
[0].wait_event(["WPS-FAIL", "CTRL-EVENT-CONNECTED"])
461 raise Exception("Timeout on receiving WPS operation failure event")
462 if "CTRL-EVENT-CONNECTED" in ev
:
463 raise Exception("Unexpected connection")
464 if "config_error=15" in ev
:
465 logger
.info("AP Setup Locked")
467 elif "config_error=18" not in ev
:
468 raise Exception("config_error=18 not reported")
469 ev
= dev
[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
471 raise Exception("Timeout on disconnection event")
473 if not ap_setup_locked
:
474 raise Exception("AP setup was not locked")
476 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
477 status
= hapd
.request("WPS_GET_STATUS")
478 if "Last WPS result: Failed" not in status
:
479 raise Exception("WPS failure result not shown correctly")
480 if "Peer Address: " + dev
[0].p2p_interface_addr() not in status
:
481 raise Exception("Peer address not shown correctly")
484 dev
[0].dump_monitor()
485 logger
.info("WPS provisioning step")
486 pin
= dev
[0].wps_read_pin()
487 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
488 hapd
.request("WPS_PIN any " + pin
)
489 dev
[0].request("WPS_PIN any " + pin
)
490 ev
= dev
[0].wait_event(["WPS-SUCCESS"], timeout
=30)
492 raise Exception("WPS success was not reported")
493 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=30)
495 raise Exception("Association with the AP timed out")
497 def test_ap_wps_pbc_overlap_2ap(dev
, apdev
):
498 """WPS PBC session overlap with two active APs"""
499 hostapd
.add_ap(apdev
[0]['ifname'],
500 { "ssid": "wps1", "eap_server": "1", "wps_state": "2",
501 "wpa_passphrase": "12345678", "wpa": "2",
502 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
503 "wps_independent": "1"})
504 hostapd
.add_ap(apdev
[1]['ifname'],
505 { "ssid": "wps2", "eap_server": "1", "wps_state": "2",
506 "wpa_passphrase": "123456789", "wpa": "2",
507 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
508 "wps_independent": "1"})
509 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
510 hapd
.request("WPS_PBC")
511 hapd2
= hostapd
.Hostapd(apdev
[1]['ifname'])
512 hapd2
.request("WPS_PBC")
513 logger
.info("WPS provisioning step")
514 dev
[0].dump_monitor()
515 dev
[0].request("WPS_PBC")
516 ev
= dev
[0].wait_event(["WPS-OVERLAP-DETECTED"], timeout
=15)
518 raise Exception("PBC session overlap not detected")
520 def test_ap_wps_pbc_overlap_2sta(dev
, apdev
):
521 """WPS PBC session overlap with two active STAs"""
522 ssid
= "test-wps-pbc-overlap"
523 hostapd
.add_ap(apdev
[0]['ifname'],
524 { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
525 "wpa_passphrase": "12345678", "wpa": "2",
526 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"})
527 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
528 logger
.info("WPS provisioning step")
529 hapd
.request("WPS_PBC")
530 dev
[0].dump_monitor()
531 dev
[1].dump_monitor()
532 dev
[0].request("WPS_PBC")
533 dev
[1].request("WPS_PBC")
534 ev
= dev
[0].wait_event(["WPS-M2D"], timeout
=15)
536 raise Exception("PBC session overlap not detected (dev0)")
537 if "config_error=12" not in ev
:
538 raise Exception("PBC session overlap not correctly reported (dev0)")
539 ev
= dev
[1].wait_event(["WPS-M2D"], timeout
=15)
541 raise Exception("PBC session overlap not detected (dev1)")
542 if "config_error=12" not in ev
:
543 raise Exception("PBC session overlap not correctly reported (dev1)")
544 hapd
.request("WPS_CANCEL")
545 ret
= hapd
.request("WPS_PBC")
546 if "FAIL" not in ret
:
547 raise Exception("PBC mode allowed to be started while PBC overlap still active")
549 def test_ap_wps_cancel(dev
, apdev
):
550 """WPS AP cancelling enabled config method"""
551 ssid
= "test-wps-ap-cancel"
552 hostapd
.add_ap(apdev
[0]['ifname'],
553 { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
554 "wpa_passphrase": "12345678", "wpa": "2",
555 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" })
556 bssid
= apdev
[0]['bssid']
557 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
559 logger
.info("Verify PBC enable/cancel")
560 hapd
.request("WPS_PBC")
561 dev
[0].scan(freq
="2412")
562 bss
= dev
[0].get_bss(apdev
[0]['bssid'])
563 if "[WPS-PBC]" not in bss
['flags']:
564 raise Exception("WPS-PBC flag missing")
565 if "FAIL" in hapd
.request("WPS_CANCEL"):
566 raise Exception("WPS_CANCEL failed")
567 dev
[0].scan(freq
="2412")
568 bss
= dev
[0].get_bss(apdev
[0]['bssid'])
569 if "[WPS-PBC]" in bss
['flags']:
570 raise Exception("WPS-PBC flag not cleared")
572 logger
.info("Verify PIN enable/cancel")
573 hapd
.request("WPS_PIN any 12345670")
574 dev
[0].scan(freq
="2412")
575 bss
= dev
[0].get_bss(apdev
[0]['bssid'])
576 if "[WPS-AUTH]" not in bss
['flags']:
577 raise Exception("WPS-AUTH flag missing")
578 if "FAIL" in hapd
.request("WPS_CANCEL"):
579 raise Exception("WPS_CANCEL failed")
580 dev
[0].scan(freq
="2412")
581 bss
= dev
[0].get_bss(apdev
[0]['bssid'])
582 if "[WPS-AUTH]" in bss
['flags']:
583 raise Exception("WPS-AUTH flag not cleared")
585 def test_ap_wps_er_add_enrollee(dev
, apdev
):
586 """WPS ER configuring AP and adding a new enrollee using PIN"""
587 ssid
= "wps-er-add-enrollee"
589 ap_uuid
= "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"
590 hostapd
.add_ap(apdev
[0]['ifname'],
591 { "ssid": ssid
, "eap_server": "1", "wps_state": "1",
592 "device_name": "Wireless AP", "manufacturer": "Company",
593 "model_name": "WAP", "model_number": "123",
594 "serial_number": "12345", "device_type": "6-0050F204-1",
595 "os_version": "01020300",
596 "config_methods": "label push_button",
597 "ap_pin": ap_pin
, "uuid": ap_uuid
, "upnp_iface": "lo"})
598 logger
.info("WPS configuration step")
599 new_passphrase
= "1234567890"
600 dev
[0].dump_monitor()
601 dev
[0].wps_reg(apdev
[0]['bssid'], ap_pin
, ssid
, "WPA2PSK", "CCMP",
603 status
= dev
[0].get_status()
604 if status
['wpa_state'] != 'COMPLETED' or status
['bssid'] != apdev
[0]['bssid']:
605 raise Exception("Not fully connected")
606 if status
['ssid'] != ssid
:
607 raise Exception("Unexpected SSID")
608 if status
['pairwise_cipher'] != 'CCMP' or status
['group_cipher'] != 'CCMP':
609 raise Exception("Unexpected encryption configuration")
610 if status
['key_mgmt'] != 'WPA2-PSK':
611 raise Exception("Unexpected key_mgmt")
613 logger
.info("Start ER")
614 dev
[0].request("WPS_ER_START ifname=lo")
615 ev
= dev
[0].wait_event(["WPS-ER-AP-ADD"], timeout
=15)
617 raise Exception("AP discovery timed out")
618 if ap_uuid
not in ev
:
619 raise Exception("Expected AP UUID not found")
621 logger
.info("Learn AP configuration through UPnP")
622 dev
[0].dump_monitor()
623 dev
[0].request("WPS_ER_LEARN " + ap_uuid
+ " " + ap_pin
)
624 ev
= dev
[0].wait_event(["WPS-ER-AP-SETTINGS"], timeout
=15)
626 raise Exception("AP learn timed out")
627 if ap_uuid
not in ev
:
628 raise Exception("Expected AP UUID not in settings")
629 if "ssid=" + ssid
not in ev
:
630 raise Exception("Expected SSID not in settings")
631 if "key=" + new_passphrase
not in ev
:
632 raise Exception("Expected passphrase not in settings")
634 logger
.info("Add Enrollee using ER")
635 pin
= dev
[1].wps_read_pin()
636 dev
[0].dump_monitor()
637 dev
[0].request("WPS_ER_PIN any " + pin
+ " " + dev
[1].p2p_interface_addr())
638 dev
[1].dump_monitor()
639 dev
[1].request("WPS_PIN any " + pin
)
640 ev
= dev
[1].wait_event(["WPS-SUCCESS"], timeout
=30)
642 raise Exception("Enrollee did not report success")
643 ev
= dev
[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=15)
645 raise Exception("Association with the AP timed out")
646 ev
= dev
[0].wait_event(["WPS-SUCCESS"], timeout
=15)
648 raise Exception("WPS ER did not report success")
649 hwsim_utils
.test_connectivity_sta(dev
[0], dev
[1])
651 logger
.info("Add a specific Enrollee using ER")
652 pin
= dev
[2].wps_read_pin()
653 addr2
= dev
[2].p2p_interface_addr()
654 dev
[0].dump_monitor()
655 dev
[2].dump_monitor()
656 dev
[2].request("WPS_PIN any " + pin
)
657 ev
= dev
[0].wait_event(["WPS-ER-ENROLLEE-ADD"], timeout
=10)
659 raise Exception("Enrollee not seen")
661 raise Exception("Unexpected Enrollee MAC address")
662 dev
[0].request("WPS_ER_PIN " + addr2
+ " " + pin
+ " " + addr2
)
663 ev
= dev
[2].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=15)
665 raise Exception("Association with the AP timed out")
666 ev
= dev
[0].wait_event(["WPS-SUCCESS"], timeout
=15)
668 raise Exception("WPS ER did not report success")
670 logger
.info("Verify registrar selection behavior")
671 dev
[0].request("WPS_ER_PIN any " + pin
+ " " + dev
[1].p2p_interface_addr())
672 dev
[1].request("DISCONNECT")
673 dev
[1].wait_event(["CTRL-EVENT-DISCONNECTED"])
674 dev
[1].scan(freq
="2412")
675 bss
= dev
[1].get_bss(apdev
[0]['bssid'])
676 if "[WPS-AUTH]" not in bss
['flags']:
677 raise Exception("WPS-AUTH flag missing")
679 logger
.info("Stop ER")
680 dev
[0].dump_monitor()
681 dev
[0].request("WPS_ER_STOP")
682 ev
= dev
[0].wait_event(["WPS-ER-AP-REMOVE"])
684 raise Exception("WPS ER unsubscription timed out")
685 # It takes some time for the UPnP UNSUBSCRIBE command to go through, so wait
686 # a bit before verifying that the scan results have change.
689 dev
[1].scan(freq
="2412")
690 bss
= dev
[1].get_bss(apdev
[0]['bssid'])
691 if "[WPS-AUTH]" in bss
['flags']:
692 raise Exception("WPS-AUTH flag not removed")
694 def test_ap_wps_er_add_enrollee_pbc(dev
, apdev
):
695 """WPS ER connected to AP and adding a new enrollee using PBC"""
696 ssid
= "wps-er-add-enrollee-pbc"
698 ap_uuid
= "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"
699 hostapd
.add_ap(apdev
[0]['ifname'],
700 { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
701 "wpa_passphrase": "12345678", "wpa": "2",
702 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
703 "device_name": "Wireless AP", "manufacturer": "Company",
704 "model_name": "WAP", "model_number": "123",
705 "serial_number": "12345", "device_type": "6-0050F204-1",
706 "os_version": "01020300",
707 "config_methods": "label push_button",
708 "ap_pin": ap_pin
, "uuid": ap_uuid
, "upnp_iface": "lo"})
709 logger
.info("Learn AP configuration")
710 dev
[0].dump_monitor()
711 dev
[0].wps_reg(apdev
[0]['bssid'], ap_pin
)
712 status
= dev
[0].get_status()
713 if status
['wpa_state'] != 'COMPLETED' or status
['bssid'] != apdev
[0]['bssid']:
714 raise Exception("Not fully connected")
716 logger
.info("Start ER")
717 dev
[0].request("WPS_ER_START ifname=lo")
718 ev
= dev
[0].wait_event(["WPS-ER-AP-ADD"], timeout
=15)
720 raise Exception("AP discovery timed out")
721 if ap_uuid
not in ev
:
722 raise Exception("Expected AP UUID not found")
724 logger
.info("Use learned network configuration on ER")
725 dev
[0].request("WPS_ER_SET_CONFIG " + ap_uuid
+ " 0")
727 logger
.info("Add Enrollee using ER and PBC")
728 dev
[0].dump_monitor()
729 enrollee
= dev
[1].p2p_interface_addr()
730 dev
[1].dump_monitor()
731 dev
[1].request("WPS_PBC")
733 for i
in range(0, 2):
734 ev
= dev
[0].wait_event(["WPS-ER-ENROLLEE-ADD"], timeout
=15)
736 raise Exception("Enrollee discovery timed out")
740 raise Exception("Expected Enrollee not found")
741 dev
[0].request("WPS_ER_PBC " + enrollee
)
743 ev
= dev
[1].wait_event(["WPS-SUCCESS"], timeout
=15)
745 raise Exception("Enrollee did not report success")
746 ev
= dev
[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=15)
748 raise Exception("Association with the AP timed out")
749 ev
= dev
[0].wait_event(["WPS-SUCCESS"], timeout
=15)
751 raise Exception("WPS ER did not report success")
752 hwsim_utils
.test_connectivity_sta(dev
[0], dev
[1])
754 # verify BSSID selection of the AP instead of UUID
755 if "FAIL" in dev
[0].request("WPS_ER_SET_CONFIG " + apdev
[0]['bssid'] + " 0"):
756 raise Exception("Could not select AP based on BSSID")
758 def test_ap_wps_er_v10_add_enrollee_pin(dev
, apdev
):
759 """WPS v1.0 ER connected to AP and adding a new enrollee using PIN"""
760 ssid
= "wps-er-add-enrollee-pbc"
762 ap_uuid
= "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"
763 hostapd
.add_ap(apdev
[0]['ifname'],
764 { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
765 "wpa_passphrase": "12345678", "wpa": "2",
766 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
767 "device_name": "Wireless AP", "manufacturer": "Company",
768 "model_name": "WAP", "model_number": "123",
769 "serial_number": "12345", "device_type": "6-0050F204-1",
770 "os_version": "01020300",
771 "config_methods": "label push_button",
772 "ap_pin": ap_pin
, "uuid": ap_uuid
, "upnp_iface": "lo"})
773 logger
.info("Learn AP configuration")
774 dev
[0].request("SET wps_version_number 0x10")
775 dev
[0].dump_monitor()
776 dev
[0].wps_reg(apdev
[0]['bssid'], ap_pin
)
777 status
= dev
[0].get_status()
778 if status
['wpa_state'] != 'COMPLETED' or status
['bssid'] != apdev
[0]['bssid']:
779 raise Exception("Not fully connected")
781 logger
.info("Start ER")
782 dev
[0].request("WPS_ER_START ifname=lo")
783 ev
= dev
[0].wait_event(["WPS-ER-AP-ADD"], timeout
=15)
785 raise Exception("AP discovery timed out")
786 if ap_uuid
not in ev
:
787 raise Exception("Expected AP UUID not found")
789 logger
.info("Use learned network configuration on ER")
790 dev
[0].request("WPS_ER_SET_CONFIG " + ap_uuid
+ " 0")
792 logger
.info("Add Enrollee using ER and PIN")
793 enrollee
= dev
[1].p2p_interface_addr()
794 pin
= dev
[1].wps_read_pin()
795 dev
[0].dump_monitor()
796 dev
[0].request("WPS_ER_PIN any " + pin
+ " " + enrollee
)
797 dev
[1].dump_monitor()
798 dev
[1].request("WPS_PIN any " + pin
)
799 ev
= dev
[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=15)
801 raise Exception("Association with the AP timed out")
802 ev
= dev
[0].wait_event(["WPS-SUCCESS"], timeout
=15)
804 raise Exception("WPS ER did not report success")
806 def test_ap_wps_er_config_ap(dev
, apdev
):
807 """WPS ER configuring AP over UPnP"""
808 ssid
= "wps-er-ap-config"
810 ap_uuid
= "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"
811 hostapd
.add_ap(apdev
[0]['ifname'],
812 { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
813 "wpa_passphrase": "12345678", "wpa": "2",
814 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
815 "device_name": "Wireless AP", "manufacturer": "Company",
816 "model_name": "WAP", "model_number": "123",
817 "serial_number": "12345", "device_type": "6-0050F204-1",
818 "os_version": "01020300",
819 "config_methods": "label push_button",
820 "ap_pin": ap_pin
, "uuid": ap_uuid
, "upnp_iface": "lo"})
822 logger
.info("Connect ER to the AP")
823 dev
[0].connect(ssid
, psk
="12345678", scan_freq
="2412")
825 logger
.info("WPS configuration step")
826 dev
[0].request("WPS_ER_START ifname=lo")
827 ev
= dev
[0].wait_event(["WPS-ER-AP-ADD"], timeout
=15)
829 raise Exception("AP discovery timed out")
830 if ap_uuid
not in ev
:
831 raise Exception("Expected AP UUID not found")
832 new_passphrase
= "1234567890"
833 dev
[0].request("WPS_ER_CONFIG " + apdev
[0]['bssid'] + " " + ap_pin
+ " " +
834 ssid
.encode("hex") + " WPA2PSK CCMP " +
835 new_passphrase
.encode("hex"))
836 ev
= dev
[0].wait_event(["WPS-SUCCESS"])
838 raise Exception("WPS ER configuration operation timed out")
839 dev
[1].wait_event(["CTRL-EVENT-DISCONNECTED"])
840 dev
[0].connect(ssid
, psk
="1234567890", scan_freq
="2412")
842 def test_ap_wps_fragmentation(dev
, apdev
):
843 """WPS with fragmentation in EAP-WSC and mixed mode WPA+WPA2"""
844 ssid
= "test-wps-fragmentation"
845 hostapd
.add_ap(apdev
[0]['ifname'],
846 { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
847 "wpa_passphrase": "12345678", "wpa": "3",
848 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
849 "wpa_pairwise": "TKIP",
850 "fragment_size": "50" })
851 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
852 logger
.info("WPS provisioning step")
853 hapd
.request("WPS_PBC")
854 dev
[0].dump_monitor()
855 dev
[0].request("SET wps_fragment_size 50")
856 dev
[0].request("WPS_PBC")
857 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=30)
859 raise Exception("Association with the AP timed out")
860 status
= dev
[0].get_status()
861 if status
['wpa_state'] != 'COMPLETED':
862 raise Exception("Not fully connected")
863 if status
['pairwise_cipher'] != 'CCMP' or status
['group_cipher'] != 'TKIP':
864 raise Exception("Unexpected encryption configuration")
865 if status
['key_mgmt'] != 'WPA2-PSK':
866 raise Exception("Unexpected key_mgmt")
868 def test_ap_wps_new_version_sta(dev
, apdev
):
869 """WPS compatibility with new version number on the station"""
870 ssid
= "test-wps-ver"
871 hostapd
.add_ap(apdev
[0]['ifname'],
872 { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
873 "wpa_passphrase": "12345678", "wpa": "2",
874 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" })
875 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
876 logger
.info("WPS provisioning step")
877 hapd
.request("WPS_PBC")
878 dev
[0].dump_monitor()
879 dev
[0].request("SET wps_version_number 0x43")
880 dev
[0].request("SET wps_vendor_ext_m1 000137100100020001")
881 dev
[0].request("WPS_PBC")
882 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=30)
884 raise Exception("Association with the AP timed out")
886 def test_ap_wps_new_version_ap(dev
, apdev
):
887 """WPS compatibility with new version number on the AP"""
888 ssid
= "test-wps-ver"
889 hostapd
.add_ap(apdev
[0]['ifname'],
890 { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
891 "wpa_passphrase": "12345678", "wpa": "2",
892 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" })
893 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
894 logger
.info("WPS provisioning step")
895 if "FAIL" in hapd
.request("SET wps_version_number 0x43"):
896 raise Exception("Failed to enable test functionality")
897 hapd
.request("WPS_PBC")
898 dev
[0].dump_monitor()
899 dev
[0].request("WPS_PBC")
900 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=30)
901 hapd
.request("SET wps_version_number 0x20")
903 raise Exception("Association with the AP timed out")
905 def test_ap_wps_check_pin(dev
, apdev
):
906 """Verify PIN checking through control interface"""
907 hostapd
.add_ap(apdev
[0]['ifname'],
908 { "ssid": "wps", "eap_server": "1", "wps_state": "2",
909 "wpa_passphrase": "12345678", "wpa": "2",
910 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" })
911 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
912 for t
in [ ("12345670", "12345670"),
913 ("12345678", "FAIL-CHECKSUM"),
914 ("1234-5670", "12345670"),
915 ("1234 5670", "12345670"),
916 ("1-2.3:4 5670", "12345670") ]:
917 res
= hapd
.request("WPS_CHECK_PIN " + t
[0]).rstrip('\n')
918 res2
= dev
[0].request("WPS_CHECK_PIN " + t
[0]).rstrip('\n')
920 raise Exception("Unexpected difference in WPS_CHECK_PIN responses")
922 raise Exception("Incorrect WPS_CHECK_PIN response {} (expected {})".format(res
, t
[1]))
924 def test_ap_wps_wep_config(dev
, apdev
):
925 """WPS 2.0 AP rejecting WEP configuration"""
926 ssid
= "test-wps-config"
928 hostapd
.add_ap(apdev
[0]['ifname'],
929 { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
931 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
932 dev
[0].wps_reg(apdev
[0]['bssid'], appin
, "wps-new-ssid-wep", "OPEN", "WEP",
933 "hello", no_wait
=True)
934 ev
= hapd
.wait_event(["WPS-FAIL"], timeout
=15)
936 raise Exception("WPS-FAIL timed out")
937 if "reason=2" not in ev
:
938 raise Exception("Unexpected reason code in WPS-FAIL")
939 status
= hapd
.request("WPS_GET_STATUS")
940 if "Last WPS result: Failed" not in status
:
941 raise Exception("WPS failure result not shown correctly")
942 if "Failure Reason: WEP Prohibited" not in status
:
943 raise Exception("Failure reason not reported correctly")
944 if "Peer Address: " + dev
[0].p2p_interface_addr() not in status
:
945 raise Exception("Peer address not shown correctly")
947 def test_ap_wps_ie_fragmentation(dev
, apdev
):
948 """WPS AP using fragmented WPS IE"""
949 ssid
= "test-wps-ie-fragmentation"
950 params
= { "ssid": ssid
, "eap_server": "1", "wps_state": "2",
951 "wpa_passphrase": "12345678", "wpa": "2",
952 "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
953 "device_name": "1234567890abcdef1234567890abcdef",
954 "manufacturer": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
955 "model_name": "1234567890abcdef1234567890abcdef",
956 "model_number": "1234567890abcdef1234567890abcdef",
957 "serial_number": "1234567890abcdef1234567890abcdef" }
958 hostapd
.add_ap(apdev
[0]['ifname'], params
)
959 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
960 hapd
.request("WPS_PBC")
961 dev
[0].request("WPS_PBC")
962 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=30)
964 raise Exception("Association with the AP timed out")
965 bss
= dev
[0].get_bss(apdev
[0]['bssid'])
966 if "wps_device_name" not in bss
or bss
['wps_device_name'] != "1234567890abcdef1234567890abcdef":
967 raise Exception("Device Name not received correctly")
968 if len(re
.findall("dd..0050f204", bss
['ie'])) != 2:
969 raise Exception("Unexpected number of WPS IEs")