All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
eap.h
Go to the documentation of this file.
1 /*
2  * eap.h Header file containing the interfaces for all EAP types.
3  *
4  * Version: $Id: 6350e13e189a6c0ab8d2bb866ee046ef84673035 $
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  *
20  * Copyright 2001 hereUare Communications, Inc. <raghud@hereuare.com>
21  * Copyright 2003 Alan DeKok <aland@freeradius.org>
22  * Copyright 2006 The FreeRADIUS server project
23  */
24 #ifndef _EAP_H
25 #define _EAP_H
26 
27 RCSIDH(eap_h, "$Id: 6350e13e189a6c0ab8d2bb866ee046ef84673035 $")
28 
29 #include <freeradius-devel/radiusd.h>
30 #include <freeradius-devel/modules.h>
31 #include <freeradius-devel/rad_assert.h>
32 
33 #include "eap_types.h"
34 
35 /* TLS configuration name */
36 #define TLS_CONFIG_SECTION "tls-config"
37 #define LOG_PREFIX "eap"
38 
39 /** Contains a pair of request and response packets
40  *
41  * Helps with formulating/correlating requests to responses we've received.
42  */
43 typedef struct eap_round {
44  eap_packet_t *response; //!< Packet we received from the peer.
45  eap_packet_t *request; //!< Packet we will send to the peer.
47 } eap_round_t;
48 
49 typedef struct _eap_session eap_session_t;
50 
51 /*
52  * Function to process EAP packets.
53  */
54 typedef int (*eap_process_t)(void *instance, eap_session_t *eap_session);
55 
56 #define EAP_STATE_LEN (AUTH_VECTOR_LEN)
57 /** Tracks the progress of a single session of any EAP method
58  *
59  */
60 struct _eap_session {
61  eap_session_t *prev, *next; //!< Next/previous eap session in this doubly linked list.
62 
63  eap_session_t *child; //!< Session for tunnelled EAP method.
64 
65  void *inst; //!< Instance of the eap module this session was created by.
66  fr_ipaddr_t src_ipaddr; //!< of client which sent us the RADIUS request for this
67  //!< session.
68 
69  eap_type_t type; //!< EAP method number.
70 
71  REQUEST *request; //!< Request that contains the response we're processing.
72 
73  char *identity; //!< NAI (User-Name) from EAP-Identity
74 
75  eap_round_t *prev_round; //!< Previous response/request pair. #this_round should contain
76  //!< the response to the request in #prev_round.
77  eap_round_t *this_round; //!< The EAP response we're processing, and the EAP request
78  //!< we're building.
79 
80  void *opaque; //!< Opaque data used by EAP methods.
81 
82  eap_process_t process; //!< Callback that should be used to process the next round.
83  //!< Usually set to the process functino of an EAP submodule.
84  int rounds; //!< How many roundtrips have occurred this session.
85 
86  time_t updated; //!< The last time we received a packet for this EAP session.
87 
88  bool tls; //!< Whether EAP method uses TLS.
89  bool finished; //!< Whether we consider this session complete.
90 };
91 
92 /** Interface to call EAP sub mdoules
93  *
94  */
95 typedef struct rlm_eap_module {
96  char const *name; //!< The name of the sub-module
97  //!< (without rlm_ prefix).
98  int (*instantiate)(CONF_SECTION *conf, void **instance); //!< Create a new submodule instance.
99  eap_process_t session_init; //!< Callback for creating a new #eap_session_t.
100  eap_process_t process; //!< Callback for processing the next #eap_round_t of an
101  //!< #eap_session_t.
102 
103  int (*detach)(void *instance); //!< Destroy an EAP submodule instance.
105 
106 #define REQUEST_DATA_EAP_SESSION (1)
107 #define REQUEST_DATA_EAP_SESSION_PROXIED (2)
108 
109 #define REQUEST_DATA_EAP_TUNNEL_CALLBACK PW_EAP_MESSAGE
110 #define REQUEST_DATA_EAP_MSCHAP_TUNNEL_CALLBACK ((PW_EAP_MESSAGE << 16) | PW_EAP_MSCHAPV2)
111 #define RAD_REQUEST_OPTION_PROXY_EAP (1 << 16)
112 
113 /*
114  * This is for tunneled callbacks
115  */
116 typedef int (*eap_tunnel_callback_t)(eap_session_t *eap_session, void *tls_session);
117 
118 typedef struct eap_tunnel_data_t {
119  void *tls_session;
122 
124  eap_session_t *eap_session, char const *virtual_server);
125 
126 #endif /*_EAP_H*/
rlm_rcode_t eap_virtual_server(REQUEST *request, REQUEST *fake, eap_session_t *eap_session, char const *virtual_server)
Send a fake request to a virtual server, managing the eap_session_t of the child. ...
Definition: eapcommon.c:418
#define RCSIDH(h, id)
Definition: build.h:136
eap_process_t session_init
Callback for creating a new eap_session_t.
Definition: eap.h:99
void * inst
Instance of the eap module this session was created by.
Definition: eap.h:65
int rounds
How many roundtrips have occurred this session.
Definition: eap.h:84
struct eap_round eap_round_t
Contains a pair of request and response packets.
struct rlm_eap_module rlm_eap_module_t
Interface to call EAP sub mdoules.
eap_process_t process
Callback that should be used to process the next round.
Definition: eap.h:82
bool tls
Whether EAP method uses TLS.
Definition: eap.h:88
bool finished
Whether we consider this session complete.
Definition: eap.h:89
struct eap_tunnel_data_t eap_tunnel_data_t
eap_packet_t * request
Packet we will send to the peer.
Definition: eap.h:45
void * opaque
Opaque data used by EAP methods.
Definition: eap.h:80
eap_session_t * child
Session for tunnelled EAP method.
Definition: eap.h:63
eap_round_t * prev_round
Previous response/request pair.
Definition: eap.h:75
REQUEST * request
Request that contains the response we're processing.
Definition: eap.h:71
fr_ipaddr_t src_ipaddr
of client which sent us the RADIUS request for this session.
Definition: eap.h:66
enum eap_method eap_type_t
eap_session_t * next
Next/previous eap session in this doubly linked list.
Definition: eap.h:61
int(* eap_process_t)(void *instance, eap_session_t *eap_session)
Definition: eap.h:54
eap_type_t type
EAP method number.
Definition: eap.h:69
Tracks the progress of a single session of any EAP method.
Definition: eap.h:60
int(* detach)(void *instance)
Destroy an EAP submodule instance.
Definition: eap.h:103
eap_round_t * this_round
The EAP response we're processing, and the EAP request we're building.
Definition: eap.h:77
void * tls_session
Definition: eap.h:119
eap_tunnel_callback_t callback
Definition: eap.h:120
int(* eap_tunnel_callback_t)(eap_session_t *eap_session, void *tls_session)
Definition: eap.h:116
enum rlm_rcodes rlm_rcode_t
Return codes indicating the result of the module call.
Contains a pair of request and response packets.
Definition: eap.h:43
static rs_t * conf
Definition: radsniff.c:46
char const * name
The name of the sub-module (without rlm_ prefix).
Definition: eap.h:96
char * identity
NAI (User-Name) from EAP-Identity.
Definition: eap.h:73
Interface to call EAP sub mdoules.
Definition: eap.h:95
static const void * fake
Definition: rlm_sql_null.c:33
eap_process_t process
Callback for processing the next eap_round_t of an eap_session_t.
Definition: eap.h:100
int(* instantiate)(CONF_SECTION *conf, void **instance)
Create a new submodule instance.
Definition: eap.h:98
Structure to hold EAP data.
Definition: eap_types.h:132
IPv4/6 prefix.
Definition: inet.h:41
eap_packet_t * response
Packet we received from the peer.
Definition: eap.h:44
bool set_request_id
Definition: eap.h:46
eap_session_t * prev
Definition: eap.h:61
time_t updated
The last time we received a packet for this EAP session.
Definition: eap.h:86