2019-07-26 09:36:54 +03:00
|
|
|
#ifndef PROTO_H
|
|
|
|
#define PROTO_H
|
|
|
|
|
|
|
|
// OpenVPN sends 2 bytes, thus this is the buffer size.
|
|
|
|
// If another protocol requires more bytes to be detected, the buffer size must be increased.
|
|
|
|
#define PROTO_CHECK_BUFFER_SIZE 2
|
|
|
|
|
|
|
|
#define PROTO_TCP_BUFFER_SIZE (128 * 1024)
|
|
|
|
|
2020-05-11 08:07:04 +03:00
|
|
|
typedef enum PROTO_MODE
|
|
|
|
{
|
|
|
|
PROTO_MODE_UNKNOWN = 0,
|
|
|
|
PROTO_MODE_TCP = 1,
|
|
|
|
PROTO_MODE_UDP = 2
|
|
|
|
} PROTO_MODE;
|
2019-07-26 09:36:54 +03:00
|
|
|
|
2020-05-01 08:14:38 +03:00
|
|
|
typedef struct PROTO
|
|
|
|
{
|
|
|
|
CEDAR *Cedar;
|
|
|
|
LIST *Impls;
|
|
|
|
} PROTO;
|
|
|
|
|
2019-07-26 09:36:54 +03:00
|
|
|
typedef struct PROTO_IMPL
|
|
|
|
{
|
|
|
|
bool (*Init)(void **param, CEDAR *cedar, INTERRUPT_MANAGER *im, SOCK_EVENT *se);
|
|
|
|
void (*Free)(void *param);
|
|
|
|
char *(*Name)();
|
2020-05-11 08:07:04 +03:00
|
|
|
bool (*IsPacketForMe)(const PROTO_MODE mode, const UCHAR *data, const UINT size);
|
2019-07-26 09:36:54 +03:00
|
|
|
bool (*ProcessData)(void *param, TCP_RAW_DATA *received_data, FIFO *data_to_send);
|
|
|
|
void (*BufferLimit)(void *param, const bool reached);
|
|
|
|
} PROTO_IMPL;
|
|
|
|
|
2020-05-01 08:14:38 +03:00
|
|
|
int ProtoImplCompare(void *p1, void *p2);
|
2019-07-26 09:36:54 +03:00
|
|
|
|
2020-05-01 08:14:38 +03:00
|
|
|
PROTO *ProtoNew(CEDAR *cedar);
|
|
|
|
void ProtoDelete(PROTO *proto);
|
2019-07-26 09:36:54 +03:00
|
|
|
|
2020-05-01 08:14:38 +03:00
|
|
|
bool ProtoImplAdd(PROTO *proto, PROTO_IMPL *impl);
|
2020-05-11 08:07:04 +03:00
|
|
|
PROTO_IMPL *ProtoImplDetect(PROTO *proto, const PROTO_MODE mode, const UCHAR *data, const UINT size);
|
2019-07-26 09:36:54 +03:00
|
|
|
|
2020-05-01 08:14:38 +03:00
|
|
|
bool ProtoHandleConnection(PROTO *proto, SOCK *sock);
|
2019-07-26 09:36:54 +03:00
|
|
|
|
|
|
|
#endif
|