123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- #ifndef EAPOL_SM_H
- #define EAPOL_SM_H
- #include "defs.h"
- #include "radius/radius.h"
- typedef enum { ForceUnauthorized = 1, ForceAuthorized = 3, Auto = 2 }
- PortTypes;
- typedef enum { Unauthorized = 2, Authorized = 1 } PortState;
- typedef enum { Both = 0, In = 1 } ControlledDirection;
- typedef unsigned int Counter;
- struct eap_sm;
- struct eapol_auth_config {
- int eap_reauth_period;
- int wpa;
- int individual_wep_key_len;
- int eap_server;
- void *ssl_ctx;
- void *eap_sim_db_priv;
- char *eap_req_id_text;
- size_t eap_req_id_text_len;
- u8 *pac_opaque_encr_key;
- u8 *eap_fast_a_id;
- size_t eap_fast_a_id_len;
- char *eap_fast_a_id_info;
- int eap_fast_prov;
- int pac_key_lifetime;
- int pac_key_refresh_time;
- int eap_sim_aka_result_ind;
- int tnc;
- struct wps_context *wps;
-
- struct hostapd_data *hapd;
- };
- struct eap_user;
- typedef enum {
- EAPOL_LOGGER_DEBUG, EAPOL_LOGGER_INFO, EAPOL_LOGGER_WARNING
- } eapol_logger_level;
- struct eapol_auth_cb {
- void (*eapol_send)(void *ctx, void *sta_ctx, u8 type, const u8 *data,
- size_t datalen);
- void (*aaa_send)(void *ctx, void *sta_ctx, const u8 *data,
- size_t datalen);
- void (*finished)(void *ctx, void *sta_ctx, int success, int preauth);
- int (*get_eap_user)(void *ctx, const u8 *identity, size_t identity_len,
- int phase2, struct eap_user *user);
- int (*sta_entry_alive)(void *ctx, const u8 *addr);
- void (*logger)(void *ctx, const u8 *addr, eapol_logger_level level,
- const char *txt);
- void (*set_port_authorized)(void *ctx, void *sta_ctx, int authorized);
- void (*abort_auth)(void *ctx, void *sta_ctx);
- void (*tx_key)(void *ctx, void *sta_ctx);
- };
- struct eapol_authenticator {
- struct eapol_auth_config conf;
- struct eapol_auth_cb cb;
- };
- struct eapol_state_machine {
-
- int aWhile;
- int quietWhile;
- int reAuthWhen;
-
- Boolean authAbort;
- Boolean authFail;
- PortState authPortStatus;
- Boolean authStart;
- Boolean authTimeout;
- Boolean authSuccess;
- Boolean eapolEap;
- Boolean initialize;
- Boolean keyDone;
- Boolean keyRun;
- Boolean keyTxEnabled;
- PortTypes portControl;
- Boolean portValid;
- Boolean reAuthenticate;
-
-
-
- enum { AUTH_PAE_INITIALIZE, AUTH_PAE_DISCONNECTED, AUTH_PAE_CONNECTING,
- AUTH_PAE_AUTHENTICATING, AUTH_PAE_AUTHENTICATED,
- AUTH_PAE_ABORTING, AUTH_PAE_HELD, AUTH_PAE_FORCE_AUTH,
- AUTH_PAE_FORCE_UNAUTH, AUTH_PAE_RESTART } auth_pae_state;
-
- Boolean eapolLogoff;
- Boolean eapolStart;
- PortTypes portMode;
- unsigned int reAuthCount;
-
- unsigned int quietPeriod;
- #define AUTH_PAE_DEFAULT_quietPeriod 60
- unsigned int reAuthMax;
- #define AUTH_PAE_DEFAULT_reAuthMax 2
-
- Counter authEntersConnecting;
- Counter authEapLogoffsWhileConnecting;
- Counter authEntersAuthenticating;
- Counter authAuthSuccessesWhileAuthenticating;
- Counter authAuthTimeoutsWhileAuthenticating;
- Counter authAuthFailWhileAuthenticating;
- Counter authAuthEapStartsWhileAuthenticating;
- Counter authAuthEapLogoffWhileAuthenticating;
- Counter authAuthReauthsWhileAuthenticated;
- Counter authAuthEapStartsWhileAuthenticated;
- Counter authAuthEapLogoffWhileAuthenticated;
-
- enum { BE_AUTH_REQUEST, BE_AUTH_RESPONSE, BE_AUTH_SUCCESS,
- BE_AUTH_FAIL, BE_AUTH_TIMEOUT, BE_AUTH_IDLE, BE_AUTH_INITIALIZE,
- BE_AUTH_IGNORE
- } be_auth_state;
-
- unsigned int serverTimeout;
- #define BE_AUTH_DEFAULT_serverTimeout 30
-
- Counter backendResponses;
- Counter backendAccessChallenges;
- Counter backendOtherRequestsToSupplicant;
- Counter backendAuthSuccesses;
- Counter backendAuthFails;
-
- enum { REAUTH_TIMER_INITIALIZE, REAUTH_TIMER_REAUTHENTICATE
- } reauth_timer_state;
-
- unsigned int reAuthPeriod;
- Boolean reAuthEnabled;
-
- enum { AUTH_KEY_TX_NO_KEY_TRANSMIT, AUTH_KEY_TX_KEY_TRANSMIT
- } auth_key_tx_state;
-
- enum { KEY_RX_NO_KEY_RECEIVE, KEY_RX_KEY_RECEIVE } key_rx_state;
-
- Boolean rxKey;
-
- enum { CTRL_DIR_FORCE_BOTH, CTRL_DIR_IN_OR_BOTH } ctrl_dir_state;
-
- ControlledDirection adminControlledDirections;
- ControlledDirection operControlledDirections;
- Boolean operEdge;
-
- Counter dot1xAuthEapolFramesRx;
- Counter dot1xAuthEapolFramesTx;
- Counter dot1xAuthEapolStartFramesRx;
- Counter dot1xAuthEapolLogoffFramesRx;
- Counter dot1xAuthEapolRespIdFramesRx;
- Counter dot1xAuthEapolRespFramesRx;
- Counter dot1xAuthEapolReqIdFramesTx;
- Counter dot1xAuthEapolReqFramesTx;
- Counter dot1xAuthInvalidEapolFramesRx;
- Counter dot1xAuthEapLengthErrorFramesRx;
- Counter dot1xAuthLastEapolFrameVersion;
-
- u8 addr[ETH_ALEN];
- #define EAPOL_SM_PREAUTH BIT(0)
- #define EAPOL_SM_WAIT_START BIT(1)
- int flags;
-
- struct eap_eapol_interface *eap_if;
- int radius_identifier;
-
- struct radius_msg *last_recv_radius;
- u8 last_eap_id;
- u8 *identity;
- size_t identity_len;
- u8 eap_type_authsrv;
- u8 eap_type_supp;
- struct radius_class_data radius_class;
-
- u8 *eapol_key_sign;
- size_t eapol_key_sign_len;
- u8 *eapol_key_crypt;
- size_t eapol_key_crypt_len;
- struct eap_sm *eap;
- Boolean initializing;
- Boolean changed;
- struct eapol_authenticator *eapol;
-
- struct hostapd_data *hapd;
- struct sta_info *sta;
- };
- struct eapol_authenticator * eapol_auth_init(struct eapol_auth_config *conf,
- struct eapol_auth_cb *cb);
- void eapol_auth_deinit(struct eapol_authenticator *eapol);
- struct eapol_state_machine *
- eapol_auth_alloc(struct eapol_authenticator *eapol, const u8 *addr,
- int preauth, struct sta_info *sta);
- void eapol_auth_free(struct eapol_state_machine *sm);
- void eapol_auth_step(struct eapol_state_machine *sm);
- void eapol_auth_initialize(struct eapol_state_machine *sm);
- void eapol_auth_dump_state(FILE *f, const char *prefix,
- struct eapol_state_machine *sm);
- int eapol_auth_eap_pending_cb(struct eapol_state_machine *sm, void *ctx);
- #endif
|