d4-core/client/d4.h

72 lines
1.4 KiB
C
Raw Normal View History

2018-11-27 12:47:18 +01:00
#ifndef D4_H
#define D4_H
2018-11-27 22:05:42 +01:00
#define ND4PARAMS 6
2018-11-27 15:30:58 +01:00
#define NERRORS 100
#define SZCONFVALUE 1024
2018-11-27 15:30:58 +01:00
#define SZERRVALUE 1024
2018-11-27 22:37:44 +01:00
#define STDIN "stdin"
#define STDOUT "stdout"
#define MAXSNAPLEN 65535
#define SZUUID 128
2018-11-27 22:37:44 +01:00
#define INSERT_ERROR(...) do { \
if (d4->err_idx < NERRORS) \
snprintf(d4->errors[d4->err_idx],SZERRVALUE,__VA_ARGS__); \
2018-11-27 17:35:31 +01:00
d4->err_idx++;\
} while(0)
2018-11-27 12:47:18 +01:00
typedef struct d4_header_s {
uint8_t version;
uint8_t type;
uint8_t uuid[128];
uint64_t timestamp;
uint8_t hmac[256];
uint32_t size;
} d4_header_t;
// Information about the source
typedef struct source_s {
int fd;
} source_t;
//Information about the destination
//Write data to stdout, fifo, shared memory segment
typedef struct destination_s {
int fd;
} destination_t;
typedef struct d4_s {
source_t source;
destination_t destination;
char confdir[FILENAME_MAX];
int snaplen;
int caplen;
int d4_error;
int errno_copy;
char conf[ND4PARAMS][SZCONFVALUE];
2018-11-27 15:30:58 +01:00
char errors[NERRORS][SZERRVALUE];
int err_idx;
d4_header_t header;
2018-11-27 12:47:18 +01:00
} d4_t;
/* D4 configuration is a directory structure shown below (like proc filesytem)
* d4-conf/snaplen
* d4-conf/caplen
* d4-conf/uuid
* d4-conf/collector
*/
2018-11-27 22:05:42 +01:00
const char* d4params[] = {"uuid", "snaplen", "key", "version", "source", "destination"};
2018-11-27 12:47:18 +01:00
#define UUID 0
#define SNAPLEN 1
2018-11-27 22:05:42 +01:00
#define KEY 2
#define VERSION 3
#define SOURCE 4
#define DESTINATION 5
2018-11-27 12:47:18 +01:00
#endif