.\" Copyright (c) 1985 The Regents of the University of California.
.\" Redistribution and use in source and binary forms are permitted
.\" provided that the above copyright notice and this paragraph are
.\" duplicated in all such forms and that any documentation,
.\" advertising materials, and other materials related to such
.\" distribution and use acknowledge that the software was developed
.\" by the University of California, Berkeley. The name of the
.\" University may not be used to endorse or promote products derived
.\" from this software without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\" @(#)resolver.3 6.4 (Berkeley) %G%
res_query, res_search, res_mkquery, res_send, res_init, dn_comp, dn_expand \- resolver routines
.B #include <sys/types.h>
.B #include <netinet/in.h>
.B #include <arpa/nameser.h>
.B "res_query(dname, class, type, answer, anslen)"
.B "res_search(dname, class, type, answer, anslen)"
.B "res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen)"
.B res_send(msg, msglen, answer, anslen)
.B dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr)
.B char *exp_dn, *comp_dn;
.B char **dnptrs, **lastdnptr;
.B dn_expand(msg, eomorig, comp_dn, exp_dn, length)
.B char *msg, *eomorig, *comp_dn, exp_dn;
These routines are used for making, sending and interpreting
query and reply messages with Internet domain name servers.
Global configuration and state information that is used by the
resolver routines is kept in the structure
Most of the values have reasonable defaults and can be ignored.
Options are stored as a simple bit mask containing the bitwise ``or''
True if the initial name server address and default domain name are
Print debugging messages.
Accept authoritative answers only.
should continue until it finds an authoritative answer or finds an error.
Currently this is not implemented.
Use TCP connections for queries instead of UDP datagrams.
Used with RES_USEVC to keep the TCP connection open between
This is useful only in programs that regularly do many queries.
UDP should be the normal mode used.
Unused currently (ignore truncation errors, i.e., don't retry with TCP).
Set the recursion-desired bit in queries.
does not do iterative queries and expects the name server
will append the default domain name to single-component names
(those that do not contain a dot).
This option is enabled by default.
will search for host names in the current domain and in parent domains; see
This is used by the standard host lookup routine
This option is enabled by default.
reads the configuration file (if any; see
to get the default domain name,
the Internet address of the local name server(s).
If no server is configured, the host running
The current domain name is defined by the hostname
if not specified in the configuration file;
it can be overridden by the environment variable LOCALDOMAIN.
Initialization normally occurs on the first call
to one of the following routines.
function 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
for the specified fully-qualified domain name
The reply message is left in the
routine makes a query and awaits a response like
but in addition, it implements the default and search rules
controlled by the RES_DEFNAMES and RES_DNSRCH options.
It returns the first successful reply.
The remaining routines are lower-level routines used by
constructs a standard query message and places it in
It returns the size of the query, or \-1 if the query is
is usually QUERY, but can be any of the query types defined in
The domain name for the query is given by
is currently unused but is intended for making update messages.
sends a pre-formatted query and returns an answer.
if RES_INIT is not set, send the query to the local name server, and
handle timeouts and retries.
The length of the reply message is returned, or
\-1 if there were errors.
compresses the domain name
The size of the compressed name is returned or \-1 if there were errors.
The size of the array pointed to by
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
is to update the list of pointers for
labels inserted into the message
as the name is compressed.
is NULL, names are not compressed.
is NULL, the list of labels is not updated.
expands the compressed domain name
The compressed name is contained in a query or reply message;
is a pointer to the beginning of the message.
The uncompressed name is placed in the buffer indicated by
The size of compressed name is returned or \-1 if there was an error.
/etc/resolv.conf see resolver(5)
gethostbyname(3), named(8), resolver(5), hostname(7),
RFC1032, RFC1033, RFC1034, RFC1035, RFC974,
SMM:11 Name Server Operations Guide for BIND