lookup3.h revision 269257
1314817Sngie/* 2272343Sngie * util/storage/lookup3.h - header file for hashing functions. 3272343Sngie * 4272343Sngie * Copyright (c) 2007, NLnet Labs. All rights reserved. 5272343Sngie * 6272343Sngie * This software is open source. 7272343Sngie * 8272343Sngie * Redistribution and use in source and binary forms, with or without 9272343Sngie * modification, are permitted provided that the following conditions 10272343Sngie * are met: 11272343Sngie * 12272343Sngie * Redistributions of source code must retain the above copyright notice, 13272343Sngie * this list of conditions and the following disclaimer. 14272343Sngie * 15272343Sngie * Redistributions in binary form must reproduce the above copyright notice, 16272343Sngie * this list of conditions and the following disclaimer in the documentation 17272343Sngie * and/or other materials provided with the distribution. 18272343Sngie * 19272343Sngie * Neither the name of the NLNET LABS nor the names of its contributors may 20272343Sngie * be used to endorse or promote products derived from this software without 21272343Sngie * specific prior written permission. 22272343Sngie * 23272343Sngie * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24272343Sngie * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25272343Sngie * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26272343Sngie * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27272343Sngie * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28272343Sngie * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29272343Sngie * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30272343Sngie * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31272343Sngie * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32314817Sngie * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33272343Sngie * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34272343Sngie */ 35272343Sngie 36272343Sngie/** 37272343Sngie * \file 38272343Sngie * 39272343Sngie * This file contains header definitions for the hash functions we use. 40272343Sngie * The hash functions are public domain (see lookup3.c). 41272343Sngie */ 42272343Sngie 43272343Sngie#ifndef UTIL_STORAGE_LOOKUP3_H 44272343Sngie#define UTIL_STORAGE_LOOKUP3_H 45272343Sngie 46272343Sngie/** 47272343Sngie * Hash key made of 4byte chunks. 48276478Sngie * @param k: the key, an array of uint32_t values 49272343Sngie * @param length: the length of the key, in uint32_ts 50272343Sngie * @param initval: the previous hash, or an arbitrary value 51272343Sngie * @return: hash value. 52272343Sngie */ 53330422Sbdreweryuint32_t hashword(const uint32_t *k, size_t length, uint32_t initval); 54330422Sbdrewery 55330422Sbdrewery/** 56330422Sbdrewery * Hash key data. 57330422Sbdrewery * @param k: the key, array of uint8_t 58330422Sbdrewery * @param length: the length of the key, in uint8_ts 59330422Sbdrewery * @param initval: the previous hash, or an arbitrary value 60330422Sbdrewery * @return: hash value. 61330422Sbdrewery */ 62272343Sngieuint32_t hashlittle(const void *k, size_t length, uint32_t initval); 63272343Sngie 64272343Sngie/** 65272343Sngie * Set the randomisation initial value, set this before threads start, 66272343Sngie * and before hashing stuff (because it changes subsequent results). 67272343Sngie * @param v: value 68272343Sngie */ 69272343Sngievoid hash_set_raninit(uint32_t v); 70272343Sngie 71272343Sngie#endif /* UTIL_STORAGE_LOOKUP3_H */ 72272343Sngie