1 /* See the DRL-LICENSE file for this file's software license. */
6 #define _XOPEN_SOURCE 600 /* for pthread_rwlock_t */
14 #include <linux/jhash.h>
16 #define MAP_KEY_SIZE 4 /* all 4 bytes for now */
17 #define GENERIC_HASH_SIZE 16 /* must be powers of 2 */
19 enum bool {false=0,true};
22 struct map_entry *table[GENERIC_HASH_SIZE];
24 struct map_entry *iterator;
29 struct map_entry *nxt;
35 typedef struct map *map_handle;
37 /* function prototypes */
41 void ip_from_bytes(uint32_t addr, char *buf);
44 double myrand_double();
47 /* hash map interface */
48 void init_hashing(void);
49 map_handle allocate_map(void);
50 void free_map(map_handle map, int dealloc);
51 void** map_to_array(map_handle map, int *length);
52 void* map_search(map_handle map,void *key, int keylen);
53 void map_reset_iterate(map_handle map);
54 void* map_next(map_handle table);
55 void* map_remove(map_handle map,void *key, int keylen);
56 void map_insert(map_handle map, void *key, int keylen, void *value);
57 int map_size(map_handle map);