resolver.c File Reference

Go to the source code of this file.

Functions

uint16_t ldns_resolver_port (const ldns_resolver *r)
 Get the port the resolver should use. More...
 
ldns_rdfldns_resolver_source (const ldns_resolver *r)
 Get the source address the resolver should use. More...
 
uint16_t ldns_resolver_edns_udp_size (const ldns_resolver *r)
 Get the resolver's udp size. More...
 
uint8_t ldns_resolver_retry (const ldns_resolver *r)
 Get the number of retries. More...
 
uint8_t ldns_resolver_retrans (const ldns_resolver *r)
 Get the retransmit interval. More...
 
bool ldns_resolver_fallback (const ldns_resolver *r)
 Get the truncation fallback status. More...
 
uint8_t ldns_resolver_ip6 (const ldns_resolver *r)
 Does the resolver use ip6 or ip4. More...
 
bool ldns_resolver_recursive (const ldns_resolver *r)
 Is the resolver set to recurse. More...
 
bool ldns_resolver_debug (const ldns_resolver *r)
 Get the debug status of the resolver. More...
 
bool ldns_resolver_dnsrch (const ldns_resolver *r)
 Does the resolver apply search list. More...
 
bool ldns_resolver_fail (const ldns_resolver *r)
 Does the resolver only try the first nameserver. More...
 
bool ldns_resolver_defnames (const ldns_resolver *r)
 Does the resolver apply default domain name. More...
 
ldns_rdfldns_resolver_domain (const ldns_resolver *r)
 What is the default dname to add to relative queries. More...
 
ldns_rdf ** ldns_resolver_searchlist (const ldns_resolver *r)
 What is the searchlist as used by the resolver. More...
 
ldns_rdf ** ldns_resolver_nameservers (const ldns_resolver *r)
 Return the configured nameserver ip address. More...
 
size_t ldns_resolver_nameserver_count (const ldns_resolver *r)
 How many nameserver are configured in the resolver. More...
 
bool ldns_resolver_dnssec (const ldns_resolver *r)
 Does the resolver do DNSSEC. More...
 
bool ldns_resolver_dnssec_cd (const ldns_resolver *r)
 Does the resolver set the CD bit. More...
 
ldns_rr_listldns_resolver_dnssec_anchors (const ldns_resolver *r)
 Get the resolver's DNSSEC anchors. More...
 
bool ldns_resolver_trusted_key (const ldns_resolver *r, ldns_rr_list *keys, ldns_rr_list *trusted_keys)
 Returns true if at least one of the provided keys is a trust anchor. More...
 
bool ldns_resolver_igntc (const ldns_resolver *r)
 Does the resolver ignore the TC bit (truncated) More...
 
bool ldns_resolver_usevc (const ldns_resolver *r)
 Does the resolver use tcp or udp. More...
 
size_t * ldns_resolver_rtt (const ldns_resolver *r)
 Return the used round trip times for the nameservers. More...
 
size_t ldns_resolver_nameserver_rtt (const ldns_resolver *r, size_t pos)
 Return the used round trip time for a specific nameserver. More...
 
struct timeval ldns_resolver_timeout (const ldns_resolver *r)
 What is the timeout on socket connections. More...
 
const char * ldns_resolver_tsig_keyname (const ldns_resolver *r)
 Return the tsig keyname as used by the nameserver. More...
 
const char * ldns_resolver_tsig_algorithm (const ldns_resolver *r)
 Return the tsig algorithm as used by the nameserver. More...
 
const char * ldns_resolver_tsig_keydata (const ldns_resolver *r)
 Return the tsig keydata as used by the nameserver. More...
 
bool ldns_resolver_random (const ldns_resolver *r)
 Does the resolver randomize the nameserver before usage. More...
 
size_t ldns_resolver_searchlist_count (const ldns_resolver *r)
 Return the resolver's searchlist count. More...
 
void ldns_resolver_set_port (ldns_resolver *r, uint16_t p)
 Set the port the resolver should use. More...
 
void ldns_resolver_set_source (ldns_resolver *r, ldns_rdf *s)
 Set the source rdf (address) the resolver should use. More...
 
ldns_rdfldns_resolver_pop_nameserver (ldns_resolver *r)
 pop the last nameserver from the resolver. More...
 
ldns_status ldns_resolver_push_nameserver (ldns_resolver *r, const ldns_rdf *n)
 Push a new nameserver to the resolver. More...
 
ldns_status ldns_resolver_push_nameserver_rr (ldns_resolver *r, const ldns_rr *rr)
 Push a new nameserver to the resolver. More...
 
ldns_status ldns_resolver_push_nameserver_rr_list (ldns_resolver *r, const ldns_rr_list *rrlist)
 Push a new nameserver rr_list to the resolver. More...
 
void ldns_resolver_set_edns_udp_size (ldns_resolver *r, uint16_t s)
 Set maximum udp size. More...
 
void ldns_resolver_set_recursive (ldns_resolver *r, bool re)
 Set the resolver recursion. More...
 
void ldns_resolver_set_dnssec (ldns_resolver *r, bool d)
 Whether the resolver uses DNSSEC. More...
 
void ldns_resolver_set_dnssec_cd (ldns_resolver *r, bool d)
 Whether the resolver uses the checking disable bit. More...
 
void ldns_resolver_set_dnssec_anchors (ldns_resolver *r, ldns_rr_list *l)
 Set the resolver's DNSSEC anchor list directly. More...
 
ldns_status ldns_resolver_push_dnssec_anchor (ldns_resolver *r, ldns_rr *rr)
 Push a new trust anchor to the resolver. More...
 
void ldns_resolver_set_igntc (ldns_resolver *r, bool i)
 Whether or not to ignore the TC bit. More...
 
void ldns_resolver_set_usevc (ldns_resolver *r, bool vc)
 Whether the resolver uses a virtual circuit (TCP) More...
 
void ldns_resolver_set_debug (ldns_resolver *r, bool d)
 Set the resolver debugging. More...
 
void ldns_resolver_set_ip6 (ldns_resolver *r, uint8_t ip6)
 Whether the resolver uses ip6. More...
 
void ldns_resolver_set_fail (ldns_resolver *r, bool f)
 Whether or not to fail after one failed query. More...
 
void ldns_resolver_set_nameserver_count (ldns_resolver *r, size_t c)
 Set the resolver's nameserver count directly. More...
 
void ldns_resolver_set_dnsrch (ldns_resolver *r, bool d)
 Whether the resolver uses the searchlist. More...
 
void ldns_resolver_set_retry (ldns_resolver *r, uint8_t retry)
 Set the number of times a resolver should retry a nameserver before the next one is tried. More...
 
void ldns_resolver_set_retrans (ldns_resolver *r, uint8_t retrans)
 Set the resolver retrans timeout (in seconds) More...
 
void ldns_resolver_set_fallback (ldns_resolver *r, bool fallback)
 Set whether the resolvers truncation fallback mechanism is used when ldns_resolver_query() is called. More...
 
void ldns_resolver_set_nameservers (ldns_resolver *r, ldns_rdf **n)
 Set the resolver's nameserver count directly by using an rdf list. More...
 
void ldns_resolver_set_defnames (ldns_resolver *r, bool d)
 Whether the resolver uses the name set with _set_domain. More...
 
void ldns_resolver_set_rtt (ldns_resolver *r, size_t *rtt)
 Set round trip time for all nameservers. More...
 
void ldns_resolver_set_nameserver_rtt (ldns_resolver *r, size_t pos, size_t value)
 Set round trip time for a specific nameserver. More...
 
void ldns_resolver_incr_nameserver_count (ldns_resolver *r)
 Incremental the resolver's nameserver count. More...
 
void ldns_resolver_dec_nameserver_count (ldns_resolver *r)
 Decrement the resolver's nameserver count. More...
 
void ldns_resolver_set_domain (ldns_resolver *r, ldns_rdf *d)
 Set the resolver's default domain. More...
 
void ldns_resolver_set_timeout (ldns_resolver *r, struct timeval timeout)
 Set the resolver's socket time out when talking to remote hosts. More...
 
void ldns_resolver_push_searchlist (ldns_resolver *r, ldns_rdf *d)
 Push a new rd to the resolver's searchlist. More...
 
void ldns_resolver_set_tsig_keyname (ldns_resolver *r, const char *tsig_keyname)
 Set the tsig key name. More...
 
void ldns_resolver_set_tsig_algorithm (ldns_resolver *r, const char *tsig_algorithm)
 Set the tsig algorithm. More...
 
void ldns_resolver_set_tsig_keydata (ldns_resolver *r, const char *tsig_keydata)
 Set the tsig key data. More...
 
void ldns_resolver_set_random (ldns_resolver *r, bool b)
 Should the nameserver list be randomized before each use. More...
 
ldns_resolverldns_resolver_new (void)
 Create a new resolver structure. More...
 
ldns_resolverldns_resolver_clone (ldns_resolver *src)
 Clone a resolver. More...
 
ldns_status ldns_resolver_new_frm_fp (ldns_resolver **res, FILE *fp)
 Create a resolver structure from a file like /etc/resolv.conf. More...
 
ldns_status ldns_resolver_new_frm_fp_l (ldns_resolver **res, FILE *fp, int *line_nr)
 Create a resolver structure from a file like /etc/resolv.conf. More...
 
ldns_status ldns_resolver_new_frm_file (ldns_resolver **res, const char *filename)
 Configure a resolver by means of a resolv.conf file The file may be NULL in which case there will be looked the RESOLV_CONF (defaults to /etc/resolv.conf) More...
 
void ldns_resolver_free (ldns_resolver *res)
 Frees the allocated space for this resolver. More...
 
void ldns_resolver_deep_free (ldns_resolver *res)
 Frees the allocated space for this resolver and all it's data. More...
 
ldns_status ldns_resolver_search_status (ldns_pkt **pkt, ldns_resolver *r, const ldns_rdf *name, ldns_rr_type t, ldns_rr_class c, uint16_t flags)
 Send the query for using the resolver and take the search list into account The search algorithm is as follows: If the name is absolute, try it as-is, otherwise apply the search list. More...
 
ldns_pktldns_resolver_search (const ldns_resolver *r, const ldns_rdf *name, ldns_rr_type t, ldns_rr_class c, uint16_t flags)
 Send the query for using the resolver and take the search list into account The search algorithm is as follows: If the name is absolute, try it as-is, otherwise apply the search list. More...
 
ldns_status ldns_resolver_query_status (ldns_pkt **pkt, ldns_resolver *r, const ldns_rdf *name, ldns_rr_type t, ldns_rr_class c, uint16_t flags)
 Send a query to a nameserver. More...
 
ldns_pktldns_resolver_query (const ldns_resolver *r, const ldns_rdf *name, ldns_rr_type t, ldns_rr_class c, uint16_t flags)
 Send a query to a nameserver. More...
 
ldns_status ldns_resolver_send_pkt (ldns_pkt **answer, ldns_resolver *r, ldns_pkt *query_pkt)
 Send the given packet to a nameserver. More...
 
ldns_status ldns_resolver_prepare_query_pkt (ldns_pkt **query_pkt, ldns_resolver *r, const ldns_rdf *name, ldns_rr_type t, ldns_rr_class c, uint16_t flags)
 Form a query packet from a resolver and name/type/class combo. More...
 
ldns_status ldns_resolver_send (ldns_pkt **answer, ldns_resolver *r, const ldns_rdf *name, ldns_rr_type t, ldns_rr_class c, uint16_t flags)
 Send the query for name as-is. More...
 
ldns_rrldns_axfr_next (ldns_resolver *resolver)
 Get the next stream of RRs in a AXFR. More...
 
void ldns_axfr_abort (ldns_resolver *resolver)
 Abort a transfer that is in progress. More...
 
bool ldns_axfr_complete (const ldns_resolver *res)
 Returns true if the axfr transfer has completed (i.e. More...
 
ldns_pktldns_axfr_last_pkt (const ldns_resolver *res)
 Returns a pointer to the last ldns_pkt that was sent by the server in the AXFR transfer usable for instance to get the error code on failure. More...
 
void ldns_resolver_set_ixfr_serial (ldns_resolver *r, uint32_t serial)
 Get the serial for requesting IXFR. More...
 
uint32_t ldns_resolver_get_ixfr_serial (const ldns_resolver *res)
 Get the serial for requesting IXFR. More...
 
void ldns_resolver_nameservers_randomize (ldns_resolver *r)
 Randomize the nameserver list in the resolver. More...
 

Function Documentation

◆ ldns_resolver_port()

uint16_t ldns_resolver_port ( const ldns_resolver r)

Get the port the resolver should use.

Parameters
[in]rthe resolver
Returns
the port number

Definition at line 24 of file resolver.c.

References ldns_struct_resolver::_port.

◆ ldns_resolver_source()

ldns_rdf* ldns_resolver_source ( const ldns_resolver r)

Get the source address the resolver should use.

Parameters
[in]rthe resolver
Returns
the source rdf

Definition at line 30 of file resolver.c.

References ldns_struct_resolver::_source.

◆ ldns_resolver_edns_udp_size()

uint16_t ldns_resolver_edns_udp_size ( const ldns_resolver r)

Get the resolver's udp size.

Parameters
[in]rthe resolver
Returns
the udp mesg size

Definition at line 36 of file resolver.c.

References ldns_struct_resolver::_edns_udp_size.

◆ ldns_resolver_retry()

uint8_t ldns_resolver_retry ( const ldns_resolver r)

Get the number of retries.

Parameters
[in]rthe resolver
Returns
the number of retries

Definition at line 42 of file resolver.c.

References ldns_struct_resolver::_retry.

◆ ldns_resolver_retrans()

uint8_t ldns_resolver_retrans ( const ldns_resolver r)

Get the retransmit interval.

Parameters
[in]rthe resolver
Returns
the retransmit interval

Definition at line 48 of file resolver.c.

References ldns_struct_resolver::_retrans.

◆ ldns_resolver_fallback()

bool ldns_resolver_fallback ( const ldns_resolver r)

Get the truncation fallback status.

Parameters
[in]rthe resolver
Returns
whether the truncation fallback mechanism is used

Definition at line 54 of file resolver.c.

References ldns_struct_resolver::_fallback.

◆ ldns_resolver_ip6()

uint8_t ldns_resolver_ip6 ( const ldns_resolver r)

Does the resolver use ip6 or ip4.

Parameters
[in]rthe resolver
Returns
0: both, 1: ip4, 2:ip6

Definition at line 60 of file resolver.c.

References ldns_struct_resolver::_ip6.

◆ ldns_resolver_recursive()

bool ldns_resolver_recursive ( const ldns_resolver r)

Is the resolver set to recurse.

Parameters
[in]rthe resolver
Returns
true if so, otherwise false

Definition at line 66 of file resolver.c.

References ldns_struct_resolver::_recursive.

◆ ldns_resolver_debug()

bool ldns_resolver_debug ( const ldns_resolver r)

Get the debug status of the resolver.

Parameters
[in]rthe resolver
Returns
true if so, otherwise false

Definition at line 72 of file resolver.c.

References ldns_struct_resolver::_debug.

◆ ldns_resolver_dnsrch()

bool ldns_resolver_dnsrch ( const ldns_resolver r)

Does the resolver apply search list.

Parameters
[in]rthe resolver
Returns
true: yes, false: no

Definition at line 78 of file resolver.c.

References ldns_struct_resolver::_dnsrch.

◆ ldns_resolver_fail()

bool ldns_resolver_fail ( const ldns_resolver r)

Does the resolver only try the first nameserver.

Parameters
[in]rthe resolver
Returns
true: yes, fail, false: no, try the others

Definition at line 84 of file resolver.c.

References ldns_struct_resolver::_fail.

◆ ldns_resolver_defnames()

bool ldns_resolver_defnames ( const ldns_resolver r)

Does the resolver apply default domain name.

Parameters
[in]rthe resolver
Returns
true: yes, false: no

Definition at line 90 of file resolver.c.

References ldns_struct_resolver::_defnames.

◆ ldns_resolver_domain()

ldns_rdf* ldns_resolver_domain ( const ldns_resolver r)

What is the default dname to add to relative queries.

Parameters
[in]rthe resolver
Returns
the dname which is added

Definition at line 96 of file resolver.c.

References ldns_struct_resolver::_domain.

◆ ldns_resolver_searchlist()

ldns_rdf** ldns_resolver_searchlist ( const ldns_resolver r)

What is the searchlist as used by the resolver.

Parameters
[in]rthe resolver
Returns
a ldns_rdf pointer to a list of the addresses

Definition at line 102 of file resolver.c.

References ldns_struct_resolver::_searchlist.

◆ ldns_resolver_nameservers()

ldns_rdf** ldns_resolver_nameservers ( const ldns_resolver r)

Return the configured nameserver ip address.

Parameters
[in]rthe resolver
Returns
a ldns_rdf pointer to a list of the addresses

Definition at line 108 of file resolver.c.

References ldns_struct_resolver::_nameservers.

◆ ldns_resolver_nameserver_count()

size_t ldns_resolver_nameserver_count ( const ldns_resolver r)

How many nameserver are configured in the resolver.

Parameters
[in]rthe resolver
Returns
number of nameservers

Definition at line 114 of file resolver.c.

References ldns_struct_resolver::_nameserver_count.

◆ ldns_resolver_dnssec()

bool ldns_resolver_dnssec ( const ldns_resolver r)

Does the resolver do DNSSEC.

Parameters
[in]rthe resolver
Returns
true: yes, false: no

Definition at line 120 of file resolver.c.

References ldns_struct_resolver::_dnssec.

◆ ldns_resolver_dnssec_cd()

bool ldns_resolver_dnssec_cd ( const ldns_resolver r)

Does the resolver set the CD bit.

Parameters
[in]rthe resolver
Returns
true: yes, false: no

Definition at line 126 of file resolver.c.

References ldns_struct_resolver::_dnssec_cd.

◆ ldns_resolver_dnssec_anchors()

ldns_rr_list* ldns_resolver_dnssec_anchors ( const ldns_resolver r)

Get the resolver's DNSSEC anchors.

Parameters
[in]rthe resolver
Returns
an rr_list containing trusted DNSSEC anchors

Definition at line 132 of file resolver.c.

References ldns_struct_resolver::_dnssec_anchors.

◆ ldns_resolver_trusted_key()

bool ldns_resolver_trusted_key ( const ldns_resolver r,
ldns_rr_list keys,
ldns_rr_list trusted_keys 
)

Returns true if at least one of the provided keys is a trust anchor.

Parameters
[in]rthe current resolver
[in]keysthe keyset to check
[out]trusted_keysthe subset of trusted keys in the 'keys' rrset
Returns
true if at least one of the provided keys is a configured trust anchor

Definition at line 138 of file resolver.c.

References ldns_resolver_dnssec_anchors(), ldns_rr_list_contains_rr(), ldns_rr_list_push_rr(), ldns_rr_list_rr(), and ldns_rr_list_rr_count().

◆ ldns_resolver_igntc()

bool ldns_resolver_igntc ( const ldns_resolver r)

Does the resolver ignore the TC bit (truncated)

Parameters
[in]rthe resolver
Returns
true: yes, false: no

Definition at line 165 of file resolver.c.

References ldns_struct_resolver::_igntc.

◆ ldns_resolver_usevc()

bool ldns_resolver_usevc ( const ldns_resolver r)

Does the resolver use tcp or udp.

Parameters
[in]rthe resolver
Returns
true: tcp, false: udp

Definition at line 171 of file resolver.c.

References ldns_struct_resolver::_usevc.

◆ ldns_resolver_rtt()

size_t* ldns_resolver_rtt ( const ldns_resolver r)

Return the used round trip times for the nameservers.

Parameters
[in]rthe resolver
Returns
a size_t* pointer to the list. yet)

Definition at line 177 of file resolver.c.

References ldns_struct_resolver::_rtt.

◆ ldns_resolver_nameserver_rtt()

size_t ldns_resolver_nameserver_rtt ( const ldns_resolver r,
size_t  pos 
)

Return the used round trip time for a specific nameserver.

Parameters
[in]rthe resolver
[in]posthe index to the nameserver
Returns
the rrt, 0: infinite, >0: undefined (as of * yet)

Definition at line 183 of file resolver.c.

References ldns_resolver_nameserver_count(), and ldns_resolver_rtt().

◆ ldns_resolver_timeout()

struct timeval ldns_resolver_timeout ( const ldns_resolver r)

What is the timeout on socket connections.

Parameters
[in]rthe resolver
Returns
the timeout as struct timeval

Definition at line 183 of file resolver.c.

◆ ldns_resolver_tsig_keyname()

const char* ldns_resolver_tsig_keyname ( const ldns_resolver r)

Return the tsig keyname as used by the nameserver.

Parameters
[in]rthe resolver
Returns
the name used. Still owned by the resolver - change using ldns_resolver_set_tsig_keyname().

Definition at line 207 of file resolver.c.

References ldns_struct_resolver::_tsig_keyname.

◆ ldns_resolver_tsig_algorithm()

const char* ldns_resolver_tsig_algorithm ( const ldns_resolver r)

Return the tsig algorithm as used by the nameserver.

Parameters
[in]rthe resolver
Returns
the algorithm used. Still owned by the resolver - change using ldns_resolver_set_tsig_algorithm().

Definition at line 213 of file resolver.c.

References ldns_struct_resolver::_tsig_algorithm.

◆ ldns_resolver_tsig_keydata()

const char* ldns_resolver_tsig_keydata ( const ldns_resolver r)

Return the tsig keydata as used by the nameserver.

Parameters
[in]rthe resolver
Returns
the keydata used. Still owned by the resolver - change using ldns_resolver_set_tsig_keydata().

Definition at line 219 of file resolver.c.

References ldns_struct_resolver::_tsig_keydata.

◆ ldns_resolver_random()

bool ldns_resolver_random ( const ldns_resolver r)

Does the resolver randomize the nameserver before usage.

Parameters
[in]rthe resolver
Returns
true: yes, false: no

Definition at line 225 of file resolver.c.

References ldns_struct_resolver::_random.

◆ ldns_resolver_searchlist_count()

size_t ldns_resolver_searchlist_count ( const ldns_resolver r)

Return the resolver's searchlist count.

Parameters
[in]rthe resolver
Returns
the searchlist count

Definition at line 231 of file resolver.c.

References ldns_struct_resolver::_searchlist_count.

◆ ldns_resolver_set_port()

void ldns_resolver_set_port ( ldns_resolver r,
uint16_t  p 
)

Set the port the resolver should use.

Parameters
[in]rthe resolver
[in]pthe port number

Definition at line 238 of file resolver.c.

References ldns_struct_resolver::_port.

◆ ldns_resolver_set_source()

void ldns_resolver_set_source ( ldns_resolver r,
ldns_rdf s 
)

Set the source rdf (address) the resolver should use.

Parameters
[in]rthe resolver
[in]sthe source address

Definition at line 244 of file resolver.c.

References ldns_struct_resolver::_source.

◆ ldns_resolver_pop_nameserver()

ldns_rdf* ldns_resolver_pop_nameserver ( ldns_resolver r)

pop the last nameserver from the resolver.

Parameters
[in]rthe resolver
Returns
the popped address or NULL if empty

Definition at line 250 of file resolver.c.

References LDNS_FREE, ldns_resolver_dec_nameserver_count(), ldns_resolver_nameserver_count(), ldns_resolver_nameservers(), ldns_resolver_rtt(), ldns_resolver_set_nameservers(), ldns_resolver_set_rtt(), and LDNS_XREALLOC.

◆ ldns_resolver_push_nameserver()

ldns_status ldns_resolver_push_nameserver ( ldns_resolver r,
const ldns_rdf n 
)

Push a new nameserver to the resolver.

It must be an IP address v4 or v6.

Parameters
[in]rthe resolver
[in]nthe ip address
Returns
ldns_status a status

Definition at line 288 of file resolver.c.

References ldns_rdf_clone(), ldns_rdf_get_type(), LDNS_RDF_TYPE_A, LDNS_RDF_TYPE_AAAA, LDNS_RESOLV_RTT_MIN, ldns_resolver_incr_nameserver_count(), ldns_resolver_nameserver_count(), ldns_resolver_nameservers(), ldns_resolver_rtt(), ldns_resolver_set_nameservers(), ldns_resolver_set_rtt(), LDNS_STATUS_ERR, LDNS_STATUS_MEM_ERR, LDNS_STATUS_OK, LDNS_XMALLOC, and LDNS_XREALLOC.

◆ ldns_resolver_push_nameserver_rr()

ldns_status ldns_resolver_push_nameserver_rr ( ldns_resolver r,
const ldns_rr rr 
)

Push a new nameserver to the resolver.

It must be an A or AAAA RR record type

Parameters
[in]rthe resolver
[in]rrthe resource record
Returns
ldns_status a status

Definition at line 335 of file resolver.c.

References ldns_resolver_push_nameserver(), ldns_rr_get_type(), ldns_rr_rdf(), LDNS_RR_TYPE_A, LDNS_RR_TYPE_AAAA, and LDNS_STATUS_ERR.

◆ ldns_resolver_push_nameserver_rr_list()

ldns_status ldns_resolver_push_nameserver_rr_list ( ldns_resolver r,
const ldns_rr_list rrlist 
)

Push a new nameserver rr_list to the resolver.

Parameters
[in]rthe resolver
[in]rrlistthe rr_list to push
Returns
ldns_status a status

Definition at line 351 of file resolver.c.

References ldns_resolver_push_nameserver_rr(), ldns_rr_list_rr(), ldns_rr_list_rr_count(), LDNS_STATUS_ERR, and LDNS_STATUS_OK.

◆ ldns_resolver_set_edns_udp_size()

void ldns_resolver_set_edns_udp_size ( ldns_resolver r,
uint16_t  s 
)

Set maximum udp size.

Parameters
[in]rthe resolver
[in]sthe udp max size

Definition at line 373 of file resolver.c.

References ldns_struct_resolver::_edns_udp_size.

◆ ldns_resolver_set_recursive()

void ldns_resolver_set_recursive ( ldns_resolver r,
bool  b 
)

Set the resolver recursion.

Parameters
[in]rthe resolver
[in]btrue: set to recurse, false: unset

Definition at line 379 of file resolver.c.

References ldns_struct_resolver::_recursive.

◆ ldns_resolver_set_dnssec()

void ldns_resolver_set_dnssec ( ldns_resolver r,
bool  b 
)

Whether the resolver uses DNSSEC.

Parameters
[in]rthe resolver
[in]btrue: use DNSSEC, false: don't use DNSSEC

Definition at line 385 of file resolver.c.

References ldns_struct_resolver::_dnssec.

◆ ldns_resolver_set_dnssec_cd()

void ldns_resolver_set_dnssec_cd ( ldns_resolver r,
bool  b 
)

Whether the resolver uses the checking disable bit.

Parameters
[in]rthe resolver
[in]btrue: enable , false: don't use TCP

Definition at line 391 of file resolver.c.

References ldns_struct_resolver::_dnssec_cd.

◆ ldns_resolver_set_dnssec_anchors()

void ldns_resolver_set_dnssec_anchors ( ldns_resolver r,
ldns_rr_list l 
)

Set the resolver's DNSSEC anchor list directly.

RRs should be of type DS or DNSKEY.

Parameters
[in]rthe resolver
[in]lthe list of RRs to use as trust anchors

Definition at line 397 of file resolver.c.

References ldns_struct_resolver::_dnssec_anchors.

◆ ldns_resolver_push_dnssec_anchor()

ldns_status ldns_resolver_push_dnssec_anchor ( ldns_resolver r,
ldns_rr rr 
)

Push a new trust anchor to the resolver.

It must be a DS or DNSKEY rr

Parameters
[in]rthe resolver.
[in]rrthe RR to add as a trust anchor.
Returns
a status

Definition at line 403 of file resolver.c.

References ldns_resolver_dnssec_anchors(), ldns_resolver_set_dnssec_anchors(), ldns_rr_clone(), ldns_rr_get_type(), ldns_rr_list_new(), ldns_rr_list_push_rr(), LDNS_RR_TYPE_DNSKEY, LDNS_RR_TYPE_DS, LDNS_STATUS_ERR, and LDNS_STATUS_OK.

◆ ldns_resolver_set_igntc()

void ldns_resolver_set_igntc ( ldns_resolver r,
bool  b 
)

Whether or not to ignore the TC bit.

Parameters
[in]rthe resolver
[in]btrue: yes ignore, false: don't ignore

Definition at line 422 of file resolver.c.

References ldns_struct_resolver::_igntc.

◆ ldns_resolver_set_usevc()

void ldns_resolver_set_usevc ( ldns_resolver r,
bool  b 
)

Whether the resolver uses a virtual circuit (TCP)

Parameters
[in]rthe resolver
[in]btrue: use TCP, false: don't use TCP

Definition at line 428 of file resolver.c.

References ldns_struct_resolver::_usevc.

◆ ldns_resolver_set_debug()

void ldns_resolver_set_debug ( ldns_resolver r,
bool  b 
)

Set the resolver debugging.

Parameters
[in]rthe resolver
[in]btrue: debug on: false debug off

Definition at line 434 of file resolver.c.

References ldns_struct_resolver::_debug.

◆ ldns_resolver_set_ip6()

void ldns_resolver_set_ip6 ( ldns_resolver r,
uint8_t  i 
)

Whether the resolver uses ip6.

Parameters
[in]rthe resolver
[in]i0: no pref, 1: ip4, 2: ip6

Definition at line 440 of file resolver.c.

References ldns_struct_resolver::_ip6.

◆ ldns_resolver_set_fail()

void ldns_resolver_set_fail ( ldns_resolver r,
bool  b 
)

Whether or not to fail after one failed query.

Parameters
[in]rthe resolver
[in]btrue: yes fail, false: continue with next nameserver

Definition at line 446 of file resolver.c.

References ldns_struct_resolver::_fail.

◆ ldns_resolver_set_nameserver_count()

void ldns_resolver_set_nameserver_count ( ldns_resolver r,
size_t  c 
)

Set the resolver's nameserver count directly.

Parameters
[in]rthe resolver
[in]cthe nameserver count

Definition at line 458 of file resolver.c.

References ldns_struct_resolver::_nameserver_count.

◆ ldns_resolver_set_dnsrch()

void ldns_resolver_set_dnsrch ( ldns_resolver r,
bool  b 
)

Whether the resolver uses the searchlist.

Parameters
[in]rthe resolver
[in]btrue: use the list, false: don't use the list

Definition at line 464 of file resolver.c.

References ldns_struct_resolver::_dnsrch.

◆ ldns_resolver_set_retry()

void ldns_resolver_set_retry ( ldns_resolver r,
uint8_t  re 
)

Set the number of times a resolver should retry a nameserver before the next one is tried.

Parameters
[in]rthe resolver
[in]rethe number of retries

Definition at line 470 of file resolver.c.

References ldns_struct_resolver::_retry.

◆ ldns_resolver_set_retrans()

void ldns_resolver_set_retrans ( ldns_resolver r,
uint8_t  re 
)

Set the resolver retrans timeout (in seconds)

Parameters
[in]rthe resolver
[in]rethe retransmission interval in seconds

Definition at line 476 of file resolver.c.

References ldns_struct_resolver::_retrans.

◆ ldns_resolver_set_fallback()

void ldns_resolver_set_fallback ( ldns_resolver r,
bool  fallback 
)

Set whether the resolvers truncation fallback mechanism is used when ldns_resolver_query() is called.

Parameters
[in]rthe resolver
[in]fallbackwhether to use the fallback mechanism

Definition at line 482 of file resolver.c.

References ldns_struct_resolver::_fallback.

◆ ldns_resolver_set_nameservers()

void ldns_resolver_set_nameservers ( ldns_resolver r,
ldns_rdf **  rd 
)

Set the resolver's nameserver count directly by using an rdf list.

Parameters
[in]rthe resolver
[in]rdthe resolver addresses

Definition at line 488 of file resolver.c.

References ldns_struct_resolver::_nameservers.

◆ ldns_resolver_set_defnames()

void ldns_resolver_set_defnames ( ldns_resolver r,
bool  b 
)

Whether the resolver uses the name set with _set_domain.

Parameters
[in]rthe resolver
[in]btrue: use the defaults, false: don't use them

Definition at line 494 of file resolver.c.

References ldns_struct_resolver::_defnames.

◆ ldns_resolver_set_rtt()

void ldns_resolver_set_rtt ( ldns_resolver r,
size_t *  rtt 
)

Set round trip time for all nameservers.

Note this currently differentiates between: unreachable and reachable.

Parameters
[in]rthe resolver
[in]rtta list with the times

Definition at line 500 of file resolver.c.

References ldns_struct_resolver::_rtt.

◆ ldns_resolver_set_nameserver_rtt()

void ldns_resolver_set_nameserver_rtt ( ldns_resolver r,
size_t  pos,
size_t  value 
)

Set round trip time for a specific nameserver.

Note this currently differentiates between: unreachable and reachable.

Parameters
[in]rthe resolver
[in]posthe nameserver position
[in]valuethe rtt

Definition at line 506 of file resolver.c.

References ldns_resolver_nameserver_count(), and ldns_resolver_rtt().

◆ ldns_resolver_incr_nameserver_count()

void ldns_resolver_incr_nameserver_count ( ldns_resolver r)

Incremental the resolver's nameserver count.

Parameters
[in]rthe resolver

Definition at line 523 of file resolver.c.

References ldns_resolver_nameserver_count(), and ldns_resolver_set_nameserver_count().

◆ ldns_resolver_dec_nameserver_count()

void ldns_resolver_dec_nameserver_count ( ldns_resolver r)

Decrement the resolver's nameserver count.

Parameters
[in]rthe resolver

Definition at line 532 of file resolver.c.

References ldns_resolver_nameserver_count(), and ldns_resolver_set_nameserver_count().

◆ ldns_resolver_set_domain()

void ldns_resolver_set_domain ( ldns_resolver r,
ldns_rdf rd 
)

Set the resolver's default domain.

This gets appended when no absolute name is given

Parameters
[in]rthe resolver
[in]rdthe name to append

Definition at line 545 of file resolver.c.

References ldns_struct_resolver::_domain.

◆ ldns_resolver_set_timeout()

void ldns_resolver_set_timeout ( ldns_resolver r,
struct timeval  timeout 
)

Set the resolver's socket time out when talking to remote hosts.

Parameters
[in]rthe resolver
[in]timeoutthe timeout to use

Definition at line 551 of file resolver.c.

References ldns_struct_resolver::_timeout.

◆ ldns_resolver_push_searchlist()

void ldns_resolver_push_searchlist ( ldns_resolver r,
ldns_rdf rd 
)

Push a new rd to the resolver's searchlist.

Parameters
[in]rthe resolver
[in]rdto push

Definition at line 558 of file resolver.c.

References ldns_struct_resolver::_searchlist, ldns_rdf_clone(), ldns_rdf_get_type(), LDNS_RDF_TYPE_DNAME, ldns_resolver_searchlist(), ldns_resolver_searchlist_count(), and LDNS_XREALLOC.

◆ ldns_resolver_set_tsig_keyname()

void ldns_resolver_set_tsig_keyname ( ldns_resolver r,
const char *  tsig_keyname 
)

Set the tsig key name.

Parameters
[in]rthe resolver
[in]tsig_keynamethe tsig key name (copied into resolver)

Definition at line 580 of file resolver.c.

References ldns_struct_resolver::_tsig_keyname, and LDNS_FREE.

◆ ldns_resolver_set_tsig_algorithm()

void ldns_resolver_set_tsig_algorithm ( ldns_resolver r,
const char *  tsig_algorithm 
)

Set the tsig algorithm.

Parameters
[in]rthe resolver
[in]tsig_algorithmthe tsig algorithm (copied into resolver)

Definition at line 587 of file resolver.c.

References ldns_struct_resolver::_tsig_algorithm, and LDNS_FREE.

◆ ldns_resolver_set_tsig_keydata()

void ldns_resolver_set_tsig_keydata ( ldns_resolver r,
const char *  tsig_keydata 
)

Set the tsig key data.

Parameters
[in]rthe resolver
[in]tsig_keydatathe key data (copied into resolver)

Definition at line 594 of file resolver.c.

References ldns_struct_resolver::_tsig_keydata, and LDNS_FREE.

◆ ldns_resolver_set_random()

void ldns_resolver_set_random ( ldns_resolver r,
bool  b 
)

Should the nameserver list be randomized before each use.

Parameters
[in]rthe resolver
[in]btrue: randomize, false: don't

Definition at line 601 of file resolver.c.

References ldns_struct_resolver::_random.

◆ ldns_resolver_new()

ldns_resolver* ldns_resolver_new ( void  )

Create a new resolver structure.

Returns
ldns_resolver* pointer to new structure

Definition at line 608 of file resolver.c.

References ldns_struct_resolver::_nameservers, ldns_struct_resolver::_rtt, ldns_struct_resolver::_searchlist, and LDNS_MALLOC.

◆ ldns_resolver_clone()

◆ ldns_resolver_new_frm_fp()

ldns_status ldns_resolver_new_frm_fp ( ldns_resolver **  r,
FILE *  fp 
)

Create a resolver structure from a file like /etc/resolv.conf.

Parameters
[out]rthe new resolver
[in]fpfile pointer to create new resolver from if NULL use /etc/resolv.conf
Returns
LDNS_STATUS_OK or the error

Definition at line 759 of file resolver.c.

References ldns_resolver_new_frm_fp_l().

◆ ldns_resolver_new_frm_fp_l()

ldns_status ldns_resolver_new_frm_fp_l ( ldns_resolver **  r,
FILE *  fp,
int *  line_nr 
)

◆ ldns_resolver_new_frm_file()

ldns_status ldns_resolver_new_frm_file ( ldns_resolver **  r,
const char *  filename 
)

Configure a resolver by means of a resolv.conf file The file may be NULL in which case there will be looked the RESOLV_CONF (defaults to /etc/resolv.conf)

Parameters
[out]rthe new resolver
[in]filenamethe filename to use
Returns
LDNS_STATUS_OK or the error

Definition at line 1002 of file resolver.c.

References LDNS_RESOLV_CONF, ldns_resolver_free(), ldns_resolver_new_frm_fp(), LDNS_STATUS_FILE_ERR, LDNS_STATUS_NULL, and LDNS_STATUS_OK.

◆ ldns_resolver_free()

void ldns_resolver_free ( ldns_resolver res)

Frees the allocated space for this resolver.

Only frees the resolver pointer! You should probably be using _deep_free.

Parameters
resresolver to free

Definition at line 1033 of file resolver.c.

References LDNS_FREE.

◆ ldns_resolver_deep_free()

◆ ldns_resolver_search_status()

ldns_status ldns_resolver_search_status ( ldns_pkt **  pkt,
ldns_resolver r,
const ldns_rdf rdf,
ldns_rr_type  t,
ldns_rr_class  c,
uint16_t  flags 
)

Send the query for using the resolver and take the search list into account The search algorithm is as follows: If the name is absolute, try it as-is, otherwise apply the search list.

Parameters
[out]pkta packet with the reply from the nameserver
[in]*roperate using this resolver
[in]*rdfquery for this name
[in]tquery for this type (may be 0, defaults to A)
[in]cquery for this class (may be 0, default to IN)
[in]flagsthe query flags
Returns
ldns_status LDNS_STATUS_OK on success

Definition at line 1086 of file resolver.c.

References ldns_dname_absolute(), ldns_dname_cat_clone(), ldns_pkt_free(), ldns_pkt_get_rcode(), LDNS_RCODE_NOERROR, ldns_rdf_deep_free(), LDNS_RDF_TYPE_DNAME, ldns_resolver_dnsrch(), ldns_resolver_query_status(), ldns_resolver_searchlist(), ldns_resolver_searchlist_count(), and LDNS_STATUS_OK.

◆ ldns_resolver_search()

ldns_pkt* ldns_resolver_search ( const ldns_resolver r,
const ldns_rdf rdf,
ldns_rr_type  t,
ldns_rr_class  c,
uint16_t  flags 
)

Send the query for using the resolver and take the search list into account The search algorithm is as follows: If the name is absolute, try it as-is, otherwise apply the search list.

Parameters
[in]*roperate using this resolver
[in]*rdfquery for this name
[in]tquery for this type (may be 0, defaults to A)
[in]cquery for this class (may be 0, default to IN)
[in]flagsthe query flags
Returns
ldns_pkt* a packet with the reply from the nameserver

Definition at line 1130 of file resolver.c.

References ldns_pkt_free(), ldns_resolver_search_status(), and LDNS_STATUS_OK.

◆ ldns_resolver_query_status()

ldns_status ldns_resolver_query_status ( ldns_pkt **  pkt,
ldns_resolver r,
const ldns_rdf name,
ldns_rr_type  t,
ldns_rr_class  c,
uint16_t  flags 
)

Send a query to a nameserver.

Parameters
[out]pkta packet with the reply from the nameserver
[in]*roperate using this resolver
[in]*namequery for this name
[in]*tquery for this type (may be 0, defaults to A)
[in]*cquery for this class (may be 0, default to IN)
[in]flagsthe query flags
Returns
ldns_status LDNS_STATUS_OK on success if _defnames is true the default domain will be added

Definition at line 1143 of file resolver.c.

References ldns_dname_cat_clone(), ldns_rdf_free(), ldns_resolver_defnames(), ldns_resolver_domain(), ldns_resolver_send(), and LDNS_STATUS_MEM_ERR.

◆ ldns_resolver_query()

ldns_pkt* ldns_resolver_query ( const ldns_resolver r,
const ldns_rdf name,
ldns_rr_type  t,
ldns_rr_class  c,
uint16_t  flags 
)

Send a query to a nameserver.

Parameters
[in]*roperate using this resolver (despite the const in the declaration, the struct is altered as a side-effect)
[in]*namequery for this name
[in]*tquery for this type (may be 0, defaults to A)
[in]*cquery for this class (may be 0, default to IN)
[in]flagsthe query flags
Returns
ldns_pkt* a packet with the reply from the nameserver if _defnames is true the default domain will be added

Definition at line 1164 of file resolver.c.

References ldns_pkt_free(), ldns_resolver_query_status(), and LDNS_STATUS_OK.

◆ ldns_resolver_send_pkt()

ldns_status ldns_resolver_send_pkt ( ldns_pkt **  answer,
ldns_resolver r,
ldns_pkt query_pkt 
)

Send the given packet to a nameserver.

Parameters
[out]**answera pointer to a ldns_pkt pointer (initialized by this function)
[in]*roperate using this resolver
[in]*query_pktquery

Definition at line 1206 of file resolver.c.

References ldns_pkt_edns_udp_size(), ldns_pkt_free(), ldns_pkt_set_edns_udp_size(), ldns_pkt_tc(), ldns_resolver_fallback(), ldns_resolver_usevc(), ldns_send(), and LDNS_STATUS_OK.

◆ ldns_resolver_prepare_query_pkt()

ldns_status ldns_resolver_prepare_query_pkt ( ldns_pkt **  q,
ldns_resolver r,
const ldns_rdf name,
ldns_rr_type  t,
ldns_rr_class  c,
uint16_t  f 
)

Form a query packet from a resolver and name/type/class combo.

Parameters
[out]**qa pointer to a ldns_pkt pointer (initialized by this function)
[in]*roperate using this resolver
[in]*namequery for this name
[in]tquery for this type (may be 0, defaults to A)
[in]cquery for this class (may be 0, default to IN)
[in]fthe query flags
Returns
ldns_pkt* a packet with the reply from the nameserver

Definition at line 1264 of file resolver.c.

References LDNS_CD, ldns_native2rdf_int32(), ldns_pkt_id(), ldns_pkt_ixfr_request_new(), ldns_pkt_print(), ldns_pkt_query_new(), ldns_pkt_set_cd(), ldns_pkt_set_edns_do(), ldns_pkt_set_edns_udp_size(), ldns_pkt_set_random_id(), ldns_pkt_set_timestamp(), ldns_rdf_clone(), LDNS_RDF_TYPE_INT32, ldns_resolver_debug(), ldns_resolver_dnssec(), ldns_resolver_dnssec_cd(), ldns_resolver_edns_udp_size(), ldns_resolver_get_ixfr_serial(), ldns_resolver_set_edns_udp_size(), ldns_rr_free(), ldns_rr_new(), ldns_rr_push_rdf(), ldns_rr_set_class(), ldns_rr_set_owner(), ldns_rr_set_question(), ldns_rr_set_type(), LDNS_RR_TYPE_IXFR, LDNS_RR_TYPE_SOA, LDNS_STATUS_ERR, LDNS_STATUS_OK, and ldns_str2rdf_dname().

◆ ldns_resolver_send()

ldns_status ldns_resolver_send ( ldns_pkt **  answer,
ldns_resolver r,
const ldns_rdf name,
ldns_rr_type  t,
ldns_rr_class  c,
uint16_t  flags 
)

Send the query for name as-is.

Parameters
[out]**answera pointer to a ldns_pkt pointer (initialized by this function)
[in]*roperate using this resolver
[in]*namequery for this name
[in]tquery for this type (may be 0, defaults to A)
[in]cquery for this class (may be 0, default to IN)
[in]flagsthe query flags
Returns
ldns_status LDNS_STATUS_OK on success

Definition at line 1375 of file resolver.c.

References ldns_pkt_free(), ldns_pkt_tsig_sign(), ldns_rdf_get_type(), LDNS_RDF_TYPE_DNAME, ldns_resolver_nameserver_count(), ldns_resolver_prepare_query_pkt(), ldns_resolver_send_pkt(), ldns_resolver_tsig_algorithm(), ldns_resolver_tsig_keydata(), ldns_resolver_tsig_keyname(), LDNS_RR_CLASS_IN, LDNS_RR_TYPE_A, LDNS_STATUS_CRYPTO_TSIG_ERR, LDNS_STATUS_OK, LDNS_STATUS_RES_NO_NS, and LDNS_STATUS_RES_QUERY.

◆ ldns_axfr_next()

ldns_rr* ldns_axfr_next ( ldns_resolver resolver)

Get the next stream of RRs in a AXFR.

Parameters
[in]resolverthe resolver to use. First ldns_axfr_start() must be called
Returns
ldns_rr the next RR from the AXFR stream After you get this returned RR (not NULL: on error), then check if ldns_axfr_complete() is true to see if the zone transfer has completed.

Definition at line 1442 of file resolver.c.

References ldns_struct_resolver::_axfr_i, ldns_struct_resolver::_axfr_soa_count, ldns_struct_resolver::_cur_axfr_pkt, ldns_struct_resolver::_socket, ldns_struct_resolver::_timeout, close_socket, LDNS_FREE, ldns_get_errorstr_by_id(), ldns_lookup_by_id(), ldns_pkt_ancount(), ldns_pkt_answer(), ldns_pkt_free(), ldns_pkt_get_rcode(), ldns_rcodes, ldns_rr_clone(), ldns_rr_get_type(), ldns_rr_list_rr(), LDNS_RR_TYPE_SOA, LDNS_STATUS_OK, ldns_tcp_read_wire_timeout(), ldns_wire2pkt(), and ldns_struct_lookup_table::name.

◆ ldns_axfr_abort()

void ldns_axfr_abort ( ldns_resolver resolver)

Abort a transfer that is in progress.

Parameters
[in]resolverthe resolver that is used

Definition at line 1534 of file resolver.c.

References ldns_struct_resolver::_socket.

◆ ldns_axfr_complete()

bool ldns_axfr_complete ( const ldns_resolver resolver)

Returns true if the axfr transfer has completed (i.e.

2 SOA RRs and no errors were encountered

Parameters
[in]resolverthe resolver that is used
Returns
bool true if axfr transfer was completed without error

Definition at line 1549 of file resolver.c.

References ldns_struct_resolver::_axfr_soa_count.

◆ ldns_axfr_last_pkt()

ldns_pkt* ldns_axfr_last_pkt ( const ldns_resolver res)

Returns a pointer to the last ldns_pkt that was sent by the server in the AXFR transfer usable for instance to get the error code on failure.

Parameters
[in]resthe resolver that was used in the axfr transfer
Returns
ldns_pkt the last packet sent

Definition at line 1556 of file resolver.c.

References ldns_struct_resolver::_cur_axfr_pkt.

◆ ldns_resolver_set_ixfr_serial()

void ldns_resolver_set_ixfr_serial ( ldns_resolver r,
uint32_t  serial 
)

Get the serial for requesting IXFR.

Parameters
[in]rthe resolver
[in]serialserial

Definition at line 1562 of file resolver.c.

References ldns_struct_resolver::_serial.

◆ ldns_resolver_get_ixfr_serial()

uint32_t ldns_resolver_get_ixfr_serial ( const ldns_resolver res)

Get the serial for requesting IXFR.

Parameters
[in]resthe resolver
Returns
uint32_t serial

Definition at line 1568 of file resolver.c.

References ldns_struct_resolver::_serial.

◆ ldns_resolver_nameservers_randomize()

void ldns_resolver_nameservers_randomize ( ldns_resolver r)

Randomize the nameserver list in the resolver.

Parameters
[in]rthe resolver

Definition at line 1576 of file resolver.c.

References ldns_get_random(), ldns_resolver_nameserver_count(), ldns_resolver_nameservers(), ldns_resolver_rtt(), and ldns_resolver_set_nameservers().