Optional scan id for ctrl_iface SCAN requests
This allows users of wpa_supplicant control interface to figure out when their specific scan command has been started and completed. For example: CTRL-EVENT-SCAN-STARTED > scan freq=2412,2417 passive=1 use_id=1 3 CTRL-EVENT-SCAN-RESULTS CTRL-EVENT-SCAN-STARTED id=3 CTRL-EVENT-SCAN-RESULTS id=3 Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
a5f40eff18
commit
d81c73be18
4 changed files with 44 additions and 3 deletions
|
@ -5264,6 +5264,7 @@ static void wpas_ctrl_scan(struct wpa_supplicant *wpa_s, char *params,
|
||||||
}
|
}
|
||||||
|
|
||||||
wpa_s->manual_scan_passive = 0;
|
wpa_s->manual_scan_passive = 0;
|
||||||
|
wpa_s->manual_scan_use_id = 0;
|
||||||
|
|
||||||
if (params) {
|
if (params) {
|
||||||
if (os_strncasecmp(params, "TYPE=ONLY", 9) == 0)
|
if (os_strncasecmp(params, "TYPE=ONLY", 9) == 0)
|
||||||
|
@ -5278,6 +5279,10 @@ static void wpas_ctrl_scan(struct wpa_supplicant *wpa_s, char *params,
|
||||||
pos = os_strstr(params, "passive=");
|
pos = os_strstr(params, "passive=");
|
||||||
if (pos)
|
if (pos)
|
||||||
wpa_s->manual_scan_passive = !!atoi(pos + 8);
|
wpa_s->manual_scan_passive = !!atoi(pos + 8);
|
||||||
|
|
||||||
|
pos = os_strstr(params, "use_id=");
|
||||||
|
if (pos)
|
||||||
|
wpa_s->manual_scan_use_id = atoi(pos + 7);
|
||||||
} else {
|
} else {
|
||||||
os_free(wpa_s->manual_scan_freqs);
|
os_free(wpa_s->manual_scan_freqs);
|
||||||
wpa_s->manual_scan_freqs = NULL;
|
wpa_s->manual_scan_freqs = NULL;
|
||||||
|
@ -5293,11 +5298,25 @@ static void wpas_ctrl_scan(struct wpa_supplicant *wpa_s, char *params,
|
||||||
wpa_s->after_wps = 0;
|
wpa_s->after_wps = 0;
|
||||||
wpa_s->known_wps_freq = 0;
|
wpa_s->known_wps_freq = 0;
|
||||||
wpa_supplicant_req_scan(wpa_s, 0, 0);
|
wpa_supplicant_req_scan(wpa_s, 0, 0);
|
||||||
|
if (wpa_s->manual_scan_use_id) {
|
||||||
|
wpa_s->manual_scan_id++;
|
||||||
|
wpa_dbg(wpa_s, MSG_DEBUG, "Assigned scan id %u",
|
||||||
|
wpa_s->manual_scan_id);
|
||||||
|
*reply_len = os_snprintf(reply, reply_size, "%u\n",
|
||||||
|
wpa_s->manual_scan_id);
|
||||||
|
}
|
||||||
} else if (wpa_s->sched_scanning) {
|
} else if (wpa_s->sched_scanning) {
|
||||||
wpa_printf(MSG_DEBUG, "Stop ongoing sched_scan to allow requested full scan to proceed");
|
wpa_printf(MSG_DEBUG, "Stop ongoing sched_scan to allow requested full scan to proceed");
|
||||||
wpa_supplicant_cancel_sched_scan(wpa_s);
|
wpa_supplicant_cancel_sched_scan(wpa_s);
|
||||||
wpa_s->scan_req = MANUAL_SCAN_REQ;
|
wpa_s->scan_req = MANUAL_SCAN_REQ;
|
||||||
wpa_supplicant_req_scan(wpa_s, 0, 0);
|
wpa_supplicant_req_scan(wpa_s, 0, 0);
|
||||||
|
if (wpa_s->manual_scan_use_id) {
|
||||||
|
wpa_s->manual_scan_id++;
|
||||||
|
*reply_len = os_snprintf(reply, reply_size, "%u\n",
|
||||||
|
wpa_s->manual_scan_id);
|
||||||
|
wpa_dbg(wpa_s, MSG_DEBUG, "Assigned scan id %u",
|
||||||
|
wpa_s->manual_scan_id);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
wpa_printf(MSG_DEBUG, "Ongoing scan action - reject new request");
|
wpa_printf(MSG_DEBUG, "Ongoing scan action - reject new request");
|
||||||
*reply_len = os_snprintf(reply, reply_size, "FAIL-BUSY\n");
|
*reply_len = os_snprintf(reply, reply_size, "FAIL-BUSY\n");
|
||||||
|
|
|
@ -1267,7 +1267,14 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
|
||||||
|
|
||||||
wpa_dbg(wpa_s, MSG_DEBUG, "New scan results available (own=%u ext=%u)",
|
wpa_dbg(wpa_s, MSG_DEBUG, "New scan results available (own=%u ext=%u)",
|
||||||
wpa_s->own_scan_running, wpa_s->external_scan_running);
|
wpa_s->own_scan_running, wpa_s->external_scan_running);
|
||||||
|
if (wpa_s->last_scan_req == MANUAL_SCAN_REQ &&
|
||||||
|
wpa_s->manual_scan_use_id && wpa_s->own_scan_running) {
|
||||||
|
wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS "id=%u",
|
||||||
|
wpa_s->manual_scan_id);
|
||||||
|
wpa_s->manual_scan_use_id = 0;
|
||||||
|
} else {
|
||||||
wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS);
|
wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS);
|
||||||
|
}
|
||||||
wpas_notify_scan_results(wpa_s);
|
wpas_notify_scan_results(wpa_s);
|
||||||
|
|
||||||
wpas_notify_scan_done(wpa_s, 1);
|
wpas_notify_scan_done(wpa_s, 1);
|
||||||
|
@ -2742,7 +2749,13 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
|
||||||
wpa_dbg(wpa_s, MSG_DEBUG, "Own scan request started a scan");
|
wpa_dbg(wpa_s, MSG_DEBUG, "Own scan request started a scan");
|
||||||
wpa_s->own_scan_requested = 0;
|
wpa_s->own_scan_requested = 0;
|
||||||
wpa_s->own_scan_running = 1;
|
wpa_s->own_scan_running = 1;
|
||||||
|
if (wpa_s->last_scan_req == MANUAL_SCAN_REQ &&
|
||||||
|
wpa_s->manual_scan_use_id) {
|
||||||
|
wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCAN_STARTED "id=%u",
|
||||||
|
wpa_s->manual_scan_id);
|
||||||
|
} else {
|
||||||
wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCAN_STARTED);
|
wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCAN_STARTED);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
wpa_dbg(wpa_s, MSG_DEBUG, "External program started a scan");
|
wpa_dbg(wpa_s, MSG_DEBUG, "External program started a scan");
|
||||||
wpa_s->external_scan_running = 1;
|
wpa_s->external_scan_running = 1;
|
||||||
|
|
|
@ -1670,7 +1670,14 @@ void scan_only_handler(struct wpa_supplicant *wpa_s,
|
||||||
struct wpa_scan_results *scan_res)
|
struct wpa_scan_results *scan_res)
|
||||||
{
|
{
|
||||||
wpa_dbg(wpa_s, MSG_DEBUG, "Scan-only results received");
|
wpa_dbg(wpa_s, MSG_DEBUG, "Scan-only results received");
|
||||||
|
if (wpa_s->last_scan_req == MANUAL_SCAN_REQ &&
|
||||||
|
wpa_s->manual_scan_use_id && wpa_s->own_scan_running) {
|
||||||
|
wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS "id=%u",
|
||||||
|
wpa_s->manual_scan_id);
|
||||||
|
wpa_s->manual_scan_use_id = 0;
|
||||||
|
} else {
|
||||||
wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS);
|
wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS);
|
||||||
|
}
|
||||||
wpas_notify_scan_results(wpa_s);
|
wpas_notify_scan_results(wpa_s);
|
||||||
wpas_notify_scan_done(wpa_s, 1);
|
wpas_notify_scan_done(wpa_s, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -483,9 +483,11 @@ struct wpa_supplicant {
|
||||||
int *next_scan_freqs;
|
int *next_scan_freqs;
|
||||||
int *manual_scan_freqs;
|
int *manual_scan_freqs;
|
||||||
unsigned int manual_scan_passive:1;
|
unsigned int manual_scan_passive:1;
|
||||||
|
unsigned int manual_scan_use_id:1;
|
||||||
unsigned int own_scan_requested:1;
|
unsigned int own_scan_requested:1;
|
||||||
unsigned int own_scan_running:1;
|
unsigned int own_scan_running:1;
|
||||||
unsigned int external_scan_running:1;
|
unsigned int external_scan_running:1;
|
||||||
|
unsigned int manual_scan_id;
|
||||||
int scan_interval; /* time in sec between scans to find suitable AP */
|
int scan_interval; /* time in sec between scans to find suitable AP */
|
||||||
int normal_scans; /* normal scans run before sched_scan */
|
int normal_scans; /* normal scans run before sched_scan */
|
||||||
int scan_for_connection; /* whether the scan request was triggered for
|
int scan_for_connection; /* whether the scan request was triggered for
|
||||||
|
|
Loading…
Reference in a new issue