d4-core/client/d4.h

78 lines
1.6 KiB
C
Raw Normal View History

2018-11-27 12:47:18 +01:00
#ifndef D4_H
#define D4_H
2018-12-04 14:24:52 +01:00
#include "others/hmac/hmac_sha2.h"
2018-12-03 09:39:44 +01:00
#define ND4PARAMS 7
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
#define SZHMAC 32
2018-11-27 22:37:44 +01:00
#define STDIN "stdin"
#define STDOUT "stdout"
#define MAXSNAPLEN 65535
2018-12-03 14:30:03 +01:00
#define SZUUID 16
2018-12-03 12:00:34 +01:00
#define SZUUID_TEXT 37
#define SZD4HDR 62
#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;
2018-12-03 14:30:03 +01:00
uint8_t uuid[SZUUID];
2018-11-27 12:47:18 +01:00
uint64_t timestamp;
uint8_t hmac[SZHMAC];
2018-11-27 12:47:18 +01:00
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-12-04 14:24:52 +01:00
hmac_sha256_ctx *ctx;
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-12-03 09:39:44 +01:00
const char* d4params[] = {"uuid", "snaplen", "key", "version", "source", "destination","type"};
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-12-03 09:39:44 +01:00
#define TYPE 6
2018-11-27 12:47:18 +01:00
#endif