222 lines
9.5 KiB
HTML
222 lines
9.5 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>resolver(3)</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<H1>resolver(3)</H1>
|
|
<HR>
|
|
<PRE>
|
|
|
|
</PRE>
|
|
<H2>NAME</H2><PRE>
|
|
resolver, res_query, res_search, res_mkquery, res_send, res_init,
|
|
dn_comp, dn_expand - resolver routines
|
|
|
|
|
|
</PRE>
|
|
<H2>SYNOPSIS</H2><PRE>
|
|
<STRONG>#include</STRONG> <STRONG><sys/types.h></STRONG>
|
|
<STRONG>#include</STRONG> <STRONG><net/gen/in.h></STRONG>
|
|
<STRONG>#include</STRONG> <STRONG><net/gen/nameser.h></STRONG>
|
|
<STRONG>#include</STRONG> <STRONG><net/gen/resolv.h></STRONG>
|
|
|
|
<STRONG>res_query(dname,</STRONG> <STRONG>class,</STRONG> <STRONG>type,</STRONG> <STRONG>answer,</STRONG> <STRONG>anslen)</STRONG>
|
|
<STRONG>char</STRONG> <STRONG>*dname;</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>class,</STRONG> <STRONG>type;</STRONG>
|
|
<STRONG>u_char</STRONG> <STRONG>*answer;</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>anslen;</STRONG>
|
|
|
|
<STRONG>res_search(dname,</STRONG> <STRONG>class,</STRONG> <STRONG>type,</STRONG> <STRONG>answer,</STRONG> <STRONG>anslen)</STRONG>
|
|
<STRONG>char</STRONG> <STRONG>*dname;</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>class,</STRONG> <STRONG>type;</STRONG>
|
|
<STRONG>u_char</STRONG> <STRONG>*answer;</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>anslen;</STRONG>
|
|
|
|
<STRONG>res_mkquery(op,</STRONG> <STRONG>dname,</STRONG> <STRONG>class,</STRONG> <STRONG>type,</STRONG> <STRONG>data,</STRONG> <STRONG>datalen,</STRONG> <STRONG>newrr,</STRONG> <STRONG>buf,</STRONG> <STRONG>buflen)</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>op;</STRONG>
|
|
<STRONG>char</STRONG> <STRONG>*dname;</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>class,</STRONG> <STRONG>type;</STRONG>
|
|
<STRONG>char</STRONG> <STRONG>*data;</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>datalen;</STRONG>
|
|
<STRONG>struct</STRONG> <STRONG>rrec</STRONG> <STRONG>*newrr;</STRONG>
|
|
<STRONG>char</STRONG> <STRONG>*buf;</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>buflen;</STRONG>
|
|
|
|
<STRONG>res_send(msg,</STRONG> <STRONG>msglen,</STRONG> <STRONG>answer,</STRONG> <STRONG>anslen)</STRONG>
|
|
<STRONG>char</STRONG> <STRONG>*msg;</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>msglen;</STRONG>
|
|
<STRONG>char</STRONG> <STRONG>*answer;</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>anslen;</STRONG>
|
|
|
|
<STRONG>res_init()</STRONG>
|
|
|
|
<STRONG>dn_comp(exp_dn,</STRONG> <STRONG>comp_dn,</STRONG> <STRONG>length,</STRONG> <STRONG>dnptrs,</STRONG> <STRONG>lastdnptr)</STRONG>
|
|
<STRONG>char</STRONG> <STRONG>*exp_dn,</STRONG> <STRONG>*comp_dn;</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>length;</STRONG>
|
|
<STRONG>char</STRONG> <STRONG>**dnptrs,</STRONG> <STRONG>**lastdnptr;</STRONG>
|
|
|
|
<STRONG>dn_expand(msg,</STRONG> <STRONG>eomorig,</STRONG> <STRONG>comp_dn,</STRONG> <STRONG>exp_dn,</STRONG> <STRONG>length)</STRONG>
|
|
<STRONG>char</STRONG> <STRONG>*msg,</STRONG> <STRONG>*eomorig,</STRONG> <STRONG>*comp_dn,</STRONG> <STRONG>exp_dn;</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>length;</STRONG>
|
|
|
|
|
|
|
|
</PRE>
|
|
<H2>DESCRIPTION</H2><PRE>
|
|
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 _<EM>res</EM>. Most of the values have
|
|
reasonable defaults and can be ignored. Options stored in _<EM>res</EM>.<EM>options</EM>
|
|
are defined in <EM>resolv</EM>.<EM>h</EM> and are as follows. Options are stored as a
|
|
simple bit mask containing the bitwise ``or'' of the options enabled.
|
|
|
|
RES_INIT
|
|
True if the initial name server address and default domain name are
|
|
initialized (i.e., <EM>res</EM>_<EM>init</EM> has been called).
|
|
|
|
RES_DEBUG
|
|
Print debugging messages.
|
|
|
|
RES_AAONLY
|
|
Accept authoritative answers only. With this option, <EM>res</EM>_<EM>send</EM>
|
|
should continue until it finds an authoritative answer or finds an
|
|
error. Currently this is not implemented.
|
|
|
|
RES_USEVC
|
|
Use TCP connections for queries instead of UDP datagrams.
|
|
|
|
RES_STAYOPEN
|
|
Used with RES_USEVC 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.
|
|
|
|
RES_IGNTC
|
|
Unused currently (ignore truncation errors, i.e., don't retry with
|
|
TCP).
|
|
|
|
RES_RECURSE
|
|
Set the recursion-desired bit in queries. This is the default.
|
|
(<EM>res</EM>_<EM>send</EM> does not do iterative queries and expects the name server
|
|
to handle recursion.)
|
|
|
|
RES_DEFNAMES
|
|
If set, <EM>res</EM>_<EM>search</EM> will append the default domain name to single-
|
|
component names (those that do not contain a dot). This option is
|
|
enabled by default.
|
|
|
|
RES_DNSRCH
|
|
If this option is set, <EM>res</EM>_<EM>search</EM> will search for host names in the
|
|
current domain and in parent domains; see <STRONG><A HREF="../man7/hostname.7.html">hostname(7)</A></STRONG>. This is used
|
|
by the standard host lookup routine <STRONG><A HREF="../man3/gethostbyname.3.html">gethostbyname(3)</A></STRONG>. This option
|
|
is enabled by default.
|
|
|
|
The <EM>res</EM>_<EM>init</EM> routine reads the configuration file (if any; see
|
|
<STRONG><A HREF="../man5/resolver.5.html">resolver(5)</A></STRONG>) to get the default domain name, search list and the Internet
|
|
address of the local name server(s). 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 LOCALDOMAIN. Initialization
|
|
normally occurs on the first call to one of the following routines.
|
|
|
|
The <EM>res</EM>_<EM>query</EM> 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 <EM>type</EM> and <EM>class</EM> for the specified fully-
|
|
qualified domain name <EM>dname</EM> . The reply message is left in the <EM>answer</EM>
|
|
buffer with length <EM>anslen</EM> supplied by the caller.
|
|
|
|
The <EM>res</EM>_<EM>search</EM> routine makes a query and awaits a response like
|
|
<EM>res</EM>_<EM>query</EM>, 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 <EM>res</EM>_<EM>query</EM>. The
|
|
<EM>res</EM>_<EM>mkquery</EM> function constructs a standard query message and places it in
|
|
<EM>buf</EM>. It returns the size of the query, or -1 if the query is larger than
|
|
<EM>buflen</EM>. The query type <EM>op</EM> is usually QUERY, but can be any of the query
|
|
types defined in <<EM>arpa</EM>/<EM>nameser</EM>.<EM>h</EM>>. The domain name for the query is
|
|
given by <EM>dname</EM>. <EM>Newrr</EM> is currently unused but is intended for making
|
|
update messages.
|
|
|
|
The <EM>res</EM>_<EM>send</EM> routine sends a pre-formatted query and returns an answer.
|
|
It will call <EM>res</EM>_<EM>init</EM> 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.
|
|
|
|
The <EM>dn</EM>_<EM>comp</EM> function compresses the domain name <EM>exp</EM>_<EM>dn</EM> and stores it in
|
|
<EM>comp</EM>_<EM>dn</EM>. The size of the compressed name is returned or -1 if there were
|
|
errors. The size of the array pointed to by <EM>comp</EM>_<EM>dn</EM> is given by <EM>length</EM>.
|
|
The compression uses an array of pointers <EM>dnptrs</EM> 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 <EM>lastdnptr</EM>. A side effect of <EM>dn</EM>_<EM>comp</EM> is to update
|
|
the list of pointers for labels inserted into the message as the name is
|
|
compressed. If <EM>dnptr</EM> is NULL, names are not compressed. If <EM>lastdnptr</EM> is
|
|
NULL, the list of labels is not updated.
|
|
|
|
The <EM>dn</EM>_<EM>expand</EM> entry expands the compressed domain name <EM>comp</EM>_<EM>dn</EM> to a full
|
|
domain name The compressed name is contained in a query or reply message;
|
|
<EM>msg</EM> is a pointer to the beginning of the message. The uncompressed name
|
|
is placed in the buffer indicated by <EM>exp</EM>_<EM>dn</EM> which is of size <EM>length</EM>. The
|
|
size of compressed name is returned or -1 if there was an error.
|
|
|
|
|
|
</PRE>
|
|
<H2>FILES</H2><PRE>
|
|
/etc/resolv.conf see <STRONG><A HREF="../man5/resolver.5.html">resolver(5)</A></STRONG>
|
|
|
|
|
|
</PRE>
|
|
<H2>SEE ALSO</H2><PRE>
|
|
<STRONG><A HREF="../man3/gethostbyname.3.html">gethostbyname(3)</A></STRONG>, <STRONG><A HREF="../man8/named.8.html">named(8)</A></STRONG>, <STRONG><A HREF="../man5/resolver.5.html">resolver(5)</A></STRONG>, <STRONG><A HREF="../man7/hostname.7.html">hostname(7)</A></STRONG>,
|
|
RFC1032, RFC1033, RFC1034, RFC1035, RFC974,
|
|
SMM:11 Name Server Operations Guide for BIND
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</PRE>
|
|
</BODY>
|
|
</HTML>
|