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

Data Structures

struct  tls_receiver_private_s
 

Typedefs

typedef struct tls_receiver_private_s tls_receiver_private_t
 

Functions

static int receive_part (void *priv, void **data, uint32_t *size, struct timeval *tm)
 
int tls_receiver_recv (void *priv, void *data, uint32_t *size, int timeout)
 Receive data from interface. More...
 
void tls_receiver_terminate (void *priv)
 Set interface state as terminated. More...
 
void tls_receiver_destroy (void *priv)
 Destructor of TLS receiver (input ifc) More...
 
static void tls_receiver_create_dump (void *priv, uint32_t idx, const char *path)
 
char * tls_recv_ifc_get_id (void *priv)
 
uint8_t tls_recv_ifc_is_conn (void *priv)
 
int create_tls_receiver_ifc (trap_ctx_priv_t *ctx, char *params, trap_input_ifc_t *ifc, uint32_t idx)
 Constructor of input TCP/IP IFC module. This function is called by TRAP library to initialize one input interface. More...
 
static int wait_for_connection (int sock, struct timeval *tv)
 
static void client_socket_disconnect (void *priv)
 
static int client_socket_connect (tls_receiver_private_t *c, struct timeval *tv)
 client_socket is used as a receiver More...
 

Detailed Description

Typedef Documentation

◆ tls_receiver_private_t

Function Documentation

◆ client_socket_connect()

static int client_socket_connect ( tls_receiver_private_t c,
struct timeval *  tv 
)
static

client_socket is used as a receiver

Parameters
[in]cpointer to module private data
[in]tvtimeout
Returns
TRAP_E_OK on success

Input interface negotiation

Definition at line 941 of file ifc_tls.c.

◆ client_socket_disconnect()

static void client_socket_disconnect ( void *  priv)
static

Disconnect from output IFC.

Parameters
[in,out]privpointer to private structure of input IFC (client)

Definition at line 892 of file ifc_tls.c.

◆ create_tls_receiver_ifc()

int create_tls_receiver_ifc ( trap_ctx_priv_t ctx,
char *  params,
trap_input_ifc_t ifc,
uint32_t  idx 
)

Constructor of input TCP/IP IFC module. This function is called by TRAP library to initialize one input 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): dest_addr dest_port, 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 738 of file ifc_tls.c.

◆ receive_part()

static int receive_part ( void *  priv,
void **  data,
uint32_t *  size,
struct timeval *  tm 
)
static

Receive data

Parameters
[in]privprivate IFC data
[out]datareceived data
[in,out]sizeexpected size to wait for, it is used to return size that was not read
[in]tmtimeout
Todo:
continue with timeout minus time already waited

Definition at line 286 of file ifc_tls.c.

◆ tls_receiver_create_dump()

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

Definition at line 643 of file ifc_tls.c.

◆ tls_receiver_destroy()

void tls_receiver_destroy ( void *  priv)

Destructor of TLS receiver (input ifc)

Parameters
[in]privpointer to module private data

Definition at line 622 of file ifc_tls.c.

◆ tls_receiver_recv()

int tls_receiver_recv ( void *  priv,
void *  data,
uint32_t *  size,
int  timeout 
)

Receive data from interface.

It is expected that data is always the same pointer because it is buffer given by trap.c.

This function contains finite state machine that controls receiving messages (header and payload), handles timeouts and sleep (to offload CPU during waiting for connection). The transition graph is:

dot_inline_dotgraph_2.png
Parameters
[in,out]privprivate configuration structure
[out]datawhere received data are stored
[out]sizesize of received data
[in]timeouttimeout in usec, can be TRAP_WAIT, TRAP_HALFWAIT, or TRAP_NO_WAIT
Returns
TRAP_E_OK (0) on success

messageframe contains header that is read (even partially) in HEAD_WAIT

Definition at line 395 of file ifc_tls.c.

◆ tls_receiver_terminate()

void tls_receiver_terminate ( void *  priv)

Set interface state as terminated.

Parameters
[in]privpointer to module private data

Definition at line 606 of file ifc_tls.c.

◆ tls_recv_ifc_get_id()

char* tls_recv_ifc_get_id ( void *  priv)

Definition at line 701 of file ifc_tls.c.

◆ tls_recv_ifc_is_conn()

uint8_t tls_recv_ifc_is_conn ( void *  priv)

Definition at line 714 of file ifc_tls.c.

◆ wait_for_connection()

static int wait_for_connection ( int  sock,
struct timeval *  tv 
)
static

Function waits for non-blocking connect().

Parameters
[in]socksocket descriptor of client
[in]tvtimeout
Returns
TRAP_E_OK on success, TRAP_E_TIMEOUT on error (can be caused by interrupt)

Definition at line 912 of file ifc_tls.c.