Libtrap: Internal development docs  1.16.1
Data Structures | Macros | Functions
ifc_tcpip.c File Reference

TRAP TCP/IP interfaces. More...

#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <inttypes.h>
#include <pthread.h>
#include <errno.h>
#include <semaphore.h>
#include <assert.h>
#include <poll.h>
#include "../include/libtrap/trap.h"
#include "trap_internal.h"
#include "trap_ifc.h"
#include "trap_error.h"
#include "ifc_tcpip.h"
#include "ifc_tcpip_internal.h"
#include "ifc_socket_common.h"
Include dependency graph for ifc_tcpip.c:

Go to the source code of this file.

Data Structures

union  tcpip_socket_addr
 

Macros

#define _GNU_SOURCE
 
#define MAX_RECOVERY_TRY   10
 
#define RECOVERY_WAIT_USEC   500000
 
#define USEC_IN_SEC   1000000
 
#define ACK_MESS_SIZE   1
 
#define CRIT_1VS2SEND   10000
 
#define MAX(a, b)   ((a)<(b)?(b):(a))
 
#define MIN(a, b)   ((a)>(b)?(b):(a))
 
#define X(p)
 
#define X(pointer)
 
#define X(x)   free(x); x = NULL;
 
#define X(pointer)
 

Functions

char *trap_default_socket_path_format __attribute__ ((used))
 
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...
 
static void client_socket_disconnect (void *priv)
 
static int server_socket_open (void *priv)
 Open TCPIP socket for sender module. More...
 
static void * get_in_addr (struct sockaddr *sa)
 Get sockaddr, IPv4 or IPv6. More...
 
static int check_portrange (const char *port)
 Check if the given port is a correct port number. More...
 
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 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...
 

Detailed Description

TRAP TCP/IP interfaces.

Author
Tomas Cejka cejka.nosp@m.t@ce.nosp@m.snet..nosp@m.cz
Date
2018

Definition in file ifc_tcpip.c.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 44 of file ifc_tcpip.c.

◆ X [1/4]

#define X (   p)
Value:
if (p != NULL) { \
free(p); \
p = NULL; \
}

◆ X [2/4]

#define X (   pointer)
Value:
free(pointer); \
pointer = NULL;

◆ X [3/4]

#define X (   x)    free(x); x = NULL;

◆ X [4/4]

#define X (   pointer)
Value:
free(pointer); \
pointer = NULL;