Add delayed scheduled scan request

When initializing, the scheduled scan code was being called before
everything is ready. With normal scans, the first scan round is
delayed, so the initialization is finished by the time it really
starts.

Add a function that can be used to request a delayed scheduled scan.
The scan will only start after the specified time has elapsed. Call
this function instead of starting the scheduled scan directly during
driver initialization.

Signed-off-by: Luciano Coelho <coelho@ti.com>
This commit is contained in:
Luciano Coelho 2011-09-27 22:21:38 +03:00 committed by Jouni Malinen
parent bd525934e5
commit 6a90053cdf
3 changed files with 39 additions and 1 deletions

View file

@ -215,6 +215,18 @@ int wpa_supplicant_trigger_scan(struct wpa_supplicant *wpa_s,
} }
static void
wpa_supplicant_delayed_sched_scan_timeout(void *eloop_ctx, void *timeout_ctx)
{
struct wpa_supplicant *wpa_s = eloop_ctx;
wpa_dbg(wpa_s, MSG_DEBUG, "Starting delayed sched scan");
if (wpa_supplicant_req_sched_scan(wpa_s))
wpa_supplicant_req_scan(wpa_s, 0, 0);
}
static void static void
wpa_supplicant_sched_scan_timeout(void *eloop_ctx, void *timeout_ctx) wpa_supplicant_sched_scan_timeout(void *eloop_ctx, void *timeout_ctx)
{ {
@ -614,6 +626,29 @@ void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec)
} }
/**
* wpa_supplicant_delayed_sched_scan - Request a delayed scheduled scan
* @wpa_s: Pointer to wpa_supplicant data
* @sec: Number of seconds after which to scan
* @usec: Number of microseconds after which to scan
*
* This function is used to schedule periodic scans for neighboring
* access points after the specified time.
*/
int wpa_supplicant_delayed_sched_scan(struct wpa_supplicant *wpa_s,
int sec, int usec)
{
if (!wpa_s->sched_scan_supported)
return -1;
eloop_register_timeout(sec, usec,
wpa_supplicant_delayed_sched_scan_timeout,
wpa_s, NULL);
return 0;
}
/** /**
* wpa_supplicant_req_sched_scan - Start a periodic scheduled scan * wpa_supplicant_req_sched_scan - Start a periodic scheduled scan
* @wpa_s: Pointer to wpa_supplicant data * @wpa_s: Pointer to wpa_supplicant data

View file

@ -17,6 +17,8 @@
int wpa_supplicant_enabled_networks(struct wpa_config *conf); int wpa_supplicant_enabled_networks(struct wpa_config *conf);
void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec); void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
int wpa_supplicant_delayed_sched_scan(struct wpa_supplicant *wpa_s,
int sec, int usec);
int wpa_supplicant_req_sched_scan(struct wpa_supplicant *wpa_s); int wpa_supplicant_req_sched_scan(struct wpa_supplicant *wpa_s);
void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s); void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
void wpa_supplicant_cancel_sched_scan(struct wpa_supplicant *wpa_s); void wpa_supplicant_cancel_sched_scan(struct wpa_supplicant *wpa_s);

View file

@ -2090,7 +2090,8 @@ int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s)
wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN; wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN;
if (wpa_supplicant_enabled_networks(wpa_s->conf)) { if (wpa_supplicant_enabled_networks(wpa_s->conf)) {
if (wpa_supplicant_req_sched_scan(wpa_s)) if (wpa_supplicant_delayed_sched_scan(wpa_s, interface_count,
100000))
wpa_supplicant_req_scan(wpa_s, interface_count, wpa_supplicant_req_scan(wpa_s, interface_count,
100000); 100000);
interface_count++; interface_count++;