libtrap  1.16.1
Enumerations | Functions
Message format
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_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 ifc_idx, uint8_t *data_type, const char **spec)
 
void trap_ctx_set_data_fmt (trap_ctx_t *ctx, uint32_t out_ifc_idx, uint8_t data_type,...)
 
void trap_ctx_vset_data_fmt (trap_ctx_t *ctx, uint32_t out_ifc_idx, uint8_t data_type, va_list ap)
 
int trap_ctx_get_in_ifc_state (trap_ctx_t *ctx, uint32_t ifc_idx)
 
int trap_ctx_set_required_fmt (trap_ctx_t *ctx, uint32_t in_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_get_data_fmt (trap_ctx_t *ctx, uint8_t ifc_dir, uint32_t ifc_idx, uint8_t *data_type, const char **spec)
 

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_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.

◆ 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).

◆ 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.

◆ 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().

◆ 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.

◆ 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.

◆ 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().

◆ 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

◆ 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