24 RCSIDH(value_h,
"$Id: 208084ca8f3681eb26891d412ffa8b5e1fa2e776 $")
30 #define FR_MAX_STRING_LEN 254
38 #include <freeradius-devel/build.h>
39 #include <freeradius-devel/util/dcursor.h>
40 #include <freeradius-devel/missing.h>
41 #include <freeradius-devel/util/dbuff.h>
42 #include <freeradius-devel/util/debug.h>
43 #include <freeradius-devel/util/dict.h>
44 #include <freeradius-devel/util/dlist.h>
45 #include <freeradius-devel/util/inet.h>
46 #include <freeradius-devel/util/log.h>
47 #include <freeradius-devel/util/strerror.h>
48 #include <freeradius-devel/util/table.h>
49 #include <freeradius-devel/util/time.h>
50 #include <freeradius-devel/util/token.h>
51 #include <freeradius-devel/util/types.h>
61 # error _CONST can only be defined in the local header
63 #ifndef _VALUE_PRIVATE
91 # define FR_VALUE_BOX_MAGIC RADIUSD_MAGIC_NUMBER
107 char const *
_CONST strvalue;
206 #define fr_value_box_list_foreach(_list_head, _iter) fr_dlist_foreach(fr_value_box_list_dlist_head(_list_head), fr_value_box_t, _iter)
207 #define fr_value_box_list_foreach_safe(_list_head, _iter) fr_dlist_foreach_safe(fr_value_box_list_dlist_head(_list_head), fr_value_box_t, _iter)
224 #define vb_should_free(_action) ((_action & FR_VALUE_BOX_LIST_FREE_BOX) == FR_VALUE_BOX_LIST_FREE_BOX)
225 #define vb_should_free_value(_action) ((_action & FR_VALUE_BOX_LIST_FREE_BOX_VALUE) == FR_VALUE_BOX_LIST_FREE_BOX_VALUE)
226 #define vb_should_remove(_action) ((_action & FR_VALUE_BOX_LIST_REMOVE) == FR_VALUE_BOX_LIST_REMOVE)
229 #define VALUE_BOX_NDEBUG_INITIALISER .file = __FILE__, .line = __LINE__, .magic = FR_VALUE_BOX_MAGIC
231 #define VALUE_BOX_NDEBUG_INITIALISER
241 #define vb_strvalue datum.strvalue
242 #define vb_octets datum.octets
243 #define vb_void datum.ptr
244 #define vb_group datum.children
246 #define vb_ip datum.ip
248 #define vb_ifid datum.ifid.addr
249 #define vb_ether datum.ether.addr
251 #define vb_bool datum.boolean
252 #define vb_uint8 datum.uint8
253 #define vb_uint16 datum.uint16
254 #define vb_uint32 datum.uint32
255 #define vb_uint64 datum.uint64
256 #define vb_uint128 datum.uint128
258 #define vb_int8 datum.int8
259 #define vb_int16 datum.int16
260 #define vb_int32 datum.int32
261 #define vb_int64 datum.int64
263 #define vb_float32 datum.float32
264 #define vb_float64 datum.float64
266 #define vb_date datum.date
268 #define vb_size datum.size
269 #define vb_timeval datum.timeval
270 #define vb_time_delta datum.time_delta
272 #define vb_length datum.length
283 #define _fr_box_with_len(_type, _field, _val, _len) &(fr_value_box_t){ .type = _type, _field = _val, .vb_length = _len, VALUE_BOX_NDEBUG_INITIALISER }
285 #define fr_box_strvalue(_val) _fr_box_with_len(FR_TYPE_STRING, .vb_strvalue, _val, strlen(_val))
286 #define fr_box_strvalue_len(_val, _len) _fr_box_with_len(FR_TYPE_STRING, .vb_strvalue, _val, _len)
288 #define fr_box_octets(_val, _len) _fr_box_with_len(FR_TYPE_OCTETS, .vb_octets, _val, _len)
289 #define fr_box_strvalue_buffer(_val) _fr_box_with_len(FR_TYPE_STRING, .vb_strvalue, _val, talloc_array_length(_val) - 1)
290 #define fr_box_octets_buffer(_val) _fr_box_with_len(FR_TYPE_OCTETS, .vb_octets, _val, talloc_array_length(_val))
292 #define _fr_box(_type, _field, _val) (&(fr_value_box_t){ .type = _type, _field = (_val), VALUE_BOX_NDEBUG_INITIALISER })
294 #define fr_box_ipaddr(_val) _fr_box((((_val).af == AF_INET) ? \
295 (((_val).prefix == 32) ? FR_TYPE_IPV4_ADDR : \
296 FR_TYPE_IPV4_PREFIX) : \
297 (((_val).prefix == 128) ? FR_TYPE_IPV6_ADDR : \
298 FR_TYPE_IPV6_PREFIX)), \
300 #define fr_box_ipv4addr(_val) _fr_box(FR_TYPE_IPV4_ADDR, .vb_ip, _val)
301 #define fr_box_ipv4prefix(_val) _fr_box(FR_TYPE_IPV4_PREFIX, .vb_ip, _val)
302 #define fr_box_ipv6addr(_val) _fr_box(FR_TYPE_IPV6_ADDR, .vb_ip, _val)
303 #define fr_box_ipv6prefix(_val) _fr_box(FR_TYPE_IPV6_PREFIX, .vb_ip, _val)
305 #define fr_box_ifid(_val) _fr_box(FR_TYPE_IFID, .vb_ifid, _val)
306 #define fr_box_ether(_val) &(fr_value_box_t){ .type = FR_TYPE_ETHERNET, .vb_ether = { _val[0], _val[1], _val[2], _val[3], _val[4], _val[5] } }
308 #define fr_box_bool(_val) _fr_box(FR_TYPE_BOOL, .vb_bool, _val)
310 #define fr_box_uint8(_val) _fr_box(FR_TYPE_UINT8, .vb_uint8, _val)
311 #define fr_box_uint16(_val) _fr_box(FR_TYPE_UINT16, .vb_uint16, _val)
312 #define fr_box_uint32(_val) _fr_box(FR_TYPE_UINT32, .vb_uint32, _val)
313 #define fr_box_uint64(_val) _fr_box(FR_TYPE_UINT64, .vb_uint64, _val)
314 #define fr_box_uint128(_val) _fr_box(FR_TYPE_UINT128, .vb_uint128, _val)
316 #define fr_box_int8(_val) _fr_box(FR_TYPE_INT8, .vb_int8, _val)
317 #define fr_box_int16(_val) _fr_box(FR_TYPE_INT16, .vb_int16, _val)
318 #define fr_box_int32(_val) _fr_box(FR_TYPE_INT32, .vb_int32, _val)
319 #define fr_box_int64(_val) _fr_box(FR_TYPE_INT64, .vb_int64, _val)
321 #define fr_box_float32(_val) _fr_box(FR_TYPE_FLOAT32, .vb_float32, _val)
322 #define fr_box_float64(_val) _fr_box(FR_TYPE_FLOAT64, .vb_float64, _val)
324 #define fr_box_date(_val) _fr_box(FR_TYPE_DATE, .vb_date, _val)
326 #define fr_box_time(_val) _fr_box(FR_TYPE_DATE, .vb_date, fr_time_to_unix_time(_val))
328 #define fr_box_size(_val) _fr_box(FR_TYPE_SIZE, .vb_size, _val)
330 #define _fr_box_with_da(_type, _field, _val, _da) (&(fr_value_box_t){ .type = _type, _field = (_val), .enumv = (_da) })
332 #define fr_box_time_delta_with_res(_val, _res) _fr_box_with_da(FR_TYPE_TIME_DELTA, \
335 (&(fr_dict_attr_t){ \
337 .type = FR_TYPE_TIME_DELTA, \
343 #define fr_box_time_delta(_val) fr_box_time_delta_with_res((_val), FR_TIME_RES_SEC)
345 #define fr_box_time_delta_sec(_val) fr_box_time_delta_with_res((_val), FR_TIME_RES_SEC)
347 #define fr_box_time_delta_msec(_val) fr_box_time_delta_with_res((_val), FR_TIME_RES_MSEC)
349 #define fr_box_time_delta_nsec(_val) fr_box_time_delta_with_res((_val), FR_TIME_RES_NSEC)
351 #define fr_box_time_delta_usec(_val) fr_box_time_delta_with_res((_val), FR_TIME_RES_USEC)
360 #define fr_box(_val) _Generic((_val), \
361 fr_ipaddr_t * : fr_box_ipaddr, \
362 fr_ipaddr_t const * : fr_box_ipaddr, \
363 fr_ethernet_t * : fr_box_ether, \
364 fr_ethernet_t const * : fr_box_ether, \
365 bool : fr_box_bool, \
366 int8_t : fr_box_int8, \
367 int16_t : fr_box_int16, \
368 int32_t : fr_box_int32, \
369 int64_t : fr_box_int16, \
370 uint8_t : fr_box_uint8, \
371 uint16_t : fr_box_uint16, \
372 uint32_t : fr_box_uint32, \
373 uint64_t : fr_box_uint64, \
374 size_t : fr_box_size, \
375 float : fr_box_float32, \
376 double : fr_box_float64 \
384 #define fr_box_len( _val, _len) \
386 char * : fr_box_strvalue_len, \
387 char const * : fr_box_strvalue_len, \
388 uint8_t * : fr_box_octets, \
389 uint8_t const * : fr_box_octets \
401 #define fr_box_is_null(_x) fr_type_is_null((_x)->type)
402 #define fr_box_is_string(_x) fr_type_is_string((_x)->type)
403 #define fr_box_is_octets(_x) fr_type_is_octets((_x)->type)
404 #define fr_box_is_ipv4addr(_x) fr_type_is_ipv4addr((_x)->type)
405 #define fr_box_is_ipv4prefix(_x) fr_type_is_ipv4prefix((_x)->type)
406 #define fr_box_is_ipv6addr(_x) fr_type_is_ipv6addr((_x)->type)
407 #define fr_box_is_ipv6prefix(_x) fr_type_is_ipv6prefix((_x)->type)
408 #define fr_box_is_ifid(_x) fr_type_is_ifid((_x)->type)
409 #define fr_box_is_combo_ipaddr(_x) fr_type_is_combo_ipaddr((_x)->type)
410 #define fr_box_is_combo_ipprefix(_x) fr_type_is_combo_ipprefix((_x)->type)
411 #define fr_box_is_ethernet(_x) fr_type_is_ethernet((_x)->type)
412 #define fr_box_is_bool(_x) fr_type_is_bool((_x)->type)
413 #define fr_box_is_uint8(_x) fr_type_is_uint8((_x)->type)
414 #define fr_box_is_uint16(_x) fr_type_is_uint16((_x)->type)
415 #define fr_box_is_uint32(_x) fr_type_is_uint32((_x)->type)
416 #define fr_box_is_uint64(_x) fr_type_is_uint64((_x)->type)
417 #define fr_box_is_int8(_x) fr_type_is_int8((_x)->type)
418 #define fr_box_is_int16(_x) fr_type_is_int16((_x)->type)
419 #define fr_box_is_int32(_x) fr_type_is_int32((_x)->type)
420 #define fr_box_is_int64(_x) fr_type_is_int64((_x)->type)
421 #define fr_box_is_float32(_x) fr_type_is_float32((_x)->type)
422 #define fr_box_is_float64(_x) fr_type_is_float64((_x)->type)
423 #define fr_box_is_date(_x) fr_type_is_date((_x)->type)
424 #define fr_box_is_time_delta(_x) fr_type_is_time_delta((_x)->type)
425 #define fr_box_is_size(_x) fr_type_is_size((_x)->type)
426 #define fr_box_is_tlv(_x) fr_type_is_tlv((_x)->type)
427 #define fr_box_is_struct(_x) fr_type_is_struct((_x)->type)
428 #define fr_box_is_vsa(_x) fr_type_is_vsa((_x)->type)
429 #define fr_box_is_vendor(_x) fr_type_is_vendor((_x)->type)
430 #define fr_box_is_group(_x) fr_type_is_group((_x)->type)
431 #define fr_box_is_value_box(_x) fr_type_is_value_box((_x)->type)
432 #define fr_box_is_void(_x) fr_type_is_void((_x)->type)
434 #define fr_box_is_integer_except_bool(_x) fr_type_is_integer_except_bool((_x)->type)
435 #define fr_box_is_integer(_x) fr_type_is_integer((_x)->type)
436 #define fr_box_is_numeric(_x) fr_type_is_numeric((_x)->type)
438 #define fr_box_is_ip(_x) fr_type_is_ip((_x)->type)
440 #define fr_box_is_fixed_size(_x) fr_type_is_fixed_size((_x)->type)
441 #define fr_box_is_variable_size(_x) fr_type_is_variable_size((_x)->type)
442 #define fr_box_is_value(_x) fr_type_is_value((_x)->type)
443 #define fr_box_is_quoted(_x) fr_type_is_quoted((_x)->type)
445 #define fr_box_is_structural_except_vsa(_x) fr_type_is_structural_except_vsa((_x)->type)
446 #define fr_box_is_structural(_x) fr_type_is_structural((_x)->type)
447 #define fr_box_is_non_value(_x) fr_type_is_non_value((_x)->type)
488 #define FR_VALUE_BOX_INITIALISER_NULL(_vb) \
490 .type = FR_TYPE_NULL, \
492 .entry = FR_DLIST_ENTRY_INITIALISER((_vb).entry.entry) \
494 VALUE_BOX_NDEBUG_INITIALISER \
500 #define FR_VALUE_BOX_INITIALISER(_vb, _type, _field, _val) \
507 .entry = FR_DLIST_ENTRY_INITIALISER((_vb).entry.entry) \
509 VALUE_BOX_NDEBUG_INITIALISER \
512 static inline CC_HINT(
nonnull(1), always_inline)
531 .secret = enumv && enumv->flags.secret,
534 fr_value_box_list_entry_init(vb);
542 fr_value_box_list_init(&vb->vb_group);
547 vb->vb_ip.af = AF_INET;
548 vb->vb_ip.prefix = 32;
553 vb->vb_ip.af = AF_INET;
557 vb->vb_ip.af = AF_INET6;
558 vb->vb_ip.prefix = 128;
562 vb->vb_ip.af = AF_INET6;
587 #define fr_value_box_init(_vb, _type, _enumv, _tainted) _fr_value_box_init(NDEBUG_LOCATION_EXP _vb, _type, _enumv, _tainted)
593 #define fr_value_box_init_null(_vb) _fr_value_box_init(NDEBUG_LOCATION_EXP _vb, FR_TYPE_NULL, NULL, false)
595 static inline CC_HINT(always_inline)
621 #define fr_value_box_alloc(_ctx, _type, _enumv) _fr_value_box_alloc(NDEBUG_LOCATION_EXP _ctx, _type, _enumv)
632 #define fr_value_box_alloc_null(_ctx) _fr_value_box_alloc(NDEBUG_LOCATION_EXP _ctx, FR_TYPE_NULL, NULL)
679 unsigned int i = fr_value_box_list_num_elements(list);
710 static inline CC_HINT(
nonnull(2))
739 static inline CC_HINT(always_inline)
763 static inline CC_HINT(always_inline)
797 static inline CC_HINT(always_inline)
822 static inline CC_HINT(
nonnull(1,3), always_inline) \
827 memcpy(dst->vb_ether, src,
sizeof(dst->vb_ether));
831 #define DEF_BOXING_FUNC(_ctype, _field, _type) \
832 static inline CC_HINT(nonnull(1), always_inline) \
833 int fr_value_box_##_field(fr_value_box_t *dst, fr_dict_attr_t const *enumv, \
834 _ctype const value, bool tainted) { \
835 fr_value_box_init(dst, _type, enumv, tainted); \
836 dst->vb_##_field = value; \
871 #define fr_value_box(_box, _var, _tainted) \
873 fr_ipaddr_t * : fr_value_box_ipaddr, \
874 fr_ipaddr_t const * : fr_value_box_ipaddr, \
875 fr_ethernet_t * : fr_value_box_ethernet_addr, \
876 fr_ethernet_t const * : fr_value_box_ethernet_addr, \
877 bool : fr_value_box_bool, \
878 uint8_t : fr_value_box_uint8, \
879 uint16_t : fr_value_box_uint16, \
880 uint32_t : fr_value_box_uint32, \
881 uint64_t : fr_value_box_uint64, \
882 int8_t : fr_value_box_int8, \
883 int16_t : fr_value_box_int16, \
884 int32_t : fr_value_box_int32, \
885 int64_t : fr_value_box_int64, \
886 float : fr_value_box_float32, \
887 double : fr_value_box_float64 \
888 )(_box, NULL, _var, _tainted)
898 #define fr_value_box_len(_ctx, _box, _var, _len, _tainted) \
900 char * : fr_value_box_bstrndup, \
901 char const * : fr_value_box_bstrndup, \
902 uint8_t * : fr_value_box_memdup, \
903 uint8_t const * : fr_value_box_memdup \
904 )(_ctx, _box, NULL, _var, _len, _tainted)
918 fr_strerror_printf(
"Unboxing failed. Needed type %s, had type %s",
923 memcpy(dst, src->vb_ether,
sizeof(src->vb_ether));
927 #define DEF_UNBOXING_FUNC(_ctype, _field, _type) \
928 static inline CC_HINT(nonnull) \
929 int fr_value_unbox_##_field(_ctype *var, fr_value_box_t const *src) { \
930 if (unlikely(src->type != _type)) { \
931 fr_strerror_printf("Unboxing failed. Needed type %s, had type %s", \
932 fr_type_to_str(_type), \
933 fr_type_to_str(src->type)); \
936 *var = src->vb_##_field; \
960 #define fr_value_unbox_shallow(_var, _box) \
962 uint8_t * : fr_value_unbox_uint8, \
963 uint16_t * : fr_value_unbox_uint16, \
964 uint32_t * : fr_value_unbox_uint32, \
965 uint64_t * : fr_value_unbox_uint64, \
966 int8_t * : fr_value_unbox_int8, \
967 int16_t * : fr_value_unbox_int16, \
968 int32_t * : fr_value_unbox_int32, \
969 int64_t * : fr_value_unbox_int64, \
970 float * : fr_value_unbox_float32, \
971 double * : fr_value_unbox_float64 \
997 static inline
size_t fr_value_substr_aunescape(TALLOC_CTX *ctx,
char **
out,
fr_sbuff_t *
in,
size_t inlen,
char quote)
1007 #define FR_VALUE_BOX_TO_NETWORK_RETURN(_dbuff, _value) FR_DBUFF_RETURN(fr_value_box_to_network, _dbuff, _value)
1014 #define FR_VALUE_BOX_NET_ERROR SSIZE_MIN
1018 #define FR_VALUE_BOX_NET_OOM (FR_VALUE_BOX_NET_ERROR + 1)
1022 #define FR_VALUE_BOX_NET_MAX (FR_VALUE_BOX_NET_OOM + 1)
1048 #define fr_value_box_mark_safe_for(_box, _safe_for) _fr_value_box_mark_safe_for(_box, (fr_value_box_safe_for_t)_safe_for)
1055 #define fr_value_box_is_safe_for(_box, _safe_for) (_box->safe_for == (fr_value_box_safe_for_t)_safe_for)
1059 static inline CC_HINT(
nonnull, always_inline)
1065 static inline CC_HINT(
nonnull)
1070 if (box->secret)
return true;
1072 while ((vb = fr_value_box_list_next(&box->vb_group, vb))) {
1079 static inline CC_HINT(
nonnull, always_inline)
1090 char const *src,
bool tainted)
1097 char const *
fmt, va_list ap)
1101 char const *
fmt, ...)
1105 char const *src,
bool tainted)
1117 size_t len,
bool tainted)
1124 char const *src,
size_t len,
bool tainted)
1132 char const *src,
bool tainted)
1136 char const *src,
size_t len,
bool tainted)
1140 char const *src,
bool tainted)
1155 size_t len,
bool tainted)
1162 uint8_t const *src,
size_t len,
bool tainted)
1170 uint8_t const *src,
bool tainted)
1174 uint8_t const *src,
size_t len,
bool tainted)
1178 uint8_t const *src,
bool tainted)
1182 uint8_t const *src,
size_t len,
bool tainted)
1198 fr_sbuff_t *
in, fr_sbuff_parse_rules_t const *rules,
bool tainted)
1218 uint8_t const *sep,
size_t sep_len,
1262 static inline CC_HINT(
nonnull(2,3))
1267 static inline CC_HINT(
nonnull(2,3))
1286 #ifdef WITH_VERIFY_PTR
1287 # define VALUE_BOX_VERIFY(_x) fr_value_box_verify(__FILE__, __LINE__, _x)
1288 # define VALUE_BOX_LIST_VERIFY(_x) fr_value_box_list_verify(__FILE__, __LINE__, _x)
1295 # define VALUE_BOX_VERIFY(_x) fr_assert(_x)
1296 # define VALUE_BOX_LIST_VERIFY(_x) fr_assert(_x)
1297 # define VALUE_BOX_VERIFY(_x) fr_assert(_x)
1298 # define VALUE_BOX_LIST_VERIFY(_x) fr_assert(_x)
static int const char * fmt
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
#define NDEBUG_LOCATION_VALS
#define NDEBUG_LOCATION_ARGS
Pass caller information to the function.
#define FR_DCURSOR_DLIST_TYPES(_name, _list_name, _element_type)
Define type specific wrapper structs for dcursors.
fr_dcursor_eval_t void const * uctx
#define FR_DCURSOR_FUNCS(_name, _list_name, _element_type)
Define type specific wrapper functions for dcursors.
#define FR_DLIST_TYPES(_name)
Define type specific wrapper structs for dlists.
#define FR_DLIST_FUNCS(_name, _element_type, _element_entry)
Define type specific wrapper functions for dlists.
#define FR_DLIST_TYPEDEFS(_name, _head, _entry)
Define friendly names for type specific dlist head and entry structures.
Struct to represent an ethernet address.
Struct to represent an interface id.
@ FR_TYPE_FLOAT32
Single precision floating point.
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
@ FR_TYPE_INT8
8 Bit signed integer.
@ FR_TYPE_ETHERNET
48 Bit Mac-Address.
@ FR_TYPE_IPV6_PREFIX
IPv6 Prefix.
@ 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_COMBO_IP_PREFIX
IPv4 or IPv6 address prefix depending on length.
@ 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_IPV6_ADDR
128 Bit IPv6 Address.
@ FR_TYPE_IPV4_PREFIX
IPv4 Prefix.
@ FR_TYPE_BOOL
A truth value.
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.
@ FR_TYPE_GROUP
A grouping of other attributes.
@ FR_TYPE_FLOAT64
Double precision floating point.
static size_t min(size_t x, size_t y)
#define SBUFF_OUT_TALLOC_FUNC_NO_LEN_DEF(_func,...)
#define SBUFF_OUT_TALLOC_FUNC_DEF(_func, _in, _len,...)
Set of parsing rules for *unescape_until functions.
PRIVATE void float64(struct DATA *p, double d)
fr_aka_sim_id_type_t type
A time delta, a difference in time measured in nanoseconds.
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
static char const * fr_type_to_str(fr_type_t type)
Return a static string containing the type name.
#define FR_TYPE_STRUCTURAL
fr_value_box_list_action_t
Actions to perform when we process a box in a list.
@ FR_VALUE_BOX_LIST_NONE
Do nothing to processed boxes.
@ FR_VALUE_BOX_LIST_REMOVE
Remove the box from the input list.
@ FR_VALUE_BOX_LIST_FREE_BOX_VALUE
Explicitly free any value buffers associated with a box.
@ FR_VALUE_BOX_LIST_FREE_BOX
Free each processed box.
size_t const fr_value_box_field_sizes[]
How many bytes wide each of the value data fields are.
fr_sbuff_escape_rules_t fr_value_escape_double
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.
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)
fr_ifid_t ifid
IPv6 interface ID.
void fr_value_box_debug(fr_value_box_t const *vb)
Print the value of a box as info messages.
uint16_t uint16
16bit unsigned integer.
#define DEF_UNBOXING_FUNC(_ctype, _field, _type)
fr_sbuff_escape_rules_t fr_value_escape_single
uint32_t fr_value_box_hash(fr_value_box_t const *vb)
Hash the contents of a value box.
static int fr_value_box_memcpy_out(void *out, fr_value_box_t const *vb)
Copy the value of a value box to a field in a C struct.
int8_t int8
8bit signed integer.
fr_sbuff_parse_rules_t const value_parse_rules_single_3quoted
void fr_value_box_list_untaint(fr_value_box_list_t *head))
Untaint every list member (and their children)
static fr_slen_t fr_value_box_aprint(TALLOC_CTX *ctx, char **out, fr_value_box_t const *data, fr_sbuff_escape_rules_t const *e_rules) 1(fr_value_box_print
static bool fr_value_box_is_secret(fr_value_box_t const *box)
#define DEF_BOXING_FUNC(_ctype, _field, _type)
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.
fr_sbuff_parse_rules_t const value_parse_rules_double_unquoted
size_t size
System specific file/memory size.
fr_sbuff_parse_rules_t const value_parse_rules_solidus_quoted
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.
static bool fr_value_box_contains_secret(fr_value_box_t const *box)
fr_value_box_list_t children
for groups
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.
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_asprintf(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, bool tainted, char const *fmt,...)
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.
static bool fr_value_box_list_len_min(fr_value_box_list_t const *list, unsigned int min)
Determines whether a list contains the number of boxes required.
fr_type_t _CONST type
Type and flags should appear together for packing efficiency.
fr_sbuff_parse_rules_t const * value_parse_rules_unquoted_char[UINT8_MAX]
fr_sbuff_parse_rules_t const * value_parse_rules_quoted[T_TOKEN_LAST]
Parse rules for quoted strings.
static void fr_value_box_set_secret(fr_value_box_t *box, bool secret)
int fr_value_box_mem_append(TALLOC_CTX *ctx, fr_value_box_t *dst, uint8_t const *src, size_t len, bool tainted))
Append data to an existing fr_value_box_t.
float float32
Single precision float.
int(* fr_value_box_escape_t)(fr_value_box_t *vb, void *uctx)
Escape a value box.
int8_t fr_value_box_cmp(fr_value_box_t const *a, fr_value_box_t const *b)
Compare two values.
size_t const fr_value_box_offsets[]
Where the value starts in the fr_value_box_t.
fr_sbuff_parse_rules_t const * value_parse_rules_quoted_char[UINT8_MAX]
int fr_value_box_bstr_append_buffer(TALLOC_CTX *ctx, fr_value_box_t *dst, char const *src, bool tainted))
Append a talloced buffer to an existing fr_value_box_t.
#define FR_VALUE_BOX_MAGIC
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.
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.
fr_sbuff_parse_rules_t const value_parse_rules_bareword_unquoted
Default formatting rules.
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_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.
fr_sbuff_parse_rules_t const value_parse_rules_single_unquoted
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.
unsigned int immutable
once set, the value cannot be changed
fr_sbuff_unescape_rules_t fr_value_unescape_solidus
void fr_value_box_list_taint(fr_value_box_list_t *head))
Taint every list member (and their children)
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))
fr_unix_time_t date
Date internal format in nanoseconds.
ssize_t fr_value_box_from_str(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, char const *in, size_t inlen, fr_sbuff_unescape_rules_t const *erules, bool tainted))
uint64_t magic
Value to verify that the structure was allocated or initialised properly.
fr_ipaddr_t ip
IPv4/6 address/prefix.
fr_sbuff_parse_rules_t const value_parse_rules_single_quoted
int32_t int32
32bit signed integer.
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.
fr_sbuff_unescape_rules_t * fr_value_unescape_by_char[UINT8_MAX+1]
void fr_value_box_list_debug(fr_value_box_list_t const *head)
Print a list of value boxes as info messages.
fr_sbuff_escape_rules_t fr_value_escape_solidus
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.
char const * file
File where the box was allocated or initialised.
void fr_value_box_increment(fr_value_box_t *vb)
Increment a boxed value.
fr_sbuff_escape_rules_t * fr_value_escape_by_quote[T_TOKEN_LAST]
size_t fr_value_str_unescape(fr_sbuff_t *out, fr_sbuff_t *in, size_t inlen, char quote)
Convert a string value with escape sequences into its binary form.
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.
ssize_t fr_value_box_list_concat_as_string(bool *tainted, bool *secret, fr_sbuff_t *sbuff, fr_value_box_list_t *list, char const *sep, size_t sep_len, fr_sbuff_escape_rules_t const *e_rules, fr_value_box_list_action_t proc_action, fr_value_box_safe_for_t safe_for, bool flatten))
Concatenate a list of value boxes together.
static size_t char fr_sbuff_t size_t inlen
void fr_value_box_list_verify(char const *file, int line, fr_value_box_list_t const *list))
ssize_t fr_value_box_list_concat_as_octets(bool *tainted, bool *secret, fr_dbuff_t *dbuff, fr_value_box_list_t *list, uint8_t const *sep, size_t sep_len, fr_value_box_list_action_t proc_action, bool flatten))
Concatenate a list of value boxes together.
fr_sbuff_parse_rules_t const * value_parse_rules_3quoted[T_TOKEN_LAST]
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.
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.
void _fr_value_box_mark_safe_for(fr_value_box_t *box, fr_value_box_safe_for_t safe_for)
Mark a value-box as "safe", of a particular type.
void fr_value_box_clear_value(fr_value_box_t *data))
Clear/free any existing value.
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 int fr_value_box_memcpy_in(fr_value_box_t *vb, void const *in)
Copy a C value value to a value box.
static fr_value_box_t * fr_value_box_acopy(TALLOC_CTX *ctx, fr_value_box_t const *src)
Copy an existing box, allocating a new box to hold its contents.
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)
bool boolean
A truth value.
fr_sbuff_parse_rules_t const value_parse_rules_double_3quoted
static always_inline void _fr_value_box_init(NDEBUG_LOCATION_ARGS fr_value_box_t *vb, fr_type_t type, fr_dict_attr_t const *enumv, bool tainted)
static size_t fr_value_str_aunescape(TALLOC_CTX *ctx, char **out, fr_sbuff_t *in, size_t inlen, char quote) static inline size_t fr_value_substr_aunescape(TALLOC_CTX *ctx
fr_sbuff_escape_rules_t fr_value_escape_unprintables
int line
Line where the box was allocated or initialised.
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.
fr_sbuff_escape_rules_t fr_value_escape_backtick
fr_dict_attr_t const * enumv
Enumeration values.
bool fr_value_box_is_truthy(fr_value_box_t const *box))
Check truthiness of values.
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.
uintptr_t fr_value_box_safe_for_t
Escaping that's been applied to a value box.
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.
fr_sbuff_escape_rules_t * fr_value_escape_by_char[UINT8_MAX+1]
fr_sbuff_unescape_rules_t fr_value_unescape_backtick
int fr_value_unbox_ipaddr(fr_ipaddr_t *dst, fr_value_box_t *src)
Unbox an IP address performing a type check.
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.
int fr_value_box_list_escape_in_place(fr_value_box_list_t *list, fr_value_box_escape_t escape, fr_value_box_safe_for_t escaped, void *uctx))
Escape a list of value boxes in place.
fr_sbuff_parse_rules_t const value_parse_rules_bareword_quoted
fr_sbuff_parse_rules_t const value_parse_rules_backtick_3quoted
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.
fr_value_box_entry_t entry
Doubly linked list entry.
fr_ethernet_t ether
Ethernet (MAC) address.
unsigned int secret
Same as fr_dict_attr_flags_t secret.
fr_sbuff_parse_rules_t const value_parse_rules_solidus_unquoted
fr_sbuff_parse_rules_t const value_parse_rules_backtick_quoted
fr_value_box_datum_t datum
The value held by the value box.
fr_sbuff_parse_rules_t const * value_parse_rules_unquoted[T_TOKEN_LAST]
Parse rules for non-quoted strings.
unsigned int talloced
Talloced, not stack or text allocated.
double float64
Double precision float.
#define fr_value_box_alloc_null(_ctx)
Allocate a value box for later use with a value assignment function.
uint64_t uint64
64bit unsigned integer.
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.
fr_value_box_safe_for_t _CONST safe_for
A unique value to indicate if that value box is safe for consumption by a particular module for a par...
fr_sbuff_unescape_rules_t fr_value_unescape_single
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.
static fr_slen_t static e_rules fr_slen_t fr_value_box_aprint_quoted(TALLOC_CTX *ctx, char **out, fr_value_box_t const *data, fr_token_t quote) 1(fr_value_box_print_quoted
unsigned int tainted
i.e. did it come from an untrusted source
fr_sbuff_parse_rules_t const value_parse_rules_backtick_unquoted
fr_sbuff_parse_rules_t const value_parse_rules_double_quoted
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.
fr_sbuff_unescape_rules_t * fr_value_unescape_by_quote[T_TOKEN_LAST]
static size_t char fr_sbuff_t * in
static fr_value_box_t * _fr_value_box_alloc(NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, fr_type_t type, fr_dict_attr_t const *enumv)
fr_sbuff_parse_rules_t const value_parse_rules_solidus_3quoted
uint32_t uint32
32bit unsigned integer.
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.
unsigned int edit
to control foreach / edits
static size_t char fr_sbuff_t size_t char quote 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.
uint128_t uint128
128bit unsigned integer.
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.
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.
int16_t int16
16bit signed integer.
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.
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.
void fr_value_box_copy_shallow(TALLOC_CTX *ctx, fr_value_box_t *dst, const fr_value_box_t *src))
Perform a shallow copy of a value_box.
static always_inline int fr_value_box_ethernet_addr(fr_value_box_t *dst, fr_dict_attr_t const *enumv, fr_ethernet_t const *src, bool tainted)
static int fr_value_unbox_ethernet_addr(fr_ethernet_t *dst, fr_value_box_t *src)
Unbox an ethernet value (6 bytes, network byte order)
ssize_t fr_value_box_from_substr(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *rules, bool tainted))
Convert string value to a fr_value_box_t type.
#define fr_value_box_init(_vb, _type, _enumv, _tainted)
Initialise a fr_value_box_t.
void fr_value_box_clear(fr_value_box_t *data))
Clear/free any existing value and metadata.
void fr_value_box_mark_unsafe(fr_value_box_t *box)
Mark a value-box as "unsafe".
uint8_t uint8
8bit unsigned integer.
int fr_value_box_mem_append_buffer(TALLOC_CTX *ctx, fr_value_box_t *dst, uint8_t const *src, bool tainted))
Append a talloc buffer to an existing fr_value_box_t.
fr_sbuff_unescape_rules_t fr_value_unescape_double
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.
int format(printf, 5, 0))
int fr_value_box_escape_in_place(fr_value_box_t *vb, fr_value_box_escape_t escape, fr_value_box_safe_for_t escaped, void *uctx))
Escape a single value box in place.
size_t fr_value_substr_unescape(fr_sbuff_t *out, fr_sbuff_t *in, size_t inlen, char quote)
Convert a string value with escape sequences into its binary form.
fr_sbuff_escape_rules_t fr_value_escape_secret
Escape secret fields by simply mashing all data to '.
static size_t char ** out
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.
int fr_value_box_bstrn_append(TALLOC_CTX *ctx, fr_value_box_t *dst, char const *src, size_t len, bool tainted))
Append bytes from a buffer to an existing fr_value_box_t.
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.
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.
fr_time_delta_t time_delta
a delta time in nanoseconds
int64_t int64
64bit signed integer;
static uint8_t * fr_value_box_raw(fr_value_box_t const *vb, fr_type_t type)
Return a pointer to the "raw" value from a value-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.
Union containing all data types supported by the server.