from wlantest import Wlantest
from datetime import datetime
+def clear_regdom_state(dev, hapd, hapd2):
+ for i in range(0, 3):
+ ev = dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
+ if ev is None or "init=COUNTRY_IE" in ev:
+ break
+ dev[0].request("DISCONNECT")
+ dev[0].request("ABORT_SCAN")
+ dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
+ if hapd:
+ hapd.request("DISABLE")
+ if hapd2:
+ hapd2.request("DISABLE")
+ dev[0].dump_monitor()
+ subprocess.call(['iw', 'reg', 'set', '00'])
+ dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
+ dev[0].flush_scan_cache()
+
@remote_compatible
def test_wnm_bss_transition_mgmt(dev, apdev):
"""WNM BSS Transition Management"""
if ev is not None:
raise Exception("Unexpected reassociation")
finally:
- dev[0].request("DISCONNECT")
- if hapd:
- hapd.request("DISABLE")
- if hapd2:
- hapd2.request("DISABLE")
- subprocess.call(['iw', 'reg', 'set', '00'])
- dev[0].flush_scan_cache()
+ clear_regdom_state(dev, hapd, hapd2)
def test_wnm_bss_tm_errors(dev, apdev):
"""WNM BSS Transition Management errors"""
raise Exception("Unexpected scan started")
dev[0].dump_monitor()
finally:
- dev[0].request("DISCONNECT")
- if hapd:
- hapd.request("DISABLE")
- if hapd2:
- hapd2.request("DISABLE")
- subprocess.call(['iw', 'reg', 'set', '00'])
- dev[0].flush_scan_cache()
+ clear_regdom_state(dev, hapd, hapd2)
def test_wnm_bss_tm_scan_needed(dev, apdev):
"""WNM BSS Transition Management and scan needed"""
raise Exception("Unexpected scan started")
dev[0].dump_monitor()
finally:
- dev[0].request("DISCONNECT")
- if hapd:
- hapd.request("DISABLE")
- if hapd2:
- hapd2.request("DISABLE")
- subprocess.call(['iw', 'reg', 'set', '00'])
- dev[0].flush_scan_cache()
+ clear_regdom_state(dev, hapd, hapd2)
def test_wnm_bss_tm_scan_needed_e4(dev, apdev):
"""WNM BSS Transition Management and scan needed (Table E-4)"""
break
dev[0].dump_monitor()
finally:
- dev[0].request("REMOVE_NETWORK all")
- dev[0].request("ABORT_SCAN")
- if hapd:
- hapd.request("DISABLE")
- if hapd2:
- hapd2.request("DISABLE")
- subprocess.call(['iw', 'reg', 'set', '00'])
- dev[0].flush_scan_cache()
+ clear_regdom_state(dev, hapd, hapd2)
def start_wnm_tm(ap, country, dev, country3=None):
params = { "ssid": "test-wnm",
if apdev[1]['bssid'] not in ev:
raise Exception("Unexpected reassociation target: " + ev)
finally:
- dev[0].request("DISCONNECT")
- if hapd:
- hapd.request("DISABLE")
- if hapd2:
- hapd2.request("DISABLE")
- subprocess.call(['iw', 'reg', 'set', '00'])
- dev[0].flush_scan_cache()
+ clear_regdom_state(dev, hapd, hapd2)
def test_wnm_action_proto(dev, apdev):
"""WNM Action protocol testing"""