]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: TDLS link status test
authorOren Givon <oren.givon@intel.com>
Tue, 28 Apr 2015 11:00:51 +0000 (14:00 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 3 May 2015 14:24:38 +0000 (17:24 +0300)
Add a test case for checking TDLS link status.

Signed-off-by: Oren Givon <oren.givon@intel.com>
tests/hwsim/test_ap_tdls.py
tests/hwsim/wpasupplicant.py

index b2e458620ca99c7bc3512dcfce30627bef759753..95a76b4d730960b5e4dcd482a3b2d5bc92258cbe 100644 (file)
@@ -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")
index e29b3fc3bd63d89a0673b565dfbb1e19fff1048d..53df0390ce2e6b8fede6643f5838daaeb9c44163 100644 (file)
@@ -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")