/** * pmksa_cache_set_current - Set the current PMKSA entry selection * @sm: Pointer to WPA state machine data from wpa_sm_init() * @pmkid: PMKID for selecting PMKSA or %NULL if not used * @bssid: BSSID for PMKSA or %NULL if not used * @network_ctx: Network configuration context * @try_opportunistic: Whether to allow opportunistic PMKSA caching * Returns: 0 if PMKSA was found or -1 if no matching entry was found */ int pmksa_cache_set_current(struct wpa_sm *sm, const u8 *pmkid, const u8 *bssid, void *network_ctx, int try_opportunistic) { struct rsn_pmksa_cache *pmksa = sm->pmksa; wpa_printf(MSG_DEBUG, "RSN: PMKSA cache search - network_ctx=%p " "try_opportunistic=%d", network_ctx, try_opportunistic); if (pmkid) wpa_hexdump(MSG_DEBUG, "RSN: Search for PMKID", pmkid, PMKID_LEN); if (bssid) wpa_printf(MSG_DEBUG, "RSN: Search for BSSID " MACSTR, MAC2STR(bssid)); sm->cur_pmksa = NULL; if (pmkid) sm->cur_pmksa = pmksa_cache_get(pmksa, NULL, pmkid, network_ctx); if (sm->cur_pmksa == NULL && bssid) sm->cur_pmksa = pmksa_cache_get(pmksa, bssid, NULL, network_ctx); if (sm->cur_pmksa == NULL && try_opportunistic && bssid) sm->cur_pmksa = pmksa_cache_get_opportunistic(pmksa, network_ctx, bssid); if (sm->cur_pmksa) { wpa_hexdump(MSG_DEBUG, "RSN: PMKSA cache entry found - PMKID", sm->cur_pmksa->pmkid, PMKID_LEN); return 0; } wpa_printf(MSG_DEBUG, "RSN: No PMKSA cache entry found"); return -1; }
/** * pmksa_cache_set_current - Set the current PMKSA entry selection * @sm: Pointer to WPA state machine data from wpa_sm_init() * @pmkid: PMKID for selecting PMKSA or %NULL if not used * @bssid: BSSID for PMKSA or %NULL if not used * @ssid: The network configuration for the current network * @try_opportunistic: Whether to allow opportunistic PMKSA caching * Returns: 0 if PMKSA was found or -1 if no matching entry was found */ int pmksa_cache_set_current(struct wpa_sm *sm, const u8 *pmkid, const u8 *bssid, struct wpa_ssid *ssid, int try_opportunistic) { sm->cur_pmksa = NULL; if (pmkid) sm->cur_pmksa = pmksa_cache_get(sm, NULL, pmkid); if (sm->cur_pmksa == NULL && bssid) sm->cur_pmksa = pmksa_cache_get(sm, bssid, NULL); if (sm->cur_pmksa == NULL && try_opportunistic && bssid) sm->cur_pmksa = pmksa_cache_get_opportunistic(sm, ssid, bssid); if (sm->cur_pmksa) { wpa_hexdump(MSG_DEBUG, "RSN: PMKID", sm->cur_pmksa->pmkid, PMKID_LEN); return 0; } return -1; }
/** * pmksa_cache_set_current - Set the current PMKSA entry selection * @sm: Pointer to WPA state machine data from wpa_sm_init() * @pmkid: PMKID for selecting PMKSA or %NULL if not used * @bssid: BSSID for PMKSA or %NULL if not used * @network_ctx: Network configuration context * @try_opportunistic: Whether to allow opportunistic PMKSA caching * Returns: 0 if PMKSA was found or -1 if no matching entry was found */ int pmksa_cache_set_current(struct wpa_sm *sm, const u8 *pmkid, const u8 *bssid, void *network_ctx, int try_opportunistic) { struct rsn_pmksa_cache *pmksa = sm->pmksa; sm->cur_pmksa = NULL; if (pmkid) sm->cur_pmksa = pmksa_cache_get(pmksa, NULL, pmkid); if (sm->cur_pmksa == NULL && bssid) sm->cur_pmksa = pmksa_cache_get(pmksa, bssid, NULL); if (sm->cur_pmksa == NULL && try_opportunistic && bssid) sm->cur_pmksa = pmksa_cache_get_opportunistic(pmksa, network_ctx, bssid); if (sm->cur_pmksa) { wpa_hexdump(MSG_DEBUG, "RSN: PMKID", sm->cur_pmksa->pmkid, PMKID_LEN); return 0; } return -1; }
/** * pmksa_candidate_add - Add a new PMKSA candidate * @sm: Pointer to WPA state machine data from wpa_sm_init() * @bssid: BSSID (authenticator address) of the candidate * @prio: Priority (the smaller number, the higher priority) * @preauth: Whether the candidate AP advertises support for pre-authentication * * This function is used to add PMKSA candidates for RSN pre-authentication. It * is called from scan result processing and from driver events for PMKSA * candidates, i.e., EVENT_PMKID_CANDIDATE events to wpa_supplicant_event(). */ void pmksa_candidate_add(struct wpa_sm *sm, const u8 *bssid, int prio, int preauth) { struct rsn_pmksa_candidate *cand, *prev, *pos; if (sm->network_ctx && sm->proactive_key_caching) pmksa_cache_get_opportunistic(sm->pmksa, sm->network_ctx, bssid); if (!preauth) { wpa_printf(MSG_DEBUG, "RSN: Ignored PMKID candidate without " "preauth flag"); return; } /* If BSSID already on candidate list, update the priority of the old * entry. Do not override priority based on normal scan results. */ prev = NULL; cand = sm->pmksa_candidates; while (cand) { if (os_memcmp(cand->bssid, bssid, ETH_ALEN) == 0) { if (prev) prev->next = cand->next; else sm->pmksa_candidates = cand->next; break; } prev = cand; cand = cand->next; } if (cand) { if (prio < PMKID_CANDIDATE_PRIO_SCAN) cand->priority = prio; } else { cand = os_zalloc(sizeof(*cand)); if (cand == NULL) return; os_memcpy(cand->bssid, bssid, ETH_ALEN); cand->priority = prio; } /* Add candidate to the list; order by increasing priority value. i.e., * highest priority (smallest value) first. */ prev = NULL; pos = sm->pmksa_candidates; while (pos) { if (cand->priority <= pos->priority) break; prev = pos; pos = pos->next; } cand->next = pos; if (prev) prev->next = cand; else sm->pmksa_candidates = cand; wpa_msg(sm->ctx->ctx, MSG_DEBUG, "RSN: added PMKSA cache " "candidate " MACSTR " prio %d", MAC2STR(bssid), prio); rsn_preauth_candidate_process(sm); }