tests: Scan using SSID List and Short SSID List elements

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2019-12-28 23:14:47 +02:00
parent 1c7f652f9e
commit d5c39e1488

View file

@ -1903,3 +1903,53 @@ def test_scan_only_one(dev, apdev):
entries = len(list(filter(lambda x: x.startswith('BSS '), lines))) entries = len(list(filter(lambda x: x.startswith('BSS '), lines)))
if entries != 1: if entries != 1:
raise Exception("expected to find 1 BSS entry, got %d" % entries) raise Exception("expected to find 1 BSS entry, got %d" % entries)
def test_scan_ssid_list(dev, apdev):
"""Scan using SSID List element"""
dev[0].flush_scan_cache()
ssid = "test-ssid-list"
hapd = hostapd.add_ap(apdev[0], {"ssid": ssid,
"ignore_broadcast_ssid": "1"})
bssid = apdev[0]['bssid']
found = False
try:
payload = struct.pack('BB', 0, len(ssid)) + ssid.encode()
ssid_list = struct.pack('BB', 84, len(payload)) + payload
cmd = "VENDOR_ELEM_ADD 14 " + binascii.hexlify(ssid_list).decode()
if "OK" not in dev[0].request(cmd):
raise Exception("VENDOR_ELEM_ADD failed")
for i in range(10):
check_scan(dev[0], "freq=2412 use_id=1")
if ssid in dev[0].request("SCAN_RESULTS"):
found = True
break
finally:
dev[0].request("VENDOR_ELEM_REMOVE 14 *")
if not found:
raise Exception("AP not found in scan results")
def test_scan_short_ssid_list(dev, apdev):
"""Scan using Short SSID List element"""
dev[0].flush_scan_cache()
ssid = "test-short-ssid-list"
hapd = hostapd.add_ap(apdev[0], {"ssid": ssid,
"ignore_broadcast_ssid": "1"})
bssid = apdev[0]['bssid']
found = False
try:
payload = struct.pack('<L', binascii.crc32(ssid.encode()))
ssid_list = struct.pack('BBB', 255, 1 + len(payload), 58) + payload
cmd = "VENDOR_ELEM_ADD 14 " + binascii.hexlify(ssid_list).decode()
if "OK" not in dev[0].request(cmd):
raise Exception("VENDOR_ELEM_ADD failed")
for i in range(10):
check_scan(dev[0], "freq=2412 use_id=1")
if ssid in dev[0].request("SCAN_RESULTS"):
found = True
break
finally:
dev[0].request("VENDOR_ELEM_REMOVE 14 *")
if not found:
raise Exception("AP not found in scan results")