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>
65 RCSID(
"$Id: 032eff53ce83ae0d66ac6dd33ec4e57e1224a133 $")
100 if(reply->
packet != NULL)
return 0;
103 if (reply->
code < 3) {
116 header->
code = (reply->
code & 0xFF);
117 header->
id = (reply->
id & 0xFF);
119 total_length = htons(total_length);
120 memcpy(header->
length, &total_length,
sizeof(total_length));
162 eap_session = talloc_get_type_abort(eap_session,
eap_session_t);
184 switch (reply->
code) {
232 eap_packet->
length[0] * 256 + eap_packet->
length[1],
false);
250 switch (reply->
code) {
273 REDEBUG(
"Reply code %d is unknown, rejecting the request", reply->
code);
280 RDEBUG2(
"Sending EAP %s (code %i) ID %d length %i",
298 RDEBUG2(
"No EAP-Message, not doing EAP");
307 if (
vp &&
vp->vp_uint32 == 0) {
308 RDEBUG2(
"Found EAP-Message, but EAP-Type = None, so we're not doing EAP");
327 if ((eap_msg->vp_length == 0) || (eap_msg->vp_length == 2)) {
330 RDEBUG2(
"Got EAP_START message");
353 REDEBUG(
"Peer sent EAP %s (code %i) ID %d length %zu",
355 eap_msg->vp_octets[0],
356 eap_msg->vp_octets[1],
364 RDEBUG2(
"Ignoring EAP-Message which is too short to be meaningful");
373 vp->vp_uint32 = eap_msg->vp_octets[4];
384 if ((eap_msg->vp_octets[0] == 0) ||
386 RDEBUG2(
"Peer sent EAP packet with unknown code %i", eap_msg->vp_octets[0]);
388 RDEBUG2(
"Peer sent EAP %s (code %i) ID %d length %zu",
390 eap_msg->vp_octets[0],
391 eap_msg->vp_octets[1],
403 RDEBUG2(
"Ignoring EAP packet which we don't know how to handle");
416 ignore_unknown_types &&
417 ((eap_msg->vp_octets[4] == 0) ||
419 (!methods[eap_msg->vp_octets[4]].
submodule))) {
420 RDEBUG2(
"Ignoring Unknown EAP type");
441 ignore_unknown_types &&
442 ((eap_msg->vp_octets[5] == 0) ||
444 (!methods[eap_msg->vp_octets[5]].
submodule))) {
445 RDEBUG2(
"Ignoring NAK with request for unknown EAP type");
451 RDEBUG2(
"Continuing tunnel setup");
467 RDEBUG2(
"Peer sent EAP-Identity. Returning 'ok' so we can short-circuit the rest of authorize");
478 RDEBUG2(
"Continuing on-going EAP conversation");
529 if (!eap_round)
return NULL;
556 if (eap_round == NULL)
return NULL;
559 (void) talloc_steal(eap_round, eap_packet);
571 *eap_packet_p = NULL;
eap_round_t * eap_round_build(eap_session_t *eap_session, eap_packet_raw_t **eap_packet_p)
rlm_rcode_t eap_continue(eap_session_t *eap_session)
static int eap_wireformat(eap_packet_t *reply)
static char const * eap_codes[]
rlm_rcode_t eap_fail(eap_session_t *eap_session)
static eap_round_t * eap_round_alloc(eap_session_t *eap_session)
rlm_rcode_t eap_success(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)
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.
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
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_value_memdup(fr_pair_t *vp, uint8_t const *src, size_t len, bool tainted)
Copy data into an "octets" data type.
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.
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
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.