Libtrap: Internal development docs
1.16.1
|
Data Structures | |
struct | tcpip_receiver_private_s |
Typedefs | |
typedef struct tcpip_receiver_private_s | tcpip_receiver_private_t |
Functions | |
static int | receive_part (void *priv, void **data, uint32_t *size, struct timeval *tm) |
static uint64_t | get_cur_timestamp () |
int | tcpip_receiver_recv (void *priv, void *data, uint32_t *size, int timeout) |
Receive data from interface. More... | |
void | tcpip_receiver_terminate (void *priv) |
Set interface state as terminated. More... | |
void | tcpip_receiver_destroy (void *priv) |
Destructor of TCPIP receiver (input ifc) More... | |
static void | tcpip_receiver_create_dump (void *priv, uint32_t idx, const char *path) |
char * | tcpip_recv_ifc_get_id (void *priv) |
uint8_t | tcpip_recv_ifc_is_conn (void *priv) |
int | create_tcpip_receiver_ifc (trap_ctx_priv_t *ctx, char *params, trap_input_ifc_t *ifc, uint32_t idx, enum tcpip_ifc_sockettype type) |
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 (void *priv, const char *dest_addr, const char *dest_port, int *socket_descriptor, struct timeval *tv) |
client_socket is used as a receiver More... | |
typedef struct tcpip_receiver_private_s tcpip_receiver_private_t |
|
static |
client_socket is used as a receiver
[in] | priv | pointer to module private data |
[in] | dest_addr | destination address where to connect and where receive |
[in] | dest_port | destination port where to connect and where receive |
[out] | socket_descriptor | socket descriptor of established connection |
[in] | tv | timeout |
Input interface negotiation
Definition at line 804 of file ifc_tcpip.c.
|
static |
Disconnect from output IFC.
[in,out] | priv | pointer to private structure of input IFC (client) |
Definition at line 751 of file ifc_tcpip.c.
int create_tcpip_receiver_ifc | ( | trap_ctx_priv_t * | ctx, |
char * | params, | ||
trap_input_ifc_t * | ifc, | ||
uint32_t | idx, | ||
enum tcpip_ifc_sockettype | type | ||
) |
Constructor of input TCP/IP IFC module. This function is called by TRAP library to initialize one input interface.
[in,out] | ctx | Pointer to the private libtrap context data (trap_ctx_init()). |
[in] | params | Configuration 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] | ifc | IFC interface used for calling TCP/IP module. |
[in] | idx | Index of IFC that is created. |
[in] | type | Select the type of socket (see tcpip_ifc_sockettype for options). |
Definition at line 636 of file ifc_tcpip.c.
|
inlinestatic |
Return current time in microseconds.
This is used to get current timestamp in tcpip_receiver_recv() and tcpip_sender_send().
Definition at line 258 of file ifc_tcpip.c.
|
static |
Receive chunk of data.
Caller is responsible for checking elapsed time, since this function may finished before the given timeout without having data.
[in] | priv | private IFC data |
[out] | data | received data |
[in,out] | size | expected size to wait for, it is used to return size that was not read |
[in] | tm | timeout |
Definition at line 177 of file ifc_tcpip.c.
|
static |
Definition at line 541 of file ifc_tcpip.c.
void tcpip_receiver_destroy | ( | void * | priv | ) |
Destructor of TCPIP receiver (input ifc)
[in] | priv | pointer to module private data |
Definition at line 520 of file ifc_tcpip.c.
int tcpip_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:
[in,out] | priv | private configuration structure |
[out] | data | where received data are stored |
[out] | size | size of received data |
[in] | timeout | timeout in usec, can be TRAP_WAIT, TRAP_HALFWAIT, or TRAP_NO_WAIT |
messageframe contains header that is read (even partially) in HEAD_WAIT
Definition at line 302 of file ifc_tcpip.c.
void tcpip_receiver_terminate | ( | void * | priv | ) |
Set interface state as terminated.
[in] | priv | pointer to module private data |
Definition at line 504 of file ifc_tcpip.c.
char* tcpip_recv_ifc_get_id | ( | void * | priv | ) |
Definition at line 598 of file ifc_tcpip.c.
uint8_t tcpip_recv_ifc_is_conn | ( | void * | priv | ) |
Definition at line 611 of file ifc_tcpip.c.
|
static |
Function waits for non-blocking connect().
[in] | sock | socket descriptor of client |
[in] | tv | timeout |
Definition at line 769 of file ifc_tcpip.c.