Maintain a pointer to the current BSS table entry
authorJouni Malinen <j@w1.fi>
Sat, 2 Jan 2010 14:59:19 +0000 (16:59 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 2 Jan 2010 14:59:19 +0000 (16:59 +0200)
wpa_supplicant/bss.c
wpa_supplicant/dbus/dbus_new_handlers.c
wpa_supplicant/events.c
wpa_supplicant/sme.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index a981f89..62086a4 100644 (file)
@@ -271,7 +271,8 @@ static void wpa_bss_timeout(void *eloop_ctx, void *timeout_ctx)
        t.sec -= WPA_BSS_EXPIRATION_AGE;
 
        dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) {
-               if (os_memcmp(bss->bssid, wpa_s->bssid, ETH_ALEN) == 0 ||
+               if (bss == wpa_s->current_bss ||
+                   os_memcmp(bss->bssid, wpa_s->bssid, ETH_ALEN) == 0 ||
                    os_memcmp(bss->bssid, wpa_s->pending_bssid, ETH_ALEN) == 0)
                        continue; /* do not expire BSSes that are in use */
 
index ea2e5cb..315caec 100644 (file)
@@ -2086,20 +2086,15 @@ DBusMessage * wpas_dbus_getter_current_bss(DBusMessage *message,
 {
        DBusMessage *reply = NULL;
        char *bss_obj_path = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX);
-       struct wpa_bss *bss = NULL;
 
        if (bss_obj_path == NULL)
                return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
                                              NULL);
 
-       /* TODO: store current BSS or BSS id in wpa_s */
-       if (!is_zero_ether_addr(wpa_s->bssid))
-               bss = wpa_bss_get_bssid(wpa_s, wpa_s->bssid);
-
-       if (bss)
+       if (wpa_s->current_bss)
                os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
                            "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
-                           wpa_s->dbus_new_path, bss->id);
+                           wpa_s->dbus_new_path, wpa_s->current_bss->id);
        else
                os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX, "/");
 
index 7a9b557..3c2010c 100644 (file)
@@ -1037,6 +1037,17 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
                                wpa_s, WLAN_REASON_DEAUTH_LEAVING);
                        return;
                }
+               if (wpa_s->current_ssid) {
+                       struct wpa_bss *bss = NULL;
+                       struct wpa_ssid *ssid = wpa_s->current_ssid;
+                       if (ssid->ssid_len > 0)
+                               bss = wpa_bss_get(wpa_s, bssid,
+                                                 ssid->ssid, ssid->ssid_len);
+                       if (!bss)
+                               bss = wpa_bss_get_bssid(wpa_s, bssid);
+                       if (bss)
+                               wpa_s->current_bss = bss;
+               }
        }
 
 #ifdef CONFIG_SME
index 5ed95eb..580ed2a 100644 (file)
@@ -47,6 +47,8 @@ void sme_authenticate(struct wpa_supplicant *wpa_s,
                return;
        }
 
+       wpa_s->current_bss = bss;
+
        os_memset(&params, 0, sizeof(params));
        wpa_s->reassociate = 0;
 
index 8a38b26..fd8a19f 100644 (file)
@@ -998,6 +998,7 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
                        return;
                }
                wpa_supplicant_create_ap(wpa_s, ssid);
+               wpa_s->current_bss = bss;
 #else /* CONFIG_AP */
                wpa_printf(MSG_ERROR, "AP mode support not included in the "
                           "build");
@@ -1291,6 +1292,7 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
        }
        old_ssid = wpa_s->current_ssid;
        wpa_s->current_ssid = ssid;
+       wpa_s->current_bss = bss;
        wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
        wpa_supplicant_initiate_eapol(wpa_s);
        if (old_ssid != wpa_s->current_ssid)
@@ -1323,6 +1325,7 @@ void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
        wpa_supplicant_mark_disassoc(wpa_s);
        old_ssid = wpa_s->current_ssid;
        wpa_s->current_ssid = NULL;
+       wpa_s->current_bss = NULL;
        wpa_sm_set_config(wpa_s->wpa, NULL);
        eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
        if (old_ssid != wpa_s->current_ssid)
@@ -1356,6 +1359,7 @@ void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
        wpa_supplicant_mark_disassoc(wpa_s);
        old_ssid = wpa_s->current_ssid;
        wpa_s->current_ssid = NULL;
+       wpa_s->current_bss = NULL;
        wpa_sm_set_config(wpa_s->wpa, NULL);
        eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
        if (old_ssid != wpa_s->current_ssid)
index 707fac4..f86a172 100644 (file)
@@ -323,6 +323,7 @@ struct wpa_supplicant {
        int disconnected; /* all connections disabled; i.e., do no reassociate
                           * before this has been cleared */
        struct wpa_ssid *current_ssid;
+       struct wpa_bss *current_bss;
        int ap_ies_from_associnfo;
        unsigned int assoc_freq;