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