Patchwork WPS: Skip rescanning after provisioning

login
register
mail settings
Submitter Masashi Honma
Date March 11, 2013, 8:28 a.m.
Message ID <CAFk-A4nKdJYyLi6W+P2Tu0S5giCzkLx1yFk6CHgPYJEv8XepsQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/226487/
State Accepted
Commit 97236cee6a52ca15c488af548ae7be31f854a85d
Headers show

Comments

Masashi Honma - March 11, 2013, 8:28 a.m.
2013/2/26 Jouni Malinen <j@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@gmail.com>


Regards,
Masashi Honma.
Jouni Malinen - March 31, 2013, 5:09 p.m.
On Mon, Mar 11, 2013 at 05:28:26PM +0900, Masashi Honma wrote:
> 2013/2/26 Jouni Malinen <j@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.

Thanks, applied.

Patch

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;
 	}