ctstats/hashtable.h

37 lines
713 B
C
Raw Normal View History

2007-03-24 19:49:30 +01:00
#ifndef _HASHTABLE_H_
#define _HASHTABLE_H_
#include <inttypes.h>
#include <pthread.h>
struct hash_entry {
struct hash_entry *next;
uint32_t src_ip;
uint16_t dst_port;
2007-04-08 17:02:24 +02:00
uint8_t protonum;
uint8_t flags;
2007-03-24 19:49:30 +01:00
uint64_t src_bytes;
uint64_t dst_bytes;
uint32_t count;
};
struct hash_table {
uint32_t buckets;
uint32_t hash_rnd;
pthread_mutex_t mutex;
struct hash_entry *bucket[0];
};
struct hash_table * create_hash(uint32_t buckets);
void purge_hash(struct hash_table *table,
2007-03-31 21:16:52 +02:00
void (*callback)(const struct hash_entry *entry, void *privdata),
2007-03-24 19:49:30 +01:00
void *privdata);
void destroy_hash(struct hash_table *table);
void hash_add(struct hash_table *table, struct hash_entry *entry);
#endif /* _HASHTABLE_H_ */