tests: Verify Interworking Probe Request filtering

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2013-12-25 18:55:08 +02:00
parent ae98e1f5b2
commit 715bf904ff
3 changed files with 97 additions and 0 deletions

View file

@ -14,6 +14,7 @@ import os.path
import subprocess import subprocess
import hostapd import hostapd
from wlantest import Wlantest
def hs20_ap_params(): def hs20_ap_params():
params = hostapd.wpa2_params(ssid="test-hs20") params = hostapd.wpa2_params(ssid="test-hs20")
@ -122,6 +123,87 @@ def interworking_connect(dev, bssid, method):
if ev is None: if ev is None:
raise Exception("Connection timed out") 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): def test_ap_hs20_select(dev, apdev):
"""Hotspot 2.0 network selection""" """Hotspot 2.0 network selection"""
bssid = apdev[0]['bssid'] bssid = apdev[0]['bssid']

View file

@ -49,6 +49,19 @@ class Wlantest:
raise Exception("Could not get BSS info from wlantest for " + bssid) raise Exception("Could not get BSS info from wlantest for " + bssid)
return res 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): def info_sta(self, field, bssid, addr):
res = subprocess.check_output([self.wlantest_cli, "info_sta", res = subprocess.check_output([self.wlantest_cli, "info_sta",
field, bssid, addr]) field, bssid, addr])

View file

@ -57,6 +57,8 @@ class WpaSupplicant:
logger.info("FLUSH to " + self.ifname + " failed: " + res) logger.info("FLUSH to " + self.ifname + " failed: " + res)
self.request("SET ignore_old_scan_res 0") self.request("SET ignore_old_scan_res 0")
self.request("SET external_sim 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_add_cli_chan 0")
self.request("SET p2p_no_go_freq ") self.request("SET p2p_no_go_freq ")
self.request("SET p2p_pref_chan ") self.request("SET p2p_pref_chan ")