resolver(3N) resolver(3N)
NAME
resolver: dn_comp(), dn_expand(), get_resfield(), herror(), res_init(), res_mkquery(), res_query(), res_search(), res_send(), set_res-
field() - resolver routines
SYNOPSIS
OBSOLESCENT INTERFACE
DESCRIPTION
These routines are used for making, sending, and interpreting query and reply messages with Internet domain name servers.
Global configuration and state information used by the resolver routines are kept in the structure and are defined in Most of the fields
have reasonable defaults and can be ignored. The resolver options are stored in the field and are listed below. The options are stored as
a simple bit mask containing the bitwise OR of the options enabled.
In a multithreaded environment, a thread specific structure is allocated for each thread.
True if the initial name server address and default domain name are
initialized (i.e., has been called).
Print debugging messages.
Accept authoritative answers only.
With this option, should continue until it finds an authoritative answer or finds an error. Currently this is
not implemented.
Query the primary server only.
Currently this is not implemented.
Use TCP connections for queries instead of UDP datagrams.
Used with to keep the TCP connection open between queries. This is useful only in programs that regularly do many
queries. UDP should be the normal mode used.
The name server will set the truncation bit
if all of the data does not fit into the response datagram packet. If is set, will not retry the query with TCP
(i.e., ignore truncation errors).
Set the recursion-desired bit in queries.
This is the default. (does not do iterative queries and expects the name server to handle recursion.)
If set, appends the default domain name to single-component names (those that do not contain a dot). This option is
enabled by default.
If this option is set,
searches for host names in the current domain and in parent domains; see hostname(5). This is used by the stan-
dard host lookup routine (see gethostent(3N)). This option is enabled by default.
Initialization of the resolver structure normally occurs on the first call to one of the resolver routines below. If there are errors in
the configuration file, they are silently ignored.
The values for retransmission timeout and number of retries to be attempted can be configured. These correspond to the retrans and retry
fields in the structure. The following three options, listed in the order of precedence, have been provided for configuring the retrans-
mission timeout and retry values.
1. Environment Variables,
2. Configuration file
3. Through calls to API
retrans and retry can be configured through the Environmental Variables and as follows:
Alternatively in the following name-value pairs can be added :
While the Environmental Variables and entries in the file are interpreted when the API is called, the API has to be explicitly called from
within the code. Setting the retrans and retry values through a lower precedence option will be ignored if these values have been config-
ured through higher precedence option. A message is flagged in when an invalid value is specified in either or Environmental variables.
The retrans is to be specified in milliseconds, and its default value is 5000 milliseconds. The default value for retry is 4.
Primary Routines
Reads the configuration file,
to get the default domain name, search list, the Internet address of the local name server(s), the values for retrans
and retry. If no server is configured, the host running the resolver is tried. The current domain name is defined by
the hostname if not specified in the configuration file; it can be overridden by the environment variable This environ-
ment variable may contain several blank separated tokens and overrides the search list on a per process basis. This is
similar to the command in the configuration file. Another environment variable such as, can be set to override certain
internal resolver options which are set by calling some of the configuration routines above, or by using the configura-
tion file's command. The syntax of the environment variable is explained in resolver(4). The entries for retrans and
retry can be overridden by and Environmental Variables respectively.
Provides an interface to the server query mechanism.
It constructs a query, sends it to the local server, awaits a response, and makes preliminary checks on the reply. The
query requests information of the specified type and class for the specified fully-qualified domain name dname. The
reply message is left in the answer buffer with length anslen supplied by the caller.
Makes a query and awaits a response much like
but in addition, it implements the default and search rules controlled by the and options. It returns the first suc-
cessful reply.
Sets the value for the
retry and retrans fields in the structure. The value for the retrans option must be specified in milliseconds. This
routine also validates the values which the user tries to set for the retry and retrans options. returns on success,
and on failure. Calls to fails when values for the field passed as argument is already set by any higher precedence
option like entering name-value pairs in the file or setting the Environmental Variables and
Get the value for the
retry and retrans fields in the structure. returns the value of the field requested on success and if on failure. It
fails when the arguments do not refer to retrans or retry.
Other Routines
Routines described here are lower-level routines used by
Constructs a standard query message and places it in
buf. It returns the size of the query, or -1 if the query is larger than buflen. The query type op is usually but can
be any of the query types defined in The domain name for the query is given by dname. class can be any of the query
classes defined in type can be any of the query types defined in data is the data for an inverse query newrr is cur-
rently unused but is intended for making update messages.
Sends a pre-formatted query and returns an answer.
It calls if is not set, sends the query to the local name server, and handles timeouts and retries. returns the length
of the reply message, or -1 if there were errors.
Compresses the domain name
exp_dn and stores it in comp_dn. The size of the compressed name is returned or -1 if there were errors. length is
the size of the array pointed to by comp_dn. The compression uses an array of pointers dnptrs to previously compressed
names in the current message. The first pointer points to to the beginning of the message and the list ends with NULL.
The limit to the array is specified by lastdnptr. A side effect of is to update the list of pointers for labels
inserted into the message as the name is compressed. If dnptr is NULL, names are not compressed. If lastdnptr is
NULL, the list of labels is not updated.
Expands the compressed domain name
comp_dn to a full domain name. The compressed name is contained in a query or reply message; msg is a pointer to the
beginning of the message. The uncompressed name is placed in the buffer indicated by exp_dn which is of size length.
The size of compressed name is returned or -1 if there was an error.
Obsolescent Routine
supports existing applications to print an error message describing
a failure. ANSI applications must specify the following definition for
The argument string s is printed first, followed by a colon, a blank, the message, and a new-line. may be
removed in future releases.
RETURN VALUE
Error return status from is indicated by a return value of -1. The external integer can then be checked to see whether this is a temporary
failure or an invalid or unknown host.
In a multithreaded application using kernel thread, a thread specific is allocated for each thread.
ERRORS
can have the following values:
No such host is known.
This is usually a temporary error and means that the local server
did not receive a response from an authoritative server. A retry at some later time may succeed.
Some unexpected server failure was encountered.
This is a non-recoverable error.
The name is known to the name server,
but there is no data of the requested type associated with this name; this is not a temporary error. Another
type of request to the name server using this domain name will result in an answer.
WARNINGS
The field should be modified only by using call, and should not be manipulated directly. is referenced as an for non-threaded applications
and is defined as function call macro for multithreaded applications in file Applications which reference should include
is referenced as an for non-threaded applications and is defined as function call macro for multithreaded application in file Applications
which reference should include
AUTHOR
These resolver routines were developed by the University of California, Berkeley.
FILES
Resolver configuration file.
SEE ALSO
named(1M), gethostent(3N), resolver(4), hostname(5), thread_safety(5), RFC1034, RFC1035, RFC1535.
resolver(3N)