alen,attr = struct.unpack("@HH", msg[0:4])
if alen < 4:
raise Exception("Too short nl80211 attribute")
- alen -= 4;
+ alen -= 4
msg = msg[4:]
if alen > len(msg):
raise Exception("nl80211 attribute underflow")
peer = inv.get_peer(addr)
cmd = "P2P_INVITE persistent=" + peer['persistent'] + " peer=" + addr
if extra:
- cmd = cmd + " " + extra;
+ cmd = cmd + " " + extra
inv.global_request(cmd)
def check_result(go, cli):
cmd = ' '.join(command)
logger.debug("thread run: " + cmd)
try:
- status = 0;
+ status = 0
buf = subprocess.check_output(command, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
status = e.returncode
def local_execute(self, command):
logger.debug("execute: " + str(command))
try:
- status = 0;
+ status = 0
buf = subprocess.check_output(command, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
status = e.returncode
passphrase="12345678"
params = ft_params1(ssid=ssid, passphrase=passphrase)
- params["ieee80211w"] = "2";
+ params["ieee80211w"] = "2"
hapd0 = hostapd.add_ap(apdev[0], params)
params = ft_params2(ssid=ssid, passphrase=passphrase)
- params["ieee80211w"] = "2";
+ params["ieee80211w"] = "2"
hapd1 = hostapd.add_ap(apdev[1], params)
run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase)
passphrase="12345678"
params = ft_params1(ssid=ssid, passphrase=passphrase)
- params["ieee80211w"] = "2";
+ params["ieee80211w"] = "2"
hapd0 = hostapd.add_ap(apdev[0], params)
params = ft_params2(ssid=ssid, passphrase=passphrase)
- params["ieee80211w"] = "2";
+ params["ieee80211w"] = "2"
hapd1 = hostapd.add_ap(apdev[1], params)
run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True)
passphrase="12345678"
params = ft_params1(ssid=ssid, passphrase=passphrase)
- params["ieee80211w"] = "2";
+ params["ieee80211w"] = "2"
hapd0 = hostapd.add_ap(apdev[0], params)
params = ft_params2_incorrect_rrb_key(ssid=ssid, passphrase=passphrase)
- params["ieee80211w"] = "2";
+ params["ieee80211w"] = "2"
hapd1 = hostapd.add_ap(apdev[1], params)
run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True,
passphrase="12345678"
params = ft_params1(ssid=ssid, passphrase=passphrase)
- params["ieee80211w"] = "2";
+ params["ieee80211w"] = "2"
hapd0 = hostapd.add_ap(apdev[0], params)
params = ft_params2_r0kh_mismatch(ssid=ssid, passphrase=passphrase)
- params["ieee80211w"] = "2";
+ params["ieee80211w"] = "2"
hapd1 = hostapd.add_ap(apdev[1], params)
run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True,
passphrase="12345678"
params = ft_params1(ssid=ssid, passphrase=passphrase)
- params["ieee80211w"] = "1";
+ params["ieee80211w"] = "1"
# This is the RSN element used normally by hostapd
params['own_ie_override'] = '30140100000fac040100000fac040100000fac048c00' + '3603a1b201'
hapd = hostapd.add_ap(apdev[0], params)
ev = dev.wait_event(["INTERWORKING-AP", "INTERWORKING-NO-MATCH"],
timeout=15)
if ev is None:
- raise Exception("Network selection timed out");
+ raise Exception("Network selection timed out")
if no_match:
if "INTERWORKING-NO-MATCH" not in ev:
raise Exception("Unexpected network match")
ev = dev.wait_event(["INTERWORKING-AP", "INTERWORKING-NO-MATCH"],
timeout=15)
if ev is None:
- raise Exception("Network selection timed out");
+ raise Exception("Network selection timed out")
if "INTERWORKING-NO-MATCH" in ev:
raise Exception("Matching network not found")
if bssid and bssid not in ev:
'domain': "no.match.example.com" })
interworking_select(dev[0], bssid, "roaming", freq="2412")
- dev[0].set_cred_quoted(id, "realm", "no.match.example.com");
+ dev[0].set_cred_quoted(id, "realm", "no.match.example.com")
interworking_select(dev[0], bssid, no_match=True, freq="2412")
res = dev[0].request("SCAN_RESULTS")
dev.request("INTERWORKING_SELECT freq=2412")
ev = dev.wait_event(["INTERWORKING-AP"])
if ev is None:
- raise Exception("Network selection timed out");
+ raise Exception("Network selection timed out")
if "type=" + type not in ev:
raise Exception("Unexpected network type")
if missing and "conn_capab_missing=1" not in ev:
for i in range(0, 2):
ev = dev[0].wait_event(["INTERWORKING-AP"])
if ev is None:
- raise Exception("Network selection timed out");
+ raise Exception("Network selection timed out")
if bssid in ev and "conn_capab_missing=1" not in ev:
raise Exception("Missing protocol connection capability not reported")
if bssid2 in ev and "conn_capab_missing=1" in ev:
dev.request("INTERWORKING_SELECT freq=2412")
ev = dev.wait_event(["INTERWORKING-AP"])
if ev is None:
- raise Exception("Network selection timed out");
+ raise Exception("Network selection timed out")
logger.debug("BSS entries:\n" + dev.request("BSS RANGE=ALL"))
if "type=" + type not in ev:
raise Exception("Unexpected network type")
ev = dev[0].wait_event(["INTERWORKING-AP", "INTERWORKING-NO-MATCH"],
timeout=15)
if ev is None:
- raise Exception("Network selection timed out");
+ raise Exception("Network selection timed out")
dev[0].dump_monitor()
if "OK" not in dev[0].request("FETCH_OSU"):
"""WPA2-PSK AP with PMF required"""
ssid = "test-pmf-required"
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
- params["wpa_key_mgmt"] = "WPA-PSK-SHA256";
- params["ieee80211w"] = "2";
+ params["wpa_key_mgmt"] = "WPA-PSK-SHA256"
+ params["ieee80211w"] = "2"
hapd = hostapd.add_ap(apdev[0], params)
Wlantest.setup(hapd)
wt = Wlantest()
"""WPA2-PSK AP with PMF optional"""
ssid = "test-pmf-optional"
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
- params["wpa_key_mgmt"] = "WPA-PSK";
- params["ieee80211w"] = "1";
+ params["wpa_key_mgmt"] = "WPA-PSK"
+ params["ieee80211w"] = "1"
hapd = hostapd.add_ap(apdev[0], params)
Wlantest.setup(hapd)
wt = Wlantest()
"""WPA2-PSK AP with PMF optional (2 AKMs)"""
ssid = "test-pmf-optional-2akm"
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
- params["wpa_key_mgmt"] = "WPA-PSK WPA-PSK-SHA256";
- params["ieee80211w"] = "1";
+ params["wpa_key_mgmt"] = "WPA-PSK WPA-PSK-SHA256"
+ params["ieee80211w"] = "1"
hapd = hostapd.add_ap(apdev[0], params)
Wlantest.setup(hapd)
wt = Wlantest()
"""WPA2-PSK AP with PMF association comeback"""
ssid = "assoc-comeback"
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
- params["wpa_key_mgmt"] = "WPA-PSK-SHA256";
- params["ieee80211w"] = "2";
+ params["wpa_key_mgmt"] = "WPA-PSK-SHA256"
+ params["ieee80211w"] = "2"
hapd = hostapd.add_ap(apdev[0], params)
Wlantest.setup(hapd)
wt = Wlantest()
"""WPA2-PSK AP with PMF association comeback (using DROP_SA)"""
ssid = "assoc-comeback"
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
- params["wpa_key_mgmt"] = "WPA-PSK";
- params["ieee80211w"] = "1";
+ params["wpa_key_mgmt"] = "WPA-PSK"
+ params["ieee80211w"] = "1"
hapd = hostapd.add_ap(apdev[0], params)
Wlantest.setup(hapd)
wt = Wlantest()
"""WPA2-EAP AP with PMF required"""
ssid = "test-pmf-required-eap"
params = hostapd.wpa2_eap_params(ssid=ssid)
- params["wpa_key_mgmt"] = "WPA-EAP-SHA256";
- params["ieee80211w"] = "2";
+ params["wpa_key_mgmt"] = "WPA-EAP-SHA256"
+ params["ieee80211w"] = "2"
hapd = hostapd.add_ap(apdev[0], params)
key_mgmt = hapd.get_config()['key_mgmt']
if key_mgmt.split(' ')[0] != "WPA-EAP-SHA256":
def test_ap_pmf_optional_eap(dev, apdev):
"""WPA2EAP AP with PMF optional"""
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
- params["ieee80211w"] = "1";
+ params["ieee80211w"] = "1"
hapd = hostapd.add_ap(apdev[0], params)
dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="TTLS",
identity="pap user", anonymous_identity="ttls",
"""WPA2-PSK AP with PMF required with SHA1 AKM"""
ssid = "test-pmf-required-sha1"
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
- params["wpa_key_mgmt"] = "WPA-PSK";
- params["ieee80211w"] = "2";
+ params["wpa_key_mgmt"] = "WPA-PSK"
+ params["ieee80211w"] = "2"
hapd = hostapd.add_ap(apdev[0], params)
Wlantest.setup(hapd)
wt = Wlantest()
def _test_ap_pmf_toggle(dev, apdev):
ssid = "test-pmf-optional"
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
- params["wpa_key_mgmt"] = "WPA-PSK";
- params["ieee80211w"] = "1";
+ params["wpa_key_mgmt"] = "WPA-PSK"
+ params["ieee80211w"] = "1"
params["assoc_sa_query_max_timeout"] = "1"
params["assoc_sa_query_retry_timeout"] = "1"
hapd = hostapd.add_ap(apdev[0], params)
"""WPA2-PSK AP with PMF required and PMF disabled on STA"""
ssid = "test-pmf-required"
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
- params["wpa_key_mgmt"] = "WPA-PSK-SHA256";
- params["ieee80211w"] = "2";
+ params["wpa_key_mgmt"] = "WPA-PSK-SHA256"
+ params["ieee80211w"] = "2"
hapd = hostapd.add_ap(apdev[0], params)
# Disable PMF on the station and try to connect
if pos < 0:
break
logger.info("Found %s at %d" % (keyname, pos))
- context = 128;
+ context = 128
start = pos - context if pos > context else 0
before = binascii.hexlify(buf[start:pos])
context += len(key)
ev = dev[0].wait_event(["CTRL-EVENT-SSID-REENABLED"], 3)
if not ev:
- raise Exception("CTRL-EVENT-SSID-REENABLED not seen");
+ raise Exception("CTRL-EVENT-SSID-REENABLED not seen")
dev[0].wait_connected(timeout=5)
hwsim_utils.test_connectivity(dev[0], hapd0)
def tdls_check_ap(sta0, sta1, bssid, addr0, addr1):
wt = Wlantest()
- wt.tdls_clear(bssid, addr0, addr1);
+ wt.tdls_clear(bssid, addr0, addr1)
hwsim_utils.test_connectivity_sta(sta0, sta1)
[dl,inv_dl,ap,inv_ap] = wlantest_tdls_packet_counters(bssid, addr0, addr1)
if dl > 0:
addr0 = sta0.p2p_interface_addr()
addr1 = sta1.p2p_interface_addr()
wt = Wlantest()
- wt.tdls_clear(bssid, addr0, addr1);
- wt.tdls_clear(bssid, addr1, addr0);
+ wt.tdls_clear(bssid, addr0, addr1)
+ wt.tdls_clear(bssid, addr1, addr0)
sta0.tdls_setup(addr1)
time.sleep(1)
if expect_fail:
if reverse:
addr1 = sta0.p2p_interface_addr()
addr0 = sta1.p2p_interface_addr()
- conf = wt.get_tdls_counter("setup_conf_ok", bssid, addr0, addr1);
+ conf = wt.get_tdls_counter("setup_conf_ok", bssid, addr0, addr1)
if conf == 0:
raise Exception("No TDLS Setup Confirm (success) seen")
tdls_check_dl(sta0, sta1, bssid, addr0, addr1)
sta0.tdls_teardown(addr1)
time.sleep(1)
wt = Wlantest()
- teardown = wt.get_tdls_counter("teardown", bssid, addr0, addr1);
+ teardown = wt.get_tdls_counter("teardown", bssid, addr0, addr1)
if teardown == 0:
raise Exception("No TDLS Setup Teardown seen")
tdls_check_ap(sta0, sta1, bssid, addr0, addr1)
"""AP VLAN with WPA2-PSK"""
params = hostapd.wpa2_params(ssid="test-vlan",
passphrase="12345678")
- params['dynamic_vlan'] = "1";
- params['accept_mac_file'] = "hostapd.accept";
+ params['dynamic_vlan'] = "1"
+ params['accept_mac_file'] = "hostapd.accept"
hapd = hostapd.add_ap(apdev[0], params)
dev[0].connect("test-vlan", psk="12345678", scan_freq="2412")
def test_ap_vlan_wpa2_radius(dev, apdev):
"""AP VLAN with WPA2-Enterprise and RADIUS attributes"""
params = hostapd.wpa2_eap_params(ssid="test-vlan")
- params['dynamic_vlan'] = "1";
+ params['dynamic_vlan'] = "1"
hapd = hostapd.add_ap(apdev[0], params)
dev[0].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
def test_ap_vlan_wpa2_radius_2(dev, apdev):
"""AP VLAN with WPA2-Enterprise and RADIUS EGRESS_VLANID attributes"""
params = hostapd.wpa2_eap_params(ssid="test-vlan")
- params['dynamic_vlan'] = "1";
+ params['dynamic_vlan'] = "1"
hapd = hostapd.add_ap(apdev[0], params)
dev[0].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
authserv = hostapd.add_ap(apdev[1], as_params)
params = hostapd.wpa2_eap_params(ssid="test-vlan")
- params['dynamic_vlan'] = "1";
+ params['dynamic_vlan'] = "1"
params['auth_server_port'] = "18128"
hapd = hostapd.add_ap(apdev[0], params)
def test_ap_vlan_wpa2_radius_required(dev, apdev):
"""AP VLAN with WPA2-Enterprise and RADIUS attributes required"""
params = hostapd.wpa2_eap_params(ssid="test-vlan")
- params['dynamic_vlan'] = "2";
+ params['dynamic_vlan'] = "2"
hostapd.add_ap(apdev[0], params)
dev[0].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
# inject decrypted frames into pcap
params = hostapd.wpa2_params(ssid="test-vlan",
passphrase="12345678x")
- params['dynamic_vlan'] = "1";
+ params['dynamic_vlan'] = "1"
params['vlan_file'] = 'hostapd.wlan3.vlan'
- params['accept_mac_file'] = "hostapd.accept";
+ params['accept_mac_file'] = "hostapd.accept"
hapd = hostapd.add_ap(apdev[0], params)
# inject some traffic
"""AP VLAN with WPA2-PSK connect, disconnect, connect"""
params = hostapd.wpa2_params(ssid="test-vlan",
passphrase="12345678")
- params['dynamic_vlan'] = "1";
- params['accept_mac_file'] = "hostapd.accept";
+ params['dynamic_vlan'] = "1"
+ params['accept_mac_file'] = "hostapd.accept"
hapd = hostapd.add_ap(apdev[0], params)
logger.info("connect sta")
ssdp_send_msearch("upnp:rootdevice")
ssdp_send_msearch("uuid:" + ap_uuid)
ssdp_send_msearch("urn:schemas-wifialliance-org:service:WFAWLANConfig:1")
- ssdp_send_msearch("urn:schemas-wifialliance-org:device:WFADevice:1");
+ ssdp_send_msearch("urn:schemas-wifialliance-org:device:WFADevice:1")
msg = '\r\n'.join([
'M-SEARCH * HTTP/1.1',
dbus_interface=dbus.PROPERTIES_IFACE)
if if_obj.Get(WPAS_DBUS_IFACE_WPS, "ProcessCredentials",
dbus_interface=dbus.PROPERTIES_IFACE) != True:
- raise Exception("Unexpected Get(ProcessCredentials) result after Set");
+ raise Exception("Unexpected Get(ProcessCredentials) result after Set")
if_obj.Set(WPAS_DBUS_IFACE_WPS, "ProcessCredentials",
dbus.Boolean(0),
dbus_interface=dbus.PROPERTIES_IFACE)
if if_obj.Get(WPAS_DBUS_IFACE_WPS, "ProcessCredentials",
dbus_interface=dbus.PROPERTIES_IFACE) != False:
- raise Exception("Unexpected Get(ProcessCredentials) result after Set");
+ raise Exception("Unexpected Get(ProcessCredentials) result after Set")
self.dbus_sets_done = True
return False
if not dev1.discover_peer(addr0):
raise Exception("Peer not found")
dev1.global_request("P2P_CONNECT " + addr0 + " 12345670 display go_intent=0")
- ev = dev1.wait_global_event(["P2P-GROUP-STARTED"], timeout=15);
+ ev = dev1.wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
if ev is None:
raise Exception("Group formation timed out")
self.sta_group_ev = ev
if ev is None:
raise Exception("Timeout while waiting for GO Neg Request")
dev1.global_request("P2P_CONNECT " + addr0 + " 12345670 display go_intent=15")
- ev = dev1.wait_global_event(["P2P-GROUP-STARTED"], timeout=15);
+ ev = dev1.wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
if ev is None:
raise Exception("Group formation timed out")
self.sta_group_ev = ev
if ev is None:
raise Exception("Timeout while waiting for GO Neg Request")
dev1.global_request("P2P_CONNECT " + addr0 + " 12345670 display go_intent=15")
- ev = dev1.wait_global_event(["P2P-GROUP-STARTED"], timeout=15);
+ ev = dev1.wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
if ev is None:
raise Exception("Group formation timed out")
self.sta_group_ev = ev
if ev is None:
raise Exception("Timeout while waiting for GO Neg Request")
dev1.global_request("P2P_CONNECT " + addr0 + " 12345670 display go_intent=15")
- ev = dev1.wait_global_event(["P2P-GROUP-STARTED"], timeout=15);
+ ev = dev1.wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
if ev is None:
raise Exception("Group formation timed out")
self.sta_group_ev = ev
dev2 = WpaSupplicant('wlan2', '/tmp/wpas-wlan2')
dev2.scan_for_bss(bssid, freq=2412)
dev2.global_request("P2P_CONNECT " + bssid + " 12345670 join freq=2412")
- ev = dev2.wait_global_event(["P2P-GROUP-STARTED"], timeout=15);
+ ev = dev2.wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
if ev is None:
raise Exception("Group join timed out")
self.dev2_group_ev = ev
if ev is None:
raise Exception("DFS-RADAR-DETECTED event not reported")
if "freq=5260" not in ev:
- raise Exception("Incorrect frequency in radar detected event: " + ev);
+ raise Exception("Incorrect frequency in radar detected event: " + ev)
ev = hapd.wait_event(["DFS-NEW-CHANNEL"], timeout=70)
if ev is None:
raise Exception("DFS-NEW-CHANNEL event not reported")
if "freq=5260" in ev:
- raise Exception("Channel did not change after radar was detected");
+ raise Exception("Channel did not change after radar was detected")
ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=70)
if ev is None:
raise Exception("AP-CSA-FINISHED event not reported")
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)
hwsim_utils.test_connectivity(dev[0], hapd)
finally:
self.nof_aps -= 1
else:
self.nof_stas -= 1
- config_file = self.get_cfg_pathname(cfg);
+ config_file = self.get_cfg_pathname(cfg)
if os.path.exists(config_file):
os.remove(config_file)
def test_fst_disconnect_fst_sta(dev, apdev, test_params):
"""FST disconnect FST STA"""
ap1, ap2, fst_sta1, fst_sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
- external_sta_connected = False;
+ external_sta_connected = False
try:
vals = fst_sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
fst_sta1.connect(ap1, key_mgmt="NONE",
ssid = "test-wnm-mbo"
passphrase = "12345678"
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
- params["wpa_key_mgmt"] = "WPA-PSK-SHA256";
- params["ieee80211w"] = "2";
+ params["wpa_key_mgmt"] = "WPA-PSK-SHA256"
+ params["ieee80211w"] = "2"
params['mbo'] = '1'
hapd = hostapd.add_ap(apdev[0], params)
bssid = apdev[0]['bssid']
dev[1].tdls_setup(addr2)
time.sleep(1)
hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
- conf = wt.get_tdls_counter("setup_conf_ok", bssid, addr1, addr2);
+ conf = wt.get_tdls_counter("setup_conf_ok", bssid, addr1, addr2)
if conf == 0:
raise Exception("No TDLS Setup Confirm (success) seen")
- dl = wt.get_tdls_counter("valid_direct_link", bssid, addr1, addr2);
+ dl = wt.get_tdls_counter("valid_direct_link", bssid, addr1, addr2)
if dl == 0:
raise Exception("No valid frames through direct link")
- wt.tdls_clear(bssid, addr1, addr2);
+ wt.tdls_clear(bssid, addr1, addr2)
dev[1].tdls_teardown(addr2)
time.sleep(1)
- teardown = wt.get_tdls_counter("teardown", bssid, addr1, addr2);
+ teardown = wt.get_tdls_counter("teardown", bssid, addr1, addr2)
if teardown == 0:
raise Exception("No TDLS Setup Teardown seen")
- wt.tdls_clear(bssid, addr1, addr2);
+ wt.tdls_clear(bssid, addr1, addr2)
hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
- ap_path = wt.get_tdls_counter("valid_ap_path", bssid, addr1, addr2);
+ ap_path = wt.get_tdls_counter("valid_ap_path", bssid, addr1, addr2)
if ap_path == 0:
raise Exception("No valid frames via AP path")
- direct_link = wt.get_tdls_counter("valid_direct_link", bssid, addr1, addr2);
+ direct_link = wt.get_tdls_counter("valid_direct_link", bssid, addr1, addr2)
if direct_link > 0:
raise Exception("Unexpected frames through direct link")
idirect_link = wt.get_tdls_counter("invalid_direct_link", bssid, addr1,
- addr2);
+ addr2)
if idirect_link > 0:
raise Exception("Unexpected frames through direct link (invalid)")
dev[2].remove_group()
if dev[0].get_mcc() > 1:
logger.info("Skip as-client case due to MCC being enabled")
- return;
+ return
#dev[0] as client
[i_res2, r_res2] = go_neg_pbc(i_dev=dev[0], i_intent=1, r_dev=dev[1],
hapd = hostapd.add_ap(apdev[0], { "ssid" : 'ap-test',
"channel" : '11' })
- logger.info('Connecting client to to an AP on channel 11');
+ logger.info('Connecting client to to an AP on channel 11')
dev[0].connect("ap-test", key_mgmt="NONE",
scan_freq="2462")
hapd = hostapd.add_ap(apdev[0], { "ssid" : 'ap-test',
"channel" : '11' })
- logger.info('Connecting client to to an AP on channel 11');
+ logger.info('Connecting client to to an AP on channel 11')
dev[0].connect("ap-test", key_mgmt="NONE",
scan_freq="2462")
addr1 = dev[1].p2p_dev_addr()
try:
- dev[1].p2p_listen();
+ dev[1].p2p_listen()
if not wpas.discover_peer(addr1, social=True):
raise Exception("Peer " + addr1 + " not found")
wpas.p2p_stop_find()
pin = dev[1].wps_read_pin()
dev[1].global_request("P2P_CONNECT " + addr0 + " " + pin + " join auth")
- dev[1].p2p_listen();
+ dev[1].p2p_listen()
# Force P2P GO channel switch on successful invitation signaling
wpas.group_request("SET p2p_go_csa_on_inv 1")
msg['payload'] += ie_p2p(attrs)
mgmt_tx(dev[1], "MGMT_TX {} {} freq={} wait_time=200 no_cck=1 action={}".format(addr0, addr0, rx_msg['freq'], binascii.hexlify(msg['payload'])))
- ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=15);
+ ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
if ev is None:
raise Exception("Group was not started")
mgmt_tx(dev[1], "MGMT_TX {} {} freq={} wait_time=200 no_cck=1 action={}".format(addr0, addr0, rx_msg['freq'], binascii.hexlify(msg['payload'])))
ev = dev[0].wait_global_event(["P2P-INVITATION-RESULT"], timeout=15)
if ev is None:
- raise Exception("Timeout on invitation result");
+ raise Exception("Timeout on invitation result")
if "status=7" not in ev:
raise Exception("Unexpected invitation result: " + ev)
- logger.info("Any channel allowed, only preference provided in invitation");
+ logger.info("Any channel allowed, only preference provided in invitation")
invite(dev[0], dev[1], extra="pref=2422")
rx_msg = dev[1].mgmt_rx()
if rx_msg is None:
mgmt_tx(dev[1], "MGMT_TX {} {} freq={} wait_time=200 no_cck=1 action={}".format(addr0, addr0, rx_msg['freq'], binascii.hexlify(msg['payload'])))
ev = dev[0].wait_global_event(["P2P-INVITATION-RESULT"], timeout=15)
if ev is None:
- raise Exception("Timeout on invitation result");
+ raise Exception("Timeout on invitation result")
if "status=0" not in ev:
raise Exception("Unexpected invitation result: " + ev)
- ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=15);
+ ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
if ev is None:
raise Exception("Group was not started on dev0")
- ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=15);
+ ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
if ev is None:
raise Exception("Group was not started on dev1")
if "FAIL" in dev[1].request("SET ext_mgmt_frame_handling 1"):
raise Exception("Failed to enable external management frame handling")
- logger.info("Any channel allowed, only preference provided in invitation");
+ logger.info("Any channel allowed, only preference provided in invitation")
invite(dev[0], dev[1], extra="pref=2422")
rx_msg = dev[1].mgmt_rx()
if rx_msg is None:
ev = dev[0].wait_global_event(["P2P-INVITATION-RESULT"], timeout=10)
if ev is None:
- raise Exception("Timeout on invitation result");
+ raise Exception("Timeout on invitation result")
if "status=0" not in ev:
raise Exception("Unexpected invitation result: " + ev)
ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
ev = dev[0].wait_global_event(["P2P-GO-NEG-SUCCESS"], timeout=10)
if ev is None:
raise Exception("GO Neg did not succeed")
- ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=5);
+ ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=5)
if ev is None:
raise Exception("Group formation not succeed")
- ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=5);
+ ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=5)
if ev is None:
raise Exception("Group formation not succeed")
ev = dev[0].wait_global_event(["P2P-INVITATION-RECEIVED"], timeout=15)
if ev is None:
- raise Exception("No invitation request reported");
+ raise Exception("No invitation request reported")
if "persistent=" not in ev:
raise Exception("Invalid invitation type reported: " + ev)
ev2 = dev[1].wait_global_event(["P2P-INVITATION-RESULT"], timeout=15)
if ev2 is None:
- raise Exception("No invitation response reported");
+ raise Exception("No invitation response reported")
if "status=1" not in ev2:
raise Exception("Unexpected status: " + ev2)
dev[1].p2p_listen()
ev = dev[1].wait_global_event(["P2P-INVITATION-RECEIVED"], timeout=15)
if ev is None:
- raise Exception("No invitation request reported");
+ raise Exception("No invitation request reported")
if "persistent=" not in ev:
raise Exception("Invalid invitation type reported: " + ev)
ev2 = dev[0].wait_global_event(["P2P-INVITATION-RESULT"], timeout=15)
if ev2 is None:
- raise Exception("No invitation response reported");
+ raise Exception("No invitation response reported")
if "status=1" not in ev2:
raise Exception("Unexpected status: " + ev2)
dev[0].p2p_listen()
dev[1].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2442")
(grp_ifname0, grp_ifname1, ifnames) = p2ps_connect_p2ps_method(dev, keep_group=True, join_extra=" freq=2442")
- freq = dev[0].get_group_status_field('freq');
+ freq = dev[0].get_group_status_field('freq')
if freq != '2442':
raise Exception('Unexpected frequency for group 2442 != ' + freq)
tmpdev = [ dev[2], dev[1] ]
(grp_ifname0, grp_ifname1, ifnames) = p2ps_connect_p2ps_method(tmpdev, keep_group=True, join_extra=" freq=2437", flush=False)
- freq = dev[2].get_group_status_field('freq');
+ freq = dev[2].get_group_status_field('freq')
if freq != '2437':
raise Exception('Unexpected frequency for group 2437 != ' + freq)
ev1, ev0 = p2ps_provision(dev[1], dev[0], adv_id, auto_accept=False,
handler=disconnect_handler)
p2ps_connect_pd(dev[0], dev[1], ev0, ev1)
- freq = dev[0].get_group_status_field('freq');
+ freq = dev[0].get_group_status_field('freq')
if freq != '2457':
raise Exception('Unexpected frequency for group 2457 != ' + freq)
finally:
dev[1].connect("bss-channel-10", key_mgmt="NONE", scan_freq="2457")
(grp_ifname0, grp_ifname1, ifnames) = p2ps_connect_p2ps_method(dev, keep_group=True)
- freq = dev[0].get_group_status_field('freq');
+ freq = dev[0].get_group_status_field('freq')
if freq != '2422' and freq != '2457':
raise Exception('Unexpected frequency for group =' + freq)
handler=clear_disallow_handler)
p2ps_connect_pd(dev[0], dev[1], ev0, ev1)
- freq = dev[0].get_group_status_field('freq');
+ freq = dev[0].get_group_status_field('freq')
if freq != '2412':
raise Exception('Unexpected frequency for group 2412 != ' + freq)
finally:
handler=clear_disallow_handler)
p2ps_connect_pd(dev[0], dev[1], ev0, ev1)
- freq = dev[0].get_group_status_field('freq');
+ freq = dev[0].get_group_status_field('freq')
if freq != '2437':
raise Exception('Unexpected frequency for group 2437 != ' + freq)
finally:
tmpdev = [ dev[0], wpas ]
(grp_ifname0, grp_ifname1, ifnames) = p2ps_connect_p2ps_method(tmpdev, keep_group=True)
- freq = dev[0].get_group_status_field('freq');
+ freq = dev[0].get_group_status_field('freq')
if freq == '2437':
raise Exception('Unexpected frequency=2437')
finally:
handler=disconnect_handler, adv_role='2',
seeker_role='4')
p2ps_connect_pd(dev[0], dev[1], ev0, ev1)
- freq = dev[0].get_group_status_field('freq');
+ freq = dev[0].get_group_status_field('freq')
if freq != '2462':
raise Exception('Unexpected frequency for group 2462!=' + freq)
finally:
if ev is None:
raise Exception("Timeout while waiting radio work to start")
if "FAIL" not in dev[0].request("RADIO_WORK done 12345678"):
- raise Exception("Invalid RADIO_WORK done accepted");
+ raise Exception("Invalid RADIO_WORK done accepted")
if "FAIL" not in dev[0].request("RADIO_WORK foo"):
- raise Exception("Invalid RADIO_WORK accepted");
+ raise Exception("Invalid RADIO_WORK accepted")
dev[0].request("FLUSH")
items = dev[0].request("RADIO_WORK show")
if items != "":
if bss is None:
raise Exception("BSS entry for hidden AP not found")
if 'test-hidden' not in dev[0].request("SCAN_RESULTS"):
- raise Exception("Expected SSID not included in the scan results");
+ raise Exception("Expected SSID not included in the scan results")
hapd.disable()
dev[0].flush_scan_cache(freq=2432)
def check_suite_b_tls_lib(dev):
tls = dev[0].request("GET tls_library")
if not tls.startswith("OpenSSL"):
- raise HwsimSkip("TLS library not supported for Suite B: " + tls);
+ raise HwsimSkip("TLS library not supported for Suite B: " + tls)
supported = False
for ver in [ '1.0.2', '1.1.0' ]:
if "build=OpenSSL " + ver in tls and "run=OpenSSL " + ver in tls:
wpas = get_wext_interface()
params = hostapd.wpa2_params(ssid="wext-wpa2-psk", passphrase="12345678")
- params["wpa_key_mgmt"] = "WPA-PSK-SHA256";
- params["ieee80211w"] = "2";
+ params["wpa_key_mgmt"] = "WPA-PSK-SHA256"
+ params["ieee80211w"] = "2"
hapd = hostapd.add_ap(apdev[0], params)
wpas.connect("wext-wpa2-psk", psk="12345678", ieee80211w="1",
p.terminate()
p.wait()
# test that releasing hwsim works correctly
- _test_ap_open(dev, apdev);
+ _test_ap_open(dev, apdev)
finally:
os.unlink(fn)
def test_wnm_ess_disassoc_imminent_pmf(dev, apdev):
"""WNM ESS Disassociation Imminent"""
params = hostapd.wpa2_params("test-wnm-rsn", "12345678")
- params["wpa_key_mgmt"] = "WPA-PSK-SHA256";
- params["ieee80211w"] = "2";
+ params["wpa_key_mgmt"] = "WPA-PSK-SHA256"
+ params["ieee80211w"] = "2"
params["bss_transition"] = "1"
hapd = hostapd.add_ap(apdev[0], params)
def test_wnm_sleep_mode_rsn_pmf(dev, apdev):
"""WNM Sleep Mode - RSN with PMF"""
params = hostapd.wpa2_params("test-wnm-rsn", "12345678")
- params["wpa_key_mgmt"] = "WPA-PSK-SHA256";
- params["ieee80211w"] = "2";
+ params["wpa_key_mgmt"] = "WPA-PSK-SHA256"
+ params["ieee80211w"] = "2"
params["time_advertisement"] = "2"
params["time_zone"] = "EST5"
params["wnm_sleep_mode"] = "1"
raise Exception("Unexpected scan started")
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=0.5)
if ev is not None:
- raise Exception("Unexpected reassociation");
+ raise Exception("Unexpected reassociation")
finally:
dev[0].request("DISCONNECT")
if hapd:
raise Exception("Too short PSK accepted")
if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' psk "1234567890123456789012345678901234567890123456789012345678901234"'):
raise Exception("Too long PSK accepted")
- dev[0].set_network_quoted(id, "psk", "123456768");
- dev[0].set_network_quoted(id, "psk", "123456789012345678901234567890123456789012345678901234567890123");
+ dev[0].set_network_quoted(id, "psk", "123456768")
+ dev[0].set_network_quoted(id, "psk", "123456789012345678901234567890123456789012345678901234567890123")
if dev[0].get_network(id, "psk") != '*':
- raise Exception("Unexpected psk read result");
+ raise Exception("Unexpected psk read result")
if "FAIL" not in dev[0].request('SET_NETWORK ' + str(id) + ' eap UNKNOWN'):
raise Exception("Unknown EAP method accepted")
if field in params:
self.set_cred(id, field, params[field])
- return id;
+ return id
def select_network(self, id, freq=None):
if freq:
def p2p_go_neg_auth_result(self, timeout=1, expect_failure=False):
go_neg_res = None
ev = self.wait_global_event(["P2P-GO-NEG-SUCCESS",
- "P2P-GO-NEG-FAILURE"], timeout);
+ "P2P-GO-NEG-FAILURE"], timeout)
if ev is None:
if expect_failure:
return None
raise Exception("Group formation timed out")
if "P2P-GO-NEG-SUCCESS" in ev:
go_neg_res = ev
- ev = self.wait_global_event(["P2P-GROUP-STARTED"], timeout);
+ ev = self.wait_global_event(["P2P-GROUP-STARTED"], timeout)
if ev is None:
if expect_failure:
return None