From: Ted Lemon Date: Thu, 27 Jan 2000 22:17:09 +0000 (+0000) Subject: Make a macro to compute option hash table index; parameterize it. X-Git-Tag: V3-BETA-2-PATCH-1~389 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0dbb132f360568b795ea2a42800581f7728c6575;p=thirdparty%2Fdhcp.git Make a macro to compute option hash table index; parameterize it. --- diff --git a/includes/dhcpd.h b/includes/dhcpd.h index e1614b145..427267b29 100644 --- a/includes/dhcpd.h +++ b/includes/dhcpd.h @@ -62,8 +62,15 @@ #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 *,