Re-enable hardware UDP/TCP checksum calculation with pseudo header on
[dragonfly/port-amd64.git] / contrib / wpa_supplicant-0.4.9 / eap.h
blobe00e29bd96785d2175bdaca784ab33540174c956
1 /*
2 * WPA Supplicant / EAP state machine functions (RFC 4137)
3 * Copyright (c) 2004-2005, Jouni Malinen <jkmaline@cc.hut.fi>
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.
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
12 * See README and COPYING for more details.
15 #ifndef EAP_H
16 #define EAP_H
18 #include "defs.h"
19 #include "eap_defs.h"
21 struct eap_sm;
22 struct wpa_ssid;
23 struct wpa_config_blob;
26 #ifdef IEEE8021X_EAPOL
28 /**
29 * enum eapol_bool_var - EAPOL boolean state variables for EAP state machine
31 * These variables are used in the interface between EAP peer state machine and
32 * lower layer. These are defined in RFC 4137, Sect. 4.1. Lower layer code is
33 * expected to maintain these variables and register a callback functions for
34 * EAP state machine to get and set the variables.
36 enum eapol_bool_var {
37 /**
38 * EAPOL_eapSuccess - EAP SUCCESS state reached
40 * EAP state machine reads and writes this value.
42 EAPOL_eapSuccess,
44 /**
45 * EAPOL_eapRestart - Lower layer request to restart authentication
47 * Set to TRUE in lower layer, FALSE in EAP state machine.
49 EAPOL_eapRestart,
51 /**
52 * EAPOL_eapFail - EAP FAILURE state reached
54 * EAP state machine writes this value.
56 EAPOL_eapFail,
58 /**
59 * EAPOL_eapResp - Response to send
61 * Set to TRUE in EAP state machine, FALSE in lower layer.
63 EAPOL_eapResp,
65 /**
66 * EAPOL_eapNoResp - Request has been process; no response to send
68 * Set to TRUE in EAP state machine, FALSE in lower layer.
70 EAPOL_eapNoResp,
72 /**
73 * EAPOL_eapReq - EAP request available from lower layer
75 * Set to TRUE in lower layer, FALSE in EAP state machine.
77 EAPOL_eapReq,
79 /**
80 * EAPOL_portEnabled - Lower layer is ready for communication
82 * EAP state machines reads this value.
84 EAPOL_portEnabled,
86 /**
87 * EAPOL_altAccept - Alternate indication of success (RFC3748)
89 * EAP state machines reads this value.
91 EAPOL_altAccept,
93 /**
94 * EAPOL_altReject - Alternate indication of failure (RFC3748)
96 * EAP state machines reads this value.
98 EAPOL_altReject
102 * enum eapol_int_var - EAPOL integer state variables for EAP state machine
104 * These variables are used in the interface between EAP peer state machine and
105 * lower layer. These are defined in RFC 4137, Sect. 4.1. Lower layer code is
106 * expected to maintain these variables and register a callback functions for
107 * EAP state machine to get and set the variables.
109 enum eapol_int_var {
111 * EAPOL_idleWhile - Outside time for EAP peer timeout
113 * This integer variable is used to provide an outside timer that the
114 * external (to EAP state machine) code must decrement by one every
115 * second until the value reaches zero. This is used in the same way as
116 * EAPOL state machine timers. EAP state machine reads and writes this
117 * value.
119 EAPOL_idleWhile
123 * struct eapol_callbacks - Callback functions from EAP to lower layer
125 * This structure defines the callback functions that EAP state machine
126 * requires from the lower layer (usually EAPOL state machine) for updating
127 * state variables and requesting information. eapol_ctx from eap_sm_init()
128 * call will be used as the ctx parameter for these callback functions.
130 struct eapol_callbacks {
132 * get_config - Get pointer to the current network configuration
133 * @ctx: eapol_ctx from eap_sm_init() call
135 struct wpa_ssid * (*get_config)(void *ctx);
138 * get_bool - Get a boolean EAPOL state variable
139 * @variable: EAPOL boolean variable to get
140 * Returns: Value of the EAPOL variable
142 Boolean (*get_bool)(void *ctx, enum eapol_bool_var variable);
145 * set_bool - Set a boolean EAPOL state variable
146 * @ctx: eapol_ctx from eap_sm_init() call
147 * @variable: EAPOL boolean variable to set
148 * @value: Value for the EAPOL variable
150 void (*set_bool)(void *ctx, enum eapol_bool_var variable,
151 Boolean value);
154 * get_int - Get an integer EAPOL state variable
155 * @ctx: eapol_ctx from eap_sm_init() call
156 * @variable: EAPOL integer variable to get
157 * Returns: Value of the EAPOL variable
159 unsigned int (*get_int)(void *ctx, enum eapol_int_var variable);
162 * set_int - Set an integer EAPOL state variable
163 * @ctx: eapol_ctx from eap_sm_init() call
164 * @variable: EAPOL integer variable to set
165 * @value: Value for the EAPOL variable
167 void (*set_int)(void *ctx, enum eapol_int_var variable,
168 unsigned int value);
171 * get_eapReqData - Get EAP-Request data
172 * @ctx: eapol_ctx from eap_sm_init() call
173 * @len: Pointer to variable that will be set to eapReqDataLen
174 * Returns: Reference to eapReqData (EAP state machine will not free
175 * this) or %NULL if eapReqData not available.
177 u8 * (*get_eapReqData)(void *ctx, size_t *len);
180 * set_config_blob - Set named configuration blob
181 * @ctx: eapol_ctx from eap_sm_init() call
182 * @blob: New value for the blob
184 * Adds a new configuration blob or replaces the current value of an
185 * existing blob.
187 void (*set_config_blob)(void *ctx, struct wpa_config_blob *blob);
190 * get_config_blob - Get a named configuration blob
191 * @ctx: eapol_ctx from eap_sm_init() call
192 * @name: Name of the blob
193 * Returns: Pointer to blob data or %NULL if not found
195 const struct wpa_config_blob * (*get_config_blob)(void *ctx,
196 const char *name);
200 * struct eap_config - Configuration for EAP state machine
202 struct eap_config {
204 * opensc_engine_path - OpenSC engine for OpenSSL engine support
206 * Usually, path to engine_opensc.so.
208 const char *opensc_engine_path;
210 * pkcs11_engine_path - PKCS#11 engine for OpenSSL engine support
212 * Usually, path to engine_pkcs11.so.
214 const char *pkcs11_engine_path;
216 * pkcs11_module_path - OpenSC PKCS#11 module for OpenSSL engine
218 * Usually, path to opensc-pkcs11.so.
220 const char *pkcs11_module_path;
223 struct eap_sm * eap_sm_init(void *eapol_ctx, struct eapol_callbacks *eapol_cb,
224 void *msg_ctx, struct eap_config *conf);
225 void eap_sm_deinit(struct eap_sm *sm);
226 int eap_sm_step(struct eap_sm *sm);
227 void eap_sm_abort(struct eap_sm *sm);
228 int eap_sm_get_status(struct eap_sm *sm, char *buf, size_t buflen,
229 int verbose);
230 u8 * eap_sm_buildIdentity(struct eap_sm *sm, int id, size_t *len,
231 int encrypted);
232 const struct eap_method * eap_sm_get_eap_methods(int method);
233 void eap_sm_request_identity(struct eap_sm *sm, struct wpa_ssid *config);
234 void eap_sm_request_password(struct eap_sm *sm, struct wpa_ssid *config);
235 void eap_sm_request_new_password(struct eap_sm *sm, struct wpa_ssid *config);
236 void eap_sm_request_pin(struct eap_sm *sm, struct wpa_ssid *config);
237 void eap_sm_request_otp(struct eap_sm *sm, struct wpa_ssid *config,
238 const char *msg, size_t msg_len);
239 void eap_sm_request_passphrase(struct eap_sm *sm, struct wpa_ssid *config);
240 void eap_sm_notify_ctrl_attached(struct eap_sm *sm);
241 u8 eap_get_type(const char *name);
242 const char * eap_get_name(EapType type);
243 size_t eap_get_names(char *buf, size_t buflen);
244 u8 eap_get_phase2_type(const char *name);
245 u8 *eap_get_phase2_types(struct wpa_ssid *config, size_t *count);
246 void eap_set_fast_reauth(struct eap_sm *sm, int enabled);
247 void eap_set_workaround(struct eap_sm *sm, unsigned int workaround);
248 void eap_set_force_disabled(struct eap_sm *sm, int disabled);
249 struct wpa_ssid * eap_get_config(struct eap_sm *sm);
250 int eap_key_available(struct eap_sm *sm);
251 void eap_notify_success(struct eap_sm *sm);
252 void eap_notify_lower_layer_success(struct eap_sm *sm);
253 const u8 * eap_get_eapKeyData(struct eap_sm *sm, size_t *len);
254 u8 * eap_get_eapRespData(struct eap_sm *sm, size_t *len);
255 void eap_register_scard_ctx(struct eap_sm *sm, void *ctx);
257 #else /* IEEE8021X_EAPOL */
259 static inline u8 eap_get_type(const char *name)
261 return EAP_TYPE_NONE;
264 static inline const char * eap_get_name(EapType type)
266 return NULL;
269 static inline size_t eap_get_names(char *buf, size_t buflen)
271 return 0;
274 #endif /* IEEE8021X_EAPOL */
276 #endif /* EAP_H */