diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/ndpi_api.h | 16 | ||||
-rw-r--r-- | src/include/ndpi_typedefs.h | 10 |
2 files changed, 23 insertions, 3 deletions
diff --git a/src/include/ndpi_api.h b/src/include/ndpi_api.h index f1a64f26b..d9e48047f 100644 --- a/src/include/ndpi_api.h +++ b/src/include/ndpi_api.h @@ -992,12 +992,15 @@ extern "C" { void ndpi_set_log_level(struct ndpi_detection_module_struct *ndpi_mod, u_int l); void ndpi_set_debug_bitmask(struct ndpi_detection_module_struct *ndpi_mod, NDPI_PROTOCOL_BITMASK debug_bitmask); + /* Simple helper to get current time, in sec */ + u_int32_t ndpi_get_current_time(struct ndpi_flow_struct *flow); + /* LRU cache */ - struct ndpi_lru_cache* ndpi_lru_cache_init(u_int32_t num_entries); + struct ndpi_lru_cache* ndpi_lru_cache_init(u_int32_t num_entries, u_int32_t ttl); void ndpi_lru_free_cache(struct ndpi_lru_cache *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); + u_int16_t *value, u_int8_t clean_key_when_found, u_int32_t now_sec); + void ndpi_lru_add_to_cache(struct ndpi_lru_cache *c, u_int32_t key, u_int16_t value, u_int32_t now_sec); 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, @@ -1011,6 +1014,13 @@ extern "C" { lru_cache_type cache_type, u_int32_t num_entries); + int ndpi_set_lru_cache_ttl(struct ndpi_detection_module_struct *ndpi_struct, + lru_cache_type cache_type, + u_int32_t ttl); + int ndpi_get_lru_cache_ttl(struct ndpi_detection_module_struct *ndpi_struct, + lru_cache_type cache_type, + u_int32_t *ttl); + int ndpi_set_opportunistic_tls(struct ndpi_detection_module_struct *ndpi_struct, u_int16_t proto, int value); int ndpi_get_opportunistic_tls(struct ndpi_detection_module_struct *ndpi_struct, diff --git a/src/include/ndpi_typedefs.h b/src/include/ndpi_typedefs.h index 022c21ce0..8c1b1823a 100644 --- a/src/include/ndpi_typedefs.h +++ b/src/include/ndpi_typedefs.h @@ -641,6 +641,7 @@ typedef enum { 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; + u_int32_t timestamp; /* sec */ }; struct ndpi_lru_cache_stats { @@ -651,6 +652,7 @@ struct ndpi_lru_cache_stats { struct ndpi_lru_cache { u_int32_t num_entries; + u_int32_t ttl; struct ndpi_lru_cache_stats stats; struct ndpi_lru_cache_entry *entries; }; @@ -1187,32 +1189,40 @@ struct ndpi_detection_module_struct { /* NDPI_PROTOCOL_OOKLA */ struct ndpi_lru_cache *ookla_cache; u_int32_t ookla_cache_num_entries; + u_int32_t ookla_cache_ttl; /* NDPI_PROTOCOL_BITTORRENT */ struct ndpi_lru_cache *bittorrent_cache; u_int32_t bittorrent_cache_num_entries; + u_int32_t bittorrent_cache_ttl; /* NDPI_PROTOCOL_ZOOM */ struct ndpi_lru_cache *zoom_cache; u_int32_t zoom_cache_num_entries; + u_int32_t zoom_cache_ttl; /* NDPI_PROTOCOL_STUN and subprotocols */ struct ndpi_lru_cache *stun_cache; u_int32_t stun_cache_num_entries; + u_int32_t stun_cache_ttl; struct ndpi_lru_cache *stun_zoom_cache; u_int32_t stun_zoom_cache_num_entries; + u_int32_t stun_zoom_cache_ttl; /* NDPI_PROTOCOL_TLS and subprotocols */ struct ndpi_lru_cache *tls_cert_cache; u_int32_t tls_cert_cache_num_entries; + int32_t tls_cert_cache_ttl; /* NDPI_PROTOCOL_MINING and subprotocols */ struct ndpi_lru_cache *mining_cache; u_int32_t mining_cache_num_entries; + u_int32_t mining_cache_ttl; /* NDPI_PROTOCOL_MSTEAMS */ struct ndpi_lru_cache *msteams_cache; u_int32_t msteams_cache_num_entries; + u_int32_t msteams_cache_ttl; /* *** If you add a new LRU cache, please update lru_cache_type above! *** */ |