diff options
author | Luca Deri <deri@ntop.org> | 2021-01-20 21:30:19 +0100 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2021-01-20 21:30:19 +0100 |
commit | 3e5e9569ff6454e11a09d4cbb88efa778508ed05 (patch) | |
tree | a5d15631ae14cbe325a8280e0cddf16d345f1a61 /src/include | |
parent | d964c3e08179fd68da655b5f2975486cf918ff4a (diff) |
Added simple hash implementation to the nDPI API
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/ndpi_api.h.in | 9 | ||||
-rw-r--r-- | src/include/ndpi_typedefs.h | 17 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/include/ndpi_api.h.in b/src/include/ndpi_api.h.in index f5b5f15db..18936f9ff 100644 --- a/src/include/ndpi_api.h.in +++ b/src/include/ndpi_api.h.in @@ -1433,8 +1433,17 @@ extern "C" { u_int8_t num_clusters, u_int16_t *cluster_ids, struct ndpi_bin *centroids); + /* ******************************* */ + u_int32_t ndpi_quick_16_byte_hash(u_int8_t *in_16_bytes_long); + /* ******************************* */ + + ndpi_str_hash* ndpi_hash_alloc(u_int32_t max_num_entries); + void ndpi_hash_free(ndpi_str_hash *h); + int ndpi_hash_find_entry(ndpi_str_hash *h, char *key, u_int key_len, u_int8_t *value); + int ndpi_hash_add_entry(ndpi_str_hash *h, char *key, u_int8_t key_len, u_int8_t value); + #ifdef __cplusplus } #endif diff --git a/src/include/ndpi_typedefs.h b/src/include/ndpi_typedefs.h index 6f9cc9885..76f9198da 100644 --- a/src/include/ndpi_typedefs.h +++ b/src/include/ndpi_typedefs.h @@ -1559,4 +1559,21 @@ struct ndpi_bin { } u; }; +/* **************************************** */ + +struct ndpi_str_hash_info { + char *key; /* Key */ + u_int8_t key_len; + u_int8_t value; /* Value */ + struct ndpi_str_hash_info *next; +}; + +typedef struct { + u_int32_t num_buckets, max_num_entries; + struct ndpi_str_hash_info **buckets; +} ndpi_str_hash; + + +/* **************************************** */ + #endif /* __NDPI_TYPEDEFS_H__ */ |