61RCSID(
"$Id: 55db89cc494d1ee0b3de0f628947dcd2e23021f2 $")
63#define LOG_PREFIX "eap"
65#include <freeradius-devel/eap/base.h>
66#include <freeradius-devel/radius/defs.h>
67#include <freeradius-devel/server/state.h>
68#include <freeradius-devel/server/virtual_servers.h>
69#include <freeradius-devel/server/pair.h>
70#include <freeradius-devel/server/auth.h>
71#include <freeradius-devel/unlang/call.h>
72#include <freeradius-devel/unlang/interpret.h>
73#include <freeradius-devel/unlang/function.h>
85 { .out = &
dict_tls, .proto =
"tls" },
141 DEBUG(
"Asked to encode empty EAP-Message!");
149 if (size > 253) size = 253;
180 packet_len = talloc_array_length((
uint8_t *) eap_packet);
190 fr_strerror_printf(
"Invalid EAP length field. Expected value in range %d-%zu, was %u bytes",
198 switch (eap_packet->
code) {
208 if ((eap_packet->
data[0] == 0) ||
222 if ((eap_packet->
data[1] != 0) ||
223 (eap_packet->
data[2] != 0) ||
224 (eap_packet->
data[3] != 0)) {
225 fr_strerror_const(
"Expanded EAP type has unknown Vendor-ID: ignoring the packet");
229 if ((eap_packet->
data[4] != 0) ||
230 (eap_packet->
data[5] != 0) ||
231 (eap_packet->
data[6] != 0)) {
232 fr_strerror_const(
"Expanded EAP type has unknown Vendor-Type: ignoring the packet");
236 if ((eap_packet->
data[7] == 0) ||
254 p = talloc_realloc(ctx, eap_packet,
uint8_t, len - 7);
262 p[2] = (len >> 8) & 0xff;
312 if (
vp->vp_length < 4) {
321 memcpy(&len,
vp->vp_strvalue + 2,
sizeof(len));
339 total_len +=
vp->vp_length;
341 if (total_len > len) {
343 "does not match actual length %i", len, total_len);
351 if (total_len < len) {
353 "match actual length");
361 if (!eap_packet)
return NULL;
366 ptr = (
unsigned char *)eap_packet;
372 memcpy(ptr,
vp->vp_strvalue,
vp->vp_length);
373 ptr +=
vp->vp_length;
458 PERROR(
"%s", __FUNCTION__);
467 PERROR(
"%s", __FUNCTION__);
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
@ UNLANG_ACTION_PUSHED_CHILD
unlang_t pushed a new child onto the stack, execute it instead of continuing.
@ UNLANG_ACTION_FAIL
Encountered an unexpected error.
@ UNLANG_ACTION_CALCULATE_RESULT
Calculate a new section rlm_rcode_t value.
unlang_action_t unlang_call_push(request_t *request, CONF_SECTION *server_cs, bool top_frame)
Push a call frame onto the stack.
A section grouping multiple CONF_PAIR.
char const * cf_section_name(CONF_SECTION const *cs)
Return name2 if set, else name1.
static void * fr_dcursor_next(fr_dcursor_t *cursor)
Advanced the cursor to the next item.
static void * fr_dcursor_head(fr_dcursor_t *cursor)
Rewind cursor to the start of the list.
@ FR_RADIUS_CODE_ACCESS_REQUEST
RFC2865 - Access-Request.
#define fr_dict_autofree(_to_free)
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
int fr_dict_attr_autoload(fr_dict_attr_autoload_t const *to_load)
Process a dict_attr_autoload element to load/verify a dictionary attribute.
#define fr_dict_autoload(_to_load)
Specifies an attribute which must be present for the module to function.
Specifies a dictionary which must be loaded/loadable for the module to function.
char const * eap_type2name(eap_type_t method)
Return an EAP-name for a particular type.
#define FR_EAP_EXPANDED_TYPE
@ FR_EAP_METHOD_NOTIFICATION
Structure to represent packet format of eap on wire
#define unlang_function_push(_request, _func, _repeat, _signal, _sigmask, _top_frame, _uctx)
Push a generic function onto the unlang stack.
static fr_dict_t const * dict_freeradius
fr_dict_attr_autoload_t eap_base_dict_attr[]
fr_dict_attr_t const * attr_packet_type
void eap_packet_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *list, eap_packet_raw_t const *eap)
fr_dict_attr_t const * attr_eap_session_id
fr_dict_attr_t const * attr_state
fr_dict_attr_t const * attr_eap_identity
fr_dict_attr_t const * attr_freeradius_proxied_to
fr_dict_attr_t const * attr_chbind_response_code
fr_dict_attr_t const * attr_eap_message
fr_dict_attr_t const * attr_eap_type
fr_dict_attr_t const * attr_eap_msk
fr_dict_attr_t const * attr_eap_channel_binding_message
fr_dict_t const * dict_tls
fr_dict_attr_t const * attr_tls_min_version
fr_dict_t const * dict_radius
int eap_base_init(void)
Initialise the lib eap base library.
void eap_base_free(void)
De-init the lib eap base library.
eap_packet_raw_t * eap_packet_from_vp(TALLOC_CTX *ctx, fr_pair_list_t *vps)
fr_dict_attr_t const * attr_eap_emsk
fr_dict_attr_t const * attr_ms_mppe_send_key
fr_dict_attr_t const * attr_tls_max_version
static unlang_action_t eap_virtual_server_resume(UNUSED rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx)
Handle the result of running a subrequest through a virtual server.
fr_dict_attr_t const * attr_user_name
static bool eap_is_valid(TALLOC_CTX *ctx, eap_packet_raw_t **eap_packet_p)
Basic EAP packet verifications & validations.
fr_dict_attr_t const * attr_framed_mtu
fr_dict_attr_t const * attr_ms_mppe_recv_key
unlang_action_t eap_virtual_server(request_t *request, eap_session_t *eap_session, CONF_SECTION *server_cs)
Run a subrequest through a virtual server.
fr_dict_autoload_t eap_base_dict[]
void eap_add_reply(request_t *request, fr_dict_attr_t const *da, uint8_t const *value, int len)
fr_dict_attr_t const * attr_message_authenticator
char * identity
NAI (User-Name) from EAP-Identity.
#define REQUEST_DATA_EAP_SESSION
Tracks the progress of a single session of any EAP method.
#define REXDENT()
Exdent (unindent) R* messages by one level.
#define RINDENT()
Indent R* messages by one level.
@ FR_TYPE_FLOAT32
Single precision floating point.
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_OCTETS
Raw octets.
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_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
fr_pair_t * fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Dynamically allocate a new attribute and assign a fr_dict_attr_t.
int fr_pair_prepend_by_da(TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t *list, fr_dict_attr_t const *da)
Alloc a new fr_pair_t (and prepend)
rlm_rcode_t
Return codes indicating the result of the module call.
#define pair_update_reply(_attr, _da)
Return or allocate a fr_pair_t in the reply list.
void fr_state_restore_to_child(request_t *child, void const *unique_ptr, int unique_int)
Restore subrequest data from a parent request.
void fr_state_store_in_parent(request_t *child, void const *unique_ptr, int unique_int)
Store subrequest's session-state list and persistable request data in its parent.
Stores an attribute, a value and various bits of other data.
#define fr_pair_dcursor_by_da_init(_cursor, _list, _da)
Initialise a cursor that will return only attributes matching the specified fr_dict_attr_t.
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
#define fr_strerror_const(_msg)
Types of values contained within an fr_value_box_t.