]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
host: convert host hash to use lookup3.c
authorVictor Julien <victor@inliniac.net>
Tue, 27 Mar 2012 08:38:15 +0000 (10:38 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 27 Mar 2012 08:38:15 +0000 (10:38 +0200)
src/host.c

index f0136ca740d432fabda5b4fdc0d04f151f2f4977..7d98278270a2c76f3a15673ac70725fe08b969e2 100644 (file)
@@ -38,6 +38,8 @@
 #include "detect-tag.h"
 #include "detect-engine-threshold.h"
 
+#include "util-hash-lookup3.h"
+
 static Host *HostGetUsedHost(void);
 
 /** queue with spare hosts */
@@ -286,11 +288,11 @@ uint32_t HostGetKey(Address *a) {
     uint32_t key;
 
     if (a->family == AF_INET) {
-        key = (host_config.hash_rand + a->addr_data32[0]) % host_config.hash_size;
+        uint32_t hash = hashword(&a->addr_data32[0], 1, host_config.hash_rand);
+        key = hash % host_config.hash_size;
     } else if (a->family == AF_INET6) {
-        key = (host_config.hash_rand + a->addr_data32[0] + \
-               a->addr_data32[1] + a->addr_data32[2] + \
-               a->addr_data32[3]) % host_config.hash_size;
+        uint32_t hash = hashword(a->addr_data32, 4, host_config.hash_rand);
+        key = hash % host_config.hash_size;
     } else
         key = 0;