144
144
* not have enough time to get the association information
145
145
* event before receiving this 1/4 message, so try to find a
146
146
* matching PMKSA cache entry here. */
147
sm->cur_pmksa = pmksa_cache_get(sm->pmksa, src_addr, pmkid);
147
sm->cur_pmksa = pmksa_cache_get(sm->pmksa, src_addr, pmkid,
148
149
if (sm->cur_pmksa) {
149
150
wpa_printf(MSG_DEBUG, "RSN: found matching PMKID from "
187
188
#endif /* CONFIG_IEEE80211R */
191
struct rsn_pmksa_cache_entry *sa = NULL;
190
192
wpa_hexdump_key(MSG_DEBUG, "WPA: PMK from EAPOL state "
191
193
"machines", sm->pmk, pmk_len);
192
194
sm->pmk_len = pmk_len;
193
195
if (sm->proto == WPA_PROTO_RSN) {
194
pmksa_cache_add(sm->pmksa, sm->pmk, pmk_len,
195
src_addr, sm->own_addr,
196
sm->network_ctx, sm->key_mgmt);
196
sa = pmksa_cache_add(sm->pmksa,
198
src_addr, sm->own_addr,
198
202
if (!sm->cur_pmksa && pmkid &&
199
pmksa_cache_get(sm->pmksa, src_addr, pmkid)) {
203
pmksa_cache_get(sm->pmksa, src_addr, pmkid, NULL))
200
205
wpa_printf(MSG_DEBUG, "RSN: the new PMK "
201
206
"matches with the PMKID");
202
207
abort_cached = 0;
205
213
wpa_msg(sm->ctx->msg_ctx, MSG_WARNING,
206
214
"WPA: Failed to get master session key from "
1935
1943
static void wpa_sm_pmksa_free_cb(struct rsn_pmksa_cache_entry *entry,
1936
void *ctx, int replace)
1944
void *ctx, int reason)
1938
1946
struct wpa_sm *sm = ctx;
1940
if (sm->cur_pmksa == entry ||
1949
if (sm->cur_pmksa == entry) {
1950
wpa_printf(MSG_DEBUG, "RSN: removed current PMKSA entry");
1951
pmksa_cache_clear_current (sm);
1953
/* If an entry is simply being replaced, there's no need to
1954
* deauthenticate because it will be immediately re-added.
1955
* This happens when EAP authentication is completed again
1956
* (reauth or failed PMKSA caching attempt). */
1957
if (reason != PMKSA_REPLACE) {
1958
wpa_printf(MSG_DEBUG,
1959
"RSN: deauthenticating due to removed entry");
1964
if (reason == PMKSA_EXPIRE &&
1941
1965
(sm->pmk_len == entry->pmk_len &&
1942
1966
os_memcmp(sm->pmk, entry->pmk, sm->pmk_len) == 0)) {
1943
wpa_printf(MSG_DEBUG, "RSN: removed current PMKSA entry");
1944
sm->cur_pmksa = NULL;
1947
/* A new entry is being added, so no need to
1948
* deauthenticate in this case. This happens when EAP
1949
* authentication is completed again (reauth or failed
1950
* PMKSA caching attempt). */
1967
wpa_printf(MSG_DEBUG,
1968
"RSN: deauthenticating due to expired PMK");
1969
pmksa_cache_clear_current (sm);
1954
1974
os_memset(sm->pmk, 0, sizeof(sm->pmk));
1955
1975
wpa_sm_deauthenticate(sm, WLAN_REASON_UNSPECIFIED);
2019
2039
* wpa_sm_notify_assoc - Notify WPA state machine about association
2020
2040
* @sm: Pointer to WPA state machine data from wpa_sm_init()
2021
2041
* @bssid: The BSSID of the new association
2042
* @network_ctx: Network configuration context for this BSSID
2023
2044
* This function is called to let WPA state machine know that the connection
2024
2045
* was established.
2026
void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid)
2047
void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid, void *network_ctx)
2028
2049
int clear_ptk = 1;
2038
2059
if (os_memcmp(sm->preauth_bssid, bssid, ETH_ALEN) == 0)
2039
2060
rsn_preauth_deinit(sm);
2062
if (!pmksa_cache_set_current(sm, NULL, bssid, network_ctx, 0)) {
2063
wpa_printf(MSG_WARNING, "WPA: expected existing PMKSA cache "
2064
"entry for " MACSTR " but none found",
2065
MAC2STR(sm->bssid));
2041
2068
#ifdef CONFIG_IEEE80211R
2042
2069
if (wpa_ft_is_completed(sm)) {