diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index 4a17b65cc..b7ac10024 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -58,7 +58,7 @@ def interworking_select(dev, bssid, type=None, no_match=False): return if "INTERWORKING-NO-MATCH" in ev: raise Exception("Matching network not found") - if bssid not in ev: + if bssid and bssid not in ev: raise Exception("Unexpected BSSID in match") if type and "type=" + type not in ev: raise Exception("Network type not recognized correctly") @@ -134,6 +134,49 @@ def check_probe_resp(wt, bssid_unexpected, bssid_expected): if count == 0: raise Exception("No Probe Response frame from AP") +def test_ap_anqp_sharing(dev, apdev): + """ANQP sharing within ESS and explicit unshare""" + bssid = apdev[0]['bssid'] + params = hs20_ap_params() + params['hessid'] = bssid + hostapd.add_ap(apdev[0]['ifname'], params) + + bssid2 = apdev[1]['bssid'] + params = hs20_ap_params() + params['hessid'] = bssid + params['nai_realm'] = [ "0,example.com,13[5:6],21[2:4][5:7]" ] + hostapd.add_ap(apdev[1]['ifname'], params) + + dev[0].request("SET ignore_old_scan_res 1") + dev[0].hs20_enable() + id = dev[0].add_cred_values({ 'realm': "example.com", 'username': "test", + 'password': "secret", + 'domain': "example.com" }) + logger.info("Normal network selection with shared ANQP results") + interworking_select(dev[0], None, "home") + dev[0].dump_monitor() + + res1 = dev[0].get_bss(bssid) + res2 = dev[0].get_bss(bssid2) + if res1['anqp_nai_realm'] != res2['anqp_nai_realm']: + raise Exception("ANQP results were not shared between BSSes") + + logger.info("Explicit ANQP request to unshare ANQP results") + dev[0].request("ANQP_GET " + bssid + " 263") + ev = dev[0].wait_event(["RX-ANQP"], timeout=5) + if ev is None: + raise Exception("ANQP operation timed out") + + dev[0].request("ANQP_GET " + bssid2 + " 263") + ev = dev[0].wait_event(["RX-ANQP"], timeout=5) + if ev is None: + raise Exception("ANQP operation timed out") + + res1 = dev[0].get_bss(bssid) + res2 = dev[0].get_bss(bssid2) + if res1['anqp_nai_realm'] == res2['anqp_nai_realm']: + raise Exception("ANQP results were not unshared") + def test_ap_interworking_scan_filtering(dev, apdev): """Interworking scan filtering with HESSID and access network type""" bssid = apdev[0]['bssid'] diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index 04ea58602..90dd698f2 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -639,3 +639,12 @@ class WpaSupplicant: if "FAIL" in res: return None return res.split(' ') + + def get_bss(self, bssid): + res = self.request("BSS " + bssid) + lines = res.splitlines() + vals = dict() + for l in lines: + [name,value] = l.split('=', 1) + vals[name] = value + return vals