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

TRAP TCP with TLS 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 <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/bio.h>
#include <openssl/pem.h>
#include <openssl/x509.h>
#include <openssl/x509_vfy.h>
#include "../include/libtrap/trap.h"
#include "trap_internal.h"
#include "trap_ifc.h"
#include "trap_error.h"
#include "ifc_tls.h"
#include "ifc_tls_internal.h"
#include "ifc_socket_common.h"
Include dependency graph for ifc_tls.c:

Go to the source code of this file.

Data Structures

union  tls_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(pointer)
 

Functions

static SSL_CTX * tlsserver_create_context ()
 
static SSL_CTX * tlsclient_create_context ()
 
static int verify_certificate (SSL *arg)
 Verify context of ssl. More...
 
static int tls_server_configure_ctx (const char *cert, SSL_CTX *ctx)
 Configure context of ssl server. More...
 
static int tls_configure_ctx (SSL_CTX *ctx, const char *key, const char *crt, const char *ca)
 Configure ssl context of new connection. More...
 
static int client_socket_connect (tls_receiver_private_t *c, 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 TLS socket for sender module. More...
 
static void * get_in_addr (struct sockaddr *sa)
 Get sockaddr, IPv4 or IPv6. More...
 
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 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...
 

Detailed Description

TRAP TCP with TLS interfaces.

Author
Tomas Cejka cejka.nosp@m.t@ce.nosp@m.snet..nosp@m.cz
Jaroslav Hlavac hlava.nosp@m.j20@.nosp@m.fit.c.nosp@m.vut..nosp@m.cz
Date
2018

Definition in file ifc_tls.c.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 45 of file ifc_tls.c.

◆ X

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