Re-import of fprobe-ulog
[fprobe-ulog.git] / src / hash.h
1 /*
2         Copyright (C) Slava Astashonok <sla@0n.ru>
3
4         This program is free software; you can redistribute it and/or
5         modify it under the terms of the GNU General Public License.
6
7         $Id: hash.h,v 1.1.1.1.2.3.2.1 2005/01/29 19:30:41 sla Exp $
8 */
9
10 #ifndef _HASH_H_
11 #define _HASH_H_
12
13 #ifndef HASH_TYPE_XOR
14 # ifndef HASH_TYPE_CRC
15 #  error HASH_TYPE_XOR or HASH_TYPE_CRC must be defined
16 # endif
17 #else
18 # ifdef HASH_TYPE_CRC
19 #  error HASH_TYPE_XOR or HASH_TYPE_CRC must be defined
20 # endif
21 #endif
22
23 #if HASH_BITS != 16
24 # ifdef HASH_TYPE_CRC
25 #  error illegal value in HASH_BITS
26 # endif
27 # if HASH_BITS != 8
28 #  error illegal value in HASH_BITS
29 # endif
30 #endif
31
32 #include <my_inttypes.h>
33
34 #if HASH_BITS == 8
35 typedef uint8_t hash_t;
36 #endif
37
38 #if HASH_BITS == 16
39 typedef uint16_t hash_t;
40 #endif
41
42 #define CRC16_POLY  0x8005
43
44 #ifndef RNDDEV
45 # define RNDDEV "/dev/random"
46 #endif
47
48 uint16_t crc16(uint16_t, uint8_t);
49 hash_t hash(void *, int);
50 void hash_init();
51
52 #endif