bgscan: Add new channel condition parameters to signal change events
[libeap.git] / wpa_supplicant / events.c
index 6d8daaf..602f992 100644 (file)
@@ -463,6 +463,11 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
                }
 
 #ifdef CONFIG_WPS
+               if ((ssid->key_mgmt & WPA_KEY_MGMT_WPS) && e && e->count > 0) {
+                       wpa_printf(MSG_DEBUG, "   skip - blacklisted (WPS)");
+                       continue;
+               }
+
                if (wpa && ssid->ssid_len == 0 &&
                    wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss))
                        check_ssid = 0;
@@ -623,7 +628,14 @@ void wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
        if (wpas_wps_scan_pbc_overlap(wpa_s, selected, ssid)) {
                wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_OVERLAP
                        "PBC session overlap");
-               wpa_supplicant_req_new_scan(wpa_s, 10, 0);
+#ifdef CONFIG_P2P
+               if (wpas_p2p_notif_pbc_overlap(wpa_s) == 1)
+                       return;
+#endif /* CONFIG_P2P */
+
+#ifdef CONFIG_WPS
+               wpas_wps_cancel(wpa_s);
+#endif /* CONFIG_WPS */
                return;
        }
 
@@ -1221,8 +1233,19 @@ static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s,
                wpa_msg(wpa_s, MSG_INFO, "WPA: 4-Way Handshake failed - "
                        "pre-shared key may be incorrect");
        }
-       if (wpa_s->wpa_state >= WPA_ASSOCIATED)
-               wpa_supplicant_req_scan(wpa_s, 0, 100000);
+       if (!wpa_s->auto_reconnect_disabled ||
+           wpa_s->key_mgmt == WPA_KEY_MGMT_WPS) {
+               wpa_printf(MSG_DEBUG, "WPA: Auto connect enabled: try to "
+                          "reconnect (wps=%d)",
+                          wpa_s->key_mgmt == WPA_KEY_MGMT_WPS);
+               if (wpa_s->wpa_state >= WPA_ASSOCIATING)
+                       wpa_supplicant_req_scan(wpa_s, 0, 100000);
+       } else {
+               wpa_printf(MSG_DEBUG, "WPA: Auto connect disabled: do not try "
+                          "to re-connect");
+               wpa_s->reassociate = 0;
+               wpa_s->disconnected = 1;
+       }
        bssid = wpa_s->bssid;
        if (is_zero_ether_addr(bssid))
                bssid = wpa_s->pending_bssid;
@@ -1547,8 +1570,18 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                        break;
                }
 #endif /* CONFIG_AP */
-               if (data)
-                       reason_code = data->deauth_info.reason_code;
+               if (data) {
+                       reason_code = data->disassoc_info.reason_code;
+                       wpa_hexdump(MSG_DEBUG, "Disassociation frame IE(s)",
+                                   data->disassoc_info.ie,
+                                   data->disassoc_info.ie_len);
+#ifdef CONFIG_P2P
+                       wpas_p2p_disassoc_notif(
+                               wpa_s, data->disassoc_info.addr, reason_code,
+                               data->disassoc_info.ie,
+                               data->disassoc_info.ie_len);
+#endif /* CONFIG_P2P */
+               }
                if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
                        sme_event_disassoc(wpa_s, data);
                /* fall through */
@@ -1565,6 +1598,17 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                                                   MAC2STR(data->deauth_info.
                                                           addr));
                                }
+                               wpa_hexdump(MSG_DEBUG,
+                                           "Deauthentication frame IE(s)",
+                                           data->deauth_info.ie,
+                                           data->deauth_info.ie_len);
+#ifdef CONFIG_P2P
+                               wpas_p2p_deauth_notif(
+                                       wpa_s, data->deauth_info.addr,
+                                       reason_code,
+                                       data->deauth_info.ie,
+                                       data->deauth_info.ie_len);
+#endif /* CONFIG_P2P */
                        }
                }
 #ifdef CONFIG_AP
@@ -1759,14 +1803,25 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
        case EVENT_SIGNAL_CHANGE:
                bgscan_notify_signal_change(
                        wpa_s, data->signal_change.above_threshold,
-                       data->signal_change.current_signal);
+                       data->signal_change.current_signal,
+                       data->signal_change.current_noise,
+                       data->signal_change.current_txrate);
                break;
        case EVENT_INTERFACE_ENABLED:
                wpa_printf(MSG_DEBUG, "Interface was enabled");
                if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
-                       wpa_supplicant_set_state(wpa_s,
-                                                WPA_DISCONNECTED);
+#ifdef CONFIG_AP
+                       if (!wpa_s->ap_iface) {
+                               wpa_supplicant_set_state(wpa_s,
+                                                        WPA_DISCONNECTED);
+                               wpa_supplicant_req_scan(wpa_s, 0, 0);
+                       } else
+                               wpa_supplicant_set_state(wpa_s,
+                                                        WPA_COMPLETED);
+#else /* CONFIG_AP */
+                       wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
                        wpa_supplicant_req_scan(wpa_s, 0, 0);
+#endif /* CONFIG_AP */
                }
                break;
        case EVENT_INTERFACE_DISABLED: