OSDN Git Service

Send termination message only in case of wpa_supplicant_deinit() call
[android-x86/external-wpa_supplicant_8.git] / wpa_supplicant / events.c
index c540bd4..812cd52 100644 (file)
@@ -118,6 +118,10 @@ void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
        wpa_s->ibss_rsn = NULL;
 #endif /* CONFIG_IBSS_RSN */
 
+#ifdef CONFIG_AP
+       wpa_supplicant_ap_deinit(wpa_s);
+#endif /* CONFIG_AP */
+
        if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
                return;
 
@@ -128,6 +132,13 @@ void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
        os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
        wpa_s->current_bss = NULL;
        wpa_s->assoc_freq = 0;
+#ifdef CONFIG_IEEE80211R
+#ifdef CONFIG_SME
+       if (wpa_s->sme.ft_ies)
+               sme_update_ft_ies(wpa_s, NULL, NULL, 0);
+#endif /* CONFIG_SME */
+#endif /* CONFIG_IEEE80211R */
+
        if (bssid_changed)
                wpas_notify_bssid_changed(wpa_s);
 
@@ -303,6 +314,9 @@ static int wpa_supplicant_match_privacy(struct wpa_scan_res *bss,
                privacy = 1;
 #endif /* IEEE8021X_EAPOL */
 
+       if (wpa_key_mgmt_wpa(ssid->key_mgmt))
+               privacy = 1;
+
        if (bss->caps & IEEE80211_CAP_PRIVACY)
                return privacy;
        return !privacy;
@@ -572,13 +586,13 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
                        continue;
                }
 
-               if (!wpa && !wpa_supplicant_match_privacy(bss, ssid)) {
+               if (!wpa_supplicant_match_privacy(bss, ssid)) {
                        wpa_dbg(wpa_s, MSG_DEBUG, "   skip - privacy "
                                "mismatch");
                        continue;
                }
 
-               if (!wpa && (bss->caps & IEEE80211_CAP_IBSS)) {
+               if (bss->caps & IEEE80211_CAP_IBSS) {
                        wpa_dbg(wpa_s, MSG_DEBUG, "   skip - IBSS (adhoc) "
                                "network");
                        continue;
@@ -710,7 +724,12 @@ void wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
         * reassociation is requested. If we are in process of associating with
         * the selected BSSID, do not trigger new attempt.
         */
-       if (wpa_s->reassociate ||
+       if ((wpa_s->reassociate
+#ifdef ANDROID_BRCM_P2P_PATCH
+               && (os_memcmp(selected->bssid, wpa_s->bssid, ETH_ALEN) != 0)
+               && (wpa_s->wpa_state != WPA_COMPLETED)
+#endif
+               )||
            (os_memcmp(selected->bssid, wpa_s->bssid, ETH_ALEN) != 0 &&
             ((wpa_s->wpa_state != WPA_ASSOCIATING &&
               wpa_s->wpa_state != WPA_AUTHENTICATING) ||
@@ -757,28 +776,25 @@ wpa_supplicant_pick_new_network(struct wpa_supplicant *wpa_s)
 /* TODO: move the rsn_preauth_scan_result*() to be called from notify.c based
  * on BSS added and BSS changed events */
 static void wpa_supplicant_rsn_preauth_scan_results(
-       struct wpa_supplicant *wpa_s, struct wpa_scan_results *scan_res)
+       struct wpa_supplicant *wpa_s)
 {
-       int i;
+       struct wpa_bss *bss;
 
        if (rsn_preauth_scan_results(wpa_s->wpa) < 0)
                return;
 
-       for (i = scan_res->num - 1; i >= 0; i--) {
+       dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
                const u8 *ssid, *rsn;
-               struct wpa_scan_res *r;
-
-               r = scan_res->res[i];
 
-               ssid = wpa_scan_get_ie(r, WLAN_EID_SSID);
+               ssid = wpa_bss_get_ie(bss, WLAN_EID_SSID);
                if (ssid == NULL)
                        continue;
 
-               rsn = wpa_scan_get_ie(r, WLAN_EID_RSN);
+               rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
                if (rsn == NULL)
                        continue;
 
-               rsn_preauth_scan_result(wpa_s->wpa, r->bssid, ssid, rsn);
+               rsn_preauth_scan_result(wpa_s->wpa, bss->bssid, ssid, rsn);
        }
 
 }
@@ -946,8 +962,6 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
                return 0;
        }
 
-       wpa_supplicant_rsn_preauth_scan_results(wpa_s, scan_res);
-
        selected = wpa_supplicant_pick_network(wpa_s, scan_res, &ssid);
 
        if (selected) {
@@ -958,6 +972,7 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
                if (skip)
                        return 0;
                wpa_supplicant_connect(wpa_s, selected, ssid);
+               wpa_supplicant_rsn_preauth_scan_results(wpa_s);
        } else {
                wpa_scan_results_free(scan_res);
                wpa_dbg(wpa_s, MSG_DEBUG, "No suitable network found");
@@ -965,6 +980,7 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
                if (ssid) {
                        wpa_dbg(wpa_s, MSG_DEBUG, "Setup a new network");
                        wpa_supplicant_associate(wpa_s, NULL, ssid);
+                       wpa_supplicant_rsn_preauth_scan_results(wpa_s);
                } else {
                        int timeout_sec = wpa_s->scan_interval;
                        int timeout_usec = 0;
@@ -1186,6 +1202,14 @@ static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s,
        if (wpa_found || rsn_found)
                wpa_s->ap_ies_from_associnfo = 1;
 
+       if (wpa_s->assoc_freq && data->assoc_info.freq &&
+           wpa_s->assoc_freq != data->assoc_info.freq) {
+               wpa_printf(MSG_DEBUG, "Operating frequency changed from "
+                          "%u to %u MHz",
+                          wpa_s->assoc_freq, data->assoc_info.freq);
+               wpa_supplicant_update_scan_results(wpa_s);
+       }
+
        wpa_s->assoc_freq = data->assoc_info.freq;
 
        return 0;
@@ -1832,6 +1856,11 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                }
 #endif /* CONFIG_AP */
                wpa_supplicant_event_disassoc(wpa_s, reason_code);
+
+#if defined(ANDROID_BRCM_P2P_PATCH) && defined(CONFIG_P2P)
+               wpas_p2p_group_remove_notif(wpa_s, reason_code);
+#endif
+
                break;
        case EVENT_MICHAEL_MIC_FAILURE:
                wpa_supplicant_event_michael_mic_failure(wpa_s, data);
@@ -1969,6 +1998,25 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                                size_t ie_len = data->rx_mgmt.frame_len -
                                        (mgmt->u.probe_req.variable -
                                         data->rx_mgmt.frame);
+                       #ifdef ANDROID_BRCM_P2P_PATCH
+                               wpa_printf(MSG_DEBUG, "Non-AP: Probe request frame ");
+                       {
+                               /* If we are Go or client, we need not reply the probe reqest on eth0 interface */
+                               struct wpa_supplicant* ifs;
+                               int ignore = 0;
+                               for (ifs = wpa_s->global->ifaces; ifs; ifs = ifs->next) {
+                                       if ( (ifs->p2p_group_interface == P2P_GROUP_INTERFACE_GO ) ||(ifs->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT )) {
+                                               wpa_printf(MSG_DEBUG, "Non-AP: NEERAJKG Ignoring Probe request");
+                                               ignore = 1;
+                                               break;
+                                       }
+                               }
+                               if(ignore)
+                                       break;
+                               else
+                                       wpa_printf(MSG_DEBUG, "Non-AP: Couln't Ignore Probe request %d", wpa_s->p2p_group_interface);
+                       }
+                       #endif
                                wpas_p2p_probe_req_rx(wpa_s, src, ie, ie_len);
                                break;
                        }