exception_text = "Failure. Bad parameter was not detected (%s)" % bad_param_names[bad_param_type]
raise Exception(exception_text)
else:
- print "Failure. Unexpected exception"
+ logger.info("Failure. Unexpected exception")
def fst_initiate_session(apdev, test_params, bad_param_type, init_on_ap):
"""This function makes the necessary preparations and then adds, sets and
else:
raise Exception("Failure. Bad parameter was not detected (%s)" % bad_param_names[bad_param_type])
else:
- print "Failure. Unexpected exception"
+ logger.info("Failure. Unexpected exception")
def fst_transfer_session(apdev, test_params, bad_param_type, init_on_ap,
rsn=False):
else:
raise Exception("Failure. Bad parameter was not detected (%s)" % bad_param_names[bad_param_type])
else:
- print "Failure. Unexpected exception"
+ logger.info("Failure. Unexpected exception")
def fst_tear_down_session(apdev, test_params, bad_param_type, init_on_ap):
else:
raise Exception("Failure. Bad parameter was not detected (%s)" % bad_param_names[bad_param_type])
else:
- print "Failure. Unexpected exception"
+ logger.info("Failure. Unexpected exception")
#enum - remove session scenarios
else:
raise Exception("Failure. Remove scenario ended in an unexpected way (%s)" % remove_scenario_names[remove_session_scenario])
else:
- print "Failure. Unexpected exception"
+ logger.info("Failure. Unexpected exception")
#enum - frame types
else:
raise Exception("Failure. Frame was not ignored (%s)" % frame_type_names[frame_type])
else:
- print "Failure. Unexpected exception"
+ logger.info("Failure. Unexpected exception")
#enum - bad session transfer scenarios
else:
raise Exception("Failure. Bad scenario was handled incorrectly (%s)" % bad_scenario_names[bad_scenario_type])
else:
- print "Failure. Unexpected exception"
+ logger.info("Failure. Unexpected exception")
def test_fst_sta_connect_to_non_fst_ap(dev, apdev, test_params):
"""FST STA connecting to non-FST AP"""
res_sta2_mbies = sta2.get_local_mbies()
if (orig_sta1_mbies.startswith("FAIL") or
orig_sta2_mbies.startswith("FAIL") or
- not res_sta1_mbies.startswith("FAIL") or
- not res_sta2_mbies.startswith("FAIL")):
- raise Exception("Failure. MB IEs have not been removed on the stations")
+ res_sta1_mbies.startswith("FAIL") or
+ res_sta2_mbies.startswith("FAIL")):
+ raise Exception("Failure. MB IEs must be present on the stations")
except Exception, e:
logger.info(e)
raise
finally:
sta2.disconnect_from_external_ap()
fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
+ hostapd.HostapdGlobal().remove(iface)
def test_fst_sta_connect_to_fst_ap(dev, apdev, test_params):
"""FST STA connecting to FST AP"""
res_sta2_mbies = sta2.get_local_mbies()
if (orig_sta1_mbies.startswith("FAIL") or
orig_sta2_mbies.startswith("FAIL") or
- not res_sta1_mbies.startswith("FAIL") or
- not res_sta2_mbies.startswith("FAIL")):
- raise Exception("Failure. MB IEs have not been removed on the stations")
+ res_sta1_mbies.startswith("FAIL") or
+ res_sta2_mbies.startswith("FAIL")):
+ raise Exception("Failure. MB IEs must be present on the stations")
except Exception, e:
logger.info(e)
raise
sta1.disconnect()
sta2.disconnect_from_external_ap()
fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
-
+ hostapd.HostapdGlobal().remove(iface)
def test_fst_second_sta_connect_to_fst_ap(dev, apdev, test_params):
"""FST STA 2nd connecting to FST AP"""
time.sleep(2)
res_sta1_mbies = sta1.get_local_mbies()
res_sta2_mbies = sta2.get_local_mbies()
- if (not orig_sta1_mbies.startswith("FAIL") or
- not orig_sta2_mbies.startswith("FAIL") or
- not res_sta1_mbies.startswith("FAIL") or
- not res_sta2_mbies.startswith("FAIL")):
- raise Exception("Failure. MB IEs should have stayed non-present on the stations")
+ if (orig_sta1_mbies.startswith("FAIL") or
+ orig_sta2_mbies.startswith("FAIL") or
+ res_sta1_mbies.startswith("FAIL") or
+ res_sta2_mbies.startswith("FAIL")):
+ raise Exception("Failure. MB IEs must be present on the stations")
except Exception, e:
logger.info(e)
raise
sta1.disconnect()
sta2.disconnect_from_external_ap()
fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
+ hostapd.HostapdGlobal().remove(iface)
def test_fst_disconnect_1_of_2_stas_from_non_fst_ap(dev, apdev, test_params):
"""FST disconnect 1 of 2 STAs from non-FST AP"""
time.sleep(2)
res_sta1_mbies = sta1.get_local_mbies()
res_sta2_mbies = sta2.get_local_mbies()
- if (not orig_sta1_mbies.startswith("FAIL") or
- not orig_sta2_mbies.startswith("FAIL") or
+ if (orig_sta1_mbies.startswith("FAIL") or
+ orig_sta2_mbies.startswith("FAIL") or
res_sta1_mbies.startswith("FAIL") or
res_sta2_mbies.startswith("FAIL")):
- raise Exception("Failure. MB IEs haven't reappeared on the stations")
+ raise Exception("Failure. MB IEs must be present on the stations")
except Exception, e:
logger.info(e)
raise
sta1.disconnect()
sta2.disconnect_from_external_ap()
fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
-
+ hostapd.HostapdGlobal().remove(iface)
def test_fst_disconnect_1_of_2_stas_from_fst_ap(dev, apdev, test_params):
"""FST disconnect 1 of 2 STAs from FST AP"""
time.sleep(2)
res_sta1_mbies = sta1.get_local_mbies()
res_sta2_mbies = sta2.get_local_mbies()
- if (not orig_sta1_mbies.startswith("FAIL") or
- not orig_sta2_mbies.startswith("FAIL") or
- not res_sta1_mbies.startswith("FAIL") or
- not res_sta2_mbies.startswith("FAIL")):
- raise Exception("Failure. MB IEs should have stayed non-present on the stations")
+ if (orig_sta1_mbies.startswith("FAIL") or
+ orig_sta2_mbies.startswith("FAIL") or
+ res_sta1_mbies.startswith("FAIL") or
+ res_sta2_mbies.startswith("FAIL")):
+ raise Exception("Failure. MB IEs must be present on the stations")
except Exception, e:
logger.info(e)
raise
sta1.disconnect()
sta2.disconnect_from_external_ap()
fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
+ hostapd.HostapdGlobal().remove(iface)
def test_fst_disconnect_2_of_2_stas_from_non_fst_ap(dev, apdev, test_params):
"""FST disconnect 2 of 2 STAs from non-FST AP"""
time.sleep(2)
res_sta1_mbies = sta1.get_local_mbies()
res_sta2_mbies = sta2.get_local_mbies()
- if (not orig_sta1_mbies.startswith("FAIL") or
- not orig_sta2_mbies.startswith("FAIL") or
+ if (orig_sta1_mbies.startswith("FAIL") or
+ orig_sta2_mbies.startswith("FAIL") or
res_sta1_mbies.startswith("FAIL") or
res_sta2_mbies.startswith("FAIL")):
- raise Exception("Failure. MB IEs haven't reappeared on the stations")
+ raise Exception("Failure. MB IEs must be present on the stations")
except Exception, e:
logger.info(e)
raise
sta1.disconnect()
sta2.disconnect_from_external_ap()
fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
+ hostapd.HostapdGlobal().remove(iface)
def test_fst_disconnect_2_of_2_stas_from_fst_ap(dev, apdev, test_params):
"""FST disconnect 2 of 2 STAs from FST AP"""
sta1.disconnect()
sta2.disconnect_from_external_ap()
fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
+ hostapd.HostapdGlobal().remove(iface)
def test_fst_disconnect_non_fst_sta(dev, apdev, test_params):
"""FST disconnect non-FST STA"""
def test_fst_disconnect_fst_sta(dev, apdev, test_params):
"""FST disconnect FST STA"""
ap1, ap2, fst_sta1, fst_sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
- external_sta_connected = False;
+ external_sta_connected = False
try:
vals = fst_sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
fst_sta1.connect(ap1, key_mgmt="NONE",
"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",
+ "GET_PEER_MBIES " + initiator.ifname() + " 00:ff:ff:ff:ff:ff",
+ "GET_PEER_MBIES " + initiator.ifname() + " 00:00:00:00:00:00",
"IFACE_PEERS",
"IFACE_PEERS ",
"IFACE_PEERS unknown",
fst_test_common.fst_test_def_prio_low,
fst_test_common.fst_test_def_llt)
ap1.start()
+ try:
+ run_fst_ap_start_session_oom(apdev, ap1)
+ finally:
+ ap1.stop()
+
+def run_fst_ap_start_session_oom(apdev, ap1):
with alloc_fail(ap1, 1, "fst_iface_create"):
ap2_started = False
try:
except:
pass
finally:
- ap1.stop()
try:
ap2.stop()
except:
if "OK" not in dev.global_request(cmd):
raise Exception(cmd + " failed")
+def fst_session_set_ap(dev, sid, param, value):
+ cmd = "FST-MANAGER SESSION_SET %s %s=%s" % (sid, param, value)
+ if "OK" not in dev.request(cmd):
+ raise Exception(cmd + " failed")
+
def fst_attach_ap(dev, ifname, group):
cmd = "FST-ATTACH %s %s" % (ifname, group)
if "OK" not in dev.request(cmd):
if t not in ev:
raise Exception("Unexpected FST-EVENT-PEER data (STA): " + ev)
-def fst_setup_req(dev, hglobal, freq, dst, req, stie, mbie=""):
+def fst_setup_req(dev, hglobal, freq, dst, req, stie, mbie="", no_wait=False):
act = req + stie + mbie
dev.request("MGMT_TX %s %s freq=%d action=%s" % (dst, dst, freq, act))
ev = dev.wait_event(['MGMT-TX-STATUS'], timeout=5)
if ev is None or "result=SUCCESS" not in ev:
raise Exception("FST Action frame not ACKed")
+ if no_wait:
+ return
while True:
ev = hglobal.wait_event(['FST-EVENT-SESSION'], timeout=5)
if ev is None:
if "new_state=SETUP_COMPLETION" in ev:
break
-def test_fst_test_setup(dev, apdev, test_params):
- """FST setup using separate commands"""
- try:
- _test_fst_test_setup(dev, apdev, test_params)
- finally:
- subprocess.call(['iw', 'reg', 'set', '00'])
- dev[0].flush_scan_cache()
- dev[1].flush_scan_cache()
-
-def _test_fst_test_setup(dev, apdev, test_params):
+def fst_start_and_connect(apdev, group, sgroup):
hglobal = hostapd.HostapdGlobal()
if "OK" not in hglobal.request("FST-MANAGER TEST_REQUEST IS_SUPPORTED"):
raise HwsimSkip("No FST testing support")
params = { "ssid": "fst_11a", "hw_mode": "a", "channel": "36",
"country_code": "US" }
- hapd = hostapd.add_ap(apdev[0]['ifname'], params)
+ hapd = hostapd.add_ap(apdev[0], params)
- group = "fstg0"
fst_attach_ap(hglobal, apdev[0]['ifname'], group)
cmd = "FST-ATTACH %s %s" % (apdev[0]['ifname'], group)
params = { "ssid": "fst_11g", "hw_mode": "g", "channel": "1",
"country_code": "US" }
- hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)
+ hapd2 = hostapd.add_ap(apdev[1], params)
fst_attach_ap(hglobal, apdev[1]['ifname'], group)
- sgroup = "fstg1"
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add("wlan5")
fst_attach_sta(wpas, wpas.ifname, sgroup)
fst_wait_event_peer_sta(wpas, "connected", wpas2.ifname, apdev[1]['bssid'])
fst_wait_event_peer_ap(hglobal, "connected", apdev[1]['ifname'],
wpas2.own_addr())
+ return hglobal, wpas, wpas2, hapd, hapd2
+
+def test_fst_test_setup(dev, apdev, test_params):
+ """FST setup using separate commands"""
+ try:
+ _test_fst_test_setup(dev, apdev, test_params)
+ finally:
+ subprocess.call(['iw', 'reg', 'set', '00'])
+ dev[0].flush_scan_cache()
+ dev[1].flush_scan_cache()
+
+def _test_fst_test_setup(dev, apdev, test_params):
+ group = "fstg0b"
+ sgroup = "fstg1b"
+ hglobal, wpas, wpas2, hapd, hapd2 = fst_start_and_connect(apdev, group, sgroup)
sid = wpas.global_request("FST-MANAGER SESSION_ADD " + sgroup).strip()
if "FAIL" in sid:
dev[1].flush_scan_cache()
def _test_fst_setup_mbie_diff(dev, apdev, test_params):
- hglobal = hostapd.HostapdGlobal()
- if "OK" not in hglobal.request("FST-MANAGER TEST_REQUEST IS_SUPPORTED"):
- raise HwsimSkip("No FST testing support")
-
- params = { "ssid": "fst_11a", "hw_mode": "a", "channel": "36",
- "country_code": "US" }
- hapd = hostapd.add_ap(apdev[0]['ifname'], params)
-
- group = "fstg0"
- fst_attach_ap(hglobal, apdev[0]['ifname'], group)
-
- cmd = "FST-ATTACH %s %s" % (apdev[0]['ifname'], group)
- if "FAIL" not in hglobal.request(cmd):
- raise Exception("Duplicated FST-ATTACH (AP) accepted")
-
- params = { "ssid": "fst_11g", "hw_mode": "g", "channel": "1",
- "country_code": "US" }
- hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)
- fst_attach_ap(hglobal, apdev[1]['ifname'], group)
-
- sgroup = "fstg1"
- wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
- wpas.interface_add("wlan5")
- fst_attach_sta(wpas, wpas.ifname, sgroup)
-
- wpas.interface_add("wlan6", set_ifname=False)
- wpas2 = WpaSupplicant(ifname="wlan6")
- fst_attach_sta(wpas, wpas2.ifname, sgroup)
-
- wpas.connect("fst_11a", key_mgmt="NONE", scan_freq="5180",
- wait_connect=False)
- wpas.wait_connected()
-
- fst_wait_event_peer_sta(wpas, "connected", wpas.ifname, apdev[0]['bssid'])
- fst_wait_event_peer_ap(hglobal, "connected", apdev[0]['ifname'],
- wpas.own_addr())
-
- wpas2.connect("fst_11g", key_mgmt="NONE", scan_freq="2412",
- wait_connect=False)
- wpas2.wait_connected()
-
- fst_wait_event_peer_sta(wpas, "connected", wpas2.ifname, apdev[1]['bssid'])
- fst_wait_event_peer_ap(hglobal, "connected", apdev[1]['ifname'],
- wpas2.own_addr())
+ group = "fstg0c"
+ sgroup = "fstg1c"
+ hglobal, wpas, wpas2, hapd, hapd2 = fst_start_and_connect(apdev, group, sgroup)
# FST Setup Request: Category, FST Action, Dialog Token (non-zero),
# LLT (32 bits, see 10.32), Session Transition (see 8.4.2.147),
stie = "a40b0200000000020001040001"
fst_setup_req(wpas, hglobal, 5180, apdev[0]['bssid'], req, stie)
+ # MBIE update OOM on AP
+ req = "1200011a060000"
+ stie = "a40b0100000000020001040001"
+ mbie = "9e16040200010200000004000000000000000000000000ff"
+ try:
+ with alloc_fail(hapd, 1, "mb_ies_by_info"):
+ fst_setup_req(wpas, hglobal, 5180, apdev[0]['bssid'], req, stie,
+ mbie, no_wait=True)
+ except HwsimSkip, e:
+ # Skip exception to allow proper cleanup
+ pass
+
+ # Remove sessions to avoid causing issues to following test ases
+ s = hglobal.request("FST-MANAGER LIST_SESSIONS " + group)
+ if not s.startswith("FAIL"):
+ for sid in s.split(' '):
+ if len(sid):
+ hglobal.request("FST-MANAGER SESSION_REMOVE " + sid)
+
def test_fst_many_setup(dev, apdev, test_params):
"""FST setup multiple times"""
try:
dev[1].flush_scan_cache()
def _test_fst_many_setup(dev, apdev, test_params):
- hglobal = hostapd.HostapdGlobal()
- if "OK" not in hglobal.request("FST-MANAGER TEST_REQUEST IS_SUPPORTED"):
- raise HwsimSkip("No FST testing support")
-
- params = { "ssid": "fst_11a", "hw_mode": "a", "channel": "36",
- "country_code": "US" }
- hapd = hostapd.add_ap(apdev[0]['ifname'], params)
-
- group = "fstg0"
- fst_attach_ap(hglobal, apdev[0]['ifname'], group)
-
- cmd = "FST-ATTACH %s %s" % (apdev[0]['ifname'], group)
- if "FAIL" not in hglobal.request(cmd):
- raise Exception("Duplicated FST-ATTACH (AP) accepted")
-
- params = { "ssid": "fst_11g", "hw_mode": "g", "channel": "1",
- "country_code": "US" }
- hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)
- fst_attach_ap(hglobal, apdev[1]['ifname'], group)
-
- sgroup = "fstg1"
- wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
- wpas.interface_add("wlan5")
- fst_attach_sta(wpas, wpas.ifname, sgroup)
-
- wpas.interface_add("wlan6", set_ifname=False)
- wpas2 = WpaSupplicant(ifname="wlan6")
- fst_attach_sta(wpas, wpas2.ifname, sgroup)
-
- wpas.connect("fst_11a", key_mgmt="NONE", scan_freq="5180",
- wait_connect=False)
- wpas.wait_connected()
-
- fst_wait_event_peer_sta(wpas, "connected", wpas.ifname, apdev[0]['bssid'])
- fst_wait_event_peer_ap(hglobal, "connected", apdev[0]['ifname'],
- wpas.own_addr())
-
- wpas2.connect("fst_11g", key_mgmt="NONE", scan_freq="2412",
- wait_connect=False)
- wpas2.wait_connected()
-
- fst_wait_event_peer_sta(wpas, "connected", wpas2.ifname, apdev[1]['bssid'])
- fst_wait_event_peer_ap(hglobal, "connected", apdev[1]['ifname'],
- wpas2.own_addr())
+ group = "fstg0d"
+ sgroup = "fstg1d"
+ hglobal, wpas, wpas2, hapd, hapd2 = fst_start_and_connect(apdev, group, sgroup)
sid = wpas.global_request("FST-MANAGER SESSION_ADD " + sgroup).strip()
if "FAIL" in sid:
fst_detach_sta(wpas, wpas.ifname, sgroup)
fst_detach_sta(wpas, wpas2.ifname, sgroup)
+
+def test_fst_attach_wpas_error(dev, apdev, test_params):
+ """FST attach errors in wpa_supplicant"""
+ if "OK" not in dev[0].global_request("FST-MANAGER TEST_REQUEST IS_SUPPORTED"):
+ raise HwsimSkip("No FST testing support")
+ group = "fstg0"
+ wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
+ wpas.interface_add("wlan5")
+ fst_attach_sta(wpas, wpas.ifname, group)
+ if "FAIL" not in wpas.global_request("FST-ATTACH %s %s" % (wpas.ifname,
+ group)):
+ raise Exception("Duplicated FST-ATTACH accepted")
+ if "FAIL" not in wpas.global_request("FST-ATTACH %s %s" % ("foofoo",
+ group)):
+ raise Exception("FST-ATTACH for unknown interface accepted")
+
+def test_fst_session_initiate_errors(dev, apdev, test_params):
+ """FST SESSION_INITIATE error cases"""
+ try:
+ _test_fst_session_initiate_errors(dev, apdev, test_params)
+ finally:
+ subprocess.call(['iw', 'reg', 'set', '00'])
+ dev[0].flush_scan_cache()
+ dev[1].flush_scan_cache()
+
+def _test_fst_session_initiate_errors(dev, apdev, test_params):
+ group = "fstg0"
+ sgroup = "fstg1"
+ hglobal, wpas, wpas2, hapd, hapd2 = fst_start_and_connect(apdev, group, sgroup)
+
+ sid = wpas.global_request("FST-MANAGER SESSION_ADD " + sgroup).strip()
+ if "FAIL" in sid:
+ raise Exception("FST-MANAGER SESSION_ADD (STA) failed")
+
+ # No old peer MAC address
+ if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
+ raise Exception("Invalid FST-MANAGER SESSION_INITIATE accepted")
+
+ fst_session_set(wpas, sid, "old_peer_addr", "00:ff:ff:ff:ff:ff")
+ # No new peer MAC address
+ if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
+ raise Exception("Invalid FST-MANAGER SESSION_INITIATE accepted")
+
+ fst_session_set(wpas, sid, "new_peer_addr", "00:ff:ff:ff:ff:fe")
+ # No old interface defined
+ if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
+ raise Exception("Invalid FST-MANAGER SESSION_INITIATE accepted")
+
+ fst_session_set(wpas, sid, "old_ifname", wpas.ifname)
+ # No new interface defined
+ if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
+ raise Exception("Invalid FST-MANAGER SESSION_INITIATE accepted")
+
+ fst_session_set(wpas, sid, "new_ifname", wpas.ifname)
+ # Same interface set as old and new
+ if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
+ raise Exception("Invalid FST-MANAGER SESSION_INITIATE accepted")
+
+ fst_session_set(wpas, sid, "new_ifname", wpas2.ifname)
+ # The preset old peer address is not connected
+ if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
+ raise Exception("Invalid FST-MANAGER SESSION_INITIATE accepted")
+
+ fst_session_set(wpas, sid, "old_peer_addr", apdev[0]['bssid'])
+ # The preset new peer address is not connected
+ if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
+ raise Exception("Invalid FST-MANAGER SESSION_INITIATE accepted")
+
+ fst_session_set(wpas, sid, "new_peer_addr", apdev[1]['bssid'])
+ # Initiate session setup
+ if "OK" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
+ raise Exception("FST-MANAGER SESSION_INITIATE failed")
+
+ # Session in progress
+ if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
+ raise Exception("Duplicated FST-MANAGER SESSION_INITIATE accepted")
+
+ sid2 = wpas.global_request("FST-MANAGER SESSION_ADD " + sgroup).strip()
+ if "FAIL" in sid:
+ raise Exception("FST-MANAGER SESSION_ADD (STA) failed")
+ fst_session_set(wpas, sid2, "old_ifname", wpas.ifname)
+ fst_session_set(wpas, sid2, "old_peer_addr", apdev[0]['bssid'])
+ fst_session_set(wpas, sid2, "new_ifname", wpas2.ifname)
+ fst_session_set(wpas, sid2, "new_peer_addr", apdev[1]['bssid'])
+
+ # There is another session in progress (old)
+ if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid2):
+ raise Exception("Duplicated FST-MANAGER SESSION_INITIATE accepted")
+
+ if "OK" not in wpas.global_request("FST-MANAGER SESSION_REMOVE " + sid):
+ raise Exception("FST-MANAGER SESSION_REMOVE failed")
+
+ while True:
+ ev = hglobal.wait_event(['FST-EVENT-SESSION'], timeout=5)
+ if ev is None:
+ raise Exception("No FST-EVENT-SESSION (AP)")
+ if "new_state=SETUP_COMPLETION" in ev:
+ f = re.search("session_id=(\d+)", ev)
+ if f is None:
+ raise Exception("No session_id in FST-EVENT-SESSION")
+ sid_ap = f.group(1)
+ break
+ if "OK" not in hglobal.request("FST-MANAGER SESSION_REMOVE " + sid_ap):
+ raise Exception("FST-MANAGER SESSION_REMOVE (AP) failed")
+
+ if "OK" not in wpas.global_request("FST-MANAGER SESSION_REMOVE " + sid2):
+ raise Exception("FST-MANAGER SESSION_REMOVE failed")
+
+def test_fst_session_respond_errors(dev, apdev, test_params):
+ """FST SESSION_RESPOND error cases"""
+ try:
+ _test_fst_session_respond_errors(dev, apdev, test_params)
+ finally:
+ subprocess.call(['iw', 'reg', 'set', '00'])
+ dev[0].flush_scan_cache()
+ dev[1].flush_scan_cache()
+
+def _test_fst_session_respond_errors(dev, apdev, test_params):
+ group = "fstg0b"
+ sgroup = "fstg1b"
+ hglobal, wpas, wpas2, hapd, hapd2 = fst_start_and_connect(apdev, group, sgroup)
+
+ sid = wpas.global_request("FST-MANAGER SESSION_ADD " + sgroup).strip()
+ if "FAIL" in sid:
+ raise Exception("FST-MANAGER SESSION_ADD (STA) failed")
+
+ fst_session_set(wpas, sid, "old_ifname", wpas.ifname)
+ fst_session_set(wpas, sid, "old_peer_addr", apdev[0]['bssid'])
+ fst_session_set(wpas, sid, "new_ifname", wpas2.ifname)
+ fst_session_set(wpas, sid, "new_peer_addr", apdev[1]['bssid'])
+
+ if "OK" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
+ raise Exception("FST-MANAGER SESSION_INITIATE failed")
+
+ while True:
+ ev = hglobal.wait_event(['FST-EVENT-SESSION'], timeout=5)
+ if ev is None:
+ raise Exception("No FST-EVENT-SESSION (AP)")
+ if "new_state=SETUP_COMPLETION" in ev:
+ f = re.search("session_id=(\d+)", ev)
+ if f is None:
+ raise Exception("No session_id in FST-EVENT-SESSION")
+ sid_ap = f.group(1)
+ break
+
+ # The preset peer address is not in the peer list
+ fst_session_set_ap(hglobal, sid_ap, "old_peer_addr", "00:00:00:00:00:01")
+ cmd = "FST-MANAGER SESSION_RESPOND %s accept" % sid_ap
+ if "FAIL" not in hglobal.request(cmd):
+ raise Exception("Invalid FST-MANAGER SESSION_RESPOND accepted")
+
+ # Same interface set as old and new
+ fst_session_set_ap(hglobal, sid_ap, "old_peer_addr", wpas.own_addr())
+ fst_session_set_ap(hglobal, sid_ap, "old_ifname", apdev[1]['ifname'])
+ cmd = "FST-MANAGER SESSION_RESPOND %s accept" % sid_ap
+ if "FAIL" not in hglobal.request(cmd):
+ raise Exception("Invalid FST-MANAGER SESSION_RESPOND accepted")
+
+ # valid command
+ fst_session_set_ap(hglobal, sid_ap, "old_ifname", apdev[0]['ifname'])
+ cmd = "FST-MANAGER SESSION_RESPOND %s accept" % sid_ap
+ if "OK" not in hglobal.request(cmd):
+ raise Exception("FST-MANAGER SESSION_RESPOND failed")
+
+ # incorrect state
+ cmd = "FST-MANAGER SESSION_RESPOND %s accept" % sid_ap
+ if "FAIL" not in hglobal.request(cmd):
+ raise Exception("Invalid FST-MANAGER SESSION_RESPOND accepted")
+
+ cmd = "FST-MANAGER SESSION_REMOVE " + sid
+ if "OK" not in wpas.global_request(cmd):
+ raise Exception("FST-MANAGER SESSION_REMOVE (STA) failed")
+
+ cmd = "FST-MANAGER SESSION_REMOVE %s" % sid_ap
+ if "OK" not in hglobal.request(cmd):
+ raise Exception("FST-MANAGER SESSION_REMOVE (AP) failed")