Merge from vendor branch OPENSSH:
[dragonfly.git] / contrib / hostapd-0.4.9 / eap.h
1 #ifndef EAP_H
2 #define EAP_H
3
4 #include "defs.h"
5 #include "eap_defs.h"
6
7 struct eap_sm;
8
9 #define EAP_MAX_METHODS 8
10 struct eap_user {
11         u8 methods[EAP_MAX_METHODS];
12         u8 *password;
13         size_t password_len;
14         int phase2;
15         int force_version;
16 };
17
18 enum eapol_bool_var {
19         EAPOL_eapSuccess, EAPOL_eapRestart, EAPOL_eapFail, EAPOL_eapResp,
20         EAPOL_eapReq, EAPOL_eapNoReq, EAPOL_portEnabled, EAPOL_eapTimeout
21 };
22
23 struct eapol_callbacks {
24         Boolean (*get_bool)(void *ctx, enum eapol_bool_var variable);
25         void (*set_bool)(void *ctx, enum eapol_bool_var variable,
26                          Boolean value);
27         void (*set_eapReqData)(void *ctx, const u8 *eapReqData,
28                                size_t eapReqDataLen);
29         void (*set_eapKeyData)(void *ctx, const u8 *eapKeyData,
30                                size_t eapKeyDataLen);
31         int (*get_eap_user)(void *ctx, const u8 *identity, size_t identity_len,
32                             int phase2, struct eap_user *user);
33         const char * (*get_eap_req_id_text)(void *ctx, size_t *len);
34 };
35
36 struct eap_config {
37         void *ssl_ctx;
38         void *eap_sim_db_priv;
39         Boolean backend_auth;
40 };
41
42
43 #ifdef EAP_SERVER
44
45 struct eap_sm * eap_sm_init(void *eapol_ctx, struct eapol_callbacks *eapol_cb,
46                             struct eap_config *eap_conf);
47 void eap_sm_deinit(struct eap_sm *sm);
48 int eap_sm_step(struct eap_sm *sm);
49 u8 eap_get_type(const char *name);
50 void eap_set_eapRespData(struct eap_sm *sm, const u8 *eapRespData,
51                          size_t eapRespDataLen);
52 void eap_sm_notify_cached(struct eap_sm *sm);
53
54 #else /* EAP_SERVER */
55
56 static inline struct eap_sm * eap_sm_init(void *eapol_ctx,
57                                           struct eapol_callbacks *eapol_cb,
58                                           struct eap_config *eap_conf)
59 {
60         return NULL;
61 }
62
63 static inline void eap_sm_deinit(struct eap_sm *sm)
64 {
65 }
66
67 static inline int eap_sm_step(struct eap_sm *sm)
68 {
69         return 0;
70 }
71
72 static inline u8 eap_get_type(const char *name)
73 {
74         return EAP_TYPE_NONE;
75 }
76
77 static inline void eap_set_eapRespData(struct eap_sm *sm,
78                                        const u8 *eapRespData,
79                                        size_t eapRespDataLen)
80 {
81 }
82
83 static inline void eap_sm_notify_cached(struct eap_sm *sm)
84 {
85 }
86
87 #endif /* EAP_SERVER */
88
89 #endif /* EAP_H */