From 6b69e7ebbc55538b75daf925177c8cbe59a4e7b8 Mon Sep 17 00:00:00 2001 From: Nardi Ivan Date: Mon, 25 May 2020 19:04:52 +0200 Subject: Restore extcap functionality, i.e. integration with wireshark --- example/ndpiReader.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'example/ndpiReader.c') diff --git a/example/ndpiReader.c b/example/ndpiReader.c index a24756c7d..c4b3ab99c 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -840,6 +840,11 @@ static void parseOptions(int argc, char **argv) { printCSVHeader(); #ifndef USE_DPDK + if(do_capture) { + quiet_mode = 1; + extcap_capture(); + } + if(strchr(_pcap_file[0], ',')) { /* multiple ingress interfaces */ num_threads = 0; /* setting number of threads = number of interfaces */ __pcap_file = strtok(_pcap_file[0], ","); -- cgit v1.2.3 From 70a926088f64f3a12c4bd3373001281de6ab991f Mon Sep 17 00:00:00 2001 From: Nardi Ivan Date: Wed, 27 May 2020 13:06:07 +0200 Subject: Fixed harmless memory leak in extcap initialization --- example/ndpiReader.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'example/ndpiReader.c') diff --git a/example/ndpiReader.c b/example/ndpiReader.c index c4b3ab99c..57f8048df 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -172,6 +172,7 @@ struct ndpi_packet_trailer { }; static pcap_dumper_t *extcap_dumper = NULL; +static pcap_t *extcap_fifo_h = NULL; static char extcap_buf[16384]; static char *extcap_capture_fifo = NULL; static u_int16_t extcap_packet_filter = (u_int16_t)-1; @@ -559,7 +560,16 @@ void extcap_capture() { if(trace) fprintf(trace, " #### %s #### \n", __FUNCTION__); #endif - if((extcap_dumper = pcap_dump_open(pcap_open_dead(DLT_EN10MB, 16384 /* MTU */), + if((extcap_fifo_h = pcap_open_dead(DLT_EN10MB, 16384 /* MTU */)) == NULL) { + fprintf(stderr, "Error pcap_open_dead"); + +#ifdef DEBUG_TRACE + if(trace) fprintf(trace, "Error pcap_open_dead\n"); +#endif + return; + } + + if((extcap_dumper = pcap_dump_open(extcap_fifo_h, extcap_capture_fifo)) == NULL) { fprintf(stderr, "Unable to open the pcap dumper on %s", extcap_capture_fifo); @@ -3512,6 +3522,7 @@ int orginal_main(int argc, char **argv) { if(results_path) free(results_path); if(results_file) fclose(results_file); if(extcap_dumper) pcap_dump_close(extcap_dumper); + if(extcap_fifo_h) pcap_close(extcap_fifo_h); if(ndpi_info_mod) ndpi_exit_detection_module(ndpi_info_mod); if(csv_fp) fclose(csv_fp); -- cgit v1.2.3