diff --git a/tests/hwsim/fst_module_aux.py b/tests/hwsim/fst_module_aux.py index 47ccd3017..c51649238 100644 --- a/tests/hwsim/fst_module_aux.py +++ b/tests/hwsim/fst_module_aux.py @@ -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 diff --git a/tests/hwsim/test_fst_module.py b/tests/hwsim/test_fst_module.py index a242d291f..95b651e1e 100644 --- a/tests/hwsim/test_fst_module.py +++ b/tests/hwsim/test_fst_module.py @@ -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):