From 13a17a77a4e2a571220c786a8ef7689ce4d635ec Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 26 Feb 2016 17:18:39 +0200 Subject: [PATCH] tests: WNM BSS Transition Management and scan behavior Signed-off-by: Jouni Malinen --- tests/hwsim/test_wnm.py | 116 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/tests/hwsim/test_wnm.py b/tests/hwsim/test_wnm.py index 59acc1e..24bb784 100644 --- a/tests/hwsim/test_wnm.py +++ b/tests/hwsim/test_wnm.py @@ -556,6 +556,122 @@ def test_wnm_bss_tm(dev, apdev): subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() +def test_wnm_bss_tm_scan_not_needed(dev, apdev): + """WNM BSS Transition Management and scan not needed""" + try: + hapd = None + hapd2 = None + params = { "ssid": "test-wnm", + "country_code": "FI", + "ieee80211d": "1", + "hw_mode": "g", + "channel": "1", + "bss_transition": "1" } + hapd = hostapd.add_ap(apdev[0]['ifname'], params) + + params = { "ssid": "test-wnm", + "country_code": "FI", + "ieee80211d": "1", + "hw_mode": "a", + "channel": "36", + "bss_transition": "1" } + hapd2 = hostapd.add_ap(apdev[1]['ifname'], params) + + dev[0].scan_for_bss(apdev[1]['bssid'], 5180) + + id = dev[0].connect("test-wnm", key_mgmt="NONE", + bssid=apdev[0]['bssid'], scan_freq="2412") + dev[0].set_network(id, "scan_freq", "") + dev[0].set_network(id, "bssid", "") + + addr = dev[0].own_addr() + dev[0].dump_monitor() + + logger.info("Preferred Candidate List (matching neighbor for another BSS) without Disassociation Imminent") + if "OK" not in hapd.request("BSS_TM_REQ " + addr + " pref=1 abridged=1 valid_int=255 neighbor=" + apdev[1]['bssid'] + ",0x0000,115,36,7,0301ff"): + raise Exception("BSS_TM_REQ command failed") + ev = hapd.wait_event(['BSS-TM-RESP'], timeout=10) + if ev is None: + raise Exception("No BSS Transition Management Response") + if "status_code=0" not in ev: + raise Exception("BSS transition request was not accepted: " + ev) + if "target_bssid=" + apdev[1]['bssid'] not in ev: + raise Exception("Unexpected target BSS: " + ev) + dev[0].wait_connected(timeout=15, error="No reassociation seen") + if apdev[1]['bssid'] not in ev: + raise Exception("Unexpected reassociation target: " + ev) + ev = dev[0].wait_event(["CTRL-EVENT-SCAN-STARTED"], timeout=0.1) + if ev is not None: + 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() + +def test_wnm_bss_tm_scan_needed(dev, apdev): + """WNM BSS Transition Management and scan needed""" + try: + hapd = None + hapd2 = None + params = { "ssid": "test-wnm", + "country_code": "FI", + "ieee80211d": "1", + "hw_mode": "g", + "channel": "1", + "bss_transition": "1" } + hapd = hostapd.add_ap(apdev[0]['ifname'], params) + + params = { "ssid": "test-wnm", + "country_code": "FI", + "ieee80211d": "1", + "hw_mode": "a", + "channel": "36", + "bss_transition": "1" } + hapd2 = hostapd.add_ap(apdev[1]['ifname'], params) + + dev[0].scan_for_bss(apdev[1]['bssid'], 5180) + + id = dev[0].connect("test-wnm", key_mgmt="NONE", + bssid=apdev[0]['bssid'], scan_freq="2412") + dev[0].set_network(id, "scan_freq", "") + dev[0].set_network(id, "bssid", "") + + addr = dev[0].own_addr() + dev[0].dump_monitor() + + logger.info("Wait 11 seconds for the last scan result to be too old, but still present in BSS table") + time.sleep(11) + logger.info("Preferred Candidate List (matching neighbor for another BSS) without Disassociation Imminent") + if "OK" not in hapd.request("BSS_TM_REQ " + addr + " pref=1 abridged=1 valid_int=255 neighbor=" + apdev[1]['bssid'] + ",0x0000,115,36,7,0301ff"): + raise Exception("BSS_TM_REQ command failed") + ev = hapd.wait_event(['BSS-TM-RESP'], timeout=10) + if ev is None: + raise Exception("No BSS Transition Management Response") + if "status_code=0" not in ev: + raise Exception("BSS transition request was not accepted: " + ev) + if "target_bssid=" + apdev[1]['bssid'] not in ev: + raise Exception("Unexpected target BSS: " + ev) + dev[0].wait_connected(timeout=15, error="No reassociation seen") + if apdev[1]['bssid'] not in ev: + raise Exception("Unexpected reassociation target: " + ev) + ev = dev[0].wait_event(["CTRL-EVENT-SCAN-STARTED"], timeout=0.1) + if ev is not None: + 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() + def start_wnm_tm(ap, country, dev): params = { "ssid": "test-wnm", "country_code": country, -- 2.1.4