diff options
Diffstat (limited to 'hicn-light/src/hicn/core/listener_table.h')
-rw-r--r-- | hicn-light/src/hicn/core/listener_table.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/hicn-light/src/hicn/core/listener_table.h b/hicn-light/src/hicn/core/listener_table.h index 91b68ee94..91e985221 100644 --- a/hicn-light/src/hicn/core/listener_table.h +++ b/hicn-light/src/hicn/core/listener_table.h @@ -40,8 +40,8 @@ #define _lt_var(x) _lt_var_##x /* Hash functions for indices */ -#define key_hash(key) (hash(key, sizeof(listener_key_t))) -#define key_hash_eq(a, b) (key_hash(b) - key_hash(a)) +#define key_hash(key) (hash_struct(key)) +#define key_hash_eq(a, b) (key_hash(b) == key_hash(a)) /* Hash table types for indices */ KHASH_MAP_INIT_STR(lt_name, unsigned); @@ -72,7 +72,7 @@ typedef struct { */ #define listener_table_allocate(TABLE, LISTENER, KEY, NAME) \ do { \ - pool_get(table->listeners, (LISTENER)); \ + pool_get(TABLE->listeners, (LISTENER)); \ if (LISTENER) { \ off_t _lt_var(id) = (LISTENER) - (TABLE)->listeners; \ int _lt_var(res); \ @@ -176,6 +176,11 @@ do { ? listener_table_at(table, id) : NULL /** + * @brief Helper function to avoid macro expansion in c++ tests. Wrapper around 'listener_table_get_by_id'. + */ +listener_t *_listener_table_get_by_id(listener_table_t *table, off_t id); + +/** * @brief Returns the index of a given listener in the listener table. * * @param[in] table The listener table from which to retrieve the index. @@ -248,6 +253,9 @@ listener_t * listener_table_get_by_name(listener_table_t * table, */ void listener_table_remove_by_id(listener_table_t * table, off_t id); -unsigned listener_table_add(listener_table_t * table, listener_t * listener); +// TODO: not implemented yet +unsigned listener_table_add(const listener_table_t * table, listener_t * listener); + +void listener_table_print(const listener_table_t *table); #endif /* HICNLIGHT_LISTENER_TABLE_H */ |