The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Enumerations
call_env.h File Reference

Structures and functions for handling call environments. More...

#include "lib/util/value.h"
#include <freeradius-devel/util/dlist.h>
#include <freeradius-devel/unlang/action.h>
#include <freeradius-devel/server/cf_parse.h>
#include <freeradius-devel/server/dl_module.h>
#include <freeradius-devel/server/request.h>
#include <freeradius-devel/server/tmpl.h>
+ Include dependency graph for call_env.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  call_env_method_s
 
struct  call_env_parser_s
 Per method call config. More...
 
union  call_env_parser_s.__unnamed90__
 
struct  call_env_parser_s.__unnamed90__.pair
 
struct  call_env_parser_s.__unnamed90__.pair.parsed
 
struct  call_env_parser_s.__unnamed90__.section
 
struct  call_env_s
 Structure containing both a talloc pool, a list of parsed call_env_pairs. More...
 

Macros

#define CALL_ENV_FLAGS(_cast_type, _flags, _struct, _field)
 
#define CALL_ENV_PARSE_TYPE(_s, _f)
 Where we're specifying a parsing phase output field, determine its type. More...
 
#define CALL_ENV_TERMINATOR   { NULL }
 
#define FR_CALL_ENV_CONCAT(_c, _ct)
 Only FR_TYPE_STRING and FR_TYPE_OCTETS can be concatenated. More...
 
#define FR_CALL_ENV_DST_SIZE(_s, _f)
 
#define FR_CALL_ENV_DST_TYPE(_s, _f)
 Mapping from field types to destination type enum. More...
 
#define FR_CALL_ENV_METHOD_OUT(_inst)
 Helper macro for populating the size/type fields of a call_env_method_t from the output structure type. More...
 
#define FR_CALL_ENV_MULTI(_s, _f)
 Derive whether multi conf pairs are allowed from target field type. More...
 
#define FR_CALL_ENV_OFFSET(_name, _cast_type, _flags, _struct, _field)
 Specify a call_env_parser_t which writes out runtime results to the specified field. More...
 
#define FR_CALL_ENV_PARSE_OFFSET(_name, _cast_type, _flags, _struct, _field, _parse_field)
 Specify a call_env_parser_t which writes out runtime results and the result of the parsing phase to the fields specified. More...
 
#define FR_CALL_ENV_PARSE_ONLY_OFFSET(_name, _cast_type, _flags, _struct, _parse_field)
 Specify a call_env_parser_t which writes out the result of the parsing phase to the field specified. More...
 
#define FR_CALL_ENV_RESULT_TYPE_NAME(_s, _f)
 
#define FR_CALL_ENV_SINGLE(_s, _f, _c)
 Derive whether tmpl can only emit a single box. More...
 
#define FR_CALL_ENV_SUBSECTION(_name, _ident2, _flags, _subcs)
 Specify a call_env_parser_t which defines a nested subsection. More...
 
#define FR_CALL_ENV_SUBSECTION_FUNC(_name, _ident2, _flags, _func)
 Specify a call_env_parser_t which parses a subsection using a callback function. More...
 

Typedefs

typedef void _mismatch_flags
 Dummy type used to indicate bad flags. More...
 
typedef struct call_env_method_s call_env_method_t
 
typedef int(* call_env_parse_pair_t) (TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, char const *section_name1, char const *section_name2, void const *data, call_env_parser_t const *rule)
 Callback for performing custom parsing of a CONF_PAIR. More...
 
typedef int(* call_env_parse_section_t) (TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, char const *section_name1, char const *section_name2, void const *data, call_env_parser_t const *rule)
 Callback for performing custom parsing of a CONF_SECTION. More...
 
typedef struct call_env_parsed_s call_env_parsed_t
 
typedef struct call_env_parser_s call_env_parser_t
 
typedef struct call_env_s call_env_t
 

Enumerations

enum  call_env_flags_t {
  CALL_ENV_FLAG_NONE = 0 ,
  CALL_ENV_FLAG_REQUIRED = 1 ,
  CALL_ENV_FLAG_CONCAT = (1 << 1) ,
  CALL_ENV_FLAG_SINGLE = (1 << 2) ,
  CALL_ENV_FLAG_MULTI = (1 << 3) ,
  CALL_ENV_FLAG_NULLABLE = (1 << 4) ,
  CALL_ENV_FLAG_FORCE_QUOTE = (1 << 5) ,
  CALL_ENV_FLAG_PARSE_ONLY = (1 << 6) ,
  CALL_ENV_FLAG_ATTRIBUTE = (1 << 7) ,
  CALL_ENV_FLAG_SUBSECTION = (1 << 8) ,
  CALL_ENV_FLAG_PARSE_MISSING = (1 << 9) ,
  CALL_ENV_FLAG_SECRET = (1 << 10)
}
 
enum  call_env_parse_type_t {
  CALL_ENV_PARSE_TYPE_TMPL = 1 ,
  CALL_ENV_PARSE_TYPE_VALUE_BOX ,
  CALL_ENV_PARSE_TYPE_VOID
}
 What type of structure is produced by the parsing phase. More...
 
enum  call_env_result_t {
  CALL_ENV_SUCCESS = 0 ,
  CALL_ENV_MISSING = -1 ,
  CALL_ENV_INVALID = -2
}
 
enum  call_env_result_type_t {
  CALL_ENV_RESULT_TYPE_VALUE_BOX = 1 ,
  CALL_ENV_RESULT_TYPE_VALUE_BOX_LIST
}
 What type of structure is produced by the evaluation phase. More...
 

#conf_parser_t flags checks

#define call_env_attribute(_flags)   ((_flags) & CALL_ENV_FLAG_ATTRIBUTE)
 
#define call_env_concat(_flags)   ((_flags) & CALL_ENV_FLAG_CONCAT)
 
#define call_env_force_quote(_flags)   ((_flags) & CALL_ENV_FLAG_FORCE_QUOTE)
 
#define call_env_is_subsection(_flags)   ((_flags) & CALL_ENV_FLAG_SUBSECTION)
 
#define call_env_multi(_flags)   ((_flags) & CALL_ENV_FLAG_MULTI)
 
#define call_env_nullable(_flags)   ((_flags) & CALL_ENV_FLAG_NULLABLE)
 
#define call_env_pair_flags(_flags)   (((_flags) & (CALL_ENV_FLAG_SUBSECTION)) == 0)
 Evaluates to true if flags are valid for a pair. More...
 
#define call_env_parse_missing(_flags)   ((_flags) & CALL_ENV_FLAG_PARSE_MISSING)
 
#define call_env_parse_only(_flags)   ((_flags) & CALL_ENV_FLAG_PARSE_ONLY)
 
#define call_env_required(_flags)   ((_flags) & CALL_ENV_FLAG_REQUIRED)
 
#define call_env_secret(_flags)   ((_flags) & CALL_ENV_FLAG_SECRET)
 
#define call_env_single(_flags)   ((_flags) & CALL_ENV_FLAG_SINGLE)
 
#define call_env_subsection_flags(_flags)   (((_flags) & (CALL_ENV_FLAG_CONCAT | CALL_ENV_FLAG_SINGLE | CALL_ENV_FLAG_MULTI | CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_FORCE_QUOTE | CALL_ENV_FLAG_ATTRIBUTE | CALL_ENV_FLAG_PARSE_MISSING)) == 0)
 Evaluates to true if flags are valid for a subsection. More...
 

Expand a call_env_t

unlang_action_t call_env_expand (TALLOC_CTX *ctx, request_t *request, call_env_result_t *result, void **env_data, call_env_t const *call_env)
 Initialise the expansion of a call environment. More...
 

Functions that implement standard parsing behaviour which can be called by callbacks

int call_env_parse_pair (TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, char const *section_name1, char const *section_name2, void const *data, call_env_parser_t const *rule)
 

Functions to be used by the section callbacks to add parsed data.

call_env_parsed_tcall_env_parsed_add (TALLOC_CTX *ctx, call_env_parsed_head_t *head, call_env_parser_t const *rule)
 Allocate a new call_env_parsed_t structure and add it to the list of parsed call envs. More...
 
void call_env_parsed_free (call_env_parsed_head_t *parsed, call_env_parsed_t *ptr)
 Remove a call_env_parsed_t from the list of parsed call envs. More...
 
void call_env_parsed_set_data (call_env_parsed_t *parsed, void const *data)
 Assign data to a call_env_parsed_t. More...
 
void call_env_parsed_set_multi_index (call_env_parsed_t *parsed, size_t count, size_t index)
 Assign a count and index to a call_env_parsed_t. More...
 
void call_env_parsed_set_tmpl (call_env_parsed_t *parsed, tmpl_t const *tmpl)
 Assign a tmpl to a call_env_parsed_t. More...
 
void call_env_parsed_set_value (call_env_parsed_t *parsed, fr_value_box_t const *vb)
 Assign a value box to a call_env_parsed_t. More...
 

Allocate a new call env

call_env_tcall_env_alloc (TALLOC_CTX *ctx, char const *name, call_env_method_t const *call_env_method, tmpl_rules_t const *rules, CONF_SECTION *cs, char const *section_name1, char const *section_name2, void const *data))
 Given a call_env_method, parse all call_env_pair_t in the context of a specific call to an xlat or module method. More...
 

Detailed Description

Structures and functions for handling call environments.

Id
66b26b226152c7e6f6263e4a974dfe25eeb95b82

Definition in file call_env.h.


Data Structure Documentation

◆ call_env_method_s

struct call_env_method_s

Definition at line 220 of file call_env.h.

+ Collaboration diagram for call_env_method_s:
Data Fields
call_env_parser_t const * env Parsing rules for call method env.
size_t inst_size Size of per call env.
char const * inst_type Type of per call env.

◆ call_env_parser_s

struct call_env_parser_s

Per method call config.

Similar to a conf_parser_t used to hold details of conf pairs which are evaluated per call for each module method / xlat.

This allows the conf pairs to be evaluated within the appropriate context and use the appropriate dictionaries for where the module is in use.

Definition at line 171 of file call_env.h.

Data Fields
union call_env_parser_s __unnamed__
call_env_flags_t flags Flags controlling parser behaviour.
char const * name Of conf pair to pass to tmpl_tokenizer.
void const * uctx User context for callback functions.

◆ call_env_parser_s.__unnamed90__

union call_env_parser_s.__unnamed90__

Definition at line 175 of file call_env.h.

Data Fields
__unnamed90__ pair
__unnamed90__ section

◆ call_env_parser_s.__unnamed90__.pair

struct call_env_parser_s.__unnamed90__.pair

Definition at line 176 of file call_env.h.

Data Fields
fr_type_t cast_type To cast boxes to. Also contains flags controlling parser behaviour.
char const * dflt Default string to pass to the tmpl_tokenizer if no CONF_PAIR found.
fr_token_t dflt_quote Quoting for the default string.
tmpl_escape_t escape Escape method to use when evaluating tmpl_t.
call_env_parse_pair_t func Callback for parsing a CONF_PAIR.
fr_value_box_safe_for_t literals_safe_for What safe_for value to assign any literals that are arguments to the tmpl_t.
size_t offset Where to write the result of evaluating the tmpl_t produced in the parsing phase.
pair parsed
size_t size Size of structure boxes will be written to.
call_env_result_type_t type Type of structure boxes will be written to.
char const * type_name Name of structure type boxes will be written to.

◆ call_env_parser_s.__unnamed90__.pair.parsed

struct call_env_parser_s.__unnamed90__.pair.parsed

Definition at line 189 of file call_env.h.

Data Fields
ssize_t offset Where to write the result of the parsing phase.

This is usually a tmpl_t, but could be other things when a callback function is used to parse the CONF_SECTION or CONF_PAIR.

call_env_parse_type_t type What type of output the parsing phase is expected to produce.

◆ call_env_parser_s.__unnamed90__.section

struct call_env_parser_s.__unnamed90__.section

Definition at line 201 of file call_env.h.

Data Fields
call_env_parse_section_t func Callback for parsing CONF_SECTION.
char const * ident2 Second identifier for a section.
call_env_parser_t const * subcs Nested definitions for subsection.

◆ call_env_s

struct call_env_s

Structure containing both a talloc pool, a list of parsed call_env_pairs.

Definition at line 228 of file call_env.h.

+ Collaboration diagram for call_env_s:
Data Fields
call_env_method_t const * method The method this call env is for.
call_env_parsed_head_t parsed The per call parsed call environment.

Macro Definition Documentation

◆ call_env_attribute

#define call_env_attribute (   _flags)    ((_flags) & CALL_ENV_FLAG_ATTRIBUTE)

Definition at line 123 of file call_env.h.

◆ call_env_concat

#define call_env_concat (   _flags)    ((_flags) & CALL_ENV_FLAG_CONCAT)

Definition at line 111 of file call_env.h.

◆ CALL_ENV_FLAGS

#define CALL_ENV_FLAGS (   _cast_type,
  _flags,
  _struct,
  _field 
)
Value:
(FR_CALL_ENV_CONCAT(((_flags) & CALL_ENV_FLAG_CONCAT), _cast_type) | \
FR_CALL_ENV_SINGLE(_struct, _field, ((_flags) & CALL_ENV_FLAG_CONCAT)) | \
FR_CALL_ENV_MULTI(_struct, _field) |\
((_flags) & ~CALL_ENV_FLAG_CONCAT)) \
#define FR_CALL_ENV_CONCAT(_c, _ct)
Only FR_TYPE_STRING and FR_TYPE_OCTETS can be concatenated.
Definition: call_env.h:267
@ CALL_ENV_FLAG_CONCAT
If the tmpl produced multiple boxes they should be concatenated.
Definition: call_env.h:74

Definition at line 302 of file call_env.h.

◆ call_env_force_quote

#define call_env_force_quote (   _flags)    ((_flags) & CALL_ENV_FLAG_FORCE_QUOTE)

Definition at line 119 of file call_env.h.

◆ call_env_is_subsection

#define call_env_is_subsection (   _flags)    ((_flags) & CALL_ENV_FLAG_SUBSECTION)

Definition at line 125 of file call_env.h.

◆ call_env_multi

#define call_env_multi (   _flags)    ((_flags) & CALL_ENV_FLAG_MULTI)

Definition at line 115 of file call_env.h.

◆ call_env_nullable

#define call_env_nullable (   _flags)    ((_flags) & CALL_ENV_FLAG_NULLABLE)

Definition at line 117 of file call_env.h.

◆ call_env_pair_flags

#define call_env_pair_flags (   _flags)    (((_flags) & (CALL_ENV_FLAG_SUBSECTION)) == 0)

Evaluates to true if flags are valid for a pair.

Parameters
[in]_flagsto evaluate

Definition at line 101 of file call_env.h.

◆ call_env_parse_missing

#define call_env_parse_missing (   _flags)    ((_flags) & CALL_ENV_FLAG_PARSE_MISSING)

Definition at line 127 of file call_env.h.

◆ call_env_parse_only

#define call_env_parse_only (   _flags)    ((_flags) & CALL_ENV_FLAG_PARSE_ONLY)

Definition at line 121 of file call_env.h.

◆ CALL_ENV_PARSE_TYPE

#define CALL_ENV_PARSE_TYPE (   _s,
  _f 
)
Value:
_Generic((((_s *)NULL)->_f), \
)
@ CALL_ENV_PARSE_TYPE_VALUE_BOX
Output of the parsing phase is a single value box (static data).
Definition: call_env.h:59
@ CALL_ENV_PARSE_TYPE_TMPL
Output of the parsing phase is a tmpl_t.
Definition: call_env.h:58
@ CALL_ENV_PARSE_TYPE_VOID
Output of the parsing phase is undefined (a custom structure).
Definition: call_env.h:60

Where we're specifying a parsing phase output field, determine its type.

Definition at line 235 of file call_env.h.

◆ call_env_required

#define call_env_required (   _flags)    ((_flags) & CALL_ENV_FLAG_REQUIRED)

Definition at line 109 of file call_env.h.

◆ call_env_secret

#define call_env_secret (   _flags)    ((_flags) & CALL_ENV_FLAG_SECRET)

Definition at line 129 of file call_env.h.

◆ call_env_single

#define call_env_single (   _flags)    ((_flags) & CALL_ENV_FLAG_SINGLE)

Definition at line 113 of file call_env.h.

◆ call_env_subsection_flags

Evaluates to true if flags are valid for a subsection.

Parameters
[in]_flagsto evaluate

Definition at line 107 of file call_env.h.

◆ CALL_ENV_TERMINATOR

#define CALL_ENV_TERMINATOR   { NULL }

Definition at line 212 of file call_env.h.

◆ FR_CALL_ENV_CONCAT

#define FR_CALL_ENV_CONCAT (   _c,
  _ct 
)
Value:
__builtin_choose_expr(_ct == FR_TYPE_STRING, _c, \
__builtin_choose_expr(_ct == FR_TYPE_OCTETS, _c, \
__builtin_choose_expr(_c, (void)0, false)))
@ FR_TYPE_STRING
String of printable characters.
Definition: merged_model.c:83
@ FR_TYPE_OCTETS
Raw octets.
Definition: merged_model.c:84

Only FR_TYPE_STRING and FR_TYPE_OCTETS can be concatenated.

Definition at line 267 of file call_env.h.

◆ FR_CALL_ENV_DST_SIZE

#define FR_CALL_ENV_DST_SIZE (   _s,
  _f 
)
Value:
_Generic((((_s *)NULL)->_f), \
fr_value_box_list_t : sizeof(fr_value_box_list_t), \
fr_value_box_list_t * : sizeof(fr_value_box_list_t), \
default : 0 \
)

Definition at line 282 of file call_env.h.

◆ FR_CALL_ENV_DST_TYPE

#define FR_CALL_ENV_DST_TYPE (   _s,
  _f 
)
Value:
_Generic((((_s *)NULL)->_f), \
fr_value_box_list_t : CALL_ENV_RESULT_TYPE_VALUE_BOX_LIST, \
fr_value_box_list_t * : CALL_ENV_RESULT_TYPE_VALUE_BOX_LIST \
)
@ CALL_ENV_RESULT_TYPE_VALUE_BOX_LIST
Output of the evaluation phase is a list of value boxes.
Definition: call_env.h:67
@ CALL_ENV_RESULT_TYPE_VALUE_BOX
Output of the evaluation phase is a single value box.
Definition: call_env.h:66

Mapping from field types to destination type enum.

Definition at line 274 of file call_env.h.

◆ FR_CALL_ENV_METHOD_OUT

#define FR_CALL_ENV_METHOD_OUT (   _inst)
Value:
.inst_size = sizeof(_inst), \
.inst_type = STRINGIFY(_inst) \
#define STRINGIFY(x)
Definition: build.h:195

Helper macro for populating the size/type fields of a call_env_method_t from the output structure type.

Definition at line 216 of file call_env.h.

◆ FR_CALL_ENV_MULTI

#define FR_CALL_ENV_MULTI (   _s,
  _f 
)
Value:
_Generic((((_s *)NULL)->_f), \
fr_value_box_list_t : CALL_ENV_FLAG_NONE, \
fr_value_box_list_t * : CALL_ENV_FLAG_MULTI \
)
@ CALL_ENV_FLAG_NONE
Definition: call_env.h:72
@ CALL_ENV_FLAG_MULTI
Multiple instances of the conf pairs are allowed.
Definition: call_env.h:76

Derive whether multi conf pairs are allowed from target field type.

Definition at line 257 of file call_env.h.

◆ FR_CALL_ENV_OFFSET

#define FR_CALL_ENV_OFFSET (   _name,
  _cast_type,
  _flags,
  _struct,
  _field 
)
Value:
.name = _name, \
.flags = CALL_ENV_FLAGS(_cast_type, _flags, _struct, _field), \
.pair = { \
.cast_type = _cast_type, \
.type = FR_CALL_ENV_DST_TYPE(_struct, _field), \
.size = FR_CALL_ENV_DST_SIZE(_struct, _field), \
.type_name = FR_CALL_ENV_RESULT_TYPE_NAME(_struct, _field), \
.offset = offsetof(_struct, _field), \
.parsed = { \
.offset = -1, \
} \
}
#define CALL_ENV_FLAGS(_cast_type, _flags, _struct, _field)
Definition: call_env.h:302
#define FR_CALL_ENV_RESULT_TYPE_NAME(_s, _f)
Definition: call_env.h:291
#define FR_CALL_ENV_DST_TYPE(_s, _f)
Mapping from field types to destination type enum.
Definition: call_env.h:274
#define FR_CALL_ENV_DST_SIZE(_s, _f)
Definition: call_env.h:282

Specify a call_env_parser_t which writes out runtime results to the specified field.

Parameters
[in]_nameof the conf pair to parse.
[in]_cast_typeCast any value boxes produced to this type.
[in]_flagscontrolling parser behaviour.
[in]_structwhich contains the field to write the result of the evaluation phase to.
[in]_fieldwhere to write the result.

Definition at line 316 of file call_env.h.

◆ FR_CALL_ENV_PARSE_OFFSET

#define FR_CALL_ENV_PARSE_OFFSET (   _name,
  _cast_type,
  _flags,
  _struct,
  _field,
  _parse_field 
)
Value:
.name = _name, \
.flags = CALL_ENV_FLAGS(_cast_type, _flags, _struct, _field), \
.pair = { \
.cast_type = _cast_type, \
.type = FR_CALL_ENV_DST_TYPE(_struct, _field), \
.size = FR_CALL_ENV_DST_SIZE(_struct, _field), \
.type_name = FR_CALL_ENV_RESULT_TYPE_NAME(_struct, _field), \
.offset = offsetof(_struct, _field), \
.parsed = { \
.offset = offsetof(_struct, _parse_field), \
.type = CALL_ENV_PARSE_TYPE(_struct, _parse_field) \
} \
}
#define CALL_ENV_PARSE_TYPE(_s, _f)
Where we're specifying a parsing phase output field, determine its type.
Definition: call_env.h:235

Specify a call_env_parser_t which writes out runtime results and the result of the parsing phase to the fields specified.

Parameters
[in]_nameof the conf pair to parse.
[in]_cast_typeCast any value boxes produced to this type.
[in]_flagscontrolling parser behaviour.
[in]_structwhich contains the field to write the result of the evaluation phase to.
[in]_fieldwhere to write the result.
[in]_parse_fieldwhere to write the result of the parsing phase. This must be a field in the specified _struct.

Definition at line 341 of file call_env.h.

◆ FR_CALL_ENV_PARSE_ONLY_OFFSET

#define FR_CALL_ENV_PARSE_ONLY_OFFSET (   _name,
  _cast_type,
  _flags,
  _struct,
  _parse_field 
)
Value:
.name = _name, \
.flags = (_flags) | CALL_ENV_FLAG_PARSE_ONLY, \
.pair = { \
.cast_type = _cast_type, \
.parsed = { \
.offset = offsetof(_struct, _parse_field), \
.type = CALL_ENV_PARSE_TYPE(_struct, _parse_field) \
} \
}
@ CALL_ENV_FLAG_PARSE_ONLY
The result of parsing will not be evaluated at runtime.
Definition: call_env.h:83

Specify a call_env_parser_t which writes out the result of the parsing phase to the field specified.

Parameters
[in]_nameof the conf pair to parse.
[in]_cast_typeSets the cast used by the tmpl.
[in]_flagscontrolling parser behaviour.
[in]_structwhich contains the field to write the result of the evaluation phase to.
[in]_parse_fieldwhere to write the result of the parsing phase. This must be a field in the specified _struct.

Definition at line 365 of file call_env.h.

◆ FR_CALL_ENV_RESULT_TYPE_NAME

#define FR_CALL_ENV_RESULT_TYPE_NAME (   _s,
  _f 
)
Value:
_Generic((((_s *)NULL)->_f), \
fr_value_box_t : "fr_value_box_t", \
fr_value_box_t * : "fr_value_box_t", \
fr_value_box_list_t : "fr_value_box_list_t", \
fr_value_box_list_t * : "fr_value_box_list_t", \
default : NULL \
)

Definition at line 291 of file call_env.h.

◆ FR_CALL_ENV_SINGLE

#define FR_CALL_ENV_SINGLE (   _s,
  _f,
  _c 
)
Value:
_Generic((((_s *)NULL)->_f), \
fr_value_box_t : __builtin_choose_expr(_c, CALL_ENV_FLAG_NONE, CALL_ENV_FLAG_SINGLE), \
fr_value_box_t * : __builtin_choose_expr(_c, CALL_ENV_FLAG_NONE, CALL_ENV_FLAG_SINGLE), \
fr_value_box_list_t : CALL_ENV_FLAG_NONE, \
fr_value_box_list_t * : CALL_ENV_FLAG_NONE, \
default : CALL_ENV_FLAG_NONE \
)
@ CALL_ENV_FLAG_SINGLE
If the tmpl produces more than one box this is an error.
Definition: call_env.h:75

Derive whether tmpl can only emit a single box.

Definition at line 246 of file call_env.h.

◆ FR_CALL_ENV_SUBSECTION

#define FR_CALL_ENV_SUBSECTION (   _name,
  _ident2,
  _flags,
  _subcs 
)
Value:
.name = _name, \
.flags = CALL_ENV_FLAG_SUBSECTION | (_flags), \
.section = { \
.ident2 = _ident2, \
.subcs = _subcs, \
}
@ CALL_ENV_FLAG_SUBSECTION
This is a subsection.
Definition: call_env.h:85

Specify a call_env_parser_t which defines a nested subsection.

Definition at line 378 of file call_env.h.

◆ FR_CALL_ENV_SUBSECTION_FUNC

#define FR_CALL_ENV_SUBSECTION_FUNC (   _name,
  _ident2,
  _flags,
  _func 
)
Value:
.name = _name, \
.flags = CALL_ENV_FLAG_SUBSECTION | (_flags), \
.section = { \
.ident2 = _ident2, \
.func = _func \
}

Specify a call_env_parser_t which parses a subsection using a callback function.

Definition at line 388 of file call_env.h.

Typedef Documentation

◆ _mismatch_flags

typedef void _mismatch_flags

Dummy type used to indicate bad flags.

Definition at line 300 of file call_env.h.

◆ call_env_method_t

Definition at line 1 of file call_env.h.

◆ call_env_parse_pair_t

typedef int(* call_env_parse_pair_t) (TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, char const *section_name1, char const *section_name2, void const *data, call_env_parser_t const *rule)

Callback for performing custom parsing of a CONF_PAIR.

Parameters
[in]ctxto allocate any data in.
[out]outWhere to write the result of parsing.
[in]t_ruleswe're parsing attributes with. Contains the default dictionary and nested 'caller' tmpl_rules_t.
[in]ciThe CONF_SECTION or CONF_PAIR to parse.
[in]datamodule / xlat instance data of the module / xlat allocating this call_env
[in]ruleParse rules - How the CONF_PAIR or CONF_SECTION should be converted.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 144 of file call_env.h.

◆ call_env_parse_section_t

typedef int(* call_env_parse_section_t) (TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, char const *section_name1, char const *section_name2, void const *data, call_env_parser_t const *rule)

Callback for performing custom parsing of a CONF_SECTION.

The callback function is expected to call call_env_parsed_add to allocate a new call_env_parsed_t, and either call_env_parsed_set_tmpl, or call_env_parsed_set_data to populate the call env_parsed_t structure.

Parameters
[in]ctxto allocate any data in.
[out]outWhere to write the result of parsing.
[in]t_ruleswe're parsing attributes with. Contains the default dictionary and nested 'caller' tmpl_rules_t.
[in]ciThe CONF_SECTION or CONF_PAIR to parse.
[in]ruleParse rules - How the CONF_PAIR or CONF_SECTION should be converted.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 161 of file call_env.h.

◆ call_env_parsed_t

Definition at line 1 of file call_env.h.

◆ call_env_parser_t

Definition at line 1 of file call_env.h.

◆ call_env_t

typedef struct call_env_s call_env_t

Definition at line 1 of file call_env.h.

Enumeration Type Documentation

◆ call_env_flags_t

Enumerator
CALL_ENV_FLAG_NONE 
CALL_ENV_FLAG_REQUIRED 

Associated conf pair or section is required.

CALL_ENV_FLAG_CONCAT 

If the tmpl produced multiple boxes they should be concatenated.

CALL_ENV_FLAG_SINGLE 

If the tmpl produces more than one box this is an error.

CALL_ENV_FLAG_MULTI 

Multiple instances of the conf pairs are allowed.

Resulting boxes are stored in an array - one entry per conf pair.

CALL_ENV_FLAG_NULLABLE 

Tmpl expansions are allowed to produce no output.

CALL_ENV_FLAG_FORCE_QUOTE 

Force quote method when parsing tmpl.

This is for corner cases where tmpls should always be parsed with a particular quoting regardless of how they are in the config file. E.g. the program option of rlm_exec should always be parsed as T_BACK_QUOTED_STRING.

CALL_ENV_FLAG_PARSE_ONLY 

The result of parsing will not be evaluated at runtime.

CALL_ENV_FLAG_ATTRIBUTE 

Tmpl must contain an attribute reference.

CALL_ENV_FLAG_SUBSECTION 

This is a subsection.

CALL_ENV_FLAG_PARSE_MISSING 

If this subsection is missing, still parse it.

Useful for cases where there is a callback which always needs to be run to set up required data structures.

CALL_ENV_FLAG_SECRET 

The value is a secret, and should not be logged.

Definition at line 71 of file call_env.h.

◆ call_env_parse_type_t

What type of structure is produced by the parsing phase.

Enumerator
CALL_ENV_PARSE_TYPE_TMPL 

Output of the parsing phase is a tmpl_t.

CALL_ENV_PARSE_TYPE_VALUE_BOX 

Output of the parsing phase is a single value box (static data).

CALL_ENV_PARSE_TYPE_VOID 

Output of the parsing phase is undefined (a custom structure).

Definition at line 57 of file call_env.h.

◆ call_env_result_t

Enumerator
CALL_ENV_SUCCESS 
CALL_ENV_MISSING 
CALL_ENV_INVALID 

Definition at line 49 of file call_env.h.

◆ call_env_result_type_t

What type of structure is produced by the evaluation phase.

Enumerator
CALL_ENV_RESULT_TYPE_VALUE_BOX 

Output of the evaluation phase is a single value box.

CALL_ENV_RESULT_TYPE_VALUE_BOX_LIST 

Output of the evaluation phase is a list of value boxes.

Definition at line 65 of file call_env.h.

Function Documentation

◆ call_env_alloc()

call_env_t* call_env_alloc ( TALLOC_CTX *  ctx,
char const *  name,
call_env_method_t const *  call_env_method,
tmpl_rules_t const *  t_rules,
CONF_SECTION cs,
char const *  section_name1,
char const *  section_name2,
void const *  data 
)

Given a call_env_method, parse all call_env_pair_t in the context of a specific call to an xlat or module method.

Parameters
[in]ctxto allocate the call_env_t in.
[in]nameModule name for error messages.
[in]call_env_methodcontaining the call_env_pair_t to evaluate against the specified CONF_SECTION.
[in]t_rulesthat control how call_env_pair_t are parsed.
[in]csto parse in the context of the call.
[in]datamodule / xlat instance data of the module / xlat allocating this call_env
Returns
  • A new call_env_t on success.
    • NULL on failure.

Definition at line 718 of file call_env.c.

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

◆ call_env_expand()

unlang_action_t call_env_expand ( TALLOC_CTX *  ctx,
request_t request,
call_env_result_t env_result,
void **  env_data,
call_env_t const *  call_env 
)

Initialise the expansion of a call environment.

Parameters
[in]ctxin which to allocate destination structure for resulting value boxes.
[in]requestCurrent request.
[out]env_resultWhere to write the result of the callenv expansion. May be NULL
[in,out]env_dataWhere the destination structure should be created.
[in]call_envCall environment being expanded.

Definition at line 287 of file call_env.c.

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

◆ call_env_parse_pair()

int call_env_parse_pair ( TALLOC_CTX *  ctx,
void *  out,
tmpl_rules_t const *  t_rules,
CONF_ITEM ci,
char const *  section_name1,
char const *  section_name2,
void const *  data,
call_env_parser_t const *  rule 
)

◆ call_env_parsed_add()

call_env_parsed_t* call_env_parsed_add ( TALLOC_CTX *  ctx,
call_env_parsed_head_t *  head,
call_env_parser_t const *  rule 
)

Allocate a new call_env_parsed_t structure and add it to the list of parsed call envs.

Note
tmpl_t and void * should be allocated in the context of the call_env_parsed_t
Parameters
[in]ctxto allocate the new call_env_parsed_t in.
[out]headto add the new call_env_parsed_t to.
[in]ruleto base call_env_parsed_t around. MUST NOT BE THE RULE PASSED TO THE CALLBACK. The rule passed to the callback describes how to parse a subsection, but the subsection callback is adding rules describing how to parse its children.
Returns
The new call_env_parsed_t.

Definition at line 613 of file call_env.c.

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

◆ call_env_parsed_free()

void call_env_parsed_free ( call_env_parsed_head_t *  parsed,
call_env_parsed_t ptr 
)

Remove a call_env_parsed_t from the list of parsed call envs.

Note
Intended to be used by subsection callbacks to remove a call_env_parsed_t from the list of parsed call envs (typically on error).
Parameters
[in]parsedto remove parsed data from.
[in]ptrto remove.

Definition at line 700 of file call_env.c.

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

◆ call_env_parsed_set_data()

void call_env_parsed_set_data ( call_env_parsed_t parsed,
void const *  data 
)

Assign data to a call_env_parsed_t.

Note
Intended to be used by subsection callbacks to set arbitrary data to be written out to the result structure.
Parameters
[in]parsedto assign the tmpl to.
[in]datato assign.

Definition at line 670 of file call_env.c.

+ Here is the caller graph for this function:

◆ call_env_parsed_set_multi_index()

void call_env_parsed_set_multi_index ( call_env_parsed_t parsed,
size_t  count,
size_t  index 
)

Assign a count and index to a call_env_parsed_t.

Note
Intended to be used by subsection callbacks to indicate related call_env_parsed_t.
Parameters
[in]parsedto modify metadata of.
[in]countto assign.
[in]indexto assign.

Definition at line 685 of file call_env.c.

+ Here is the caller graph for this function:

◆ call_env_parsed_set_tmpl()

void call_env_parsed_set_tmpl ( call_env_parsed_t parsed,
tmpl_t const *  tmpl 
)

Assign a tmpl to a call_env_parsed_t.

Note
Intended to be used by subsection callbacks to add a tmpl to be evaluated during the call.
Parameters
[in]parsedto assign the tmpl to.
[in]tmplto assign.

Definition at line 642 of file call_env.c.

+ Here is the caller graph for this function:

◆ call_env_parsed_set_value()

void call_env_parsed_set_value ( call_env_parsed_t parsed,
fr_value_box_t const *  vb 
)

Assign a value box to a call_env_parsed_t.

Note
Intended to be used by subsection callbacks to set a static boxed value to be written out to the result structure.
Parameters
[in]parsedto assign the tmpl to.
[in]vbto assign.

Definition at line 656 of file call_env.c.

+ Here is the caller graph for this function: