remove @EAP_LDFLAGS@, no longer exists
[mech_eap.orig] / libeap / src / eap_peer / eap.h
1 /*
2  * EAP peer state machine functions (RFC 4137)
3  * Copyright (c) 2004-2007, 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 EAP_H
16 #define EAP_H
17
18 #include "common/defs.h"
19 #include "eap_common/eap_defs.h"
20 #include "eap_peer/eap_methods.h"
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 struct eap_sm;
27 struct wpa_config_blob;
28 struct wpabuf;
29
30 struct eap_method_type {
31         int vendor;
32         u32 method;
33 };
34
35 #ifdef IEEE8021X_EAPOL
36
37 /**
38  * enum eapol_bool_var - EAPOL boolean state variables for EAP state machine
39  *
40  * These variables are used in the interface between EAP peer state machine and
41  * lower layer. These are defined in RFC 4137, Sect. 4.1. Lower layer code is
42  * expected to maintain these variables and register a callback functions for
43  * EAP state machine to get and set the variables.
44  */
45 enum eapol_bool_var {
46         /**
47          * EAPOL_eapSuccess - EAP SUCCESS state reached
48          *
49          * EAP state machine reads and writes this value.
50          */
51         EAPOL_eapSuccess,
52
53         /**
54          * EAPOL_eapRestart - Lower layer request to restart authentication
55          *
56          * Set to TRUE in lower layer, FALSE in EAP state machine.
57          */
58         EAPOL_eapRestart,
59
60         /**
61          * EAPOL_eapFail - EAP FAILURE state reached
62          *
63          * EAP state machine writes this value.
64          */
65         EAPOL_eapFail,
66
67         /**
68          * EAPOL_eapResp - Response to send
69          *
70          * Set to TRUE in EAP state machine, FALSE in lower layer.
71          */
72         EAPOL_eapResp,
73
74         /**
75          * EAPOL_eapNoResp - Request has been process; no response to send
76          *
77          * Set to TRUE in EAP state machine, FALSE in lower layer.
78          */
79         EAPOL_eapNoResp,
80
81         /**
82          * EAPOL_eapReq - EAP request available from lower layer
83          *
84          * Set to TRUE in lower layer, FALSE in EAP state machine.
85          */
86         EAPOL_eapReq,
87
88         /**
89          * EAPOL_portEnabled - Lower layer is ready for communication
90          *
91          * EAP state machines reads this value.
92          */
93         EAPOL_portEnabled,
94
95         /**
96          * EAPOL_altAccept - Alternate indication of success (RFC3748)
97          *
98          * EAP state machines reads this value.
99          */
100         EAPOL_altAccept,
101
102         /**
103          * EAPOL_altReject - Alternate indication of failure (RFC3748)
104          *
105          * EAP state machines reads this value.
106          */
107         EAPOL_altReject
108 };
109
110 /**
111  * enum eapol_int_var - EAPOL integer state variables for EAP state machine
112  *
113  * These variables are used in the interface between EAP peer state machine and
114  * lower layer. These are defined in RFC 4137, Sect. 4.1. Lower layer code is
115  * expected to maintain these variables and register a callback functions for
116  * EAP state machine to get and set the variables.
117  */
118 enum eapol_int_var {
119         /**
120          * EAPOL_idleWhile - Outside time for EAP peer timeout
121          *
122          * This integer variable is used to provide an outside timer that the
123          * external (to EAP state machine) code must decrement by one every
124          * second until the value reaches zero. This is used in the same way as
125          * EAPOL state machine timers. EAP state machine reads and writes this
126          * value.
127          */
128         EAPOL_idleWhile
129 };
130
131 /**
132  * struct eapol_callbacks - Callback functions from EAP to lower layer
133  *
134  * This structure defines the callback functions that EAP state machine
135  * requires from the lower layer (usually EAPOL state machine) for updating
136  * state variables and requesting information. eapol_ctx from
137  * eap_peer_sm_init() call will be used as the ctx parameter for these
138  * callback functions.
139  */
140 struct eapol_callbacks {
141         /**
142          * get_config - Get pointer to the current network configuration
143          * @ctx: eapol_ctx from eap_peer_sm_init() call
144          */
145         struct eap_peer_config * (*get_config)(void *ctx);
146
147         /**
148          * get_bool - Get a boolean EAPOL state variable
149          * @variable: EAPOL boolean variable to get
150          * Returns: Value of the EAPOL variable
151          */
152         Boolean (*get_bool)(void *ctx, enum eapol_bool_var variable);
153
154         /**
155          * set_bool - Set a boolean EAPOL state variable
156          * @ctx: eapol_ctx from eap_peer_sm_init() call
157          * @variable: EAPOL boolean variable to set
158          * @value: Value for the EAPOL variable
159          */
160         void (*set_bool)(void *ctx, enum eapol_bool_var variable,
161                          Boolean value);
162
163         /**
164          * get_int - Get an integer EAPOL state variable
165          * @ctx: eapol_ctx from eap_peer_sm_init() call
166          * @variable: EAPOL integer variable to get
167          * Returns: Value of the EAPOL variable
168          */
169         unsigned int (*get_int)(void *ctx, enum eapol_int_var variable);
170
171         /**
172          * set_int - Set an integer EAPOL state variable
173          * @ctx: eapol_ctx from eap_peer_sm_init() call
174          * @variable: EAPOL integer variable to set
175          * @value: Value for the EAPOL variable
176          */
177         void (*set_int)(void *ctx, enum eapol_int_var variable,
178                         unsigned int value);
179
180         /**
181          * get_eapReqData - Get EAP-Request data
182          * @ctx: eapol_ctx from eap_peer_sm_init() call
183          * @len: Pointer to variable that will be set to eapReqDataLen
184          * Returns: Reference to eapReqData (EAP state machine will not free
185          * this) or %NULL if eapReqData not available.
186          */
187         struct wpabuf * (*get_eapReqData)(void *ctx);
188
189         /**
190          * set_config_blob - Set named configuration blob
191          * @ctx: eapol_ctx from eap_peer_sm_init() call
192          * @blob: New value for the blob
193          *
194          * Adds a new configuration blob or replaces the current value of an
195          * existing blob.
196          */
197         void (*set_config_blob)(void *ctx, struct wpa_config_blob *blob);
198
199         /**
200          * get_config_blob - Get a named configuration blob
201          * @ctx: eapol_ctx from eap_peer_sm_init() call
202          * @name: Name of the blob
203          * Returns: Pointer to blob data or %NULL if not found
204          */
205         const struct wpa_config_blob * (*get_config_blob)(void *ctx,
206                                                           const char *name);
207
208         /**
209          * notify_pending - Notify that a pending request can be retried
210          * @ctx: eapol_ctx from eap_peer_sm_init() call
211          *
212          * An EAP method can perform a pending operation (e.g., to get a
213          * response from an external process). Once the response is available,
214          * this callback function can be used to request EAPOL state machine to
215          * retry delivering the previously received (and still unanswered) EAP
216          * request to EAP state machine.
217          */
218         void (*notify_pending)(void *ctx);
219
220         /**
221          * eap_param_needed - Notify that EAP parameter is needed
222          * @ctx: eapol_ctx from eap_peer_sm_init() call
223          * @field: Field name (e.g., "IDENTITY")
224          * @txt: User readable text describing the required parameter
225          */
226         void (*eap_param_needed)(void *ctx, const char *field,
227                                  const char *txt);
228 };
229
230 /**
231  * struct eap_config - Configuration for EAP state machine
232  */
233 struct eap_config {
234         /**
235          * opensc_engine_path - OpenSC engine for OpenSSL engine support
236          *
237          * Usually, path to engine_opensc.so.
238          */
239         const char *opensc_engine_path;
240         /**
241          * pkcs11_engine_path - PKCS#11 engine for OpenSSL engine support
242          *
243          * Usually, path to engine_pkcs11.so.
244          */
245         const char *pkcs11_engine_path;
246         /**
247          * pkcs11_module_path - OpenSC PKCS#11 module for OpenSSL engine
248          *
249          * Usually, path to opensc-pkcs11.so.
250          */
251         const char *pkcs11_module_path;
252         /**
253          * wps - WPS context data
254          *
255          * This is only used by EAP-WSC and can be left %NULL if not available.
256          */
257         struct wps_context *wps;
258 };
259
260 struct eap_sm * eap_peer_sm_init(void *eapol_ctx,
261                                  struct eapol_callbacks *eapol_cb,
262                                  void *msg_ctx, struct eap_config *conf);
263 void eap_peer_sm_deinit(struct eap_sm *sm);
264 int eap_peer_sm_step(struct eap_sm *sm);
265 void eap_sm_abort(struct eap_sm *sm);
266 int eap_sm_get_status(struct eap_sm *sm, char *buf, size_t buflen,
267                       int verbose);
268 struct wpabuf * eap_sm_buildIdentity(struct eap_sm *sm, int id, int encrypted);
269 void eap_sm_request_identity(struct eap_sm *sm);
270 void eap_sm_request_password(struct eap_sm *sm);
271 void eap_sm_request_new_password(struct eap_sm *sm);
272 void eap_sm_request_pin(struct eap_sm *sm);
273 void eap_sm_request_otp(struct eap_sm *sm, const char *msg, size_t msg_len);
274 void eap_sm_request_passphrase(struct eap_sm *sm);
275 void eap_sm_notify_ctrl_attached(struct eap_sm *sm);
276 u32 eap_get_phase2_type(const char *name, int *vendor);
277 struct eap_method_type * eap_get_phase2_types(struct eap_peer_config *config,
278                                               size_t *count);
279 void eap_set_fast_reauth(struct eap_sm *sm, int enabled);
280 void eap_set_workaround(struct eap_sm *sm, unsigned int workaround);
281 void eap_set_force_disabled(struct eap_sm *sm, int disabled);
282 int eap_key_available(struct eap_sm *sm);
283 void eap_notify_success(struct eap_sm *sm);
284 void eap_notify_lower_layer_success(struct eap_sm *sm);
285 const u8 * eap_get_eapKeyData(struct eap_sm *sm, size_t *len);
286 struct wpabuf * eap_get_eapRespData(struct eap_sm *sm);
287 void eap_register_scard_ctx(struct eap_sm *sm, void *ctx);
288 void eap_invalidate_cached_session(struct eap_sm *sm);
289
290 int eap_is_wps_pbc_enrollee(struct eap_peer_config *conf);
291 int eap_is_wps_pin_enrollee(struct eap_peer_config *conf);
292
293 #endif /* IEEE8021X_EAPOL */
294
295 #ifdef __cplusplus
296 }
297 #endif
298
299 #endif /* EAP_H */