diff --git a/tests/hwsim/test_gas.py b/tests/hwsim/test_gas.py index 2ac610f04..6e731637c 100644 --- a/tests/hwsim/test_gas.py +++ b/tests/hwsim/test_gas.py @@ -1465,3 +1465,56 @@ def test_gas_failures(dev, apdev): wpas.request("SET preassoc_mac_addr 0") if ev is None: raise Exception("No random MAC address error seen") + +def test_gas_anqp_venue_url(dev, apdev): + """GAS/ANQP and Venue URL""" + venue_group = 1 + venue_type = 13 + venue_info = struct.pack('BB', venue_group, venue_type) + lang1 = "eng" + name1= "Example venue" + lang2 = "fin" + name2 = "Esimerkkipaikka" + venue1 = struct.pack('B', len(lang1 + name1)) + lang1 + name1 + venue2 = struct.pack('B', len(lang2 + name2)) + lang2 + name2 + venue_name = binascii.hexlify(venue_info + venue1 + venue2) + + url1 = "http://example.com/venue" + url2 = "https://example.org/venue-info/" + duple1 = struct.pack('BB', 1 + len(url1), 0) + duple2 = struct.pack('BB', 1 + len(url2), 1) + venue_url = binascii.hexlify(duple1 + duple2) + + params = { "ssid": "gas/anqp", + "interworking": "1", + "venue_group": str(venue_group), + "venue_type": str(venue_type), + "venue_name": [ lang1 + ":" + name1, lang2 + ":" + name2 ], + "anqp_elem": [ "277:" + venue_url ] } + hapd = hostapd.add_ap(apdev[0], params) + bssid = apdev[0]['bssid'] + + dev[0].scan_for_bss(bssid, freq="2412", force_scan=True) + if "OK" not in dev[0].request("ANQP_GET " + bssid + " 257,258,277"): + raise Exception("ANQP_GET command failed") + + ev = dev[0].wait_event(["GAS-QUERY-DONE"], timeout=10) + if ev is None: + raise Exception("GAS query timed out") + + bss = dev[0].get_bss(bssid) + + if 'anqp_venue_name' not in bss: + raise Exception("Venue Name ANQP-element not seen") + if bss['anqp_venue_name'] != venue_name: + raise Exception("Unexpected Venue Name ANQP-element value: " + bss['anqp_venue_name']) + if 'anqp[277]' not in bss: + raise Exception("Venue URL ANQP-element not seen") + if bss['anqp[277]'] != venue_url: + raise Exception("Unexpected Venue URL ANQP-element value: " + bss['anqp[277]']) + + if 'anqp_capability_list' not in bss: + raise Exception("Capability List ANQP-element not seen") + ids = struct.pack('