The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
value.c File Reference

Boxed value structures and functions to manipulate them. More...

#include <freeradius-devel/util/value.h>
#include <freeradius-devel/util/base16.h>
#include <freeradius-devel/util/size.h>
#include <math.h>
#include <float.h>
+ Include dependency graph for value.c:

Go to the source code of this file.

Data Structures

struct  fr_value_box_escape_rules_ctx_t
 
struct  fr_value_box_ipaddr_sizes_t
 

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, ...)   fprintf(fp, "%*s" _fmt "\n", 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])
 How many bytes on-the-wire would a fr_value_box_t value consume.
 
#define O(_x, _y)   case FR_TYPE_##_x: return vb->vb_##_y
 
#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)
 
#define VB_NAME   "fr_value_box_t %p (from %s:%d)"
 
#define VB_NAME_LOCATION(_x)   (void const *) (_x), (_x)->file ? (_x)->file : "", (_x)->line
 
#define VERIFY_CLEAR(_vb)   UNCONST(fr_value_box_t *, _vb)->verified = false
 
#define VERIFY_IS_SET(_vb)   UNCONST(fr_value_box_t *, _vb)->verified
 Sanity checks.
 
#define VERIFY_SET(_vb)   UNCONST(fr_value_box_t *, _vb)->verified = true
 

Functions

static void _fr_value_box_debug (FILE *fp, fr_value_box_t const *vb, int depth, int idx)
 
static void _fr_value_box_list_debug (FILE *fp, 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.
 
static int _value_box_escape_rules (fr_value_box_t *vb, void *uctx)
 
static void _value_box_list_safety_merge (fr_value_box_t *out, fr_value_box_list_t const *list)
 Merge the safety of every leaf box in a list into out.
 
static void _value_box_safety_merge (fr_value_box_safety_t *out, fr_value_box_safety_t const *in)
 Merge one safety into another.
 
static fr_cmp_ret_t float_cmp (double a, double b)
 Compare two floating point numbers for equality.
 
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.
 
uint64_t fr_value_box_as_uint64 (fr_value_box_t const *vb)
 Return a uint64_t from a fr_value_box_t.
 
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.
 
static fr_dict_attr_t const * fr_value_box_attr_enumv (fr_dict_attr_t const *da)
 
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.
 
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.
 
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.
 
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.
 
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.
 
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)
 
int fr_value_box_bstrndup_replace (TALLOC_CTX *ctx, 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 copy of a new one.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
static int fr_value_box_cast_unsupported (fr_type_t dst, fr_type_t src)
 
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.
 
void fr_value_box_clear_value (fr_value_box_t *data)
 Clear/free any existing value.
 
fr_cmp_ret_t fr_value_box_cmp (fr_value_box_t const *a, fr_value_box_t const *b)
 Compare two values.
 
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.
 
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.
 
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.
 
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.
 
void fr_value_box_debug (FILE *fp, fr_value_box_t const *vb)
 Print the value of a box as info messages.
 
int fr_value_box_escape_erules (fr_value_box_t *vb, void *uctx)
 Escape a value-box in place using the supplied fr_sbuff_escape_rules_t in uctx.
 
int fr_value_box_escape_in_place (fr_value_box_t *vb, fr_value_box_escape_t const *escape, void *uctx)
 Escape a single value box in place.
 
int fr_value_box_escape_in_place_erules (TALLOC_CTX *ctx, fr_value_box_t *vb, fr_sbuff_escape_rules_t const *erules)
 Escape a value-box in place using sbuff escaping rules, and mark it safe-for.
 
int fr_value_box_escape_in_place_func (TALLOC_CTX *ctx, fr_value_box_t *vb, fr_sbuff_escape_func_t escape)
 Escape a value box in place using an sbuff escape function.
 
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.
 
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.
 
ssize_t fr_value_box_from_memory (TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t type, fr_dict_attr_t const *enumv, void const *src, size_t len)
 Decode a fr_value_box_t from a C type in memory.
 
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.
 
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.
 
fr_slen_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)
 
fr_slen_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)
 Convert string value to a fr_value_box_t type.
 
uint32_t fr_value_box_hash (fr_value_box_t const *vb)
 Hash the contents of a value box.
 
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.
 
void fr_value_box_increment (fr_value_box_t *vb)
 Increment a boxed value.
 
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.
 
ssize_t fr_value_box_ipaddr_from_network (fr_value_box_t *dst, fr_type_t type, fr_dict_attr_t const *enumv, int prefix_len, uint8_t const *data, size_t data_len, bool fixed, bool tainted)
 Decode a fr_value_box_t of type IP address / prefix.
 
bool fr_value_box_is_truthy (fr_value_box_t const *in)
 Check truthiness of values.
 
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.
 
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.
 
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.
 
ssize_t fr_value_box_list_concat_as_octets (fr_value_box_safety_t *safety, 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.
 
ssize_t fr_value_box_list_concat_as_string (fr_value_box_safety_t *safety, 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.
 
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.
 
void fr_value_box_list_debug (FILE *fp, fr_value_box_list_t const *head)
 Print a list of value boxes as info messages.
 
int fr_value_box_list_escape_in_place (fr_value_box_list_t *list, fr_value_box_escape_t const *escape, void *uctx)
 Escape a list of value boxes in place.
 
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.
 
void fr_value_box_list_safety_merge (fr_value_box_t *out, fr_value_box_list_t const *list)
 Set the safety of out to the most restrictive safety of any leaf box in a list.
 
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.
 
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".
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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)
 
void fr_value_box_safety_copy (fr_value_box_t *out, fr_value_box_t const *in)
 Copy the safety values from one box to another.
 
void fr_value_box_safety_copy_changed (fr_value_box_t *out, fr_value_box_t const *in)
 Copy the safety values from one box to another.
 
void fr_value_box_safety_merge (fr_value_box_t *out, fr_value_box_t const *in)
 Merge safety results.
 
void fr_value_box_safety_set (fr_value_box_t *box, fr_value_box_safety_t const *safety)
 Replace the safety of a box.
 
void fr_value_box_set_attr (fr_value_box_t *dst, fr_dict_attr_t const *da)
 
void fr_value_box_set_cursor_shallow (fr_value_box_t *dst, fr_type_t type, void *cursor, char const *name)
 
void fr_value_box_set_secret (fr_value_box_t *box, bool secret)
 Mark a box as holding a secret, or not.
 
void fr_value_box_set_void_shallow (fr_value_box_t *dst, void const *ptr)
 Assign a void pointer to a box.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
fr_sbuff_err_t fr_value_str_unescape (size_t *len, fr_sbuff_t *out, fr_sbuff_t *in, size_t max, char quote)
 Convert a string value with escape sequences into its binary form.
 
fr_sbuff_err_t fr_value_substr_unescape (size_t *len, fr_sbuff_t *out, fr_sbuff_t *in, size_t max, char quote)
 Convert a string value with escape sequences into its binary form.
 
int fr_value_unbox_ipaddr (fr_ipaddr_t *dst, fr_value_box_t *src)
 Unbox an IP address performing a type check.
 
static int value_box_ipv6_scope_id_to_network (fr_dbuff_t *dbuff, fr_value_box_t const *value)
 Encode the scope_id of an IPv6 address or prefix as one byte.
 

Variables

size_t const fr_value_box_field_sizes []
 How many bytes wide each of the value data fields are.
 
static uint64_t const fr_value_box_integer_max []
 
static int64_t const fr_value_box_integer_min []
 
static size_t const fr_value_box_network_sizes [FR_TYPE_MAX+1][2]
 
size_t const fr_value_box_offsets []
 Where the value starts in the fr_value_box_t.
 
fr_sbuff_escape_rules_t const fr_value_escape_backtick
 
fr_sbuff_escape_rules_t const * fr_value_escape_by_char [SBUFF_CHAR_CLASS]
 
fr_sbuff_escape_rules_t const * fr_value_escape_by_quote [T_TOKEN_LAST]
 
fr_sbuff_escape_rules_t const fr_value_escape_double
 
fr_sbuff_escape_rules_t const fr_value_escape_secret
 Escape secret fields by simply mashing all data to '.
 
fr_sbuff_escape_rules_t const fr_value_escape_single
 
fr_sbuff_escape_rules_t const fr_value_escape_solidus
 
fr_sbuff_escape_rules_t const fr_value_escape_unprintables
 
fr_sbuff_unescape_rules_t const fr_value_unescape_backtick
 
fr_sbuff_unescape_rules_t const * fr_value_unescape_by_char [SBUFF_CHAR_CLASS]
 
fr_sbuff_unescape_rules_t const * fr_value_unescape_by_quote [T_TOKEN_LAST]
 
fr_sbuff_unescape_rules_t const fr_value_unescape_double
 
fr_sbuff_unescape_rules_t const fr_value_unescape_single
 
fr_sbuff_unescape_rules_t const fr_value_unescape_solidus
 
static const fr_value_box_ipaddr_sizes_t ipaddr_sizes [FR_TYPE_MAX]
 
static uint8_t const v4_v6_map []
 v4 to v6 mapping prefix
 

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.
 
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.
 
fr_sbuff_parse_rules_t const * value_parse_rules_quoted_char [SBUFF_CHAR_CLASS]
 
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.
 
fr_sbuff_parse_rules_t const * value_parse_rules_unquoted_char [SBUFF_CHAR_CLASS]
 

Detailed Description

Boxed value structures and functions to manipulate them.

There are three notional data formats used in the server:

Definition in file value.c.


Data Structure Documentation

◆ fr_value_box_escape_rules_ctx_t

struct fr_value_box_escape_rules_ctx_t

Definition at line 6979 of file value.c.

+ Collaboration diagram for fr_value_box_escape_rules_ctx_t:
Data Fields
TALLOC_CTX * ctx
fr_sbuff_escape_rules_t const * erules

◆ fr_value_box_ipaddr_sizes_t

struct fr_value_box_ipaddr_sizes_t

Definition at line 2303 of file value.c.

Data Fields
size_t addr_max
size_t addr_min
int af
int prefix_max
int prefix_min

Macro Definition Documentation

◆ _VALUE_PRIVATE

#define _VALUE_PRIVATE

Definition at line 47 of file value.c.

◆ CAST_IP_FIX_COMBO

#define CAST_IP_FIX_COMBO
Value:
if (src->vb_ip.af == AF_INET) { \
src_type = FR_TYPE_IPV4_ADDR; \
} else if (src->vb_ip.af == AF_INET6) { \
src_type = FR_TYPE_IPV6_ADDR; \
} \
break; \
if (src->vb_ip.af == AF_INET) { \
src_type = FR_TYPE_IPV4_PREFIX; \
} else if (src->vb_ip.af == AF_INET6) { \
src_type = FR_TYPE_IPV6_PREFIX; \
} \
break
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
@ FR_TYPE_IPV6_PREFIX
IPv6 Prefix.
@ FR_TYPE_COMBO_IP_PREFIX
IPv4 or IPv6 address prefix depending on length.
@ FR_TYPE_IPV6_ADDR
128 Bit IPv6 Address.
@ FR_TYPE_IPV4_PREFIX
IPv4 Prefix.
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.

Definition at line 2849 of file value.c.

◆ COMPARE

#define COMPARE (   _type)    return CMP(memcmp(&a->datum._type, &b->datum._type, sizeof(a->datum._type)), 0)

◆ INFO_INDENT

#define INFO_INDENT (   _fmt,
  ... 
)    fprintf(fp, "%*s" _fmt "\n", depth * 2, " ", ## __VA_ARGS__)

Definition at line 7671 of file value.c.

◆ network_max_size

#define network_max_size (   _x)    (fr_value_box_network_sizes[_x][1])

Definition at line 117 of file value.c.

◆ network_min_size

#define network_min_size (   _x)    (fr_value_box_network_sizes[_x][0])

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.

Note
Don't use this array directly when determining the length that would be consumed by the on-the-wire representation. Use fr_value_box_network_length instead, as that deals with variable length attributes too.

Definition at line 116 of file value.c.

◆ O

#define O (   _x,
  _y 
)    case FR_TYPE_##_x: return vb->vb_##_y

◆ RETURN

#define RETURN (   _type)    return CMP(a->datum._type, b->datum._type)

◆ SIGN_BIT_HIGH

#define SIGN_BIT_HIGH (   _int,
  _len 
)    ((((uint64_t)1) << (((_len) << 3) - 1)) & (_int))

◆ SIGN_PROMOTE

#define SIGN_PROMOTE (   _int,
  _len 
)
Value:
((_len) < sizeof(_int) ? \
(_int) | (~((__typeof__(_int))0)) << ((_len) << 3) : (_int))

◆ VB_NAME

#define VB_NAME   "fr_value_box_t %p (from %s:%d)"

Definition at line 7337 of file value.c.

◆ VB_NAME_LOCATION

#define VB_NAME_LOCATION (   _x)    (void const *) (_x), (_x)->file ? (_x)->file : "", (_x)->line

Definition at line 7338 of file value.c.

◆ VERIFY_CLEAR

#define VERIFY_CLEAR (   _vb)    UNCONST(fr_value_box_t *, _vb)->verified = false

Definition at line 99 of file value.c.

◆ VERIFY_IS_SET

#define VERIFY_IS_SET (   _vb)    UNCONST(fr_value_box_t *, _vb)->verified

Sanity checks.

There should never be an instance where these fail.

Definition at line 97 of file value.c.

◆ VERIFY_SET

#define VERIFY_SET (   _vb)    UNCONST(fr_value_box_t *, _vb)->verified = true

Definition at line 98 of file value.c.

Function Documentation

◆ _fr_value_box_debug()

static void _fr_value_box_debug ( FILE *  fp,
fr_value_box_t const *  vb,
int  depth,
int  idx 
)
static

Definition at line 7692 of file value.c.

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

◆ _fr_value_box_list_debug()

static void _fr_value_box_list_debug ( FILE *  fp,
fr_value_box_list_t const *  head,
int  depth 
)
static

Definition at line 7674 of file value.c.

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

◆ _fr_value_box_mark_safe_for()

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.

Definition at line 7448 of file value.c.

◆ _value_box_escape_rules()

static int _value_box_escape_rules ( fr_value_box_t *  vb,
void *  uctx 
)
static

Definition at line 6984 of file value.c.

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

◆ _value_box_list_safety_merge()

static void _value_box_list_safety_merge ( fr_value_box_t *  out,
fr_value_box_list_t const *  list 
)
static

Merge the safety of every leaf box in a list into out.

Recurses into group boxes, which carry no safety of their own.

Definition at line 7588 of file value.c.

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

◆ _value_box_safety_merge()

static void _value_box_safety_merge ( fr_value_box_safety_t *  out,
fr_value_box_safety_t const *  in 
)
static

Merge one safety into another.

Parameters
[in,out]outsafety to narrow.
[in]insafety to merge in.

Definition at line 7522 of file value.c.

+ Here is the caller graph for this function:

◆ float_cmp()

static fr_cmp_ret_t float_cmp ( double  a,
double  b 
)
static

Compare two floating point numbers for equality.

We're not quite supposed to use DBL_EPSILON here, and are instead supposed to choose our own epsilon. But this is good enough for most purposed.

Definition at line 716 of file value.c.

+ Here is the caller graph for this function:

◆ fr_regex_cmp_op()

int fr_regex_cmp_op ( fr_token_t  op,
fr_value_box_t const *  a,
fr_value_box_t const *  b 
)
extern

Compare two boxes using an operator.

Todo:
  • allow /foo/i on the RHS

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.

Parameters
[in]opto use in comparison. MUST be T_OP_REG_EQ or T_OP_REG_NE
[in]aValue to compare, MUST be FR_TYPE_STRING
[in]buncompiled regex as FR_TYPE_STRING
Returns
  • 1 if true
  • 0 if false
  • -1 on failure.

Definition at line 1065 of file regex.c.

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

◆ fr_value_box_as_uint64()

uint64_t fr_value_box_as_uint64 ( fr_value_box_t const *  vb)

Return a uint64_t from a fr_value_box_t.

Parameters
[in]vbthe value-box. Must be an unsigned integer data type.
Returns
the value as uint64_t.

Definition at line 4315 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_asprintf()

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.

Parameters
[in]ctxto allocate any new buffers in.
[in]dstto assign new buffer to.
[in]enumvAliases for values.
[in]taintedWhether the value came from a trusted source.
[in]fmtThe printf format string to process.
[in]...Substitution arguments.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 4790 of file value.c.

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

◆ fr_value_box_attr_enumv()

static fr_dict_attr_t const * fr_value_box_attr_enumv ( fr_dict_attr_t const *  da)
static

Definition at line 5330 of file value.c.

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

◆ fr_value_box_bstr_alloc()

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.

Parameters
[in]ctxto allocate any new buffers in.
[out]outif non-null where to write a pointer to the new buffer.
[in]dstto assign new buffer to.
[in]enumvAliases for values.
[in]lenof buffer to allocate.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 4879 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_bstr_realloc()

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.

Note
Do not use on an uninitialised box.
Parameters
[in]ctxto realloc buffer in.
[out]outif non-null where to write a pointer to the new buffer.
[in]dstto realloc buffer for.
[in]lento realloc to (don't include nul byte).
Returns
  • 0 on success.
    • -1 on failure.

Definition at line 4912 of file value.c.

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

◆ fr_value_box_bstrdup_buffer()

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.

Parameters
[in]ctxto allocate any new buffers in.
[in]dstto assign new buffer to.
[in]enumvAliases for values.
[in]srca talloced nul terminated buffer.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 5016 of file value.c.

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

◆ fr_value_box_bstrdup_buffer_shallow()

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.

Parameters
[in]ctxto add reference from. If NULL no reference will be added.
[in]dstto assign string to.
[in]enumvAliases for values.
[in]srcto copy string from.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 5061 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_bstrndup()

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.

Parameters
[in]ctxto allocate any new buffers in.
[in]dstto assign buffer to.
[in]enumvAliases for values.
[in]srca string. May be NULL only if len == 0.
[in]lenof src.
[in]taintedWhether the value came from a trusted source.

Definition at line 4953 of file value.c.

+ Here is the call graph for this function:

◆ fr_value_box_bstrndup_dbuff()

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 
)

Definition at line 4977 of file value.c.

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

◆ fr_value_box_bstrndup_replace()

int fr_value_box_bstrndup_replace ( TALLOC_CTX *  ctx,
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 copy of a new one.

The box's flags are left as they were. src may alias the existing value, the copy is taken before the existing value is freed.

Parameters
[in]ctxto allocate the copy in.
[in]vbto replace string in.
[in]srcto copy string from.
[in]lenof src. If negative, src must be NUL terminated.
Returns
  • 0 on success.
  • -1 on allocation failure.

Definition at line 4848 of file value.c.

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

◆ fr_value_box_bstrndup_shallow()

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.

Parameters
[in]dstto assign new buffer to.
[in]enumvAliases for values.
[in]srca string.
[in]lenof src.
[in]taintedWhether the value came from a trusted source.

Definition at line 5040 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_cast()

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.

Note
src and dst must not be the same box. We do not support casting in place.
Parameters
ctxto allocate buffers in (usually the same as dst)
dstWhere to write result of casting.
dst_typeto cast to.
dst_enumvAliases 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.
srcInput data.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 4015 of file value.c.

+ Here is the call graph for this function:

◆ fr_value_box_cast_in_place()

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.

Parameters
ctxto allocate buffers in (usually the same as dst)
vbto cast.
dst_typeto cast to.
dst_enumvAliases 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.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 4265 of file value.c.

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

◆ fr_value_box_cast_integer_to_integer()

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 
)
inlinestatic

Convert any signed or unsigned integer type to any other signed or unsigned integer type.

Definition at line 3476 of file value.c.

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

◆ fr_value_box_cast_to_bool()

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 
)
inlinestatic

Convert any supported type to a bool.

Allowed input types are:

  • FR_TYPE_STRING ("yes", "true", "no", "false")
Parameters
ctxunused.
dstWhere to write result of casting.
dst_typeto cast to.
dst_enumvenumeration values.
srcInput data.

Definition at line 3389 of file value.c.

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

◆ fr_value_box_cast_to_ethernet()

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 
)
inlinestatic

Convert any supported type to an ethernet address.

Allowed input types are:

  • FR_TYPE_STRING ("00:11:22:33:44:55")
  • FR_TYPE_OCTETS (0x001122334455)
Parameters
ctxunused.
dstWhere to write result of casting.
dst_typeto cast to.
dst_enumvenumeration values.
srcInput data.

Definition at line 3331 of file value.c.

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

◆ fr_value_box_cast_to_float()

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 
)
inlinestatic

Convert any value to a floating point value.

Parameters
ctxunused.
dstWhere to write result of casting.
dst_typeto cast to.
dst_enumvenumeration values.
srcInput data.

Definition at line 3894 of file value.c.

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

◆ fr_value_box_cast_to_integer()

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 
)
inlinestatic

Convert any value to a signed or unsigned integer.

Parameters
ctxunused.
dstWhere to write result of casting.
dst_typeto cast to.
dst_enumvenumeration values.
srcInput data.

Definition at line 3633 of file value.c.

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

◆ fr_value_box_cast_to_ipv4addr()

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 
)
inlinestatic

Convert any supported type to an IPv4 address.

Allowed input types are:

  • FR_TYPE_IPV6_ADDR (with v4 prefix).
  • FR_TYPE_IPV4_PREFIX (with 32bit mask).
  • FR_TYPE_IPV6_PREFIX (with v4 prefix and 128bit mask).
  • FR_TYPE_OCTETS (of length 4).
  • FR_TYPE_UINT32
Parameters
ctxunused.
dstWhere to write result of casting.
dst_typeto cast to.
dst_enumvenumeration values.
srcInput data.

Definition at line 2890 of file value.c.

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

◆ fr_value_box_cast_to_ipv4prefix()

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 
)
inlinestatic

Convert any supported type to an IPv6 address.

Allowed input types are:

  • FR_TYPE_IPV4_ADDR
  • FR_TYPE_IPV4_PREFIX (with 32bit mask).
  • FR_TYPE_IPV6_PREFIX (with 128bit mask).
  • FR_TYPE_OCTETS (of length 16).
Parameters
ctxunused.
dstWhere to write result of casting.
dst_typeto cast to.
dst_enumvenumeration values.
srcInput data.

Definition at line 3004 of file value.c.

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

◆ fr_value_box_cast_to_ipv6addr()

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 
)
inlinestatic

Convert any supported type to an IPv6 address.

Allowed input types are:

  • FR_TYPE_IPV4_ADDR
  • FR_TYPE_IPV4_PREFIX (with 32bit mask).
  • FR_TYPE_IPV6_PREFIX (with 128bit mask).
  • FR_TYPE_OCTETS (of length 16).
Parameters
ctxunused.
dstWhere to write result of casting.
dst_typeto cast to.
dst_enumvenumeration values.
srcInput data.

Definition at line 3119 of file value.c.

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

◆ fr_value_box_cast_to_ipv6prefix()

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 
)
inlinestatic

Convert any supported type to an IPv6 address.

Allowed input types are:

  • FR_TYPE_IPV4_ADDR
  • FR_TYPE_IPV4_PREFIX (with 32bit mask).
  • FR_TYPE_IPV6_PREFIX (with 128bit mask).
  • FR_TYPE_OCTETS (of length 16).
Parameters
ctxunused.
dstWhere to write result of casting.
dst_typeto cast to.
dst_enumvenumeration values.
srcInput data.

Definition at line 3233 of file value.c.

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

◆ fr_value_box_cast_to_octets()

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 
)
inlinestatic

Convert any supported type to octets.

All non-structural types are allowed.

Parameters
ctxunused.
dstWhere to write result of casting.
dst_typeto cast to.
dst_enumvenumeration values.
srcInput data.

Definition at line 2727 of file value.c.

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

◆ fr_value_box_cast_to_strvalue()

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 
)
inlinestatic

Convert any supported type to a string.

All non-structural types are allowed.

Parameters
ctxunused.
dstWhere to write result of casting.
dst_typeto cast to.
dst_enumvenumeration values.
srcInput data.

Definition at line 2667 of file value.c.

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

◆ fr_value_box_cast_unsupported()

static int fr_value_box_cast_unsupported ( fr_type_t  dst,
fr_type_t  src 
)
inlinestatic

Definition at line 2866 of file value.c.

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

◆ fr_value_box_cidr_cmp_op()

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 
)
static

Definition at line 894 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_clear()

void fr_value_box_clear ( fr_value_box_t *  data)

Clear/free any existing value and metadata.

Note
Do not use on uninitialised memory.
Parameters
[in]datato clear.

Definition at line 4448 of file value.c.

+ Here is the call graph for this function:

◆ fr_value_box_clear_value()

void fr_value_box_clear_value ( fr_value_box_t *  data)

Clear/free any existing value.

Note
Do not use on uninitialised memory.
Parameters
[in]datato clear.

Definition at line 4400 of file value.c.

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

◆ fr_value_box_cmp()

fr_cmp_ret_t fr_value_box_cmp ( fr_value_box_t const *  a,
fr_value_box_t const *  b 
)

Compare two values.

Parameters
[in]aValue to compare.
[in]bValue to compare.
Returns
  • CMP_LT if a is less than b.
  • CMP_EQ if both are equal.
  • CMP_GT if a is more than b.
  • CMP_ERR if the values are not comparable, retrieve the error with fr_strerror.

Definition at line 770 of file value.c.

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

◆ fr_value_box_cmp_op()

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.

Parameters
[in]opto use in comparison.
[in]aValue to compare.
[in]bValue to compare.
Returns
  • 1 if true
  • 0 if false
  • -1 on failure.
  • < -1 on failure.

Definition at line 1017 of file value.c.

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

◆ fr_value_box_copy()

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.

Note
Will free any exiting buffers associated with the dst fr_value_box_t.
Parameters
ctxTo allocate buffers in.
dstWhere to copy value_box to.
srcWhere to copy value_box from.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 4465 of file value.c.

+ Here is the call graph for this function:

◆ fr_value_box_copy_meta()

static void fr_value_box_copy_meta ( fr_value_box_t *  dst,
fr_value_box_t const *  src 
)
inlinestatic

Copy flags and type data from one value box to another.

Parameters
[in]dstto copy flags to
[in]srcof data.

Definition at line 652 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_copy_shallow()

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.

Parameters
[in]ctxto add reference from. If NULL no reference will be added.
[in]dstto copy value to.
[in]srcto copy value from.

Definition at line 4591 of file value.c.

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

◆ fr_value_box_debug()

void fr_value_box_debug ( FILE *  fp,
fr_value_box_t const *  vb 
)

Print the value of a box as info messages.

Note
Call directly from the debugger

Definition at line 7734 of file value.c.

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

◆ fr_value_box_escape_erules()

int fr_value_box_escape_erules ( fr_value_box_t *  vb,
void *  uctx 
)

Escape a value-box in place using the supplied fr_sbuff_escape_rules_t in uctx.

If the input type isn't a string, then it is converted to a string.

The output type is always FR_TYPE_STRING

Parameters
[in]vbwhich will be escaped
[in]uctxescape rules
Returns
  • <0 for error, generally OOM
  • 0 for success (did not set safe_for)
  • 1 for success (did set safe_for)

Definition at line 7087 of file value.c.

+ Here is the call graph for this function:

◆ fr_value_box_escape_in_place()

int fr_value_box_escape_in_place ( fr_value_box_t *  vb,
fr_value_box_escape_t const *  escape,
void *  uctx 
)

Escape a single value box in place.

Note
Applies recursively to the children of group boxes.
Parameters
[in]vbto escape.
[in]escapeescape definition to apply to the value box.
[in]uctxuser context to pass to the escape function.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 6911 of file value.c.

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

◆ fr_value_box_escape_in_place_erules()

int fr_value_box_escape_in_place_erules ( TALLOC_CTX *  ctx,
fr_value_box_t *  vb,
fr_sbuff_escape_rules_t const *  erules 
)

Escape a value-box in place using sbuff escaping rules, and mark it safe-for.

If the input type isn't a string, then it is converted to a string.

The output type is always FR_TYPE_STRING

Parameters
[in]ctxto allocate any new buffers in.
[in]vbwhich will be escaped
[in]erulesescape rules
Returns
  • <0 for error, generally OOM
  • 0 for success (did not set safe_for)
  • 1 for success (did set safe_for)

Definition at line 7021 of file value.c.

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

◆ fr_value_box_escape_in_place_func()

int fr_value_box_escape_in_place_func ( TALLOC_CTX *  ctx,
fr_value_box_t *  vb,
fr_sbuff_escape_func_t  escape 
)

Escape a value box in place using an sbuff escape function.

If the input type isn't a string, then it is converted to a string.

The output type is always FR_TYPE_STRING. The safe_for and tainted flags are left as they were. The caller marks the box once it knows which dialect the escape function produced.

Parameters
[in]ctxto allocate the escaped string in.
[in]vbwhich will be escaped. Must be a leaf type.
[in]escapefunction to run over the string value.
Returns
  • <0 for error, generally OOM.
  • 0 for success.

Definition at line 7107 of file value.c.

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

◆ fr_value_box_fixed_size_from_octets()

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 
)
static

Convert octets to a fixed size value box value.

All fixed size types are allowed.

Parameters
dstWhere to write result of casting.
dst_typeto cast to.
dst_enumvenumeration values.
srcInput data.

Definition at line 2597 of file value.c.

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

◆ fr_value_box_flatten()

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.

Parameters
[in]ctxto reparent children in if steal is true.
[in]listto flatten.
[in]stealwhether to change the talloc ctx of children.
[in]freewhether to free any group boxes which have had their children removed.

Definition at line 7133 of file value.c.

+ Here is the call graph for this function:

◆ fr_value_box_from_memory()

ssize_t fr_value_box_from_memory ( TALLOC_CTX *  ctx,
fr_value_box_t *  dst,
fr_type_t  type,
fr_dict_attr_t const *  enumv,
void const *  src,
size_t  len 
)

Decode a fr_value_box_t from a C type in memory.

We ignore arrays

Parameters
[in]ctxWhere to allocate any talloc buffers required.
[out]dstvalue_box to write the result to.
[in]typeto decode data to.
[in]enumvAliases for values.
[in]srcraw pointer to the (possibly unaligned) source
[in]lenLength of data to decode. For fixed length types we only decode complete values.
Returns
  • >= 0 The number of bytes consumed.
  • <0 an error occured

Definition at line 2467 of file value.c.

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

◆ fr_value_box_from_network()

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:

  • Octets are decoded in binary form (not hex).
  • Strings are decoded without the trailing \0 byte. Strings must consist only of valid UTF8 chars.
  • Integers are decoded big-endian.
  • Bools are decoded using one byte, with value 0x00 (false) or 0x01 (true).
  • Signed integers are decoded two's complement, with the MSB as the sign bit. Byte order is big-endian.
  • Network addresses are decoded big-endian.
  • IPv4 prefixes are decoded with 1 byte for the prefix, then 4 bytes of address.
  • IPv6 prefixes are decoded with 1 byte for the scope_id, 1 byte for the prefix, and 16 bytes of address.
  • Floats are decoded in IEEE-754 format with a big-endian byte order. We rely on the fact that the C standards require floats to be represented in IEEE-754 format in memory.
  • 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.

Parameters
[in]ctxWhere to allocate any talloc buffers required.
[out]dstvalue_box to write the result to.
[in]typeto decode data to.
[in]enumvAliases for values.
[in]dbuffBinary data to decode.
[in]lenLength of data to decode. For fixed length types we only decode complete values.
[in]taintedWhether the value came from a trusted source.
Returns
  • >= 0 The number of bytes consumed.
  • <0 - The negative offset where the error occurred.
  • FR_VALUE_BOX_NET_OOM (negative value) - Out of memory.

Definition at line 1942 of file value.c.

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

◆ fr_value_box_from_numeric_substr()

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 
)
inlinestatic

Convert integer encoded as string to a fr_value_box_t type.

Parameters
[out]dstwhere to write parsed value.
[in]dst_typetype of integer to convert string to.
[in]dst_enumvEnumeration values.
[in]inString to convert to integer.
[in]rulesfor parsing string.
[in]taintedWhether the value came from a trusted source.
Returns
  • >= 0 on success (number of bytes parsed).
  • < 0 on error (where the parse error occurred).

Definition at line 5424 of file value.c.

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

◆ fr_value_box_from_str()

fr_slen_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 
)

Definition at line 6195 of file value.c.

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

◆ fr_value_box_from_substr()

fr_slen_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 
)

Convert string value to a fr_value_box_t type.

Parameters
[in]ctxto alloc strings in.
[out]dstwhere to write parsed value.
[in,out]dst_typeof value data to create/dst_type of value created.
[in]dst_enumvfr_dict_attr_t with string names for uint32 values.
[in]insbuff to read data from.
[in]rulesunescape and termination rules.
Returns
  • >0 on success.
  • <= 0 on parse error.

Definition at line 5523 of file value.c.

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

◆ fr_value_box_hash()

uint32_t fr_value_box_hash ( fr_value_box_t const *  vb)

Hash the contents of a value box.

Definition at line 7259 of file value.c.

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

◆ fr_value_box_hton()

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.

Parameters
[in]dstWhere to write the result. May be the same as src.
[in]srcfr_value_box_t containing an uint32 value.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1330 of file value.c.

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

◆ fr_value_box_increment()

void fr_value_box_increment ( fr_value_box_t *  vb)

Increment a boxed value.

Implements safe integer overflow.

Parameters
[in]vbto increment.

Definition at line 5370 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_ipaddr()

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.

Parameters
[in]dstto assign ipaddr to.
[in]enumvAliases for values.
[in]ipaddrto copy address from.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 4349 of file value.c.

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

◆ fr_value_box_ipaddr_from_network()

ssize_t fr_value_box_ipaddr_from_network ( fr_value_box_t *  dst,
fr_type_t  type,
fr_dict_attr_t const *  enumv,
int  prefix_len,
uint8_t const *  data,
size_t  data_len,
bool  fixed,
bool  tainted 
)

Decode a fr_value_box_t of type IP address / prefix.

This function also gets passed a prefix length, and is a bit more forgiving that fr_value_box_from_network().

Parameters
[out]dstvalue_box to write the result to.
[in]typeto decode data to.
[in]enumvAliases for values.
[in]prefix_lenfor prefix types
[in]dataBinary data to decode.
[in]data_lenLength of data to decode.
[in]fixedis this a fixed size, or a variable one?
[in]taintedWhether the value came from a trusted source.
Returns
  • >= 0 The number of bytes consumed.
  • <0 - an error occurred.

Definition at line 2346 of file value.c.

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

◆ fr_value_box_is_truthy()

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 7627 of file value.c.

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

◆ fr_value_box_list_acopy()

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.

Parameters
[in]ctxto allocate boxes in.
[out]outWhere to write the head of the new list.
[in]inboxes to copy.
Returns
  • A duplicate list of value boxes, allocated in the context of 'ctx'
  • NULL on error, or empty input list.

Definition at line 7296 of file value.c.

+ Here is the call graph for this function:

◆ fr_value_box_list_aprint()

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.

Parameters
[in]ctxto allocate the buffer in.
[in]listof value boxes.
[in]delimto insert between value box values.
[in]e_rulesto control escaping of the concatenated elements.
Returns
  • NULL on error.
  • The concatenation of the string values of the value box list on success.

Definition at line 7158 of file value.c.

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

◆ fr_value_box_list_aprint_secure()

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.

Parameters
[in]ctxto allocate the buffer in.
[in]listof value boxes.
[in]delimto insert between value box values.
[in]e_rulesto control escaping of the concatenated elements.
Returns
  • NULL on error.
  • The concatenation of the string values of the value box list on success.

Definition at line 7208 of file value.c.

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

◆ fr_value_box_list_concat_as_octets()

ssize_t fr_value_box_list_concat_as_octets ( fr_value_box_safety_t *  safety,
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.

Parameters
[out]safetyif !NULL, the results of tainted / secret / safe_for will be stored here.
[out]dbuffto write the result of the concatenation to.
[in]listto concatenate.
[in]sepInsert a separator between the values.
[in]sep_lenLength of the separator.
[in]proc_actionWhat to do with the boxes in the list once they've been processed.
[in]flattenIf 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.
Returns
  • >=0 the number of bytes written to the sbuff.
  • <0 how many additional bytes we would have needed to concat the next box.

Definition at line 6632 of file value.c.

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

◆ fr_value_box_list_concat_as_string()

ssize_t fr_value_box_list_concat_as_string ( fr_value_box_safety_t *  safety,
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.

Parameters
[out]safetyif !NULL, the results of tainted / secret / safe_for will be stored here.
[out]sbuffto write the result of the concatenation to.
[in]listto concatenate.
[in]sepInsert a separator between the values.
[in]sep_lenLength of the separator.
[in]e_rulesTo apply to FR_TYPE_STRING types. Is not currently applied to any other box type.
[in]proc_actionWhat to do with the boxes in the list once they've been processed.
[in]safe_forif value has this safe_for value, don't apply the escape rules. for values which are escaped, mash the safe_for value to this.
[in]flattenIf 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.
Returns
  • >=0 the number of bytes written to the sbuff.
  • <0 how many additional bytes we would have needed to concat the next box.

Definition at line 6515 of file value.c.

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

◆ fr_value_box_list_concat_in_place()

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.

Note
Will automatically cast all fr_value_box_t to type specified.
Parameters
[in]ctxto allocate new value buffer in.
[out]outWhere to write the resulting box.
[in]listto concatenate together.
[in]typeMay be FR_TYPE_STRING or FR_TYPE_OCTETS, no other types are supported.
[in]proc_actionWhat to do with the boxes in the list once they've been processed.
[in]flattenIf 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_sizeof the value.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 6732 of file value.c.

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

◆ fr_value_box_list_debug()

void fr_value_box_list_debug ( FILE *  fp,
fr_value_box_list_t const *  head 
)

Print a list of value boxes as info messages.

Note
Call directly from the debugger

Definition at line 7687 of file value.c.

+ Here is the call graph for this function:

◆ fr_value_box_list_escape_in_place()

int fr_value_box_list_escape_in_place ( fr_value_box_list_t *  list,
fr_value_box_escape_t const *  escape,
void *  uctx 
)

Escape a list of value boxes in place.

Note
Applies recursively to the children of group boxes.
on error, the list may be left in an inconsistent/partially escaped state.
Parameters
[in]listto escape.
[in]escapeescape definition to apply to the value box.
[in]uctxuser context to pass to the escape function.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 6967 of file value.c.

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

◆ fr_value_box_list_mark_safe_for()

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.

Note
Only operates on a single level.
Parameters
[in]listto operate on.
[in]safe_forvalue to set.

Definition at line 7479 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_list_safety_merge()

void fr_value_box_list_safety_merge ( fr_value_box_t *  out,
fr_value_box_list_t const *  list 
)

Set the safety of out to the most restrictive safety of any leaf box in a list.

Use when a value is built from several boxes without going through fr_value_box_list_concat_in_place, e.g. when a separator is inserted between them. A box safe for consumer X, joined with a box safe for X or for anything, is still safe for X. Any other combination is safe for nothing.

Parameters
[out]outBox whose safety is replaced. Its value is left alone.
[in]listBoxes to merge. Group boxes are descended into.

Definition at line 7610 of file value.c.

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

◆ fr_value_box_list_tainted()

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.

Parameters
[in]headof list to check.
Returns
  • true if a list member is tainted.
  • false if no list members are tainted.

Definition at line 7324 of file value.c.

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

◆ fr_value_box_list_verify()

void fr_value_box_list_verify ( char const *  file,
int  line,
fr_value_box_list_t const *  list 
)

Definition at line 7439 of file value.c.

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

◆ fr_value_box_mark_unsafe()

void fr_value_box_mark_unsafe ( fr_value_box_t *  vb)

Mark a value-box as "unsafe".

This always succeeds, and there are no side effects.

Definition at line 7467 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_mem_alloc()

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.

Note
Buffer will not be zeroed, as it's assumed the caller will be filling it.
Parameters
[in]ctxto allocate any new buffers in.
[out]outIf non-null will be filled with a pointer to the new buffer.
[in]dstto assign new buffer to.
[in]enumvAliases for values.
[in]lenof 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]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 5100 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_mem_realloc()

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.

Note
Do not use on an uninitialised box.
Parameters
[in]ctxto realloc buffer in.
[out]outif non-null where to write a pointer to the new buffer.
[in]dstto realloc buffer for.
[in]lento realloc to.
Returns
  • 0 on success.
    • -1 on failure.

Definition at line 5133 of file value.c.

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

◆ fr_value_box_memdup()

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.

Parameters
[in]ctxto allocate any new buffers in.
[in]dstto assign new buffer to.
[in]enumvAliases for values.
[in]srca buffer.
[in]lenof 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]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 5194 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_memdup_buffer()

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.

Parameters
[in]ctxto allocate any new buffers in.
[in]dstto assign new buffer to.
[in]enumvAliases for values.
[in]srca buffer.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 5256 of file value.c.

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

◆ fr_value_box_memdup_buffer_shallow()

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.

Parameters
[in]ctxto allocate any new buffers in.
[in]dstto assign buffer to.
[in]enumvAliases for values.
[in]srca talloced buffer.
[in]taintedWhether the value came from a trusted source.

Definition at line 5296 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_memdup_dbuff()

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 
)

Definition at line 5219 of file value.c.

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

◆ fr_value_box_memdup_shallow()

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.

Note
Will free any exiting buffers associated with the value box.
Parameters
[in]dstto assign buffer to.
[in]enumvAliases for values.
[in]srca talloced buffer.
[in]lenof buffer.
[in]taintedWhether the value came from a trusted source.

Definition at line 5278 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_network_length()

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 1431 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_print()

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.

Note
- this function does NOT respect tainting! The escaping rules are ONLY for escaping quotation characters, CR, LF, etc.
Parameters
[in]outWhere to write the printed string.
[in]dataValue box to print.
[in]e_rulesTo apply to FR_TYPE_STRING types, for escaping quotation characters only. Is not currently applied to any other box type.

Definition at line 6232 of file value.c.

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

◆ fr_value_box_print_quoted()

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)

Parameters
[in]outWhere to write the printed string.
[in]dataValue box to print.
[in]quoteTo apply to FR_TYPE_STRING types. Is not currently applied to any other box type.

Definition at line 6472 of file value.c.

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

◆ fr_value_box_safety_copy()

void fr_value_box_safety_copy ( fr_value_box_t *  out,
fr_value_box_t const *  in 
)

Copy the safety values from one box to another.

Definition at line 7497 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_safety_copy_changed()

void fr_value_box_safety_copy_changed ( fr_value_box_t *  out,
fr_value_box_t const *  in 
)

Copy the safety values from one box to another.

But note that we have changed the output format, so we reset the "safe_for" value to NONE.

Definition at line 7510 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_safety_merge()

void fr_value_box_safety_merge ( fr_value_box_t *  out,
fr_value_box_t const *  in 
)

Merge safety results.

Definition at line 7555 of file value.c.

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

◆ fr_value_box_safety_set()

void fr_value_box_safety_set ( fr_value_box_t *  box,
fr_value_box_safety_t const *  safety 
)

Replace the safety of a box.

Parameters
[out]boxto update.
[in]safetyto copy into the box.

Definition at line 7566 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_set_attr()

void fr_value_box_set_attr ( fr_value_box_t *  dst,
fr_dict_attr_t const *  da 
)

Definition at line 5356 of file value.c.

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

◆ fr_value_box_set_cursor_shallow()

void fr_value_box_set_cursor_shallow ( fr_value_box_t *  dst,
fr_type_t  type,
void *  cursor,
char const *  name 
)

Definition at line 5309 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_set_secret()

void fr_value_box_set_secret ( fr_value_box_t *  box,
bool  secret 
)

Mark a box as holding a secret, or not.

A structural value has no safety of its own, the children carry theirs. In a fr_pair_t the children list overlays the safety field, so a structural box is left alone rather than written to.

Definition at line 7577 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_set_void_shallow()

void fr_value_box_set_void_shallow ( fr_value_box_t *  dst,
void const *  ptr 
)

Assign a void pointer to a box.

Parameters
[in]dstto assign void pointer to.
[in]ptrto assign.

Definition at line 5324 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_steal()

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.

Parameters
[in]ctxto allocate any new buffers in.
[in]dstto copy value to.
[in]srcto copy value from.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 4627 of file value.c.

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

◆ fr_value_box_strdup()

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.

Parameters
[in]ctxto allocate any new buffers in.
[in]dstto assign new buffer to.
[in]enumvAliases for values.
[in]srca nul terminated buffer.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 4702 of file value.c.

+ Here is the call graph for this function:

◆ fr_value_box_strdup_shallow()

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.

Note
Input string will not be duplicated.
Parameters
[in]dstto assign string to.
[in]enumvAliases for values.
[in]srcto copy string from.
[in]taintedWhether the value came from a trusted source.

Definition at line 4812 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_strdup_shallow_replace()

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.

Note
Input string will not be duplicated.
Parameters
[in]vbto replace string in.
[in]srcto assign string from.
[in]lenof src.

Definition at line 4828 of file value.c.

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

◆ fr_value_box_strtrim()

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.

Parameters
[in]ctxto re-alloc the buffer in.
[in,out]vbto trim.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 4728 of file value.c.

+ Here is the caller graph for this function:

◆ fr_value_box_to_key()

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.

Parameters
[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]outlenThe number of bits available in the initial buffer. On output, the number of bits available in the key
[in]valuethe value box which contains the key
Returns
  • <0 on error
  • 0 on success

Definition at line 2534 of file value.c.

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

◆ fr_value_box_to_network()

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:

  • Octets are encoded in binary form (not hex).
  • Strings are encoded without the trailing \0 byte.
  • Integers are encoded big-endian.
  • Bools are encoded using one byte, with value 0x00 (false) or 0x01 (true).
  • Signed integers are encoded two's complement, with the MSB as the sign bit. Byte order is big-endian.
  • Network addresses are encoded big-endian.
  • IPv4 prefixes are encoded with 1 byte for the prefix, then 4 bytes of address.
  • IPv6 prefixes are encoded with 1 byte for the scope_id, 1 byte for the prefix, and 16 bytes of address.
  • Floats are encoded in IEEE-754 format with a big-endian byte order. We rely on the fact that the C standards require floats to be represented in IEEE-754 format in memory.
  • Dates are encoded as 16/32/64-bit unsigned UNIX timestamps.
  • time_deltas are encoded as 16/32/64-bit signed integers.

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.

Parameters
[out]dbuffWhere to write serialized data.
[in]valueto encode.
Returns
  • 0 no bytes were written.
  • >0 the number of bytes written to out.
  • <0 the number of bytes we'd need in dbuff to complete the operation.

Definition at line 1534 of file value.c.

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

◆ fr_value_box_vasprintf()

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.

Parameters
[in]ctxto allocate any new buffers in.
[in]dstto assign new buffer to.
[in]enumvAliases for values.
[in]fmtThe printf format string to process.
[in]taintedWhether the value came from a trusted source.
[in]apSubstitution arguments.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 4759 of file value.c.

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

◆ fr_value_box_verify()

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 7343 of file value.c.

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

◆ fr_value_str_unescape()

fr_sbuff_err_t fr_value_str_unescape ( size_t *  len,
fr_sbuff_t *  out,
fr_sbuff_t *  in,
size_t  max,
char  quote 
)

Convert a string value with escape sequences into its binary form.

The quote character determines the escape sequences recognised.

  • Literal mode ("'" quote char) will unescape:
      - \\        - Literal backslash.
      - \<quote>  - The quotation char.
    
  • Expanded mode ('"' quote char) will also unescape:
      - \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.
    
  • Backtick mode ('‘’ quote char) identical to expanded mode.
  • Regex mode ('/') identical to expanded mode but two successive backslashes will be interpreted as an escape sequence, but not unescaped, so that they will be passed to the underlying regex library.
  • Verbatim mode ('\0' quote char) copies in to out verbatim.
Note
The resulting output may contain embedded \0s.
Unrecognised escape sequences will be copied verbatim.
In and out may point to the same underlying buffer.
Copying will stop early if an unescaped instance of the quoting char is found in the input buffer.
Parameters
[out]lenNumber of bytes written to out. May be NULL.
[out]outWhere to write the unescaped string.
[in]inThe string to unescape.
[in]maxMaximum number of input bytes to consume. Pass SIZE_MAX to consume all data in the input buffer.
[in]quoteCharacter around the string, determines unescaping mode.
Returns
  • FR_SBUFF_OK on success, including when the input was empty.
  • FR_SBUFF_ERR_NO_SPACE out filled before the input was consumed.
  • FR_SBUFF_ERR_EXTEND in's extend callback failed.

Definition at line 1232 of file value.c.

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

◆ fr_value_substr_unescape()

fr_sbuff_err_t fr_value_substr_unescape ( size_t *  len,
fr_sbuff_t *  out,
fr_sbuff_t *  in,
size_t  max,
char  quote 
)

Convert a string value with escape sequences into its binary form.

The quote character determines the escape sequences recognised.

  • Literal mode ("'" quote char) will unescape:
      - \\        - Literal backslash.
      - \<quote>  - The quotation char.
    
  • Expanded mode ('"' quote char) will also unescape:
      - \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.
    
  • Backtick mode ('‘’ quote char) identical to expanded mode.
  • Regex mode ('/') identical to expanded mode but two successive backslashes will be interpreted as an escape sequence, but not unescaped, so that they will be passed to the underlying regex library.
  • Verbatim mode ('\0' quote char) copies in to out verbatim.
Note
The resulting output may contain embedded \0s.
Unrecognised escape sequences will be copied verbatim.
In and out may point to the same underlying buffer.
Copying will stop early if an unescaped instance of the quoting char is found in the input buffer.
Parameters
[out]lenNumber of bytes written to out. May be NULL.
[out]outWhere to write the unescaped string.
[in]inThe string to unescape.
[in]maxMaximum number of input bytes to consume. Pass SIZE_MAX to consume all data in the input buffer.
[in]quoteCharacter around the string, determines unescaping mode.
Returns
  • FR_SBUFF_OK on success, including when the input was empty.
  • FR_SBUFF_ERR_NO_SPACE out filled before the input was consumed.
  • FR_SBUFF_ERR_EXTEND in's extend callback failed.

Definition at line 1300 of file value.c.

+ Here is the call graph for this function:

◆ fr_value_unbox_ipaddr()

int fr_value_unbox_ipaddr ( fr_ipaddr_t *  dst,
fr_value_box_t *  src 
)

Unbox an IP address performing a type check.

Parameters
[out]dstWhere to copy the IP address to.
[in]srcWhere to copy the IP address from.
Returns
  • 0 on success.
  • -1 on type mismatch.

Definition at line 4381 of file value.c.

+ Here is the call graph for this function:

◆ value_box_ipv6_scope_id_to_network()

static int value_box_ipv6_scope_id_to_network ( fr_dbuff_t *  dbuff,
fr_value_box_t const *  value 
)
static

Encode the scope_id of an IPv6 address or prefix as one byte.

The network format gives the scope_id one byte, but fr_ipaddr_t holds the scope_id in a uint32_t. The function fails for a scope_id above 255 rather than truncating the scope_id.

Definition at line 1483 of file value.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ fr_value_box_field_sizes

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 *.

Definition at line 162 of file value.c.

◆ fr_value_box_integer_max

uint64_t const fr_value_box_integer_max[]
static
Initial value:
= {
[FR_TYPE_BOOL] = true,
[FR_TYPE_UINT16] = UINT16_MAX,
[FR_TYPE_UINT32] = UINT32_MAX,
[FR_TYPE_UINT64] = UINT64_MAX,
[FR_TYPE_INT8] = INT8_MAX,
[FR_TYPE_INT16] = INT16_MAX,
[FR_TYPE_INT32] = INT32_MAX,
[FR_TYPE_INT64] = INT64_MAX,
[FR_TYPE_DATE] = UINT64_MAX,
[FR_TYPE_TIME_DELTA] = INT64_MAX,
[FR_TYPE_SIZE] = SIZE_MAX,
[FR_TYPE_MAX] = 0
}
@ FR_TYPE_TIME_DELTA
A period of time measured in nanoseconds.
@ FR_TYPE_INT8
8 Bit signed integer.
@ FR_TYPE_MAX
Number of defined data types.
@ FR_TYPE_UINT16
16 Bit unsigned integer.
@ FR_TYPE_INT64
64 Bit signed integer.
@ FR_TYPE_INT16
16 Bit signed integer.
@ FR_TYPE_DATE
Unix time stamp, always has value >2^31.
@ FR_TYPE_UINT8
8 Bit unsigned integer.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_INT32
32 Bit signed integer.
@ FR_TYPE_UINT64
64 Bit unsigned integer.
@ FR_TYPE_BOOL
A truth value.
@ FR_TYPE_SIZE
Unsigned integer capable of representing any memory address on the local system.
#define UINT8_MAX

Definition at line 242 of file value.c.

◆ fr_value_box_integer_min

int64_t const fr_value_box_integer_min[]
static
Initial value:
= {
[FR_TYPE_BOOL] = false,
[FR_TYPE_INT8] = INT8_MIN,
[FR_TYPE_INT16] = INT16_MIN,
[FR_TYPE_INT32] = INT32_MIN,
[FR_TYPE_INT64] = INT64_MIN,
[FR_TYPE_DATE] = 0,
[FR_TYPE_TIME_DELTA] = INT64_MIN,
[FR_TYPE_SIZE] = 0,
[FR_TYPE_MAX] = 0
}

Definition at line 262 of file value.c.

◆ fr_value_box_network_sizes

size_t const fr_value_box_network_sizes[FR_TYPE_MAX+1][2]
static

Definition at line 118 of file value.c.

◆ fr_value_box_offsets

size_t const fr_value_box_offsets[]

Where the value starts in the fr_value_box_t.

Definition at line 204 of file value.c.

◆ fr_value_escape_backtick

fr_sbuff_escape_rules_t const fr_value_escape_backtick
Initial value:
= {
.name = "backtick",
.chr = '\\',
.subs = {
['%'] = '%',
['\\'] = '\\',
['`'] = '`',
['\a'] = 'a',
['\b'] = 'b',
['\n'] = 'n',
['\r'] = 'r',
['\t'] = 't',
['\v'] = 'v'
},
.esc = {
},
.do_utf8 = true,
.do_oct = true
}
#define SBUFF_CHAR_UNPRINTABLES_EXTENDED
#define SBUFF_CHAR_UNPRINTABLES_LOW

Definition at line 433 of file value.c.

◆ fr_value_escape_by_char

fr_sbuff_escape_rules_t const* fr_value_escape_by_char[SBUFF_CHAR_CLASS]
Initial value:
= {
}
fr_sbuff_escape_rules_t const fr_value_escape_double
Definition value.c:366
fr_sbuff_escape_rules_t const fr_value_escape_backtick
Definition value.c:433
fr_sbuff_escape_rules_t const fr_value_escape_solidus
Definition value.c:412
fr_sbuff_escape_rules_t const fr_value_escape_single
Definition value.c:402

Definition at line 462 of file value.c.

◆ fr_value_escape_by_quote

fr_sbuff_escape_rules_t const* fr_value_escape_by_quote[T_TOKEN_LAST]
Initial value:

Definition at line 455 of file value.c.

◆ fr_value_escape_double

fr_sbuff_escape_rules_t const fr_value_escape_double
Initial value:
= {
.name = "double",
.chr = '\\',
.subs = {
['"'] = '"',
['%'] = '%',
['\\'] = '\\',
['\a'] = 'a',
['\b'] = 'b',
['\n'] = 'n',
['\r'] = 'r',
['\t'] = 't',
['\v'] = 'v'
},
.esc = {
},
.do_utf8 = true,
.do_oct = true
}

Definition at line 366 of file value.c.

◆ fr_value_escape_secret

fr_sbuff_escape_rules_t const fr_value_escape_secret
Initial value:
= {
.name = "secret",
.subs = {
[ 0 ... 255 ] = '.',
},
}

Escape secret fields by simply mashing all data to '.

'

The length of the secret still leaks, but that is likely fine. Fixing that is more work.

Definition at line 395 of file value.c.

◆ fr_value_escape_single

fr_sbuff_escape_rules_t const fr_value_escape_single
Initial value:
= {
.name = "single",
.chr = '\\',
.subs = {
['\''] = '\'',
['\\'] = '\\'
},
.do_utf8 = true,
}

Definition at line 402 of file value.c.

◆ fr_value_escape_solidus

fr_sbuff_escape_rules_t const fr_value_escape_solidus
Initial value:
= {
.name = "solidus",
.chr = '\\',
.subs = {
['%'] = '%',
['/'] = '/',
['\a'] = 'a',
['\b'] = 'b',
['\n'] = 'n',
['\r'] = 'r',
['\t'] = 't',
['\v'] = 'v'
},
.esc = {
},
.do_utf8 = true,
.do_oct = true
}

Definition at line 412 of file value.c.

◆ fr_value_escape_unprintables

fr_sbuff_escape_rules_t const fr_value_escape_unprintables
Initial value:
= {
.name = "unprintables",
.chr = '\\',
.subs = {
['\\'] = '\\',
},
.esc = {
},
.do_utf8 = true,
.do_oct = true
}

Definition at line 469 of file value.c.

◆ fr_value_unescape_backtick

fr_sbuff_unescape_rules_t const fr_value_unescape_backtick
Initial value:
= {
.name = "backtick",
.chr = '\\',
.subs = {
['%'] = '%',
['\\'] = '\\',
['`'] = '`',
['a'] = '\a',
['b'] = '\b',
['e'] = '\\',
['n'] = '\n',
['r'] = '\r',
['t'] = '\t',
['v'] = '\v'
},
.do_hex = true,
.do_oct = true
}

Definition at line 333 of file value.c.

◆ fr_value_unescape_by_char

fr_sbuff_unescape_rules_t const* fr_value_unescape_by_char[SBUFF_CHAR_CLASS]
Initial value:
= {
}
fr_sbuff_unescape_rules_t const fr_value_unescape_single
Definition value.c:301
fr_sbuff_unescape_rules_t const fr_value_unescape_backtick
Definition value.c:333
fr_sbuff_unescape_rules_t const fr_value_unescape_double
Definition value.c:282
fr_sbuff_unescape_rules_t const fr_value_unescape_solidus
Definition value.c:312

Definition at line 359 of file value.c.

◆ fr_value_unescape_by_quote

fr_sbuff_unescape_rules_t const* fr_value_unescape_by_quote[T_TOKEN_LAST]

◆ fr_value_unescape_double

fr_sbuff_unescape_rules_t const fr_value_unescape_double
Initial value:
= {
.name = "double",
.chr = '\\',
.subs = {
['"'] = '"',
['%'] = '%',
['\\'] = '\\',
['a'] = '\a',
['b'] = '\b',
['e'] = '\\',
['n'] = '\n',
['r'] = '\r',
['t'] = '\t',
['v'] = '\v'
},
.do_hex = true,
.do_oct = true
}

Definition at line 282 of file value.c.

◆ fr_value_unescape_single

fr_sbuff_unescape_rules_t const fr_value_unescape_single
Initial value:
= {
.name = "single",
.chr = '\\',
.subs = {
['\''] = '\'',
['\\'] = '\\'
},
.do_hex = false,
.do_oct = false
}

Definition at line 301 of file value.c.

◆ fr_value_unescape_solidus

fr_sbuff_unescape_rules_t const fr_value_unescape_solidus
Initial value:
= {
.name = "solidus",
.chr = '\\',
.subs = {
['%'] = '%',
['/'] = '/',
['a'] = '\a',
['b'] = '\b',
['e'] = '\\',
['n'] = '\n',
['r'] = '\r',
['t'] = '\t',
['v'] = '\v'
},
.skip = {
['\\'] = '\\'
},
.do_hex = true,
.do_oct = true
}

Definition at line 312 of file value.c.

◆ ipaddr_sizes

const fr_value_box_ipaddr_sizes_t ipaddr_sizes[FR_TYPE_MAX]
static
Initial value:
= {
AF_INET, 32, 32, 0, 4,
},
AF_INET, 0, 32, 0, 4,
},
AF_INET6, 128, 128, 16, 16,
},
AF_INET6, 0, 128, 0, 16,
},
}

Definition at line 2311 of file value.c.

◆ v4_v6_map

uint8_t const v4_v6_map[]
static
Initial value:
= { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff }

v4 to v6 mapping prefix

Part of the IPv6 range is allocated to represent IPv4 addresses.

Definition at line 2653 of file value.c.

◆ value_parse_rules_3quoted

fr_sbuff_parse_rules_t const* value_parse_rules_3quoted[T_TOKEN_LAST]
Initial value:
= {
}
@ T_BARE_WORD
Definition token.h:118
fr_sbuff_parse_rules_t const value_parse_rules_single_3quoted
Definition value.c:594
fr_sbuff_parse_rules_t const value_parse_rules_double_3quoted
Definition value.c:588
fr_sbuff_parse_rules_t const value_parse_rules_bareword_quoted
Definition value.c:538
fr_sbuff_parse_rules_t const value_parse_rules_backtick_3quoted
Definition value.c:606
fr_sbuff_parse_rules_t const value_parse_rules_solidus_3quoted
Definition value.c:600

Definition at line 636 of file value.c.

◆ value_parse_rules_backtick_3quoted

fr_sbuff_parse_rules_t const value_parse_rules_backtick_3quoted
Initial value:
= {
.terminals = &FR_SBUFF_TERMS(
L(""), L("\n"), L("\r"), L("```"))
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition build.h:245
#define FR_SBUFF_TERMS(...)
Initialise a terminal structure with a list of sorted strings.
Definition sbuff.h:191

Definition at line 606 of file value.c.

◆ value_parse_rules_backtick_quoted

fr_sbuff_parse_rules_t const value_parse_rules_backtick_quoted
Initial value:
= {
.terminals = &FR_SBUFF_TERMS(
L(""), L("\n"), L("\r"), L("`"))
}

Definition at line 579 of file value.c.

◆ value_parse_rules_backtick_unquoted

fr_sbuff_parse_rules_t const value_parse_rules_backtick_unquoted
Initial value:
= {
}

Definition at line 510 of file value.c.

◆ value_parse_rules_bareword_quoted

fr_sbuff_parse_rules_t const value_parse_rules_bareword_quoted
Initial value:
= {
.chr = '\\',
.subs = {
['\t'] = '\t',
['\n'] = '\n',
[' '] = ' '
},
.do_hex = false,
.do_oct = false
},
.terminals = &FR_SBUFF_TERMS(
L(""),
L("\t"),
L("\n"),
L(" ")
)
}
Set of parsing rules for *unescape_until functions.

Definition at line 538 of file value.c.

◆ value_parse_rules_bareword_unquoted

fr_sbuff_parse_rules_t const value_parse_rules_bareword_unquoted
Initial value:
= {
}

Default formatting rules.

Control token termination, escaping and how the tmpl is printed.

Definition at line 494 of file value.c.

◆ value_parse_rules_double_3quoted

fr_sbuff_parse_rules_t const value_parse_rules_double_3quoted
Initial value:
= {
.terminals = &FR_SBUFF_TERMS(
L(""), L("\n"), L("\r"), L("\"\"\""))
}

Definition at line 588 of file value.c.

◆ value_parse_rules_double_quoted

fr_sbuff_parse_rules_t const value_parse_rules_double_quoted
Initial value:
= {
.terminals = &FR_SBUFF_TERMS(
L(""), L("\n"), L("\r"), L("\""))
}

Definition at line 561 of file value.c.

◆ value_parse_rules_double_unquoted

fr_sbuff_parse_rules_t const value_parse_rules_double_unquoted
Initial value:
= {
}

Definition at line 498 of file value.c.

◆ value_parse_rules_quoted

fr_sbuff_parse_rules_t const* value_parse_rules_quoted[T_TOKEN_LAST]
Initial value:
= {
}
fr_sbuff_parse_rules_t const value_parse_rules_solidus_quoted
Definition value.c:573
fr_sbuff_parse_rules_t const value_parse_rules_single_quoted
Definition value.c:567
fr_sbuff_parse_rules_t const value_parse_rules_backtick_quoted
Definition value.c:579
fr_sbuff_parse_rules_t const value_parse_rules_double_quoted
Definition value.c:561

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.

Definition at line 620 of file value.c.

◆ value_parse_rules_quoted_char

fr_sbuff_parse_rules_t const* value_parse_rules_quoted_char[SBUFF_CHAR_CLASS]

◆ value_parse_rules_single_3quoted

fr_sbuff_parse_rules_t const value_parse_rules_single_3quoted
Initial value:
= {
.terminals = &FR_SBUFF_TERMS(
L(""), L("\n"), L("\r"), L("'''"))
}

Definition at line 594 of file value.c.

◆ value_parse_rules_single_quoted

fr_sbuff_parse_rules_t const value_parse_rules_single_quoted
Initial value:
= {
.terminals = &FR_SBUFF_TERMS(
L(""), L("\n"), L("\r"), L("'"))
}

Definition at line 567 of file value.c.

◆ value_parse_rules_single_unquoted

fr_sbuff_parse_rules_t const value_parse_rules_single_unquoted
Initial value:
= {
}

Definition at line 502 of file value.c.

◆ value_parse_rules_solidus_3quoted

fr_sbuff_parse_rules_t const value_parse_rules_solidus_3quoted
Initial value:
= {
.terminals = &FR_SBUFF_TERMS(
L(""), L("\n"), L("\r"), L("///"))
}

Definition at line 600 of file value.c.

◆ value_parse_rules_solidus_quoted

fr_sbuff_parse_rules_t const value_parse_rules_solidus_quoted
Initial value:
= {
.terminals = &FR_SBUFF_TERMS(
L(""), L("\n"), L("\r"), L("/"))
}

Definition at line 573 of file value.c.

◆ value_parse_rules_solidus_unquoted

fr_sbuff_parse_rules_t const value_parse_rules_solidus_unquoted
Initial value:
= {
}

Definition at line 506 of file value.c.

◆ value_parse_rules_unquoted

fr_sbuff_parse_rules_t const* value_parse_rules_unquoted[T_TOKEN_LAST]
Initial value:
= {
}
fr_sbuff_parse_rules_t const value_parse_rules_double_unquoted
Definition value.c:498
fr_sbuff_parse_rules_t const value_parse_rules_bareword_unquoted
Default formatting rules.
Definition value.c:494
fr_sbuff_parse_rules_t const value_parse_rules_single_unquoted
Definition value.c:502
fr_sbuff_parse_rules_t const value_parse_rules_solidus_unquoted
Definition value.c:506
fr_sbuff_parse_rules_t const value_parse_rules_backtick_unquoted
Definition value.c:510

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.

Definition at line 522 of file value.c.

◆ value_parse_rules_unquoted_char

fr_sbuff_parse_rules_t const* value_parse_rules_unquoted_char[SBUFF_CHAR_CLASS]