Libtrap: Internal development docs  1.16.1
Data Structures | Typedefs | Functions
Collaboration diagram for TLS Output IFC:

Data Structures

struct  tlsclient_s
 Structure for TLS IFC client information. More...
 
struct  tls_sender_private_s
 Structure for TLS IFC private information. More...
 

Typedefs

typedef struct tlsclient_s tlsclient_t
 Structure for TLS IFC client information. More...
 
typedef struct tls_sender_private_s tls_sender_private_t
 Structure for TLS IFC private information. More...
 

Functions

static void disconnect_client (tls_sender_private_t *priv, int cl_id)
 This function is called when a client was/is being disconnected. More...
 
void tls_server_disconnect_all_clients (void *priv)
 Function disconnects all clients of the output interface whose private structure is passed via "priv" parameter. More...
 
static uint64_t get_cur_timestamp ()
 
static void * accept_clients_thread (void *arg)
 This function runs in a separate thread and handles new client's connection requests. More...
 
static void finish_buffer (tls_sender_private_t *priv, buffer_t *buffer)
 Write buffer size to its header and shift active index. More...
 
void tls_sender_flush (void *priv)
 Force flush of active buffer. More...
 
static int send_data (tls_sender_private_t *priv, tlsclient_t *c, uint32_t cl_id)
 Send data to client from his assigned buffer. More...
 
static void * sending_thread_func (void *priv)
 This function runs in a separate thread. It handles sending data to connected clients for TLS interface. More...
 
int tls_sender_send (void *priv, const void *data, uint16_t size, int timeout)
 Store message into buffer. More...
 
void tls_sender_terminate (void *priv)
 Set interface state as terminated. More...
 
void tls_sender_destroy (void *priv)
 Destructor of TCP sender (output ifc) More...
 
int32_t tls_sender_get_client_count (void *priv)
 
int8_t tls_sender_get_client_stats_json (void *priv, json_t *client_stats_arr)
 
static void tls_sender_create_dump (void *priv, uint32_t idx, const char *path)
 
char * tls_send_ifc_get_id (void *priv)
 
int create_tls_sender_ifc (trap_ctx_priv_t *ctx, const char *params, trap_output_ifc_t *ifc, uint32_t idx)
 Constructor of output TCP/IP IFC module. This function is called by TRAP library to initialize one output interface. More...
 
static int server_socket_open (void *priv)
 Open TLS socket for sender module. More...
 

Detailed Description

Typedef Documentation

◆ tls_sender_private_t

Structure for TLS IFC private information.

◆ tlsclient_t

typedef struct tlsclient_s tlsclient_t

Structure for TLS IFC client information.

Function Documentation

◆ accept_clients_thread()

static void* accept_clients_thread ( void *  arg)
static

This function runs in a separate thread and handles new client's connection requests.

Parameters
[in]argPointer to interface's private data structure.

Verifying SSL certificate of client.

Definition at line 1200 of file ifc_tls.c.

◆ create_tls_sender_ifc()

int create_tls_sender_ifc ( trap_ctx_priv_t ctx,
const char *  params,
trap_output_ifc_t ifc,
uint32_t  idx 
)

Constructor of output TCP/IP IFC module. This function is called by TRAP library to initialize one output interface.

Parameters
[in,out]ctxPointer to the private libtrap context data (trap_ctx_init()).
[in]paramsConfiguration string containing space separated values of these parameters (in this exact order): server_port max_clients, where dest_addr is destination address of output TCP/IP IFC module and dest_port is the port where sender is listening.
[in,out]ifcIFC interface used for calling TCP/IP module.
[in]idxIndex of IFC that is created.
Returns
0 on success (TRAP_E_OK)

Definition at line 1883 of file ifc_tls.c.

◆ disconnect_client()

static void disconnect_client ( tls_sender_private_t priv,
int  cl_id 
)
inlinestatic

This function is called when a client was/is being disconnected.

Parameters
[in]privPointer to interface's private data structure.
[in]cl_idIndex of the client in 'clients' array.

Definition at line 1139 of file ifc_tls.c.

◆ finish_buffer()

static void finish_buffer ( tls_sender_private_t priv,
buffer_t buffer 
)
inlinestatic

Write buffer size to its header and shift active index.

Parameters
[in]privPointer to output interface private structure.
[in]bufferPointer to the buffer.

Definition at line 1334 of file ifc_tls.c.

◆ get_cur_timestamp()

static uint64_t get_cur_timestamp ( )
inlinestatic

Return current time in microseconds.

This is used to get current timestamp in tls_sender_send().

Returns
current timestamp

Definition at line 1186 of file ifc_tls.c.

◆ send_data()

static int send_data ( tls_sender_private_t priv,
tlsclient_t c,
uint32_t  cl_id 
)
inlinestatic

Send data to client from his assigned buffer.

Parameters
[in]privPointer to iterface's private data structure.
[in]cPointer to the client's structure.
[in]cl_idClient's index in the 'clients' array.
Returns
TRAP_E_OK successfully sent.
TRAP_E_TERMINATED TRAP was terminated.
TRAP_E_IO_ERROR send failed although TRAP was not terminated.

Definition at line 1385 of file ifc_tls.c.

◆ sending_thread_func()

static void* sending_thread_func ( void *  priv)
static

This function runs in a separate thread. It handles sending data to connected clients for TLS interface.

Parameters
[in]privpointer to interface private data

Definition at line 1434 of file ifc_tls.c.

◆ server_socket_open()

static int server_socket_open ( void *  priv)
static

Open TLS socket for sender module.

Parameters
[in]privtls_sender_private_t structure (private data)
Returns
0 on success (TRAP_E_OK), TRAP_E_IO_ERROR on error

Definition at line 2091 of file ifc_tls.c.

◆ tls_send_ifc_get_id()

char* tls_send_ifc_get_id ( void *  priv)

Definition at line 1858 of file ifc_tls.c.

◆ tls_sender_create_dump()

static void tls_sender_create_dump ( void *  priv,
uint32_t  idx,
const char *  path 
)
static

Definition at line 1809 of file ifc_tls.c.

◆ tls_sender_destroy()

void tls_sender_destroy ( void *  priv)

Destructor of TCP sender (output ifc)

Parameters
[in]privpointer to module private data

Definition at line 1727 of file ifc_tls.c.

◆ tls_sender_flush()

void tls_sender_flush ( void *  priv)

Force flush of active buffer.

Parameters
[in]privpointer to interface private data

Definition at line 1358 of file ifc_tls.c.

◆ tls_sender_get_client_count()

int32_t tls_sender_get_client_count ( void *  priv)

Definition at line 1771 of file ifc_tls.c.

◆ tls_sender_get_client_stats_json()

int8_t tls_sender_get_client_stats_json ( void *  priv,
json_t *  client_stats_arr 
)

Definition at line 1782 of file ifc_tls.c.

◆ tls_sender_send()

int tls_sender_send ( void *  priv,
const void *  data,
uint16_t  size,
int  timeout 
)

Store message into buffer.

Parameters
[in]privpointer to module private data
[in]datapointer to data to write
[in]sizesize of data to write
[in]timeoutmaximum time spent waiting for the message to be stored [microseconds]
Returns
TRAP_E_OK Success.
TRAP_E_TIMEOUT Message was not stored into buffer and the attempt should be repeated.
TRAP_E_TERMINATED Libtrap was terminated during the process.

Definition at line 1600 of file ifc_tls.c.

◆ tls_sender_terminate()

void tls_sender_terminate ( void *  priv)

Set interface state as terminated.

Parameters
[in]privpointer to module private data

Definition at line 1697 of file ifc_tls.c.

◆ tls_server_disconnect_all_clients()

void tls_server_disconnect_all_clients ( void *  priv)

Function disconnects all clients of the output interface whose private structure is passed via "priv" parameter.

Parameters
[in]privPointer to output interface private structure.

Definition at line 1167 of file ifc_tls.c.