|
|
@ -34,7 +34,7 @@ struct hash_table * create_hash(uint32_t buckets) |
|
|
|
table->bucket[i] = NULL; |
|
|
|
|
|
|
|
table->buckets = buckets; |
|
|
|
table->hash_rnd = 0x56789ABC; |
|
|
|
table->hash_rnd = time(NULL); |
|
|
|
|
|
|
|
pthread_mutex_init(&table->mutex, NULL); |
|
|
|
return table; |
|
|
@ -61,6 +61,7 @@ void purge_hash(struct hash_table *table, |
|
|
|
table->bucket[i] = NULL; |
|
|
|
} |
|
|
|
|
|
|
|
table->hash_rnd = time(NULL); |
|
|
|
pthread_mutex_unlock(&table->mutex); |
|
|
|
} |
|
|
|
|
|
|
@ -74,7 +75,7 @@ void destroy_hash(struct hash_table *table) |
|
|
|
static uint32_t calc_hashkey(const struct hash_entry *entry, uint32_t initval) |
|
|
|
{ |
|
|
|
uint32_t a = entry->src_ip; |
|
|
|
uint32_t b = entry->protonum; |
|
|
|
uint32_t b = (entry->flags << 8) | entry->protonum; |
|
|
|
uint32_t c = entry->dst_port; |
|
|
|
|
|
|
|
a += JHASH_GOLDEN_RATIO; |
|
|
@ -90,7 +91,8 @@ static int cmp_entry(const struct hash_entry *a, const struct hash_entry *b) |
|
|
|
{ |
|
|
|
return (a->src_ip ^ b->src_ip) | |
|
|
|
(a->protonum ^ b->protonum) | |
|
|
|
(a->dst_port ^ b->dst_port); |
|
|
|
(a->dst_port ^ b->dst_port) | |
|
|
|
(a->flags ^ b->flags); |
|
|
|
} |
|
|
|
|
|
|
|
void hash_add(struct hash_table *table, struct hash_entry *entry) |
|
|
|