1/*	$Id: hash.h,v 1.1.1.1 2006/12/04 00:45:29 Exp $	*/
2
3/*
4 * Copyright (C) International Business Machines  Corp., 2003
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 *    may be used to endorse or promote products derived from this software
17 *    without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32/* Author: Elizabeth Kon, beth@us.ibm.com */
33
34#ifndef DHCPV6_HASH_H
35#define DHCPV6_HASH_H
36
37#define DEFAULT_HASH_SIZE 4096-1
38
39#define MATCH 0
40#define MISCOMPARE 1
41#define HASH_COLLISION        2
42#define HASH_ITEM_NOT_FOUND   3
43
44struct hashlist_element {
45        struct hashlist_element *next;
46        void *data;
47};
48
49struct hash_table {
50        unsigned int hash_count;
51        unsigned int hash_size;
52        struct hashlist_element **hash_list;
53        unsigned int (*hash_function)(const void *hash_key);
54	void * (*find_hashkey)(const void *data);
55        int (*compare_hashkey)(const void *data, const void *key);
56};
57
58
59extern int init_hashes(void);
60extern struct hash_table * hash_table_create(unsigned int hash_size,
61	unsigned int (*hash_function)(const void *hash_key),
62	void * (*find_hashkey)(const void *data),
63	int (*compare_hashkey)(const void *data, const void *hashkey));
64extern int  hash_add(struct hash_table *table, const void *key, void *data);
65extern int hash_delete(struct hash_table *table, const void *key);
66extern void * hash_search(struct hash_table *table, const void *key);
67extern int hash_full(struct hash_table *table);
68extern int grow_hash(struct hash_table *table);
69#endif
70