use new RCSID macro to prevent Id keyword from being optimized out
[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/autoconf.h>
31
32 #ifdef HAVE_SYS_TYPES_H
33 #include <sys/types.h>
34 #endif
35
36 #ifdef HAVE_NETINET_IN_H
37 #include <netinet/in.h>
38 #endif
39
40 #include <string.h>
41 #include <stdlib.h>
42
43 #include <freeradius-devel/radiusd.h>
44 #include <freeradius-devel/modules.h>
45
46 #include <freeradius-devel/rad_assert.h>
47
48 #include "eap_types.h"
49
50 /*
51  * EAP_DS contains all the received/sending information
52  * response = Received EAP packet
53  * request = Sending EAP packet
54  *
55  * Note: We are authentication server,
56  *  we get ONLY EAP-Responses and
57  *  we send EAP-Request/EAP-success/EAP-failure
58  */
59 typedef struct eap_ds {
60         EAP_PACKET      *response;
61         EAP_PACKET      *request;
62         int             set_request_id;
63 } EAP_DS;
64
65 /*
66  * Currently there are only 2 types
67  * of operations defined,
68  * apart from attach & detach for each EAP-Type.
69  */
70 typedef enum operation_t {
71         INITIATE = 0,
72         AUTHORIZE,
73         AUTHENTICATE
74 } operation_t;
75
76
77 /*
78  * EAP_HANDLER is the interface for any EAP-Type.
79  * Each handler contains information for one specific EAP-Type.
80  * This way we don't need to change any interfaces in future.
81  * It is also a list of EAP-request handlers waiting for EAP-response
82  * eap_id = copy of the eap packet we sent to the
83  *
84  * next = pointer to next
85  * state = state attribute from the reply we sent
86  * state_len = length of data in the state attribute.
87  * src_ipaddr = client which sent us the RADIUS request containing
88  *              this EAP conversation.
89  * eap_id = copy of EAP id we sent to the client.
90  * timestamp  = timestamp when this handler was last used.
91  * identity = Identity, as obtained, from EAP-Identity response.
92  * request = RADIUS request data structure
93  * prev_eapds = Previous EAP request, for which eap_ds contains the response.
94  * eap_ds   = Current EAP response.
95  * opaque   = EAP-Type holds some data that corresponds to the current
96  *              EAP-request/response
97  * free_opaque = To release memory held by opaque,
98  *              when this handler is timedout & needs to be deleted.
99  *              It is the responsibility of the specific EAP-TYPE
100  *              to avoid any memory leaks in opaque
101  *              Hence this pointer should be provided by the EAP-Type
102  *              if opaque is not NULL
103  * status   = finished/onhold/..
104  */
105 #define EAP_STATE_LEN (AUTH_VECTOR_LEN)
106 typedef struct _eap_handler {
107         struct _eap_handler *prev, *next;
108         uint8_t         state[EAP_STATE_LEN];
109         lrad_ipaddr_t   src_ipaddr;
110         unsigned int    eap_id;
111         unsigned int    eap_type;
112
113         time_t          timestamp;
114
115         REQUEST         *request;
116
117         char            *identity; /* User name from EAP-Identity */
118
119         EAP_DS          *prev_eapds;
120         EAP_DS          *eap_ds;
121
122         void            *opaque;
123         void            (*free_opaque)(void *opaque);
124
125         int             status;
126
127         int             stage;
128 } EAP_HANDLER;
129
130 /*
131  * Interface to call EAP sub mdoules
132  */
133 typedef struct eap_type_t {
134         const   char *name;
135         int     (*attach)(CONF_SECTION *conf, void **type_data);
136         int     (*initiate)(void *type_data, EAP_HANDLER *handler);
137         int     (*authorize)(void *type_data, EAP_HANDLER *handler);
138         int     (*authenticate)(void *type_data, EAP_HANDLER *handler);
139         int     (*detach)(void *type_data);
140 } EAP_TYPE;
141
142 #define REQUEST_DATA_EAP_HANDLER         (1)
143 #define REQUEST_DATA_EAP_TUNNEL_CALLBACK PW_EAP_MESSAGE
144 #define REQUEST_DATA_EAP_MSCHAP_TUNNEL_CALLBACK ((PW_EAP_MESSAGE << 16) | PW_EAP_MSCHAPV2)
145 #define RAD_REQUEST_OPTION_PROXY_EAP    (1 << 16)
146
147 /*
148  *      This is for tunneled callbacks
149  */
150 typedef int (*eap_tunnel_callback_t)(EAP_HANDLER *handler, void *tls_session);
151 typedef struct eap_tunnel_data_t {
152   void                  *tls_session;
153   eap_tunnel_callback_t callback;
154 } eap_tunnel_data_t;
155
156 #endif /*_EAP_H*/