Home | History | Annotate | Download | only in rsn_supp

Lines Matching refs:pmksa

2  * WPA Supplicant - RSN PMKSA cache
23 struct rsn_pmksa_cache_entry *pmksa; /* PMKSA cache */
24 int pmksa_count; /* number of entries in PMKSA cache */
33 static void pmksa_cache_set_expiration(struct rsn_pmksa_cache *pmksa);
42 static void pmksa_cache_free_entry(struct rsn_pmksa_cache *pmksa,
46 wpa_sm_remove_pmkid(pmksa->sm, entry->network_ctx, entry->aa,
48 pmksa->pmksa_count--;
49 pmksa->free_cb(entry, pmksa->ctx, reason);
56 struct rsn_pmksa_cache *pmksa = eloop_ctx;
60 while (pmksa->pmksa && pmksa->pmksa->expiration <= now.sec) {
61 struct rsn_pmksa_cache_entry *entry = pmksa->pmksa;
62 pmksa->pmksa = entry->next;
63 wpa_printf(MSG_DEBUG, "RSN: expired PMKSA cache entry for "
65 pmksa_cache_free_entry(pmksa, entry, PMKSA_EXPIRE);
68 pmksa_cache_set_expiration(pmksa);
74 struct rsn_pmksa_cache *pmksa = eloop_ctx;
75 pmksa->sm->cur_pmksa = NULL;
76 eapol_sm_request_reauth(pmksa->sm->eapol);
80 static void pmksa_cache_set_expiration(struct rsn_pmksa_cache *pmksa)
86 eloop_cancel_timeout(pmksa_cache_expire, pmksa, NULL);
87 eloop_cancel_timeout(pmksa_cache_reauth, pmksa, NULL);
88 if (pmksa->pmksa == NULL)
91 sec = pmksa->pmksa->expiration - now.sec;
94 eloop_register_timeout(sec + 1, 0, pmksa_cache_expire, pmksa, NULL);
96 entry = pmksa->sm->cur_pmksa ? pmksa->sm->cur_pmksa :
97 pmksa_cache_get(pmksa, pmksa->sm->bssid, NULL, NULL);
99 sec = pmksa->pmksa->reauth_time - now.sec;
102 eloop_register_timeout(sec, 0, pmksa_cache_reauth, pmksa,
109 * pmksa_cache_add - Add a PMKSA cache entry
110 * @pmksa: Pointer to PMKSA cache data from pmksa_cache_init()
120 * Returns: Pointer to the added PMKSA cache entry or %NULL on error
122 * This function create a PMKSA entry for a new PMK and adds it to the PMKSA
128 pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len,
156 entry->expiration = now.sec + pmksa->sm->dot11RSNAConfigPMKLifetime;
157 entry->reauth_time = now.sec + pmksa->sm->dot11RSNAConfigPMKLifetime *
158 pmksa->sm->dot11RSNAConfigPMKReauthThreshold / 100;
163 return pmksa_cache_add_entry(pmksa, entry);
168 pmksa_cache_add_entry(struct rsn_pmksa_cache *pmksa,
175 pos = pmksa->pmksa;
185 "PMKSA entry");
190 pmksa->pmksa = pos->next;
195 * If OKC is used, there may be other PMKSA cache
203 wpa_printf(MSG_DEBUG, "RSN: Replace PMKSA entry for "
204 "the current AP and any PMKSA cache entry "
207 pmksa_cache_flush(pmksa, entry->network_ctx,
209 pmksa_cache_free_entry(pmksa, pos, PMKSA_REPLACE);
216 if (pmksa->pmksa_count >= pmksa_cache_max_entries && pmksa->pmksa) {
218 pos = pmksa->pmksa;
220 if (pos == pmksa->sm->cur_pmksa) {
222 * Never remove the current PMKSA cache entry, since
227 pmksa->pmksa->next = pos ? pos->next : NULL;
229 pmksa->pmksa = pos->next;
233 "PMKSA cache entry (for " MACSTR ") to "
236 pmksa_cache_free_entry(pmksa, pos, PMKSA_FREE);
241 pos = pmksa->pmksa;
250 entry->next = pmksa->pmksa;
251 pmksa->pmksa = entry;
252 pmksa_cache_set_expiration(pmksa);
257 pmksa->pmksa_count++;
258 wpa_printf(MSG_DEBUG, "RSN: Added PMKSA cache entry for " MACSTR
260 wpa_sm_add_pmkid(pmksa->sm, entry->network_ctx, entry->aa,
268 * pmksa_cache_flush - Flush PMKSA cache entries for a specific network
269 * @pmksa: Pointer to PMKSA cache data from pmksa_cache_init()
274 void pmksa_cache_flush(struct rsn_pmksa_cache *pmksa, void *network_ctx,
280 entry = pmksa->pmksa;
287 wpa_printf(MSG_DEBUG, "RSN: Flush PMKSA cache entry "
292 pmksa->pmksa = entry->next;
295 pmksa_cache_free_entry(pmksa, tmp, PMKSA_FREE);
303 pmksa_cache_set_expiration(pmksa);
308 * pmksa_cache_deinit - Free all entries in PMKSA cache
309 * @pmksa: Pointer to PMKSA cache data from pmksa_cache_init()
311 void pmksa_cache_deinit(struct rsn_pmksa_cache *pmksa)
315 if (pmksa == NULL)
318 entry = pmksa->pmksa;
319 pmksa->pmksa = NULL;
325 pmksa_cache_set_expiration(pmksa);
326 os_free(pmksa);
331 * pmksa_cache_get - Fetch a PMKSA cache entry
332 * @pmksa: Pointer to PMKSA cache data from pmksa_cache_init()
336 * Returns: Pointer to PMKSA cache entry or %NULL if no match was found
338 struct rsn_pmksa_cache_entry * pmksa_cache_get(struct rsn_pmksa_cache *pmksa,
342 struct rsn_pmksa_cache_entry *entry = pmksa->pmksa;
356 pmksa_cache_clone_entry(struct rsn_pmksa_cache *pmksa,
362 new_entry = pmksa_cache_add(pmksa, old_entry->pmk, old_entry->pmk_len,
364 aa, pmksa->sm->own_addr,
378 * pmksa_cache_get_opportunistic - Try to get an opportunistic PMKSA entry
379 * @pmksa: Pointer to PMKSA cache data from pmksa_cache_init()
382 * Returns: Pointer to a new PMKSA cache entry or %NULL if not available
384 * Try to create a new PMKSA cache entry opportunistically by guessing that the
386 * already an entry in PMKSA cache.
389 pmksa_cache_get_opportunistic(struct rsn_pmksa_cache *pmksa, void *network_ctx,
392 struct rsn_pmksa_cache_entry *entry = pmksa->pmksa;
399 entry = pmksa_cache_clone_entry(pmksa, entry, aa);
402 "opportunistic PMKSA cache entry "
414 * pmksa_cache_get_current - Get the current used PMKSA entry
416 * Returns: Pointer to the current PMKSA cache entry or %NULL if not available
427 * pmksa_cache_clear_current - Clear the current PMKSA entry selection
439 * pmksa_cache_set_current - Set the current PMKSA entry selection
441 * @pmkid: PMKID for selecting PMKSA or %NULL if not used
442 * @bssid: BSSID for PMKSA or %NULL if not used
444 * @try_opportunistic: Whether to allow opportunistic PMKSA caching
445 * Returns: 0 if PMKSA was found or -1 if no matching entry was found
451 struct rsn_pmksa_cache *pmksa = sm->pmksa;
452 wpa_printf(MSG_DEBUG, "RSN: PMKSA cache search - network_ctx=%p "
463 sm->cur_pmksa = pmksa_cache_get(pmksa, NULL, pmkid,
466 sm->cur_pmksa = pmksa_cache_get(pmksa, bssid, NULL,
469 sm->cur_pmksa = pmksa_cache_get_opportunistic(pmksa,
473 wpa_hexdump(MSG_DEBUG, "RSN: PMKSA cache entry found - PMKID",
477 wpa_printf(MSG_DEBUG, "RSN: No PMKSA cache entry found");
483 * pmksa_cache_list - Dump text list of entries in PMKSA cache
484 * @pmksa: Pointer to PMKSA cache data from pmksa_cache_init()
490 * current PMKSA cache contents for the ctrl_iface PMKSA command.
492 int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len)
507 entry = pmksa->pmksa;
529 struct rsn_pmksa_cache_entry * pmksa_cache_head(struct rsn_pmksa_cache *pmksa)
531 return pmksa->pmksa;
536 * pmksa_cache_init - Initialize PMKSA cache
537 * @free_cb: Callback function to be called when a PMKSA cache entry is freed
540 * Returns: Pointer to PMKSA cache data or %NULL on failure
547 struct rsn_pmksa_cache *pmksa;
549 pmksa = os_zalloc(sizeof(*pmksa));
550 if (pmksa) {
551 pmksa->free_cb = free_cb;
552 pmksa->ctx = ctx;
553 pmksa->sm = sm;
556 return pmksa;