27RCSID(
"$Id: c2663365128ed7fef25c3a42af055014d0dbaf20 $")
29#include <freeradius-devel/protocol/freeradius/freeradius.internal.h>
30#include <freeradius-devel/server/base.h>
31#include <freeradius-devel/server/process.h>
32#include <freeradius-devel/server/virtual_servers.h>
33#include <freeradius-devel/server/cf_util.h>
35#include <freeradius-devel/unlang/compile.h>
36#include <freeradius-devel/unlang/function.h>
37#include <freeradius-devel/unlang/finally.h>
38#include <freeradius-devel/unlang/interpret.h>
40#include <freeradius-devel/io/application.h>
41#include <freeradius-devel/io/master.h>
42#include <freeradius-devel/io/listen.h>
44#include <freeradius-devel/util/dict.h>
45#include <freeradius-devel/util/pair.h>
46#include <freeradius-devel/util/talloc.h>
47#include <freeradius-devel/util/types.h>
48#include <freeradius-devel/util/value.h>
238 char const *
namespace;
239 char *module_name, *p, *end;
240 char const *inst_name;
244 "virtual_servers_init MUST be called before reading virtual server config");
246 namespace = cf_pair_value(cp);
247 module_name = talloc_strdup(ctx,
namespace);
252 for (p = module_name, end = module_name + talloc_array_length(module_name) - 1;
254 p++)
if (*p ==
'-') *p =
'_';
265 module_name, inst_name,
276 if (!*(process->
dict)) {
277 cf_log_err(ci,
"Process module is invalid - missing namespace dictionary");
281 cf_data_add(server_cs, mi,
"process_module",
false);
287static inline CC_HINT(always_inline)
295 for (i = 0; list[i].
section; i++) {
309 cf_log_err(cs,
"Failed registering processing section name %s for %s",
310 list[i].section->name1,
name);
335 char const *
namespace = cf_pair_value(cp);
358 cf_log_perr(ci,
"Failed bootstrapping process module");
393 char const *module, *name2, *p;
399 "virtual_servers_init MUST be called before reading virtual server config");
402 cf_log_err(server_cs,
"No 'namespace' set for virtual server");
403 cf_log_err(server_cs,
"Please add 'namespace = <protocol>' inside of the 'server %s { ... }' section",
418 module = cf_pair_value(cp);
424 module = cf_pair_value(namespace);
450 cf_log_perr(listener_cs,
"Invalid name in 'listen %s'", name2);
466 cf_log_err(listener_cs,
"Invalid 'listen' section - No 'transport = ...' definition was found.");
479 cf_log_perr(listener_cs,
"Failed loading listen section.");
485 cf_log_perr(listener_cs,
"Failed creating listen section");
490 cf_log_perr(listener_cs,
"Failed parsing listen section");
496 cf_data_add(listener_cs, mi,
"proto_module",
false);
510 cf_log_err(cp,
"Listener has 'type = %s', but there is no 'recv %s { ... }' section defined.",
547 cf_log_err(server_cs,
"virtual server %s MUST contain a 'namespace' option",
580 if (!vs)
return NULL;
598 if (!cd)
return NULL;
601 (void) talloc_get_type_abort(dict,
fr_dict_t);
619 if (!cd)
return NULL;
622 (void) talloc_get_type_abort(dict,
fr_dict_t);
652 if (ci)
cf_log_err(ci,
"Can't find virtual server \"%s\"", virtual_server);
662 if (ci)
cf_log_err(ci,
"No namespace found in virtual server \"%s\"", virtual_server);
666 if (dict !=
namespace) {
669 "Expected virtual server \"%s\" to be of namespace \"%s\", got namespace \"%s\"",
675 if (
out) *
out = server_cs;
724 if (!
vp)
goto check_default;
761 cf_log_err(server_cs,
"server_cs does not contain virtual server data");
812 if (!server_cnt)
return 0;
814 for (i = 0; i < server_cnt; i++) {
826 .help =
"Show virtual server settings.",
831 .parent =
"show server",
834 .help =
"Show the list of virtual servers loaded in the server.",
886 CMP_RETURN(a, b, app_io_addr->inet.src_ipaddr.af);
893 CMP_RETURN(a, b, app_io_addr->inet.src_ipaddr.scope_id);
907 }
else if (ret > 0) {
965 if (
unlikely(server_cs == NULL))
return NULL;
968 if (
unlikely(cd == NULL))
return NULL;
987 cf_log_err(ci,
"Child section is not associated with a virtual server");
993 cf_log_err(ci,
"Virtual server section missing virtual_server_t data");
1060 cf_log_err(subcs,
"Duplicate 'finally { ... }' section");
1064 ret =
unlang_compile(vs, subcs, &mod_actions_finally, rules, &instruction);
1065 if (ret < 0)
return -1;
1080 cf_log_err(subcs,
"Invalid 'finally %s { ... }' section, "
1081 "does not match any Packet-Type value", packet_type);
1092 cf_log_err(subcs,
"'finally %s { ... }' section, "
1093 "not supported for this protocol. %s is a %s", packet_type,
1097 cf_log_err(subcs,
"'finally %s { ... }' section, "
1098 "not supported for this protocol", packet_type);
1109 void *, key.vb_uint16 + 1));
1113 cf_log_err(subcs,
"Duplicate 'finally %s { ... }' section", packet_type);
1117 ret =
unlang_compile(vs, subcs, &mod_actions_finally, rules, &instruction);
1118 if (ret < 0)
return -1;
1166 if ((strcmp(
name,
"authorize") == 0) ||
1167 (strcmp(
name,
"authenticate") == 0) ||
1168 (strcmp(
name,
"post-auth") == 0) ||
1169 (strcmp(
name,
"preacct") == 0) ||
1170 (strcmp(
name,
"accounting") == 0) ||
1171 (strcmp(
name,
"pre-proxy") == 0) ||
1172 (strcmp(
name,
"post-proxy") == 0)) {
1173 cf_log_err(subcs,
"Version 3 processing section '%s' is not valid in version 4.",
1182 if (fail)
return -1;
1190 for (i = 0; list[i].
section; i++) {
1200 void *instruction = NULL;
1204 DEBUG3(
"Warning: Skipping %s %s { ... } as it was not found.",
1209 if ((instance) && !list[i].dont_cache) {
1221 cf_log_err(bad,
"Duplicate sections are forbidden.");
1222 cf_log_err(subcs,
"Previous definition occurs here.");
1226 rcode =
unlang_compile(vs, subcs, list[i].actions, rules, &instruction);
1227 if (rcode < 0)
return -1;
1233 if (!list[i].dont_cache) {
1236 if (list[i].instruction > 0) {
1237 *(
void **) (((
uint8_t *) instance) + list[i].instruction) = instruction;
1261 cf_log_err(subcs,
"Invalid '%s { ... }' section, it must have a name", list[i].section->name1);
1269 if (bad)
goto forbidden;
1272 if (rcode < 0)
return -1;
1291 cf_log_err(server,
"Failed to compile finally sections");
1304 cf_log_err(server,
"No processing sections are defined for this virtual server");
1305 cf_log_err(server,
"The server WILL NOT be able to process packets until the configuration is fixed");
1336 for (i = 0; entry->
methods[i]; i++) {
1338 ERROR(
"Processing sections cannot allow \"*\"");
1343 ERROR(
"Processing sections cannot allow \"%s *\"",
1375 if (entry)
return entry->
methods;
1383 .section = SECTION_NAME(section->name1, CF_IDENT_ANY)
1385 if (!entry)
return NULL;
1414 cf_log_err(subcs,
"Invalid '%s { ... }' section, it must have a name", subcs_name);
1425 cf_log_debug(subcs,
"Creating %s = %s", da->name, name2);
1434 PERROR(
"Failed adding section value");
1452 cf_log_err(cs,
"Expected 'values <name> { ... }'");
1458 cf_log_err(cs,
"No such attribute \"%s\"", ref);
1463 cf_log_err(cs,
"Cannot define value for structural attribute \"%s\"", ref);
1472 cf_log_err(cs,
"Cannot define value for 'string' attribute \"%s\"", ref);
1478 char const *attr, *
value;
1498 cf_log_err(ci,
"Definition is not in 'name = value' format");
1513 len = talloc_array_length(
value) - 1;
1525 cf_log_err(cp,
"Unexpected text after value");
1556 char const *attr, *
value;
1566 if (strcmp(attr,
"values") == 0) {
1575 cf_log_err(ci,
"Definition is not in 'tlv name { ... }' format");
1594 cf_log_err(ci,
"Definition is not in 'type name' format");
1604 cf_log_err(ci,
"Invalid data type '%s'", attr);
1618 cf_log_err(ci,
"Local variable '%s' duplicates a dictionary attribute.",
value);
1623 cf_log_err(ci,
"Local variable '%s' duplicates a previous local attribute.",
value);
1635 if (!subcs)
return -1;
1653 if (!cs)
return dict_def;
1657 cf_log_err(cs,
"Failed allocating local dictionary");
1687 DEBUG2(
"#### Opening listener interfaces ####");
1690 for (i = 0; i < server_cnt; i++) {
1692 size_t j, listener_cnt;
1695 listener_cnt = talloc_array_length(listeners);
1697 for (j = 0; j < listener_cnt; j++) {
1729 "Failed opening listener %s",
1745 ERROR(
"There are no 'listen' sections defined.");
1746 ERROR(
"Refusing to start, as the server will never process any packets.");
1783 size_t i, server_cnt;
1789 ERROR(
"No virtual servers configured");
1795 DEBUG2(
"#### Instantiating listeners ####");
1798 PERROR(
"Failed registering radmin commands for virtual servers");
1802 for (i = 0; i < server_cnt; i++) {
1829 if (!dict)
return -1;
1877 if ((strcmp(
name,
"listen") == 0) || (strcmp(
name,
"client") == 0))
continue;
1887 if (!name2) name2 =
"";
1895 PERROR(
"Failed instantiating process modules");
1899 PERROR(
"Failed instantiating protocol modules");
1923 PERROR(
"Failed instantiating process modules");
1927 PERROR(
"Failed instantiating protocol modules");
1963 PERROR(
"%s", __FUNCTION__);
1967 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.
module_t common
Common fields provided by all modules.
fr_app_open_t open
Callback to allow the fr_app_t to build an fr_listen_t and register it with the scheduler so we can r...
Describes a new application (protocol)
#define fr_atexit_global(_func, _uctx)
Add a free function to the global free list.
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
#define CMP_RETURN(_a, _b, _field)
Return if the comparison is not 0 (is unequal)
static int invalid_type(fr_type_t type)
int cf_section_parse(TALLOC_CTX *ctx, void *base, CONF_SECTION *cs)
Parse a configuration section into user-supplied variables.
int cf_null_on_read(UNUSED TALLOC_CTX *ctx, UNUSED void *out, UNUSED void *parent, UNUSED CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
NULL callback for sections.
#define CONF_PARSER_TERMINATOR
cf_parse_t func
Override default parsing behaviour for the specified type with a custom parsing function.
void const * uctx
User data accessible by the cf_parse_t func.
#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
char const * name2
Second identifier for CONF_SECTION.
#define FR_CONF_POINTER(_name, _type, _flags, _res_p)
conf_parser_t which parses a single CONF_PAIR producing a single global result
cf_parse_t on_read
Function to call as the item is being read, just after it has been allocated and initialized.
@ 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_OK_MISSING
OK if it's missing.
@ 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.
Internal data that is associated with a configuration section.
Common header for all CONF_* types.
Configuration AVP similar to a fr_pair_t.
A section grouping multiple CONF_PAIR.
bool cf_item_is_pair(CONF_ITEM const *ci)
Determine if CONF_ITEM is a CONF_PAIR.
fr_token_t cf_pair_attr_quote(CONF_PAIR const *pair)
Return the value (lhs) quoting of a pair.
CONF_PAIR * cf_pair_find_next(CONF_SECTION const *cs, CONF_PAIR const *prev, char const *attr)
Find a pair with a name matching attr, after specified pair.
char const * cf_section_name2(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
void * cf_data_value(CONF_DATA const *cd)
Return the user assigned value of CONF_DATA.
CONF_SECTION * cf_section_next(CONF_SECTION const *cs, CONF_SECTION const *curr)
Return the next child that's a CONF_SECTION.
char const * cf_section_name1(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
CONF_SECTION * cf_section_find(CONF_SECTION const *cs, char const *name1, char const *name2)
Find a CONF_SECTION with name1 and optionally name2.
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
CONF_PAIR * cf_pair_find(CONF_SECTION const *cs, char const *attr)
Search for a CONF_PAIR with a specific name.
fr_token_t cf_pair_operator(CONF_PAIR const *pair)
Return the operator of a pair.
fr_token_t cf_pair_value_quote(CONF_PAIR const *pair)
Return the value (rhs) quoting of a pair.
bool cf_item_is_section(CONF_ITEM const *ci)
Determine if CONF_ITEM is a CONF_SECTION.
CONF_PAIR * cf_item_to_pair(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_PAIR.
CONF_SECTION * cf_section_find_next(CONF_SECTION const *cs, CONF_SECTION const *prev, char const *name1, char const *name2)
Return the next matching section.
char const * cf_pair_value(CONF_PAIR const *pair)
Return the value of a CONF_PAIR.
char const * cf_pair_attr(CONF_PAIR const *pair)
Return the attr of a CONF_PAIR.
#define cf_log_err(_cf, _fmt,...)
#define cf_data_add(_cf, _data, _name, _free)
#define cf_data_find(_cf, _type, _name)
#define cf_data_remove(_cf, _type, _name)
Remove an item from a parent by type and name.
#define cf_item_next(_parent, _curr)
#define cf_log_perr(_cf, _fmt,...)
#define cf_section_find_parent(_cf, _name1, _name2)
#define cf_section_alloc(_ctx, _parent, _name1, _name2)
#define cf_data_find_in_parent(_cf, _type, _name)
#define cf_log_warn(_cf, _fmt,...)
#define cf_log_debug(_cf, _fmt,...)
fr_command_register_hook_t fr_command_register_hook
char const * parent
e.g. "show module"
int unlang_compile(virtual_server_t const *vs, CONF_SECTION *cs, unlang_mod_actions_t const *actions, tmpl_rules_t const *rules, void **instruction)
Compile an unlang section for a virtual server.
#define fr_assert_msg(_x, _msg,...)
Calls panic_action ifndef NDEBUG, else logs error and causes the server to exit immediately with code...
#define fr_cond_assert_msg(_x, _fmt,...)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
int fr_dict_enum_add_name(fr_dict_attr_t *da, char const *name, fr_value_box_t const *value, bool coerce, bool replace)
Add a value name.
int fr_dict_attr_add_name_only(fr_dict_t *dict, fr_dict_attr_t const *parent, char const *name, fr_type_t type, fr_dict_attr_flags_t const *flags))
Add an attribute to the dictionary.
#define fr_dict_autofree(_to_free)
fr_dict_attr_t const * fr_dict_attr_by_name(fr_dict_attr_err_t *err, fr_dict_attr_t const *parent, char const *attr))
Locate a fr_dict_attr_t by its name.
fr_dict_attr_t * fr_dict_attr_unconst(fr_dict_attr_t const *da)
Coerce to non-const.
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
unsigned int internal
Internal attribute, should not be received in protocol packets, should not be encoded.
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).
int fr_dict_enum_add_name_next(fr_dict_attr_t *da, char const *name)
Add an name to an integer attribute hashing the name for the integer value.
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)
fr_dict_t * fr_dict_protocol_alloc(fr_dict_t const *parent)
Allocate a new local dictionary.
fr_dict_enum_value_t const * 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.
Values of the encryption flags.
Specifies a dictionary which must be loaded/loadable for the module to function.
Value of an enumerated attribute.
@ DL_MODULE_TYPE_PROTO
Protocol module.
@ DL_MODULE_TYPE_PROCESS
protocol processor.
int unlang_finally_push_instruction(request_t *request, void *instruction, fr_time_delta_t min_time, bool top_frame)
Push a finally instructtion on the stack, to be evaluated as the stack is unwound.
#define unlang_function_push(_request, _func, _repeat, _signal, _sigmask, _top_frame, _uctx)
Push a generic function onto the unlang stack.
int global_lib_instantiate(void)
Walk the tree of libraries and instantiate any which are pending.
int8_t fr_ipaddr_cmp(fr_ipaddr_t const *a, fr_ipaddr_t const *b)
Compare two ip addresses.
void fr_ipaddr_mask(fr_ipaddr_t *addr, uint8_t prefix)
Zeroes out the host portion of an fr_ipaddr_t.
int unlang_interpret_stack_depth(request_t *request)
Return the depth of the request's stack.
fr_socket_t * app_io_addr
for tracking duplicate sockets
fr_log_t * log_dst_by_name(char const *name)
Get a logging destination by name.
#define DEBUG_ENABLED
True if global debug level 1 messages are enabled.
Stores all information relating to an event list.
@ L_DBG_LVL_DISABLE
Don't print messages.
@ FR_TYPE_TLV
Contains nested attributes.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_NULL
Invalid (uninitialised) attribute type.
@ FR_TYPE_UINT16
16 Bit unsigned integer.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_GROUP
A grouping of other attributes.
unlang_mod_action_t actions[RLM_MODULE_NUMCODES]
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.
static const virtual_server_compile_t compile_list[]
static const conf_parser_t config[]
fr_dict_t const ** dict
pointer to local fr_dict_t *
module_method_t process
Process packets.
virtual_server_compile_t const * compile_list
list of processing sections
fr_dict_attr_t const ** packet_type
Request packet types to look for finally sections for.
Common public symbol definition for all process modules.
void * fr_rb_find(fr_rb_tree_t const *tree, void const *data)
Find an element in the tree, returning the data, not the node.
bool fr_rb_insert(fr_rb_tree_t *tree, void const *data)
Insert data into a tree.
#define fr_rb_alloc(_ctx, _data_cmp, _data_free)
Allocs a red black tree.
#define fr_rb_inline_alloc(_ctx, _type, _field, _data_cmp, _data_free)
Allocs a red black tree.
The main red black tree structure.
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_DISALLOW
Reject the request (user is locked out).
@ RLM_MODULE_REJECT
Immediately reject the request.
@ RLM_MODULE_NOTFOUND
User not found.
@ RLM_MODULE_UPDATED
OK (pairs modified).
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
@ RLM_MODULE_HANDLED
The module handled the request, so stop.
fr_dict_attr_t const * request_attr_request
void request_log_prepend(request_t *request, fr_log_t *log_dst, fr_log_lvl_t lvl)
Prepend another logging destination to the list.
#define fr_sbuff_start(_sbuff_or_marker)
#define FR_SBUFF_IN_CHAR_RETURN(_sbuff,...)
#define FR_SBUFF_IN_STRCPY_RETURN(...)
#define FR_SBUFF_TALLOC_THREAD_LOCAL(_out, _init, _max)
int8_t section_name_cmp(void const *one, void const *two)
Compare two sections.
char const * name2
Second section name. Usually a packet type like 'access-request', 'access-accept',...
char const * name1
First section name. Usually a verb like 'recv', 'send', etc...
CONF_SECTION * conf
Module's instance configuration.
void * data
Module's instance data.
#define MODULE_INSTANCE_LEN_MAX
The maximum size of a module instance.
module_t * exported
Public module structure.
tmpl_attr_rules_t attr
Rules/data for parsing attribute references.
Optional arguments passed to vp_tmpl functions.
fr_signal_t
Signals that can be generated/processed by request signal handlers.
@ FR_SIGNAL_CANCEL
Request has been cancelled.
static const uchar sc[16]
int module_instance_data_protect(module_instance_t const *mi)
Mark module data as read only.
void module_list_debug(module_list_t const *ml)
Print the contents of a module list.
module_instance_t * module_instance_alloc(module_list_t *ml, module_instance_t const *parent, dl_module_type_t type, char const *mod_name, char const *inst_name, module_instance_state_t init_state)
Allocate a new module and add it to a module list for later bootstrap/instantiation.
fr_slen_t module_instance_name_from_conf(char const **name, CONF_SECTION *conf)
Avoid boilerplate when setting the module instance name.
void modules_thread_detach(module_list_t *ml)
Remove thread-specific data for a given module list.
int modules_thread_instantiate(TALLOC_CTX *ctx, module_list_t const *ml, fr_event_list_t *el)
Creates per-thread instance data for modules which need it.
module_instance_t * module_instance_by_data(module_list_t const *ml, void const *data)
Find an existing module instance by its private instance data.
int modules_instantiate(module_list_t const *ml)
Completes instantiation of modules.
module_list_t * module_list_alloc(TALLOC_CTX *ctx, module_list_type_t const *type, char const *name, bool write_protect)
Allocate a new module list.
fr_slen_t module_instance_name_valid(char const *inst_name)
Check to see if a module instance name is valid.
int module_instance_data_unprotect(module_instance_t const *mi)
Mark module data as read/write.
module_list_type_t const module_list_type_global
Callbacks for a global module list.
int modules_bootstrap(module_list_t const *ml)
Bootstrap any modules which have not been bootstrapped already.
int module_submodule_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Generic callback for conf_parser_t to load a submodule.
int module_instance_conf_parse(module_instance_t *mi, CONF_SECTION *conf)
Covert a CONF_SECTION into parsed module instance data.
int unlang_module_push(rlm_rcode_t *p_result, request_t *request, module_instance_t *mi, module_method_t method, bool top_frame)
Push a module or submodule onto the stack for evaluation.
fr_aka_sim_id_type_t type
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 fr_table_value_by_str(_table, _name, _def)
Convert a string to a value using a sorted or ordered table.
#define talloc_realloc_zero(_ctx, _ptr, _type, _count)
static size_t talloc_strlen(char const *s)
Returns the length of a talloc array containing a string.
static fr_time_delta_t fr_time_delta_from_sec(int64_t sec)
static fr_event_list_t * el
Generic representation of a grouping.
int af
AF_INET, AF_INET6, or AF_UNIX.
char const * fr_strerror(void)
Get the last library error.
void fr_strerror_clear(void)
Clears all pending messages from the talloc pools.
#define fr_strerror_const(_msg)
fr_table_num_ordered_t const fr_type_table[]
Map data types to names representing those types.
#define fr_type_is_structural(_x)
#define fr_type_is_integer_except_bool(_x)
#define fr_type_is_leaf(_x)
static char const * fr_type_to_str(fr_type_t type)
Return a static string containing the type name.
int fr_value_box_cast(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, fr_value_box_t const *src)
Convert one type of fr_value_box_t to another.
ssize_t fr_value_box_from_str(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, char const *in, size_t inlen, fr_sbuff_unescape_rules_t const *erules)
void fr_value_box_clear(fr_value_box_t *data)
Clear/free any existing value and metadata.
fr_type_t _CONST type
Type and flags should appear together for packing efficiency.
#define fr_value_box_init_null(_vb)
Initialise an empty/null box that will be filled later.
static size_t char ** out
#define FR_VALUE_BOX_SAFE_FOR_ANY
fr_dict_autoload_t virtual_server_dict_autoload[]
static const conf_parser_t server_on_read_config[]
bool listen_record(fr_listen_t *li)
Record that we're listening on a particular IP / port.
int virtual_server_section_register(virtual_server_t *vs, virtual_server_compile_t const *entry)
Register name1 / name2 as allowed processing sections.
fr_process_module_t const * process_module
Public interface to the process_mi.
void * finally_default
Default finally instruction.
int virtual_servers_bootstrap(CONF_SECTION *config)
Load protocol modules and call their bootstrap methods.
module_instance_t * process_mi
The process_* module for a virtual server.
const conf_parser_t virtual_servers_on_read_config[]
fr_dict_t const * virtual_server_dict_by_name(char const *virtual_server)
Return the namespace for the named virtual server.
static int server_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
static int virtual_server_compile_sections(virtual_server_t *vs, tmpl_rules_t const *rules)
Compile sections for a virtual server.
CONF_SECTION * server_cs
The server section.
module_instance_t * virtual_server_listener_by_data(void const *data)
Resolve proto data to a module instance.
fr_rb_tree_t * sections
List of sections that need to be compiled.
static int namespace_on_read(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
fr_app_t const * proto_module
Public interface to the proto_mi.
section_name_t const ** virtual_server_section_methods(virtual_server_t const *vs, section_name_t const *section)
Find the component for a section.
fr_dict_attr_autoload_t virtual_server_dict_attr_autoload[]
int virtual_servers_open(fr_schedule_t *sc)
Open all the listen sockets.
int virtual_server_cf_parse(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
Wrapper for the config parser to allow pass1 resolution of virtual servers.
static int virtual_server_compile_finally_sections(virtual_server_t *vs, tmpl_rules_t const *rules, int *found)
static module_list_t * process_modules
List of process modules we've loaded.
int virtual_server_has_namespace(CONF_SECTION **out, char const *virtual_server, fr_dict_t const *namespace, CONF_ITEM *ci)
Verify that a given virtual_server exists and is of a particular namespace.
static fr_dict_t const * dict_freeradius
int virtual_server_listen_transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Generic conf_parser_t func for loading drivers.
const conf_parser_t virtual_servers_config[]
static CONF_SECTION * virtual_server_root
CONF_SECTION holding all the virtual servers.
static const conf_parser_t server_config[]
virtual_server_t const * virtual_server_find(char const *name)
Return virtual server matching the specified name.
static fr_dict_t const * virtual_server_local_dict(CONF_SECTION *server_cs, fr_dict_t const *dict_def)
fr_dict_t const * virtual_server_dict_by_child_ci(CONF_ITEM const *ci)
Return the namespace for a given virtual server specified by a CONF_ITEM within the virtual server.
static int8_t virtual_server_compile_name_cmp(void const *a, void const *b)
fr_listen_t * listen_find_any(fr_listen_t *li)
See if another global listener is using a particular IP / port.
static virtual_server_t ** virtual_servers
Top level structure holding all virtual servers.
static fr_dict_attr_t const * attr_auth_type
int virtual_server_section_attribute_define(CONF_SECTION *server_cs, char const *subcs_name, fr_dict_attr_t const *da)
Define a values for Auth-Type attributes by the sections present in a virtual-server.
unlang_action_t virtual_server_push(request_t *request, CONF_SECTION *server_cs, bool top_frame)
Set the request processing function.
void virtual_servers_thread_detach(void)
Free thread-specific data for all process modules and listeners.
static fr_cmd_table_t cmd_table[]
void virtual_server_process_debug(void)
Print all the loaded process module instances.
CONF_SECTION * virtual_server_cs(virtual_server_t const *vs)
Return the configuration section for a virtual server.
fr_dict_t const * virtual_server_dict_by_cs(CONF_SECTION const *server_cs)
Return the namespace for the virtual server specified by a config section.
int virtual_servers_init(void)
Performs global initialisation for the virtual server code.
static fr_rb_tree_t * listen_addr_root
void virtual_server_listen_debug(void)
Print all the loaded listener instances.
fr_log_t * log
log destination
static int virtual_server_push_finally(request_t *request, virtual_server_t const *vs, bool *top_frame)
Push a finally section onto the stack.
static int define_server_attrs(CONF_SECTION *cs, fr_dict_t *dict, fr_dict_attr_t *parent, fr_dict_attr_t const *root)
static int8_t listen_addr_cmp(void const *one, void const *two)
Compare listeners by app_io_addr.
static module_list_t * proto_modules
List of proto modules we've loaded.
static int _virtual_servers_atexit(UNUSED void *uctx)
static int listen_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
int virtual_servers_instantiate(void)
Instantiate all the virtual servers.
module_instance_t * proto_mi
The proto_* module for a listen section.
void ** finally_by_packet_type
Finalise instruction by packet type.
static void server_signal_remove_log_destination(request_t *request, UNUSED fr_signal_t action, void *uctx)
virtual_server_t const * virtual_server_by_child(CONF_ITEM const *ci)
Find a virtual server using one of its sections.
int virtual_servers_free(void)
static int namespace_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
static int add_compile_list(virtual_server_t *vs, CONF_SECTION *cs, virtual_server_compile_t const *compile_list, char const *name)
static unlang_action_t server_remove_log_destination(UNUSED rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx)
int virtual_servers_thread_instantiate(TALLOC_CTX *ctx, fr_event_list_t *el)
Perform thread instantiation for all process modules and listeners.
static int cmd_show_server_list(FILE *fp, UNUSED FILE *fp_err, UNUSED void *ctx, UNUSED fr_cmd_info_t const *info)
static int define_server_values(CONF_SECTION *cs, fr_dict_attr_t *parent)
char const * log_name
name of log destination
virtual_server_listen_t ** listeners
Listeners in this virtual server.
section_name_t const * section
Identifier for the section.
size_t offset
where the CONF_SECTION pointer is written
struct virtual_server_s virtual_server_t
section_name_t const ** methods
list of auxilliary module methods which are allowed in if the main name doesn't match.
Processing sections which are allowed in this virtual server.