Import of hostapd 0.4.9
[dragonfly.git] / contrib / hostapd-0.4.9 / eap_i.h
1 #ifndef EAP_I_H
2 #define EAP_I_H
3
4 #include "eap.h"
5
6 /* draft-ietf-eap-statemachine-05.pdf - EAP Standalone Authenticator */
7
8 struct eap_method {
9         EapType method;
10         const char *name;
11
12         void * (*init)(struct eap_sm *sm);
13         void * (*initPickUp)(struct eap_sm *sm);
14         void (*reset)(struct eap_sm *sm, void *priv);
15
16         u8 * (*buildReq)(struct eap_sm *sm, void *priv, int id,
17                          size_t *reqDataLen);
18         int (*getTimeout)(struct eap_sm *sm, void *priv);
19         Boolean (*check)(struct eap_sm *sm, void *priv,
20                          u8 *respData, size_t respDataLen);
21         void (*process)(struct eap_sm *sm, void *priv,
22                         u8 *respData, size_t respDataLen);
23         Boolean (*isDone)(struct eap_sm *sm, void *priv);
24         u8 * (*getKey)(struct eap_sm *sm, void *priv, size_t *len);
25         /* isSuccess is not specified in draft-ietf-eap-statemachine-05.txt,
26          * but it is useful in implementing Policy.getDecision() */
27         Boolean (*isSuccess)(struct eap_sm *sm, void *priv);
28 };
29
30 struct eap_sm {
31         enum {
32                 EAP_DISABLED, EAP_INITIALIZE, EAP_IDLE, EAP_RECEIVED,
33                 EAP_INTEGRITY_CHECK, EAP_METHOD_RESPONSE, EAP_METHOD_REQUEST,
34                 EAP_PROPOSE_METHOD, EAP_SELECT_ACTION, EAP_SEND_REQUEST,
35                 EAP_DISCARD, EAP_NAK, EAP_RETRANSMIT, EAP_SUCCESS, EAP_FAILURE,
36                 EAP_TIMEOUT_FAILURE, EAP_PICK_UP_METHOD
37         } EAP_state;
38
39         /* Constants */
40         int MaxRetrans;
41
42         /* Lower layer to standalone authenticator variables */
43         /* eapResp: eapol_sm->be_auth.eapResp */
44         /* portEnabled: eapol_sm->portEnabled */
45         /* eapRestart: eapol_sm->auth_pae.eapRestart */
46         u8 *eapRespData;
47         size_t eapRespDataLen;
48         int retransWhile;
49         int eapSRTT;
50         int eapRTTVAR;
51
52         /* Standalone authenticator to lower layer variables */
53         /* eapReq: eapol_sm->be_auth.eapReq */
54         /* eapNoReq: eapol_sm->be_auth.eapNoReq */
55         /* eapSuccess: eapol_sm->eapSuccess */
56         /* eapFail: eapol_sm->eapFail */
57         /* eapTimeout: eapol_sm->eapTimeout */
58         u8 *eapReqData;
59         size_t eapReqDataLen;
60         u8 *eapKeyData; /* also eapKeyAvailable (boolean) */
61         size_t eapKeyDataLen;
62
63         /* Standalone authenticator state machine local variables */
64
65         /* Long-term (maintained betwen packets) */
66         EapType currentMethod;
67         int currentId;
68         enum {
69                 METHOD_PROPOSED, METHOD_CONTINUE, METHOD_END
70         } methodState;
71         int retransCount;
72         u8 *lastReqData;
73         size_t lastReqDataLen;
74         int methodTimeout;
75
76         /* Short-term (not maintained between packets) */
77         Boolean rxResp;
78         int respId;
79         EapType respMethod;
80         Boolean ignore;
81         enum {
82                 DECISION_SUCCESS, DECISION_FAILURE, DECISION_CONTINUE
83         } decision;
84
85         /* Miscellaneous variables */
86         const struct eap_method *m; /* selected EAP method */
87         /* not defined in draft-ietf-eap-statemachine-02 */
88         Boolean changed;
89         void *eapol_ctx, *msg_ctx;
90         struct eapol_callbacks *eapol_cb;
91         void *eap_method_priv;
92         u8 *identity;
93         size_t identity_len;
94         int lastId; /* Identifier used in the last EAP-Packet */
95         struct eap_user *user;
96         int user_eap_method_index;
97         int init_phase2;
98         void *ssl_ctx;
99         enum { TLV_REQ_NONE, TLV_REQ_SUCCESS, TLV_REQ_FAILURE } tlv_request;
100         void *eap_sim_db_priv;
101         Boolean backend_auth;
102         Boolean update_user;
103
104         int num_rounds;
105 };
106
107 const struct eap_method * eap_sm_get_eap_methods(int method);
108 int eap_user_get(struct eap_sm *sm, const u8 *identity, size_t identity_len,
109                  int phase2);
110 void eap_sm_process_nak(struct eap_sm *sm, u8 *nak_list, size_t len);
111
112 #endif /* EAP_I_H */