The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions | Variables
rlm_eap.c File Reference

Implements the EAP framework. More...

#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/server/dl_module.h>
#include <freeradius-devel/protocol/freeradius/freeradius.internal.h>
#include <freeradius-devel/unlang/interpret.h>
#include <freeradius-devel/unlang/module.h>
#include "rlm_eap.h"
+ Include dependency graph for rlm_eap.c:

Go to the source code of this file.

Data Structures

struct  eap_auth_rctx_t
 Resume context for calling a submodule. More...
 

Macros

#define LOG_PREFIX   mctx->mi->name
 

Functions

static ssize_t eap_identity_is_nai_with_realm (char const *identity)
 Basic tests to determine if an identity is a valid NAI. More...
 
static unlang_action_t eap_method_select (rlm_rcode_t *p_result, module_ctx_t const *mctx, eap_session_t *eap_session)
 Select the correct callback based on a response. More...
 
static eap_type_t eap_process_nak (module_ctx_t const *mctx, request_t *request, eap_type_t last_type, eap_type_data_t *nak)
 Process NAK data from EAP peer. More...
 
static int eap_type_parse (UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
 Convert EAP type strings to eap_type_t values. More...
 
static unlang_action_t mod_authenticate (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static void mod_authenticate_cancel (module_ctx_t const *mctx, request_t *request, UNUSED fr_signal_t action)
 Cancel a call to a submodule. More...
 
static unlang_action_t mod_authenticate_result (rlm_rcode_t *p_result, UNUSED module_ctx_t const *mctx, request_t *request, eap_session_t *eap_session, rlm_rcode_t result)
 Process the result of calling a submodule. More...
 
static unlang_action_t mod_authenticate_result_async (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 Call mod_authenticate_result asynchronously from the unlang interpreter. More...
 
static unlang_action_t mod_authorize (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static int mod_instantiate (module_inst_ctx_t const *mctx)
 
static int mod_load (void)
 
static unlang_action_t mod_post_auth (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static void mod_unload (void)
 
static int submodule_parse (TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
 
static int submodule_parse (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 Loads submodules based on type = foo pairs. More...
 

Variables

static fr_dict_attr_t const * attr_auth_type
 
static fr_dict_attr_t const * attr_eap_identity
 
static fr_dict_attr_t const * attr_eap_message
 
static fr_dict_attr_t const * attr_eap_type
 
static fr_dict_attr_t const * attr_message_authenticator
 
static fr_dict_attr_t const * attr_state
 
static fr_dict_attr_t const * attr_stripped_user_domain
 
static fr_dict_attr_t const * attr_user_name
 
static fr_dict_t const * dict_freeradius
 
static fr_dict_t const * dict_radius
 
static const conf_parser_t module_config []
 
static fr_table_num_sorted_t const require_identity_realm_table []
 
static size_t require_identity_realm_table_len = NUM_ELEMENTS(require_identity_realm_table)
 
module_rlm_t rlm_eap
 
fr_dict_autoload_t rlm_eap_dict []
 
fr_dict_attr_autoload_t rlm_eap_dict_attr []
 

Detailed Description

Implements the EAP framework.

Id
bad43ddfa90e68ffb181637404a768fd50ac2412

Definition in file rlm_eap.c.


Data Structure Documentation

◆ eap_auth_rctx_t

struct eap_auth_rctx_t

Resume context for calling a submodule.

Definition at line 44 of file rlm_eap.c.

+ Collaboration diagram for eap_auth_rctx_t:
Data Fields
char const * caller Original caller.
eap_session_t * eap_session The eap_session we're continuing.
rlm_eap_t * inst Instance of the rlm_eap module.
rlm_rcode_t rcode The result of the submodule.

Macro Definition Documentation

◆ LOG_PREFIX

#define LOG_PREFIX   mctx->mi->name

Definition at line 28 of file rlm_eap.c.

Function Documentation

◆ eap_identity_is_nai_with_realm()

static ssize_t eap_identity_is_nai_with_realm ( char const *  identity)
static

Basic tests to determine if an identity is a valid NAI.

In this version we mostly just care about realm.

Parameters
[in]identityto check.
Returns
  • The length of the string on success.
  • <= 0 a negative offset specifying where the format error occurred.

Definition at line 521 of file rlm_eap.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eap_method_select()

static unlang_action_t eap_method_select ( rlm_rcode_t p_result,
module_ctx_t const *  mctx,
eap_session_t eap_session 
)
static

Select the correct callback based on a response.

Based on the EAP response from the supplicant, and setup a call on the unlang stack to the appropriate submodule.

Default to the configured EAP-Type for all Unsupported EAP-Types.

Parameters
[out]p_resultthe result of the operation.
[in]mctxmodule calling ctx.
[in]eap_sessionState data that persists over multiple rounds of EAP.
Returns
  • UNLANG_ACTION_CALCULATE_RESULT + *p_result = RLM_MODULE_INVALID. Invalid request.
  • UNLANG_ACTION_PUSHED_CHILD Yield control back to the interpreter so it can call the submodule.

Definition at line 573 of file rlm_eap.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eap_process_nak()

static eap_type_t eap_process_nak ( module_ctx_t const *  mctx,
request_t request,
eap_type_t  last_type,
eap_type_data_t nak 
)
static

Process NAK data from EAP peer.

Definition at line 230 of file rlm_eap.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eap_type_parse()

static int eap_type_parse ( UNUSED TALLOC_CTX *  ctx,
void *  out,
UNUSED void *  parent,
CONF_ITEM ci,
UNUSED conf_parser_t const *  rule 
)
static

Convert EAP type strings to eap_type_t values.

Parameters
[in]ctxunused.
[out]outWhere to write the eap_type_t value we found.
[in]parentBase structure address.
[in]ciCONF_PAIR specifying the name of the EAP method.
[in]ruleunused.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 207 of file rlm_eap.c.

+ Here is the call graph for this function:

◆ mod_authenticate()

static unlang_action_t mod_authenticate ( rlm_rcode_t p_result,
module_ctx_t const *  mctx,
request_t request 
)
static

Definition at line 856 of file rlm_eap.c.

+ Here is the call graph for this function:

◆ mod_authenticate_cancel()

static void mod_authenticate_cancel ( module_ctx_t const *  mctx,
request_t request,
UNUSED fr_signal_t  action 
)
static

Cancel a call to a submodule.

Parameters
[in]mctxmodule calling ctx.
[in]requestThe current request.
[in]actionto perform.

Definition at line 389 of file rlm_eap.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_authenticate_result()

static unlang_action_t mod_authenticate_result ( rlm_rcode_t p_result,
UNUSED module_ctx_t const *  mctx,
request_t request,
eap_session_t eap_session,
rlm_rcode_t  result 
)
static

Process the result of calling a submodule.

Parameters
[out]p_resultResult of calling the module, one of:
  • RLM_MODULE_INVALID if the request or EAP session state is invalid.
  • RLM_MODULE_OK if this round succeeded.
  • RLM_MODULE_HANDLED if we're done with this round.
  • RLM_MODULE_REJECT if the user should be rejected.
[in]requestThe current request.
[in]mctxmodule calling ctx.
[in]eap_sessionthe EAP session
[in]resultthe input result from the submodule

Definition at line 419 of file rlm_eap.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_authenticate_result_async()

static unlang_action_t mod_authenticate_result_async ( rlm_rcode_t p_result,
module_ctx_t const *  mctx,
request_t request 
)
static

Call mod_authenticate_result asynchronously from the unlang interpreter.

Parameters
[out]p_resultThe result of the operation.
[in]mctxmodule calling ctx.
[in]requestthe current request.
Returns
The result of this round of authentication.

Definition at line 504 of file rlm_eap.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_authorize()

static unlang_action_t mod_authorize ( rlm_rcode_t p_result,
module_ctx_t const *  mctx,
request_t request 
)
static

Definition at line 921 of file rlm_eap.c.

+ Here is the call graph for this function:

◆ mod_instantiate()

static int mod_instantiate ( module_inst_ctx_t const *  mctx)
static

Definition at line 1044 of file rlm_eap.c.

+ Here is the call graph for this function:

◆ mod_load()

static int mod_load ( void  )
static

Definition at line 1162 of file rlm_eap.c.

+ Here is the call graph for this function:

◆ mod_post_auth()

static unlang_action_t mod_post_auth ( rlm_rcode_t p_result,
module_ctx_t const *  mctx,
request_t request 
)
static

Definition at line 960 of file rlm_eap.c.

+ Here is the call graph for this function:

◆ mod_unload()

static void mod_unload ( void  )
static

Definition at line 1171 of file rlm_eap.c.

+ Here is the call graph for this function:

◆ submodule_parse() [1/2]

static int submodule_parse ( TALLOC_CTX *  ctx,
void *  out,
UNUSED void *  parent,
CONF_ITEM ci,
UNUSED conf_parser_t const *  rule 
)
static

◆ submodule_parse() [2/2]

static int submodule_parse ( TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM ci,
conf_parser_t const *  rule 
)
static

Loads submodules based on type = foo pairs.

Parameters
[in]ctxto allocate data in (instance of rlm_eap_t).
[out]outWhere to write child conf section to.
[in]parentBase structure address.
[in]ciCONF_PAIR specifying the name of the type module.
[in]ruleunused.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 132 of file rlm_eap.c.

+ Here is the call graph for this function:

Variable Documentation

◆ attr_auth_type

fr_dict_attr_t const* attr_auth_type
static

Definition at line 92 of file rlm_eap.c.

◆ attr_eap_identity

fr_dict_attr_t const* attr_eap_identity
static

Definition at line 94 of file rlm_eap.c.

◆ attr_eap_message

fr_dict_attr_t const* attr_eap_message
static

Definition at line 97 of file rlm_eap.c.

◆ attr_eap_type

fr_dict_attr_t const* attr_eap_type
static

Definition at line 93 of file rlm_eap.c.

◆ attr_message_authenticator

fr_dict_attr_t const* attr_message_authenticator
static

Definition at line 98 of file rlm_eap.c.

◆ attr_state

fr_dict_attr_t const* attr_state
static

Definition at line 99 of file rlm_eap.c.

◆ attr_stripped_user_domain

fr_dict_attr_t const* attr_stripped_user_domain
static

Definition at line 95 of file rlm_eap.c.

◆ attr_user_name

fr_dict_attr_t const* attr_user_name
static

Definition at line 100 of file rlm_eap.c.

◆ dict_freeradius

fr_dict_t const* dict_freeradius
static

Definition at line 82 of file rlm_eap.c.

◆ dict_radius

fr_dict_t const* dict_radius
static

Definition at line 83 of file rlm_eap.c.

◆ module_config

const conf_parser_t module_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("require_identity_realm", rlm_eap_t, require_realm),
.dflt = "nai" },
{ FR_CONF_OFFSET_IS_SET("default_eap_type", FR_TYPE_VOID, 0, rlm_eap_t, default_method), .func = eap_type_parse },
{ FR_CONF_OFFSET("ignore_unknown_eap_types", rlm_eap_t, ignore_unknown_types), .dflt = "no" },
{ FR_CONF_DEPRECATED("timer_expire", rlm_eap_t, timer_limit), .dflt = "60" },
{ FR_CONF_DEPRECATED("cisco_accounting_username_bug", rlm_eap_t,
cisco_accounting_username_bug), .dflt = "no" },
{ FR_CONF_DEPRECATED("max_sessions", rlm_eap_t, max_sessions), .dflt = "2048" },
}
int cf_table_parse_int(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Generic function for parsing conf pair values as int.
Definition: cf_parse.c:1474
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:627
#define FR_CONF_DEPRECATED(_name, _struct, _field)
conf_parser_t entry which raises an error if a matching CONF_PAIR is found
Definition: cf_parse.h:385
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:268
#define FR_CONF_OFFSET_IS_SET(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct,...
Definition: cf_parse.h:282
@ CONF_FLAG_MULTI
CONF_PAIR can have multiple copies.
Definition: cf_parse.h:419
@ CONF_FLAG_NOT_EMPTY
CONF_PAIR is required to have a non zero length value.
Definition: cf_parse.h:420
#define FR_CONF_OFFSET_TYPE_FLAGS(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:241
@ FR_TYPE_VOID
User data.
Definition: merged_model.c:127
static fr_table_num_sorted_t const require_identity_realm_table[]
Definition: rlm_eap.c:56
static int submodule_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
static int eap_type_parse(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
Convert EAP type strings to eap_type_t values.
Definition: rlm_eap.c:207
static size_t require_identity_realm_table_len
Definition: rlm_eap.c:61
Instance data for rlm_eap.
Definition: rlm_eap.h:47

Definition at line 63 of file rlm_eap.c.

◆ require_identity_realm_table

fr_table_num_sorted_t const require_identity_realm_table[]
static
Initial value:
= {
{ L("nai"), REQUIRE_REALM_NAI },
{ L("no"), REQUIRE_REALM_NO },
{ L("yes"), REQUIRE_REALM_YES }
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition: build.h:207
@ REQUIRE_REALM_NAI
Require the EAP-Identity contains an NAI domain.
Definition: rlm_eap.h:41
@ REQUIRE_REALM_NO
Don't require that the identity is qualified.
Definition: rlm_eap.h:40
@ REQUIRE_REALM_YES
Require the EAP-Identity string contain an NAI realm or that Stripped-User-Domain is present in the r...
Definition: rlm_eap.h:38

Definition at line 56 of file rlm_eap.c.

◆ require_identity_realm_table_len

size_t require_identity_realm_table_len = NUM_ELEMENTS(require_identity_realm_table)
static

Definition at line 61 of file rlm_eap.c.

◆ rlm_eap

module_rlm_t rlm_eap
Initial value:
= {
.common = {
.name = "eap",
.inst_size = sizeof(rlm_eap_t),
.onload = mod_load,
.unload = mod_unload,
},
.method_group = {
.bindings = (module_method_binding_t[]){
{ .section = SECTION_NAME("authenticate", CF_IDENT_ANY), .method = mod_authenticate },
{ .section = SECTION_NAME("recv", "Access-Request"), .method = mod_authorize },
{ .section = SECTION_NAME("send", CF_IDENT_ANY), .method = mod_post_auth },
}
}
}
#define CF_IDENT_ANY
Definition: cf_util.h:78
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:63
static const conf_parser_t config[]
Definition: base.c:183
static int mod_load(void)
Definition: rlm_eap.c:1162
static unlang_action_t mod_authenticate(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition: rlm_eap.c:856
static void mod_unload(void)
Definition: rlm_eap.c:1171
static unlang_action_t mod_authorize(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition: rlm_eap.c:921
static const conf_parser_t module_config[]
Definition: rlm_eap.c:63
static int mod_instantiate(module_inst_ctx_t const *mctx)
Definition: rlm_eap.c:1044
static unlang_action_t mod_post_auth(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition: rlm_eap.c:960
static int instantiate(module_inst_ctx_t const *mctx)
Definition: rlm_rest.c:1302
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
Definition: section.h:40
#define MODULE_BINDING_TERMINATOR
Terminate a module binding list.
Definition: module.h:151
Named methods exported by a module.
Definition: module.h:173

Definition at line 1180 of file rlm_eap.c.

◆ rlm_eap_dict

fr_dict_autoload_t rlm_eap_dict
Initial value:
= {
{ .out = &dict_freeradius, .proto = "freeradius" },
{ .out = &dict_radius, .proto = "radius" },
{ NULL }
}
static fr_dict_t const * dict_freeradius
Definition: rlm_eap.c:82
static fr_dict_t const * dict_radius
Definition: rlm_eap.c:83

Definition at line 86 of file rlm_eap.c.

◆ rlm_eap_dict_attr

fr_dict_attr_autoload_t rlm_eap_dict_attr
Initial value:
= {
{ .out = &attr_auth_type, .name = "Auth-Type", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
{ .out = &attr_eap_type, .name = "EAP-Type", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
{ .out = &attr_eap_identity, .name = "EAP-Identity", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
{ .out = &attr_stripped_user_domain, .name = "Stripped-User-Domain", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
{ .out = &attr_eap_message, .name = "EAP-Message", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ .out = &attr_message_authenticator, .name = "Message-Authenticator", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ .out = &attr_state, .name = "State", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ .out = &attr_user_name, .name = "User-Name", .type = FR_TYPE_STRING, .dict = &dict_radius },
{ NULL }
}
@ FR_TYPE_STRING
String of printable characters.
Definition: merged_model.c:83
@ FR_TYPE_UINT32
32 Bit unsigned integer.
Definition: merged_model.c:99
@ FR_TYPE_OCTETS
Raw octets.
Definition: merged_model.c:84
static fr_dict_attr_t const * attr_state
Definition: rlm_eap.c:99
static fr_dict_attr_t const * attr_eap_identity
Definition: rlm_eap.c:94
static fr_dict_attr_t const * attr_eap_message
Definition: rlm_eap.c:97
static fr_dict_attr_t const * attr_eap_type
Definition: rlm_eap.c:93
static fr_dict_attr_t const * attr_auth_type
Definition: rlm_eap.c:92
static fr_dict_attr_t const * attr_stripped_user_domain
Definition: rlm_eap.c:95
static fr_dict_attr_t const * attr_user_name
Definition: rlm_eap.c:100
static fr_dict_attr_t const * attr_message_authenticator
Definition: rlm_eap.c:98

Definition at line 104 of file rlm_eap.c.