]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Make scan interval configurable
authorDmitry Shmidt <dimitrysh@google.com>
Mon, 11 Apr 2011 20:14:38 +0000 (23:14 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 11 Apr 2011 20:14:38 +0000 (23:14 +0300)
It is now possible to configure the the time in seconds that
wpa_supplicant waits before requesting a new scan after failing to find
a suitable network in scan results.

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

index 5488ea4479b28beca1ac9e2afff78a0ccd91dd6f..dd39f8b0d451d0e320a7210db6d3c2ee6efe72bb 100644 (file)
@@ -2005,6 +2005,17 @@ static int wpa_supplicant_ctrl_iface_ap_scan(
 }
 
 
+static int wpa_supplicant_ctrl_iface_scan_interval(
+       struct wpa_supplicant *wpa_s, char *cmd)
+{
+       int scan_int = atoi(cmd);
+       if (scan_int < 0)
+               return -1;
+       wpa_s->scan_interval = scan_int;
+       return 0;
+}
+
+
 static int wpa_supplicant_ctrl_iface_bss_expire_age(
        struct wpa_supplicant *wpa_s, char *cmd)
 {
@@ -3190,6 +3201,9 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
        } else if (os_strncmp(buf, "AP_SCAN ", 8) == 0) {
                if (wpa_supplicant_ctrl_iface_ap_scan(wpa_s, buf + 8))
                        reply_len = -1;
+       } else if (os_strncmp(buf, "SCAN_INTERVAL ", 14) == 0) {
+               if (wpa_supplicant_ctrl_iface_scan_interval(wpa_s, buf + 14))
+                       reply_len = -1;
        } else if (os_strcmp(buf, "INTERFACE_LIST") == 0) {
                reply_len = wpa_supplicant_global_iface_list(
                        wpa_s->global, reply, reply_size);
index 7198e1dedb3239d466a518b34dcf792ead75ddd6..4d7fa82b6c05c48cc86fda245de68a484e15caa5 100644 (file)
@@ -965,7 +965,7 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
                        wpa_dbg(wpa_s, MSG_DEBUG, "Setup a new network");
                        wpa_supplicant_associate(wpa_s, NULL, ssid);
                } else {
-                       int timeout_sec = 5;
+                       int timeout_sec = wpa_s->scan_interval;
                        int timeout_usec = 0;
 #ifdef CONFIG_P2P
                        if (wpa_s->p2p_in_provisioning) {
index e4224029dde72631c6127dd982fd809ae42fd562..f414af70241f3094eee3f1c0b2692e209b51a0e4 100644 (file)
@@ -475,6 +475,26 @@ static int wpa_cli_cmd_ap_scan(struct wpa_ctrl *ctrl, int argc, char *argv[])
 }
 
 
+static int wpa_cli_cmd_scan_interval(struct wpa_ctrl *ctrl, int argc,
+                                    char *argv[])
+{
+       char cmd[256];
+       int res;
+
+       if (argc != 1) {
+               printf("Invalid SCAN_INTERVAL command: needs one argument "
+                      "scan_interval value)\n");
+               return -1;
+       }
+       res = os_snprintf(cmd, sizeof(cmd), "SCAN_INTERVAL %s", argv[0]);
+       if (res < 0 || (size_t) res >= sizeof(cmd) - 1) {
+               printf("Too long SCAN_INTERVAL command.\n");
+               return -1;
+       }
+       return wpa_ctrl_command(ctrl, cmd);
+}
+
+
 static int wpa_cli_cmd_bss_expire_age(struct wpa_ctrl *ctrl, int argc,
                                      char *argv[])
 {
@@ -2429,6 +2449,9 @@ static struct wpa_cli_cmd wpa_cli_commands[] = {
        { "ap_scan", wpa_cli_cmd_ap_scan,
          cli_cmd_flag_none,
          "<value> = set ap_scan parameter" },
+       { "scan_interval", wpa_cli_cmd_scan_interval,
+         cli_cmd_flag_none,
+         "<value> = set scan_interval parameter (in seconds)" },
        { "bss_expire_age", wpa_cli_cmd_bss_expire_age,
          cli_cmd_flag_none,
          "<value> = set BSS expiration age parameter" },
index d8c2a2cce31a42909100f37c8fa099d107491b41..2c5a20c6207b7bc76b189b3ddad3ed8d7130d50e 100644 (file)
@@ -2068,6 +2068,7 @@ static struct wpa_supplicant * wpa_supplicant_alloc(void)
        if (wpa_s == NULL)
                return NULL;
        wpa_s->scan_req = 1;
+       wpa_s->scan_interval = 5;
        wpa_s->new_connection = 1;
        wpa_s->parent = wpa_s;
 
index 859a65b89d7060587181e2781cf097e8425832e9..8498666fc594b8c5868d8a7bbb899ce85b62652a 100644 (file)
@@ -405,6 +405,7 @@ struct wpa_supplicant {
                       * are no enabled networks in the configuration */
        int scan_runs; /* number of scan runs since WPS was started */
        int *next_scan_freqs;
+       int scan_interval; /* time in sec between scans to find suitable AP */
 
        struct wpa_client_mlme mlme;
        unsigned int drv_flags;