diff options
author | sam <sam@FreeBSD.org> | 2008-03-24 21:08:25 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2008-03-24 21:08:25 +0000 |
commit | 8e449bffe3af56fe8cfa5bac6cf6a4171bcb20eb (patch) | |
tree | 5c9b3ca5761e9736e2f8e2871bdd9b087549d59d /contrib/hostapd/wpa.c | |
parent | 9c6231a7376ca18ee605d9bd2f0e357b3bf0069e (diff) | |
download | FreeBSD-src-8e449bffe3af56fe8cfa5bac6cf6a4171bcb20eb.zip FreeBSD-src-8e449bffe3af56fe8cfa5bac6cf6a4171bcb20eb.tar.gz |
resolve merge conflicts
MFC after: 3 weeks
Diffstat (limited to 'contrib/hostapd/wpa.c')
-rw-r--r-- | contrib/hostapd/wpa.c | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/contrib/hostapd/wpa.c b/contrib/hostapd/wpa.c index 7d40b9a..25ca57f 100644 --- a/contrib/hostapd/wpa.c +++ b/contrib/hostapd/wpa.c @@ -1,6 +1,6 @@ /* * hostapd - IEEE 802.11i-2004 / WPA Authenticator - * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi> + * Copyright (c) 2004-2008, 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 @@ -107,7 +107,6 @@ struct wpa_state_machine { unsigned int in_step_loop:1; unsigned int pending_deinit:1; unsigned int started:1; - unsigned int sta_counted:1; unsigned int mgmt_frame_prot:1; u8 req_replay_counter[WPA_REPLAY_COUNTER_LEN]; @@ -136,7 +135,6 @@ struct wpa_group { int vlan_id; Boolean GInit; - int GNoStations; int GKeyDoneStations; Boolean GTKReKey; int GTK_len; @@ -2687,14 +2685,6 @@ SM_STATE(WPA_PTK, DISCONNECT) SM_STATE(WPA_PTK, DISCONNECTED) { SM_ENTRY_MA(WPA_PTK, DISCONNECTED, wpa_ptk); - if (sm->sta_counted) { - sm->group->GNoStations--; - sm->sta_counted = 0; - } else { - wpa_printf(MSG_DEBUG, "WPA: WPA_PTK::DISCONNECTED - did not " - "decrease GNoStations (STA " MACSTR ")", - MAC2STR(sm->addr)); - } sm->DeauthenticationRequest = FALSE; } @@ -2702,14 +2692,6 @@ SM_STATE(WPA_PTK, DISCONNECTED) SM_STATE(WPA_PTK, AUTHENTICATION) { SM_ENTRY_MA(WPA_PTK, AUTHENTICATION, wpa_ptk); - if (!sm->sta_counted) { - sm->group->GNoStations++; - sm->sta_counted = 1; - } else { - wpa_printf(MSG_DEBUG, "WPA: WPA_PTK::DISCONNECTED - did not " - "increase GNoStations (STA " MACSTR ")", - MAC2STR(sm->addr)); - } memset(&sm->PTK, 0, sizeof(sm->PTK)); sm->PTK_valid = FALSE; wpa_auth_set_eapol(sm->wpa_auth, sm->addr, WPA_EAPOL_portControl_Auto, @@ -3221,8 +3203,9 @@ SM_STATE(WPA_PTK_GROUP, REKEYESTABLISHED) { SM_ENTRY_MA(WPA_PTK_GROUP, REKEYESTABLISHED, wpa_ptk_group); sm->EAPOLKeyReceived = FALSE; + if (sm->GUpdateStationKeys) + sm->group->GKeyDoneStations--; sm->GUpdateStationKeys = FALSE; - sm->group->GKeyDoneStations--; sm->GTimeoutCtr = 0; /* FIX: MLME.SetProtection.Request(TA, Tx_Rx) */ wpa_auth_vlogger(sm->wpa_auth, sm->addr, LOGGER_INFO, @@ -3235,7 +3218,8 @@ SM_STATE(WPA_PTK_GROUP, REKEYESTABLISHED) SM_STATE(WPA_PTK_GROUP, KEYERROR) { SM_ENTRY_MA(WPA_PTK_GROUP, KEYERROR, wpa_ptk_group); - sm->group->GKeyDoneStations--; + if (sm->GUpdateStationKeys) + sm->group->GKeyDoneStations--; sm->GUpdateStationKeys = FALSE; sm->Disconnect = TRUE; } @@ -3311,6 +3295,12 @@ static void wpa_group_gtk_init(struct wpa_authenticator *wpa_auth, static int wpa_group_update_sta(struct wpa_state_machine *sm, void *ctx) { + if (sm->wpa_ptk_state != WPA_PTK_PTKINITDONE) { + wpa_auth_logger(sm->wpa_auth, sm->addr, LOGGER_DEBUG, + "Not in PTKINITDONE; skip Group Key update"); + return 0; + } + sm->group->GKeyDoneStations++; sm->GUpdateStationKeys = TRUE; wpa_sm_step(sm); return 0; @@ -3330,10 +3320,14 @@ static void wpa_group_setkeys(struct wpa_authenticator *wpa_auth, tmp = group->GM; group->GM = group->GN; group->GN = tmp; - group->GKeyDoneStations = group->GNoStations; + /* "GKeyDoneStations = GNoStations" is done in more robust way by + * counting the STAs that are marked with GUpdateStationKeys instead of + * including all STAs that could be in not-yet-completed state. */ wpa_gtk_update(wpa_auth, group); wpa_auth_for_each_sta(wpa_auth, wpa_group_update_sta, NULL); + wpa_printf(MSG_DEBUG, "wpa_group_setkeys: GKeyDoneStations=%d", + group->GKeyDoneStations); } @@ -3782,13 +3776,6 @@ int wpa_auth_sta_set_vlan(struct wpa_state_machine *sm, int vlan_id) wpa_printf(MSG_DEBUG, "WPA: Moving STA " MACSTR " to use group state " "machine for VLAN ID %d", MAC2STR(sm->addr), vlan_id); - if (sm->group && sm->group != group && sm->sta_counted) { - sm->group->GNoStations--; - sm->sta_counted = 0; - wpa_printf(MSG_DEBUG, "WLA: Decreased GNoStations for the " - "previously used group state machine"); - } - sm->group = group; return 0; } |