![]() |
The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
|
Convert internal format configuration values into native C types. More...
#include <string.h>#include <sys/errno.h>#include <sys/fcntl.h>#include <freeradius-devel/server/cf_file.h>#include <freeradius-devel/server/cf_parse.h>#include <freeradius-devel/server/cf_priv.h>#include <freeradius-devel/server/log.h>#include <freeradius-devel/server/tmpl.h>#include <freeradius-devel/server/virtual_servers.h>#include <freeradius-devel/server/main_config.h>#include <freeradius-devel/util/debug.h>#include <freeradius-devel/util/inet.h>#include <freeradius-devel/util/misc.h>#include <freeradius-devel/util/perm.h>
Include dependency graph for cf_parse.c:Go to the source code of this file.
Macros | |
| #define | CF_TABLE_PARSE_DEF(_name, _type, _out_of_range) |
| Define a function which resolves a CONF_PAIR value in a table, and writes the result as _type. | |
| #define | PAIR_SPACE(_cs) ((_cs->depth + 1) * 2) |
| #define | SECTION_SPACE(_cs) (_cs->depth * 2) |
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. | |
| 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. | |
| 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. | |
| void | cf_pair_debug_log (CONF_SECTION const *cs, CONF_PAIR *cp, conf_parser_t const *rule) |
| static int | cf_pair_default (CONF_PAIR **out, void *parent, CONF_SECTION *cs, conf_parser_t const *rule) |
| Allocate a pair using the dflt value and quotation. | |
| 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. | |
| static int | cf_pair_parse_internal (TALLOC_CTX *ctx, void *out, void *base, CONF_SECTION *cs, conf_parser_t const *rule) |
| Parses a CONF_PAIR into a C data type, with a default value. | |
| int | cf_pair_parse_value (TALLOC_CTX *ctx, void *out, UNUSED void *base, CONF_ITEM *ci, conf_parser_t const *rule) |
| Parses a CONF_PAIR into a C data type. | |
| 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. | |
| static int | cf_pair_unescape (CONF_PAIR *cp, conf_parser_t const *rule) |
| int | cf_parse_gid (TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule) |
| Generic function for resolving GID strings to uid_t values. | |
| int | cf_parse_permissions (UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule) |
| Generic function for resolving permissions to a mode-t. | |
| static int | cf_parse_tmpl_pass2 (UNUSED CONF_SECTION *cs, tmpl_t **out, CONF_PAIR *cp, fr_type_t type, bool attribute, fr_dict_t const *dict_def) |
| char const * | cf_parser_flag_to_enum_str (conf_parser_flags_t mask) |
| Return the source-identifier name for a single CONF_FLAG_* bit. | |
| static bool * | cf_rule_is_set_ptr (void *base, conf_parser_t const *rule) |
| Find where a rule records whether the rule's config item was present. | |
| int | cf_section_parse (TALLOC_CTX *ctx, void *base, CONF_SECTION *cs) |
| Parse a configuration section into user-supplied variables. | |
| static int | cf_section_parse_init (CONF_SECTION *cs, void *base, conf_parser_t const *rule) |
| Pre-allocate a config section structure to allow defaults to be set. | |
| int | cf_section_parse_pass2 (void *base, CONF_SECTION *cs) |
| Fixup xlat expansions and attributes. | |
| static int | cf_section_parse_rule (TALLOC_CTX *ctx, void *base, CONF_SECTION *cs, conf_parser_t const *rule) |
| static void | cf_section_parse_warn (CONF_SECTION *cs) |
| static int | cf_subsection_parse (TALLOC_CTX *ctx, void *out, void *base, CONF_SECTION *cs, conf_parser_t const *rule) |
| Parse a subsection. | |
| CF_TABLE_PARSE_DEF (int8, int8_t,(num< INT8_MIN)||(num > INT8_MAX)) | |
Variables | |
| static fr_table_num_indexed_bit_pos_t const | cf_parser_flag_table [] |
Bit-pos indexed table of CONF_FLAG_* names. | |
| static size_t | cf_parser_flag_table_len = NUM_ELEMENTS(cf_parser_flag_table) |
| static conf_parser_t | conf_term = CONF_PARSER_TERMINATOR |
| static char const | parse_spaces [] = " " |
Convert internal format configuration values into native C types.
Definition in file cf_parse.c.
| #define CF_TABLE_PARSE_DEF | ( | _name, | |
| _type, | |||
| _out_of_range | |||
| ) |
Define a function which resolves a CONF_PAIR value in a table, and writes the result as _type.
Each function looks the value of the CONF_PAIR up in the cf_table_parse_ctx_t table passed as the rule's uctx, and stores the result in a field of type _type. Use the function whose type matches the field, so the store writes exactly as many bytes as the field holds. An enum field gets the function matching the enum's fixed underlying type.
| [in] | _name | suffix of the function name, cf_table_parse_<_name>. |
| [in] | _type | C type of the field the function writes to. |
| [in] | _out_of_range | expression of num, true if num does not fit in _type. |
Definition at line 1808 of file cf_parse.c.
Definition at line 47 of file cf_parse.c.
Definition at line 48 of file cf_parse.c.
| 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.
| [in] | cs | to add rules to. |
| [in] | rule | to add. |
| [in] | filename | where the rule was pushed. |
| [in] | lineno | where the rule was pushed. |
Definition at line 1662 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
| [in] | cs | to add rules to. |
| [in] | rules | to add. Last element should have NULL name field. |
| [in] | filename | where the rule was pushed. |
| [in] | lineno | where the rule was pushed. |
Definition at line 1776 of file cf_parse.c.
Here is the call graph for this function:| 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.
This callback exists only as a place-holder to ensure that the nested on_read functions are called. The conf file routines won't recurse into every conf_parser_t section to check if there's an "on_read" callback. So this place-holder is a signal to do that.
| [in] | ctx | to allocate data in. |
| [out] | out | Unused |
| [in] | parent | Base structure address. |
| [in] | ci | CONF_SECTION containing the current section. |
| [in] | rule | unused. |
Definition at line 1899 of file cf_parse.c.
| void cf_pair_debug_log | ( | CONF_SECTION const * | cs, |
| CONF_PAIR * | cp, | ||
| conf_parser_t const * | rule | ||
| ) |
Definition at line 50 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Allocate a pair using the dflt value and quotation.
The pair created by this function should fed to cf_pair_parse for parsing.
| [out] | out | Where to write the CONF_PAIR we created with the default value. |
| [in] | parent | being populated. |
| [in] | cs | to parent the CONF_PAIR from. |
| [in] | rule | to use to create the default. |
Definition at line 415 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
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 |
| [in] | ctx | To allocate arrays and values in. |
| [in] | cs | to search for matching CONF_PAIR in. |
| [in] | name | of CONF_PAIR to search for. |
| [in] | type | Data 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: |
data FR_TYPE_BOOL - A truth value. data FR_TYPE_UINT32 - 32 Bit unsigned integer. data FR_TYPE_UINT16 - 16 Bit unsigned integer. data FR_TYPE_UINT64 - 64 Bit unsigned integer. data FR_TYPE_INT32 - 32 Bit signed integer. data FR_TYPE_STRING - String of printable characters. data FR_TYPE_IPV4_ADDR - 32 Bit IPv4 Address. (IPv4 address with prefix 32).data FR_TYPE_IPV4_PREFIX - IPv4 Prefix. (IPv4 address with variable prefix).data FR_TYPE_IPV6_ADDR - 128 Bit IPv6 Address. (IPv6 address with prefix 128).data FR_TYPE_IPV6_PREFIX - IPv6 Prefix. (IPv6 address with variable prefix).data FR_TYPE_COMBO_IP_ADDR - IPv4 or IPv6 address depending on length. (IPv4/IPv6 address with prefix 32/128).data FR_TYPE_COMBO_IP_PREFIX - IPv4 or IPv6 address prefix depending on length. (IPv4/IPv6 address with variable prefix).data FR_TYPE_TIME_DELTA - A period of time measured in nanoseconds. flag CONF_FLAG_TMPL - CONF_PAIR should be parsed as a template. Feeds the value into tmpl_afrom_substr. Value can be obtained when processing requests, with tmpl_expand or tmpl_aexpand.flag CONF_FLAG_V3_DEPRECATED - If a matching CONF_PAIR is found, error out with a deprecated message. flag CONF_FLAG_REQUIRED - Error out if no matching CONF_PAIR is found, and no dflt value is set. flag CONF_FLAG_ATTRIBUTE - Value must resolve to attribute in dict (deprecated, use CONF_FLAG_TMPL). flag CONF_FLAG_SECRET - Only print value if debug level >= 3. flag CONF_FLAG_FILE_READABLE - File matching value must exist, and must be readable. flag CONF_FLAG_FILE_WRITABLE - File matching value must exist, and must be writable. flag CONF_FLAG_NOT_EMPTY - CONF_PAIR is required to have a non zero length value. flag CONF_FLAG_MULTI - CONF_PAIR can have multiple copies. flag CONF_FLAG_IS_SET - Write whether this config item was left as the default to is_set_offset or is_set_ptr. | [out] | data | Pointer to a global variable, or pointer to a field in the struct being populated with values. |
| [in] | dflt | value to use, if no CONF_PAIR is found. |
| [in] | dflt_quote | around the dflt value. |
Definition at line 844 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Parses a CONF_PAIR into a C data type, with a default value.
| [in] | ctx | To allocate arrays and values in. |
| [out] | out | Where to write the result. Must not be NULL unless rule->runc is provided. |
| [in] | base | address of the structure out points into. May be NULL in the case of manual parsing. |
| [in] | cs | to search for matching CONF_PAIR in. |
| [in] | rule | to parse CONF_PAIR with. |
Definition at line 577 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int cf_pair_parse_value | ( | TALLOC_CTX * | ctx, |
| void * | out, | ||
| UNUSED void * | base, | ||
| CONF_ITEM * | ci, | ||
| conf_parser_t const * | rule | ||
| ) |
Parses a CONF_PAIR into a C data type.
Return the value of a CONF_PAIR.
| [in] | ctx | to allocate any dynamic buffers in. |
| [out] | out | Where to write the parsed value. |
| [in] | base | address of the structure out points into. May be NULL in the case of manual parsing. |
| [in] | ci | to parse. |
| [in] | rule | to parse to. May contain flags. |
Definition at line 252 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
| [in] | ctx | to allocate any dynamic buffers in. |
| [out] | out | Where to write the parsed value. |
| [in] | cp | to parse. |
| [in] | rule | to parse to. May contain flags. |
Definition at line 127 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 472 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int cf_parse_gid | ( | TALLOC_CTX * | ctx, |
| void * | out, | ||
| UNUSED void * | parent, | ||
| CONF_ITEM * | ci, | ||
| UNUSED conf_parser_t const * | rule | ||
| ) |
Generic function for resolving GID strings to uid_t values.
Type should be FR_TYPE_VOID, struct field should be a gid_t.
Definition at line 1852 of file cf_parse.c.
Here is the call graph for this function:| int cf_parse_permissions | ( | UNUSED TALLOC_CTX * | ctx, |
| void * | out, | ||
| UNUSED void * | parent, | ||
| CONF_ITEM * | ci, | ||
| UNUSED conf_parser_t const * | rule | ||
| ) |
Generic function for resolving permissions to a mode-t.
Type should be FR_TYPE_VOID, struct field should be a gid_t.
Definition at line 1867 of file cf_parse.c.
Here is the call graph for this function:
|
static |
Definition at line 1403 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:| char const * cf_parser_flag_to_enum_str | ( | conf_parser_flags_t | mask | ) |
Return the source-identifier name for a single CONF_FLAG_* bit.
mask MUST be a single-bit mask from conf_parser_flags_t (e.g. CONF_FLAG_REQUIRED). Used by tooling that wants to stringify a flag set bit-by-bit (radmod2json).
| [in] | mask | single-bit CONF_FLAG_* value. |
NULL if mask is not a known flag bit. Definition at line 1936 of file cf_parse.c.
Here is the caller graph for this function:
|
inlinestatic |
Find where a rule records whether the rule's config item was present.
| base | Struct the rule writes into, or NULL if the rule only writes through the rule's own pointers. |
| rule | Rule whose flags include CONF_FLAG_IS_SET. |
Definition at line 866 of file cf_parse.c.
Here is the caller graph for this function:| int cf_section_parse | ( | TALLOC_CTX * | ctx, |
| void * | base, | ||
| CONF_SECTION * | cs | ||
| ) |
Parse a configuration section into user-supplied variables.
| [in] | ctx | to allocate any strings, or additional structures in. Usually the same as base, unless base is a nested struct. |
| [out] | base | pointer to a struct to fill with data. |
| [in] | cs | to parse. |
Definition at line 1360 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Pre-allocate a config section structure to allow defaults to be set.
| cs | The parent subsection. |
| base | pointer or variable. |
| rule | that may have defaults in this config section. |
Definition at line 888 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int cf_section_parse_pass2 | ( | void * | base, |
| CONF_SECTION * | cs | ||
| ) |
Fixup xlat expansions and attributes.
| [out] | base | start of structure to write tmpl_t s to. |
| [in] | cs | CONF_SECTION to fixup. |
Definition at line 1470 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 1198 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 1012 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Parse a subsection.
| [in] | ctx | to allocate any additional structures under. |
| [out] | out | pointer to a struct/pointer to fill with data. |
| [in] | base | address of the structure out points into. May be NULL in the case of manual parsing. |
| [in] | cs | to parse. |
| [in] | rule | to parse the subcs with. |
Definition at line 1056 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:| CF_TABLE_PARSE_DEF | ( | int8 | , |
| int8_t | , | ||
| (num< INT8_MIN)||(num > INT8_MAX) | |||
| ) |
|
static |
Bit-pos indexed table of CONF_FLAG_* names.
Index is fr_high_bit_pos() of the flag value, which matches the _Generic dispatch on fr_table_num_indexed_bit_pos_t in fr_table_str_by_value.
Definition at line 1911 of file cf_parse.c.
|
static |
Definition at line 1934 of file cf_parse.c.
|
static |
Definition at line 44 of file cf_parse.c.
|
static |
Definition at line 45 of file cf_parse.c.
1.9.8