tests: Pass wpas/hapd instance to test_connectivity()

This makes it easier to replace data connectivity testing to use
something else than local hwsim_test binary on the controller device.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-10-19 17:54:49 +03:00
parent 5d7746b589
commit a8375c94c0
26 changed files with 411 additions and 380 deletions

View file

@ -10,7 +10,7 @@ import time
import logging import logging
logger = logging.getLogger() logger = logging.getLogger()
def test_connectivity(ifname1, ifname2, dscp=None, tos=None, max_tries=1): def test_connectivity_run(ifname1, ifname2, dscp=None, tos=None, max_tries=1):
if os.path.isfile("../../mac80211_hwsim/tools/hwsim_test"): if os.path.isfile("../../mac80211_hwsim/tools/hwsim_test"):
hwsim_test = "../../mac80211_hwsim/tools/hwsim_test" hwsim_test = "../../mac80211_hwsim/tools/hwsim_test"
else: else:
@ -40,17 +40,25 @@ def test_connectivity(ifname1, ifname2, dscp=None, tos=None, max_tries=1):
if not success: if not success:
raise Exception("hwsim_test failed") raise Exception("hwsim_test failed")
def test_connectivity(dev1, dev2, dscp=None, tos=None, max_tries=1):
test_connectivity_run(dev1.ifname, dev2.ifname, dscp=dscp, tos=tos,
max_tries=max_tries)
def test_connectivity_iface(dev1, ifname, dscp=None, tos=None, max_tries=1):
test_connectivity_run(dev1.ifname, ifname, dscp=dscp, tos=tos,
max_tries=max_tries)
def test_connectivity_p2p(dev1, dev2, dscp=None, tos=None): def test_connectivity_p2p(dev1, dev2, dscp=None, tos=None):
ifname1 = dev1.group_ifname if dev1.group_ifname else dev1.ifname ifname1 = dev1.group_ifname if dev1.group_ifname else dev1.ifname
ifname2 = dev2.group_ifname if dev2.group_ifname else dev2.ifname ifname2 = dev2.group_ifname if dev2.group_ifname else dev2.ifname
test_connectivity(ifname1, ifname2, dscp, tos) test_connectivity_run(ifname1, ifname2, dscp, tos)
def test_connectivity_p2p_sta(dev1, dev2, dscp=None, tos=None): def test_connectivity_p2p_sta(dev1, dev2, dscp=None, tos=None):
ifname1 = dev1.group_ifname if dev1.group_ifname else dev1.ifname ifname1 = dev1.group_ifname if dev1.group_ifname else dev1.ifname
ifname2 = dev2.ifname ifname2 = dev2.ifname
test_connectivity(ifname1, ifname2, dscp, tos) test_connectivity_run(ifname1, ifname2, dscp, tos)
def test_connectivity_sta(dev1, dev2, dscp=None, tos=None): def test_connectivity_sta(dev1, dev2, dscp=None, tos=None):
ifname1 = dev1.ifname ifname1 = dev1.ifname
ifname2 = dev2.ifname ifname2 = dev2.ifname
test_connectivity(ifname1, ifname2, dscp, tos) test_connectivity_run(ifname1, ifname2, dscp, tos)

View file

@ -21,10 +21,10 @@ def check_cipher(dev, ap, cipher):
"wpa": "2", "wpa": "2",
"wpa_key_mgmt": "WPA-PSK", "wpa_key_mgmt": "WPA-PSK",
"rsn_pairwise": cipher } "rsn_pairwise": cipher }
hostapd.add_ap(ap['ifname'], params) hapd = hostapd.add_ap(ap['ifname'], params)
dev.connect("test-wpa2-psk", psk="12345678", dev.connect("test-wpa2-psk", psk="12345678",
pairwise=cipher, group=cipher, scan_freq="2412") pairwise=cipher, group=cipher, scan_freq="2412")
hwsim_utils.test_connectivity(dev.ifname, ap['ifname']) hwsim_utils.test_connectivity(dev, hapd)
def test_ap_cipher_tkip(dev, apdev): def test_ap_cipher_tkip(dev, apdev):
"""WPA2-PSK/TKIP connection""" """WPA2-PSK/TKIP connection"""
@ -140,7 +140,7 @@ def test_ap_cipher_mixed_wpa_wpa2(dev, apdev):
"wpa_key_mgmt": "WPA-PSK", "wpa_key_mgmt": "WPA-PSK",
"rsn_pairwise": "CCMP", "rsn_pairwise": "CCMP",
"wpa_pairwise": "TKIP" } "wpa_pairwise": "TKIP" }
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk=passphrase, proto="WPA2", dev[0].connect(ssid, psk=passphrase, proto="WPA2",
pairwise="CCMP", group="TKIP", scan_freq="2412") pairwise="CCMP", group="TKIP", scan_freq="2412")
status = dev[0].get_status() status = dev[0].get_status()
@ -157,7 +157,7 @@ def test_ap_cipher_mixed_wpa_wpa2(dev, apdev):
raise Exception("Missing BSS flag WPA-PSK-TKIP") raise Exception("Missing BSS flag WPA-PSK-TKIP")
if "[WPA2-PSK-CCMP]" not in bss['flags']: if "[WPA2-PSK-CCMP]" not in bss['flags']:
raise Exception("Missing BSS flag WPA2-PSK-CCMP") raise Exception("Missing BSS flag WPA2-PSK-CCMP")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
dev[1].connect(ssid, psk=passphrase, proto="WPA", dev[1].connect(ssid, psk=passphrase, proto="WPA",
pairwise="TKIP", group="TKIP", scan_freq="2412") pairwise="TKIP", group="TKIP", scan_freq="2412")
@ -168,5 +168,5 @@ def test_ap_cipher_mixed_wpa_wpa2(dev, apdev):
raise Exception("Incorrect pairwise_cipher reported") raise Exception("Incorrect pairwise_cipher reported")
if status['group_cipher'] != 'TKIP': if status['group_cipher'] != 'TKIP':
raise Exception("Incorrect group_cipher reported") raise Exception("Incorrect group_cipher reported")
hwsim_utils.test_connectivity(dev[1].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[1], hapd)
hwsim_utils.test_connectivity(dev[0].ifname, dev[1].ifname) hwsim_utils.test_connectivity(dev[0], dev[1])

View file

@ -39,9 +39,9 @@ def test_ap_csa_1_switch(dev, apdev):
return "skip" return "skip"
ap = connect(dev[0], apdev) ap = connect(dev[0], apdev)
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], ap)
switch_channel(ap, 10, 2462) switch_channel(ap, 10, 2462)
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], ap)
def test_ap_csa_2_switches(dev, apdev): def test_ap_csa_2_switches(dev, apdev):
"""AP Channel Switch, two switches""" """AP Channel Switch, two switches"""
@ -49,11 +49,11 @@ def test_ap_csa_2_switches(dev, apdev):
return "skip" return "skip"
ap = connect(dev[0], apdev) ap = connect(dev[0], apdev)
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], ap)
switch_channel(ap, 10, 2462) switch_channel(ap, 10, 2462)
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], ap)
switch_channel(ap, 10, 2412) switch_channel(ap, 10, 2412)
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], ap)
def test_ap_csa_1_switch_count_0(dev, apdev): def test_ap_csa_1_switch_count_0(dev, apdev):
"""AP Channel Switch, one switch with count 0""" """AP Channel Switch, one switch with count 0"""
@ -61,7 +61,7 @@ def test_ap_csa_1_switch_count_0(dev, apdev):
return "skip" return "skip"
ap = connect(dev[0], apdev) ap = connect(dev[0], apdev)
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], ap)
switch_channel(ap, 0, 2462) switch_channel(ap, 0, 2462)
# this does not result in CSA currently, so do not bother checking # this does not result in CSA currently, so do not bother checking
# connectivity # connectivity
@ -72,7 +72,7 @@ def test_ap_csa_2_switches_count_0(dev, apdev):
return "skip" return "skip"
ap = connect(dev[0], apdev) ap = connect(dev[0], apdev)
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], ap)
switch_channel(ap, 0, 2462) switch_channel(ap, 0, 2462)
# this does not result in CSA currently, so do not bother checking # this does not result in CSA currently, so do not bother checking
# connectivity # connectivity
@ -86,7 +86,7 @@ def test_ap_csa_1_switch_count_1(dev, apdev):
return "skip" return "skip"
ap = connect(dev[0], apdev) ap = connect(dev[0], apdev)
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], ap)
switch_channel(ap, 1, 2462) switch_channel(ap, 1, 2462)
# this does not result in CSA currently, so do not bother checking # this does not result in CSA currently, so do not bother checking
# connectivity # connectivity
@ -97,7 +97,7 @@ def test_ap_csa_2_switches_count_1(dev, apdev):
return "skip" return "skip"
ap = connect(dev[0], apdev) ap = connect(dev[0], apdev)
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], ap)
switch_channel(ap, 1, 2462) switch_channel(ap, 1, 2462)
# this does not result in CSA currently, so do not bother checking # this does not result in CSA currently, so do not bother checking
# connectivity # connectivity
@ -111,6 +111,6 @@ def test_ap_csa_1_switch_count_2(dev, apdev):
return "skip" return "skip"
ap = connect(dev[0], apdev) ap = connect(dev[0], apdev)
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], ap)
switch_channel(ap, 2, 2462) switch_channel(ap, 2, 2462)
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], ap)

View file

@ -107,10 +107,10 @@ def test_ap_wpa2_eap_sim(dev, apdev):
logger.info("No hlr_auc_gw available"); logger.info("No hlr_auc_gw available");
return "skip" return "skip"
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
eap_connect(dev[0], apdev[0], "SIM", "1232010000000000", eap_connect(dev[0], apdev[0], "SIM", "1232010000000000",
password="90dca4eda45b53cf0f12d7c9c3bc6a89:cb9cccc4b9258e6dca4760379fb82581") password="90dca4eda45b53cf0f12d7c9c3bc6a89:cb9cccc4b9258e6dca4760379fb82581")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
eap_reauth(dev[0], "SIM") eap_reauth(dev[0], "SIM")
eap_connect(dev[1], apdev[0], "SIM", "1232010000000001", eap_connect(dev[1], apdev[0], "SIM", "1232010000000001",
@ -378,10 +378,10 @@ def test_ap_wpa2_eap_aka(dev, apdev):
logger.info("No hlr_auc_gw available"); logger.info("No hlr_auc_gw available");
return "skip" return "skip"
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
eap_connect(dev[0], apdev[0], "AKA", "0232010000000000", eap_connect(dev[0], apdev[0], "AKA", "0232010000000000",
password="90dca4eda45b53cf0f12d7c9c3bc6a89:cb9cccc4b9258e6dca4760379fb82581:000000000123") password="90dca4eda45b53cf0f12d7c9c3bc6a89:cb9cccc4b9258e6dca4760379fb82581:000000000123")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
eap_reauth(dev[0], "AKA") eap_reauth(dev[0], "AKA")
logger.info("Negative test with incorrect key") logger.info("Negative test with incorrect key")
@ -672,10 +672,10 @@ def test_ap_wpa2_eap_aka_prime(dev, apdev):
logger.info("No hlr_auc_gw available"); logger.info("No hlr_auc_gw available");
return "skip" return "skip"
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
eap_connect(dev[0], apdev[0], "AKA'", "6555444333222111", eap_connect(dev[0], apdev[0], "AKA'", "6555444333222111",
password="5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123") password="5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
eap_reauth(dev[0], "AKA'") eap_reauth(dev[0], "AKA'")
logger.info("EAP-AKA' bidding protection when EAP-AKA enabled as well") logger.info("EAP-AKA' bidding protection when EAP-AKA enabled as well")
@ -765,7 +765,7 @@ def test_ap_wpa2_eap_ttls_pap(dev, apdev):
ca_cert="auth_serv/ca.pem", phase2="auth=PAP", ca_cert="auth_serv/ca.pem", phase2="auth=PAP",
subject_match="/C=FI/O=w1.fi/CN=server.w1.fi", subject_match="/C=FI/O=w1.fi/CN=server.w1.fi",
altsubject_match="EMAIL:noone@example.com;DNS:server.w1.fi;URI:http://example.com/") altsubject_match="EMAIL:noone@example.com;DNS:server.w1.fi;URI:http://example.com/")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
eap_reauth(dev[0], "TTLS") eap_reauth(dev[0], "TTLS")
check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-1"), check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-1"),
("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-1") ]) ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-1") ])
@ -786,12 +786,12 @@ def test_ap_wpa2_eap_ttls_pap_incorrect_password(dev, apdev):
def test_ap_wpa2_eap_ttls_chap(dev, apdev): def test_ap_wpa2_eap_ttls_chap(dev, apdev):
"""WPA2-Enterprise connection using EAP-TTLS/CHAP""" """WPA2-Enterprise connection using EAP-TTLS/CHAP"""
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
eap_connect(dev[0], apdev[0], "TTLS", "chap user", eap_connect(dev[0], apdev[0], "TTLS", "chap user",
anonymous_identity="ttls", password="password", anonymous_identity="ttls", password="password",
ca_cert="auth_serv/ca.der", phase2="auth=CHAP", ca_cert="auth_serv/ca.der", phase2="auth=CHAP",
altsubject_match="EMAIL:noone@example.com;URI:http://example.com/;DNS:server.w1.fi") altsubject_match="EMAIL:noone@example.com;URI:http://example.com/;DNS:server.w1.fi")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
eap_reauth(dev[0], "TTLS") eap_reauth(dev[0], "TTLS")
def test_ap_wpa2_eap_ttls_chap_incorrect_password(dev, apdev): def test_ap_wpa2_eap_ttls_chap_incorrect_password(dev, apdev):
@ -810,12 +810,12 @@ def test_ap_wpa2_eap_ttls_chap_incorrect_password(dev, apdev):
def test_ap_wpa2_eap_ttls_mschap(dev, apdev): def test_ap_wpa2_eap_ttls_mschap(dev, apdev):
"""WPA2-Enterprise connection using EAP-TTLS/MSCHAP""" """WPA2-Enterprise connection using EAP-TTLS/MSCHAP"""
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
eap_connect(dev[0], apdev[0], "TTLS", "mschap user", eap_connect(dev[0], apdev[0], "TTLS", "mschap user",
anonymous_identity="ttls", password="password", anonymous_identity="ttls", password="password",
ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAP", ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAP",
domain_suffix_match="server.w1.fi") domain_suffix_match="server.w1.fi")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
eap_reauth(dev[0], "TTLS") eap_reauth(dev[0], "TTLS")
dev[0].request("REMOVE_NETWORK all") dev[0].request("REMOVE_NETWORK all")
eap_connect(dev[0], apdev[0], "TTLS", "mschap user", eap_connect(dev[0], apdev[0], "TTLS", "mschap user",
@ -849,7 +849,7 @@ def test_ap_wpa2_eap_ttls_mschapv2(dev, apdev):
anonymous_identity="ttls", password="password", anonymous_identity="ttls", password="password",
ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2", ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2",
domain_suffix_match="w1.fi") domain_suffix_match="w1.fi")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
sta1 = hapd.get_sta(dev[0].p2p_interface_addr()) sta1 = hapd.get_sta(dev[0].p2p_interface_addr())
eapol1 = hapd.get_sta(dev[0].p2p_interface_addr(), info="eapol") eapol1 = hapd.get_sta(dev[0].p2p_interface_addr(), info="eapol")
eap_reauth(dev[0], "TTLS") eap_reauth(dev[0], "TTLS")
@ -898,31 +898,31 @@ def test_ap_wpa2_eap_ttls_mschapv2_utf8(dev, apdev):
def test_ap_wpa2_eap_ttls_eap_gtc(dev, apdev): def test_ap_wpa2_eap_ttls_eap_gtc(dev, apdev):
"""WPA2-Enterprise connection using EAP-TTLS/EAP-GTC""" """WPA2-Enterprise connection using EAP-TTLS/EAP-GTC"""
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
eap_connect(dev[0], apdev[0], "TTLS", "user", eap_connect(dev[0], apdev[0], "TTLS", "user",
anonymous_identity="ttls", password="password", anonymous_identity="ttls", password="password",
ca_cert="auth_serv/ca.pem", phase2="autheap=GTC") ca_cert="auth_serv/ca.pem", phase2="autheap=GTC")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
eap_reauth(dev[0], "TTLS") eap_reauth(dev[0], "TTLS")
def test_ap_wpa2_eap_ttls_eap_md5(dev, apdev): def test_ap_wpa2_eap_ttls_eap_md5(dev, apdev):
"""WPA2-Enterprise connection using EAP-TTLS/EAP-MD5""" """WPA2-Enterprise connection using EAP-TTLS/EAP-MD5"""
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
eap_connect(dev[0], apdev[0], "TTLS", "user", eap_connect(dev[0], apdev[0], "TTLS", "user",
anonymous_identity="ttls", password="password", anonymous_identity="ttls", password="password",
ca_cert="auth_serv/ca.pem", phase2="autheap=MD5") ca_cert="auth_serv/ca.pem", phase2="autheap=MD5")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
eap_reauth(dev[0], "TTLS") eap_reauth(dev[0], "TTLS")
def test_ap_wpa2_eap_ttls_eap_mschapv2(dev, apdev): def test_ap_wpa2_eap_ttls_eap_mschapv2(dev, apdev):
"""WPA2-Enterprise connection using EAP-TTLS/EAP-MSCHAPv2""" """WPA2-Enterprise connection using EAP-TTLS/EAP-MSCHAPv2"""
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
eap_connect(dev[0], apdev[0], "TTLS", "user", eap_connect(dev[0], apdev[0], "TTLS", "user",
anonymous_identity="ttls", password="password", anonymous_identity="ttls", password="password",
ca_cert="auth_serv/ca.pem", phase2="autheap=MSCHAPV2") ca_cert="auth_serv/ca.pem", phase2="autheap=MSCHAPV2")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
eap_reauth(dev[0], "TTLS") eap_reauth(dev[0], "TTLS")
logger.info("Negative test with incorrect password") logger.info("Negative test with incorrect password")
@ -964,11 +964,11 @@ def test_ap_wpa2_eap_fast_eap_aka(dev, apdev):
def test_ap_wpa2_eap_peap_eap_mschapv2(dev, apdev): def test_ap_wpa2_eap_peap_eap_mschapv2(dev, apdev):
"""WPA2-Enterprise connection using EAP-PEAP/EAP-MSCHAPv2""" """WPA2-Enterprise connection using EAP-PEAP/EAP-MSCHAPv2"""
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
eap_connect(dev[0], apdev[0], "PEAP", "user", eap_connect(dev[0], apdev[0], "PEAP", "user",
anonymous_identity="peap", password="password", anonymous_identity="peap", password="password",
ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2") ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
eap_reauth(dev[0], "PEAP") eap_reauth(dev[0], "PEAP")
dev[0].request("REMOVE_NETWORK all") dev[0].request("REMOVE_NETWORK all")
eap_connect(dev[0], apdev[0], "PEAP", "user", eap_connect(dev[0], apdev[0], "PEAP", "user",
@ -993,12 +993,12 @@ def test_ap_wpa2_eap_peap_eap_mschapv2(dev, apdev):
def test_ap_wpa2_eap_peap_crypto_binding(dev, apdev): def test_ap_wpa2_eap_peap_crypto_binding(dev, apdev):
"""WPA2-Enterprise connection using EAP-PEAPv0/EAP-MSCHAPv2 and crypto binding""" """WPA2-Enterprise connection using EAP-PEAPv0/EAP-MSCHAPv2 and crypto binding"""
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
eap_connect(dev[0], apdev[0], "PEAP", "user", password="password", eap_connect(dev[0], apdev[0], "PEAP", "user", password="password",
ca_cert="auth_serv/ca.pem", ca_cert="auth_serv/ca.pem",
phase1="peapver=0 crypto_binding=2", phase1="peapver=0 crypto_binding=2",
phase2="auth=MSCHAPV2") phase2="auth=MSCHAPV2")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
eap_reauth(dev[0], "PEAP") eap_reauth(dev[0], "PEAP")
eap_connect(dev[1], apdev[0], "PEAP", "user", password="password", eap_connect(dev[1], apdev[0], "PEAP", "user", password="password",
@ -1692,13 +1692,13 @@ def test_ap_wpa2_eap_psk(dev, apdev):
def test_ap_wpa_eap_peap_eap_mschapv2(dev, apdev): def test_ap_wpa_eap_peap_eap_mschapv2(dev, apdev):
"""WPA-Enterprise connection using EAP-PEAP/EAP-MSCHAPv2""" """WPA-Enterprise connection using EAP-PEAP/EAP-MSCHAPv2"""
params = hostapd.wpa_eap_params(ssid="test-wpa-eap") params = hostapd.wpa_eap_params(ssid="test-wpa-eap")
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect("test-wpa-eap", key_mgmt="WPA-EAP", eap="PEAP", dev[0].connect("test-wpa-eap", key_mgmt="WPA-EAP", eap="PEAP",
identity="user", password="password", phase2="auth=MSCHAPV2", identity="user", password="password", phase2="auth=MSCHAPV2",
ca_cert="auth_serv/ca.pem", wait_connect=False, ca_cert="auth_serv/ca.pem", wait_connect=False,
scan_freq="2412") scan_freq="2412")
eap_check_auth(dev[0], "PEAP", True, rsn=False) eap_check_auth(dev[0], "PEAP", True, rsn=False)
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
eap_reauth(dev[0], "PEAP", rsn=False) eap_reauth(dev[0], "PEAP", rsn=False)
check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-50-f2-1"), check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-50-f2-1"),
("dot11RSNAAuthenticationSuiteSelected", "00-50-f2-1") ]) ("dot11RSNAAuthenticationSuiteSelected", "00-50-f2-1") ])
@ -1756,12 +1756,12 @@ def test_ap_wpa2_eap_vendor_test(dev, apdev):
def test_ap_wpa2_eap_fast_mschapv2_unauth_prov(dev, apdev): def test_ap_wpa2_eap_fast_mschapv2_unauth_prov(dev, apdev):
"""WPA2-Enterprise connection using EAP-FAST/MSCHAPv2 and unauthenticated provisioning""" """WPA2-Enterprise connection using EAP-FAST/MSCHAPv2 and unauthenticated provisioning"""
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
eap_connect(dev[0], apdev[0], "FAST", "user", eap_connect(dev[0], apdev[0], "FAST", "user",
anonymous_identity="FAST", password="password", anonymous_identity="FAST", password="password",
ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2", ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2",
phase1="fast_provisioning=1", pac_file="blob://fast_pac") phase1="fast_provisioning=1", pac_file="blob://fast_pac")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
eap_reauth(dev[0], "FAST") eap_reauth(dev[0], "FAST")
def test_ap_wpa2_eap_fast_pac_file(dev, apdev, params): def test_ap_wpa2_eap_fast_pac_file(dev, apdev, params):
@ -1842,12 +1842,12 @@ def test_ap_wpa2_eap_fast_missing_pac_config(dev, apdev):
def test_ap_wpa2_eap_fast_gtc_auth_prov(dev, apdev): def test_ap_wpa2_eap_fast_gtc_auth_prov(dev, apdev):
"""WPA2-Enterprise connection using EAP-FAST/GTC and authenticated provisioning""" """WPA2-Enterprise connection using EAP-FAST/GTC and authenticated provisioning"""
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
eap_connect(dev[0], apdev[0], "FAST", "user", eap_connect(dev[0], apdev[0], "FAST", "user",
anonymous_identity="FAST", password="password", anonymous_identity="FAST", password="password",
ca_cert="auth_serv/ca.pem", phase2="auth=GTC", ca_cert="auth_serv/ca.pem", phase2="auth=GTC",
phase1="fast_provisioning=2", pac_file="blob://fast_pac_auth") phase1="fast_provisioning=2", pac_file="blob://fast_pac_auth")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
eap_reauth(dev[0], "FAST") eap_reauth(dev[0], "FAST")
def test_ap_wpa2_eap_tls_ocsp(dev, apdev): def test_ap_wpa2_eap_tls_ocsp(dev, apdev):

View file

@ -88,7 +88,7 @@ def ft_params2_r0kh_mismatch(rsn=True, ssid=None, passphrase=None):
params['r1kh'] = "12:00:00:00:03:00 10:01:02:03:04:05 300102030405060708090a0b0c0d0e0f" params['r1kh'] = "12:00:00:00:03:00 10:01:02:03:04:05 300102030405060708090a0b0c0d0e0f"
return params return params
def run_roams(dev, apdev, ssid, passphrase, over_ds=False, sae=False, eap=False, fail_test=False, roams=1): def run_roams(dev, apdev, hapd0, hapd1, ssid, passphrase, over_ds=False, sae=False, eap=False, fail_test=False, roams=1):
logger.info("Connect to first AP") logger.info("Connect to first AP")
if eap: if eap:
dev.connect(ssid, key_mgmt="FT-EAP", proto="WPA2", ieee80211w="1", dev.connect(ssid, key_mgmt="FT-EAP", proto="WPA2", ieee80211w="1",
@ -103,10 +103,14 @@ def run_roams(dev, apdev, ssid, passphrase, over_ds=False, sae=False, eap=False,
if dev.get_status_field('bssid') == apdev[0]['bssid']: if dev.get_status_field('bssid') == apdev[0]['bssid']:
ap1 = apdev[0] ap1 = apdev[0]
ap2 = apdev[1] ap2 = apdev[1]
hapd1ap = hapd0
hapd2ap = hapd1
else: else:
ap1 = apdev[1] ap1 = apdev[1]
ap2 = apdev[0] ap2 = apdev[0]
hwsim_utils.test_connectivity(dev.ifname, ap1['ifname']) hapd1ap = hapd1
hapd2ap = hapd0
hwsim_utils.test_connectivity(dev, hapd1ap)
dev.scan_for_bss(ap2['bssid'], freq="2412") dev.scan_for_bss(ap2['bssid'], freq="2412")
@ -121,7 +125,7 @@ def run_roams(dev, apdev, ssid, passphrase, over_ds=False, sae=False, eap=False,
if dev.get_status_field('bssid') != ap2['bssid']: if dev.get_status_field('bssid') != ap2['bssid']:
raise Exception("Did not connect to correct AP") raise Exception("Did not connect to correct AP")
if i == 0 or i == roams - 1: if i == 0 or i == roams - 1:
hwsim_utils.test_connectivity(dev.ifname, ap2['ifname']) hwsim_utils.test_connectivity(dev, hapd2ap)
logger.info("Roam back to the first AP") logger.info("Roam back to the first AP")
if over_ds: if over_ds:
@ -131,7 +135,7 @@ def run_roams(dev, apdev, ssid, passphrase, over_ds=False, sae=False, eap=False,
if dev.get_status_field('bssid') != ap1['bssid']: if dev.get_status_field('bssid') != ap1['bssid']:
raise Exception("Did not connect to correct AP") raise Exception("Did not connect to correct AP")
if i == 0 or i == roams - 1: if i == 0 or i == roams - 1:
hwsim_utils.test_connectivity(dev.ifname, ap1['ifname']) hwsim_utils.test_connectivity(dev, hapd1ap)
def test_ap_ft(dev, apdev): def test_ap_ft(dev, apdev):
"""WPA2-PSK-FT AP""" """WPA2-PSK-FT AP"""
@ -139,11 +143,11 @@ def test_ap_ft(dev, apdev):
passphrase="12345678" passphrase="12345678"
params = ft_params1(ssid=ssid, passphrase=passphrase) params = ft_params1(ssid=ssid, passphrase=passphrase)
hostapd.add_ap(apdev[0]['ifname'], params) hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
params = ft_params2(ssid=ssid, passphrase=passphrase) params = ft_params2(ssid=ssid, passphrase=passphrase)
hostapd.add_ap(apdev[1]['ifname'], params) hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
run_roams(dev[0], apdev, ssid, passphrase) run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase)
if "[WPA2-FT/PSK-CCMP]" not in dev[0].request("SCAN_RESULTS"): if "[WPA2-FT/PSK-CCMP]" not in dev[0].request("SCAN_RESULTS"):
raise Exception("Scan results missing RSN element info") raise Exception("Scan results missing RSN element info")
@ -153,11 +157,11 @@ def test_ap_ft_many(dev, apdev):
passphrase="12345678" passphrase="12345678"
params = ft_params1(ssid=ssid, passphrase=passphrase) params = ft_params1(ssid=ssid, passphrase=passphrase)
hostapd.add_ap(apdev[0]['ifname'], params) hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
params = ft_params2(ssid=ssid, passphrase=passphrase) params = ft_params2(ssid=ssid, passphrase=passphrase)
hostapd.add_ap(apdev[1]['ifname'], params) hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
run_roams(dev[0], apdev, ssid, passphrase, roams=50) run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, roams=50)
def test_ap_ft_mixed(dev, apdev): def test_ap_ft_mixed(dev, apdev):
"""WPA2-PSK-FT mixed-mode AP""" """WPA2-PSK-FT mixed-mode AP"""
@ -171,9 +175,9 @@ def test_ap_ft_mixed(dev, apdev):
if vals[0] != "WPA-PSK" or vals[1] != "FT-PSK": if vals[0] != "WPA-PSK" or vals[1] != "FT-PSK":
raise Exception("Unexpected GET_CONFIG(key_mgmt): " + key_mgmt) raise Exception("Unexpected GET_CONFIG(key_mgmt): " + key_mgmt)
params = ft_params2(rsn=False, ssid=ssid, passphrase=passphrase) params = ft_params2(rsn=False, ssid=ssid, passphrase=passphrase)
hostapd.add_ap(apdev[1]['ifname'], params) hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
run_roams(dev[0], apdev, ssid, passphrase) run_roams(dev[0], apdev, hapd, hapd1, ssid, passphrase)
def test_ap_ft_pmf(dev, apdev): def test_ap_ft_pmf(dev, apdev):
"""WPA2-PSK-FT AP with PMF""" """WPA2-PSK-FT AP with PMF"""
@ -182,12 +186,12 @@ def test_ap_ft_pmf(dev, apdev):
params = ft_params1(ssid=ssid, passphrase=passphrase) params = ft_params1(ssid=ssid, passphrase=passphrase)
params["ieee80211w"] = "2"; params["ieee80211w"] = "2";
hostapd.add_ap(apdev[0]['ifname'], params) hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
params = ft_params2(ssid=ssid, passphrase=passphrase) params = ft_params2(ssid=ssid, passphrase=passphrase)
params["ieee80211w"] = "2"; params["ieee80211w"] = "2";
hostapd.add_ap(apdev[1]['ifname'], params) hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
run_roams(dev[0], apdev, ssid, passphrase) run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase)
def test_ap_ft_over_ds(dev, apdev): def test_ap_ft_over_ds(dev, apdev):
"""WPA2-PSK-FT AP over DS""" """WPA2-PSK-FT AP over DS"""
@ -195,11 +199,11 @@ def test_ap_ft_over_ds(dev, apdev):
passphrase="12345678" passphrase="12345678"
params = ft_params1(ssid=ssid, passphrase=passphrase) params = ft_params1(ssid=ssid, passphrase=passphrase)
hostapd.add_ap(apdev[0]['ifname'], params) hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
params = ft_params2(ssid=ssid, passphrase=passphrase) params = ft_params2(ssid=ssid, passphrase=passphrase)
hostapd.add_ap(apdev[1]['ifname'], params) hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
run_roams(dev[0], apdev, ssid, passphrase, over_ds=True) run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True)
check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-4"), check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-4"),
("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-4") ]) ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-4") ])
@ -209,11 +213,12 @@ def test_ap_ft_over_ds_many(dev, apdev):
passphrase="12345678" passphrase="12345678"
params = ft_params1(ssid=ssid, passphrase=passphrase) params = ft_params1(ssid=ssid, passphrase=passphrase)
hostapd.add_ap(apdev[0]['ifname'], params) hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
params = ft_params2(ssid=ssid, passphrase=passphrase) params = ft_params2(ssid=ssid, passphrase=passphrase)
hostapd.add_ap(apdev[1]['ifname'], params) hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
run_roams(dev[0], apdev, ssid, passphrase, over_ds=True, roams=50) run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True,
roams=50)
def test_ap_ft_pmf_over_ds(dev, apdev): def test_ap_ft_pmf_over_ds(dev, apdev):
"""WPA2-PSK-FT AP over DS with PMF""" """WPA2-PSK-FT AP over DS with PMF"""
@ -222,12 +227,12 @@ def test_ap_ft_pmf_over_ds(dev, apdev):
params = ft_params1(ssid=ssid, passphrase=passphrase) params = ft_params1(ssid=ssid, passphrase=passphrase)
params["ieee80211w"] = "2"; params["ieee80211w"] = "2";
hostapd.add_ap(apdev[0]['ifname'], params) hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
params = ft_params2(ssid=ssid, passphrase=passphrase) params = ft_params2(ssid=ssid, passphrase=passphrase)
params["ieee80211w"] = "2"; params["ieee80211w"] = "2";
hostapd.add_ap(apdev[1]['ifname'], params) hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
run_roams(dev[0], apdev, ssid, passphrase, over_ds=True) run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True)
def test_ap_ft_over_ds_pull(dev, apdev): def test_ap_ft_over_ds_pull(dev, apdev):
"""WPA2-PSK-FT AP over DS (pull PMK)""" """WPA2-PSK-FT AP over DS (pull PMK)"""
@ -236,12 +241,12 @@ def test_ap_ft_over_ds_pull(dev, apdev):
params = ft_params1(ssid=ssid, passphrase=passphrase) params = ft_params1(ssid=ssid, passphrase=passphrase)
params["pmk_r1_push"] = "0" params["pmk_r1_push"] = "0"
hostapd.add_ap(apdev[0]['ifname'], params) hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
params = ft_params2(ssid=ssid, passphrase=passphrase) params = ft_params2(ssid=ssid, passphrase=passphrase)
params["pmk_r1_push"] = "0" params["pmk_r1_push"] = "0"
hostapd.add_ap(apdev[1]['ifname'], params) hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
run_roams(dev[0], apdev, ssid, passphrase, over_ds=True) run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True)
def test_ap_ft_sae(dev, apdev): def test_ap_ft_sae(dev, apdev):
"""WPA2-PSK-FT-SAE AP""" """WPA2-PSK-FT-SAE AP"""
@ -250,7 +255,7 @@ def test_ap_ft_sae(dev, apdev):
params = ft_params1(ssid=ssid, passphrase=passphrase) params = ft_params1(ssid=ssid, passphrase=passphrase)
params['wpa_key_mgmt'] = "FT-SAE" params['wpa_key_mgmt'] = "FT-SAE"
hostapd.add_ap(apdev[0]['ifname'], params) hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
params = ft_params2(ssid=ssid, passphrase=passphrase) params = ft_params2(ssid=ssid, passphrase=passphrase)
params['wpa_key_mgmt'] = "FT-SAE" params['wpa_key_mgmt'] = "FT-SAE"
hapd = hostapd.add_ap(apdev[1]['ifname'], params) hapd = hostapd.add_ap(apdev[1]['ifname'], params)
@ -258,7 +263,7 @@ def test_ap_ft_sae(dev, apdev):
if key_mgmt.split(' ')[0] != "FT-SAE": if key_mgmt.split(' ')[0] != "FT-SAE":
raise Exception("Unexpected GET_CONFIG(key_mgmt): " + key_mgmt) raise Exception("Unexpected GET_CONFIG(key_mgmt): " + key_mgmt)
run_roams(dev[0], apdev, ssid, passphrase, sae=True) run_roams(dev[0], apdev, hapd0, hapd, ssid, passphrase, sae=True)
def test_ap_ft_sae_over_ds(dev, apdev): def test_ap_ft_sae_over_ds(dev, apdev):
"""WPA2-PSK-FT-SAE AP over DS""" """WPA2-PSK-FT-SAE AP over DS"""
@ -267,12 +272,13 @@ def test_ap_ft_sae_over_ds(dev, apdev):
params = ft_params1(ssid=ssid, passphrase=passphrase) params = ft_params1(ssid=ssid, passphrase=passphrase)
params['wpa_key_mgmt'] = "FT-SAE" params['wpa_key_mgmt'] = "FT-SAE"
hostapd.add_ap(apdev[0]['ifname'], params) hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
params = ft_params2(ssid=ssid, passphrase=passphrase) params = ft_params2(ssid=ssid, passphrase=passphrase)
params['wpa_key_mgmt'] = "FT-SAE" params['wpa_key_mgmt'] = "FT-SAE"
hostapd.add_ap(apdev[1]['ifname'], params) hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
run_roams(dev[0], apdev, ssid, passphrase, sae=True, over_ds=True) run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, sae=True,
over_ds=True)
def test_ap_ft_eap(dev, apdev): def test_ap_ft_eap(dev, apdev):
"""WPA2-EAP-FT AP""" """WPA2-EAP-FT AP"""
@ -292,9 +298,9 @@ def test_ap_ft_eap(dev, apdev):
params['wpa_key_mgmt'] = "FT-EAP" params['wpa_key_mgmt'] = "FT-EAP"
params["ieee8021x"] = "1" params["ieee8021x"] = "1"
params = dict(radius.items() + params.items()) params = dict(radius.items() + params.items())
hostapd.add_ap(apdev[1]['ifname'], params) hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
run_roams(dev[0], apdev, ssid, passphrase, eap=True) run_roams(dev[0], apdev, hapd, hapd1, ssid, passphrase, eap=True)
if "[WPA2-FT/EAP-CCMP]" not in dev[0].request("SCAN_RESULTS"): if "[WPA2-FT/EAP-CCMP]" not in dev[0].request("SCAN_RESULTS"):
raise Exception("Scan results missing RSN element info") raise Exception("Scan results missing RSN element info")
check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-3"), check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-3"),
@ -320,9 +326,9 @@ def test_ap_ft_eap_pull(dev, apdev):
params["ieee8021x"] = "1" params["ieee8021x"] = "1"
params["pmk_r1_push"] = "0" params["pmk_r1_push"] = "0"
params = dict(radius.items() + params.items()) params = dict(radius.items() + params.items())
hostapd.add_ap(apdev[1]['ifname'], params) hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
run_roams(dev[0], apdev, ssid, passphrase, eap=True) run_roams(dev[0], apdev, hapd, hapd1, ssid, passphrase, eap=True)
def test_ap_ft_mismatching_rrb_key_push(dev, apdev): def test_ap_ft_mismatching_rrb_key_push(dev, apdev):
"""WPA2-PSK-FT AP over DS with mismatching RRB key (push)""" """WPA2-PSK-FT AP over DS with mismatching RRB key (push)"""
@ -331,12 +337,13 @@ def test_ap_ft_mismatching_rrb_key_push(dev, apdev):
params = ft_params1(ssid=ssid, passphrase=passphrase) params = ft_params1(ssid=ssid, passphrase=passphrase)
params["ieee80211w"] = "2"; params["ieee80211w"] = "2";
hostapd.add_ap(apdev[0]['ifname'], params) hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
params = ft_params2_incorrect_rrb_key(ssid=ssid, passphrase=passphrase) params = ft_params2_incorrect_rrb_key(ssid=ssid, passphrase=passphrase)
params["ieee80211w"] = "2"; params["ieee80211w"] = "2";
hostapd.add_ap(apdev[1]['ifname'], params) hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
run_roams(dev[0], apdev, ssid, passphrase, over_ds=True, fail_test=True) run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True,
fail_test=True)
def test_ap_ft_mismatching_rrb_key_pull(dev, apdev): def test_ap_ft_mismatching_rrb_key_pull(dev, apdev):
"""WPA2-PSK-FT AP over DS with mismatching RRB key (pull)""" """WPA2-PSK-FT AP over DS with mismatching RRB key (pull)"""
@ -345,12 +352,13 @@ def test_ap_ft_mismatching_rrb_key_pull(dev, apdev):
params = ft_params1(ssid=ssid, passphrase=passphrase) params = ft_params1(ssid=ssid, passphrase=passphrase)
params["pmk_r1_push"] = "0" params["pmk_r1_push"] = "0"
hostapd.add_ap(apdev[0]['ifname'], params) hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
params = ft_params2_incorrect_rrb_key(ssid=ssid, passphrase=passphrase) params = ft_params2_incorrect_rrb_key(ssid=ssid, passphrase=passphrase)
params["pmk_r1_push"] = "0" params["pmk_r1_push"] = "0"
hostapd.add_ap(apdev[1]['ifname'], params) hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
run_roams(dev[0], apdev, ssid, passphrase, over_ds=True, fail_test=True) run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True,
fail_test=True)
def test_ap_ft_mismatching_r0kh_id_pull(dev, apdev): def test_ap_ft_mismatching_r0kh_id_pull(dev, apdev):
"""WPA2-PSK-FT AP over DS with mismatching R0KH-ID (pull)""" """WPA2-PSK-FT AP over DS with mismatching R0KH-ID (pull)"""
@ -377,12 +385,13 @@ def test_ap_ft_mismatching_rrb_r0kh_push(dev, apdev):
params = ft_params1(ssid=ssid, passphrase=passphrase) params = ft_params1(ssid=ssid, passphrase=passphrase)
params["ieee80211w"] = "2"; params["ieee80211w"] = "2";
hostapd.add_ap(apdev[0]['ifname'], params) hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
params = ft_params2_r0kh_mismatch(ssid=ssid, passphrase=passphrase) params = ft_params2_r0kh_mismatch(ssid=ssid, passphrase=passphrase)
params["ieee80211w"] = "2"; params["ieee80211w"] = "2";
hostapd.add_ap(apdev[1]['ifname'], params) hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
run_roams(dev[0], apdev, ssid, passphrase, over_ds=True, fail_test=True) run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True,
fail_test=True)
def test_ap_ft_mismatching_rrb_r0kh_pull(dev, apdev): def test_ap_ft_mismatching_rrb_r0kh_pull(dev, apdev):
"""WPA2-PSK-FT AP over DS with mismatching R0KH key (pull)""" """WPA2-PSK-FT AP over DS with mismatching R0KH key (pull)"""
@ -391,12 +400,13 @@ def test_ap_ft_mismatching_rrb_r0kh_pull(dev, apdev):
params = ft_params1_r0kh_mismatch(ssid=ssid, passphrase=passphrase) params = ft_params1_r0kh_mismatch(ssid=ssid, passphrase=passphrase)
params["pmk_r1_push"] = "0" params["pmk_r1_push"] = "0"
hostapd.add_ap(apdev[0]['ifname'], params) hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
params = ft_params2(ssid=ssid, passphrase=passphrase) params = ft_params2(ssid=ssid, passphrase=passphrase)
params["pmk_r1_push"] = "0" params["pmk_r1_push"] = "0"
hostapd.add_ap(apdev[1]['ifname'], params) hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
run_roams(dev[0], apdev, ssid, passphrase, over_ds=True, fail_test=True) run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True,
fail_test=True)
def test_ap_ft_gtk_rekey(dev, apdev): def test_ap_ft_gtk_rekey(dev, apdev):
"""WPA2-PSK-FT AP and GTK rekey""" """WPA2-PSK-FT AP and GTK rekey"""
@ -405,7 +415,7 @@ def test_ap_ft_gtk_rekey(dev, apdev):
params = ft_params1(ssid=ssid, passphrase=passphrase) params = ft_params1(ssid=ssid, passphrase=passphrase)
params['wpa_group_rekey'] = '1' params['wpa_group_rekey'] = '1'
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk=passphrase, key_mgmt="FT-PSK", proto="WPA2", dev[0].connect(ssid, psk=passphrase, key_mgmt="FT-PSK", proto="WPA2",
ieee80211w="1") ieee80211w="1")
@ -413,19 +423,19 @@ def test_ap_ft_gtk_rekey(dev, apdev):
ev = dev[0].wait_event(["WPA: Group rekeying completed"], timeout=2) ev = dev[0].wait_event(["WPA: Group rekeying completed"], timeout=2)
if ev is None: if ev is None:
raise Exception("GTK rekey timed out after initial association") raise Exception("GTK rekey timed out after initial association")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
params = ft_params2(ssid=ssid, passphrase=passphrase) params = ft_params2(ssid=ssid, passphrase=passphrase)
params['wpa_group_rekey'] = '1' params['wpa_group_rekey'] = '1'
hostapd.add_ap(apdev[1]['ifname'], params) hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
dev[0].scan_for_bss(apdev[1]['bssid'], freq="2412") dev[0].scan_for_bss(apdev[1]['bssid'], freq="2412")
dev[0].roam(apdev[1]['bssid']) dev[0].roam(apdev[1]['bssid'])
if dev[0].get_status_field('bssid') != apdev[1]['bssid']: if dev[0].get_status_field('bssid') != apdev[1]['bssid']:
raise Exception("Did not connect to correct AP") raise Exception("Did not connect to correct AP")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[1]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd1)
ev = dev[0].wait_event(["WPA: Group rekeying completed"], timeout=2) ev = dev[0].wait_event(["WPA: Group rekeying completed"], timeout=2)
if ev is None: if ev is None:
raise Exception("GTK rekey timed out after FT protocol") raise Exception("GTK rekey timed out after FT protocol")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[1]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd1)

View file

@ -17,7 +17,7 @@ def test_ap_open(dev, apdev):
"""AP with open mode (no security) configuration""" """AP with open mode (no security) configuration"""
hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" }) hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5) ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5)
if ev is None: if ev is None:
raise Exception("No connection event received from hostapd") raise Exception("No connection event received from hostapd")

View file

@ -18,9 +18,9 @@ def test_ap_fragmentation_rts_set_high(dev, apdev):
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
params['rts_threshold'] = "1000" params['rts_threshold'] = "1000"
params['fragm_threshold'] = "2000" params['fragm_threshold'] = "2000"
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk=passphrase, scan_freq="2412") dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_ap_fragmentation_open(dev, apdev): def test_ap_fragmentation_open(dev, apdev):
"""Open AP with fragmentation threshold""" """Open AP with fragmentation threshold"""
@ -28,9 +28,9 @@ def test_ap_fragmentation_open(dev, apdev):
params = {} params = {}
params['ssid'] = ssid params['ssid'] = ssid
params['fragm_threshold'] = "1000" params['fragm_threshold'] = "1000"
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412") dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_ap_fragmentation_wpa2(dev, apdev): def test_ap_fragmentation_wpa2(dev, apdev):
"""WPA2-PSK AP with fragmentation threshold""" """WPA2-PSK AP with fragmentation threshold"""
@ -38,9 +38,9 @@ def test_ap_fragmentation_wpa2(dev, apdev):
passphrase = 'qwertyuiop' passphrase = 'qwertyuiop'
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
params['fragm_threshold'] = "1000" params['fragm_threshold'] = "1000"
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk=passphrase, scan_freq="2412") dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_ap_vendor_elements(dev, apdev): def test_ap_vendor_elements(dev, apdev):
"""WPA2-PSK AP with vendor elements added""" """WPA2-PSK AP with vendor elements added"""
@ -66,9 +66,9 @@ def test_ap_country(dev, apdev):
params['ieee80211d'] = '1' params['ieee80211d'] = '1'
params['hw_mode'] = 'a' params['hw_mode'] = 'a'
params['channel'] = '36' params['channel'] = '36'
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk=passphrase, scan_freq="5180") dev[0].connect(ssid, psk=passphrase, scan_freq="5180")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
finally: finally:
subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
@ -123,7 +123,7 @@ def test_ap_wds_sta(dev, apdev):
subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'wds-br0', 'up']) subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'wds-br0', 'up'])
subprocess.call(['sudo', 'iw', dev[0].ifname, 'set', '4addr', 'on']) subprocess.call(['sudo', 'iw', dev[0].ifname, 'set', '4addr', 'on'])
dev[0].connect(ssid, psk=passphrase, scan_freq="2412") dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, "wds-br0", max_tries=15) hwsim_utils.test_connectivity_iface(dev[0], "wds-br0", max_tries=15)
finally: finally:
subprocess.call(['sudo', 'iw', dev[0].ifname, 'set', '4addr', 'off']) subprocess.call(['sudo', 'iw', dev[0].ifname, 'set', '4addr', 'off'])
subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'wds-br0', 'down']) subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'wds-br0', 'down'])
@ -241,6 +241,6 @@ def test_ap_tx_queue_params(dev, apdev):
params['tx_queue_data1_cwmin'] = "7" params['tx_queue_data1_cwmin'] = "7"
params['tx_queue_data1_cwmax'] = "1023" params['tx_queue_data1_cwmax'] = "1023"
params['tx_queue_data1_burst'] = "2" params['tx_queue_data1_burst'] = "2"
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412") dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)

View file

@ -33,11 +33,11 @@ def test_ap_pmf_required(dev, apdev):
scan_freq="2412") scan_freq="2412")
if "[WPA2-PSK-SHA256-CCMP]" not in dev[0].request("SCAN_RESULTS"): if "[WPA2-PSK-SHA256-CCMP]" not in dev[0].request("SCAN_RESULTS"):
raise Exception("Scan results missing RSN element info") raise Exception("Scan results missing RSN element info")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
dev[1].connect(ssid, psk="12345678", ieee80211w="2", dev[1].connect(ssid, psk="12345678", ieee80211w="2",
key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2", key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2",
scan_freq="2412") scan_freq="2412")
hwsim_utils.test_connectivity(dev[1].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[1], hapd)
hapd = hostapd.Hostapd(apdev[0]['ifname']) hapd = hostapd.Hostapd(apdev[0]['ifname'])
hapd.request("SA_QUERY " + dev[0].p2p_interface_addr()) hapd.request("SA_QUERY " + dev[0].p2p_interface_addr())
hapd.request("SA_QUERY " + dev[1].p2p_interface_addr()) hapd.request("SA_QUERY " + dev[1].p2p_interface_addr())
@ -61,15 +61,15 @@ def test_ap_pmf_optional(dev, apdev):
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678") params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
params["wpa_key_mgmt"] = "WPA-PSK"; params["wpa_key_mgmt"] = "WPA-PSK";
params["ieee80211w"] = "1"; params["ieee80211w"] = "1";
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk="12345678", ieee80211w="1", dev[0].connect(ssid, psk="12345678", ieee80211w="1",
key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2", key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2",
scan_freq="2412") scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
dev[1].connect(ssid, psk="12345678", ieee80211w="2", dev[1].connect(ssid, psk="12345678", ieee80211w="2",
key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2", key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2",
scan_freq="2412") scan_freq="2412")
hwsim_utils.test_connectivity(dev[1].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[1], hapd)
wt.require_ap_pmf_optional(apdev[0]['bssid']) wt.require_ap_pmf_optional(apdev[0]['bssid'])
wt.require_sta_pmf(apdev[0]['bssid'], dev[0].p2p_interface_addr()) wt.require_sta_pmf(apdev[0]['bssid'], dev[0].p2p_interface_addr())
wt.require_sta_pmf_mandatory(apdev[0]['bssid'], dev[1].p2p_interface_addr()) wt.require_sta_pmf_mandatory(apdev[0]['bssid'], dev[1].p2p_interface_addr())
@ -83,15 +83,15 @@ def test_ap_pmf_optional_2akm(dev, apdev):
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678") params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
params["wpa_key_mgmt"] = "WPA-PSK WPA-PSK-SHA256"; params["wpa_key_mgmt"] = "WPA-PSK WPA-PSK-SHA256";
params["ieee80211w"] = "1"; params["ieee80211w"] = "1";
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk="12345678", ieee80211w="1", dev[0].connect(ssid, psk="12345678", ieee80211w="1",
key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2", key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2",
scan_freq="2412") scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
dev[1].connect(ssid, psk="12345678", ieee80211w="2", dev[1].connect(ssid, psk="12345678", ieee80211w="2",
key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2", key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2",
scan_freq="2412") scan_freq="2412")
hwsim_utils.test_connectivity(dev[1].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[1], hapd)
wt.require_ap_pmf_optional(apdev[0]['bssid']) wt.require_ap_pmf_optional(apdev[0]['bssid'])
wt.require_sta_pmf(apdev[0]['bssid'], dev[0].p2p_interface_addr()) wt.require_sta_pmf(apdev[0]['bssid'], dev[0].p2p_interface_addr())
wt.require_sta_key_mgmt(apdev[0]['bssid'], dev[0].p2p_interface_addr(), wt.require_sta_key_mgmt(apdev[0]['bssid'], dev[0].p2p_interface_addr(),
@ -107,16 +107,16 @@ def test_ap_pmf_negative(dev, apdev):
wt.flush() wt.flush()
wt.add_passphrase("12345678") wt.add_passphrase("12345678")
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678") params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk="12345678", ieee80211w="1", dev[0].connect(ssid, psk="12345678", ieee80211w="1",
key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2", key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2",
scan_freq="2412") scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
try: try:
dev[1].connect(ssid, psk="12345678", ieee80211w="2", dev[1].connect(ssid, psk="12345678", ieee80211w="2",
key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2", key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2",
scan_freq="2412") scan_freq="2412")
hwsim_utils.test_connectivity(dev[1].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[1], hapd)
raise Exception("PMF required STA connected to no PMF AP") raise Exception("PMF required STA connected to no PMF AP")
except Exception, e: except Exception, e:
logger.debug("Ignore expected exception: " + str(e)) logger.debug("Ignore expected exception: " + str(e))

View file

@ -65,12 +65,12 @@ def test_ap_wpa2_ptk_rekey(dev, apdev):
ssid = "test-wpa2-psk" ssid = "test-wpa2-psk"
passphrase = 'qwertyuiop' passphrase = 'qwertyuiop'
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk=passphrase, wpa_ptk_rekey="1", scan_freq="2412") dev[0].connect(ssid, psk=passphrase, wpa_ptk_rekey="1", scan_freq="2412")
ev = dev[0].wait_event(["WPA: Key negotiation completed"]) ev = dev[0].wait_event(["WPA: Key negotiation completed"])
if ev is None: if ev is None:
raise Exception("PTK rekey timed out") raise Exception("PTK rekey timed out")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_ap_wpa2_ptk_rekey_ap(dev, apdev): def test_ap_wpa2_ptk_rekey_ap(dev, apdev):
"""WPA2-PSK AP and PTK rekey enforced by AP""" """WPA2-PSK AP and PTK rekey enforced by AP"""
@ -78,12 +78,12 @@ def test_ap_wpa2_ptk_rekey_ap(dev, apdev):
passphrase = 'qwertyuiop' passphrase = 'qwertyuiop'
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
params['wpa_ptk_rekey'] = '2' params['wpa_ptk_rekey'] = '2'
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk=passphrase, scan_freq="2412") dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
ev = dev[0].wait_event(["WPA: Key negotiation completed"]) ev = dev[0].wait_event(["WPA: Key negotiation completed"])
if ev is None: if ev is None:
raise Exception("PTK rekey timed out") raise Exception("PTK rekey timed out")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_ap_wpa2_sha256_ptk_rekey(dev, apdev): def test_ap_wpa2_sha256_ptk_rekey(dev, apdev):
"""WPA2-PSK/SHA256 AKM AP and PTK rekey enforced by station""" """WPA2-PSK/SHA256 AKM AP and PTK rekey enforced by station"""
@ -91,13 +91,13 @@ def test_ap_wpa2_sha256_ptk_rekey(dev, apdev):
passphrase = 'qwertyuiop' passphrase = 'qwertyuiop'
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
params["wpa_key_mgmt"] = "WPA-PSK-SHA256" params["wpa_key_mgmt"] = "WPA-PSK-SHA256"
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk=passphrase, key_mgmt="WPA-PSK-SHA256", dev[0].connect(ssid, psk=passphrase, key_mgmt="WPA-PSK-SHA256",
wpa_ptk_rekey="1", scan_freq="2412") wpa_ptk_rekey="1", scan_freq="2412")
ev = dev[0].wait_event(["WPA: Key negotiation completed"]) ev = dev[0].wait_event(["WPA: Key negotiation completed"])
if ev is None: if ev is None:
raise Exception("PTK rekey timed out") raise Exception("PTK rekey timed out")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-6"), check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-6"),
("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-6") ]) ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-6") ])
@ -108,13 +108,13 @@ def test_ap_wpa2_sha256_ptk_rekey_ap(dev, apdev):
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
params["wpa_key_mgmt"] = "WPA-PSK-SHA256" params["wpa_key_mgmt"] = "WPA-PSK-SHA256"
params['wpa_ptk_rekey'] = '2' params['wpa_ptk_rekey'] = '2'
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk=passphrase, key_mgmt="WPA-PSK-SHA256", dev[0].connect(ssid, psk=passphrase, key_mgmt="WPA-PSK-SHA256",
scan_freq="2412") scan_freq="2412")
ev = dev[0].wait_event(["WPA: Key negotiation completed"]) ev = dev[0].wait_event(["WPA: Key negotiation completed"])
if ev is None: if ev is None:
raise Exception("PTK rekey timed out") raise Exception("PTK rekey timed out")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-6"), check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-6"),
("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-6") ]) ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-6") ])
@ -123,14 +123,14 @@ def test_ap_wpa_ptk_rekey(dev, apdev):
ssid = "test-wpa-psk" ssid = "test-wpa-psk"
passphrase = 'qwertyuiop' passphrase = 'qwertyuiop'
params = hostapd.wpa_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa_params(ssid=ssid, passphrase=passphrase)
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk=passphrase, wpa_ptk_rekey="1", scan_freq="2412") dev[0].connect(ssid, psk=passphrase, wpa_ptk_rekey="1", scan_freq="2412")
if "[WPA-PSK-TKIP]" not in dev[0].request("SCAN_RESULTS"): if "[WPA-PSK-TKIP]" not in dev[0].request("SCAN_RESULTS"):
raise Exception("Scan results missing WPA element info") raise Exception("Scan results missing WPA element info")
ev = dev[0].wait_event(["WPA: Key negotiation completed"]) ev = dev[0].wait_event(["WPA: Key negotiation completed"])
if ev is None: if ev is None:
raise Exception("PTK rekey timed out") raise Exception("PTK rekey timed out")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_ap_wpa_ptk_rekey_ap(dev, apdev): def test_ap_wpa_ptk_rekey_ap(dev, apdev):
"""WPA-PSK/TKIP AP and PTK rekey enforced by AP""" """WPA-PSK/TKIP AP and PTK rekey enforced by AP"""
@ -138,12 +138,12 @@ def test_ap_wpa_ptk_rekey_ap(dev, apdev):
passphrase = 'qwertyuiop' passphrase = 'qwertyuiop'
params = hostapd.wpa_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa_params(ssid=ssid, passphrase=passphrase)
params['wpa_ptk_rekey'] = '2' params['wpa_ptk_rekey'] = '2'
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk=passphrase, scan_freq="2412") dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
ev = dev[0].wait_event(["WPA: Key negotiation completed"], timeout=10) ev = dev[0].wait_event(["WPA: Key negotiation completed"], timeout=10)
if ev is None: if ev is None:
raise Exception("PTK rekey timed out") raise Exception("PTK rekey timed out")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_ap_wpa_ccmp(dev, apdev): def test_ap_wpa_ccmp(dev, apdev):
"""WPA-PSK/CCMP""" """WPA-PSK/CCMP"""
@ -151,9 +151,9 @@ def test_ap_wpa_ccmp(dev, apdev):
passphrase = 'qwertyuiop' passphrase = 'qwertyuiop'
params = hostapd.wpa_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa_params(ssid=ssid, passphrase=passphrase)
params['wpa_pairwise'] = "CCMP" params['wpa_pairwise'] = "CCMP"
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk=passphrase, scan_freq="2412") dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
check_mib(dev[0], [ ("dot11RSNAConfigGroupCipherSize", "128"), check_mib(dev[0], [ ("dot11RSNAConfigGroupCipherSize", "128"),
("dot11RSNAGroupCipherRequested", "00-50-f2-4"), ("dot11RSNAGroupCipherRequested", "00-50-f2-4"),
("dot11RSNAPairwiseCipherRequested", "00-50-f2-4"), ("dot11RSNAPairwiseCipherRequested", "00-50-f2-4"),
@ -243,12 +243,12 @@ def test_ap_wpa2_gtk_rekey(dev, apdev):
passphrase = 'qwertyuiop' passphrase = 'qwertyuiop'
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
params['wpa_group_rekey'] = '1' params['wpa_group_rekey'] = '1'
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk=passphrase, scan_freq="2412") dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
ev = dev[0].wait_event(["WPA: Group rekeying completed"], timeout=2) ev = dev[0].wait_event(["WPA: Group rekeying completed"], timeout=2)
if ev is None: if ev is None:
raise Exception("GTK rekey timed out") raise Exception("GTK rekey timed out")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_ap_wpa_gtk_rekey(dev, apdev): def test_ap_wpa_gtk_rekey(dev, apdev):
"""WPA-PSK/TKIP AP and GTK rekey enforced by AP""" """WPA-PSK/TKIP AP and GTK rekey enforced by AP"""
@ -256,12 +256,12 @@ def test_ap_wpa_gtk_rekey(dev, apdev):
passphrase = 'qwertyuiop' passphrase = 'qwertyuiop'
params = hostapd.wpa_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa_params(ssid=ssid, passphrase=passphrase)
params['wpa_group_rekey'] = '1' params['wpa_group_rekey'] = '1'
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk=passphrase, scan_freq="2412") dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
ev = dev[0].wait_event(["WPA: Group rekeying completed"], timeout=2) ev = dev[0].wait_event(["WPA: Group rekeying completed"], timeout=2)
if ev is None: if ev is None:
raise Exception("GTK rekey timed out") raise Exception("GTK rekey timed out")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_ap_wpa2_gmk_rekey(dev, apdev): def test_ap_wpa2_gmk_rekey(dev, apdev):
"""WPA2-PSK AP and GMK and GTK rekey enforced by AP""" """WPA2-PSK AP and GMK and GTK rekey enforced by AP"""
@ -270,13 +270,13 @@ def test_ap_wpa2_gmk_rekey(dev, apdev):
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
params['wpa_group_rekey'] = '1' params['wpa_group_rekey'] = '1'
params['wpa_gmk_rekey'] = '2' params['wpa_gmk_rekey'] = '2'
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk=passphrase, scan_freq="2412") dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
for i in range(0, 3): for i in range(0, 3):
ev = dev[0].wait_event(["WPA: Group rekeying completed"], timeout=2) ev = dev[0].wait_event(["WPA: Group rekeying completed"], timeout=2)
if ev is None: if ev is None:
raise Exception("GTK rekey timed out") raise Exception("GTK rekey timed out")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_ap_wpa2_strict_rekey(dev, apdev): def test_ap_wpa2_strict_rekey(dev, apdev):
"""WPA2-PSK AP and strict GTK rekey enforced by AP""" """WPA2-PSK AP and strict GTK rekey enforced by AP"""
@ -284,14 +284,14 @@ def test_ap_wpa2_strict_rekey(dev, apdev):
passphrase = 'qwertyuiop' passphrase = 'qwertyuiop'
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
params['wpa_strict_rekey'] = '1' params['wpa_strict_rekey'] = '1'
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, psk=passphrase, scan_freq="2412") dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
dev[1].connect(ssid, psk=passphrase, scan_freq="2412") dev[1].connect(ssid, psk=passphrase, scan_freq="2412")
dev[1].request("DISCONNECT") dev[1].request("DISCONNECT")
ev = dev[0].wait_event(["WPA: Group rekeying completed"], timeout=2) ev = dev[0].wait_event(["WPA: Group rekeying completed"], timeout=2)
if ev is None: if ev is None:
raise Exception("GTK rekey timed out") raise Exception("GTK rekey timed out")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_ap_wpa2_bridge_fdb(dev, apdev): def test_ap_wpa2_bridge_fdb(dev, apdev):
"""Bridge FDB entry removal""" """Bridge FDB entry removal"""

View file

@ -13,14 +13,14 @@ import hwsim_utils
import hostapd import hostapd
from wlantest import Wlantest from wlantest import Wlantest
def check_qos_map(ap, dev, dscp, tid, ap_tid=None): def check_qos_map(ap, hapd, dev, dscp, tid, ap_tid=None):
if not ap_tid: if not ap_tid:
ap_tid = tid ap_tid = tid
bssid = ap['bssid'] bssid = ap['bssid']
sta = dev.p2p_interface_addr() sta = dev.p2p_interface_addr()
wt = Wlantest() wt = Wlantest()
wt.clear_sta_counters(bssid, sta) wt.clear_sta_counters(bssid, sta)
hwsim_utils.test_connectivity(dev.ifname, ap['ifname'], dscp=dscp) hwsim_utils.test_connectivity(dev, hapd, dscp=dscp)
time.sleep(0.02) time.sleep(0.02)
[ tx, rx ] = wt.get_tid_counters(bssid, sta) [ tx, rx ] = wt.get_tid_counters(bssid, sta)
if tx[tid] == 0: if tx[tid] == 0:
@ -38,41 +38,40 @@ def test_ap_qosmap(dev, apdev):
ssid = "test-qosmap" ssid = "test-qosmap"
params = { "ssid": ssid } params = { "ssid": ssid }
params['qos_map_set'] = '53,2,22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55' params['qos_map_set'] = '53,2,22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55'
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412") dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
time.sleep(0.1) time.sleep(0.1)
check_qos_map(apdev[0], dev[0], 53, 2) check_qos_map(apdev[0], hapd, dev[0], 53, 2)
check_qos_map(apdev[0], dev[0], 22, 6) check_qos_map(apdev[0], hapd, dev[0], 22, 6)
check_qos_map(apdev[0], dev[0], 8, 0) check_qos_map(apdev[0], hapd, dev[0], 8, 0)
check_qos_map(apdev[0], dev[0], 15, 0) check_qos_map(apdev[0], hapd, dev[0], 15, 0)
check_qos_map(apdev[0], dev[0], 0, 1) check_qos_map(apdev[0], hapd, dev[0], 0, 1)
check_qos_map(apdev[0], dev[0], 7, 1) check_qos_map(apdev[0], hapd, dev[0], 7, 1)
check_qos_map(apdev[0], dev[0], 16, 3) check_qos_map(apdev[0], hapd, dev[0], 16, 3)
check_qos_map(apdev[0], dev[0], 31, 3) check_qos_map(apdev[0], hapd, dev[0], 31, 3)
check_qos_map(apdev[0], dev[0], 32, 4) check_qos_map(apdev[0], hapd, dev[0], 32, 4)
check_qos_map(apdev[0], dev[0], 39, 4) check_qos_map(apdev[0], hapd, dev[0], 39, 4)
check_qos_map(apdev[0], dev[0], 40, 6) check_qos_map(apdev[0], hapd, dev[0], 40, 6)
check_qos_map(apdev[0], dev[0], 47, 6) check_qos_map(apdev[0], hapd, dev[0], 47, 6)
check_qos_map(apdev[0], dev[0], 48, 7) check_qos_map(apdev[0], hapd, dev[0], 48, 7)
check_qos_map(apdev[0], dev[0], 55, 7) check_qos_map(apdev[0], hapd, dev[0], 55, 7)
hapd = hostapd.Hostapd(apdev[0]['ifname'])
hapd.request("SET_QOS_MAP_SET 22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55") hapd.request("SET_QOS_MAP_SET 22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55")
hapd.request("SEND_QOS_MAP_CONF " + dev[0].get_status_field("address")) hapd.request("SEND_QOS_MAP_CONF " + dev[0].get_status_field("address"))
check_qos_map(apdev[0], dev[0], 53, 7) check_qos_map(apdev[0], hapd, dev[0], 53, 7)
check_qos_map(apdev[0], dev[0], 22, 6) check_qos_map(apdev[0], hapd, dev[0], 22, 6)
check_qos_map(apdev[0], dev[0], 48, 7) check_qos_map(apdev[0], hapd, dev[0], 48, 7)
check_qos_map(apdev[0], dev[0], 55, 7) check_qos_map(apdev[0], hapd, dev[0], 55, 7)
check_qos_map(apdev[0], dev[0], 56, 56 >> 3) check_qos_map(apdev[0], hapd, dev[0], 56, 56 >> 3)
check_qos_map(apdev[0], dev[0], 63, 63 >> 3) check_qos_map(apdev[0], hapd, dev[0], 63, 63 >> 3)
def test_ap_qosmap_default(dev, apdev): def test_ap_qosmap_default(dev, apdev):
"""QoS mapping with default values""" """QoS mapping with default values"""
ssid = "test-qosmap-default" ssid = "test-qosmap-default"
params = { "ssid": ssid } params = { "ssid": ssid }
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412") dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
for dscp in [ 0, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 63]: for dscp in [ 0, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 63]:
check_qos_map(apdev[0], dev[0], dscp, dscp >> 3) check_qos_map(apdev[0], hapd, dev[0], dscp, dscp >> 3)
def test_ap_qosmap_default_acm(dev, apdev): def test_ap_qosmap_default_acm(dev, apdev):
"""QoS mapping with default values and ACM=1 for VO/VI""" """QoS mapping with default values and ACM=1 for VO/VI"""
@ -98,7 +97,7 @@ def test_ap_qosmap_default_acm(dev, apdev):
"wmm_ac_vo_cwmax": "2", "wmm_ac_vo_cwmax": "2",
"wmm_ac_vo_txop_limit": "47", "wmm_ac_vo_txop_limit": "47",
"wmm_ac_vo_acm": "1" } "wmm_ac_vo_acm": "1" }
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412") dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
for dscp in [ 0, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 63]: for dscp in [ 0, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 63]:
ap_tid = dscp >> 3 ap_tid = dscp >> 3
@ -106,7 +105,7 @@ def test_ap_qosmap_default_acm(dev, apdev):
# downgrade VI/VO to BE # downgrade VI/VO to BE
if tid in [ 4, 5, 6, 7 ]: if tid in [ 4, 5, 6, 7 ]:
tid = 3 tid = 3
check_qos_map(apdev[0], dev[0], dscp, tid, ap_tid) check_qos_map(apdev[0], hapd, dev[0], dscp, tid, ap_tid)
def test_ap_qosmap_invalid(dev, apdev): def test_ap_qosmap_invalid(dev, apdev):
"""QoS mapping ctrl_iface error handling""" """QoS mapping ctrl_iface error handling"""

View file

@ -14,45 +14,45 @@ import hostapd
def test_ap_roam_open(dev, apdev): def test_ap_roam_open(dev, apdev):
"""Roam between two open APs""" """Roam between two open APs"""
hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" }) hapd0 = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
dev[0].connect("test-open", key_mgmt="NONE") dev[0].connect("test-open", key_mgmt="NONE")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd0)
hostapd.add_ap(apdev[1]['ifname'], { "ssid": "test-open" }) hapd1 = hostapd.add_ap(apdev[1]['ifname'], { "ssid": "test-open" })
dev[0].scan(type="ONLY") dev[0].scan(type="ONLY")
dev[0].roam(apdev[1]['bssid']) dev[0].roam(apdev[1]['bssid'])
hwsim_utils.test_connectivity(dev[0].ifname, apdev[1]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd1)
dev[0].roam(apdev[0]['bssid']) dev[0].roam(apdev[0]['bssid'])
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd0)
def test_ap_roam_wpa2_psk(dev, apdev): def test_ap_roam_wpa2_psk(dev, apdev):
"""Roam between two WPA2-PSK APs""" """Roam between two WPA2-PSK APs"""
params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678") params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678")
hostapd.add_ap(apdev[0]['ifname'], params) hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect("test-wpa2-psk", psk="12345678") dev[0].connect("test-wpa2-psk", psk="12345678")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd0)
hostapd.add_ap(apdev[1]['ifname'], params) hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
dev[0].scan(type="ONLY") dev[0].scan(type="ONLY")
dev[0].roam(apdev[1]['bssid']) dev[0].roam(apdev[1]['bssid'])
hwsim_utils.test_connectivity(dev[0].ifname, apdev[1]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd1)
dev[0].roam(apdev[0]['bssid']) dev[0].roam(apdev[0]['bssid'])
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd0)
def test_ap_reassociation_to_same_bss(dev, apdev): def test_ap_reassociation_to_same_bss(dev, apdev):
"""Reassociate to the same BSS""" """Reassociate to the same BSS"""
hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" }) hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
dev[0].connect("test-open", key_mgmt="NONE") dev[0].connect("test-open", key_mgmt="NONE")
dev[0].request("REASSOCIATE") dev[0].request("REASSOCIATE")
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10) ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
if ev is None: if ev is None:
raise Exception("Reassociation with the AP timed out") raise Exception("Reassociation with the AP timed out")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
dev[0].request("REATTACH") dev[0].request("REATTACH")
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10) ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
if ev is None: if ev is None:
raise Exception("Reassociation (reattach) with the AP timed out") raise Exception("Reassociation (reattach) with the AP timed out")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_ap_roam_set_bssid(dev, apdev): def test_ap_roam_set_bssid(dev, apdev):
"""Roam control""" """Roam control"""

View file

@ -17,42 +17,42 @@ from wlantest import Wlantest
def start_ap_wpa2_psk(ifname): def start_ap_wpa2_psk(ifname):
params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678") params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678")
hostapd.add_ap(ifname, params) return hostapd.add_ap(ifname, params)
def connectivity(dev, ap_ifname): def connectivity(dev, hapd):
hwsim_utils.test_connectivity_sta(dev[0], dev[1]) hwsim_utils.test_connectivity_sta(dev[0], dev[1])
hwsim_utils.test_connectivity(dev[0].ifname, ap_ifname) hwsim_utils.test_connectivity(dev[0], hapd)
hwsim_utils.test_connectivity(dev[1].ifname, ap_ifname) hwsim_utils.test_connectivity(dev[1], hapd)
def connect_2sta(dev, ssid, ap_ifname): def connect_2sta(dev, ssid, hapd):
dev[0].connect(ssid, psk="12345678", scan_freq="2412") dev[0].connect(ssid, psk="12345678", scan_freq="2412")
dev[1].connect(ssid, psk="12345678", scan_freq="2412") dev[1].connect(ssid, psk="12345678", scan_freq="2412")
connectivity(dev, ap_ifname) connectivity(dev, hapd)
def connect_2sta_wpa2_psk(dev, ap_ifname): def connect_2sta_wpa2_psk(dev, hapd):
connect_2sta(dev, "test-wpa2-psk", ap_ifname) connect_2sta(dev, "test-wpa2-psk", hapd)
def connect_2sta_wpa_psk(dev, ap_ifname): def connect_2sta_wpa_psk(dev, hapd):
connect_2sta(dev, "test-wpa-psk", ap_ifname) connect_2sta(dev, "test-wpa-psk", hapd)
def connect_2sta_wpa_psk_mixed(dev, ap_ifname): def connect_2sta_wpa_psk_mixed(dev, hapd):
dev[0].connect("test-wpa-mixed-psk", psk="12345678", proto="WPA", dev[0].connect("test-wpa-mixed-psk", psk="12345678", proto="WPA",
scan_freq="2412") scan_freq="2412")
dev[1].connect("test-wpa-mixed-psk", psk="12345678", proto="WPA2", dev[1].connect("test-wpa-mixed-psk", psk="12345678", proto="WPA2",
scan_freq="2412") scan_freq="2412")
connectivity(dev, ap_ifname) connectivity(dev, hapd)
def connect_2sta_wep(dev, ap_ifname): def connect_2sta_wep(dev, hapd):
dev[0].connect("test-wep", key_mgmt="NONE", wep_key0='"hello"', dev[0].connect("test-wep", key_mgmt="NONE", wep_key0='"hello"',
scan_freq="2412") scan_freq="2412")
dev[1].connect("test-wep", key_mgmt="NONE", wep_key0='"hello"', dev[1].connect("test-wep", key_mgmt="NONE", wep_key0='"hello"',
scan_freq="2412") scan_freq="2412")
connectivity(dev, ap_ifname) connectivity(dev, hapd)
def connect_2sta_open(dev, ap_ifname): def connect_2sta_open(dev, hapd):
dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412") dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
dev[1].connect("test-open", key_mgmt="NONE", scan_freq="2412") dev[1].connect("test-open", key_mgmt="NONE", scan_freq="2412")
connectivity(dev, ap_ifname) connectivity(dev, hapd)
def wlantest_setup(): def wlantest_setup():
wt = Wlantest() wt = Wlantest()
@ -96,14 +96,15 @@ def tdls_check_ap(sta0, sta1, bssid, addr0, addr1):
if inv_ap > 0: if inv_ap > 0:
raise Exception("Invalid frames through AP path") raise Exception("Invalid frames through AP path")
def check_connectivity(sta0, sta1, ap): def check_connectivity(sta0, sta1, hapd):
hwsim_utils.test_connectivity_sta(sta0, sta1) hwsim_utils.test_connectivity_sta(sta0, sta1)
hwsim_utils.test_connectivity(sta0.ifname, ap['ifname']) hwsim_utils.test_connectivity(sta0, hapd)
hwsim_utils.test_connectivity(sta1.ifname, ap['ifname']) hwsim_utils.test_connectivity(sta1, hapd)
def setup_tdls(sta0, sta1, ap, reverse=False, expect_fail=False): def setup_tdls(sta0, sta1, ap, reverse=False, expect_fail=False):
logger.info("Setup TDLS") logger.info("Setup TDLS")
check_connectivity(sta0, sta1, ap) hapd = hostapd.Hostapd(ap['ifname'])
check_connectivity(sta0, sta1, hapd)
bssid = ap['bssid'] bssid = ap['bssid']
addr0 = sta0.p2p_interface_addr() addr0 = sta0.p2p_interface_addr()
addr1 = sta1.p2p_interface_addr() addr1 = sta1.p2p_interface_addr()
@ -122,11 +123,12 @@ def setup_tdls(sta0, sta1, ap, reverse=False, expect_fail=False):
if conf == 0: if conf == 0:
raise Exception("No TDLS Setup Confirm (success) seen") raise Exception("No TDLS Setup Confirm (success) seen")
tdls_check_dl(sta0, sta1, bssid, addr0, addr1) tdls_check_dl(sta0, sta1, bssid, addr0, addr1)
check_connectivity(sta0, sta1, ap) check_connectivity(sta0, sta1, hapd)
def teardown_tdls(sta0, sta1, ap, responder=False): def teardown_tdls(sta0, sta1, ap, responder=False):
logger.info("Teardown TDLS") logger.info("Teardown TDLS")
check_connectivity(sta0, sta1, ap) hapd = hostapd.Hostapd(ap['ifname'])
check_connectivity(sta0, sta1, hapd)
bssid = ap['bssid'] bssid = ap['bssid']
addr0 = sta0.p2p_interface_addr() addr0 = sta0.p2p_interface_addr()
addr1 = sta1.p2p_interface_addr() addr1 = sta1.p2p_interface_addr()
@ -140,21 +142,21 @@ def teardown_tdls(sta0, sta1, ap, responder=False):
if teardown == 0: if teardown == 0:
raise Exception("No TDLS Setup Teardown seen") raise Exception("No TDLS Setup Teardown seen")
tdls_check_ap(sta0, sta1, bssid, addr0, addr1) tdls_check_ap(sta0, sta1, bssid, addr0, addr1)
check_connectivity(sta0, sta1, ap) check_connectivity(sta0, sta1, hapd)
def test_ap_tdls_discovery(dev, apdev): def test_ap_tdls_discovery(dev, apdev):
"""WPA2-PSK AP and two stations using TDLS discovery""" """WPA2-PSK AP and two stations using TDLS discovery"""
start_ap_wpa2_psk(apdev[0]['ifname']) hapd = start_ap_wpa2_psk(apdev[0]['ifname'])
wlantest_setup() wlantest_setup()
connect_2sta_wpa2_psk(dev, apdev[0]['ifname']) connect_2sta_wpa2_psk(dev, hapd)
dev[0].request("TDLS_DISCOVER " + dev[1].p2p_interface_addr()) dev[0].request("TDLS_DISCOVER " + dev[1].p2p_interface_addr())
time.sleep(0.2) time.sleep(0.2)
def test_ap_wpa2_tdls(dev, apdev): def test_ap_wpa2_tdls(dev, apdev):
"""WPA2-PSK AP and two stations using TDLS""" """WPA2-PSK AP and two stations using TDLS"""
start_ap_wpa2_psk(apdev[0]['ifname']) hapd = start_ap_wpa2_psk(apdev[0]['ifname'])
wlantest_setup() wlantest_setup()
connect_2sta_wpa2_psk(dev, apdev[0]['ifname']) connect_2sta_wpa2_psk(dev, hapd)
setup_tdls(dev[0], dev[1], apdev[0]) setup_tdls(dev[0], dev[1], apdev[0])
teardown_tdls(dev[0], dev[1], apdev[0]) teardown_tdls(dev[0], dev[1], apdev[0])
setup_tdls(dev[1], dev[0], apdev[0]) setup_tdls(dev[1], dev[0], apdev[0])
@ -162,41 +164,41 @@ def test_ap_wpa2_tdls(dev, apdev):
def test_ap_wpa2_tdls_concurrent_init(dev, apdev): def test_ap_wpa2_tdls_concurrent_init(dev, apdev):
"""Concurrent TDLS setup initiation""" """Concurrent TDLS setup initiation"""
start_ap_wpa2_psk(apdev[0]['ifname']) hapd = start_ap_wpa2_psk(apdev[0]['ifname'])
wlantest_setup() wlantest_setup()
connect_2sta_wpa2_psk(dev, apdev[0]['ifname']) connect_2sta_wpa2_psk(dev, hapd)
dev[0].request("SET tdls_testing 0x80") dev[0].request("SET tdls_testing 0x80")
setup_tdls(dev[1], dev[0], apdev[0], reverse=True) setup_tdls(dev[1], dev[0], apdev[0], reverse=True)
def test_ap_wpa2_tdls_concurrent_init2(dev, apdev): def test_ap_wpa2_tdls_concurrent_init2(dev, apdev):
"""Concurrent TDLS setup initiation (reverse)""" """Concurrent TDLS setup initiation (reverse)"""
start_ap_wpa2_psk(apdev[0]['ifname']) hapd = start_ap_wpa2_psk(apdev[0]['ifname'])
wlantest_setup() wlantest_setup()
connect_2sta_wpa2_psk(dev, apdev[0]['ifname']) connect_2sta_wpa2_psk(dev, hapd)
dev[1].request("SET tdls_testing 0x80") dev[1].request("SET tdls_testing 0x80")
setup_tdls(dev[0], dev[1], apdev[0]) setup_tdls(dev[0], dev[1], apdev[0])
def test_ap_wpa2_tdls_decline_resp(dev, apdev): def test_ap_wpa2_tdls_decline_resp(dev, apdev):
"""Decline TDLS Setup Response""" """Decline TDLS Setup Response"""
start_ap_wpa2_psk(apdev[0]['ifname']) hapd = start_ap_wpa2_psk(apdev[0]['ifname'])
wlantest_setup() wlantest_setup()
connect_2sta_wpa2_psk(dev, apdev[0]['ifname']) connect_2sta_wpa2_psk(dev, hapd)
dev[1].request("SET tdls_testing 0x200") dev[1].request("SET tdls_testing 0x200")
setup_tdls(dev[1], dev[0], apdev[0], expect_fail=True) setup_tdls(dev[1], dev[0], apdev[0], expect_fail=True)
def test_ap_wpa2_tdls_long_lifetime(dev, apdev): def test_ap_wpa2_tdls_long_lifetime(dev, apdev):
"""TDLS with long TPK lifetime""" """TDLS with long TPK lifetime"""
start_ap_wpa2_psk(apdev[0]['ifname']) hapd = start_ap_wpa2_psk(apdev[0]['ifname'])
wlantest_setup() wlantest_setup()
connect_2sta_wpa2_psk(dev, apdev[0]['ifname']) connect_2sta_wpa2_psk(dev, hapd)
dev[1].request("SET tdls_testing 0x40") dev[1].request("SET tdls_testing 0x40")
setup_tdls(dev[1], dev[0], apdev[0]) setup_tdls(dev[1], dev[0], apdev[0])
def test_ap_wpa2_tdls_long_frame(dev, apdev): def test_ap_wpa2_tdls_long_frame(dev, apdev):
"""TDLS with long setup/teardown frames""" """TDLS with long setup/teardown frames"""
start_ap_wpa2_psk(apdev[0]['ifname']) hapd = start_ap_wpa2_psk(apdev[0]['ifname'])
wlantest_setup() wlantest_setup()
connect_2sta_wpa2_psk(dev, apdev[0]['ifname']) connect_2sta_wpa2_psk(dev, hapd)
dev[0].request("SET tdls_testing 0x1") dev[0].request("SET tdls_testing 0x1")
dev[1].request("SET tdls_testing 0x1") dev[1].request("SET tdls_testing 0x1")
setup_tdls(dev[1], dev[0], apdev[0]) setup_tdls(dev[1], dev[0], apdev[0])
@ -205,34 +207,34 @@ def test_ap_wpa2_tdls_long_frame(dev, apdev):
def test_ap_wpa2_tdls_reneg(dev, apdev): def test_ap_wpa2_tdls_reneg(dev, apdev):
"""Renegotiate TDLS link""" """Renegotiate TDLS link"""
start_ap_wpa2_psk(apdev[0]['ifname']) hapd = start_ap_wpa2_psk(apdev[0]['ifname'])
wlantest_setup() wlantest_setup()
connect_2sta_wpa2_psk(dev, apdev[0]['ifname']) connect_2sta_wpa2_psk(dev, hapd)
setup_tdls(dev[1], dev[0], apdev[0]) setup_tdls(dev[1], dev[0], apdev[0])
setup_tdls(dev[0], dev[1], apdev[0]) setup_tdls(dev[0], dev[1], apdev[0])
def test_ap_wpa2_tdls_wrong_lifetime_resp(dev, apdev): def test_ap_wpa2_tdls_wrong_lifetime_resp(dev, apdev):
"""Incorrect TPK lifetime in TDLS Setup Response""" """Incorrect TPK lifetime in TDLS Setup Response"""
start_ap_wpa2_psk(apdev[0]['ifname']) hapd = start_ap_wpa2_psk(apdev[0]['ifname'])
wlantest_setup() wlantest_setup()
connect_2sta_wpa2_psk(dev, apdev[0]['ifname']) connect_2sta_wpa2_psk(dev, hapd)
dev[1].request("SET tdls_testing 0x10") dev[1].request("SET tdls_testing 0x10")
setup_tdls(dev[0], dev[1], apdev[0], expect_fail=True) setup_tdls(dev[0], dev[1], apdev[0], expect_fail=True)
def test_ap_wpa2_tdls_diff_rsnie(dev, apdev): def test_ap_wpa2_tdls_diff_rsnie(dev, apdev):
"""TDLS with different RSN IEs""" """TDLS with different RSN IEs"""
start_ap_wpa2_psk(apdev[0]['ifname']) hapd = start_ap_wpa2_psk(apdev[0]['ifname'])
wlantest_setup() wlantest_setup()
connect_2sta_wpa2_psk(dev, apdev[0]['ifname']) connect_2sta_wpa2_psk(dev, hapd)
dev[1].request("SET tdls_testing 0x2") dev[1].request("SET tdls_testing 0x2")
setup_tdls(dev[1], dev[0], apdev[0]) setup_tdls(dev[1], dev[0], apdev[0])
teardown_tdls(dev[1], dev[0], apdev[0]) teardown_tdls(dev[1], dev[0], apdev[0])
def test_ap_wpa2_tdls_wrong_tpk_m2_mic(dev, apdev): def test_ap_wpa2_tdls_wrong_tpk_m2_mic(dev, apdev):
"""Incorrect MIC in TDLS Setup Response""" """Incorrect MIC in TDLS Setup Response"""
start_ap_wpa2_psk(apdev[0]['ifname']) hapd = start_ap_wpa2_psk(apdev[0]['ifname'])
wlantest_setup() wlantest_setup()
connect_2sta_wpa2_psk(dev, apdev[0]['ifname']) connect_2sta_wpa2_psk(dev, hapd)
dev[0].request("SET tdls_testing 0x800") dev[0].request("SET tdls_testing 0x800")
addr0 = dev[0].p2p_interface_addr() addr0 = dev[0].p2p_interface_addr()
dev[1].tdls_setup(addr0) dev[1].tdls_setup(addr0)
@ -240,9 +242,9 @@ def test_ap_wpa2_tdls_wrong_tpk_m2_mic(dev, apdev):
def test_ap_wpa2_tdls_wrong_tpk_m3_mic(dev, apdev): def test_ap_wpa2_tdls_wrong_tpk_m3_mic(dev, apdev):
"""Incorrect MIC in TDLS Setup Confirm""" """Incorrect MIC in TDLS Setup Confirm"""
start_ap_wpa2_psk(apdev[0]['ifname']) hapd = start_ap_wpa2_psk(apdev[0]['ifname'])
wlantest_setup() wlantest_setup()
connect_2sta_wpa2_psk(dev, apdev[0]['ifname']) connect_2sta_wpa2_psk(dev, hapd)
dev[1].request("SET tdls_testing 0x800") dev[1].request("SET tdls_testing 0x800")
addr0 = dev[0].p2p_interface_addr() addr0 = dev[0].p2p_interface_addr()
dev[1].tdls_setup(addr0) dev[1].tdls_setup(addr0)
@ -250,41 +252,41 @@ def test_ap_wpa2_tdls_wrong_tpk_m3_mic(dev, apdev):
def test_ap_wpa_tdls(dev, apdev): def test_ap_wpa_tdls(dev, apdev):
"""WPA-PSK AP and two stations using TDLS""" """WPA-PSK AP and two stations using TDLS"""
hostapd.add_ap(apdev[0]['ifname'], hapd = hostapd.add_ap(apdev[0]['ifname'],
hostapd.wpa_params(ssid="test-wpa-psk", hostapd.wpa_params(ssid="test-wpa-psk",
passphrase="12345678")) passphrase="12345678"))
wlantest_setup() wlantest_setup()
connect_2sta_wpa_psk(dev, apdev[0]['ifname']) connect_2sta_wpa_psk(dev, hapd)
setup_tdls(dev[0], dev[1], apdev[0]) setup_tdls(dev[0], dev[1], apdev[0])
teardown_tdls(dev[0], dev[1], apdev[0]) teardown_tdls(dev[0], dev[1], apdev[0])
setup_tdls(dev[1], dev[0], apdev[0]) setup_tdls(dev[1], dev[0], apdev[0])
def test_ap_wpa_mixed_tdls(dev, apdev): def test_ap_wpa_mixed_tdls(dev, apdev):
"""WPA+WPA2-PSK AP and two stations using TDLS""" """WPA+WPA2-PSK AP and two stations using TDLS"""
hostapd.add_ap(apdev[0]['ifname'], hapd = hostapd.add_ap(apdev[0]['ifname'],
hostapd.wpa_mixed_params(ssid="test-wpa-mixed-psk", hostapd.wpa_mixed_params(ssid="test-wpa-mixed-psk",
passphrase="12345678")) passphrase="12345678"))
wlantest_setup() wlantest_setup()
connect_2sta_wpa_psk_mixed(dev, apdev[0]['ifname']) connect_2sta_wpa_psk_mixed(dev, hapd)
setup_tdls(dev[0], dev[1], apdev[0]) setup_tdls(dev[0], dev[1], apdev[0])
teardown_tdls(dev[0], dev[1], apdev[0]) teardown_tdls(dev[0], dev[1], apdev[0])
setup_tdls(dev[1], dev[0], apdev[0]) setup_tdls(dev[1], dev[0], apdev[0])
def test_ap_wep_tdls(dev, apdev): def test_ap_wep_tdls(dev, apdev):
"""WEP AP and two stations using TDLS""" """WEP AP and two stations using TDLS"""
hostapd.add_ap(apdev[0]['ifname'], hapd = hostapd.add_ap(apdev[0]['ifname'],
{ "ssid": "test-wep", "wep_key0": '"hello"' }) { "ssid": "test-wep", "wep_key0": '"hello"' })
wlantest_setup() wlantest_setup()
connect_2sta_wep(dev, apdev[0]['ifname']) connect_2sta_wep(dev, hapd)
setup_tdls(dev[0], dev[1], apdev[0]) setup_tdls(dev[0], dev[1], apdev[0])
teardown_tdls(dev[0], dev[1], apdev[0]) teardown_tdls(dev[0], dev[1], apdev[0])
setup_tdls(dev[1], dev[0], apdev[0]) setup_tdls(dev[1], dev[0], apdev[0])
def test_ap_open_tdls(dev, apdev): def test_ap_open_tdls(dev, apdev):
"""Open AP and two stations using TDLS""" """Open AP and two stations using TDLS"""
hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" }) hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
wlantest_setup() wlantest_setup()
connect_2sta_open(dev, apdev[0]['ifname']) connect_2sta_open(dev, hapd)
setup_tdls(dev[0], dev[1], apdev[0]) setup_tdls(dev[0], dev[1], apdev[0])
teardown_tdls(dev[0], dev[1], apdev[0]) teardown_tdls(dev[0], dev[1], apdev[0])
setup_tdls(dev[1], dev[0], apdev[0]) setup_tdls(dev[1], dev[0], apdev[0])
@ -305,7 +307,10 @@ def test_ap_wpa2_tdls_bssid_mismatch(dev, apdev):
bssid=apdev[0]['bssid']) bssid=apdev[0]['bssid'])
dev[1].connect(ssid, psk=passphrase, scan_freq="2412", dev[1].connect(ssid, psk=passphrase, scan_freq="2412",
bssid=apdev[1]['bssid']) bssid=apdev[1]['bssid'])
connectivity(dev, "ap-br0") hwsim_utils.test_connectivity_sta(dev[0], dev[1])
hwsim_utils.test_connectivity_iface(dev[0], "ap-br0")
hwsim_utils.test_connectivity_iface(dev[1], "ap-br0")
addr0 = dev[0].p2p_interface_addr() addr0 = dev[0].p2p_interface_addr()
dev[1].tdls_setup(addr0) dev[1].tdls_setup(addr0)
time.sleep(1) time.sleep(1)
@ -316,8 +321,8 @@ def test_ap_wpa2_tdls_bssid_mismatch(dev, apdev):
def test_ap_wpa2_tdls_responder_teardown(dev, apdev): def test_ap_wpa2_tdls_responder_teardown(dev, apdev):
"""TDLS teardown from responder with WPA2-PSK AP""" """TDLS teardown from responder with WPA2-PSK AP"""
start_ap_wpa2_psk(apdev[0]['ifname']) hapd = start_ap_wpa2_psk(apdev[0]['ifname'])
wlantest_setup() wlantest_setup()
connect_2sta_wpa2_psk(dev, apdev[0]['ifname']) connect_2sta_wpa2_psk(dev, hapd)
setup_tdls(dev[0], dev[1], apdev[0]) setup_tdls(dev[0], dev[1], apdev[0])
teardown_tdls(dev[0], dev[1], apdev[0], responder=True) teardown_tdls(dev[0], dev[1], apdev[0], responder=True)

View file

@ -36,7 +36,7 @@ def test_ap_vht80(dev, apdev):
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180") dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
except Exception, e: except Exception, e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
@ -71,7 +71,7 @@ def test_ap_vht80_params(dev, apdev):
if "status_code=104" not in ev: if "status_code=104" not in ev:
raise Exception("Unexpected rejection status code") raise Exception("Unexpected rejection status code")
dev[1].request("DISCONNECT") dev[1].request("DISCONNECT")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
except Exception, e: except Exception, e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
@ -98,9 +98,9 @@ def test_ap_vht_20(devs, apdevs):
"supported_rates": "60 120 240 360 480 540", "supported_rates": "60 120 240 360 480 540",
"require_vht": "1", "require_vht": "1",
} }
hostapd.add_ap(ap['ifname'], params) hapd = hostapd.add_ap(ap['ifname'], params)
dev.connect("test-vht20", scan_freq="5180", key_mgmt="NONE") dev.connect("test-vht20", scan_freq="5180", key_mgmt="NONE")
hwsim_utils.test_connectivity(dev.ifname, ap['ifname']) hwsim_utils.test_connectivity(dev, hapd)
finally: finally:
subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
@ -213,9 +213,9 @@ def test_ap_vht160(dev, apdev):
raise Exception("Unexpected frequency(2)") raise Exception("Unexpected frequency(2)")
dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180") dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
dev[1].connect("vht2", key_mgmt="NONE", scan_freq="5500") dev[1].connect("vht2", key_mgmt="NONE", scan_freq="5500")
hwsim_utils.test_connectivity(dev[1].ifname, apdev[1]['ifname']) hwsim_utils.test_connectivity(dev[1], hapd2)
except Exception, e: except Exception, e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
@ -266,7 +266,7 @@ def test_ap_vht80plus80(dev, apdev):
raise Exception("Unexpected interface state(2)") raise Exception("Unexpected interface state(2)")
dev[1].connect("vht2", key_mgmt="NONE", scan_freq="5180") dev[1].connect("vht2", key_mgmt="NONE", scan_freq="5180")
hwsim_utils.test_connectivity(dev[1].ifname, apdev[1]['ifname']) hwsim_utils.test_connectivity(dev[1], hapd2)
except Exception, e: except Exception, e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():

View file

@ -19,14 +19,14 @@ def test_ap_vlan_open(dev, apdev):
params = { "ssid": "test-vlan-open", params = { "ssid": "test-vlan-open",
"dynamic_vlan": "1", "dynamic_vlan": "1",
"accept_mac_file": "hostapd.accept" } "accept_mac_file": "hostapd.accept" }
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, "brvlan1") hwsim_utils.test_connectivity_iface(dev[0], "brvlan1")
hwsim_utils.test_connectivity(dev[1].ifname, "brvlan2") hwsim_utils.test_connectivity_iface(dev[1], "brvlan2")
hwsim_utils.test_connectivity(dev[2].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[2], hapd)
def test_ap_vlan_file_open(dev, apdev): def test_ap_vlan_file_open(dev, apdev):
"""AP VLAN with open network and vlan_file mapping""" """AP VLAN with open network and vlan_file mapping"""
@ -34,14 +34,14 @@ def test_ap_vlan_file_open(dev, apdev):
"dynamic_vlan": "1", "dynamic_vlan": "1",
"vlan_file": "hostapd.vlan", "vlan_file": "hostapd.vlan",
"accept_mac_file": "hostapd.accept" } "accept_mac_file": "hostapd.accept" }
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, "brvlan1") hwsim_utils.test_connectivity_iface(dev[0], "brvlan1")
hwsim_utils.test_connectivity(dev[1].ifname, "brvlan2") hwsim_utils.test_connectivity_iface(dev[1], "brvlan2")
hwsim_utils.test_connectivity(dev[2].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[2], hapd)
def test_ap_vlan_wpa2(dev, apdev): def test_ap_vlan_wpa2(dev, apdev):
"""AP VLAN with WPA2-PSK""" """AP VLAN with WPA2-PSK"""
@ -49,20 +49,20 @@ def test_ap_vlan_wpa2(dev, apdev):
passphrase="12345678") passphrase="12345678")
params['dynamic_vlan'] = "1"; params['dynamic_vlan'] = "1";
params['accept_mac_file'] = "hostapd.accept"; params['accept_mac_file'] = "hostapd.accept";
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect("test-vlan", psk="12345678", scan_freq="2412") dev[0].connect("test-vlan", psk="12345678", scan_freq="2412")
dev[1].connect("test-vlan", psk="12345678", scan_freq="2412") dev[1].connect("test-vlan", psk="12345678", scan_freq="2412")
dev[2].connect("test-vlan", psk="12345678", scan_freq="2412") dev[2].connect("test-vlan", psk="12345678", scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, "brvlan1") hwsim_utils.test_connectivity_iface(dev[0], "brvlan1")
hwsim_utils.test_connectivity(dev[1].ifname, "brvlan2") hwsim_utils.test_connectivity_iface(dev[1], "brvlan2")
hwsim_utils.test_connectivity(dev[2].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[2], hapd)
def test_ap_vlan_wpa2_radius(dev, apdev): def test_ap_vlan_wpa2_radius(dev, apdev):
"""AP VLAN with WPA2-Enterprise and RADIUS attributes""" """AP VLAN with WPA2-Enterprise and RADIUS attributes"""
params = hostapd.wpa2_eap_params(ssid="test-vlan") params = hostapd.wpa2_eap_params(ssid="test-vlan")
params['dynamic_vlan'] = "1"; params['dynamic_vlan'] = "1";
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX", dev[0].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
identity="vlan1", identity="vlan1",
@ -76,9 +76,9 @@ def test_ap_vlan_wpa2_radius(dev, apdev):
identity="pax.user@example.com", identity="pax.user@example.com",
password_hex="0123456789abcdef0123456789abcdef", password_hex="0123456789abcdef0123456789abcdef",
scan_freq="2412") scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, "brvlan1") hwsim_utils.test_connectivity_iface(dev[0], "brvlan1")
hwsim_utils.test_connectivity(dev[1].ifname, "brvlan2") hwsim_utils.test_connectivity_iface(dev[1], "brvlan2")
hwsim_utils.test_connectivity(dev[2].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[2], hapd)
def test_ap_vlan_wpa2_radius_required(dev, apdev): def test_ap_vlan_wpa2_radius_required(dev, apdev):
"""AP VLAN with WPA2-Enterprise and RADIUS attributes required""" """AP VLAN with WPA2-Enterprise and RADIUS attributes required"""
@ -107,11 +107,11 @@ def test_ap_vlan_tagged(dev, apdev):
"dynamic_vlan": "1", "dynamic_vlan": "1",
"vlan_tagged_interface": "lo", "vlan_tagged_interface": "lo",
"accept_mac_file": "hostapd.accept" } "accept_mac_file": "hostapd.accept" }
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, "brlo.1") hwsim_utils.test_connectivity_iface(dev[0], "brlo.1")
hwsim_utils.test_connectivity(dev[1].ifname, "brlo.2") hwsim_utils.test_connectivity_iface(dev[1], "brlo.2")
hwsim_utils.test_connectivity(dev[2].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[2], hapd)

View file

@ -52,7 +52,7 @@ def test_connect_cmd_wpa2_psk(dev, apdev):
def test_connect_cmd_concurrent_grpform_while_connecting(dev, apdev): def test_connect_cmd_concurrent_grpform_while_connecting(dev, apdev):
"""Concurrent P2P group formation while connecting to an AP using cfg80211 connect command""" """Concurrent P2P group formation while connecting to an AP using cfg80211 connect command"""
logger.info("Start connection to an infrastructure AP") logger.info("Start connection to an infrastructure AP")
hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" }) hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") wpas.interface_add("wlan5", drv_params="force_connect_cmd=1")
@ -67,7 +67,7 @@ def test_connect_cmd_concurrent_grpform_while_connecting(dev, apdev):
remove_group(dev[0], wpas) remove_group(dev[0], wpas)
logger.info("Confirm AP connection after P2P group removal") logger.info("Confirm AP connection after P2P group removal")
hwsim_utils.test_connectivity(wpas.ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(wpas, hapd)
def test_connect_cmd_reject_assoc(dev, apdev): def test_connect_cmd_reject_assoc(dev, apdev):
"""Connection using cfg80211 connect command getting rejected""" """Connection using cfg80211 connect command getting rejected"""

View file

@ -83,7 +83,7 @@ def test_dfs(dev, apdev):
raise Exception("Unexpected frequency") raise Exception("Unexpected frequency")
dev[0].connect("dfs", key_mgmt="NONE") dev[0].connect("dfs", key_mgmt="NONE")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
hapd.request("RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1") hapd.request("RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1")
ev = hapd.wait_event(["DFS-RADAR-DETECTED"], timeout=10) ev = hapd.wait_event(["DFS-RADAR-DETECTED"], timeout=10)
@ -103,7 +103,7 @@ def test_dfs(dev, apdev):
if "freq=5260" in ev: if "freq=5260" in ev:
raise Exception("Channel did not change after radar was detected(2)"); raise Exception("Channel did not change after radar was detected(2)");
time.sleep(1) time.sleep(1)
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
finally: finally:
subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])

View file

@ -110,9 +110,9 @@ def test_ibss_rsn(dev):
# Allow some time for all peers to complete key setup # Allow some time for all peers to complete key setup
time.sleep(3) time.sleep(3)
hwsim_utils.test_connectivity(dev[0].ifname, dev[1].ifname) hwsim_utils.test_connectivity(dev[0], dev[1])
hwsim_utils.test_connectivity(dev[0].ifname, dev[2].ifname) hwsim_utils.test_connectivity(dev[0], dev[2])
hwsim_utils.test_connectivity(dev[1].ifname, dev[2].ifname) hwsim_utils.test_connectivity(dev[1], dev[2])
dev[1].request("REMOVE_NETWORK all") dev[1].request("REMOVE_NETWORK all")
time.sleep(1) time.sleep(1)
@ -126,7 +126,7 @@ def test_ibss_rsn(dev):
wait_4way_handshake(dev[0], dev[1]) wait_4way_handshake(dev[0], dev[1])
wait_4way_handshake(dev[1], dev[0]) wait_4way_handshake(dev[1], dev[0])
time.sleep(3) time.sleep(3)
hwsim_utils.test_connectivity(dev[0].ifname, dev[1].ifname) hwsim_utils.test_connectivity(dev[0], dev[1])
def test_ibss_wpa_none(dev): def test_ibss_wpa_none(dev):
"""IBSS WPA-None""" """IBSS WPA-None"""
@ -172,15 +172,15 @@ def test_ibss_wpa_none(dev):
# This is supposed to work, but looks like WPA-None does not work with # This is supposed to work, but looks like WPA-None does not work with
# mac80211 currently.. # mac80211 currently..
try: try:
hwsim_utils.test_connectivity(dev[0].ifname, dev[1].ifname) hwsim_utils.test_connectivity(dev[0], dev[1])
except Exception, e: except Exception, e:
logger.info("Ignoring known connectivity failure: " + str(e)) logger.info("Ignoring known connectivity failure: " + str(e))
try: try:
hwsim_utils.test_connectivity(dev[0].ifname, dev[2].ifname) hwsim_utils.test_connectivity(dev[0], dev[2])
except Exception, e: except Exception, e:
logger.info("Ignoring known connectivity failure: " + str(e)) logger.info("Ignoring known connectivity failure: " + str(e))
try: try:
hwsim_utils.test_connectivity(dev[1].ifname, dev[2].ifname) hwsim_utils.test_connectivity(dev[1], dev[2])
except Exception, e: except Exception, e:
logger.info("Ignoring known connectivity failure: " + str(e)) logger.info("Ignoring known connectivity failure: " + str(e))
@ -220,7 +220,7 @@ def test_ibss_wpa_none_ccmp(dev):
# This is supposed to work, but looks like WPA-None does not work with # This is supposed to work, but looks like WPA-None does not work with
# mac80211 currently.. # mac80211 currently..
try: try:
hwsim_utils.test_connectivity(dev[0].ifname, dev[1].ifname) hwsim_utils.test_connectivity(dev[0], dev[1])
except Exception, e: except Exception, e:
logger.info("Ignoring known connectivity failure: " + str(e)) logger.info("Ignoring known connectivity failure: " + str(e))

View file

@ -19,12 +19,12 @@ def test_ieee8021x_wep104(dev, apdev):
params["ieee8021x"] = "1" params["ieee8021x"] = "1"
params["wep_key_len_broadcast"] = "13" params["wep_key_len_broadcast"] = "13"
params["wep_key_len_unicast"] = "13" params["wep_key_len_unicast"] = "13"
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect("ieee8021x-wep", key_mgmt="IEEE8021X", eap="PSK", dev[0].connect("ieee8021x-wep", key_mgmt="IEEE8021X", eap="PSK",
identity="psk.user@example.com", identity="psk.user@example.com",
password_hex="0123456789abcdef0123456789abcdef") password_hex="0123456789abcdef0123456789abcdef")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_ieee8021x_wep40(dev, apdev): def test_ieee8021x_wep40(dev, apdev):
"""IEEE 802.1X connection using dynamic WEP40""" """IEEE 802.1X connection using dynamic WEP40"""
@ -33,24 +33,24 @@ def test_ieee8021x_wep40(dev, apdev):
params["ieee8021x"] = "1" params["ieee8021x"] = "1"
params["wep_key_len_broadcast"] = "5" params["wep_key_len_broadcast"] = "5"
params["wep_key_len_unicast"] = "5" params["wep_key_len_unicast"] = "5"
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect("ieee8021x-wep", key_mgmt="IEEE8021X", eap="PSK", dev[0].connect("ieee8021x-wep", key_mgmt="IEEE8021X", eap="PSK",
identity="psk.user@example.com", identity="psk.user@example.com",
password_hex="0123456789abcdef0123456789abcdef") password_hex="0123456789abcdef0123456789abcdef")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_ieee8021x_open(dev, apdev): def test_ieee8021x_open(dev, apdev):
"""IEEE 802.1X connection using open network""" """IEEE 802.1X connection using open network"""
params = hostapd.radius_params() params = hostapd.radius_params()
params["ssid"] = "ieee8021x-open" params["ssid"] = "ieee8021x-open"
params["ieee8021x"] = "1" params["ieee8021x"] = "1"
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
id = dev[0].connect("ieee8021x-open", key_mgmt="IEEE8021X", eapol_flags="0", id = dev[0].connect("ieee8021x-open", key_mgmt="IEEE8021X", eapol_flags="0",
eap="PSK", identity="psk.user@example.com", eap="PSK", identity="psk.user@example.com",
password_hex="0123456789abcdef0123456789abcdef") password_hex="0123456789abcdef0123456789abcdef")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
logger.info("Test EAPOL-Logoff") logger.info("Test EAPOL-Logoff")
dev[0].request("LOGOFF") dev[0].request("LOGOFF")
@ -62,4 +62,4 @@ def test_ieee8021x_open(dev, apdev):
dev[0].request("LOGON") dev[0].request("LOGON")
dev[0].connect_network(id) dev[0].connect_network(id)
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)

View file

@ -12,7 +12,7 @@ logger = logging.getLogger()
import hwsim_utils import hwsim_utils
import hostapd import hostapd
def check_wpa2_connection(sta, ap, ssid, mixed=False): def check_wpa2_connection(sta, ap, hapd, ssid, mixed=False):
status = sta.get_status() status = sta.get_status()
if status['wpa_state'] != 'COMPLETED': if status['wpa_state'] != 'COMPLETED':
raise Exception("Not fully connected") raise Exception("Not fully connected")
@ -26,7 +26,7 @@ def check_wpa2_connection(sta, ap, ssid, mixed=False):
raise Exception("Unexpected encryption configuration") raise Exception("Unexpected encryption configuration")
if status['key_mgmt'] != 'WPA2-PSK': if status['key_mgmt'] != 'WPA2-PSK':
raise Exception("Unexpected key_mgmt") raise Exception("Unexpected key_mgmt")
hwsim_utils.test_connectivity(sta.ifname, ap['ifname']) hwsim_utils.test_connectivity(sta, hapd)
def ap_wps_params(ssid): def ap_wps_params(ssid):
return { "ssid": ssid, "eap_server": "1", "wps_state": "2", return { "ssid": ssid, "eap_server": "1", "wps_state": "2",
@ -53,7 +53,7 @@ def test_nfc_wps_password_token_sta(dev, apdev):
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
if ev is None: if ev is None:
raise Exception("Association with the AP timed out") raise Exception("Association with the AP timed out")
check_wpa2_connection(dev[0], apdev[0], ssid) check_wpa2_connection(dev[0], apdev[0], hapd, ssid)
def test_nfc_wps_config_token(dev, apdev): def test_nfc_wps_config_token(dev, apdev):
"""NFC tag with configuration token from AP""" """NFC tag with configuration token from AP"""
@ -72,7 +72,7 @@ def test_nfc_wps_config_token(dev, apdev):
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15) ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
if ev is None: if ev is None:
raise Exception("Association with the AP timed out") raise Exception("Association with the AP timed out")
check_wpa2_connection(dev[0], apdev[0], ssid) check_wpa2_connection(dev[0], apdev[0], hapd, ssid)
def test_nfc_wps_config_token_init(dev, apdev): def test_nfc_wps_config_token_init(dev, apdev):
"""NFC tag with configuration token from AP with auto configuration""" """NFC tag with configuration token from AP with auto configuration"""
@ -91,7 +91,7 @@ def test_nfc_wps_config_token_init(dev, apdev):
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15) ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
if ev is None: if ev is None:
raise Exception("Association with the AP timed out") raise Exception("Association with the AP timed out")
check_wpa2_connection(dev[0], apdev[0], ssid, mixed=True) check_wpa2_connection(dev[0], apdev[0], hapd, ssid, mixed=True)
def test_nfc_wps_password_token_sta_init(dev, apdev): def test_nfc_wps_password_token_sta_init(dev, apdev):
"""Initial AP configuration with first WPS NFC Enrollee""" """Initial AP configuration with first WPS NFC Enrollee"""
@ -113,7 +113,7 @@ def test_nfc_wps_password_token_sta_init(dev, apdev):
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
if ev is None: if ev is None:
raise Exception("Association with the AP timed out") raise Exception("Association with the AP timed out")
check_wpa2_connection(dev[0], apdev[0], ssid, mixed=True) check_wpa2_connection(dev[0], apdev[0], hapd, ssid, mixed=True)
def test_nfc_wps_password_token_ap(dev, apdev): def test_nfc_wps_password_token_ap(dev, apdev):
"""WPS registrar configuring an AP using AP password token""" """WPS registrar configuring an AP using AP password token"""
@ -140,7 +140,7 @@ def test_nfc_wps_password_token_ap(dev, apdev):
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
if ev is None: if ev is None:
raise Exception("Association with the AP timed out") raise Exception("Association with the AP timed out")
check_wpa2_connection(dev[0], apdev[0], new_ssid, mixed=True) check_wpa2_connection(dev[0], apdev[0], hapd, new_ssid, mixed=True)
if "FAIL" in hapd.request("WPS_NFC_TOKEN disable"): if "FAIL" in hapd.request("WPS_NFC_TOKEN disable"):
raise Exception("Failed to disable AP password token") raise Exception("Failed to disable AP password token")
if "FAIL" in hapd.request("WPS_NFC_TOKEN WPS"): if "FAIL" in hapd.request("WPS_NFC_TOKEN WPS"):
@ -170,7 +170,7 @@ def test_nfc_wps_handover_init(dev, apdev):
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15) ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
if ev is None: if ev is None:
raise Exception("Association with the AP timed out") raise Exception("Association with the AP timed out")
check_wpa2_connection(dev[0], apdev[0], ssid, mixed=True) check_wpa2_connection(dev[0], apdev[0], hapd, ssid, mixed=True)
def test_nfc_wps_handover_errors(dev, apdev): def test_nfc_wps_handover_errors(dev, apdev):
"""WPS AP NFC handover report error cases""" """WPS AP NFC handover report error cases"""
@ -225,7 +225,7 @@ def test_nfc_wps_handover(dev, apdev):
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
if ev is None: if ev is None:
raise Exception("Association with the AP timed out") raise Exception("Association with the AP timed out")
check_wpa2_connection(dev[0], apdev[0], ssid) check_wpa2_connection(dev[0], apdev[0], hapd, ssid)
def test_nfc_wps_handover_5ghz(dev, apdev): def test_nfc_wps_handover_5ghz(dev, apdev):
"""Connect to WPS AP with NFC connection handover on 5 GHz band""" """Connect to WPS AP with NFC connection handover on 5 GHz band"""
@ -253,7 +253,7 @@ def test_nfc_wps_handover_5ghz(dev, apdev):
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
if ev is None: if ev is None:
raise Exception("Association with the AP timed out") raise Exception("Association with the AP timed out")
check_wpa2_connection(dev[0], apdev[0], ssid) check_wpa2_connection(dev[0], apdev[0], hapd, ssid)
finally: finally:
subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
@ -283,7 +283,7 @@ def test_nfc_wps_handover_chan14(dev, apdev):
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
if ev is None: if ev is None:
raise Exception("Association with the AP timed out") raise Exception("Association with the AP timed out")
check_wpa2_connection(dev[0], apdev[0], ssid) check_wpa2_connection(dev[0], apdev[0], hapd, ssid)
finally: finally:
subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
@ -317,7 +317,7 @@ def test_nfc_wps_handover_with_pw_token_set(dev, apdev):
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15) ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
if ev is None: if ev is None:
raise Exception("Association with the AP timed out") raise Exception("Association with the AP timed out")
check_wpa2_connection(dev[0], apdev[0], ssid) check_wpa2_connection(dev[0], apdev[0], hapd, ssid)
def test_nfc_wps_handover_pk_hash_mismatch_sta(dev, apdev): def test_nfc_wps_handover_pk_hash_mismatch_sta(dev, apdev):
"""WPS NFC connection handover with invalid pkhash from station (negative)""" """WPS NFC connection handover with invalid pkhash from station (negative)"""
@ -410,6 +410,7 @@ def test_nfc_wps_er_pw_token(dev, apdev):
"""WPS NFC password token from Enrollee to ER""" """WPS NFC password token from Enrollee to ER"""
ssid = "wps-nfc-er-pw-token" ssid = "wps-nfc-er-pw-token"
start_ap_er(dev[0], apdev[0], ssid) start_ap_er(dev[0], apdev[0], ssid)
hapd = hostapd.Hostapd(apdev[0]['ifname'])
logger.info("WPS provisioning step using password token from station") logger.info("WPS provisioning step using password token from station")
dev[1].request("SET ignore_old_scan_res 1") dev[1].request("SET ignore_old_scan_res 1")
pw = dev[1].request("WPS_NFC_TOKEN NDEF").rstrip() pw = dev[1].request("WPS_NFC_TOKEN NDEF").rstrip()
@ -428,12 +429,13 @@ def test_nfc_wps_er_pw_token(dev, apdev):
ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15) ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
if ev is None: if ev is None:
raise Exception("Association with the AP timed out") raise Exception("Association with the AP timed out")
check_wpa2_connection(dev[1], apdev[0], ssid) check_wpa2_connection(dev[1], apdev[0], hapd, ssid)
def test_nfc_wps_er_config_token(dev, apdev): def test_nfc_wps_er_config_token(dev, apdev):
"""WPS NFC configuration token from ER to Enrollee""" """WPS NFC configuration token from ER to Enrollee"""
ssid = "wps-nfc-er-config-token" ssid = "wps-nfc-er-config-token"
start_ap_er(dev[0], apdev[0], ssid) start_ap_er(dev[0], apdev[0], ssid)
hapd = hostapd.Hostapd(apdev[0]['ifname'])
logger.info("WPS provisioning step using configuration token from ER") logger.info("WPS provisioning step using configuration token from ER")
conf = dev[0].request("WPS_ER_NFC_CONFIG_TOKEN NDEF " + apdev[0]['bssid']).rstrip() conf = dev[0].request("WPS_ER_NFC_CONFIG_TOKEN NDEF " + apdev[0]['bssid']).rstrip()
if "FAIL" in conf: if "FAIL" in conf:
@ -445,12 +447,13 @@ def test_nfc_wps_er_config_token(dev, apdev):
ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15) ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
if ev is None: if ev is None:
raise Exception("Association with the AP timed out") raise Exception("Association with the AP timed out")
check_wpa2_connection(dev[1], apdev[0], ssid) check_wpa2_connection(dev[1], apdev[0], hapd, ssid)
def test_nfc_wps_er_handover(dev, apdev): def test_nfc_wps_er_handover(dev, apdev):
"""WPS NFC connection handover between Enrollee and ER""" """WPS NFC connection handover between Enrollee and ER"""
ssid = "wps-nfc-er-handover" ssid = "wps-nfc-er-handover"
start_ap_er(dev[0], apdev[0], ssid) start_ap_er(dev[0], apdev[0], ssid)
hapd = hostapd.Hostapd(apdev[0]['ifname'])
logger.info("WPS provisioning step using connection handover") logger.info("WPS provisioning step using connection handover")
req = dev[1].request("NFC_GET_HANDOVER_REQ NDEF WPS-CR").rstrip() req = dev[1].request("NFC_GET_HANDOVER_REQ NDEF WPS-CR").rstrip()
if "FAIL" in req: if "FAIL" in req:
@ -468,12 +471,13 @@ def test_nfc_wps_er_handover(dev, apdev):
ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15) ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
if ev is None: if ev is None:
raise Exception("Association with the AP timed out") raise Exception("Association with the AP timed out")
check_wpa2_connection(dev[1], apdev[0], ssid) check_wpa2_connection(dev[1], apdev[0], hapd, ssid)
def test_nfc_wps_er_handover_pk_hash_mismatch_sta(dev, apdev): def test_nfc_wps_er_handover_pk_hash_mismatch_sta(dev, apdev):
"""WPS NFC connection handover with invalid pkhash from station to ER (negative)""" """WPS NFC connection handover with invalid pkhash from station to ER (negative)"""
ssid = "wps-nfc-er-handover-pkhash-sta" ssid = "wps-nfc-er-handover-pkhash-sta"
start_ap_er(dev[0], apdev[0], ssid) start_ap_er(dev[0], apdev[0], ssid)
hapd = hostapd.Hostapd(apdev[0]['ifname'])
logger.info("WPS provisioning step using connection handover") logger.info("WPS provisioning step using connection handover")
if "FAIL" in dev[1].request("SET wps_corrupt_pkhash 1"): if "FAIL" in dev[1].request("SET wps_corrupt_pkhash 1"):
raise Exception("Could not enable wps_corrupt_pkhash") raise Exception("Could not enable wps_corrupt_pkhash")
@ -501,6 +505,7 @@ def test_nfc_wps_er_handover_pk_hash_mismatch_er(dev, apdev):
"""WPS NFC connection handover with invalid pkhash from ER to station (negative)""" """WPS NFC connection handover with invalid pkhash from ER to station (negative)"""
ssid = "wps-nfc-er-handover-pkhash-er" ssid = "wps-nfc-er-handover-pkhash-er"
start_ap_er(dev[0], apdev[0], ssid) start_ap_er(dev[0], apdev[0], ssid)
hapd = hostapd.Hostapd(apdev[0]['ifname'])
logger.info("WPS provisioning step using connection handover") logger.info("WPS provisioning step using connection handover")
if "FAIL" in dev[0].request("SET wps_corrupt_pkhash 1"): if "FAIL" in dev[0].request("SET wps_corrupt_pkhash 1"):
raise Exception("Could not enable wps_corrupt_pkhash") raise Exception("Could not enable wps_corrupt_pkhash")

View file

@ -192,14 +192,14 @@ def test_autogo_following_bss(dev, apdev):
channels = { 3 : "2422", 5 : "2432", 9 : "2452" } channels = { 3 : "2422", 5 : "2432", 9 : "2452" }
for key in channels: for key in channels:
hostapd.add_ap(apdev[0]['ifname'], { "ssid" : 'ap-test', hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid" : 'ap-test',
"channel" : str(key) }) "channel" : str(key) })
dev[0].connect("ap-test", key_mgmt="NONE", dev[0].connect("ap-test", key_mgmt="NONE",
scan_freq=str(channels[key])) scan_freq=str(channels[key]))
res_go = autogo(dev[0]) res_go = autogo(dev[0])
if res_go['freq'] != channels[key]: if res_go['freq'] != channels[key]:
raise Exception("Group operation channel is not the same as on connected station interface") raise Exception("Group operation channel is not the same as on connected station interface")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
dev[0].remove_group(res_go['ifname']) dev[0].remove_group(res_go['ifname'])
def test_go_neg_with_bss_connected(dev, apdev): def test_go_neg_with_bss_connected(dev, apdev):
@ -207,7 +207,8 @@ def test_go_neg_with_bss_connected(dev, apdev):
dev[0].request("SET p2p_no_group_iface 0") dev[0].request("SET p2p_no_group_iface 0")
hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz', "channel": '5' }) hapd = hostapd.add_ap(apdev[0]['ifname'],
{ "ssid": 'bss-2.4ghz', "channel": '5' })
dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2432") dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2432")
#dev[0] as GO #dev[0] as GO
[i_res, r_res] = go_neg_pbc(i_dev=dev[0], i_intent=10, r_dev=dev[1], [i_res, r_res] = go_neg_pbc(i_dev=dev[0], i_intent=10, r_dev=dev[1],
@ -217,7 +218,7 @@ def test_go_neg_with_bss_connected(dev, apdev):
raise Exception("GO not selected according to go_intent") raise Exception("GO not selected according to go_intent")
if i_res['freq'] != "2432": if i_res['freq'] != "2432":
raise Exception("Group formed on a different frequency than BSS") raise Exception("Group formed on a different frequency than BSS")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
dev[0].remove_group(i_res['ifname']) dev[0].remove_group(i_res['ifname'])
if dev[0].get_mcc() > 1: if dev[0].get_mcc() > 1:
@ -232,7 +233,7 @@ def test_go_neg_with_bss_connected(dev, apdev):
raise Exception("GO not selected according to go_intent") raise Exception("GO not selected according to go_intent")
if i_res2['freq'] != "2432": if i_res2['freq'] != "2432":
raise Exception("Group formed on a different frequency than BSS") raise Exception("Group formed on a different frequency than BSS")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_autogo_with_bss_on_disallowed_chan(dev, apdev): def test_autogo_with_bss_on_disallowed_chan(dev, apdev):
"""P2P channel selection: Autonomous GO with BSS on a disallowed channel""" """P2P channel selection: Autonomous GO with BSS on a disallowed channel"""
@ -243,14 +244,14 @@ def test_autogo_with_bss_on_disallowed_chan(dev, apdev):
logger.info("Skipping test because driver does not support MCC") logger.info("Skipping test because driver does not support MCC")
return "skip" return "skip"
try: try:
hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz', hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz',
"channel": '1' }) "channel": '1' })
dev[0].request("P2P_SET disallow_freq 2412") dev[0].request("P2P_SET disallow_freq 2412")
dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412") dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
res = autogo(dev[0]) res = autogo(dev[0])
if res['freq'] == "2412": if res['freq'] == "2412":
raise Exception("GO set on a disallowed channel") raise Exception("GO set on a disallowed channel")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
finally: finally:
dev[0].request("P2P_SET disallow_freq ") dev[0].request("P2P_SET disallow_freq ")
@ -263,7 +264,8 @@ def test_go_neg_with_bss_on_disallowed_chan(dev, apdev):
logger.info("Skipping test because driver does not support MCC") logger.info("Skipping test because driver does not support MCC")
return "skip" return "skip"
try: try:
hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz', "channel": '1' }) hapd = hostapd.add_ap(apdev[0]['ifname'],
{ "ssid": 'bss-2.4ghz', "channel": '1' })
dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412") dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
dev[0].request("P2P_SET disallow_freq 2412") dev[0].request("P2P_SET disallow_freq 2412")
@ -275,7 +277,7 @@ def test_go_neg_with_bss_on_disallowed_chan(dev, apdev):
raise Exception("GO not selected according to go_intent") raise Exception("GO not selected according to go_intent")
if i_res['freq'] == "2412": if i_res['freq'] == "2412":
raise Exception("Group formed on a disallowed channel") raise Exception("Group formed on a disallowed channel")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
dev[0].remove_group(i_res['ifname']) dev[0].remove_group(i_res['ifname'])
#dev[0] as client #dev[0] as client
@ -286,7 +288,7 @@ def test_go_neg_with_bss_on_disallowed_chan(dev, apdev):
raise Exception("GO not selected according to go_intent") raise Exception("GO not selected according to go_intent")
if i_res2['freq'] == "2412": if i_res2['freq'] == "2412":
raise Exception("Group formed on a disallowed channel") raise Exception("Group formed on a disallowed channel")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
finally: finally:
dev[0].request("P2P_SET disallow_freq ") dev[0].request("P2P_SET disallow_freq ")
@ -298,12 +300,13 @@ def test_autogo_force_diff_channel(dev, apdev):
dev[0].request("SET p2p_no_group_iface 0") dev[0].request("SET p2p_no_group_iface 0")
hostapd.add_ap(apdev[0]['ifname'], {"ssid" : 'ap-test', "channel" : '1'}) hapd = hostapd.add_ap(apdev[0]['ifname'],
{"ssid" : 'ap-test', "channel" : '1'})
dev[0].connect("ap-test", key_mgmt = "NONE", scan_freq = "2412") dev[0].connect("ap-test", key_mgmt = "NONE", scan_freq = "2412")
channels = { 2 : 2417, 5 : 2432, 9 : 2452 } channels = { 2 : 2417, 5 : 2432, 9 : 2452 }
for key in channels: for key in channels:
res_go = autogo(dev[0], channels[key]) res_go = autogo(dev[0], channels[key])
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
if int(res_go['freq']) == 2412: if int(res_go['freq']) == 2412:
raise Exception("Group operation channel is: 2412 excepted: " + res_go['freq']) raise Exception("Group operation channel is: 2412 excepted: " + res_go['freq'])
dev[0].remove_group(res_go['ifname']) dev[0].remove_group(res_go['ifname'])
@ -316,7 +319,8 @@ def test_go_neg_forced_freq_diff_than_bss_freq(dev, apdev):
dev[0].request("SET p2p_no_group_iface 0") dev[0].request("SET p2p_no_group_iface 0")
hostapd.add_ap(apdev[0]['ifname'], { "country_code": 'US', hapd = hostapd.add_ap(apdev[0]['ifname'],
{ "country_code": 'US',
"ssid": 'bss-5ghz', "hw_mode": 'a', "ssid": 'bss-5ghz', "hw_mode": 'a',
"channel": '40' }) "channel": '40' })
dev[0].connect("bss-5ghz", key_mgmt="NONE", scan_freq="5200") dev[0].connect("bss-5ghz", key_mgmt="NONE", scan_freq="5200")
@ -330,7 +334,7 @@ def test_go_neg_forced_freq_diff_than_bss_freq(dev, apdev):
raise Exception("P2P group formed on unexpected frequency: " + i_res['freq']) raise Exception("P2P group formed on unexpected frequency: " + i_res['freq'])
if r_res['role'] != "GO": if r_res['role'] != "GO":
raise Exception("GO not selected according to go_intent") raise Exception("GO not selected according to go_intent")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
dev[0].remove_group(r_res['ifname']) dev[0].remove_group(r_res['ifname'])
# GO and peer force the same freq, different than BSS freq, dev[0] to # GO and peer force the same freq, different than BSS freq, dev[0] to
@ -342,7 +346,7 @@ def test_go_neg_forced_freq_diff_than_bss_freq(dev, apdev):
raise Exception("P2P group formed on unexpected frequency: " + i_res2['freq']) raise Exception("P2P group formed on unexpected frequency: " + i_res2['freq'])
if r_res2['role'] != "client": if r_res2['role'] != "client":
raise Exception("GO not selected according to go_intent") raise Exception("GO not selected according to go_intent")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_go_pref_chan_bss_on_diff_chan(dev, apdev): def test_go_pref_chan_bss_on_diff_chan(dev, apdev):
"""P2P channel selection: Station on different channel than GO configured pref channel""" """P2P channel selection: Station on different channel than GO configured pref channel"""
@ -350,14 +354,14 @@ def test_go_pref_chan_bss_on_diff_chan(dev, apdev):
dev[0].request("SET p2p_no_group_iface 0") dev[0].request("SET p2p_no_group_iface 0")
try: try:
hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz', hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz',
"channel": '1' }) "channel": '1' })
dev[0].request("SET p2p_pref_chan 81:2") dev[0].request("SET p2p_pref_chan 81:2")
dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412") dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
res = autogo(dev[0]) res = autogo(dev[0])
if res['freq'] != "2412": if res['freq'] != "2412":
raise Exception("GO channel did not follow BSS") raise Exception("GO channel did not follow BSS")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
finally: finally:
dev[0].request("SET p2p_pref_chan ") dev[0].request("SET p2p_pref_chan ")
@ -370,7 +374,7 @@ def test_go_pref_chan_bss_on_disallowed_chan(dev, apdev):
dev[0].request("SET p2p_no_group_iface 0") dev[0].request("SET p2p_no_group_iface 0")
try: try:
hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz', hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz',
"channel": '1' }) "channel": '1' })
dev[0].request("P2P_SET disallow_freq 2412") dev[0].request("P2P_SET disallow_freq 2412")
dev[0].request("SET p2p_pref_chan 81:2") dev[0].request("SET p2p_pref_chan 81:2")
@ -378,7 +382,7 @@ def test_go_pref_chan_bss_on_disallowed_chan(dev, apdev):
res2 = autogo(dev[0]) res2 = autogo(dev[0])
if res2['freq'] != "2417": if res2['freq'] != "2417":
raise Exception("GO channel did not follow pref_chan configuration") raise Exception("GO channel did not follow pref_chan configuration")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
finally: finally:
dev[0].request("P2P_SET disallow_freq ") dev[0].request("P2P_SET disallow_freq ")
dev[0].request("SET p2p_pref_chan ") dev[0].request("SET p2p_pref_chan ")

View file

@ -22,9 +22,9 @@ from test_p2p_persistent import invite
def test_concurrent_autogo(dev, apdev): def test_concurrent_autogo(dev, apdev):
"""Concurrent P2P autonomous GO""" """Concurrent P2P autonomous GO"""
logger.info("Connect to an infrastructure AP") logger.info("Connect to an infrastructure AP")
hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" }) hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412") dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
logger.info("Start a P2P group while associated to an AP") logger.info("Start a P2P group while associated to an AP")
dev[0].request("SET p2p_no_group_iface 0") dev[0].request("SET p2p_no_group_iface 0")
@ -38,14 +38,14 @@ def test_concurrent_autogo(dev, apdev):
dev[1].wait_go_ending_session() dev[1].wait_go_ending_session()
logger.info("Confirm AP connection after P2P group removal") logger.info("Confirm AP connection after P2P group removal")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_concurrent_p2pcli(dev, apdev): def test_concurrent_p2pcli(dev, apdev):
"""Concurrent P2P client join""" """Concurrent P2P client join"""
logger.info("Connect to an infrastructure AP") logger.info("Connect to an infrastructure AP")
hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" }) hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412") dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
logger.info("Join a P2P group while associated to an AP") logger.info("Join a P2P group while associated to an AP")
dev[0].request("SET p2p_no_group_iface 0") dev[0].request("SET p2p_no_group_iface 0")
@ -59,14 +59,14 @@ def test_concurrent_p2pcli(dev, apdev):
dev[0].wait_go_ending_session() dev[0].wait_go_ending_session()
logger.info("Confirm AP connection after P2P group removal") logger.info("Confirm AP connection after P2P group removal")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_concurrent_grpform_go(dev, apdev): def test_concurrent_grpform_go(dev, apdev):
"""Concurrent P2P group formation to become GO""" """Concurrent P2P group formation to become GO"""
logger.info("Connect to an infrastructure AP") logger.info("Connect to an infrastructure AP")
hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" }) hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412") dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
logger.info("Form a P2P group while associated to an AP") logger.info("Form a P2P group while associated to an AP")
dev[0].request("SET p2p_no_group_iface 0") dev[0].request("SET p2p_no_group_iface 0")
@ -77,14 +77,14 @@ def test_concurrent_grpform_go(dev, apdev):
remove_group(dev[0], dev[1]) remove_group(dev[0], dev[1])
logger.info("Confirm AP connection after P2P group removal") logger.info("Confirm AP connection after P2P group removal")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_concurrent_grpform_cli(dev, apdev): def test_concurrent_grpform_cli(dev, apdev):
"""Concurrent P2P group formation to become P2P Client""" """Concurrent P2P group formation to become P2P Client"""
logger.info("Connect to an infrastructure AP") logger.info("Connect to an infrastructure AP")
hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" }) hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412") dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
logger.info("Form a P2P group while associated to an AP") logger.info("Form a P2P group while associated to an AP")
dev[0].request("SET p2p_no_group_iface 0") dev[0].request("SET p2p_no_group_iface 0")
@ -95,12 +95,12 @@ def test_concurrent_grpform_cli(dev, apdev):
remove_group(dev[0], dev[1]) remove_group(dev[0], dev[1])
logger.info("Confirm AP connection after P2P group removal") logger.info("Confirm AP connection after P2P group removal")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_concurrent_grpform_while_connecting(dev, apdev): def test_concurrent_grpform_while_connecting(dev, apdev):
"""Concurrent P2P group formation while connecting to an AP""" """Concurrent P2P group formation while connecting to an AP"""
logger.info("Start connection to an infrastructure AP") logger.info("Start connection to an infrastructure AP")
hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" }) hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False) dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False)
logger.info("Form a P2P group while connecting to an AP") logger.info("Form a P2P group while connecting to an AP")
@ -112,12 +112,12 @@ def test_concurrent_grpform_while_connecting(dev, apdev):
remove_group(dev[0], dev[1]) remove_group(dev[0], dev[1])
logger.info("Confirm AP connection after P2P group removal") logger.info("Confirm AP connection after P2P group removal")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_concurrent_grpform_while_connecting2(dev, apdev): def test_concurrent_grpform_while_connecting2(dev, apdev):
"""Concurrent P2P group formation while connecting to an AP (2)""" """Concurrent P2P group formation while connecting to an AP (2)"""
logger.info("Start connection to an infrastructure AP") logger.info("Start connection to an infrastructure AP")
hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" }) hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False) dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False)
dev[1].request("BSS_FLUSH 0") dev[1].request("BSS_FLUSH 0")
dev[1].scan(freq="2412", only_new=True) dev[1].scan(freq="2412", only_new=True)
@ -132,12 +132,12 @@ def test_concurrent_grpform_while_connecting2(dev, apdev):
logger.info("Confirm AP connection after P2P group removal") logger.info("Confirm AP connection after P2P group removal")
dev[0].wait_completed() dev[0].wait_completed()
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_concurrent_grpform_while_connecting3(dev, apdev): def test_concurrent_grpform_while_connecting3(dev, apdev):
"""Concurrent P2P group formation while connecting to an AP (3)""" """Concurrent P2P group formation while connecting to an AP (3)"""
logger.info("Start connection to an infrastructure AP") logger.info("Start connection to an infrastructure AP")
hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" }) hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False) dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False)
logger.info("Form a P2P group while connecting to an AP") logger.info("Form a P2P group while connecting to an AP")
@ -150,7 +150,7 @@ def test_concurrent_grpform_while_connecting3(dev, apdev):
logger.info("Confirm AP connection after P2P group removal") logger.info("Confirm AP connection after P2P group removal")
dev[0].wait_completed() dev[0].wait_completed()
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
def test_concurrent_persistent_group(dev, apdev): def test_concurrent_persistent_group(dev, apdev):
"""Concurrent P2P persistent group""" """Concurrent P2P persistent group"""

View file

@ -46,7 +46,7 @@ def test_rfkill_open(dev, apdev):
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10) ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
if ev is None: if ev is None:
raise Exception("Missing connection event on rfkill unblock") raise Exception("Missing connection event on rfkill unblock")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
finally: finally:
subprocess.call(['sudo', 'rfkill', 'unblock', id]) subprocess.call(['sudo', 'rfkill', 'unblock', id])
@ -73,7 +73,7 @@ def test_rfkill_wpa2_psk(dev, apdev):
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10) ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
if ev is None: if ev is None:
raise Exception("Missing connection event on rfkill unblock") raise Exception("Missing connection event on rfkill unblock")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
finally: finally:
subprocess.call(['sudo', 'rfkill', 'unblock', id]) subprocess.call(['sudo', 'rfkill', 'unblock', id])

View file

@ -90,13 +90,13 @@ def test_sta_ap_scan_2(dev, apdev):
def test_sta_dynamic_down_up(dev, apdev): def test_sta_dynamic_down_up(dev, apdev):
"""Dynamically added wpa_supplicant interface down/up""" """Dynamically added wpa_supplicant interface down/up"""
params = hostapd.wpa2_params(ssid="sta-dynamic", passphrase="12345678") params = hostapd.wpa2_params(ssid="sta-dynamic", passphrase="12345678")
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
logger.info("Create a dynamic wpa_supplicant interface and connect") logger.info("Create a dynamic wpa_supplicant interface and connect")
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add("wlan5") wpas.interface_add("wlan5")
wpas.connect("sta-dynamic", psk="12345678", scan_freq="2412") wpas.connect("sta-dynamic", psk="12345678", scan_freq="2412")
hwsim_utils.test_connectivity(wpas.ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(wpas, hapd)
subprocess.call(['sudo', 'ifconfig', wpas.ifname, 'down']) subprocess.call(['sudo', 'ifconfig', wpas.ifname, 'down'])
ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10) ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
if ev is None: if ev is None:
@ -107,7 +107,7 @@ def test_sta_dynamic_down_up(dev, apdev):
ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=15) ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
if ev is None: if ev is None:
raise Exception("Reconnection not reported") raise Exception("Reconnection not reported")
hwsim_utils.test_connectivity(wpas.ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(wpas, hapd)
def test_sta_dynamic_ext_mac_addr_change(dev, apdev): def test_sta_dynamic_ext_mac_addr_change(dev, apdev):
"""Dynamically added wpa_supplicant interface with external MAC address change""" """Dynamically added wpa_supplicant interface with external MAC address change"""
@ -118,7 +118,7 @@ def test_sta_dynamic_ext_mac_addr_change(dev, apdev):
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add("wlan5") wpas.interface_add("wlan5")
wpas.connect("sta-dynamic", psk="12345678", scan_freq="2412") wpas.connect("sta-dynamic", psk="12345678", scan_freq="2412")
hwsim_utils.test_connectivity(wpas.ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(wpas, hapd)
subprocess.call(['sudo', 'ifconfig', wpas.ifname, 'down']) subprocess.call(['sudo', 'ifconfig', wpas.ifname, 'down'])
ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10) ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
if ev is None: if ev is None:
@ -136,7 +136,7 @@ def test_sta_dynamic_ext_mac_addr_change(dev, apdev):
raise Exception("Reconnection not reported") raise Exception("Reconnection not reported")
if wpas.get_driver_status_field('addr') != new_addr: if wpas.get_driver_status_field('addr') != new_addr:
raise Exception("Address change not reported") raise Exception("Address change not reported")
hwsim_utils.test_connectivity(wpas.ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(wpas, hapd)
sta = hapd.get_sta(new_addr) sta = hapd.get_sta(new_addr)
if sta['addr'] != new_addr: if sta['addr'] != new_addr:
raise Exception("STA association with new address not found") raise Exception("STA association with new address not found")

View file

@ -9,25 +9,25 @@ import hwsim_utils
def test_wep_open_auth(dev, apdev): def test_wep_open_auth(dev, apdev):
"""WEP Open System authentication""" """WEP Open System authentication"""
hostapd.add_ap(apdev[0]['ifname'], hapd = hostapd.add_ap(apdev[0]['ifname'],
{ "ssid": "wep-open", { "ssid": "wep-open",
"wep_key0": '"hello"' }) "wep_key0": '"hello"' })
dev[0].connect("wep-open", key_mgmt="NONE", wep_key0='"hello"', dev[0].connect("wep-open", key_mgmt="NONE", wep_key0='"hello"',
scan_freq="2412") scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
if "[WEP]" not in dev[0].request("SCAN_RESULTS"): if "[WEP]" not in dev[0].request("SCAN_RESULTS"):
raise Exception("WEP flag not indicated in scan results") raise Exception("WEP flag not indicated in scan results")
def test_wep_shared_key_auth(dev, apdev): def test_wep_shared_key_auth(dev, apdev):
"""WEP Shared Key authentication""" """WEP Shared Key authentication"""
hostapd.add_ap(apdev[0]['ifname'], hapd = hostapd.add_ap(apdev[0]['ifname'],
{ "ssid": "wep-shared-key", { "ssid": "wep-shared-key",
"wep_key0": '"hello12345678"', "wep_key0": '"hello12345678"',
"auth_algs": "2" }) "auth_algs": "2" })
dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED", dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
wep_key0='"hello12345678"', wep_key0='"hello12345678"',
scan_freq="2412") scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(dev[0], hapd)
dev[1].connect("wep-shared-key", key_mgmt="NONE", auth_alg="OPEN SHARED", dev[1].connect("wep-shared-key", key_mgmt="NONE", auth_alg="OPEN SHARED",
wep_key0='"hello12345678"', wep_key0='"hello12345678"',
scan_freq="2412") scan_freq="2412")

View file

@ -22,7 +22,7 @@ def REMOVED_test_wext_open(dev, apdev):
return "skip" return "skip"
params = { "ssid": "wext-open" } params = { "ssid": "wext-open" }
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
try: try:
@ -32,7 +32,7 @@ def REMOVED_test_wext_open(dev, apdev):
return "skip" return "skip"
wpas.connect("wext-open", key_mgmt="NONE") wpas.connect("wext-open", key_mgmt="NONE")
hwsim_utils.test_connectivity(wpas.ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(wpas, hapd)
def test_wext_wpa2_psk(dev, apdev): def test_wext_wpa2_psk(dev, apdev):
"""WEXT driver interface with WPA2-PSK""" """WEXT driver interface with WPA2-PSK"""
@ -41,7 +41,7 @@ def test_wext_wpa2_psk(dev, apdev):
return "skip" return "skip"
params = hostapd.wpa2_params(ssid="wext-wpa2-psk", passphrase="12345678") params = hostapd.wpa2_params(ssid="wext-wpa2-psk", passphrase="12345678")
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
try: try:
@ -51,4 +51,4 @@ def test_wext_wpa2_psk(dev, apdev):
return "skip" return "skip"
wpas.connect("wext-wpa2-psk", psk="12345678") wpas.connect("wext-wpa2-psk", psk="12345678")
hwsim_utils.test_connectivity(wpas.ifname, apdev[0]['ifname']) hwsim_utils.test_connectivity(wpas, hapd)

View file

@ -28,8 +28,8 @@ def test_wpas_ap_open(dev):
dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412") dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")
dev[2].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412") dev[2].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, dev[1].ifname) hwsim_utils.test_connectivity(dev[0], dev[1])
hwsim_utils.test_connectivity(dev[1].ifname, dev[2].ifname) hwsim_utils.test_connectivity(dev[1], dev[2])
addr1 = dev[1].p2p_interface_addr() addr1 = dev[1].p2p_interface_addr()
addr2 = dev[2].p2p_interface_addr() addr2 = dev[2].p2p_interface_addr()
@ -84,7 +84,7 @@ def test_wpas_ap_wep(dev):
dev[1].connect("wpas-ap-wep", key_mgmt="NONE", wep_key0='"hello"', dev[1].connect("wpas-ap-wep", key_mgmt="NONE", wep_key0='"hello"',
scan_freq="2412") scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, dev[1].ifname) hwsim_utils.test_connectivity(dev[0], dev[1])
dev[1].request("DISCONNECT") dev[1].request("DISCONNECT")
def test_wpas_ap_no_ssid(dev): def test_wpas_ap_no_ssid(dev):
@ -158,7 +158,7 @@ def test_wpas_ap_wps(dev):
ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
if ev is None: if ev is None:
raise Exception("WPS PBC operation timed out") raise Exception("WPS PBC operation timed out")
hwsim_utils.test_connectivity(dev[0].ifname, dev[1].ifname) hwsim_utils.test_connectivity(dev[0], dev[1])
logger.info("Test AP PIN to learn configuration") logger.info("Test AP PIN to learn configuration")
pin = dev[0].request("WPS_AP_PIN random") pin = dev[0].request("WPS_AP_PIN random")
@ -167,7 +167,7 @@ def test_wpas_ap_wps(dev):
if pin not in dev[0].request("WPS_AP_PIN get"): if pin not in dev[0].request("WPS_AP_PIN get"):
raise Exception("Could not fetch current AP PIN") raise Exception("Could not fetch current AP PIN")
dev[2].wps_reg(bssid, pin) dev[2].wps_reg(bssid, pin)
hwsim_utils.test_connectivity(dev[1].ifname, dev[2].ifname) hwsim_utils.test_connectivity(dev[1], dev[2])
dev[1].request("REMOVE_NETWORK all") dev[1].request("REMOVE_NETWORK all")
dev[2].request("REMOVE_NETWORK all") dev[2].request("REMOVE_NETWORK all")