From: Jouni Malinen Date: Wed, 5 Jan 2011 09:49:03 +0000 (+0200) Subject: WPS: Make WPS-AP-AVAILABLE* events a bit more consistent X-Git-Tag: hostap-1-bp~656 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c6ad81f9c46d8e1d958feaa38fa105b186ee861;p=thirdparty%2Fhostap.git WPS: Make WPS-AP-AVAILABLE* events a bit more consistent The BSS table entries may be in more or less random order and it is better to show the most likely WPS configuration method in a way that is somewhat more consistent instead of just showing the method of the first BSS entry found in the table. --- diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c index a5770f16d..6dfea2f44 100644 --- a/wpa_supplicant/wps_supplicant.c +++ b/wpa_supplicant/wps_supplicant.c @@ -1297,6 +1297,7 @@ int wpas_wps_scan_pbc_overlap(struct wpa_supplicant *wpa_s, void wpas_wps_notify_scan_results(struct wpa_supplicant *wpa_s) { struct wpa_bss *bss; + unsigned int pbc = 0, auth = 0, pin = 0, wps = 0; if (wpa_s->disconnected || wpa_s->wpa_state >= WPA_ASSOCIATED) return; @@ -1307,20 +1308,24 @@ void wpas_wps_notify_scan_results(struct wpa_supplicant *wpa_s) if (!ie) continue; if (wps_is_selected_pbc_registrar(ie)) - wpa_msg_ctrl(wpa_s, MSG_INFO, - WPS_EVENT_AP_AVAILABLE_PBC); + pbc++; else if (wps_is_addr_authorized(ie, wpa_s->own_addr, 0)) - wpa_msg_ctrl(wpa_s, MSG_INFO, - WPS_EVENT_AP_AVAILABLE_AUTH); + auth++; else if (wps_is_selected_pin_registrar(ie)) - wpa_msg_ctrl(wpa_s, MSG_INFO, - WPS_EVENT_AP_AVAILABLE_PIN); + pin++; else - wpa_msg_ctrl(wpa_s, MSG_INFO, - WPS_EVENT_AP_AVAILABLE); + wps++; wpabuf_free(ie); - break; } + + if (pbc) + wpa_msg_ctrl(wpa_s, MSG_INFO, WPS_EVENT_AP_AVAILABLE_PBC); + else if (auth) + wpa_msg_ctrl(wpa_s, MSG_INFO, WPS_EVENT_AP_AVAILABLE_AUTH); + else if (pin) + wpa_msg_ctrl(wpa_s, MSG_INFO, WPS_EVENT_AP_AVAILABLE_PIN); + else if (wps) + wpa_msg_ctrl(wpa_s, MSG_INFO, WPS_EVENT_AP_AVAILABLE); }