xref: /freebsd/contrib/wpa/src/eapol_auth/eapol_auth_sm.h (revision 43a5ec4eb41567cc92586503212743d89686d78f)
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 	const struct eap_config *eap_cfg;
19 	int eap_reauth_period;
20 	int wpa;
21 	int individual_wep_key_len;
22 	char *eap_req_id_text; /* a copy of this will be allocated */
23 	size_t eap_req_id_text_len;
24 	int erp_send_reauth_start;
25 	char *erp_domain; /* a copy of this will be allocated */
26 
27 	/* Opaque context pointer to owner data for callback functions */
28 	void *ctx;
29 };
30 
31 struct eap_user;
32 struct eap_server_erp_key;
33 
34 typedef enum {
35 	EAPOL_LOGGER_DEBUG, EAPOL_LOGGER_INFO, EAPOL_LOGGER_WARNING
36 } eapol_logger_level;
37 
38 enum eapol_event {
39 	EAPOL_AUTH_SM_CHANGE,
40 	EAPOL_AUTH_REAUTHENTICATE
41 };
42 
43 struct eapol_auth_cb {
44 	void (*eapol_send)(void *ctx, void *sta_ctx, u8 type, const u8 *data,
45 			   size_t datalen);
46 	void (*aaa_send)(void *ctx, void *sta_ctx, const u8 *data,
47 			 size_t datalen);
48 	void (*finished)(void *ctx, void *sta_ctx, int success, int preauth,
49 			 int remediation);
50 	int (*get_eap_user)(void *ctx, const u8 *identity, size_t identity_len,
51 			    int phase2, struct eap_user *user);
52 	int (*sta_entry_alive)(void *ctx, const u8 *addr);
53 	void (*logger)(void *ctx, const u8 *addr, eapol_logger_level level,
54 		       const char *txt);
55 	void (*set_port_authorized)(void *ctx, void *sta_ctx, int authorized);
56 	void (*abort_auth)(void *ctx, void *sta_ctx);
57 	void (*tx_key)(void *ctx, void *sta_ctx);
58 	void (*eapol_event)(void *ctx, void *sta_ctx, enum eapol_event type);
59 	struct eap_server_erp_key * (*erp_get_key)(void *ctx,
60 						   const char *keyname);
61 	int (*erp_add_key)(void *ctx, struct eap_server_erp_key *erp);
62 };
63 
64 
65 struct eapol_authenticator * eapol_auth_init(struct eapol_auth_config *conf,
66 					     struct eapol_auth_cb *cb);
67 void eapol_auth_deinit(struct eapol_authenticator *eapol);
68 struct eapol_state_machine *
69 eapol_auth_alloc(struct eapol_authenticator *eapol, const u8 *addr,
70 		 int flags, const struct wpabuf *assoc_wps_ie,
71 		 const struct wpabuf *assoc_p2p_ie, void *sta_ctx,
72 		 const char *identity, const char *radius_cui);
73 void eapol_auth_free(struct eapol_state_machine *sm);
74 void eapol_auth_step(struct eapol_state_machine *sm);
75 int eapol_auth_dump_state(struct eapol_state_machine *sm, char *buf,
76 			  size_t buflen);
77 int eapol_auth_eap_pending_cb(struct eapol_state_machine *sm, void *ctx);
78 void eapol_auth_reauthenticate(struct eapol_state_machine *sm);
79 int eapol_auth_set_conf(struct eapol_state_machine *sm, const char *param,
80 			const char *value);
81 
82 #endif /* EAPOL_AUTH_SM_H */
83