Lines Matching full:entry
31 void (*free_cb)(struct rsn_pmksa_cache_entry *entry, void *ctx);
39 static void _pmksa_cache_free_entry(struct rsn_pmksa_cache_entry *entry)
41 os_free(entry->vlan_desc);
42 os_free(entry->identity);
43 os_free(entry->dpp_pkhash);
44 wpabuf_free(entry->cui);
46 radius_free_class(&entry->radius_class);
48 bin_clear_free(entry, sizeof(*entry));
53 struct rsn_pmksa_cache_entry *entry)
61 pmksa->free_cb(entry, pmksa->ctx);
64 hash = PMKID_HASH(entry->pmkid);
68 if (pos == entry) {
70 prev->hnext = entry->hnext;
72 pmksa->pmkid[hash] = entry->hnext;
79 /* unlink from entry list */
83 if (pos == entry) {
85 prev->next = entry->next;
87 pmksa->pmksa = entry->next;
94 _pmksa_cache_free_entry(entry);
105 wpa_printf(MSG_DEBUG, "RSN: Flush PMKSA cache entry for "
119 wpa_printf(MSG_DEBUG, "RSN: expired PMKSA cache entry for "
144 static void pmksa_cache_from_eapol_data(struct rsn_pmksa_cache_entry *entry,
153 entry->identity = os_malloc(eapol->identity_len);
154 if (entry->identity) {
155 entry->identity_len = eapol->identity_len;
156 os_memcpy(entry->identity, eapol->identity,
162 entry->cui = wpabuf_dup(eapol->radius_cui);
165 radius_copy_class(&entry->radius_class, &eapol->radius_class);
168 entry->eap_type_authsrv = eapol->eap_type_authsrv;
172 entry->vlan_desc = os_zalloc(sizeof(struct vlan_description));
173 if (entry->vlan_desc)
174 *entry->vlan_desc = *vlan_desc;
176 entry->vlan_desc = NULL;
179 entry->acct_multi_session_id = eapol->acct_multi_session_id;
184 struct rsn_pmksa_cache_entry *entry,
187 if (entry == NULL || eapol == NULL)
190 if (entry->identity) {
192 eapol->identity = os_malloc(entry->identity_len);
194 eapol->identity_len = entry->identity_len;
195 os_memcpy(eapol->identity, entry->identity,
196 entry->identity_len);
202 if (entry->cui) {
204 eapol->radius_cui = wpabuf_dup(entry->cui);
209 radius_copy_class(&eapol->radius_class, &entry->radius_class);
216 eapol->eap_type_authsrv = entry->eap_type_authsrv;
218 ap_sta_set_vlan(hapd, eapol->sta, entry->vlan_desc);
221 eapol->acct_multi_session_id = entry->acct_multi_session_id;
226 struct rsn_pmksa_cache_entry *entry)
231 /* Add the new entry; order by expiration time */
235 if (pos->expiration > entry->expiration)
241 entry->next = pmksa->pmksa;
242 pmksa->pmksa = entry;
244 entry->next = prev->next;
245 prev->next = entry;
248 hash = PMKID_HASH(entry->pmkid);
249 entry->hnext = pmksa->pmkid[hash];
250 pmksa->pmkid[hash] = entry;
255 wpa_printf(MSG_DEBUG, "RSN: added PMKSA cache entry for " MACSTR,
256 MAC2STR(entry->spa));
257 wpa_hexdump(MSG_DEBUG, "RSN: added PMKID", entry->pmkid, PMKID_LEN);
262 * pmksa_cache_auth_add - Add a PMKSA cache entry
274 * Returns: Pointer to the added PMKSA cache entry or %NULL on error
276 * This function create a PMKSA entry for a new PMK and adds it to the PMKSA
277 * cache. If an old entry is already in the cache for the same Supplicant,
278 * this entry will be replaced with the new entry. PMKID will be calculated
288 struct rsn_pmksa_cache_entry *entry;
290 entry = pmksa_cache_auth_create_entry(pmk, pmk_len, pmkid, kck, kck_len,
294 if (pmksa_cache_auth_add_entry(pmksa, entry) < 0)
297 return entry;
302 * pmksa_cache_auth_create_entry - Create a PMKSA cache entry
313 * Returns: Pointer to the added PMKSA cache entry or %NULL on error
315 * This function creates a PMKSA entry.
323 struct rsn_pmksa_cache_entry *entry;
332 entry = os_zalloc(sizeof(*entry));
333 if (entry == NULL)
335 os_memcpy(entry->pmk, pmk, pmk_len);
336 entry->pmk_len = pmk_len;
338 os_memcpy(entry->kck, kck, kck_len);
339 entry->kck_len = kck_len;
342 os_memcpy(entry->pmkid, pmkid, PMKID_LEN);
344 rsn_pmkid_suite_b_192(kck, kck_len, aa, spa, entry->pmkid);
346 rsn_pmkid_suite_b(kck, kck_len, aa, spa, entry->pmkid);
348 rsn_pmkid(pmk, pmk_len, aa, spa, entry->pmkid, akmp);
350 entry->expiration = now.sec;
352 entry->expiration += session_timeout;
354 entry->expiration += dot11RSNAConfigPMKLifetime;
355 entry->akmp = akmp;
356 os_memcpy(entry->spa, spa, ETH_ALEN);
357 pmksa_cache_from_eapol_data(entry, eapol);
359 return entry;
364 * pmksa_cache_auth_add_entry - Add a PMKSA cache entry
366 * @entry: Pointer to PMKSA cache entry
368 * This function adds PMKSA cache entry to the PMKSA cache. If an old entry is
369 * already in the cache for the same Supplicant, this entry will be replaced
370 * with the new entry. PMKID will be calculated based on the PMK.
373 struct rsn_pmksa_cache_entry *entry)
377 if (entry == NULL)
380 /* Replace an old entry for the same STA (if found) with the new entry
382 pos = pmksa_cache_auth_get(pmksa, entry->spa, NULL);
387 /* Remove the oldest entry to make room for the new entry */
389 "entry (for " MACSTR ") to make room for new one",
394 pmksa_cache_link_entry(pmksa, entry);
405 struct rsn_pmksa_cache_entry *entry;
407 entry = os_zalloc(sizeof(*entry));
408 if (entry == NULL)
410 os_memcpy(entry->pmkid, pmkid, PMKID_LEN);
411 os_memcpy(entry->pmk, old_entry->pmk, old_entry->pmk_len);
412 entry->pmk_len = old_entry->pmk_len;
413 entry->expiration = old_entry->expiration;
414 entry->akmp = old_entry->akmp;
415 os_memcpy(entry->spa, old_entry->spa, ETH_ALEN);
416 entry->opportunistic = 1;
418 entry->identity = os_malloc(old_entry->identity_len);
419 if (entry->identity) {
420 entry->identity_len = old_entry->identity_len;
421 os_memcpy(entry->identity, old_entry->identity,
426 entry->cui = wpabuf_dup(old_entry->cui);
428 radius_copy_class(&entry->radius_class, &old_entry->radius_class);
430 entry->eap_type_authsrv = old_entry->eap_type_authsrv;
432 entry->vlan_desc = os_zalloc(sizeof(struct vlan_description));
433 if (entry->vlan_desc)
434 *entry->vlan_desc = *old_entry->vlan_desc;
436 entry->vlan_desc = NULL;
438 entry->opportunistic = 1;
440 pmksa_cache_link_entry(pmksa, entry);
442 return entry;
452 struct rsn_pmksa_cache_entry *entry, *prev;
458 entry = pmksa->pmksa;
459 while (entry) {
460 prev = entry;
461 entry = entry->next;
474 * pmksa_cache_auth_get - Fetch a PMKSA cache entry
478 * Returns: Pointer to PMKSA cache entry or %NULL if no match was found
484 struct rsn_pmksa_cache_entry *entry;
487 for (entry = pmksa->pmkid[PMKID_HASH(pmkid)]; entry;
488 entry = entry->hnext) {
490 ether_addr_equal(entry->spa, spa)) &&
491 os_memcmp(entry->pmkid, pmkid, PMKID_LEN) == 0)
492 return entry;
495 for (entry = pmksa->pmksa; entry; entry = entry->next) {
497 ether_addr_equal(entry->spa, spa))
498 return entry;
507 * pmksa_cache_get_okc - Fetch a PMKSA cache entry using OKC
512 * Returns: Pointer to PMKSA cache entry or %NULL if no match was found
520 struct rsn_pmksa_cache_entry *entry;
523 for (entry = pmksa->pmksa; entry; entry = entry->next) {
524 if (!ether_addr_equal(entry->spa, spa))
526 if (wpa_key_mgmt_sae(entry->akmp) ||
527 wpa_key_mgmt_fils(entry->akmp)) {
528 if (os_memcmp(entry->pmkid, pmkid, PMKID_LEN) == 0)
529 return entry;
532 if (entry->akmp == WPA_KEY_MGMT_IEEE8021X_SUITE_B_192 &&
533 entry->kck_len > 0)
534 rsn_pmkid_suite_b_192(entry->kck, entry->kck_len,
536 else if (wpa_key_mgmt_suite_b(entry->akmp) &&
537 entry->kck_len > 0)
538 rsn_pmkid_suite_b(entry->kck, entry->kck_len, aa, spa,
541 rsn_pmkid(entry->pmk, entry->pmk_len, aa, spa,
542 new_pmkid, entry->akmp);
544 return entry;
552 * @free_cb: Callback function to be called when a PMKSA cache entry is freed
557 pmksa_cache_auth_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry,
572 static int das_attr_match(struct rsn_pmksa_cache_entry *entry,
578 if (!ether_addr_equal(attr->sta_addr, entry->spa))
589 (unsigned long long) entry->acct_multi_session_id);
596 if (!entry->cui ||
597 attr->cui_len != wpabuf_len(entry->cui) ||
598 os_memcmp(attr->cui, wpabuf_head(entry->cui),
605 if (!entry->identity ||
606 attr->user_name_len != entry->identity_len ||
607 os_memcmp(attr->user_name, entry->identity,
621 struct rsn_pmksa_cache_entry *entry, *prev;
626 entry = pmksa->pmksa;
627 while (entry) {
628 if (das_attr_match(entry, attr)) {
630 prev = entry;
631 entry = entry->next;
635 entry = entry->next;
656 struct rsn_pmksa_cache_entry *entry;
666 entry = pmksa->pmksa;
667 while (entry) {
669 i, MAC2STR(entry->spa));
673 pos += wpa_snprintf_hex(pos, buf + len - pos, entry->pmkid,
676 (int) (entry->expiration - now.sec),
677 entry->opportunistic);
681 entry = entry->next;
707 struct rsn_pmksa_cache_entry *entry;
716 * Entry format:
719 for (entry = pmksa->pmksa; entry; entry = entry->next) {
720 if (addr && !ether_addr_equal(entry->spa, addr))
724 MAC2STR(entry->spa));
729 pos += wpa_snprintf_hex(pos, end - pos, entry->pmkid,
737 pos += wpa_snprintf_hex(pos, end - pos, entry->pmk,
738 entry->pmk_len);
741 (int) (entry->expiration - now.sec));