aboutsummaryrefslogtreecommitdiff
path: root/src/include/ndpi_utils.h
blob: 4d72849e13173e15047bf1666a3b5f2fac9a04dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef __NDPI_UTILS_H__
#define __NDPI_UTILS_H__

#include "ndpi_define.h"

#define MYDBG(m, ...) \
	printf(" DBG[%s:%s:%u]: \t" m "\n", __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__);

// #define NDPI_ENABLE_DEBUG_POINTER_MESSAGES
// #define NDPI_ENABLE_DEBUG_INFO_MESSAGES
// #define NDPI_ENABLE_DEBUG_TRACE_MESSAGES

#ifdef FRAG_MAN
#ifdef NDPI_ENABLE_DEBUG_POINTER_MESSAGES
#define DBGPOINTER(m, args...) MYDBG(m, ##args)
#else
#define DBGPOINTER(m, args...) 
#endif

#ifdef NDPI_ENABLE_DEBUG_INFO_MESSAGES
#define DBGINFO(m, args...) MYDBG(m, ##args)
#else
#define DBGINFO(m, args...) 
#endif

#ifdef NDPI_ENABLE_DEBUG_TRACE_MESSAGES
#define DBGTRACER(m, args...) MYDBG(m, ##args)
#else
#define DBGTRACER(m, args...) 
#endif

// FRAGMENTATION
typedef struct {
    uint32_t offset;
    size_t len;
    void *data;    
} fragment_t;

typedef struct fragment_wrapper {
     uint16_t id;
     uint8_t l4_protocol;
     uint32_t initial_offset;
     uint16_t ct_frag;
     char   *flow_label;    // IP6
     char gap[200];
     fragment_t **fragments_list;
} fragments_wrapper_t;

typedef struct fragments_buffer  {
    u_int8_t *buffer;
    u_int buffer_len, buffer_used;
} fragments_buffer_t;

// SORTING 
typedef struct  {
	int sort_value;
	int item_index;
} sorter_index_item_t;


/* ***************************************************** */

extern void ins_sort_array(sorter_index_item_t arr[], int len);
extern void shell_sort_array(sorter_index_item_t arr[], int len);
extern void free_fragment(fragments_wrapper_t *frag);

#endif


extern void printRawData(const uint8_t *ptr, size_t len);
//extern uint8_t add_segment_to_buffer( struct ndpi_flow_struct *flow, struct ndpi_tcphdr const * tcph, uint32_t waited);
//extern uint8_t check_for_sequence( struct ndpi_flow_struct *flow, struct ndpi_tcphdr const * tcph);

#endif