2013-03-29 16:19:47 +01:00
|
|
|
# TDLS tests
|
2014-04-05 17:53:12 +02:00
|
|
|
# Copyright (c) 2013-2014, Jouni Malinen <j@w1.fi>
|
2013-03-27 12:57:48 +01:00
|
|
|
#
|
|
|
|
# This software may be distributed under the terms of the BSD license.
|
|
|
|
# See README for more details.
|
|
|
|
|
2016-06-23 19:16:36 +02:00
|
|
|
from remotehost import remote_compatible
|
2013-03-27 12:57:48 +01:00
|
|
|
import time
|
|
|
|
import logging
|
2013-10-31 11:46:42 +01:00
|
|
|
logger = logging.getLogger()
|
2014-04-05 17:53:12 +02:00
|
|
|
import subprocess
|
2013-03-27 12:57:48 +01:00
|
|
|
|
|
|
|
import hwsim_utils
|
2013-03-29 17:37:03 +01:00
|
|
|
from hostapd import HostapdGlobal
|
|
|
|
from hostapd import Hostapd
|
2013-03-29 19:33:25 +01:00
|
|
|
import hostapd
|
2020-04-17 15:07:24 +02:00
|
|
|
from utils import *
|
2013-03-30 12:47:22 +01:00
|
|
|
from wlantest import Wlantest
|
2013-03-29 17:37:03 +01:00
|
|
|
|
2016-03-30 10:55:56 +02:00
|
|
|
def start_ap_wpa2_psk(ap):
|
2013-03-29 19:33:25 +01:00
|
|
|
params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678")
|
2016-03-30 10:55:56 +02:00
|
|
|
return hostapd.add_ap(ap, params)
|
2013-03-29 18:15:43 +01:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
def connectivity(dev, hapd):
|
2013-03-29 17:51:48 +01:00
|
|
|
hwsim_utils.test_connectivity_sta(dev[0], dev[1])
|
2014-10-19 16:54:49 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
hwsim_utils.test_connectivity(dev[1], hapd)
|
2013-03-29 17:51:48 +01:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
def connect_2sta(dev, ssid, hapd):
|
2013-11-02 10:22:16 +01:00
|
|
|
dev[0].connect(ssid, psk="12345678", scan_freq="2412")
|
|
|
|
dev[1].connect(ssid, psk="12345678", scan_freq="2412")
|
2019-12-26 10:39:12 +01:00
|
|
|
hapd.wait_sta()
|
|
|
|
hapd.wait_sta()
|
2014-10-19 16:54:49 +02:00
|
|
|
connectivity(dev, hapd)
|
2013-03-29 19:41:33 +01:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
def connect_2sta_wpa2_psk(dev, hapd):
|
|
|
|
connect_2sta(dev, "test-wpa2-psk", hapd)
|
2013-03-29 17:51:48 +01:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
def connect_2sta_wpa_psk(dev, hapd):
|
|
|
|
connect_2sta(dev, "test-wpa-psk", hapd)
|
2013-03-29 17:51:48 +01:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
def connect_2sta_wpa_psk_mixed(dev, hapd):
|
2013-11-02 10:22:16 +01:00
|
|
|
dev[0].connect("test-wpa-mixed-psk", psk="12345678", proto="WPA",
|
|
|
|
scan_freq="2412")
|
|
|
|
dev[1].connect("test-wpa-mixed-psk", psk="12345678", proto="WPA2",
|
|
|
|
scan_freq="2412")
|
2019-12-26 10:39:12 +01:00
|
|
|
hapd.wait_sta()
|
|
|
|
hapd.wait_sta()
|
2014-10-19 16:54:49 +02:00
|
|
|
connectivity(dev, hapd)
|
2013-03-29 18:15:43 +01:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
def connect_2sta_wep(dev, hapd):
|
2013-11-02 10:22:16 +01:00
|
|
|
dev[0].connect("test-wep", key_mgmt="NONE", wep_key0='"hello"',
|
|
|
|
scan_freq="2412")
|
|
|
|
dev[1].connect("test-wep", key_mgmt="NONE", wep_key0='"hello"',
|
|
|
|
scan_freq="2412")
|
2019-12-26 10:39:12 +01:00
|
|
|
hapd.wait_sta()
|
|
|
|
hapd.wait_sta()
|
2014-10-19 16:54:49 +02:00
|
|
|
connectivity(dev, hapd)
|
2013-03-29 18:15:43 +01:00
|
|
|
|
2014-12-20 17:29:57 +01:00
|
|
|
def connect_2sta_open(dev, hapd, scan_freq="2412"):
|
|
|
|
dev[0].connect("test-open", key_mgmt="NONE", scan_freq=scan_freq)
|
|
|
|
dev[1].connect("test-open", key_mgmt="NONE", scan_freq=scan_freq)
|
2019-12-26 10:39:12 +01:00
|
|
|
hapd.wait_sta()
|
|
|
|
hapd.wait_sta()
|
2014-10-19 16:54:49 +02:00
|
|
|
connectivity(dev, hapd)
|
2013-03-27 12:57:48 +01:00
|
|
|
|
2016-05-19 15:06:49 +02:00
|
|
|
def wlantest_setup(hapd):
|
|
|
|
Wlantest.setup(hapd)
|
2013-03-30 12:47:22 +01:00
|
|
|
wt = Wlantest()
|
|
|
|
wt.flush()
|
|
|
|
wt.add_passphrase("12345678")
|
|
|
|
wt.add_wepkey("68656c6c6f")
|
2013-03-27 12:57:48 +01:00
|
|
|
|
2013-03-27 15:05:52 +01:00
|
|
|
def wlantest_tdls_packet_counters(bssid, addr0, addr1):
|
2013-03-30 12:47:22 +01:00
|
|
|
wt = Wlantest()
|
|
|
|
dl = wt.get_tdls_counter("valid_direct_link", bssid, addr0, addr1)
|
|
|
|
inv_dl = wt.get_tdls_counter("invalid_direct_link", bssid, addr0, addr1)
|
|
|
|
ap = wt.get_tdls_counter("valid_ap_path", bssid, addr0, addr1)
|
|
|
|
inv_ap = wt.get_tdls_counter("invalid_ap_path", bssid, addr0, addr1)
|
2019-03-15 11:10:37 +01:00
|
|
|
return [dl, inv_dl, ap, inv_ap]
|
2013-03-27 15:05:52 +01:00
|
|
|
|
|
|
|
def tdls_check_dl(sta0, sta1, bssid, addr0, addr1):
|
2013-03-30 12:47:22 +01:00
|
|
|
wt = Wlantest()
|
|
|
|
wt.tdls_clear(bssid, addr0, addr1)
|
2013-03-27 15:05:52 +01:00
|
|
|
hwsim_utils.test_connectivity_sta(sta0, sta1)
|
2019-03-15 11:10:37 +01:00
|
|
|
[dl, inv_dl, ap, inv_ap] = wlantest_tdls_packet_counters(bssid, addr0, addr1)
|
2013-03-27 15:05:52 +01:00
|
|
|
if dl == 0:
|
|
|
|
raise Exception("No valid frames through direct link")
|
|
|
|
if inv_dl > 0:
|
|
|
|
raise Exception("Invalid frames through direct link")
|
|
|
|
if ap > 0:
|
|
|
|
raise Exception("Unexpected frames through AP path")
|
|
|
|
if inv_ap > 0:
|
|
|
|
raise Exception("Invalid frames through AP path")
|
|
|
|
|
|
|
|
def tdls_check_ap(sta0, sta1, bssid, addr0, addr1):
|
2013-03-30 12:47:22 +01:00
|
|
|
wt = Wlantest()
|
2016-07-03 18:37:50 +02:00
|
|
|
wt.tdls_clear(bssid, addr0, addr1)
|
2013-03-27 15:05:52 +01:00
|
|
|
hwsim_utils.test_connectivity_sta(sta0, sta1)
|
2019-03-15 11:10:37 +01:00
|
|
|
[dl, inv_dl, ap, inv_ap] = wlantest_tdls_packet_counters(bssid, addr0, addr1)
|
2013-03-27 15:05:52 +01:00
|
|
|
if dl > 0:
|
|
|
|
raise Exception("Unexpected frames through direct link")
|
|
|
|
if inv_dl > 0:
|
|
|
|
raise Exception("Invalid frames through direct link")
|
|
|
|
if ap == 0:
|
|
|
|
raise Exception("No valid frames through AP path")
|
|
|
|
if inv_ap > 0:
|
|
|
|
raise Exception("Invalid frames through AP path")
|
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
def check_connectivity(sta0, sta1, hapd):
|
2013-07-31 12:38:34 +02:00
|
|
|
hwsim_utils.test_connectivity_sta(sta0, sta1)
|
2014-10-19 16:54:49 +02:00
|
|
|
hwsim_utils.test_connectivity(sta0, hapd)
|
|
|
|
hwsim_utils.test_connectivity(sta1, hapd)
|
2013-07-31 12:38:34 +02:00
|
|
|
|
2016-04-07 07:38:07 +02:00
|
|
|
def setup_tdls(sta0, sta1, hapd, reverse=False, expect_fail=False):
|
2013-03-27 12:57:48 +01:00
|
|
|
logger.info("Setup TDLS")
|
2014-10-19 16:54:49 +02:00
|
|
|
check_connectivity(sta0, sta1, hapd)
|
2016-04-07 07:38:07 +02:00
|
|
|
bssid = hapd.own_addr()
|
2013-03-27 12:57:48 +01:00
|
|
|
addr0 = sta0.p2p_interface_addr()
|
|
|
|
addr1 = sta1.p2p_interface_addr()
|
2013-03-30 12:47:22 +01:00
|
|
|
wt = Wlantest()
|
2016-07-03 18:37:50 +02:00
|
|
|
wt.tdls_clear(bssid, addr0, addr1)
|
|
|
|
wt.tdls_clear(bssid, addr1, addr0)
|
2013-03-27 12:57:48 +01:00
|
|
|
sta0.tdls_setup(addr1)
|
|
|
|
time.sleep(1)
|
2013-03-27 15:40:49 +01:00
|
|
|
if expect_fail:
|
|
|
|
tdls_check_ap(sta0, sta1, bssid, addr0, addr1)
|
|
|
|
return
|
2013-03-27 12:57:48 +01:00
|
|
|
if reverse:
|
|
|
|
addr1 = sta0.p2p_interface_addr()
|
|
|
|
addr0 = sta1.p2p_interface_addr()
|
2016-07-03 18:37:50 +02:00
|
|
|
conf = wt.get_tdls_counter("setup_conf_ok", bssid, addr0, addr1)
|
2013-03-27 12:57:48 +01:00
|
|
|
if conf == 0:
|
|
|
|
raise Exception("No TDLS Setup Confirm (success) seen")
|
2013-03-27 15:05:52 +01:00
|
|
|
tdls_check_dl(sta0, sta1, bssid, addr0, addr1)
|
2014-10-19 16:54:49 +02:00
|
|
|
check_connectivity(sta0, sta1, hapd)
|
2013-03-27 12:57:48 +01:00
|
|
|
|
2016-04-07 07:38:07 +02:00
|
|
|
def teardown_tdls(sta0, sta1, hapd, responder=False, wildcard=False):
|
2013-03-27 12:57:48 +01:00
|
|
|
logger.info("Teardown TDLS")
|
2014-10-19 16:54:49 +02:00
|
|
|
check_connectivity(sta0, sta1, hapd)
|
2016-04-07 07:38:07 +02:00
|
|
|
bssid = hapd.own_addr()
|
2013-03-27 12:57:48 +01:00
|
|
|
addr0 = sta0.p2p_interface_addr()
|
|
|
|
addr1 = sta1.p2p_interface_addr()
|
2014-09-29 20:47:54 +02:00
|
|
|
if responder:
|
|
|
|
sta1.tdls_teardown(addr0)
|
2014-12-05 15:56:14 +01:00
|
|
|
elif wildcard:
|
|
|
|
sta0.tdls_teardown("*")
|
2014-09-29 20:47:54 +02:00
|
|
|
else:
|
|
|
|
sta0.tdls_teardown(addr1)
|
2013-03-27 12:57:48 +01:00
|
|
|
time.sleep(1)
|
2013-03-30 12:47:22 +01:00
|
|
|
wt = Wlantest()
|
2016-07-03 18:37:50 +02:00
|
|
|
teardown = wt.get_tdls_counter("teardown", bssid, addr0, addr1)
|
2013-03-27 12:57:48 +01:00
|
|
|
if teardown == 0:
|
|
|
|
raise Exception("No TDLS Setup Teardown seen")
|
2013-03-27 15:05:52 +01:00
|
|
|
tdls_check_ap(sta0, sta1, bssid, addr0, addr1)
|
2014-10-19 16:54:49 +02:00
|
|
|
check_connectivity(sta0, sta1, hapd)
|
2013-03-27 12:57:48 +01:00
|
|
|
|
2015-04-28 13:00:51 +02:00
|
|
|
def check_tdls_link(sta0, sta1, connected=True):
|
|
|
|
addr0 = sta0.own_addr()
|
|
|
|
addr1 = sta1.own_addr()
|
|
|
|
status0 = sta0.tdls_link_status(addr1).rstrip()
|
|
|
|
status1 = sta1.tdls_link_status(addr0).rstrip()
|
|
|
|
logger.info("%s: %s" % (sta0.ifname, status0))
|
|
|
|
logger.info("%s: %s" % (sta1.ifname, status1))
|
|
|
|
if status0 != status1:
|
|
|
|
raise Exception("TDLS link status differs between stations")
|
|
|
|
if "status: connected" in status0:
|
|
|
|
if not connected:
|
|
|
|
raise Exception("Expected TDLS link status NOT to be connected")
|
|
|
|
else:
|
|
|
|
if connected:
|
|
|
|
raise Exception("Expected TDLS link status to be connected")
|
|
|
|
|
2016-06-23 19:16:36 +02:00
|
|
|
@remote_compatible
|
2014-03-15 23:03:07 +01:00
|
|
|
def test_ap_tdls_discovery(dev, apdev):
|
|
|
|
"""WPA2-PSK AP and two stations using TDLS discovery"""
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = start_ap_wpa2_psk(apdev[0])
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-10-19 16:54:49 +02:00
|
|
|
connect_2sta_wpa2_psk(dev, hapd)
|
2014-03-15 23:03:07 +01:00
|
|
|
dev[0].request("TDLS_DISCOVER " + dev[1].p2p_interface_addr())
|
|
|
|
time.sleep(0.2)
|
|
|
|
|
2013-03-31 15:16:37 +02:00
|
|
|
def test_ap_wpa2_tdls(dev, apdev):
|
2013-03-27 12:57:48 +01:00
|
|
|
"""WPA2-PSK AP and two stations using TDLS"""
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = start_ap_wpa2_psk(apdev[0])
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-10-19 16:54:49 +02:00
|
|
|
connect_2sta_wpa2_psk(dev, hapd)
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[0], dev[1], hapd)
|
|
|
|
teardown_tdls(dev[0], dev[1], hapd)
|
|
|
|
setup_tdls(dev[1], dev[0], hapd)
|
|
|
|
#teardown_tdls(dev[0], dev[1], hapd)
|
2013-03-27 12:57:48 +01:00
|
|
|
|
2013-03-31 15:16:37 +02:00
|
|
|
def test_ap_wpa2_tdls_concurrent_init(dev, apdev):
|
2013-03-27 12:57:48 +01:00
|
|
|
"""Concurrent TDLS setup initiation"""
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = start_ap_wpa2_psk(apdev[0])
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-10-19 16:54:49 +02:00
|
|
|
connect_2sta_wpa2_psk(dev, hapd)
|
2013-03-27 12:57:48 +01:00
|
|
|
dev[0].request("SET tdls_testing 0x80")
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[1], dev[0], hapd, reverse=True)
|
2013-03-27 12:57:48 +01:00
|
|
|
|
2013-03-31 15:16:37 +02:00
|
|
|
def test_ap_wpa2_tdls_concurrent_init2(dev, apdev):
|
2013-03-27 12:57:48 +01:00
|
|
|
"""Concurrent TDLS setup initiation (reverse)"""
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = start_ap_wpa2_psk(apdev[0])
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-10-19 16:54:49 +02:00
|
|
|
connect_2sta_wpa2_psk(dev, hapd)
|
2013-03-27 12:57:48 +01:00
|
|
|
dev[1].request("SET tdls_testing 0x80")
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[0], dev[1], hapd)
|
2013-03-27 12:57:48 +01:00
|
|
|
|
2013-03-31 15:16:37 +02:00
|
|
|
def test_ap_wpa2_tdls_decline_resp(dev, apdev):
|
2013-03-27 15:40:49 +01:00
|
|
|
"""Decline TDLS Setup Response"""
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = start_ap_wpa2_psk(apdev[0])
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-10-19 16:54:49 +02:00
|
|
|
connect_2sta_wpa2_psk(dev, hapd)
|
2013-03-27 15:40:49 +01:00
|
|
|
dev[1].request("SET tdls_testing 0x200")
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[1], dev[0], hapd, expect_fail=True)
|
2013-03-27 15:40:49 +01:00
|
|
|
|
2013-03-31 15:16:37 +02:00
|
|
|
def test_ap_wpa2_tdls_long_lifetime(dev, apdev):
|
2013-03-27 15:40:49 +01:00
|
|
|
"""TDLS with long TPK lifetime"""
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = start_ap_wpa2_psk(apdev[0])
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-10-19 16:54:49 +02:00
|
|
|
connect_2sta_wpa2_psk(dev, hapd)
|
2013-03-27 15:40:49 +01:00
|
|
|
dev[1].request("SET tdls_testing 0x40")
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[1], dev[0], hapd)
|
2013-03-27 15:40:49 +01:00
|
|
|
|
2013-03-31 15:16:37 +02:00
|
|
|
def test_ap_wpa2_tdls_long_frame(dev, apdev):
|
2013-03-27 15:40:49 +01:00
|
|
|
"""TDLS with long setup/teardown frames"""
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = start_ap_wpa2_psk(apdev[0])
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-10-19 16:54:49 +02:00
|
|
|
connect_2sta_wpa2_psk(dev, hapd)
|
2013-03-27 15:40:49 +01:00
|
|
|
dev[0].request("SET tdls_testing 0x1")
|
|
|
|
dev[1].request("SET tdls_testing 0x1")
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[1], dev[0], hapd)
|
|
|
|
teardown_tdls(dev[1], dev[0], hapd)
|
|
|
|
setup_tdls(dev[0], dev[1], hapd)
|
2013-03-27 15:40:49 +01:00
|
|
|
|
2013-03-31 15:16:37 +02:00
|
|
|
def test_ap_wpa2_tdls_reneg(dev, apdev):
|
2013-03-27 15:40:49 +01:00
|
|
|
"""Renegotiate TDLS link"""
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = start_ap_wpa2_psk(apdev[0])
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-10-19 16:54:49 +02:00
|
|
|
connect_2sta_wpa2_psk(dev, hapd)
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[1], dev[0], hapd)
|
|
|
|
setup_tdls(dev[0], dev[1], hapd)
|
2013-03-27 15:40:49 +01:00
|
|
|
|
2013-03-31 15:16:37 +02:00
|
|
|
def test_ap_wpa2_tdls_wrong_lifetime_resp(dev, apdev):
|
2013-03-27 15:40:49 +01:00
|
|
|
"""Incorrect TPK lifetime in TDLS Setup Response"""
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = start_ap_wpa2_psk(apdev[0])
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-10-19 16:54:49 +02:00
|
|
|
connect_2sta_wpa2_psk(dev, hapd)
|
2013-03-27 15:40:49 +01:00
|
|
|
dev[1].request("SET tdls_testing 0x10")
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[0], dev[1], hapd, expect_fail=True)
|
2013-03-27 15:40:49 +01:00
|
|
|
|
2013-03-31 15:16:37 +02:00
|
|
|
def test_ap_wpa2_tdls_diff_rsnie(dev, apdev):
|
2013-03-27 15:40:49 +01:00
|
|
|
"""TDLS with different RSN IEs"""
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = start_ap_wpa2_psk(apdev[0])
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-10-19 16:54:49 +02:00
|
|
|
connect_2sta_wpa2_psk(dev, hapd)
|
2013-03-27 15:40:49 +01:00
|
|
|
dev[1].request("SET tdls_testing 0x2")
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[1], dev[0], hapd)
|
|
|
|
teardown_tdls(dev[1], dev[0], hapd)
|
2013-03-27 15:40:49 +01:00
|
|
|
|
2014-04-05 18:04:46 +02:00
|
|
|
def test_ap_wpa2_tdls_wrong_tpk_m2_mic(dev, apdev):
|
|
|
|
"""Incorrect MIC in TDLS Setup Response"""
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = start_ap_wpa2_psk(apdev[0])
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-10-19 16:54:49 +02:00
|
|
|
connect_2sta_wpa2_psk(dev, hapd)
|
2014-04-05 18:04:46 +02:00
|
|
|
dev[0].request("SET tdls_testing 0x800")
|
|
|
|
addr0 = dev[0].p2p_interface_addr()
|
|
|
|
dev[1].tdls_setup(addr0)
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
def test_ap_wpa2_tdls_wrong_tpk_m3_mic(dev, apdev):
|
|
|
|
"""Incorrect MIC in TDLS Setup Confirm"""
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = start_ap_wpa2_psk(apdev[0])
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-10-19 16:54:49 +02:00
|
|
|
connect_2sta_wpa2_psk(dev, hapd)
|
2014-04-05 18:04:46 +02:00
|
|
|
dev[1].request("SET tdls_testing 0x800")
|
|
|
|
addr0 = dev[0].p2p_interface_addr()
|
|
|
|
dev[1].tdls_setup(addr0)
|
|
|
|
time.sleep(1)
|
|
|
|
|
2017-11-20 23:49:17 +01:00
|
|
|
def test_ap_wpa2_tdls_double_tpk_m2(dev, apdev):
|
|
|
|
"""Double TPK M2 during TDLS setup initiation"""
|
|
|
|
hapd = start_ap_wpa2_psk(apdev[0])
|
|
|
|
wlantest_setup(hapd)
|
|
|
|
connect_2sta_wpa2_psk(dev, hapd)
|
|
|
|
dev[0].request("SET tdls_testing 0x1000")
|
|
|
|
setup_tdls(dev[1], dev[0], hapd)
|
|
|
|
|
2013-03-31 15:16:37 +02:00
|
|
|
def test_ap_wpa_tdls(dev, apdev):
|
2013-03-29 17:51:48 +01:00
|
|
|
"""WPA-PSK AP and two stations using TDLS"""
|
2015-08-01 21:54:07 +02:00
|
|
|
skip_with_fips(dev[0])
|
2020-04-17 15:07:24 +02:00
|
|
|
skip_without_tkip(dev[0])
|
|
|
|
skip_without_tkip(dev[1])
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0],
|
2014-10-19 16:54:49 +02:00
|
|
|
hostapd.wpa_params(ssid="test-wpa-psk",
|
|
|
|
passphrase="12345678"))
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-10-19 16:54:49 +02:00
|
|
|
connect_2sta_wpa_psk(dev, hapd)
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[0], dev[1], hapd)
|
|
|
|
teardown_tdls(dev[0], dev[1], hapd)
|
|
|
|
setup_tdls(dev[1], dev[0], hapd)
|
2013-03-29 17:51:48 +01:00
|
|
|
|
2013-03-31 15:16:37 +02:00
|
|
|
def test_ap_wpa_mixed_tdls(dev, apdev):
|
2013-03-29 17:51:48 +01:00
|
|
|
"""WPA+WPA2-PSK AP and two stations using TDLS"""
|
2015-08-01 21:54:07 +02:00
|
|
|
skip_with_fips(dev[0])
|
2020-04-17 15:07:24 +02:00
|
|
|
skip_without_tkip(dev[0])
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0],
|
2014-10-19 16:54:49 +02:00
|
|
|
hostapd.wpa_mixed_params(ssid="test-wpa-mixed-psk",
|
|
|
|
passphrase="12345678"))
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-10-19 16:54:49 +02:00
|
|
|
connect_2sta_wpa_psk_mixed(dev, hapd)
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[0], dev[1], hapd)
|
|
|
|
teardown_tdls(dev[0], dev[1], hapd)
|
|
|
|
setup_tdls(dev[1], dev[0], hapd)
|
2013-03-29 17:51:48 +01:00
|
|
|
|
2013-03-31 15:16:37 +02:00
|
|
|
def test_ap_wep_tdls(dev, apdev):
|
2013-03-29 18:15:43 +01:00
|
|
|
"""WEP AP and two stations using TDLS"""
|
2020-02-29 15:52:39 +01:00
|
|
|
check_wep_capa(dev[0])
|
|
|
|
check_wep_capa(dev[1])
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0],
|
2019-03-15 11:10:37 +01:00
|
|
|
{"ssid": "test-wep", "wep_key0": '"hello"'})
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-10-19 16:54:49 +02:00
|
|
|
connect_2sta_wep(dev, hapd)
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[0], dev[1], hapd)
|
|
|
|
teardown_tdls(dev[0], dev[1], hapd)
|
|
|
|
setup_tdls(dev[1], dev[0], hapd)
|
2013-03-29 18:15:43 +01:00
|
|
|
|
2013-03-31 15:16:37 +02:00
|
|
|
def test_ap_open_tdls(dev, apdev):
|
2013-03-29 18:15:43 +01:00
|
|
|
"""Open AP and two stations using TDLS"""
|
2019-03-15 11:10:37 +01:00
|
|
|
hapd = hostapd.add_ap(apdev[0], {"ssid": "test-open"})
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-10-19 16:54:49 +02:00
|
|
|
connect_2sta_open(dev, hapd)
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[0], dev[1], hapd)
|
|
|
|
teardown_tdls(dev[0], dev[1], hapd)
|
|
|
|
setup_tdls(dev[1], dev[0], hapd)
|
|
|
|
teardown_tdls(dev[1], dev[0], hapd, wildcard=True)
|
2014-04-05 17:53:12 +02:00
|
|
|
|
|
|
|
def test_ap_wpa2_tdls_bssid_mismatch(dev, apdev):
|
|
|
|
"""TDLS failure due to BSSID mismatch"""
|
|
|
|
try:
|
|
|
|
ssid = "test-wpa2-psk"
|
|
|
|
passphrase = "12345678"
|
|
|
|
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
|
|
|
|
params['bridge'] = 'ap-br0'
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
|
|
|
hostapd.add_ap(apdev[1], params)
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2015-02-06 23:22:32 +01:00
|
|
|
subprocess.call(['brctl', 'setfd', 'ap-br0', '0'])
|
|
|
|
subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'up'])
|
2014-04-05 17:53:12 +02:00
|
|
|
dev[0].connect(ssid, psk=passphrase, scan_freq="2412",
|
|
|
|
bssid=apdev[0]['bssid'])
|
|
|
|
dev[1].connect(ssid, psk=passphrase, scan_freq="2412",
|
|
|
|
bssid=apdev[1]['bssid'])
|
2014-10-19 16:54:49 +02:00
|
|
|
hwsim_utils.test_connectivity_sta(dev[0], dev[1])
|
2014-11-27 13:04:51 +01:00
|
|
|
hwsim_utils.test_connectivity_iface(dev[0], hapd, "ap-br0")
|
|
|
|
hwsim_utils.test_connectivity_iface(dev[1], hapd, "ap-br0")
|
2014-10-19 16:54:49 +02:00
|
|
|
|
2014-04-05 17:53:12 +02:00
|
|
|
addr0 = dev[0].p2p_interface_addr()
|
|
|
|
dev[1].tdls_setup(addr0)
|
|
|
|
time.sleep(1)
|
|
|
|
hwsim_utils.test_connectivity_sta(dev[0], dev[1])
|
|
|
|
finally:
|
2015-02-06 23:22:32 +01:00
|
|
|
subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'down'])
|
|
|
|
subprocess.call(['brctl', 'delbr', 'ap-br0'])
|
2014-09-29 20:47:54 +02:00
|
|
|
|
|
|
|
def test_ap_wpa2_tdls_responder_teardown(dev, apdev):
|
|
|
|
"""TDLS teardown from responder with WPA2-PSK AP"""
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = start_ap_wpa2_psk(apdev[0])
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-10-19 16:54:49 +02:00
|
|
|
connect_2sta_wpa2_psk(dev, hapd)
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[0], dev[1], hapd)
|
|
|
|
teardown_tdls(dev[0], dev[1], hapd, responder=True)
|
2014-12-20 17:29:57 +01:00
|
|
|
|
2018-12-29 16:01:01 +01:00
|
|
|
def tdls_clear_reg(hapd, dev):
|
|
|
|
if hapd:
|
|
|
|
hapd.request("DISABLE")
|
|
|
|
dev[1].request("DISCONNECT")
|
2019-03-17 16:55:43 +01:00
|
|
|
dev[0].disconnect_and_stop_scan()
|
|
|
|
dev[1].disconnect_and_stop_scan()
|
2018-12-29 16:01:01 +01:00
|
|
|
subprocess.call(['iw', 'reg', 'set', '00'])
|
|
|
|
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
|
|
|
dev[0].flush_scan_cache()
|
|
|
|
dev[1].flush_scan_cache()
|
|
|
|
|
2014-12-20 17:29:57 +01:00
|
|
|
def test_ap_open_tdls_vht(dev, apdev):
|
|
|
|
"""Open AP and two stations using TDLS"""
|
2019-03-15 11:10:37 +01:00
|
|
|
params = {"ssid": "test-open",
|
|
|
|
"country_code": "DE",
|
|
|
|
"hw_mode": "a",
|
|
|
|
"channel": "36",
|
|
|
|
"ieee80211n": "1",
|
|
|
|
"ieee80211ac": "1",
|
|
|
|
"ht_capab": "",
|
|
|
|
"vht_capab": "",
|
|
|
|
"vht_oper_chwidth": "0",
|
|
|
|
"vht_oper_centr_freq_seg0_idx": "0"}
|
2016-06-23 19:16:32 +02:00
|
|
|
hapd = None
|
2014-12-20 17:29:57 +01:00
|
|
|
try:
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2014-12-20 17:29:57 +01:00
|
|
|
connect_2sta_open(dev, hapd, scan_freq="5180")
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[0], dev[1], hapd)
|
|
|
|
teardown_tdls(dev[0], dev[1], hapd)
|
|
|
|
setup_tdls(dev[1], dev[0], hapd)
|
|
|
|
teardown_tdls(dev[1], dev[0], hapd, wildcard=True)
|
2014-12-20 17:29:57 +01:00
|
|
|
finally:
|
2018-12-29 16:01:01 +01:00
|
|
|
tdls_clear_reg(hapd, dev)
|
2015-01-04 20:45:18 +01:00
|
|
|
|
2015-12-17 18:26:40 +01:00
|
|
|
def test_ap_open_tdls_vht80(dev, apdev):
|
|
|
|
"""Open AP and two stations using TDLS with VHT 80"""
|
2019-03-15 11:10:37 +01:00
|
|
|
params = {"ssid": "test-open",
|
|
|
|
"country_code": "US",
|
|
|
|
"hw_mode": "a",
|
|
|
|
"channel": "36",
|
|
|
|
"ht_capab": "[HT40+]",
|
|
|
|
"ieee80211n": "1",
|
|
|
|
"ieee80211ac": "1",
|
|
|
|
"vht_capab": "",
|
|
|
|
"vht_oper_chwidth": "1",
|
|
|
|
"vht_oper_centr_freq_seg0_idx": "42"}
|
2015-12-17 18:26:40 +01:00
|
|
|
try:
|
|
|
|
hapd = None
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2015-12-17 18:26:40 +01:00
|
|
|
connect_2sta_open(dev, hapd, scan_freq="5180")
|
|
|
|
sig = dev[0].request("SIGNAL_POLL").splitlines()
|
|
|
|
if "WIDTH=80 MHz" not in sig:
|
|
|
|
raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[0], dev[1], hapd)
|
2015-12-17 18:26:40 +01:00
|
|
|
for i in range(10):
|
|
|
|
check_connectivity(dev[0], dev[1], hapd)
|
|
|
|
for i in range(2):
|
|
|
|
cmd = subprocess.Popen(['iw', dev[0].ifname, 'station', 'dump'],
|
|
|
|
stdout=subprocess.PIPE)
|
|
|
|
res = cmd.stdout.read()
|
|
|
|
cmd.stdout.close()
|
2019-03-13 19:40:31 +01:00
|
|
|
logger.info("Station dump on dev[%d]:\n%s" % (i, res.decode()))
|
2019-01-24 08:45:41 +01:00
|
|
|
except Exception as e:
|
2015-12-17 18:26:40 +01:00
|
|
|
if isinstance(e, Exception) and str(e) == "AP startup failed":
|
|
|
|
if not vht_supported():
|
|
|
|
raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
|
|
|
|
raise
|
|
|
|
finally:
|
2018-12-29 16:01:01 +01:00
|
|
|
tdls_clear_reg(hapd, dev)
|
2015-12-17 18:26:40 +01:00
|
|
|
|
|
|
|
def test_ap_open_tdls_vht80plus80(dev, apdev):
|
|
|
|
"""Open AP and two stations using TDLS with VHT 80+80"""
|
2019-03-15 11:10:37 +01:00
|
|
|
params = {"ssid": "test-open",
|
|
|
|
"country_code": "US",
|
|
|
|
"hw_mode": "a",
|
|
|
|
"channel": "36",
|
|
|
|
"ht_capab": "[HT40+]",
|
|
|
|
"ieee80211n": "1",
|
|
|
|
"ieee80211ac": "1",
|
|
|
|
"vht_capab": "",
|
|
|
|
"vht_oper_chwidth": "3",
|
|
|
|
"vht_oper_centr_freq_seg0_idx": "42",
|
|
|
|
"vht_oper_centr_freq_seg1_idx": "155"}
|
2015-12-17 18:26:40 +01:00
|
|
|
try:
|
|
|
|
hapd = None
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2015-12-17 18:26:40 +01:00
|
|
|
connect_2sta_open(dev, hapd, scan_freq="5180")
|
|
|
|
sig = dev[0].request("SIGNAL_POLL").splitlines()
|
|
|
|
if "FREQUENCY=5180" not in sig:
|
|
|
|
raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
|
|
|
|
if "WIDTH=80+80 MHz" not in sig:
|
|
|
|
raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
|
|
|
|
if "CENTER_FRQ1=5210" not in sig:
|
|
|
|
raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig))
|
|
|
|
if "CENTER_FRQ2=5775" not in sig:
|
|
|
|
raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig))
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[0], dev[1], hapd)
|
2015-12-17 18:26:40 +01:00
|
|
|
for i in range(10):
|
|
|
|
check_connectivity(dev[0], dev[1], hapd)
|
|
|
|
for i in range(2):
|
|
|
|
cmd = subprocess.Popen(['iw', dev[0].ifname, 'station', 'dump'],
|
|
|
|
stdout=subprocess.PIPE)
|
|
|
|
res = cmd.stdout.read()
|
|
|
|
cmd.stdout.close()
|
2019-03-13 19:40:31 +01:00
|
|
|
logger.info("Station dump on dev[%d]:\n%s" % (i, res.decode()))
|
2019-01-24 08:45:41 +01:00
|
|
|
except Exception as e:
|
2015-12-17 18:26:40 +01:00
|
|
|
if isinstance(e, Exception) and str(e) == "AP startup failed":
|
|
|
|
if not vht_supported():
|
|
|
|
raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
|
|
|
|
raise
|
|
|
|
finally:
|
2018-12-29 16:01:01 +01:00
|
|
|
tdls_clear_reg(hapd, dev)
|
2015-12-17 18:26:40 +01:00
|
|
|
|
|
|
|
def test_ap_open_tdls_vht160(dev, apdev):
|
|
|
|
"""Open AP and two stations using TDLS with VHT 160"""
|
2019-03-15 11:10:37 +01:00
|
|
|
params = {"ssid": "test-open",
|
|
|
|
"country_code": "ZA",
|
|
|
|
"hw_mode": "a",
|
|
|
|
"channel": "104",
|
|
|
|
"ht_capab": "[HT40-]",
|
|
|
|
"ieee80211n": "1",
|
|
|
|
"ieee80211ac": "1",
|
|
|
|
"vht_oper_chwidth": "2",
|
|
|
|
"vht_oper_centr_freq_seg0_idx": "114"}
|
2015-12-17 18:26:40 +01:00
|
|
|
try:
|
|
|
|
hapd = None
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False)
|
2015-12-17 18:26:40 +01:00
|
|
|
ev = hapd.wait_event(["AP-ENABLED"], timeout=2)
|
|
|
|
if not ev:
|
|
|
|
cmd = subprocess.Popen(["iw", "reg", "get"], stdout=subprocess.PIPE)
|
|
|
|
reg = cmd.stdout.readlines()
|
|
|
|
for r in reg:
|
|
|
|
if "5490" in r and "DFS" in r:
|
|
|
|
raise HwsimSkip("ZA regulatory rule did not have DFS requirement removed")
|
|
|
|
raise Exception("AP setup timed out")
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2015-12-17 18:26:40 +01:00
|
|
|
connect_2sta_open(dev, hapd, scan_freq="5520")
|
|
|
|
sig = dev[0].request("SIGNAL_POLL").splitlines()
|
|
|
|
if "WIDTH=160 MHz" not in sig:
|
|
|
|
raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[0], dev[1], hapd)
|
2015-12-17 18:26:40 +01:00
|
|
|
for i in range(10):
|
|
|
|
check_connectivity(dev[0], dev[1], hapd)
|
|
|
|
for i in range(2):
|
|
|
|
cmd = subprocess.Popen(['iw', dev[0].ifname, 'station', 'dump'],
|
|
|
|
stdout=subprocess.PIPE)
|
|
|
|
res = cmd.stdout.read()
|
|
|
|
cmd.stdout.close()
|
2019-03-13 19:40:31 +01:00
|
|
|
logger.info("Station dump on dev[%d]:\n%s" % (i, res.decode()))
|
2019-01-24 08:45:41 +01:00
|
|
|
except Exception as e:
|
2015-12-17 18:26:40 +01:00
|
|
|
if isinstance(e, Exception) and str(e) == "AP startup failed":
|
|
|
|
if not vht_supported():
|
|
|
|
raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
|
|
|
|
raise
|
|
|
|
finally:
|
2018-12-29 16:01:01 +01:00
|
|
|
tdls_clear_reg(hapd, dev)
|
2015-12-17 18:26:40 +01:00
|
|
|
|
2015-01-04 20:45:18 +01:00
|
|
|
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:
|
2015-01-07 13:19:30 +01:00
|
|
|
raise HwsimSkip("Driver does not support TDLS channel switching")
|
2015-01-04 20:45:18 +01:00
|
|
|
|
2019-03-15 11:10:37 +01:00
|
|
|
hapd = hostapd.add_ap(apdev[0], {"ssid": "test-open"})
|
2016-06-23 19:16:34 +02:00
|
|
|
wlantest_setup(hapd)
|
2015-01-04 20:45:18 +01:00
|
|
|
connect_2sta_open(dev, hapd)
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[0], dev[1], hapd)
|
2015-01-04 20:45:18 +01:00
|
|
|
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")
|
2017-01-08 16:16:01 +01:00
|
|
|
if "FAIL" not in dev[0].request("TDLS_CHAN_SWITCH foo 81 2462"):
|
|
|
|
raise Exception("Invalid TDLS channel switching command accepted")
|
2015-04-28 13:00:51 +02:00
|
|
|
|
|
|
|
def test_ap_tdls_link_status(dev, apdev):
|
|
|
|
"""Check TDLS link status between two stations"""
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = start_ap_wpa2_psk(apdev[0])
|
2016-05-19 15:06:49 +02:00
|
|
|
wlantest_setup(hapd)
|
2015-04-28 13:00:51 +02:00
|
|
|
connect_2sta_wpa2_psk(dev, hapd)
|
|
|
|
check_tdls_link(dev[0], dev[1], connected=False)
|
2016-04-07 07:38:07 +02:00
|
|
|
setup_tdls(dev[0], dev[1], hapd)
|
2015-04-28 13:00:51 +02:00
|
|
|
check_tdls_link(dev[0], dev[1], connected=True)
|
2016-04-07 07:38:07 +02:00
|
|
|
teardown_tdls(dev[0], dev[1], hapd)
|
2015-04-28 13:00:51 +02:00
|
|
|
check_tdls_link(dev[0], dev[1], connected=False)
|
|
|
|
if "FAIL" not in dev[0].request("TDLS_LINK_STATUS foo"):
|
|
|
|
raise Exception("Unexpected TDLS_LINK_STATUS response for invalid argument")
|
2016-10-28 23:25:17 +02:00
|
|
|
|
|
|
|
def test_ap_tdls_prohibit(dev, apdev):
|
|
|
|
"""Open AP and TDLS prohibited"""
|
2019-03-15 11:10:37 +01:00
|
|
|
hapd = hostapd.add_ap(apdev[0], {"ssid": "test-open",
|
|
|
|
"tdls_prohibit": "1"})
|
2016-10-28 23:25:17 +02:00
|
|
|
connect_2sta_open(dev, hapd)
|
|
|
|
if "FAIL" not in dev[0].request("TDLS_SETUP " + dev[1].own_addr()):
|
|
|
|
raise Exception("TDLS_SETUP accepted unexpectedly")
|
|
|
|
|
|
|
|
def test_ap_tdls_chan_switch_prohibit(dev, apdev):
|
|
|
|
"""Open AP and TDLS channel switch prohibited"""
|
2019-03-15 11:10:37 +01:00
|
|
|
hapd = hostapd.add_ap(apdev[0], {"ssid": "test-open",
|
|
|
|
"tdls_prohibit_chan_switch": "1"})
|
2016-10-28 23:25:17 +02:00
|
|
|
wlantest_setup(hapd)
|
|
|
|
connect_2sta_open(dev, hapd)
|
|
|
|
setup_tdls(dev[0], dev[1], hapd)
|
2017-01-08 16:12:55 +01:00
|
|
|
|
|
|
|
def test_ap_open_tdls_external_control(dev, apdev):
|
|
|
|
"""TDLS and tdls_external_control"""
|
|
|
|
try:
|
|
|
|
_test_ap_open_tdls_external_control(dev, apdev)
|
|
|
|
finally:
|
|
|
|
dev[0].set("tdls_external_control", "0")
|
|
|
|
|
|
|
|
def _test_ap_open_tdls_external_control(dev, apdev):
|
2019-03-15 11:10:37 +01:00
|
|
|
hapd = hostapd.add_ap(apdev[0], {"ssid": "test-open"})
|
2017-01-08 16:12:55 +01:00
|
|
|
dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
|
|
|
|
dev[1].connect("test-open", key_mgmt="NONE", scan_freq="2412")
|
|
|
|
addr0 = dev[0].own_addr()
|
|
|
|
addr1 = dev[1].own_addr()
|
|
|
|
|
|
|
|
dev[0].set("tdls_external_control", "1")
|
|
|
|
if "FAIL" in dev[0].request("TDLS_SETUP " + addr1):
|
|
|
|
# tdls_external_control not supported; try without it
|
|
|
|
dev[0].set("tdls_external_control", "0")
|
|
|
|
if "FAIL" in dev[0].request("TDLS_SETUP " + addr1):
|
|
|
|
raise Exception("TDLS_SETUP failed")
|
|
|
|
connected = False
|
|
|
|
for i in range(50):
|
|
|
|
res0 = dev[0].request("TDLS_LINK_STATUS " + addr1)
|
|
|
|
res1 = dev[1].request("TDLS_LINK_STATUS " + addr0)
|
|
|
|
if "TDLS link status: connected" in res0 and "TDLS link status: connected" in res1:
|
|
|
|
connected = True
|
|
|
|
break
|
|
|
|
time.sleep(0.1)
|
|
|
|
if not connected:
|
|
|
|
raise Exception("TDLS setup did not complete")
|
|
|
|
|
|
|
|
dev[0].set("tdls_external_control", "1")
|
|
|
|
if "FAIL" in dev[0].request("TDLS_TEARDOWN " + addr1):
|
|
|
|
# tdls_external_control not supported; try without it
|
|
|
|
dev[0].set("tdls_external_control", "0")
|
|
|
|
if "FAIL" in dev[0].request("TDLS_TEARDOWN " + addr1):
|
|
|
|
raise Exception("TDLS_TEARDOWN failed")
|
|
|
|
for i in range(50):
|
|
|
|
res0 = dev[0].request("TDLS_LINK_STATUS " + addr1)
|
|
|
|
res1 = dev[1].request("TDLS_LINK_STATUS " + addr0)
|
|
|
|
if "TDLS link status: connected" not in res0 and "TDLS link status: connected" not in res1:
|
|
|
|
connected = False
|
|
|
|
break
|
|
|
|
time.sleep(0.1)
|
|
|
|
if connected:
|
|
|
|
raise Exception("TDLS teardown did not complete")
|