aboutsummaryrefslogtreecommitdiffstats
path: root/src/rsn_supp/preauth.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-11-29 15:06:03 (GMT)
committerJouni Malinen <j@w1.fi>2009-11-29 15:06:03 (GMT)
commit6ae9318536ecffa7374431767e2e3cb0c6b56758 (patch)
treedc3d65a2d93159b7444d91fb64cd4282abca57a1 /src/rsn_supp/preauth.c
parent4d69dc3ecc6b4a4665c8c5164587876751abfec2 (diff)
downloadhostap-6ae9318536ecffa7374431767e2e3cb0c6b56758.zip
hostap-6ae9318536ecffa7374431767e2e3cb0c6b56758.tar.gz
hostap-6ae9318536ecffa7374431767e2e3cb0c6b56758.tar.bz2
Split scan processing for RSN preauthentication into parts
This avoids passing the raw scan results into the RSN code and by doing so, removes the only dependency on src/drivers from the src/rsn_supp code (or from any src subdirectory for that matter).
Diffstat (limited to 'src/rsn_supp/preauth.c')
-rw-r--r--src/rsn_supp/preauth.c76
1 files changed, 37 insertions, 39 deletions
diff --git a/src/rsn_supp/preauth.c b/src/rsn_supp/preauth.c
index 07d5b81..f4e8cbb 100644
--- a/src/rsn_supp/preauth.c
+++ b/src/rsn_supp/preauth.c
@@ -1,6 +1,6 @@
/*
* WPA Supplicant - RSN pre-authentication
- * Copyright (c) 2003-2008, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2003-2009, Jouni Malinen <j@w1.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -16,7 +16,6 @@
#include "common.h"
#include "wpa.h"
-#include "drivers/driver.h"
#include "eloop.h"
#include "l2_packet/l2_packet.h"
#include "eapol_supp/eapol_supp_sm.h"
@@ -423,23 +422,18 @@ void pmksa_candidate_add(struct wpa_sm *sm, const u8 *bssid,
/* TODO: schedule periodic scans if current AP supports preauth */
/**
- * rsn_preauth_scan_results - Process scan results to find PMKSA candidates
+ * rsn_preauth_scan_results - Start processing scan results for canditates
* @sm: Pointer to WPA state machine data from wpa_sm_init()
- * @results: Scan results
+ * Returns: 0 if ready to process results or -1 to skip processing
*
- * This functions goes through the scan results and adds all suitable APs
- * (Authenticators) into PMKSA candidate list.
+ * This functions is used to notify RSN code about start of new scan results
+ * processing. The actual scan results will be provided by calling
+ * rsn_preauth_scan_result() for each BSS if this function returned 0.
*/
-void rsn_preauth_scan_results(struct wpa_sm *sm,
- struct wpa_scan_results *results)
+int rsn_preauth_scan_results(struct wpa_sm *sm)
{
- struct wpa_scan_res *r;
- struct wpa_ie_data ie;
- int i;
- struct rsn_pmksa_cache_entry *pmksa;
-
if (sm->ssid_len == 0)
- return;
+ return -1;
/*
* TODO: is it ok to free all candidates? What about the entries
@@ -447,37 +441,41 @@ void rsn_preauth_scan_results(struct wpa_sm *sm,
*/
pmksa_candidate_free(sm);
- for (i = results->num - 1; i >= 0; i--) {
- const u8 *ssid, *rsn;
+ return 0;
+}
- r = results->res[i];
- ssid = wpa_scan_get_ie(r, WLAN_EID_SSID);
- if (ssid == NULL || ssid[1] != sm->ssid_len ||
- os_memcmp(ssid + 2, sm->ssid, ssid[1]) != 0)
- continue;
+/**
+ * rsn_preauth_scan_result - Processing scan result for PMKSA canditates
+ * @sm: Pointer to WPA state machine data from wpa_sm_init()
+ *
+ * Add all suitable APs (Authenticators) from scan results into PMKSA
+ * candidate list.
+ */
+void rsn_preauth_scan_result(struct wpa_sm *sm, const u8 *bssid,
+ const u8 *ssid, const u8 *rsn)
+{
+ struct wpa_ie_data ie;
+ struct rsn_pmksa_cache_entry *pmksa;
+
+ if (ssid[1] != sm->ssid_len ||
+ os_memcmp(ssid + 2, sm->ssid, sm->ssid_len) != 0)
+ return; /* Not for the current SSID */
- if (os_memcmp(r->bssid, sm->bssid, ETH_ALEN) == 0)
- continue;
+ if (os_memcmp(bssid, sm->bssid, ETH_ALEN) == 0)
+ return; /* Ignore current AP */
- rsn = wpa_scan_get_ie(r, WLAN_EID_RSN);
- if (rsn == NULL || wpa_parse_wpa_ie(rsn, 2 + rsn[1], &ie))
- continue;
+ if (wpa_parse_wpa_ie(rsn, 2 + rsn[1], &ie))
+ return;
- pmksa = pmksa_cache_get(sm->pmksa, r->bssid, NULL);
- if (pmksa &&
- (!pmksa->opportunistic ||
- !(ie.capabilities & WPA_CAPABILITY_PREAUTH)))
- continue;
+ pmksa = pmksa_cache_get(sm->pmksa, bssid, NULL);
+ if (pmksa && (!pmksa->opportunistic ||
+ !(ie.capabilities & WPA_CAPABILITY_PREAUTH)))
+ return;
- /*
- * Give less priority to candidates found from normal
- * scan results.
- */
- pmksa_candidate_add(sm, r->bssid,
- PMKID_CANDIDATE_PRIO_SCAN,
- ie.capabilities & WPA_CAPABILITY_PREAUTH);
- }
+ /* Give less priority to candidates found from normal scan results. */
+ pmksa_candidate_add(sm, bssid, PMKID_CANDIDATE_PRIO_SCAN,
+ ie.capabilities & WPA_CAPABILITY_PREAUTH);
}