23RCSID(
"$Id: 9aa3c64e83f4569f6b5d9e3557fb0983559f9d72 $")
25#include <freeradius-devel/util/stats.h>
61 memcpy(&str, field,
sizeof(str));
83 memcpy(&
vp->vp_date, field,
sizeof(
vp->vp_date));
87 memcpy(&
vp->vp_time_delta, field,
sizeof(
vp->vp_time_delta));
124 memset(
out, 0,
inst->def->size);
147 memcpy(&field, &str,
sizeof(str));
154 memcpy(field,
vp->vp_ptr,
vp->vp_length);
161#define COPY(_type, _field) \
163 memcpy(field, &vp->vp_ ## _field, sizeof(vp->vp_ ##_field)); \
187#define add(_type, _out, _in) \
189 _type _a, _b, _sum; \
190 memcpy(&_a, &_out, sizeof(_a)); \
191 memcpy(&_b, &_in, sizeof(_b)); \
193 memcpy(&_out, &_sum, sizeof(_sum)); \
222 add(uint64_t, field_out, field_in);
243 if (
out->def !=
in->def) {
244 fr_strerror_printf(
"Cannot merge stats into structure %s from different structure %s",
245 out->def->name,
in->def->name);
262 if (dst->type != src->type) {
267 if (dst->enumv != src->enumv) {
284 dst->vb_uint16 += src->vb_uint16;
288 dst->vb_uint32 += src->vb_uint32;
292 dst->vb_uint64 += src->vb_uint64;
324 if (iter->
current < iter->
inst->def->num_elements) {
350 if (index >=
inst->def->num_elements) {
356 da = *(
inst->def->entry[index].da_p);
362 field = ((
uint8_t const *)
inst->stats) +
inst->def->entry[index].offset;
366 if (!
inst->def->entry[index].size) {
369 memcpy(&str, field,
sizeof(str));
377 end = memchr(field,
'\0',
inst->def->entry[index].size);
378 len = (
size_t) (end - field);
388 len =
inst->def->entry[index].size;
#define FALL_THROUGH
clang 10 doesn't recognised the FALL-THROUGH comment anymore
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
fr_dict_attr_t const * fr_dict_attr_by_name(fr_dict_attr_err_t *err, fr_dict_attr_t const *parent, char const *attr))
Locate a fr_dict_attr_t by its name.
fr_dict_attr_t const ** root_p
point to the autoload definition of the DA for this structure
size_t size
size of this field
fr_type_t type
cached for locality and simplicity
size_t offset
from the start of the struct
fr_stats_link_entry_t entry[]
the field entries, in offset order
size_t num_elements
number of elements in the table. Note no "NULL" terminator
fr_dict_attr_t const ** da_p
point to the autoload definition of the DA for this field
fr_stats_instance_t const * inst
Generic statistics structure.
Iterator for a statistics structure.
@ FR_TYPE_TIME_DELTA
A period of time measured in nanoseconds.
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_UINT16
16 Bit unsigned integer.
@ FR_TYPE_DATE
Unix time stamp, always has value >2^31.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_UINT64
64 Bit unsigned integer.
@ FR_TYPE_IPV6_ADDR
128 Bit IPv6 Address.
@ FR_TYPE_OCTETS
Raw octets.
int fr_pair_value_strdup(fr_pair_t *vp, char const *src, bool tainted)
Copy data into an "string" data type.
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
fr_pair_t * fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Dynamically allocate a new attribute and assign a fr_dict_attr_t.
eap_aka_sim_process_conf_t * inst
eap_type_t type
The preferred EAP-Type of this instance of the EAP-SIM/AKA/AKA' state machine.
Stores an attribute, a value and various bits of other data.
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
char * talloc_bstrndup(TALLOC_CTX *ctx, char const *in, size_t inlen)
Binary safe strndup function.
#define add(_type, _out, _in)
void fr_stats_iter_init(fr_stats_instance_t const *inst, fr_stats_iter_t *iter)
Initialize an iterator over a structure.
#define COPY(_type, _field)
int fr_stats_iter_to_value_box(TALLOC_CTX *ctx, fr_value_box_t **out, fr_stats_iter_t *iter)
Convert the statistic at the current iterator to a value-box.
bool fr_stats_iter_next(fr_stats_iter_t *iter)
Go to the next entry in a structure.
int fr_stats_index_to_value_box(TALLOC_CTX *ctx, fr_value_box_t **out, fr_stats_instance_t const *inst, unsigned int index)
Convert the statistic at an index to a value-box.
static int stats_merge_internal(fr_stats_link_t const *def, void *out, void const *in)
Merge to statistics structures.
int fr_stats_merge_instance(fr_stats_instance_t *out, fr_stats_instance_t const *in)
Public API for merging two statistics structures.
int fr_stats_from_pairs(TALLOC_CTX *ctx, fr_stats_instance_t *inst, fr_pair_list_t const *list)
Convert a statistics structure to fr_pair_t.
int fr_stats_merge_value_box(fr_value_box_t *dst, fr_value_box_t const *src)
Public API for merging two value-boxes based on their enums.
int fr_stats_to_pairs(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_stats_instance_t const *inst)
Convert a statistics structure to fr_pair_t.
int fr_stats_name_to_value_box(TALLOC_CTX *ctx, fr_value_box_t **out, fr_stats_instance_t const *inst, char const *name)
Convert the statistic of a given name to a value-box.
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
#define fr_strerror_const(_msg)
static char const * fr_type_to_str(fr_type_t type)
Return a static string containing the type name.
ssize_t fr_value_box_from_network(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t type, fr_dict_attr_t const *enumv, fr_dbuff_t *dbuff, size_t len, bool tainted)
Decode a fr_value_box_t from serialized binary data.
ssize_t fr_value_box_from_memory(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t type, fr_dict_attr_t const *enumv, void const *src, size_t len)
Decode a fr_value_box_t from a C type in memory.
#define fr_value_box_alloc(_ctx, _type, _enumv)
Allocate a value box of a specific type.
static size_t char ** out