subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
dev[0].flush_scan_cache()
dev[1].flush_scan_cache()
+
+def test_tdls_chan_switch(dev, apdev):
+ """Open AP and two stations using TDLS"""
+ flags = int(dev[0].get_driver_status_field('capa.flags'), 16)
+ if flags & 0x800000000 == 0:
+ logger.info("Driver does not support TDLS channel switching")
+ return "skip"
+
+ hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
+ connect_2sta_open(dev, hapd)
+ setup_tdls(dev[0], dev[1], apdev[0])
+ if "OK" not in dev[0].request("TDLS_CHAN_SWITCH " + dev[1].own_addr() + " 81 2462"):
+ raise Exception("Failed to enable TDLS channel switching")
+ if "OK" not in dev[0].request("TDLS_CANCEL_CHAN_SWITCH " + dev[1].own_addr()):
+ raise Exception("Could not disable TDLS channel switching")
+ if "FAIL" not in dev[0].request("TDLS_CANCEL_CHAN_SWITCH " + dev[1].own_addr()):
+ raise Exception("TDLS_CANCEL_CHAN_SWITCH accepted even though channel switching was already disabled")
if "FAIL" not in dev[0].request("TDLS_DISCOVER 00:11:22:33:44:55"):
raise Exception("Unexpected success on TDLS_DISCOVER")
+def test_wpas_ctrl_tdls_chan_switch(dev):
+ """wpa_supplicant ctrl_iface tdls_chan_switch error cases"""
+ for args in [ '', '00:11:22:33:44:55' ]:
+ if "FAIL" not in dev[0].request("TDLS_CANCEL_CHAN_SWITCH " + args):
+ raise Exception("Unexpected success on invalid TDLS_CANCEL_CHAN_SWITCH: " + args)
+
+ for args in [ '', 'foo ', '00:11:22:33:44:55 ', '00:11:22:33:44:55 q',
+ '00:11:22:33:44:55 81', '00:11:22:33:44:55 81 1234',
+ '00:11:22:33:44:55 81 1234 center_freq1=234 center_freq2=345 bandwidth=456 sec_channel_offset=567 ht vht' ]:
+ if "FAIL" not in dev[0].request("TDLS_CHAN_SWITCH " + args):
+ raise Exception("Unexpected success on invalid TDLS_CHAN_SWITCH: " + args)
+
def test_wpas_ctrl_addr(dev):
"""wpa_supplicant ctrl_iface invalid address"""
if "FAIL" not in dev[0].request("TDLS_SETUP "):