1238106Sdes/* 2238106Sdes * util/storage/lookup3.h - header file for hashing functions. 3238106Sdes * 4238106Sdes * Copyright (c) 2007, NLnet Labs. All rights reserved. 5238106Sdes * 6238106Sdes * This software is open source. 7238106Sdes * 8238106Sdes * Redistribution and use in source and binary forms, with or without 9238106Sdes * modification, are permitted provided that the following conditions 10238106Sdes * are met: 11238106Sdes * 12238106Sdes * Redistributions of source code must retain the above copyright notice, 13238106Sdes * this list of conditions and the following disclaimer. 14238106Sdes * 15238106Sdes * Redistributions in binary form must reproduce the above copyright notice, 16238106Sdes * this list of conditions and the following disclaimer in the documentation 17238106Sdes * and/or other materials provided with the distribution. 18238106Sdes * 19238106Sdes * Neither the name of the NLNET LABS nor the names of its contributors may 20238106Sdes * be used to endorse or promote products derived from this software without 21238106Sdes * specific prior written permission. 22238106Sdes * 23238106Sdes * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24266114Sdes * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25266114Sdes * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26266114Sdes * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27266114Sdes * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28266114Sdes * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29266114Sdes * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30266114Sdes * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31266114Sdes * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32266114Sdes * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33266114Sdes * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34238106Sdes */ 35238106Sdes 36238106Sdes/** 37238106Sdes * \file 38238106Sdes * 39238106Sdes * This file contains header definitions for the hash functions we use. 40238106Sdes * The hash functions are public domain (see lookup3.c). 41238106Sdes */ 42238106Sdes 43238106Sdes#ifndef UTIL_STORAGE_LOOKUP3_H 44238106Sdes#define UTIL_STORAGE_LOOKUP3_H 45238106Sdes 46238106Sdes/** 47238106Sdes * Hash key made of 4byte chunks. 48238106Sdes * @param k: the key, an array of uint32_t values 49238106Sdes * @param length: the length of the key, in uint32_ts 50238106Sdes * @param initval: the previous hash, or an arbitrary value 51238106Sdes * @return: hash value. 52238106Sdes */ 53238106Sdesuint32_t hashword(const uint32_t *k, size_t length, uint32_t initval); 54238106Sdes 55238106Sdes/** 56238106Sdes * Hash key data. 57238106Sdes * @param k: the key, array of uint8_t 58238106Sdes * @param length: the length of the key, in uint8_ts 59238106Sdes * @param initval: the previous hash, or an arbitrary value 60238106Sdes * @return: hash value. 61238106Sdes */ 62238106Sdesuint32_t hashlittle(const void *k, size_t length, uint32_t initval); 63238106Sdes 64238106Sdes/** 65238106Sdes * Set the randomisation initial value, set this before threads start, 66238106Sdes * and before hashing stuff (because it changes subsequent results). 67238106Sdes * @param v: value 68238106Sdes */ 69238106Sdesvoid hash_set_raninit(uint32_t v); 70238106Sdes 71238106Sdes#endif /* UTIL_STORAGE_LOOKUP3_H */ 72