]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Make a macro to compute option hash table index; parameterize it.
authorTed Lemon <source@isc.org>
Thu, 27 Jan 2000 22:17:09 +0000 (22:17 +0000)
committerTed Lemon <source@isc.org>
Thu, 27 Jan 2000 22:17:09 +0000 (22:17 +0000)
includes/dhcpd.h

index e1614b145a0e762947a7bd097f4c5316a1d0c5e2..427267b29c5c4d76f9957cbd087f13cd6350587a 100644 (file)
 
 #if !defined (OPTION_HASH_SIZE)
 # define OPTION_HASH_SIZE 17
+# define OPTION_HASH_PTWO 32   /* Next power of two above option hash. */
+# define OPTION_HASH_EXP 5     /* The exponent for that power of two. */
 #endif
 
+#define compute_option_hash(x) \
+       (((x) & (OPTION_HASH_PTWO - 1)) + \
+        (((x) >> OPTION_HASH_EXP) & \
+         (OPTION_HASH_PTWO - 1))) % OPTION_HASH_SIZE;
+
 /* Client FQDN option, failover FQDN option, etc. */
 typedef struct {
        u_int8_t codes [2];
@@ -856,9 +863,11 @@ void delete_hashed_option PROTO ((struct universe *,
 int option_cache_dereference PROTO ((struct option_cache **,
                                     const char *, int));
 int hashed_option_state_dereference PROTO ((struct universe *,
-                                           struct option_state *));
+                                           struct option_state *,
+                                           const char *, int));
 int agent_option_state_dereference PROTO ((struct universe *,
-                                          struct option_state *));
+                                          struct option_state *,
+                                          const char *, int));
 int store_option PROTO ((struct data_string *,
                         struct universe *, struct packet *, struct lease *,
                         struct option_state *, struct option_state *,