Electroneum
msgreply.h
Go to the documentation of this file.
1 /*
2  * util/data/msgreply.h - store message and reply data.
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 UTIL_DATA_MSGREPLY_H
43 #define UTIL_DATA_MSGREPLY_H
44 #include "util/storage/lruhash.h"
45 #include "util/data/packed_rrset.h"
46 struct sldns_buffer;
47 struct comm_reply;
48 struct alloc_cache;
49 struct iovec;
50 struct regional;
51 struct edns_data;
52 struct edns_option;
53 struct inplace_cb;
54 struct module_qstate;
55 struct module_env;
56 struct msg_parse;
57 struct rrset_parse;
58 struct local_rrset;
59 struct dns_msg;
60 
63 #define PREFETCH_TTL_CALC(ttl) ((ttl) - (ttl)/10)
64 
69 struct query_info {
77  size_t qname_len;
99 };
100 
104 struct rrset_ref {
109 };
110 
125 struct reply_info {
128 
134 
142 
145 
151  time_t ttl;
152 
157  time_t prefetch_ttl;
158 
163 
170  size_t an_numrrsets;
171 
173  size_t ns_numrrsets;
175  size_t ar_numrrsets;
176 
178  size_t rrset_count;
179 
188 
205  struct rrset_ref ref[1];
206 };
207 
213  struct query_info key;
216 };
217 
233 struct reply_info*
234 construct_reply_info_base(struct regional* region, uint16_t flags, size_t qd,
235  time_t ttl, time_t prettl, size_t an, size_t ns, size_t ar,
236  size_t total, enum sec_status sec);
237 
248 int query_info_parse(struct query_info* m, struct sldns_buffer* query);
249 
265 int reply_info_parse(struct sldns_buffer* pkt, struct alloc_cache* alloc,
266  struct query_info* qinf, struct reply_info** rep,
267  struct regional* region, struct edns_data* edns);
268 
284 int parse_create_msg(struct sldns_buffer* pkt, struct msg_parse* msg,
285  struct alloc_cache* alloc, struct query_info* qinf,
286  struct reply_info** rep, struct regional* region);
287 
290  struct regional* region, struct query_info* qi);
291 
296 void reply_info_sortref(struct reply_info* rep);
297 
304 void reply_info_set_ttls(struct reply_info* rep, time_t timenow);
305 
312 void reply_info_parsedelete(struct reply_info* rep, struct alloc_cache* alloc);
313 
321 int query_info_compare(void* m1, void* m2);
322 
324 void query_info_clear(struct query_info* m);
325 
327 size_t msgreply_sizefunc(void* k, void* d);
328 
330 void query_entry_delete(void *q, void* arg);
331 
333 void reply_info_delete(void* d, void* arg);
334 
338 
347  struct reply_info* r, hashvalue_type h);
348 
360 struct reply_info* reply_info_copy(struct reply_info* rep,
361  struct alloc_cache* alloc, struct regional* region);
362 
376  struct alloc_cache* alloc, struct regional* region);
377 
389 int parse_copy_decompress_rrset(struct sldns_buffer* pkt, struct msg_parse* msg,
390  struct rrset_parse *pset, struct regional* region,
391  struct ub_packed_rrset_key* pk);
392 
400  struct reply_info* rep);
401 
408 int reply_check_cname_chain(struct query_info* qinfo, struct reply_info* rep);
409 
416 int reply_all_rrsets_secure(struct reply_info* rep);
417 
426  struct reply_info* rep);
427 
438  uint8_t* name, size_t namelen, uint16_t type, uint16_t dclass);
439 
450  uint8_t* name, size_t namelen, uint16_t type, uint16_t dclass);
451 
462  uint8_t* name, size_t namelen, uint16_t type, uint16_t dclass);
463 
470 void log_dns_msg(const char* str, struct query_info* qinfo,
471  struct reply_info* rep);
472 
486 void log_reply_info(enum verbosity_value v, struct query_info *qinf,
487  struct sockaddr_storage *addr, socklen_t addrlen, struct timeval dur,
488  int cached, struct sldns_buffer *rmsg);
489 
496 void log_query_info(enum verbosity_value v, const char* str,
497  struct query_info* qinf);
498 
508 int edns_opt_append(struct edns_data* edns, struct regional* region,
509  uint16_t code, size_t len, uint8_t* data);
510 
520 int edns_opt_list_append(struct edns_option** list, uint16_t code, size_t len,
521  uint8_t* data, struct regional* region);
522 
529 int edns_opt_list_remove(struct edns_option** list, uint16_t code);
530 
537 struct edns_option* edns_opt_list_find(struct edns_option* list, uint16_t code);
538 
551 int inplace_cb_reply_call(struct module_env* env, struct query_info* qinfo,
552  struct module_qstate* qstate, struct reply_info* rep, int rcode,
553  struct edns_data* edns, struct regional* region);
554 
568  struct query_info* qinfo, struct module_qstate* qstate,
569  struct reply_info* rep, int rcode, struct edns_data* edns,
570  struct regional* region);
571 
585  struct query_info* qinfo, struct module_qstate* qstate,
586  struct reply_info* rep, int rcode, struct edns_data* edns,
587  struct regional* region);
588 
603  struct query_info* qinfo, struct module_qstate* qstate,
604  struct reply_info* rep, int rcode, struct edns_data* edns,
605  struct regional* region);
606 
624 int inplace_cb_query_call(struct module_env* env, struct query_info* qinfo,
625  uint16_t flags, struct sockaddr_storage* addr, socklen_t addrlen,
626  uint8_t* zone, size_t zonelen, struct module_qstate* qstate,
627  struct regional* region);
628 
638  struct module_qstate* qstate);
639 
650  struct module_qstate* qstate, struct dns_msg* response);
651 
655 struct edns_option* edns_opt_copy_region(struct edns_option* list,
656  struct regional* region);
657 
661 struct edns_option* edns_opt_copy_alloc(struct edns_option* list);
662 
666 void edns_opt_list_free(struct edns_option* list);
667 
671 int edns_opt_compare(struct edns_option* p, struct edns_option* q);
672 
676 int edns_opt_list_compare(struct edns_option* p, struct edns_option* q);
677 
678 #endif /* UTIL_DATA_MSGREPLY_H */
struct edns_option * edns_opt_copy_region(struct edns_option *list, struct regional *region)
int parse_copy_decompress_rrset(struct sldns_buffer *pkt, struct msg_parse *msg, struct rrset_parse *pset, struct regional *region, struct ub_packed_rrset_key *pk)
uint8_t * qname
Definition: msgreply.h:75
Definition: dns.h:61
Definition: msgreply.h:211
int edns_opt_compare(struct edns_option *p, struct edns_option *q)
int reply_info_alloc_rrset_keys(struct reply_info *rep, struct alloc_cache *alloc, struct regional *region)
struct edns_option * edns_opt_copy_alloc(struct edns_option *list)
int inplace_cb_reply_local_call(struct module_env *env, struct query_info *qinfo, struct module_qstate *qstate, struct reply_info *rep, int rcode, struct edns_data *edns, struct regional *region)
int edns_opt_list_compare(struct edns_option *p, struct edns_option *q)
epee::misc_utils::struct_init< response_t > response
int reply_info_parse(struct sldns_buffer *pkt, struct alloc_cache *alloc, struct query_info *qinf, struct reply_info **rep, struct regional *region, struct edns_data *edns)
int query_info_compare(void *m1, void *m2)
void reply_info_delete(void *d, void *arg)
size_t an_numrrsets
Definition: msgreply.h:170
void query_info_clear(struct query_info *m)
unsigned short uint16_t
Definition: stdint.h:125
uint8_t authoritative
Definition: msgreply.h:133
int edns_opt_list_remove(struct edns_option **list, uint16_t code)
time_t ttl
Definition: msgreply.h:151
uint32_t padding
Definition: msgreply.h:144
unsigned char uint8_t
Definition: stdint.h:124
void edns_opt_list_free(struct edns_option *list)
size_t qname_len
Definition: msgreply.h:77
struct ub_packed_rrset_key ** rrsets
Definition: msgreply.h:187
struct reply_info * construct_reply_info_base(struct regional *region, uint16_t flags, size_t qd, time_t ttl, time_t prettl, size_t an, size_t ns, size_t ar, size_t total, enum sec_status sec)
const char * name
void reply_info_parsedelete(struct reply_info *rep, struct alloc_cache *alloc)
void reply_info_sortref(struct reply_info *rep)
uint16_t flags
Definition: msgreply.h:127
uint16_t qclass
Definition: msgreply.h:81
struct rrset_ref ref[1]
Definition: msgreply.h:205
void reply_info_set_ttls(struct reply_info *rep, time_t timenow)
int inplace_cb_reply_call(struct module_env *env, struct query_info *qinfo, struct module_qstate *qstate, struct reply_info *rep, int rcode, struct edns_data *edns, struct regional *region)
int inplace_cb_reply_servfail_call(struct module_env *env, struct query_info *qinfo, struct module_qstate *qstate, struct reply_info *rep, int rcode, struct edns_data *edns, struct regional *region)
time_t prefetch_ttl
Definition: msgreply.h:157
int inplace_cb_edns_back_parsed_call(struct module_env *env, struct module_qstate *qstate)
unsigned int uint32_t
Definition: stdint.h:126
void query_entry_delete(void *q, void *arg)
struct ub_packed_rrset_key * reply_find_rrset_section_ns(struct reply_info *rep, uint8_t *name, size_t namelen, uint16_t type, uint16_t dclass)
void log_dns_msg(const char *str, struct query_info *qinfo, struct reply_info *rep)
uint32_t hashvalue_type
Definition: lruhash.h:119
sec_status
Definition: packed_rrset.h:176
rrset_id_type id
Definition: msgreply.h:108
verbosity_value
Definition: log.h:49
int inplace_cb_query_call(struct module_env *env, struct query_info *qinfo, uint16_t flags, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *zone, size_t zonelen, struct module_qstate *qstate, struct regional *region)
struct ub_packed_rrset_key * reply_find_rrset_section_an(struct reply_info *rep, uint8_t *name, size_t namelen, uint16_t type, uint16_t dclass)
struct reply_info * reply_info_copy(struct reply_info *rep, struct alloc_cache *alloc, struct regional *region)
int reply_check_cname_chain(struct query_info *qinfo, struct reply_info *rep)
size_t rrset_count
Definition: msgreply.h:178
uint8_t qdcount
Definition: msgreply.h:141
struct ub_packed_rrset_key * key
Definition: msgreply.h:106
int inplace_cb_query_response_call(struct module_env *env, struct module_qstate *qstate, struct dns_msg *response)
struct msgreply_entry * query_info_entrysetup(struct query_info *q, struct reply_info *r, hashvalue_type h)
struct ub_packed_rrset_key * reply_find_rrset(struct reply_info *rep, uint8_t *name, size_t namelen, uint16_t type, uint16_t dclass)
struct reply_info * parse_reply_in_temp_region(struct sldns_buffer *pkt, struct regional *region, struct query_info *qi)
enum sec_status security
Definition: msgreply.h:162
int query_info_parse(struct query_info *m, struct sldns_buffer *query)
uint64_t rrset_id_type
Definition: packed_rrset.h:46
struct local_rrset * local_alias
Definition: msgreply.h:98
int reply_all_rrsets_secure(struct reply_info *rep)
int parse_create_msg(struct sldns_buffer *pkt, struct msg_parse *msg, struct alloc_cache *alloc, struct query_info *qinf, struct reply_info **rep, struct regional *region)
uint16_t qtype
Definition: msgreply.h:79
size_t msgreply_sizefunc(void *k, void *d)
size_t ar_numrrsets
Definition: msgreply.h:175
int edns_opt_append(struct edns_data *edns, struct regional *region, uint16_t code, size_t len, uint8_t *data)
void log_reply_info(enum verbosity_value v, struct query_info *qinf, struct sockaddr_storage *addr, socklen_t addrlen, struct timeval dur, int cached, struct sldns_buffer *rmsg)
struct lruhash_entry entry
Definition: msgreply.h:215
struct edns_option * edns_opt_list_find(struct edns_option *list, uint16_t code)
struct ub_packed_rrset_key * reply_find_answer_rrset(struct query_info *qinfo, struct reply_info *rep)
int inplace_cb_reply_cache_call(struct module_env *env, struct query_info *qinfo, struct module_qstate *qstate, struct reply_info *rep, int rcode, struct edns_data *edns, struct regional *region)
Definition: lruhash.h:203
size_t ns_numrrsets
Definition: msgreply.h:173
void log_query_info(enum verbosity_value v, const char *str, struct query_info *qinf)
struct query_info key
Definition: msgreply.h:213
hashvalue_type query_info_hash(struct query_info *q, uint16_t flags)
int edns_opt_list_append(struct edns_option **list, uint16_t code, size_t len, uint8_t *data, struct regional *region)
uint8_t * reply_find_final_cname_target(struct query_info *qinfo, struct reply_info *rep)