Libtrap: Internal development docs  1.16.1
Data Structures | Typedefs | Functions
Collaboration diagram for TCPIP output IFC:

Data Structures

struct  client_s
 Structure for TCP/IP IFC client information. More...
 
struct  tcpip_sender_private_s
 Structure for TCP/IP IFC private information. More...
 

Typedefs

typedef struct client_s client_t
 Structure for TCP/IP IFC client information. More...
 
typedef struct tcpip_sender_private_s tcpip_sender_private_t
 Structure for TCP/IP IFC private information. More...
 

Functions

static void disconnect_client (tcpip_sender_private_t *priv, int cl_id)
 This function is called when a client was/is being disconnected. More...
 
void tcpip_server_disconnect_all_clients (void *priv)
 Function disconnects all clients of the output interface whose private structure is passed via "priv" parameter. More...
 
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 (tcpip_sender_private_t *priv, buffer_t *buffer)
 Write buffer size to its header and shift active index. More...
 
void tcpip_sender_flush (void *priv)
 Force flush of active buffer. More...
 
static int send_data (tcpip_sender_private_t *priv, client_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 TCPIP and UNIX interfaces. More...
 
int tcpip_sender_send (void *priv, const void *data, uint16_t size, int timeout)
 Store message into buffer. More...
 
void tcpip_sender_terminate (void *priv)
 Set interface state as terminated. More...
 
void tcpip_sender_destroy (void *priv)
 Destructor of TCP sender (output ifc) More...
 
int32_t tcpip_sender_get_client_count (void *priv)
 
int8_t tcpip_sender_get_client_stats_json (void *priv, json_t *client_stats_arr)
 
static void tcpip_sender_create_dump (void *priv, uint32_t idx, const char *path)
 
char * tcpip_send_ifc_get_id (void *priv)
 
int create_tcpip_sender_ifc (trap_ctx_priv_t *ctx, const char *params, trap_output_ifc_t *ifc, uint32_t idx, enum tcpip_ifc_sockettype type)
 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 TCPIP socket for sender module. More...
 

Detailed Description

Typedef Documentation

◆ client_t

typedef struct client_s client_t

Structure for TCP/IP IFC client information.

◆ tcpip_sender_private_t

Structure for TCP/IP IFC private 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.

Definition at line 1026 of file ifc_tcpip.c.

◆ create_tcpip_sender_ifc()

int create_tcpip_sender_ifc ( trap_ctx_priv_t ctx,
const char *  params,
trap_output_ifc_t ifc,
uint32_t  idx,
enum tcpip_ifc_sockettype  type 
)

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 interface specific parameters -
  • tcp port/unix socket, max number of clients, buffer size, buffer count.
[in,out]ifcIFC interface used for calling TCP/IP module.
[in]idxIndex of IFC that is created.
[in]typeselect the type of socket (see tcpip_ifc_sockettype for options)
Returns
0 on success (TRAP_E_OK)

Definition at line 1730 of file ifc_tcpip.c.

◆ disconnect_client()

static void disconnect_client ( tcpip_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 982 of file ifc_tcpip.c.

◆ finish_buffer()

static void finish_buffer ( tcpip_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 1144 of file ifc_tcpip.c.

◆ send_data()

static int send_data ( tcpip_sender_private_t priv,
client_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 1190 of file ifc_tcpip.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 TCPIP and UNIX interfaces.

Parameters
[in]privpointer to interface private data

Definition at line 1239 of file ifc_tcpip.c.

◆ server_socket_open()

static int server_socket_open ( void *  priv)
static

Open TCPIP socket for sender module.

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

Definition at line 1910 of file ifc_tcpip.c.

◆ tcpip_send_ifc_get_id()

char* tcpip_send_ifc_get_id ( void *  priv)

Definition at line 1705 of file ifc_tcpip.c.

◆ tcpip_sender_create_dump()

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

Definition at line 1654 of file ifc_tcpip.c.

◆ tcpip_sender_destroy()

void tcpip_sender_destroy ( void *  priv)

Destructor of TCP sender (output ifc)

Parameters
[in]privpointer to module private data

Definition at line 1561 of file ifc_tcpip.c.

◆ tcpip_sender_flush()

void tcpip_sender_flush ( void *  priv)

Force flush of active buffer.

Parameters
[in]privpointer to interface private data

Definition at line 1168 of file ifc_tcpip.c.

◆ tcpip_sender_get_client_count()

int32_t tcpip_sender_get_client_count ( void *  priv)

Definition at line 1616 of file ifc_tcpip.c.

◆ tcpip_sender_get_client_stats_json()

int8_t tcpip_sender_get_client_stats_json ( void *  priv,
json_t *  client_stats_arr 
)

Definition at line 1627 of file ifc_tcpip.c.

◆ tcpip_sender_send()

int tcpip_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 1434 of file ifc_tcpip.c.

◆ tcpip_sender_terminate()

void tcpip_sender_terminate ( void *  priv)

Set interface state as terminated.

Parameters
[in]privpointer to module private data

Definition at line 1531 of file ifc_tcpip.c.

◆ tcpip_server_disconnect_all_clients()

void tcpip_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 1009 of file ifc_tcpip.c.