Maintain a pointer to the current BSS table entry

This commit is contained in:
Jouni Malinen 2010-01-02 16:59:19 +02:00
parent a1fd2ce54e
commit 8f770587d9
6 changed files with 22 additions and 8 deletions

View File

@ -271,7 +271,8 @@ static void wpa_bss_timeout(void *eloop_ctx, void *timeout_ctx)
t.sec -= WPA_BSS_EXPIRATION_AGE; t.sec -= WPA_BSS_EXPIRATION_AGE;
dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) { 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) os_memcmp(bss->bssid, wpa_s->pending_bssid, ETH_ALEN) == 0)
continue; /* do not expire BSSes that are in use */ continue; /* do not expire BSSes that are in use */

View File

@ -2086,20 +2086,15 @@ DBusMessage * wpas_dbus_getter_current_bss(DBusMessage *message,
{ {
DBusMessage *reply = NULL; DBusMessage *reply = NULL;
char *bss_obj_path = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX); char *bss_obj_path = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX);
struct wpa_bss *bss = NULL;
if (bss_obj_path == NULL) if (bss_obj_path == NULL)
return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY, return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
NULL); NULL);
/* TODO: store current BSS or BSS id in wpa_s */ if (wpa_s->current_bss)
if (!is_zero_ether_addr(wpa_s->bssid))
bss = wpa_bss_get_bssid(wpa_s, wpa_s->bssid);
if (bss)
os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX, os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u", "%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 else
os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX, "/"); os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX, "/");

View File

@ -1037,6 +1037,17 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
wpa_s, WLAN_REASON_DEAUTH_LEAVING); wpa_s, WLAN_REASON_DEAUTH_LEAVING);
return; 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 #ifdef CONFIG_SME

View File

@ -47,6 +47,8 @@ void sme_authenticate(struct wpa_supplicant *wpa_s,
return; return;
} }
wpa_s->current_bss = bss;
os_memset(&params, 0, sizeof(params)); os_memset(&params, 0, sizeof(params));
wpa_s->reassociate = 0; wpa_s->reassociate = 0;

View File

@ -998,6 +998,7 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
return; return;
} }
wpa_supplicant_create_ap(wpa_s, ssid); wpa_supplicant_create_ap(wpa_s, ssid);
wpa_s->current_bss = bss;
#else /* CONFIG_AP */ #else /* CONFIG_AP */
wpa_printf(MSG_ERROR, "AP mode support not included in the " wpa_printf(MSG_ERROR, "AP mode support not included in the "
"build"); "build");
@ -1291,6 +1292,7 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
} }
old_ssid = wpa_s->current_ssid; old_ssid = wpa_s->current_ssid;
wpa_s->current_ssid = 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_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
wpa_supplicant_initiate_eapol(wpa_s); wpa_supplicant_initiate_eapol(wpa_s);
if (old_ssid != wpa_s->current_ssid) 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); wpa_supplicant_mark_disassoc(wpa_s);
old_ssid = wpa_s->current_ssid; old_ssid = wpa_s->current_ssid;
wpa_s->current_ssid = NULL; wpa_s->current_ssid = NULL;
wpa_s->current_bss = NULL;
wpa_sm_set_config(wpa_s->wpa, NULL); wpa_sm_set_config(wpa_s->wpa, NULL);
eapol_sm_notify_config(wpa_s->eapol, NULL, NULL); eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
if (old_ssid != wpa_s->current_ssid) 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); wpa_supplicant_mark_disassoc(wpa_s);
old_ssid = wpa_s->current_ssid; old_ssid = wpa_s->current_ssid;
wpa_s->current_ssid = NULL; wpa_s->current_ssid = NULL;
wpa_s->current_bss = NULL;
wpa_sm_set_config(wpa_s->wpa, NULL); wpa_sm_set_config(wpa_s->wpa, NULL);
eapol_sm_notify_config(wpa_s->eapol, NULL, NULL); eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
if (old_ssid != wpa_s->current_ssid) if (old_ssid != wpa_s->current_ssid)

View File

@ -323,6 +323,7 @@ struct wpa_supplicant {
int disconnected; /* all connections disabled; i.e., do no reassociate int disconnected; /* all connections disabled; i.e., do no reassociate
* before this has been cleared */ * before this has been cleared */
struct wpa_ssid *current_ssid; struct wpa_ssid *current_ssid;
struct wpa_bss *current_bss;
int ap_ies_from_associnfo; int ap_ies_from_associnfo;
unsigned int assoc_freq; unsigned int assoc_freq;