The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Functions | Variables
proto_radius.c File Reference

RADIUS master protocol handler. More...

#include <freeradius-devel/radius/radius.h>
#include <freeradius-devel/io/listen.h>
#include <freeradius-devel/unlang/xlat_func.h>
#include <freeradius-devel/server/module_rlm.h>
#include <stdbool.h>
#include "proto_radius.h"
+ Include dependency graph for proto_radius.c:

Go to the source code of this file.

Functions

static int mod_decode (void const *instance, request_t *request, uint8_t *const data, size_t data_len)
 Decode the packet. More...
 
static ssize_t mod_encode (UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
 
static int mod_instantiate (module_inst_ctx_t const *mctx)
 Instantiate the application. More...
 
static int mod_load (void)
 
static int mod_open (void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
 Open listen sockets/connect to external event source. More...
 
static int mod_priority_set (void const *instance, uint8_t const *buffer, UNUSED size_t buflen)
 
static void mod_unload (void)
 
static xlat_action_t packet_vector_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, request_t *request, UNUSED fr_value_box_list_t *in)
 Get the authentication vector. More...
 
static int transport_parse (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 
static int type_parse (TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 
static int type_parse (UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
 Translates the packet-type into a submodule name. More...
 

Variables

static fr_dict_attr_t const * attr_message_authenticator
 
static fr_dict_attr_t const * attr_packet_type
 
static fr_dict_attr_t const * attr_proxy_state
 
static fr_dict_attr_t const * attr_state
 
static fr_dict_attr_t const * attr_user_name
 
static fr_dict_t const * dict_radius
 
static conf_parser_t const limit_config []
 
static const conf_parser_t priority_config []
 
fr_app_t proto_radius
 
static conf_parser_t const proto_radius_config []
 How to parse a RADIUS listen section. More...
 
fr_dict_autoload_t proto_radius_dict []
 
fr_dict_attr_autoload_t proto_radius_dict_attr []
 

Detailed Description

RADIUS master protocol handler.

Id
a8111b5bde7221537a0a9f1425164abe81eb59f4

Definition in file proto_radius.c.

Function Documentation

◆ mod_decode()

static int mod_decode ( void const *  instance,
request_t request,
uint8_t *const  data,
size_t  data_len 
)
static

Decode the packet.

Definition at line 180 of file proto_radius.c.

+ Here is the call graph for this function:

◆ mod_encode()

static ssize_t mod_encode ( UNUSED void const *  instance,
request_t request,
uint8_t buffer,
size_t  buffer_len 
)
static

Definition at line 392 of file proto_radius.c.

+ Here is the call graph for this function:

◆ mod_instantiate()

static int mod_instantiate ( module_inst_ctx_t const *  mctx)
static

Instantiate the application.

Instantiate I/O and type submodules.

Returns
  • 0 on success.
  • -1 on failure.

Definition at line 564 of file proto_radius.c.

+ Here is the call graph for this function:

◆ mod_load()

static int mod_load ( void  )
static

Definition at line 662 of file proto_radius.c.

+ Here is the call graph for this function:

◆ mod_open()

static int mod_open ( void *  instance,
fr_schedule_t sc,
UNUSED CONF_SECTION conf 
)
static

Open listen sockets/connect to external event source.

Parameters
[in]instanceCtx data for this application.
[in]scto add our file descriptor to.
[in]confListen section parsed to give us instance.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 545 of file proto_radius.c.

+ Here is the call graph for this function:

◆ mod_priority_set()

static int mod_priority_set ( void const *  instance,
uint8_t const *  buffer,
UNUSED size_t  buflen 
)
static

Definition at line 509 of file proto_radius.c.

+ Here is the call graph for this function:

◆ mod_unload()

static void mod_unload ( void  )
static

Definition at line 675 of file proto_radius.c.

+ Here is the call graph for this function:

◆ packet_vector_xlat()

static xlat_action_t packet_vector_xlat ( TALLOC_CTX *  ctx,
fr_dcursor_t out,
UNUSED xlat_ctx_t const *  xctx,
request_t request,
UNUSED fr_value_box_list_t *  in 
)
static

Get the authentication vector.

Note that we don't allow people to get the reply vector, because it doesn't exist until the reply is sent.

Definition at line 642 of file proto_radius.c.

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

◆ transport_parse()

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

Definition at line 160 of file proto_radius.c.

+ Here is the call graph for this function:

◆ type_parse() [1/2]

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

◆ type_parse() [2/2]

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

Translates the packet-type into a submodule name.

If we found a Packet-Type = Access-Request CONF_PAIR for example, here's we'd load the proto_radius_auth module.

Parameters
[in]ctxto allocate data in (instance of proto_radius).
[out]outWhere to write a module_instance_t containing the module handle and instance.
[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 138 of file proto_radius.c.

+ Here is the call graph for this function:

Variable Documentation

◆ attr_message_authenticator

fr_dict_attr_t const* attr_message_authenticator
static

Definition at line 112 of file proto_radius.c.

◆ attr_packet_type

fr_dict_attr_t const* attr_packet_type
static

Definition at line 108 of file proto_radius.c.

◆ attr_proxy_state

fr_dict_attr_t const* attr_proxy_state
static

Definition at line 111 of file proto_radius.c.

◆ attr_state

fr_dict_attr_t const* attr_state
static

Definition at line 110 of file proto_radius.c.

◆ attr_user_name

fr_dict_attr_t const* attr_user_name
static

Definition at line 109 of file proto_radius.c.

◆ dict_radius

fr_dict_t const* dict_radius
static

Definition at line 100 of file proto_radius.c.

◆ limit_config

conf_parser_t const limit_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("cleanup_delay", proto_radius_t, io.cleanup_delay), .dflt = "5.0" } ,
{ FR_CONF_OFFSET("idle_timeout", proto_radius_t, io.idle_timeout), .dflt = "30.0" } ,
{ FR_CONF_OFFSET("nak_lifetime", proto_radius_t, io.nak_lifetime), .dflt = "30.0" } ,
{ FR_CONF_OFFSET("max_connections", proto_radius_t, io.max_connections), .dflt = "1024" } ,
{ FR_CONF_OFFSET("max_clients", proto_radius_t, io.max_clients), .dflt = "256" } ,
{ FR_CONF_OFFSET("max_pending_packets", proto_radius_t, io.max_pending_packets), .dflt = "256" } ,
{ FR_CONF_OFFSET("max_packet_size", proto_radius_t, max_packet_size) } ,
{ FR_CONF_OFFSET("num_messages", proto_radius_t, num_messages) } ,
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:627
#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
An instance of a proto_radius listen section.
Definition: proto_radius.h:32

Definition at line 37 of file proto_radius.c.

◆ priority_config

const conf_parser_t priority_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("Access-Request", proto_radius_t, priorities[FR_RADIUS_CODE_ACCESS_REQUEST]),
.func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "high" },
{ FR_CONF_OFFSET("Accounting-Request", proto_radius_t, priorities[FR_RADIUS_CODE_ACCOUNTING_REQUEST]),
.func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "low" },
.func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
{ FR_CONF_OFFSET("Disconnect-Request", proto_radius_t, priorities[FR_RADIUS_CODE_DISCONNECT_REQUEST]),
.func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "low" },
.func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "now" },
}
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
size_t channel_packet_priority_len
Definition: channel.c:170
fr_table_num_sorted_t const channel_packet_priority[]
Definition: channel.c:164
@ FR_RADIUS_CODE_ACCESS_REQUEST
RFC2865 - Access-Request.
Definition: defs.h:33
@ FR_RADIUS_CODE_DISCONNECT_REQUEST
RFC3575/RFC5176 - Disconnect-Request.
Definition: defs.h:46
@ FR_RADIUS_CODE_STATUS_SERVER
RFC2865/RFC5997 - Status Server (request)
Definition: defs.h:44
@ FR_RADIUS_CODE_COA_REQUEST
RFC3575/RFC5176 - CoA-Request.
Definition: defs.h:49
@ FR_RADIUS_CODE_ACCOUNTING_REQUEST
RFC2866 - Accounting-Request.
Definition: defs.h:36

Definition at line 55 of file proto_radius.c.

◆ proto_radius

fr_app_t proto_radius
Initial value:
= {
.common = {
.name = "radius",
.inst_size = sizeof(proto_radius_t),
.onload = mod_load,
.unload = mod_unload,
},
.dict = &dict_radius,
.open = mod_open,
.decode = mod_decode,
.encode = mod_encode,
.priority = mod_priority_set
}
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:63
static int mod_load(void)
Definition: proto_radius.c:662
static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
Definition: proto_radius.c:392
static int mod_decode(void const *instance, request_t *request, uint8_t *const data, size_t data_len)
Decode the packet.
Definition: proto_radius.c:180
static fr_dict_t const * dict_radius
Definition: proto_radius.c:100
static void mod_unload(void)
Definition: proto_radius.c:675
static int mod_instantiate(module_inst_ctx_t const *mctx)
Instantiate the application.
Definition: proto_radius.c:564
static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
Open listen sockets/connect to external event source.
Definition: proto_radius.c:545
static int mod_priority_set(void const *instance, uint8_t const *buffer, UNUSED size_t buflen)
Definition: proto_radius.c:509
static conf_parser_t const proto_radius_config[]
How to parse a RADIUS listen section.
Definition: proto_radius.c:73
static int instantiate(module_inst_ctx_t const *mctx)
Definition: rlm_rest.c:1302

Definition at line 682 of file proto_radius.c.

◆ proto_radius_config

conf_parser_t const proto_radius_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET_FLAGS("type", CONF_FLAG_NOT_EMPTY, proto_radius_t, allowed_types), .func = type_parse },
{ FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_radius_t, io.submodule),
.func = transport_parse },
{ FR_CONF_OFFSET("tunnel_password_zeros", proto_radius_t, tunnel_password_zeros) } ,
{ FR_CONF_POINTER("limit", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) limit_config },
{ FR_CONF_POINTER("priority", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) priority_config },
{ FR_CONF_OFFSET("require_message_authenticator", proto_radius_t, require_message_authenticator),
.dflt = "no" },
{ FR_CONF_OFFSET("limit_proxy_state", proto_radius_t, limit_proxy_state),
.dflt = "auto" },
}
#define FR_CONF_POINTER(_name, _type, _flags, _res_p)
conf_parser_t which parses a single CONF_PAIR producing a single global result
Definition: cf_parse.h:310
#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
Definition: cf_parse.h:256
@ CONF_FLAG_NOT_EMPTY
CONF_PAIR is required to have a non zero length value.
Definition: cf_parse.h:420
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition: cf_parse.h:399
#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 conf_parser_t const limit_config[]
Definition: proto_radius.c:37
static int type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
static const conf_parser_t priority_config[]
Definition: proto_radius.c:55
static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Definition: proto_radius.c:160
size_t fr_radius_limit_proxy_state_table_len
Definition: base.c:99
size_t fr_radius_require_ma_table_len
Definition: base.c:90
fr_table_num_sorted_t const fr_radius_limit_proxy_state_table[]
Definition: base.c:92
fr_table_num_sorted_t const fr_radius_require_ma_table[]
Definition: base.c:83

How to parse a RADIUS listen section.

Definition at line 73 of file proto_radius.c.

◆ proto_radius_dict

fr_dict_autoload_t proto_radius_dict
Initial value:
= {
{ .out = &dict_radius, .proto = "radius" },
{ NULL }
}

Definition at line 103 of file proto_radius.c.

◆ proto_radius_dict_attr

fr_dict_attr_autoload_t proto_radius_dict_attr
Initial value:
= {
{ .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_radius},
{ .out = &attr_user_name, .name = "User-Name", .type = FR_TYPE_STRING, .dict = &dict_radius},
{ .out = &attr_state, .name = "State", .type = FR_TYPE_OCTETS, .dict = &dict_radius},
{ .out = &attr_proxy_state, .name = "Proxy-State", .type = FR_TYPE_OCTETS, .dict = &dict_radius},
{ .out = &attr_message_authenticator, .name = "Message-Authenticator", .type = FR_TYPE_OCTETS, .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_packet_type
Definition: proto_radius.c:108
static fr_dict_attr_t const * attr_state
Definition: proto_radius.c:110
static fr_dict_attr_t const * attr_proxy_state
Definition: proto_radius.c:111
static fr_dict_attr_t const * attr_user_name
Definition: proto_radius.c:109
static fr_dict_attr_t const * attr_message_authenticator
Definition: proto_radius.c:112

Definition at line 115 of file proto_radius.c.