25 RCSID(
"$Id: c04c443728feb3ce42241322e8fb2ea6125eee19 $")
27 #include <freeradius-devel/io/application.h>
28 #include <freeradius-devel/server/modpriv.h>
29 #include <freeradius-devel/util/debug.h>
30 #include <freeradius-devel/util/dlist.h>
191 cf_log_err(ci,
"Unknown or invalid RADIUS packet type '%s'", type_str);
195 code = type_enum->
value->vb_uint32;
201 cf_log_err(ci,
"Invalid setting of 'type = Status-Server'. Status-Server packets cannot be proxied.");
215 memcpy(
out, &code,
sizeof(code));
246 cf_log_err(ci,
"Unknown or invalid RADIUS packet type '%s'", type_str);
250 code = type_enum->
value->vb_uint32;
266 memcpy(
out, &code,
sizeof(code));
295 map_list_t *
head = (map_list_t *)
out;
302 if (!name2 || (strcmp(name2,
"request") != 0)) {
303 cf_log_err(cs,
"You must specify 'request' as the destination list");
318 if (rcode < 0)
return -1;
319 if (map_list_empty(
head)) {
320 cf_log_err(cs,
"'update' sections cannot be empty");
343 if ((action == FR_SIGNAL_DUP) && !
inst->synchronous)
return;
349 mctx->
rctx), request, action);
368 if (
vp->vp_length != 4)
continue;
370 if (memcmp(&
inst->proxy_state,
vp->vp_octets, 4) == 0) {
371 RWARN(
"Possible proxy loop - please check server configuration.");
399 if (!request->packet->code) {
400 REDEBUG(
"You MUST specify a packet code");
409 REDEBUG(
"Cannot proxy Status-Server packets");
415 REDEBUG(
"Invalid packet code %d", request->packet->code);
419 if (!
inst->allowed[request->packet->code]) {
420 REDEBUG(
"Packet code %s is disallowed by the configuration",
427 REDEBUG(
"Cannot proxy packets which define dynamic clients");
445 ua =
inst->io->enqueue(&rcode, &rctx,
inst->io_submodule->dl_inst->data,
477 if (!
inst->status_check) {
482 num_types = talloc_array_length(
inst->types);
488 for (i = 0; i < num_types; i++) {
491 code =
inst->types[i];
495 inst->allowed[code] =
true;
504 if (
inst->replicate &&
inst->status_check) {
505 cf_log_warn(
conf,
"Ignoring 'status_check = %s' due to 'replicate = true'",
507 inst->status_check = 0;
517 if (
inst->status_check) {
519 inst->allowed[
inst->status_check] =
true;
521 }
else if (!
inst->allowed[
inst->status_check]) {
522 cf_log_err(
conf,
"Using 'status_check = %s' requires also 'type = %s'",
538 if (
inst->synchronous)
goto setup_io_submodule;
633 PERROR(
"Failed initialising protocol library");
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
@ UNLANG_ACTION_YIELD
Temporarily pause execution until an event occurs.
#define CONF_PARSER_TERMINATOR
#define FR_INTEGER_BOUND_CHECK(_name, _var, _op, _bound)
#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
#define FR_CONF_POINTER(_name, _type, _flags, _res_p)
conf_parser_t which parses a single CONF_PAIR producing a single global result
#define cf_section_rule_push(_cs, _rule)
#define FR_CONF_OFFSET_FLAGS(_name, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
#define FR_CONF_OFFSET_SUBSECTION(_name, _flags, _struct, _field, _subcs)
conf_parser_t which populates a sub-struct using a CONF_SECTION
#define FR_TIME_DELTA_BOUND_CHECK(_name, _var, _op, _bound)
@ CONF_FLAG_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
@ CONF_FLAG_MULTI
CONF_PAIR can have multiple copies.
@ CONF_FLAG_NOT_EMPTY
CONF_PAIR is required to have a non zero length value.
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
#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
Defines a CONF_PAIR to C data type mapping.
Common header for all CONF_* types.
A section grouping multiple CONF_PAIR.
CONF_PAIR * cf_item_to_pair(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_PAIR.
char const * cf_section_name2(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
char const * cf_pair_value(CONF_PAIR const *pair)
Return the value of a CONF_PAIR.
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
bool cf_item_is_section(CONF_ITEM const *ci)
Determine if CONF_ITEM is a CONF_SECTION.
char const * cf_section_name1(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
#define cf_log_err(_cf, _fmt,...)
#define cf_log_warn(_cf, _fmt,...)
static void * fr_dcursor_next(fr_dcursor_t *cursor)
Advanced the cursor to the next item.
@ FR_RADIUS_CODE_ACCESS_REQUEST
RFC2865 - Access-Request.
@ FR_RADIUS_CODE_DISCONNECT_REQUEST
RFC3575/RFC5176 - Disconnect-Request.
@ FR_RADIUS_CODE_MAX
Maximum possible protocol code.
@ FR_RADIUS_CODE_STATUS_SERVER
RFC2865/RFC5997 - Status Server (request)
@ FR_RADIUS_CODE_COA_REQUEST
RFC3575/RFC5176 - CoA-Request.
@ FR_RADIUS_CODE_ACCOUNTING_REQUEST
RFC2866 - Accounting-Request.
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.
fr_value_box_t const * value
Enum value (what name maps to).
fr_dict_enum_value_t * fr_dict_enum_by_name(fr_dict_attr_t const *da, char const *name, ssize_t len)
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.
Value of an enumerated attribute.
char const *_CONST name
Instance name.
void *_CONST data
Module instance's parsed configuration.
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
CONF_SECTION *_CONST conf
Module's instance configuration.
bool active
for dynamic clients
bool dynamic
Whether the client was dynamically defined.
Describes a host allowed to send packets to the server.
int map_afrom_cs(TALLOC_CTX *ctx, map_list_t *out, CONF_SECTION *cs, tmpl_rules_t const *lhs_rules, tmpl_rules_t const *rhs_rules, map_validate_t validate, void *uctx, unsigned int max)
Convert a config section into an attribute map.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_OCTETS
Raw octets.
int unlang_fixup_update(map_t *map, void *ctx)
Validate and fixup a map that's part of an update section.
void * env_data
Per call environment data.
void * rctx
Resume ctx that a module previously set.
dl_module_inst_t const * inst
Dynamic loader API handle for the module.
dl_module_inst_t const * inst
Dynamic loader API handle for the module.
#define MODULE_CTX(_dl_inst, _thread, _env_data, _rctx)
Wrapper to create a module_ctx_t as a compound literal.
Temporary structure to hold arguments for module calls.
Temporary structure to hold arguments for instantiation calls.
Specifies a module method identifier.
int module_rlm_submodule_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Generic conf_parser_t func for loading drivers.
module_t common
Common fields presented by all modules.
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.
static const conf_parser_t config[]
int fr_radius_global_init(void)
void fr_radius_global_free(void)
char const * fr_radius_packet_name[FR_RADIUS_CODE_MAX]
#define RADIUS_MAX_ATTRIBUTES
uint32_t fr_rand(void)
Return a 32-bit random number.
#define RETURN_MODULE_RCODE(_rcode)
rlm_rcode_t
Return codes indicating the result of the module call.
static conf_parser_t coa_config[]
static conf_parser_t disconnect_config[]
static int status_check_type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
static int mod_load(void)
static fr_dict_attr_t const * attr_packet_type
static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Send packets outbound.
static int type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
static fr_dict_attr_t const * attr_chap_password
static fr_dict_t const * dict_radius
static int mod_bootstrap(module_inst_ctx_t const *mctx)
static fr_dict_attr_t const * attr_chap_challenge
static conf_parser_t status_config[]
fr_dict_attr_autoload_t rlm_radius_dict_attr[]
static void mod_unload(void)
static void mod_radius_signal(module_ctx_t const *mctx, request_t *request, fr_signal_t action)
static void radius_fixups(rlm_radius_t const *inst, request_t *request)
Do any RADIUS-layer fixups for proxying.
static fr_dict_attr_t const * attr_proxy_state
static conf_parser_t const type_interval_config[FR_RADIUS_CODE_MAX]
static conf_parser_t auth_config[]
fr_dict_autoload_t rlm_radius_dict[]
static int status_check_update_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
static conf_parser_t const status_check_update_config[]
static conf_parser_t const status_check_config[]
static conf_parser_t const module_config[]
static conf_parser_t acct_config[]
struct rlm_radius_s rlm_radius_t
unlang_module_signal_t signal
Send a signal to an IO module.
Public structure describing an I/O path for an outgoing socket.
@ MODULE_TYPE_RESUMABLE
does yield / resume
@ MODULE_TYPE_THREAD_SAFE
Module is threadsafe.
#define MODULE_NAME_TERMINATOR
void * data
Thread specific instance data.
#define pair_append_request(_attr, _da)
Allocate and append a fr_pair_t to the request list.
tmpl_attr_rules_t attr
Rules/data for parsing attribute references.
Optional arguments passed to vp_tmpl functions.
fr_client_t * client_from_request(request_t *request)
Search up a list of requests trying to locate one which has a client.
module_thread_instance_t * module_thread(module_instance_t *mi)
Retrieve module/thread specific instance for a module.
unlang_action_t unlang_module_yield(request_t *request, module_method_t resume, unlang_module_signal_t signal, fr_signal_t sigmask, void *rctx)
Yield a request back to the interpreter from within a module.
if(!subtype_vp) goto fail
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
eap_aka_sim_process_conf_t * inst
fr_dict_t const * dict_def
Default dictionary to use with unqualified attribute references.
Stores an attribute, a value and various bits of other data.
#define talloc_get_type_abort_const
static fr_time_delta_t fr_time_delta_from_sec(int64_t sec)
#define fr_time_delta_ispos(_a)
conf_parser_t const fr_trunk_config[]
Config parser definitions to populate a fr_trunk_conf_t.
#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.
static size_t char ** out