mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-02-21 03:23:04 -05:00
tests: Wait for AP-ENABLED
It takes some time for hostapd to complete AP startup. In some cases, this could potentially result in station starting a scan before the AP is beaconing or ready to reply to probes. To avoid such race conditions, wait for AP-ENABLED before going ahead with the test cases. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
629edfef81
commit
629dbdd36a
@ -179,7 +179,7 @@ class Hostapd:
|
|||||||
hdr = struct.pack('<HH6B6B6BH', *t)
|
hdr = struct.pack('<HH6B6B6BH', *t)
|
||||||
self.request("MGMT_TX " + binascii.hexlify(hdr + msg['payload']))
|
self.request("MGMT_TX " + binascii.hexlify(hdr + msg['payload']))
|
||||||
|
|
||||||
def add_ap(ifname, params):
|
def add_ap(ifname, params, wait_enabled=True):
|
||||||
logger.info("Starting AP " + ifname)
|
logger.info("Starting AP " + ifname)
|
||||||
hapd_global = HostapdGlobal()
|
hapd_global = HostapdGlobal()
|
||||||
hapd_global.remove(ifname)
|
hapd_global.remove(ifname)
|
||||||
@ -203,6 +203,10 @@ def add_ap(ifname, params):
|
|||||||
else:
|
else:
|
||||||
hapd.set(f, v)
|
hapd.set(f, v)
|
||||||
hapd.enable()
|
hapd.enable()
|
||||||
|
if wait_enabled:
|
||||||
|
ev = hapd.wait_event(["AP-ENABLED"], timeout=30)
|
||||||
|
if ev is None:
|
||||||
|
raise Exception("AP startup timed out")
|
||||||
return hapd
|
return hapd
|
||||||
|
|
||||||
def add_bss(phy, ifname, confname, ignore_error=False):
|
def add_bss(phy, ifname, confname, ignore_error=False):
|
||||||
|
@ -42,7 +42,7 @@ def test_ap_acs(dev, apdev):
|
|||||||
"""Automatic channel selection"""
|
"""Automatic channel selection"""
|
||||||
params = hostapd.wpa2_params(ssid="test-acs", passphrase="12345678")
|
params = hostapd.wpa2_params(ssid="test-acs", passphrase="12345678")
|
||||||
params['channel'] = '0'
|
params['channel'] = '0'
|
||||||
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
|
||||||
wait_acs(hapd)
|
wait_acs(hapd)
|
||||||
|
|
||||||
freq = hapd.get_status_field("freq")
|
freq = hapd.get_status_field("freq")
|
||||||
|
@ -17,11 +17,11 @@ def test_ap_ht40_scan(dev, apdev):
|
|||||||
params = { "ssid": "test-ht40",
|
params = { "ssid": "test-ht40",
|
||||||
"channel": "5",
|
"channel": "5",
|
||||||
"ht_capab": "[HT40-]"}
|
"ht_capab": "[HT40-]"}
|
||||||
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
|
||||||
|
|
||||||
state = hapd.get_status_field("state")
|
state = hapd.get_status_field("state")
|
||||||
if state != "HT_SCAN":
|
if state != "HT_SCAN":
|
||||||
time.wait(0.1)
|
time.sleep(0.1)
|
||||||
state = hapd.get_status_field("state")
|
state = hapd.get_status_field("state")
|
||||||
if state != "HT_SCAN":
|
if state != "HT_SCAN":
|
||||||
raise Exception("Unexpected interface state - expected HT_SCAN")
|
raise Exception("Unexpected interface state - expected HT_SCAN")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user