]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add 'SCAN TYPE=ONLY' functionality
authorDmitry Shmidt <dimitrysh@google.com>
Thu, 7 Feb 2013 16:06:51 +0000 (18:06 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 7 Feb 2013 16:09:50 +0000 (18:09 +0200)
Usual manual scan request may cause reassociation due to several
reasons. New command is intended to perform pure scan without taking any
automatic action based on the results.

Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
wpa_supplicant/ctrl_iface.c
wpa_supplicant/events.c
wpa_supplicant/scan.c
wpa_supplicant/scan.h
wpa_supplicant/wpa_cli.c

index 4e5e169e24a72ba57b3b61c4eeb3c979e101be79..03ff7ebd767dfdd0d54400cbb13e2f762de5fcd6 100644 (file)
@@ -5125,10 +5125,14 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
                wpa_supplicant_cancel_scan(wpa_s);
                wpa_supplicant_deauthenticate(wpa_s,
                                              WLAN_REASON_DEAUTH_LEAVING);
-       } else if (os_strcmp(buf, "SCAN") == 0) {
+       } else if (os_strcmp(buf, "SCAN") == 0 ||
+                  os_strncmp(buf, "SCAN ", 5) == 0) {
                if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
                        reply_len = -1;
                else {
+                       if (os_strlen(buf) > 4 &&
+                           os_strncasecmp(buf + 5, "TYPE=ONLY", 9) == 0)
+                               wpa_s->scan_res_handler = scan_only_handler;
                        if (!wpa_s->sched_scanning && !wpa_s->scanning &&
                            ((wpa_s->wpa_state <= WPA_SCANNING) ||
                             (wpa_s->wpa_state == WPA_COMPLETED))) {
index 28d80e99776fd615eeb8b921cbf538e1b4f77f05..6c8ab6ca25ba99b929f0184ad37859b0b5c7f6ab 100644 (file)
@@ -1125,7 +1125,8 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
                                                   data ? &data->scan_info :
                                                   NULL, 1);
        if (scan_res == NULL) {
-               if (wpa_s->conf->ap_scan == 2 || ap)
+               if (wpa_s->conf->ap_scan == 2 || ap ||
+                   wpa_s->scan_res_handler == scan_only_handler)
                        return -1;
                wpa_dbg(wpa_s, MSG_DEBUG, "Failed to get scan results - try "
                        "scanning again");
index 19405a453892ef87f76b522eb18b77edd09194c3..6bc07fedf67098b96c6042cacbb6ca1fe9f53c14 100644 (file)
@@ -11,6 +11,7 @@
 #include "utils/common.h"
 #include "utils/eloop.h"
 #include "common/ieee802_11_defs.h"
+#include "common/wpa_ctrl.h"
 #include "config.h"
 #include "wpa_supplicant_i.h"
 #include "driver_i.h"
@@ -1580,3 +1581,16 @@ int wpa_supplicant_update_scan_results(struct wpa_supplicant *wpa_s)
 
        return 0;
 }
+
+
+/**
+ * scan_only_handler - Reports scan results
+ */
+void scan_only_handler(struct wpa_supplicant *wpa_s,
+                      struct wpa_scan_results *scan_res)
+{
+       wpa_dbg(wpa_s, MSG_DEBUG, "Scan-only results received");
+       wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS);
+       wpas_notify_scan_results(wpa_s);
+       wpas_notify_scan_done(wpa_s, 1);
+}
index 7a9b232d0c957d7127ae4a2a6551b889a63ee829..5ecfa00cfd9d82d24eaaa6b66a995ab7ac90dcc6 100644 (file)
@@ -33,5 +33,7 @@ struct wpabuf * wpa_scan_get_vendor_ie_multi(const struct wpa_scan_res *res,
 int wpa_supplicant_filter_bssid_match(struct wpa_supplicant *wpa_s,
                                      const u8 *bssid);
 void wpa_supplicant_update_scan_int(struct wpa_supplicant *wpa_s, int sec);
+void scan_only_handler(struct wpa_supplicant *wpa_s,
+                      struct wpa_scan_results *scan_res);
 
 #endif /* SCAN_H */
index 632db804bdda10c0dfe19b011000c2decbc4ed66..1a764bb96ab91040ce1a2ef23052c64f28fad3cc 100644 (file)
@@ -1433,7 +1433,7 @@ static int wpa_cli_cmd_save_config(struct wpa_ctrl *ctrl, int argc,
 
 static int wpa_cli_cmd_scan(struct wpa_ctrl *ctrl, int argc, char *argv[])
 {
-       return wpa_ctrl_command(ctrl, "SCAN");
+       return wpa_cli_cmd(ctrl, "SCAN", 0, argc, argv);
 }