Backing out removal of "modules.h".
[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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  * Copyright 2001  hereUare Communications, Inc. <raghud@hereuare.com>
21  */
22 #ifndef _EAP_H
23 #define _EAP_H
24
25 #include "autoconf.h"
26
27 #if HAVE_SYS_TYPES_H
28 #include <sys/types.h>
29 #endif
30
31 #if HAVE_NETINET_IN_H
32 #include <netinet/in.h>
33 #endif
34
35 #include <string.h>
36 #include <stdlib.h>
37
38 #include "radiusd.h"
39 #include "modules.h"
40
41
42 #define PW_EAP_REQUEST          1
43 #define PW_EAP_RESPONSE         2
44 #define PW_EAP_SUCCESS          3
45 #define PW_EAP_FAILURE          4
46 #define PW_EAP_MAX_CODES        4
47
48 #define PW_EAP_IDENTITY         1
49 #define PW_EAP_NOTIFICATION     2
50 #define PW_EAP_NAK              3
51 #define PW_EAP_MD5              4
52 #define PW_EAP_OTP              5
53 #define PW_EAP_GTC              6
54 #define PW_EAP_TLS              13
55 #define PW_EAP_MAX_TYPES        13
56
57 #define EAP_HEADER_LEN          4
58
59 /*
60  * EAP-Type specific data.
61  */
62 typedef struct eaptype_t {
63         unsigned char   type;
64         unsigned int    length;
65         unsigned char   *data;
66 } eaptype_t;
67
68 /*
69  * Structure to hold EAP data.
70  *
71  * length = code + id + length + type + type.data
72  *        =  1   +  1 +   2    +  1   +  X
73  */
74 typedef struct eap_packet {
75         unsigned char   code;
76         unsigned char   id;
77         unsigned int    length;
78         eaptype_t       type;
79
80         unsigned char   *packet;
81 } EAP_PACKET;
82
83 /*
84  * EAP_DS contains all the received/sending information
85  * response = Received EAP packet
86  * request = Sending EAP packet
87  *
88  * Note: We are authentication server, 
89  *  we get ONLY EAP-Responses and 
90  *  we send EAP-Request/EAP-success/EAP-failure
91  */
92 typedef struct eap_ds {
93         EAP_PACKET      *response;
94         EAP_PACKET      *request;
95 } EAP_DS;
96
97 /*
98  * EAP_HANDLER is the interface for any EAP-Type.
99  * Each handler contains information for one specific EAP-Type.
100  * This way we don't need to change any interfaces in future.
101  * It is also a list of EAP-request handlers waiting for EAP-response
102  *
103  * id = Length + Request-ID + State + (NAS-IP-Address|NAS-Identifier)
104  * identity = Identity, as obtained, from EAP-Identity response.
105  * username = as obtained in Radius request, It might differ from identity.
106  * configured = List of configured values for this user.
107  * prev_eapds = Previous EAP request, for which eap_ds contains the response.
108  * eap_ds   = Current EAP response.
109  * opaque   = EAP-Type holds some data that corresponds to the current
110  *              EAP-request/response
111  * free_opaque = To release memory held by opaque, 
112  *              when this handler is timedout & needs to be deleted.
113  *              It is the responsibility of the specific EAP-TYPE 
114  *              to avoid any memory leaks in opaque
115  *              Hence this pointer should be provided by the EAP-Type
116  *              if opaque is not NULL
117  * timestamp  = timestamp when this handler is created.
118  * status   = finished/onhold/..
119  */
120 typedef struct _eap_handler {
121         unsigned char   *id;
122
123         VALUE_PAIR      *username;
124         VALUE_PAIR      *configured;
125
126         char    *identity;
127
128         EAP_DS  *prev_eapds;
129         EAP_DS  *eap_ds;
130
131         void    *opaque;
132         void    (*free_opaque)(void **opaque);
133
134         time_t  timestamp;
135         int     status;
136
137         struct _eap_handler *next;
138 } EAP_HANDLER;
139
140 /* 
141  * Interface to call EAP sub mdoules
142  */
143 typedef struct eap_type_t {
144         const   char *name;
145         int     (*attach)(CONF_SECTION *conf, void **type_arg);
146         int     (*initiate)(void *type_arg, EAP_HANDLER *handler);
147         int     (*authenticate)(void *type_arg, EAP_HANDLER *handler);
148         int     (*detach)(void **type_arg);
149 } EAP_TYPE;
150
151 #endif /*_EAP_H*/