if "CTRL-EVENT-DISCONNECTED" not in ev:
raise Exception("Unexpected connection result")
-def run_multi_ap_wps(dev, apdev, params, params_backhaul=None):
+def run_multi_ap_wps(dev, apdev, params, params_backhaul=None, add_apdev=False,
+ run_csa=False, allow_csa_fail=False):
"""Helper for running Multi-AP WPS tests
dev[0] does multi_ap WPS, dev[1] does normal WPS. apdev[0] is the fronthaul
the WPS parameters. multi_ap_bssid must be given if it is not equal to the
fronthaul BSSID."""
+ wpas_apdev = None
+
if params_backhaul:
hapd_backhaul = hostapd.add_ap(apdev[1], params_backhaul)
multi_ap_bssid = hapd_backhaul.own_addr()
if len(dev[1].list_networks()) != 1:
raise Exception("Unexpected number of network blocks")
+ try:
+ # Add apdev to the same phy that dev[0]
+ if add_apdev:
+ wpas_apdev = {}
+ wpas_apdev['ifname'] = dev[0].ifname + "_ap"
+ status, buf = dev[0].cmd_execute(['iw', dev[0].ifname,
+ 'interface', 'add',
+ wpas_apdev['ifname'],
+ 'type', 'managed'])
+ if status != 0:
+ raise Exception("iw interface add failed")
+ wpas_hapd = hostapd.add_ap(wpas_apdev, params)
+
+ if run_csa:
+ if 'OK' not in hapd.request("CHAN_SWITCH 5 2462 ht"):
+ raise Exception("chan switch request failed")
+
+ ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=5)
+ if not ev:
+ raise Exception("chan switch failed")
+
+ # now check station
+ ev = dev[0].wait_event(["CTRL-EVENT-CHANNEL-SWITCH",
+ "CTRL-EVENT-DISCONNECTED"], timeout=5)
+ if not ev:
+ raise Exception("sta - no chanswitch event")
+ if "CTRL-EVENT-CHANNEL-SWITCH" not in ev and not allow_csa_fail:
+ raise Exception("Received disconnection event instead of channel switch event")
+
+ if add_apdev:
+ dev[0].cmd_execute(['iw', wpas_apdev['ifname'], 'del'])
+ except:
+ if wpas_apdev:
+ dev[0].cmd_execute(['iw', wpas_apdev['ifname'], 'del'])
+ raise
+
def test_multi_ap_wps_shared(dev, apdev):
"""WPS on shared fronthaul/backhaul AP"""
ssid = "multi-ap-wps"
"multi_ap_backhaul_wpa_passphrase": passphrase})
run_multi_ap_wps(dev, apdev, params)
+def test_multi_ap_wps_shared_csa(dev, apdev):
+ """WPS on shared fronthaul/backhaul AP, run CSA"""
+ ssid = "multi-ap-wps-csa"
+ passphrase = "12345678"
+ params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
+ params.update({"multi_ap": "3",
+ "multi_ap_backhaul_ssid": '"%s"' % ssid,
+ "multi_ap_backhaul_wpa_passphrase": passphrase})
+ run_multi_ap_wps(dev, apdev, params, run_csa=True)
+
+def test_multi_ap_wps_shared_apdev_csa(dev, apdev):
+ """WPS on shared fronthaul/backhaul AP add apdev on same phy and run CSA"""
+ ssid = "multi-ap-wps-apdev-csa"
+ passphrase = "12345678"
+ params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
+ params.update({"multi_ap": "3",
+ "multi_ap_backhaul_ssid": '"%s"' % ssid,
+ "multi_ap_backhaul_wpa_passphrase": passphrase})
+ # This case is currently failing toc omplete CSA on the station interface.
+ # For the time being, ignore that to avoid always failing tests. Full
+ # validation can be enabled once the issue behind this is fixed.
+ run_multi_ap_wps(dev, apdev, params, add_apdev=True, run_csa=True,
+ allow_csa_fail=True)
+
def test_multi_ap_wps_shared_psk(dev, apdev):
"""WPS on shared fronthaul/backhaul AP using PSK"""
ssid = "multi-ap-wps"