Port "use_tunneled_reply" fix for MS-CHAP from branch_1_1
[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 #include <freeradius-devel/ident.h>
30 RCSIDH(eap_types_h, "$Id$")
31
32 #if HAVE_SYS_TYPES_H
33 #include <sys/types.h>
34 #endif
35
36 #if 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 #define PW_EAP_REQUEST          1
47 #define PW_EAP_RESPONSE         2
48 #define PW_EAP_SUCCESS          3
49 #define PW_EAP_FAILURE          4
50 #define PW_EAP_MAX_CODES        4
51
52 /* base for dictionary values */
53 #define ATTRIBUTE_EAP_ID        1020
54 #define ATTRIBUTE_EAP_CODE      1021
55 #define ATTRIBUTE_EAP_BASE      1280
56
57 #define PW_EAP_IDENTITY         1
58 #define PW_EAP_NOTIFICATION     2
59 #define PW_EAP_NAK              3
60 #define PW_EAP_MD5              4
61 #define PW_EAP_OTP              5
62 #define PW_EAP_GTC              6
63 #define PW_EAP_TLS              13
64 #define PW_EAP_LEAP             17
65 #define PW_EAP_SIM              18
66 #define PW_EAP_TTLS             21
67 #define PW_EAP_PEAP             25
68 #define PW_EAP_MSCHAPV2         26
69 #define PW_EAP_CISCO_MSCHAPV2   29
70 #define PW_EAP_MAX_TYPES        29
71
72 #define EAP_HEADER_LEN          4
73
74 #define EAP_START               2
75 #define NAME_LEN                32
76
77 enum {
78         EAP_NOTFOUND,    /* not found */
79         EAP_FOUND,       /* found, continue */
80         EAP_OK,          /* ok, continue */
81         EAP_FAIL,        /* failed, don't reply */
82         EAP_NOOP,        /* succeeded without doing anything */
83         EAP_INVALID,     /* invalid, don't reply */
84         EAP_VALID        /* valid, continue */
85 };
86
87 /*
88  * EAP-Type specific data.
89  */
90 typedef struct eaptype_t {
91         unsigned char   type;
92         unsigned int    length;
93         unsigned char   *data;
94 } eaptype_t;
95
96 /*
97  * Structure to hold EAP data.
98  *
99  * length = code + id + length + type + type.data
100  *        =  1   +  1 +   2    +  1   +  X
101  */
102 typedef struct eap_packet {
103         unsigned char   code;
104         unsigned char   id;
105         unsigned int    length;
106         eaptype_t       type;
107
108         unsigned char   *packet;
109 } EAP_PACKET;
110
111 /*
112  * Structure to represent packet format of eap *on wire*
113  */
114 typedef struct eap_packet_t {
115         unsigned char   code;
116         unsigned char   id;
117         unsigned char   length[2];
118         unsigned char   data[1];
119 } eap_packet_t;
120
121
122
123
124
125 /*
126  * interfaces in eapcommon.c
127  */
128 extern int eaptype_name2type(const char *name);
129 extern const char *eaptype_type2name(unsigned int type, char *buffer, size_t buflen);
130 extern int eap_basic_compose(RADIUS_PACKET *packet, EAP_PACKET *reply);
131 extern void map_eap_types(RADIUS_PACKET *req);
132 extern eap_packet_t *eap_attribute(VALUE_PAIR *vps);
133 extern void unmap_eap_types(RADIUS_PACKET *rep);
134
135 #endif /* _EAP_TYPES_H */