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