]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: FST control interface behavior
authorJouni Malinen <jouni@qca.qualcomm.com>
Tue, 9 Jun 2015 09:19:47 +0000 (12:19 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 16 Jul 2015 15:26:16 +0000 (18:26 +0300)
Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
tests/hwsim/fst_module_aux.py
tests/hwsim/test_fst_module.py

index 47ccd3017b5e1e822536b9f64a88796c7a03268c..c5164923847d8b67eb7ed83fbf163444dbbe9009 100644 (file)
@@ -262,6 +262,48 @@ class FstDevice:
             request = request + ' ' + params
         return self.grequest(request)
 
+    def get_session_params(self, sid):
+        request = "FST-MANAGER SESSION_GET " + sid
+        res = self.grequest(request)
+        if res.startswith("FAIL"):
+            return None
+        params = {}
+        for i in res.splitlines():
+            p = i.split('=')
+            params[p[0]] = p[1]
+        return params
+
+    def iface_peers(self, ifname):
+        grp = self.fst_group if self.fst_group != '' else ''
+        res = self.grequest("FST-MANAGER IFACE_PEERS " + grp + ' ' + ifname)
+        if res.startswith("FAIL"):
+            return None
+        return res.splitlines()
+
+    def get_peer_mbies(self, ifname, peer_addr):
+        return self.grequest("FST-MANAGER GET_PEER_MBIES %s %s" % (ifname, peer_addr))
+
+    def list_ifaces(self):
+        grp = self.fst_group if self.fst_group != '' else ''
+        res = self.grequest("FST-MANAGER LIST_IFACES " + grp)
+        if res.startswith("FAIL"):
+            return None
+        ifaces = []
+        for i in res.splitlines():
+            p = i.split(':')
+            iface = {}
+            iface['name'] = p[0]
+            iface['priority'] = p[1]
+            iface['llt'] = p[2]
+            ifaces.append(iface)
+        return ifaces
+
+    def list_groups(self):
+        res = self.grequest("FST-MANAGER LIST_GROUPS")
+        if res.startswith("FAIL"):
+            return None
+        return res.splitlines()
+
     def configure_session(self, sid, new_iface, old_iface = None):
         """Calls session_set for a number of parameters some of which are stored
         in "self" while others are passed to this function explicitly. If
index a242d291f5c20d8e776719c03ea2b2adf1575d85..95b651e1e5b45a83299725c723196650bb248bc2 100644 (file)
@@ -1401,6 +1401,85 @@ def test_fst_ap_remove_session_bad_session_id(dev, apdev, test_params):
     """FST AP remove session - bad session id"""
     fst_remove_session(apdev, test_params, remove_scenario_bad_session_id, True)
 
+def test_fst_ap_ctrl_iface(dev, apdev, test_params):
+    """FST control interface behavior"""
+    ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
+    try:
+        fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
+        initiator = ap1
+        responder = sta1
+        initiator.add_peer(responder, None)
+        initiator.set_fst_parameters(group_id=None)
+        sid = initiator.add_session()
+        res = initiator.get_session_params(sid)
+        logger.info("Initial session params:\n" + str(res))
+        if res['state'] != 'INITIAL':
+            raise Exception("Unexpected state: " + res['state'])
+        initiator.set_fst_parameters(llt=None)
+        initiator.configure_session(sid, ap2.ifname(), None)
+        res = initiator.get_session_params(sid)
+        logger.info("Session params after configuration:\n" + str(res))
+        res = initiator.iface_peers(initiator.ifname())
+        logger.info("Interface peers: " + str(res))
+        if len(res) != 1:
+            raise Exception("Unexpected number of peers")
+        res = initiator.get_peer_mbies(initiator.ifname(),
+                                       initiator.get_new_peer_addr())
+        logger.info("Peer MB IEs: " + str(res))
+        res = initiator.list_ifaces()
+        logger.info("Interfaces: " + str(res))
+        if len(res) != 2:
+            raise Exception("Unexpected number of interfaces")
+        res = initiator.list_groups()
+        logger.info("Groups: " + str(res))
+        if len(res) != 1:
+            raise Exception("Unexpected number of groups")
+
+        tests = [ "LIST_IFACES unknown",
+                  "LIST_IFACES     unknown2",
+                  "SESSION_GET 12345678",
+                  "SESSION_SET " + sid + " unknown=foo",
+                  "SESSION_RESPOND 12345678 foo",
+                  "SESSION_RESPOND " + sid,
+                  "SESSION_RESPOND " + sid + " foo",
+                  "TEST_REQUEST foo",
+                  "GET_PEER_MBIES",
+                  "GET_PEER_MBIES ",
+                  "GET_PEER_MBIES unknown",
+                  "GET_PEER_MBIES unknown unknown",
+                  "GET_PEER_MBIES unknown  " + initiator.get_new_peer_addr(),
+                  "GET_PEER_MBIES " + initiator.ifname() + " 01:ff:ff:ff:ff:ff",
+                  "IFACE_PEERS",
+                  "IFACE_PEERS ",
+                  "IFACE_PEERS unknown",
+                  "IFACE_PEERS unknown unknown",
+                  "IFACE_PEERS " + initiator.fst_group,
+                  "IFACE_PEERS " + initiator.fst_group + " unknown" ]
+        for t in tests:
+            if "FAIL" not in initiator.grequest("FST-MANAGER " + t):
+                raise Exception("Unexpected response for invalid FST-MANAGER command " + t)
+        if "UNKNOWN FST COMMAND" not in initiator.grequest("FST-MANAGER unknown"):
+            raise Exception("Unexpected response for unknown FST-MANAGER command")
+
+        tests = [ "FST-DETACH", "FST-DETACH ", "FST-DETACH unknown",
+                  "FST-ATTACH", "FST-ATTACH ", "FST-ATTACH unknown",
+                  "FST-ATTACH unknown unknown" ]
+        for t in tests:
+            if "FAIL" not in initiator.grequest(t):
+                raise Exception("Unexpected response for invalid command " + t)
+
+        try:
+            # Trying to add same interface again needs to fail.
+            ap1.send_iface_attach_request(ap1.iface, ap1.fst_group,
+                                          ap1.fst_llt, ap1.fst_pri)
+            raise Exception("Duplicate FST-ATTACH succeeded")
+        except Exception, e:
+            if not str(e).startswith("Cannot attach"):
+                raise
+    finally:
+        fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
+        fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
+
 # STA side FST module tests
 
 def test_fst_sta_start_session(dev, apdev, test_params):