UniRec  2.9.3
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
unirec.h File Reference

Definition of UniRec structures and functions. More...

#include <stdint.h>
#include "ipaddr.h"
#include "macaddr.h"
#include "ur_time.h"
#include "links.h"
#include "ur_values.h"
#include <libtrap/trap.h>

Go to the source code of this file.

Data Structures

struct  ur_field_id_linked_list_t
 Linked list for undefined field ids Linked list consisting of field ids, which are freed after operation undefine. More...
 
struct  ur_static_field_specs_t
 UniRec default field list It contains all fields which are specified statically in source code of a module. This structure is passed to ur_init() More...
 
struct  ur_field_specs_t
 UniRec fields structure It contains all fields which are statically defined by UR_FIELDS(...) and run-time generated fields. This structure can be modified during run-time by generating new fields and erasing existing fields. More...
 
struct  field_spec_t
 Sorting fields structure This structure is used to sort fields by their size and name. The structure is passed to the sorting algorithm. More...
 
struct  ur_template_t
 UniRec template. It contains a table mapping a field to its position in an UniRec record. More...
 

Macros

#define __STDC_LIMIT_MACROS
 
#define UR_DEFAULT_LENGTH_OF_TEMPLATE   1024
 
#define UR_DEFAULT_LENGTH_OF_FIELD_NAME   128
 
#define UR_DEFAULT_LENGTH_OF_FIELD_TYPE   16
 
#define UR_INITIAL_SIZE_FIELDS_TABLE   5
 Initial size of free space in fields tables. More...
 
#define UR_FIELD_ID_MAX   INT16_MAX
 Max ID of a field. More...
 
#define UR_FIELDS(...)
 Definition of UniRec fields. More...
 
#define UR_ARRAY_DELIMITER   ' '
 Delimiter of array elements in string. More...
 
#define UR_ARRAY_ALLOC   10
 Default alloc size increment for ur_set_array_from_string. More...
 
#define UR_ITER_BEGIN   (-1)
 First value in iterating through the fields. More...
 
#define UR_ITER_END   INT16_MAX
 Last value in iterating through the fields. More...
 
#define UR_INVALID_OFFSET   0xffff
 Default value of all offsets (value is not in the record) More...
 
#define UR_NO_DYNAMIC_VALUES   0xffff
 Value of variable "first_dynamic" if no dynamic values are present. More...
 
#define UR_UNINITIALIZED   0
 Indicator if the UniRec has not been initialized by calling function ur_init. More...
 
#define UR_INITIALIZED   1
 Indicator if the UniRec has been initialized by calling function ur_init. More...
 
#define UR_INVALID_FIELD   ((ur_field_id_t) 0xffff)
 ID of invalid field. More...
 
#define UR_E_INVALID_PARAMETER   -6
 The given parameter is wrong. More...
 
#define UR_E_INVALID_FIELD_ID   -5
 The field ID is not present in a template. More...
 
#define UR_E_TYPE_MISMATCH   -4
 The type of a field is different. More...
 
#define UR_E_INVALID_NAME   -3
 The given name is not present in a template. More...
 
#define UR_E_INVALID_TYPE   -2
 The type of a field is not defined. More...
 
#define UR_E_MEMORY   -1
 Problem during allocating memory. More...
 
#define UR_OK   0
 No problem. More...
 
#define UR_COUNT_OF_TYPES   29
 Constants for all possible types of UniRec fields. More...
 
#define TRAP_RECEIVE(ifc_num, data, data_size, tmplt)   TRAP_CTX_RECEIVE(trap_get_global_ctx(), ifc_num, data, data_size, tmplt);
 Receive data from interface Receive data with specified template from libtrap interface. If the receiving template is subset of sending template, it will define new fields and expand receiving template. More...
 
#define TRAP_CTX_RECEIVE(ctx, ifc_num, data, data_size, tmplt)
 Receive data from interface with given context Receive data with specified template from libtrap interface with specified context. If the receiving template is subset of sending template, it will define new fields and expand receiving template. More...
 
#define ur_template_string(tmplt)   ur_template_string_delimiter(tmplt, ',')
 Get string of a template Get names and sizes of fields separated by comma. Return string has to be freed by user. More...
 
#define ur_size_of(type)   ur_field_type_size[type]
 Get size of UniRec type Get size of fixed-length UniRec type. For variable-length type return value < 0. More...
 
#define ur_get_name(field_id)   ur_field_specs.ur_field_names[field_id]
 Get name of UniRec field Get name of any UniRec defined field. More...
 
#define ur_get_type(field_id)   ur_field_specs.ur_field_types[field_id]
 Get type of UniRec field Get type of any UniRec defined field. More...
 
#define ur_get_size(field_id)   ur_field_specs.ur_field_sizes[field_id]
 Get size of UniRec field Get size of a fixed-length UniRec field. When variable-length field is passed, return value < 0. To get real length of a variable-length field use ur_get_var_len. More...
 
#define ur_get(tmplt, data, field_id)   (*(field_id ## _T*)((char *)(data) + (tmplt)->offset[field_id]))
 Get value of UniRec field Get value of a fixed-length UniRec field. For variable-length fields, use ur_get_ptr or ur_get_ptr_by_id. More...
 
#define ur_get_ptr(tmplt, data, field_id)
 Get pointer to UniRec field Get pointer to fixed or varible length statically defined UniRec field. For dynamically defined fields, use ur_get_ptr_by_id. More...
 
#define ur_get_ptr_by_id(tmplt, data, field_id)
 Get pointer to UniRec field Get pointer to fixed or varible length UniRec field. In contrast to ur_get_ptr, field_id may be a variable (not only F_ token). Returned pointer is always void *. More...
 
#define ur_set(tmplt, data, field_id, value)   (*(field_id ## _T*)((char *)(data) + (tmplt)->offset[field_id]) = (value))
 Set value of UniRec (static) field Set value of a fixed-length UniRec field. For variable-length fields, use ur_set_var. More...
 
#define ur_get_var_offset(tmplt, rec, field_id)   *((uint16_t *)((char *) rec + tmplt->offset[field_id]))
 Get offset of variable-length field in the record. Get offset of a specified variable-length field in the record. Given field has to be part of the record. More...
 
#define ur_get_var_len(tmplt, rec, field_id)   *((uint16_t *)((char *) rec + tmplt->offset[field_id] + 2))
 Get size of a variable sized field in the record. Get size of a variable-length field in the record. Given field has to be part of the record. More...
 
#define ur_set_var_len(tmplt, rec, field_id, len)   *((uint16_t *)((char *) rec + tmplt->offset[field_id] + 2)) = (uint16_t) len
 Set size of variable-length field in the record. Set size of specified variable-length field in the record. Field has to be part of the record. It does not move other variable sized records. It just sets given value to the right position in the record. More...
 
#define ur_set_var_offset(tmplt, rec, field_id, offset_val)   *((uint16_t *)((char *) rec + tmplt->offset[field_id])) = (uint16_t) offset_val
 Set offset of variable-length field in the record. Set offset of specified variable-length field in the record. Field has to be part of the record. It does not move other variable sized records. It just sets given value to the right position in the record. More...
 
#define ur_get_len(tmplt, rec, field)   ur_is_static(field) ? ur_get_size(field) : ur_get_var_len(tmplt, rec, field)
 Get length of UniRec field Get actual length of fixed or variable-length UniRec field. More...
 
#define ur_set_string(tmplt, rec, field_id, str)   ur_set_var(tmplt, rec, field_id, str, strlen(str))
 Set variable-length field to given string. Set contents of a variable-length field in the record. Field has to be part of the record. It copies string terminated with \0 and safely moves other variable-length records. More...
 
#define ur_is_array(field_id)   (ur_field_type_size[ur_get_type(field_id)] < 0 ? 1 : 0)
 
#define ur_array_get_elem_size(field_id)   (ur_field_type_size[ur_get_type(field_id)] < 0 ? -ur_field_type_size[ur_get_type(field_id)] : ur_field_type_size[ur_get_type(field_id)])
 Get size of a single element of UniRec field. More...
 
#define ur_array_get_elem_cnt(tmplt, rec, field_id)   (ur_get_var_len(tmplt, rec, field_id) / ur_array_get_elem_size(field_id))
 Get number of elements stored in an UniRec array. More...
 
#define ur_array_get_elem_type(field_id)   ur_field_array_elem_type[ur_get_type(field_id)]
 Get type of an element stored in an UniRec array. More...
 
#define ur_array_set(tmplt, rec, field_id, index, element)
 Set element to array at given index. Automatically resizes array when index is out of array bounds. Set contents of a variable-length field in the record. Field has to be part of the record. More...
 
#define ur_array_append(tmplt, rec, field_id, element)
 Set element to array at last position. Automatically resizes array. More...
 
#define ur_array_clear(tmplt, rec, field_id)   ur_array_resize(tmplt, rec, field_id, 0)
 Clear contents of an UniRec array. Array is resized to 0 elements. More...
 
#define ur_array_get(tmplt, rec, field_id, index)   ((field_id ## _T)((char *)(ur_get_ptr_by_id(tmplt, rec, field_id))))[index]
 Get element of an array field at given index. More...
 
#define ur_array_allocate(tmplt, rec, field_id, elem_cnt)   ur_array_resize(tmplt, rec, field_id, (elem_cnt) * ur_array_get_elem_size(field_id))
 Preallocates UniRec array field to have requested number of elements. More...
 
#define ur_is_present(tmplt, field_id)   ((tmplt)->offset_size > (field_id) && (tmplt)->offset[(field_id)] != UR_INVALID_OFFSET)
 Is given field present in given template? Return true (non-zero value) if given template contains field with given ID. More...
 
#define ur_is_varlen(field_id)   (ur_field_specs.ur_field_sizes[field_id] < 0)
 Is given field variable-length? Return true (non-zero value) if given ID refers to a field with variable length. More...
 
#define ur_is_dynamic(field_id)   ur_is_varlen(field_id)
 Alias for ur_is_varlen (for backwards compatibility only) More...
 
#define ur_is_fixlen(field_id)   (ur_field_specs.ur_field_sizes[field_id] >= 0)
 Is given field fixed-length? Return true (non-zero value) if given ID refers to a field with fixed length. More...
 
#define ur_is_static(field_id)   ur_is_fixlen(field_id)
 Alias for ur_is_fixlen (for backwards compatibility only) More...
 
#define ur_rec_fixlen_size(tmplt)   ((tmplt)->static_size)
 Get size of fixed-length part of UniRec record Get total size of UniRec record except variable-length fields. More...
 
#define ur_rec_size(tmplt, rec)   (ur_rec_fixlen_size(tmplt) + ur_rec_varlen_size(tmplt, rec))
 Get size of UniRec record (static and variable length) Get total size of whole UniRec record. More...
 
#define ur_create_input_template(ifc, fields, errstr)   ur_ctx_create_input_template(trap_get_global_ctx(), ifc, fields, errstr);
 Create UniRec template and set it to input interface Creates UniRec template (same like ur_create_template) and set this template to input interface of a module. More...
 
#define ur_create_output_template(ifc, fields, errstr)   ur_ctx_create_output_template(trap_get_global_ctx(), ifc, fields, errstr);
 Create UniRec template and set it to output interface Creates UniRec template (same like ur_create_template) and set this template to ouput interface of a module. More...
 
#define ur_set_output_template(ifc, tmplt)   ur_ctx_set_output_template(trap_get_global_ctx(), ifc, tmplt)
 Set UniRec template to ouput interface. More...
 
#define ur_set_input_template(ifc, tmplt)   ur_ctx_set_input_template(trap_get_global_ctx(), ifc, tmplt)
 Set UniRec template to input interface. More...
 
#define ur_create_bidirectional_template(ifc_in, ifc_out, fields, errstr)   ur_ctx_create_bidirectional_template(trap_get_global_ctx(), ifc_in, ifc_out, fields, errstr);
 Create UniRec template and set it to input and output interface Creates UniRec template (same like ur_create_template) and set this template to input and ouput interface of a module. More...
 
#define UR_MAX_SIZE   0xffff
 
#define ur_cpy(tmplt, src, dst)   (memcpy(dst,src,ur_rec_size(tmplt,src)))
 Copy data from one UniRec to another. Procedure gets template and void pointer of source and destination. Then it copies the data defined by the given template. The destination pointer must have required space allocated. More...
 
#define ur_values_get_name(field, value)   ur_values_get_name_start_end(UR_TYPE_START_ ## field, UR_TYPE_END_ ## field, value)
 Returns name of specified value This function returns name of specified value and field, which is defined in values file. More...
 
#define ur_values_get_description(field, value)   ur_values_get_description_start_end(UR_TYPE_START_ ## field, UR_TYPE_END_ ## field, value)
 Returns description of specified value This function returns description of specified value and field, which is defined in values file. More...
 

Typedefs

typedef int16_t ur_field_id_t
 Type of UniRec field identifiers. More...
 
typedef ur_field_id_t ur_iter_t
 Type for identifying iteration id through all fields. More...
 

Enumerations

enum  ur_field_type_t {
  UR_TYPE_STRING, UR_TYPE_BYTES, UR_TYPE_CHAR, UR_TYPE_UINT8,
  UR_TYPE_INT8, UR_TYPE_UINT16, UR_TYPE_INT16, UR_TYPE_UINT32,
  UR_TYPE_INT32, UR_TYPE_UINT64, UR_TYPE_INT64, UR_TYPE_FLOAT,
  UR_TYPE_DOUBLE, UR_TYPE_IP, UR_TYPE_MAC, UR_TYPE_TIME,
  UR_TYPE_A_UINT8, UR_TYPE_A_INT8, UR_TYPE_A_UINT16, UR_TYPE_A_INT16,
  UR_TYPE_A_UINT32, UR_TYPE_A_INT32, UR_TYPE_A_UINT64, UR_TYPE_A_INT64,
  UR_TYPE_A_FLOAT, UR_TYPE_A_DOUBLE, UR_TYPE_A_IP, UR_TYPE_A_MAC,
  UR_TYPE_A_TIME
}
 
enum  ur_tmplt_direction { UR_TMPLT_DIRECTION_NO, UR_TMPLT_DIRECTION_IN, UR_TMPLT_DIRECTION_OUT, UR_TMPLT_DIRECTION_BI }
 

Functions

char * ur_template_string_delimiter (const ur_template_t *tmplt, int delimiter)
 Get UniRec specifier of the tmplt template with delimiter between fields. More...
 
int ur_get_field_type_from_str (const char *type)
 
char * ur_array_append_get_ptr (const ur_template_t *tmplt, void *rec, int field_id)
 Allocate new element at the end of array and return its pointer. More...
 
int ur_init (ur_static_field_specs_t field_specs_static)
 Initialize UniRec structures Initialize UniRec structures. Function is called during defining first own field. More...
 
int ur_get_empty_id ()
 Return first empty id for new UniRec field Return first empty id for new UniRec field. If there is no space in the UniRec structures, it will increase space in the existing structures. More...
 
int ur_define_field (const char *name, ur_field_type_t type)
 Define new UniRec field Define new UniRec field at run-time. It adds new field into existing structures. If the field already exists (name and type are equal) it only returns its ID. More...
 
int ur_define_set_of_fields (const char *ifc_data_fmt)
 Define set of new UniRec fields Define new UniRec fields at run-time. It adds new fields into existing structures. If the field already exists and type is equal nothing will happen. If the type is not equal an error will be returned. Example ifc_data_fmt: "uint32 FOO,uint8 BAR,float FOO2". More...
 
int ur_undefine_field_by_id (ur_field_id_t field_id)
 Undefine UniRec field by its id Undefine UniRec field created at run-time. It erases given field from UniRec structures and the field ID can be used for another field. By undefining field, all templates which were using the undefined field, has to be recreated. More...
 
int ur_undefine_field (const char *name)
 Undefine UniRec field by its name Undefine UniRec field created at run-time. It erases given field from UniRec structures and the field ID can be used for another field. By undefining field, all templates which were using the undefined field, has to be recreated. More...
 
void ur_finalize ()
 Deallocate UniRec structures Deallocate UniRec structures at the end of a program. This function SHOULD be called after all UniRec functions and macros invocations, typically during a cleanup phase before the program's end. This function has to be called if some fields are defined during run-time, otherwise this function is needless. More...
 
int ur_get_id_by_name (const char *name)
 Get ID of a field by its name Get ID of a field by its name. More...
 
int compare_fields (const void *field1, const void *field2)
 Compare fields Compare two fields. This function is for sorting the fields in the right order. First by sizes (larger first) and then by names. More...
 
ur_template_tur_create_template (const char *fields, char **errstr)
 Create UniRec template Create new UniRec template specified by a string containing names of its fields separated by commas. Example spec-string: "SRC_IP,DST_IP,SRC_PORT,DST_PORT,PROTOCOL,PACKETS" Order of fields is not important (templates with the same set of fields are equivalent). Template created by this function should be destroyed by ur_free_template. More...
 
ur_template_tur_ctx_create_output_template (trap_ctx_t *ctx, int ifc, const char *fields, char **errstr)
 Create UniRec template and set it to output interface on specified context Creates UniRec template, same like ur_create_output_template, but context is specified. More...
 
ur_template_tur_ctx_create_input_template (trap_ctx_t *ctx, int ifc, const char *fields, char **errstr)
 Create UniRec template and set it to input interface on specified context Creates UniRec template, same like ur_create_input_template, but context is specified. More...
 
int ur_ctx_set_output_template (trap_ctx_t *ctx, int ifc, ur_template_t *tmplt)
 Set UniRec template to ouput interface on specified context. More...
 
int ur_ctx_set_input_template (trap_ctx_t *ctx, int ifc, ur_template_t *tmplt)
 Set UniRec template to input interface on specified context. More...
 
ur_template_tur_ctx_create_bidirectional_template (trap_ctx_t *ctx, int ifc_in, int ifc_out, const char *fields, char **errstr)
 Create UniRec template and set it to input and output interface on specified context Creates UniRec template, same like ur_create_bidirectional_template, but context is specified. More...
 
ur_template_tur_expand_template (const char *ifc_data_fmt, ur_template_t *tmplt)
 Expand UniRec template Expand existing UniRec template by a string containing types and names of its fields separated by commas. Example ifc_data_fmt: "uint32 FOO,uint8 BAR,float FOO2" Order of fields is not important (templates with the same set of fields are equivalent). In case of success the given template will be destroyed and new template will be returned. More...
 
ur_template_tur_define_fields_and_update_template (const char *ifc_data_fmt, ur_template_t *tmplt)
 Defined new fields and expand an UniRec template Define new fields (function ur_define_set_of_fields) and create new UniRec template (function ur_create_template_from_ifc_spec). The string describing fields contain types and names of fields separated by commas. Example ifc_data_fmt: "uint32 FOO,uint8 BAR,float FOO2" Order of fields is not important (templates with the same set of fields are equivalent). In case of success the given template will be destroyed and new template will be returned. More...
 
ur_template_tur_create_template_from_ifc_spec (const char *ifc_data_fmt)
 Create UniRec template from data format string. Creates new UniRec template (function ur_create_template_from_ifc_spec). The string describing fields contain types and names of fields separated by commas. Example ifc_data_fmt: "uint32 FOO,uint8 BAR,float FOO2" Order of fields is not important (templates with the same set of fields are equivalent).. More...
 
void ur_free_template (ur_template_t *tmplt)
 Destroy UniRec template Free all memory allocated for a template created previously by ur_create_template. More...
 
int ur_template_compare (const ur_template_t *tmpltA, const ur_template_t *tmpltB)
 Compares fields of two UniRec templates Function compares only sets of UniRec fields (direction is not compared). More...
 
void ur_print_template (ur_template_t *tmplt)
 Print UniRec template Print static_size, first_dynamic and table of offsets to stdout (for debugging). If template does not contain any dynamic fields, print '-' instead. param[in] tmplt pointer to the template. More...
 
int ur_set_var (const ur_template_t *tmplt, void *rec, int field_id, const void *val_ptr, int val_len)
 Set content of variable-length UniRec field Copy given data into variable-length UniRec field, set its offset and length in a record and move data which are behind this field. For better performance use function ur_clear_varlen, before setting all variable fields in record. More...
 
int ur_array_resize (const ur_template_t *tmplt, void *rec, int field_id, int len)
 Change length of a array field. More...
 
void ur_clear_varlen (const ur_template_t *tmplt, void *rec)
 Clear variable-length part of a record. For better performance of setting content to variable-length fields, use this function before setting of all the variable-length fields. This function will clear all the variable-length fields, so they don't have to be moved in memory during setting of them. More...
 
uint16_t ur_rec_varlen_size (const ur_template_t *tmplt, const void *rec)
 Get size of variable sized part of UniRec record Get total size of all variable-length fields in an UniRec record. More...
 
void * ur_create_record (const ur_template_t *tmplt, uint16_t max_var_size)
 
void ur_free_record (void *record)
 
char * ur_get_var_as_str (const ur_template_t *tmplt, const void *rec, ur_field_id_t field_id)
 Get variable-length UniRec field as a C string Copy data of a variable-length field from UniRec record and append '\0' character. The function allocates new memory space for the string, it must be freed using free()! More...
 
void ur_copy_fields (const ur_template_t *dst_tmplt, void *dst, const ur_template_t *src_tmplt, const void *src)
 Copy data from one UniRec record to another. Copies all fields present in both templates from src to dst. The function compares src_tmplt and dst_tmplt and for each field present in both templates it sets the value of field in dst to a corresponding value in src. "dst" must point to a memory of enough size. More...
 
void * ur_clone_record (const ur_template_t *tmplt, const void *src)
 Create new UniRec and copy the source UniRec into it. Function creates new UniRec record and fills it with the data given by parameter. More...
 
ur_iter_t ur_iter_fields (const ur_template_t *tmplt, ur_iter_t id)
 Iterate over fields of a template in order of a record This function can be used to iterate over all fields of a given template. It returns ID of the next field present in the template after a given ID. If ID is set to UR_ITER_BEGIN, it returns the first fields. If no more fields are present, UR_ITER_END is returned. Example usage: ur_field_id_t id = UR_ITER_BEGIN while ((id = ur_iter_fields(&tmplt, id)) != UR_ITER_END) { ... } The order of fields is given by the order in which they are defined. More...
 
ur_iter_t ur_iter_fields_record_order (const ur_template_t *tmplt, int index)
 Iterate over fields of a template This function can be used to iterate over all fields of a given template. It returns n-th ID of a record specified by index. If the return value is UR_ITER_END. The index is higher than count of fields in the template. Example usage: int i = 0; while ((id = ur_iter_fields(&tmplt, i++)) != UR_ITER_END) { ... } The order of fields is given by the order in the record. More...
 
int ur_set_array_from_string (const ur_template_t *tmpl, void *data, ur_field_id_t f_id, const char *v)
 Set value of a UniRec array field. More...
 
int ur_set_from_string (const ur_template_t *tmpl, void *data, ur_field_id_t f_id, const char *v)
 Set value of a UniRec field. More...
 
char * ur_ifc_data_fmt_to_field_names (const char *ifc_data_fmt)
 Parses field names from data format Function parses field names from data format and returns pointer to new allocated string. Example: "type1 name1,type2 name2" => "name1,name2" New string has to be freed by user. More...
 
char * ur_cpy_string (const char *str)
 Duplicates given string. Helper function which returns pointer to duplicated string. New string has to be freed by user. More...
 
const char * ur_values_get_name_start_end (uint32_t start, uint32_t end, int32_t value)
 Returns name of specified value (Helper function) Helper function for ur_values_get_name. This function returns name of specified value and field, which is defined in values file. Function needs start and end index of a field. More...
 
const char * ur_values_get_description_start_end (uint32_t start, uint32_t end, int32_t value)
 Returns description of specified value (Helper function) Helper function for ur_values_get_description. This function returns description of specified value and field, which is defined in values file. Function needs start and end index of a field. More...
 

Variables

const int ur_field_type_size []
 Sizes of UniRec data types. More...
 
const char * ur_field_type_str []
 UniRec data types. More...
 
int ur_field_array_elem_type []
 UniRec array element types. More...
 
ur_field_specs_t ur_field_specs
 Structure that lists UniRec field specifications such as names, types, id. More...
 
ur_static_field_specs_t UR_FIELD_SPECS_STATIC
 Structure that lists staticaly defined UniRec field specifications such as names, types, id (using UR_FIELDS()). More...
 

Detailed Description

Definition of UniRec structures and functions.

Author
Vaclav Bartos ibart.nosp@m.osv@.nosp@m.fit.v.nosp@m.utbr.nosp@m..cz
Zdenek Rosa rosaz.nosp@m.den@.nosp@m.fit.c.nosp@m.vut..nosp@m.cz
Date
2015

Definition in file unirec.h.


Data Structure Documentation

◆ ur_field_id_linked_list_s

struct ur_field_id_linked_list_s

Linked list for undefined field ids Linked list consisting of field ids, which are freed after operation undefine.

Definition at line 143 of file unirec.h.

Data Fields
ur_field_id_t id free id
ur_field_id_linked_list_t * next Pointer to next item in the linked list.

◆ ur_static_field_specs_t

struct ur_static_field_specs_t

UniRec default field list It contains all fields which are specified statically in source code of a module. This structure is passed to ur_init()

Definition at line 152 of file unirec.h.

Data Fields
char ** ur_field_names Array of names of fields.
short * ur_field_sizes Array of sizes of fields.
ur_field_type_t * ur_field_types Array of types of fields.
ur_field_id_t ur_last_id Last specified ID.

◆ ur_field_specs_t

struct ur_field_specs_t

UniRec fields structure It contains all fields which are statically defined by UR_FIELDS(...) and run-time generated fields. This structure can be modified during run-time by generating new fields and erasing existing fields.

Definition at line 164 of file unirec.h.

Data Fields
uint8_t intialized If the UniRec is initialized by function ur_init variable is set to UR_INITIALIZED, otherwise 0.
ur_field_id_t ur_allocated_fields

Count of fields which is allocated (ur_allocated_fields - ur_last_id = remaining fields count)

char ** ur_field_names Array of names of fields.
short * ur_field_sizes Array of sizes of fields.
ur_field_type_t * ur_field_types Array of types of fields.
ur_field_id_t ur_last_id The highest ID of a field + 1.
ur_field_id_t ur_last_statically_defined_id Last statically defined field by UR_FIELDS(...)
ur_field_id_linked_list_t * ur_undefine_fields linked list of free (undefined) IDs

◆ field_spec_t

struct field_spec_t

Sorting fields structure This structure is used to sort fields by their size and name. The structure is passed to the sorting algorithm.

Definition at line 182 of file unirec.h.

Data Fields
ur_field_id_t id ID of a field.
char * name Name of a field.
int size Size of a field.

◆ ur_template_t

struct ur_template_t

UniRec template. It contains a table mapping a field to its position in an UniRec record.

Definition at line 191 of file unirec.h.

Data Fields
uint16_t count Count of fields in template.
ur_tmplt_direction direction Direction of data input, output, bidirection, no direction.
uint16_t first_dynamic First dynamic (variable-length) field. Index to the ids array.
int16_t * ids Array of ids in template.
uint32_t ifc_out output interface number (stored only if the direction == UR_TMPLT_DIRECTION_BI)
uint16_t * offset Table of offsets.
uint16_t offset_size size of offset table.
uint16_t static_size Size of static part.

Macro Definition Documentation

◆ __STDC_LIMIT_MACROS

#define __STDC_LIMIT_MACROS

Definition at line 54 of file unirec.h.

◆ UR_ARRAY_ALLOC

#define UR_ARRAY_ALLOC   10

Default alloc size increment for ur_set_array_from_string.

Definition at line 73 of file unirec.h.

◆ UR_ARRAY_DELIMITER

#define UR_ARRAY_DELIMITER   ' '

Delimiter of array elements in string.

Definition at line 72 of file unirec.h.

◆ UR_COUNT_OF_TYPES

#define UR_COUNT_OF_TYPES   29

Constants for all possible types of UniRec fields.

Count of types of UniRec fields

Definition at line 94 of file unirec.h.

◆ UR_DEFAULT_LENGTH_OF_FIELD_NAME

#define UR_DEFAULT_LENGTH_OF_FIELD_NAME   128

Definition at line 67 of file unirec.h.

◆ UR_DEFAULT_LENGTH_OF_FIELD_TYPE

#define UR_DEFAULT_LENGTH_OF_FIELD_TYPE   16

Definition at line 68 of file unirec.h.

◆ UR_DEFAULT_LENGTH_OF_TEMPLATE

#define UR_DEFAULT_LENGTH_OF_TEMPLATE   1024

Definition at line 66 of file unirec.h.

◆ UR_E_INVALID_FIELD_ID

#define UR_E_INVALID_FIELD_ID   -5

The field ID is not present in a template.

Definition at line 85 of file unirec.h.

◆ UR_E_INVALID_NAME

#define UR_E_INVALID_NAME   -3

The given name is not present in a template.

Definition at line 87 of file unirec.h.

◆ UR_E_INVALID_PARAMETER

#define UR_E_INVALID_PARAMETER   -6

The given parameter is wrong.

Definition at line 84 of file unirec.h.

◆ UR_E_INVALID_TYPE

#define UR_E_INVALID_TYPE   -2

The type of a field is not defined.

Definition at line 88 of file unirec.h.

◆ UR_E_MEMORY

#define UR_E_MEMORY   -1

Problem during allocating memory.

Definition at line 89 of file unirec.h.

◆ UR_E_TYPE_MISMATCH

#define UR_E_TYPE_MISMATCH   -4

The type of a field is different.

Definition at line 86 of file unirec.h.

◆ UR_FIELD_ID_MAX

#define UR_FIELD_ID_MAX   INT16_MAX

Max ID of a field.

Definition at line 70 of file unirec.h.

◆ UR_FIELDS

#define UR_FIELDS (   ...)

Definition of UniRec fields.

Definition at line 71 of file unirec.h.

◆ UR_INITIAL_SIZE_FIELDS_TABLE

#define UR_INITIAL_SIZE_FIELDS_TABLE   5

Initial size of free space in fields tables.

Definition at line 69 of file unirec.h.

◆ UR_INITIALIZED

#define UR_INITIALIZED   1

Indicator if the UniRec has been initialized by calling function ur_init.

Definition at line 81 of file unirec.h.

◆ UR_INVALID_FIELD

#define UR_INVALID_FIELD   ((ur_field_id_t) 0xffff)

ID of invalid field.

Definition at line 82 of file unirec.h.

◆ UR_INVALID_OFFSET

#define UR_INVALID_OFFSET   0xffff

Default value of all offsets (value is not in the record)

Definition at line 78 of file unirec.h.

◆ UR_ITER_BEGIN

#define UR_ITER_BEGIN   (-1)

First value in iterating through the fields.

Definition at line 75 of file unirec.h.

◆ UR_ITER_END

#define UR_ITER_END   INT16_MAX

Last value in iterating through the fields.

Definition at line 76 of file unirec.h.

◆ UR_NO_DYNAMIC_VALUES

#define UR_NO_DYNAMIC_VALUES   0xffff

Value of variable "first_dynamic" if no dynamic values are present.

Definition at line 79 of file unirec.h.

◆ UR_OK

#define UR_OK   0

No problem.

Definition at line 90 of file unirec.h.

◆ UR_UNINITIALIZED

#define UR_UNINITIALIZED   0

Indicator if the UniRec has not been initialized by calling function ur_init.

Definition at line 80 of file unirec.h.

Typedef Documentation

◆ ur_field_id_t

typedef int16_t ur_field_id_t

Type of UniRec field identifiers.

Definition at line 136 of file unirec.h.

◆ ur_iter_t

Type for identifying iteration id through all fields.

Definition at line 137 of file unirec.h.

Enumeration Type Documentation

◆ ur_field_type_t

Enumerator
UR_TYPE_STRING 

var-len fields (string where only printable characters are expected; '\0' at the end should NOT be included)

UR_TYPE_BYTES 

var-len fields (generic string of bytes)

UR_TYPE_CHAR 

char

UR_TYPE_UINT8 

unsigned int (8b)

UR_TYPE_INT8 

int (8b)

UR_TYPE_UINT16 

unsigned int (16b)

UR_TYPE_INT16 

int (8b)

UR_TYPE_UINT32 

unsigned int (32b)

UR_TYPE_INT32 

int (32b)

UR_TYPE_UINT64 

unsigned int (64b)

UR_TYPE_INT64 

int (64b)

UR_TYPE_FLOAT 

float (32b)

UR_TYPE_DOUBLE 

double (64b)

UR_TYPE_IP 

IP address (128b)

UR_TYPE_MAC 

MAC address (48b)

UR_TYPE_TIME 

time (64b)

UR_TYPE_A_UINT8 

unsigned int (8b) array

UR_TYPE_A_INT8 

int (8b) array

UR_TYPE_A_UINT16 

unsigned int (16b) array

UR_TYPE_A_INT16 

int (8b) array

UR_TYPE_A_UINT32 

unsigned int (32b) array

UR_TYPE_A_INT32 

int (32b) array

UR_TYPE_A_UINT64 

unsigned int (64b) array

UR_TYPE_A_INT64 

int (64b) array

UR_TYPE_A_FLOAT 

float (32b) array

UR_TYPE_A_DOUBLE 

double (64b) array

UR_TYPE_A_IP 

IP address (128b) array.

UR_TYPE_A_MAC 

MAC address (48b) array.

UR_TYPE_A_TIME 

time (64b) array

Definition at line 95 of file unirec.h.

◆ ur_tmplt_direction

Enumerator
UR_TMPLT_DIRECTION_NO 

template is not used for sending data

UR_TMPLT_DIRECTION_IN 

input direction

UR_TMPLT_DIRECTION_OUT 

ouput direction

UR_TMPLT_DIRECTION_BI 

bidirection

Definition at line 129 of file unirec.h.