24 #include <freeradius-devel/server/pair.h>
25 #include <freeradius-devel/radius/radius.h>
26 #include <freeradius-devel/util/nbo.h>
40 #ifdef WITH_VERIFY_PTR
54 ROPTIONAL(
RWDEBUG,
WARN,
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
56 (uintptr_t)eap_session);
57 ROPTIONAL(
RWDEBUG,
WARN,
"!! See http://wiki.freeradius.org/guide/Certificate_Compatibility !!");
58 ROPTIONAL(
RWDEBUG,
WARN,
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
66 if (!request)
return 0;
82 fr_assert(!in_request || (eap_session == in_request));
110 ERROR(
"Failed allocating eap_session");
113 eap_session->
request = request;
114 eap_session->
updated = request->packet->timestamp;
132 eap_session,
true,
true,
true);
150 if (!*eap_session)
return;
175 if (!*eap_session)
return;
178 (*eap_session)->request = NULL;
210 if (!eap_session)
return NULL;
215 eap_session->
request = request;
216 eap_session->
updated = request->packet->timestamp;
238 len = talloc_array_length((
uint8_t *) eap_packet);
268 REDEBUG(
"EAP-Identity length field too short, expected >= 5, got %u", len);
313 eap_packet = *eap_packet_p;
330 *eap_packet_p = NULL;
333 eap_session->
inst = instance;
336 RDEBUG4(
"New EAP session - eap_session_t %p", eap_session);
338 RDEBUG2(
"New EAP session started");
344 switch (eap_packet->
data[0]) {
348 REDEBUG(
"Invalid identity response");
352 *eap_packet_p = NULL;
361 talloc_array_length(eap_session->
identity) - 1,
362 "EAP Identity Response - \"%pV\"",
364 talloc_array_length(eap_session->
identity) - 1));
370 REDEBUG(
"Initial EAP method %s(%u) invalid",
388 RDEBUG4(
"Continuing EAP session - eap_session_t %p", eap_session);
390 RDEBUG2(
"Continuing EAP session");
395 if (eap_session->
rounds >= 50) {
396 RERROR(
"Failing EAP session due to too many round trips");
409 (eap_packet->
data[0] != eap_session->
type)) {
410 RERROR(
"Response appears to match a previous request, but the EAP type is wrong");
411 RERROR(
"We expected EAP type %s, but received type %s",
414 RERROR(
"Your Supplicant or NAS is probably broken");
437 RDEBUG2(
"Broken NAS did not set User-Name, setting from EAP Identity");
461 REDEBUG(
"Identity from EAP Identity-Response \"%s\" does not match User-Name attribute \"%s\"",
462 eap_session->
identity, user->vp_strvalue);
469 REDEBUG(
"Failed allocating memory for round");
eap_round_t * eap_round_build(eap_session_t *eap_session, eap_packet_raw_t **eap_packet_p)
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
char const * eap_type2name(eap_type_t method)
Return an EAP-name for a particular type.
@ FR_EAP_METHOD_NOTIFICATION
Structure to represent packet format of eap on wire
static int _eap_session_free(eap_session_t *eap_session)
static char * eap_identity(request_t *request, eap_session_t *eap_session, eap_packet_raw_t *eap_packet)
Extract the EAP identity from EAP-Identity-Response packets.
eap_session_t * eap_session_continue(void const *instance, eap_packet_raw_t **eap_packet_p, request_t *request)
Ingest an eap_packet into a thawed or newly allocated session.
static eap_session_t * eap_session_alloc(request_t *request)
Allocate a new eap_session_t.
void eap_session_freeze(eap_session_t **eap_session)
Freeze an eap_session_t so that it can continue later.
void eap_session_destroy(eap_session_t **eap_session)
'destroy' an EAP session and disassociate it from the current request
eap_session_t * eap_session_thaw(request_t *request)
Thaw an eap_session_t so it can be continued.
char * identity
NAI (User-Name) from EAP-Identity.
bool tls
Whether EAP method uses TLS.
eap_type_t type
EAP method number.
request_t * request
Current request.
void const * inst
Instance of the eap module this session was created by.
eap_round_t * this_round
The EAP response we're processing, and the EAP request we're building.
eap_round_t * prev_round
Previous response/request pair.
#define REQUEST_DATA_EAP_SESSION
bool finished
Whether we consider this session complete.
int rounds
How many roundtrips have occurred this session.
fr_time_t updated
The last time we received a packet for this EAP session.
Tracks the progress of a single session of any EAP method.
#define ROPTIONAL(_l_request, _l_global, _fmt,...)
Use different logging functions depending on whether request is NULL or not.
#define DEBUG_ENABLED
True if global debug level 1 messages are enabled.
#define RHEXDUMP3(_data, _len, _fmt,...)
#define RDEBUG_ENABLED4
True if request debug level 1-4 messages are enabled.
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
static fr_dict_attr_t const * attr_user_name
#define RADIUS_MAX_STRING_LENGTH
void * request_data_get(request_t *request, void const *unique_ptr, int unique_int)
Get opaque data from a request.
void * request_data_reference(request_t *request, void const *unique_ptr, int unique_int)
Get opaque data from a request without removing it.
#define request_data_talloc_add(_request, _unique_ptr, _unique_int, _type, _opaque, _free_on_replace, _free_on_parent, _persist)
Add opaque data to a request_t.
#define pair_append_request(_attr, _da)
Allocate and append a fr_pair_t to the request list.
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
fr_pair_value_bstrdup_buffer(vp, eap_session->identity, true)
#define fr_time()
Allow us to arbitrarily manipulate time.
Stores an attribute, a value and various bits of other data.
char * talloc_bstrndup(TALLOC_CTX *ctx, char const *in, size_t inlen)
Binary safe strndup function.
int talloc_memcmp_bstr(char const *a, char const *b)
Compares two talloced char arrays with memcmp.
static fr_time_delta_t fr_time_delta_from_sec(int64_t sec)
#define fr_time_sub(_a, _b)
Subtract one time from another.
#define fr_time_delta_gt(_a, _b)
#define fr_box_strvalue_len(_val, _len)