unbound: util/data/msgreply.h File Reference

unbound 0.1

Data Structures | Macros | Functions
msgreply.h File Reference

This file contains a data structure to store a message and its reply. More...

`#include "util/storage/lruhash.h"`
`#include "util/data/packed_rrset.h"`
`#include "sldns/rrdef.h"`

## Data Structures
struct | query_info
| Structure to store query information that makes answers to queries different. More...
struct | rrset_ref
| Information to reference an rrset. More...
struct | reply_info
| Structure to store DNS query and the reply packet. More...
struct | msgreply_entry
| Structure to keep hash table entry for message replies. More...

## Macros
#define | PREFETCH_TTL_CALC(ttl)
| calculate the prefetch TTL as 90% of original.
#define | EDNS_OPT_LIST_APPEND_EDE(LIST, REGION, CODE, TXT)
| Append edns EDE option to edns options list.

## Functions
struct reply_info * | construct_reply_info_base (struct regional *region, uint16_t flags, size_t qd, time_t ttl, time_t prettl, time_t expttl, size_t an, size_t ns, size_t ar, size_t total, enum sec_status sec, sldns_ede_code reason_bogus)
| Constructor for replyinfo.
int | query_info_parse (struct query_info *m, struct sldns_buffer *query)
| Parse wire query into a queryinfo structure, return 0 on parse error.
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)
| Parse query reply.
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)
| Allocate and decompress parsed message and rrsets.
struct reply_info * | parse_reply_in_temp_region (struct sldns_buffer *pkt, struct regional *region, struct query_info *qi)
| get msg reply struct (in temp region)
void | reply_info_sortref (struct reply_info *rep)
| Sorts the ref array.
void | reply_info_set_ttls (struct reply_info *rep, time_t timenow)
| Set TTLs inside the replyinfo to absolute values.
void | reply_info_parsedelete (struct reply_info *rep, struct alloc_cache *alloc)
| Delete reply_info and packed_rrsets (while they are not yet added to the hashtables.).
int | query_info_compare (void *m1, void *m2)
| Compare two queryinfo structures, on query and type, class.
void | query_info_clear (struct query_info *m)
| clear out query info structure
size_t | msgreply_sizefunc (void *k, void *d)
| calculate size of struct query_info + reply_info
void | query_entry_delete (void *q, void *arg)
| delete msgreply_entry key structure
void | reply_info_delete (void *d, void *arg)
| delete reply_info data structure
hashvalue_type | query_info_hash (struct query_info *q, uint16_t flags)
| calculate hash value of query_info, lowercases the qname, uses CD flag for AAAA qtype
struct msgreply_entry * | query_info_entrysetup (struct query_info *q, struct reply_info *r, hashvalue_type h)
| Setup query info entry.
struct reply_info * | reply_info_copy (struct reply_info *rep, struct alloc_cache *alloc, struct regional *region)
| Copy reply_info and all rrsets in it and allocate.
int | reply_info_alloc_rrset_keys (struct reply_info *rep, struct alloc_cache *alloc, struct regional *region)
| Allocate (special) rrset keys.
struct reply_info * | make_new_reply_info (const struct reply_info *rep, struct regional *region, size_t an_numrrsets, size_t copy_rrsets)
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)
| Copy a parsed rrset into given key, decompressing and allocating rdata.
uint8_t * | reply_find_final_cname_target (struct query_info *qinfo, struct reply_info *rep)
| Find final cname target in reply, the one matching qinfo.
int | reply_check_cname_chain (struct query_info *qinfo, struct reply_info *rep)
| Check if cname chain in cached reply is still valid.
int | reply_all_rrsets_secure (struct reply_info *rep)
| Check security status of all RRs in the message.
struct ub_packed_rrset_key * | reply_find_answer_rrset (struct query_info *qinfo, struct reply_info *rep)
| Find answer rrset in reply, the one matching qinfo.
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)
| Find rrset in reply, inside the answer section.
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)
| Find rrset in reply, inside the authority section.
struct ub_packed_rrset_key * | reply_find_rrset (struct reply_info *rep, uint8_t *name, size_t namelen, uint16_t type, uint16_t dclass)
| Find rrset in reply, inside any section.
void | log_dns_msg (const char *str, struct query_info *qinfo, struct reply_info *rep)
| Debug send the query info and reply info to the log in readable form.
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 sockaddr_storage *daddr, enum comm_point_type tp)
| Print string with neat domain name, type, class, status code from, and size of a query response.
void | log_query_info (enum verbosity_value v, const char *str, struct query_info *qinf)
| Print string with neat domain name, type, class from query info.
int | edns_opt_list_append (struct edns_option **list, uint16_t code, size_t len, uint8_t *data, struct regional *region)
| Append edns option to edns option list.
int | edns_opt_list_append_ede (struct edns_option **list, struct regional *region, sldns_ede_code code, const char *txt)
| Append edns EDE option to edns options list.
int | edns_opt_list_append_keepalive (struct edns_option **list, int msec, struct regional *region)
| Append edns keep alive option to edns options list.
int | edns_opt_list_remove (struct edns_option **list, uint16_t code)
| Remove any option found on the edns option list that matches the code.
struct edns_option * | edns_opt_list_find (struct edns_option *list, uint16_t code)
| Find edns option in edns list.
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 comm_reply *repinfo, struct regional *region, struct timeval *start_time)
| Call the registered functions in the inplace_cb_reply linked list.
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 comm_reply *repinfo, struct regional *region, struct timeval *start_time)
| Call the registered functions in the inplace_cb_reply_cache linked 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 comm_reply *repinfo, struct regional *region, struct timeval *start_time)
| Call the registered functions in the inplace_cb_reply_local linked list.
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 comm_reply *repinfo, struct regional *region, struct timeval *start_time)
| Call the registered functions in the inplace_cb_reply linked list.
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)
| Call the registered functions in the inplace_cb_query linked list.
int | inplace_cb_edns_back_parsed_call (struct module_env *env, struct module_qstate *qstate)
| Call the registered functions in the inplace_cb_edns_back_parsed linked list.
int | inplace_cb_query_response_call (struct module_env *env, struct module_qstate *qstate, struct dns_msg *response)
| Call the registered functions in the inplace_cb_query_response linked list.
struct edns_option * | edns_opt_copy_region (struct edns_option *list, struct regional *region)
| Copy edns option list allocated to the new region.
struct edns_option * | edns_opt_copy_filter_region (struct edns_option *list, uint16_t *filter_list, size_t filter_list_len, struct regional *region)
| Copy a filtered edns option list allocated to the new region.
struct edns_option * | edns_opt_copy_alloc (struct edns_option *list)
| Copy edns option list allocated with malloc.
void | edns_opt_list_free (struct edns_option *list)
| Free edns option list allocated with malloc.
int | edns_opt_compare (struct edns_option *p, struct edns_option *q)
| Compare an edns option.
int | edns_opt_list_compare (struct edns_option *p, struct edns_option *q)
| Compare edns option lists, also the order and contents of edns-options.

## Detailed Description

This file contains a data structure to store a message and its reply.

## Macro Definition Documentation

## ◆ PREFETCH_TTL_CALC

#define PREFETCH_TTL_CALC | ( |  | ttl | ) |

Value:
((ttl) - (ttl)/10)

calculate the prefetch TTL as 90% of original.

Calculation without numerical overflow (uin32_t)

Referenced by az_add_negative_soa(), error_response_cache(), load_msg(), msg_ttl(), parse_copy_decompress(), processFinished(), rrset_msg(), store_rrsets(), synth_dname_msg(), and tomsg().

## ◆ EDNS_OPT_LIST_APPEND_EDE

#define EDNS_OPT_LIST_APPEND_EDE | ( |  | LIST,
|  |  | REGION,
|  |  | CODE,
|  |  | TXT )

Value:
do { \
struct { \
uint16_t code; \
char text[sizeof(TXT) - 1]; \
} ede = { htons(CODE), TXT }; \
verbose(VERB_ALGO, "attached EDE code: %d with" \
" message: %s", CODE, TXT); \
edns_opt_list_append((LIST), LDNS_EDNS_EDE, \
sizeof(uint16_t) + sizeof(TXT) - 1, \
(void *)&ede, (REGION)); \
} while(0)
VERB_ALGO
@ VERB_ALGO
4 - algorithm level information
Definition log.h:59

Append edns EDE option to edns options list.

Parameters

  LIST | the edns option list to append the edns option to.
  REGION | region to allocate the new edns option.
  CODE | the EDE code.
  TXT | Additional text for the option

Referenced by answer_from_cache(), and worker_handle_request().

## Function Documentation

## ◆ construct_reply_info_base()

struct reply_info * construct_reply_info_base | ( | struct regional * | region,
|  | uint16_t | flags,
|  | size_t | qd,
|  | time_t | ttl,
|  | time_t | prettl,
|  | time_t | expttl,
|  | size_t | an,
|  | size_t | ns,
|  | size_t | ar,
|  | size_t | total,
|  | enum sec_status | sec,
|  | sldns_ede_code | reason_bogus )

Constructor for replyinfo.

Parameters

  region | where to allocate the results, pass NULL to use malloc.
  flags | flags for the replyinfo.
  qd | qd count
  ttl | TTL of replyinfo
  prettl | prefetch ttl
  expttl | serve expired ttl
  an | an count
  ns | ns count
  ar | ar count
  total | total rrset count (presumably an+ns+ar).
  sec | security status of the reply info.
  reason_bogus | the Extended DNS Error for DNSSEC bogus status

Returns
  the reply_info base struct with the array for putting the rrsets in. The array has been zeroed. Returns NULL on malloc failure.

Constructor for replyinfo.

References reply_info::an_numrrsets, reply_info::ar_numrrsets, reply_info::authoritative, reply_info::flags, reply_info::ns_numrrsets, reply_info::prefetch_ttl, reply_info::qdcount, reply_info::reason_bogus, reply_info::reason_bogus_str, reply_info::ref, regional_alloc(), RR_COUNT_MAX, reply_info::rrset_count, reply_info::rrsets, reply_info::security, reply_info::serve_expired_ttl, and reply_info::ttl.

Referenced by dns64_adjust_a(), edns_ede_answer_encode_test(), parse_create_repinfo(), reply_info_copy(), and rpz_synthesize_cname_override_msg().

## ◆ query_info_parse()

int query_info_parse | ( | struct query_info * | m,
|  | struct sldns_buffer * | query )

Parse wire query into a queryinfo structure, return 0 on parse error.

initialises the (prealloced) queryinfo structure as well. This query structure contains a pointer back info the buffer! This pointer avoids memory allocation. allocqname does memory allocation.

Parameters

  m | the prealloced queryinfo structure to put query into. must be unused, or _clear()ed.
  query | the wireformat packet query. starts with ID.

Returns
  : 0 on format error.

References query_info::local_alias, query_info::qclass, query_info::qname, query_info::qname_len, query_info::qtype, query_dname_len(), sldns_buffer_begin(), sldns_buffer_current(), sldns_buffer_limit(), sldns_buffer_position(), sldns_buffer_read_u16(), sldns_buffer_remaining(), and sldns_buffer_skip().

Referenced by auth_zone_parse_notify_serial(), and worker_handle_request().

## ◆ reply_info_parse()

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 )

Parse query reply.

Fills in preallocated query_info structure (with ptr into buffer). Allocates reply_info and packed_rrsets. These are not yet added to any caches or anything, this is only parsing. Returns formerror on qdcount > 1.

Parameters

  pkt | the packet buffer. Must be positioned after the query section.
  alloc | creates packed rrset key structures.
  rep | allocated reply_info is returned (only on no error).
  qinf | query_info is returned (only on no error).
  region | where to store temporary data (for parsing).
  edns | where to store edns information, does not need to be inited.

Returns
  : zero is OK, or DNS error code in case of error o FORMERR for parse errors. o SERVFAIL for memory allocation errors.

References query_info::local_alias, parse_create_msg(), parse_extract_edns_from_response_msg(), parse_packet(), query_info::qname, query_info_clear(), regional_alloc(), and sldns_buffer_set_position().

Referenced by entry_to_repinfo(), perftestpkt(), and testpkt().

## ◆ parse_create_msg()

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 )

Allocate and decompress parsed message and rrsets.

Parameters

  pkt | for name decompression.
  msg | parsed message in scratch region.
  alloc | alloc cache for special rrset key structures. Not used if region!=NULL, it can be NULL in that case.
  qinf | where to store query info. qinf itself is allocated by the caller.
  rep | reply info is allocated and returned.
  region | if this parameter is NULL then malloc and the alloc is used. otherwise, everything is allocated in this region. In a region, no special rrset key structures are needed (not shared), and no rrset_ref array in the reply is built up.

Returns
  0 if allocation failed.

References log_assert, parse_copy_decompress(), parse_create_qinfo(), parse_create_repinfo(), reply_info_alloc_rrset_keys(), and reply_info_parsedelete().

Referenced by createResponse(), dns_alloc_msg(), parse_reply_in_temp_region(), and reply_info_parse().

## ◆ reply_info_sortref()

void reply_info_sortref | ( | struct reply_info * | rep | ) |

Sorts the ref array.

Parameters

  rep | reply info. rrsets must be filled in.

References reply_info::ref, reply_info_sortref_cmp(), and reply_info::rrset_count.

Referenced by dns_cache_store_msg().

## ◆ reply_info_set_ttls()

void reply_info_set_ttls | ( | struct reply_info * | rep,
|  | time_t | timenow )

Set TTLs inside the replyinfo to absolute values.

Parameters

  rep | reply info. rrsets must be filled in. Also refs must be filled in.
  timenow | the current time.

References packed_rrset_data::count, lruhash_entry::data, ub_packed_rrset_key::entry, rrset_ref::key, reply_info::prefetch_ttl, reply_info::ref, packed_rrset_data::rr_ttl, reply_info::rrset_count, packed_rrset_data::rrsig_count, reply_info::serve_expired_ttl, packed_rrset_data::ttl, reply_info::ttl, and packed_rrset_data::ttl_add.

Referenced by dns_cache_store_msg().

## ◆ reply_info_parsedelete()

void reply_info_parsedelete | ( | struct reply_info * | rep,
|  | struct alloc_cache * | alloc )

Delete reply_info and packed_rrsets (while they are not yet added to the hashtables.).

Returns rrsets to the alloc cache.

Parameters

  rep | reply_info to delete.
  alloc | where to return rrset structures to.

References reply_info::reason_bogus_str, reply_info::rrset_count, reply_info::rrsets, and ub_packed_rrset_parsedelete().

Referenced by dns_cache_store(), dstest_entry(), extract_keys(), nsec3_hash_test_entry(), parse_create_msg(), perftestpkt(), reply_info_copy(), testpkt(), and verifytest_entry().

## ◆ query_info_compare()

int query_info_compare | ( | void * | m1,
|  | void * | m2 )

Compare two queryinfo structures, on query and type, class.

It is not sorted in canonical ordering.

Parameters

  m1 | struct query_info* , void* here to ease use as function pointer.
  m2 | struct query_info* , void* here to ease use as function pointer.

Returns
  : 0 = same, -1 m1 is smaller, +1 m1 is larger.

References COMPARE_IT, log_assert, query_info::qclass, query_info::qname, query_info::qname_len, query_info::qtype, and query_dname_compare().

Referenced by context_finalize(), daemon_apply_cfg(), fptr_whitelist_hash_compfunc(), and mesh_state_compare().

## ◆ query_info_entrysetup()

struct msgreply_entry * query_info_entrysetup | ( | struct query_info * | q,
|  | struct reply_info * | r,
|  | hashvalue_type | h )

Setup query info entry.

Parameters

  q | query info to copy. Emptied as if clear is called.
  r | reply to init data.
  h | hash value.

Returns
  : newly allocated message reply cache item.

References lruhash_entry::data, msgreply_entry::entry, lruhash_entry::hash, lruhash_entry::key, msgreply_entry::key, query_info::local_alias, lruhash_entry::lock, query_info::qclass, query_info::qname, query_info::qname_len, and query_info::qtype.

Referenced by dns_cache_store_msg().

## ◆ reply_info_copy()

struct reply_info * reply_info_copy | ( | struct reply_info * | rep,
|  | struct alloc_cache * | alloc,
|  | struct regional * | region )

Copy reply_info and all rrsets in it and allocate.

Parameters

  rep | what to copy, probably inside region, no ref[] array in it.
  alloc | how to allocate rrset keys. Not used if region!=NULL, it can be NULL in that case.
  region | if this parameter is NULL then malloc and the alloc is used. otherwise, everything is allocated in this region. In a region, no special rrset key structures are needed (not shared), and no rrset_ref array in the reply is built up.

Returns
  new reply info or NULL on memory error.

References reply_info::an_numrrsets, reply_info::ar_numrrsets, construct_reply_info_base(), reply_info::flags, reply_info::ns_numrrsets, reply_info::prefetch_ttl, reply_info::qdcount, reply_info::reason_bogus, reply_info::reason_bogus_str, regional_alloc(), repinfo_copy_rrsets(), reply_info_alloc_rrset_keys(), reply_info_parsedelete(), reply_info::rrset_count, reply_info::security, reply_info::serve_expired_ttl, and reply_info::ttl.

Referenced by answer_from_cache(), dns64_adjust_ptr(), dns_cache_store(), and dns_copy_msg().

## ◆ reply_info_alloc_rrset_keys()

int reply_info_alloc_rrset_keys | ( | struct reply_info * | rep,
|  | struct alloc_cache * | alloc,
|  | struct regional * | region )

Allocate (special) rrset keys.

Parameters

  rep | reply info in which the rrset keys to be allocated, rrset[] array should have bee allocated with NULL pointers.
  alloc | how to allocate rrset keys. Not used if region!=NULL, it can be NULL in that case.
  region | if this parameter is NULL then the alloc is used. otherwise, rrset keys are allocated in this region. In a region, no special rrset key structures are needed (not shared). and no rrset_ref array in the reply needs to be built up.

Returns
  1 on success, 0 on error

References alloc_special_obtain(), lruhash_entry::data, ub_packed_rrset_key::entry, lruhash_entry::key, regional_alloc(), reply_info::rrset_count, and reply_info::rrsets.

Referenced by dns64_adjust_a(), parse_create_msg(), and reply_info_copy().

## ◆ parse_copy_decompress_rrset()

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 )

Copy a parsed rrset into given key, decompressing and allocating rdata.

Parameters

  pkt | packet for decompression
  msg | the parser message (for flags for trust).
  pset | the parsed rrset to copy.
  region | if NULL - malloc, else data is allocated in this region.
  pk | a freshly obtained rrsetkey structure. No dname is set yet, will be set on return. Note that TTL will still be relative on return.

Returns
  false on alloc failure.

copy & decompress dname

copy over type and class

read data part.

References lruhash_entry::data, packed_rrset_key::dname, rrset_parse::dname, packed_rrset_key::dname_len, rrset_parse::dname_len, dname_pkt_copy(), ub_packed_rrset_key::entry, packed_rrset_key::flags, rrset_parse::flags, get_rrset_trust(), lruhash_entry::hash, rrset_parse::hash, lruhash_entry::key, parse_create_rrset(), regional_alloc(), ub_packed_rrset_key::rk, packed_rrset_key::rrset_class, rrset_parse::rrset_class, packed_rrset_data::trust, packed_rrset_key::type, and rrset_parse::type.

Referenced by parse_copy_decompress(), and store_rrset().

## ◆ reply_find_final_cname_target()

uint8_t * reply_find_final_cname_target | ( | struct query_info * | qinfo,
|  | struct reply_info * | rep )

Find final cname target in reply, the one matching qinfo.

Follows CNAMEs.

Parameters

  qinfo | what to start with.
  rep | looks in answer section of this message.

Returns
  : pointer dname, or NULL if not found.

References reply_info::an_numrrsets, packed_rrset_key::dname, packed_rrset_key::dname_len, get_cname_target(), LDNS_RR_TYPE_CNAME, query_info::qclass, query_info::qname, query_info::qname_len, query_dname_compare(), ub_packed_rrset_key::rk, packed_rrset_key::rrset_class, reply_info::rrsets, and packed_rrset_key::type.

Referenced by libworker_enter_result().

## ◆ reply_check_cname_chain()

int reply_check_cname_chain | ( | struct query_info * | qinfo,
|  | struct reply_info * | rep )

Check if cname chain in cached reply is still valid.

Parameters

  qinfo | query info with query name.
  rep | reply to check.

Returns
  : true if valid, false if invalid.

References reply_info::an_numrrsets, packed_rrset_key::dname, get_cname_target(), LDNS_RR_TYPE_CNAME, LDNS_RR_TYPE_DNAME, query_info::qname, query_info::qname_len, query_dname_compare(), ub_packed_rrset_key::rk, reply_info::rrsets, and packed_rrset_key::type.

Referenced by answer_from_cache(), and tomsg().

## ◆ reply_all_rrsets_secure()

int reply_all_rrsets_secure | ( | struct reply_info * | rep | ) |

Check security status of all RRs in the message.

Parameters

  rep | reply to check

Returns
  : true if all RRs are secure. False if not. True if there are zero RRs.

References lruhash_entry::data, ub_packed_rrset_key::entry, reply_info::rrset_count, reply_info::rrsets, and sec_status_secure.

Referenced by answer_from_cache(), mesh_serve_expired_lookup(), and tomsg().

## ◆ reply_find_answer_rrset()

struct ub_packed_rrset_key * reply_find_answer_rrset | ( | struct query_info * | qinfo,
|  | struct reply_info * | rep )

Find answer rrset in reply, the one matching qinfo.

Follows CNAMEs, so the result may have a different owner name.

Parameters

  qinfo | what to look for.
  rep | looks in answer section of this message.

Returns
  : pointer to rrset, or NULL if not found.

References reply_info::an_numrrsets, packed_rrset_key::dname, packed_rrset_key::dname_len, get_cname_target(), LDNS_RR_TYPE_CNAME, query_info::qclass, query_info::qname, query_info::qname_len, query_info::qtype, query_dname_compare(), ub_packed_rrset_key::rk, packed_rrset_key::rrset_class, reply_info::rrsets, and packed_rrset_key::type.

Referenced by auth_xfer_probe_lookup_callback(), auth_xfer_transfer_lookup_callback(), auth_zonemd_dnskey_lookup_callback(), dns64_adjust_ptr(), dns64_inform_super(), ds_response_to_ke(), handle_event_moddone(), libworker_enter_result(), process_dnskey_response(), and processTargetResponse().

## ◆ reply_find_rrset_section_an()

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 )

Find rrset in reply, inside the answer section.

Does not follow CNAMEs.

Parameters

  rep | looks in answer section of this message.
  name | what to look for.
  namelen | length of name.
  type | looks for (host order).
  dclass | looks for (host order).

Returns
  : pointer to rrset, or NULL if not found.

References reply_info::an_numrrsets, packed_rrset_key::dname, packed_rrset_key::dname_len, query_dname_compare(), ub_packed_rrset_key::rk, packed_rrset_key::rrset_class, reply_info::rrsets, and packed_rrset_key::type.

Referenced by ds_response_to_ke(), iter_msg_from_zone(), process_prime_response(), processInitRequest(), processQueryResponse(), and processQueryTargets().

## ◆ reply_find_rrset_section_ns()

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 )

Find rrset in reply, inside the authority section.

Does not follow CNAMEs.

Parameters

  rep | looks in authority section of this message.
  name | what to look for.
  namelen | length of name.
  type | looks for (host order).
  dclass | looks for (host order).

Returns
  : pointer to rrset, or NULL if not found.

References reply_info::an_numrrsets, packed_rrset_key::dname, packed_rrset_key::dname_len, reply_info::ns_numrrsets, query_dname_compare(), ub_packed_rrset_key::rk, packed_rrset_key::rrset_class, reply_info::rrsets, and packed_rrset_key::type.

Referenced by iter_indicates_dnssec(), iter_msg_from_zone(), processQueryResponse(), and val_nsec_prove_nodata_dsreply().

## ◆ reply_find_rrset()

struct ub_packed_rrset_key * reply_find_rrset | ( | struct reply_info * | rep,
|  | uint8_t * | name,
|  | size_t | namelen,
|  | uint16_t | type,
|  | uint16_t | dclass )

Find rrset in reply, inside any section.

Does not follow CNAMEs.

Parameters

  rep | looks in answer,authority and additional section of this message.
  name | what to look for.
  namelen | length of name.
  type | looks for (host order).
  dclass | looks for (host order).

Returns
  : pointer to rrset, or NULL if not found.

References packed_rrset_key::dname, packed_rrset_key::dname_len, query_dname_compare(), ub_packed_rrset_key::rk, packed_rrset_key::rrset_class, reply_info::rrset_count, reply_info::rrsets, and packed_rrset_key::type.

Referenced by processDSNSResponse(), and processQueryResponse().

## ◆ log_dns_msg()

void log_dns_msg | ( | const char * | str,
|  | struct query_info * | qinfo,
|  | struct reply_info * | rep )

Debug send the query info and reply info to the log in readable form.

Parameters

  str | descriptive string printed with packet content.
  qinfo | query section.
  rep | rest of message.

References reply_info::flags, log_err(), log_info(), regional_create(), regional_destroy(), reply_info_encode(), sldns_buffer_begin(), sldns_buffer_free(), sldns_buffer_limit(), sldns_buffer_new(), and sldns_wire2str_pkt().

Referenced by check_the_rrsigs(), createResponse(), mesh_serve_expired_callback(), process_response(), processInit(), processInitRequest(), processInitRequest3(), processQueryResponse(), processQueryTargets(), val_classify_response(), validate_cname_noanswer_response(), and validate_nodata_response().

## ◆ log_reply_info()

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 sockaddr_storage * | daddr,
|  | enum comm_point_type | tp )

Print string with neat domain name, type, class, status code from, and size of a query response.

Parameters

  v | at what verbosity level to print this.
  qinf | query section.
  addr | address of the client.
  addrlen | length of the client address.
  dur | how long it took to complete the query.
  cached | whether or not the reply is coming from the cache, or an outside network.
  rmsg | sldns buffer packet.
  daddr | if not NULL, the destination address and port are logged.
  tp | type of the comm point for logging destination connection type.

References addr_to_str(), dname_str(), FLAGS_GET_RCODE, LDNS_MAX_DOMAINLEN, log_info(), LOG_TAG_QUERYREPLY, query_info::qclass, query_info::qname, query_info::qtype, sldns_buffer_limit(), sldns_buffer_read_u16_at(), sldns_wire2str_class_buf(), sldns_wire2str_rcode_buf(), sldns_wire2str_type_buf(), and verbosity.

Referenced by mesh_send_reply(), and worker_handle_request().

## ◆ log_query_info()

void log_query_info | ( | enum verbosity_value | v,
|  | const char * | str,
|  | struct query_info * | qinf )

Print string with neat domain name, type, class from query info.

Parameters

  v | at what verbosity level to print this.
  str | string of message.
  qinf | query info structure with name, type and class.

References log_nametypeclass(), query_info::qclass, query_info::qname, and query_info::qtype.

Referenced by dns64_inform_super(), dns64_operate(), ds_response_to_ke(), error_supers(), generate_request(), ipset_operate(), iter_operate(), mesh_continue(), mesh_log_list(), prime_supers(), print_packet_rrsets(), probe_anchor(), process_dnskey_response(), process_response(), processClassResponse(), processFindKey(), processFinished(), processFinished(), processInitRequest(), processInitRequest2(), processInitRequest3(), processQueryResponse(), processQueryTargets(), processTargetResponse(), processValidate(), pythonmod_inform_super(), respip_operate(), val_inform_super(), val_operate(), xfr_probe_lookup_host(), xfr_transfer_lookup_host(), and zonemd_lookup_dnskey().

## ◆ edns_opt_list_append()

int edns_opt_list_append | ( | struct edns_option ** | list,
|  | uint16_t | code,
|  | size_t | len,
|  | uint8_t * | data,
|  | struct regional * | region )

Append edns option to edns option list.

Parameters

  list | the edns option list to append the edns option to.
  code | the edns option's code.
  len | the edns option's length.
  data | the edns option's data.
  region | region to allocate the new edns option.

Returns
  false on failure.

References edns_option::next, edns_option::opt_code, edns_option::opt_data, edns_option::opt_len, regional_alloc(), and regional_alloc_init().

Referenced by edns_opt_list_append_keepalive(), mesh_continue(), outnet_serviced_query(), parse_edns_options_from_query(), and parse_extract_edns_from_response_msg().

## ◆ edns_opt_list_append_ede()

int edns_opt_list_append_ede | ( | struct edns_option ** | list,
|  | struct regional * | region,
|  | sldns_ede_code | code,
|  | const char * | txt )

Append edns EDE option to edns options list.

Parameters

  list | the edns option list to append the edns option to.
  region | region to allocate the new edns option.
  code | the EDE code.
  txt | Additional text for the option

Returns
  false on failure.

References edns_option::next, edns_option::opt_code, edns_option::opt_data, edns_option::opt_len, regional_alloc(), VERB_ALGO, and verbose().

Referenced by answer_from_cache(), answer_norec_from_cache(), local_error_encode(), and mesh_serve_expired_callback().

## ◆ edns_opt_list_append_keepalive()

int edns_opt_list_append_keepalive | ( | struct edns_option ** | list,
|  | int | msec,
|  | struct regional * | region )

Append edns keep alive option to edns options list.

Parameters

  list | the edns option list to append the edns option to.
  msec | the duration in msecs for the keep alive.
  region | region to allocate the new edns option.

Returns
  false on failure.

References edns_opt_list_append().

Referenced by parse_edns_options_from_query().

## ◆ edns_opt_list_remove()

int edns_opt_list_remove | ( | struct edns_option ** | list,
|  | uint16_t | code )

Remove any option found on the edns option list that matches the code.

Parameters

  list | the list of edns options.
  code | the opt code to remove.

Returns
  true when at least one edns option was removed, false otherwise.

References edns_option::next, and edns_option::opt_code.

Referenced by extended_error_encode(), and reply_info_answer_encode().

## ◆ edns_opt_list_find()

struct edns_option * edns_opt_list_find | ( | struct edns_option * | list,
|  | uint16_t | code )

Find edns option in edns list.

Parameters

  list | list of edns options (eg. edns.opt_list)
  code | opt code to find.

Returns
  NULL or the edns_option element.

References edns_option::next, and edns_option::opt_code.

Referenced by mesh_continue().

## ◆ inplace_cb_reply_call()

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 comm_reply * | repinfo,
|  | struct regional * | region,
|  | struct timeval * | start_time )

Call the registered functions in the inplace_cb_reply linked list.

This function is going to get called while answering with a resolved query.

Parameters

  env | module environment.
  qinfo | query info.
  qstate | module qstate.
  rep | Reply info. Could be NULL.
  rcode | return code.
  edns | edns data of the reply.
  repinfo | comm_reply. Reply information for a communication point.
  region | region to store data.
  start_time | the start time of recursion, when the packet arrived, or the current time for cache responses.

Returns
  false on failure (a callback function returned an error).

Referenced by mesh_do_callback(), and mesh_send_reply().

## ◆ inplace_cb_reply_cache_call()

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 comm_reply * | repinfo,
|  | struct regional * | region,
|  | struct timeval * | start_time )

Call the registered functions in the inplace_cb_reply_cache linked list.

This function is going to get called while answering from cache.

Parameters

  env | module environment.
  qinfo | query info.
  qstate | module qstate. NULL when replying from cache.
  rep | Reply info.
  rcode | return code.
  edns | edns data of the reply. Edns input can be found here.
  repinfo | comm_reply. Reply information for a communication point.
  region | region to store data.
  start_time | the start time of recursion, when the packet arrived, or the current time for cache responses.

Returns
  false on failure (a callback function returned an error).

Referenced by answer_from_cache(), and answer_norec_from_cache().

## ◆ inplace_cb_reply_local_call()

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 comm_reply * | repinfo,
|  | struct regional * | region,
|  | struct timeval * | start_time )

Call the registered functions in the inplace_cb_reply_local linked list.

This function is going to get called while answering with local data.

Parameters

  env | module environment.
  qinfo | query info.
  qstate | module qstate. NULL when replying from cache.
  rep | Reply info.
  rcode | return code.
  edns | edns data of the reply. Edns input can be found here.
  repinfo | comm_reply. Reply information for a communication point.
  region | region to store data.
  start_time | the start time of recursion, when the packet arrived, or the current time for cache responses.

Returns
  false on failure (a callback function returned an error).

Referenced by auth_answer_encode(), auth_error_encode(), chaos_replystr(), local_encode(), local_error_encode(), and rpz_local_encode().

## ◆ inplace_cb_reply_servfail_call()

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 comm_reply * | repinfo,
|  | struct regional * | region,
|  | struct timeval * | start_time )

Call the registered functions in the inplace_cb_reply linked list.

This function is going to get called while answering with a servfail.

Parameters

  env | module environment.
  qinfo | query info.
  qstate | module qstate. Contains the edns option lists. Could be NULL.
  rep | Reply info. NULL when servfail.
  rcode | return code. LDNS_RCODE_SERVFAIL.
  edns | edns data of the reply. Edns input can be found here if qstate is NULL.
  repinfo | comm_reply. Reply information for a communication point.
  region | region to store data.
  start_time | the start time of recursion, when the packet arrived, or the current time for cache responses.

Returns
  false on failure (a callback function returned an error).

References module_qstate::edns_opts_front_out.

Referenced by answer_from_cache(), answer_norec_from_cache(), mesh_do_callback(), mesh_new_client(), and mesh_send_reply().

## ◆ inplace_cb_query_call()

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 )

Call the registered functions in the inplace_cb_query linked list.

This function is going to get called just before sending a query to a nameserver.

Parameters

  env | module environment.
  qinfo | query info.
  flags | flags of the query.
  addr | to which server to send the query.
  addrlen | length of addr.
  zone | name of the zone of the delegation point. wireformat dname. This is the delegation point name for which the server is deemed authoritative.
  zonelen | length of zone.
  qstate | module qstate.
  region | region to store data.

Returns
  false on failure (a callback function returned an error).

References inplace_cb::cb, fptr_ok, and fptr_whitelist_inplace_cb_query().

Referenced by outnet_serviced_query().

## ◆ inplace_cb_edns_back_parsed_call()

int inplace_cb_edns_back_parsed_call | ( | struct module_env * | env,
|  | struct module_qstate * | qstate )

Call the registered functions in the inplace_cb_edns_back_parsed linked list.

This function is going to get called after parsing the EDNS data on the reply from a nameserver.

Parameters

  env | module environment.
  qstate | module qstate.

Returns
  false on failure (a callback function returned an error).

References inplace_cb::cb, fptr_ok, and fptr_whitelist_inplace_cb_edns_back_parsed().

Referenced by process_response().

## ◆ inplace_cb_query_response_call()

int inplace_cb_query_response_call | ( | struct module_env * | env,
|  | struct module_qstate * | qstate,
|  | struct dns_msg * | response )

Call the registered functions in the inplace_cb_query_response linked list.

This function is going to get called after receiving a reply from a nameserver.

Parameters

  env | module environment.
  qstate | module qstate.
  response | received response

Returns
  false on failure (a callback function returned an error).

References inplace_cb::cb, fptr_ok, and fptr_whitelist_inplace_cb_query_response().

Referenced by processQueryResponse().

## ◆ edns_opt_compare()

int edns_opt_compare | ( | struct edns_option * | p,
|  | struct edns_option * | q )

Compare an edns option.

(not entire list). Also compares contents.

References log_assert, edns_option::opt_code, edns_option::opt_data, and edns_option::opt_len.

Referenced by edns_opt_list_compare().