Allow WPS APs for PIN enrollment even without Selected Registrar
[wpasupplicant] / wpa_supplicant / events.c
index b3c414a..703106c 100644 (file)
@@ -32,6 +32,7 @@
 #include "blacklist.h"
 #include "wpas_glue.h"
 #include "wps_supplicant.h"
+#include "ibss_rsn.h"
 
 
 static int wpa_supplicant_select_config(struct wpa_supplicant *wpa_s)
@@ -270,7 +271,8 @@ static int wpa_supplicant_match_privacy(struct wpa_scan_res *bss,
 }
 
 
-static int wpa_supplicant_ssid_bss_match(struct wpa_ssid *ssid,
+static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
+                                        struct wpa_ssid *ssid,
                                         struct wpa_scan_res *bss)
 {
        struct wpa_ie_data ie;
@@ -278,7 +280,7 @@ static int wpa_supplicant_ssid_bss_match(struct wpa_ssid *ssid,
        const u8 *rsn_ie, *wpa_ie;
        int ret;
 
-       ret = wpas_wps_ssid_bss_match(ssid, bss);
+       ret = wpas_wps_ssid_bss_match(wpa_s, ssid, bss);
        if (ret >= 0)
                return ret;
 
@@ -424,7 +426,7 @@ wpa_supplicant_select_bss_wpa(struct wpa_supplicant *wpa_s,
 
 #ifdef CONFIG_WPS
                        if (ssid->ssid_len == 0 &&
-                           wpas_wps_ssid_wildcard_ok(ssid, bss))
+                           wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss))
                                check_ssid = 0;
 #endif /* CONFIG_WPS */
 
@@ -444,7 +446,7 @@ wpa_supplicant_select_bss_wpa(struct wpa_supplicant *wpa_s,
                                continue;
                        }
 
-                       if (!wpa_supplicant_ssid_bss_match(ssid, bss))
+                       if (!wpa_supplicant_ssid_bss_match(wpa_s, ssid, bss))
                                continue;
 
                        wpa_printf(MSG_DEBUG, "   selected WPA AP "
@@ -514,7 +516,8 @@ wpa_supplicant_select_bss_non_wpa(struct wpa_supplicant *wpa_s,
                                 * with our mode. */
                                check_ssid = 1;
                                if (ssid->ssid_len == 0 &&
-                                   wpas_wps_ssid_wildcard_ok(ssid, bss))
+                                   wpas_wps_ssid_wildcard_ok(wpa_s, ssid,
+                                                             bss))
                                        check_ssid = 0;
                        }
 #endif /* CONFIG_WPS */
@@ -629,7 +632,8 @@ static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s)
                wpas_wps_notify_scan_results(wpa_s);
        }
 
-       if (wpa_s->conf->ap_scan == 2 || wpa_s->disconnected)
+       if ((wpa_s->conf->ap_scan == 2 && !wpas_wps_searching(wpa_s)) ||
+           wpa_s->disconnected)
                return;
 
        while (selected == NULL) {
@@ -644,6 +648,7 @@ static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s)
                        wpa_printf(MSG_DEBUG, "No APs found - clear blacklist "
                                   "and try again");
                        wpa_blacklist_clear(wpa_s);
+                       wpa_s->blacklist_cleared++;
                } else if (selected == NULL) {
                        break;
                }
@@ -1066,6 +1071,17 @@ wpa_supplicant_event_ft_response(struct wpa_supplicant *wpa_s,
 #endif /* CONFIG_IEEE80211R */
 
 
+#ifdef CONFIG_IBSS_RSN
+static void wpa_supplicant_event_ibss_rsn_start(struct wpa_supplicant *wpa_s,
+                                               union wpa_event_data *data)
+{
+       if (data == NULL)
+               return;
+       ibss_rsn_start(wpa_s->ibss_rsn, data->ibss_rsn_start.peer);
+}
+#endif /* CONFIG_IBSS_RSN */
+
+
 void wpa_supplicant_event(void *ctx, wpa_event_type event,
                          union wpa_event_data *data)
 {
@@ -1105,6 +1121,11 @@ void wpa_supplicant_event(void *ctx, wpa_event_type event,
                wpa_supplicant_event_ft_response(wpa_s, data);
                break;
 #endif /* CONFIG_IEEE80211R */
+#ifdef CONFIG_IBSS_RSN
+       case EVENT_IBSS_RSN_START:
+               wpa_supplicant_event_ibss_rsn_start(wpa_s, data);
+               break;
+#endif /* CONFIG_IBSS_RSN */
        default:
                wpa_printf(MSG_INFO, "Unknown event %d", event);
                break;