Pass apdev param to Hostapd(), not only ifname. Now we can handle also remote hosts while we will know apdev['hostname']. Signed-off-by: Janusz Dziedzic <janusz.dziedzic@xxxxxxxxx> --- tests/hwsim/fst_module_aux.py | 3 +- tests/hwsim/fst_test_common.py | 3 +- tests/hwsim/hostapd.py | 50 +++++++++++++++------------ tests/hwsim/test_ap_dynamic.py | 47 ++++++++++--------------- tests/hwsim/test_ap_eap.py | 17 ++++----- tests/hwsim/test_ap_hs20.py | 6 ++-- tests/hwsim/test_ap_pmf.py | 2 +- tests/hwsim/test_ap_psk.py | 2 +- tests/hwsim/test_ap_tdls.py | 4 +-- tests/hwsim/test_ap_vlan.py | 5 +-- tests/hwsim/test_ap_wps.py | 78 +++++++++++++++++++++--------------------- tests/hwsim/test_dbus.py | 4 +-- tests/hwsim/test_dbus_old.py | 2 +- tests/hwsim/test_dfs.py | 4 +-- tests/hwsim/test_gas.py | 2 +- tests/hwsim/test_nfc_wps.py | 32 ++++++++--------- tests/hwsim/test_radius.py | 45 ++++++++++++++---------- tests/hwsim/test_wnm.py | 12 +++---- 18 files changed, 164 insertions(+), 154 deletions(-) diff --git a/tests/hwsim/fst_module_aux.py b/tests/hwsim/fst_module_aux.py index 4b52a71..d34e8bc 100644 --- a/tests/hwsim/fst_module_aux.py +++ b/tests/hwsim/fst_module_aux.py @@ -639,7 +639,8 @@ class FstAP (FstDevice): def get_instance(self): """Return the Hostapd/WpaSupplicant instance""" if self.instance is None: - self.instance = hostapd.Hostapd(self.iface) + ap = { "ifname" : self.iface } + self.instance = hostapd.Hostapd(ap) return self.instance def get_global_instance(self): diff --git a/tests/hwsim/fst_test_common.py b/tests/hwsim/fst_test_common.py index 22d0ff6..851dd8d 100644 --- a/tests/hwsim/fst_test_common.py +++ b/tests/hwsim/fst_test_common.py @@ -33,7 +33,8 @@ class HapdRegCtrl: def start(self): if self.ifname != None: - hapd = hostapd.Hostapd(self.ifname) + apdev = { "ifname" : self.ifname } + hapd = hostapd.Hostapd(apdev) self.changed = self.wait_hapd_reg_change(hapd) def stop(self): diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py index db37d20..084c43e 100644 --- a/tests/hwsim/hostapd.py +++ b/tests/hwsim/hostapd.py @@ -117,7 +117,15 @@ class HostapdGlobal: self.ctrl = None class Hostapd: - def __init__(self, ifname, bssidx=0, hostname=None, port=8877): + def __init__(self, apdev, bssidx=0): + ifname = apdev['ifname'] + try: + hostname = apdev['hostname'] + port = apdev['port'] + except: + hostname = None + port = 8878 + self.host = remotehost.Host(hostname, ifname) self.ifname = ifname if hostname is None: @@ -348,18 +356,16 @@ class Hostapd: def add_ap(apdev, params, wait_enabled=True, no_enable=False, timeout=30): ifname = apdev['ifname'] try: - hostname = apdev['hostname'] - port = apdev['port'] - logger.info("Starting AP " + hostname + "/" + port + " " + ifname) + logger.info("Starting AP " + apdev['hostname'] + "/" + apdev['port'] + " " + ifname) except: logger.info("Starting AP " + ifname) - hostname = None - port = 8878 hapd_global = HostapdGlobal(apdev) hapd_global.remove(ifname) hapd_global.add(ifname) port = hapd_global.get_ctrl_iface_port(ifname) - hapd = Hostapd(ifname, hostname=hostname, port=port) + dev = apdev.copy() + dev['port'] = port + hapd = Hostapd(dev) if not hapd.ping(): raise Exception("Could not ping hostapd") hapd.set_defaults() @@ -392,45 +398,47 @@ def add_ap(apdev, params, wait_enabled=True, no_enable=False, timeout=30): def add_bss(phy, apdev, confname, ignore_error=False): ifname = apdev['ifname'] try: - hostname = apdev['hostname'] - port = apdev['port'] - logger.info("Starting BSS " + hostname + "/" + port + " phy=" + phy + " ifname=" + ifname) + logger.info("Starting BSS " + apdev['hostname'] + "/" + apdev['port'] + " phy=" + phy + " ifname=" + ifname) except: logger.info("Starting BSS phy=" + phy + " ifname=" + ifname) - hostname = None - port = 8878 hapd_global = HostapdGlobal(apdev) hapd_global.add_bss(phy, confname, ignore_error) port = hapd_global.get_ctrl_iface_port(ifname) - hapd = Hostapd(ifname, hostname=hostname, port=port) + dev = apdev.copy() + dev['port'] = port + hapd = Hostapd(dev) if not hapd.ping(): raise Exception("Could not ping hostapd") def add_iface(apdev, confname): ifname = apdev['ifname'] try: - hostname = apdev['hostname'] - port = apdev['port'] - logger.info("Starting interface " + hostname + "/" + port + " " + ifname) + logger.info("Starting interface " + apdev['hostname'] + "/" + apdev['port'] + " " + ifname) except: logger.info("Starting interface " + ifname) - hostname = None - port = 8878 hapd_global = HostapdGlobal(apdev) hapd_global.add_iface(ifname, confname) port = hapd_global.get_ctrl_iface_port(ifname) - hapd = Hostapd(ifname, hostname=hostname, port=port) + dev = apdev.copy() + dev['port'] = port + hapd = Hostapd(dev) if not hapd.ping(): raise Exception("Could not ping hostapd") def remove_bss(apdev): ifname = apdev['ifname'] - logger.info("Removing BSS " + ifname) + try: + logger.info("Removing BSS " + apdev['hostname'] + "/" + apdev['port'] + " " + ifname) + except: + logger.info("Removing BSS " + ifname) hapd_global = HostapdGlobal(apdev) hapd_global.remove(ifname) def terminate(apdev): - logger.info("Terminating hostapd") + try: + logger.info("Terminating hostapd " + apdev['hostname'] + "/" + apdev['port']) + except: + logger.info("Terminating hostapd") hapd_global = HostapdGlobal(apdev) hapd_global.terminate() diff --git a/tests/hwsim/test_ap_dynamic.py b/tests/hwsim/test_ap_dynamic.py index 742abfc..420f95f 100644 --- a/tests/hwsim/test_ap_dynamic.py +++ b/tests/hwsim/test_ap_dynamic.py @@ -25,7 +25,7 @@ def test_ap_change_ssid(dev, apdev): dev[0].request("DISCONNECT") logger.info("Change SSID dynamically") - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) res = hapd.request("SET ssid test-wpa2-psk-new") if "OK" not in res: raise Exception("SET command failed") @@ -189,7 +189,7 @@ def test_ap_multi_bss_config(dev, apdev): apdev3['ifname'] = apdev[0]['ifname'] + '-3' logger.info("Set up three BSSes with one configuration file") hostapd.add_iface(apdev1, 'multi-bss.conf') - hapd = hostapd.Hostapd(apdev1['ifname']) + hapd = hostapd.Hostapd(apdev1) hapd.enable() multi_check(dev, [ True, True, True ]) hostapd.remove_bss(apdev2) @@ -200,21 +200,14 @@ def test_ap_multi_bss_config(dev, apdev): multi_check(dev, [ False, False, False ]) hostapd.add_iface(apdev1, 'multi-bss.conf') - hapd = hostapd.Hostapd(apdev1['ifname']) + hapd = hostapd.Hostapd(apdev1) hapd.enable() hostapd.remove_bss(apdev1) multi_check(dev, [ False, False, False ]) -def invalid_ap(hapd_global, ifname): - logger.info("Trying to start AP " + ifname + " with invalid configuration") - hapd_global.remove(ifname) - hapd_global.add(ifname) - hapd = hostapd.Hostapd(ifname) - if not hapd.ping(): - raise Exception("Could not ping hostapd") - hapd.set_defaults() - hapd.set("ssid", "invalid-config") - hapd.set("channel", "12345") +def invalid_ap(apdev): + logger.info("Trying to start AP " + apdev['ifname'] + " with invalid configuration") + hapd = hostapd.add_ap(apdev, { "ssid" : "invalid-config", "channel" : "12345" }, no_enable=True ) try: hapd.enable() started = True @@ -226,9 +219,7 @@ def invalid_ap(hapd_global, ifname): def test_ap_invalid_config(dev, apdev): """Try to start AP with invalid configuration and fix configuration""" - hapd_global = hostapd.HostapdGlobal() - ifname = apdev[0]['ifname'] - hapd = invalid_ap(hapd_global, ifname) + hapd = invalid_ap(apdev[0]) logger.info("Fix configuration and start AP again") hapd.set("channel", "1") @@ -237,11 +228,9 @@ def test_ap_invalid_config(dev, apdev): def test_ap_invalid_config2(dev, apdev): """Try to start AP with invalid configuration and remove interface""" - hapd_global = hostapd.HostapdGlobal() - ifname = apdev[0]['ifname'] - hapd = invalid_ap(hapd_global, ifname) + hapd = invalid_ap(apdev[0]) logger.info("Remove interface with failed configuration") - hapd_global.remove(ifname) + hostapd.remove_bss(apdev[0]) def test_ap_remove_during_acs(dev, apdev): """Remove interface during ACS""" @@ -260,7 +249,7 @@ def test_ap_remove_during_acs2(dev, apdev): ifname2 = ifname + "-2" hapd_global = hostapd.HostapdGlobal() hapd_global.add(ifname) - hapd = hostapd.Hostapd(ifname) + hapd = hostapd.Hostapd(apdev[0]) hapd.set_defaults() hapd.set("ssid", "test-acs-remove") hapd.set("channel", "0") @@ -276,7 +265,7 @@ def test_ap_remove_during_acs3(dev, apdev): ifname2 = ifname + "-2" hapd_global = hostapd.HostapdGlobal() hapd_global.add(ifname) - hapd = hostapd.Hostapd(ifname) + hapd = hostapd.Hostapd(apdev[0]) hapd.set_defaults() hapd.set("ssid", "test-acs-remove") hapd.set("channel", "0") @@ -301,7 +290,7 @@ def test_ap_remove_during_ht_coex_scan2(dev, apdev): ifname2 = ifname + "-2" hapd_global = hostapd.HostapdGlobal() hapd_global.add(ifname) - hapd = hostapd.Hostapd(ifname) + hapd = hostapd.Hostapd(apdev[0]) hapd.set_defaults() hapd.set("ssid", "test-ht-remove") hapd.set("channel", "1") @@ -317,7 +306,7 @@ def test_ap_remove_during_ht_coex_scan3(dev, apdev): ifname2 = ifname + "-2" hapd_global = hostapd.HostapdGlobal() hapd_global.add(ifname) - hapd = hostapd.Hostapd(ifname) + hapd = hostapd.Hostapd(apdev[0]) hapd.set_defaults() hapd.set("ssid", "test-ht-remove") hapd.set("channel", "1") @@ -332,7 +321,7 @@ def test_ap_enable_disable_reenable(dev, apdev): ifname = apdev[0]['ifname'] hapd_global = hostapd.HostapdGlobal() hapd_global.add(ifname) - hapd = hostapd.Hostapd(ifname) + hapd = hostapd.Hostapd(apdev[0]) hapd.set_defaults() hapd.set("ssid", "dynamic") hapd.enable() @@ -359,7 +348,7 @@ def test_ap_double_disable(dev, apdev): apdev2['ifname'] = apdev[0]['ifname'] + '-2' hostapd.add_bss('phy3', apdev1, 'bss-1.conf') hostapd.add_bss('phy3', apdev2, 'bss-2.conf') - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) hapd.disable() if "FAIL" not in hapd.request("DISABLE"): raise Exception("Second DISABLE accepted unexpectedly") @@ -472,8 +461,8 @@ def test_ap_multi_bss(dev, apdev): dev[0].connect("bss-1", key_mgmt="NONE", scan_freq="2412") dev[1].connect("bss-2", key_mgmt="NONE", scan_freq="2412") - hapd1 = hostapd.Hostapd(apdev1['ifname']) - hapd2 = hostapd.Hostapd(apdev2['ifname']) + hapd1 = hostapd.Hostapd(apdev1) + hapd2 = hostapd.Hostapd(apdev2) hwsim_utils.test_connectivity(dev[0], hapd1) hwsim_utils.test_connectivity(dev[1], hapd2) @@ -490,7 +479,7 @@ def test_ap_add_with_driver(dev, apdev): ifname = apdev[0]['ifname'] hapd_global = hostapd.HostapdGlobal() hapd_global.add(ifname, driver="nl80211") - hapd = hostapd.Hostapd(ifname) + hapd = hostapd.Hostapd(apdev[0]) hapd.set_defaults() hapd.set("ssid", "dynamic") hapd.enable() diff --git a/tests/hwsim/test_ap_eap.py b/tests/hwsim/test_ap_eap.py index 46372a2..3a75b71 100644 --- a/tests/hwsim/test_ap_eap.py +++ b/tests/hwsim/test_ap_eap.py @@ -84,7 +84,8 @@ def check_ocsp_multi_support(dev): tls = dev.request("GET tls_library") if not tls.startswith("internal"): raise HwsimSkip("OCSP-multi not supported with this TLS library: " + tls) - as_hapd = hostapd.Hostapd("as") + asap = { "ifname" : "as" } + as_hapd = hostapd.Hostapd(asap) res = as_hapd.request("GET tls_library") del as_hapd if not res.startswith("internal"): @@ -117,7 +118,7 @@ def read_pem(fname): def eap_connect(dev, ap, method, identity, sha256=False, expect_failure=False, local_error_report=False, maybe_local_error=False, **kwargs): - hapd = hostapd.Hostapd(ap['ifname']) + hapd = hostapd.Hostapd(ap) id = dev.connect("test-wpa2-eap", key_mgmt="WPA-EAP WPA-EAP-SHA256", eap=method, identity=identity, wait_connect=False, scan_freq="2412", ieee80211w="1", @@ -1262,7 +1263,7 @@ def test_ap_wpa2_eap_ttls_mschapv2(dev, apdev): check_eap_capa(dev[0], "MSCHAPV2") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) eap_connect(dev[0], apdev[0], "TTLS", "DOMAIN\mschapv2 user", anonymous_identity="ttls", password="password", ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2", @@ -1317,7 +1318,7 @@ def test_ap_wpa2_eap_ttls_mschapv2_suffix_match(dev, apdev): skip_with_fips(dev[0]) params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) eap_connect(dev[0], apdev[0], "TTLS", "DOMAIN\mschapv2 user", anonymous_identity="ttls", password="password", ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2", @@ -1331,7 +1332,7 @@ def test_ap_wpa2_eap_ttls_mschapv2_domain_match(dev, apdev): skip_with_fips(dev[0]) params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) eap_connect(dev[0], apdev[0], "TTLS", "DOMAIN\mschapv2 user", anonymous_identity="ttls", password="password", ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2", @@ -1358,7 +1359,7 @@ def test_ap_wpa2_eap_ttls_mschapv2_utf8(dev, apdev): skip_with_fips(dev[0]) params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) eap_connect(dev[0], apdev[0], "TTLS", "utf8-user-hash", anonymous_identity="ttls", password="secret-åäö-€-password", ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2") @@ -2834,7 +2835,7 @@ def test_ap_wpa2_eap_interactive(dev, apdev): check_eap_capa(dev[0], "MSCHAPV2") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) tests = [ ("Connection with dynamic TTLS/MSCHAPv2 password entry", "TTLS", "ttls", "DOMAIN\mschapv2 user", "auth=MSCHAPV2", @@ -2876,7 +2877,7 @@ def test_ap_wpa2_eap_ext_enable_network_while_connected(dev, apdev): check_eap_capa(dev[0], "MSCHAPV2") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) id_other = dev[0].connect("other", key_mgmt="NONE", scan_freq="2412", only_add_network=True) diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index 2541a35..f36cb16 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -1041,7 +1041,7 @@ def test_ap_hs20_gas_frag_while_associated(dev, apdev): params = hs20_ap_params() params['hessid'] = bssid hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) hapd.set("gas_frag_limit", "50") dev[0].hs20_enable() @@ -1858,7 +1858,7 @@ def _test_ap_hs20_deauth_req_ess(dev, apdev): eap_test(dev[0], apdev[0], "21[3:26]", "TTLS", "user") dev[0].dump_monitor() addr = dev[0].p2p_interface_addr() - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) hapd.request("HS20_DEAUTH_REQ " + addr + " 1 120 http://example.com/") ev = dev[0].wait_event(["HS20-DEAUTH-IMMINENT-NOTICE"]) if ev is None: @@ -1888,7 +1888,7 @@ def _test_ap_hs20_deauth_req_bss(dev, apdev): eap_test(dev[0], apdev[0], "21[3:26]", "TTLS", "user") dev[0].dump_monitor() addr = dev[0].p2p_interface_addr() - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) hapd.request("HS20_DEAUTH_REQ " + addr + " 0 120 http://example.com/") ev = dev[0].wait_event(["HS20-DEAUTH-IMMINENT-NOTICE"]) if ev is None: diff --git a/tests/hwsim/test_ap_pmf.py b/tests/hwsim/test_ap_pmf.py index 69bc3d4..3136e8c 100644 --- a/tests/hwsim/test_ap_pmf.py +++ b/tests/hwsim/test_ap_pmf.py @@ -38,7 +38,7 @@ def test_ap_pmf_required(dev, apdev): key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2", scan_freq="2412") hwsim_utils.test_connectivity(dev[1], hapd) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) hapd.request("SA_QUERY " + dev[0].p2p_interface_addr()) hapd.request("SA_QUERY " + dev[1].p2p_interface_addr()) wt.require_ap_pmf_mandatory(apdev[0]['bssid']) diff --git a/tests/hwsim/test_ap_psk.py b/tests/hwsim/test_ap_psk.py index d5c22af..93bac83 100644 --- a/tests/hwsim/test_ap_psk.py +++ b/tests/hwsim/test_ap_psk.py @@ -2131,7 +2131,7 @@ def test_ap_cli_order(dev, apdev): hapd_global.remove(ifname) hapd_global.add(ifname) - hapd = hostapd.Hostapd(ifname) + hapd = hostapd.Hostapd(apdev[0]) hapd.set_defaults() hapd.set('ssid', ssid) hapd.set('wpa_passphrase', passphrase) diff --git a/tests/hwsim/test_ap_tdls.py b/tests/hwsim/test_ap_tdls.py index 71a6521..0a14c1d 100644 --- a/tests/hwsim/test_ap_tdls.py +++ b/tests/hwsim/test_ap_tdls.py @@ -105,7 +105,7 @@ def check_connectivity(sta0, sta1, hapd): def setup_tdls(sta0, sta1, ap, reverse=False, expect_fail=False): logger.info("Setup TDLS") - hapd = hostapd.Hostapd(ap['ifname']) + hapd = hostapd.Hostapd(ap) check_connectivity(sta0, sta1, hapd) bssid = ap['bssid'] addr0 = sta0.p2p_interface_addr() @@ -129,7 +129,7 @@ def setup_tdls(sta0, sta1, ap, reverse=False, expect_fail=False): def teardown_tdls(sta0, sta1, ap, responder=False, wildcard=False): logger.info("Teardown TDLS") - hapd = hostapd.Hostapd(ap['ifname']) + hapd = hostapd.Hostapd(ap) check_connectivity(sta0, sta1, hapd) bssid = ap['bssid'] addr0 = sta0.p2p_interface_addr() diff --git a/tests/hwsim/test_ap_vlan.py b/tests/hwsim/test_ap_vlan.py index 79c4166..8a7962d 100644 --- a/tests/hwsim/test_ap_vlan.py +++ b/tests/hwsim/test_ap_vlan.py @@ -331,8 +331,9 @@ def ap_vlan_iface_cleanup_multibss(dev, apdev, cfgfile): # start the actual test hostapd.add_iface(apdev[0], cfgfile) - hapd = hostapd.Hostapd(ifname) - hapd1 = hostapd.Hostapd("wlan3-2", 1) + hapd = hostapd.Hostapd(apdev[0]) + apdev1 = { "ifname" : "wlan3-2" } + hapd1 = hostapd.Hostapd(apdev1, 1) hapd1.enable() ifaces = netifaces.interfaces() diff --git a/tests/hwsim/test_ap_wps.py b/tests/hwsim/test_ap_wps.py index 712c7de..b69e22f 100644 --- a/tests/hwsim/test_ap_wps.py +++ b/tests/hwsim/test_ap_wps.py @@ -43,7 +43,7 @@ def test_ap_wps_init(dev, apdev): ssid = "test-wps" hostapd.add_ap(apdev[0], { "ssid": ssid, "eap_server": "1", "wps_state": "1" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step") hapd.request("WPS_PBC") if "PBC Status: Active" not in hapd.request("WPS_GET_STATUS"): @@ -100,7 +100,7 @@ def test_ap_wps_init_2ap_pbc(dev, apdev): params = { "ssid": ssid, "eap_server": "1", "wps_state": "1" } hostapd.add_ap(apdev[0], params) hostapd.add_ap(apdev[1], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step") hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412", force_scan=True) @@ -137,7 +137,7 @@ def test_ap_wps_init_2ap_pin(dev, apdev): params = { "ssid": ssid, "eap_server": "1", "wps_state": "1" } hostapd.add_ap(apdev[0], params) hostapd.add_ap(apdev[1], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step") pin = dev[0].wps_read_pin() hapd.request("WPS_PIN any " + pin) @@ -167,7 +167,7 @@ def test_ap_wps_init_through_wps_config(dev, apdev): ssid = "test-wps-init-config" hostapd.add_ap(apdev[0], { "ssid": ssid, "eap_server": "1", "wps_state": "1" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) if "FAIL" in hapd.request("WPS_CONFIG " + ssid.encode("hex") + " WPA2PSK CCMP " + "12345678".encode("hex")): raise Exception("WPS_CONFIG command failed") ev = hapd.wait_event(["WPS-NEW-AP-SETTINGS"], timeout=5) @@ -187,7 +187,7 @@ def test_ap_wps_init_through_wps_config_2(dev, apdev): hostapd.add_ap(apdev[0], { "ssid": ssid, "eap_server": "1", "wps_state": "1", "wps_cred_processing": "2" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) if "FAIL" in hapd.request("WPS_CONFIG " + ssid.encode("hex") + " WPA2PSK CCMP " + "12345678".encode("hex")): raise Exception("WPS_CONFIG command failed") ev = hapd.wait_event(["WPS-NEW-AP-SETTINGS"], timeout=5) @@ -201,7 +201,7 @@ def test_ap_wps_invalid_wps_config_passphrase(dev, apdev): ssid = "test-wps-init-config" hostapd.add_ap(apdev[0], { "ssid": ssid, "eap_server": "1", "wps_state": "1" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) if "FAIL" not in hapd.request("WPS_CONFIG " + ssid.encode("hex") + " WPA2PSK CCMP " + "1234567".encode("hex")): raise Exception("Invalid WPS_CONFIG command accepted") @@ -212,7 +212,7 @@ def test_ap_wps_conf(dev, apdev): { "ssid": ssid, "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step") hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") @@ -293,7 +293,7 @@ def test_ap_wps_twice(dev, apdev): "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" } hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step") hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") @@ -307,7 +307,7 @@ def test_ap_wps_twice(dev, apdev): hapd_global.remove(apdev[0]['ifname']) params['wpa_passphrase'] = 'another passphrase' hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step") hapd.request("WPS_PBC") dev[0].dump_monitor() @@ -324,7 +324,7 @@ def test_ap_wps_incorrect_pin(dev, apdev): { "ssid": ssid, "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning attempt 1") hapd.request("WPS_PIN any 12345670") @@ -367,7 +367,7 @@ def test_ap_wps_conf_pin(dev, apdev): { "ssid": ssid, "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step") pin = dev[0].wps_read_pin() hapd.request("WPS_PIN any " + pin) @@ -407,7 +407,7 @@ def test_ap_wps_conf_pin_mixed_mode(dev, apdev): "wpa_passphrase": "12345678", "wpa": "3", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", "wpa_pairwise": "TKIP" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step") pin = dev[0].wps_read_pin() @@ -464,7 +464,7 @@ def test_ap_wps_conf_pin_v1(dev, apdev): { "ssid": ssid, "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step") pin = dev[0].wps_read_pin() hapd.request("SET wps_version_number 0x10") @@ -490,7 +490,7 @@ def test_ap_wps_conf_pin_2sta(dev, apdev): { "ssid": ssid, "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step") pin = "12345670" pin2 = "55554444" @@ -512,7 +512,7 @@ def test_ap_wps_conf_pin_timeout(dev, apdev): { "ssid": ssid, "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) addr = dev[0].p2p_interface_addr() pin = dev[0].wps_read_pin() if "FAIL" not in hapd.request("WPS_PIN "): @@ -633,7 +633,7 @@ def test_ap_wps_random_ap_pin(dev, apdev): "os_version": "01020300", "config_methods": "label push_button", "uuid": ap_uuid, "upnp_iface": "lo" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) appin = hapd.request("WPS_AP_PIN random") if "FAIL" in appin: raise Exception("Could not generate random AP PIN") @@ -817,7 +817,7 @@ def test_ap_wps_setup_locked(dev, apdev): logger.info("BSS: " + str(bss)) raise Exception("AP Setup Locked not indicated in scan results") - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) status = hapd.request("WPS_GET_STATUS") if "Last WPS result: Failed" not in status: raise Exception("WPS failure result not shown correctly") @@ -828,7 +828,7 @@ def test_ap_wps_setup_locked(dev, apdev): dev[0].dump_monitor() logger.info("WPS provisioning step") pin = dev[0].wps_read_pin() - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) hapd.request("WPS_PIN any " + pin) dev[0].request("WPS_PIN %s %s" % (apdev[0]['bssid'], pin)) ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=30) @@ -877,7 +877,7 @@ def test_ap_wps_setup_locked_timeout(dev, apdev): time.sleep(0.1) if not ap_setup_locked: raise Exception("AP setup was not locked") - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) ev = hapd.wait_event(["WPS-AP-SETUP-UNLOCKED"], timeout=80) if ev is None: raise Exception("AP PIN did not get unlocked on 60 second timeout") @@ -932,9 +932,9 @@ def test_ap_wps_pbc_overlap_2ap(dev, apdev): "wpa_passphrase": "123456789", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", "wps_independent": "1"}) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) hapd.request("WPS_PBC") - hapd2 = hostapd.Hostapd(apdev[1]['ifname']) + hapd2 = hostapd.Hostapd(apdev[1]) hapd2.request("WPS_PBC") logger.info("WPS provisioning step") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412", force_scan=True) @@ -954,7 +954,7 @@ def test_ap_wps_pbc_overlap_2sta(dev, apdev): { "ssid": ssid, "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step") hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") @@ -993,7 +993,7 @@ def test_ap_wps_cancel(dev, apdev): "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" }) bssid = apdev[0]['bssid'] - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("Verify PBC enable/cancel") hapd.request("WPS_PBC") @@ -1917,7 +1917,7 @@ def test_ap_wps_fragmentation(dev, apdev): "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", "wpa_pairwise": "TKIP", "ap_pin": appin, "fragment_size": "50" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step (PBC)") hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) @@ -1967,7 +1967,7 @@ def test_ap_wps_new_version_sta(dev, apdev): { "ssid": ssid, "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step") hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") @@ -1984,7 +1984,7 @@ def test_ap_wps_new_version_ap(dev, apdev): { "ssid": ssid, "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step") if "FAIL" in hapd.request("SET wps_version_number 0x43"): raise Exception("Failed to enable test functionality") @@ -2001,7 +2001,7 @@ def test_ap_wps_check_pin(dev, apdev): { "ssid": "wps", "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) for t in [ ("12345670", "12345670"), ("12345678", "FAIL-CHECKSUM"), ("12345", "FAIL"), @@ -2034,7 +2034,7 @@ def test_ap_wps_wep_config(dev, apdev): hostapd.add_ap(apdev[0], { "ssid": ssid, "eap_server": "1", "wps_state": "2", "ap_pin": appin}) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) dev[0].wps_reg(apdev[0]['bssid'], appin, "wps-new-ssid-wep", "OPEN", "WEP", "hello", no_wait=True) @@ -2057,7 +2057,7 @@ def test_ap_wps_wep_enroll(dev, apdev): hostapd.add_ap(apdev[0], { "ssid": ssid, "eap_server": "1", "wps_state": "2", "skip_cred_build": "1", "extra_cred": "wps-wep-cred" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) dev[0].request("WPS_PBC " + apdev[0]['bssid']) @@ -2079,7 +2079,7 @@ def test_ap_wps_ie_fragmentation(dev, apdev): "model_number": "1234567890abcdef1234567890abcdef", "serial_number": "1234567890abcdef1234567890abcdef" } hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") dev[0].request("WPS_PBC " + apdev[0]['bssid']) @@ -2245,7 +2245,7 @@ def test_ap_wps_pin_request_file(dev, apdev): "wps_pin_requests": pinfile, "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) uuid = dev[0].get_status_field("uuid") pin = dev[0].wps_read_pin() try: @@ -2288,7 +2288,7 @@ def test_ap_wps_auto_setup_with_config_file(dev, apdev): f.write("eap_server=1\n") f.write("wps_state=1\n") hostapd.add_bss('phy3', apdev[0], conffile) - hapd = hostapd.Hostapd(ifname) + hapd = hostapd.Hostapd(apdev[0]) hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") dev[0].request("WPS_PBC " + apdev[0]['bssid']) @@ -3436,7 +3436,7 @@ def test_ap_wps_disabled(dev, apdev): """WPS operations while WPS is disabled""" ssid = "test-wps-disabled" hostapd.add_ap(apdev[0], { "ssid": ssid }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) if "FAIL" not in hapd.request("WPS_PBC"): raise Exception("WPS_PBC succeeded unexpectedly") if "FAIL" not in hapd.request("WPS_CANCEL"): @@ -3448,7 +3448,7 @@ def test_ap_wps_mixed_cred(dev, apdev): hostapd.add_ap(apdev[0], { "ssid": ssid, "eap_server": "1", "wps_state": "2", "skip_cred_build": "1", "extra_cred": "wps-mixed-cred" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") dev[0].request("WPS_PBC " + apdev[0]['bssid']) @@ -3473,7 +3473,7 @@ def test_ap_wps_while_connected(dev, apdev): { "ssid": ssid, "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) hostapd.add_ap(apdev[1], { "ssid": "open" }) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") @@ -3494,7 +3494,7 @@ def test_ap_wps_while_connected_no_autoconnect(dev, apdev): { "ssid": ssid, "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) hostapd.add_ap(apdev[1], { "ssid": "open" }) @@ -3573,7 +3573,7 @@ def test_ap_wps_eapol_workaround(dev, apdev): ssid = "test-wps" hostapd.add_ap(apdev[0], { "ssid": ssid, "eap_server": "1", "wps_state": "1" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) bssid = apdev[0]['bssid'] hapd.request("SET ext_eapol_frame_io 1") dev[0].request("SET ext_eapol_frame_io 1") @@ -3682,7 +3682,7 @@ def test_ap_wps_priority(dev, apdev): { "ssid": ssid, "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step") pin = dev[0].wps_read_pin() hapd.request("WPS_PIN any " + pin) @@ -3835,7 +3835,7 @@ def test_ap_wps_wpa_cli_action(dev, apdev, test_params): { "ssid": ssid, "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) prg = os.path.join(test_params['logdir'], 'alt-wpa_supplicant/wpa_supplicant/wpa_cli') diff --git a/tests/hwsim/test_dbus.py b/tests/hwsim/test_dbus.py index d8572dc..bff633a 100644 --- a/tests/hwsim/test_dbus.py +++ b/tests/hwsim/test_dbus.py @@ -759,7 +759,7 @@ def _test_dbus_wps_pin2(dev, apdev): res = wps.Start({'Role': 'enrollee', 'Type': 'pin', 'Bssid': bssid_ay}) pin = res['Pin'] - h = hostapd.Hostapd(apdev[0]['ifname']) + h = hostapd.Hostapd(apdev[0]) h.request("WPS_PIN any " + pin) return False @@ -810,7 +810,7 @@ def _test_dbus_wps_pin_m2d(dev, apdev): if self.credentials_received: self.loop.quit() elif name == "m2d": - h = hostapd.Hostapd(apdev[0]['ifname']) + h = hostapd.Hostapd(apdev[0]) h.request("WPS_PIN any 12345670") def credentials(self, args): diff --git a/tests/hwsim/test_dbus_old.py b/tests/hwsim/test_dbus_old.py index 9034fdd..f933df8 100644 --- a/tests/hwsim/test_dbus_old.py +++ b/tests/hwsim/test_dbus_old.py @@ -745,7 +745,7 @@ def _test_dbus_old_wps_pin(dev, apdev): pin = if_obj.wpsPin(self.bssid, self.pin, dbus_interface=WPAS_DBUS_OLD_IFACE) if len(self.pin) == 0: - h = hostapd.Hostapd(apdev[0]['ifname']) + h = hostapd.Hostapd(apdev[0]) h.request("WPS_PIN any " + pin) return False diff --git a/tests/hwsim/test_dfs.py b/tests/hwsim/test_dfs.py index 49b0611..e4c9bdb 100644 --- a/tests/hwsim/test_dfs.py +++ b/tests/hwsim/test_dfs.py @@ -30,10 +30,10 @@ def start_dfs_ap(ap, allow_failure=False, ssid="dfs", ht=True, ht40=False, channel=None): ifname = ap['ifname'] logger.info("Starting AP " + ifname + " on DFS channel") - hapd_global = hostapd.HostapdGlobal() + hapd_global = hostapd.HostapdGlobal(ap) hapd_global.remove(ifname) hapd_global.add(ifname) - hapd = hostapd.Hostapd(ifname) + hapd = hostapd.Hostapd(ap) if not hapd.ping(): raise Exception("Could not ping hostapd") hapd.set_defaults() diff --git a/tests/hwsim/test_gas.py b/tests/hwsim/test_gas.py index f44d718..053e0d8 100644 --- a/tests/hwsim/test_gas.py +++ b/tests/hwsim/test_gas.py @@ -53,7 +53,7 @@ def start_ap(ap): params = hs20_ap_params() params['hessid'] = ap['bssid'] hostapd.add_ap(ap, params) - return hostapd.Hostapd(ap['ifname']) + return hostapd.Hostapd(ap) def get_gas_response(dev, bssid, info, allow_fetch_failure=False, extra_test=False): diff --git a/tests/hwsim/test_nfc_wps.py b/tests/hwsim/test_nfc_wps.py index 5f7add8..d8fe639 100644 --- a/tests/hwsim/test_nfc_wps.py +++ b/tests/hwsim/test_nfc_wps.py @@ -39,7 +39,7 @@ def test_nfc_wps_password_token_sta(dev, apdev): ssid = "test-wps-nfc-pw-token-conf" params = ap_wps_params(ssid) hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step using password token from station") wps = dev[0].request("WPS_NFC_TOKEN WPS").rstrip() if "FAIL" in wps: @@ -62,7 +62,7 @@ def test_nfc_wps_config_token(dev, apdev): ssid = "test-wps-nfc-conf-token" params = ap_wps_params(ssid) hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("NFC configuration token from AP to station") conf = hapd.request("WPS_NFC_CONFIG_TOKEN NDEF").rstrip() if "FAIL" in conf: @@ -84,7 +84,7 @@ def test_nfc_wps_config_token_init(dev, apdev): ssid = "test-wps-nfc-conf-token-init" hostapd.add_ap(apdev[0], { "ssid": ssid, "eap_server": "1", "wps_state": "1" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("NFC configuration token from AP to station") conf = hapd.request("WPS_NFC_CONFIG_TOKEN NDEF").rstrip() if "FAIL" in conf: @@ -101,7 +101,7 @@ def test_nfc_wps_password_token_sta_init(dev, apdev): ssid = "test-wps-nfc-pw-token-init" hostapd.add_ap(apdev[0], { "ssid": ssid, "eap_server": "1", "wps_state": "1" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step using password token from station") pw = dev[0].request("WPS_NFC_TOKEN NDEF").rstrip() if "FAIL" in pw: @@ -121,7 +121,7 @@ def test_nfc_wps_password_token_ap(dev, apdev): ssid = "test-wps-nfc-pw-token-init" hostapd.add_ap(apdev[0], { "ssid": ssid, "eap_server": "1", "wps_state": "1" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS configuration step") pw = hapd.request("WPS_NFC_TOKEN NDEF").rstrip() if "FAIL" in pw: @@ -164,7 +164,7 @@ def _test_nfc_wps_handover_init(dev, apdev): ssid = "test-wps-nfc-handover-init" hostapd.add_ap(apdev[0], { "ssid": ssid, "eap_server": "1", "wps_state": "1" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("NFC connection handover") req = dev[0].request("NFC_GET_HANDOVER_REQ NDEF WPS-CR").rstrip() if "FAIL" in req: @@ -191,7 +191,7 @@ def test_nfc_wps_handover_errors(dev, apdev): ssid = "test-wps-nfc-handover" hostapd.add_ap(apdev[0], { "ssid": ssid, "eap_server": "1", "wps_state": "1" }) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) sel = hapd.request("NFC_GET_HANDOVER_SEL NDEF WPS-CR").rstrip() if "FAIL" in sel: raise Exception("Failed to generate NFC connection handover select") @@ -221,7 +221,7 @@ def test_nfc_wps_handover(dev, apdev): ssid = "test-wps-nfc-handover" params = ap_wps_params(ssid) hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("NFC connection handover") req = dev[0].request("NFC_GET_HANDOVER_REQ NDEF WPS-CR").rstrip() if "FAIL" in req: @@ -308,7 +308,7 @@ def test_nfc_wps_handover_with_pw_token_set(dev, apdev): ssid = "test-wps-nfc-handover2" params = ap_wps_params(ssid) hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) # enable a password token (which won't be used in this test case) pw = hapd.request("WPS_NFC_TOKEN NDEF").rstrip() if "FAIL" in pw: @@ -340,7 +340,7 @@ def test_nfc_wps_handover_pk_hash_mismatch_sta(dev, apdev): raise Exception("Could not enable wps_corrupt_pkhash") params = ap_wps_params(ssid) hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("NFC connection handover") req = dev[0].request("NFC_GET_HANDOVER_REQ NDEF WPS-CR").rstrip() if "FAIL" in req: @@ -366,7 +366,7 @@ def test_nfc_wps_handover_pk_hash_mismatch_ap(dev, apdev): ssid = "wps-nfc-handover-pkhash-ap" params = ap_wps_params(ssid) hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) if "FAIL" in hapd.request("SET wps_corrupt_pkhash 1"): raise Exception("Could not enable wps_corrupt_pkhash") logger.info("NFC connection handover") @@ -434,7 +434,7 @@ def test_nfc_wps_er_pw_token(dev, apdev): def _test_nfc_wps_er_pw_token(dev, apdev): ssid = "wps-nfc-er-pw-token" start_ap_er(dev[0], apdev[0], ssid) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step using password token from station") dev[1].request("SET ignore_old_scan_res 1") pw = dev[1].request("WPS_NFC_TOKEN NDEF").rstrip() @@ -464,7 +464,7 @@ def test_nfc_wps_er_config_token(dev, apdev): def _test_nfc_wps_er_config_token(dev, apdev): ssid = "wps-nfc-er-config-token" start_ap_er(dev[0], apdev[0], ssid) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step using configuration token from ER") wps = dev[0].request("WPS_ER_NFC_CONFIG_TOKEN WPS " + apdev[0]['bssid']).rstrip() if "FAIL" in wps: @@ -489,7 +489,7 @@ def test_nfc_wps_er_handover(dev, apdev): def _test_nfc_wps_er_handover(dev, apdev): ssid = "wps-nfc-er-handover" start_ap_er(dev[0], apdev[0], ssid) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step using connection handover") req = dev[1].request("NFC_GET_HANDOVER_REQ NDEF WPS-CR").rstrip() if "FAIL" in req: @@ -518,7 +518,7 @@ def test_nfc_wps_er_handover_pk_hash_mismatch_sta(dev, apdev): def _test_nfc_wps_er_handover_pk_hash_mismatch_sta(dev, apdev): ssid = "wps-nfc-er-handover-pkhash-sta" start_ap_er(dev[0], apdev[0], ssid) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step using connection handover") if "FAIL" in dev[1].request("SET wps_corrupt_pkhash 1"): raise Exception("Could not enable wps_corrupt_pkhash") @@ -553,7 +553,7 @@ def test_nfc_wps_er_handover_pk_hash_mismatch_er(dev, apdev): def _test_nfc_wps_er_handover_pk_hash_mismatch_er(dev, apdev): ssid = "wps-nfc-er-handover-pkhash-er" start_ap_er(dev[0], apdev[0], ssid) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) logger.info("WPS provisioning step using connection handover") if "FAIL" in dev[0].request("SET wps_corrupt_pkhash 1"): raise Exception("Could not enable wps_corrupt_pkhash") diff --git a/tests/hwsim/test_radius.py b/tests/hwsim/test_radius.py index b1fb477..b7d3c5f 100644 --- a/tests/hwsim/test_radius.py +++ b/tests/hwsim/test_radius.py @@ -32,7 +32,7 @@ def test_radius_auth_unreachable(dev, apdev): params = hostapd.wpa2_eap_params(ssid="radius-auth") params['auth_server_port'] = "18139" hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) connect(dev[0], "radius-auth", wait_connect=False) ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"]) if ev is None: @@ -54,7 +54,7 @@ def test_radius_auth_unreachable2(dev, apdev): params['auth_server_addr'] = "192.168.213.17" params['auth_server_port'] = "18139" hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) subprocess.call(['ip', 'ro', 'del', '192.168.213.17', 'dev', 'lo']) connect(dev[0], "radius-auth", wait_connect=False) ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"]) @@ -74,7 +74,7 @@ def test_radius_auth_unreachable3(dev, apdev): params = hostapd.wpa2_eap_params(ssid="radius-auth") params['auth_server_addr'] = "192.168.213.18" hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) connect(dev[0], "radius-auth", wait_connect=False) ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"]) if ev is None: @@ -94,7 +94,7 @@ def test_radius_acct_unreachable(dev, apdev): params['acct_server_port'] = "18139" params['acct_server_shared_secret'] = "radius" hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) connect(dev[0], "radius-acct") logger.info("Checking for RADIUS retries") time.sleep(4) @@ -114,7 +114,7 @@ def test_radius_acct_unreachable2(dev, apdev): params['acct_server_port'] = "18139" params['acct_server_shared_secret'] = "radius" hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) subprocess.call(['ip', 'ro', 'del', '192.168.213.17', 'dev', 'lo']) connect(dev[0], "radius-acct") logger.info("Checking for RADIUS retries") @@ -129,14 +129,15 @@ def test_radius_acct_unreachable3(dev, apdev): """RADIUS Accounting server initially unreachable, but then available""" require_under_vm() subprocess.call(['ip', 'ro', 'replace', 'blackhole', '192.168.213.18']) - as_hapd = hostapd.Hostapd("as") + apas = { "ifname" : "as" } + as_hapd = hostapd.Hostapd(apas) as_mib_start = as_hapd.get_mib(param="radius_server") params = hostapd.wpa2_eap_params(ssid="radius-acct") params['acct_server_addr'] = "192.168.213.18" params['acct_server_port'] = "1813" params['acct_server_shared_secret'] = "radius" hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) connect(dev[0], "radius-acct") subprocess.call(['ip', 'ro', 'del', 'blackhole', '192.168.213.18']) time.sleep(0.1) @@ -158,7 +159,7 @@ def test_radius_acct_unreachable4(dev, apdev): params['acct_server_port'] = "18139" params['acct_server_shared_secret'] = "radius" hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) for i in range(20): connect(dev[0], "radius-acct") dev[0].request("REMOVE_NETWORK all") @@ -166,7 +167,8 @@ def test_radius_acct_unreachable4(dev, apdev): def test_radius_acct(dev, apdev): """RADIUS Accounting""" - as_hapd = hostapd.Hostapd("as") + apas = { "ifname" : "as" } + as_hapd = hostapd.Hostapd(apas) as_mib_start = as_hapd.get_mib(param="radius_server") params = hostapd.wpa2_eap_params(ssid="radius-acct") params['acct_server_addr'] = "127.0.0.1" @@ -175,7 +177,7 @@ def test_radius_acct(dev, apdev): params['radius_auth_req_attr'] = [ "126:s:Operator", "77:s:testing" ] params['radius_acct_req_attr'] = [ "126:s:Operator", "77:s:testing" ] hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) connect(dev[0], "radius-acct") dev[1].connect("radius-acct", key_mgmt="WPA-EAP", scan_freq="2412", eap="PAX", identity="test-class", @@ -225,7 +227,8 @@ def test_radius_acct_non_ascii_ssid(dev, apdev): def test_radius_acct_pmksa_caching(dev, apdev): """RADIUS Accounting with PMKSA caching""" - as_hapd = hostapd.Hostapd("as") + apas = { "ifname" : "as" } + as_hapd = hostapd.Hostapd(apas) as_mib_start = as_hapd.get_mib(param="radius_server") params = hostapd.wpa2_eap_params(ssid="radius-acct") params['acct_server_addr'] = "127.0.0.1" @@ -267,14 +270,15 @@ def test_radius_acct_pmksa_caching(dev, apdev): def test_radius_acct_interim(dev, apdev): """RADIUS Accounting interim update""" - as_hapd = hostapd.Hostapd("as") + apas = { "ifname" : "as" } + as_hapd = hostapd.Hostapd(apas) params = hostapd.wpa2_eap_params(ssid="radius-acct") params['acct_server_addr'] = "127.0.0.1" params['acct_server_port'] = "1813" params['acct_server_shared_secret'] = "radius" params['radius_acct_interim_interval'] = "1" hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) connect(dev[0], "radius-acct") logger.info("Checking for RADIUS counters") as_mib_start = as_hapd.get_mib(param="radius_server") @@ -380,7 +384,8 @@ def send_and_check_reply(srv, req, code, error_cause=0): def test_radius_acct_psk(dev, apdev): """RADIUS Accounting - PSK""" - as_hapd = hostapd.Hostapd("as") + apas = { "ifname" : "as" } + as_hapd = hostapd.Hostapd(apas) params = hostapd.wpa2_params(ssid="radius-acct", passphrase="12345678") params['acct_server_addr'] = "127.0.0.1" params['acct_server_port'] = "1813" @@ -390,7 +395,8 @@ def test_radius_acct_psk(dev, apdev): def test_radius_acct_psk_sha256(dev, apdev): """RADIUS Accounting - PSK SHA256""" - as_hapd = hostapd.Hostapd("as") + apas = { "ifname" : "as" } + as_hapd = hostapd.Hostapd(apas) params = hostapd.wpa2_params(ssid="radius-acct", passphrase="12345678") params["wpa_key_mgmt"] = "WPA-PSK-SHA256" params['acct_server_addr'] = "127.0.0.1" @@ -402,7 +408,8 @@ def test_radius_acct_psk_sha256(dev, apdev): def test_radius_acct_ft_psk(dev, apdev): """RADIUS Accounting - FT-PSK""" - as_hapd = hostapd.Hostapd("as") + apas = { "ifname" : "as" } + as_hapd = hostapd.Hostapd(apas) params = ft_params1(ssid="radius-acct", passphrase="12345678") params['acct_server_addr'] = "127.0.0.1" params['acct_server_port'] = "1813" @@ -414,7 +421,8 @@ def test_radius_acct_ft_psk(dev, apdev): def test_radius_acct_ieee8021x(dev, apdev): """RADIUS Accounting - IEEE 802.1X""" skip_with_fips(dev[0]) - as_hapd = hostapd.Hostapd("as") + apas = { "ifname" : "as" } + as_hapd = hostapd.Hostapd(apas) params = hostapd.radius_params() params["ssid"] = "radius-acct-1x" params["ieee8021x"] = "1" @@ -814,7 +822,8 @@ def test_radius_macacl_acct(dev, apdev): def test_radius_failover(dev, apdev): """RADIUS Authentication and Accounting server failover""" subprocess.call(['ip', 'ro', 'replace', '192.168.213.17', 'dev', 'lo']) - as_hapd = hostapd.Hostapd("as") + apas = { "ifname" : "as" } + as_hapd = hostapd.Hostapd(apas) as_mib_start = as_hapd.get_mib(param="radius_server") params = hostapd.wpa2_eap_params(ssid="radius-failover") params["auth_server_addr"] = "192.168.213.17" diff --git a/tests/hwsim/test_wnm.py b/tests/hwsim/test_wnm.py index 0eb27da..bc3d1e4 100644 --- a/tests/hwsim/test_wnm.py +++ b/tests/hwsim/test_wnm.py @@ -36,7 +36,7 @@ def test_wnm_disassoc_imminent(dev, apdev): "wnm_sleep_mode": "1", "bss_transition": "1" } hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) dev[0].connect("test-wnm", key_mgmt="NONE", scan_freq="2412") addr = dev[0].p2p_interface_addr() @@ -58,7 +58,7 @@ def test_wnm_ess_disassoc_imminent(dev, apdev): "wnm_sleep_mode": "1", "bss_transition": "1" } hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) dev[0].connect("test-wnm", key_mgmt="NONE", scan_freq="2412") addr = dev[0].p2p_interface_addr() @@ -79,7 +79,7 @@ def test_wnm_ess_disassoc_imminent_pmf(dev, apdev): params["ieee80211w"] = "2"; params["bss_transition"] = "1" hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) dev[0].connect("test-wnm-rsn", psk="12345678", ieee80211w="2", key_mgmt="WPA-PSK-SHA256", proto="WPA2", scan_freq="2412") @@ -138,7 +138,7 @@ def test_wnm_sleep_mode_open(dev, apdev): "wnm_sleep_mode": "1", "bss_transition": "1" } hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) dev[0].connect("test-wnm", key_mgmt="NONE", scan_freq="2412") ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5) @@ -163,7 +163,7 @@ def test_wnm_sleep_mode_rsn(dev, apdev): params["wnm_sleep_mode"] = "1" params["bss_transition"] = "1" hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) dev[0].connect("test-wnm-rsn", psk="12345678", scan_freq="2412") ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5) @@ -201,7 +201,7 @@ def test_wnm_sleep_mode_rsn_pmf(dev, apdev): params["wnm_sleep_mode"] = "1" params["bss_transition"] = "1" hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.Hostapd(apdev[0]) dev[0].connect("test-wnm-rsn", psk="12345678", ieee80211w="2", key_mgmt="WPA-PSK-SHA256", proto="WPA2", scan_freq="2412") -- 1.9.1 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap