diff options
author | Luca Deri <deri@ntop.org> | 2024-10-10 18:10:03 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2024-10-10 18:10:03 +0200 |
commit | 2e5edd2cc956b420f6b9e2a2ffec7d435694a69a (patch) | |
tree | 51cafc72126996a24cb821ba5050ca6a9081f5e8 /example/reader_util.c | |
parent | b9348e9d6e0e754c4b17661c643ca258f1540ca1 (diff) |
Added -N option for dumping/restoring the DNS cache (when enabled)
Example ndpiReader -i en0 --cfg=dpi.address_cache_size,32768 -N /tmp/a
Diffstat (limited to 'example/reader_util.c')
-rw-r--r-- | example/reader_util.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/example/reader_util.c b/example/reader_util.c index 5ddb9f000..8ed32cad4 100644 --- a/example/reader_util.c +++ b/example/reader_util.c @@ -80,7 +80,7 @@ extern u_int8_t verbose, human_readeable_string_len; extern u_int8_t max_num_udp_dissected_pkts /* 24 */, max_num_tcp_dissected_pkts /* 80 */; static u_int32_t flow_id = 0; extern FILE *fingerprint_fp; - +extern char *addr_dump_path; u_int8_t enable_doh_dot_detection = 0; extern bool do_load_lists; extern int malloc_size_stats; @@ -404,6 +404,7 @@ int parse_proto_name_list(char *str, NDPI_PROTOCOL_BITMASK *bitmask, int inverte else NDPI_BITMASK_DEL(*bitmask,proto); } + ndpi_exit_detection_module(module); return 0; } @@ -456,6 +457,7 @@ struct ndpi_workflow* ndpi_workflow_init(const struct ndpi_workflow_prefs * pref if(do_init_flows_root) { workflow->ndpi_flows_root = ndpi_calloc(workflow->prefs.num_roots, sizeof(void *)); + if(!workflow->ndpi_flows_root) { ndpi_exit_detection_module(module); ndpi_free(workflow); @@ -592,6 +594,9 @@ void ndpi_workflow_free(struct ndpi_workflow * workflow) { for(i=0; i<workflow->prefs.num_roots; i++) ndpi_tdestroy(workflow->ndpi_flows_root[i], ndpi_flow_info_freer); + if(addr_dump_path != NULL) + ndpi_cache_address_dump(workflow->ndpi_struct, addr_dump_path, 0); + ndpi_exit_detection_module(workflow->ndpi_struct); ndpi_free(workflow->ndpi_flows_root); ndpi_free(workflow); @@ -2020,6 +2025,11 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow, *flow_risk = 0 /* NDPI_NO_RISK */; *flow = NULL; + if((addr_dump_path != NULL) && (workflow->stats.raw_packet_count == 0)) { + /* At the first packet flush expired cached addresses */ + ndpi_cache_address_flush_expired(workflow->ndpi_struct, header->ts.tv_sec); + } + /* Increment raw packet counter */ workflow->stats.raw_packet_count++; |