]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - contrib/hostapd/eap.h
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / contrib / hostapd / eap.h
1 /* $FreeBSD$ */
2
3 /*
4  * hostapd / EAP Standalone Authenticator state machine (RFC 4137)
5  * Copyright (c) 2004-2005, Jouni Malinen <j@w1.fi>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  * Alternatively, this software may be distributed under the terms of BSD
12  * license.
13  *
14  * See README and COPYING for more details.
15  */
16
17 #ifndef EAP_H
18 #define EAP_H
19
20 #include "defs.h"
21 #include "eap_defs.h"
22 #include "eap_methods.h"
23
24 struct eap_sm;
25
26 #define EAP_MAX_METHODS 8
27 struct eap_user {
28         struct {
29                 int vendor;
30                 u32 method;
31         } methods[EAP_MAX_METHODS];
32         u8 *password;
33         size_t password_len;
34         int password_hash; /* whether password is hashed with
35                             * nt_password_hash() */
36         int phase2;
37         int force_version;
38 };
39
40 enum eapol_bool_var {
41         EAPOL_eapSuccess, EAPOL_eapRestart, EAPOL_eapFail, EAPOL_eapResp,
42         EAPOL_eapReq, EAPOL_eapNoReq, EAPOL_portEnabled, EAPOL_eapTimeout
43 };
44
45 struct eapol_callbacks {
46         Boolean (*get_bool)(void *ctx, enum eapol_bool_var variable);
47         void (*set_bool)(void *ctx, enum eapol_bool_var variable,
48                          Boolean value);
49         void (*set_eapReqData)(void *ctx, const u8 *eapReqData,
50                                size_t eapReqDataLen);
51         void (*set_eapKeyData)(void *ctx, const u8 *eapKeyData,
52                                size_t eapKeyDataLen);
53         int (*get_eap_user)(void *ctx, const u8 *identity, size_t identity_len,
54                             int phase2, struct eap_user *user);
55         const char * (*get_eap_req_id_text)(void *ctx, size_t *len);
56 };
57
58 struct eap_config {
59         void *ssl_ctx;
60         void *eap_sim_db_priv;
61         Boolean backend_auth;
62 };
63
64
65 #ifdef EAP_SERVER
66
67 struct eap_sm * eap_sm_init(void *eapol_ctx, struct eapol_callbacks *eapol_cb,
68                             struct eap_config *eap_conf);
69 void eap_sm_deinit(struct eap_sm *sm);
70 int eap_sm_step(struct eap_sm *sm);
71 void eap_set_eapRespData(struct eap_sm *sm, const u8 *eapRespData,
72                          size_t eapRespDataLen);
73 void eap_sm_notify_cached(struct eap_sm *sm);
74 void eap_sm_pending_cb(struct eap_sm *sm);
75 int eap_sm_method_pending(struct eap_sm *sm);
76
77 #else /* EAP_SERVER */
78
79 static inline struct eap_sm * eap_sm_init(void *eapol_ctx,
80                                           struct eapol_callbacks *eapol_cb,
81                                           struct eap_config *eap_conf)
82 {
83         return NULL;
84 }
85
86 static inline void eap_sm_deinit(struct eap_sm *sm)
87 {
88 }
89
90 static inline int eap_sm_step(struct eap_sm *sm)
91 {
92         return 0;
93 }
94
95
96 static inline void eap_set_eapRespData(struct eap_sm *sm,
97                                        const u8 *eapRespData,
98                                        size_t eapRespDataLen)
99 {
100 }
101
102 static inline void eap_sm_notify_cached(struct eap_sm *sm)
103 {
104 }
105
106 static inline void eap_sm_pending_cb(struct eap_sm *sm)
107 {
108 }
109
110 static inline int eap_sm_method_pending(struct eap_sm *sm)
111 {
112         return 0;
113 }
114
115 #endif /* EAP_SERVER */
116
117 #endif /* EAP_H */