[RFC PATCH 4/4] keep and use list of PSK entries per station
Michael Braun
michael-dev
Sun Aug 26 08:46:09 PDT 2012
This updates struct sta_info to keep a linked list of PSKs per station and
lets hostapd_wpa_auth_get_psk iterate over all those entries, too.
---
src/ap/ieee802_11.c | 13 +++++++------
src/ap/sta_info.c | 6 +++++-
src/ap/sta_info.h | 2 +-
src/ap/wpa_auth_glue.c | 15 +++++++++++----
4 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index 246b773..5379cbf 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -412,13 +412,14 @@ static void handle_auth(struct hostapd_data *hapd,
HOSTAPD_LEVEL_INFO, "VLAN ID %d", sta->vlan_id);
}
- if (psk && hapd->conf->wpa_psk_radius != PSK_RADIUS_IGNORED) {
- os_free(sta->psk);
- sta->psk = os_malloc(PMK_LEN);
- if (sta->psk)
- os_memcpy(sta->psk, psk->psk, PMK_LEN);
+ while (sta->psk) {
+ struct hostapd_sta_wpa_psk_short *prev = sta->psk;
+ sta->psk = sta->psk->next;
+ os_free(prev);
+ }
+ if (hapd->conf->wpa_psk_radius != PSK_RADIUS_IGNORED) {
+ sta->psk = psk; psk = NULL;
} else {
- os_free(sta->psk);
sta->psk = NULL;
}
diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c
index d61177f..b033f7c 100644
--- a/src/ap/sta_info.c
+++ b/src/ap/sta_info.c
@@ -234,7 +234,11 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
wpabuf_free(sta->p2p_ie);
os_free(sta->ht_capabilities);
- os_free(sta->psk);
+ while (sta->psk) {
+ struct hostapd_sta_wpa_psk_short* prev = sta->psk;
+ sta->psk = sta->psk->next;
+ os_free(prev);
+ }
os_free(sta->identity);
os_free(sta->radius_cui);
diff --git a/src/ap/sta_info.h b/src/ap/sta_info.h
index b3c57b4..e5213d4 100644
--- a/src/ap/sta_info.h
+++ b/src/ap/sta_info.h
@@ -95,7 +95,7 @@ struct sta_info {
struct hostapd_ssid *ssid_probe; /* SSID selection based on ProbeReq */
int vlan_id;
- u8 *psk; /* PSK from RADIUS authentication server */
+ struct hostapd_sta_wpa_psk_short *psk; /* PSKs from RADIUS authentication server */
char *identity; /* User-Name from RADIUS */
char *radius_cui; /* Chargeable-User-Identity from RADIUS */
diff --git a/src/ap/wpa_auth_glue.c b/src/ap/wpa_auth_glue.c
index bdc89e4..21eb3b2 100644
--- a/src/ap/wpa_auth_glue.c
+++ b/src/ap/wpa_auth_glue.c
@@ -16,12 +16,12 @@
#include "l2_packet/l2_packet.h"
#include "drivers/driver.h"
#include "hostapd.h"
+#include "ap_config.h"
#include "ieee802_1x.h"
#include "preauth_auth.h"
#include "sta_info.h"
#include "tkip_countermeasures.h"
#include "ap_drv_ops.h"
-#include "ap_config.h"
#include "wpa_auth.h"
#include "wpa_auth_glue.h"
@@ -188,10 +188,17 @@ static const u8 * hostapd_wpa_auth_get_psk(void *ctx, const u8 *addr,
/*
* This is about to iterate over all psks, prev_psk gives the last
* returned psk which should not be returned again.
- * logic list (all hostapd_get_psk; sta->psk)
+ * logic list (all hostapd_get_psk; all sta->psk)
*/
- if (sta && sta->psk && !psk && sta->psk != prev_psk)
- psk = sta->psk;
+ if (sta && sta->psk && !psk) {
+ struct hostapd_sta_wpa_psk_short* pos;
+ for (pos = sta->psk; pos; pos = pos->next) {
+ if (pos->psk == prev_psk && pos->next) {
+ psk = pos->next->psk;
+ break;
+ }
+ }
+ }
return psk;
}
More information about the Hostap
mailing list