When we have a tunneled MS-CHAP2-Success attribute, it goes
[freeradius.git] / src / modules / rlm_eap / rlm_eap.h
1 /*
2  * rlm_eap.h    Local Header file.
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  * Copyright 2003  Alan DeKok <aland@freeradius.org>
22  */
23 #ifndef _RLM_EAP_H
24 #define _RLM_EAP_H
25
26 #include <ltdl.h>
27 #include "eap.h"
28 #include "eap_types.h"
29
30 /*
31  * Keep track of which sub modules we've loaded.
32  */
33 typedef struct eap_types_t {
34         const char      *typename;
35         EAP_TYPE        *type;
36         lt_dlhandle     handle;
37         CONF_SECTION    *cs;
38         void            *type_data;
39 } EAP_TYPES;
40
41 /*
42  * This structure contains eap's persistent data.
43  * sessions = remembered sessions, in a tree for speed.
44  * types = All supported EAP-Types
45  * mutex = ensure only one thread is updating the sessions[] struct
46  */
47 typedef struct rlm_eap_t {
48         rbtree_t        *session_tree;
49         EAP_HANDLER     *session_head, *session_tail;
50         EAP_TYPES       *types[PW_EAP_MAX_TYPES + 1];
51
52         /*
53          *      Configuration items.
54          */
55         int             timer_limit;
56         char            *default_eap_type_name;
57         int             default_eap_type;
58         int             ignore_unknown_eap_types;
59         int             cisco_accounting_username_bug;
60
61 #ifdef HAVE_PTHREAD_H
62         pthread_mutex_t session_mutex;
63 #endif
64 } rlm_eap_t;
65
66 /*
67  *      For simplicity in the rest of the code.
68  */
69 #ifndef HAVE_PTHREAD_H
70 /*
71  *      This is easier than ifdef's throughout the code.
72  */
73 #define pthread_mutex_init(_x, _y)
74 #define pthread_mutex_destroy(_x)
75 #define pthread_mutex_lock(_x)
76 #define pthread_mutex_unlock(_x)
77 #endif
78
79 /* function definitions */
80 /* EAP-Type */
81 int             eaptype_load(EAP_TYPES **type, int eap_type, CONF_SECTION *cs);
82 int             eaptype_select(rlm_eap_t *inst, EAP_HANDLER *h);
83 void            eaptype_free(EAP_TYPES *tl);
84
85 /* EAP */
86 int             eap_start(rlm_eap_t *inst, REQUEST *request);
87 void            eap_fail(EAP_HANDLER *handler);
88 void            eap_success(EAP_HANDLER *handler);
89 int             eap_compose(EAP_HANDLER *handler);
90 EAP_HANDLER     *eap_handler(rlm_eap_t *inst, eap_packet_t **eap_msg, REQUEST *request);
91
92 /* Memory Management */
93 EAP_PACKET      *eap_packet_alloc(void);
94 EAP_DS          *eap_ds_alloc(void);
95 EAP_HANDLER     *eap_handler_alloc(void);
96 void            eap_packet_free(EAP_PACKET **eap_packet);
97 void            eap_ds_free(EAP_DS **eap_ds);
98 void            eap_handler_free(EAP_HANDLER *handler);
99
100 int             eaplist_add(rlm_eap_t *inst, EAP_HANDLER *handler);
101 EAP_HANDLER     *eaplist_find(rlm_eap_t *inst, REQUEST *request,
102                               eap_packet_t *eap_packet);
103 void            eaplist_free(rlm_eap_t *inst);
104
105 /* State */
106 void            generate_key(void);
107 VALUE_PAIR      *generate_state(time_t timestamp);
108 int             verify_state(VALUE_PAIR *state, time_t timestamp);
109
110 #endif /*_RLM_EAP_H*/