From 974c1cc681af5a8faa6e7186a947a76a045b266f Mon Sep 17 00:00:00 2001 From: Nardi Ivan Date: Thu, 2 Jul 2020 09:42:53 +0200 Subject: Improve help message of --dbg-proto option Make it clear that such option is general, not about extcap functionality --- example/ndpiReader.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'example/ndpiReader.c') diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 57f8048df..1b20ac2f9 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -383,7 +383,8 @@ static void help(u_int long_help) { " | 3 = port stats\n" " -V <1-4> | nDPI logging level\n" " | 1 - trace, 2 - debug, 3 - full debug\n" - " | >3 - full debug + dbg_proto = all\n" + " | >3 - full debug + log enabled for all protocols (i.e. '-u all')\n" + " -u proto|num[,...] | Enable logging only for such protocol(s)\n" " -T | Max number of TCP processed packets before giving up [default: %u]\n" " -U | Max number of UDP processed packets before giving up [default: %u]\n" , @@ -402,7 +403,6 @@ static void help(u_int long_help) { " --extcap-capture-filter\n" " --fifo \n" " --debug\n" - " --dbg-proto proto|num[,...]\n" ); #endif @@ -434,7 +434,6 @@ static struct option longopts[] = { { "extcap-capture-filter", required_argument, NULL, '6'}, { "fifo", required_argument, NULL, '7'}, { "debug", no_argument, NULL, '8'}, - { "dbg-proto", required_argument, NULL, 257}, { "ndpi-proto-filter", required_argument, NULL, '9'}, /* ndpiReader options */ @@ -453,6 +452,7 @@ static struct option longopts[] = { { "revision", no_argument, NULL, 'r'}, { "verbose", no_argument, NULL, 'v'}, { "version", no_argument, NULL, 'V'}, + { "dbg-proto", required_argument, NULL, 'u'}, { "help", no_argument, NULL, 'h'}, { "joy", required_argument, NULL, 'J'}, { "payload-analysis", required_argument, NULL, 'P'}, @@ -660,7 +660,7 @@ static void parseOptions(int argc, char **argv) { } #endif - while((opt = getopt_long(argc, argv, "e:c:C:df:g:i:hp:P:l:s:tv:V:n:Jrp:w:q0123:456:7:89:m:T:U:", + while((opt = getopt_long(argc, argv, "e:c:C:df:g:i:hp:P:l:s:tv:V:u:n:Jrp:w:q0123:456:7:89:m:T:U:", longopts, &option_idx)) != EOF) { #ifdef DEBUG_TRACE if(trace) fprintf(trace, " #### -%c [%s] #### \n", opt, optarg ? optarg : ""); @@ -740,6 +740,10 @@ static void parseOptions(int argc, char **argv) { } break; + case 'u': + _debug_protocols = strdup(optarg); + break; + case 'h': help(1); break; @@ -823,10 +827,6 @@ static void parseOptions(int argc, char **argv) { if(extcap_packet_filter == NDPI_PROTOCOL_UNKNOWN) extcap_packet_filter = atoi(optarg); break; - case 257: - _debug_protocols = strdup(optarg); - break; - case 'T': max_num_tcp_dissected_pkts = atoi(optarg); if(max_num_tcp_dissected_pkts < 3) max_num_tcp_dissected_pkts = 3; -- cgit v1.2.3 From 030f3f3d48184133a6647108c156787fb3f39b58 Mon Sep 17 00:00:00 2001 From: Nardi Ivan Date: Tue, 7 Jul 2020 10:26:11 +0200 Subject: Fix a memory leak --- example/ndpiReader.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'example/ndpiReader.c') diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 1b20ac2f9..4be142d28 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -384,7 +384,9 @@ static void help(u_int long_help) { " -V <1-4> | nDPI logging level\n" " | 1 - trace, 2 - debug, 3 - full debug\n" " | >3 - full debug + log enabled for all protocols (i.e. '-u all')\n" - " -u proto|num[,...] | Enable logging only for such protocol(s)\n" + " -u all|proto|num[,...] | Enable logging only for such protocol(s)\n" + " | If this flag is present multiple times (directly, or via '-V'),\n" + " | only the last instance will be considered\n" " -T | Max number of TCP processed packets before giving up [default: %u]\n" " -U | Max number of UDP processed packets before giving up [default: %u]\n" , @@ -736,11 +738,13 @@ static void parseOptions(int argc, char **argv) { if(nDPI_LogLevel < 0) nDPI_LogLevel = 0; if(nDPI_LogLevel > 3) { nDPI_LogLevel = 3; + free(_debug_protocols); _debug_protocols = strdup("all"); } break; case 'u': + free(_debug_protocols); _debug_protocols = strdup(optarg); break; @@ -819,6 +823,7 @@ static void parseOptions(int argc, char **argv) { case '8': nDPI_LogLevel = NDPI_LOG_DEBUG_EXTRA; + free(_debug_protocols); _debug_protocols = strdup("all"); break; @@ -3525,6 +3530,7 @@ int orginal_main(int argc, char **argv) { 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); + free(_debug_protocols); return 0; } -- cgit v1.2.3