|
#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...
|
|
|
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_t * | ur_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_t * | ur_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_t * | ur_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_t * | ur_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_t * | ur_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_t * | ur_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_t * | ur_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...
|
|