]> git.ipfire.org Git - thirdparty/hostap.git/blame - tests/hwsim/test_dfs.py
tests: DPP and provisoning DPP and legacy AKMs
[thirdparty/hostap.git] / tests / hwsim / test_dfs.py
CommitLineData
8454e1fd 1# Test cases for DFS
df71e160 2# Copyright (c) 2013-2019, Jouni Malinen <j@w1.fi>
8454e1fd
JM
3#
4# This software may be distributed under the terms of the BSD license.
5# See README for more details.
6
9fd6804d 7from remotehost import remote_compatible
8454e1fd
JM
8import os
9import subprocess
10import time
11import logging
12logger = logging.getLogger()
13
14import hwsim_utils
15import hostapd
df71e160 16from utils import *
8454e1fd
JM
17
18def wait_dfs_event(hapd, event, timeout):
19 dfs_events = [ "DFS-RADAR-DETECTED", "DFS-NEW-CHANNEL",
20 "DFS-CAC-START", "DFS-CAC-COMPLETED",
bd5a7691 21 "DFS-NOP-FINISHED", "AP-ENABLED", "AP-CSA-FINISHED" ]
8454e1fd
JM
22 ev = hapd.wait_event(dfs_events, timeout=timeout)
23 if not ev:
24 raise Exception("DFS event timed out")
bc86d8c1 25 if event and event not in ev:
9a3eba46 26 raise Exception("Unexpected DFS event: " + ev + " (expected: %s)" % event)
8454e1fd
JM
27 return ev
28
d92da8a2 29def start_dfs_ap(ap, allow_failure=False, ssid="dfs", ht=True, ht40=False,
803d0190 30 ht40minus=False, vht80=False, vht20=False, chanlist=None,
9cd52ac3 31 channel=None, country="FI"):
8454e1fd 32 ifname = ap['ifname']
8454e1fd 33 logger.info("Starting AP " + ifname + " on DFS channel")
b29c46be 34 hapd = hostapd.add_ap(ap, {}, no_enable=True)
bd5a7691 35 hapd.set("ssid", ssid)
9cd52ac3 36 hapd.set("country_code", country)
8454e1fd
JM
37 hapd.set("ieee80211d", "1")
38 hapd.set("ieee80211h", "1")
39 hapd.set("hw_mode", "a")
40 hapd.set("channel", "52")
d92da8a2
JM
41 if not ht:
42 hapd.set("ieee80211n", "0")
bd5a7691
JM
43 if ht40:
44 hapd.set("ht_capab", "[HT40+]")
d92da8a2
JM
45 elif ht40minus:
46 hapd.set("ht_capab", "[HT40-]")
47 hapd.set("channel", "56")
2a6cce38
JM
48 if vht80:
49 hapd.set("ieee80211ac", "1")
50 hapd.set("vht_oper_chwidth", "1")
51 hapd.set("vht_oper_centr_freq_seg0_idx", "58")
52 if vht20:
53 hapd.set("ieee80211ac", "1")
54 hapd.set("vht_oper_chwidth", "0")
55 hapd.set("vht_oper_centr_freq_seg0_idx", "0")
56 if chanlist:
57 hapd.set("chanlist", chanlist)
803d0190
JM
58 if channel:
59 hapd.set("channel", str(channel))
8454e1fd
JM
60 hapd.enable()
61
62 ev = wait_dfs_event(hapd, "DFS-CAC-START", 5)
63 if "DFS-CAC-START" not in ev:
9a3eba46 64 raise Exception("Unexpected DFS event: " + ev)
8454e1fd
JM
65
66 state = hapd.get_status_field("state")
67 if state != "DFS":
4f62bfef
JM
68 if allow_failure:
69 logger.info("Interface state not DFS: " + state)
81e787b7
JM
70 if not os.path.exists("dfs"):
71 raise HwsimSkip("Assume DFS testing not supported")
72 raise Exception("Failed to start DFS AP")
4f62bfef 73 raise Exception("Unexpected interface state: " + state)
8454e1fd
JM
74
75 return hapd
76
bd5a7691
JM
77def dfs_simulate_radar(hapd):
78 logger.info("Trigger a simulated radar event")
79 phyname = hapd.get_driver_status_field("phyname")
80 radar_file = '/sys/kernel/debug/ieee80211/' + phyname + '/hwsim/dfs_simulate_radar'
81 with open(radar_file, 'w') as f:
82 f.write('1')
83
8454e1fd
JM
84def test_dfs(dev, apdev):
85 """DFS CAC functionality on clear channel"""
4f62bfef 86 try:
e246d7d5 87 hapd = None
9cd52ac3 88 hapd = start_dfs_ap(apdev[0], allow_failure=True, country="US")
4f62bfef
JM
89
90 ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
91 if "success=1" not in ev:
92 raise Exception("CAC failed")
93 if "freq=5260" not in ev:
94 raise Exception("Unexpected DFS freq result")
95
96 ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
97 if not ev:
98 raise Exception("AP setup timed out")
99
100 state = hapd.get_status_field("state")
101 if state != "ENABLED":
102 raise Exception("Unexpected interface state")
103
104 freq = hapd.get_status_field("freq")
105 if freq != "5260":
106 raise Exception("Unexpected frequency")
107
c634d320 108 dev[0].connect("dfs", key_mgmt="NONE")
b586054f 109 dev[0].wait_regdom(country_ie=True)
a8375c94 110 hwsim_utils.test_connectivity(dev[0], hapd)
831cb7af
JM
111
112 hapd.request("RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1")
113 ev = hapd.wait_event(["DFS-RADAR-DETECTED"], timeout=10)
114 if ev is None:
115 raise Exception("DFS-RADAR-DETECTED event not reported")
116 if "freq=5260" not in ev:
bc6e3288 117 raise Exception("Incorrect frequency in radar detected event: " + ev)
831cb7af
JM
118 ev = hapd.wait_event(["DFS-NEW-CHANNEL"], timeout=70)
119 if ev is None:
120 raise Exception("DFS-NEW-CHANNEL event not reported")
121 if "freq=5260" in ev:
bc6e3288 122 raise Exception("Channel did not change after radar was detected")
831cb7af
JM
123
124 ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=70)
125 if ev is None:
126 raise Exception("AP-CSA-FINISHED event not reported")
127 if "freq=5260" in ev:
bc6e3288 128 raise Exception("Channel did not change after radar was detected(2)")
831cb7af 129 time.sleep(1)
a8375c94 130 hwsim_utils.test_connectivity(dev[0], hapd)
9cd52ac3 131 finally:
df71e160 132 clear_regdom(hapd, dev)
9cd52ac3
JM
133
134def test_dfs_etsi(dev, apdev, params):
135 """DFS and uniform spreading requirement for ETSI [long]"""
136 if not params['long']:
137 raise HwsimSkip("Skip test case with long duration due to --long not specified")
138 try:
139 hapd = None
140 hapd = start_dfs_ap(apdev[0], allow_failure=True)
141
142 ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
143 if "success=1" not in ev:
144 raise Exception("CAC failed")
145 if "freq=5260" not in ev:
146 raise Exception("Unexpected DFS freq result")
147
148 ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
149 if not ev:
150 raise Exception("AP setup timed out")
151
152 state = hapd.get_status_field("state")
153 if state != "ENABLED":
154 raise Exception("Unexpected interface state")
155
156 freq = hapd.get_status_field("freq")
157 if freq != "5260":
158 raise Exception("Unexpected frequency")
159
160 dev[0].connect("dfs", key_mgmt="NONE")
b586054f 161 dev[0].wait_regdom(country_ie=True)
9cd52ac3
JM
162 hwsim_utils.test_connectivity(dev[0], hapd)
163
164 hapd.request("RADAR DETECTED freq=%s ht_enabled=1 chan_width=1" % freq)
165 ev = hapd.wait_event(["DFS-RADAR-DETECTED"], timeout=5)
166 if ev is None:
167 raise Exception("DFS-RADAR-DETECTED event not reported")
168 if "freq=%s" % freq not in ev:
169 raise Exception("Incorrect frequency in radar detected event: " + ev)
170 ev = hapd.wait_event(["DFS-NEW-CHANNEL"], timeout=5)
171 if ev is None:
172 raise Exception("DFS-NEW-CHANNEL event not reported")
173 if "freq=%s" % freq in ev:
174 raise Exception("Channel did not change after radar was detected")
175
176 ev = hapd.wait_event(["AP-CSA-FINISHED", "DFS-CAC-START"], timeout=10)
177 if ev is None:
178 raise Exception("AP-CSA-FINISHED or DFS-CAC-START event not reported")
179 if "DFS-CAC-START" in ev:
180 # The selected new channel requires CAC
181 ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
182 if "success=1" not in ev:
183 raise Exception("CAC failed")
184
185 ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
186 if not ev:
187 raise Exception("AP setup timed out")
188 ev = hapd.wait_event(["AP-STA-CONNECTED"], timeout=30)
189 if not ev:
190 raise Exception("STA did not reconnect on new DFS channel")
191 else:
192 # The new channel did not require CAC - try again
193 if "freq=%s" % freq in ev:
194 raise Exception("Channel did not change after radar was detected(2)")
195 time.sleep(1)
196 hwsim_utils.test_connectivity(dev[0], hapd)
4f62bfef 197 finally:
df71e160 198 clear_regdom(hapd, dev)
8454e1fd 199
32452fd2
JM
200def test_dfs_radar1(dev, apdev):
201 """DFS CAC functionality with radar detected during initial CAC"""
4f62bfef 202 try:
e246d7d5 203 hapd = None
8c6f6ac1 204 hapd = start_dfs_ap(apdev[0], allow_failure=True)
bc86d8c1 205 time.sleep(1)
8454e1fd 206
bd5a7691
JM
207 dfs_simulate_radar(hapd)
208
bc86d8c1
JM
209 ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 5)
210 if ev is None:
211 raise Exception("Timeout on DFS aborted event")
212 if "success=0 freq=5260" not in ev:
213 raise Exception("Unexpected DFS aborted event contents: " + ev)
214
215 ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
4f62bfef
JM
216 if "freq=5260" not in ev:
217 raise Exception("Unexpected DFS radar detection freq")
8454e1fd 218
4f62bfef
JM
219 ev = wait_dfs_event(hapd, "DFS-NEW-CHANNEL", 5)
220 if "freq=5260" in ev:
221 raise Exception("Unexpected DFS new freq")
8454e1fd 222
bc86d8c1
JM
223 ev = wait_dfs_event(hapd, None, 5)
224 if "AP-ENABLED" in ev:
225 logger.info("Started AP on non-DFS channel")
226 else:
227 logger.info("Trying to start AP on another DFS channel")
228 if "DFS-CAC-START" not in ev:
9a3eba46 229 raise Exception("Unexpected DFS event: " + ev)
bc86d8c1
JM
230 if "freq=5260" in ev:
231 raise Exception("Unexpected DFS CAC freq")
232
233 ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
234 if "success=1" not in ev:
235 raise Exception("CAC failed")
236 if "freq=5260" in ev:
237 raise Exception("Unexpected DFS freq result - radar channel")
238
239 ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
240 if not ev:
241 raise Exception("AP setup timed out")
242
243 state = hapd.get_status_field("state")
244 if state != "ENABLED":
245 raise Exception("Unexpected interface state")
246
247 freq = hapd.get_status_field("freq")
248 if freq == "5260":
249 raise Exception("Unexpected frequency: " + freq)
8454e1fd 250
c634d320 251 dev[0].connect("dfs", key_mgmt="NONE")
b586054f 252 dev[0].wait_regdom(country_ie=True)
32452fd2 253 finally:
df71e160 254 clear_regdom(hapd, dev)
bd5a7691 255
32452fd2
JM
256def test_dfs_radar2(dev, apdev):
257 """DFS CAC functionality with radar detected after initial CAC"""
258 try:
259 hapd = None
260 hapd = start_dfs_ap(apdev[0], ssid="dfs2", ht40=True)
261
262 ev = hapd.wait_event(["AP-ENABLED"], timeout=70)
bd5a7691
JM
263 if not ev:
264 raise Exception("AP2 setup timed out")
265
32452fd2 266 dfs_simulate_radar(hapd)
bd5a7691 267
32452fd2 268 ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
bd5a7691
JM
269 if "freq=5260 ht_enabled=1 chan_offset=1 chan_width=2" not in ev:
270 raise Exception("Unexpected DFS radar detection freq from AP2")
271
32452fd2 272 ev = wait_dfs_event(hapd, "DFS-NEW-CHANNEL", 5)
bd5a7691
JM
273 if "freq=5260" in ev:
274 raise Exception("Unexpected DFS new freq for AP2")
275
32452fd2 276 wait_dfs_event(hapd, None, 5)
4f62bfef 277 finally:
9d7fdac5
JM
278 if hapd:
279 hapd.request("DISABLE")
c4668009 280 subprocess.call(['iw', 'reg', 'set', '00'])
ba3146e1 281 time.sleep(0.1)
8454e1fd 282
9fd6804d 283@remote_compatible
4f62bfef
JM
284def test_dfs_radar_on_non_dfs_channel(dev, apdev):
285 """DFS radar detection test code on non-DFS channel"""
286 params = { "ssid": "radar" }
8b8a1864 287 hapd = hostapd.add_ap(apdev[0], params)
4f62bfef
JM
288
289 hapd.request("RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1")
290 hapd.request("RADAR DETECTED freq=2412 ht_enabled=1 chan_width=1")
2a6cce38
JM
291
292def test_dfs_radar_chanlist(dev, apdev):
293 """DFS chanlist when radar is detected"""
294 try:
e246d7d5 295 hapd = None
8c6f6ac1 296 hapd = start_dfs_ap(apdev[0], chanlist="40 44", allow_failure=True)
2a6cce38
JM
297 time.sleep(1)
298
299 dfs_simulate_radar(hapd)
300
301 ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 5)
302 if ev is None:
303 raise Exception("Timeout on DFS aborted event")
304 if "success=0 freq=5260" not in ev:
305 raise Exception("Unexpected DFS aborted event contents: " + ev)
306
307 ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
308 if "freq=5260" not in ev:
309 raise Exception("Unexpected DFS radar detection freq")
310
311 ev = wait_dfs_event(hapd, "DFS-NEW-CHANNEL", 5)
312 if "freq=5200 chan=40" not in ev and "freq=5220 chan=44" not in ev:
313 raise Exception("Unexpected DFS new freq: " + ev)
314
315 ev = wait_dfs_event(hapd, None, 5)
316 if "AP-ENABLED" not in ev:
9a3eba46 317 raise Exception("Unexpected DFS event: " + ev)
2a6cce38 318 dev[0].connect("dfs", key_mgmt="NONE")
b586054f 319 dev[0].wait_regdom(country_ie=True)
2a6cce38 320 finally:
df71e160 321 clear_regdom(hapd, dev)
2a6cce38
JM
322
323def test_dfs_radar_chanlist_vht80(dev, apdev):
324 """DFS chanlist when radar is detected and VHT80 configured"""
325 try:
e246d7d5 326 hapd = None
8c6f6ac1
JM
327 hapd = start_dfs_ap(apdev[0], chanlist="36", ht40=True, vht80=True,
328 allow_failure=True)
2a6cce38
JM
329 time.sleep(1)
330
331 dfs_simulate_radar(hapd)
332
333 ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 5)
334 if ev is None:
335 raise Exception("Timeout on DFS aborted event")
336 if "success=0 freq=5260" not in ev:
337 raise Exception("Unexpected DFS aborted event contents: " + ev)
338
339 ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
340 if "freq=5260" not in ev:
341 raise Exception("Unexpected DFS radar detection freq")
342
343 ev = wait_dfs_event(hapd, "DFS-NEW-CHANNEL", 5)
344 if "freq=5180 chan=36 sec_chan=1" not in ev:
345 raise Exception("Unexpected DFS new freq: " + ev)
346
347 ev = wait_dfs_event(hapd, None, 5)
348 if "AP-ENABLED" not in ev:
9a3eba46 349 raise Exception("Unexpected DFS event: " + ev)
2a6cce38 350 dev[0].connect("dfs", key_mgmt="NONE")
b586054f 351 dev[0].wait_regdom(country_ie=True)
2a6cce38
JM
352
353 if hapd.get_status_field('vht_oper_centr_freq_seg0_idx') != "42":
354 raise Exception("Unexpected seg0 idx")
355 finally:
df71e160 356 clear_regdom(hapd, dev)
2a6cce38
JM
357
358def test_dfs_radar_chanlist_vht20(dev, apdev):
359 """DFS chanlist when radar is detected and VHT40 configured"""
360 try:
e246d7d5 361 hapd = None
8c6f6ac1
JM
362 hapd = start_dfs_ap(apdev[0], chanlist="36", vht20=True,
363 allow_failure=True)
2a6cce38
JM
364 time.sleep(1)
365
366 dfs_simulate_radar(hapd)
367
368 ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 5)
369 if ev is None:
370 raise Exception("Timeout on DFS aborted event")
371 if "success=0 freq=5260" not in ev:
372 raise Exception("Unexpected DFS aborted event contents: " + ev)
373
374 ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
375 if "freq=5260" not in ev:
376 raise Exception("Unexpected DFS radar detection freq")
377
378 ev = wait_dfs_event(hapd, "DFS-NEW-CHANNEL", 5)
379 if "freq=5180 chan=36 sec_chan=0" not in ev:
380 raise Exception("Unexpected DFS new freq: " + ev)
381
382 ev = wait_dfs_event(hapd, None, 5)
383 if "AP-ENABLED" not in ev:
9a3eba46 384 raise Exception("Unexpected DFS event: " + ev)
2a6cce38 385 dev[0].connect("dfs", key_mgmt="NONE")
b586054f 386 dev[0].wait_regdom(country_ie=True)
2a6cce38 387 finally:
df71e160 388 clear_regdom(hapd, dev)
d92da8a2
JM
389
390def test_dfs_radar_no_ht(dev, apdev):
391 """DFS chanlist when radar is detected and no HT configured"""
392 try:
e246d7d5 393 hapd = None
8c6f6ac1
JM
394 hapd = start_dfs_ap(apdev[0], chanlist="36", ht=False,
395 allow_failure=True)
d92da8a2
JM
396 time.sleep(1)
397
398 dfs_simulate_radar(hapd)
399
400 ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 5)
401 if ev is None:
402 raise Exception("Timeout on DFS aborted event")
403 if "success=0 freq=5260" not in ev:
404 raise Exception("Unexpected DFS aborted event contents: " + ev)
405
406 ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
407 if "freq=5260 ht_enabled=0" not in ev:
408 raise Exception("Unexpected DFS radar detection freq: " + ev)
409
410 ev = wait_dfs_event(hapd, "DFS-NEW-CHANNEL", 5)
411 if "freq=5180 chan=36 sec_chan=0" not in ev:
412 raise Exception("Unexpected DFS new freq: " + ev)
413
414 ev = wait_dfs_event(hapd, None, 5)
415 if "AP-ENABLED" not in ev:
9a3eba46 416 raise Exception("Unexpected DFS event: " + ev)
d92da8a2 417 dev[0].connect("dfs", key_mgmt="NONE")
b586054f 418 dev[0].wait_regdom(country_ie=True)
d92da8a2 419 finally:
df71e160 420 clear_regdom(hapd, dev)
d92da8a2
JM
421
422def test_dfs_radar_ht40minus(dev, apdev):
423 """DFS chanlist when radar is detected and HT40- configured"""
424 try:
e246d7d5 425 hapd = None
8c6f6ac1
JM
426 hapd = start_dfs_ap(apdev[0], chanlist="36", ht40minus=True,
427 allow_failure=True)
d92da8a2
JM
428 time.sleep(1)
429
430 dfs_simulate_radar(hapd)
431
432 ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 5)
433 if ev is None:
434 raise Exception("Timeout on DFS aborted event")
435 if "success=0 freq=5280 ht_enabled=1 chan_offset=-1" not in ev:
436 raise Exception("Unexpected DFS aborted event contents: " + ev)
437
438 ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
439 if "freq=5280 ht_enabled=1 chan_offset=-1" not in ev:
440 raise Exception("Unexpected DFS radar detection freq: " + ev)
441
442 ev = wait_dfs_event(hapd, "DFS-NEW-CHANNEL", 5)
443 if "freq=5180 chan=36 sec_chan=1" not in ev:
444 raise Exception("Unexpected DFS new freq: " + ev)
445
446 ev = wait_dfs_event(hapd, None, 5)
447 if "AP-ENABLED" not in ev:
9a3eba46 448 raise Exception("Unexpected DFS event: " + ev)
d92da8a2 449 dev[0].connect("dfs", key_mgmt="NONE")
b586054f
JM
450 dev[0].wait_regdom(country_ie=True)
451 dev[0].request("STA_AUTOCONNECT 0")
d92da8a2 452 finally:
df71e160 453 clear_regdom(hapd, dev)
b586054f 454 dev[0].request("STA_AUTOCONNECT 1")
803d0190
JM
455
456def test_dfs_ht40_minus(dev, apdev, params):
457 """DFS CAC functionality on channel 104 HT40- [long]"""
458 if not params['long']:
459 raise HwsimSkip("Skip test case with long duration due to --long not specified")
460 try:
461 hapd = None
462 hapd = start_dfs_ap(apdev[0], allow_failure=True, ht40minus=True,
463 channel=104)
464
465 ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
466 if "success=1" not in ev:
467 raise Exception("CAC failed")
468 if "freq=5520" not in ev:
469 raise Exception("Unexpected DFS freq result")
470
471 ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
472 if not ev:
473 raise Exception("AP setup timed out")
474
475 state = hapd.get_status_field("state")
476 if state != "ENABLED":
477 raise Exception("Unexpected interface state")
478
479 freq = hapd.get_status_field("freq")
480 if freq != "5520":
481 raise Exception("Unexpected frequency")
482
483 dev[0].connect("dfs", key_mgmt="NONE", scan_freq="5520")
b586054f 484 dev[0].wait_regdom(country_ie=True)
803d0190
JM
485 hwsim_utils.test_connectivity(dev[0], hapd)
486 finally:
df71e160 487 clear_regdom(hapd, dev)
78a9ba72
JM
488
489def test_dfs_cac_restart_on_enable(dev, apdev):
490 """DFS CAC interrupted and restarted"""
491 try:
492 hapd = None
493 hapd = start_dfs_ap(apdev[0], allow_failure=True)
494 time.sleep(0.1)
495 subprocess.check_call(['ip', 'link', 'set', 'dev', hapd.ifname, 'down'])
496 ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 5)
497 if ev is None:
498 raise Exception("Timeout on DFS aborted event")
499 if "success=0 freq=5260" not in ev:
500 raise Exception("Unexpected DFS aborted event contents: " + ev)
501 time.sleep(0.1)
502 subprocess.check_call(['ip', 'link', 'set', 'dev', hapd.ifname, 'up'])
503
504 ev = wait_dfs_event(hapd, "DFS-CAC-START", 5)
505 if "DFS-CAC-START" not in ev:
506 raise Exception("Unexpected DFS event: " + ev)
507 hapd.disable()
508
509 finally:
510 if hapd:
511 hapd.request("DISABLE")
512 subprocess.call(['iw', 'reg', 'set', '00'])
513 time.sleep(0.1)