Debian Codegraph @

include/netlink/hashtable.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3 * Copyright (c) 2012 Cumulus Networks, Inc
4 */
5
6 #ifndef NETLINK_HASHTABLE_H_
7 #define NETLINK_HASHTABLE_H_
8
9 #include <stddef.h>
10 #include <stdint.h>
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 typedef struct nl_hash_node {
17 uint32_t key;
18 uint32_t key_size;
19 struct nl_object *obj;
20 struct nl_hash_node *next;
21 } nl_hash_node_t;
22
23 typedef struct nl_hash_table {
24 int size;
25 nl_hash_node_t **nodes;
26 } nl_hash_table_t;
27
28 /* Default hash table size */
29 #define NL_MAX_HASH_ENTRIES 1024
30
31 /* Access Functions */
32 extern nl_hash_table_t *nl_hash_table_alloc(int size);
33 extern void nl_hash_table_free(nl_hash_table_t *ht);
34
35 extern int nl_hash_table_add(nl_hash_table_t *ht, struct nl_object *obj);
36 extern int nl_hash_table_del(nl_hash_table_t *ht, struct nl_object *obj);
37
38 extern struct nl_object *nl_hash_table_lookup(nl_hash_table_t *ht,
39 struct nl_object *obj);
40 extern uint32_t nl_hash(void *k, size_t length, uint32_t initval);
41
42 #ifdef __cplusplus
43 }
44 #endif
45
46 #endif /* NETLINK_HASHTABLE_H_ */