Electroneum
dns.h
Go to the documentation of this file.
1 /*
2  * services/cache/dns.h - Cache services for DNS using msg and rrset caches.
3  *
4  * Copyright (c) 2007, 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 
42 #ifndef SERVICES_CACHE_DNS_H
43 #define SERVICES_CACHE_DNS_H
44 #include "util/storage/lruhash.h"
45 #include "util/data/msgreply.h"
46 struct module_env;
47 struct query_info;
48 struct reply_info;
49 struct regional;
50 struct delegpt;
51 
56 #define DNSCACHE_STORE_ZEROTTL 0x100000
57 
61 struct dns_msg {
63  struct query_info qinfo;
65  struct reply_info *rep;
66 };
67 
93 int dns_cache_store(struct module_env* env, struct query_info* qinf,
94  struct reply_info* rep, int is_referral, time_t leeway, int pside,
95  struct regional* region, uint32_t flags);
96 
117 void dns_cache_store_msg(struct module_env* env, struct query_info* qinfo,
118  hashvalue_type hash, struct reply_info* rep, time_t leeway, int pside,
119  struct reply_info* qrep, uint32_t flags, struct regional* region);
120 
134 struct delegpt* dns_cache_find_delegation(struct module_env* env,
135  uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass,
136  struct regional* region, struct dns_msg** msg, time_t timenow);
137 
148 struct dns_msg* tomsg(struct module_env* env, struct query_info* q,
149  struct reply_info* r, struct regional* region, time_t now,
150  struct regional* scratch);
151 
168 struct dns_msg* dns_cache_lookup(struct module_env* env,
169  uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass,
170  uint16_t flags, struct regional* region, struct regional* scratch,
171  int no_partial);
172 
181 int cache_fill_missing(struct module_env* env, uint16_t qclass,
182  struct regional* region, struct delegpt* dp);
183 
195 struct dns_msg* dns_msg_create(uint8_t* qname, size_t qnamelen, uint16_t qtype,
196  uint16_t qclass, struct regional* region, size_t capacity);
197 
207 int dns_msg_authadd(struct dns_msg* msg, struct regional* region,
208  struct ub_packed_rrset_key* rrset, time_t now);
209 
219 int dns_msg_ansadd(struct dns_msg* msg, struct regional* region,
220  struct ub_packed_rrset_key* rrset, time_t now);
221 
232 int dns_cache_prefetch_adjust(struct module_env* env, struct query_info* qinfo,
233  time_t adjust, uint16_t flags);
234 
237 struct msgreply_entry* msg_cache_lookup(struct module_env* env,
238  uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass,
239  uint16_t flags, time_t now, int wr);
240 
241 #endif /* SERVICES_CACHE_DNS_H */
struct dns_msg * dns_cache_lookup(struct module_env *env, uint8_t *qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, uint16_t flags, struct regional *region, struct regional *scratch, int no_partial)
int dns_msg_ansadd(struct dns_msg *msg, struct regional *region, struct ub_packed_rrset_key *rrset, time_t now)
Definition: dns.h:61
struct reply_info * rep
Definition: dns.h:65
Definition: msgreply.h:211
void dp(key a)
Definition: rctTypes.cpp:46
struct dns_msg * tomsg(struct module_env *env, struct query_info *q, struct reply_info *r, struct regional *region, time_t now, struct regional *scratch)
unsigned short uint16_t
Definition: stdint.h:125
int dns_msg_authadd(struct dns_msg *msg, struct regional *region, struct ub_packed_rrset_key *rrset, time_t now)
unsigned char uint8_t
Definition: stdint.h:124
struct msgreply_entry * msg_cache_lookup(struct module_env *env, uint8_t *qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, uint16_t flags, time_t now, int wr)
int cache_fill_missing(struct module_env *env, uint16_t qclass, struct regional *region, struct delegpt *dp)
void dns_cache_store_msg(struct module_env *env, struct query_info *qinfo, hashvalue_type hash, struct reply_info *rep, time_t leeway, int pside, struct reply_info *qrep, uint32_t flags, struct regional *region)
uint16_t flags
Definition: msgreply.h:127
struct delegpt * dns_cache_find_delegation(struct module_env *env, uint8_t *qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, struct regional *region, struct dns_msg **msg, time_t timenow)
unsigned int uint32_t
Definition: stdint.h:126
uint32_t hashvalue_type
Definition: lruhash.h:119
POD_CLASS hash
Definition: hash.h:50
int dns_cache_prefetch_adjust(struct module_env *env, struct query_info *qinfo, time_t adjust, uint16_t flags)
struct dns_msg * dns_msg_create(uint8_t *qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, struct regional *region, size_t capacity)
struct query_info qinfo
Definition: dns.h:63
int dns_cache_store(struct module_env *env, struct query_info *qinf, struct reply_info *rep, int is_referral, time_t leeway, int pside, struct regional *region, uint32_t flags)