6 /* IEEE Std 802.1X-REV-d11, Ch. 8.2 */
8 typedef enum { ForceUnauthorized
= 1, ForceAuthorized
= 3, Auto
= 2 }
10 typedef enum { Unauthorized
= 2, Authorized
= 1 } PortState
;
11 typedef enum { Both
= 0, In
= 1 } ControlledDirection
;
12 typedef unsigned int Counter
;
15 /* Authenticator PAE state machine */
16 struct eapol_auth_pae_sm
{
22 unsigned int reAuthCount
;
25 unsigned int quietPeriod
; /* default 60; 0..65535 */
26 #define AUTH_PAE_DEFAULT_quietPeriod 60
27 unsigned int reAuthMax
; /* default 2 */
28 #define AUTH_PAE_DEFAULT_reAuthMax 2
31 Counter authEntersConnecting
;
32 Counter authEapLogoffsWhileConnecting
;
33 Counter authEntersAuthenticating
;
34 Counter authAuthSuccessesWhileAuthenticating
;
35 Counter authAuthTimeoutsWhileAuthenticating
;
36 Counter authAuthFailWhileAuthenticating
;
37 Counter authAuthEapStartsWhileAuthenticating
;
38 Counter authAuthEapLogoffWhileAuthenticating
;
39 Counter authAuthReauthsWhileAuthenticated
;
40 Counter authAuthEapStartsWhileAuthenticated
;
41 Counter authAuthEapLogoffWhileAuthenticated
;
43 enum { AUTH_PAE_INITIALIZE
, AUTH_PAE_DISCONNECTED
, AUTH_PAE_CONNECTING
,
44 AUTH_PAE_AUTHENTICATING
, AUTH_PAE_AUTHENTICATED
,
45 AUTH_PAE_ABORTING
, AUTH_PAE_HELD
, AUTH_PAE_FORCE_AUTH
,
46 AUTH_PAE_FORCE_UNAUTH
, AUTH_PAE_RESTART
} state
;
50 /* Backend Authentication state machine */
51 struct eapol_backend_auth_sm
{
58 unsigned int serverTimeout
; /* default 30; 1..X */
59 #define BE_AUTH_DEFAULT_serverTimeout 30
62 Counter backendResponses
;
63 Counter backendAccessChallenges
;
64 Counter backendOtherRequestsToSupplicant
;
65 Counter backendAuthSuccesses
;
66 Counter backendAuthFails
;
68 enum { BE_AUTH_REQUEST
, BE_AUTH_RESPONSE
, BE_AUTH_SUCCESS
,
69 BE_AUTH_FAIL
, BE_AUTH_TIMEOUT
, BE_AUTH_IDLE
, BE_AUTH_INITIALIZE
,
75 /* Reauthentication Timer state machine */
76 struct eapol_reauth_timer_sm
{
78 unsigned int reAuthPeriod
; /* default 3600 s */
79 Boolean reAuthEnabled
;
81 enum { REAUTH_TIMER_INITIALIZE
, REAUTH_TIMER_REAUTHENTICATE
} state
;
85 /* Authenticator Key Transmit state machine */
86 struct eapol_auth_key_tx
{
87 enum { AUTH_KEY_TX_NO_KEY_TRANSMIT
, AUTH_KEY_TX_KEY_TRANSMIT
} state
;
91 /* Key Receive state machine */
96 enum { KEY_RX_NO_KEY_RECEIVE
, KEY_RX_KEY_RECEIVE
} state
;
100 /* Controlled Directions state machine */
101 struct eapol_ctrl_dir
{
103 ControlledDirection adminControlledDirections
;
104 ControlledDirection operControlledDirections
;
107 enum { CTRL_DIR_FORCE_BOTH
, CTRL_DIR_IN_OR_BOTH
} state
;
113 struct radius_attr_data
{
118 struct radius_class_data
{
119 struct radius_attr_data
*attr
;
123 struct eapol_state_machine
{
129 /* global variables */
132 PortState authPortStatus
;
141 Boolean keyAvailable
;
144 Boolean keyTxEnabled
;
145 PortTypes portControl
;
148 Boolean reAuthenticate
;
150 /* Port Timers state machine */
151 /* 'Boolean tick' implicitly handled as registered timeout */
153 struct eapol_auth_pae_sm auth_pae
;
154 struct eapol_backend_auth_sm be_auth
;
155 struct eapol_reauth_timer_sm reauth_timer
;
156 struct eapol_auth_key_tx auth_key_tx
;
157 struct eapol_key_rx key_rx
;
158 struct eapol_ctrl_dir ctrl_dir
;
160 /* Authenticator Statistics Table */
161 Counter dot1xAuthEapolFramesRx
;
162 Counter dot1xAuthEapolFramesTx
;
163 Counter dot1xAuthEapolStartFramesRx
;
164 Counter dot1xAuthEapolLogoffFramesRx
;
165 Counter dot1xAuthEapolRespIdFramesRx
;
166 Counter dot1xAuthEapolRespFramesRx
;
167 Counter dot1xAuthEapolReqIdFramesTx
;
168 Counter dot1xAuthEapolReqFramesTx
;
169 Counter dot1xAuthInvalidEapolFramesRx
;
170 Counter dot1xAuthEapLengthErrorFramesRx
;
171 Counter dot1xAuthLastEapolFrameVersion
;
173 /* Other variables - not defined in IEEE 802.1X */
174 u8 addr
[ETH_ALEN
]; /* Supplicant address */
175 #define EAPOL_SM_PREAUTH BIT(0)
176 int flags
; /* EAPOL_SM_* */
178 int radius_identifier
;
179 /* TODO: check when the last messages can be released */
180 struct radius_msg
*last_recv_radius
;
181 u8
*last_eap_supp
; /* last received EAP Response from Supplicant */
182 size_t last_eap_supp_len
;
183 u8
*last_eap_radius
; /* last received EAP Response from Authentication
185 size_t last_eap_radius_len
;
188 struct radius_class_data radius_class
;
190 /* Keys for encrypting and signing EAPOL-Key frames */
192 size_t eapol_key_sign_len
;
194 size_t eapol_key_crypt_len
;
196 Boolean rx_identity
; /* set to TRUE on reception of
197 * EAP-Response/Identity */
201 /* currentId was removed in IEEE 802.1X-REV, but it is needed to filter
202 * out EAP-Responses to old packets (e.g., to two EAP-Request/Identity
203 * packets that are often sent in the beginning of the authentication).
207 Boolean initializing
; /* in process of initializing state machines */
209 /* Somewhat nasty pointers to global hostapd and STA data to avoid
210 * passing these to every function */
211 struct hostapd_data
*hapd
;
212 struct sta_info
*sta
;
216 struct eapol_state_machine
*eapol_sm_alloc(hostapd
*hapd
,
217 struct sta_info
*sta
);
218 void eapol_sm_free(struct eapol_state_machine
*sm
);
219 void eapol_sm_step(struct eapol_state_machine
*sm
);
220 void eapol_sm_initialize(struct eapol_state_machine
*sm
);
221 void eapol_sm_dump_state(FILE *f
, const char *prefix
,
222 struct eapol_state_machine
*sm
);
224 #endif /* EAPOL_SM_H */