New API for library configuration

This is the first step into providing (more) configuration options in nDPI.

The idea is to have a simple way to configure (most of) nDPI: only one
function (`ndpi_set_config()`) to set any configuration parameters
(in the present or on in the future) and we try to keep this function
prototype as agnostic as possible.

You can configure the library:
* via API, using `ndpi_set_config()`
* via a configuration file, in a text format

This way, anytime we need to add a new configuration parameter:
* we don't need to add two public functions (a getter and a setter)
* we don't break API/ABI compatibility of the library; even changing
the parameter type (from integer to a list of integer, for example)
doesn't break the compatibility.

The complete list of configuration options is provided in
`doc/configuration_parameters.md`.

As a first example, two configuration knobs are provided:
* the ability to enable/disable the extraction of the sha1 fingerprint of
the TLS certificates.
* the upper limit on the number of packets per flow that will be subject
to inspection
This commit is contained in:
Nardi Ivan
2024-01-18 10:21:24 +01:00
committed by Ivan Nardi
parent ca7df1db82
commit d72a760ac3
52 changed files with 740 additions and 77 deletions
+15 -2
View File
@@ -144,13 +144,24 @@ typedef struct {
} nbpf_filter;
#endif
#define CFG_MAX_LEN 256
struct ndpi_detection_module_config_struct {
int max_packets_to_process;
char filename_config[CFG_MAX_LEN];
/* Protocols */
int tls_sha1_fingerprint_enabled;
};
struct ndpi_detection_module_struct {
NDPI_PROTOCOL_BITMASK detection_bitmask;
u_int64_t current_ts;
u_int16_t max_packets_to_process;
u_int16_t num_tls_blocks_to_follow;
u_int8_t skip_tls_blocks_until_change_cipher:1, _notused:7;
u_int8_t skip_tls_blocks_until_change_cipher:1, finalized:1, _notused:6;
u_int8_t tls_certificate_expire_in_x_days;
void *user_data;
@@ -226,6 +237,8 @@ struct ndpi_detection_module_struct {
u_int8_t ip_version_limit;
struct ndpi_detection_module_config_struct cfg;
/* NDPI_PROTOCOL_TINC */
struct cache *tinc_cache;