Commit 7d4625d5 authored by Chen Wei's avatar Chen Wei

update doc

parent 1291b335
/* dict.c is Copyright (c) 2015 Chen Wei <weichen302@gmail.com>
Use a dictionary like structure to store config options for fast lookup
Use cascade of open addressing hash tables to store config options that
involve domain names.
root
|
+---------------------+
com org
| |
+------------------+ +-------------+
yahoo google twitter debian freebsd
| | | |
www mail +---------+ www
cn jp uk us
|
ftp
The lookup steps over domain name hierarchy top-down. All labels are stored
in open addressing hash tables. Sub-level labels that belong to different
parent nodes are stored separately. e.g. yahoo, google, and twitter are in
one hash table, while debian and freebsd are in another.
The hash table size is power of 2, two hash functions are used to compute
hash bucket. For locating a particular label from hash table, two hash
values are compared first, only if they are match, should the more
expensive string comparison be used to confirm the search.
The search should take constant time regardless the size of --ipset and
--server rules.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -21,7 +49,6 @@
#define OPEN_ADDRESSING_MAXJUMP 7 /* no reason, just like 7 */
#define OPEN_ADDRESSING_DEFAULT_SLOT 4
#define FNV1_32A_INIT ((uint32_t)0x811c9dc5)
#define FNV_32_PRIME ((uint32_t)0x01000193)
#define max(A, B) ((A) > (B) ? (A) : (B))
static char buf[MAXDNAME];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment