57 |
/* Cache already exists */ |
/* Cache already exists */ |
58 |
return; |
return; |
59 |
|
|
60 |
negcache_trie = New_Patricia(PATRICIA_MAXBITS); |
negcache_trie = patricia_new(PATRICIA_MAXBITS); |
61 |
negcache_list = list_create(); |
negcache_list = list_create(); |
62 |
} |
} |
63 |
|
|
71 |
if (OptionsItem->negcache == 0) |
if (OptionsItem->negcache == 0) |
72 |
return NULL; |
return NULL; |
73 |
|
|
74 |
patricia_node_t *pnode = try_search_exact(negcache_trie, ipstr); |
patricia_node_t *pnode = patricia_try_search_exact(negcache_trie, ipstr); |
75 |
if (pnode) |
if (pnode) |
76 |
{ |
{ |
77 |
struct negcache_item *n = pnode->data; |
struct negcache_item *n = pnode->data; |
90 |
void |
void |
91 |
negcache_insert(const char *ipstr) |
negcache_insert(const char *ipstr) |
92 |
{ |
{ |
93 |
patricia_node_t *pnode = make_and_lookup(negcache_trie, ipstr); |
patricia_node_t *pnode = patricia_make_and_lookup(negcache_trie, ipstr); |
94 |
if (!pnode || pnode->data) |
if (!pnode || pnode->data) |
95 |
return; /* Malformed IP address or already added to the trie */ |
return; /* Malformed IP address or already added to the trie */ |
96 |
|
|
118 |
{ |
{ |
119 |
if (OPT_DEBUG >= 2) |
if (OPT_DEBUG >= 2) |
120 |
log_printf("NEGCACHE -> Deleting expired negcache node for %s added at %lu", |
log_printf("NEGCACHE -> Deleting expired negcache node for %s added at %lu", |
121 |
prefix_toa(pnode->prefix), n->seen); |
patricia_prefix_toa(pnode->prefix, 0), n->seen); |
122 |
|
|
123 |
list_remove(negcache_list, node); |
list_remove(negcache_list, node); |
124 |
node_free(node); |
node_free(node); |