Massively cleaned up #include's, so they're in a consistent
[freeradius.git] / src / modules / rlm_eap / eap.h
1 /*
2  * eap.h    Header file containing the interfaces for all EAP types.
3  *
4  * Version:     $Id$
5  *
6  *   This program is free software; you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation; either version 2 of the License, or
9  *   (at your option) any later version.
10  *
11  *   This program is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *   GNU General Public License for more details.
15  *
16  *   You should have received a copy of the GNU General Public License
17  *   along with this program; if not, write to the Free Software
18  *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  *
20  * Copyright 2001  hereUare Communications, Inc. <raghud@hereuare.com>
21  * Copyright 2003  Alan DeKok <aland@freeradius.org>
22  * Copyright 2006  The FreeRADIUS server project
23  */
24 #ifndef _EAP_H
25 #define _EAP_H
26
27 #include <freeradius-devel/ident.h>
28 RCSIDH(eap_h, "$Id$")
29
30 #include <freeradius-devel/radiusd.h>
31 #include <freeradius-devel/modules.h>
32 #include <freeradius-devel/rad_assert.h>
33
34 #include "eap_types.h"
35
36 /*
37  * EAP_DS contains all the received/sending information
38  * response = Received EAP packet
39  * request = Sending EAP packet
40  *
41  * Note: We are authentication server,
42  *  we get ONLY EAP-Responses and
43  *  we send EAP-Request/EAP-success/EAP-failure
44  */
45 typedef struct eap_ds {
46         EAP_PACKET      *response;
47         EAP_PACKET      *request;
48         int             set_request_id;
49 } EAP_DS;
50
51 /*
52  * Currently there are only 2 types
53  * of operations defined,
54  * apart from attach & detach for each EAP-Type.
55  */
56 typedef enum operation_t {
57         INITIATE = 0,
58         AUTHORIZE,
59         AUTHENTICATE
60 } operation_t;
61
62
63 /*
64  * EAP_HANDLER is the interface for any EAP-Type.
65  * Each handler contains information for one specific EAP-Type.
66  * This way we don't need to change any interfaces in future.
67  * It is also a list of EAP-request handlers waiting for EAP-response
68  * eap_id = copy of the eap packet we sent to the
69  *
70  * next = pointer to next
71  * state = state attribute from the reply we sent
72  * state_len = length of data in the state attribute.
73  * src_ipaddr = client which sent us the RADIUS request containing
74  *              this EAP conversation.
75  * eap_id = copy of EAP id we sent to the client.
76  * timestamp  = timestamp when this handler was last used.
77  * identity = Identity, as obtained, from EAP-Identity response.
78  * request = RADIUS request data structure
79  * prev_eapds = Previous EAP request, for which eap_ds contains the response.
80  * eap_ds   = Current EAP response.
81  * opaque   = EAP-Type holds some data that corresponds to the current
82  *              EAP-request/response
83  * free_opaque = To release memory held by opaque,
84  *              when this handler is timedout & needs to be deleted.
85  *              It is the responsibility of the specific EAP-TYPE
86  *              to avoid any memory leaks in opaque
87  *              Hence this pointer should be provided by the EAP-Type
88  *              if opaque is not NULL
89  * status   = finished/onhold/..
90  */
91 #define EAP_STATE_LEN (AUTH_VECTOR_LEN)
92 typedef struct _eap_handler {
93         struct _eap_handler *prev, *next;
94         uint8_t         state[EAP_STATE_LEN];
95         lrad_ipaddr_t   src_ipaddr;
96         unsigned int    eap_id;
97         unsigned int    eap_type;
98
99         time_t          timestamp;
100
101         REQUEST         *request;
102
103         char            *identity; /* User name from EAP-Identity */
104
105         EAP_DS          *prev_eapds;
106         EAP_DS          *eap_ds;
107
108         void            *opaque;
109         void            (*free_opaque)(void *opaque);
110
111         int             status;
112
113         int             stage;
114 } EAP_HANDLER;
115
116 /*
117  * Interface to call EAP sub mdoules
118  */
119 typedef struct eap_type_t {
120         const   char *name;
121         int     (*attach)(CONF_SECTION *conf, void **type_data);
122         int     (*initiate)(void *type_data, EAP_HANDLER *handler);
123         int     (*authorize)(void *type_data, EAP_HANDLER *handler);
124         int     (*authenticate)(void *type_data, EAP_HANDLER *handler);
125         int     (*detach)(void *type_data);
126 } EAP_TYPE;
127
128 #define REQUEST_DATA_EAP_HANDLER         (1)
129 #define REQUEST_DATA_EAP_TUNNEL_CALLBACK PW_EAP_MESSAGE
130 #define REQUEST_DATA_EAP_MSCHAP_TUNNEL_CALLBACK ((PW_EAP_MESSAGE << 16) | PW_EAP_MSCHAPV2)
131 #define RAD_REQUEST_OPTION_PROXY_EAP    (1 << 16)
132
133 /*
134  *      This is for tunneled callbacks
135  */
136 typedef int (*eap_tunnel_callback_t)(EAP_HANDLER *handler, void *tls_session);
137 typedef struct eap_tunnel_data_t {
138   void                  *tls_session;
139   eap_tunnel_callback_t callback;
140 } eap_tunnel_data_t;
141
142 #endif /*_EAP_H*/