1 #ifndef __FHASH_H_ 2 #define __FHASH_H_ 3 4 #include <sys/queue.h> 5 #include "tcp_stream.h" 6 7 #define NUM_BINS (131072) /* 132 K entries per thread*/ 8 #define TCP_AR_CNT (3) 9 10 #define STATIC_TABLE FALSE 11 #define INVALID_HASH (NUM_BINS + 1) 12 13 typedef struct hash_bucket_head { 14 tcp_stream *tqh_first; 15 tcp_stream **tqh_last; 16 } hash_bucket_head; 17 18 /* hashtable structure */ 19 struct hashtable { 20 uint8_t ht_count ; // count for # entry 21 22 #if STATIC_TABLE 23 tcp_stream* ht_array[NUM_BINS][TCP_AR_CNT]; 24 #endif 25 hash_bucket_head ht_table[NUM_BINS]; 26 }; 27 28 /*functions for hashtable*/ 29 struct hashtable *CreateHashtable(void); 30 void DestroyHashtable(struct hashtable *ht); 31 32 33 int HTInsert(struct hashtable *ht, tcp_stream *, unsigned int *hash); 34 void* HTRemove(struct hashtable *ht, tcp_stream *); 35 tcp_stream* HTSearch(struct hashtable *ht, const tcp_stream *, unsigned int *hash); 36 37 #endif /* __FHASH_H_ */ 38