From: Jay Shukla Date: Thu, 20 Feb 2025 10:36:24 +0000 (+0530) Subject: nl80211: Send allowed BSSIDs, if set, for an NL80211_CMD_CONNECT command X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe5b88e78cc7fcb68efcee08da6a36b1658089c0;p=thirdparty%2Fhostap.git nl80211: Send allowed BSSIDs, if set, for an NL80211_CMD_CONNECT command Add support for configuring the allowed BSSIDs to the driver with the vendor command QCA_NL80211_VENDOR_SUBCMD_CONNECT_EXT when using NL80211_CMD_CONNECT for the connection. This limits which BSSIDs the driver-based SME can consider for the connection similarly to the wpa_supplicant-based SME design. Signed-off-by: Jouni Malinen --- diff --git a/src/drivers/driver.h b/src/drivers/driver.h index b356371b5..48092ea9a 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -1412,6 +1412,16 @@ struct wpa_driver_associate_params { * spp_amsdu - SPP A-MSDU used on this connection */ bool spp_amsdu; + + /** + * bssid_filter - Allowed BSSIDs for the current association + * This can be %NULL to indicate no constraint. */ + const u8 *bssid_filter; + + /** + * bssid_filter_count - Number of allowed BSSIDs + */ + unsigned int bssid_filter_count; }; enum hide_ssid { diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 1ba8f1f33..d54c3e078 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -7205,6 +7205,26 @@ static int nl80211_connect_ext(struct wpa_driver_nl80211_data *drv, sizeof(features), features)) goto fail; + if (params->bssid_filter && params->bssid_filter_count) { + struct nlattr *bssid_list; + unsigned int i; + + bssid_list = nla_nest_start( + msg, QCA_WLAN_VENDOR_ATTR_CONNECT_EXT_ALLOWED_BSSIDS); + if (!bssid_list) + goto fail; + + for (i = 0; i < params->bssid_filter_count; i++) { + wpa_printf(MSG_DEBUG, "- bssid_filter[%d]=" MACSTR, i, + MAC2STR(¶ms->bssid_filter[i * ETH_ALEN])); + if (nla_put(msg, i + 1, ETH_ALEN, + ¶ms->bssid_filter[i * ETH_ALEN])) + goto fail; + } + + nla_nest_end(msg, bssid_list); + } + nla_nest_end(msg, attr); return send_and_recv_cmd(drv, msg); diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index e63048d18..cbda854c5 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -4573,6 +4573,9 @@ static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit) params.pbss = (ssid->pbss != 2) ? ssid->pbss : 0; } + params.bssid_filter = wpa_s->bssid_filter; + params.bssid_filter_count = wpa_s->bssid_filter_count; + if (ssid->mode == WPAS_MODE_IBSS && ssid->bssid_set && wpa_s->conf->ap_scan == 2) { params.bssid = ssid->bssid;