Import hostapd 0.5.8
[dragonfly.git] / contrib / hostapd-0.5.8 / eap.h
1 /*
2  * hostapd / EAP Standalone Authenticator state machine (RFC 4137)
3  * Copyright (c) 2004-2005, 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 "defs.h"
19 #include "eap_defs.h"
20 #include "eap_methods.h"
21
22 struct eap_sm;
23
24 #define EAP_MAX_METHODS 8
25 struct eap_user {
26         struct {
27                 int vendor;
28                 u32 method;
29         } methods[EAP_MAX_METHODS];
30         u8 *password;
31         size_t password_len;
32         int password_hash; /* whether password is hashed with
33                             * nt_password_hash() */
34         int phase2;
35         int force_version;
36 };
37
38 enum eapol_bool_var {
39         EAPOL_eapSuccess, EAPOL_eapRestart, EAPOL_eapFail, EAPOL_eapResp,
40         EAPOL_eapReq, EAPOL_eapNoReq, EAPOL_portEnabled, EAPOL_eapTimeout
41 };
42
43 struct eapol_callbacks {
44         Boolean (*get_bool)(void *ctx, enum eapol_bool_var variable);
45         void (*set_bool)(void *ctx, enum eapol_bool_var variable,
46                          Boolean value);
47         void (*set_eapReqData)(void *ctx, const u8 *eapReqData,
48                                size_t eapReqDataLen);
49         void (*set_eapKeyData)(void *ctx, const u8 *eapKeyData,
50                                size_t eapKeyDataLen);
51         int (*get_eap_user)(void *ctx, const u8 *identity, size_t identity_len,
52                             int phase2, struct eap_user *user);
53         const char * (*get_eap_req_id_text)(void *ctx, size_t *len);
54 };
55
56 struct eap_config {
57         void *ssl_ctx;
58         void *eap_sim_db_priv;
59         Boolean backend_auth;
60 };
61
62
63 #ifdef EAP_SERVER
64
65 struct eap_sm * eap_sm_init(void *eapol_ctx, struct eapol_callbacks *eapol_cb,
66                             struct eap_config *eap_conf);
67 void eap_sm_deinit(struct eap_sm *sm);
68 int eap_sm_step(struct eap_sm *sm);
69 void eap_set_eapRespData(struct eap_sm *sm, const u8 *eapRespData,
70                          size_t eapRespDataLen);
71 void eap_sm_notify_cached(struct eap_sm *sm);
72 void eap_sm_pending_cb(struct eap_sm *sm);
73 int eap_sm_method_pending(struct eap_sm *sm);
74
75 #else /* EAP_SERVER */
76
77 static inline struct eap_sm * eap_sm_init(void *eapol_ctx,
78                                           struct eapol_callbacks *eapol_cb,
79                                           struct eap_config *eap_conf)
80 {
81         return NULL;
82 }
83
84 static inline void eap_sm_deinit(struct eap_sm *sm)
85 {
86 }
87
88 static inline int eap_sm_step(struct eap_sm *sm)
89 {
90         return 0;
91 }
92
93
94 static inline void eap_set_eapRespData(struct eap_sm *sm,
95                                        const u8 *eapRespData,
96                                        size_t eapRespDataLen)
97 {
98 }
99
100 static inline void eap_sm_notify_cached(struct eap_sm *sm)
101 {
102 }
103
104 static inline void eap_sm_pending_cb(struct eap_sm *sm)
105 {
106 }
107
108 static inline int eap_sm_method_pending(struct eap_sm *sm)
109 {
110         return 0;
111 }
112
113 #endif /* EAP_SERVER */
114
115 #endif /* EAP_H */