Revert "Patricia tree, Ahocarasick automa, LRU cache: add statistics (#1677)" (#1682)

This reverts commit bb83899985.
This commit is contained in:
Ivan Nardi
2022-07-29 12:08:40 +02:00
committed by GitHub
parent bb83899985
commit df2e11ef51
9 changed files with 8 additions and 378 deletions
-32
View File
@@ -925,28 +925,6 @@ extern "C" {
*/
void ndpi_finalize_automa(void *_automa);
/**
* Get the automa statistics
*
* @par The automata initialized with ndpi_init_automa();
*
*/
void ndpi_automa_get_stats(void *_automa, struct ndpi_automa_stats *stats);
/**
* Get the statistics of one of the automas used internally by the library
*
* @par ndpi_mod = the detection module
* @par automa_type = of which automa we want the stats
* @par stats = buffer where to save the stats
* @return 0 in case of no error, or -1 if an error occurred.
*
*/
int ndpi_get_automa_stats(struct ndpi_detection_module_struct *ndpi_struct,
automa_type automa_type,
struct ndpi_automa_stats *stats);
/**
* Add a string to match to an automata
*
@@ -1004,11 +982,6 @@ extern "C" {
u_int8_t ndpi_lru_find_cache(struct ndpi_lru_cache *c, u_int32_t key,
u_int16_t *value, u_int8_t clean_key_when_found);
void ndpi_lru_add_to_cache(struct ndpi_lru_cache *c, u_int32_t key, u_int16_t value);
void ndpi_lru_get_stats(struct ndpi_lru_cache *c, struct ndpi_lru_cache_stats *stats);
int ndpi_get_lru_cache_stats(struct ndpi_detection_module_struct *ndpi_struct,
lru_cache_type cache_type,
struct ndpi_lru_cache_stats *stats);
/**
* Find a protocol id associated with a string automata
@@ -1123,11 +1096,6 @@ extern "C" {
ndpi_prefix_t *ndpi_patricia_get_node_prefix(ndpi_patricia_node_t *node);
u_int16_t ndpi_patricia_get_node_bits(ndpi_patricia_node_t *node);
u_int16_t ndpi_patricia_get_maxbits(ndpi_patricia_tree_t *tree);
void ndpi_patricia_get_stats(ndpi_patricia_tree_t *tree, struct ndpi_patricia_tree_stats *stats);
int ndpi_get_patricia_stats(struct ndpi_detection_module_struct *ndpi_struct,
ptree_type ptree_type,
struct ndpi_patricia_tree_stats *stats);
/* ptree (trie) API - a wrapper on top of Patricia that seamlessly handle IPv4 and IPv6 */
ndpi_ptree_t* ndpi_ptree_create(void);
-6
View File
@@ -99,16 +99,10 @@ typedef struct _ndpi_patricia_node_t {
union ndpi_patricia_node_value_t value;
} ndpi_patricia_node_t;
struct ndpi_patricia_tree_stats {
u_int64_t n_search;
u_int64_t n_found;
};
typedef struct _ndpi_patricia_tree_t {
ndpi_patricia_node_t *head;
u_int16_t maxbits; /* for IP, 32 bit addresses */
int num_active_node; /* for debug purpose */
struct ndpi_patricia_tree_stats stats;
} ndpi_patricia_tree_t;
#endif /* _NDPI_PATRICIA_TYPEDEF_H_ */
+4 -54
View File
@@ -595,55 +595,13 @@ typedef enum {
NDPI_HTTP_METHOD_RPC_OUT_DATA,
} ndpi_http_method;
typedef enum {
NDPI_PTREE_RISK_MASK = 0,
NDPI_PTREE_RISK,
NDPI_PTREE_PROTOCOLS,
NDPI_PTREE_MAX /* Last one! */
} ptree_type;
typedef enum {
NDPI_AUTOMA_HOST = 0,
NDPI_AUTOMA_DOMAIN,
NDPI_AUTOMA_TLS_CERT,
NDPI_AUTOMA_RISK_MASK,
NDPI_AUTOMA_COMMON_ALPNS,
NDPI_AUTOMA_MAX /* Last one! */
} automa_type;
struct ndpi_automa_stats {
u_int64_t n_search;
u_int64_t n_found;
};
typedef enum {
NDPI_LRUCACHE_OOKLA = 0,
NDPI_LRUCACHE_BITTORRENT,
NDPI_LRUCACHE_ZOOM,
NDPI_LRUCACHE_STUN,
NDPI_LRUCACHE_TLS_CERT,
NDPI_LRUCACHE_MINING,
NDPI_LRUCACHE_MSTEAMS,
NDPI_LRUCACHE_MAX /* Last one! */
} lru_cache_type;
struct ndpi_lru_cache_entry {
u_int32_t key; /* Store the whole key to avoid ambiguities */
u_int32_t is_full:1, value:16, pad:15;
};
struct ndpi_lru_cache_stats {
u_int64_t n_insert;
u_int64_t n_search;
u_int64_t n_found;
};
struct ndpi_lru_cache {
u_int32_t num_entries;
struct ndpi_lru_cache_stats stats;
struct ndpi_lru_cache_entry *entries;
};
@@ -1055,7 +1013,6 @@ typedef struct ndpi_default_ports_tree_node {
typedef struct _ndpi_automa {
void *ac_automa; /* Real type is AC_AUTOMATA_t */
struct ndpi_automa_stats stats;
} ndpi_automa;
typedef struct ndpi_str_hash {
@@ -1154,28 +1111,23 @@ struct ndpi_detection_module_struct {
ndpi_automa host_automa, /* Used for DNS/HTTPS */
risky_domain_automa, tls_cert_subject_automa,
host_risk_mask_automa, common_alpns_automa;
/* IMPORTANT: please, whenever you add a new automa:
* update ndpi_finalize_initialization()
* update automa_type above
*/
ndpi_str_hash *malicious_ja3_hashmap, *malicious_sha1_hashmap;
/* IMPORTANT: please update ndpi_finalize_initialization() whenever you add a new automa */
ndpi_list *trusted_issuer_dn;
void *ip_risk_mask_ptree;
void *ip_risk_ptree;
/* IP-based protocol detection */
void *protocols_ptree;
/* *** If you add a new Patricia tree, please update ptree_type above! *** */
struct {
ndpi_automa hostnames, hostnames_shadow;
void *ipAddresses, *ipAddresses_shadow; /* Patricia */
u_int8_t categories_loaded;
} custom_categories;
/* IP-based protocol detection */
void *protocols_ptree;
u_int8_t ip_version_limit;
/* NDPI_PROTOCOL_OOKLA */
@@ -1202,8 +1154,6 @@ struct ndpi_detection_module_struct {
/* NDPI_PROTOCOL_MSTEAMS */
struct ndpi_lru_cache *msteams_cache;
/* *** If you add a new LRU cache, please update lru_cache_type above! *** */
ndpi_proto_defaults_t proto_defaults[NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS];
u_int8_t direction_detect_disable:1, /* disable internal detection of packet direction */ _pad:7;