56#define LOG_PREFIX "eap"
57#include <freeradius-devel/server/modpriv.h>
58#include <freeradius-devel/server/pair.h>
59#include <freeradius-devel/radius/radius.h>
65RCSID(
"$Id: 908b87943621688589c6f80cd66c11121d1db4e0 $")
100 if(reply->
packet != NULL)
return 0;
106 if (reply->
type.
length > (
size_t) (UINT16_MAX - total_length)) {
120 header->
code = (reply->
code & 0xFF);
121 header->
id = (reply->
id & 0xFF);
123 total_length = htons(total_length);
124 memcpy(header->
length, &total_length,
sizeof(total_length));
166 eap_session = talloc_get_type_abort(eap_session,
eap_session_t);
188 switch (reply->
code) {
236 eap_packet->
length[0] * 256 + eap_packet->
length[1],
false);
254 switch (reply->
code) {
277 REDEBUG(
"Reply code %u is unknown, rejecting the request", reply->
code);
284 RDEBUG2(
"Sending EAP %s (code %d) ID %d length %i",
309 RDEBUG2(
"No EAP-Message, not doing EAP");
318 if (
vp &&
vp->vp_uint32 == 0) {
319 RDEBUG2(
"Found EAP-Message, but EAP-Type = None, so we're not doing EAP");
332 if ((eap_msg->vp_length == 0) || (eap_msg->vp_length == 2)) {
335 RDEBUG2(
"Got EAP_START message");
360 REDEBUG(
"Peer sent EAP %s (code %i) ID %d length %zu",
362 eap_msg->vp_octets[0],
363 eap_msg->vp_octets[1],
373 RDEBUG2(
"Ignoring EAP-Message which is too short to be meaningful");
383 RDEBUG2(
"Ignoring unexpected EAP code %d", eap_msg->vp_octets[0]);
387 if ((eap_msg->vp_octets[4] == 0) ||
389 RDEBUG2(
"Ignoring invalid EAP type %d", eap_msg->vp_octets[4]);
398 vp->vp_uint32 = eap_msg->vp_octets[4];
405 RDEBUG2(
"Peer sent EAP %s (code %i) ID %d length %zu Type %d",
407 eap_msg->vp_octets[0],
408 eap_msg->vp_octets[1],
410 eap_msg->vp_octets[4]);
424 RDEBUG2(
"Peer sent EAP-Identity. Returning 'ok' so we can short-circuit the rest of authorize");
440 RDEBUG2(
"Received NAK with no proposed EAP types");
448 type = eap_msg->vp_octets[5];
454 RDEBUG2(
"Ignoring NAK for invalid EAP type %d",
type);
459 RDEBUG2(
"Ignoring NAK for unknown EAP type %d",
type);
463 if (!methods[
type].submodule) {
464 RDEBUG2(
"Ignoring NAK for unsupported EAP type %d", eap_msg->vp_octets[4]);
478 RDEBUG2(
"Ignoring unknown EAP type %d", eap_msg->vp_octets[4]);
485 if (!methods[eap_msg->vp_octets[4]].
submodule) {
486 RDEBUG2(
"Ignoring unsupported EAP type %d", eap_msg->vp_octets[4]);
497 RDEBUG2(
"Continuing on-going EAP conversation");
548 if (!eap_round)
return NULL;
575 if (eap_round == NULL)
return NULL;
578 (void) talloc_steal(eap_round, eap_packet);
590 *eap_packet_p = NULL;
rlm_rcode_t eap_continue(eap_session_t *eap_session)
static int eap_wireformat(eap_packet_t *reply)
static const rlm_rcode_t rcode_ignore[2]
static char const * eap_codes[]
eap_round_t * eap_round_build(eap_session_t *eap_session, eap_packet_raw_t **eap_packet_p)
rlm_rcode_t eap_fail(eap_session_t *eap_session)
rlm_rcode_t eap_start(request_t *request, rlm_eap_method_t const methods[], bool ignore_unknown_types)
rlm_rcode_t eap_compose(eap_session_t *eap_session)
static eap_round_t * eap_round_alloc(eap_session_t *eap_session)
bool set_request_id
Whether the EAP-Method already set the next request ID.
eap_packet_t * response
Packet we received from the peer.
eap_packet_t * request
Packet we will send to the peer.
Structure to hold EAP data.
Contains a pair of request and response packets.
@ FR_RADIUS_CODE_ACCESS_CHALLENGE
RFC2865 - Access-Challenge.
@ FR_RADIUS_CODE_ACCESS_ACCEPT
RFC2865 - Access-Accept.
@ FR_RADIUS_CODE_ACCESS_REJECT
RFC2865 - Access-Reject.
@ FR_EAP_METHOD_NOTIFICATION
Structure to represent packet format of eap on wire
HIDDEN fr_dict_attr_t const * attr_state
HIDDEN fr_dict_attr_t const * attr_eap_message
HIDDEN fr_dict_attr_t const * attr_eap_type
eap_type_t type
EAP method number.
request_t * request
Current request.
eap_round_t * this_round
The EAP response we're processing, and the EAP request we're building.
bool finished
Whether we consider this session complete.
Tracks the progress of a single session of any EAP method.
#define RADIUS_AUTH_VECTOR_LENGTH
int fr_pair_value_memdup(fr_pair_t *vp, uint8_t const *src, size_t len, bool tainted)
Copy data into an "octets" data type.
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.
int fr_pair_delete_by_da(fr_pair_list_t *list, fr_dict_attr_t const *da)
Delete matching pairs from the specified list.
int fr_pair_value_memdup_shallow(fr_pair_t *vp, uint8_t const *src, size_t len, bool tainted)
Assign a buffer to a "octets" type value pair.
int fr_pair_value_mem_alloc(fr_pair_t *vp, uint8_t **out, size_t size, bool tainted)
Pre-allocate a memory buffer for a "octets" type value pair.
static fr_dict_attr_t const * attr_message_authenticator
rlm_rcode_t
Return codes indicating the result of the module call.
@ RLM_MODULE_INVALID
The module considers the request invalid.
@ RLM_MODULE_OK
The module is OK, continue.
@ RLM_MODULE_FAIL
Module failed, don't reply.
@ RLM_MODULE_REJECT
Immediately reject the request.
@ RLM_MODULE_NOTFOUND
User not found.
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
@ RLM_MODULE_HANDLED
The module handled the request, so stop.
#define pair_append_request(_attr, _da)
Allocate and append a fr_pair_t to the request list.
#define pair_append_reply(_attr, _da)
Allocate and append a fr_pair_t to reply list.
eap_success
SUCCESS state - State machine exit point after sending EAP-Success.
fr_aka_sim_id_type_t type
Stores an attribute, a value and various bits of other data.
rlm_eap_submodule_t const * submodule
Submodule's exported interface.
Private structure to hold handles and interfaces for an EAP method.
#define fr_strerror_const(_msg)