From 715bf904ffb6a5c8ec7d8e6002af0dd51da9ad68 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 25 Dec 2013 18:55:08 +0200 Subject: [PATCH] tests: Verify Interworking Probe Request filtering Signed-hostap: Jouni Malinen --- tests/hwsim/test_ap_hs20.py | 82 ++++++++++++++++++++++++++++++++++++ tests/hwsim/wlantest.py | 13 ++++++ tests/hwsim/wpasupplicant.py | 2 + 3 files changed, 97 insertions(+) diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index 796b4f35f..06985d8c3 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -14,6 +14,7 @@ import os.path import subprocess import hostapd +from wlantest import Wlantest def hs20_ap_params(): params = hostapd.wpa2_params(ssid="test-hs20") @@ -122,6 +123,87 @@ def interworking_connect(dev, bssid, method): if ev is None: raise Exception("Connection timed out") +def check_probe_resp(wt, bssid_unexpected, bssid_expected): + if bssid_unexpected: + count = wt.get_bss_counter("probe_response", bssid_unexpected) + if count > 0: + raise Exception("Unexpected Probe Response frame from AP") + + if bssid_expected: + count = wt.get_bss_counter("probe_response", bssid_expected) + if count == 0: + raise Exception("No Probe Response frame from AP") + +def test_ap_interworking_scan_filtering(dev, apdev): + """Interworking scan filtering with HESSID and access network type""" + bssid = apdev[0]['bssid'] + params = hs20_ap_params() + ssid = "test-hs20-ap1" + params['ssid'] = ssid + params['hessid'] = bssid + hostapd.add_ap(apdev[0]['ifname'], params) + + bssid2 = apdev[1]['bssid'] + params = hs20_ap_params() + ssid2 = "test-hs20-ap2" + params['ssid'] = ssid2 + params['hessid'] = bssid2 + params['access_network_type'] = "1" + hostapd.add_ap(apdev[1]['ifname'], params) + + dev[0].request("SET ignore_old_scan_res 1") + dev[0].hs20_enable() + + wt = Wlantest() + wt.flush() + + logger.info("Check probe request filtering based on HESSID") + + dev[0].request("SET hessid " + bssid2) + dev[0].scan() + check_probe_resp(wt, bssid, bssid2) + + logger.info("Check probe request filtering based on access network type") + + wt.clear_bss_counters(bssid) + wt.clear_bss_counters(bssid2) + dev[0].request("SET hessid 00:00:00:00:00:00") + dev[0].request("SET access_network_type 14") + dev[0].scan() + check_probe_resp(wt, bssid2, bssid) + + wt.clear_bss_counters(bssid) + wt.clear_bss_counters(bssid2) + dev[0].request("SET hessid 00:00:00:00:00:00") + dev[0].request("SET access_network_type 1") + dev[0].scan() + check_probe_resp(wt, bssid, bssid2) + + logger.info("Check probe request filtering based on HESSID and ANT") + + wt.clear_bss_counters(bssid) + wt.clear_bss_counters(bssid2) + dev[0].request("SET hessid " + bssid) + dev[0].request("SET access_network_type 14") + dev[0].scan() + check_probe_resp(wt, bssid2, bssid) + + wt.clear_bss_counters(bssid) + wt.clear_bss_counters(bssid2) + dev[0].request("SET hessid " + bssid2) + dev[0].request("SET access_network_type 14") + dev[0].scan() + check_probe_resp(wt, bssid, None) + check_probe_resp(wt, bssid2, None) + + wt.clear_bss_counters(bssid) + wt.clear_bss_counters(bssid2) + dev[0].request("SET hessid " + bssid) + dev[0].request("SET access_network_type 1") + dev[0].scan() + check_probe_resp(wt, bssid, None) + check_probe_resp(wt, bssid2, None) + def test_ap_hs20_select(dev, apdev): """Hotspot 2.0 network selection""" bssid = apdev[0]['bssid'] diff --git a/tests/hwsim/wlantest.py b/tests/hwsim/wlantest.py index 57853fb41..a934edff6 100644 --- a/tests/hwsim/wlantest.py +++ b/tests/hwsim/wlantest.py @@ -49,6 +49,19 @@ class Wlantest: raise Exception("Could not get BSS info from wlantest for " + bssid) return res + def get_bss_counter(self, field, bssid): + res = subprocess.check_output([self.wlantest_cli, "get_bss_counter", + field, bssid]); + if "FAIL" in res: + raise Exception("wlantest_cli command failed") + return int(res) + + def clear_bss_counters(self, bssid): + res = subprocess.check_output([self.wlantest_cli, "clear_bss_counters", + bssid]); + if "FAIL" in res: + raise Exception("wlantest_cli command failed") + def info_sta(self, field, bssid, addr): res = subprocess.check_output([self.wlantest_cli, "info_sta", field, bssid, addr]) diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index b344b36f8..af9127786 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -57,6 +57,8 @@ class WpaSupplicant: logger.info("FLUSH to " + self.ifname + " failed: " + res) self.request("SET ignore_old_scan_res 0") self.request("SET external_sim 0") + self.request("SET hessid 00:00:00:00:00:00") + self.request("SET access_network_type 15") self.request("SET p2p_add_cli_chan 0") self.request("SET p2p_no_go_freq ") self.request("SET p2p_pref_chan ")