]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Use default IEs in wpa_supplicant_trigger_scan()
authorMatthew Wang <matthewmwang@chromium.org>
Fri, 2 Jun 2023 22:15:08 +0000 (15:15 -0700)
committerJouni Malinen <j@w1.fi>
Tue, 31 Oct 2023 10:01:26 +0000 (12:01 +0200)
wpa_supplicant_trigger_scan() previously wouldn't include any of the IEs
generated by wpa_supplicant_extra_ies(). Instruct it to do so in most
cases. This is necessary because MBO STAs are required to include MBO
capabilities in their Probe Request frames.

Signed-off-by: Matthew Wang <matthewmwang@chromium.org>
doc/dbus.doxygen
wpa_supplicant/bgscan_learn.c
wpa_supplicant/bgscan_simple.c
wpa_supplicant/dbus/dbus_new_handlers.c
wpa_supplicant/rrm.c
wpa_supplicant/scan.c
wpa_supplicant/scan.h
wpa_supplicant/sme.c

index 409db9522f85b19f44558d98800deb21a5690899..17d4df06a8b06da7d2a317ace8c877d367d54fb9 100644 (file)
@@ -209,7 +209,7 @@ fi.w1.wpa_supplicant1.CreateInterface.
              <tr><th>Key</th><th>Value type</th><th>Description</th><th>Required</th>
              <tr><td>Type</td><td>s</td><td>Type of the scan. Possible values: "active", "passive"</td><td>Yes</td>
              <tr><td>SSIDs</td><td>aay</td><td>Array of SSIDs to scan for (applies only if scan type is active)</td><td>No</td>
-             <tr><td>IEs</td><td>aay</td><td>Information elements to used in active scan (applies only if scan type is active)</td><td>No</td>
+             <tr><td>IEs</td><td>aay</td><td>Information elements to used in active scan (applies only if scan type is active). Default IEs will be used in absence of this option.</td><td>No</td>
              <tr><td>Channels</td><td>a(uu)</td><td>Array of frequencies to scan in form of (center, width) in MHz.</td><td>No</td>
              <tr><td>AllowRoam</td><td>b</td><td>TRUE (or absent) to allow a roaming decision based on the results of this scan, FALSE to prevent a roaming decision.</td><td>No</td>
              <tr><td>NonColoc6GHz</td><td>b</td><td>TRUE to force scanning of non-PSC 6 GHz channels, FALSE (or absent) to skip scanning of non-PSC 6 GHz channels.</td><td>No</td>
index 75bdec1c0a975a9e513fd871147c4c9bbfa5a2a6..3db425963eb025d0b45e2a1b04018942a7509248 100644 (file)
@@ -305,7 +305,7 @@ static void bgscan_learn_timeout(void *eloop_ctx, void *timeout_ctx)
        }
 
        wpa_printf(MSG_DEBUG, "bgscan learn: Request a background scan");
-       if (wpa_supplicant_trigger_scan(wpa_s, &params)) {
+       if (wpa_supplicant_trigger_scan(wpa_s, &params, true)) {
                wpa_printf(MSG_DEBUG, "bgscan learn: Failed to trigger scan");
                eloop_register_timeout(data->scan_interval, 0,
                                       bgscan_learn_timeout, data, NULL);
index 5a8f97c2a6aa9e2859b99acaed50691d4371d15a..1b12726d203373caf8763cc4f77b654bd1f514a0 100644 (file)
@@ -49,7 +49,7 @@ static void bgscan_simple_timeout(void *eloop_ctx, void *timeout_ctx)
         */
 
        wpa_printf(MSG_DEBUG, "bgscan simple: Request a background scan");
-       if (wpa_supplicant_trigger_scan(wpa_s, &params)) {
+       if (wpa_supplicant_trigger_scan(wpa_s, &params, true)) {
                wpa_printf(MSG_DEBUG, "bgscan simple: Failed to trigger scan");
                eloop_register_timeout(data->scan_interval, 0,
                                       bgscan_simple_timeout, data, NULL);
index b47f130ae2d88959d86ede8a1c41521623f03a90..6651267110b6f5612c3441d696975845bf3c1b4d 100644 (file)
@@ -1632,6 +1632,7 @@ DBusMessage * wpas_dbus_handler_scan(DBusMessage *message,
        dbus_bool_t allow_roam = TRUE;
        dbus_bool_t non_coloc_6ghz = FALSE;
        dbus_bool_t scan_6ghz_only = FALSE;
+       bool custom_ies = false;
 
        os_memset(&params, 0, sizeof(params));
 
@@ -1658,6 +1659,7 @@ DBusMessage * wpas_dbus_handler_scan(DBusMessage *message,
                        if (wpas_dbus_get_scan_ies(message, &variant_iter,
                                                   &params, &reply) < 0)
                                goto out;
+                       custom_ies = true;
                } else if (os_strcmp(key, "Channels") == 0) {
                        if (wpas_dbus_get_scan_channels(message, &variant_iter,
                                                        &params, &reply) < 0)
@@ -1724,7 +1726,8 @@ DBusMessage * wpas_dbus_handler_scan(DBusMessage *message,
                        if (params.freqs && params.freqs[0]) {
                                wpa_s->last_scan_req = MANUAL_SCAN_REQ;
                                if (wpa_supplicant_trigger_scan(wpa_s,
-                                                               &params)) {
+                                                               &params,
+                                                               false)) {
                                        reply = wpas_dbus_error_scan_error(
                                                message,
                                                "Scan request rejected");
@@ -1750,7 +1753,7 @@ DBusMessage * wpas_dbus_handler_scan(DBusMessage *message,
                }
 
                wpa_s->last_scan_req = MANUAL_SCAN_REQ;
-               if (wpa_supplicant_trigger_scan(wpa_s, &params)) {
+               if (wpa_supplicant_trigger_scan(wpa_s, &params, !custom_ies)) {
                        reply = wpas_dbus_error_scan_error(
                                message, "Scan request rejected");
                }
index 238fe68da057d63c1e4800220bee4a0aa8df2b8d..bf6575a0bf3919d20e9e9a490342a9e1b7c84647 100644 (file)
@@ -1033,7 +1033,7 @@ static void wpas_rrm_scan_timeout(void *eloop_ctx, void *timeout_ctx)
        }
        os_get_reltime(&wpa_s->beacon_rep_scan);
        if (wpa_s->scanning || wpas_p2p_in_progress(wpa_s) ||
-           wpa_supplicant_trigger_scan(wpa_s, params))
+           wpa_supplicant_trigger_scan(wpa_s, params, true))
                wpas_rrm_refuse_request(wpa_s);
        params->duration = prev_duration;
 }
index e4883d51860793b8a2fa87d078cd30f89428fa01..e4b72a8fa95bcd2b8e8b370460fbd340acecc4fc 100644 (file)
@@ -24,6 +24,8 @@
 #include "scan.h"
 #include "mesh.h"
 
+static struct wpabuf * wpa_supplicant_extra_ies(struct wpa_supplicant *wpa_s);
+
 
 static void wpa_supplicant_gen_assoc_event(struct wpa_supplicant *wpa_s)
 {
@@ -278,19 +280,43 @@ static void wpas_trigger_scan_cb(struct wpa_radio_work *work, int deinit)
  * wpa_supplicant_trigger_scan - Request driver to start a scan
  * @wpa_s: Pointer to wpa_supplicant data
  * @params: Scan parameters
+ * @default_ies: Whether or not to use the default IEs in the Probe Request
+ * frames. Note that this will free any existing IEs set in @params, so this
+ * shouldn't be set if the IEs have already been set with
+ * wpa_supplicant_extra_ies(). Otherwise, wpabuf_free() will lead to a
+ * double-free.
  * Returns: 0 on success, -1 on failure
  */
 int wpa_supplicant_trigger_scan(struct wpa_supplicant *wpa_s,
-                               struct wpa_driver_scan_params *params)
+                               struct wpa_driver_scan_params *params,
+                               bool default_ies)
 {
        struct wpa_driver_scan_params *ctx;
+       struct wpabuf *ies = NULL;
 
        if (wpa_s->scan_work) {
                wpa_dbg(wpa_s, MSG_INFO, "Reject scan trigger since one is already pending");
                return -1;
        }
 
+       if (default_ies) {
+               if (params->extra_ies_len) {
+                       os_free((u8 *) params->extra_ies);
+                       params->extra_ies = NULL;
+                       params->extra_ies_len = 0;
+               }
+               ies = wpa_supplicant_extra_ies(wpa_s);
+               if (ies) {
+                       params->extra_ies = wpabuf_head(ies);
+                       params->extra_ies_len = wpabuf_len(ies);
+               }
+       }
        ctx = wpa_scan_clone_params(params);
+       if (ies) {
+               wpabuf_free(ies);
+               params->extra_ies = NULL;
+               params->extra_ies_len = 0;
+       }
        if (!ctx ||
            radio_add_work(wpa_s, 0, "scan", 0, wpas_trigger_scan_cb, ctx) < 0)
        {
@@ -1534,7 +1560,7 @@ scan:
                wpas_p2p_scan_freqs(wpa_s, &params, true);
 #endif /* CONFIG_P2P */
 
-       ret = wpa_supplicant_trigger_scan(wpa_s, scan_params);
+       ret = wpa_supplicant_trigger_scan(wpa_s, scan_params, false);
 
        if (ret && wpa_s->last_scan_req == MANUAL_SCAN_REQ && params.freqs &&
            !wpa_s->manual_scan_freqs) {
index 30f43951c2a8f49ad150e41ea4a34d61dc732cda..4a21b42210c4d61cae4f7d9ea5cec72b94c8115e 100644 (file)
@@ -45,7 +45,8 @@ void wpa_supplicant_notify_scanning(struct wpa_supplicant *wpa_s,
                                    int scanning);
 struct wpa_driver_scan_params;
 int wpa_supplicant_trigger_scan(struct wpa_supplicant *wpa_s,
-                               struct wpa_driver_scan_params *params);
+                               struct wpa_driver_scan_params *params,
+                               bool default_ies);
 struct wpa_scan_results *
 wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s,
                                struct scan_info *info, int new_scan);
index ab64d467bfe074c19db1d7d78ef563848b03e6af..9f12a7b3c47c66c42f6796aadac0a9e0d373e214 100644 (file)
@@ -3093,7 +3093,7 @@ static void sme_obss_scan_timeout(void *eloop_ctx, void *timeout_ctx)
        params.low_priority = 1;
        wpa_printf(MSG_DEBUG, "SME OBSS: Request an OBSS scan");
 
-       if (wpa_supplicant_trigger_scan(wpa_s, &params))
+       if (wpa_supplicant_trigger_scan(wpa_s, &params, true))
                wpa_printf(MSG_DEBUG, "SME OBSS: Failed to trigger scan");
        else
                wpa_s->sme.sched_obss_scan = 1;