* @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.
*
* @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.
#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*/
// 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
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);
* - 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);
/*
* 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
* @{
*/
#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
@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
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,
* $Id$
*
* @file include/types.h
- * @brief #value_box_t types
+ * @brief #fr_value_box_t types
*
* @copyright 2017 The FreeRADIUS server project
*/
#include <freeradius-devel/types.h>
#include <freeradius-devel/dict.h>
-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
*
*
* 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 {
/*
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 */
* @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;
/** 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,
* - 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;
*/
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;
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);
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;
* 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
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;
*/
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);
{
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;
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)) {
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;
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;
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;
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
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
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);
*
* 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 <a.cudbardb@freeradius.org>
#include <freeradius-devel/rad_assert.h>
#include <ctype.h>
-/** 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},
[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.
};
* @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;
*
* @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:
* @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:
* - 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;
*
* 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)
{
* - 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;
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:
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);
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:
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);
default:
cmp:
- compare = value_box_cmp(a, b);
+ compare = fr_value_box_cmp(a, b);
if (compare < -1) { /* comparison error */
return -1;
}
/** 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;
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 */
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:
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;
}
* @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;
* 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;
}
* @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;
* 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;
* @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;
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;
* @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;
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;
* @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;
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;
* @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:
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;
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)
* - 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;
/*
* 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
*/
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
}
/*
- * 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) &&
}
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, "<INVALID>"),
fr_int2str(dict_attr_types, dst_type, "<INVALID>"),
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, "<INVALID>"),
fr_int2str(dict_attr_types, dst_type, "<INVALID>"),
src->datum.length,
- value_box_network_sizes[dst_type][1]);
+ fr_value_box_network_sizes[dst_type][1]);
return -1;
}
* 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.
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;
/** 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.
* - 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:
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.
* - 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:
{
return -1;
}
dst->datum.strvalue = str;
- value_box_copy_meta(dst, src);
+ fr_value_box_copy_meta(dst, src);
}
return 0;
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;
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.
*
* - 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;
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.
*
* - 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;
* - 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;
* - 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;
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.
*
* - 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;
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.
*
* - 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.
*
* - 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;
* - 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;
* - 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);
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.
* - 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;
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.
*
* - 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)
{
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;
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);
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);
}
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);
}
* - 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;
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);
{
int rcode;
int modcode;
- value_box_t data;
+ fr_value_box_t data;
switch (vpt->type) {
case TMPL_TYPE_UNPARSED:
* - 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;
#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) {
* - 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;
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;
}
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:
* - 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;
EVAL_DEBUG("CASTING " #_s " FROM %s TO %s",\
fr_int2str(dict_attr_types, _s->type, "<INVALID>"),\
fr_int2str(dict_attr_types, cast_type, "<INVALID>"));\
- 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;\
EVAL_DEBUG("NORMALISATION TYPE %s (IMPLICIT FROM RHS REF)",
fr_int2str(dict_attr_types, cast->type, "<INVALID>"));
} 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, "<INVALID>"));
} 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, "<INVALID>"));
}
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;
{
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);
/*
* 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;
*/
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;
}
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");
}
* 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.
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
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);
/*
* 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);
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);
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;
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);
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;
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);
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);
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;
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;
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);
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);
}
-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);
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;
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;
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;
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;
case PW_FREERADIUS_SNMP_OPERATION_VALUE_GET:
{
- value_box_t data;
+ fr_value_box_t data;
memset(&data, 0, sizeof(data));
* 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);
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.
* - 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;
}
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:
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);
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);
* 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,
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);
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;
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
{
int rcode;
VALUE_PAIR *vp;
- value_box_t data;
+ fr_value_box_t data;
char *p;
VERIFY_TMPL(vpt);
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;
}
*
* @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
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;
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;
/*
* 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) {
}
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;
}
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;
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");
*
* @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;
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");
*
* @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;
* 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) {
}
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
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;
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);
* 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,
"<INVALID>"), map->lhs->tmpl_da->name);
return -1;
}
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;
*/
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;
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);
}
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++;
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;
}
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;
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) {
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);
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;
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;
* Encode the entry created date
*/
tmpl_init(&created_value, TMPL_TYPE_DATA, "<TEMP>", 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
* to ignore entries that were created before the last epoch.
*/
tmpl_init(&expires_value, TMPL_TYPE_DATA, "<TEMP>", 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);
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;
(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;
}
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,
*/
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;
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);
}
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;
* 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.
* - 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;
* 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:
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;
}
}
#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; \
}
/** 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.
* - 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;
* 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;
/** 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.
* - 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;
#include <freeradius-devel/rad_assert.h>
#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.
* - 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));
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;
}
* @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:
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);
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);
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);
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;
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;
}
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;
}
}
-/** 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
* - 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));
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;
}
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,
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;
/*
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);
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,
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,
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) {
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 = {
.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;
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 = {
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;
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);
* 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;
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 = {
.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;
.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;
}
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);
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());
TALLOC_CTX *ctx;
VALUE_PAIR **list;
int code;
- value_box_t value;
+ fr_value_box_t value;
code = rest_get_handle_code(handle);
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 */