]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: Make WPS-AP-AVAILABLE* events a bit more consistent
authorJouni Malinen <jouni.malinen@atheros.com>
Wed, 5 Jan 2011 09:49:03 +0000 (11:49 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 5 Jan 2011 09:49:03 +0000 (11:49 +0200)
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.

wpa_supplicant/wps_supplicant.c

index a5770f16dcc6edbb3aa39c9f2f4d1a0f1ee40a73..6dfea2f4455089ce08c2c523a11eb71b4ce541e8 100644 (file)
@@ -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);
 }