00001
00016 #ifndef EAP_I_H
00017 #define EAP_I_H
00018
00019 #include "eap.h"
00020
00021
00022
00030 struct eap_method {
00031 int vendor;
00032 EapType method;
00033 const char *name;
00034
00035 void * (*init)(struct eap_sm *sm);
00036 void * (*initPickUp)(struct eap_sm *sm);
00037 void (*reset)(struct eap_sm *sm, void *priv);
00038
00039 u8 * (*buildReq)(struct eap_sm *sm, void *priv, int id,
00040 size_t *reqDataLen);
00041 int (*getTimeout)(struct eap_sm *sm, void *priv);
00042 Boolean (*check)(struct eap_sm *sm, void *priv,
00043 u8 *respData, size_t respDataLen);
00044 void (*process)(struct eap_sm *sm, void *priv,
00045 u8 *respData, size_t respDataLen);
00046 Boolean (*isDone)(struct eap_sm *sm, void *priv);
00047 u8 * (*getKey)(struct eap_sm *sm, void *priv, size_t *len);
00048
00049
00050 Boolean (*isSuccess)(struct eap_sm *sm, void *priv);
00051
00066 void (*free)(struct eap_method *method);
00067
00068 #define EAP_SERVER_METHOD_INTERFACE_VERSION 1
00069
00078 int version;
00079
00087 struct eap_method *next;
00088
00101 u8 * (*get_emsk)(struct eap_sm *sm, void *priv, size_t *len);
00102 };
00103
00108 struct eap_sm {
00109 enum {
00110 EAP_DISABLED, EAP_INITIALIZE, EAP_IDLE, EAP_RECEIVED,
00111 EAP_INTEGRITY_CHECK, EAP_METHOD_RESPONSE, EAP_METHOD_REQUEST,
00112 EAP_PROPOSE_METHOD, EAP_SELECT_ACTION, EAP_SEND_REQUEST,
00113 EAP_DISCARD, EAP_NAK, EAP_RETRANSMIT, EAP_SUCCESS, EAP_FAILURE,
00114 EAP_TIMEOUT_FAILURE, EAP_PICK_UP_METHOD
00115 } EAP_state;
00116
00117
00118 int MaxRetrans;
00119
00120
00121
00122
00123
00124 u8 *eapRespData;
00125 size_t eapRespDataLen;
00126 int retransWhile;
00127 int eapSRTT;
00128 int eapRTTVAR;
00129
00130
00131
00132
00133
00134
00135
00136 u8 *eapReqData;
00137 size_t eapReqDataLen;
00138 u8 *eapKeyData;
00139 size_t eapKeyDataLen;
00140
00141
00142
00143
00144 EapType currentMethod;
00145 int currentId;
00146 enum {
00147 METHOD_PROPOSED, METHOD_CONTINUE, METHOD_END
00148 } methodState;
00149 int retransCount;
00150 u8 *lastReqData;
00151 size_t lastReqDataLen;
00152 int methodTimeout;
00153
00154
00155 Boolean rxResp;
00156 int respId;
00157 EapType respMethod;
00158 int respVendor;
00159 u32 respVendorMethod;
00160 Boolean ignore;
00161 enum {
00162 DECISION_SUCCESS, DECISION_FAILURE, DECISION_CONTINUE
00163 } decision;
00164
00165
00166 const struct eap_method *m;
00167
00168 Boolean changed;
00169 void *eapol_ctx, *msg_ctx;
00170 struct eapol_callbacks *eapol_cb;
00171 void *eap_method_priv;
00172 u8 *identity;
00173 size_t identity_len;
00174 int lastId;
00175 struct eap_user *user;
00176 int user_eap_method_index;
00177 int init_phase2;
00178 void *ssl_ctx;
00179 enum { TLV_REQ_NONE, TLV_REQ_SUCCESS, TLV_REQ_FAILURE } tlv_request;
00180 void *eap_sim_db_priv;
00181 Boolean backend_auth;
00182 Boolean update_user;
00183
00184 int num_rounds;
00185 enum {
00186 METHOD_PENDING_NONE, METHOD_PENDING_WAIT, METHOD_PENDING_CONT
00187 } method_pending;
00188 };
00189
00190 int eap_user_get(struct eap_sm *sm, const u8 *identity, size_t identity_len,
00191 int phase2);
00192 void eap_sm_process_nak(struct eap_sm *sm, u8 *nak_list, size_t len);
00193 const u8 * eap_hdr_validate(int vendor, EapType eap_type,
00194 const u8 *msg, size_t msglen, size_t *plen);
00195 struct eap_hdr * eap_msg_alloc(int vendor, EapType type, size_t *len,
00196 size_t payload_len, u8 code, u8 identifier,
00197 u8 **payload);
00198
00199 #endif
00200