[PATCH] WPS: Skip rescanning after provisioning
Masashi Honma
masashi.honma
Mon Mar 11 01:28:26 PDT 2013
2013/2/26 Jouni Malinen <j at w1.fi>:
> On Tue, Feb 26, 2013 at 10:26:19AM +0900, Masashi Honma wrote:
>> This patch uses existing scan results for fast connection after
>> provisioning.
>
> I have been thinking of doing this. However, it needs to be kept in mind
> that the provisioning step can result in the AP changing its
> configuration. This happens whenever the AP is in WPS unconfigured
> state. As such, I would not do this optimization without first verifying
> that WPS state was configured.
I have added the WPS state check.
Signed-hostap: Masashi Honma <masashi.honma at gmail.com>
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 6c8ab6c..7590efb 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -851,9 +851,8 @@ wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s,
}
-static struct wpa_bss *
-wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
- struct wpa_ssid **selected_ssid)
+struct wpa_bss *wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
+ struct wpa_ssid **selected_ssid)
{
struct wpa_bss *selected = NULL;
int prio;
diff --git a/wpa_supplicant/wpa_supplicant_i.h
b/wpa_supplicant/wpa_supplicant_i.h
index 4ec15c1..deca023 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -789,6 +789,8 @@ void wpa_supplicant_stop_countermeasures(void
*eloop_ctx, void *sock_ctx);
void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx, void *sock_ctx);
void wnm_bss_keep_alive_deinit(struct wpa_supplicant *wpa_s);
int wpa_supplicant_fast_associate(struct wpa_supplicant *wpa_s);
+struct wpa_bss *wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
+ struct wpa_ssid **selected_ssid);
/* eap_register.c */
int eap_register_methods(void);
diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c
index 509a7c0..bd655af 100644
--- a/wpa_supplicant/wps_supplicant.c
+++ b/wpa_supplicant/wps_supplicant.c
@@ -84,6 +84,10 @@ int wpas_wps_eapol_cb(struct wpa_supplicant *wpa_s)
!(wpa_s->current_ssid->key_mgmt & WPA_KEY_MGMT_WPS)) {
int disabled = wpa_s->current_ssid->disabled;
unsigned int freq = wpa_s->assoc_freq;
+ struct wpa_bss *bss;
+ struct wpa_ssid *ssid = NULL;
+ int use_fast_assoc = 0;
+
wpa_printf(MSG_DEBUG, "WPS: Network configuration replaced - "
"try to associate with the received credential "
"(freq=%u)", freq);
@@ -98,7 +102,24 @@ int wpas_wps_eapol_cb(struct wpa_supplicant *wpa_s)
wpa_s->wps_freq = freq;
wpa_s->normal_scans = 0;
wpa_s->reassociate = 1;
- wpa_supplicant_req_scan(wpa_s, 0, 0);
+
+ bss = wpa_supplicant_pick_network(wpa_s, &ssid);
+ if (bss != NULL) {
+ struct wpabuf *wps;
+ struct wps_parse_attr attr;
+
+ wps = wpa_bss_get_vendor_ie_multi(bss,
+ WPS_IE_VENDOR_TYPE);
+ if (wps != NULL && wps_parse_msg(wps, &attr) == 0 &&
+ attr.wps_state != NULL &&
+ *attr.wps_state == WPS_STATE_CONFIGURED)
+ use_fast_assoc = 1;
+ wpabuf_free(wps);
+ }
+
+ if (!use_fast_assoc ||
+ wpa_supplicant_fast_associate(wpa_s) != 1)
+ wpa_supplicant_req_scan(wpa_s, 0, 0);
return 1;
}
Regards,
Masashi Honma.
More information about the Hostap
mailing list