00001
00016 #ifndef EAP_H
00017 #define EAP_H
00018
00019 #include "defs.h"
00020 #include "eap_defs.h"
00021
00022 struct eap_sm;
00023 struct wpa_ssid;
00024 struct wpa_config_blob;
00025
00026
00027 #ifdef IEEE8021X_EAPOL
00028
00037 enum eapol_bool_var {
00044 EAPOL_eapSuccess,
00045
00052 EAPOL_eapRestart,
00053
00060 EAPOL_eapFail,
00061
00068 EAPOL_eapResp,
00069
00076 EAPOL_eapNoResp,
00077
00084 EAPOL_eapReq,
00085
00092 EAPOL_portEnabled,
00093
00100 EAPOL_altAccept,
00101
00108 EAPOL_altReject
00109 };
00110
00119 enum eapol_int_var {
00130 EAPOL_idleWhile
00131 };
00132
00142 struct eapol_callbacks {
00148 struct wpa_ssid * (*get_config)(void *ctx);
00149
00156 Boolean (*get_bool)(void *ctx, enum eapol_bool_var variable);
00157
00165 void (*set_bool)(void *ctx, enum eapol_bool_var variable,
00166 Boolean value);
00167
00175 unsigned int (*get_int)(void *ctx, enum eapol_int_var variable);
00176
00184 void (*set_int)(void *ctx, enum eapol_int_var variable,
00185 unsigned int value);
00186
00195 u8 * (*get_eapReqData)(void *ctx, size_t *len);
00196
00206 void (*set_config_blob)(void *ctx, struct wpa_config_blob *blob);
00207
00215 const struct wpa_config_blob * (*get_config_blob)(void *ctx,
00216 const char *name);
00217 };
00218
00223 struct eap_config {
00230 const char *opensc_engine_path;
00237 const char *pkcs11_engine_path;
00244 const char *pkcs11_module_path;
00245 };
00246
00247 struct eap_sm * eap_sm_init(void *eapol_ctx, struct eapol_callbacks *eapol_cb,
00248 void *msg_ctx, struct eap_config *conf);
00249 void eap_sm_deinit(struct eap_sm *sm);
00250 int eap_sm_step(struct eap_sm *sm);
00251 void eap_sm_abort(struct eap_sm *sm);
00252 int eap_sm_get_status(struct eap_sm *sm, char *buf, size_t buflen,
00253 int verbose);
00254 u8 * eap_sm_buildIdentity(struct eap_sm *sm, int id, size_t *len,
00255 int encrypted);
00256 const struct eap_method * eap_sm_get_eap_methods(int method);
00257 void eap_sm_request_identity(struct eap_sm *sm, struct wpa_ssid *config);
00258 void eap_sm_request_password(struct eap_sm *sm, struct wpa_ssid *config);
00259 void eap_sm_request_new_password(struct eap_sm *sm, struct wpa_ssid *config);
00260 void eap_sm_request_pin(struct eap_sm *sm, struct wpa_ssid *config);
00261 void eap_sm_request_otp(struct eap_sm *sm, struct wpa_ssid *config,
00262 const char *msg, size_t msg_len);
00263 void eap_sm_request_passphrase(struct eap_sm *sm, struct wpa_ssid *config);
00264 void eap_sm_notify_ctrl_attached(struct eap_sm *sm);
00265 u8 eap_get_type(const char *name);
00266 const char * eap_get_name(EapType type);
00267 size_t eap_get_names(char *buf, size_t buflen);
00268 u8 eap_get_phase2_type(const char *name);
00269 u8 *eap_get_phase2_types(struct wpa_ssid *config, size_t *count);
00270 void eap_set_fast_reauth(struct eap_sm *sm, int enabled);
00271 void eap_set_workaround(struct eap_sm *sm, unsigned int workaround);
00272 void eap_set_force_disabled(struct eap_sm *sm, int disabled);
00273 struct wpa_ssid * eap_get_config(struct eap_sm *sm);
00274 int eap_key_available(struct eap_sm *sm);
00275 void eap_notify_success(struct eap_sm *sm);
00276 void eap_notify_lower_layer_success(struct eap_sm *sm);
00277 const u8 * eap_get_eapKeyData(struct eap_sm *sm, size_t *len);
00278 u8 * eap_get_eapRespData(struct eap_sm *sm, size_t *len);
00279 void eap_register_scard_ctx(struct eap_sm *sm, void *ctx);
00280
00281 #else
00282
00283 static inline u8 eap_get_type(const char *name)
00284 {
00285 return EAP_TYPE_NONE;
00286 }
00287
00288 static inline const char * eap_get_name(EapType type)
00289 {
00290 return NULL;
00291 }
00292
00293 static inline size_t eap_get_names(char *buf, size_t buflen)
00294 {
00295 return 0;
00296 }
00297
00298 #endif
00299
00300 #endif
00301