diff --git a/tests/hwsim/test_gas.py b/tests/hwsim/test_gas.py index 2250b7fcb..e75cfee38 100644 --- a/tests/hwsim/test_gas.py +++ b/tests/hwsim/test_gas.py @@ -1386,6 +1386,55 @@ def _test_gas_anqp_address3_ap_non_compliant(dev, apdev, params): if res[1] != bssid: raise Exception("GAS response used unexpected Address3 field value: " + res[1]) +def test_gas_anqp_address3_pmf(dev, apdev): + """GAS/ANQP query using IEEE 802.11 compliant Address 3 value with PMF""" + try: + _test_gas_anqp_address3_pmf(dev, apdev) + finally: + dev[0].request("SET gas_address3 0") + +def _test_gas_anqp_address3_pmf(dev, apdev): + hapd = start_ap(apdev[0]) + bssid = apdev[0]['bssid'] + hapd.set("gas_comeback_delay", "2") + hapd.set("gas_address3", "1") + + if "OK" not in dev[0].request("SET gas_address3 1"): + raise Exception("Failed to set gas_address3") + + dev[0].scan_for_bss(bssid, freq="2412") + dev[0].connect("test-gas", key_mgmt="WPA-EAP", eap="TTLS", + identity="DOMAIN\mschapv2 user", anonymous_identity="ttls", + password="password", phase2="auth=MSCHAPV2", + ca_cert="auth_serv/ca.pem", scan_freq="2412", + ieee80211w="2") + + if "OK" not in dev[0].request("ANQP_GET " + bssid + " 258"): + raise Exception("ANQP_GET command failed") + + ev = dev[0].wait_event(["GAS-QUERY-START"], timeout=5) + if ev is None: + raise Exception("GAS query start timed out") + + ev = dev[0].wait_event(["GAS-QUERY-DONE"], timeout=10) + if ev is None: + raise Exception("GAS query timed out") + + ev = dev[0].wait_event(["RX-ANQP"], timeout=1) + if ev is None or "Venue Name" not in ev: + raise Exception("Did not receive Venue Name") + + ev = dev[0].wait_event(["ANQP-QUERY-DONE"], timeout=10) + if ev is None: + raise Exception("ANQP-QUERY-DONE event not seen") + if "result=SUCCESS" not in ev: + raise Exception("Unexpected result: " + ev) + + req = dev[0].request("GAS_REQUEST " + bssid + " 42 000102000101") + if "FAIL" in req: + raise Exception("GAS query request rejected") + expect_gas_result(dev[0], "FAILURE", "59") + def test_gas_prot_vs_not_prot(dev, apdev, params): """GAS/ANQP query protected vs. not protected""" hapd = start_ap(apdev[0]) @@ -1569,3 +1618,222 @@ def test_gas_anqp_capab_list(dev, apdev): continue if i not in ids: raise Exception("Unexpected Capability List ANQP-element value (missing %d): %s" % (i, bss['anqp_capability_list'])) + +def test_gas_server_oom(dev, apdev): + """GAS server OOM""" + bssid = apdev[0]['bssid'] + params = hs20_ap_params() + params['hessid'] = bssid + params['gas_comeback_delay'] = "5" + hapd = hostapd.add_ap(apdev[0], params) + + dev[0].scan_for_bss(bssid, freq="2412", force_scan=True) + + tests = [ "ap_sta_add;gas_dialog_create", + "=gas_dialog_create", + "wpabuf_alloc_copy;gas_serv_rx_gas_comeback_req" ] + for t in tests: + with alloc_fail(hapd, 1, t): + if "OK" not in dev[0].request("ANQP_GET " + bssid + " 258"): + raise Exception("ANQP_GET command failed") + ev = dev[0].wait_event(["GAS-QUERY-DONE"], timeout=5) + if ev is None: + raise Exception("No GAS-QUERY-DONE seen") + dev[0].dump_monitor() + + hapd.set("gas_comeback_delay", "0") + + tests = [ "gas_serv_build_gas_resp_payload" ] + for t in tests: + with alloc_fail(hapd, 1, t): + if "OK" not in dev[0].request("ANQP_GET " + bssid + " 258"): + raise Exception("ANQP_GET command failed") + ev = dev[0].wait_event(["GAS-QUERY-DONE"], timeout=5) + if ev is None: + raise Exception("No GAS-QUERY-DONE seen") + dev[0].dump_monitor() + + with alloc_fail(hapd, 1, + "gas_build_initial_resp;gas_serv_rx_gas_initial_req"): + req = dev[0].request("GAS_REQUEST " + bssid + " 42 000102000101") + if "FAIL" in req: + raise Exception("GAS query request rejected") + ev = dev[0].wait_event(["GAS-QUERY-DONE"], timeout=5) + if ev is None: + raise Exception("No GAS-QUERY-DONE seen") + dev[0].dump_monitor() + + wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') + wpas.interface_add("wlan5") + if "OK" not in wpas.request("P2P_SET listen_channel 1"): + raise Exception("Failed to set listen channel") + if "OK" not in wpas.p2p_listen(): + raise Exception("Failed to start listen state") + if "FAIL" in wpas.request("SET ext_mgmt_frame_handling 1"): + raise Exception("Failed to enable external management frame handling") + + msg = struct.pack('