xref: /freebsd/contrib/wpa/src/eapol_auth/eapol_auth_sm.h (revision 396c556d77189a5c474d35cec6f44a762e310b7d)
1 /*
2  * IEEE 802.1X-2004 Authenticator - EAPOL state machine
3  * Copyright (c) 2002-2015, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #ifndef EAPOL_AUTH_SM_H
10 #define EAPOL_AUTH_SM_H
11 
12 #define EAPOL_SM_PREAUTH BIT(0)
13 #define EAPOL_SM_WAIT_START BIT(1)
14 #define EAPOL_SM_USES_WPA BIT(2)
15 #define EAPOL_SM_FROM_PMKSA_CACHE BIT(3)
16 
17 struct eapol_auth_config {
18 	int eap_reauth_period;
19 	int wpa;
20 	int individual_wep_key_len;
21 	int eap_server;
22 	void *ssl_ctx;
23 	void *msg_ctx;
24 	void *eap_sim_db_priv;
25 	char *eap_req_id_text; /* a copy of this will be allocated */
26 	size_t eap_req_id_text_len;
27 	int erp_send_reauth_start;
28 	char *erp_domain; /* a copy of this will be allocated */
29 	int erp; /* Whether ERP is enabled on authentication server */
30 	unsigned int tls_session_lifetime;
31 	u8 *pac_opaque_encr_key;
32 	u8 *eap_fast_a_id;
33 	size_t eap_fast_a_id_len;
34 	char *eap_fast_a_id_info;
35 	int eap_fast_prov;
36 	int pac_key_lifetime;
37 	int pac_key_refresh_time;
38 	int eap_sim_aka_result_ind;
39 	int tnc;
40 	struct wps_context *wps;
41 	int fragment_size;
42 	u16 pwd_group;
43 	int pbc_in_m1;
44 	const u8 *server_id;
45 	size_t server_id_len;
46 
47 	/* Opaque context pointer to owner data for callback functions */
48 	void *ctx;
49 };
50 
51 struct eap_user;
52 struct eap_server_erp_key;
53 
54 typedef enum {
55 	EAPOL_LOGGER_DEBUG, EAPOL_LOGGER_INFO, EAPOL_LOGGER_WARNING
56 } eapol_logger_level;
57 
58 enum eapol_event {
59 	EAPOL_AUTH_SM_CHANGE,
60 	EAPOL_AUTH_REAUTHENTICATE
61 };
62 
63 struct eapol_auth_cb {
64 	void (*eapol_send)(void *ctx, void *sta_ctx, u8 type, const u8 *data,
65 			   size_t datalen);
66 	void (*aaa_send)(void *ctx, void *sta_ctx, const u8 *data,
67 			 size_t datalen);
68 	void (*finished)(void *ctx, void *sta_ctx, int success, int preauth,
69 			 int remediation);
70 	int (*get_eap_user)(void *ctx, const u8 *identity, size_t identity_len,
71 			    int phase2, struct eap_user *user);
72 	int (*sta_entry_alive)(void *ctx, const u8 *addr);
73 	void (*logger)(void *ctx, const u8 *addr, eapol_logger_level level,
74 		       const char *txt);
75 	void (*set_port_authorized)(void *ctx, void *sta_ctx, int authorized);
76 	void (*abort_auth)(void *ctx, void *sta_ctx);
77 	void (*tx_key)(void *ctx, void *sta_ctx);
78 	void (*eapol_event)(void *ctx, void *sta_ctx, enum eapol_event type);
79 	struct eap_server_erp_key * (*erp_get_key)(void *ctx,
80 						   const char *keyname);
81 	int (*erp_add_key)(void *ctx, struct eap_server_erp_key *erp);
82 };
83 
84 
85 struct eapol_authenticator * eapol_auth_init(struct eapol_auth_config *conf,
86 					     struct eapol_auth_cb *cb);
87 void eapol_auth_deinit(struct eapol_authenticator *eapol);
88 struct eapol_state_machine *
89 eapol_auth_alloc(struct eapol_authenticator *eapol, const u8 *addr,
90 		 int flags, const struct wpabuf *assoc_wps_ie,
91 		 const struct wpabuf *assoc_p2p_ie, void *sta_ctx,
92 		 const char *identity, const char *radius_cui);
93 void eapol_auth_free(struct eapol_state_machine *sm);
94 void eapol_auth_step(struct eapol_state_machine *sm);
95 int eapol_auth_dump_state(struct eapol_state_machine *sm, char *buf,
96 			  size_t buflen);
97 int eapol_auth_eap_pending_cb(struct eapol_state_machine *sm, void *ctx);
98 void eapol_auth_reauthenticate(struct eapol_state_machine *sm);
99 int eapol_auth_set_conf(struct eapol_state_machine *sm, const char *param,
100 			const char *value);
101 
102 #endif /* EAPOL_AUTH_SM_H */
103