Remove duplicate chbind functions now located in eap_chbind.*
[freeradius.git] / src / modules / rlm_eap / libeap / eap_types.h
1 /*
2  * eap_types.h  Header file containing the interfaces for all EAP types.
3  *
4  * most contents moved from modules/rlm_eap/eap.h
5  *
6  * Version:     $Id$
7  *
8  *   This program is free software; you can redistribute it and/or modify
9  *   it under the terms of the GNU General Public License as published by
10  *   the Free Software Foundation; either version 2 of the License, or
11  *   (at your option) any later version.
12  *
13  *   This program is distributed in the hope that it will be useful,
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *   GNU General Public License for more details.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with this program; if not, write to the Free Software
20  *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  *
22  * Copyright 2001  hereUare Communications, Inc. <raghud@hereuare.com>
23  * Copyright 2003  Alan DeKok <aland@freeradius.org>
24  * Copyright 2006  The FreeRADIUS server project
25  */
26 #ifndef _EAP_TYPES_H
27 #define _EAP_TYPES_H
28
29 RCSIDH(eap_methods_h, "$Id$")
30
31 #include <freeradius-devel/radiusd.h>
32 #include <freeradius-devel/modules.h>
33
34 /* Field length and other arbitrary things */
35 #define EAP_HEADER_LEN          4
36
37 typedef enum eap_code {
38         PW_EAP_REQUEST = 1,
39         PW_EAP_RESPONSE,
40         PW_EAP_SUCCESS,
41         PW_EAP_FAILURE,
42         PW_EAP_MAX_CODES
43 } eap_code_t;
44
45 typedef enum eap_method {
46         PW_EAP_INVALID = 0,             /* 0 */
47         PW_EAP_IDENTITY,                /* 1 */
48         PW_EAP_NOTIFICATION,            /* 2 */
49         PW_EAP_NAK,                     /* 3 */
50         PW_EAP_MD5,                     /* 4 */
51         PW_EAP_OTP,                     /* 5 */
52         PW_EAP_GTC,                     /* 6 */
53         PW_EAP_7,                       /* 7  - unused */
54         PW_EAP_8,                       /* 8  - unused */
55         PW_EAP_RSA_PUBLIC_KEY,          /* 9 */
56         PW_EAP_DSS_UNILATERAL,          /* 10 */
57         PW_EAP_KEA,                     /* 11 */
58         PW_EAP_KEA_VALIDATE,            /* 12 */
59         PW_EAP_TLS,                     /* 13 */
60         PW_EAP_DEFENDER_TOKEN,          /* 14 */
61         PW_EAP_RSA_SECURID,             /* 15 */
62         PW_EAP_ARCOT_SYSTEMS,           /* 16 */
63         PW_EAP_LEAP,                    /* 17 */
64         PW_EAP_SIM,                     /* 18 */
65         PW_EAP_SRP_SHA1,                /* 19 */
66         PW_EAP_20,                      /* 20 - unassigned */
67         PW_EAP_TTLS,                    /* 21 */
68         PW_EAP_REMOTE_ACCESS_SERVICE,   /* 22 */
69         PW_EAP_AKA,                     /* 23 */
70         PW_EAP_3COM,                    /* 24 - should this be EAP-HP now? */
71         PW_EAP_PEAP,                    /* 25 */
72         PW_EAP_MSCHAPV2,                /* 26 */
73         PW_EAP_MAKE,                    /* 27 */
74         PW_EAP_CRYPTOCARD,              /* 28 */
75         PW_EAP_CISCO_MSCHAPV2,          /* 29 */
76         PW_EAP_DYNAMID,                 /* 30 */
77         PW_EAP_ROB,                     /* 31 */
78         PW_EAP_POTP,                    /* 32 */
79         PW_EAP_MS_ATLV,                 /* 33 */
80         PW_EAP_SENTRINET,               /* 34 */
81         PW_EAP_ACTIONTEC,               /* 35 */
82         PW_EAP_COGENT_BIOMETRIC,        /* 36 */
83         PW_EAP_AIRFORTRESS,             /* 37 */
84         PW_EAP_TNC,                     /* 38 - fixme conflicts with HTTP DIGEST */
85 //      PW_EAP_HTTP_DIGEST,             /* 38 */
86         PW_EAP_SECURISUITE,             /* 39 */
87         PW_EAP_DEVICECONNECT,           /* 40 */
88         PW_EAP_SPEKE,                   /* 41 */
89         PW_EAP_MOBAC,                   /* 42 */
90         PW_EAP_FAST,                    /* 43 */
91         PW_EAP_ZONELABS,                /* 44 */
92         PW_EAP_LINK,                    /* 45 */
93         PW_EAP_PAX,                     /* 46 */
94         PW_EAP_PSK,                     /* 47 */
95         PW_EAP_SAKE,                    /* 48 */
96         PW_EAP_IKEV2,                   /* 49 */
97         PW_EAP_AKA2,                    /* 50 */
98         PW_EAP_GPSK,                    /* 51 */
99         PW_EAP_PWD,                     /* 52 */
100         PW_EAP_EKE,                     /* 53 */
101         PW_EAP_MAX_TYPES                /* 54 - for validation */
102 } eap_type_t;
103
104 typedef enum eap_rcode {
105         EAP_NOTFOUND,           //!< EAP handler data not found.
106         EAP_FOUND,              //!< EAP handler data found, continue.
107         EAP_OK,                 //!< Ok, continue.
108         EAP_FAIL,               //!< Failed, don't reply.
109         EAP_NOOP,               //!< Succeeded without doing anything.
110         EAP_INVALID,            //!< Invalid, don't reply.
111         EAP_VALID,              //!< Valid, continue.
112         EAP_MAX_RCODES
113 } eap_rcode_t;
114
115 extern const FR_NAME_NUMBER eap_rcode_table[];
116
117 /*
118  * EAP-Type specific data.
119  */
120 typedef struct eap_type_data {
121         eap_type_t      num;
122         size_t          length;
123         uint8_t         *data;
124 } eap_type_data_t;
125
126 /*
127  * Structure to hold EAP data.
128  *
129  * length = code + id + length + type + type.data
130  *      =  1   +  1 +   2    +  1   +  X
131  */
132 typedef struct eap_packet {
133         eap_code_t      code;
134         uint8_t         id;
135         size_t          length;
136         eap_type_data_t type;
137
138         uint8_t         *packet;
139 } eap_packet_t;
140
141 /*
142  * Structure to represent packet format of eap *on wire*
143  */
144 typedef struct eap_packet_raw {
145         uint8_t         code;
146         uint8_t         id;
147         uint8_t         length[2];
148         uint8_t         data[1];
149 } eap_packet_raw_t;
150
151 /*
152  * Structure to represent eap channel binding packet format *on wire*
153  */
154 typedef struct eap_chbind_packet_t {
155         uint8_t         code;
156         uint8_t         data[1];
157 } eap_chbind_packet_t;
158
159
160 /*
161  * interfaces in eapcommon.c
162  */
163 extern eap_type_t eap_name2type(char const *name);
164 extern char const *eap_type2name(eap_type_t method);
165 extern int eap_wireformat(eap_packet_t *reply);
166 extern int eap_basic_compose(RADIUS_PACKET *packet, eap_packet_t *reply);
167 extern VALUE_PAIR *eap_packet2vp(RADIUS_PACKET *packet, eap_packet_raw_t const *reply);
168 extern eap_packet_raw_t *eap_vp2packet(TALLOC_CTX *ctx, VALUE_PAIR *vps);
169 void eap_add_reply(REQUEST *request,
170                    char const *name, uint8_t const *value, int len);
171
172 #endif /* _EAP_TYPES_H */