From patchwork Mon Mar 11 08:28:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masashi Honma X-Patchwork-Id: 226487 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id C20472C00DC for ; Mon, 11 Mar 2013 19:28:44 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id B79D59C0E5; Mon, 11 Mar 2013 04:28:39 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zNjrbS29n0RO; Mon, 11 Mar 2013 04:28:39 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 8570B9C10D; Mon, 11 Mar 2013 04:28:35 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 2771E9C0E5 for ; Mon, 11 Mar 2013 04:28:34 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Tbu68c-PzX0M for ; Mon, 11 Mar 2013 04:28:29 -0400 (EDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com [209.85.215.44]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 3760D9C10D for ; Mon, 11 Mar 2013 04:28:28 -0400 (EDT) Received: by mail-la0-f44.google.com with SMTP id eb20so3608251lab.3 for ; Mon, 11 Mar 2013 01:28:27 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.112.88.10 with SMTP id bc10mr4143066lbb.70.1362990506281; Mon, 11 Mar 2013 01:28:26 -0700 (PDT) Received: by 10.114.68.145 with HTTP; Mon, 11 Mar 2013 01:28:26 -0700 (PDT) In-Reply-To: <20130226093504.GA4186@w1.fi> References: <20130226093504.GA4186@w1.fi> Date: Mon, 11 Mar 2013 17:28:26 +0900 Message-ID: Subject: Re: [PATCH] WPS: Skip rescanning after provisioning From: Masashi Honma To: hostap@lists.shmoo.com X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com 2013/2/26 Jouni Malinen : > 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 Regards, Masashi Honma. 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; }