Replaced nDPI's internal hashmap with uthash. (#1602)
Signed-off-by: lns <matzeton@googlemail.com>
This commit is contained 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);
|
||||
|
||||
/* ******************************* */
|
||||
|
||||
|
||||
@@ -1608,19 +1608,12 @@ struct ndpi_bin {
|
||||
|
||||
/* **************************************** */
|
||||
|
||||
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;
|
||||
typedef struct ndpi_str_hash {
|
||||
unsigned int hash;
|
||||
void *value;
|
||||
u_int8_t private_data[0];
|
||||
} ndpi_str_hash;
|
||||
|
||||
|
||||
/* **************************************** */
|
||||
|
||||
#define HW_HISTORY_LEN 4
|
||||
|
||||
Reference in New Issue
Block a user