From f68caa35e3d3c289c69894dacce81aef839ff036 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 26 Mar 2018 16:11:54 +0300 Subject: [PATCH] tests: GAS/ANQP and Venue URL (hostapd venue_url) Test the hostapd venue_url configuration parameter. In addition, fix the previous defined gas_anqp_venue_url test case to use correct encoding of the Venue URL ANQP-element payload (URLs were missing and Venue Number was off-by-one). Signed-off-by: Jouni Malinen --- tests/hwsim/test_gas.py | 58 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/tests/hwsim/test_gas.py b/tests/hwsim/test_gas.py index 99673c924..416399b9a 100644 --- a/tests/hwsim/test_gas.py +++ b/tests/hwsim/test_gas.py @@ -1608,8 +1608,8 @@ def test_gas_anqp_venue_url(dev, apdev): 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) + duple1 = struct.pack('BB', 1 + len(url1), 1) + url1 + duple2 = struct.pack('BB', 1 + len(url2), 2) + url2 venue_url = binascii.hexlify(duple1 + duple2) params = { "ssid": "gas/anqp", @@ -1646,6 +1646,60 @@ def test_gas_anqp_venue_url(dev, apdev): if not bss['anqp_capability_list'].startswith(binascii.hexlify(ids)): raise Exception("Unexpected Capability List ANQP-element value: " + bss['anqp_capability_list']) +def test_gas_anqp_venue_url2(dev, apdev): + """GAS/ANQP and Venue URL (hostapd 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), 1) + url1 + duple2 = struct.pack('BB', 1 + len(url2), 2) + url2 + 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 ], + "venue_url": [ "1:" + url1, "2:" + url2 ] } + 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: + print 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('