diff --git a/tests/hwsim/test_ap_tdls.py b/tests/hwsim/test_ap_tdls.py index b2e458620..95a76b4d7 100644 --- a/tests/hwsim/test_ap_tdls.py +++ b/tests/hwsim/test_ap_tdls.py @@ -147,6 +147,22 @@ def teardown_tdls(sta0, sta1, ap, responder=False, wildcard=False): tdls_check_ap(sta0, sta1, bssid, addr0, addr1) check_connectivity(sta0, sta1, hapd) +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") + def test_ap_tdls_discovery(dev, apdev): """WPA2-PSK AP and two stations using TDLS discovery""" hapd = start_ap_wpa2_psk(apdev[0]['ifname']) @@ -375,3 +391,16 @@ def test_tdls_chan_switch(dev, apdev): 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") + +def test_ap_tdls_link_status(dev, apdev): + """Check TDLS link status between two stations""" + hapd = start_ap_wpa2_psk(apdev[0]['ifname']) + wlantest_setup() + connect_2sta_wpa2_psk(dev, hapd) + check_tdls_link(dev[0], dev[1], connected=False) + setup_tdls(dev[0], dev[1], apdev[0]) + check_tdls_link(dev[0], dev[1], connected=True) + teardown_tdls(dev[0], dev[1], apdev[0]) + 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") diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index e29b3fc3b..53df0390c 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -760,6 +760,13 @@ class WpaSupplicant: raise Exception("Failed to request TDLS teardown") return None + def tdls_link_status(self, peer): + cmd = "TDLS_LINK_STATUS " + peer + ret = self.group_request(cmd) + if "FAIL" in ret: + raise Exception("Failed to request TDLS link status") + return ret + def tspecs(self): """Return (tsid, up) tuples representing current tspecs""" res = self.request("WMM_AC_STATUS")