aboutsummaryrefslogtreecommitdiff
path: root/src/include/ndpi_utils.h
diff options
context:
space:
mode:
authorRoberto AGOSTINO <roberto.agostino@sistemiditlc.it>2021-02-03 10:28:51 +0100
committerGitHub <noreply@github.com>2021-02-03 10:28:51 +0100
commitb70ad0e2f19aa1d6f4b3b64208e14c6e5839d60a (patch)
tree4ba76c7f9a3ac3baab27697a2f040e5d02788f07 /src/include/ndpi_utils.h
parentee945349063418882eb7a4a968fe72176c4eda04 (diff)
fragments management added (#1122)
Management of tcp segments managements. Co-authored-by: ragostino <ragostino73@gmail.com> Co-authored-by: Luca Deri <lucaderi@users.noreply.github.com>
Diffstat (limited to 'src/include/ndpi_utils.h')
-rw-r--r--src/include/ndpi_utils.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/include/ndpi_utils.h b/src/include/ndpi_utils.h
new file mode 100644
index 000000000..296bd6254
--- /dev/null
+++ b/src/include/ndpi_utils.h
@@ -0,0 +1,74 @@
+
+
+#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 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;
+#ifdef NDPI_DETECTION_SUPPORT_IPV6
+ char *flow_label; // IP6
+#endif
+ 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);
+
+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