aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2024-01-20 16:14:41 +0100
committerGitHub <noreply@github.com>2024-01-20 16:14:41 +0100
commit42d23cff6a87825e6d3bc8e81080e6a9102f7709 (patch)
tree8987bfac24ff24de845e1a6ae369513c3567740e /example
parent8651ce981149a73df6f2d9d64218ef58a4479c46 (diff)
config: follow-up (#2268)
Some changes in the parameters names. Add a fuzzer to fuzz the configuration file format. Add the infrastructure to configuratin callbacks. Add an helper to map LRU cache indexes to names.
Diffstat (limited to 'example')
-rw-r--r--example/config.txt4
-rw-r--r--example/ndpiReader.c16
2 files changed, 10 insertions, 10 deletions
diff --git a/example/config.txt b/example/config.txt
index 95b66b1b6..bf48e22b8 100644
--- a/example/config.txt
+++ b/example/config.txt
@@ -5,8 +5,8 @@
#See doc/configuration_parameters.md for a complete list and description of all the accepted knobs
packets_limit_per_flow,32
-ookla,aggressiveness,0x1
-tls,metadata.sha1_fingerprint.enable,1
+ookla,dpi.aggressiveness,0x1
+tls,metadata.sha1_fingerprint,1
lru.bittorrent.ttl,0
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 7aa0d2ae6..ecb2a7477 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -384,7 +384,7 @@ static void ndpiCheckIPMatch(char *testChar) {
for(i = 0; i < num_cfgs; i++) {
rc = ndpi_set_config(ndpi_str,
cfgs[i].proto, cfgs[i].param, cfgs[i].value);
- if (rc < NDPI_CFG_OK)
+ if (rc != NDPI_CFG_OK)
fprintf(stderr, "Error setting config [%s][%s][%s]: %d\n",
cfgs[i].proto, cfgs[i].param, cfgs[i].value, rc);
}
@@ -557,7 +557,7 @@ static void help(u_int long_help) {
" | 0 - List known protocols\n"
" | 1 - List known categories\n"
" | 2 - List known risks\n"
- " -d | Disable protocol guess (by ip and by port) and use only DPI. It is a shortcut to --cfg=,NULL,guess_on_giveup,0\n"
+ " -d | Disable protocol guess (by ip and by port) and use only DPI. It is a shortcut to --cfg=dpi.guess_on_giveup,0\n"
" -e <len> | Min human readeable string match len. Default %u\n"
" -q | Quiet mode\n"
" -F | Enable flow stats\n"
@@ -1021,7 +1021,7 @@ static void parseOptions(int argc, char **argv) {
case 'd':
enable_protocol_guess = 0;
- if(reader_add_cfg(NULL, "guess_on_giveup", "0", 1) == 1) {
+ if(reader_add_cfg(NULL, "dpi.guess_on_giveup", "0", 1) == 1) {
printf("Invalid parameter [%s] [num:%d/%d]\n", optarg, num_cfgs, MAX_NUM_CFGS);
exit(1);
}
@@ -1134,7 +1134,7 @@ static void parseOptions(int argc, char **argv) {
}
if(log_level > NDPI_LOG_DEBUG_EXTRA) {
log_level = NDPI_LOG_DEBUG_EXTRA;
- if(reader_add_cfg("all", "log.enable", "1", 1) == 1) {
+ if(reader_add_cfg("all", "log", "enable", 1) == 1) {
printf("Invalid cfg [num:%d/%d]\n", num_cfgs, MAX_NUM_CFGS);
exit(1);
}
@@ -1155,7 +1155,7 @@ static void parseOptions(int argc, char **argv) {
int inverted_logic;
/* Reset any previous call to this knob */
- if(reader_add_cfg("all", "log.enable", "0", 1) == 1) {
+ if(reader_add_cfg("all", "log", "disable", 1) == 1) {
printf("Invalid cfg [num:%d/%d]\n", num_cfgs, MAX_NUM_CFGS);
exit(1);
}
@@ -1166,7 +1166,7 @@ static void parseOptions(int argc, char **argv) {
inverted_logic = 1;
n++;
}
- if(reader_add_cfg(n, "log.enable", inverted_logic ? "0" : "1", 1) == 1) {
+ if(reader_add_cfg(n, "log", inverted_logic ? "disable" : "enable", 1) == 1) {
printf("Invalid parameter [%s] [num:%d/%d]\n", n, num_cfgs, MAX_NUM_CFGS);
exit(1);
}
@@ -2829,7 +2829,7 @@ static void setupDetection(u_int16_t thread_id, pcap_t * pcap_handle) {
if(_protoFilePath != NULL)
ndpi_load_protocols_file(ndpi_thread_info[thread_id].workflow->ndpi_struct, _protoFilePath);
- ndpi_set_config(ndpi_thread_info[thread_id].workflow->ndpi_struct, NULL, "tcp_ack_payload_heuristic.enable", "1");
+ ndpi_set_config(ndpi_thread_info[thread_id].workflow->ndpi_struct, NULL, "tcp_ack_payload_heuristic", "enable");
for(i = 0; i < num_cfgs; i++) {
rc = ndpi_set_config(ndpi_thread_info[thread_id].workflow->ndpi_struct,
@@ -2840,7 +2840,7 @@ static void setupDetection(u_int16_t thread_id, pcap_t * pcap_handle) {
}
if(enable_doh_dot_detection)
- ndpi_set_config(ndpi_thread_info[thread_id].workflow->ndpi_struct, "tls", "application_blocks_tracking.enable", "1");
+ ndpi_set_config(ndpi_thread_info[thread_id].workflow->ndpi_struct, "tls", "application_blocks_tracking", "enable");
ret = ndpi_finalize_initialization(ndpi_thread_info[thread_id].workflow->ndpi_struct);
if(ret != 0) {