DNS Support Calls
5-7
Network Tools Library Support Functions
5.2
DNS Support Calls
5.2.1
Synopsis
The concepts and code behind the Unix gethostbyname() and gethostby-
addr() functions is extensive. And there are public domain versions available,
can be easily run on the IP stack library.
Although the code to support the whole name, address and server database
is quite large, the basic name resolution functions are quite useful. For this rea-
son, the stack provides a basic form of these function calls, without incurring
the overhead associated with a full implementation. The DNS ”resolver” used
by these client functions is the same as accessed by the DNS server. When
the configuration contains ”client” machine records (i.e.: controls local domain
names), these entries are checked when the matching domain is encountered.
Otherwise (and for all other queries); the query is resolved via external DNS
servers.
In addition to providing a more compact implementation, the calls provided
here are reentrant, which is not true of the standard Unix counterparts.
5.2.2
Function Overview
The following is a summary of the support functions described in this section:
DNSGetHostname()
Return the hostname of the current host
DNSGetHostByAddr()
Resolve a hostname from an IP address
DNSGetHostByName()
Resolve a hostname and IP address from
a hostname
5.2.3
Standard Types and Definitions
5.2.3.1
Host Entry Structure
The DNS client functions all take a pointer to a buffer. They treat this buffer as
a pointer to a host entry structure. In the case where the function takes a point-
er to a “scrap” buffer, a host entry structure is allocated from the start of this
scrap buffer. Thus on successful return from one of these calls, the pointer to
the scrap buffer may be treated as a pointer to a host entry structure.