1
/* hash.h - Manage hashes for cached dns records
2
Copyright (C) 2000 Thomas Moestl
4
This file is part of the pdnsd package.
6
pdnsd is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
11
pdnsd 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 pdsnd; see the file COPYING. If not, write to
18
the Free Software Foundation, 59 Temple Place - Suite 330,
19
Boston, MA 02111-1307, USA. */
21
/* $Id: hash.h,v 1.3 2001/05/09 17:51:52 tmm Exp $ */
30
unsigned long rhash; /* this is a better hash */
34
/* Redefine this if you want another hash size. Should work ;-). The number of hash buckets is computed as power of two;
35
* so, eg HASH_SZ set to 10 yields 1024 hash rows (2^10 or 1<<10). Only powers of two are possible conveniently.
36
* If you modify HASH_NUM_BUCKETS, also change HASH_SZ! HASH_SZ may not be bigger than 32 (if you set it even close to
37
* that value, you are nuts.)*/
38
#define HASH_NUM_BUCKETS 1024
41
#define HASH_BITMASK (HASH_NUM_BUCKETS-1)
44
* The hash structures are the same for an ip and an dns hash, so we use
45
* an additional element in debug mode to report misuse.
48
dns_hash_ent_t *(buckets[HASH_NUM_BUCKETS]);
51
/* A type for position specification for fetch_first and fetch_next */
53
int bucket; /* bucket chain we are in */
54
dns_hash_ent_t *ent; /* entry */
57
void mk_hash_ctable(void);
58
void mk_dns_hash(dns_hash_t *hash);
59
void add_dns_hash(dns_hash_t *hash,unsigned char *key, dns_cent_t *data);
60
dns_cent_t *del_dns_hash(dns_hash_t *hash, unsigned char *key);
61
dns_cent_t *dns_lookup(dns_hash_t *hash, unsigned char *key);
62
void free_dns_hash(dns_hash_t *hash);
64
dns_cent_t *fetch_first(dns_hash_t *hash, dns_hash_pos_t *pos);
65
dns_cent_t *fetch_next(dns_hash_t *hash, dns_hash_pos_t *pos);
68
void dumphash(dns_hash_t *hash);