From: Arran Cudbard-Bell Date: Tue, 9 May 2017 16:31:38 +0000 (-0400) Subject: s/value_box_t/fr_value_box_t/ X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=709ea8dad0cba4ef6e88021b544f584ca1115aaa;p=thirdparty%2Ffreeradius-server.git s/value_box_t/fr_value_box_t/ --- diff --git a/src/include/cursor.h b/src/include/cursor.h index 7b03adcff8b..7f1b48d96cc 100644 --- a/src/include/cursor.h +++ b/src/include/cursor.h @@ -85,7 +85,7 @@ void fr_cursor_list_free(fr_cursor_t *cursor) CC_HINT(nonnull); * @param[in] _head of item list. * @param[in] _iter function. * @param[in] _ctx _iter function _ctx. - * @param[in] _type Talloc type i.e. VALUE_PAIR or value_box_t. + * @param[in] _type Talloc type i.e. VALUE_PAIR or fr_value_box_t. * @return * - NULL if _head does not point to any items, or the iterator matches no items * in the current list. @@ -112,7 +112,7 @@ void fr_cursor_list_free(fr_cursor_t *cursor) CC_HINT(nonnull); * * @param[in] _cursor to initialise. * @param[in] _head of item list. - * @param[in] _type Talloc type i.e. VALUE_PAIR or value_box_t. + * @param[in] _type Talloc type i.e. VALUE_PAIR or fr_value_box_t. * @return * - NULL if _head does not point to any items. * - The first item in the list. diff --git a/src/include/libradius.h b/src/include/libradius.h index 719eb2830a9..8a45cc22727 100644 --- a/src/include/libradius.h +++ b/src/include/libradius.h @@ -206,7 +206,7 @@ void fr_talloc_verify_cb(const void *ptr, int depth, #ifdef WITH_ASCEND_BINARY /* filters.c */ -int ascend_parse_filter(value_box_t *out, char const *value, size_t len); +int ascend_parse_filter(fr_value_box_t *out, char const *value, size_t len); void print_abinary(char *out, size_t outlen, uint8_t const *data, size_t len, int8_t quote); #endif /*WITH_ASCEND_BINARY*/ diff --git a/src/include/pair.h b/src/include/pair.h index 7c8e44ded87..9fa45fc7eb6 100644 --- a/src/include/pair.h +++ b/src/include/pair.h @@ -86,13 +86,13 @@ typedef struct value_pair { // VALUE_SET *set; //!< Set of child attributes. // VALUE_LIST *list; //!< List of values for //!< multivalued attribute. - // value_box_t *data; //!< Value data for this attribute. + // fr_value_box_t *data; //!< Value data for this attribute. char const *xlat; //!< Source string for xlat expansion. }; value_type_t type; //!< Type of pointer in value union. - value_box_t data; + fr_value_box_t data; } VALUE_PAIR; /** Abstraction to allow iterating over different configurations of VALUE_PAIRs @@ -198,7 +198,7 @@ void fr_pair_replace(VALUE_PAIR **head, VALUE_PAIR *add); int fr_pair_update_by_num(TALLOC_CTX *ctx, VALUE_PAIR **list, unsigned int vendor, unsigned int attr, int8_t tag, - value_box_t *value); + fr_value_box_t *value); void fr_pair_delete_by_num(VALUE_PAIR **head, unsigned int vendor, unsigned int attr, int8_t tag); @@ -212,7 +212,7 @@ typedef int8_t (*fr_cmp_t)(void const *a, void const *b); * - 0 if not equal. * - -1 on failure. */ -#define fr_pair_cmp_op(_op, _a, _b) value_box_cmp_op(_op, &_a->data, &_b->data) +#define fr_pair_cmp_op(_op, _a, _b) fr_value_box_cmp_op(_op, &_a->data, &_b->data) int8_t fr_pair_cmp_by_da_tag(void const *a, void const *b); int8_t fr_pair_cmp_by_parent_num_tag(void const *a, void const *b); int fr_pair_cmp(VALUE_PAIR *a, VALUE_PAIR *b); diff --git a/src/include/tmpl.h b/src/include/tmpl.h index 349cf1ae1a7..83a478d9ccd 100644 --- a/src/include/tmpl.h +++ b/src/include/tmpl.h @@ -197,7 +197,7 @@ typedef struct vp_tmpl_t { /* * Attribute value. Typically used as the RHS of an update map. */ - value_box_t literal; //!< Value data. + fr_value_box_t literal; //!< Value data. xlat_exp_t *xlat; //!< pre-parsed xlat_exp_t @@ -232,9 +232,9 @@ typedef struct vp_tmpl_t { * @{ */ #define tmpl_value_box data.literal -#define tmpl_value_box_datum data.literal.datum -#define tmpl_value_box_length data.literal.datum.length -#define tmpl_value_box_type data.literal.type +#define tmpl_fr_value_box_datum data.literal.datum +#define tmpl_fr_value_box_length data.literal.datum.length +#define tmpl_fr_value_box_type data.literal.type /* @} **/ /** @name Field accessors for #TMPL_TYPE_REGEX_STRUCT and #TMPL_TYPE_REGEX @@ -299,7 +299,7 @@ void tmpl_verify(char const *file, int line, vp_tmpl_t const *vpt); @code{.c} TALLOC_CTX *ctx; VALUE_PAIR **head; - value_box_t value; + fr_value_box_t value; RADIUS_LIST_AND_CTX(ctx, head, request, CURRENT_REQUEST, PAIR_LIST_REQUEST); if (!list) return -1; // error @@ -384,7 +384,7 @@ vp_tmpl_t *tmpl_alloc(TALLOC_CTX *ctx, tmpl_type_t type, char const *name, void tmpl_from_da(vp_tmpl_t *vpt, fr_dict_attr_t const *da, int8_t tag, int num, request_refs_t request, pair_lists_t list); -int tmpl_afrom_value_box(TALLOC_CTX *ctx, vp_tmpl_t **out, value_box_t *data, bool steal); +int tmpl_afrom_value_box(TALLOC_CTX *ctx, vp_tmpl_t **out, fr_value_box_t *data, bool steal); ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, vp_tmpl_t **out, char const *name, request_refs_t request_def, pair_lists_t list_def, diff --git a/src/include/types.h b/src/include/types.h index 3b675fee326..bbca1315c15 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -19,7 +19,7 @@ * $Id$ * * @file include/types.h - * @brief #value_box_t types + * @brief #fr_value_box_t types * * @copyright 2017 The FreeRADIUS server project */ diff --git a/src/include/value.h b/src/include/value.h index 992a4e478b8..9846e55b5a3 100644 --- a/src/include/value.h +++ b/src/include/value.h @@ -19,10 +19,10 @@ #include #include -extern size_t const value_box_field_sizes[]; -extern size_t const value_box_offsets[]; +extern size_t const fr_value_box_field_sizes[]; +extern size_t const fr_value_box_offsets[]; -#define value_box_foreach(_v, _iv) for (value_box_t *_iv = v; _iv; _iv = _iv->next) +#define fr_value_box_foreach(_v, _iv) for (fr_value_box_t *_iv = v; _iv; _iv = _iv->next) /** Union containing all data types supported by the server * @@ -31,7 +31,7 @@ extern size_t const value_box_offsets[]; * * fr_type_t should be an enumeration of the values in this union. */ -typedef struct value_box value_box_t; +typedef struct value_box fr_value_box_t; struct value_box { union { /* @@ -79,68 +79,68 @@ struct value_box { bool tainted; //!< i.e. did it come from an untrusted source - value_box_t *next; //!< Next in a series of value_box. + fr_value_box_t *next; //!< Next in a series of value_box. }; /* * Allocation */ -value_box_t *value_box_alloc(TALLOC_CTX *ctx, fr_type_t type); +fr_value_box_t *fr_value_box_alloc(TALLOC_CTX *ctx, fr_type_t type); -void value_box_clear(value_box_t *data); +void fr_value_box_clear(fr_value_box_t *data); /* * Comparison */ -int value_box_cmp(value_box_t const *a, value_box_t const *b); +int fr_value_box_cmp(fr_value_box_t const *a, fr_value_box_t const *b); -int value_box_cmp_op(FR_TOKEN op, value_box_t const *a, value_box_t const *b); +int fr_value_box_cmp_op(FR_TOKEN op, fr_value_box_t const *a, fr_value_box_t const *b); /* * Conversion */ size_t value_str_unescape(uint8_t *out, char const *in, size_t inlen, char quote); -int value_box_hton(value_box_t *dst, value_box_t const *src); +int fr_value_box_hton(fr_value_box_t *dst, fr_value_box_t const *src); -int value_box_cast(TALLOC_CTX *ctx, value_box_t *dst, +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, - value_box_t const *src); + fr_value_box_t const *src); /* * Assignment */ -int value_box_copy(TALLOC_CTX *ctx, value_box_t *dst, const value_box_t *src); -void value_box_copy_shallow(TALLOC_CTX *ctx, value_box_t *dst, const value_box_t *src); -int value_box_steal(TALLOC_CTX *ctx, value_box_t *dst, value_box_t const *src); - -int value_box_strdup(TALLOC_CTX *ctx, value_box_t *dst, char const *src, bool tainted); -int value_box_strdup_buffer(TALLOC_CTX *ctx, value_box_t *dst, char const *src, bool tainted); -int value_box_strsteal(TALLOC_CTX *ctx, value_box_t *dst, char *src, bool tainted); -int value_box_strdup_shallow(value_box_t *dst, char const *src, bool tainted); -int value_box_strdup_buffer_shallow(TALLOC_CTX *ctx, value_box_t *dst, char const *src, bool tainted); - -int value_box_memdup(TALLOC_CTX *ctx, value_box_t *dst, uint8_t const *src, size_t len, bool tainted); -int value_box_memdup_buffer(TALLOC_CTX *ctx, value_box_t *dst, uint8_t *src, bool tainted); -int value_box_memsteal(TALLOC_CTX *ctx, value_box_t *dst, uint8_t const *src, bool tainted); -int value_box_memdup_shallow(value_box_t *dst, uint8_t *src, size_t len, bool tainted); -int value_box_memdup_buffer_shallow(TALLOC_CTX *ctx, value_box_t *dst, uint8_t *src, bool tainted); +int fr_value_box_copy(TALLOC_CTX *ctx, fr_value_box_t *dst, const fr_value_box_t *src); +void fr_value_box_copy_shallow(TALLOC_CTX *ctx, fr_value_box_t *dst, const fr_value_box_t *src); +int fr_value_box_steal(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t const *src); + +int fr_value_box_strdup(TALLOC_CTX *ctx, fr_value_box_t *dst, char const *src, bool tainted); +int fr_value_box_strdup_buffer(TALLOC_CTX *ctx, fr_value_box_t *dst, char const *src, bool tainted); +int fr_value_box_strsteal(TALLOC_CTX *ctx, fr_value_box_t *dst, char *src, bool tainted); +int fr_value_box_strdup_shallow(fr_value_box_t *dst, char const *src, bool tainted); +int fr_value_box_strdup_buffer_shallow(TALLOC_CTX *ctx, fr_value_box_t *dst, char const *src, bool tainted); + +int fr_value_box_memdup(TALLOC_CTX *ctx, fr_value_box_t *dst, uint8_t const *src, size_t len, bool tainted); +int fr_value_box_memdup_buffer(TALLOC_CTX *ctx, fr_value_box_t *dst, uint8_t *src, bool tainted); +int fr_value_box_memsteal(TALLOC_CTX *ctx, fr_value_box_t *dst, uint8_t const *src, bool tainted); +int fr_value_box_memdup_shallow(fr_value_box_t *dst, uint8_t *src, size_t len, bool tainted); +int fr_value_box_memdup_buffer_shallow(TALLOC_CTX *ctx, fr_value_box_t *dst, uint8_t *src, bool tainted); /* * Parsing */ -int value_box_from_ipaddr(value_box_t *dst, fr_ipaddr_t const *ipaddr); +int fr_value_box_from_ipaddr(fr_value_box_t *dst, fr_ipaddr_t const *ipaddr); -int value_box_from_str(TALLOC_CTX *ctx, value_box_t *dst, +int fr_value_box_from_str(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t *src_type, fr_dict_attr_t const *src_enumv, char const *src, ssize_t src_len, char quote); /* * Printing */ -size_t value_box_network_length(value_box_t *value); +size_t fr_value_box_network_length(fr_value_box_t *value); -char *value_box_asprint(TALLOC_CTX *ctx, value_box_t const *data, char quote); +char *fr_value_box_asprint(TALLOC_CTX *ctx, fr_value_box_t const *data, char quote); -size_t value_box_snprint(char *out, size_t outlen, value_box_t const *data, char quote); +size_t fr_value_box_snprint(char *out, size_t outlen, fr_value_box_t const *data, char quote); #endif /* _FR_VALUE_H */ diff --git a/src/lib/ldap/libfreeradius-ldap.h b/src/lib/ldap/libfreeradius-ldap.h index 2f39bb928e1..fe2a734f17c 100644 --- a/src/lib/ldap/libfreeradius-ldap.h +++ b/src/lib/ldap/libfreeradius-ldap.h @@ -345,7 +345,7 @@ extern FR_NAME_NUMBER const fr_ldap_tls_require_cert[]; * @param[out] value to write berval values to. * @param[in] berval to copy pointers/lengths from. */ -static inline void fr_ldap_berval_to_value(value_box_t *value, struct berval *berval) +static inline void fr_ldap_berval_to_value(fr_value_box_t *value, struct berval *berval) { value->datum.ptr = berval->bv_val; value->datum.length = berval->bv_len; diff --git a/src/lib/util/dict.c b/src/lib/util/dict.c index 9d11e092795..f4acef1bb2d 100644 --- a/src/lib/util/dict.c +++ b/src/lib/util/dict.c @@ -216,7 +216,7 @@ bool const fr_dict_non_data_types[FR_TYPE_MAX + 1] = { /** Numeric dictionary types * - * @note Must be updated to match the anonymous enum types union in value_box_t + * @note Must be updated to match the anonymous enum types union in fr_value_box_t */ bool const fr_dict_enum_types[FR_TYPE_MAX + 1] = { [FR_TYPE_BYTE] = true, diff --git a/src/lib/util/filters.c b/src/lib/util/filters.c index 3ee34967f46..7c8cdc7c597 100644 --- a/src/lib/util/filters.c +++ b/src/lib/util/filters.c @@ -952,7 +952,7 @@ static int ascend_parse_generic(int argc, char **argv, * - 0 on success. * - -1 on failure. */ -int ascend_parse_filter(value_box_t *out, char const *value, size_t len) +int ascend_parse_filter(fr_value_box_t *out, char const *value, size_t len) { int token, type; int rcode; diff --git a/src/lib/util/pair.c b/src/lib/util/pair.c index 4fb1dba5c35..1af8da291dd 100644 --- a/src/lib/util/pair.c +++ b/src/lib/util/pair.c @@ -770,7 +770,7 @@ void fr_pair_replace(VALUE_PAIR **head, VALUE_PAIR *replace) */ int fr_pair_update_by_num(TALLOC_CTX *ctx, VALUE_PAIR **list, unsigned int vendor, unsigned int attr, int8_t tag, - value_box_t *value) + fr_value_box_t *value) { vp_cursor_t cursor; VALUE_PAIR *vp; @@ -779,14 +779,14 @@ int fr_pair_update_by_num(TALLOC_CTX *ctx, VALUE_PAIR **list, vp = fr_pair_cursor_next_by_num(&cursor, vendor, attr, tag); if (vp) { VERIFY_VP(vp); - if (value_box_steal(vp, &vp->data, value) < 0) return -1; + if (fr_value_box_steal(vp, &vp->data, value) < 0) return -1; return 0; } vp = fr_pair_afrom_num(ctx, vendor, attr); if (!vp) return -1; vp->tag = tag; - if (value_box_steal(vp, &vp->data, value) < 0) return -1; + if (fr_value_box_steal(vp, &vp->data, value) < 0) return -1; fr_pair_cursor_append(&cursor, vp); @@ -1066,7 +1066,7 @@ int fr_pair_list_cmp(VALUE_PAIR *a, VALUE_PAIR *b) return 1; } - ret = value_box_cmp(&a_p->data, &b_p->data); + ret = fr_value_box_cmp(&a_p->data, &b_p->data); if (ret != 0) { (void)fr_cond_assert(ret >= -1); /* Comparison error */ return ret; @@ -1977,7 +1977,7 @@ int fr_pair_value_from_str(VALUE_PAIR *vp, char const *value, size_t inlen) * We presume that the input data is from a double quoted * string, and needs escaping */ - if (value_box_from_str(vp, &vp->data, &type, vp->da, value, inlen, '"') < 0) return -1; + if (fr_value_box_from_str(vp, &vp->data, &type, vp->da, value, inlen, '"') < 0) return -1; /* * If we parsed to a different type than the DA associated with @@ -2020,7 +2020,7 @@ void fr_pair_value_memcpy(VALUE_PAIR *vp, uint8_t const *src, size_t size) p = talloc_memdup(vp, src, size); if (!p) return; - value_box_clear(&vp->data); + fr_value_box_clear(&vp->data); vp->vp_octets = p; vp->vp_length = size; @@ -2039,7 +2039,7 @@ void fr_pair_value_memcpy(VALUE_PAIR *vp, uint8_t const *src, size_t size) */ void fr_pair_value_memsteal(VALUE_PAIR *vp, uint8_t const *src) { - value_box_clear(&vp->data); + fr_value_box_clear(&vp->data); vp->vp_octets = talloc_steal(vp, src); vp->vp_length = talloc_array_length(vp->vp_octets); @@ -2060,7 +2060,7 @@ void fr_pair_value_strsteal(VALUE_PAIR *vp, char const *src) { if (!fr_cond_assert(vp->da->type == FR_TYPE_STRING)) return; - value_box_clear(&vp->data); + fr_value_box_clear(&vp->data); vp->vp_strvalue = talloc_steal(vp, src); vp->vp_length = talloc_array_length(vp->vp_strvalue) - 1; @@ -2089,7 +2089,7 @@ void fr_pair_value_strnsteal(VALUE_PAIR *vp, char *src, size_t len) if (!fr_cond_assert(vp->da->type == FR_TYPE_STRING)) return; - value_box_clear(&vp->data); + fr_value_box_clear(&vp->data); buf_len = talloc_array_length(src); if (buf_len > (len + 1)) { @@ -2125,7 +2125,7 @@ void fr_pair_value_strcpy(VALUE_PAIR *vp, char const *src) p = talloc_strdup(vp, src); if (!p) return; - value_box_clear(&vp->data); + fr_value_box_clear(&vp->data); vp->vp_strvalue = p; vp->type = VT_DATA; @@ -2159,7 +2159,7 @@ void fr_pair_value_bstrncpy(VALUE_PAIR *vp, void const *src, size_t len) memcpy(p, src, len); /* embdedded \0 safe */ p[len] = '\0'; - value_box_clear(&vp->data); + fr_value_box_clear(&vp->data); vp->vp_strvalue = p; vp->vp_length = len; @@ -2190,7 +2190,7 @@ void fr_pair_value_snprintf(VALUE_PAIR *vp, char const *fmt, ...) va_end(ap); if (!p) return; - value_box_clear(&vp->data); + fr_value_box_clear(&vp->data); vp->vp_strvalue = p; vp->vp_length = talloc_array_length(vp->vp_strvalue) - 1; @@ -2219,7 +2219,7 @@ size_t fr_pair_value_snprint(char *out, size_t outlen, VALUE_PAIR const *vp, cha if (vp->type == VT_XLAT) return snprintf(out, outlen, "%c%s%c", quote, vp->xlat, quote); - return value_box_snprint(out, outlen, &vp->data, quote); + return fr_value_box_snprint(out, outlen, &vp->data, quote); } /** Print one attribute value to a string @@ -2235,7 +2235,7 @@ char *fr_pair_value_asprint(TALLOC_CTX *ctx, VALUE_PAIR const *vp, char quote) if (vp->type == VT_XLAT) return fr_asprint(ctx, vp->xlat, talloc_array_length(vp->xlat) - 1, quote); - return value_box_asprint(ctx, &vp->data, quote); + return fr_value_box_asprint(ctx, &vp->data, quote); } /** Return a const buffer for an enum type attribute diff --git a/src/lib/util/print.c b/src/lib/util/print.c index 62b4410ab97..884b9fc014f 100644 --- a/src/lib/util/print.c +++ b/src/lib/util/print.c @@ -606,14 +606,14 @@ char *fr_vasprintf(TALLOC_CTX *ctx, char const *fmt, va_list ap) switch (*(p + 1)) { case 'V': { - value_box_t const *in = va_arg(ap_q, value_box_t const *); + fr_value_box_t const *in = va_arg(ap_q, fr_value_box_t const *); /* * Allocations that are not part of the output * string need to occur in the NULL ctx so we don't fragment * any pool associated with it. */ - subst = value_box_asprint(NULL, in, '"'); + subst = fr_value_box_asprint(NULL, in, '"'); if (!subst) { talloc_free(out); va_end(ap_p); diff --git a/src/lib/util/value.c b/src/lib/util/value.c index cb9b83f53e2..234a60c51cf 100644 --- a/src/lib/util/value.c +++ b/src/lib/util/value.c @@ -21,24 +21,24 @@ * * There are three notional data formats used in the server: * - * - #value_box_t are the INTERNAL format. This is usually close to the in-memory representation + * - #fr_value_box_t are the INTERNAL format. This is usually close to the in-memory representation * of the data, though integers and IPs are always converted to/from octets with BIG ENDIAN * byte ordering for consistency. - * - #value_box_cast is used to convert (cast) #value_box_t between INTERNAL formats. - * - #value_box_strdup* is used to ingest nul terminated strings into the INTERNAL format. - * - #value_box_memdup* is used to ingest binary data into the INTERNAL format. + * - #fr_value_box_cast is used to convert (cast) #fr_value_box_t between INTERNAL formats. + * - #fr_value_box_strdup* is used to ingest nul terminated strings into the INTERNAL format. + * - #fr_value_box_memdup* is used to ingest binary data into the INTERNAL format. * * - NETWORK format is the format we send/receive on the wire. It is not a perfect representation * of data packing for all protocols, so you will likely need to overload conversion for some types. - * - value_box_to_network is used to covert INTERNAL format data to generic NETWORK format data. + * - fr_value_box_to_network is used to covert INTERNAL format data to generic NETWORK format data. * For integers, IP addresses etc... This means BIG ENDIAN byte ordering. - * - value_box_from_network is used to convert packet buffer fragments in NETWORK format to + * - fr_value_box_from_network is used to convert packet buffer fragments in NETWORK format to * INTERNAL format. * * - PRESENTATION format is what we print to the screen, and what we get from the user, databases * and configuration files. - * - #value_box_asprint is used to convert INTERNAL format PRESENTATION format. - * - #value_box_from_str is used to convert from INTERNAL to PRESENTATION format. + * - #fr_value_box_asprint is used to convert INTERNAL format PRESENTATION format. + * - #fr_value_box_from_str is used to convert from INTERNAL to PRESENTATION format. * * @copyright 2014-2017 The FreeRADIUS server project * @copyright 2017 Arran Cudbard-Bell @@ -49,17 +49,17 @@ RCSID("$Id$") #include #include -/** How many bytes on-the-wire would a #value_box_t value consume +/** 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 #value_box_field_sizes. + * 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 #value_box_network_length instead, as that deals with variable + * Use #fr_value_box_network_length instead, as that deals with variable * length attributes too. */ -static size_t const value_box_network_sizes[FR_TYPE_MAX + 1][2] = { +static size_t const fr_value_box_network_sizes[FR_TYPE_MAX + 1][2] = { [FR_TYPE_INVALID] = {~0, 0}, [FR_TYPE_STRING] = {0, ~0}, @@ -86,90 +86,90 @@ static size_t const value_box_network_sizes[FR_TYPE_MAX + 1][2] = { [FR_TYPE_MAX] = {~0, 0} //!< Ensure array covers all types. }; -static_assert(SIZEOF_MEMBER(value_box_t, datum.ip.addr.v4.s_addr) == 4, +static_assert(SIZEOF_MEMBER(fr_value_box_t, datum.ip.addr.v4.s_addr) == 4, "in_addr.s_addr has unexpected length"); -static_assert(SIZEOF_MEMBER(value_box_t, datum.ip.addr.v6.s6_addr) == 16, +static_assert(SIZEOF_MEMBER(fr_value_box_t, datum.ip.addr.v6.s6_addr) == 16, "in6_addr.s6_addr has unexpected length"); -static_assert(SIZEOF_MEMBER(value_box_t, datum.ifid) == 8, +static_assert(SIZEOF_MEMBER(fr_value_box_t, datum.ifid) == 8, "datum.ifid has unexpected length"); -static_assert(SIZEOF_MEMBER(value_box_t, datum.ether) == 6, +static_assert(SIZEOF_MEMBER(fr_value_box_t, datum.ether) == 6, "datum.ether has unexpected length"); -static_assert(SIZEOF_MEMBER(value_box_t, datum.boolean) == 1, +static_assert(SIZEOF_MEMBER(fr_value_box_t, datum.boolean) == 1, "datum.boolean has unexpected length"); -static_assert(SIZEOF_MEMBER(value_box_t, datum.byte) == 1, +static_assert(SIZEOF_MEMBER(fr_value_box_t, datum.byte) == 1, "datum.byte has unexpected length"); -static_assert(SIZEOF_MEMBER(value_box_t, datum.ushort) == 2, +static_assert(SIZEOF_MEMBER(fr_value_box_t, datum.ushort) == 2, "datum.ushort has unexpected length"); -static_assert(SIZEOF_MEMBER(value_box_t, datum.integer) == 4, +static_assert(SIZEOF_MEMBER(fr_value_box_t, datum.integer) == 4, "datum.integer has unexpected length"); -static_assert(SIZEOF_MEMBER(value_box_t, datum.integer64) == 8, +static_assert(SIZEOF_MEMBER(fr_value_box_t, datum.integer64) == 8, "datum.integer64 has unexpected length"); -static_assert(SIZEOF_MEMBER(value_box_t, datum.sinteger) == 4, +static_assert(SIZEOF_MEMBER(fr_value_box_t, datum.sinteger) == 4, "datum.sinteger has unexpected length"); /** How many bytes wide each of the value data fields are * - * This is useful when copying a value from a value_box_t to a memory + * This is useful when copying a value from a fr_value_box_t to a memory * location passed as a void *. */ -size_t const value_box_field_sizes[] = { - [FR_TYPE_STRING] = SIZEOF_MEMBER(value_box_t, datum.strvalue), - [FR_TYPE_OCTETS] = SIZEOF_MEMBER(value_box_t, datum.octets), - - [FR_TYPE_IPV4_ADDR] = SIZEOF_MEMBER(value_box_t, datum.ip), - [FR_TYPE_IPV4_PREFIX] = SIZEOF_MEMBER(value_box_t, datum.ip), - [FR_TYPE_IPV6_ADDR] = SIZEOF_MEMBER(value_box_t, datum.ip), - [FR_TYPE_IPV6_PREFIX] = SIZEOF_MEMBER(value_box_t, datum.ip), - [FR_TYPE_IFID] = SIZEOF_MEMBER(value_box_t, datum.ifid), - [FR_TYPE_ETHERNET] = SIZEOF_MEMBER(value_box_t, datum.ether), - - [FR_TYPE_BOOLEAN] = SIZEOF_MEMBER(value_box_t, datum.boolean), - [FR_TYPE_BYTE] = SIZEOF_MEMBER(value_box_t, datum.byte), - [FR_TYPE_SHORT] = SIZEOF_MEMBER(value_box_t, datum.ushort), - [FR_TYPE_INTEGER] = SIZEOF_MEMBER(value_box_t, datum.integer), - [FR_TYPE_INTEGER64] = SIZEOF_MEMBER(value_box_t, datum.integer64), - [FR_TYPE_SIZE] = SIZEOF_MEMBER(value_box_t, datum.size), - - [FR_TYPE_SIGNED] = SIZEOF_MEMBER(value_box_t, datum.sinteger), - - [FR_TYPE_TIMEVAL] = SIZEOF_MEMBER(value_box_t, datum.timeval), - [FR_TYPE_DECIMAL] = SIZEOF_MEMBER(value_box_t, datum.decimal), - [FR_TYPE_DATE] = SIZEOF_MEMBER(value_box_t, datum.date), - - [FR_TYPE_ABINARY] = SIZEOF_MEMBER(value_box_t, datum.filter), +size_t const fr_value_box_field_sizes[] = { + [FR_TYPE_STRING] = SIZEOF_MEMBER(fr_value_box_t, datum.strvalue), + [FR_TYPE_OCTETS] = SIZEOF_MEMBER(fr_value_box_t, datum.octets), + + [FR_TYPE_IPV4_ADDR] = SIZEOF_MEMBER(fr_value_box_t, datum.ip), + [FR_TYPE_IPV4_PREFIX] = SIZEOF_MEMBER(fr_value_box_t, datum.ip), + [FR_TYPE_IPV6_ADDR] = SIZEOF_MEMBER(fr_value_box_t, datum.ip), + [FR_TYPE_IPV6_PREFIX] = SIZEOF_MEMBER(fr_value_box_t, datum.ip), + [FR_TYPE_IFID] = SIZEOF_MEMBER(fr_value_box_t, datum.ifid), + [FR_TYPE_ETHERNET] = SIZEOF_MEMBER(fr_value_box_t, datum.ether), + + [FR_TYPE_BOOLEAN] = SIZEOF_MEMBER(fr_value_box_t, datum.boolean), + [FR_TYPE_BYTE] = SIZEOF_MEMBER(fr_value_box_t, datum.byte), + [FR_TYPE_SHORT] = SIZEOF_MEMBER(fr_value_box_t, datum.ushort), + [FR_TYPE_INTEGER] = SIZEOF_MEMBER(fr_value_box_t, datum.integer), + [FR_TYPE_INTEGER64] = SIZEOF_MEMBER(fr_value_box_t, datum.integer64), + [FR_TYPE_SIZE] = SIZEOF_MEMBER(fr_value_box_t, datum.size), + + [FR_TYPE_SIGNED] = SIZEOF_MEMBER(fr_value_box_t, datum.sinteger), + + [FR_TYPE_TIMEVAL] = SIZEOF_MEMBER(fr_value_box_t, datum.timeval), + [FR_TYPE_DECIMAL] = SIZEOF_MEMBER(fr_value_box_t, datum.decimal), + [FR_TYPE_DATE] = SIZEOF_MEMBER(fr_value_box_t, datum.date), + + [FR_TYPE_ABINARY] = SIZEOF_MEMBER(fr_value_box_t, datum.filter), [FR_TYPE_MAX] = 0 //!< Ensure array covers all types. }; -/** Where the value starts in the #value_box_t +/** Where the value starts in the #fr_value_box_t * */ -size_t const value_box_offsets[] = { - [FR_TYPE_STRING] = offsetof(value_box_t, datum.strvalue), - [FR_TYPE_OCTETS] = offsetof(value_box_t, datum.octets), +size_t const fr_value_box_offsets[] = { + [FR_TYPE_STRING] = offsetof(fr_value_box_t, datum.strvalue), + [FR_TYPE_OCTETS] = offsetof(fr_value_box_t, datum.octets), - [FR_TYPE_IPV4_ADDR] = offsetof(value_box_t, datum.ip), - [FR_TYPE_IPV4_PREFIX] = offsetof(value_box_t, datum.ip), - [FR_TYPE_IPV6_ADDR] = offsetof(value_box_t, datum.ip), - [FR_TYPE_IPV6_PREFIX] = offsetof(value_box_t, datum.ip), - [FR_TYPE_IFID] = offsetof(value_box_t, datum.ifid), - [FR_TYPE_ETHERNET] = offsetof(value_box_t, datum.ether), + [FR_TYPE_IPV4_ADDR] = offsetof(fr_value_box_t, datum.ip), + [FR_TYPE_IPV4_PREFIX] = offsetof(fr_value_box_t, datum.ip), + [FR_TYPE_IPV6_ADDR] = offsetof(fr_value_box_t, datum.ip), + [FR_TYPE_IPV6_PREFIX] = offsetof(fr_value_box_t, datum.ip), + [FR_TYPE_IFID] = offsetof(fr_value_box_t, datum.ifid), + [FR_TYPE_ETHERNET] = offsetof(fr_value_box_t, datum.ether), - [FR_TYPE_BOOLEAN] = offsetof(value_box_t, datum.boolean), - [FR_TYPE_BYTE] = offsetof(value_box_t, datum.byte), - [FR_TYPE_SHORT] = offsetof(value_box_t, datum.ushort), - [FR_TYPE_INTEGER] = offsetof(value_box_t, datum.integer), - [FR_TYPE_INTEGER64] = offsetof(value_box_t, datum.integer64), - [FR_TYPE_SIZE] = offsetof(value_box_t, datum.size), + [FR_TYPE_BOOLEAN] = offsetof(fr_value_box_t, datum.boolean), + [FR_TYPE_BYTE] = offsetof(fr_value_box_t, datum.byte), + [FR_TYPE_SHORT] = offsetof(fr_value_box_t, datum.ushort), + [FR_TYPE_INTEGER] = offsetof(fr_value_box_t, datum.integer), + [FR_TYPE_INTEGER64] = offsetof(fr_value_box_t, datum.integer64), + [FR_TYPE_SIZE] = offsetof(fr_value_box_t, datum.size), - [FR_TYPE_SIGNED] = offsetof(value_box_t, datum.sinteger), + [FR_TYPE_SIGNED] = offsetof(fr_value_box_t, datum.sinteger), - [FR_TYPE_TIMEVAL] = offsetof(value_box_t, datum.timeval), - [FR_TYPE_DECIMAL] = offsetof(value_box_t, datum.decimal), + [FR_TYPE_TIMEVAL] = offsetof(fr_value_box_t, datum.timeval), + [FR_TYPE_DECIMAL] = offsetof(fr_value_box_t, datum.decimal), - [FR_TYPE_DATE] = offsetof(value_box_t, datum.date), + [FR_TYPE_DATE] = offsetof(fr_value_box_t, datum.date), - [FR_TYPE_ABINARY] = offsetof(value_box_t, datum.filter), + [FR_TYPE_ABINARY] = offsetof(fr_value_box_t, datum.filter), [FR_TYPE_MAX] = 0 //!< Ensure array covers all types. }; @@ -181,14 +181,14 @@ size_t const value_box_offsets[] = { * @param[in] ctx to allocate the value_box in. * @param[in] type of value. * @return - * - A new value_box_t. + * - A new fr_value_box_t. * - NULL on error. */ -value_box_t *value_box_alloc(TALLOC_CTX *ctx, fr_type_t type) +fr_value_box_t *fr_value_box_alloc(TALLOC_CTX *ctx, fr_type_t type) { - value_box_t *value; + fr_value_box_t *value; - value = talloc_zero(ctx, value_box_t); + value = talloc_zero(ctx, fr_value_box_t); if (!value) return NULL; value->type = type; @@ -201,7 +201,7 @@ value_box_t *value_box_alloc(TALLOC_CTX *ctx, fr_type_t type) * * @param[in] data to clear. */ -inline void value_box_clear(value_box_t *data) +inline void fr_value_box_clear(fr_value_box_t *data) { switch (data->type) { case FR_TYPE_OCTETS: @@ -230,7 +230,7 @@ inline void value_box_clear(value_box_t *data) * @param[in] dst to copy flags to * @param[in] src of data. */ -static inline void value_box_copy_meta(value_box_t *dst, value_box_t const *src) +static inline void fr_value_box_copy_meta(fr_value_box_t *dst, fr_value_box_t const *src) { switch (src->type) { case FR_TYPE_VARIABLE_SIZE: @@ -256,7 +256,7 @@ static inline void value_box_copy_meta(value_box_t *dst, value_box_t const *src) * - 1 if a is more than b. * - < -1 on failure. */ -int value_box_cmp(value_box_t const *a, value_box_t const *b) +int fr_value_box_cmp(fr_value_box_t const *a, fr_value_box_t const *b) { int compare = 0; @@ -383,7 +383,7 @@ int value_box_cmp(value_box_t const *a, value_box_t const *b) * * reserved, prefix-len, data... */ -static int value_box_cidr_cmp_op(FR_TOKEN op, int bytes, +static int fr_value_box_cidr_cmp_op(FR_TOKEN op, int bytes, uint8_t a_net, uint8_t const *a, uint8_t b_net, uint8_t const *b) { @@ -500,7 +500,7 @@ static int value_box_cidr_cmp_op(FR_TOKEN op, int bytes, * - 0 if false * - -1 on failure. */ -int value_box_cmp_op(FR_TOKEN op, value_box_t const *a, value_box_t const *b) +int fr_value_box_cmp_op(FR_TOKEN op, fr_value_box_t const *a, fr_value_box_t const *b) { int compare = 0; @@ -516,7 +516,7 @@ int value_box_cmp_op(FR_TOKEN op, value_box_t const *a, value_box_t const *b) goto cmp; case FR_TYPE_IPV4_PREFIX: /* IPv4 and IPv4 Prefix */ - return value_box_cidr_cmp_op(op, 4, 32, (uint8_t const *) &a->datum.ip.addr.v4.s_addr, + return fr_value_box_cidr_cmp_op(op, 4, 32, (uint8_t const *) &a->datum.ip.addr.v4.s_addr, b->datum.ip.prefix, (uint8_t const *) &b->datum.ip.addr.v4.s_addr); default: @@ -527,12 +527,12 @@ int value_box_cmp_op(FR_TOKEN op, value_box_t const *a, value_box_t const *b) case FR_TYPE_IPV4_PREFIX: /* IPv4 and IPv4 Prefix */ switch (b->type) { case FR_TYPE_IPV4_ADDR: - return value_box_cidr_cmp_op(op, 4, a->datum.ip.prefix, + return fr_value_box_cidr_cmp_op(op, 4, a->datum.ip.prefix, (uint8_t const *) &a->datum.ip.addr.v4.s_addr, 32, (uint8_t const *) &b->datum.ip.addr.v4); case FR_TYPE_IPV4_PREFIX: /* IPv4 Prefix and IPv4 Prefix */ - return value_box_cidr_cmp_op(op, 4, a->datum.ip.prefix, + return fr_value_box_cidr_cmp_op(op, 4, a->datum.ip.prefix, (uint8_t const *) &a->datum.ip.addr.v4.s_addr, b->datum.ip.prefix, (uint8_t const *) &b->datum.ip.addr.v4.s_addr); @@ -547,7 +547,7 @@ int value_box_cmp_op(FR_TOKEN op, value_box_t const *a, value_box_t const *b) goto cmp; case FR_TYPE_IPV6_PREFIX: /* IPv6 and IPv6 Preifx */ - return value_box_cidr_cmp_op(op, 16, 128, (uint8_t const *) &a->datum.ip.addr.v6, + return fr_value_box_cidr_cmp_op(op, 16, 128, (uint8_t const *) &a->datum.ip.addr.v6, b->datum.ip.prefix, (uint8_t const *) &b->datum.ip.addr.v6); default: @@ -558,12 +558,12 @@ int value_box_cmp_op(FR_TOKEN op, value_box_t const *a, value_box_t const *b) case FR_TYPE_IPV6_PREFIX: switch (b->type) { case FR_TYPE_IPV6_ADDR: /* IPv6 Prefix and IPv6 */ - return value_box_cidr_cmp_op(op, 16, a->datum.ip.prefix, + return fr_value_box_cidr_cmp_op(op, 16, a->datum.ip.prefix, (uint8_t const *) &a->datum.ip.addr.v6, 128, (uint8_t const *) &b->datum.ip.addr.v6); case FR_TYPE_IPV6_PREFIX: /* IPv6 Prefix and IPv6 */ - return value_box_cidr_cmp_op(op, 16, a->datum.ip.prefix, + return fr_value_box_cidr_cmp_op(op, 16, a->datum.ip.prefix, (uint8_t const *) &a->datum.ip.addr.v6, b->datum.ip.prefix, (uint8_t const *) &b->datum.ip.addr.v6); @@ -574,7 +574,7 @@ int value_box_cmp_op(FR_TOKEN op, value_box_t const *a, value_box_t const *b) default: cmp: - compare = value_box_cmp(a, b); + compare = fr_value_box_cmp(a, b); if (compare < -1) { /* comparison error */ return -1; } @@ -791,12 +791,12 @@ size_t value_str_unescape(uint8_t *out, char const *in, size_t inlen, char quote /** Performs byte order reversal for types that need it * * @param[in] dst Where to write the result. May be the same as src. - * @param[in] src #value_box_t containing an integer value. + * @param[in] src #fr_value_box_t containing an integer value. * @return * - 0 on success. * - -1 on failure. */ -int value_box_hton(value_box_t *dst, value_box_t const *src) +int fr_value_box_hton(fr_value_box_t *dst, fr_value_box_t const *src) { if (!fr_cond_assert(src->type != FR_TYPE_INVALID)) return -1; @@ -804,7 +804,7 @@ int value_box_hton(value_box_t *dst, value_box_t const *src) switch (src->type) { case FR_TYPE_INTEGER64: dst->datum.integer64 = htonll(src->datum.integer64); - value_box_copy_meta(dst, src); + fr_value_box_copy_meta(dst, src); break; /* 4 byte integers */ @@ -812,13 +812,13 @@ int value_box_hton(value_box_t *dst, value_box_t const *src) case FR_TYPE_DATE: case FR_TYPE_SIGNED: dst->datum.integer = htonl(src->datum.integer); - value_box_copy_meta(dst, src); + fr_value_box_copy_meta(dst, src); break; /* 2 byte integers */ case FR_TYPE_SHORT: dst->datum.ushort = htons(src->datum.ushort); - value_box_copy_meta(dst, src); + fr_value_box_copy_meta(dst, src); break; case FR_TYPE_OCTETS: @@ -826,7 +826,7 @@ int value_box_hton(value_box_t *dst, value_box_t const *src) if (!fr_cond_assert(0)) return -1; /* shouldn't happen */ default: - value_box_copy(NULL, dst, src); + fr_value_box_copy(NULL, dst, src); break; } @@ -850,9 +850,9 @@ static uint8_t const v4_v6_map[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, * @param dst_enumv unused. * @param src Input data. */ -static inline int value_box_cast_to_strvalue(TALLOC_CTX *ctx, value_box_t *dst, +static inline int fr_value_box_cast_to_strvalue(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t dst_type, UNUSED fr_dict_attr_t const *dst_enumv, - value_box_t const *src) + fr_value_box_t const *src) { if (!fr_cond_assert(dst_type == FR_TYPE_STRING)) return -1; @@ -870,7 +870,7 @@ static inline int value_box_cast_to_strvalue(TALLOC_CTX *ctx, value_box_t *dst, * Get the presentation format */ default: - dst->datum.strvalue = value_box_asprint(ctx, src, '\0'); + dst->datum.strvalue = fr_value_box_asprint(ctx, src, '\0'); dst->datum.length = talloc_array_length(dst->datum.strvalue) - 1; break; } @@ -891,9 +891,9 @@ static inline int value_box_cast_to_strvalue(TALLOC_CTX *ctx, value_box_t *dst, * @param dst_enumv unused. * @param src Input data. */ -static inline int value_box_cast_to_octets(TALLOC_CTX *ctx, value_box_t *dst, +static inline int fr_value_box_cast_to_octets(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t dst_type, UNUSED fr_dict_attr_t const *dst_enumv, - value_box_t const *src) + fr_value_box_t const *src) { uint8_t *bin; @@ -947,16 +947,16 @@ static inline int value_box_cast_to_octets(TALLOC_CTX *ctx, value_box_t *dst, * Get the raw binary in memory representation */ default: - value_box_hton(dst, src); /* Flip any integer representations */ - bin = talloc_memdup(ctx, ((uint8_t *)&dst->datum) + value_box_offsets[src->type], - value_box_field_sizes[src->type]); + fr_value_box_hton(dst, src); /* Flip any integer representations */ + bin = talloc_memdup(ctx, ((uint8_t *)&dst->datum) + fr_value_box_offsets[src->type], + fr_value_box_field_sizes[src->type]); break; } if (!bin) return -1; talloc_set_type(bin, uint8_t); - value_box_memsteal(ctx, dst, bin, src->tainted); + fr_value_box_memsteal(ctx, dst, bin, src->tainted); dst->type = FR_TYPE_OCTETS; return 0; @@ -977,9 +977,9 @@ static inline int value_box_cast_to_octets(TALLOC_CTX *ctx, value_box_t *dst, * @param dst_enumv unused. * @param src Input data. */ -static inline int value_box_cast_to_ipv4addr(TALLOC_CTX *ctx, value_box_t *dst, +static inline 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, - value_box_t const *src) + fr_value_box_t const *src) { if (!fr_cond_assert(dst_type == FR_TYPE_IPV4_ADDR)) return -1; @@ -1025,7 +1025,7 @@ static inline int value_box_cast_to_ipv4addr(TALLOC_CTX *ctx, value_box_t *dst, break; case FR_TYPE_STRING: - if (value_box_from_str(ctx, dst, &dst_type, dst_enumv, + if (fr_value_box_from_str(ctx, dst, &dst_type, dst_enumv, src->datum.strvalue, src->datum.length, '\0') < 0) return -1; break; @@ -1079,9 +1079,9 @@ static inline int value_box_cast_to_ipv4addr(TALLOC_CTX *ctx, value_box_t *dst, * @param dst_enumv unused. * @param src Input data. */ -static inline int value_box_cast_to_ipv4prefix(TALLOC_CTX *ctx, value_box_t *dst, +static inline 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, - value_box_t const *src) + fr_value_box_t const *src) { if (!fr_cond_assert(dst_type == FR_TYPE_IPV4_PREFIX)) return -1; @@ -1126,7 +1126,7 @@ static inline int value_box_cast_to_ipv4prefix(TALLOC_CTX *ctx, value_box_t *dst break; case FR_TYPE_STRING: - if (value_box_from_str(ctx, dst, &dst_type, dst_enumv, + if (fr_value_box_from_str(ctx, dst, &dst_type, dst_enumv, src->datum.strvalue, src->datum.length, '\0') < 0) return -1; break; @@ -1178,9 +1178,9 @@ static inline int value_box_cast_to_ipv4prefix(TALLOC_CTX *ctx, value_box_t *dst * @param dst_enumv unused. * @param src Input data. */ -static inline int value_box_cast_to_ipv6addr(TALLOC_CTX *ctx, value_box_t *dst, +static inline 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, - value_box_t const *src) + fr_value_box_t const *src) { if (!fr_cond_assert(dst_type == FR_TYPE_IPV6_ADDR)) return -1; @@ -1236,7 +1236,7 @@ static inline int value_box_cast_to_ipv6addr(TALLOC_CTX *ctx, value_box_t *dst, break; case FR_TYPE_STRING: - if (value_box_from_str(ctx, dst, &dst_type, dst_enumv, + if (fr_value_box_from_str(ctx, dst, &dst_type, dst_enumv, src->datum.strvalue, src->datum.length, '\0') < 0) return -1; break; @@ -1280,9 +1280,9 @@ static inline int value_box_cast_to_ipv6addr(TALLOC_CTX *ctx, value_box_t *dst, * @param dst_enumv unused. * @param src Input data. */ -static inline int value_box_cast_to_ipv6prefix(TALLOC_CTX *ctx, value_box_t *dst, +static inline 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, - value_box_t const *src) + fr_value_box_t const *src) { switch (src->type) { case FR_TYPE_IPV4_ADDR: @@ -1319,7 +1319,7 @@ static inline int value_box_cast_to_ipv6prefix(TALLOC_CTX *ctx, value_box_t *dst break; case FR_TYPE_STRING: - if (value_box_from_str(ctx, dst, &dst_type, dst_enumv, + if (fr_value_box_from_str(ctx, dst, &dst_type, dst_enumv, src->datum.strvalue, src->datum.length, '\0') < 0) return -1; break; @@ -1347,11 +1347,11 @@ static inline int value_box_cast_to_ipv6prefix(TALLOC_CTX *ctx, value_box_t *dst return 0; } -/** Convert one type of value_box_t to another +/** 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 #value_box_from_str. + * - If you want to convert from PRESENTATION format, use #fr_value_box_from_str. * * @param ctx to allocate buffers in (usually the same as dst) @@ -1363,9 +1363,9 @@ static inline int value_box_cast_to_ipv6prefix(TALLOC_CTX *ctx, value_box_t *dst * - 0 on success. * - -1 on failure. */ -int value_box_cast(TALLOC_CTX *ctx, value_box_t *dst, +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, - value_box_t const *src) + fr_value_box_t const *src) { if (!fr_cond_assert(dst_type != FR_TYPE_INVALID)) return -1; if (!fr_cond_assert(src->type != FR_TYPE_INVALID)) return -1; @@ -1380,7 +1380,7 @@ int value_box_cast(TALLOC_CTX *ctx, value_box_t *dst, /* * If it's the same type, copy. */ - if (dst_type == src->type) return value_box_copy(ctx, dst, src); + if (dst_type == src->type) return fr_value_box_copy(ctx, dst, src); /* * Initialise dst @@ -1392,22 +1392,22 @@ int value_box_cast(TALLOC_CTX *ctx, value_box_t *dst, */ switch (dst_type) { case FR_TYPE_STRING: - return value_box_cast_to_strvalue(ctx, dst, dst_type, dst_enumv, src); + return fr_value_box_cast_to_strvalue(ctx, dst, dst_type, dst_enumv, src); case FR_TYPE_OCTETS: - return value_box_cast_to_octets(ctx, dst, dst_type, dst_enumv, src); + return fr_value_box_cast_to_octets(ctx, dst, dst_type, dst_enumv, src); case FR_TYPE_IPV4_ADDR: - return value_box_cast_to_ipv4addr(ctx, dst, dst_type, dst_enumv, src); + return fr_value_box_cast_to_ipv4addr(ctx, dst, dst_type, dst_enumv, src); case FR_TYPE_IPV4_PREFIX: - return value_box_cast_to_ipv4prefix(ctx, dst, dst_type, dst_enumv, src); + return fr_value_box_cast_to_ipv4prefix(ctx, dst, dst_type, dst_enumv, src); case FR_TYPE_IPV6_ADDR: - return value_box_cast_to_ipv6addr(ctx, dst, dst_type, dst_enumv, src); + return fr_value_box_cast_to_ipv6addr(ctx, dst, dst_type, dst_enumv, src); case FR_TYPE_IPV6_PREFIX: - return value_box_cast_to_ipv6prefix(ctx, dst, dst_type, dst_enumv, src); + return fr_value_box_cast_to_ipv6prefix(ctx, dst, dst_type, dst_enumv, src); /* * Need func @@ -1439,9 +1439,9 @@ int value_box_cast(TALLOC_CTX *ctx, value_box_t *dst, } /* - * Deserialise a value_box_t + * Deserialise a fr_value_box_t */ - if (src->type == FR_TYPE_STRING) return value_box_from_str(ctx, dst, &dst_type, dst_enumv, + if (src->type == FR_TYPE_STRING) return fr_value_box_from_str(ctx, dst, &dst_type, dst_enumv, src->datum.strvalue, src->datum.length, '\0'); if ((src->type == FR_TYPE_IFID) && @@ -1632,26 +1632,26 @@ int value_box_cast(TALLOC_CTX *ctx, value_box_t *dst, } if (src->type == FR_TYPE_OCTETS) { - value_box_t tmp; + fr_value_box_t tmp; do_octets: - if (src->datum.length < value_box_network_sizes[dst_type][0]) { + if (src->datum.length < fr_value_box_network_sizes[dst_type][0]) { fr_strerror_printf("Invalid cast from %s to %s. Source is length %zd is smaller than " "destination type size %zd", fr_int2str(dict_attr_types, src->type, ""), fr_int2str(dict_attr_types, dst_type, ""), src->datum.length, - value_box_network_sizes[dst_type][0]); + fr_value_box_network_sizes[dst_type][0]); return -1; } - if (src->datum.length > value_box_network_sizes[dst_type][1]) { + if (src->datum.length > fr_value_box_network_sizes[dst_type][1]) { fr_strerror_printf("Invalid cast from %s to %s. Source length %zd is greater than " "destination type size %zd", fr_int2str(dict_attr_types, src->type, ""), fr_int2str(dict_attr_types, dst_type, ""), src->datum.length, - value_box_network_sizes[dst_type][1]); + fr_value_box_network_sizes[dst_type][1]); return -1; } @@ -1659,11 +1659,11 @@ int value_box_cast(TALLOC_CTX *ctx, value_box_t *dst, * Copy the raw octets into the datum of a value_box * inverting bytesex for integers (if LE). */ - memcpy(&tmp.datum, src->datum.octets, value_box_field_sizes[dst_type]); + memcpy(&tmp.datum, src->datum.octets, fr_value_box_field_sizes[dst_type]); tmp.type = dst_type; if (fr_dict_enum_types[dst_type]) dst->datum.enumv = dst_enumv; - value_box_hton(dst, &tmp); + fr_value_box_hton(dst, &tmp); /* * Fixup IP addresses. @@ -1707,7 +1707,7 @@ int value_box_cast(TALLOC_CTX *ctx, value_box_t *dst, dst->datum.integer = htonl(src->datum.ip.addr.v4.s_addr); } else { /* they're of the same byte order */ - memcpy(&dst->datum, &src->datum, value_box_field_sizes[src->type]); + memcpy(&dst->datum, &src->datum, fr_value_box_field_sizes[src->type]); } dst->type = dst_type; @@ -1718,7 +1718,7 @@ int value_box_cast(TALLOC_CTX *ctx, value_box_t *dst, /** Copy value data verbatim duplicating any buffers * - * @note Will free any exiting buffers associated with the dst #value_box_t. + * @note Will free any exiting buffers associated with the dst #fr_value_box_t. * * @param ctx To allocate buffers in. * @param dst Where to copy value_box to. @@ -1727,15 +1727,15 @@ int value_box_cast(TALLOC_CTX *ctx, value_box_t *dst, * - 0 on success. * - -1 on failure. */ -int value_box_copy(TALLOC_CTX *ctx, value_box_t *dst, const value_box_t *src) +int fr_value_box_copy(TALLOC_CTX *ctx, fr_value_box_t *dst, const fr_value_box_t *src) { if (!fr_cond_assert(src->type != FR_TYPE_INVALID)) return -1; switch (src->type) { default: - memcpy(((uint8_t *)dst) + value_box_offsets[src->type], - ((uint8_t const *)src) + value_box_offsets[src->type], - value_box_field_sizes[src->type]); + memcpy(((uint8_t *)dst) + fr_value_box_offsets[src->type], + ((uint8_t const *)src) + fr_value_box_offsets[src->type], + fr_value_box_field_sizes[src->type]); break; case FR_TYPE_STRING: @@ -1771,42 +1771,42 @@ int value_box_copy(TALLOC_CTX *ctx, value_box_t *dst, const value_box_t *src) break; } - value_box_copy_meta(dst, src); + fr_value_box_copy_meta(dst, src); return 0; } /** Perform a shallow copy of a value_box * - * Like #value_box_copy, but does not duplicate the buffers of the src 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. * - * @note Will free any exiting buffers associated with the dst #value_box_t. + * @note Will free any exiting buffers associated with the dst #fr_value_box_t. * * @param[in] ctx to add reference from. If NULL no reference will be added. * @param[in] dst to copy value to. * @param[in] src to copy value from. */ -void value_box_copy_shallow(TALLOC_CTX *ctx, value_box_t *dst, value_box_t const *src) +void fr_value_box_copy_shallow(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t const *src) { switch (src->type) { default: - value_box_copy(ctx, dst, src); + fr_value_box_copy(ctx, dst, src); break; case FR_TYPE_STRING: case FR_TYPE_OCTETS: dst->datum.ptr = ctx ? talloc_reference(ctx, src->datum.ptr) : src->datum.ptr; - value_box_copy_meta(dst, src); + fr_value_box_copy_meta(dst, src); break; } } /** Copy value data verbatim moving any buffers to the specified context * - * @note Will free any exiting buffers associated with the dst #value_box_t. + * @note Will free any exiting buffers associated with the dst #fr_value_box_t. * * @param[in] ctx to allocate any new buffers in. * @param[in] dst to copy value to. @@ -1815,13 +1815,13 @@ void value_box_copy_shallow(TALLOC_CTX *ctx, value_box_t *dst, value_box_t const * - 0 on success. * - -1 on failure. */ -int value_box_steal(TALLOC_CTX *ctx, value_box_t *dst, value_box_t const *src) +int fr_value_box_steal(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t const *src) { if (!fr_cond_assert(src->type != FR_TYPE_INVALID)) return -1; switch (src->type) { default: - return value_box_copy(ctx, dst, src); + return fr_value_box_copy(ctx, dst, src); case FR_TYPE_STRING: { @@ -1833,7 +1833,7 @@ int value_box_steal(TALLOC_CTX *ctx, value_box_t *dst, value_box_t const *src) return -1; } dst->datum.strvalue = str; - value_box_copy_meta(dst, src); + fr_value_box_copy_meta(dst, src); } return 0; @@ -1847,22 +1847,22 @@ int value_box_steal(TALLOC_CTX *ctx, value_box_t *dst, value_box_t const *src) return -1; } dst->datum.octets = bin; - value_box_copy_meta(dst, src); + fr_value_box_copy_meta(dst, src); } return 0; } } -/** Copy a nul terminated string to a #value_box_t +/** Copy a nul terminated string to a #fr_value_box_t * - * @note Will free any exiting buffers associated with the dst #value_box_t. + * @note Will free any exiting buffers associated with the dst #fr_value_box_t. * * @param[in] ctx to allocate any new buffers in. * @param[in] dst to assign new buffer to. * @param[in] src a nul terminated buffer. * @param[in] tainted Whether the value came from a trusted source. */ -int value_box_strdup(TALLOC_CTX *ctx, value_box_t *dst, char const *src, bool tainted) +int fr_value_box_strdup(TALLOC_CTX *ctx, fr_value_box_t *dst, char const *src, bool tainted) { char const *str; @@ -1880,7 +1880,7 @@ int value_box_strdup(TALLOC_CTX *ctx, value_box_t *dst, char const *src, bool ta return 0; } -/** Copy a nul terminated talloced buffer to a #value_box_t +/** 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. * @@ -1894,7 +1894,7 @@ int value_box_strdup(TALLOC_CTX *ctx, value_box_t *dst, char const *src, bool ta * - 0 on success. * - -1 on failure. */ -int value_box_strdup_buffer(TALLOC_CTX *ctx, value_box_t *dst, char const *src, bool tainted) +int fr_value_box_strdup_buffer(TALLOC_CTX *ctx, fr_value_box_t *dst, char const *src, bool tainted) { char *str; size_t len; @@ -1919,7 +1919,7 @@ int value_box_strdup_buffer(TALLOC_CTX *ctx, value_box_t *dst, char const *src, return 0; } -/** Steal a nul terminated talloced buffer into a specified ctx, and assign to a #value_box_t +/** Steal a nul terminated talloced buffer into a specified ctx, and assign to a #fr_value_box_t * * Steal a talloced nul terminated buffer, setting fields in the dst value box appropriately. * @@ -1933,7 +1933,7 @@ int value_box_strdup_buffer(TALLOC_CTX *ctx, value_box_t *dst, char const *src, * - 0 on success. * - -1 on failure. */ -int value_box_strsteal(TALLOC_CTX *ctx, value_box_t *dst, char *src, bool tainted) +int fr_value_box_strsteal(TALLOC_CTX *ctx, fr_value_box_t *dst, char *src, bool tainted) { size_t len; char *str; @@ -1967,7 +1967,7 @@ int value_box_strsteal(TALLOC_CTX *ctx, value_box_t *dst, char *src, bool tainte * - 0 on success. * - -1 on failure. */ -int value_box_strdup_shallow(value_box_t *dst, char const *src, bool tainted) +int fr_value_box_strdup_shallow(fr_value_box_t *dst, char const *src, bool tainted) { dst->type = FR_TYPE_STRING; dst->tainted = tainted; @@ -1989,7 +1989,7 @@ int value_box_strdup_shallow(value_box_t *dst, char const *src, bool tainted) * - 0 on success. * - -1 on failure. */ -int value_box_strdup_buffer_shallow(TALLOC_CTX *ctx, value_box_t *dst, char const *src, bool tainted) +int fr_value_box_strdup_buffer_shallow(TALLOC_CTX *ctx, fr_value_box_t *dst, char const *src, bool tainted) { size_t len; @@ -2009,7 +2009,7 @@ int value_box_strdup_buffer_shallow(TALLOC_CTX *ctx, value_box_t *dst, char cons return 0; } -/** Copy a buffer to a value_box_t +/** Copy a buffer to a fr_value_box_t * * Copy a buffer containing binary data, setting fields in the dst value box appropriately. * @@ -2024,7 +2024,7 @@ int value_box_strdup_buffer_shallow(TALLOC_CTX *ctx, value_box_t *dst, char cons * - 0 on success. * - -1 on failure. */ -int value_box_memdup(TALLOC_CTX *ctx, value_box_t *dst, uint8_t const *src, size_t len, bool tainted) +int fr_value_box_memdup(TALLOC_CTX *ctx, fr_value_box_t *dst, uint8_t const *src, size_t len, bool tainted) { uint8_t *bin; @@ -2042,7 +2042,7 @@ int value_box_memdup(TALLOC_CTX *ctx, value_box_t *dst, uint8_t const *src, size return 0; } -/** Copy a talloced buffer to a value_box_t +/** Copy a talloced buffer to a fr_value_box_t * * Copy a buffer containing binary data, setting fields in the dst value box appropriately. * @@ -2054,14 +2054,14 @@ int value_box_memdup(TALLOC_CTX *ctx, value_box_t *dst, uint8_t const *src, size * - 0 on success. * - -1 on failure. */ -int value_box_memdup_buffer(TALLOC_CTX *ctx, value_box_t *dst, uint8_t *src, bool tainted) +int fr_value_box_memdup_buffer(TALLOC_CTX *ctx, fr_value_box_t *dst, uint8_t *src, bool tainted) { (void) talloc_get_type_abort(src, uint8_t); - return value_box_memdup(ctx, dst, src, talloc_array_length(src), tainted); + return fr_value_box_memdup(ctx, dst, src, talloc_array_length(src), tainted); } -/** Steal a talloced buffer into a specified ctx, and assign to a #value_box_t +/** Steal a talloced buffer into a specified ctx, and assign to a #fr_value_box_t * * Steal a talloced buffer, setting fields in the dst value box appropriately. * @@ -2073,7 +2073,7 @@ int value_box_memdup_buffer(TALLOC_CTX *ctx, value_box_t *dst, uint8_t *src, boo * - 0 on success. * - -1 on failure. */ -int value_box_memsteal(TALLOC_CTX *ctx, value_box_t *dst, uint8_t const *src, bool tainted) +int fr_value_box_memsteal(TALLOC_CTX *ctx, fr_value_box_t *dst, uint8_t const *src, bool tainted) { uint8_t const *bin; @@ -2109,7 +2109,7 @@ int value_box_memsteal(TALLOC_CTX *ctx, value_box_t *dst, uint8_t const *src, bo * - 0 on success. * - -1 on failure. */ -int value_box_memdup_shallow(value_box_t *dst, uint8_t *src, size_t len, bool tainted) +int fr_value_box_memdup_shallow(fr_value_box_t *dst, uint8_t *src, size_t len, bool tainted) { dst->type = FR_TYPE_OCTETS; dst->tainted = tainted; @@ -2131,7 +2131,7 @@ int value_box_memdup_shallow(value_box_t *dst, uint8_t *src, size_t len, bool ta * - 0 on success. * - -1 on failure. */ -int value_box_memdup_buffer_shallow(TALLOC_CTX *ctx, value_box_t *dst, uint8_t *src, bool tainted) +int fr_value_box_memdup_buffer_shallow(TALLOC_CTX *ctx, fr_value_box_t *dst, uint8_t *src, bool tainted) { (void) talloc_get_type_abort(src, uint8_t); @@ -2143,7 +2143,7 @@ int value_box_memdup_buffer_shallow(TALLOC_CTX *ctx, value_box_t *dst, uint8_t * return 0; } -/** Assign a #value_box_t value from an #fr_ipaddr_t +/** 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. @@ -2154,7 +2154,7 @@ int value_box_memdup_buffer_shallow(TALLOC_CTX *ctx, value_box_t *dst, uint8_t * * - 0 on success. * - -1 on failure. */ -int value_box_from_ipaddr(value_box_t *dst, fr_ipaddr_t const *ipaddr) +int fr_value_box_from_ipaddr(fr_value_box_t *dst, fr_ipaddr_t const *ipaddr) { fr_type_t type; @@ -2197,7 +2197,7 @@ int value_box_from_ipaddr(value_box_t *dst, fr_ipaddr_t const *ipaddr) return 0; } -/** Convert string value to a value_box_t type +/** Convert string value to a fr_value_box_t type * * @todo Should take taint param. * @@ -2215,7 +2215,7 @@ int value_box_from_ipaddr(value_box_t *dst, fr_ipaddr_t const *ipaddr) * - 0 on success. * - -1 on parse error. */ -int value_box_from_str(TALLOC_CTX *ctx, value_box_t *dst, +int 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, ssize_t inlen, char quote) { @@ -2731,25 +2731,25 @@ finish: return 0; } -/** Get the size of the value held by the value_box_t +/** Get the size of the value held by the fr_value_box_t * * This is the length of the NETWORK presentation */ -size_t value_box_network_length(value_box_t *value) +size_t fr_value_box_network_length(fr_value_box_t *value) { switch (value->type) { case FR_TYPE_VARIABLE_SIZE: return value->datum.length; default: - return value_box_network_sizes[value->type][0]; + return fr_value_box_network_sizes[value->type][0]; } } /** Print one attribute value to a string * */ -char *value_box_asprint(TALLOC_CTX *ctx, value_box_t const *data, char quote) +char *fr_value_box_asprint(TALLOC_CTX *ctx, fr_value_box_t const *data, char quote) { char *p = NULL; @@ -2757,9 +2757,9 @@ char *value_box_asprint(TALLOC_CTX *ctx, value_box_t const *data, char quote) if (fr_dict_enum_types[data->type] && data->datum.enumv) { fr_dict_enum_t const *dv; - value_box_t tmp; + fr_value_box_t tmp; - value_box_cast(ctx, &tmp, FR_TYPE_INTEGER, NULL, data); + fr_value_box_cast(ctx, &tmp, FR_TYPE_INTEGER, NULL, data); dv = fr_dict_enum_by_da(NULL, data->datum.enumv, tmp.datum.integer); if (dv) return talloc_typed_strdup(ctx, dv->name); @@ -2813,7 +2813,7 @@ char *value_box_asprint(TALLOC_CTX *ctx, value_box_t const *data, char quote) char buff[INET_ADDRSTRLEN + 4]; // + /prefix buff[0] = '\0'; - value_box_snprint(buff, sizeof(buff), data, '\0'); + fr_value_box_snprint(buff, sizeof(buff), data, '\0'); p = talloc_typed_strdup(ctx, buff); } @@ -2825,7 +2825,7 @@ char *value_box_asprint(TALLOC_CTX *ctx, value_box_t const *data, char quote) char buff[INET6_ADDRSTRLEN + 4]; // + /prefix buff[0] = '\0'; - value_box_snprint(buff, sizeof(buff), data, '\0'); + fr_value_box_snprint(buff, sizeof(buff), data, '\0'); p = talloc_typed_strdup(ctx, buff); } @@ -2933,7 +2933,7 @@ char *value_box_asprint(TALLOC_CTX *ctx, value_box_t const *data, char quote) * - The number of bytes written to the out buffer. * - A number >= outlen if truncation has occurred. */ -size_t value_box_snprint(char *out, size_t outlen, value_box_t const *data, char quote) +size_t fr_value_box_snprint(char *out, size_t outlen, fr_value_box_t const *data, char quote) { char buf[1024]; /* Interim buffer to use with poorly behaved printing functions */ char const *a = NULL; @@ -2954,9 +2954,9 @@ size_t value_box_snprint(char *out, size_t outlen, value_box_t const *data, char if (fr_dict_enum_types[data->type] && data->datum.enumv) { fr_dict_enum_t const *dv; - value_box_t tmp; + fr_value_box_t tmp; - value_box_cast(NULL, &tmp, FR_TYPE_INTEGER, NULL, data); + fr_value_box_cast(NULL, &tmp, FR_TYPE_INTEGER, NULL, data); dv = fr_dict_enum_by_da(NULL, data->datum.enumv, tmp.datum.integer); if (dv) return strlcpy(out, dv->name, outlen); diff --git a/src/main/cond_eval.c b/src/main/cond_eval.c index bf0162c92f4..5923e140508 100644 --- a/src/main/cond_eval.c +++ b/src/main/cond_eval.c @@ -83,7 +83,7 @@ int cond_eval_tmpl(REQUEST *request, int modreturn, UNUSED int depth, vp_tmpl_t { int rcode; int modcode; - value_box_t data; + fr_value_box_t data; switch (vpt->type) { case TMPL_TYPE_UNPARSED: @@ -158,8 +158,8 @@ int cond_eval_tmpl(REQUEST *request, int modreturn, UNUSED int depth, vp_tmpl_t * - 1 for "match". */ static int cond_do_regex(REQUEST *request, fr_cond_t const *c, - value_box_t const *lhs, - value_box_t const *rhs) + fr_value_box_t const *lhs, + fr_value_box_t const *rhs) { vp_map_t const *map = c->data.map; @@ -225,7 +225,7 @@ static int cond_do_regex(REQUEST *request, fr_cond_t const *c, #endif #ifdef WITH_EVAL_DEBUG -static void cond_print_operands(value_box_t const *lhs, value_box_t const *rhs) +static void cond_print_operands(fr_value_box_t const *lhs, fr_value_box_t const *rhs) { if (lhs) { if (lhs->type == FR_TYPE_STRING) { @@ -259,7 +259,7 @@ static void cond_print_operands(value_box_t const *lhs, value_box_t const *rhs) * - 0 for "no match". * - 1 for "match". */ -static int cond_cmp_values(REQUEST *request, fr_cond_t const *c, value_box_t const *lhs, value_box_t const *rhs) +static int cond_cmp_values(REQUEST *request, fr_cond_t const *c, fr_value_box_t const *lhs, fr_value_box_t const *rhs) { vp_map_t const *map = c->data.map; int rcode; @@ -290,7 +290,7 @@ static int cond_cmp_values(REQUEST *request, fr_cond_t const *c, value_box_t con vp = fr_pair_afrom_da(request, map->lhs->tmpl_da); vp->op = c->data.map->op; - value_box_copy(vp, &vp->data, rhs); + fr_value_box_copy(vp, &vp->data, rhs); rcode = paircompare(request, request->packet->vps, vp, NULL); rcode = (rcode == 0) ? 1 : 0; @@ -299,7 +299,7 @@ static int cond_cmp_values(REQUEST *request, fr_cond_t const *c, value_box_t con } EVAL_DEBUG("CMP WITH VALUE DATA"); - rcode = value_box_cmp_op(map->op, lhs, rhs); + rcode = fr_value_box_cmp_op(map->op, lhs, rhs); finish: switch (rcode) { case 0: @@ -363,18 +363,18 @@ done: * - 0 for "no match". * - 1 for "match". */ -static int cond_normalise_and_cmp(REQUEST *request, fr_cond_t const *c, value_box_t const *lhs) +static int cond_normalise_and_cmp(REQUEST *request, fr_cond_t const *c, fr_value_box_t const *lhs) { vp_map_t const *map = c->data.map; int rcode; - value_box_t *rhs = NULL; + fr_value_box_t *rhs = NULL; fr_dict_attr_t const *cast = NULL; fr_type_t cast_type = FR_TYPE_INVALID; - value_box_t lhs_cast, rhs_cast; + fr_value_box_t lhs_cast, rhs_cast; void *lhs_cast_buff = NULL, *rhs_cast_buff = NULL; xlat_escape_t escape = NULL; @@ -393,7 +393,7 @@ do {\ EVAL_DEBUG("CASTING " #_s " FROM %s TO %s",\ fr_int2str(dict_attr_types, _s->type, ""),\ fr_int2str(dict_attr_types, cast_type, ""));\ - if (value_box_cast(request, &_s ## _cast, cast_type, cast, _s) < 0) {\ + if (fr_value_box_cast(request, &_s ## _cast, cast_type, cast, _s) < 0) {\ REDEBUG("Failed casting " #_s " operand: %s", fr_strerror());\ rcode = -1;\ goto finish;\ @@ -459,11 +459,11 @@ do {\ EVAL_DEBUG("NORMALISATION TYPE %s (IMPLICIT FROM RHS REF)", fr_int2str(dict_attr_types, cast->type, "")); } else if (map->lhs->type == TMPL_TYPE_DATA) { - cast_type = map->lhs->tmpl_value_box_type; + cast_type = map->lhs->tmpl_fr_value_box_type; EVAL_DEBUG("NORMALISATION TYPE %s (IMPLICIT FROM LHS DATA)", fr_int2str(dict_attr_types, cast_type, "")); } else if (map->rhs->type == TMPL_TYPE_DATA) { - cast_type = map->rhs->tmpl_value_box_type; + cast_type = map->rhs->tmpl_fr_value_box_type; EVAL_DEBUG("NORMALISATION TYPE %s (IMPLICIT FROM RHS DATA)", fr_int2str(dict_attr_types, cast_type, "")); } @@ -513,7 +513,7 @@ do {\ case TMPL_TYPE_XLAT_STRUCT: { ssize_t ret; - value_box_t data; + fr_value_box_t data; if (map->rhs->type != TMPL_TYPE_UNPARSED) { char *p; @@ -643,7 +643,7 @@ int cond_eval_map(REQUEST *request, UNUSED int modreturn, UNUSED int depth, fr_c { char *p = NULL; ssize_t ret; - value_box_t data; + fr_value_box_t data; if (map->lhs->type != TMPL_TYPE_UNPARSED) { ret = tmpl_aexpand(request, &p, request, map->lhs, NULL, NULL); diff --git a/src/main/cond_tokenize.c b/src/main/cond_tokenize.c index 00a79012d4f..dfa21e6f1e5 100644 --- a/src/main/cond_tokenize.c +++ b/src/main/cond_tokenize.c @@ -178,7 +178,7 @@ static ssize_t cond_tokenize_string(TALLOC_CTX *ctx, char **out, char const **e /* * Call the STANDARD parse function to figure out what the string is. */ - value_box_t data; + fr_value_box_t data; char quote = *start; fr_type_t src_type = FR_TYPE_STRING; @@ -187,7 +187,7 @@ static ssize_t cond_tokenize_string(TALLOC_CTX *ctx, char **out, char const **e */ if (quote == '/') quote = '\0'; - if (value_box_from_str(ctx, &data, &src_type, NULL, start + 1, p - (start + 1), quote) < 0) { + if (fr_value_box_from_str(ctx, &data, &src_type, NULL, start + 1, p - (start + 1), quote) < 0) { *error = "error parsing string"; return -1; } @@ -1113,7 +1113,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, CONF_ITEM *ci, char const *start, fr_dict_attr_t const *da; da = fr_dict_attr_by_type(c->data.map->lhs->tmpl_da, - c->data.map->rhs->tmpl_value_box_type); + c->data.map->rhs->tmpl_fr_value_box_type); if (!da) { return_rhs("Cannot find type for attribute"); } diff --git a/src/main/conf_file.c b/src/main/conf_file.c index 88b59290883..ca61299a611 100644 --- a/src/main/conf_file.c +++ b/src/main/conf_file.c @@ -2031,7 +2031,7 @@ static int cf_pair_default(CONF_PAIR **out, CONF_SECTION *cs, char const *name, * Takes fields from a #CONF_PARSER struct and uses them to parse the string value * of a #CONF_PAIR into a C data type matching the type argument. * - * The format of the types are the same as #value_box_t types. + * The format of the types are the same as #fr_value_box_t types. * * @note The dflt value will only be used if no matching #CONF_PAIR is found. Empty strings will not * result in the dflt value being used. diff --git a/src/main/exec.c b/src/main/exec.c index bc6c5006f0b..a9d8edb5b53 100644 --- a/src/main/exec.c +++ b/src/main/exec.c @@ -632,7 +632,7 @@ wait: if (child_pid == pid) { if (WIFEXITED(status)) { - value_box_t boxed_answer = { + fr_value_box_t boxed_answer = { .datum.strvalue = answer, .datum.length = len, .type = FR_TYPE_STRING diff --git a/src/main/map.c b/src/main/map.c index a26908829ff..518f2529581 100644 --- a/src/main/map.c +++ b/src/main/map.c @@ -64,7 +64,7 @@ bool map_cast_from_hex(vp_map_t *map, FR_TOKEN rhs_type, char const *rhs) fr_dict_attr_t const *da; VALUE_PAIR *vp = NULL; vp_tmpl_t *vpt; - value_box_t bin = { .type = FR_TYPE_STRING }, cast; + fr_value_box_t bin = { .type = FR_TYPE_STRING }, cast; rad_assert(map != NULL); @@ -104,18 +104,18 @@ bool map_cast_from_hex(vp_map_t *map, FR_TOKEN rhs_type, char const *rhs) /* * Assign but don't dup. */ - value_box_memdup_buffer_shallow(NULL, &bin, ptr, false); + fr_value_box_memdup_buffer_shallow(NULL, &bin, ptr, false); /* * Convert to da->type (if possible); */ - if (value_box_cast(map, &cast, da->type, da, &bin) < 0) { + if (fr_value_box_cast(map, &cast, da->type, da, &bin) < 0) { talloc_free(bin.datum.ptr); return false; } /* - * Package the #value_box_t as a #vp_tmpl_t + * Package the #fr_value_box_t as a #vp_tmpl_t */ if (tmpl_afrom_value_box(map, &map->rhs, &cast, true) < 0) { talloc_free(bin.datum.ptr); @@ -860,7 +860,7 @@ int map_to_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_map_t cons n = fr_pair_afrom_da(ctx, map->lhs->tmpl_da); if (!n) return -1; - if (value_box_cast(n, &n->data, + if (fr_value_box_cast(n, &n->data, map->lhs->tmpl_da->type, map->lhs->tmpl_da, &vp->data) < 0) { RPEDEBUG("Attribute conversion failed"); fr_pair_list_free(&found); @@ -899,13 +899,13 @@ int map_to_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_map_t cons n = fr_pair_afrom_da(ctx, map->lhs->tmpl_da); if (!n) return -1; - if (map->lhs->tmpl_da->type == map->rhs->tmpl_value_box_type) { - if (value_box_copy(n, &n->data, &map->rhs->tmpl_value_box) < 0) { + if (map->lhs->tmpl_da->type == map->rhs->tmpl_fr_value_box_type) { + if (fr_value_box_copy(n, &n->data, &map->rhs->tmpl_value_box) < 0) { rcode = -1; goto error; } } else { - if (value_box_cast(n, &n->data, n->vp_type, n->da, + if (fr_value_box_cast(n, &n->data, n->vp_type, n->da, &map->rhs->tmpl_value_box) < 0) { RPEDEBUG("Implicit cast failed"); rcode = -1; @@ -1361,7 +1361,7 @@ int map_to_request(REQUEST *request, vp_map_t const *map, radius_map_getvalue_t if (cmp > 0) break; else if (cmp < 0) continue; - cmp = (value_box_cmp_op(map->op, &a->data, &b->data) == 0); + cmp = (fr_value_box_cmp_op(map->op, &a->data, &b->data) == 0); if (cmp != 0) { a = fr_pair_cursor_remove(&dst_list); talloc_free(a); diff --git a/src/main/radsnmp.c b/src/main/radsnmp.c index bf21c8877ed..49aa8f88872 100644 --- a/src/main/radsnmp.c +++ b/src/main/radsnmp.c @@ -501,11 +501,11 @@ static int radsnmp_get_response(int fd, default: /* - * We call value_box_snprint with a NULL da pointer + * We call fr_value_box_snprint with a NULL da pointer * because we always need return integer values not * value aliases. */ - len = value_box_snprint(value_buff, sizeof(value_buff), &vp->data, '\0'); + len = fr_value_box_snprint(value_buff, sizeof(value_buff), &vp->data, '\0'); if (is_truncated(len, sizeof(value_buff))) { fr_strerror_printf("Insufficient fixed value buffer"); return -1; diff --git a/src/main/snmp.c b/src/main/snmp.c index acdf53aae5f..b7a618b93c2 100644 --- a/src/main/snmp.c +++ b/src/main/snmp.c @@ -37,8 +37,8 @@ RCSID("$Id$") typedef struct fr_snmp_map fr_snmp_map_t; -typedef int (*fr_snmp_get_func_t)(TALLOC_CTX *ctx, value_box_t *out, fr_snmp_map_t const *map, void *snmp_ctx); -typedef int (*fr_snmp_set_func_t)(fr_snmp_map_t const *map, void *snmp_ctx, value_box_t *data); +typedef int (*fr_snmp_get_func_t)(TALLOC_CTX *ctx, fr_value_box_t *out, fr_snmp_map_t const *map, void *snmp_ctx); +typedef int (*fr_snmp_set_func_t)(fr_snmp_map_t const *map, void *snmp_ctx, fr_value_box_t *data); typedef int (*fr_snmp_index_func_t)(TALLOC_CTX *ctx, void **snmp_ctx_out, fr_snmp_map_t const *map, void const *snmp_ctx_in, uint32_t index); @@ -79,7 +79,7 @@ static struct timeval uptime; static struct timeval reset_time; static int reset_state = PW_RADIUS_AUTH_SERV_CONFIG_RESET_VALUE_RUNNING; -static int snmp_value_serv_ident_get(TALLOC_CTX *ctx, value_box_t *out, NDEBUG_UNUSED fr_snmp_map_t const *map, +static int snmp_value_serv_ident_get(TALLOC_CTX *ctx, fr_value_box_t *out, NDEBUG_UNUSED fr_snmp_map_t const *map, UNUSED void *snmp_ctx) { rad_assert(map->da->type == FR_TYPE_STRING); @@ -89,7 +89,7 @@ static int snmp_value_serv_ident_get(TALLOC_CTX *ctx, value_box_t *out, NDEBUG_U return 0; } -static int snmp_value_uptime_get(UNUSED TALLOC_CTX *ctx, value_box_t *out, NDEBUG_UNUSED fr_snmp_map_t const *map, +static int snmp_value_uptime_get(UNUSED TALLOC_CTX *ctx, fr_value_box_t *out, NDEBUG_UNUSED fr_snmp_map_t const *map, UNUSED void *snmp_ctx) { struct timeval now; @@ -106,7 +106,7 @@ static int snmp_value_uptime_get(UNUSED TALLOC_CTX *ctx, value_box_t *out, NDEBU return 0; } -static int snmp_config_reset_time_get(UNUSED TALLOC_CTX *ctx, value_box_t *out, NDEBUG_UNUSED fr_snmp_map_t const *map, +static int snmp_config_reset_time_get(UNUSED TALLOC_CTX *ctx, fr_value_box_t *out, NDEBUG_UNUSED fr_snmp_map_t const *map, UNUSED void *snmp_ctx) { struct timeval now; @@ -123,7 +123,7 @@ static int snmp_config_reset_time_get(UNUSED TALLOC_CTX *ctx, value_box_t *out, return 0; } -static int snmp_config_reset_get(UNUSED TALLOC_CTX *ctx, value_box_t *out, NDEBUG_UNUSED fr_snmp_map_t const *map, +static int snmp_config_reset_get(UNUSED TALLOC_CTX *ctx, fr_value_box_t *out, NDEBUG_UNUSED fr_snmp_map_t const *map, UNUSED void *snmp_ctx) { rad_assert(map->da->type == FR_TYPE_INTEGER); @@ -133,7 +133,7 @@ static int snmp_config_reset_get(UNUSED TALLOC_CTX *ctx, value_box_t *out, NDEBU return 0; } -static int snmp_config_reset_set(NDEBUG_UNUSED fr_snmp_map_t const *map, UNUSED void *snmp_ctx, value_box_t *in) +static int snmp_config_reset_set(NDEBUG_UNUSED fr_snmp_map_t const *map, UNUSED void *snmp_ctx, fr_value_box_t *in) { rad_assert(map->da->type == FR_TYPE_INTEGER); @@ -149,7 +149,7 @@ static int snmp_config_reset_set(NDEBUG_UNUSED fr_snmp_map_t const *map, UNUSED } -static int snmp_auth_stats_offset_get(UNUSED TALLOC_CTX *ctx, value_box_t *out, +static int snmp_auth_stats_offset_get(UNUSED TALLOC_CTX *ctx, fr_value_box_t *out, fr_snmp_map_t const *map, UNUSED void *snmp_ctx) { rad_assert(map->da->type == FR_TYPE_INTEGER); @@ -175,7 +175,7 @@ static int snmp_client_index(UNUSED TALLOC_CTX *ctx, void **snmp_ctx_out, return 0; } -static int snmp_client_index_get(UNUSED TALLOC_CTX *ctx, value_box_t *out, +static int snmp_client_index_get(UNUSED TALLOC_CTX *ctx, fr_value_box_t *out, UNUSED fr_snmp_map_t const *map, void *snmp_ctx) { RADCLIENT *client = snmp_ctx; @@ -187,7 +187,7 @@ static int snmp_client_index_get(UNUSED TALLOC_CTX *ctx, value_box_t *out, return 0; } -static int snmp_client_ipv4addr_get(UNUSED TALLOC_CTX *ctx, value_box_t *out, +static int snmp_client_ipv4addr_get(UNUSED TALLOC_CTX *ctx, fr_value_box_t *out, NDEBUG_UNUSED fr_snmp_map_t const *map, void *snmp_ctx) { RADCLIENT *client = snmp_ctx; @@ -208,7 +208,7 @@ static int snmp_client_ipv4addr_get(UNUSED TALLOC_CTX *ctx, value_box_t *out, return 0; } -static int snmp_client_id_get(TALLOC_CTX *ctx, value_box_t *out, +static int snmp_client_id_get(TALLOC_CTX *ctx, fr_value_box_t *out, NDEBUG_UNUSED fr_snmp_map_t const *map, void *snmp_ctx) { RADCLIENT *client = snmp_ctx; @@ -225,7 +225,7 @@ static int snmp_client_id_get(TALLOC_CTX *ctx, value_box_t *out, return 0; } -static int snmp_auth_client_stats_offset_get(UNUSED TALLOC_CTX *ctx, value_box_t *out, +static int snmp_auth_client_stats_offset_get(UNUSED TALLOC_CTX *ctx, fr_value_box_t *out, fr_snmp_map_t const *map, void *snmp_ctx) { RADCLIENT *client = snmp_ctx; @@ -743,7 +743,7 @@ static ssize_t snmp_process_leaf(vp_cursor_t *out, REQUEST *request, case PW_FREERADIUS_SNMP_OPERATION_VALUE_GET: { - value_box_t data; + fr_value_box_t data; memset(&data, 0, sizeof(data)); @@ -765,13 +765,13 @@ static ssize_t snmp_process_leaf(vp_cursor_t *out, REQUEST *request, * attribute. To reduce boilerplate code * in callbacks, we handled allocating and * inserting VALUE_PAIRs, and pass in a - * value_box_t struct for the callback + * fr_value_box_t struct for the callback * to complete. */ if (map_p->get(request->reply, &data, map_p, snmp_ctx) < 0) goto error; vp = fr_pair_afrom_da(request->reply, map_p->da); - value_box_steal(vp, &vp->data, &data); + fr_value_box_steal(vp, &vp->data, &data); fr_pair_cursor_append(out, vp); vp = fr_pair_afrom_da(request->reply, fr_snmp_type); diff --git a/src/main/tmpl.c b/src/main/tmpl.c index dfdc52534a4..b25f75cd46d 100644 --- a/src/main/tmpl.c +++ b/src/main/tmpl.c @@ -594,7 +594,7 @@ void tmpl_from_da(vp_tmpl_t *vpt, fr_dict_attr_t const *da, int8_t tag, int num, vpt->tmpl_num = num; } -/** Create a #vp_tmpl_t from a #value_box_t +/** Create a #vp_tmpl_t from a #fr_value_box_t * * @param[in,out] ctx to allocate #vp_tmpl_t in. * @param[out] out Where to write pointer to new #vp_tmpl_t. @@ -604,23 +604,23 @@ void tmpl_from_da(vp_tmpl_t *vpt, fr_dict_attr_t const *da, int8_t tag, int num, * - 0 on success. * - -1 on failure. */ -int tmpl_afrom_value_box(TALLOC_CTX *ctx, vp_tmpl_t **out, value_box_t *data, bool steal) +int tmpl_afrom_value_box(TALLOC_CTX *ctx, vp_tmpl_t **out, fr_value_box_t *data, bool steal) { char const *name; vp_tmpl_t *vpt; vpt = talloc(ctx, vp_tmpl_t); - name = value_box_asprint(vpt, data, '\0'); + name = fr_value_box_asprint(vpt, data, '\0'); tmpl_init(vpt, TMPL_TYPE_DATA, name, talloc_array_length(name), (data->type == FR_TYPE_STRING) ? T_SINGLE_QUOTED_STRING : T_BARE_WORD); if (steal) { - if (value_box_steal(vpt, &vpt->tmpl_value_box, data) < 0) { + if (fr_value_box_steal(vpt, &vpt->tmpl_value_box, data) < 0) { talloc_free(vpt); return -1; } } else { - if (value_box_copy(vpt, &vpt->tmpl_value_box, data) < 0) { + if (fr_value_box_copy(vpt, &vpt->tmpl_value_box, data) < 0) { talloc_free(vpt); return -1; } @@ -956,7 +956,7 @@ ssize_t tmpl_afrom_str(TALLOC_CTX *ctx, vp_tmpl_t **out, char const *in, size_t ssize_t slen; fr_type_t data_type = FR_TYPE_STRING; vp_tmpl_t *vpt = NULL; - value_box_t data; + fr_value_box_t data; switch (type) { case T_BARE_WORD: @@ -983,11 +983,11 @@ ssize_t tmpl_afrom_str(TALLOC_CTX *ctx, vp_tmpl_t **out, char const *in, size_t binlen = (inlen - 2) / 2; vpt = tmpl_alloc(ctx, TMPL_TYPE_DATA, in, inlen, type); - vpt->tmpl_value_box_datum.ptr = talloc_array(vpt, uint8_t, binlen); - vpt->tmpl_value_box_length = binlen; - vpt->tmpl_value_box_type = FR_TYPE_OCTETS; + vpt->tmpl_fr_value_box_datum.ptr = talloc_array(vpt, uint8_t, binlen); + vpt->tmpl_fr_value_box_length = binlen; + vpt->tmpl_fr_value_box_type = FR_TYPE_OCTETS; - len = fr_hex2bin(vpt->tmpl_value_box_datum.ptr, binlen, in + 2, inlen - 2); + len = fr_hex2bin(vpt->tmpl_fr_value_box_datum.ptr, binlen, in + 2, inlen - 2); if (len != binlen) { fr_strerror_printf("Hex string contains none hex char"); talloc_free(vpt); @@ -1013,7 +1013,7 @@ ssize_t tmpl_afrom_str(TALLOC_CTX *ctx, vp_tmpl_t **out, char const *in, size_t parse: if (do_unescape) { - if (value_box_from_str(ctx, &data, &data_type, NULL, in, inlen, quote) < 0) return 0; + if (fr_value_box_from_str(ctx, &data, &data_type, NULL, in, inlen, quote) < 0) return 0; vpt = tmpl_alloc(ctx, TMPL_TYPE_UNPARSED, data.datum.strvalue, talloc_array_length(data.datum.strvalue) - 1, type); talloc_free(data.datum.ptr); @@ -1051,7 +1051,7 @@ ssize_t tmpl_afrom_str(TALLOC_CTX *ctx, vp_tmpl_t **out, char const *in, size_t * literal. */ if (do_unescape) { - if (value_box_from_str(ctx, &data, &data_type, NULL, in, + if (fr_value_box_from_str(ctx, &data, &data_type, NULL, in, inlen, fr_token_quote[type]) < 0) return -1; if (do_xlat) { vpt = tmpl_alloc(ctx, TMPL_TYPE_XLAT, data.datum.strvalue, @@ -1075,7 +1075,7 @@ ssize_t tmpl_afrom_str(TALLOC_CTX *ctx, vp_tmpl_t **out, char const *in, size_t case T_BACK_QUOTED_STRING: if (do_unescape) { - if (value_box_from_str(ctx, &data, &data_type, NULL, in, + if (fr_value_box_from_str(ctx, &data, &data_type, NULL, in, inlen, fr_token_quote[type]) < 0) return -1; vpt = tmpl_alloc(ctx, TMPL_TYPE_EXEC, data.datum.strvalue, talloc_array_length(data.datum.strvalue) - 1, type); @@ -1148,38 +1148,38 @@ int tmpl_cast_in_place(vp_tmpl_t *vpt, fr_type_t type, fr_dict_attr_t const *enu switch (vpt->type) { case TMPL_TYPE_UNPARSED: - vpt->tmpl_value_box_type = type; + vpt->tmpl_fr_value_box_type = type; /* * Why do we pass a pointer to the tmpl type? Goddamn WiMAX. */ - if (value_box_from_str(vpt, &vpt->tmpl_value_box, &vpt->tmpl_value_box_type, + if (fr_value_box_from_str(vpt, &vpt->tmpl_value_box, &vpt->tmpl_fr_value_box_type, enumv, vpt->name, vpt->len, '\0') < 0) return -1; vpt->type = TMPL_TYPE_DATA; break; case TMPL_TYPE_DATA: { - value_box_t new; + fr_value_box_t new; - if (type == vpt->tmpl_value_box_type) return 0; /* noop */ + if (type == vpt->tmpl_fr_value_box_type) return 0; /* noop */ - if (value_box_cast(vpt, &new, type, enumv, &vpt->tmpl_value_box) < 0) return -1; + if (fr_value_box_cast(vpt, &new, type, enumv, &vpt->tmpl_value_box) < 0) return -1; /* * Free old value buffers */ - switch (vpt->tmpl_value_box_type) { + switch (vpt->tmpl_fr_value_box_type) { case FR_TYPE_STRING: case FR_TYPE_OCTETS: - talloc_free(vpt->tmpl_value_box_datum.ptr); + talloc_free(vpt->tmpl_fr_value_box_datum.ptr); break; default: break; } - value_box_copy(vpt, &vpt->tmpl_value_box, &new); + fr_value_box_copy(vpt, &vpt->tmpl_value_box, &new); } break; @@ -1203,12 +1203,12 @@ void tmpl_cast_in_place_str(vp_tmpl_t *vpt) rad_assert(vpt != NULL); rad_assert(vpt->type == TMPL_TYPE_UNPARSED); - vpt->tmpl_value_box_datum.strvalue = talloc_typed_strdup(vpt, vpt->name); - rad_assert(vpt->tmpl_value_box_datum.strvalue != NULL); + vpt->tmpl_fr_value_box_datum.strvalue = talloc_typed_strdup(vpt, vpt->name); + rad_assert(vpt->tmpl_fr_value_box_datum.strvalue != NULL); vpt->type = TMPL_TYPE_DATA; - vpt->tmpl_value_box_type = FR_TYPE_STRING; - vpt->tmpl_value_box_length = talloc_array_length(vpt->tmpl_value_box_datum.strvalue) - 1; + vpt->tmpl_fr_value_box_type = FR_TYPE_STRING; + vpt->tmpl_fr_value_box_length = talloc_array_length(vpt->tmpl_fr_value_box_datum.strvalue) - 1; } /** Expand a #vp_tmpl_t to a string, parse it as an attribute of type cast, create a #VALUE_PAIR from the result @@ -1234,7 +1234,7 @@ int tmpl_cast_to_vp(VALUE_PAIR **out, REQUEST *request, { int rcode; VALUE_PAIR *vp; - value_box_t data; + fr_value_box_t data; char *p; VERIFY_TMPL(vpt); @@ -1246,9 +1246,9 @@ int tmpl_cast_to_vp(VALUE_PAIR **out, REQUEST *request, if (vpt->type == TMPL_TYPE_DATA) { VERIFY_VP(vp); - rad_assert(vp->vp_type == vpt->tmpl_value_box_type); + rad_assert(vp->vp_type == vpt->tmpl_fr_value_box_type); - value_box_copy(vp, &vp->data, &vpt->tmpl_value_box); + fr_value_box_copy(vp, &vp->data, &vpt->tmpl_value_box); *out = vp; return 0; } @@ -1386,7 +1386,7 @@ int tmpl_define_undefined_attr(vp_tmpl_t *vpt, fr_type_t type, fr_dict_attr_flag * * @param[out] out Where to write a pointer to the string buffer. On return may * point to buff if buff was used to store the value. Otherwise will - * point to a #value_box_t buffer, or the name of the template. + * point to a #fr_value_box_t buffer, or the name of the template. * Must not be NULL. * @param[out] buff Expansion buffer, may be NULL except for the following types: * - #TMPL_TYPE_EXEC @@ -1415,10 +1415,10 @@ ssize_t _tmpl_to_type(void *out, xlat_escape_t escape, void const *escape_ctx, fr_type_t dst_type) { - value_box_t value_to_cast; - value_box_t value_from_cast; - value_box_t const *to_cast = &value_to_cast; - value_box_t const *from_cast = &value_from_cast; + fr_value_box_t value_to_cast; + fr_value_box_t value_from_cast; + fr_value_box_t const *to_cast = &value_to_cast; + fr_value_box_t const *from_cast = &value_from_cast; VALUE_PAIR *vp = NULL; @@ -1522,7 +1522,7 @@ ssize_t _tmpl_to_type(void *out, if (ret < 0) return -2; to_cast = &vpt->tmpl_value_box; - src_type = vpt->tmpl_value_box_type; + src_type = vpt->tmpl_fr_value_box_type; } break; @@ -1610,13 +1610,13 @@ ssize_t _tmpl_to_type(void *out, /* * Data type conversion... */ - ret = value_box_cast(ctx, &value_from_cast, dst_type, NULL, to_cast); + ret = fr_value_box_cast(ctx, &value_from_cast, dst_type, NULL, to_cast); if (ret < 0) return -1; /* * For the dynamic types we need to copy the output - * to the buffer. Really we need a version of value_box_cast + * to the buffer. Really we need a version of fr_value_box_cast * that works with buffers, but it's not a high priority... */ switch (dst_type) { @@ -1661,9 +1661,9 @@ ssize_t _tmpl_to_type(void *out, } RDEBUG4("Copying %zu bytes to %p from offset %zu", - value_box_field_sizes[dst_type], *((void **)out), value_box_offsets[dst_type]); + fr_value_box_field_sizes[dst_type], *((void **)out), fr_value_box_offsets[dst_type]); - memcpy(out, ((uint8_t const *) from_cast) + value_box_offsets[dst_type], value_box_field_sizes[dst_type]); + memcpy(out, ((uint8_t const *) from_cast) + fr_value_box_offsets[dst_type], fr_value_box_field_sizes[dst_type]); return from_cast->datum.length; } @@ -1709,11 +1709,11 @@ ssize_t _tmpl_to_atype(TALLOC_CTX *ctx, void *out, xlat_escape_t escape, void const *escape_ctx, fr_type_t dst_type) { - value_box_t const *to_cast = NULL; - value_box_t from_cast; + fr_value_box_t const *to_cast = NULL; + fr_value_box_t from_cast; VALUE_PAIR *vp = NULL; - value_box_t value; + fr_value_box_t value; bool needs_dup = false; ssize_t slen = -1; @@ -1755,7 +1755,7 @@ ssize_t _tmpl_to_atype(TALLOC_CTX *ctx, void *out, case TMPL_TYPE_XLAT: { - value_box_t tmp; + fr_value_box_t tmp; fr_type_t src_type = FR_TYPE_STRING; RDEBUG4("EXPAND TMPL XLAT"); @@ -1771,7 +1771,7 @@ ssize_t _tmpl_to_atype(TALLOC_CTX *ctx, void *out, * * @fixme We need a way of signalling xlat not to escape things. */ - ret = value_box_from_str(tmp_ctx, &tmp, &src_type, NULL, value.datum.strvalue, value.datum.length, '"'); + ret = fr_value_box_from_str(tmp_ctx, &tmp, &src_type, NULL, value.datum.strvalue, value.datum.length, '"'); if (ret < 0) goto error; value.datum.strvalue = tmp.datum.strvalue; @@ -1783,7 +1783,7 @@ ssize_t _tmpl_to_atype(TALLOC_CTX *ctx, void *out, case TMPL_TYPE_XLAT_STRUCT: { - value_box_t tmp; + fr_value_box_t tmp; fr_type_t src_type = FR_TYPE_STRING; RDEBUG4("EXPAND TMPL XLAT STRUCT"); @@ -1801,7 +1801,7 @@ ssize_t _tmpl_to_atype(TALLOC_CTX *ctx, void *out, * * @fixme We need a way of signalling xlat not to escape things. */ - ret = value_box_from_str(tmp_ctx, &tmp, &src_type, NULL, + ret = fr_value_box_from_str(tmp_ctx, &tmp, &src_type, NULL, value.datum.strvalue, value.datum.length, '"'); if (ret < 0) goto error; @@ -1870,7 +1870,7 @@ ssize_t _tmpl_to_atype(TALLOC_CTX *ctx, void *out, * Don't dup the buffers unless we need to. */ if ((to_cast->type != dst_type) || needs_dup) { - ret = value_box_cast(ctx, &from_cast, dst_type, NULL, to_cast); + ret = fr_value_box_cast(ctx, &from_cast, dst_type, NULL, to_cast); if (ret < 0) goto error; } else { switch (to_cast->type) { @@ -1892,9 +1892,9 @@ ssize_t _tmpl_to_atype(TALLOC_CTX *ctx, void *out, } RDEBUG4("Copying %zu bytes to %p from offset %zu", - value_box_field_sizes[dst_type], *((void **)out), value_box_offsets[dst_type]); + fr_value_box_field_sizes[dst_type], *((void **)out), fr_value_box_offsets[dst_type]); - memcpy(out, ((uint8_t *)&from_cast) + value_box_offsets[dst_type], value_box_field_sizes[dst_type]); + memcpy(out, ((uint8_t *)&from_cast) + fr_value_box_offsets[dst_type], fr_value_box_field_sizes[dst_type]); /* * Frees any memory allocated for temporary buffers @@ -2051,7 +2051,7 @@ do_literal: break; case TMPL_TYPE_DATA: - return value_box_snprint(out, outlen, &vpt->tmpl_value_box, fr_token_quote[vpt->quote]); + return fr_value_box_snprint(out, outlen, &vpt->tmpl_value_box, fr_token_quote[vpt->quote]); default: goto empty; @@ -2577,24 +2577,24 @@ void tmpl_verify(char const *file, int line, vp_tmpl_t const *vpt) if (!fr_cond_assert(0)) fr_exit_now(1); } - if (vpt->tmpl_value_box_type == FR_TYPE_INVALID) { + if (vpt->tmpl_fr_value_box_type == FR_TYPE_INVALID) { FR_FAULT_LOG("CONSISTENCY CHECK FAILED %s[%u]: TMPL_TYPE_DATA type was " "FR_TYPE_INVALID (uninitialised)", file, line); if (!fr_cond_assert(0)) fr_exit_now(1); } - if (vpt->tmpl_value_box_type >= FR_TYPE_MAX) { + if (vpt->tmpl_fr_value_box_type >= FR_TYPE_MAX) { FR_FAULT_LOG("CONSISTENCY CHECK FAILED %s[%u]: TMPL_TYPE_DATA type was " - "%i (outside the range of fr_type_ts)", file, line, vpt->tmpl_value_box_type); + "%i (outside the range of fr_type_ts)", file, line, vpt->tmpl_fr_value_box_type); if (!fr_cond_assert(0)) fr_exit_now(1); } /* * Unlike VALUE_PAIRs we can't guarantee that VALUE_PAIR_TMPL buffers will * be talloced. They may be allocated on the stack or in global variables. */ - switch (vpt->tmpl_value_box_type) { + switch (vpt->tmpl_fr_value_box_type) { case FR_TYPE_STRING: - if (vpt->tmpl_value_box_datum.strvalue[vpt->tmpl_value_box_length] != '\0') { + if (vpt->tmpl_fr_value_box_datum.strvalue[vpt->tmpl_fr_value_box_length] != '\0') { FR_FAULT_LOG("CONSISTENCY CHECK FAILED %s[%u]: TMPL_TYPE_DATA char buffer not \\0 " "terminated", file, line); if (!fr_cond_assert(0)) fr_exit_now(1); diff --git a/src/main/unlang_compile.c b/src/main/unlang_compile.c index 2d772ed55e6..d83c26186b2 100644 --- a/src/main/unlang_compile.c +++ b/src/main/unlang_compile.c @@ -1273,13 +1273,13 @@ int unlang_fixup_update(vp_map_t *map, UNUSED void *ctx) * Fixup LHS da if it doesn't match the type * of the RHS. */ - if (map->lhs->tmpl_da->type != map->rhs->tmpl_value_box_type) { + if (map->lhs->tmpl_da->type != map->rhs->tmpl_fr_value_box_type) { fr_dict_attr_t const *da; - da = fr_dict_attr_by_type(map->lhs->tmpl_da, map->rhs->tmpl_value_box_type); + da = fr_dict_attr_by_type(map->lhs->tmpl_da, map->rhs->tmpl_fr_value_box_type); if (!da) { fr_strerror_printf("Cannot find %s variant of attribute \"%s\"", - fr_int2str(dict_attr_types, map->rhs->tmpl_value_box_type, + fr_int2str(dict_attr_types, map->rhs->tmpl_fr_value_box_type, ""), map->lhs->tmpl_da->name); return -1; } diff --git a/src/main/unlang_interpret.c b/src/main/unlang_interpret.c index de9306879ca..7ecad4f1c7c 100644 --- a/src/main/unlang_interpret.c +++ b/src/main/unlang_interpret.c @@ -617,7 +617,7 @@ static unlang_action_t unlang_switch(REQUEST *request, unlang_stack_t *stack, unlang_t *this, *found, *null_case; unlang_group_t *g, *h; fr_cond_t cond; - value_box_t data; + fr_value_box_t data; vp_map_t map; vp_tmpl_t vpt; diff --git a/src/main/xlat_eval.c b/src/main/xlat_eval.c index eeab86374d8..62737fba0dc 100644 --- a/src/main/xlat_eval.c +++ b/src/main/xlat_eval.c @@ -509,10 +509,10 @@ static char *xlat_aprint(TALLOC_CTX *ctx, REQUEST *request, xlat_exp_t const * c */ if (*child) { fr_type_t type; - value_box_t data; + fr_value_box_t data; type = FR_TYPE_STRING; - if (value_box_from_str(ctx, &data, &type, NULL, child, + if (fr_value_box_from_str(ctx, &data, &type, NULL, child, talloc_array_length(child) - 1, '"') < 0) { talloc_free(child); return NULL; diff --git a/src/main/xlat_func.c b/src/main/xlat_func.c index 8359d9ec94a..30d3ba8af09 100644 --- a/src/main/xlat_func.c +++ b/src/main/xlat_func.c @@ -76,7 +76,7 @@ static ssize_t xlat_length(UNUSED TALLOC_CTX *ctx, char **out, size_t outlen, if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) return 0; - snprintf(*out, outlen, "%zu", value_box_network_length(&vp->data)); + snprintf(*out, outlen, "%zu", fr_value_box_network_length(&vp->data)); return strlen(*out); } @@ -169,7 +169,7 @@ static ssize_t xlat_hex(UNUSED TALLOC_CTX *ctx, char **out, size_t outlen, VALUE_PAIR *vp; uint8_t const *p; size_t len; - value_box_t dst; + fr_value_box_t dst; uint8_t const *buff = NULL; while (isspace((int) *fmt)) fmt++; @@ -186,11 +186,11 @@ static ssize_t xlat_hex(UNUSED TALLOC_CTX *ctx, char **out, size_t outlen, p = vp->vp_octets; len = vp->vp_length; /* - * Cast the value_box_t of the VP to an octets string and + * Cast the fr_value_box_t of the VP to an octets string and * print that as hex. */ } else { - if (value_box_cast(request, &dst, FR_TYPE_OCTETS, NULL, &vp->data) < 0) { + if (fr_value_box_cast(request, &dst, FR_TYPE_OCTETS, NULL, &vp->data) < 0) { REDEBUG("%s", fr_strerror()); goto error; } @@ -383,7 +383,7 @@ static ssize_t xlat_debug_attr(UNUSED TALLOC_CTX *ctx, UNUSED char **out, UNUSED while (type->name) { int pad; - value_box_t *dst = NULL; + fr_value_box_t *dst = NULL; if ((fr_type_t) type->number == vp->vp_type) goto next_type; @@ -400,13 +400,13 @@ static ssize_t xlat_debug_attr(UNUSED TALLOC_CTX *ctx, UNUSED char **out, UNUSED break; } - dst = talloc_zero(vp, value_box_t); + dst = talloc_zero(vp, fr_value_box_t); /* We expect some to fail */ - if (value_box_cast(dst, dst, type->number, NULL, &vp->data) < 0) { + if (fr_value_box_cast(dst, dst, type->number, NULL, &vp->data) < 0) { goto next_type; } - value = value_box_asprint(dst, dst, '\''); + value = fr_value_box_asprint(dst, dst, '\''); if (!value) goto next_type; if ((pad = (11 - strlen(type->name))) < 0) { diff --git a/src/modules/proto_ldap_sync/sync.c b/src/modules/proto_ldap_sync/sync.c index ce564a44b54..7a7f061017f 100644 --- a/src/modules/proto_ldap_sync/sync.c +++ b/src/modules/proto_ldap_sync/sync.c @@ -274,7 +274,7 @@ static int sync_search_entry_or_refrence(sync_state_t *sync, LDAPMessage *msg, L if (DEBUG_ENABLED3) { char *entry_dn; - value_box_t uuid_box; + fr_value_box_t uuid_box; entry_dn = ldap_get_dn(sync->conn->handle, msg); fr_ldap_berval_to_value(&uuid_box, &entry_uuid); diff --git a/src/modules/rlm_cache/drivers/rlm_cache_redis/rlm_cache_redis.c b/src/modules/rlm_cache/drivers/rlm_cache_redis/rlm_cache_redis.c index cae75992abd..d88f9fcad2c 100644 --- a/src/modules/rlm_cache/drivers/rlm_cache_redis/rlm_cache_redis.c +++ b/src/modules/rlm_cache/drivers/rlm_cache_redis/rlm_cache_redis.c @@ -209,7 +209,7 @@ static cache_status_t cache_entry_find(rlm_cache_entry_t **out, if ((head->lhs->tmpl_da->vendor == 0) && (head->lhs->tmpl_da->attr == PW_CACHE_CREATED)) { vp_map_t *map; - c->created = head->rhs->tmpl_value_box_datum.date; + c->created = head->rhs->tmpl_fr_value_box_datum.date; map = head; head = head->next; @@ -222,7 +222,7 @@ static cache_status_t cache_entry_find(rlm_cache_entry_t **out, if ((head->lhs->tmpl_da->vendor == 0) && (head->lhs->tmpl_da->attr == PW_CACHE_EXPIRES)) { vp_map_t *map; - c->expires = head->rhs->tmpl_value_box_datum.date; + c->expires = head->rhs->tmpl_fr_value_box_datum.date; map = head; head = head->next; @@ -288,8 +288,8 @@ static cache_status_t cache_entry_insert(UNUSED rlm_cache_config_t const *config * Encode the entry created date */ tmpl_init(&created_value, TMPL_TYPE_DATA, "", 6, T_BARE_WORD); - created_value.tmpl_value_box_type = FR_TYPE_DATE; - created_value.tmpl_value_box_datum.date = c->created; + created_value.tmpl_fr_value_box_type = FR_TYPE_DATE; + created_value.tmpl_fr_value_box_datum.date = c->created; /* * Encode the entry expiry time @@ -298,8 +298,8 @@ static cache_status_t cache_entry_insert(UNUSED rlm_cache_config_t const *config * to ignore entries that were created before the last epoch. */ tmpl_init(&expires_value, TMPL_TYPE_DATA, "", 6, T_BARE_WORD); - expires_value.tmpl_value_box_type = FR_TYPE_DATE; - expires_value.tmpl_value_box_datum.date = c->expires; + expires_value.tmpl_fr_value_box_type = FR_TYPE_DATE; + expires_value.tmpl_fr_value_box_datum.date = c->expires; expires.next = c->maps; /* Head of the list */ for (cnt = 0, map = &created; map; cnt++, map = map->next); diff --git a/src/modules/rlm_cache/rlm_cache.c b/src/modules/rlm_cache/rlm_cache.c index f87c2c5ddb0..c305e314d36 100644 --- a/src/modules/rlm_cache/rlm_cache.c +++ b/src/modules/rlm_cache/rlm_cache.c @@ -368,21 +368,21 @@ static rlm_rcode_t cache_insert(rlm_cache_t const *inst, REQUEST *request, rlm_c switch (map->lhs->type) { /* * Attributes are easy, reuse the LHS, and create a new - * RHS with the value_box_t from the VALUE_PAIR. + * RHS with the fr_value_box_t from the VALUE_PAIR. */ case TMPL_TYPE_ATTR: c_map->lhs = map->lhs; /* lhs shouldn't be touched, so this is ok */ do_rhs: MEM(c_map->rhs = tmpl_init(talloc(c_map, vp_tmpl_t), TMPL_TYPE_DATA, map->rhs->name, map->rhs->len, T_BARE_WORD)); - if (value_box_copy(c_map->rhs, &c_map->rhs->tmpl_value_box, &vp->data) < 0) { + if (fr_value_box_copy(c_map->rhs, &c_map->rhs->tmpl_value_box, &vp->data) < 0) { REDEBUG("Failed copying attribute value"); error: talloc_free(pool); talloc_free(c); return RLM_MODULE_FAIL; } - c_map->rhs->tmpl_value_box_type = vp->vp_type; + c_map->rhs->tmpl_fr_value_box_type = vp->vp_type; if (vp->vp_type == FR_TYPE_STRING) { c_map->rhs->quote = is_printable(vp->vp_strvalue, vp->vp_length) ? T_SINGLE_QUOTED_STRING : T_DOUBLE_QUOTED_STRING; @@ -837,7 +837,7 @@ static ssize_t cache_xlat(TALLOC_CTX *ctx, char **out, UNUSED size_t freespace, (map->lhs->tmpl_tag != target->tmpl_tag) || (map->lhs->tmpl_list != target->tmpl_list)) continue; - *out = value_box_asprint(request, &map->rhs->tmpl_value_box, '\0'); + *out = fr_value_box_asprint(request, &map->rhs->tmpl_value_box, '\0'); ret = talloc_array_length(*out) - 1; break; } diff --git a/src/modules/rlm_cache/serialize.c b/src/modules/rlm_cache/serialize.c index 7bcf06299a2..af7109a9b8c 100644 --- a/src/modules/rlm_cache/serialize.c +++ b/src/modules/rlm_cache/serialize.c @@ -74,7 +74,7 @@ int cache_serialize(TALLOC_CTX *ctx, char **out, rlm_cache_entry_t const *c) goto error; } - value = value_box_asprint(value_pool, &map->rhs->tmpl_value_box, '\''); + value = fr_value_box_asprint(value_pool, &map->rhs->tmpl_value_box, '\''); if (!value) goto error; to_store = talloc_asprintf_append_buffer(to_store, "%s %s %s\n", attr, @@ -149,12 +149,12 @@ int cache_deserialize(rlm_cache_entry_t *c, char *in, ssize_t inlen) */ if (map->lhs->tmpl_da->vendor == 0) switch (map->lhs->tmpl_da->attr) { case PW_CACHE_CREATED: - c->created = map->rhs->tmpl_value_box_datum.date; + c->created = map->rhs->tmpl_fr_value_box_datum.date; talloc_free(map); goto next; case PW_CACHE_EXPIRES: - c->expires = map->rhs->tmpl_value_box_datum.date; + c->expires = map->rhs->tmpl_fr_value_box_datum.date; talloc_free(map); goto next; diff --git a/src/modules/rlm_eap/lib/sim/sim_proto.c b/src/modules/rlm_eap/lib/sim/sim_proto.c index 6d91460782a..dd6639bb724 100644 --- a/src/modules/rlm_eap/lib/sim/sim_proto.c +++ b/src/modules/rlm_eap/lib/sim/sim_proto.c @@ -933,9 +933,9 @@ ssize_t fr_sim_encode(REQUEST *request, fr_dict_attr_t const *parent, uint8_t ty case FR_TYPE_INTEGER64: //!< 64 Bit unsigned integer. case FR_TYPE_SIGNED: //!< 32 Bit signed integer. { - value_box_t data; + fr_value_box_t data; - value_box_hton(&data, &vp->data); + fr_value_box_hton(&data, &vp->data); memcpy(&p[2], &data.datum, vp->vp_length); } diff --git a/src/modules/rlm_expr/rlm_expr.c b/src/modules/rlm_expr/rlm_expr.c index 64e82886ff0..a5903b69c4b 100644 --- a/src/modules/rlm_expr/rlm_expr.c +++ b/src/modules/rlm_expr/rlm_expr.c @@ -258,9 +258,9 @@ static bool get_number(REQUEST *request, char const **string, int64_t *answer) int64_t y; if (vp->vp_type != FR_TYPE_INTEGER64) { - value_box_t value; + fr_value_box_t value; - if (value_box_cast(vp, &value, FR_TYPE_INTEGER64, NULL, &vp->data) < 0) { + if (fr_value_box_cast(vp, &value, FR_TYPE_INTEGER64, NULL, &vp->data) < 0) { REDEBUG("Failed converting &%.*s to an integer value: %s", (int) vpt->len, vpt->name, fr_strerror()); return false; @@ -970,7 +970,7 @@ static ssize_t toupper_xlat(UNUSED TALLOC_CTX *ctx, char **out, size_t outlen, * This needs to die, and hopefully will die, when xlat functions accept * xlat node structures. * - * @param out value_box_t containing a shallow copy of the attribute, + * @param out fr_value_box_t containing a shallow copy of the attribute, * or the fmt string. * @param request current request. * @param fmt string. @@ -978,7 +978,7 @@ static ssize_t toupper_xlat(UNUSED TALLOC_CTX *ctx, char **out, size_t outlen, * - The length of the data. * - -1 on failure. */ -static int value_box_from_fmt(value_box_t *out, REQUEST *request, char const *fmt) +static int fr_value_box_from_fmt(fr_value_box_t *out, REQUEST *request, char const *fmt) { VALUE_PAIR *vp; @@ -1006,14 +1006,14 @@ static int value_box_from_fmt(value_box_t *out, REQUEST *request, char const *fm * These are large types. Return pointers to the * data instead of copying the data. */ - value_box_copy_shallow(NULL, out, &vp->data); + fr_value_box_copy_shallow(NULL, out, &vp->data); return 0; } -static int value_box_to_bin(TALLOC_CTX *ctx, REQUEST *request, uint8_t **out, size_t *outlen, value_box_t const *in) +static int fr_value_box_to_bin(TALLOC_CTX *ctx, REQUEST *request, uint8_t **out, size_t *outlen, fr_value_box_t const *in) { - value_box_t bin; + fr_value_box_t bin; switch (in->type) { case FR_TYPE_STRING: @@ -1023,7 +1023,7 @@ static int value_box_to_bin(TALLOC_CTX *ctx, REQUEST *request, uint8_t **out, si return 0; default: - if (value_box_cast(ctx, &bin, FR_TYPE_OCTETS, NULL, in) < 0) { + if (fr_value_box_cast(ctx, &bin, FR_TYPE_OCTETS, NULL, in) < 0) { RPERROR("Failed casting xlat input to 'octets'"); return -1; } @@ -1034,10 +1034,10 @@ static int value_box_to_bin(TALLOC_CTX *ctx, REQUEST *request, uint8_t **out, si } #define VALUE_FROM_FMT(_tmp_ctx, _p, _len, _request, _fmt) \ - value_box_t _value; \ - if (value_box_from_fmt(&_value, _request, _fmt) < 0) return -1; \ + fr_value_box_t _value; \ + if (fr_value_box_from_fmt(&_value, _request, _fmt) < 0) return -1; \ if (!_tmp_ctx) _tmp_ctx = talloc_new(_request); \ - if (value_box_to_bin(_tmp_ctx, _request, &_p, &_len, &_value) < 0) { \ + if (fr_value_box_to_bin(_tmp_ctx, _request, &_p, &_len, &_value) < 0) { \ talloc_free(_tmp_ctx); \ return -1; \ } diff --git a/src/modules/rlm_json/jpath.c b/src/modules/rlm_json/jpath.c index 4a5ad2cc2b7..a442416cda6 100644 --- a/src/modules/rlm_json/jpath.c +++ b/src/modules/rlm_json/jpath.c @@ -131,8 +131,8 @@ size_t fr_jpath_escape_func(UNUSED REQUEST *request, char *out, size_t outlen, c /** Recursive function for jpath_expr_evaluate * - * @param[in,out] ctx to allocate value_box_t in. - * @param[out] tail Where to write value_box_t (**). + * @param[in,out] ctx to allocate fr_value_box_t in. + * @param[out] tail Where to write fr_value_box_t (**). * @param[in] dst_type FreeRADIUS type to convert to. * @param[in] dst_enumv Enumeration values to allow string to integer conversions. * @param[in] object current node in the json tree. @@ -142,11 +142,11 @@ size_t fr_jpath_escape_func(UNUSED REQUEST *request, char *out, size_t outlen, c * - 0 on no match. * - -1 on error. */ -static int jpath_evaluate(TALLOC_CTX *ctx, value_box_t ***tail, +static int jpath_evaluate(TALLOC_CTX *ctx, fr_value_box_t ***tail, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, json_object *object, fr_jpath_node_t const *jpath) { - value_box_t *value; + fr_value_box_t *value; fr_jpath_node_t const *node; jpath_selector_t const *selector; bool child_matched = false; @@ -350,7 +350,7 @@ static int jpath_evaluate(TALLOC_CTX *ctx, value_box_t ***tail, * we now attempt conversion of the leaf to * the specified value. */ - value = talloc_zero(ctx, value_box_t); + value = talloc_zero(ctx, fr_value_box_t); if (fr_json_object_to_value_box(value, value, object, dst_type, dst_enumv) < 0) { talloc_free(value); return -1; @@ -362,11 +362,11 @@ static int jpath_evaluate(TALLOC_CTX *ctx, value_box_t ***tail, /** Evaluate a parsed jpath expression against a json-c tree * - * Will produce one or more value_box_t structures of the desired type, + * Will produce one or more fr_value_box_t structures of the desired type, * or error out if the conversion between types fails. * - * @param[in,out] ctx to allocate value_box_t in. - * @param[out] out Where to write value_box_t. + * @param[in,out] ctx to allocate fr_value_box_t in. + * @param[out] out Where to write fr_value_box_t. * @param[in] dst_type FreeRADIUS type to convert to. * @param[in] dst_enumv Enumeration values to allow string to integer conversions. * @param[in] root of the json-c tree. @@ -376,11 +376,11 @@ static int jpath_evaluate(TALLOC_CTX *ctx, value_box_t ***tail, * - 0 on no match. * - -1 on error. */ -int fr_jpath_evaluate_leaf(TALLOC_CTX *ctx, value_box_t **out, +int fr_jpath_evaluate_leaf(TALLOC_CTX *ctx, fr_value_box_t **out, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, json_object *root, fr_jpath_node_t const *jpath) { - value_box_t **tail = out; + fr_value_box_t **tail = out; *tail = NULL; diff --git a/src/modules/rlm_json/json.c b/src/modules/rlm_json/json.c index 7a1542d9ff6..d4533d3080f 100644 --- a/src/modules/rlm_json/json.c +++ b/src/modules/rlm_json/json.c @@ -28,7 +28,7 @@ #include #include "json.h" -/** Convert json object to value_box_t +/** Convert json object to fr_value_box_t * * @param[in] ctx to allocate any value buffers in (should usually be the same as out). * @param[in] out Where to write value_box. @@ -39,10 +39,10 @@ * - 0 on success. * - -1 on failure. */ -int fr_json_object_to_value_box(TALLOC_CTX *ctx, value_box_t *out, json_object *object, +int fr_json_object_to_value_box(TALLOC_CTX *ctx, fr_value_box_t *out, json_object *object, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv) { - value_box_t in; + fr_value_box_t in; memset(&in, 0, sizeof(in)); @@ -116,7 +116,7 @@ int fr_json_object_to_value_box(TALLOC_CTX *ctx, value_box_t *out, json_object * break; } - if (value_box_cast(ctx, out, dst_type, dst_enumv, &in) < 0) return -1; + if (fr_value_box_cast(ctx, out, dst_type, dst_enumv, &in) < 0) return -1; return 0; } @@ -126,7 +126,7 @@ int fr_json_object_to_value_box(TALLOC_CTX *ctx, value_box_t *out, json_object * * @param[in] ctx to allocate temporary buffers in * @param[in] data to convert. */ -json_object *json_object_from_value_box(TALLOC_CTX *ctx, value_box_t const *data) +json_object *json_object_from_value_box(TALLOC_CTX *ctx, fr_value_box_t const *data) { switch (data->type) { default: @@ -135,7 +135,7 @@ json_object *json_object_from_value_box(TALLOC_CTX *ctx, value_box_t const *data char *p; json_object *obj; - p = value_box_asprint(ctx, data, '\0'); + p = fr_value_box_asprint(ctx, data, '\0'); if (!p) return NULL; obj = json_object_new_string(p); diff --git a/src/modules/rlm_json/json.h b/src/modules/rlm_json/json.h index b0a5011cf53..d9ab8d211ec 100644 --- a/src/modules/rlm_json/json.h +++ b/src/modules/rlm_json/json.h @@ -49,7 +49,7 @@ typedef struct fr_jpath_node fr_jpath_node_t; size_t fr_jpath_escape_func(UNUSED REQUEST *request, char *out, size_t outlen, char const *in, UNUSED void *arg); -int fr_jpath_evaluate_leaf(TALLOC_CTX *ctx, value_box_t **out, +int fr_jpath_evaluate_leaf(TALLOC_CTX *ctx, fr_value_box_t **out, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, json_object *root, fr_jpath_node_t const *jpath); @@ -58,10 +58,10 @@ char *fr_jpath_asprint(TALLOC_CTX *ctx, fr_jpath_node_t const *head); ssize_t fr_jpath_parse(TALLOC_CTX *ctx, fr_jpath_node_t **head, char const *in, size_t inlen); /* json.c */ -int fr_json_object_to_value_box(TALLOC_CTX *ctx, value_box_t *out, json_object *object, +int fr_json_object_to_value_box(TALLOC_CTX *ctx, fr_value_box_t *out, json_object *object, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv); -json_object *json_object_from_value_box(TALLOC_CTX *ctx, value_box_t const *data); +json_object *json_object_from_value_box(TALLOC_CTX *ctx, fr_value_box_t const *data); char *fr_json_from_string(TALLOC_CTX *ctx, char const *s, bool include_quotes); diff --git a/src/modules/rlm_json/rlm_json.c b/src/modules/rlm_json/rlm_json.c index fb80015a309..3cccf9423ad 100644 --- a/src/modules/rlm_json/rlm_json.c +++ b/src/modules/rlm_json/rlm_json.c @@ -163,12 +163,12 @@ static int mod_map_proc_instantiate(CONF_SECTION *cs, UNUSED void *mod_inst, voi break; case TMPL_TYPE_DATA: - if (map->rhs->tmpl_value_box_type != FR_TYPE_STRING) { + if (map->rhs->tmpl_fr_value_box_type != FR_TYPE_STRING) { cf_log_err_cp(cp, "Right side of map must be a string"); return -1; } - p = map->rhs->tmpl_value_box_datum.strvalue; - slen = fr_jpath_parse(cache, &cache->jpath, p, map->rhs->tmpl_value_box_length); + p = map->rhs->tmpl_fr_value_box_datum.strvalue; + slen = fr_jpath_parse(cache, &cache->jpath, p, map->rhs->tmpl_fr_value_box_length); if (slen <= 0) goto error; break; @@ -207,7 +207,7 @@ static int _json_map_proc_get_value(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST * VALUE_PAIR *vp; vp_cursor_t cursor; rlm_json_jpath_to_eval_t *to_eval = uctx; - value_box_t *head, *value; + fr_value_box_t *head, *value; int ret; *out = NULL; @@ -232,7 +232,7 @@ static int _json_map_proc_get_value(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST * } vp->op = map->op; - if (value_box_steal(vp, &vp->data, value) < 0) { + if (fr_value_box_steal(vp, &vp->data, value) < 0) { RPEDEBUG("Copying data to attribute failed"); talloc_free(vp); goto error; diff --git a/src/modules/rlm_redis/redis.c b/src/modules/rlm_redis/redis.c index 9cbb8f96d24..6ad716a4a7d 100644 --- a/src/modules/rlm_redis/redis.c +++ b/src/modules/rlm_redis/redis.c @@ -168,7 +168,7 @@ void fr_redis_reply_print(log_lvl_t lvl, redisReply *reply, REQUEST *request, in } } -/** Convert a string or integer type to #value_box_t of specified type +/** Convert a string or integer type to #fr_value_box_t of specified type * * Will work with REDIS_REPLY_STRING (which is converted to #FR_TYPE_STRING * then cast to dst_type), or REDIS_REPLY_INTEGER (which is converted to @@ -188,10 +188,10 @@ void fr_redis_reply_print(log_lvl_t lvl, redisReply *reply, REQUEST *request, in * - 0 on success. * - -1 on cast or parse failure. */ -int fr_redis_reply_to_value_box(TALLOC_CTX *ctx, value_box_t *out, redisReply *reply, +int fr_redis_reply_to_value_box(TALLOC_CTX *ctx, fr_value_box_t *out, redisReply *reply, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv) { - value_box_t in; + fr_value_box_t in; memset(&in, 0, sizeof(in)); @@ -243,7 +243,7 @@ int fr_redis_reply_to_value_box(TALLOC_CTX *ctx, value_box_t *out, redisReply *r rad_assert(0); } - if (value_box_cast(ctx, out, dst_type, dst_enumv, &in) < 0) return -1; + if (fr_value_box_cast(ctx, out, dst_type, dst_enumv, &in) < 0) return -1; return 0; } @@ -312,7 +312,7 @@ int fr_redis_reply_to_map(TALLOC_CTX *ctx, vp_map_t **out, REQUEST *request, case REDIS_REPLY_STRING: case REDIS_REPLY_INTEGER: { - value_box_t vpt; + fr_value_box_t vpt; /* Logs own errors */ if (fr_redis_reply_to_value_box(map, &vpt, value, @@ -378,11 +378,11 @@ int fr_redis_tuple_from_map(TALLOC_CTX *pool, char const *out[], size_t out_len[ key = talloc_bstrndup(pool, key_buf, key_len); if (!key) return -1; - switch (map->rhs->tmpl_value_box_type) { + switch (map->rhs->tmpl_fr_value_box_type) { case FR_TYPE_STRING: case FR_TYPE_OCTETS: - out[2] = map->rhs->tmpl_value_box_datum.ptr; - out_len[2] = map->rhs->tmpl_value_box_length; + out[2] = map->rhs->tmpl_fr_value_box_datum.ptr; + out_len[2] = map->rhs->tmpl_fr_value_box_length; break; /* @@ -393,7 +393,7 @@ int fr_redis_tuple_from_map(TALLOC_CTX *pool, char const *out[], size_t out_len[ char value[256]; size_t len; - len = value_box_snprint(value, sizeof(value), &map->rhs->tmpl_value_box, '\0'); + len = fr_value_box_snprint(value, sizeof(value), &map->rhs->tmpl_value_box, '\0'); new = talloc_bstrndup(pool, value, len); if (!new) { talloc_free(key); diff --git a/src/modules/rlm_redis/redis.h b/src/modules/rlm_redis/redis.h index 5b013bb1195..adefc679513 100644 --- a/src/modules/rlm_redis/redis.h +++ b/src/modules/rlm_redis/redis.h @@ -119,7 +119,7 @@ fr_redis_rcode_t fr_redis_command_status(fr_redis_conn_t *conn, redisReply *repl void fr_redis_reply_print(log_lvl_t lvl, redisReply *reply, REQUEST *request, int idx); -int fr_redis_reply_to_value_box(TALLOC_CTX *ctx, value_box_t *out, redisReply *reply, +int fr_redis_reply_to_value_box(TALLOC_CTX *ctx, fr_value_box_t *out, redisReply *reply, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv); int fr_redis_reply_to_map(TALLOC_CTX *ctx, vp_map_t **out, diff --git a/src/modules/rlm_redis_ippool/rlm_redis_ippool.c b/src/modules/rlm_redis_ippool/rlm_redis_ippool.c index 18699f49e98..cc2b5b21a67 100644 --- a/src/modules/rlm_redis_ippool/rlm_redis_ippool.c +++ b/src/modules/rlm_redis_ippool/rlm_redis_ippool.c @@ -619,7 +619,7 @@ static ippool_rcode_t redis_ippool_allocate(rlm_redis_ippool_t const *inst, REQU if (reply->elements > 1) { vp_tmpl_t ip_rhs = { .type = TMPL_TYPE_DATA, - .tmpl_value_box_type = FR_TYPE_STRING + .tmpl_fr_value_box_type = FR_TYPE_STRING }; vp_map_t ip_map = { .lhs = inst->allocated_address_attr, @@ -637,30 +637,30 @@ static ippool_rcode_t redis_ippool_allocate(rlm_redis_ippool_t const *inst, REQU case REDIS_REPLY_INTEGER: { if (ip_map.lhs->tmpl_da->type != FR_TYPE_IPV4_ADDR) { - value_box_t tmp; + fr_value_box_t tmp; memset(&tmp, 0, sizeof(tmp)); tmp.datum.integer = ntohl((uint32_t)reply->element[1]->integer); tmp.type = FR_TYPE_INTEGER; - if (value_box_cast(NULL, &ip_map.rhs->tmpl_value_box, FR_TYPE_IPV4_ADDR, + if (fr_value_box_cast(NULL, &ip_map.rhs->tmpl_value_box, FR_TYPE_IPV4_ADDR, NULL, &tmp)) { RPEDEBUG("Failed converting integer to IPv4 address"); ret = IPPOOL_RCODE_FAIL; goto finish; } } else { - ip_map.rhs->tmpl_value_box_datum.integer = ntohl((uint32_t)reply->element[1]->integer); - ip_map.rhs->tmpl_value_box_type = FR_TYPE_INTEGER; + ip_map.rhs->tmpl_fr_value_box_datum.integer = ntohl((uint32_t)reply->element[1]->integer); + ip_map.rhs->tmpl_fr_value_box_type = FR_TYPE_INTEGER; } } goto do_ip_map; case REDIS_REPLY_STRING: - ip_map.rhs->tmpl_value_box_datum.strvalue = reply->element[1]->str; - ip_map.rhs->tmpl_value_box_length = reply->element[1]->len; - ip_map.rhs->tmpl_value_box_type = FR_TYPE_STRING; + ip_map.rhs->tmpl_fr_value_box_datum.strvalue = reply->element[1]->str; + ip_map.rhs->tmpl_fr_value_box_length = reply->element[1]->len; + ip_map.rhs->tmpl_fr_value_box_type = FR_TYPE_STRING; do_ip_map: if (map_to_request(request, &ip_map, map_to_vp, NULL) < 0) { @@ -690,7 +690,7 @@ static ippool_rcode_t redis_ippool_allocate(rlm_redis_ippool_t const *inst, REQU vp_tmpl_t range_rhs = { .name = "", .type = TMPL_TYPE_DATA, - .tmpl_value_box_type = FR_TYPE_STRING, + .tmpl_fr_value_box_type = FR_TYPE_STRING, .quote = T_DOUBLE_QUOTED_STRING }; vp_map_t range_map = { @@ -699,9 +699,9 @@ static ippool_rcode_t redis_ippool_allocate(rlm_redis_ippool_t const *inst, REQU .rhs = &range_rhs }; - range_map.rhs->tmpl_value_box_datum.strvalue = reply->element[2]->str; - range_map.rhs->tmpl_value_box_length = reply->element[2]->len; - range_map.rhs->tmpl_value_box_type = FR_TYPE_STRING; + range_map.rhs->tmpl_fr_value_box_datum.strvalue = reply->element[2]->str; + range_map.rhs->tmpl_fr_value_box_length = reply->element[2]->len; + range_map.rhs->tmpl_fr_value_box_type = FR_TYPE_STRING; if (map_to_request(request, &range_map, map_to_vp, NULL) < 0) { ret = IPPOOL_RCODE_FAIL; goto finish; @@ -727,7 +727,7 @@ static ippool_rcode_t redis_ippool_allocate(rlm_redis_ippool_t const *inst, REQU vp_tmpl_t expiry_rhs = { .name = "", .type = TMPL_TYPE_DATA, - .tmpl_value_box_type = FR_TYPE_STRING, + .tmpl_fr_value_box_type = FR_TYPE_STRING, .quote = T_DOUBLE_QUOTED_STRING }; vp_map_t expiry_map = { @@ -743,8 +743,8 @@ static ippool_rcode_t redis_ippool_allocate(rlm_redis_ippool_t const *inst, REQU goto finish; } - expiry_map.rhs->tmpl_value_box_datum.integer = reply->element[3]->integer; - expiry_map.rhs->tmpl_value_box_type = FR_TYPE_INTEGER; + expiry_map.rhs->tmpl_fr_value_box_datum.integer = reply->element[3]->integer; + expiry_map.rhs->tmpl_fr_value_box_type = FR_TYPE_INTEGER; if (map_to_request(request, &expiry_map, map_to_vp, NULL) < 0) { ret = IPPOOL_RCODE_FAIL; goto finish; @@ -771,7 +771,7 @@ static ippool_rcode_t redis_ippool_update(rlm_redis_ippool_t const *inst, REQUES fr_redis_rcode_t status; ippool_rcode_t ret = IPPOOL_RCODE_SUCCESS; - vp_tmpl_t range_rhs = { .name = "", .type = TMPL_TYPE_DATA, .tmpl_value_box_type = FR_TYPE_STRING, .quote = T_DOUBLE_QUOTED_STRING }; + vp_tmpl_t range_rhs = { .name = "", .type = TMPL_TYPE_DATA, .tmpl_fr_value_box_type = FR_TYPE_STRING, .quote = T_DOUBLE_QUOTED_STRING }; vp_map_t range_map = { .lhs = inst->range_attr, .op = T_OP_SET, .rhs = &range_rhs }; gettimeofday(&now, NULL); @@ -849,9 +849,9 @@ static ippool_rcode_t redis_ippool_update(rlm_redis_ippool_t const *inst, REQUES * Add range ID to request */ case REDIS_REPLY_STRING: - range_map.rhs->tmpl_value_box_datum.strvalue = reply->element[1]->str; - range_map.rhs->tmpl_value_box_length = reply->element[1]->len; - range_map.rhs->tmpl_value_box_type = FR_TYPE_STRING; + range_map.rhs->tmpl_fr_value_box_datum.strvalue = reply->element[1]->str; + range_map.rhs->tmpl_fr_value_box_length = reply->element[1]->len; + range_map.rhs->tmpl_fr_value_box_type = FR_TYPE_STRING; if (map_to_request(request, &range_map, map_to_vp, NULL) < 0) { ret = IPPOOL_RCODE_FAIL; goto finish; @@ -876,7 +876,7 @@ static ippool_rcode_t redis_ippool_update(rlm_redis_ippool_t const *inst, REQUES vp_tmpl_t expiry_rhs = { .name = "", .type = TMPL_TYPE_DATA, - .tmpl_value_box_type = FR_TYPE_STRING, + .tmpl_fr_value_box_type = FR_TYPE_STRING, .quote = T_DOUBLE_QUOTED_STRING }; vp_map_t expiry_map = { @@ -885,8 +885,8 @@ static ippool_rcode_t redis_ippool_update(rlm_redis_ippool_t const *inst, REQUES .rhs = &expiry_rhs }; - expiry_map.rhs->tmpl_value_box_datum.integer = expires; - expiry_map.rhs->tmpl_value_box_type = FR_TYPE_INTEGER; + expiry_map.rhs->tmpl_fr_value_box_datum.integer = expires; + expiry_map.rhs->tmpl_fr_value_box_type = FR_TYPE_INTEGER; if (map_to_request(request, &expiry_map, map_to_vp, NULL) < 0) { ret = IPPOOL_RCODE_FAIL; goto finish; @@ -1142,9 +1142,9 @@ static rlm_rcode_t mod_action(rlm_redis_ippool_t const *inst, REQUEST *request, .rhs = &ip_rhs }; - ip_rhs.tmpl_value_box_length = strlen(ip_str); - ip_rhs.tmpl_value_box_datum.strvalue = ip_str; - ip_rhs.tmpl_value_box_type = FR_TYPE_STRING; + ip_rhs.tmpl_fr_value_box_length = strlen(ip_str); + ip_rhs.tmpl_fr_value_box_datum.strvalue = ip_str; + ip_rhs.tmpl_fr_value_box_type = FR_TYPE_STRING; if (map_to_request(request, &ip_map, map_to_vp, NULL) < 0) return RLM_MODULE_FAIL; } diff --git a/src/modules/rlm_rest/rest.c b/src/modules/rlm_rest/rest.c index 64b755aa5f7..ac8e92c2286 100644 --- a/src/modules/rlm_rest/rest.c +++ b/src/modules/rlm_rest/rest.c @@ -899,7 +899,7 @@ static VALUE_PAIR *json_pair_make_leaf(UNUSED rlm_rest_t const *instance, UNUSED VALUE_PAIR *vp; - value_box_t src; + fr_value_box_t src; if (fr_json_object_is_type(leaf, json_type_null)) { RDEBUG3("Got null value for attribute \"%s\", skipping...", da->name); @@ -961,7 +961,7 @@ static VALUE_PAIR *json_pair_make_leaf(UNUSED rlm_rest_t const *instance, UNUSED src.datum.length = strlen(src.datum.strvalue); } - ret = value_box_cast(vp, &vp->data, da->type, da, &src); + ret = fr_value_box_cast(vp, &vp->data, da->type, da, &src); talloc_free(expanded); if (ret < 0) { RWDEBUG("Failed parsing value for attribute \"%s\" (skipping): %s", da->name, fr_strerror()); diff --git a/src/modules/rlm_rest/rlm_rest.c b/src/modules/rlm_rest/rlm_rest.c index 191c17b8225..51e5f430384 100644 --- a/src/modules/rlm_rest/rlm_rest.c +++ b/src/modules/rlm_rest/rlm_rest.c @@ -107,7 +107,7 @@ static int rlm_rest_status_update(REQUEST *request, void *handle) TALLOC_CTX *ctx; VALUE_PAIR **list; int code; - value_box_t value; + fr_value_box_t value; code = rest_get_handle_code(handle); diff --git a/src/modules/rlm_sometimes/rlm_sometimes.c b/src/modules/rlm_sometimes/rlm_sometimes.c index f94de203510..70c94568c4f 100644 --- a/src/modules/rlm_sometimes/rlm_sometimes.c +++ b/src/modules/rlm_sometimes/rlm_sometimes.c @@ -98,7 +98,7 @@ static rlm_rcode_t sometimes_return(void const *instance, REQUEST *request, RADI return RLM_MODULE_FAIL; default: - hash = fr_hash(&vp->data.datum, value_box_field_sizes[vp->vp_type]); + hash = fr_hash(&vp->data.datum, fr_value_box_field_sizes[vp->vp_type]); break; } hash &= 0xff; /* ensure it's 0..255 */