1 /****************************************************************************
3 * Copyright (C) 2003-2009 Sourcefire, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License Version 2 as
7 * published by the Free Software Foundation. You may not use, modify or
8 * distribute this program under any other version of the GNU General
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 ****************************************************************************/
25 #ifndef SFHASHFCN_INCLUDE
26 #define SFHASHFCN_INCLUDE
33 #define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
37 a -= c; a ^= rot(c, 4); c += b; \
38 b -= a; b ^= rot(a, 6); a += c; \
39 c -= b; c ^= rot(b, 8); b += a; \
40 a -= c; a ^= rot(c,16); c += b; \
41 b -= a; b ^= rot(a,19); a += c; \
42 c -= b; c ^= rot(b, 4); b += a; \
45 #define final(a,b,c) \
47 c ^= b; c -= rot(b,14); \
48 a ^= c; a -= rot(c,11); \
49 b ^= a; b -= rot(a,25); \
50 c ^= b; c -= rot(b,16); \
51 a ^= c; a -= rot(c,4); \
52 b ^= a; b -= rot(a,14); \
53 c ^= b; c -= rot(b,24); \
56 typedef struct _SFHASHFCN
{
61 unsigned (*hash_fcn
)(struct _SFHASHFCN
* p
,
64 int (*keycmp_fcn
)( const void *s1
,
69 SFHASHFCN
* sfhashfcn_new( int nrows
);
70 void sfhashfcn_free( SFHASHFCN
* p
);
71 void sfhashfcn_static( SFHASHFCN
* p
);
73 unsigned sfhashfcn_hash( SFHASHFCN
* p
, unsigned char *d
, int n
);
75 int sfhashfcn_set_keyops( SFHASHFCN
* p
,
76 unsigned (*hash_fcn
)( SFHASHFCN
* p
,
79 int (*keycmp_fcn
)( const void *s1
,