Libtrap: Internal development docs  1.16.1
Data Structures | Macros | Typedefs | Functions | Variables
ifc_socket_common.h File Reference

This file contains common functions and structures used in socket based interfaces (tcp-ip / tls). More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  buffer_s
 Output buffer structure. More...
 

Macros

#define BUFFER_COUNT_PARAM_LENGTH   13
 
#define BUFFER_SIZE_PARAM_LENGTH   12
 
#define MAX_CLIENTS_PARAM_LENGTH   12
 
#define DEFAULT_MAX_DATA_LENGTH   (sizeof(trap_buffer_header_t) + 1024)
 
#define DEFAULT_BUFFER_COUNT   50
 
#define DEFAULT_BUFFER_SIZE   100000
 
#define DEFAULT_MAX_CLIENTS   64
 
#define NO_CLIENTS_SLEEP   100000
 

Typedefs

typedef struct buffer_s buffer_t
 Output buffer structure. More...
 

Functions

static void set_index (uint64_t *bits, int i)
 Set i-th element (one bit) of 'bits' to 1. More...
 
static void del_index (uint64_t *bits, int i)
 Set i-th element (one bit) of 'bits' to 0. More...
 
static uint64_t check_index (uint64_t bits, int i)
 Return value of i-th element (one bit) in the 'bits' array. More...
 
static void insert_into_buffer (buffer_t *buffer, const void *data, uint16_t size)
 Write data into buffer. More...
 

Variables

static uint64_t mask [64]
 Array containing constants used for operations with bit arrays. More...
 

Detailed Description

This file contains common functions and structures used in socket based interfaces (tcp-ip / tls).

Author
Matej Barnat barna.nosp@m.ma1@.nosp@m.fit.c.nosp@m.vut..nosp@m.cz
Date
2019

Definition in file ifc_socket_common.h.

Macro Definition Documentation

◆ BUFFER_COUNT_PARAM_LENGTH

#define BUFFER_COUNT_PARAM_LENGTH   13

Used for parsing ifc params

Definition at line 47 of file ifc_socket_common.h.

◆ BUFFER_SIZE_PARAM_LENGTH

#define BUFFER_SIZE_PARAM_LENGTH   12

Used for parsing ifc params

Definition at line 48 of file ifc_socket_common.h.

◆ DEFAULT_BUFFER_COUNT

#define DEFAULT_BUFFER_COUNT   50

Default buffer count

Definition at line 54 of file ifc_socket_common.h.

◆ DEFAULT_BUFFER_SIZE

#define DEFAULT_BUFFER_SIZE   100000

Default buffer size [bytes]

Definition at line 58 of file ifc_socket_common.h.

◆ DEFAULT_MAX_CLIENTS

#define DEFAULT_MAX_CLIENTS   64

Default size of client array

Definition at line 62 of file ifc_socket_common.h.

◆ DEFAULT_MAX_DATA_LENGTH

#define DEFAULT_MAX_DATA_LENGTH   (sizeof(trap_buffer_header_t) + 1024)

Obsolete?

Definition at line 51 of file ifc_socket_common.h.

◆ MAX_CLIENTS_PARAM_LENGTH

#define MAX_CLIENTS_PARAM_LENGTH   12

Used for parsing ifc params

Definition at line 49 of file ifc_socket_common.h.

◆ NO_CLIENTS_SLEEP

#define NO_CLIENTS_SLEEP   100000

Value used in usleep() when waiting for a client to connect

Definition at line 65 of file ifc_socket_common.h.

Typedef Documentation

◆ buffer_t

typedef struct buffer_s buffer_t

Output buffer structure.

Function Documentation

◆ check_index()

static uint64_t check_index ( uint64_t  bits,
int  i 
)
inlinestatic

Return value of i-th element (one bit) in the 'bits' array.

Parameters
[in]bitsPointer to the bit array.
[in]iTarget element's index in the 'bits' array.
Returns
Value of i-th element (one bit) in the 'bits' array.

Definition at line 121 of file ifc_socket_common.h.

◆ del_index()

static void del_index ( uint64_t *  bits,
int  i 
)
inlinestatic

Set i-th element (one bit) of 'bits' to 0.

Parameters
[in]bitsPointer to the bit array.
[in]iTarget element's index in the 'bits' array.

Definition at line 108 of file ifc_socket_common.h.

◆ insert_into_buffer()

static void insert_into_buffer ( buffer_t buffer,
const void *  data,
uint16_t  size 
)
inlinestatic

Write data into buffer.

Parameters
[in]bufferPointer to the buffer.
[in]dataPointer to data to write.
[in]sizeSize of the data.

Definition at line 133 of file ifc_socket_common.h.

◆ set_index()

static void set_index ( uint64_t *  bits,
int  i 
)
inlinestatic

Set i-th element (one bit) of 'bits' to 1.

Parameters
[in]bitsPointer to the bit array.
[in]iTarget element's index in the 'bits' array.

Definition at line 97 of file ifc_socket_common.h.

Variable Documentation

◆ mask

uint64_t mask[64]
static
Initial value:
= {
1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288,
1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824,
2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944,
549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832,
70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248,
4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872,
288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904, 9223372036854775808ULL
}

Array containing constants used for operations with bit arrays.

Definition at line 81 of file ifc_socket_common.h.