dns.c 20120805

A recursive, reentrant DNS Resolver

  Add it to your Download Basket!

 Add it to your Watch List!

0/5

Rate it!

What's new in dns.c 20110114:

  • Fix bug where dns_srv_print() failed to print a trailing NUL character.
Read full changelog
send us
an update
LICENSE TYPE:
Freeware 
USER RATING:
UNRATED
  0.0/5
DEVELOPED BY:
William Ahern
HOMEPAGE:
25thandclement.com
CATEGORY:
ROOT \ Internet \ DNS
dns.c is a reentrant, recursive and non-blocking DNS resolver library that resides in a sincle .c file. Also works great as a stub resolver.

Core API built around actual DNS packet; as generic as DNS itself. This makes querying and manipulating records other than A, AAAA, and PTR much easier.

Restartable record iterators with user-specified sorting. Iterating over MX or SRV records in semantic order (i.e. preference and priority) is as simple as:

dns_rr_foreach(&rr, packet, .type = DNS_T_SRV, .sort = &dns_rr_i_order) {
  ...
}


Or in a restartable manner:

switch (my->state) {
case 0:
  dns_rr_i_init(&my->rr_i);
  my->rr_i.type = DNS_T_SRV;
  my->rr_i.sort = &dns_rr_i_order;
  my->state++;
case 1:
  while (dns_rr_grep(&rr, 1, &my->rr_i, my->packet, &error)) {
    ...
    /* return into event loop */
  }
}


Supports "smart" queries. When enabled in the core resolver, queries for NS, MX, and SRV records will always attempt to resolve the RDATA canonical host name into an A record. Hosts which are not in-bailiwick and/or for which the authoritative server does not provide glue are automagically resolved and returned in the answer packet. Supported for both stub and recursive resolver instantiations. "Smart" resolution is also built into the address info (i.e. getaddrinfo()) API.

Randomized source ports and QIDs.

Non-blocking, re-entrant, iterator-based getaddrinfo() interface: dns_ai_open(), dns_ai_nextent(), dns_ai_close(). Semantically just like getaddrinfo(), but also takes a record type. Iterate over (struct addrinfo) objects even when querying an MX, NS, SRV (et al) host. There is less latency doing "smart" queries this way, since any necessary recursion can be postponed (and in all likelihood won't be necessary, since the first host is likely sufficient).

Last updated on August 8th, 2012

#DNS resolver #recursive DNS #reentrant #recursive #DNS #resolver

Add your review!

SUBMIT