D-Bus: Add Signal to notify WPS PBC Overlap event
[mech_eap.git] / wpa_supplicant / events.c
index 558e977..3af1c7d 100644 (file)
@@ -828,9 +828,9 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
        osen = ie != NULL;
 
        wpa_dbg(wpa_s, MSG_DEBUG, "%d: " MACSTR " ssid='%s' "
-               "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x level=%d%s%s%s",
+               "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x level=%d freq=%d %s%s%s",
                i, MAC2STR(bss->bssid), wpa_ssid_txt(bss->ssid, bss->ssid_len),
-               wpa_ie_len, rsn_ie_len, bss->caps, bss->level,
+               wpa_ie_len, rsn_ie_len, bss->caps, bss->level, bss->freq,
                wpa_bss_get_vendor_ie(bss, WPS_IE_VENDOR_TYPE) ? " wps" : "",
                (wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) ||
                 wpa_bss_get_vendor_ie_beacon(bss, P2P_IE_VENDOR_TYPE)) ?
@@ -1036,6 +1036,19 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
                 */
 #endif /* CONFIG_P2P */
 
+               if (os_reltime_before(&bss->last_update, &wpa_s->scan_min_time))
+               {
+                       struct os_reltime diff;
+
+                       os_reltime_sub(&wpa_s->scan_min_time,
+                                      &bss->last_update, &diff);
+                       wpa_dbg(wpa_s, MSG_DEBUG,
+                               "   skip - scan result not recent enough (%u.%06u seconds too old)",
+                               (unsigned int) diff.sec,
+                               (unsigned int) diff.usec);
+                       continue;
+               }
+
                /* Matching configuration found */
                return ssid;
        }
@@ -1188,6 +1201,7 @@ int wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
 #endif /* CONFIG_P2P */
 
 #ifdef CONFIG_WPS
+               wpas_wps_pbc_overlap(wpa_s);
                wpas_wps_cancel(wpa_s);
 #endif /* CONFIG_WPS */
                return -1;
@@ -2054,6 +2068,7 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
 {
        u8 bssid[ETH_ALEN];
        int ft_completed;
+       int new_bss = 0;
 
 #ifdef CONFIG_AP
        if (wpa_s->ap_iface) {
@@ -2085,6 +2100,7 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
        if (os_memcmp(bssid, wpa_s->bssid, ETH_ALEN) != 0) {
                wpa_dbg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID="
                        MACSTR, MAC2STR(bssid));
+               new_bss = 1;
                random_add_randomness(bssid, ETH_ALEN);
                os_memcpy(wpa_s->bssid, bssid, ETH_ALEN);
                os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
@@ -2098,13 +2114,13 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
                                wpa_s, WLAN_REASON_DEAUTH_LEAVING);
                        return;
                }
+       }
 
-               if (wpa_s->conf->ap_scan == 1 &&
-                   wpa_s->drv_flags & WPA_DRIVER_FLAGS_BSS_SELECTION) {
-                       if (wpa_supplicant_assoc_update_ie(wpa_s) < 0)
-                               wpa_msg(wpa_s, MSG_WARNING,
-                                       "WPA/RSN IEs not updated");
-               }
+       if (wpa_s->conf->ap_scan == 1 &&
+           wpa_s->drv_flags & WPA_DRIVER_FLAGS_BSS_SELECTION) {
+               if (wpa_supplicant_assoc_update_ie(wpa_s) < 0 && new_bss)
+                       wpa_msg(wpa_s, MSG_WARNING,
+                               "WPA/RSN IEs not updated");
        }
 
 #ifdef CONFIG_SME
@@ -2377,7 +2393,8 @@ static void wpa_supplicant_event_disassoc_finish(struct wpa_supplicant *wpa_s,
                        "try to re-connect");
                wpa_s->reassociate = 0;
                wpa_s->disconnected = 1;
-               wpa_supplicant_cancel_sched_scan(wpa_s);
+               if (!wpa_s->pno)
+                       wpa_supplicant_cancel_sched_scan(wpa_s);
        }
        bssid = wpa_s->bssid;
        if (is_zero_ether_addr(bssid))
@@ -2998,25 +3015,13 @@ static void wpa_supplicant_update_channel_list(
        if (wpa_s->drv_priv == NULL)
                return; /* Ignore event during drv initialization */
 
-       free_hw_features(wpa_s);
-       wpa_s->hw.modes = wpa_drv_get_hw_feature_data(
-               wpa_s, &wpa_s->hw.num_modes, &wpa_s->hw.flags);
-
-       wpas_p2p_update_channel_list(wpa_s);
-
-       /*
-        * Check other interfaces to see if they share the same radio. If
-        * so, they get updated with this same hw mode info.
-        */
        dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant,
                         radio_list) {
-               if (ifs != wpa_s) {
-                       wpa_printf(MSG_DEBUG, "%s: Updating hw mode",
-                                  ifs->ifname);
-                       free_hw_features(ifs);
-                       ifs->hw.modes = wpa_drv_get_hw_feature_data(
-                               ifs, &ifs->hw.num_modes, &ifs->hw.flags);
-               }
+               wpa_printf(MSG_DEBUG, "%s: Updating hw mode",
+                          ifs->ifname);
+               free_hw_features(ifs);
+               ifs->hw.modes = wpa_drv_get_hw_feature_data(
+                       ifs, &ifs->hw.num_modes, &ifs->hw.flags);
        }
 
        /* Restart sched_scan with updated channel list */
@@ -3026,6 +3031,8 @@ static void wpa_supplicant_update_channel_list(
                wpa_supplicant_cancel_sched_scan(wpa_s);
                wpa_supplicant_req_scan(wpa_s, 0, 0);
        }
+
+       wpas_p2p_update_channel_list(wpa_s, WPAS_P2P_CHANNEL_UPDATE_DRIVER);
 }
 
 
@@ -3164,7 +3171,8 @@ static void wpa_supplicant_notify_avoid_freq(struct wpa_supplicant *wpa_s,
                 * The update channel flow will also take care of moving a GO
                 * from the unsafe frequency if needed.
                 */
-               wpas_p2p_update_channel_list(wpa_s);
+               wpas_p2p_update_channel_list(wpa_s,
+                                            WPAS_P2P_CHANNEL_UPDATE_AVOID);
        }
 #endif /* CONFIG_P2P */