1# Test cases for Wi-Fi Alliance capabilities indication 2# Copyright (c) 2024, Qualcomm Innovation Center, Inc. 3# 4# This software may be distributed under the terms of the BSD license. 5# See README for more details. 6 7import hostapd 8from utils import * 9 10def test_wfa_gen_capa_protected(dev, apdev): 11 """WFA generational capabilities indication (protected)""" 12 try: 13 dev[0].set("wfa_gen_capa", "1") 14 run_wfa_gen_capa(dev, apdev) 15 finally: 16 dev[0].set("wfa_gen_capa", "0") 17 18def test_wfa_gen_capa_unprotected(dev, apdev): 19 """WFA generational capabilities indication (unprotected)""" 20 try: 21 dev[0].set("wfa_gen_capa", "2") 22 run_wfa_gen_capa(dev, apdev) 23 finally: 24 dev[0].set("wfa_gen_capa", "0") 25 26def test_wfa_gen_capa_protected_cert(dev, apdev): 27 """WFA generational capabilities indication (protected, cert)""" 28 try: 29 dev[0].set("wfa_gen_capa", "1") 30 run_wfa_gen_capa(dev, apdev, cert=True) 31 finally: 32 dev[0].set("wfa_gen_capa", "0") 33 34def test_wfa_gen_capa_unprotected_cert(dev, apdev): 35 """WFA generational capabilities indication (unprotected, cert)""" 36 try: 37 dev[0].set("wfa_gen_capa", "2") 38 run_wfa_gen_capa(dev, apdev, cert=True) 39 finally: 40 dev[0].set("wfa_gen_capa", "0") 41 42def test_wfa_gen_capa_automatic(dev, apdev): 43 """WFA generational capabilities indication (automatic)""" 44 try: 45 dev[0].set("wfa_gen_capa", "1") 46 run_wfa_gen_capa(dev, apdev, automatic=True) 47 finally: 48 dev[0].set("wfa_gen_capa", "0") 49 50def run_wfa_gen_capa(dev, apdev, cert=False, automatic=False): 51 check_sae_capab(dev[0]) 52 53 params = hostapd.wpa3_params(ssid="wfa-capab", password="12345678") 54 hapd = hostapd.add_ap(apdev[0], params) 55 56 dev[0].set("sae_groups", "") 57 if automatic: 58 dev[0].set("wfa_gen_capa_supp", "") 59 dev[0].set("wfa_gen_capa_cert", "") 60 else: 61 dev[0].set("wfa_gen_capa_supp", "07") 62 if cert: 63 dev[0].set("wfa_gen_capa_cert", "07") 64 else: 65 dev[0].set("wfa_gen_capa_cert", "") 66 dev[0].connect("wfa-capab", sae_password="12345678", key_mgmt="SAE", 67 ieee80211w="2", scan_freq="2412") 68 ev = hapd.wait_event(["WFA-GEN-CAPAB"], timeout=10) 69 if ev is None: 70 raise Exception("Generational capabilities indication not received") 71 _, addr, val = ev.split() 72 if addr != dev[0].own_addr(): 73 raise Exception("Unexpected STA address in the indication") 74 if automatic: 75 if not val.startswith("01"): 76 raise Exception("Unexpected indication value: " + val) 77 else: 78 if val != ("01070107" if cert else "0107"): 79 raise Exception("Unexpected indication value: " + val) 80