nl80211: Add an option to specify the BSSID to scan for
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 26 Feb 2016 14:31:33 +0000 (16:31 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 26 Feb 2016 15:19:20 +0000 (17:19 +0200)
This allows scans to be optimized when a response is needed only from a
single, known BSS.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/drivers/driver.h
src/drivers/driver_nl80211_scan.c
wpa_supplicant/scan.c

index 2315226..642276c 100644 (file)
@@ -439,6 +439,15 @@ struct wpa_driver_scan_params {
         */
         unsigned int sched_scan_plans_num;
 
+       /**
+        * bssid - Specific BSSID to scan for
+        *
+        * This optional parameter can be used to replace the default wildcard
+        * BSSID with a specific BSSID to scan for if results are needed from
+        * only a single BSS.
+        */
+       const u8 *bssid;
+
        /*
         * NOTE: Whenever adding new parameters here, please make sure
         * wpa_scan_clone_params() and wpa_scan_free_params() get updated with
index 2145022..e430a2f 100644 (file)
@@ -257,6 +257,13 @@ int wpa_driver_nl80211_scan(struct i802_bss *bss,
                        goto fail;
        }
 
+       if (params->bssid) {
+               wpa_printf(MSG_DEBUG, "nl80211: Scan for a specific BSSID: "
+                          MACSTR, MAC2STR(params->bssid));
+               if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, params->bssid))
+                       goto fail;
+       }
+
        ret = send_and_recv_msgs(drv, msg, NULL, NULL);
        msg = NULL;
        if (ret) {
index c333e57..c925cad 100644 (file)
@@ -2259,6 +2259,17 @@ wpa_scan_clone_params(const struct wpa_driver_scan_params *src)
                        params->mac_addr_mask = mac_addr + ETH_ALEN;
                }
        }
+
+       if (src->bssid) {
+               u8 *bssid;
+
+               bssid = os_malloc(ETH_ALEN);
+               if (!bssid)
+                       goto failed;
+               os_memcpy(bssid, src->bssid, ETH_ALEN);
+               params->bssid = bssid;
+       }
+
        return params;
 
 failed:
@@ -2287,6 +2298,8 @@ void wpa_scan_free_params(struct wpa_driver_scan_params *params)
         */
        os_free((u8 *) params->mac_addr);
 
+       os_free((u8 *) params->bssid);
+
        os_free(params);
 }