automake build system
[mech_eap.orig] / src / eapol_auth / eapol_auth_sm.h
1 /*
2  * IEEE 802.1X-2004 Authenticator - EAPOL state machine
3  * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  *
9  * Alternatively, this software may be distributed under the terms of BSD
10  * license.
11  *
12  * See README and COPYING for more details.
13  */
14
15 #ifndef EAPOL_AUTH_SM_H
16 #define EAPOL_AUTH_SM_H
17
18 #define EAPOL_SM_PREAUTH BIT(0)
19 #define EAPOL_SM_WAIT_START BIT(1)
20 #define EAPOL_SM_USES_WPA BIT(2)
21 #define EAPOL_SM_FROM_PMKSA_CACHE BIT(3)
22
23 struct eapol_auth_config {
24         int eap_reauth_period;
25         int wpa;
26         int individual_wep_key_len;
27         int eap_server;
28         void *ssl_ctx;
29         void *msg_ctx;
30         void *eap_sim_db_priv;
31         char *eap_req_id_text; /* a copy of this will be allocated */
32         size_t eap_req_id_text_len;
33         u8 *pac_opaque_encr_key;
34         u8 *eap_fast_a_id;
35         size_t eap_fast_a_id_len;
36         char *eap_fast_a_id_info;
37         int eap_fast_prov;
38         int pac_key_lifetime;
39         int pac_key_refresh_time;
40         int eap_sim_aka_result_ind;
41         int tnc;
42         struct wps_context *wps;
43         int fragment_size;
44         u16 pwd_group;
45
46         /* Opaque context pointer to owner data for callback functions */
47         void *ctx;
48 };
49
50 struct eap_user;
51
52 typedef enum {
53         EAPOL_LOGGER_DEBUG, EAPOL_LOGGER_INFO, EAPOL_LOGGER_WARNING
54 } eapol_logger_level;
55
56 enum eapol_event {
57         EAPOL_AUTH_SM_CHANGE,
58         EAPOL_AUTH_REAUTHENTICATE
59 };
60
61 struct eapol_auth_cb {
62         void (*eapol_send)(void *ctx, void *sta_ctx, u8 type, const u8 *data,
63                            size_t datalen);
64         void (*aaa_send)(void *ctx, void *sta_ctx, const u8 *data,
65                          size_t datalen);
66         void (*finished)(void *ctx, void *sta_ctx, int success, int preauth);
67         int (*get_eap_user)(void *ctx, const u8 *identity, size_t identity_len,
68                             int phase2, struct eap_user *user);
69         int (*sta_entry_alive)(void *ctx, const u8 *addr);
70         void (*logger)(void *ctx, const u8 *addr, eapol_logger_level level,
71                        const char *txt);
72         void (*set_port_authorized)(void *ctx, void *sta_ctx, int authorized);
73         void (*abort_auth)(void *ctx, void *sta_ctx);
74         void (*tx_key)(void *ctx, void *sta_ctx);
75         void (*eapol_event)(void *ctx, void *sta_ctx, enum eapol_event type);
76 };
77
78
79 struct eapol_authenticator * eapol_auth_init(struct eapol_auth_config *conf,
80                                              struct eapol_auth_cb *cb);
81 void eapol_auth_deinit(struct eapol_authenticator *eapol);
82 struct eapol_state_machine *
83 eapol_auth_alloc(struct eapol_authenticator *eapol, const u8 *addr,
84                  int flags, const struct wpabuf *assoc_wps_ie,
85                  const struct wpabuf *assoc_p2p_ie, void *sta_ctx);
86 void eapol_auth_free(struct eapol_state_machine *sm);
87 void eapol_auth_step(struct eapol_state_machine *sm);
88 void eapol_auth_dump_state(FILE *f, const char *prefix,
89                            struct eapol_state_machine *sm);
90 int eapol_auth_eap_pending_cb(struct eapol_state_machine *sm, void *ctx);
91
92 #endif /* EAPOL_AUTH_SM_H */