Libtrap: Internal development docs  1.16.1
Enumerations | Functions
Collaboration diagram for Message format:

Enumerations

enum  trap_data_format_t { TRAP_FMT_UNKNOWN = 0, TRAP_FMT_RAW = 1, TRAP_FMT_UNIREC = 2, TRAP_FMT_JSON = 3 }
 
enum  trap_in_ifc_state_t { FMT_WAITING = 0, FMT_OK = 1, FMT_MISMATCH = 2, FMT_CHANGED = 3 }
 

Functions

void trap_ctx_vset_data_fmt (trap_ctx_t *ctx, uint32_t out_ifc_idx, uint8_t data_type, va_list ap)
 
void trap_ctx_set_data_fmt (trap_ctx_t *ctx, uint32_t out_ifc_idx, uint8_t data_type,...)
 
int trap_ctx_vset_required_fmt (trap_ctx_t *ctx, uint32_t in_ifc_idx, uint8_t data_type, va_list ap)
 
int trap_ctx_set_required_fmt (trap_ctx_t *ctx, uint32_t in_ifc_idx, uint8_t data_type,...)
 
int trap_ctx_get_data_fmt (trap_ctx_t *ctx, uint8_t ifc_dir, uint32_t ifc_idx, uint8_t *data_type, const char **spec)
 
void trap_set_data_fmt (uint32_t out_ifc_idx, uint8_t data_type,...)
 
int trap_set_required_fmt (uint32_t in_ifc_idx, uint8_t data_type,...)
 
int trap_get_data_fmt (uint8_t ifc_dir, uint32_t in_ifc_idx, uint8_t *data_type, const char **spec)
 
int trap_ctx_get_in_ifc_state (trap_ctx_t *ctx, uint32_t ifc_idx)
 
int trap_get_in_ifc_state (uint32_t ifc_idx)
 
const char * trap_get_type_and_name_from_string (const char *source, const char **name, const char **type, int *length_name, int *length_type)
 
int trap_ctx_cmp_data_fmt (const char *sender_ifc_data_fmt, const char *receiver_ifc_data_fmt)
 
void * trap_get_global_ctx ()
 

Detailed Description

Enumeration Type Documentation

◆ trap_data_format_t

Type of messages that are sent via IFC

Enumerator
TRAP_FMT_UNKNOWN 

unknown - message format was not specified yet

TRAP_FMT_RAW 

raw data, no format specified

TRAP_FMT_UNIREC 

UniRec records

TRAP_FMT_JSON 

structured data serialized using JSON

Definition at line 225 of file trap.h.

◆ trap_in_ifc_state_t

Possible states of an IFC during data format negotiation.

Enumerator
FMT_WAITING 

Negotiation is not completed

FMT_OK 

Negotiation was successful

FMT_MISMATCH 

Negotiation failed, format mismatch

FMT_CHANGED 

Negotiation was successful, but receivers (input ifc) template is subset of senders (output ifc) template and missing fields has to be defined

Definition at line 242 of file trap.h.

Function Documentation

◆ trap_ctx_cmp_data_fmt()

int trap_ctx_cmp_data_fmt ( const char *  sender_ifc_data_fmt,
const char *  receiver_ifc_data_fmt 
)

Compares sender_ifc template and receiver_ifc template and returns whether receivers template is subset of the senders template.

Parameters
[in]sender_ifc_data_fmtsender_ifc template (char *)
[in]receiver_ifc_data_fmtreceiver_ifc template (char *)
Returns
TRAP_E_OK on success (receivers template is subset of the senders template), TRAP_E_FIELDS_MISMATCH (receivers template has field which is not in senders template).

Definition at line 2765 of file trap.c.

◆ trap_ctx_get_data_fmt()

int trap_ctx_get_data_fmt ( trap_ctx_t ctx,
uint8_t  ifc_dir,
uint32_t  ifc_idx,
uint8_t *  data_type,
const char **  spec 
)

Get message format and template that is set on IFC.

On output IFC it should return the values that were set. On input IFC it should return format and template that was received. This function is thread safe.

Parameters
[in]ctxPointer to the private libtrap context data (trap_ctx_init()).
[in]ifc_dirtrap_ifc_type direction of interface
[in]ifc_idxIndex of IFC.
[out]data_typeFormat of messages defined by trap_data_format_t.
[out]specSpecifier of data format specifies the template (char *) is expected.
Returns
TRAP_E_OK on success, TRAP_E_NOT_INITIALIZED if libtrap context is not initialized or negotiation is not successful yet for input IFC, TRAP_E_BAD_IFC_INDEX or TRAP_E_BADPARAMS on error.

Definition at line 2617 of file trap.c.

◆ trap_ctx_get_in_ifc_state()

int trap_ctx_get_in_ifc_state ( trap_ctx_t ctx,
uint32_t  ifc_idx 
)

Returns current state of an input interface on specified index.

This function is thread safe.

Parameters
[in]ctxPointer to the private libtrap context data (trap_ctx_init()).
[in]ifc_idxIndex of the input interface
Returns
Value of trap_in_ifc_state_t on success, otherwise TRAP_E_NOT_INITIALIZED when libtrap context is not initialized or TRAP_E_BAD_IFC_INDEX (ifc_idx >= number of input ifcs).

Definition at line 2719 of file trap.c.

◆ trap_ctx_set_data_fmt()

void trap_ctx_set_data_fmt ( trap_ctx_t ctx,
uint32_t  out_ifc_idx,
uint8_t  data_type,
  ... 
)

Set format of messages on output IFC.

This function is thread safe.

Parameters
[in,out]ctxPointer to the private libtrap context data (trap_ctx_init()).
[in]out_ifc_idxIndex of output IFC.
[in]data_typeFormat of messages defined by trap_data_format_t.
[in]...If data_type is TRAP_FMT_UNIREC or TRAP_FMT_JSON, additional parameter that specifies template (char *) is expected.

Definition at line 2551 of file trap.c.

◆ trap_ctx_set_required_fmt()

int trap_ctx_set_required_fmt ( trap_ctx_t ctx,
uint32_t  in_ifc_idx,
uint8_t  data_type,
  ... 
)

Set format of messages expected on input IFC.

This function is thread safe.

Parameters
[in]ctxPointer to the private libtrap context data (trap_ctx_init()).
[in]in_ifc_idxIndex of input IFC.
[in]data_typeFormat of messages defined by trap_data_format_t.
[in]...If data_type is TRAP_FMT_UNIREC or TRAP_FMT_JSON, additional parameter that specifies template (char *) is expected.
Returns
TRAP_E_OK on success, on error see trap_ctx_vset_required_fmt().

Definition at line 2602 of file trap.c.

◆ trap_ctx_vset_data_fmt()

void trap_ctx_vset_data_fmt ( trap_ctx_t ctx,
uint32_t  out_ifc_idx,
uint8_t  data_type,
va_list  ap 
)

Set format of messages on output IFC.

This function is thread safe.

Parameters
[in,out]ctxPointer to the private libtrap context data (trap_ctx_init()).
[in]out_ifc_idxIndex of output IFC.
[in]data_typeFormat of messages defined by trap_data_format_t.
[in]apIf data_type is TRAP_FMT_UNIREC or TRAP_FMT_JSON, additional parameter that specifies template (char *) is expected.

Definition at line 2516 of file trap.c.

◆ trap_ctx_vset_required_fmt()

int trap_ctx_vset_required_fmt ( trap_ctx_t ctx,
uint32_t  in_ifc_idx,
uint8_t  data_type,
va_list  ap 
)

Set format of messages expected on input IFC.

This function is thread safe.

Parameters
[in]ctxPointer to the private libtrap context data (trap_ctx_init()).
[in]in_ifc_idxIndex of input IFC.
[in]data_typeFormat of messages defined by trap_data_format_t.
[in]apIf data_type is TRAP_FMT_UNIREC or TRAP_FMT_JSON, additional parameter that specifies template (char *) is expected.
Returns
TRAP_E_OK on success, TRAP_E_NOT_INITIALIZED when libtrap context is not initialized, TRAP_E_BAD_IFC_INDEX or TRAP_E_BADPARAMS on error.

Definition at line 2565 of file trap.c.

◆ trap_get_data_fmt()

int trap_get_data_fmt ( uint8_t  ifc_dir,
uint32_t  ifc_idx,
uint8_t *  data_type,
const char **  spec 
)

Get message format and template that is set on IFC.

On output IFC it should return the values that were set. On input IFC it should return format and template that was received.

Parameters
[in]ifc_dirtrap_ifc_type direction of interface
[in]ifc_idxindex of IFC
[out]data_typeformat of messages defined by trap_data_format_t
[out]specTemplate specifier - UniRec specifier in case of TRAP_FMT_UNIREC data_type, otherwise, it can be any string.
Returns
TRAP_E_OK on success, on error see trap_ctx_get_data_fmt().

Definition at line 2714 of file trap.c.

◆ trap_get_global_ctx()

void* trap_get_global_ctx ( )

Returns global context.

Returns
pointer to global context.

Definition at line 2820 of file trap.c.

◆ trap_get_in_ifc_state()

int trap_get_in_ifc_state ( uint32_t  ifc_idx)

Returns current state of an input interface on specified index.

Parameters
[in]ifc_idxIndex of the input interface
Returns
See trap_ctx_get_in_ifc_state().

Definition at line 2734 of file trap.c.

◆ trap_get_type_and_name_from_string()

const char* trap_get_type_and_name_from_string ( const char *  source,
const char **  name,
const char **  type,
int *  length_name,
int *  length_type 
)

Parse Fields name and types from string.

Function parses the source string and sets the given pointers (pointers to source string). Than it sets length of name and type

Parameters
[in]sourceSource string to parse.
[in]nameouput parameter, where will be set the pointer to name of a field (pointer to source string).
[in]typeouput parameter, where will be set the pointer to type of a field (pointer to source string).
[in]length_nameouput parameter, where will be set the length of a name.
[in]length_typeouput parameter, where will be set the length of a type.
Returns
pointer to source string, moved to next field

Definition at line 2739 of file trap.c.

◆ trap_set_data_fmt()

void trap_set_data_fmt ( uint32_t  out_ifc_idx,
uint8_t  data_type,
  ... 
)

Set format of messages on output IFC.

Parameters
[in]out_ifc_idxindex of output IFC
[in]data_typeformat of messages defined by trap_data_format_t
[in]...if data_type is TRAP_FMT_UNIREC or TRAP_FMT_JSON, additional parameter that specifies template is expected

Definition at line 2693 of file trap.c.

◆ trap_set_required_fmt()

int trap_set_required_fmt ( uint32_t  in_ifc_idx,
uint8_t  data_type,
  ... 
)

Set format of messages expected on input IFC.

Parameters
[in]in_ifc_idxindex of input IFC
[in]data_typeformat of messages defined by trap_data_format_t
[in]...if data_type is TRAP_FMT_UNIREC or TRAP_FMT_JSON, additional parameter that specifies template is expected
Returns
TRAP_E_OK on success

Definition at line 2702 of file trap.c.