dns.c

Software Screenshot:
dns.c
Software Details:
Version: 20120805
Upload Date: 20 Feb 15
Developer: William Ahern
Distribution Type: Freeware
Downloads: 29

Rating: nan/5 (Total Votes: 0)

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).

What is new in this release:

  • Fix bug where dns_srv_print() failed to print a trailing NUL character.

What is new in version 20100813:

  • Add socket.c into contrib/. I've been using and developing this for a year or so within other projects. Conceptually it's a simple wrapper around the BSD sockets API that handles DNS lookups and SSL negotiation transparently and asynchronously.
  • After creating a socket with so_open(), the caller sets the appropriate modes, e.g. so_connect() and so_starttls(). The caller can then wait for them to complete (they'll return EAGAIN if necessary), or more conveniently ignore the result and move directly to attempting reads and writes. Errors from the previous states, including EAGAIN, will be returned on any read or write attempts until those states are complete.
  • Use so_pollfd() and so_events() just like the dns.c counterparts. They return, respectively, the appropriate descriptor and event flags depending on which internal state is executing. The application need only worry about issuing logical read/write operations.

What is new in version 20100709:

  • Fix MinGW build by adding internal dns_strsep() and DNS_ETIMEDOUT.

What is new in version 20100708:

  • Check the validity of the length returned by dns_d_expand() before passing it as the source length to dns_d_cleave() inside of dns_hints_query() else we might do an invalid read. Thanks to Anonymous.
  • Tag rel-20100708 (d493a0f7d8f1d67ef312a7ca3e142660895b32d8).
  • NOTE: Forgot to bump DNS_V_REL for the 20100708 release, and because the new stats interface was in the trunk also should have bumped DNS_V_API. Too late now.

What is new in version 20100515:

  • Loop over nameservers resolv.conf:options.attempts times.
  • Enforce SPF canonical name query limits when running MX and PTR mechanisms.
  • Add dns_p_study() to learn and store section ranges.
  • Keep track of section ranges in dns_p_push().
  • Refactor dns_p_merge() to improve performance on large packets.
  • Add dns_p_make() for malloc'ing and initializing a new packet.
  • Enforce SPF term query limits. Changed the layout of struct spf_limits in anticipation of enforcing limits on MX and PTR host queries.
  • Fix bug in the VM instruction generator for jump indices of more than 255.

What is new in version 20100416:

  • Added SSHFP support.
  • Tag rel-20100416 (5bd9963e693510e485a1f081f6c98a95d84debfe).
  • 90% passage rate on the OpenSPF test suite. Need to simulate timeouts to pass the TempError tests. Some of the grammar tests are debatable.
  • Added OpenSPF YAML test suite processor. Requires libyaml.

What is new in version 0.5:

  • Fix bug where we didn't fallback from "bind" method to "file" method if the recurse flag was disabled.
  • Search generator may have changed the qname. So, in dns_ai_nextent() canonicalize the qname from the answer, not the qname originally submitted to the resolver.

Similar Software

DNS-Tool
DNS-Tool

3 Jun 15

NSD
NSD

17 Feb 15

dnstracer
dnstracer

2 Jun 15

Comments to dns.c

Comments not found
Add Comment
Turn on images!