20 #ifndef LDNS_RESOLVER_H
21 #define LDNS_RESOLVER_H
36 #define LDNS_RESOLV_CONF "/etc/resolv.conf"
38 #define LDNS_RESOLV_HOSTS "/etc/hosts"
40 #define LDNS_RESOLV_KEYWORD -1
41 #define LDNS_RESOLV_DEFDOMAIN 0
42 #define LDNS_RESOLV_NAMESERVER 1
43 #define LDNS_RESOLV_SEARCH 2
44 #define LDNS_RESOLV_SORTLIST 3
45 #define LDNS_RESOLV_OPTIONS 4
46 #define LDNS_RESOLV_ANCHOR 5
47 #define LDNS_RESOLV_KEYWORDS 6
49 #define LDNS_RESOLV_INETANY 0
50 #define LDNS_RESOLV_INET 1
51 #define LDNS_RESOLV_INET6 2
53 #define LDNS_RESOLV_RTT_INF 0
54 #define LDNS_RESOLV_RTT_MIN 1
Common definitions for LDNS.
Defines error numbers and functions to translate those to a readable string.
enum ldns_enum_status ldns_status
Contains the definition of ldns_pkt and its parts, as well as functions to manipulate those.
Defines ldns_rdf and functions to manipulate those.
void ldns_resolver_set_edns_udp_size(ldns_resolver *r, uint16_t s)
Set maximum udp size.
void ldns_resolver_set_retrans(ldns_resolver *r, uint8_t re)
Set the resolver retrans timeout (in seconds)
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.
void ldns_resolver_set_tsig_algorithm(ldns_resolver *r, const char *tsig_algorithm)
Set the tsig algorithm.
void ldns_resolver_set_fail(ldns_resolver *r, signed char b)
Whether or not to fail after one failed 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.
ldns_rr * ldns_axfr_next(ldns_resolver *resolver)
Get the next stream of RRs in a AXFR.
const char * ldns_resolver_tsig_algorithm(const ldns_resolver *r)
Return the tsig algorithm as used by the nameserver.
void ldns_resolver_set_timeout(ldns_resolver *r, struct timeval timeout)
Set the resolver's socket time out when talking to remote hosts.
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 a...
ldns_resolver * ldns_resolver_clone(ldns_resolver *r)
Clone a resolver.
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.
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.
void ldns_resolver_set_tsig_keydata(ldns_resolver *r, const char *tsig_keydata)
Set the tsig key data.
void ldns_resolver_set_dnssec_anchors(ldns_resolver *r, ldns_rr_list *l)
Set the resolver's DNSSEC anchor list directly.
signed char ldns_resolver_dnssec_cd(const ldns_resolver *r)
Does the resolver set the CD bit.
signed char ldns_resolver_fail(const ldns_resolver *r)
Does the resolver only try the first nameserver.
ldns_resolver * ldns_resolver_new(void)
Create a new resolver structure.
void ldns_resolver_set_dnsrch(ldns_resolver *r, signed char b)
Whether the resolver uses the searchlist.
const char * ldns_resolver_tsig_keydata(const ldns_resolver *r)
Return the tsig keydata as used by the nameserver.
ldns_rdf * ldns_resolver_pop_nameserver(ldns_resolver *r)
pop the last nameserver from the resolver.
void ldns_resolver_set_nameserver_rtt(ldns_resolver *r, size_t pos, size_t value)
Set round trip time for a specific nameserver.
signed char ldns_axfr_complete(const ldns_resolver *resolver)
Returns true if the axfr transfer has completed (i.e.
ldns_status ldns_resolver_new_frm_fp_l(ldns_resolver **r, FILE *fp, int *line_nr)
Create a resolver structure from a file like /etc/resolv.conf.
signed char ldns_resolver_recursive(const ldns_resolver *r)
Is the resolver set to recurse.
size_t ldns_resolver_searchlist_count(const ldns_resolver *r)
Return the resolver's searchlist count.
ldns_rr_list * ldns_resolver_dnssec_anchors(const ldns_resolver *r)
Get the resolver's DNSSEC anchors.
signed char ldns_resolver_dnsrch(const ldns_resolver *r)
Does the resolver apply search list.
void ldns_resolver_set_ip6(ldns_resolver *r, uint8_t i)
Whether the resolver uses ip6.
signed char ldns_resolver_fallback(const ldns_resolver *r)
Get the truncation fallback status.
void ldns_resolver_set_fallback(ldns_resolver *r, signed char fallback)
Set whether the resolvers truncation fallback mechanism is used when ldns_resolver_query() is called.
size_t ldns_resolver_nameserver_count(const ldns_resolver *r)
How many nameserver are configured in the resolver.
void ldns_resolver_free(ldns_resolver *res)
Frees the allocated space for this resolver.
void ldns_resolver_set_rtt(ldns_resolver *r, size_t *rtt)
Set round trip time for all nameservers.
void ldns_resolver_dec_nameserver_count(ldns_resolver *r)
Decrement the resolver's nameserver count.
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.
void ldns_resolver_set_ixfr_serial(ldns_resolver *r, uint32_t serial)
Get the serial for requesting IXFR.
uint8_t ldns_resolver_retrans(const ldns_resolver *r)
Get the retransmit interval.
void ldns_resolver_set_port(ldns_resolver *r, uint16_t p)
Set the port the resolver should use.
size_t ldns_resolver_nameserver_rtt(const ldns_resolver *r, size_t pos)
Return the used round trip time for a specific nameserver.
void ldns_resolver_nameservers_randomize(ldns_resolver *r)
Randomize the nameserver list in the resolver.
uint32_t ldns_resolver_get_ixfr_serial(const ldns_resolver *res)
Get the serial for requesting IXFR.
signed char ldns_resolver_defnames(const ldns_resolver *r)
Does the resolver apply default domain name.
ldns_rdf * ldns_resolver_domain(const ldns_resolver *r)
What is the default dname to add to relative queries.
uint16_t ldns_resolver_edns_udp_size(const ldns_resolver *r)
Get the resolver's udp size.
void ldns_resolver_set_debug(ldns_resolver *r, signed char b)
Set the resolver debugging.
void ldns_resolver_set_nameserver_count(ldns_resolver *r, size_t c)
Set the resolver's nameserver count directly.
signed char 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.
signed char ldns_resolver_dnssec(const ldns_resolver *r)
Does the resolver do DNSSEC.
struct timeval ldns_resolver_timeout(const ldns_resolver *r)
What is the timeout on socket connections.
ldns_status ldns_resolver_push_nameserver(ldns_resolver *r, const ldns_rdf *n)
Push a new nameserver to the resolver.
size_t * ldns_resolver_rtt(const ldns_resolver *r)
Return the used round trip times for the nameservers.
uint8_t ldns_resolver_ip6(const ldns_resolver *r)
Does the resolver use ip6 or ip4.
signed char ldns_resolver_random(const ldns_resolver *r)
Does the resolver randomize the nameserver before usage.
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 in...
void ldns_resolver_set_nameservers(ldns_resolver *r, ldns_rdf **rd)
Set the resolver's nameserver count directly by using an rdf list.
ldns_status ldns_resolver_push_dnssec_anchor(ldns_resolver *r, ldns_rr *rr)
Push a new trust anchor to the resolver.
void ldns_resolver_set_source(ldns_resolver *r, ldns_rdf *s)
Set the source rdf (address) the resolver should use.
uint8_t ldns_resolver_retry(const ldns_resolver *r)
Get the number of retries.
void ldns_axfr_abort(ldns_resolver *resolver)
Abort a transfer that is in progress.
ldns_rdf ** ldns_resolver_searchlist(const ldns_resolver *r)
What is the searchlist as used by the resolver.
void ldns_resolver_set_defnames(ldns_resolver *r, signed char b)
Whether the resolver uses the name set with _set_domain.
ldns_status ldns_resolver_push_nameserver_rr(ldns_resolver *r, const ldns_rr *rr)
Push a new nameserver to the resolver.
void ldns_resolver_incr_nameserver_count(ldns_resolver *r)
Incremental the resolver's nameserver count.
const char * ldns_resolver_tsig_keyname(const ldns_resolver *r)
Return the tsig keyname as used by the nameserver.
void ldns_resolver_set_domain(ldns_resolver *r, ldns_rdf *rd)
Set the resolver's default domain.
ldns_rdf ** ldns_resolver_nameservers(const ldns_resolver *r)
Return the configured nameserver ip address.
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 a...
void ldns_resolver_set_usevc(ldns_resolver *r, signed char b)
Whether the resolver uses a virtual circuit (TCP)
signed char ldns_resolver_usevc(const ldns_resolver *r)
Does the resolver use tcp or udp.
void ldns_resolver_set_tsig_keyname(ldns_resolver *r, const char *tsig_keyname)
Set the tsig key name.
void ldns_resolver_set_dnssec(ldns_resolver *r, signed char b)
Whether the resolver uses DNSSEC.
ldns_rdf * ldns_resolver_source(const ldns_resolver *r)
Get the source address the resolver should use.
signed char ldns_resolver_igntc(const ldns_resolver *r)
Does the resolver ignore the TC bit (truncated)
void ldns_resolver_set_random(ldns_resolver *r, signed char b)
Should the nameserver list be randomized before each use.
uint16_t ldns_resolver_port(const ldns_resolver *r)
Get the port the resolver should use.
signed char ldns_resolver_debug(const ldns_resolver *r)
Get the debug status of the resolver.
void ldns_resolver_push_searchlist(ldns_resolver *r, ldns_rdf *rd)
Push a new rd to the resolver's searchlist.
void ldns_resolver_set_recursive(ldns_resolver *r, signed char b)
Set the resolver recursion.
void ldns_resolver_set_igntc(ldns_resolver *r, signed char b)
Whether or not to ignore the TC bit.
ldns_status ldns_resolver_new_frm_fp(ldns_resolver **r, FILE *fp)
Create a resolver structure from a file like /etc/resolv.conf.
ldns_status ldns_resolver_send_pkt(ldns_pkt **answer, ldns_resolver *r, ldns_pkt *query_pkt)
Send the given packet to a nameserver.
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.
void ldns_resolver_set_dnssec_cd(ldns_resolver *r, signed char b)
Whether the resolver uses the checking disable bit.
void ldns_resolver_deep_free(ldns_resolver *res)
Frees the allocated space for this resolver and all it's data.
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 ...
Contains the definition of ldns_rr and functions to manipulate those.
enum ldns_enum_rr_type ldns_rr_type
enum ldns_enum_rr_class ldns_rr_class
Resource record data field.
DNS stub resolver structure.
ldns_pkt * _cur_axfr_pkt
Packet currently handled when doing part of an AXFR.
int _socket
Keep some things to make AXFR possible.
uint16_t _axfr_i
Counter for within the AXFR packets.
char * _tsig_keyname
Name of the key to use with TSIG, if _tsig_keyname and _tsig_keydata both contain values,...
uint8_t _retrans
Time to wait before retrying.
signed char _fallback
Use new fallback mechanism (try EDNS, then do TCP)
ldns_rdf * _source
Source address to query from.
signed char _dnssec
Whether to do DNSSEC.
signed char _recursive
Whether or not to be recursive.
signed char _dnsrch
If true apply the search list.
signed char _usevc
Whether to use tcp or udp (tcp if the value is true)
signed char _defnames
If true append the default domain.
ldns_rr_list * _dnssec_anchors
Optional trust anchors for complete DNSSEC validation.
size_t _nameserver_count
Number of nameservers in _nameservers.
ldns_rdf ** _searchlist
Searchlist array, add the names in this array if a query cannot be found.
signed char _igntc
Whether to ignore the tc bit.
uint8_t _ip6
Whether to use ip6: 0->does not matter, 1 is IPv4, 2 is IPv6.
ldns_rdf ** _nameservers
Array of nameservers to query (IP addresses or dnames)
char * _tsig_keydata
Secret key data to use with TSIG, if _tsig_keyname and _tsig_keydata both contain values,...
size_t * _rtt
Round trip time; 0 -> infinity.
signed char _fail
Only try the first nameserver, and return with an error directly if it fails.
char * _tsig_algorithm
TSIG signing algorithm.
int _axfr_soa_count
Count the number of LDNS_RR_TYPE_SOA RRs we have seen so far (the second one signifies the end of the...
signed char _dnssec_cd
Whether to set the CD bit on DNSSEC requests.
size_t _searchlist_count
Number of entries in the searchlist array.
struct timeval _timeout
Timeout for socket connections.
signed char _debug
Print debug information.
signed char _random
Randomly choose a nameserver.
uint8_t _retry
Number of times to retry before giving up.
ldns_rdf * _domain
Default domain to add to non fully qualified domain names.
uint16_t _port
Port to send queries to.
List or Set of Resource Records.
Defines functions for TSIG usage.