The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
session.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or (at
6  * your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16  */
17 
18 /**
19  * $Id: 75d2b6af6edb827768aec915cf4d381824597ec9 $
20  * @file lib/eap/session.h
21  * @brief EAP session management.
22  *
23  * @copyright 2019 The FreeRADIUS server project
24  */
25 #include <freeradius-devel/server/request.h>
26 #include <freeradius-devel/server/request_data.h>
27 #include <freeradius-devel/server/module.h>
28 
29 #include "compose.h"
30 #include "types.h"
31 
32 #define REQUEST_DATA_EAP_SESSION (1)
33 #define REQUEST_DATA_EAP_SESSION_PROXIED (2)
34 
35 typedef struct eap_session_s eap_session_t;
36 
37 /** Tracks the progress of a single session of any EAP method
38  *
39  */
40 struct eap_session_s {
41  eap_session_t *prev, *next; //!< Next/previous eap session in this doubly linked list.
42 
43  eap_session_t *child; //!< Session for tunneled EAP method.
44 
45  request_t *subrequest; //!< Current subrequest being executed.
46  rlm_rcode_t submodule_rcode; //!< Result of last submodule call.
47 
48  void const *inst; //!< Instance of the eap module this session was created by.
49  eap_type_t type; //!< EAP method number.
50 
51  request_t *request; //!< Current request. Only used by OpenSSL callbacks to
52  ///< access the current request. Must be NULL if eap_session
53  ///< is not being processed by rlm_eap.
54 
55  char *identity; //!< NAI (User-Name) from EAP-Identity
56 
57  eap_round_t *prev_round; //!< Previous response/request pair. #this_round should contain
58  ///< the response to the request in #prev_round.
59  eap_round_t *this_round; //!< The EAP response we're processing, and the EAP request
60  ///< we're building.
61 
62  void *opaque; //!< Opaque data used by EAP methods.
63 
64  module_method_t process; //!< Callback that should be used to process the next round.
65  ///< Usually set to the process function of an EAP submodule.
66  int rounds; //!< How many roundtrips have occurred this session.
67 
68  fr_time_t updated; //!< The last time we received a packet for this EAP session.
69 
70  bool tls; //!< Whether EAP method uses TLS.
71  bool finished; //!< Whether we consider this session complete.
72 };
73 
74 void eap_session_destroy(eap_session_t **eap_session);
75 
76 void eap_session_freeze(eap_session_t **eap_session);
77 
79 
80 eap_session_t *eap_session_continue(void const *instance, eap_packet_raw_t **eap_packet, request_t *request) CC_HINT(nonnull);
81 
82 static inline eap_session_t *eap_session_get(request_t *request)
83 {
84  return request_data_reference(request, NULL, REQUEST_DATA_EAP_SESSION);
85 }
EAP packet composition.
Contains a pair of request and response packets.
Definition: compose.h:48
enum eap_type eap_type_t
Structure to represent packet format of eap on wire
Definition: types.h:121
eap_session_t * next
Next/previous eap session in this doubly linked list.
Definition: session.h:41
char * identity
NAI (User-Name) from EAP-Identity.
Definition: session.h:55
eap_session_t * eap_session_continue(void const *instance, eap_packet_raw_t **eap_packet, request_t *request)
Ingest an eap_packet into a thawed or newly allocated session.
Definition: session.c:307
void * opaque
Opaque data used by EAP methods.
Definition: session.h:62
request_t * subrequest
Current subrequest being executed.
Definition: session.h:45
bool tls
Whether EAP method uses TLS.
Definition: session.h:70
eap_session_t * prev
Definition: session.h:41
eap_type_t type
EAP method number.
Definition: session.h:49
module_method_t process
Callback that should be used to process the next round.
Definition: session.h:64
request_t * request
Current request.
Definition: session.h:51
void const * inst
Instance of the eap module this session was created by.
Definition: session.h:48
rlm_rcode_t submodule_rcode
Result of last submodule call.
Definition: session.h:46
eap_round_t * this_round
The EAP response we're processing, and the EAP request we're building.
Definition: session.h:59
eap_round_t * prev_round
Previous response/request pair.
Definition: session.h:57
static eap_session_t * eap_session_get(request_t *request)
Definition: session.h:82
void eap_session_freeze(eap_session_t **eap_session)
Freeze an eap_session_t so that it can continue later.
Definition: session.c:173
void eap_session_destroy(eap_session_t **eap_session)
'destroy' an EAP session and disassociate it from the current request
Definition: session.c:148
#define REQUEST_DATA_EAP_SESSION
Definition: session.h:32
eap_session_t * child
Session for tunneled EAP method.
Definition: session.h:43
bool finished
Whether we consider this session complete.
Definition: session.h:71
int rounds
How many roundtrips have occurred this session.
Definition: session.h:66
eap_session_t * eap_session_thaw(request_t *request)
Thaw an eap_session_t so it can be continued.
Definition: session.c:205
fr_time_t updated
The last time we received a packet for this EAP session.
Definition: session.h:68
Tracks the progress of a single session of any EAP method.
Definition: session.h:40
rlm_rcode_t
Return codes indicating the result of the module call.
Definition: rcode.h:40
void * request_data_reference(request_t *request, void const *unique_ptr, int unique_int)
Get opaque data from a request without removing it.
Definition: request_data.c:339
unlang_action_t(* module_method_t)(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Module section callback.
Definition: module.h:69
"server local" time.
Definition: time.h:69
Types of values contained within an fr_value_box_t.
int nonnull(2, 5))