SYNTAX

       #include "dnsresolv.h"

       int dns_ip4_packet(stralloc *out,const char *buf,unsigned int len);
       int dns_ip4(stralloc *out,stralloc *fqdn);

       int dns_ip6_packet(stralloc *out,const char *buf,unsigned int len);
       int dns_ip6(stralloc *out,stralloc *fqdn);

       int dns_mx(stralloc *out,stralloc *fqdn);
       int dns_mx_packet(stralloc *out,const char *buf,unsigned int len);

       void dns_name4_domain(char q[DNS_NAME4_DOMAIN],const char *ip[4]);
       int dns_name4(stralloc *out,const char *ip[4]);

       void dns_name6_domain(char q[DNS_NAME6_DOMAIN],const char *ip[16]);
       int dns_name6(stralloc *out,const char *ip[16]);

       int dns_name(stralloc *out,const char *ip[16]);
       int dns_name_packet(stralloc *out,const char *buf,unsigned int len);

       int dns_txt(stralloc *out,stralloc *fqdn);
       int dns_txt_packet(stralloc *out,const char *buf,unsigned int len);

       int dns_cname(stralloc *out,stralloc *fqdn);
       int dns_cname_packet(stralloc *out,const char *buf,unsigned int len);

       int dns_ip4_qualify(stralloc *out,stralloc *fqdn,const stralloc *udn);
       int dns_ip6_qualify(stralloc *out,stralloc *fqdn,const stralloc *udn);
       int dns_ip_qualify(stralloc *out,stralloc *fqdn,const stralloc *udn);


DESCRIPTION

       dns_ip[4|6]_packet is a low-level component of dns_ip[4|6], designed to
       support asynchronous DNS lookups.  It reads a DNS packet of length len
       from buf, extracts the IP(4|6) addresses from the answer section of the
       packet and puts the addresses into out.

       dns_ip[4|6] looks up 4/16-byte IPv6 addresses for the fully-qualified
       domain name of fqdn.  It puts the concatenation of the IPv[4|6]
       addresses into out and returns the number of received answers for fqdn
       or 0 if none are replied.  If the domain does not exist in DNS, or has
       no IP addresses, out will be empty.  More generally, if fqdn is considered
       by  dns_ip4  to be a dotted-decimal IPv4 address, it is provissioned as
       out without checking the DNS while returning 1.  Brackets  may  enclose
       the dotted-decimal IP address; they are ignored.

       dns_name[4|6]_packet is a low-level component of dns_name[4|6] designed
       to support asynchronous DNS lookups.  It reads a DNS packet of length
       len from buf,

       dns_name[4|6]_domain is a low-level component of dns_name[4|6].  It
       converts an IP address such as 1.2.3.4 or 4321:0:1:2:3:4:567:89ab into
       followed by a \0-terminated dot-encoded domain name. If the domain does
       not exist in DNS, or has no MX records, out will be empty.

       dns_txt_packet is a low-level component of dns_txt, designed to support
       asynchronous DNS lookups. It reads a DNS packet of length len from buf,
       extracts the TXT records from the answer section of the packet, puts
       the result into out, and returns the number of replies or -1 the same
       way as dns_txt.

       dns_txt looks up TXT records for the fully-qualified domain name in
       fqdn. It puts the concatenation of the TXT records into out and returns
       the number of replies received.  If the domain does not exist in DNS,
       or has no TXT records, out will be empty.

       dns_cname_packet is a low-level component of dns_cname, designed to
       support asynchronous DNS lookups. It reads a DNS packet of length len
       from buf, extracts the TXT records from the answer section of the
       packet, puts the result into out, and returns the number of replies
       received  or -1 the same way as dns_cname.

       dns_cname looks up the canonical name for a given fqdn.

       dns_ip[4|6]_qualify feeds the name udn through qualification and looks
       up their 4-byte/16-byte IP addresses. It puts the fully qualified
       domain name into fqdn and the concatenation of the IP addresses into
       out, while returning the number of encountered IP addresses.
       dns_ip[4|6]_qualify evaluates the environment variables $DNSREWRITEFILE
       pointing to /etc/dnsrewrite and $LOCALDOMAIN and finally reading
       /etc/resolv.conf to build the Full Qualified Domain Name (FQDN) using
       the domain suffix for hostname.  dns_ip_qualify returns out as IP[4|6]
       and FQDN.  If the domain does not exist in DNS, or has no IP addresses,
       out will be empty and the return code is 0.

       In case dns_ip[4|6]_qualify is fed with an IP[4|6] addresses instead of
       domain names, it recognizes those not to be subject of qualification.
       The particular names localhost, ip4-loopback and ip6-loopback are
       treated locally and mapped to the respective IP[4|6] addresses (and
       vice versa) without facilitating a DNS lookup.


INPUT

       For the high-level routines dns_ip[4|6], dns_ip_qualify[4|6],
       dns_name[4|6], dns_mx, dns_name, dns_txt and dns_cname the provided
       input variable stralloc fqdn needs to be un-terminated, thus the given
       string length is identitical to the number of fqdn characters.


OUTPUT

       The returned IP addresses are given as character (byte) strings with 4
       or 16 bytes: dns_ip4 and dns_ip4_qualifiy return 4 byte IPv4 addresses,
       where as dns_ip6 and dns_ip as well as dns_ip6_qualify and
       dns_ip_qualify return sets of 16 byte IPv6 addresses, where the
       potential IPv4 addresses are given in their IPv6-mapped-IPv4
       representation.


                                                             qlibs:(dnsresolv)

Man(1) output converted with man2html