1 .\" Copyright (c) 1985, 1995 The Regents of the University of California.
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms are permitted provided
5 .\" that: (1) source distributions retain this entire copyright notice and
6 .\" comment, and (2) distributions including binaries display the following
7 .\" acknowledgement: ``This product includes software developed by the
8 .\" University of California, Berkeley and its contributors'' in the
9 .\" documentation or other materials provided with the distribution and in
10 .\" all advertising materials mentioning features or use of this software.
11 .\" Neither the name of the University nor the names of its contributors may
12 .\" be used to endorse or promote products derived from this software without
13 .\" specific prior written permission.
14 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
15 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
16 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18 .\" @(#)resolver.3 6.5 (Berkeley) 6/23/90
19 .\" $Id: resolver.3,v 8.4 1996/05/09 05:59:10 vixie Exp $
21 .TH RESOLVER @LIB_NETWORK_EXT_U@ "December 11, 1995
24 res_query, res_search, res_mkquery, res_send, res_init, dn_comp, dn_expand \- resolver routines
26 .B #include <sys/types.h>
28 .B #include <netinet/in.h>
30 .B #include <arpa/nameser.h>
32 .B #include <resolv.h>
34 .B "res_query(dname, class, type, answer, anslen)"
44 .B "res_search(dname, class, type, answer, anslen)"
54 .B "res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen)"
66 .B struct rrec *newrr;
72 .B res_send(msg, msglen, answer, anslen)
84 .B dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr)
86 .B const char *exp_dn;
92 .B u_char **dnptrs, **lastdnptr;
94 .B dn_expand(msg, eomorig, comp_dn, exp_dn, length)
96 .B const u_char *msg, *eomorig, *comp_dn;
102 .B herror(const char *s)
104 .B hstrerror(int err)
106 These routines are used for making, sending and interpreting
107 query and reply messages with Internet domain name servers.
109 Global configuration and state information that is used by the
110 resolver routines is kept in the structure
112 Most of the values have reasonable defaults and can be ignored.
119 Options are stored as a simple bit mask containing the bitwise ``or''
120 of the options enabled.
122 True if the initial name server address and default domain name are
127 Print debugging messages.
129 Accept authoritative answers only.
132 should continue until it finds an authoritative answer or finds an error.
133 Currently this is not implemented.
135 Use TCP connections for queries instead of UDP datagrams.
137 Used with RES_USEVC to keep the TCP connection open between
139 This is useful only in programs that regularly do many queries.
140 UDP should be the normal mode used.
142 Unused currently (ignore truncation errors, i.e., don't retry with TCP).
144 Set the recursion-desired bit in queries.
148 does not do iterative queries and expects the name server
149 to handle recursion.)
153 will append the default domain name to single-component names
154 (those that do not contain a dot).
155 This option is enabled by default.
157 If this option is set,
159 will search for host names in the current domain and in parent domains; see
160 .IR hostname (@DESC_EXT@).
161 This is used by the standard host lookup routine
162 .IR gethostbyname (@LIB_NETWORK_EXT@).
163 This option is enabled by default.
165 This option turns off the user level aliasing feature controlled by
166 the HOSTALIASES environment variable. Network daemons should set this option.
171 reads the configuration file (if any; see
172 .IR resolver (@FORMAT_EXT@))
173 to get the default domain name,
175 the Internet address of the local name server(s).
176 If no server is configured, the host running
177 the resolver is tried.
178 The current domain name is defined by the hostname
179 if not specified in the configuration file;
180 it can be overridden by the environment variable LOCALDOMAIN.
181 This environment variable may contain several blank-separated
182 tokens if you wish to override the
184 on a per-process basis. This is similar to the
186 command in the configuration file.
187 Another environment variable (``RES_OPTIONS'') can be set to
188 override certain internal resolver options which are otherwise
189 set by changing fields in the
191 structure or are inherited from the configuration file's
193 command. The syntax of the ``RES_OPTIONS'' environment variable
195 .IR resolver (@FORMAT_EXT@).
196 Initialization normally occurs on the first call
197 to one of the other resolver routines.
201 function provides an interface to the server query mechanism.
202 It constructs a query, sends it to the local server,
203 awaits a response, and makes preliminary checks on the reply.
204 The query requests information of the specified
208 for the specified fully-qualified domain name
210 The reply message is left in the
214 supplied by the caller.
218 routine makes a query and awaits a response like
220 but in addition, it implements the default and search rules
221 controlled by the RES_DEFNAMES and RES_DNSRCH options.
222 It returns the first successful reply.
224 The remaining routines are lower-level routines used by
229 constructs a standard query message and places it in
231 It returns the size of the query, or \-1 if the query is
236 is usually QUERY, but can be any of the query types defined in
237 .IR <arpa/nameser.h> .
238 The domain name for the query is given by
241 is currently unused but is intended for making update messages.
246 sends a pre-formatted query and returns an answer.
249 if RES_INIT is not set, send the query to the local name server, and
250 handle timeouts and retries.
251 The length of the reply message is returned, or
252 \-1 if there were errors.
257 compresses the domain name
261 The size of the compressed name is returned or \-1 if there were errors.
262 The size of the array pointed to by
269 to previously-compressed names in the current message.
270 The first pointer points to
271 to the beginning of the message and the list ends with NULL.
272 The limit to the array is specified by
276 is to update the list of pointers for
277 labels inserted into the message
278 as the name is compressed.
281 is NULL, names are not compressed.
284 is NULL, the list of labels is not updated.
289 expands the compressed domain name
291 to a full domain name
292 The compressed name is contained in a query or reply message;
294 is a pointer to the beginning of the message.
295 The uncompressed name is placed in the buffer indicated by
299 The size of compressed name is returned or \-1 if there was an error.
301 The external variable
303 is set whenever an error occurs during resolver operation. The following
304 definitions are given in
308 #define NETDB_INTERNAL -1 /* see errno */
309 #define NETDB_SUCCESS 0 /* no problem */
310 #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
311 #define TRY_AGAIN 2 /* Non-Authoritive not found, or SERVFAIL */
312 #define NO_RECOVERY 3 /* Nonrecoverable: FORMERR, REFUSED, NOTIMP */
313 #define NO_DATA 4 /* Valid name, no data for requested type */
320 function writes a message to the diagnostic output consisting of the string
323 the constant string ": ", and a message corresponding to the value of
328 function returns a string which is the message text corresponding to the
333 /etc/resolv.conf see resolver(@FORMAT_EXT@)
335 gethostbyname(@LIB_NETWORK_EXT@), @INDOT@named(@SYS_OPS_EXT@), resolver(@FORMAT_EXT@), hostname(@DESC_EXT@),
337 RFC1032, RFC1033, RFC1034, RFC1035, RFC974,
339 SMM:11 Name Server Operations Guide for BIND