1e28a4053SRui Paulo /* 2e28a4053SRui Paulo * IEEE 802.1X-2004 Authenticator - EAPOL state machine 3325151a3SRui Paulo * Copyright (c) 2002-2015, Jouni Malinen <j@w1.fi> 4e28a4053SRui Paulo * 5f05cddf9SRui Paulo * This software may be distributed under the terms of the BSD license. 6f05cddf9SRui Paulo * See README for more details. 7e28a4053SRui Paulo */ 8e28a4053SRui Paulo 9e28a4053SRui Paulo #ifndef EAPOL_AUTH_SM_H 10e28a4053SRui Paulo #define EAPOL_AUTH_SM_H 11e28a4053SRui Paulo 12e28a4053SRui Paulo #define EAPOL_SM_PREAUTH BIT(0) 13e28a4053SRui Paulo #define EAPOL_SM_WAIT_START BIT(1) 14e28a4053SRui Paulo #define EAPOL_SM_USES_WPA BIT(2) 15e28a4053SRui Paulo #define EAPOL_SM_FROM_PMKSA_CACHE BIT(3) 16e28a4053SRui Paulo 17e28a4053SRui Paulo struct eapol_auth_config { 18c1d255d3SCy Schubert const struct eap_config *eap_cfg; 19e28a4053SRui Paulo int eap_reauth_period; 20e28a4053SRui Paulo int wpa; 21e28a4053SRui Paulo int individual_wep_key_len; 22e28a4053SRui Paulo char *eap_req_id_text; /* a copy of this will be allocated */ 23e28a4053SRui Paulo size_t eap_req_id_text_len; 245b9c547cSRui Paulo int erp_send_reauth_start; 255b9c547cSRui Paulo char *erp_domain; /* a copy of this will be allocated */ 26*a90b9d01SCy Schubert bool eap_skip_prot_success; 27e28a4053SRui Paulo 28e28a4053SRui Paulo /* Opaque context pointer to owner data for callback functions */ 29e28a4053SRui Paulo void *ctx; 30e28a4053SRui Paulo }; 31e28a4053SRui Paulo 32e28a4053SRui Paulo struct eap_user; 335b9c547cSRui Paulo struct eap_server_erp_key; 34e28a4053SRui Paulo 35e28a4053SRui Paulo typedef enum { 36e28a4053SRui Paulo EAPOL_LOGGER_DEBUG, EAPOL_LOGGER_INFO, EAPOL_LOGGER_WARNING 37e28a4053SRui Paulo } eapol_logger_level; 38e28a4053SRui Paulo 39e28a4053SRui Paulo enum eapol_event { 40e28a4053SRui Paulo EAPOL_AUTH_SM_CHANGE, 41e28a4053SRui Paulo EAPOL_AUTH_REAUTHENTICATE 42e28a4053SRui Paulo }; 43e28a4053SRui Paulo 44e28a4053SRui Paulo struct eapol_auth_cb { 45e28a4053SRui Paulo void (*eapol_send)(void *ctx, void *sta_ctx, u8 type, const u8 *data, 46e28a4053SRui Paulo size_t datalen); 47e28a4053SRui Paulo void (*aaa_send)(void *ctx, void *sta_ctx, const u8 *data, 48e28a4053SRui Paulo size_t datalen); 49*a90b9d01SCy Schubert bool (*finished)(void *ctx, void *sta_ctx, int success, int preauth, 50*a90b9d01SCy Schubert int remediation, bool logoff); 51e28a4053SRui Paulo int (*get_eap_user)(void *ctx, const u8 *identity, size_t identity_len, 52e28a4053SRui Paulo int phase2, struct eap_user *user); 53e28a4053SRui Paulo int (*sta_entry_alive)(void *ctx, const u8 *addr); 54e28a4053SRui Paulo void (*logger)(void *ctx, const u8 *addr, eapol_logger_level level, 55e28a4053SRui Paulo const char *txt); 56e28a4053SRui Paulo void (*set_port_authorized)(void *ctx, void *sta_ctx, int authorized); 57e28a4053SRui Paulo void (*abort_auth)(void *ctx, void *sta_ctx); 58e28a4053SRui Paulo void (*tx_key)(void *ctx, void *sta_ctx); 59e28a4053SRui Paulo void (*eapol_event)(void *ctx, void *sta_ctx, enum eapol_event type); 605b9c547cSRui Paulo struct eap_server_erp_key * (*erp_get_key)(void *ctx, 615b9c547cSRui Paulo const char *keyname); 625b9c547cSRui Paulo int (*erp_add_key)(void *ctx, struct eap_server_erp_key *erp); 63e28a4053SRui Paulo }; 64e28a4053SRui Paulo 65e28a4053SRui Paulo 66e28a4053SRui Paulo struct eapol_authenticator * eapol_auth_init(struct eapol_auth_config *conf, 67e28a4053SRui Paulo struct eapol_auth_cb *cb); 68e28a4053SRui Paulo void eapol_auth_deinit(struct eapol_authenticator *eapol); 69e28a4053SRui Paulo struct eapol_state_machine * 70e28a4053SRui Paulo eapol_auth_alloc(struct eapol_authenticator *eapol, const u8 *addr, 71f05cddf9SRui Paulo int flags, const struct wpabuf *assoc_wps_ie, 72f05cddf9SRui Paulo const struct wpabuf *assoc_p2p_ie, void *sta_ctx, 73f05cddf9SRui Paulo const char *identity, const char *radius_cui); 74e28a4053SRui Paulo void eapol_auth_free(struct eapol_state_machine *sm); 75e28a4053SRui Paulo void eapol_auth_step(struct eapol_state_machine *sm); 765b9c547cSRui Paulo int eapol_auth_dump_state(struct eapol_state_machine *sm, char *buf, 775b9c547cSRui Paulo size_t buflen); 78e28a4053SRui Paulo int eapol_auth_eap_pending_cb(struct eapol_state_machine *sm, void *ctx); 79325151a3SRui Paulo void eapol_auth_reauthenticate(struct eapol_state_machine *sm); 80325151a3SRui Paulo int eapol_auth_set_conf(struct eapol_state_machine *sm, const char *param, 81325151a3SRui Paulo const char *value); 82e28a4053SRui Paulo 83e28a4053SRui Paulo #endif /* EAPOL_AUTH_SM_H */ 84