The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Functions | Variables
cf_parse.h File Reference

API to parse internal format configuration items into native C types. More...

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/time.h>
#include <freeradius-devel/util/rb.h>
#include <freeradius-devel/util/table.h>
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/server/cf_util.h>
+ Include dependency graph for cf_parse.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cf_table_parse_ctx_t
 
struct  conf_parser_s
 Defines a CONF_PAIR to C data type mapping. More...
 
union  conf_parser_s.__unnamed54__
 Where to write status if FR_TYPE_IS_DEFAULT is set. More...
 
union  conf_parser_s.__unnamed56__
 
struct  conf_parser_s.__unnamed56__.__unnamed58__
 
struct  conf_parser_s.__unnamed56__.__unnamed60__
 

Macros

#define CF_FILE_CONFIG   (1 << 2)
 
#define CF_FILE_ERROR   (1)
 
#define CF_FILE_MODULE   (1 << 3)
 
#define CF_FILE_NONE   (0)
 
#define cf_section_rule_push(_cs, _rule)   _cf_section_rule_push(_cs, _rule, __FILE__, __LINE__)
 
#define cf_section_rules_push(_cs, _rule)   _cf_section_rules_push(_cs, _rule, __FILE__, __LINE__)
 
#define CONF_CTYPE_TO_FLAGS(_ct)
 
#define CONF_PARSER_PARTIAL_TERMINATOR
 
#define CONF_PARSER_TERMINATOR
 
#define FR_CONF_DEPRECATED(_name, _struct, _field)
 conf_parser_t entry which raises an error if a matching CONF_PAIR is found More...
 
#define FR_CONF_FLAG_CHECK(_type, _flags, _c_type, _ptr_or_offset)   _ptr_or_offset
 
#define FR_CONF_FUNC(_name, _type, _flags, _func, _dflt_func)
 conf_parser_t entry which doesn't fill in a pointer or offset, but relies on functions to record values More...
 
#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 More...
 
#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 More...
 
#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, recording if a default was used in <_field>_is_set More...
 
#define FR_CONF_OFFSET_SUBSECTION(_name, _flags, _struct, _field, _subcs)
 conf_parser_t which populates a sub-struct using a CONF_SECTION More...
 
#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 More...
 
#define FR_CONF_POINTER(_name, _type, _flags, _res_p)
 conf_parser_t which parses a single CONF_PAIR producing a single global result More...
 
#define FR_CONF_POINTER_IS_SET(_name, _type, _flags, _res_p)
 conf_parser_t which parses a single CONF_PAIR producing a single global result, recording if a default was used in <_res_p>_is_set More...
 
#define FR_CONF_SUBSECTION_ALLOC(_name, _type, _flags, _struct, _field, _subcs)
 A conf_parser_t multi-subsection. More...
 
#define FR_CONF_SUBSECTION_GLOBAL(_name, _flags, _subcs)
 conf_parser_t entry which runs conf_parser_t entries for a subsection without any output More...
 
#define FR_INTEGER_BOUND_CHECK(_name, _var, _op, _bound)   FR_INTEGER_COND_CHECK(_name, _var, (_var _op _bound), _bound)
 
#define FR_INTEGER_COND_CHECK(_name, _var, _cond, _new)
 
#define FR_ITEM_POINTER(_type, _res_p)   _type, FR_CONF_FLAG_CHECK((_type), 0, (_res_p), _res_p)
 
#define FR_SIZE_BOUND_CHECK(_name, _var, _op, _bound)   FR_SIZE_COND_CHECK(_name, _var, (_var _op _bound), _bound)
 
#define FR_SIZE_COND_CHECK(_name, _var, _cond, _new)
 
#define FR_TIME_DELTA_BOUND_CHECK(_name, _var, _op, _bound)
 
#define FR_TIME_DELTA_COND_CHECK(_name, _var, _cond, _new)
 

Typedefs

typedef int(* cf_dflt_t) (CONF_PAIR **out, void *parent, CONF_SECTION *cs, fr_token_t quote, conf_parser_t const *rule)
 Callback for producing dynamic defaults from 3rd party libraries. More...
 
typedef int(* cf_parse_t) (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 Callback for performing custom parsing of a CONF_SECTION or CONF_PAIR. More...
 
typedef struct conf_parser_s conf_parser_t
 

Functions

int _cf_section_rule_push (CONF_SECTION *cs, conf_parser_t const *rule, char const *filename, int lineno)
 Add a single rule to a CONF_SECTION. More...
 
int _cf_section_rules_push (CONF_SECTION *cs, conf_parser_t const *rules, char const *filename, int lineno)
 Add an array of parse rules to a CONF_SECTION. More...
 
void cf_pair_debug_log (CONF_SECTION const *cs, CONF_PAIR *cp, conf_parser_t const *rule)
 
int cf_pair_parse (TALLOC_CTX *ctx, CONF_SECTION *cs, char const *name, unsigned int type, void *data, char const *dflt, fr_token_t dflt_quote))
 Parses a CONF_PAIR into a C data type, with a default value. More...
 
int cf_pair_parse_value (TALLOC_CTX *ctx, void *out, void *base, CONF_ITEM *ci, conf_parser_t const *rule))
 
int cf_pair_to_value_box (TALLOC_CTX *ctx, fr_value_box_t *out, CONF_PAIR *cp, conf_parser_t const *rule))
 Parses a CONF_PAIR into a boxed value. More...
 
int cf_parse_gid (TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 
int cf_parse_uid (TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 
int cf_section_parse (TALLOC_CTX *ctx, void *base, CONF_SECTION *cs)
 Parse a configuration section into user-supplied variables. More...
 
int cf_section_parse_pass2 (void *base, CONF_SECTION *cs)
 Fixup xlat expansions and attributes. More...
 
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. More...
 
int cf_table_parse_int32 (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 int32_t (FR_TYPE_INT32) More...
 
int cf_table_parse_uint32 (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 int32_t (FR_TYPE_UINT32) More...
 

Variables

bool check_config
 

#conf_parser_t flags checks

#define fr_rule_deprecated(_rule)   ((_rule)->flags & CONF_FLAG_DEPRECATED)
 
#define fr_rule_dflt(_rule)   ((_rule)->dflt || (_rule)->dflt_func)
 
#define fr_rule_file_exists(_rule)   ((_rule)->flags & CONF_FLAG_FILE_EXISTS)
 
#define fr_rule_file_input(_rule)   ((_rule)->flags & CONF_FLAG_FILE_INPUT)
 
#define fr_rule_file_output(_rule)   ((_rule)->flags & CONF_FLAG_FILE_OUTPUT)
 
#define fr_rule_is_attribute(_rule)   ((_rule)->flags & CONF_FLAG_ATTRIBUTE)
 
#define fr_rule_is_set(_rule)   ((_rule)->flags & CONF_FLAG_IS_SET)
 
#define fr_rule_is_tmpl(_rule)   ((_rule)->flags & CONF_FLAG_TMPL)
 
#define fr_rule_is_xlat(_rule)   ((_rule)->flags & CONF_FLAG_XLAT)
 
#define fr_rule_multi(_rule)   ((_rule)->flags & CONF_FLAG_MULTI)
 
#define fr_rule_not_empty(_rule)   ((_rule)->flags & CONF_FLAG_NOT_EMPTY)
 
#define fr_rule_ok_missing(_rule)   ((_rule)->flags & CONF_FLAG_OK_MISSING)
 
#define fr_rule_required(_rule)   ((_rule)->flags & CONF_FLAG_REQUIRED)
 
#define fr_rule_secret(_rule)   ((_rule)->flags & CONF_FLAG_SECRET)
 

#conf_parser_t type flags

These flags should be or'd with another FR_TYPE_* value to create validation rules for the cf_pair_parse function.

enum  conf_parser_flags_t {
  CONF_FLAG_NONE = 0 ,
  CONF_FLAG_SUBSECTION = (1 << 1) ,
  CONF_FLAG_DEPRECATED = (1 << 10) ,
  CONF_FLAG_REQUIRED = (1 << 11) ,
  CONF_FLAG_ATTRIBUTE = (1 << 12) ,
  CONF_FLAG_SECRET = (1 << 13) ,
  CONF_FLAG_FILE_INPUT = (1 << 14) ,
  CONF_FLAG_FILE_OUTPUT = (1 << 15) ,
  CONF_FLAG_XLAT = (1 << 16) ,
  CONF_FLAG_TMPL = (1 << 17) ,
  CONF_FLAG_MULTI = (1 << 18) ,
  CONF_FLAG_NOT_EMPTY = (1 << 19) ,
  CONF_FLAG_FILE_EXISTS = (1 << 20) ,
  CONF_FLAG_IS_SET = (1 << 21) ,
  CONF_FLAG_OK_MISSING = (1 << 22) ,
  CONF_FLAG_HIDDEN = (1 << 23)
}
 

Detailed Description

API to parse internal format configuration items into native C types.

Id
b30974bcbe2a9ef4556bdcdd6b6b19db57ffff71

Definition in file cf_parse.h.


Data Structure Documentation

◆ cf_table_parse_ctx_t

struct cf_table_parse_ctx_t

Definition at line 622 of file cf_parse.h.

+ Collaboration diagram for cf_table_parse_ctx_t:
Data Fields
size_t * len
fr_table_num_sorted_t const * table

◆ conf_parser_s

struct conf_parser_s

Defines a CONF_PAIR to C data type mapping.

Is typically used to define mappings between module sections, and module instance structs. May also be used to set global configuration options.

Offset/data values should be set using FR_CONF_OFFSET or FR_CONF_POINTER.

Example with FR_CONF_OFFSET :

{ FR_CONF_OFFSET_TYPE_FLAGS("example", FR_TYPE_STRING | CONF_FLAG_NOT_EMPTY, 0, 0, example_instance_t, example), .dflt = "default_value" },
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:627
@ 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
Defines a CONF_PAIR to C data type mapping.
Definition: cf_parse.h:564
@ FR_TYPE_STRING
String of printable characters.
Definition: merged_model.c:83
static const conf_parser_t module_config[]
Definition: radwho.c:59

Example with FR_CONF_POINTER :

static conf_parser_t global_config[] = {
{ FR_CONF_POINTER("example", FR_TYPE_STRING | CONF_FLAG_NOT_EMPTY, 0, 0, 0, &my_global), .dflt = "default_value" },
}
#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
See also
FR_CONF_OFFSET
FR_CONF_POINTER
cf_section_parse
cf_pair_parse

Definition at line 564 of file cf_parse.h.

+ Collaboration diagram for conf_parser_s:
Data Fields
union conf_parser_s __unnamed__ Where to write status if FR_TYPE_IS_DEFAULT is set.
Note
Which field is used, is determined by whether data ptr is set.
union conf_parser_s __unnamed__
void * data Pointer to a static variable to write the parsed value to.
Note
Must be used exclusively to offset.
conf_parser_flags_t flags Flags which control parsing behaviour.
cf_parse_t func Override default parsing behaviour for the specified type with a custom parsing function.
char const * name1 Name of the CONF_ITEM to parse.
char const * name2 Second identifier for CONF_SECTION.
size_t offset Relative offset of field or structure to write the parsed value to.

When flags is set to CONF_FLAG_SUBSECTION, may be used to specify a base offset to add to all offsets contained within the subsection.

Note
Must be used exclusively to data.
cf_parse_t on_read Function to call as the item is being read, just after it has been allocated and initialized.
fr_token_t quote Quoting around the default value. Only used for templates.
fr_type_t type An fr_type_t value, controls the output type.
void const * uctx User data accessible by the cf_parse_t func.

Useful for building reusable functions.

◆ conf_parser_s.__unnamed54__

union conf_parser_s.__unnamed54__

Where to write status if FR_TYPE_IS_DEFAULT is set.

Note
Which field is used, is determined by whether data ptr is set.

Definition at line 595 of file cf_parse.h.

Data Fields
size_t is_set_offset If type contains FR_TYPE_IS_DEFAULT write status to bool.

at this address.

void * is_set_ptr If type contains FR_TYPE_IS_DEFAULT write status to ptr at this address.

◆ conf_parser_s.__unnamed56__

union conf_parser_s.__unnamed56__

Definition at line 602 of file cf_parse.h.

Data Fields
__unnamed56__ __unnamed__
__unnamed56__ __unnamed__

◆ conf_parser_s.__unnamed56__.__unnamed58__

struct conf_parser_s.__unnamed56__.__unnamed58__

Definition at line 603 of file cf_parse.h.

Data Fields
char const * dflt Default as it would appear in radiusd.conf.
cf_dflt_t dflt_func Function to produce dynamic defaults.

◆ conf_parser_s.__unnamed56__.__unnamed60__

struct conf_parser_s.__unnamed56__.__unnamed60__

Definition at line 609 of file cf_parse.h.

Data Fields
conf_parser_t const * subcs When CONF_FLAG_SUBSECTION is set, should be a pointer to the start of another array of conf_parser_t structs, forming the subsection.
size_t subcs_size If non-zero, allocate structs of this size to hold the parsed data.
char const * subcs_type Set a specific talloc type for subcs structures.

Macro Definition Documentation

◆ CF_FILE_CONFIG

#define CF_FILE_CONFIG   (1 << 2)

Definition at line 635 of file cf_parse.h.

◆ CF_FILE_ERROR

#define CF_FILE_ERROR   (1)

Definition at line 634 of file cf_parse.h.

◆ CF_FILE_MODULE

#define CF_FILE_MODULE   (1 << 3)

Definition at line 636 of file cf_parse.h.

◆ CF_FILE_NONE

#define CF_FILE_NONE   (0)

Definition at line 633 of file cf_parse.h.

◆ cf_section_rule_push

#define cf_section_rule_push (   _cs,
  _rule 
)    _cf_section_rule_push(_cs, _rule, __FILE__, __LINE__)

Definition at line 657 of file cf_parse.h.

◆ cf_section_rules_push

#define cf_section_rules_push (   _cs,
  _rule 
)    _cf_section_rules_push(_cs, _rule, __FILE__, __LINE__)

Definition at line 659 of file cf_parse.h.

◆ CONF_CTYPE_TO_FLAGS

#define CONF_CTYPE_TO_FLAGS (   _ct)

Definition at line 190 of file cf_parse.h.

◆ CONF_PARSER_PARTIAL_TERMINATOR

#define CONF_PARSER_PARTIAL_TERMINATOR
Value:
{ .name1 = NULL, .type = ~(UINT32_MAX - 1), \
.offset = 1, .data = NULL, .dflt = NULL, .quote = T_INVALID }
@ T_INVALID
Definition: token.h:39
static fr_slen_t data
Definition: value.h:1265

Definition at line 630 of file cf_parse.h.

◆ CONF_PARSER_TERMINATOR

#define CONF_PARSER_TERMINATOR
Value:
{ .name1 = NULL, .type = ~(UINT32_MAX - 1), \
.offset = 0, .data = NULL, .dflt = NULL, .quote = T_INVALID }

Definition at line 627 of file cf_parse.h.

◆ FR_CONF_DEPRECATED

#define FR_CONF_DEPRECATED (   _name,
  _struct,
  _field 
)
Value:
.name1 = _name, \
@ CONF_FLAG_DEPRECATED
If a matching CONF_PAIR is found, error out with a deprecated message.
Definition: cf_parse.h:403

conf_parser_t entry which raises an error if a matching CONF_PAIR is found

Parameters
[in]_nameof pair to search for.
[in]_structwhere the result was previously written.
[in]_fieldin the struct where the result was previously written.

Definition at line 385 of file cf_parse.h.

◆ FR_CONF_FLAG_CHECK

#define FR_CONF_FLAG_CHECK (   _type,
  _flags,
  _c_type,
  _ptr_or_offset 
)    _ptr_or_offset

Definition at line 187 of file cf_parse.h.

◆ FR_CONF_FUNC

#define FR_CONF_FUNC (   _name,
  _type,
  _flags,
  _func,
  _dflt_func 
)
Value:
.name1 = _name, \
.type = (_type), \
.flags = (_flags), \
.func = _func, \
.dflt_func = _dflt_func

conf_parser_t entry which doesn't fill in a pointer or offset, but relies on functions to record values

Parameters
[in]_namename of pair to search for.
[in]_typebase type to parse pair as.
[in]_flagsf lags controlling parsing behaviour.
[in]_functo use to record value.
[in]_dflt_functo use to get defaults from a 3rd party library.

Definition at line 361 of file cf_parse.h.

◆ FR_CONF_OFFSET

#define FR_CONF_OFFSET (   _name,
  _struct,
  _field 
)
Value:
FR_CTYPE_TO_TYPE((((_struct *)NULL)->_field)), \
CONF_CTYPE_TO_FLAGS((((_struct *)NULL)->_field)),\
_struct, _field)
#define CONF_CTYPE_TO_FLAGS(_ct)
Definition: cf_parse.h:190
#define FR_CTYPE_TO_TYPE(_ct)
Given a variable, return the equivalent FR_TYPE_* value.
Definition: types.h:385

conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct

Parameters
[in]_nameof the CONF_PAIR to search for.
[in]_structcontaining the field to write the result to.
[in]_fieldto write the result to.

Definition at line 268 of file cf_parse.h.

◆ FR_CONF_OFFSET_FLAGS

#define FR_CONF_OFFSET_FLAGS (   _name,
  _flags,
  _struct,
  _field 
)
Value:
FR_CTYPE_TO_TYPE((((_struct *)NULL)->_field)), \
(_flags) | CONF_CTYPE_TO_FLAGS((((_struct *)NULL)->_field)),\
_struct, _field)

conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct

This variant takes additional flags, and will add CONF_FLAG_MULTI automatically if the field is an array.

Parameters
[in]_nameof the CONF_PAIR to search for.
[in]_flagscontrolling parsing behaviour.
[in]_structcontaining the field to write the result to.
[in]_fieldto write the result to.

Definition at line 256 of file cf_parse.h.

◆ FR_CONF_OFFSET_IS_SET

#define FR_CONF_OFFSET_IS_SET (   _name,
  _type,
  _flags,
  _struct,
  _field 
)
Value:
.name1 = _name, \
.type = (_type), \
.flags = CONF_FLAG_IS_SET | (_flags), \
.offset = FR_CONF_FLAG_CHECK((_type), (_flags), &(((_struct *)NULL)->_field), offsetof(_struct, _field)), \
.is_set_offset = offsetof(_struct, _field ## _is_set)
#define FR_CONF_FLAG_CHECK(_type, _flags, _c_type, _ptr_or_offset)
Definition: cf_parse.h:187
@ CONF_FLAG_IS_SET
Write whether this config item was left as the default to is_set_offset or is_set_ptr.
Definition: cf_parse.h:424

conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct, recording if a default was used in <_field>_is_set

Parameters
[in]_nameof the CONF_PAIR to search for.
[in]_typeto parse the CONF_PAIR as.
[in]_flagscontrolling parsing behaviour.
[in]_structcontaining the field to write the result to.
[in]_fieldto write the result to.

Definition at line 282 of file cf_parse.h.

◆ FR_CONF_OFFSET_SUBSECTION

#define FR_CONF_OFFSET_SUBSECTION (   _name,
  _flags,
  _struct,
  _field,
  _subcs 
)
Value:
.name1 = _name, \
.flags = CONF_FLAG_SUBSECTION | (_flags), \
.offset = offsetof(_struct, _field), \
.subcs = _subcs
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition: cf_parse.h:399

conf_parser_t which populates a sub-struct using a CONF_SECTION

Parameters
[in]_nameof the CONF_SECTION to search for.
[in]_flagscontrolling parsing behaviour.
[in]_structcontaining the sub-struct to populate.
[in]_fieldcontaining the sub-struct to populate.
[in]_subcsCONF_SECTION to parse.

Definition at line 297 of file cf_parse.h.

◆ FR_CONF_OFFSET_TYPE_FLAGS

#define FR_CONF_OFFSET_TYPE_FLAGS (   _name,
  _type,
  _flags,
  _struct,
  _field 
)
Value:
.name1 = _name, \
.type = (_type), \
.flags = (_flags), \
.offset = FR_CONF_FLAG_CHECK((_type), (_flags), &(((_struct *)NULL)->_field), offsetof(_struct, _field))

conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct

This variant takes output type and flags manually, instead of determining them automatically.

Parameters
[in]_nameof the CONF_PAIR to search for.
[in]_typeto parse the CONF_PAIR as.
[in]_flagscontrolling parsing behaviour.
[in]_structcontaining the field to write the result to.
[in]_fieldto write the result to.

Definition at line 241 of file cf_parse.h.

◆ FR_CONF_POINTER

#define FR_CONF_POINTER (   _name,
  _type,
  _flags,
  _res_p 
)
Value:
.name1 = _name, \
.type = (_type), \
.flags = (_flags), \
.data = FR_CONF_FLAG_CHECK((_type), (_flags), (_res_p), _res_p)

conf_parser_t which parses a single CONF_PAIR producing a single global result

Parameters
[in]_nameof the CONF_PAIR to search for.
[in]_typeto parse the CONF_PAIR as.
[in]_flagscontrolling parsing behaviour.
[out]_res_ppointer to a global var, where the result will be written.

Definition at line 310 of file cf_parse.h.

◆ FR_CONF_POINTER_IS_SET

#define FR_CONF_POINTER_IS_SET (   _name,
  _type,
  _flags,
  _res_p 
)
Value:
.name1 = _name, \
.type = (_type), \
.flags = CONF_FLAG_IS_SET | (_flags), \
.data = FR_CONF_FLAG_CHECK((_type), (_flags), (_res_p), _res_p), \
.is_set_ptr = _res_p ## _is_set

conf_parser_t which parses a single CONF_PAIR producing a single global result, recording if a default was used in <_res_p>_is_set

Note
is set state is recorded in variable <_res_p>_is_set.
Parameters
[in]_nameof the CONF_PAIR to search for.
[in]_typeto parse the CONF_PAIR as.
[in]_flagscontrolling parsing behaviour.
[out]_res_ppointer to a global var, where the result will be written.

Definition at line 325 of file cf_parse.h.

◆ FR_CONF_SUBSECTION_ALLOC

#define FR_CONF_SUBSECTION_ALLOC (   _name,
  _type,
  _flags,
  _struct,
  _field,
  _subcs 
)
Value:
.name1 = _name, \
.type = (_type), \
.flags = (_flags), \
.offset = FR_CONF_FLAG_CHECK((_type), (_flags), &(((_struct *)NULL)->_field), offsetof(_struct, _field)), \
.subcs = _subcs, \
.subcs_size = sizeof(**(((_struct *)0)->_field))

A conf_parser_t multi-subsection.

Parse multiple instance of a subsection, allocating an array of structs to hold the result.

Parameters
[in]_namename of subsection to search for.
[in]_typethe output type.
[in]_flagsflags controlling parsing behaviour.
[in]_structinstance data struct.
[in]_fieldfield in instance data struct.
[in]_subcsconf_parser_t array to use to parse subsection data.

Definition at line 345 of file cf_parse.h.

◆ FR_CONF_SUBSECTION_GLOBAL

#define FR_CONF_SUBSECTION_GLOBAL (   _name,
  _flags,
  _subcs 
)
Value:
.name1 = _name, \
.flags = CONF_FLAG_SUBSECTION | (_flags), \
.subcs = _subcs

conf_parser_t entry which runs conf_parser_t entries for a subsection without any output

Parameters
[in]_nameof pair to search for.
[in]_flagsflags controlling parsing behaviour.
[in]_subcsto use to get defaults from a 3rd party library.

Definition at line 374 of file cf_parse.h.

◆ FR_INTEGER_BOUND_CHECK

#define FR_INTEGER_BOUND_CHECK (   _name,
  _var,
  _op,
  _bound 
)    FR_INTEGER_COND_CHECK(_name, _var, (_var _op _bound), _bound)

Definition at line 487 of file cf_parse.h.

◆ FR_INTEGER_COND_CHECK

#define FR_INTEGER_COND_CHECK (   _name,
  _var,
  _cond,
  _new 
)
Value:
do {\
if (!(_cond)) {\
WARN("Ignoring \"" _name " = %i\", forcing to \"" _name " = %i\"", _var, _new);\
_var = _new;\
}\
} while (0)

Definition at line 479 of file cf_parse.h.

◆ FR_ITEM_POINTER

#define FR_ITEM_POINTER (   _type,
  _res_p 
)    _type, FR_CONF_FLAG_CHECK((_type), 0, (_res_p), _res_p)

Definition at line 331 of file cf_parse.h.

◆ fr_rule_deprecated

#define fr_rule_deprecated (   _rule)    ((_rule)->flags & CONF_FLAG_DEPRECATED)

Definition at line 439 of file cf_parse.h.

◆ fr_rule_dflt

#define fr_rule_dflt (   _rule)    ((_rule)->dflt || (_rule)->dflt_func)

Definition at line 460 of file cf_parse.h.

◆ fr_rule_file_exists

#define fr_rule_file_exists (   _rule)    ((_rule)->flags & CONF_FLAG_FILE_EXISTS)

Definition at line 458 of file cf_parse.h.

◆ fr_rule_file_input

#define fr_rule_file_input (   _rule)    ((_rule)->flags & CONF_FLAG_FILE_INPUT)

Definition at line 445 of file cf_parse.h.

◆ fr_rule_file_output

#define fr_rule_file_output (   _rule)    ((_rule)->flags & CONF_FLAG_FILE_OUTPUT)

Definition at line 447 of file cf_parse.h.

◆ fr_rule_is_attribute

#define fr_rule_is_attribute (   _rule)    ((_rule)->flags & CONF_FLAG_ATTRIBUTE)

Definition at line 462 of file cf_parse.h.

◆ fr_rule_is_set

#define fr_rule_is_set (   _rule)    ((_rule)->flags & CONF_FLAG_IS_SET)

Definition at line 454 of file cf_parse.h.

◆ fr_rule_is_tmpl

#define fr_rule_is_tmpl (   _rule)    ((_rule)->flags & CONF_FLAG_TMPL)

Definition at line 466 of file cf_parse.h.

◆ fr_rule_is_xlat

#define fr_rule_is_xlat (   _rule)    ((_rule)->flags & CONF_FLAG_XLAT)

Definition at line 464 of file cf_parse.h.

◆ fr_rule_multi

#define fr_rule_multi (   _rule)    ((_rule)->flags & CONF_FLAG_MULTI)

Definition at line 450 of file cf_parse.h.

◆ fr_rule_not_empty

#define fr_rule_not_empty (   _rule)    ((_rule)->flags & CONF_FLAG_NOT_EMPTY)

Definition at line 452 of file cf_parse.h.

◆ fr_rule_ok_missing

#define fr_rule_ok_missing (   _rule)    ((_rule)->flags & CONF_FLAG_OK_MISSING)

Definition at line 456 of file cf_parse.h.

◆ fr_rule_required

#define fr_rule_required (   _rule)    ((_rule)->flags & CONF_FLAG_REQUIRED)

Definition at line 441 of file cf_parse.h.

◆ fr_rule_secret

#define fr_rule_secret (   _rule)    ((_rule)->flags & CONF_FLAG_SECRET)

Definition at line 443 of file cf_parse.h.

◆ FR_SIZE_BOUND_CHECK

#define FR_SIZE_BOUND_CHECK (   _name,
  _var,
  _op,
  _bound 
)    FR_SIZE_COND_CHECK(_name, _var, (_var _op _bound), _bound)

Definition at line 477 of file cf_parse.h.

◆ FR_SIZE_COND_CHECK

#define FR_SIZE_COND_CHECK (   _name,
  _var,
  _cond,
  _new 
)
Value:
do {\
if (!(_cond)) {\
WARN("Ignoring \"" _name " = %zu\", forcing to \"" _name " = %zu\"", _var, _new);\
_var = _new;\
}\
} while (0)

Definition at line 469 of file cf_parse.h.

◆ FR_TIME_DELTA_BOUND_CHECK

#define FR_TIME_DELTA_BOUND_CHECK (   _name,
  _var,
  _op,
  _bound 
)
Value:
do {\
if (!fr_time_delta_cond(_var, _op, _bound)) { \
WARN("Ignoring \"" _name " = %pV\", forcing to \"" _name " = %pV\"",\
fr_box_time_delta(_bound));\
_var = _bound;\
}\
} while (0)
#define fr_time_delta_cond(_a, _op, _b)
Definition: time.h:282
#define fr_box_time_delta(_val)
Definition: value.h:343

Definition at line 498 of file cf_parse.h.

◆ FR_TIME_DELTA_COND_CHECK

#define FR_TIME_DELTA_COND_CHECK (   _name,
  _var,
  _cond,
  _new 
)
Value:
do {\
if (!(_cond)) {\
WARN("Ignoring \"" _name " = %pV\", forcing to \"" _name " = %pV\"", \
_var = _new;\
}\
} while (0)

Definition at line 489 of file cf_parse.h.

Typedef Documentation

◆ cf_dflt_t

typedef int(* cf_dflt_t) (CONF_PAIR **out, void *parent, CONF_SECTION *cs, fr_token_t quote, conf_parser_t const *rule)

Callback for producing dynamic defaults from 3rd party libraries.

Parameters
[out]outWhere to write default conf pair.
[in]parentbeing populated.
[in]csto allocate pair in.
[in]quoteto use when allocing the pair. Provided as a convenience.
[in]ruleto produce default for.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 534 of file cf_parse.h.

◆ cf_parse_t

typedef int(* cf_parse_t) (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)

Callback for performing custom parsing of a CONF_SECTION or CONF_PAIR.

Parameters
[in]ctxto allocate any data in.
[out]outWhere to write the result of parsing.
[in]parentThe base address of the structure.
[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 521 of file cf_parse.h.

◆ conf_parser_t

typedef struct conf_parser_s conf_parser_t

Definition at line 1 of file cf_parse.h.

Enumeration Type Documentation

◆ conf_parser_flags_t

Enumerator
CONF_FLAG_NONE 

No special flags.

CONF_FLAG_SUBSECTION 

Instead of putting the information into a configuration structure, the configuration file routines MAY just parse it directly into user-supplied variables.

CONF_FLAG_DEPRECATED 

If a matching CONF_PAIR is found, error out with a deprecated message.

CONF_FLAG_REQUIRED 

Error out if no matching CONF_PAIR is found, and no dflt value is set.

CONF_FLAG_ATTRIBUTE 

Value must resolve to attribute in dict (deprecated, use CONF_FLAG_TMPL).

CONF_FLAG_SECRET 

Only print value if debug level >= 3.

CONF_FLAG_FILE_INPUT 

File matching value must exist, and must be readable.

CONF_FLAG_FILE_OUTPUT 

File matching value must exist, and must be writable.

CONF_FLAG_XLAT 

string will be dynamically expanded.

CONF_FLAG_TMPL 

CONF_PAIR should be parsed as a template.

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_FILE_EXISTS 

File matching value must exist.

CONF_FLAG_IS_SET 

Write whether this config item was left as the default to is_set_offset or is_set_ptr.

CONF_FLAG_OK_MISSING 

OK if it's missing.

CONF_FLAG_HIDDEN 

Used by scripts to omit items from the generated documentation.

Definition at line 397 of file cf_parse.h.

Function Documentation

◆ _cf_section_rule_push()

int _cf_section_rule_push ( CONF_SECTION cs,
conf_parser_t const *  rule,
char const *  filename,
int  lineno 
)

Add a single rule to a CONF_SECTION.

Parameters
[in]csto add rules to.
[in]ruleto add.
[in]filenamewhere the rule was pushed.
[in]linenowhere the rule was pushed.
Returns
  • 0 on success.
  • -1 if the rules added conflict.

Definition at line 1351 of file cf_parse.c.

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

◆ _cf_section_rules_push()

int _cf_section_rules_push ( CONF_SECTION cs,
conf_parser_t const *  rules,
char const *  filename,
int  lineno 
)

Add an array of parse rules to a CONF_SECTION.

Parameters
[in]csto add rules to.
[in]rulesto add. Last element should have NULL name field.
[in]filenamewhere the rule was pushed.
[in]linenowhere the rule was pushed.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1448 of file cf_parse.c.

+ Here is the call graph for this function:

◆ cf_pair_debug_log()

void cf_pair_debug_log ( CONF_SECTION const *  cs,
CONF_PAIR cp,
conf_parser_t const *  rule 
)

Definition at line 49 of file cf_parse.c.

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

◆ cf_pair_parse()

int cf_pair_parse ( TALLOC_CTX *  ctx,
CONF_SECTION cs,
char const *  name,
unsigned int  type,
void *  data,
char const *  dflt,
fr_token_t  dflt_quote 
)

Parses a CONF_PAIR into a C data type, with a default value.

Takes fields from a conf_parser_t struct and uses them to parse the string value of a CONF_PAIR into a C data type matching the type argument.

The format of the types are the same as fr_value_box_t types.

Note
The dflt value will only be used if no matching CONF_PAIR is found. Empty strings will not result in the dflt value being used.

fr_type_t to data type mappings

fr_type_t Data type Dynamically allocated
FR_TYPE_BOOL bool No
FR_TYPE_UINT32 uint32_t No
FR_TYPE_UINT16 uint16_t No
FR_TYPE_UINT64 uint64_t No
FR_TYPE_INT32 int32_t No
FR_TYPE_STRING char const * Yes
FR_TYPE_IPV4_ADDR fr_ipaddr_t No
FR_TYPE_IPV4_PREFIX fr_ipaddr_t No
FR_TYPE_IPV6_ADDR fr_ipaddr_t No
FR_TYPE_IPV6_PREFIX fr_ipaddr_t No
FR_TYPE_COMBO_IP_ADDR fr_ipaddr_t No
FR_TYPE_COMBO_IP_PREFIX fr_ipaddr_t No
FR_TYPE_TIME_DELTA fr_time_delta_t No
Parameters
[in]ctxTo allocate arrays and values in.
[in]csto search for matching CONF_PAIR in.
[in]nameof CONF_PAIR to search for.
[in]typeData type to parse CONF_PAIR value as. Should be one of the following data types, and one or more of the following flag types or'd together:

Definition at line 700 of file cf_parse.c.

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

◆ cf_pair_parse_value()

int cf_pair_parse_value ( TALLOC_CTX *  ctx,
void *  out,
void *  base,
CONF_ITEM ci,
conf_parser_t const *  rule 
)

◆ cf_pair_to_value_box()

int cf_pair_to_value_box ( TALLOC_CTX *  ctx,
fr_value_box_t out,
CONF_PAIR cp,
conf_parser_t const *  rule 
)

Parses a CONF_PAIR into a boxed value.

Return the value of a CONF_PAIR.

See also
cf_pair_value
Parameters
[in]ctxto allocate any dynamic buffers in.
[out]outWhere to write the parsed value.
[in]cpto parse.
[in]ruleto parse to. May contain flags.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 126 of file cf_parse.c.

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

◆ cf_parse_gid()

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

◆ cf_parse_uid()

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

◆ cf_section_parse()

int cf_section_parse ( TALLOC_CTX *  ctx,
void *  base,
CONF_SECTION cs 
)

Parse a configuration section into user-supplied variables.

Parameters
[in]ctxto allocate any strings, or additional structures in. Usually the same as base, unless base is a nested struct.
[out]basepointer to a struct to fill with data.
[in]csto parse.
Returns
  • 0 on success.
  • -1 on general error.
  • -2 if a deprecated CONF_ITEM was found.

Definition at line 985 of file cf_parse.c.

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

◆ cf_section_parse_pass2()

int cf_section_parse_pass2 ( void *  base,
CONF_SECTION cs 
)

Fixup xlat expansions and attributes.

Parameters
[out]basestart of structure to write tmpl_t s to.
[in]csCONF_SECTION to fixup.
Returns
  • 0 on success.
  • -1 on failure (parse errors etc...).

Definition at line 1163 of file cf_parse.c.

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

◆ cf_table_parse_int()

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.

Note
This should be used for enum types as c99 6.4.4.3 states that the enumeration constants are of type int.

Definition at line 1474 of file cf_parse.c.

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

◆ cf_table_parse_int32()

int cf_table_parse_int32 ( 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 int32_t (FR_TYPE_INT32)

Definition at line 1490 of file cf_parse.c.

+ Here is the call graph for this function:

◆ cf_table_parse_uint32()

int cf_table_parse_uint32 ( 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 int32_t (FR_TYPE_UINT32)

Definition at line 1506 of file cf_parse.c.

+ Here is the call graph for this function:

Variable Documentation

◆ check_config

bool check_config
extern

Definition at line 67 of file cf_file.c.