Electroneum
val_neg.h
Go to the documentation of this file.
1 /*
2  * validator/val_neg.h - validator aggressive negative caching functions.
3  *
4  * Copyright (c) 2008, NLnet Labs. All rights reserved.
5  *
6  * This software is open source.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * Neither the name of the NLNET LABS nor the names of its contributors may
20  * be used to endorse or promote products derived from this software without
21  * specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
45 #ifndef VALIDATOR_VAL_NEG_H
46 #define VALIDATOR_VAL_NEG_H
47 #include "util/locks.h"
48 #include "util/rbtree.h"
49 struct sldns_buffer;
50 struct val_neg_data;
51 struct config_file;
52 struct reply_info;
53 struct rrset_cache;
54 struct regional;
55 struct query_info;
56 struct dns_msg;
57 struct ub_packed_rrset_key;
58 
67 struct val_neg_cache {
76  struct val_neg_data* last;
78  size_t use;
80  size_t max;
89 };
90 
94 struct val_neg_zone {
100  size_t len;
102  int labs;
103 
106 
110  int count;
111 
115  size_t nsec3_iter;
120 
124 
129 };
130 
142 struct val_neg_data {
148  size_t len;
150  int labs;
151 
154 
158  int count;
159 
162 
167 
170 };
171 
178 struct val_neg_cache* val_neg_create(struct config_file* cfg, size_t maxiter);
179 
185 size_t val_neg_get_mem(struct val_neg_cache* neg);
186 
191 void neg_cache_delete(struct val_neg_cache* neg);
192 
196 int val_neg_data_compare(const void* a, const void* b);
197 
201 int val_neg_zone_compare(const void* a, const void* b);
202 
209 void val_neg_addreply(struct val_neg_cache* neg, struct reply_info* rep);
210 
218 void val_neg_addreferral(struct val_neg_cache* neg, struct reply_info* rep,
219  uint8_t* zone);
220 
238 int val_neg_dlvlookup(struct val_neg_cache* neg, uint8_t* qname, size_t len,
239  uint16_t qclass, struct rrset_cache* rrset_cache, time_t now);
240 
264 struct dns_msg* val_neg_getmsg(struct val_neg_cache* neg,
265  struct query_info* qinfo, struct regional* region,
266  struct rrset_cache* rrset_cache, struct sldns_buffer* buf, time_t now,
267  int addsoa, uint8_t* topname, struct config_file* cfg);
268 
269 
270 /**** functions exposed for unit test ****/
278 void neg_insert_data(struct val_neg_cache* neg,
279  struct val_neg_zone* zone, struct ub_packed_rrset_key* nsec);
280 
289 void neg_delete_data(struct val_neg_cache* neg, struct val_neg_data* el);
290 
300 struct val_neg_zone* neg_find_zone(struct val_neg_cache* neg,
301  uint8_t* nm, size_t len, uint16_t dclass);
302 
312 struct val_neg_zone* neg_create_zone(struct val_neg_cache* neg,
313  uint8_t* nm, size_t nm_len, uint16_t dclass);
314 
321 
322 #endif /* VALIDATOR_VAL_NEG_H */
int nsec3_hash
Definition: val_neg.h:113
struct val_neg_data * next
Definition: val_neg.h:166
void val_neg_zone_take_inuse(struct val_neg_zone *zone)
Definition: dns.h:61
struct dns_msg * val_neg_getmsg(struct val_neg_cache *neg, struct query_info *qinfo, struct regional *region, struct rrset_cache *rrset_cache, struct sldns_buffer *buf, time_t now, int addsoa, uint8_t *topname, struct config_file *cfg)
size_t nsec3_saltlen
Definition: val_neg.h:119
void neg_insert_data(struct val_neg_cache *neg, struct val_neg_zone *zone, struct ub_packed_rrset_key *nsec)
size_t nsec3_max_iter
Definition: val_neg.h:82
uint8_t * name
Definition: val_neg.h:146
struct val_neg_zone * zone
Definition: val_neg.h:161
size_t len
Definition: val_neg.h:148
size_t nsec3_iter
Definition: val_neg.h:115
int val_neg_zone_compare(const void *a, const void *b)
Easylogging++ entry namespace.
void neg_cache_delete(struct val_neg_cache *neg)
size_t len
Definition: val_neg.h:100
rbtree_type tree
Definition: val_neg.h:123
unsigned short uint16_t
Definition: stdint.h:125
lock_basic_type lock
Definition: val_neg.h:70
unsigned char uint8_t
Definition: stdint.h:124
rbtree_type tree
Definition: val_neg.h:72
struct val_neg_zone * parent
Definition: val_neg.h:105
struct val_neg_data * last
Definition: val_neg.h:76
rbnode_type node
Definition: val_neg.h:96
uint16_t dclass
Definition: val_neg.h:126
rbnode_type node
Definition: val_neg.h:144
uint8_t * nsec3_salt
Definition: val_neg.h:117
size_t num_neg_cache_noerror
Definition: val_neg.h:85
int lock_basic_type
Definition: locks.h:269
uint8_t in_use
Definition: val_neg.h:169
size_t val_neg_get_mem(struct val_neg_cache *neg)
struct val_neg_cache * val_neg_create(struct config_file *cfg, size_t maxiter)
void val_neg_addreply(struct val_neg_cache *neg, struct reply_info *rep)
const char * buf
Definition: slow_memmem.cpp:74
void val_neg_addreferral(struct val_neg_cache *neg, struct reply_info *rep, uint8_t *zone)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
struct val_neg_data * prev
Definition: val_neg.h:164
struct val_neg_zone * neg_find_zone(struct val_neg_cache *neg, uint8_t *nm, size_t len, uint16_t dclass)
struct val_neg_data * parent
Definition: val_neg.h:153
size_t max
Definition: val_neg.h:80
size_t num_neg_cache_nxdomain
Definition: val_neg.h:88
int val_neg_dlvlookup(struct val_neg_cache *neg, uint8_t *qname, size_t len, uint16_t qclass, struct rrset_cache *rrset_cache, time_t now)
void neg_delete_data(struct val_neg_cache *neg, struct val_neg_data *el)
struct val_neg_data * first
Definition: val_neg.h:74
size_t use
Definition: val_neg.h:78
struct query_info qinfo
Definition: dns.h:63
struct val_neg_zone * neg_create_zone(struct val_neg_cache *neg, uint8_t *nm, size_t nm_len, uint16_t dclass)
uint8_t * name
Definition: val_neg.h:98
uint8_t in_use
Definition: val_neg.h:128
int val_neg_data_compare(const void *a, const void *b)