tests: Pass full apdev to add_ap() function (1)
[mech_eap.git] / tests / hwsim / test_ap_open.py
1 # Open mode AP tests
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 import logging
8 logger = logging.getLogger()
9 import struct
10 import subprocess
11 import time
12 import os
13
14 import hostapd
15 import hwsim_utils
16 from tshark import run_tshark
17 from utils import alloc_fail
18 from wpasupplicant import WpaSupplicant
19
20 def test_ap_open(dev, apdev):
21     """AP with open mode (no security) configuration"""
22     _test_ap_open(dev, apdev)
23
24 def _test_ap_open(dev, apdev):
25     hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
26     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412",
27                    bg_scan_period="0")
28     ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5)
29     if ev is None:
30         raise Exception("No connection event received from hostapd")
31     hwsim_utils.test_connectivity(dev[0], hapd)
32
33     dev[0].request("DISCONNECT")
34     ev = hapd.wait_event([ "AP-STA-DISCONNECTED" ], timeout=5)
35     if ev is None:
36         raise Exception("No disconnection event received from hostapd")
37
38 def test_ap_open_packet_loss(dev, apdev):
39     """AP with open mode configuration and large packet loss"""
40     params = { "ssid": "open",
41                "ignore_probe_probability": "0.5",
42                "ignore_auth_probability": "0.5",
43                "ignore_assoc_probability": "0.5",
44                "ignore_reassoc_probability": "0.5" }
45     hapd = hostapd.add_ap(apdev[0], params)
46     for i in range(0, 3):
47         dev[i].connect("open", key_mgmt="NONE", scan_freq="2412",
48                        wait_connect=False)
49     for i in range(0, 3):
50         dev[i].wait_connected(timeout=20)
51
52 def test_ap_open_unknown_action(dev, apdev):
53     """AP with open mode configuration and unknown Action frame"""
54     hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
55     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
56     bssid = apdev[0]['bssid']
57     cmd = "MGMT_TX {} {} freq=2412 action=765432".format(bssid, bssid)
58     if "FAIL" in dev[0].request(cmd):
59         raise Exception("Could not send test Action frame")
60     ev = dev[0].wait_event(["MGMT-TX-STATUS"], timeout=10)
61     if ev is None:
62         raise Exception("Timeout on MGMT-TX-STATUS")
63     if "result=SUCCESS" not in ev:
64         raise Exception("AP did not ack Action frame")
65
66 def test_ap_open_invalid_wmm_action(dev, apdev):
67     """AP with open mode configuration and invalid WMM Action frame"""
68     hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
69     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
70     bssid = apdev[0]['bssid']
71     cmd = "MGMT_TX {} {} freq=2412 action=1100".format(bssid, bssid)
72     if "FAIL" in dev[0].request(cmd):
73         raise Exception("Could not send test Action frame")
74     ev = dev[0].wait_event(["MGMT-TX-STATUS"], timeout=10)
75     if ev is None or "result=SUCCESS" not in ev:
76         raise Exception("AP did not ack Action frame")
77
78 def test_ap_open_reconnect_on_inactivity_disconnect(dev, apdev):
79     """Reconnect to open mode AP after inactivity related disconnection"""
80     hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
81     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
82     hapd.request("DEAUTHENTICATE " + dev[0].p2p_interface_addr() + " reason=4")
83     dev[0].wait_disconnected(timeout=5)
84     dev[0].wait_connected(timeout=2, error="Timeout on reconnection")
85
86 def test_ap_open_assoc_timeout(dev, apdev):
87     """AP timing out association"""
88     ssid = "test"
89     hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
90     dev[0].scan(freq="2412")
91     hapd.set("ext_mgmt_frame_handling", "1")
92     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412",
93                    wait_connect=False)
94     for i in range(0, 10):
95         req = hapd.mgmt_rx()
96         if req is None:
97             raise Exception("MGMT RX wait timed out")
98         if req['subtype'] == 11:
99             break
100         req = None
101     if not req:
102         raise Exception("Authentication frame not received")
103
104     resp = {}
105     resp['fc'] = req['fc']
106     resp['da'] = req['sa']
107     resp['sa'] = req['da']
108     resp['bssid'] = req['bssid']
109     resp['payload'] = struct.pack('<HHH', 0, 2, 0)
110     hapd.mgmt_tx(resp)
111
112     assoc = 0
113     for i in range(0, 10):
114         req = hapd.mgmt_rx()
115         if req is None:
116             raise Exception("MGMT RX wait timed out")
117         if req['subtype'] == 0:
118             assoc += 1
119             if assoc == 3:
120                 break
121     if assoc != 3:
122         raise Exception("Association Request frames not received: assoc=%d" % assoc)
123     hapd.set("ext_mgmt_frame_handling", "0")
124     dev[0].wait_connected(timeout=15)
125
126 def test_ap_open_id_str(dev, apdev):
127     """AP with open mode and id_str"""
128     hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
129     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", id_str="foo",
130                    wait_connect=False)
131     ev = dev[0].wait_connected(timeout=10)
132     if "id_str=foo" not in ev:
133         raise Exception("CTRL-EVENT-CONNECT did not have matching id_str: " + ev)
134     if dev[0].get_status_field("id_str") != "foo":
135         raise Exception("id_str mismatch")
136
137 def test_ap_open_select_any(dev, apdev):
138     """AP with open mode and select any network"""
139     hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
140     id = dev[0].connect("unknown", key_mgmt="NONE", scan_freq="2412",
141                         only_add_network=True)
142     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412",
143                    only_add_network=True)
144     dev[0].select_network(id)
145     ev = dev[0].wait_event(["CTRL-EVENT-NETWORK-NOT-FOUND",
146                             "CTRL-EVENT-CONNECTED"], timeout=10)
147     if ev is None:
148         raise Exception("No result reported")
149     if "CTRL-EVENT-CONNECTED" in ev:
150         raise Exception("Unexpected connection")
151
152     dev[0].select_network("any")
153     dev[0].wait_connected(timeout=10)
154
155 def test_ap_open_unexpected_assoc_event(dev, apdev):
156     """AP with open mode and unexpected association event"""
157     hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
158     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
159     dev[0].request("DISCONNECT")
160     dev[0].wait_disconnected(timeout=15)
161     dev[0].dump_monitor()
162     # This will be accepted due to matching network
163     subprocess.call(['iw', 'dev', dev[0].ifname, 'connect', 'open', "2412",
164                      apdev[0]['bssid']])
165     dev[0].wait_connected(timeout=15)
166     dev[0].dump_monitor()
167
168     dev[0].request("REMOVE_NETWORK all")
169     dev[0].wait_disconnected(timeout=5)
170     dev[0].dump_monitor()
171     # This will result in disconnection due to no matching network
172     subprocess.call(['iw', 'dev', dev[0].ifname, 'connect', 'open', "2412",
173                      apdev[0]['bssid']])
174     dev[0].wait_disconnected(timeout=15)
175
176 def test_ap_bss_load(dev, apdev):
177     """AP with open mode (no security) configuration"""
178     hapd = hostapd.add_ap(apdev[0],
179                           { "ssid": "open",
180                             "bss_load_update_period": "10" })
181     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
182     # this does not really get much useful output with mac80211_hwsim currently,
183     # but run through the channel survey update couple of times
184     for i in range(0, 10):
185         hwsim_utils.test_connectivity(dev[0], hapd)
186         hwsim_utils.test_connectivity(dev[0], hapd)
187         hwsim_utils.test_connectivity(dev[0], hapd)
188         time.sleep(0.15)
189
190 def hapd_out_of_mem(hapd, apdev, count, func):
191     with alloc_fail(hapd, count, func):
192         started = False
193         try:
194             hostapd.add_ap(apdev['ifname'], { "ssid": "open" })
195             started = True
196         except:
197             pass
198         if started:
199             raise Exception("hostapd interface started even with memory allocation failure: %d:%s" % (count, func))
200
201 def test_ap_open_out_of_memory(dev, apdev):
202     """hostapd failing to setup interface due to allocation failure"""
203     hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
204     hapd_out_of_mem(hapd, apdev[1], 1, "hostapd_alloc_bss_data")
205
206     for i in range(1, 3):
207         hapd_out_of_mem(hapd, apdev[1], i, "hostapd_iface_alloc")
208
209     for i in range(1, 5):
210         hapd_out_of_mem(hapd, apdev[1], i, "hostapd_config_defaults;hostapd_config_alloc")
211
212     hapd_out_of_mem(hapd, apdev[1], 1, "hostapd_config_alloc")
213
214     hapd_out_of_mem(hapd, apdev[1], 1, "hostapd_driver_init")
215
216     for i in range(1, 3):
217         hapd_out_of_mem(hapd, apdev[1], i, "=wpa_driver_nl80211_drv_init")
218
219     # eloop_register_read_sock() call from i802_init()
220     hapd_out_of_mem(hapd, apdev[1], 1, "eloop_sock_table_add_sock;?eloop_register_sock;?eloop_register_read_sock;=i802_init")
221
222     # verify that a new interface can still be added when memory allocation does
223     # not fail
224     hostapd.add_ap(apdev[1], { "ssid": "open" })
225
226 def test_bssid_black_white_list(dev, apdev):
227     """BSSID black/white list"""
228     hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
229     hapd2 = hostapd.add_ap(apdev[1], { "ssid": "open" })
230
231     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412",
232                    bssid_whitelist=apdev[1]['bssid'])
233     dev[1].connect("open", key_mgmt="NONE", scan_freq="2412",
234                    bssid_blacklist=apdev[1]['bssid'])
235     dev[2].connect("open", key_mgmt="NONE", scan_freq="2412",
236                    bssid_whitelist="00:00:00:00:00:00/00:00:00:00:00:00",
237                    bssid_blacklist=apdev[1]['bssid'])
238     if dev[0].get_status_field('bssid') != apdev[1]['bssid']:
239         raise Exception("dev[0] connected to unexpected AP")
240     if dev[1].get_status_field('bssid') != apdev[0]['bssid']:
241         raise Exception("dev[1] connected to unexpected AP")
242     if dev[2].get_status_field('bssid') != apdev[0]['bssid']:
243         raise Exception("dev[2] connected to unexpected AP")
244     dev[0].request("REMOVE_NETWORK all")
245     dev[1].request("REMOVE_NETWORK all")
246     dev[2].request("REMOVE_NETWORK all")
247
248     dev[2].connect("open", key_mgmt="NONE", scan_freq="2412",
249                    bssid_whitelist="00:00:00:00:00:00", wait_connect=False)
250     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412",
251                    bssid_whitelist="11:22:33:44:55:66/ff:00:00:00:00:00 " + apdev[1]['bssid'] + " aa:bb:cc:dd:ee:ff")
252     dev[1].connect("open", key_mgmt="NONE", scan_freq="2412",
253                    bssid_blacklist="11:22:33:44:55:66/ff:00:00:00:00:00 " + apdev[1]['bssid'] + " aa:bb:cc:dd:ee:ff")
254     if dev[0].get_status_field('bssid') != apdev[1]['bssid']:
255         raise Exception("dev[0] connected to unexpected AP")
256     if dev[1].get_status_field('bssid') != apdev[0]['bssid']:
257         raise Exception("dev[1] connected to unexpected AP")
258     dev[0].request("REMOVE_NETWORK all")
259     dev[1].request("REMOVE_NETWORK all")
260     ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED"], timeout=0.1)
261     if ev is not None:
262         raise Exception("Unexpected dev[2] connectin")
263     dev[2].request("REMOVE_NETWORK all")
264
265 def test_ap_open_wpas_in_bridge(dev, apdev):
266     """Open mode AP and wpas interface in a bridge"""
267     br_ifname='sta-br0'
268     ifname='wlan5'
269     try:
270         _test_ap_open_wpas_in_bridge(dev, apdev)
271     finally:
272         subprocess.call(['ip', 'link', 'set', 'dev', br_ifname, 'down'])
273         subprocess.call(['brctl', 'delif', br_ifname, ifname])
274         subprocess.call(['brctl', 'delbr', br_ifname])
275         subprocess.call(['iw', ifname, 'set', '4addr', 'off'])
276
277 def _test_ap_open_wpas_in_bridge(dev, apdev):
278     hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
279
280     br_ifname='sta-br0'
281     ifname='wlan5'
282     wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
283     # First, try a failure case of adding an interface
284     try:
285         wpas.interface_add(ifname, br_ifname=br_ifname)
286         raise Exception("Interface addition succeeded unexpectedly")
287     except Exception, e:
288         if "Failed to add" in str(e):
289             logger.info("Ignore expected interface_add failure due to missing bridge interface: " + str(e))
290         else:
291             raise
292
293     # Next, add the bridge interface and add the interface again
294     subprocess.call(['brctl', 'addbr', br_ifname])
295     subprocess.call(['brctl', 'setfd', br_ifname, '0'])
296     subprocess.call(['ip', 'link', 'set', 'dev', br_ifname, 'up'])
297     subprocess.call(['iw', ifname, 'set', '4addr', 'on'])
298     subprocess.check_call(['brctl', 'addif', br_ifname, ifname])
299     wpas.interface_add(ifname, br_ifname=br_ifname)
300
301     wpas.connect("open", key_mgmt="NONE", scan_freq="2412")
302
303 def test_ap_open_start_disabled(dev, apdev):
304     """AP with open mode and beaconing disabled"""
305     hapd = hostapd.add_ap(apdev[0], { "ssid": "open",
306                                       "start_disabled": "1" })
307     bssid = apdev[0]['bssid']
308
309     dev[0].flush_scan_cache()
310     dev[0].scan(freq=2412, only_new=True)
311     if dev[0].get_bss(bssid) is not None:
312         raise Exception("AP was seen beaconing")
313     if "OK" not in hapd.request("RELOAD"):
314         raise Exception("RELOAD failed")
315     dev[0].scan_for_bss(bssid, freq=2412)
316     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
317
318 def test_ap_open_start_disabled2(dev, apdev):
319     """AP with open mode and beaconing disabled (2)"""
320     hapd = hostapd.add_ap(apdev[0], { "ssid": "open",
321                                       "start_disabled": "1" })
322     bssid = apdev[0]['bssid']
323
324     dev[0].flush_scan_cache()
325     dev[0].scan(freq=2412, only_new=True)
326     if dev[0].get_bss(bssid) is not None:
327         raise Exception("AP was seen beaconing")
328     if "OK" not in hapd.request("UPDATE_BEACON"):
329         raise Exception("UPDATE_BEACON failed")
330     dev[0].scan_for_bss(bssid, freq=2412)
331     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
332     if "OK" not in hapd.request("UPDATE_BEACON"):
333         raise Exception("UPDATE_BEACON failed")
334     dev[0].request("DISCONNECT")
335     dev[0].wait_disconnected()
336     dev[0].request("RECONNECT")
337     dev[0].wait_connected()
338
339 def test_ap_open_ifdown(dev, apdev):
340     """AP with open mode and external ifconfig down"""
341     params = { "ssid": "open",
342                "ap_max_inactivity": "1" }
343     hapd = hostapd.add_ap(apdev[0], params)
344     bssid = apdev[0]['bssid']
345
346     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
347     dev[1].connect("open", key_mgmt="NONE", scan_freq="2412")
348     subprocess.call(['ip', 'link', 'set', 'dev', apdev[0]['ifname'], 'down'])
349     ev = hapd.wait_event(["AP-STA-DISCONNECTED"], timeout=10)
350     if ev is None:
351         raise Exception("Timeout on AP-STA-DISCONNECTED (1)")
352     ev = hapd.wait_event(["AP-STA-DISCONNECTED"], timeout=5)
353     if ev is None:
354         raise Exception("Timeout on AP-STA-DISCONNECTED (2)")
355     ev = hapd.wait_event(["INTERFACE-DISABLED"], timeout=5)
356     if ev is None:
357         raise Exception("No INTERFACE-DISABLED event")
358     # The following wait tests beacon loss detection in mac80211 on dev0.
359     # dev1 is used to test stopping of AP side functionality on client polling.
360     dev[1].request("REMOVE_NETWORK all")
361     subprocess.call(['ip', 'link', 'set', 'dev', apdev[0]['ifname'], 'up'])
362     dev[0].wait_disconnected()
363     dev[1].wait_disconnected()
364     ev = hapd.wait_event(["INTERFACE-ENABLED"], timeout=10)
365     if ev is None:
366         raise Exception("No INTERFACE-ENABLED event")
367     dev[0].wait_connected()
368     hwsim_utils.test_connectivity(dev[0], hapd)
369
370 def test_ap_open_disconnect_in_ps(dev, apdev, params):
371     """Disconnect with the client in PS to regression-test a kernel bug"""
372     hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
373     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412",
374                    bg_scan_period="0")
375     ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5)
376     if ev is None:
377         raise Exception("No connection event received from hostapd")
378
379     time.sleep(0.2)
380     hwsim_utils.set_powersave(dev[0], hwsim_utils.PS_MANUAL_POLL)
381     try:
382         # inject some traffic
383         sa = hapd.own_addr()
384         da = dev[0].own_addr()
385         hapd.request('DATA_TEST_CONFIG 1')
386         hapd.request('DATA_TEST_TX {} {} 0'.format(da, sa))
387         hapd.request('DATA_TEST_CONFIG 0')
388
389         # let the AP send couple of Beacon frames
390         time.sleep(0.3)
391
392         # disconnect - with traffic pending - shouldn't cause kernel warnings
393         dev[0].request("DISCONNECT")
394     finally:
395         hwsim_utils.set_powersave(dev[0], hwsim_utils.PS_DISABLED)
396
397     time.sleep(0.2)
398     out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
399                      "wlan_mgt.tim.partial_virtual_bitmap",
400                      ["wlan_mgt.tim.partial_virtual_bitmap"])
401     if out is not None:
402         state = 0
403         for l in out.splitlines():
404             pvb = int(l, 16)
405             if pvb > 0 and state == 0:
406                 state = 1
407             elif pvb == 0 and state == 1:
408                 state = 2
409         if state != 2:
410             raise Exception("Didn't observe TIM bit getting set and unset (state=%d)" % state)
411
412 def test_ap_open_select_network(dev, apdev):
413     """Open mode connection and SELECT_NETWORK to change network"""
414     hapd1 = hostapd.add_ap(apdev[0], { "ssid": "open" })
415     bssid1 = apdev[0]['bssid']
416     hapd2 = hostapd.add_ap(apdev[1], { "ssid": "open2" })
417     bssid2 = apdev[1]['bssid']
418
419     id1 = dev[0].connect("open", key_mgmt="NONE", scan_freq="2412",
420                          only_add_network=True)
421     id2 = dev[0].connect("open2", key_mgmt="NONE", scan_freq="2412")
422     hwsim_utils.test_connectivity(dev[0], hapd2)
423
424     dev[0].select_network(id1)
425     dev[0].wait_connected()
426     res = dev[0].request("BLACKLIST")
427     if bssid1 in res or bssid2 in res:
428         raise Exception("Unexpected blacklist entry")
429     hwsim_utils.test_connectivity(dev[0], hapd1)
430
431     dev[0].select_network(id2)
432     dev[0].wait_connected()
433     hwsim_utils.test_connectivity(dev[0], hapd2)
434     res = dev[0].request("BLACKLIST")
435     if bssid1 in res or bssid2 in res:
436         raise Exception("Unexpected blacklist entry(2)")
437
438 def test_ap_open_disable_enable(dev, apdev):
439     """AP with open mode getting disabled and re-enabled"""
440     hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
441     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412",
442                    bg_scan_period="0")
443
444     for i in range(2):
445         hapd.request("DISABLE")
446         dev[0].wait_disconnected()
447         hapd.request("ENABLE")
448         dev[0].wait_connected()
449         hwsim_utils.test_connectivity(dev[0], hapd)
450
451 def sta_enable_disable(dev, bssid):
452     dev.scan_for_bss(bssid, freq=2412)
453     work_id = dev.request("RADIO_WORK add block-work")
454     ev = dev.wait_event(["EXT-RADIO-WORK-START"])
455     if ev is None:
456         raise Exception("Timeout while waiting radio work to start")
457     id = dev.connect("open", key_mgmt="NONE", scan_freq="2412",
458                      only_add_network=True)
459     dev.request("ENABLE_NETWORK %d" % id)
460     if "connect@" not in dev.request("RADIO_WORK show"):
461         raise Exception("connect radio work missing")
462     dev.request("DISABLE_NETWORK %d" % id)
463     dev.request("RADIO_WORK done " + work_id)
464
465     ok = False
466     for i in range(30):
467         if "connect@" not in dev.request("RADIO_WORK show"):
468             ok = True
469             break
470         time.sleep(0.1)
471     if not ok:
472         raise Exception("connect radio work not completed")
473     ev = dev.wait_event(["CTRL-EVENT-CONNECTED"], timeout=0.1)
474     if ev is not None:
475         raise Exception("Unexpected connection")
476     dev.request("DISCONNECT")
477
478 def test_ap_open_sta_enable_disable(dev, apdev):
479     """AP with open mode and wpa_supplicant ENABLE/DISABLE_NETWORK"""
480     hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
481     bssid = apdev[0]['bssid']
482
483     sta_enable_disable(dev[0], bssid)
484
485     wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
486     wpas.interface_add("wlan5", drv_params="force_connect_cmd=1")
487     sta_enable_disable(wpas, bssid)
488
489 def test_ap_open_select_twice(dev, apdev):
490     """AP with open mode and select network twice"""
491     id = dev[0].connect("open", key_mgmt="NONE", scan_freq="2412",
492                         only_add_network=True)
493     dev[0].select_network(id)
494     ev = dev[0].wait_event(["CTRL-EVENT-NETWORK-NOT-FOUND"], timeout=10)
495     if ev is None:
496         raise Exception("No result reported")
497     hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
498     # Verify that the second SELECT_NETWORK starts a new scan immediately by
499     # waiting less than the default scan period.
500     dev[0].select_network(id)
501     dev[0].wait_connected(timeout=3)
502
503 def test_ap_open_reassoc_not_found(dev, apdev):
504     """AP with open mode and REASSOCIATE not finding a match"""
505     id = dev[0].connect("open", key_mgmt="NONE", scan_freq="2412",
506                         only_add_network=True)
507     dev[0].select_network(id)
508     ev = dev[0].wait_event(["CTRL-EVENT-NETWORK-NOT-FOUND"], timeout=10)
509     if ev is None:
510         raise Exception("No result reported")
511     dev[0].request("DISCONNECT")
512
513     time.sleep(0.1)
514     dev[0].dump_monitor()
515
516     dev[0].request("REASSOCIATE")
517     ev = dev[0].wait_event(["CTRL-EVENT-NETWORK-NOT-FOUND"], timeout=10)
518     if ev is None:
519         raise Exception("No result reported")
520     dev[0].request("DISCONNECT")