diff options
author | emanuele-f <black.silver@hotmail.it> | 2016-04-20 01:32:01 +0200 |
---|---|---|
committer | emanuele-f <black.silver@hotmail.it> | 2016-04-20 01:32:01 +0200 |
commit | 9ee64420045028f20a655bce34fe795aefdb288e (patch) | |
tree | cc8d9ed2b13ac508694b8bc0546fbef5208ef143 /src/include | |
parent | 6f84b853584919659673aaa1161f0a5f4365e6a6 (diff) |
Other util API stuff
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/ndpi_util.h | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/include/ndpi_util.h b/src/include/ndpi_util.h index c7d1e6745..daa564b69 100644 --- a/src/include/ndpi_util.h +++ b/src/include/ndpi_util.h @@ -87,20 +87,25 @@ typedef struct ndpi_workflow_prefs { u_int32_t detection_tick_resolution; } ndpi_workflow_prefs_t; +struct ndpi_workflow; +/** workflow, flow, user data */ +typedef void (*ndpi_workflow_callback_ptr) (struct ndpi_workflow *, struct ndpi_flow_info *, void *); + typedef struct ndpi_workflow { u_int64_t last_time; - u_int64_t last_idle_scan_time; - u_int32_t idle_scan_idx; - u_int32_t num_idle_flows; /* TODO_EMA decide if idle flows will be handled */ struct ndpi_workflow_prefs prefs; struct ndpi_stats stats; + ndpi_workflow_callback_ptr __flow_detected_callback; + void * __flow_detected_udata; + ndpi_workflow_callback_ptr __flow_giveup_callback; + void * __flow_giveup_udata; + /* outside referencies */ pcap_t *pcap_handle; /* allocated by prefs */ - struct ndpi_flow_info **idle_flows; void **ndpi_flows_root; struct ndpi_detection_module_struct *ndpi_struct; } ndpi_workflow_t; @@ -109,7 +114,8 @@ typedef struct ndpi_workflow { struct ndpi_workflow * ndpi_workflow_init(const struct ndpi_workflow_prefs * prefs, pcap_t * pcap_handle, void * (*malloc_wrapper)(size_t), - void (*free_wrapper)(void*)); + void (*free_wrapper)(void*), + ndpi_debug_function_ptr ndpi_debug_printf); void ndpi_workflow_free(struct ndpi_workflow * workflow); @@ -117,5 +123,22 @@ void ndpi_workflow_free(struct ndpi_workflow * workflow); void ndpi_workflow_process_packet (struct ndpi_workflow * workflow, const struct pcap_pkthdr *header, const u_char *packet); + +/* flow callbacks: ndpi_flow_info will be freed right after */ +inline void ndpi_workflow_set_flow_detected_callback(struct ndpi_workflow * workflow, + ndpi_workflow_callback_ptr callback, + void * udata) { + workflow->__flow_detected_callback = callback; + workflow->__flow_detected_udata = udata; +} + +inline void ndpi_workflow_set_flow_giveup_callback(struct ndpi_workflow * workflow, + ndpi_workflow_callback_ptr callback, + void * udata) { + workflow->__flow_giveup_callback = callback; + workflow->__flow_giveup_udata = udata; +} + +int ndpi_workflow_node_cmp(const void *a, const void *b); #endif |