Libtrap: Internal development docs  1.16.1
Modules | Data Structures | Macros | Typedefs | Functions | Variables
Common libtrap API
Collaboration diagram for Common libtrap API:

Modules

 Error codes
 
 TRAP Timeout
 
 Specifier of TRAP interfaces
 
 Message format
 

Data Structures

struct  trap_ifc_spec_s
 

Macros

#define TRAP_IFC_MESSAGEQ_SIZE   100000
 size of message queue used for buffering More...
 

Typedefs

typedef struct trap_ifc_spec_s trap_ifc_spec_t
 

Functions

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 ()
 
int trap_get_in_ifc_state (uint32_t ifc_idx)
 
int trap_parse_params (int *argc, char **argv, trap_ifc_spec_t *ifc_spec)
 
char * trap_get_param_by_delimiter (const char *source, char **dest, const char delimiter)
 Splitter of params string. Cut the first param, copy it into dest and returns pointer to the start of following parameter. More...
 
int trap_check_buffer_content (void *buffer, uint32_t buffer_size)
 Check content of buffer, iterate over message headers. More...
 

Variables

const char trap_version []
 
const char trap_git_version [] = GIT_VERSION
 
char * trap_default_socket_path_format
 

TRAP interface control request

enum  trap_ifcctl_request { TRAPCTL_AUTOFLUSH_TIMEOUT = 1, TRAPCTL_BUFFERSWITCH = 2, TRAPCTL_SETTIMEOUT = 3 }
 

Detailed Description

This module declares basic public constants, structures and functions of libtrap.

Macro Definition Documentation

◆ TRAP_IFC_MESSAGEQ_SIZE

#define TRAP_IFC_MESSAGEQ_SIZE   100000

size of message queue used for buffering

Definition at line 206 of file trap.h.

Typedef Documentation

◆ trap_ifc_spec_t

Structure with specification of interface types and their parameters. This can be filled by command-line parameters using trap_parse_params function.

Enumeration Type Documentation

◆ trap_ifcctl_request

Enumerator
TRAPCTL_AUTOFLUSH_TIMEOUT 

Set timeout of automatic buffer flushing for interface, expects uint64_t argument with number of microseconds. It can be set to TRAP_NO_AUTO_FLUSH to disable autoflush.

TRAPCTL_BUFFERSWITCH 

Enable/disable buffering - could be dangerous on input interface!!! expects char argument with value 1 (default value after libtrap initialization - enabled) or 0 (for disabling buffering on interface).

TRAPCTL_SETTIMEOUT 

Set interface timeout (int32_t): in microseconds for non-blocking mode; timeout can be also: TRAP_WAIT, TRAP_HALFWAIT, or TRAP_NO_WAIT.

Definition at line 198 of file trap.h.

Function Documentation

◆ trap_check_buffer_content()

int trap_check_buffer_content ( void *  buffer,
uint32_t  buffer_size 
)

Check content of buffer, iterate over message headers.

Parameters
[in]bufferstart of buffer
[in]buffer_sizesize of buffer
Returns
0 on success, number of errors otherwise

Definition at line 222 of file trap.c.

◆ 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_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_param_by_delimiter()

char* trap_get_param_by_delimiter ( const char *  source,
char **  dest,
const char  delimiter 
)

Splitter of params string. Cut the first param, copy it into dest and returns pointer to the start of following parameter.

Parameters
[in]sourcesource string, typically params
[out]destdestination string, target of first paramater copying
[in]delimiterseparator of values in params
Returns
Pointer to the start of following parameter (char after delimiter).
Note
If NULL, no other parameter is present or error during allocation occured.
Parameters
[in]sourcesource string, typically params
[out]destdestination string, target of first parameter copying
[in]delimiterseparator of values in params
Returns
Pointer to the start of following parameter (char after delimiter).
Note
If NULL, no other parameter is present or error during allocation occured.

Definition at line 1160 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_parse_params()

int trap_parse_params ( int *  argc,
char **  argv,
trap_ifc_spec_t ifc_spec 
)

Parse command-line arguments. Extract arguments needed by TRAP to set up interfaces (-i params), verbosity level (-v/-vv/-vvv) and return the rest (argc and argv are modified, i.e. processed parameter is removed). Extracted information is stored into ifc_spec. These variables should be passed to trap_init. Data in ifc_spec must be freed by trap_free_ifc_spec. If help is requested (-h/–help) TRAP_E_HELP is returned (argc and argv are modified also).

Parameters
[in,out]argcPointer to number of command-line arguments.
[in,out]argvCommand-line arguments.
[out]ifc_specStructure with specification of interface types and their parameters.
Returns
Error code (0 on success)

Initialization function. Create and initialize all interfaces. This function parses command-line arguments; it extracts arguments it needs to set up interfaces and returns the rest (argc and argv are modified).

Parameters
[in,out]argcPointer to number of command-line arguments.
[in,out]argvCommand-line arguments.
[out]ifc_specStructure with specification of interface types and their parameters.
Returns
Error code (0 on success)

Definition at line 339 of file trap.c.

Variable Documentation

◆ trap_default_socket_path_format

char* trap_default_socket_path_format

Text string with default path format to sockets (UNIX IFC and service IFC). Assigned in ifc_tcpip.h

◆ trap_git_version

const char trap_git_version ( ) = GIT_VERSION

Text string with Git revision of libtrap.

Git revision of libtrap

Used from config.h that is generated by the configure script.

◆ trap_version

const char trap_version[]

Text string with libtrap version.