diff options
author | Toni <matzeton@googlemail.com> | 2022-06-17 19:50:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-17 19:50:31 +0200 |
commit | 9c8b2d63dafc526ff3f0872e8e88e67f72d875d1 (patch) | |
tree | b71901c710a90ecaa115213960b5ffb7ed636317 /src/include/ndpi_api.h.in | |
parent | 20a29c393f5cff3864a75070b2988fe1be1c6d17 (diff) |
Replaced nDPI's internal hashmap with uthash. (#1602)
Signed-off-by: lns <matzeton@googlemail.com>
Diffstat (limited to 'src/include/ndpi_api.h.in')
-rw-r--r-- | src/include/ndpi_api.h.in | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/src/include/ndpi_api.h.in b/src/include/ndpi_api.h.in index 36d592b8d..ed1016aea 100644 --- a/src/include/ndpi_api.h.in +++ b/src/include/ndpi_api.h.in @@ -1693,10 +1693,52 @@ extern "C" { /* ******************************* */ - 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); + /** + * Initialize the hashmap. + * + * @par h = pointer to the hash map [in, out] + * + * @return 0 on success, 1 otherwise + * + */ + int ndpi_hash_init(ndpi_str_hash **h); + + /** + * Free the hashmap. + * + * @par h = pointer to the hash map [in, out] + * @par cleanup_func = pointer to a optional callback function + * called for each element in the hashmap [in] + * + */ + void ndpi_hash_free(ndpi_str_hash **h, void (*cleanup_func)(ndpi_str_hash *h)); + + /** + * Search for an entry in the hashmap. + * + * @par h = pointer to the hash map [in] + * @par key = character string (no '\0' required) [in] + * @par key_len = length of the character string @key [in] + * @par value = pointer to a pointer to the value, which contains a + * previously added hash entry [in, out] + * + * @return 0 if an entry with that key was found, 1 otherwise + * + */ + int ndpi_hash_find_entry(ndpi_str_hash *h, char *key, u_int key_len, void **value); + + /** + * Add an entry to the hashmap. + * + * @par h = pointer to the hash map [in, out] + * @par key = character string (no '\0' required) [in] + * @par key_len = length of the character string @key [in] + * @par value = pointer to the value to add [in] + * + * @return 0 if the entry was added, 1 otherwise + * + */ + int ndpi_hash_add_entry(ndpi_str_hash **h, char *key, u_int8_t key_len, void *value); /* ******************************* */ |