mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-02-21 03:23:04 -05:00
tests: Increase DFS coverage even without hwsim support
This allows some more of the hostapd DFS operations to be executed even before mac80211_hwsim supports CAC. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
986eedcdc4
commit
4f62bfefa4
@ -24,12 +24,8 @@ def wait_dfs_event(hapd, event, timeout):
|
|||||||
raise Exception("Unexpected DFS event")
|
raise Exception("Unexpected DFS event")
|
||||||
return ev
|
return ev
|
||||||
|
|
||||||
def start_dfs_ap(ap):
|
def start_dfs_ap(ap, allow_failure=False):
|
||||||
ifname = ap['ifname']
|
ifname = ap['ifname']
|
||||||
logger.info("Reset regulatory setup")
|
|
||||||
subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
|
|
||||||
time.sleep(1)
|
|
||||||
subprocess.call(['sudo', 'iw', 'reg', 'set', 'FI'])
|
|
||||||
logger.info("Starting AP " + ifname + " on DFS channel")
|
logger.info("Starting AP " + ifname + " on DFS channel")
|
||||||
hapd_global = hostapd.HostapdGlobal()
|
hapd_global = hostapd.HostapdGlobal()
|
||||||
hapd_global.remove(ifname)
|
hapd_global.remove(ifname)
|
||||||
@ -52,15 +48,21 @@ def start_dfs_ap(ap):
|
|||||||
|
|
||||||
state = hapd.get_status_field("state")
|
state = hapd.get_status_field("state")
|
||||||
if state != "DFS":
|
if state != "DFS":
|
||||||
raise Exception("Unexpected interface state")
|
if allow_failure:
|
||||||
|
logger.info("Interface state not DFS: " + state)
|
||||||
|
return None
|
||||||
|
raise Exception("Unexpected interface state: " + state)
|
||||||
|
|
||||||
return hapd
|
return hapd
|
||||||
|
|
||||||
def test_dfs(dev, apdev):
|
def test_dfs(dev, apdev):
|
||||||
"""DFS CAC functionality on clear channel"""
|
"""DFS CAC functionality on clear channel"""
|
||||||
|
try:
|
||||||
|
hapd = start_dfs_ap(apdev[0], allow_failure=True)
|
||||||
|
if hapd is None:
|
||||||
if not os.path.exists("dfs"):
|
if not os.path.exists("dfs"):
|
||||||
return "skip"
|
return "skip"
|
||||||
hapd = start_dfs_ap(apdev[0])
|
raise Exception("Failed to start DFS AP")
|
||||||
|
|
||||||
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
|
||||||
if "success=1" not in ev:
|
if "success=1" not in ev:
|
||||||
@ -82,11 +84,15 @@ def test_dfs(dev, apdev):
|
|||||||
|
|
||||||
#TODO: need to fix hwsim for DFS?!
|
#TODO: need to fix hwsim for DFS?!
|
||||||
#dev[0].connect("dfs", key_mgmt="NONE")
|
#dev[0].connect("dfs", key_mgmt="NONE")
|
||||||
|
finally:
|
||||||
|
subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
|
||||||
|
|
||||||
def test_dfs_radar(dev, apdev):
|
def test_dfs_radar(dev, apdev):
|
||||||
"""DFS CAC functionality with radar detected"""
|
"""DFS CAC functionality with radar detected"""
|
||||||
if not os.path.exists("dfs"):
|
if not os.path.exists("dfs"):
|
||||||
return "skip"
|
return "skip"
|
||||||
|
|
||||||
|
try:
|
||||||
hapd = start_dfs_ap(apdev[0])
|
hapd = start_dfs_ap(apdev[0])
|
||||||
|
|
||||||
hapd.request("RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1")
|
hapd.request("RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1")
|
||||||
@ -126,3 +132,13 @@ def test_dfs_radar(dev, apdev):
|
|||||||
|
|
||||||
#TODO: need to fix hwsim for DFS?!
|
#TODO: need to fix hwsim for DFS?!
|
||||||
#dev[0].connect("dfs", key_mgmt="NONE")
|
#dev[0].connect("dfs", key_mgmt="NONE")
|
||||||
|
finally:
|
||||||
|
subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
|
||||||
|
|
||||||
|
def test_dfs_radar_on_non_dfs_channel(dev, apdev):
|
||||||
|
"""DFS radar detection test code on non-DFS channel"""
|
||||||
|
params = { "ssid": "radar" }
|
||||||
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
||||||
|
|
||||||
|
hapd.request("RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1")
|
||||||
|
hapd.request("RADAR DETECTED freq=2412 ht_enabled=1 chan_width=1")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user