1 # Test cases for HT operations with hostapd
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.
9 logger = logging.getLogger()
15 from test_ap_csa import csa_supported
17 def clear_scan_cache(ifname):
18 subprocess.call(['sudo', 'ifconfig', ifname, 'up'])
19 subprocess.call(['sudo', 'iw', ifname, 'scan', 'freq', '2412', 'flush'])
21 subprocess.call(['sudo', 'ifconfig', ifname, 'down'])
23 def test_ap_ht40_scan(dev, apdev):
25 clear_scan_cache(apdev[0]['ifname'])
26 params = { "ssid": "test-ht40",
28 "ht_capab": "[HT40-]"}
29 hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
31 state = hapd.get_status_field("state")
32 if state != "HT_SCAN":
34 state = hapd.get_status_field("state")
35 if state != "HT_SCAN":
36 raise Exception("Unexpected interface state - expected HT_SCAN")
38 ev = hapd.wait_event(["AP-ENABLED"], timeout=10)
40 raise Exception("AP setup timed out")
42 state = hapd.get_status_field("state")
43 if state != "ENABLED":
44 raise Exception("Unexpected interface state - expected ENABLED")
46 freq = hapd.get_status_field("freq")
48 raise Exception("Unexpected frequency")
49 pri = hapd.get_status_field("channel")
51 raise Exception("Unexpected primary channel")
52 sec = hapd.get_status_field("secondary_channel")
54 raise Exception("Unexpected secondary channel")
56 dev[0].connect("test-ht40", key_mgmt="NONE", scan_freq=freq)
58 def test_ap_ht40_scan_conflict(dev, apdev):
59 """HT40 co-ex scan conflict"""
60 clear_scan_cache(apdev[0]['ifname'])
61 params = { "ssid": "test-ht40",
63 "ht_capab": "[HT40+]"}
64 hostapd.add_ap(apdev[1]['ifname'], params)
66 params = { "ssid": "test-ht40",
68 "ht_capab": "[HT40-]"}
69 hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
71 state = hapd.get_status_field("state")
72 if state != "HT_SCAN":
74 state = hapd.get_status_field("state")
75 if state != "HT_SCAN":
76 raise Exception("Unexpected interface state - expected HT_SCAN")
78 ev = hapd.wait_event(["AP-ENABLED"], timeout=10)
80 raise Exception("AP setup timed out")
82 state = hapd.get_status_field("state")
83 if state != "ENABLED":
84 raise Exception("Unexpected interface state - expected ENABLED")
86 freq = hapd.get_status_field("freq")
88 raise Exception("Unexpected frequency")
89 pri = hapd.get_status_field("channel")
91 raise Exception("Unexpected primary channel")
92 sec = hapd.get_status_field("secondary_channel")
94 raise Exception("Unexpected secondary channel: " + sec)
96 dev[0].connect("test-ht40", key_mgmt="NONE", scan_freq=freq)
98 def test_ap_ht40_scan_legacy_conflict(dev, apdev):
99 """HT40 co-ex scan conflict with legacy 20 MHz AP"""
100 clear_scan_cache(apdev[0]['ifname'])
101 params = { "ssid": "legacy-20",
102 "channel": "7", "ieee80211n": "0" }
103 hostapd.add_ap(apdev[1]['ifname'], params)
105 params = { "ssid": "test-ht40",
107 "ht_capab": "[HT40-]"}
108 hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
110 state = hapd.get_status_field("state")
111 if state != "HT_SCAN":
113 state = hapd.get_status_field("state")
114 if state != "HT_SCAN":
115 raise Exception("Unexpected interface state - expected HT_SCAN")
117 ev = hapd.wait_event(["AP-ENABLED"], timeout=10)
119 raise Exception("AP setup timed out")
121 state = hapd.get_status_field("state")
122 if state != "ENABLED":
123 raise Exception("Unexpected interface state - expected ENABLED")
125 freq = hapd.get_status_field("freq")
127 raise Exception("Unexpected frequency: " + freq)
128 pri = hapd.get_status_field("channel")
130 raise Exception("Unexpected primary channel: " + pri)
131 sec = hapd.get_status_field("secondary_channel")
133 raise Exception("Unexpected secondary channel: " + sec)
135 dev[0].connect("test-ht40", key_mgmt="NONE", scan_freq=freq)
137 def test_ap_ht40_scan_match(dev, apdev):
138 """HT40 co-ex scan matching configuration"""
139 clear_scan_cache(apdev[0]['ifname'])
140 params = { "ssid": "test-ht40",
142 "ht_capab": "[HT40-]"}
143 hostapd.add_ap(apdev[1]['ifname'], params)
145 params = { "ssid": "test-ht40",
147 "ht_capab": "[HT40-]"}
148 hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
150 state = hapd.get_status_field("state")
151 if state != "HT_SCAN":
153 state = hapd.get_status_field("state")
154 if state != "HT_SCAN":
155 raise Exception("Unexpected interface state - expected HT_SCAN")
157 ev = hapd.wait_event(["AP-ENABLED"], timeout=10)
159 raise Exception("AP setup timed out")
161 state = hapd.get_status_field("state")
162 if state != "ENABLED":
163 raise Exception("Unexpected interface state - expected ENABLED")
165 freq = hapd.get_status_field("freq")
167 raise Exception("Unexpected frequency")
168 pri = hapd.get_status_field("channel")
170 raise Exception("Unexpected primary channel")
171 sec = hapd.get_status_field("secondary_channel")
173 raise Exception("Unexpected secondary channel: " + sec)
175 dev[0].connect("test-ht40", key_mgmt="NONE", scan_freq=freq)
177 def test_ap_ht40_5ghz_match(dev, apdev):
178 """HT40 co-ex scan on 5 GHz with matching pri/sec channel"""
179 clear_scan_cache(apdev[0]['ifname'])
183 params = { "ssid": "test-ht40",
186 "country_code": "US",
187 "ht_capab": "[HT40+]"}
188 hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)
190 params = { "ssid": "test-ht40",
193 "ht_capab": "[HT40+]"}
194 hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
196 state = hapd.get_status_field("state")
197 if state != "HT_SCAN":
199 state = hapd.get_status_field("state")
200 if state != "HT_SCAN":
201 raise Exception("Unexpected interface state - expected HT_SCAN")
203 ev = hapd.wait_event(["AP-ENABLED"], timeout=10)
205 raise Exception("AP setup timed out")
207 state = hapd.get_status_field("state")
208 if state != "ENABLED":
209 raise Exception("Unexpected interface state - expected ENABLED")
211 freq = hapd.get_status_field("freq")
213 raise Exception("Unexpected frequency")
214 pri = hapd.get_status_field("channel")
216 raise Exception("Unexpected primary channel")
217 sec = hapd.get_status_field("secondary_channel")
219 raise Exception("Unexpected secondary channel: " + sec)
221 dev[0].connect("test-ht40", key_mgmt="NONE", scan_freq=freq)
223 dev[0].request("DISCONNECT")
225 hapd.request("DISABLE")
227 hapd2.request("DISABLE")
228 subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
229 dev[0].flush_scan_cache()
231 def test_ap_ht40_5ghz_switch(dev, apdev):
232 """HT40 co-ex scan on 5 GHz switching pri/sec channel"""
233 clear_scan_cache(apdev[0]['ifname'])
237 params = { "ssid": "test-ht40",
240 "country_code": "US",
241 "ht_capab": "[HT40+]"}
242 hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)
244 params = { "ssid": "test-ht40",
247 "ht_capab": "[HT40-]"}
248 hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
250 state = hapd.get_status_field("state")
251 if state != "HT_SCAN":
253 state = hapd.get_status_field("state")
254 if state != "HT_SCAN":
255 raise Exception("Unexpected interface state - expected HT_SCAN")
257 ev = hapd.wait_event(["AP-ENABLED"], timeout=10)
259 raise Exception("AP setup timed out")
261 state = hapd.get_status_field("state")
262 if state != "ENABLED":
263 raise Exception("Unexpected interface state - expected ENABLED")
265 freq = hapd.get_status_field("freq")
267 raise Exception("Unexpected frequency: " + freq)
268 pri = hapd.get_status_field("channel")
270 raise Exception("Unexpected primary channel: " + pri)
271 sec = hapd.get_status_field("secondary_channel")
273 raise Exception("Unexpected secondary channel: " + sec)
275 dev[0].connect("test-ht40", key_mgmt="NONE", scan_freq=freq)
277 dev[0].request("DISCONNECT")
279 hapd.request("DISABLE")
281 hapd2.request("DISABLE")
282 subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
284 def test_ap_ht40_5ghz_switch2(dev, apdev):
285 """HT40 co-ex scan on 5 GHz switching pri/sec channel (2)"""
286 clear_scan_cache(apdev[0]['ifname'])
290 params = { "ssid": "test-ht40",
293 "country_code": "US",
294 "ht_capab": "[HT40+]"}
295 hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)
297 id = dev[0].add_network()
298 dev[0].set_network(id, "mode", "2")
299 dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")
300 dev[0].set_network(id, "key_mgmt", "NONE")
301 dev[0].set_network(id, "frequency", "5200")
302 dev[0].set_network(id, "scan_freq", "5200")
303 dev[0].select_network(id)
306 params = { "ssid": "test-ht40",
309 "ht_capab": "[HT40-]"}
310 hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
312 state = hapd.get_status_field("state")
313 if state != "HT_SCAN":
315 state = hapd.get_status_field("state")
316 if state != "HT_SCAN":
317 raise Exception("Unexpected interface state - expected HT_SCAN")
319 ev = hapd.wait_event(["AP-ENABLED"], timeout=10)
321 raise Exception("AP setup timed out")
323 state = hapd.get_status_field("state")
324 if state != "ENABLED":
325 raise Exception("Unexpected interface state - expected ENABLED")
327 freq = hapd.get_status_field("freq")
329 raise Exception("Unexpected frequency: " + freq)
330 pri = hapd.get_status_field("channel")
332 raise Exception("Unexpected primary channel: " + pri)
333 sec = hapd.get_status_field("secondary_channel")
335 raise Exception("Unexpected secondary channel: " + sec)
337 dev[0].connect("test-ht40", key_mgmt="NONE", scan_freq=freq)
339 dev[0].request("DISCONNECT")
341 hapd.request("DISABLE")
343 hapd2.request("DISABLE")
344 subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
345 dev[0].flush_scan_cache()
347 def test_obss_scan(dev, apdev):
348 """Overlapping BSS scan request"""
349 params = { "ssid": "obss-scan",
351 "ht_capab": "[HT40-]",
352 "obss_interval": "10" }
353 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
355 params = { "ssid": "another-bss",
358 hostapd.add_ap(apdev[1]['ifname'], params)
360 dev[0].connect("obss-scan", key_mgmt="NONE", scan_freq="2437")
361 hapd.set("ext_mgmt_frame_handling", "1")
362 logger.info("Waiting for OBSS scan to occur")
363 ev = dev[0].wait_event(["CTRL-EVENT-SCAN-STARTED"], timeout=15)
365 raise Exception("Timed out while waiting for OBSS scan to start")
366 ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], timeout=10)
368 raise Exception("Timed out while waiting for OBSS scan results")
370 for i in range(0, 4):
371 frame = hapd.mgmt_rx(timeout=5)
373 raise Exception("MGMT RX wait timed out")
374 if frame['subtype'] != 13:
376 payload = frame['payload']
379 (category, action, ie) = struct.unpack('BBB', payload[0:3])
385 logger.info("20/40 BSS Coexistence report received")
389 raise Exception("20/40 BSS Coexistence report not seen")
391 def test_obss_scan_40_intolerant(dev, apdev):
392 """Overlapping BSS scan request with 40 MHz intolerant AP"""
393 params = { "ssid": "obss-scan",
395 "ht_capab": "[HT40-]",
396 "obss_interval": "10" }
397 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
399 params = { "ssid": "another-bss",
401 "ht_capab": "[40-INTOLERANT]" }
402 hostapd.add_ap(apdev[1]['ifname'], params)
404 dev[0].connect("obss-scan", key_mgmt="NONE", scan_freq="2437")
405 hapd.set("ext_mgmt_frame_handling", "1")
406 logger.info("Waiting for OBSS scan to occur")
407 ev = dev[0].wait_event(["CTRL-EVENT-SCAN-STARTED"], timeout=15)
409 raise Exception("Timed out while waiting for OBSS scan to start")
410 ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], timeout=10)
412 raise Exception("Timed out while waiting for OBSS scan results")
414 for i in range(0, 4):
415 frame = hapd.mgmt_rx(timeout=5)
417 raise Exception("MGMT RX wait timed out")
418 if frame['subtype'] != 13:
420 payload = frame['payload']
423 (category, action, ie) = struct.unpack('BBB', payload[0:3])
429 logger.info("20/40 BSS Coexistence report received")
433 raise Exception("20/40 BSS Coexistence report not seen")
435 def test_olbc(dev, apdev):
437 params = { "ssid": "test-olbc",
439 "ht_capab": "[HT40-]",
440 "ap_table_expiration_time": "2" }
441 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
442 status = hapd.get_status()
443 if status['olbc'] != '0' or status['olbc_ht'] != '0':
444 raise Exception("Unexpected OLBC information")
446 params = { "ssid": "olbc-ap",
450 hostapd.add_ap(apdev[1]['ifname'], params)
452 status = hapd.get_status()
453 if status['olbc'] != '1' or status['olbc_ht'] != '1':
454 raise Exception("Missing OLBC information")
456 hapd_global = hostapd.HostapdGlobal()
457 hapd_global.remove(apdev[1]['ifname'])
459 logger.info("Waiting for OLBC state to time out")
461 for i in range(0, 15):
463 status = hapd.get_status()
464 if status['olbc'] == '0' and status['olbc_ht'] == '0':
468 raise Exception("OLBC state did nto time out")
470 def test_olbc_5ghz(dev, apdev):
471 """OLBC detection on 5 GHz"""
475 params = { "ssid": "test-olbc",
476 "country_code": "FI",
479 "ht_capab": "[HT40+]" }
480 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
481 status = hapd.get_status()
482 if status['olbc'] != '0' or status['olbc_ht'] != '0':
483 raise Exception("Unexpected OLBC information")
485 params = { "ssid": "olbc-ap",
486 "country_code": "FI",
491 hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)
493 status = hapd.get_status()
494 if status['olbc_ht'] != '1':
495 raise Exception("Missing OLBC information")
498 hapd.request("DISABLE")
500 hapd2.request("DISABLE")
501 subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
503 def test_ap_require_ht(dev, apdev):
505 params = { "ssid": "require-ht",
507 hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
509 dev[1].connect("require-ht", key_mgmt="NONE", scan_freq="2412",
510 disable_ht="1", wait_connect=False)
511 dev[0].connect("require-ht", key_mgmt="NONE", scan_freq="2412")
512 ev = dev[1].wait_event(["CTRL-EVENT-ASSOC-REJECT"])
514 raise Exception("Association rejection timed out")
515 if "status_code=27" not in ev:
516 raise Exception("Unexpected rejection status code")
517 dev[2].connect("require-ht", key_mgmt="NONE", scan_freq="2412",
518 ht_mcs="0x01 00 00 00 00 00 00 00 00 00",
519 disable_max_amsdu="1", ampdu_factor="2",
520 ampdu_density="1", disable_ht40="1", disable_sgi="1",
523 def test_ap_require_ht_limited_rates(dev, apdev):
524 """Require HT with limited supported rates"""
525 params = { "ssid": "require-ht",
526 "supported_rates": "60 120 240 360 480 540",
528 hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
530 dev[1].connect("require-ht", key_mgmt="NONE", scan_freq="2412",
531 disable_ht="1", wait_connect=False)
532 dev[0].connect("require-ht", key_mgmt="NONE", scan_freq="2412")
533 ev = dev[1].wait_event(["CTRL-EVENT-ASSOC-REJECT"])
535 raise Exception("Association rejection timed out")
536 if "status_code=27" not in ev:
537 raise Exception("Unexpected rejection status code")
539 def test_ap_ht_capab_not_supported(dev, apdev):
540 """HT configuration with driver not supporting all ht_capab entries"""
541 params = { "ssid": "test-ht40",
543 "ht_capab": "[HT40-][LDPC][SMPS-STATIC][SMPS-DYNAMIC][GF][SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1][RX-STBC12][RX-STBC123][DELAYED-BA][MAX-AMSDU-7935][DSSS_CCK-40][LSIG-TXOP-PROT]"}
544 hapd = hostapd.add_ap(apdev[0]['ifname'], params, no_enable=True)
545 if "FAIL" not in hapd.request("ENABLE"):
546 raise Exception("Unexpected ENABLE success")
548 def test_ap_ht_40mhz_intolerant_sta(dev, apdev):
549 """Associated STA indicating 40 MHz intolerant"""
550 clear_scan_cache(apdev[0]['ifname'])
551 params = { "ssid": "intolerant",
553 "ht_capab": "[HT40-]" }
554 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
555 if hapd.get_status_field("num_sta_ht40_intolerant") != "0":
556 raise Exception("Unexpected num_sta_ht40_intolerant value")
557 if hapd.get_status_field("secondary_channel") != "-1":
558 raise Exception("Unexpected secondary_channel")
560 dev[0].connect("intolerant", key_mgmt="NONE", scan_freq="2437")
561 if hapd.get_status_field("num_sta_ht40_intolerant") != "0":
562 raise Exception("Unexpected num_sta_ht40_intolerant value")
563 if hapd.get_status_field("secondary_channel") != "-1":
564 raise Exception("Unexpected secondary_channel")
566 dev[2].connect("intolerant", key_mgmt="NONE", scan_freq="2437",
569 if hapd.get_status_field("num_sta_ht40_intolerant") != "1":
570 raise Exception("Unexpected num_sta_ht40_intolerant value (expected 1)")
571 if hapd.get_status_field("secondary_channel") != "0":
572 raise Exception("Unexpected secondary_channel (did not disable 40 MHz)")
574 dev[2].request("DISCONNECT")
576 if hapd.get_status_field("num_sta_ht40_intolerant") != "0":
577 raise Exception("Unexpected num_sta_ht40_intolerant value (expected 0)")
578 if hapd.get_status_field("secondary_channel") != "-1":
579 raise Exception("Unexpected secondary_channel (did not re-enable 40 MHz)")
581 def test_ap_ht_40mhz_intolerant_ap(dev, apdev):
582 """Associated STA reports 40 MHz intolerant AP after association"""
583 clear_scan_cache(apdev[0]['ifname'])
584 params = { "ssid": "ht",
586 "ht_capab": "[HT40-]",
587 "obss_interval": "3" }
588 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
590 dev[0].connect("ht", key_mgmt="NONE", scan_freq="2437")
592 if hapd.get_status_field("secondary_channel") != "-1":
593 raise Exception("Unexpected secondary channel information")
595 logger.info("Start 40 MHz intolerant AP")
596 params = { "ssid": "intolerant",
598 "ht_capab": "[40-INTOLERANT]" }
599 hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)
601 logger.info("Waiting for co-ex report from STA")
603 for i in range(0, 20):
605 if hapd.get_status_field("secondary_channel") == "0":
606 logger.info("AP moved to 20 MHz channel")
610 raise Exception("AP did not move to 20 MHz channel")
612 if "OK" not in hapd2.request("DISABLE"):
613 raise Exception("Failed to disable 40 MHz intolerant AP")
615 # make sure the intolerant AP disappears from scan results more quickly
616 dev[0].scan(type="ONLY", freq="2432", only_new=True)
617 dev[0].scan(type="ONLY", freq="2432", only_new=True)
618 dev[0].dump_monitor()
620 logger.info("Waiting for AP to move back to 40 MHz channel")
622 for i in range(0, 30):
624 if hapd.get_status_field("secondary_channel") == "-1":
625 logger.info("AP moved to 40 MHz channel")
629 raise Exception("AP did not move to 40 MHz channel")
631 def test_ap_ht40_csa(dev, apdev):
632 """HT with 40 MHz channel width and CSA"""
633 if not csa_supported(dev[0]):
637 params = { "ssid": "ht",
638 "country_code": "US",
641 "ht_capab": "[HT40+]",
643 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
645 dev[0].connect("ht", key_mgmt="NONE", scan_freq="5180")
646 hwsim_utils.test_connectivity(dev[0], hapd)
648 hapd.request("CHAN_SWITCH 5 5200 ht sec_channel_offset=-1 bandwidth=40")
649 ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=10)
651 raise Exception("CSA finished event timed out")
652 if "freq=5200" not in ev:
653 raise Exception("Unexpected channel in CSA finished event")
654 ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
656 raise Exception("Unexpected STA disconnection during CSA")
657 hwsim_utils.test_connectivity(dev[0], hapd)
659 hapd.request("CHAN_SWITCH 5 5180 ht sec_channel_offset=1 bandwidth=40")
660 ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=10)
662 raise Exception("CSA finished event timed out")
663 if "freq=5180" not in ev:
664 raise Exception("Unexpected channel in CSA finished event")
665 ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
667 raise Exception("Unexpected STA disconnection during CSA")
668 hwsim_utils.test_connectivity(dev[0], hapd)
670 dev[0].request("DISCONNECT")
672 hapd.request("DISABLE")
673 subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
674 dev[0].flush_scan_cache()
676 def test_ap_ht40_csa2(dev, apdev):
677 """HT with 40 MHz channel width and CSA"""
678 if not csa_supported(dev[0]):
682 params = { "ssid": "ht",
683 "country_code": "US",
686 "ht_capab": "[HT40+]",
688 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
690 dev[0].connect("ht", key_mgmt="NONE", scan_freq="5180")
691 hwsim_utils.test_connectivity(dev[0], hapd)
693 hapd.request("CHAN_SWITCH 5 5220 ht sec_channel_offset=1 bandwidth=40")
694 ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=10)
696 raise Exception("CSA finished event timed out")
697 if "freq=5220" not in ev:
698 raise Exception("Unexpected channel in CSA finished event")
699 ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
701 raise Exception("Unexpected STA disconnection during CSA")
702 hwsim_utils.test_connectivity(dev[0], hapd)
704 hapd.request("CHAN_SWITCH 5 5180 ht sec_channel_offset=1 bandwidth=40")
705 ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=10)
707 raise Exception("CSA finished event timed out")
708 if "freq=5180" not in ev:
709 raise Exception("Unexpected channel in CSA finished event")
710 ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
712 raise Exception("Unexpected STA disconnection during CSA")
713 hwsim_utils.test_connectivity(dev[0], hapd)
715 dev[0].request("DISCONNECT")
717 hapd.request("DISABLE")
718 subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
719 dev[0].flush_scan_cache()
721 def test_ap_ht40_csa3(dev, apdev):
722 """HT with 40 MHz channel width and CSA"""
723 if not csa_supported(dev[0]):
727 params = { "ssid": "ht",
728 "country_code": "US",
731 "ht_capab": "[HT40+]",
733 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
735 dev[0].connect("ht", key_mgmt="NONE", scan_freq="5180")
736 hwsim_utils.test_connectivity(dev[0], hapd)
738 hapd.request("CHAN_SWITCH 5 5240 ht sec_channel_offset=-1 bandwidth=40")
739 ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=10)
741 raise Exception("CSA finished event timed out")
742 if "freq=5240" not in ev:
743 raise Exception("Unexpected channel in CSA finished event")
744 ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
746 raise Exception("Unexpected STA disconnection during CSA")
747 hwsim_utils.test_connectivity(dev[0], hapd)
749 hapd.request("CHAN_SWITCH 5 5180 ht sec_channel_offset=1 bandwidth=40")
750 ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=10)
752 raise Exception("CSA finished event timed out")
753 if "freq=5180" not in ev:
754 raise Exception("Unexpected channel in CSA finished event")
755 ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
757 raise Exception("Unexpected STA disconnection during CSA")
758 hwsim_utils.test_connectivity(dev[0], hapd)
760 dev[0].request("DISCONNECT")
762 hapd.request("DISABLE")
763 subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
764 dev[0].flush_scan_cache()
766 def test_ap_ht_smps(dev, apdev):
767 """SMPS AP configuration options"""
768 params = { "ssid": "ht1", "ht_capab": "[SMPS-STATIC]" }
769 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
770 params = { "ssid": "ht2", "ht_capab": "[SMPS-DYNAMIC]" }
771 hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)
773 dev[0].connect("ht1", key_mgmt="NONE", scan_freq="2412")
774 dev[1].connect("ht2", key_mgmt="NONE", scan_freq="2412")
775 hwsim_utils.test_connectivity(dev[0], hapd)
776 hwsim_utils.test_connectivity(dev[1], hapd2)