diff mbox series

ANQP: Filter info IDs based on AP extended capabilities

Message ID bb0148dd3a314f1da87cf3f6b1c57d5b@BJMBX02.spreadtrum.com
State New
Headers show
Series ANQP: Filter info IDs based on AP extended capabilities | expand

Commit Message

Chao Meng Aug. 24, 2026, 7:06 a.m. UTC
From 34890fa6fb2849841e0a3ad5b5d5086fa7aad436 Mon Sep 17 00:00:00 2001
From: Chao Meng <chao.meng@unisoc.com>
Date: Mon, 24 Aug 2026 15:04:18 +0800
Subject: [PATCH] ANQP: Filter info IDs based on AP extended capabilities

Before sending an ANQP query request, check the target AP's extended
capabilities to avoid querying for information elements that the AP does
not support. Verify the Interworking capability bit and filter out
civic/geospatial location info IDs when the corresponding capability
bits are not set.

If no valid info IDs remain after filtering, return an error instead of
sending a query that is guaranteed to fail.

Signed-off-by: Chao Meng <chao.meng@unisoc.com>
---
 wpa_supplicant/interworking.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

--
diff mbox series

Patch

diff --git a/wpa_supplicant/interworking.c b/wpa_supplicant/interworking.c
index f77880409..14e968596 100644
--- a/wpa_supplicant/interworking.c
+++ b/wpa_supplicant/interworking.c
@@ -2800,6 +2800,33 @@  int anqp_send_req(struct wpa_supplicant *wpa_s, const u8 *dst, int freq,
 "ANQP: Query Request to " MACSTR " for %u id(s)",
 MAC2STR(dst), (unsigned int) num_ids);

+if (bss) {
+if (!wpa_bss_ext_capab(bss, WLAN_EXT_CAPAB_INTERWORKING)) {
+wpa_dbg(wpa_s, MSG_ERROR, "ANQP: AP " MACSTR
+" does not support Interworking, ignore anqp query request", MAC2STR(dst));
+return -1;
+} else if (num_ids > 0) {
+size_t src, idx = 0;
+for (src = 0; src < num_ids; src++) {
+if (info_ids[src] == ANQP_AP_CIVIC_LOCATION &&
+!wpa_bss_ext_capab(bss, WLAN_EXT_CAPAB_CIVIC_LOCATION)) {
+continue;
+}
+if (info_ids[src] == ANQP_AP_GEOSPATIAL_LOCATION &&
+!wpa_bss_ext_capab(bss, WLAN_EXT_CAPAB_GEOSPATIAL_LOCATION)) {
+continue;
+}
+info_ids[idx++] = info_ids[src];
+}
+if (idx == 0) {
+wpa_printf(MSG_DEBUG, "ANQP: Cannot send query request without valid anqp_info_id for "
+MACSTR, MAC2STR(dst));
+return -1;
+}
+num_ids = idx;
+}
+}
+
 #ifdef CONFIG_HS20
 if (subtypes != 0) {
 extra_buf = wpabuf_alloc(100);