5adc913bc420c7e6928ca9ae80f911fff8c998d1
[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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  *
22  * Copyright 2001  hereUare Communications, Inc. <raghud@hereuare.com>
23  * Copyright 2003  Alan DeKok <aland@freeradius.org>
24  */
25 #ifndef _EAP_TYPES_H
26 #define _EAP_TYPES_H
27
28 #if HAVE_SYS_TYPES_H
29 #include <sys/types.h>
30 #endif
31
32 #if HAVE_NETINET_IN_H
33 #include <netinet/in.h>
34 #endif
35
36 #include <string.h>
37 #include <stdlib.h>
38
39 #include <freeradius-devel/radiusd.h>
40 #include <freeradius-devel/modules.h>
41
42 #include <freeradius-devel/rad_assert.h>
43
44 #define PW_EAP_REQUEST          1
45 #define PW_EAP_RESPONSE         2
46 #define PW_EAP_SUCCESS          3
47 #define PW_EAP_FAILURE          4
48 #define PW_EAP_MAX_CODES        4
49
50 /* base for dictionary values */
51 #define ATTRIBUTE_EAP_ID        1020
52 #define ATTRIBUTE_EAP_CODE      1021
53 #define ATTRIBUTE_EAP_MD5_PASSWORD 1022
54 #define ATTRIBUTE_EAP_BASE      (5*256)
55
56 #define PW_EAP_IDENTITY         1
57 #define PW_EAP_NOTIFICATION     2
58 #define PW_EAP_NAK              3
59 #define PW_EAP_MD5              4
60 #define PW_EAP_OTP              5
61 #define PW_EAP_GTC              6
62 #define PW_EAP_TLS              13
63 #define PW_EAP_LEAP             17
64 #define PW_EAP_SIM              18
65 #define PW_EAP_TTLS             21
66 #define PW_EAP_PEAP             25
67 #define PW_EAP_MSCHAPV2         26
68 #define PW_EAP_CISCO_MSCHAPV2   29
69 #define PW_EAP_MAX_TYPES        29
70
71 #define EAP_HEADER_LEN          4
72
73 #define EAP_START               2
74 #define NAME_LEN                32
75
76 enum {
77         EAP_NOTFOUND,    /* not found */
78         EAP_FOUND,       /* found, continue */
79         EAP_OK,          /* ok, continue */
80         EAP_FAIL,        /* failed, don't reply */
81         EAP_NOOP,        /* succeeded without doing anything */
82         EAP_INVALID,     /* invalid, don't reply */
83         EAP_VALID        /* valid, continue */
84 };
85
86 /*
87  * EAP-Type specific data.
88  */
89 typedef struct eaptype_t {
90         unsigned char   type;
91         unsigned int    length;
92         unsigned char   *data;
93 } eaptype_t;
94
95 /*
96  * Structure to hold EAP data.
97  *
98  * length = code + id + length + type + type.data
99  *        =  1   +  1 +   2    +  1   +  X
100  */
101 typedef struct eap_packet {
102         unsigned char   code;
103         unsigned char   id;
104         unsigned int    length;
105         eaptype_t       type;
106
107         unsigned char   *packet;
108 } EAP_PACKET;
109
110 /*
111  * Structure to represent packet format of eap *on wire*
112  */
113 typedef struct eap_packet_t {
114         unsigned char   code;
115         unsigned char   id;
116         unsigned char   length[2];
117         unsigned char   data[1];
118 } eap_packet_t;
119
120
121
122
123
124 /*
125  * interfaces in eapcommon.c
126  */
127 extern int eaptype_name2type(const char *name);
128 extern const char *eaptype_type2name(unsigned int type, char *buffer, size_t buflen);
129 extern int eap_basic_compose(RADIUS_PACKET *packet, EAP_PACKET *reply);
130 extern void map_eap_types(RADIUS_PACKET *req);
131 extern eap_packet_t *eap_attribute(VALUE_PAIR *vps);
132 extern void unmap_eap_types(RADIUS_PACKET *rep);
133
134 #endif /* _EAP_TYPES_H */