The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Boxed value structures and functions to manipulate them. More...
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/util/atexit.h>
#include <freeradius-devel/util/base16.h>
#include <freeradius-devel/util/dcursor.h>
#include <freeradius-devel/util/size.h>
#include <freeradius-devel/util/time.h>
#include <math.h>
Go to the source code of this file.
Macros | |
#define | _VALUE_PRIVATE |
#define | CAST_IP_FIX_COMBO |
#define | COMPARE(_type) return CMP(memcmp(&a->datum._type, &b->datum._type, sizeof(a->datum._type)), 0) |
#define | INFO_INDENT(_fmt, ...) FR_FAULT_LOG("%*s"_fmt, depth * 2, " ", ## __VA_ARGS__) |
#define | network_max_size(_x) (fr_value_box_network_sizes[_x][1]) |
#define | network_min_size(_x) (fr_value_box_network_sizes[_x][0]) |
Sanity checks. More... | |
#define | RETURN(_type) return CMP(a->datum._type, b->datum._type) |
#define | SIGN_BIT_HIGH(_int, _len) ((((uint64_t)1) << (((_len) << 3) - 1)) & (_int)) |
#define | SIGN_PROMOTE(_int, _len) |
Functions | |
static void | _fr_value_box_debug (fr_value_box_t const *vb, int depth, int idx) |
static void | _fr_value_box_list_debug (fr_value_box_list_t const *head, int depth) |
void | _fr_value_box_mark_safe_for (fr_value_box_t *vb, fr_value_box_safe_for_t safe_for) |
Mark a value-box as "safe", of a particular type. More... | |
return | fr_dbuff_set (dbuff, &our_dbuff) |
int | fr_regex_cmp_op (fr_token_t op, fr_value_box_t const *a, fr_value_box_t const *b) |
Compare two boxes using an operator. More... | |
FR_SBUFF_SET_RETURN (sbuff, &our_sbuff) | |
int | fr_value_box_asprintf (TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, bool tainted, char const *fmt,...) |
Print a formatted string using our internal printf wrapper and assign it to a value box. More... | |
int | fr_value_box_bstr_alloc (TALLOC_CTX *ctx, char **out, fr_value_box_t *dst, fr_dict_attr_t const *enumv, size_t len, bool tainted) |
Alloc and assign an empty \0 terminated string to a fr_value_box_t. More... | |
int | fr_value_box_bstr_append_buffer (TALLOC_CTX *ctx, fr_value_box_t *dst, char const *src, bool tainted) |
Append a talloced buffer to an existing fr_value_box_t. More... | |
int | fr_value_box_bstr_realloc (TALLOC_CTX *ctx, char **out, fr_value_box_t *dst, size_t len) |
Change the length of a buffer already allocated to a value box. More... | |
int | fr_value_box_bstrdup_buffer (TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, char const *src, bool tainted) |
Copy a nul terminated talloced buffer to a fr_value_box_t. More... | |
int | fr_value_box_bstrdup_buffer_shallow (TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, char const *src, bool tainted) |
Assign a talloced buffer containing a nul terminated string to a box, but don't copy it. More... | |
int | fr_value_box_bstrn_append (TALLOC_CTX *ctx, fr_value_box_t *dst, char const *src, size_t len, bool tainted) |
Append bytes from a buffer to an existing fr_value_box_t. More... | |
int | fr_value_box_bstrndup (TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, char const *src, size_t len, bool tainted) |
Copy a string to to a fr_value_box_t. More... | |
int | fr_value_box_bstrndup_dbuff (TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, fr_dbuff_t *dbuff, size_t len, bool tainted) |
void | fr_value_box_bstrndup_shallow (fr_value_box_t *dst, fr_dict_attr_t const *enumv, char const *src, size_t len, bool tainted) |
Assign a string to to a fr_value_box_t. More... | |
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. More... | |
int | fr_value_box_cast_in_place (TALLOC_CTX *ctx, fr_value_box_t *vb, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv) |
Convert one type of fr_value_box_t to another in place. More... | |
static int | fr_value_box_cast_integer_to_integer (UNUSED 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 any signed or unsigned integer type to any other signed or unsigned integer type. More... | |
static int | fr_value_box_cast_to_bool (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 any supported type to a bool. More... | |
static int | fr_value_box_cast_to_ethernet (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 any supported type to an ethernet address. More... | |
static int | fr_value_box_cast_to_float (UNUSED 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 any value to a floating point value. More... | |
static int | fr_value_box_cast_to_integer (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 any value to a signed or unsigned integer. More... | |
static int | fr_value_box_cast_to_ipv4addr (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 any supported type to an IPv4 address. More... | |
static int | fr_value_box_cast_to_ipv4prefix (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 any supported type to an IPv6 address. More... | |
static int | fr_value_box_cast_to_ipv6addr (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 any supported type to an IPv6 address. More... | |
static int | fr_value_box_cast_to_ipv6prefix (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 any supported type to an IPv6 address. More... | |
static int | fr_value_box_cast_to_octets (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 any supported type to octets. More... | |
static int | fr_value_box_cast_to_strvalue (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 any supported type to a string. More... | |
static int | fr_value_box_cidr_cmp_op (fr_token_t op, int bytes, uint8_t a_net, uint8_t const *a, uint8_t b_net, uint8_t const *b) |
void | fr_value_box_clear (fr_value_box_t *data) |
Clear/free any existing value and metadata. More... | |
void | fr_value_box_clear_value (fr_value_box_t *data) |
Clear/free any existing value. More... | |
int8_t | fr_value_box_cmp (fr_value_box_t const *a, fr_value_box_t const *b) |
Compare two values. More... | |
int | fr_value_box_cmp_op (fr_token_t op, fr_value_box_t const *a, fr_value_box_t const *b) |
Compare two attributes using an operator. More... | |
int | fr_value_box_copy (TALLOC_CTX *ctx, fr_value_box_t *dst, const fr_value_box_t *src) |
Copy value data verbatim duplicating any buffers. More... | |
static void | fr_value_box_copy_meta (fr_value_box_t *dst, fr_value_box_t const *src) |
Copy flags and type data from one value box to another. More... | |
void | fr_value_box_copy_shallow (TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t const *src) |
Perform a shallow copy of a value_box. More... | |
void | fr_value_box_debug (fr_value_box_t const *vb) |
Print the value of a box as info messages. More... | |
int | fr_value_box_escape_in_place (fr_value_box_t *vb, fr_value_box_escape_t escape, fr_value_box_safe_for_t safe_for, void *uctx) |
Escape a single value box in place. More... | |
static int | fr_value_box_fixed_size_from_octets (fr_value_box_t *dst, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, fr_value_box_t const *src) |
Convert octets to a fixed size value box value. More... | |
void | fr_value_box_flatten (TALLOC_CTX *ctx, fr_value_box_list_t *list, bool steal, bool free) |
Removes a single layer of nesting, moving all children into the parent list. More... | |
ssize_t | fr_value_box_from_network (TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t type, fr_dict_attr_t const *enumv, fr_dbuff_t *dbuff, size_t len, bool tainted) |
Decode a fr_value_box_t from serialized binary data. More... | |
static fr_slen_t | fr_value_box_from_numeric_substr (fr_value_box_t *dst, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *rules, bool tainted) |
Convert integer encoded as string to a fr_value_box_t type. More... | |
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, bool tainted) |
ssize_t | fr_value_box_from_substr (TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *rules, bool tainted) |
Convert string value to a fr_value_box_t type. More... | |
uint32_t | fr_value_box_hash (fr_value_box_t const *vb) |
Hash the contents of a value box. More... | |
int | fr_value_box_hton (fr_value_box_t *dst, fr_value_box_t const *src) |
Performs byte order reversal for types that need it. More... | |
void | fr_value_box_increment (fr_value_box_t *vb) |
Increment a boxed value. More... | |
int | fr_value_box_ipaddr (fr_value_box_t *dst, fr_dict_attr_t const *enumv, fr_ipaddr_t const *ipaddr, bool tainted) |
Assign a fr_value_box_t value from an fr_ipaddr_t. More... | |
bool | fr_value_box_is_truthy (fr_value_box_t const *in) |
Check truthiness of values. More... | |
int | fr_value_box_list_acopy (TALLOC_CTX *ctx, fr_value_box_list_t *out, fr_value_box_list_t const *in) |
Do a full copy of a list of value boxes. More... | |
char * | fr_value_box_list_aprint (TALLOC_CTX *ctx, fr_value_box_list_t const *list, char const *delim, fr_sbuff_escape_rules_t const *e_rules) |
Concatenate the string representations of a list of value boxes together. More... | |
char * | fr_value_box_list_aprint_secure (TALLOC_CTX *ctx, fr_value_box_list_t const *list, char const *delim, fr_sbuff_escape_rules_t const *e_rules) |
Concatenate the string representations of a list of value boxes together hiding "secret" values. More... | |
ssize_t | fr_value_box_list_concat_as_octets (bool *tainted, bool *secret, fr_dbuff_t *dbuff, fr_value_box_list_t *list, uint8_t const *sep, size_t sep_len, fr_value_box_list_action_t proc_action, bool flatten) |
Concatenate a list of value boxes together. More... | |
ssize_t | fr_value_box_list_concat_as_string (bool *tainted, bool *secret, fr_sbuff_t *sbuff, fr_value_box_list_t *list, char const *sep, size_t sep_len, fr_sbuff_escape_rules_t const *e_rules, fr_value_box_list_action_t proc_action, fr_value_box_safe_for_t safe_for, bool flatten) |
Concatenate a list of value boxes together. More... | |
int | fr_value_box_list_concat_in_place (TALLOC_CTX *ctx, fr_value_box_t *out, fr_value_box_list_t *list, fr_type_t type, fr_value_box_list_action_t proc_action, bool flatten, size_t max_size) |
Concatenate a list of value boxes. More... | |
void | fr_value_box_list_debug (fr_value_box_list_t const *head) |
Print a list of value boxes as info messages. More... | |
int | fr_value_box_list_escape_in_place (fr_value_box_list_t *list, fr_value_box_escape_t escape, fr_value_box_safe_for_t safe_for, void *uctx) |
Escape a list of value boxes in place. More... | |
void | fr_value_box_list_mark_safe_for (fr_value_box_list_t *list, fr_value_box_safe_for_t safe_for) |
Set the escaped flag for all value boxes in a list. More... | |
void | fr_value_box_list_taint (fr_value_box_list_t *head) |
Taint every list member (and their children) More... | |
bool | fr_value_box_list_tainted (fr_value_box_list_t const *head) |
Check to see if any list members (or their children) are tainted. More... | |
void | fr_value_box_list_untaint (fr_value_box_list_t *head) |
Untaint every list member (and their children) More... | |
void | fr_value_box_list_verify (char const *file, int line, fr_value_box_list_t const *list) |
void | fr_value_box_mark_unsafe (fr_value_box_t *vb) |
Mark a value-box as "unsafe". More... | |
int | fr_value_box_mem_alloc (TALLOC_CTX *ctx, uint8_t **out, fr_value_box_t *dst, fr_dict_attr_t const *enumv, size_t len, bool tainted) |
Pre-allocate an octets buffer for filling by the caller. More... | |
int | fr_value_box_mem_append (TALLOC_CTX *ctx, fr_value_box_t *dst, uint8_t const *src, size_t len, bool tainted) |
Append data to an existing fr_value_box_t. More... | |
int | fr_value_box_mem_append_buffer (TALLOC_CTX *ctx, fr_value_box_t *dst, uint8_t const *src, bool tainted) |
Append a talloc buffer to an existing fr_value_box_t. More... | |
int | fr_value_box_mem_realloc (TALLOC_CTX *ctx, uint8_t **out, fr_value_box_t *dst, size_t len) |
Change the length of a buffer already allocated to a value box. More... | |
int | fr_value_box_memdup (TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, uint8_t const *src, size_t len, bool tainted) |
Copy a buffer to a fr_value_box_t. More... | |
int | fr_value_box_memdup_buffer (TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, uint8_t const *src, bool tainted) |
Copy a talloced buffer to a fr_value_box_t. More... | |
void | fr_value_box_memdup_buffer_shallow (TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, uint8_t const *src, bool tainted) |
Assign a talloced buffer to a box, but don't copy it. More... | |
int | fr_value_box_memdup_dbuff (TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, fr_dbuff_t *dbuff, size_t len, bool tainted) |
void | fr_value_box_memdup_shallow (fr_value_box_t *dst, fr_dict_attr_t const *enumv, uint8_t const *src, size_t len, bool tainted) |
Assign a buffer to a box, but don't copy it. More... | |
size_t | fr_value_box_network_length (fr_value_box_t const *value) |
Get the size of the value held by the fr_value_box_t. More... | |
ssize_t | fr_value_box_print (fr_sbuff_t *out, fr_value_box_t const *data, fr_sbuff_escape_rules_t const *e_rules) |
Print one boxed value to a string. More... | |
ssize_t | fr_value_box_print_quoted (fr_sbuff_t *out, fr_value_box_t const *data, fr_token_t quote) |
Print one boxed value to a string with quotes (where needed) More... | |
int | fr_value_box_steal (TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t *src) |
Copy value data verbatim moving any buffers to the specified context. More... | |
int | fr_value_box_strdup (TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, char const *src, bool tainted) |
Copy a nul terminated string to a fr_value_box_t. More... | |
void | fr_value_box_strdup_shallow (fr_value_box_t *dst, fr_dict_attr_t const *enumv, char const *src, bool tainted) |
Assign a buffer containing a nul terminated string to a box, but don't copy it. More... | |
void | fr_value_box_strdup_shallow_replace (fr_value_box_t *vb, char const *src, ssize_t len) |
Free the existing buffer (if talloced) associated with the valuebox, and replace it with a new one. More... | |
int | fr_value_box_strtrim (TALLOC_CTX *ctx, fr_value_box_t *vb) |
Trim the length of the string buffer to match the length of the C string. More... | |
int | fr_value_box_to_key (uint8_t **out, size_t *outlen, fr_value_box_t const *value) |
Get a key from a value box. More... | |
ssize_t | fr_value_box_to_network (fr_dbuff_t *dbuff, fr_value_box_t const *value) |
Encode a single value box, serializing its contents in generic network format. More... | |
int | fr_value_box_vasprintf (TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, bool tainted, char const *fmt, va_list ap) |
Print a formatted string using our internal printf wrapper and assign it to a value box. More... | |
void | fr_value_box_verify (char const *file, int line, fr_value_box_t const *vb) |
Validation function to check that a fr_value_box_t is correctly initialised. More... | |
size_t | fr_value_str_unescape (fr_sbuff_t *out, fr_sbuff_t *in, size_t inlen, char quote) |
Convert a string value with escape sequences into its binary form. More... | |
size_t | fr_value_substr_unescape (fr_sbuff_t *out, fr_sbuff_t *in, size_t inlen, char quote) |
Convert a string value with escape sequences into its binary form. More... | |
int | fr_value_unbox_ipaddr (fr_ipaddr_t *dst, fr_value_box_t *src) |
Unbox an IP address performing a type check. More... | |
Produce a #tmpl_t from a string or substring | |
fr_sbuff_parse_rules_t const * | value_parse_rules_3quoted [T_TOKEN_LAST] |
fr_sbuff_parse_rules_t const | value_parse_rules_backtick_3quoted |
fr_sbuff_parse_rules_t const | value_parse_rules_backtick_quoted |
fr_sbuff_parse_rules_t const | value_parse_rules_backtick_unquoted |
fr_sbuff_parse_rules_t const | value_parse_rules_bareword_quoted |
fr_sbuff_parse_rules_t const | value_parse_rules_bareword_unquoted |
Default formatting rules. More... | |
fr_sbuff_parse_rules_t const | value_parse_rules_double_3quoted |
fr_sbuff_parse_rules_t const | value_parse_rules_double_quoted |
fr_sbuff_parse_rules_t const | value_parse_rules_double_unquoted |
fr_sbuff_parse_rules_t const * | value_parse_rules_quoted [T_TOKEN_LAST] |
Parse rules for quoted strings. More... | |
fr_sbuff_parse_rules_t const * | value_parse_rules_quoted_char [UINT8_MAX] |
fr_sbuff_parse_rules_t const | value_parse_rules_single_3quoted |
fr_sbuff_parse_rules_t const | value_parse_rules_single_quoted |
fr_sbuff_parse_rules_t const | value_parse_rules_single_unquoted |
fr_sbuff_parse_rules_t const | value_parse_rules_solidus_3quoted |
fr_sbuff_parse_rules_t const | value_parse_rules_solidus_quoted |
fr_sbuff_parse_rules_t const | value_parse_rules_solidus_unquoted |
fr_sbuff_parse_rules_t const * | value_parse_rules_unquoted [T_TOKEN_LAST] |
Parse rules for non-quoted strings. More... | |
fr_sbuff_parse_rules_t const * | value_parse_rules_unquoted_char [UINT8_MAX] |
Boxed value structures and functions to manipulate them.
There are three notional data formats used in the server:
Definition in file value.c.
#define CAST_IP_FIX_COMBO |
#define COMPARE | ( | _type | ) | return CMP(memcmp(&a->datum._type, &b->datum._type, sizeof(a->datum._type)), 0) |
#define INFO_INDENT | ( | _fmt, | |
... | |||
) | FR_FAULT_LOG("%*s"_fmt, depth * 2, " ", ## __VA_ARGS__) |
#define network_max_size | ( | _x | ) | (fr_value_box_network_sizes[_x][1]) |
#define network_min_size | ( | _x | ) | (fr_value_box_network_sizes[_x][0]) |
Sanity checks.
There should never be an instance where these fail. How many bytes on-the-wire would a fr_value_box_t value consume
This is for the generic NETWORK format. For field sizes in the in-memory structure use fr_value_box_field_sizes.
#define SIGN_BIT_HIGH | ( | _int, | |
_len | |||
) | ((((uint64_t)1) << (((_len) << 3) - 1)) & (_int)) |
#define SIGN_PROMOTE | ( | _int, | |
_len | |||
) |
|
static |
|
static |
void _fr_value_box_mark_safe_for | ( | fr_value_box_t * | vb, |
fr_value_box_safe_for_t | safe_for | ||
) |
return fr_dbuff_set | ( | dbuff | , |
& | our_dbuff | ||
) |
int fr_regex_cmp_op | ( | fr_token_t | op, |
fr_value_box_t const * | a, | ||
fr_value_box_t const * | b | ||
) |
Compare two boxes using an operator.
However, this involves allocating intermediate sbuffs for the unescaped RHS, and all kinds of extra work. It's not overly hard, but it's something we wish to avoid for now.
[in] | op | to use in comparison. MUST be T_OP_REG_EQ or T_OP_REG_NE |
[in] | a | Value to compare, MUST be FR_TYPE_STRING |
[in] | b | uncompiled regex as FR_TYPE_STRING |
Definition at line 1360 of file regex.c.
FR_SBUFF_SET_RETURN | ( | sbuff | , |
& | our_sbuff | ||
) |
int fr_value_box_asprintf | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
fr_dict_attr_t const * | enumv, | ||
bool | tainted, | ||
char const * | fmt, | ||
... | |||
) |
Print a formatted string using our internal printf wrapper and assign it to a value box.
[in] | ctx | to allocate any new buffers in. |
[in] | dst | to assign new buffer to. |
[in] | enumv | Aliases for values. |
[in] | tainted | Whether the value came from a trusted source. |
[in] | fmt | The printf format string to process. |
[in] | ... | Substitution arguments. |
Definition at line 4014 of file value.c.
int fr_value_box_bstr_alloc | ( | TALLOC_CTX * | ctx, |
char ** | out, | ||
fr_value_box_t * | dst, | ||
fr_dict_attr_t const * | enumv, | ||
size_t | len, | ||
bool | tainted | ||
) |
Alloc and assign an empty \0 terminated string to a fr_value_box_t.
[in] | ctx | to allocate any new buffers in. |
[out] | out | if non-null where to write a pointer to the new buffer. |
[in] | dst | to assign new buffer to. |
[in] | enumv | Aliases for values. |
[in] | len | of buffer to allocate. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 4071 of file value.c.
int fr_value_box_bstr_append_buffer | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
char const * | src, | ||
bool | tainted | ||
) |
Append a talloced buffer to an existing fr_value_box_t.
[in] | ctx | Where to allocate any talloc buffers required. |
[in] | dst | value box to append to. |
[in] | src | string data to append. |
[in] | tainted | Whether src is tainted. |
Definition at line 4337 of file value.c.
int fr_value_box_bstr_realloc | ( | TALLOC_CTX * | ctx, |
char ** | out, | ||
fr_value_box_t * | dst, | ||
size_t | len | ||
) |
Change the length of a buffer already allocated to a value box.
[in] | ctx | to realloc buffer in. |
[out] | out | if non-null where to write a pointer to the new buffer. |
[in] | dst | to realloc buffer for. |
[in] | len | to realloc to (don't include nul byte). |
Definition at line 4104 of file value.c.
int fr_value_box_bstrdup_buffer | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
fr_dict_attr_t const * | enumv, | ||
char const * | src, | ||
bool | tainted | ||
) |
Copy a nul terminated talloced buffer to a fr_value_box_t.
Copy a talloced nul terminated buffer, setting fields in the dst value box appropriately.
The buffer must be \0 terminated, or an error will be returned.
[in] | ctx | to allocate any new buffers in. |
[in] | dst | to assign new buffer to. |
[in] | enumv | Aliases for values. |
[in] | src | a talloced nul terminated buffer. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 4208 of file value.c.
int fr_value_box_bstrdup_buffer_shallow | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
fr_dict_attr_t const * | enumv, | ||
char const * | src, | ||
bool | tainted | ||
) |
Assign a talloced buffer containing a nul terminated string to a box, but don't copy it.
Adds a reference to the src buffer so that it cannot be freed until the ctx is freed.
[in] | ctx | to add reference from. If NULL no reference will be added. |
[in] | dst | to assign string to. |
[in] | enumv | Aliases for values. |
[in] | src | to copy string from. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 4253 of file value.c.
int fr_value_box_bstrn_append | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
char const * | src, | ||
size_t | len, | ||
bool | tainted | ||
) |
Append bytes from a buffer to an existing fr_value_box_t.
[in] | ctx | Where to allocate any talloc buffers required. |
[in] | dst | value box to append to. |
[in] | src | octets data to append. |
[in] | len | length of octets data. |
[in] | tainted | Whether src is tainted. |
Definition at line 4284 of file value.c.
int fr_value_box_bstrndup | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
fr_dict_attr_t const * | enumv, | ||
char const * | src, | ||
size_t | len, | ||
bool | tainted | ||
) |
Copy a string to to a fr_value_box_t.
[in] | ctx | to allocate any new buffers in. |
[in] | dst | to assign buffer to. |
[in] | enumv | Aliases for values. |
[in] | src | a string. May be NULL only if len == 0. |
[in] | len | of src. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 4148 of file value.c.
int fr_value_box_bstrndup_dbuff | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
fr_dict_attr_t const * | enumv, | ||
fr_dbuff_t * | dbuff, | ||
size_t | len, | ||
bool | tainted | ||
) |
void fr_value_box_bstrndup_shallow | ( | fr_value_box_t * | dst, |
fr_dict_attr_t const * | enumv, | ||
char const * | src, | ||
size_t | len, | ||
bool | tainted | ||
) |
Assign a string to to a fr_value_box_t.
[in] | dst | to assign new buffer to. |
[in] | enumv | Aliases for values. |
[in] | src | a string. |
[in] | len | of src. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 4232 of file value.c.
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.
This should be the canonical function used to convert between INTERNAL data formats.
If you want to convert from PRESENTATION format, use fr_value_box_from_substr.
ctx | to allocate buffers in (usually the same as dst) |
dst | Where to write result of casting. |
dst_type | to cast to. |
dst_enumv | Aliases for values contained within this fr_value_box_t. If fr_value_box_t is passed to fr_value_box_aprint names will be printed instead of actual value. |
src | Input data. |
Definition at line 3352 of file value.c.
int fr_value_box_cast_in_place | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | vb, | ||
fr_type_t | dst_type, | ||
fr_dict_attr_t const * | dst_enumv | ||
) |
Convert one type of fr_value_box_t to another in place.
This should be the canonical function used to convert between INTERNAL data formats.
If you want to convert from PRESENTATION format, use fr_value_box_from_substr.
ctx | to allocate buffers in (usually the same as dst) |
vb | to cast. |
dst_type | to cast to. |
dst_enumv | Aliases for values contained within this fr_value_box_t. If fr_value_box_t is passed to fr_value_box_aprint names will be printed instead of actual value. |
Definition at line 3572 of file value.c.
|
inlinestatic |
|
inlinestatic |
Convert any supported type to a bool.
Allowed input types are:
ctx | unused. |
dst | Where to write result of casting. |
dst_type | to cast to. |
dst_enumv | enumeration values. |
src | Input data. |
Definition at line 2885 of file value.c.
|
inlinestatic |
Convert any supported type to an ethernet address.
Allowed input types are:
ctx | unused. |
dst | Where to write result of casting. |
dst_type | to cast to. |
dst_enumv | enumeration values. |
src | Input data. |
Definition at line 2825 of file value.c.
|
inlinestatic |
|
inlinestatic |
Convert any value to a signed or unsigned integer.
ctx | unused. |
dst | Where to write result of casting. |
dst_type | to cast to. |
dst_enumv | enumeration values. |
src | Input data. |
Definition at line 3129 of file value.c.
|
inlinestatic |
Convert any supported type to an IPv4 address.
Allowed input types are:
ctx | unused. |
dst | Where to write result of casting. |
dst_type | to cast to. |
dst_enumv | enumeration values. |
src | Input data. |
Definition at line 2378 of file value.c.
|
inlinestatic |
Convert any supported type to an IPv6 address.
Allowed input types are:
ctx | unused. |
dst | Where to write result of casting. |
dst_type | to cast to. |
dst_enumv | enumeration values. |
src | Input data. |
Definition at line 2494 of file value.c.
|
inlinestatic |
Convert any supported type to an IPv6 address.
Allowed input types are:
ctx | unused. |
dst | Where to write result of casting. |
dst_type | to cast to. |
dst_enumv | enumeration values. |
src | Input data. |
Definition at line 2610 of file value.c.
|
inlinestatic |
Convert any supported type to an IPv6 address.
Allowed input types are:
ctx | unused. |
dst | Where to write result of casting. |
dst_type | to cast to. |
dst_enumv | enumeration values. |
src | Input data. |
Definition at line 2725 of file value.c.
|
inlinestatic |
Convert any supported type to octets.
All non-structural types are allowed.
ctx | unused. |
dst | Where to write result of casting. |
dst_type | to cast to. |
dst_enumv | enumeration values. |
src | Input data. |
Definition at line 2256 of file value.c.
|
inlinestatic |
Convert any supported type to a string.
All non-structural types are allowed.
ctx | unused. |
dst | Where to write result of casting. |
dst_type | to cast to. |
dst_enumv | enumeration values. |
src | Input data. |
Definition at line 2209 of file value.c.
|
static |
void fr_value_box_clear | ( | fr_value_box_t * | data | ) |
void fr_value_box_clear_value | ( | fr_value_box_t * | data | ) |
int8_t fr_value_box_cmp | ( | fr_value_box_t const * | a, |
fr_value_box_t const * | b | ||
) |
int fr_value_box_cmp_op | ( | fr_token_t | op, |
fr_value_box_t const * | a, | ||
fr_value_box_t const * | b | ||
) |
int fr_value_box_copy | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
const fr_value_box_t * | src | ||
) |
Copy value data verbatim duplicating any buffers.
ctx | To allocate buffers in. |
dst | Where to copy value_box to. |
src | Where to copy value_box from. |
Definition at line 3740 of file value.c.
|
inlinestatic |
void fr_value_box_copy_shallow | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
fr_value_box_t const * | src | ||
) |
Perform a shallow copy of a value_box.
Like fr_value_box_copy, but does not duplicate the buffers of the src value_box.
For FR_TYPE_STRING and FR_TYPE_OCTETS adds a reference from ctx so that the buffer cannot be freed until the ctx is freed.
[in] | ctx | to add reference from. If NULL no reference will be added. |
[in] | dst | to copy value to. |
[in] | src | to copy value from. |
Definition at line 3834 of file value.c.
void fr_value_box_debug | ( | fr_value_box_t const * | vb | ) |
int fr_value_box_escape_in_place | ( | fr_value_box_t * | vb, |
fr_value_box_escape_t | escape, | ||
fr_value_box_safe_for_t | safe_for, | ||
void * | uctx | ||
) |
Escape a single value box in place.
[in] | vb | to escape. |
[in] | escape | function to apply to the value box. |
[in] | safe_for | the escaped value to check value boxes again. box has an escaped value that matches, it will not be re-escaped. |
[in] | uctx | user context to pass to the escape function. |
Definition at line 5945 of file value.c.
|
static |
Convert octets to a fixed size value box value.
All fixed size types are allowed.
dst | Where to write result of casting. |
dst_type | to cast to. |
dst_enumv | enumeration values. |
src | Input data. |
Definition at line 2147 of file value.c.
Removes a single layer of nesting, moving all children into the parent list.
[in] | ctx | to reparent children in if steal is true. |
[in] | list | to flatten. |
[in] | steal | whether to change the talloc ctx of children. |
[in] | free | whether to free any group boxes which have had their children removed. |
Definition at line 6003 of file value.c.
ssize_t fr_value_box_from_network | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
fr_type_t | type, | ||
fr_dict_attr_t const * | enumv, | ||
fr_dbuff_t * | dbuff, | ||
size_t | len, | ||
bool | tainted | ||
) |
Decode a fr_value_box_t from serialized binary data.
The general deserialization rules are:
Dates are decoded as 32bit unsigned UNIX timestamps.
All of the dictionary rules are respected. string/octets can have a fixed length, or can have an 8/16-bit "length" prefix. If the enumv is not an array, then the input # len MUST be the correct size (not too large or small), otherwise an error is returned.
If the enumv is an array, then the input must have the minimum length, and the number of bytes decoded is capped at the maximum length allowed to be decoded. This behavior allows the caller to decode an array of values simply by calling this function in a loop.
[in] | ctx | Where to allocate any talloc buffers required. |
[out] | dst | value_box to write the result to. |
[in] | type | to decode data to. |
[in] | enumv | Aliases for values. |
[in] | dbuff | Binary data to decode. |
[in] | len | Length of data to decode. For fixed length types we only decode complete values. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 1754 of file value.c.
|
inlinestatic |
Convert integer encoded as string to a fr_value_box_t type.
[out] | dst | where to write parsed value. |
[in] | dst_type | type of integer to convert string to. |
[in] | dst_enumv | Enumeration values. |
[in] | in | String to convert to integer. |
[in] | rules | for parsing string. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 4701 of file value.c.
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, | ||
bool | tainted | ||
) |
ssize_t fr_value_box_from_substr | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
fr_type_t | dst_type, | ||
fr_dict_attr_t const * | dst_enumv, | ||
fr_sbuff_t * | in, | ||
fr_sbuff_parse_rules_t const * | rules, | ||
bool | tainted | ||
) |
Convert string value to a fr_value_box_t type.
[in] | ctx | to alloc strings in. |
[out] | dst | where to write parsed value. |
[in,out] | dst_type | of value data to create/dst_type of value created. |
[in] | dst_enumv | fr_dict_attr_t with string names for uint32 values. |
[in] | in | sbuff to read data from. |
[in] | rules | unescape and termination rules. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 4802 of file value.c.
uint32_t fr_value_box_hash | ( | fr_value_box_t const * | vb | ) |
int fr_value_box_hton | ( | fr_value_box_t * | dst, |
fr_value_box_t const * | src | ||
) |
Performs byte order reversal for types that need it.
[in] | dst | Where to write the result. May be the same as src. |
[in] | src | fr_value_box_t containing an uint32 value. |
Definition at line 1231 of file value.c.
void fr_value_box_increment | ( | fr_value_box_t * | vb | ) |
int fr_value_box_ipaddr | ( | fr_value_box_t * | dst, |
fr_dict_attr_t const * | enumv, | ||
fr_ipaddr_t const * | ipaddr, | ||
bool | tainted | ||
) |
Assign a fr_value_box_t value from an fr_ipaddr_t.
Automatically determines the type of the value box from the ipaddr address family and the length of the prefix field.
[in] | dst | to assign ipaddr to. |
[in] | enumv | Aliases for values. |
[in] | ipaddr | to copy address from. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 3630 of file value.c.
bool fr_value_box_is_truthy | ( | fr_value_box_t const * | in | ) |
Check truthiness of values.
The casting rules for expressions / conditions are slightly different than fr_value_box_cast(). Largely because that function is used to parse configuration files, and parses "yes / no" and "true / false" strings, even if there's no fr_dict_attr_t passed to it.
Definition at line 6326 of file value.c.
int fr_value_box_list_acopy | ( | TALLOC_CTX * | ctx, |
fr_value_box_list_t * | out, | ||
fr_value_box_list_t const * | in | ||
) |
Do a full copy of a list of value boxes.
[in] | ctx | to allocate boxes in. |
[out] | out | Where to write the head of the new list. |
[in] | in | boxes to copy. |
Definition at line 6158 of file value.c.
char* fr_value_box_list_aprint | ( | TALLOC_CTX * | ctx, |
fr_value_box_list_t const * | list, | ||
char const * | delim, | ||
fr_sbuff_escape_rules_t const * | e_rules | ||
) |
Concatenate the string representations of a list of value boxes together.
[in] | ctx | to allocate the buffer in. |
[in] | list | of value boxes. |
[in] | delim | to insert between value box values. |
[in] | e_rules | to control escaping of the concatenated elements. |
Definition at line 6028 of file value.c.
char* fr_value_box_list_aprint_secure | ( | TALLOC_CTX * | ctx, |
fr_value_box_list_t const * | list, | ||
char const * | delim, | ||
fr_sbuff_escape_rules_t const * | e_rules | ||
) |
Concatenate the string representations of a list of value boxes together hiding "secret" values.
[in] | ctx | to allocate the buffer in. |
[in] | list | of value boxes. |
[in] | delim | to insert between value box values. |
[in] | e_rules | to control escaping of the concatenated elements. |
Definition at line 6078 of file value.c.
ssize_t fr_value_box_list_concat_as_octets | ( | bool * | tainted, |
bool * | secret, | ||
fr_dbuff_t * | dbuff, | ||
fr_value_box_list_t * | list, | ||
uint8_t const * | sep, | ||
size_t | sep_len, | ||
fr_value_box_list_action_t | proc_action, | ||
bool | flatten | ||
) |
Concatenate a list of value boxes together.
All boxes will be removed from the list.
[out] | tainted | If nonnull, will be set to true if any input boxes are tainted. bool pointed to must be initialised. |
[out] | secret | If nonnull, will be set to true if any input boxes are secret. |
[out] | dbuff | to write the result of the concatenation to. |
[in] | list | to concatenate. |
[in] | sep | Insert a separator between the values. |
[in] | sep_len | Length of the separator. |
[in] | proc_action | What to do with the boxes in the list once they've been processed. |
[in] | flatten | If true and we encounter a FR_TYPE_GROUP, we concat the contents of its children together. If false, the contents will be cast to FR_TYPE_OCTETS. |
Definition at line 5677 of file value.c.
ssize_t fr_value_box_list_concat_as_string | ( | bool * | tainted, |
bool * | secret, | ||
fr_sbuff_t * | sbuff, | ||
fr_value_box_list_t * | list, | ||
char const * | sep, | ||
size_t | sep_len, | ||
fr_sbuff_escape_rules_t const * | e_rules, | ||
fr_value_box_list_action_t | proc_action, | ||
fr_value_box_safe_for_t | safe_for, | ||
bool | flatten | ||
) |
Concatenate a list of value boxes together.
All boxes will be removed from the list.
[out] | tainted | If nonnull, will be set to true if any input boxes are tainted. bool pointed to must be initialised. |
[out] | secret | If nonnull, will be set to true if any input boxes are secret. |
[out] | sbuff | to write the result of the concatenation to. |
[in] | list | to concatenate. |
[in] | sep | Insert a separator between the values. |
[in] | sep_len | Length of the separator. |
[in] | e_rules | To apply to FR_TYPE_STRING types. Is not currently applied to any other box type. |
[in] | proc_action | What to do with the boxes in the list once they've been processed. |
[in] | safe_for | if value has this safe_for value, don't apply the escape rules. |
[in] | flatten | If true and we encounter a FR_TYPE_GROUP, we concat the contents of its children together. If false, the contents will be cast to FR_TYPE_STRING. |
Definition at line 5584 of file value.c.
int fr_value_box_list_concat_in_place | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | out, | ||
fr_value_box_list_t * | list, | ||
fr_type_t | type, | ||
fr_value_box_list_action_t | proc_action, | ||
bool | flatten, | ||
size_t | max_size | ||
) |
Concatenate a list of value boxes.
[in] | ctx | to allocate new value buffer in. |
[out] | out | Where to write the resulting box. |
[in] | list | to concatenate together. |
[in] | type | May be FR_TYPE_STRING or FR_TYPE_OCTETS, no other types are supported. |
[in] | proc_action | What to do with the boxes in the list once they've been processed. |
[in] | flatten | If true and we encounter a FR_TYPE_GROUP, we concat the contents of its children together. If false, the contents will be cast to the given type. |
[in] | max_size | of the value. |
Definition at line 5777 of file value.c.
void fr_value_box_list_debug | ( | fr_value_box_list_t const * | head | ) |
int fr_value_box_list_escape_in_place | ( | fr_value_box_list_t * | list, |
fr_value_box_escape_t | escape, | ||
fr_value_box_safe_for_t | safe_for, | ||
void * | uctx | ||
) |
Escape a list of value boxes in place.
[in] | list | to escape. |
[in] | escape | function to apply to the value box. |
[in] | safe_for | the escaped value to check value boxes again. box has an escaped value that matches, it will not be re-escaped. |
[in] | uctx | user context to pass to the escape function. |
Definition at line 5982 of file value.c.
void fr_value_box_list_mark_safe_for | ( | fr_value_box_list_t * | list, |
fr_value_box_safe_for_t | safe_for | ||
) |
void fr_value_box_list_taint | ( | fr_value_box_list_t * | head | ) |
bool fr_value_box_list_tainted | ( | fr_value_box_list_t const * | head | ) |
void fr_value_box_list_untaint | ( | fr_value_box_list_t * | head | ) |
void fr_value_box_list_verify | ( | char const * | file, |
int | line, | ||
fr_value_box_list_t const * | list | ||
) |
void fr_value_box_mark_unsafe | ( | fr_value_box_t * | vb | ) |
int fr_value_box_mem_alloc | ( | TALLOC_CTX * | ctx, |
uint8_t ** | out, | ||
fr_value_box_t * | dst, | ||
fr_dict_attr_t const * | enumv, | ||
size_t | len, | ||
bool | tainted | ||
) |
Pre-allocate an octets buffer for filling by the caller.
[in] | ctx | to allocate any new buffers in. |
[out] | out | If non-null will be filled with a pointer to the new buffer. |
[in] | dst | to assign new buffer to. |
[in] | enumv | Aliases for values. |
[in] | len | of data in the buffer. If 0, a zero length talloc buffer will be alloced. dst->vb_octets will NOT be NULL. You should use the length field of the box to determine if any value is assigned. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 4371 of file value.c.
int fr_value_box_mem_append | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
uint8_t const * | src, | ||
size_t | len, | ||
bool | tainted | ||
) |
Append data to an existing fr_value_box_t.
[in] | ctx | Where to allocate any talloc buffers required. |
[in] | dst | value box to append to. |
[in] | src | octets data to append. |
[in] | len | length of octets data. |
[in] | tainted | Whether src is tainted. |
Definition at line 4587 of file value.c.
int fr_value_box_mem_append_buffer | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
uint8_t const * | src, | ||
bool | tainted | ||
) |
Append a talloc buffer to an existing fr_value_box_t.
[in] | ctx | Where to allocate any talloc buffers required. |
[in] | dst | value box to append to. |
[in] | src | octets data to append. |
[in] | tainted | Whether src is tainted. |
Definition at line 4637 of file value.c.
int fr_value_box_mem_realloc | ( | TALLOC_CTX * | ctx, |
uint8_t ** | out, | ||
fr_value_box_t * | dst, | ||
size_t | len | ||
) |
Change the length of a buffer already allocated to a value box.
[in] | ctx | to realloc buffer in. |
[out] | out | if non-null where to write a pointer to the new buffer. |
[in] | dst | to realloc buffer for. |
[in] | len | to realloc to. |
Definition at line 4404 of file value.c.
int fr_value_box_memdup | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
fr_dict_attr_t const * | enumv, | ||
uint8_t const * | src, | ||
size_t | len, | ||
bool | tainted | ||
) |
Copy a buffer to a fr_value_box_t.
Copy a buffer containing binary data, setting fields in the dst value box appropriately.
[in] | ctx | to allocate any new buffers in. |
[in] | dst | to assign new buffer to. |
[in] | enumv | Aliases for values. |
[in] | src | a buffer. |
[in] | len | of data in the buffer. If 0, a zero length talloc buffer will be alloced. dst->vb_octets will NOT be NULL. You should use the length field of the box to determine if any value is assigned. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 4468 of file value.c.
int fr_value_box_memdup_buffer | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
fr_dict_attr_t const * | enumv, | ||
uint8_t const * | src, | ||
bool | tainted | ||
) |
Copy a talloced buffer to a fr_value_box_t.
Copy a buffer containing binary data, setting fields in the dst value box appropriately.
[in] | ctx | to allocate any new buffers in. |
[in] | dst | to assign new buffer to. |
[in] | enumv | Aliases for values. |
[in] | src | a buffer. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 4526 of file value.c.
void fr_value_box_memdup_buffer_shallow | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
fr_dict_attr_t const * | enumv, | ||
uint8_t const * | src, | ||
bool | tainted | ||
) |
Assign a talloced buffer to a box, but don't copy it.
Adds a reference to the src buffer so that it cannot be freed until the ctx is freed.
[in] | ctx | to allocate any new buffers in. |
[in] | dst | to assign buffer to. |
[in] | enumv | Aliases for values. |
[in] | src | a talloced buffer. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 4566 of file value.c.
int fr_value_box_memdup_dbuff | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
fr_dict_attr_t const * | enumv, | ||
fr_dbuff_t * | dbuff, | ||
size_t | len, | ||
bool | tainted | ||
) |
void fr_value_box_memdup_shallow | ( | fr_value_box_t * | dst, |
fr_dict_attr_t const * | enumv, | ||
uint8_t const * | src, | ||
size_t | len, | ||
bool | tainted | ||
) |
Assign a buffer to a box, but don't copy it.
Adds a reference to the src buffer so that it cannot be freed until the ctx is freed.
Caller should set dst->taint = true, where the value was acquired from an untrusted source.
[in] | dst | to assign buffer to. |
[in] | enumv | Aliases for values. |
[in] | src | a talloced buffer. |
[in] | len | of buffer. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 4548 of file value.c.
size_t fr_value_box_network_length | ( | fr_value_box_t const * | value | ) |
Get the size of the value held by the fr_value_box_t.
This is the length of the NETWORK presentation
Definition at line 1325 of file value.c.
ssize_t fr_value_box_print | ( | fr_sbuff_t * | out, |
fr_value_box_t const * | data, | ||
fr_sbuff_escape_rules_t const * | e_rules | ||
) |
Print one boxed value to a string.
This function should primarily be used when a fr_value_box_t is being serialized in some non-standard way, i.e. as a value for a field in a database, in all other instances it's better to use fr_value_box_print_quoted.
[in] | out | Where to write the printed string. |
[in] | data | Value box to print. |
[in] | e_rules | To apply to FR_TYPE_STRING types, for escaping quotation characters only. Is not currently applied to any other box type. |
Definition at line 5352 of file value.c.
ssize_t fr_value_box_print_quoted | ( | fr_sbuff_t * | out, |
fr_value_box_t const * | data, | ||
fr_token_t | quote | ||
) |
Print one boxed value to a string with quotes (where needed)
[in] | out | Where to write the printed string. |
[in] | data | Value box to print. |
[in] | quote | To apply to FR_TYPE_STRING types. Is not currently applied to any other box type. |
Definition at line 5540 of file value.c.
int fr_value_box_steal | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
fr_value_box_t * | src | ||
) |
Copy value data verbatim moving any buffers to the specified context.
[in] | ctx | to allocate any new buffers in. |
[in] | dst | to copy value to. |
[in] | src | to copy value from. |
Definition at line 3858 of file value.c.
int fr_value_box_strdup | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
fr_dict_attr_t const * | enumv, | ||
char const * | src, | ||
bool | tainted | ||
) |
Copy a nul terminated string to a fr_value_box_t.
[in] | ctx | to allocate any new buffers in. |
[in] | dst | to assign new buffer to. |
[in] | enumv | Aliases for values. |
[in] | src | a nul terminated buffer. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 3927 of file value.c.
void fr_value_box_strdup_shallow | ( | fr_value_box_t * | dst, |
fr_dict_attr_t const * | enumv, | ||
char const * | src, | ||
bool | tainted | ||
) |
Assign a buffer containing a nul terminated string to a box, but don't copy it.
[in] | dst | to assign string to. |
[in] | enumv | Aliases for values. |
[in] | src | to copy string from. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 4036 of file value.c.
void fr_value_box_strdup_shallow_replace | ( | fr_value_box_t * | vb, |
char const * | src, | ||
ssize_t | len | ||
) |
Free the existing buffer (if talloced) associated with the valuebox, and replace it with a new one.
[in] | vb | to replace string in. |
[in] | src | to assign string from. |
[in] | len | of src. |
Definition at line 4052 of file value.c.
int fr_value_box_strtrim | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | vb | ||
) |
int fr_value_box_to_key | ( | uint8_t ** | out, |
size_t * | outlen, | ||
fr_value_box_t const * | value | ||
) |
Get a key from a value box.
[in,out] | out | - set to a small buffer on input. If the callback has more data than is available here, the callback can update "out" to point elsewhere |
[in,out] | outlen | The number of bits available in the initial buffer. On output, the number of bits available in the key |
[in] | value | the value box which contains the key |
Definition at line 2084 of file value.c.
ssize_t fr_value_box_to_network | ( | fr_dbuff_t * | dbuff, |
fr_value_box_t const * | value | ||
) |
Encode a single value box, serializing its contents in generic network format.
The serialized form of fr_value_box_t may not match the requirements of your protocol completely. In cases where they do not, you should overload specific types in the function calling fr_value_box_to_network.
The general serialization rules are:
FR_TYPE_SIZE is not encodable, as it is system specific.
This function will not encode structural types (TLVs, VSAs etc...). These are usually specific to the protocol anyway.
All of the dictionary rules are respected. string/octets can have a fixed length (which is zero-padded if necessary), or can have an 8/16-bit "length" prefix.
[out] | dbuff | Where to write serialized data. |
[in] | value | to encode. |
Definition at line 1404 of file value.c.
int fr_value_box_vasprintf | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | dst, | ||
fr_dict_attr_t const * | enumv, | ||
bool | tainted, | ||
char const * | fmt, | ||
va_list | ap | ||
) |
Print a formatted string using our internal printf wrapper and assign it to a value box.
[in] | ctx | to allocate any new buffers in. |
[in] | dst | to assign new buffer to. |
[in] | enumv | Aliases for values. |
[in] | fmt | The printf format string to process. |
[in] | tainted | Whether the value came from a trusted source. |
[in] | ap | Substitution arguments. |
Definition at line 3983 of file value.c.
void fr_value_box_verify | ( | char const * | file, |
int | line, | ||
fr_value_box_t const * | vb | ||
) |
Validation function to check that a fr_value_box_t is correctly initialised.
Definition at line 6229 of file value.c.
size_t fr_value_str_unescape | ( | fr_sbuff_t * | out, |
fr_sbuff_t * | in, | ||
size_t | inlen, | ||
char | quote | ||
) |
Convert a string value with escape sequences into its binary form.
The quote character determines the escape sequences recognised.
- \\ - Literal backslash. - \<quote> - The quotation char.
- \a - Alert. - \b - Backspace. - \e - Escape character i.e. (\) - \r - Carriage return. - \n - Newline. - \t - Tab. - \v - Vertical tab - \<oct> - An octal escape sequence. - \x<hex> - A hex escape sequence.
[out] | out | Where to write the unescaped string. |
[in] | in | The string to unescape. |
[in] | inlen | Length of input string. Pass SIZE_MAX to copy all data in the input buffer. |
[in] | quote | Character around the string, determines unescaping mode. |
Definition at line 1128 of file value.c.
size_t fr_value_substr_unescape | ( | fr_sbuff_t * | out, |
fr_sbuff_t * | in, | ||
size_t | inlen, | ||
char | quote | ||
) |
Convert a string value with escape sequences into its binary form.
The quote character determines the escape sequences recognised.
- \\ - Literal backslash. - \<quote> - The quotation char.
- \a - Alert. - \b - Backspace. - \e - Escape character i.e. (\) - \r - Carriage return. - \n - Newline. - \t - Tab. - \v - Vertical tab - \<oct> - An octal escape sequence. - \x<hex> - A hex escape sequence.
[out] | out | Where to write the unescaped string. |
[in] | in | The string to unescape. |
[in] | inlen | Length of input string. Pass SIZE_MAX to copy all data in the input buffer. |
[in] | quote | Character around the string, determines unescaping mode. |
Definition at line 1201 of file value.c.
int fr_value_unbox_ipaddr | ( | fr_ipaddr_t * | dst, |
fr_value_box_t * | src | ||
) |
size_t const fr_value_box_field_sizes[] |
How many bytes wide each of the value data fields are.
This is useful when copying a value from a fr_value_box_t to a memory location passed as a void *.
|
static |
|
static |
|
static |
size_t const fr_value_box_offsets[] |
Where the value starts in the fr_value_box_t.
fr_sbuff_escape_rules_t fr_value_escape_backtick |
fr_sbuff_escape_rules_t* fr_value_escape_by_char[UINT8_MAX+1] |
fr_sbuff_escape_rules_t* fr_value_escape_by_quote[T_TOKEN_LAST] |
fr_sbuff_escape_rules_t fr_value_escape_double |
fr_sbuff_escape_rules_t fr_value_escape_secret |
fr_sbuff_escape_rules_t fr_value_escape_single |
fr_sbuff_escape_rules_t fr_value_escape_solidus |
fr_sbuff_escape_rules_t fr_value_escape_unprintables |
fr_sbuff_unescape_rules_t fr_value_unescape_backtick |
fr_sbuff_unescape_rules_t* fr_value_unescape_by_char[UINT8_MAX+1] |
fr_sbuff_unescape_rules_t* fr_value_unescape_by_quote[T_TOKEN_LAST] |
fr_sbuff_unescape_rules_t fr_value_unescape_double |
fr_sbuff_unescape_rules_t fr_value_unescape_single |
fr_sbuff_unescape_rules_t fr_value_unescape_solidus |
|
static |
fr_sbuff_parse_rules_t const* value_parse_rules_3quoted[T_TOKEN_LAST] |
fr_sbuff_parse_rules_t const value_parse_rules_backtick_3quoted |
fr_sbuff_parse_rules_t const value_parse_rules_backtick_quoted |
fr_sbuff_parse_rules_t const value_parse_rules_backtick_unquoted |
fr_sbuff_parse_rules_t const value_parse_rules_bareword_quoted |
fr_sbuff_parse_rules_t const value_parse_rules_bareword_unquoted |
fr_sbuff_parse_rules_t const value_parse_rules_double_3quoted |
fr_sbuff_parse_rules_t const value_parse_rules_double_quoted |
fr_sbuff_parse_rules_t const value_parse_rules_double_unquoted |
fr_sbuff_parse_rules_t const* value_parse_rules_quoted[T_TOKEN_LAST] |
Parse rules for quoted strings.
These parse rules should be used for internal parsing functions that are working with configuration files.
They include appropriate quote terminals to force functions parsing quoted strings to return when they reach a quote character.
fr_sbuff_parse_rules_t const* value_parse_rules_quoted_char[UINT8_MAX] |
fr_sbuff_parse_rules_t const value_parse_rules_single_3quoted |
fr_sbuff_parse_rules_t const value_parse_rules_single_quoted |
fr_sbuff_parse_rules_t const value_parse_rules_single_unquoted |
fr_sbuff_parse_rules_t const value_parse_rules_solidus_3quoted |
fr_sbuff_parse_rules_t const value_parse_rules_solidus_quoted |
fr_sbuff_parse_rules_t const value_parse_rules_solidus_unquoted |
fr_sbuff_parse_rules_t const* value_parse_rules_unquoted[T_TOKEN_LAST] |
Parse rules for non-quoted strings.
These parse rules should be used for processing escape sequences in data from external data sources like SQL databases and REST APIs.
They do not include terminals to stop parsing as it assumes the values are discrete, and not wrapped in quotes.
fr_sbuff_parse_rules_t const* value_parse_rules_unquoted_char[UINT8_MAX] |