Data Structures | Functions
iter_delegpt.h File Reference

This file implements the Delegation Point. More...

#include "util/log.h"

Data Structures

struct  delegpt
 Delegation Point. More...
 
struct  delegpt_ns
 Nameservers for a delegation point. More...
 
struct  delegpt_addr
 Address of target nameserver in delegation point. More...
 

Functions

struct delegptdelegpt_create (struct regional *regional)
 Create new delegation point. More...
 
struct delegptdelegpt_copy (struct delegpt *dp, struct regional *regional)
 Create a copy of a delegation point. More...
 
int delegpt_set_name (struct delegpt *dp, struct regional *regional, uint8_t *name)
 Set name of delegation point. More...
 
int delegpt_add_ns (struct delegpt *dp, struct regional *regional, uint8_t *name, uint8_t lame)
 Add a name to the delegation point. More...
 
int delegpt_rrset_add_ns (struct delegpt *dp, struct regional *regional, struct ub_packed_rrset_key *ns_rrset, uint8_t lame)
 Add NS rrset; calls add_ns repeatedly. More...
 
int delegpt_add_target (struct delegpt *dp, struct regional *regional, uint8_t *name, size_t namelen, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t bogus, uint8_t lame)
 Add target address to the delegation point. More...
 
int delegpt_add_rrset_A (struct delegpt *dp, struct regional *regional, struct ub_packed_rrset_key *rrset, uint8_t lame)
 Add A RRset to delegpt. More...
 
int delegpt_add_rrset_AAAA (struct delegpt *dp, struct regional *regional, struct ub_packed_rrset_key *rrset, uint8_t lame)
 Add AAAA RRset to delegpt. More...
 
int delegpt_add_rrset (struct delegpt *dp, struct regional *regional, struct ub_packed_rrset_key *rrset, uint8_t lame)
 Add any RRset to delegpt. More...
 
int delegpt_add_addr (struct delegpt *dp, struct regional *regional, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t bogus, uint8_t lame)
 Add address to the delegation point. More...
 
struct delegpt_nsdelegpt_find_ns (struct delegpt *dp, uint8_t *name, size_t namelen)
 Find NS record in name list of delegation point. More...
 
struct delegpt_addrdelegpt_find_addr (struct delegpt *dp, struct sockaddr_storage *addr, socklen_t addrlen)
 Find address record in total list of delegation point. More...
 
void delegpt_log (enum verbosity_value v, struct delegpt *dp)
 Print the delegation point to the log. More...
 
void delegpt_count_ns (struct delegpt *dp, size_t *numns, size_t *missing)
 count NS and number missing for logging
 
void delegpt_count_addr (struct delegpt *dp, size_t *numaddr, size_t *numres, size_t *numavail)
 count addresses, and number in result and available lists, for logging
 
void delegpt_add_unused_targets (struct delegpt *dp)
 Add all usable targets to the result list. More...
 
size_t delegpt_count_missing_targets (struct delegpt *dp)
 Count number of missing targets. More...
 
size_t delegpt_count_targets (struct delegpt *dp)
 count total number of targets in dp
 
struct delegptdelegpt_from_message (struct dns_msg *msg, struct regional *regional)
 Create new delegation point from a dns message. More...
 
void delegpt_add_neg_msg (struct delegpt *dp, struct msgreply_entry *msg)
 Add negative message to delegation point. More...
 
void delegpt_no_ipv6 (struct delegpt *dp)
 Register the fact that there is no ipv6 and thus AAAAs are not going to be queried for or be useful. More...
 
void delegpt_no_ipv4 (struct delegpt *dp)
 Register the fact that there is no ipv4 and thus As are not going to be queried for or be useful. More...
 
struct delegptdelegpt_create_mlc (uint8_t *name)
 create malloced delegation point, with the given name More...
 
void delegpt_free_mlc (struct delegpt *dp)
 free malloced delegation point. More...
 
int delegpt_set_name_mlc (struct delegpt *dp, uint8_t *name)
 Set name of delegation point. More...
 
int delegpt_add_ns_mlc (struct delegpt *dp, uint8_t *name, uint8_t lame)
 add a name to malloced delegation point. More...
 
int delegpt_add_addr_mlc (struct delegpt *dp, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t bogus, uint8_t lame)
 add an address to a malloced delegation point. More...
 
int delegpt_add_target_mlc (struct delegpt *dp, uint8_t *name, size_t namelen, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t bogus, uint8_t lame)
 Add target address to the delegation point. More...
 
size_t delegpt_get_mem (struct delegpt *dp)
 get memory in use by dp
 

Detailed Description

This file implements the Delegation Point.

It contains a list of name servers and their addresses if known.

Function Documentation

◆ delegpt_create()

struct delegpt* delegpt_create ( struct regional regional)

Create new delegation point.

Parameters
regionalwhere to allocate it.
Returns
new delegation point or NULL on error.

References regional_alloc().

Referenced by delegpt_copy(), delegpt_from_message(), and dns_cache_find_delegation().

◆ delegpt_copy()

struct delegpt* delegpt_copy ( struct delegpt dp,
struct regional regional 
)

◆ delegpt_set_name()

int delegpt_set_name ( struct delegpt dp,
struct regional regional,
uint8_t *  name 
)

Set name of delegation point.

Parameters
dpdelegation point.
regionalwhere to allocate the name copy.
namename to use.
Returns
false on error.

References dname_count_size_labels(), delegpt::dp_type_mlc, log_assert, delegpt::name, delegpt::namelabs, delegpt::namelen, and regional_alloc_init().

Referenced by delegpt_copy(), delegpt_from_message(), and dns_cache_find_delegation().

◆ delegpt_add_ns()

int delegpt_add_ns ( struct delegpt dp,
struct regional regional,
uint8_t *  name,
uint8_t  lame 
)

Add a name to the delegation point.

Parameters
dpdelegation point.
regionalwhere to allocate the info.
namedomain name in wire format.
lamename is lame, disprefer it.
Returns
false on error.

References delegpt_find_ns(), dname_count_size_labels(), delegpt_ns::done_pside4, delegpt_ns::done_pside6, delegpt::dp_type_mlc, delegpt_ns::got4, delegpt_ns::got6, delegpt_ns::lame, log_assert, delegpt_ns::name, delegpt_ns::namelen, delegpt_ns::next, delegpt::nslist, regional_alloc(), regional_alloc_init(), and delegpt_ns::resolved.

Referenced by delegpt_copy().

◆ delegpt_rrset_add_ns()

int delegpt_rrset_add_ns ( struct delegpt dp,
struct regional regional,
struct ub_packed_rrset_key ns_rrset,
uint8_t  lame 
)

Add NS rrset; calls add_ns repeatedly.

Parameters
dpdelegation point.
regionalwhere to allocate the info.
ns_rrsetNS rrset.
lamerrset is lame, disprefer it.
Returns
0 on alloc error.

References delegpt::bogus, packed_rrset_data::count, lruhash_entry::data, dname_valid(), delegpt::dp_type_mlc, ub_packed_rrset_key::entry, log_assert, packed_rrset_data::rr_data, packed_rrset_data::rr_len, sec_status_bogus, and packed_rrset_data::security.

Referenced by delegpt_add_rrset(), delegpt_from_message(), dns_cache_find_delegation(), and iter_lookup_parent_NS_from_cache().

◆ delegpt_add_target()

int delegpt_add_target ( struct delegpt dp,
struct regional regional,
uint8_t *  name,
size_t  namelen,
struct sockaddr_storage *  addr,
socklen_t  addrlen,
uint8_t  bogus,
uint8_t  lame 
)

Add target address to the delegation point.

Parameters
dpdelegation point.
regionalwhere to allocate the info.
namename for which target was found (must be in nslist). This name is marked resolved.
namelenlength of name.
addrthe address.
addrlenthe length of addr.
bogussecurity status for the address, pass true if bogus.
lameaddress is lame.
Returns
false on error.

References addr_is_ip6(), delegpt_add_addr(), delegpt_find_ns(), delegpt::dp_type_mlc, delegpt_ns::got4, delegpt_ns::got6, log_assert, and delegpt_ns::resolved.

Referenced by delegpt_add_rrset_A(), and delegpt_add_rrset_AAAA().

◆ delegpt_add_rrset_A()

int delegpt_add_rrset_A ( struct delegpt dp,
struct regional regional,
struct ub_packed_rrset_key rrset,
uint8_t  lame 
)

◆ delegpt_add_rrset_AAAA()

int delegpt_add_rrset_AAAA ( struct delegpt dp,
struct regional regional,
struct ub_packed_rrset_key rrset,
uint8_t  lame 
)

◆ delegpt_add_rrset()

int delegpt_add_rrset ( struct delegpt dp,
struct regional regional,
struct ub_packed_rrset_key rrset,
uint8_t  lame 
)

Add any RRset to delegpt.

Does not check for duplicates added.

Parameters
dpdelegation point.
regionalwhere to allocate the info.
rrsetRRset to add, NS, A, AAAA.
lamerrset is lame, disprefer it.
Returns
0 on alloc error.

References delegpt_add_rrset_A(), delegpt_add_rrset_AAAA(), delegpt_rrset_add_ns(), LDNS_RR_TYPE_A, LDNS_RR_TYPE_AAAA, LDNS_RR_TYPE_NS, log_warn(), ub_packed_rrset_key::rk, and packed_rrset_key::type.

◆ delegpt_add_addr()

int delegpt_add_addr ( struct delegpt dp,
struct regional regional,
struct sockaddr_storage *  addr,
socklen_t  addrlen,
uint8_t  bogus,
uint8_t  lame 
)

Add address to the delegation point.

No servername is associated or checked.

Parameters
dpdelegation point.
regionalwhere to allocate the info.
addrthe address.
addrlenthe length of addr.
bogusif address is bogus.
lameif address is lame.
Returns
false on error.

References delegpt_addr::addr, delegpt_addr::addrlen, delegpt_addr::attempts, delegpt_addr::bogus, delegpt_find_addr(), delegpt_addr::dnsseclame, delegpt::dp_type_mlc, delegpt_addr::lame, log_assert, delegpt_addr::next_result, delegpt_addr::next_target, delegpt_addr::next_usable, regional_alloc(), delegpt::target_list, and delegpt::usable_list.

Referenced by delegpt_add_target(), and delegpt_copy().

◆ delegpt_find_ns()

struct delegpt_ns* delegpt_find_ns ( struct delegpt dp,
uint8_t *  name,
size_t  namelen 
)

Find NS record in name list of delegation point.

Parameters
dpdelegation point.
namename of nameserver to look for, uncompressed wireformat.
namelenlength of name.
Returns
the ns structure or NULL if not found.

References delegpt_ns::name, delegpt_ns::namelen, delegpt_ns::next, delegpt::nslist, and query_dname_compare().

Referenced by delegpt_add_neg_msg(), delegpt_add_ns(), delegpt_add_ns_mlc(), delegpt_add_target(), delegpt_add_target_mlc(), error_supers(), and iter_dp_is_useless().

◆ delegpt_find_addr()

struct delegpt_addr* delegpt_find_addr ( struct delegpt dp,
struct sockaddr_storage *  addr,
socklen_t  addrlen 
)

Find address record in total list of delegation point.

Parameters
dpdelegation point.
addraddress
addrlenlength of addr
Returns
the addr structure or NULL if not found.

References delegpt_addr::addr, delegpt_addr::addrlen, delegpt_addr::next_target, sockaddr_cmp_addr(), and delegpt::target_list.

Referenced by delegpt_add_addr(), delegpt_add_addr_mlc(), iter_merge_retry_counts(), and processQueryResponse().

◆ delegpt_log()

void delegpt_log ( enum verbosity_value  v,
struct delegpt dp 
)

◆ delegpt_add_unused_targets()

void delegpt_add_unused_targets ( struct delegpt dp)

Add all usable targets to the result list.

Parameters
dpdelegation point.

References delegpt_addr::next_result, delegpt_addr::next_usable, delegpt::result_list, and delegpt::usable_list.

◆ delegpt_count_missing_targets()

size_t delegpt_count_missing_targets ( struct delegpt dp)

Count number of missing targets.

These are ns names with no resolved flag.

Parameters
dpdelegation point.
Returns
number of missing targets (or 0).

References delegpt_ns::next, delegpt::nslist, and delegpt_ns::resolved.

Referenced by iter_filter_order(), and query_for_targets().

◆ delegpt_from_message()

struct delegpt* delegpt_from_message ( struct dns_msg msg,
struct regional regional 
)

Create new delegation point from a dns message.

Note that this method does not actually test to see if the message is an actual referral. It really is just checking to see if it can construct a delegation point, so the message could be of some other type (some ANSWER messages, some CNAME messages, generally.) Note that the resulting DelegationPoint will contain targets for all "relevant" glue (i.e., address records whose ownernames match the target of one of the NS records), so if policy dictates that some glue should be discarded beyond that, discard it before calling this method. Note that this method will find "glue" in either the ADDITIONAL section or the ANSWER section.

Parameters
msgthe dns message, referral.
regionalwhere to allocate delegation point.
Returns
new delegation point or NULL on alloc error, or if the message was not appropriate.

References reply_info::an_numrrsets, delegpt_add_rrset_A(), delegpt_add_rrset_AAAA(), delegpt_create(), delegpt_rrset_add_ns(), delegpt_set_name(), packed_rrset_key::dname, find_NS(), delegpt::has_parent_side_NS, LDNS_RR_TYPE_A, LDNS_RR_TYPE_AAAA, reply_info::ns_numrrsets, dns_msg::rep, ub_packed_rrset_key::rk, reply_info::rrset_count, reply_info::rrsets, and packed_rrset_key::type.

◆ delegpt_add_neg_msg()

void delegpt_add_neg_msg ( struct delegpt dp,
struct msgreply_entry msg 
)

◆ delegpt_no_ipv6()

void delegpt_no_ipv6 ( struct delegpt dp)

Register the fact that there is no ipv6 and thus AAAAs are not going to be queried for or be useful.

Parameters
dpthe delegation point. Updated to reflect no ipv6.

References delegpt_ns::got4, delegpt_ns::next, delegpt::nslist, and delegpt_ns::resolved.

◆ delegpt_no_ipv4()

void delegpt_no_ipv4 ( struct delegpt dp)

Register the fact that there is no ipv4 and thus As are not going to be queried for or be useful.

Parameters
dpthe delegation point. Updated to reflect no ipv4.

References delegpt_ns::got6, delegpt_ns::next, delegpt::nslist, and delegpt_ns::resolved.

◆ delegpt_create_mlc()

struct delegpt* delegpt_create_mlc ( uint8_t *  name)

create malloced delegation point, with the given name

Parameters
nameuncompressed wireformat of delegpt name.
Returns
NULL on alloc failure

References dname_count_size_labels(), delegpt::dp_type_mlc, memdup(), delegpt::name, delegpt::namelabs, and delegpt::namelen.

Referenced by compile_time_root_prime(), parse_delegpt(), read_fwds_name(), read_root_hints(), and read_stubs_name().

◆ delegpt_free_mlc()

void delegpt_free_mlc ( struct delegpt dp)

free malloced delegation point.

Parameters
dpmust have been created with delegpt_create_mlc, free'd.

References delegpt::dp_type_mlc, log_assert, delegpt::name, delegpt_ns::name, delegpt_ns::next, delegpt_addr::next_target, delegpt::nslist, and delegpt::target_list.

Referenced by compile_time_root_prime(), forwards_insert_data(), hints_insert(), parse_delegpt(), read_forwards(), and read_stubs().

◆ delegpt_set_name_mlc()

int delegpt_set_name_mlc ( struct delegpt dp,
uint8_t *  name 
)

Set name of delegation point.

Parameters
dpdelegation point. malloced.
namename to use.
Returns
false on error.

References dname_count_size_labels(), delegpt::dp_type_mlc, log_assert, memdup(), delegpt::name, delegpt::namelabs, and delegpt::namelen.

◆ delegpt_add_ns_mlc()

int delegpt_add_ns_mlc ( struct delegpt dp,
uint8_t *  name,
uint8_t  lame 
)

add a name to malloced delegation point.

Parameters
dpmust have been created with delegpt_create_mlc.
namethe name to add.
lamethe name is lame, disprefer.
Returns
false on error.

References delegpt_find_ns(), dname_count_size_labels(), delegpt_ns::done_pside4, delegpt_ns::done_pside6, delegpt::dp_type_mlc, delegpt_ns::got4, delegpt_ns::got6, delegpt_ns::lame, log_assert, memdup(), delegpt_ns::name, delegpt_ns::namelen, delegpt_ns::next, delegpt::nslist, and delegpt_ns::resolved.

Referenced by ah(), parse_delegpt(), read_fwds_host(), and read_stubs_host().

◆ delegpt_add_addr_mlc()

int delegpt_add_addr_mlc ( struct delegpt dp,
struct sockaddr_storage *  addr,
socklen_t  addrlen,
uint8_t  bogus,
uint8_t  lame 
)

add an address to a malloced delegation point.

Parameters
dpmust have been created with delegpt_create_mlc.
addrthe address.
addrlenthe length of addr.
bogusif address is bogus.
lameif address is lame.
Returns
false on error.

References delegpt_addr::addr, delegpt_addr::addrlen, delegpt_addr::attempts, delegpt_addr::bogus, delegpt_find_addr(), delegpt_addr::dnsseclame, delegpt::dp_type_mlc, delegpt_addr::lame, log_assert, delegpt_addr::next_result, delegpt_addr::next_target, delegpt_addr::next_usable, delegpt::target_list, and delegpt::usable_list.

Referenced by delegpt_add_target_mlc(), parse_delegpt(), read_fwds_addr(), and read_stubs_addr().

◆ delegpt_add_target_mlc()

int delegpt_add_target_mlc ( struct delegpt dp,
uint8_t *  name,
size_t  namelen,
struct sockaddr_storage *  addr,
socklen_t  addrlen,
uint8_t  bogus,
uint8_t  lame 
)

Add target address to the delegation point.

Parameters
dpmust have been created with delegpt_create_mlc.
namename for which target was found (must be in nslist). This name is marked resolved.
namelenlength of name.
addrthe address.
addrlenthe length of addr.
bogussecurity status for the address, pass true if bogus.
lameaddress is lame.
Returns
false on error.

References addr_is_ip6(), delegpt_add_addr_mlc(), delegpt_find_ns(), delegpt::dp_type_mlc, delegpt_ns::got4, delegpt_ns::got6, log_assert, and delegpt_ns::resolved.

Referenced by ah().