1 .\" $NetBSD: resolver.3,v 1.22 2009/06/08 16:55:30 christos Exp $
2 .\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
4 .\" Permission to use, copy, modify, and distribute this software for any
5 .\" purpose with or without fee is hereby granted, provided that the above
6 .\" copyright notice and this permission notice appear in all copies.
8 .\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
9 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
11 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 .\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 .\" Copyright (c) 1985, 1995 The Regents of the University of California.
17 .\" All rights reserved.
19 .\" Redistribution and use in source and binary forms are permitted provided
20 .\" that: (1) source distributions retain this entire copyright notice and
21 .\" comment, and (2) distributions including binaries display the following
22 .\" acknowledgement: ``This product includes software developed by the
23 .\" University of California, Berkeley and its contributors'' in the
24 .\" documentation or other materials provided with the distribution and in
25 .\" all advertising materials mentioning features or use of this software.
26 .\" Neither the name of the University nor the names of its contributors may
27 .\" be used to endorse or promote products derived from this software without
28 .\" specific prior written permission.
29 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
30 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
31 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
33 .\" @(#)resolver.3 6.5 (Berkeley) 6/23/90
34 .\" Id: resolver.man3,v 1.2 2009/01/21 00:12:34 each Exp
47 .Nm res_nquerydomain ,
83 .Vt typedef struct __res_state *res_state ;
86 .Fn res_ninit "res_state statp"
88 .Fn res_ourserver_p "const res_state statp" "const struct sockaddr_in *addr"
90 .Fn fp_resstat "const res_state statp" "FILE *fp"
92 .Fn res_hostalias "const res_state statp" "const char *name" "char *buf" "size_t buflen"
94 .Fn res_pquery "const res_state statp" "const u_char *msg" "int msglen" "FILE *fp"
96 .Fn res_nquery "res_state statp" "const char *dname" "int class" "int type" "u_char *answer" "int anslen"
98 .Fn res_nsearch "res_state statp" "const char *dname" "int class" "int type" "u_char * answer" "int anslen"
100 .Fn res_nquerydomain "res_state statp" "const char *name" "const char *domain" "int class" "int type" "u_char *answer" "int anslen"
103 .Fa "res_state statp"
105 .Fa "const char *dname"
108 .Fa "const u_char *data"
110 .Fa "const u_char *newrr"
115 .Fn res_nsend "res_state statp" "const u_char *msg" "int msglen" "u_char *answer" "int anslen"
117 .Fn res_nupdate "res_state statp" "ns_updrec *rrecp_in"
119 .Fn res_nmkupdate "res_state statp" "ns_updrec *rrecp_in" "u_char *buf" "int buflen"
121 .Fn res_nclose "res_state statp"
123 .Fn res_nsendsigned "res_state statp" "const u_char *msg" "int msglen" "ns_tsig_key *key" "u_char *answer" "int anslen"
125 .Fn res_findzonecut "res_state statp" "const char *dname" "ns_class class" "int options" "char *zname" "size_t zsize" "struct in_addr *addrs" "int naddrs"
127 .Fn res_getservers "res_state statp" "union res_sockaddr_union *set" "int cnt"
129 .Fn res_setservers "res_state statp" "const union res_sockaddr_union *set" "int cnt"
131 .Fn res_ndestroy "res_state statp"
133 .Fn dn_comp "const char *exp_dn" "u_char *comp_dn" "int length" "u_char **dnptrs" "u_char **lastdnptr"
135 .Fn dn_expand "const u_char *msg" "const u_char *eomorig" "const u_char *comp_dn" "char *exp_dn" "int length"
136 .\" .Ft "const char *"
137 .\" .Fn hstrerror "int err"
147 .Fn res_isourserver "const struct sockaddr_in *addr"
149 .Fn fp_nquery "const u_char *msg" "int msglen" "FILE *fp"
151 .Fn p_query "const u_char *msg" "FILE *fp"
153 .Fn hostalias "const char *name"
155 .Fn res_query "const char *dname" "int class" "int type" "u_char *answer" "int anslen"
157 .Fn res_search "const char *dname" "int class" "int type" "u_char *answer" "int anslen"
159 .Fn res_querydomain "const char *name" "const char *domain" "int class" "int type" "u_char *answer" "int anslen"
163 .Fa "const char *dname"
166 .Fa "const char *data"
168 .Fa "struct rrec *newrr"
173 .Fn res_send "const u_char *msg" "int msglen" "u_char *answer" "int anslen"
175 .Fn res_update "ns_updrec *rrecp_in"
179 .\" .Fn herror "const char *s"
181 These routines are used for making, sending and interpreting
182 query and reply messages with Internet domain name servers.
184 State information is kept in
186 and is used to control the behavior of these functions.
188 should be set to all zeros prior to the first call to any of these functions.
192 .Fn res_isourserver ,
198 .Fn res_querydomain ,
205 are deprecated and are supplied for compatability with old source
207 They use global configuration and state information that is
208 kept in the structure
210 rather than that referenced through
213 Most of the values in
217 are initialized on the first call to
221 to reasonable defaults and can be ignored.
230 Options are stored as a simple bit mask containing the bitwise
232 of the options enabled.
233 .Bl -tag -width "RES_USE_INET6"
235 True if the initial name server address and default domain name are
242 Print debugging messages.
244 Accept authoritative answers only.
245 Should continue until it finds an authoritative answer or finds an error.
246 Currently this is not implemented.
248 Use TCP connections for queries instead of UDP datagrams.
252 to keep the TCP connection open between queries.
253 This is useful only in programs that regularly do many queries.
254 UDP should be the normal mode used.
256 Ignore truncation errors, i.e., don't retry with TCP.
258 Set the recursion-desired bit in queries.
264 does not do iterative queries and expects the name server
265 to handle recursion.)
271 will append the default domain name to single-component names
272 (those that do not contain a dot).
273 This option is enabled by default.
275 If this option is set,
279 will search for host names in the current domain and in parent domains; see
281 This is used by the standard host lookup routine
282 .Xr gethostbyname 3 .
283 This option is enabled by default.
285 Enables support for IPv6-only applications.
286 This causes IPv4 addresses to be returned as an IPv4 mapped address.
287 For example, 10.1.1.1 will be returned as ::ffff:10.1.1.1.
288 The option is meaningful with certain kernel configuration only.
290 Enables support for OPT pseudo-RR for EDNS0 extension.
291 With the option, resolver code will attach OPT pseudo-RR into DNS queries,
292 to inform of our receive buffer size.
293 The option will allow DNS servers to take advantage of non-default receive
294 buffer size, and to send larger replies.
295 DNS query packets with EDNS0 extension is not compatible with
296 non-EDNS0 DNS servers.
298 This option turns off the user level aliasing feature controlled by
301 environment variable.
302 Network daemons should set this option.
304 This options causes the
308 to rotate the list of nameservers in
309 .Fa statp->nsaddr_list
311 .Fa _res.nsaddr_list .
315 to leave the message unchanged after TSIG verification; otherwise the TSIG
316 record would be removed and the header updated.
317 .It Dv RES_NOTLDQUERY
320 to not attempt to resolve an unqualified name as if it were a top level
322 This option can cause problems if the site has "localhost" as a TLD rather
323 than having localhost on one or more elements of the search list.
324 This option has no effect if neither
336 reads the configuration file (if any; see
338 to get the default domain name, search list and
339 the Internet address of the local name server(s).
340 If no server is configured, the host running the resolver is tried.
341 The current domain name is defined by the hostname
342 if not specified in the configuration file;
343 it can be overridden by the environment variable
345 This environment variable may contain several blank-separated
346 tokens if you wish to override the
348 on a per-process basis. This is similar to the
350 command in the configuration file.
351 Another environment variable
353 can be set to override certain internal resolver options which are otherwise
354 set by changing fields in the
358 structure or are inherited from the configuration file's
363 environment variable is explained in
365 Initialization normally occurs on the first call
366 to one of the other resolver routines.
368 The memory referred to by
370 must be set to all zeros prior to the first call to
373 should be call to free memory allocated by
381 functions provides interfaces to the server query mechanism.
382 They constructs a query, sends it to the local server,
383 awaits a response, and makes preliminary checks on the reply.
384 The query requests information of the specified
388 for the specified fully-qualified domain name
390 The reply message is left in the
394 supplied by the caller.
398 return -1 on error or the length of the answer.
404 routines make a query and awaits a response like
408 but in addition, it implements the default and search rules
414 It returns the length of the first successful reply which is stored in
418 The remaining routines are lower-level routines used by
427 constructs a standard query message and places it in
429 It returns the size of the query, or \-1 if the query is
436 but can be any of the query types defined in
437 .Pa <arpa/nameser.h> .
438 The domain name for the query is given by
441 is currently unused but is intended for making update messages.
450 sends a pre-formatted query and returns an answer.
457 is not set, send the query to the local name server, and
458 handle timeouts and retries. Additionally,
460 will use TSIG signatures to add authentication to the query and verify the
461 response. In this case, only one nameserver will be contacted.
462 The length of the reply message is returned, or \-1 if there were errors.
474 return a length that may be bigger than
476 In that case the query should be retried with a bigger buffer.
477 NOTE the answer to the second query may be larger still so supplying
478 a buffer that bigger that the answer returned by the previous
479 query is recommended.
482 MUST be big enough to receive a maximum UDP response from the server or
483 parts of the answer will be silently discarded.
484 The default maximum UDP response size is 512 bytes.
490 is one of the servers in
491 .Fa statp->nsaddr_list
493 .Fa _res.nsaddr_list .
499 print out the query and any answer in
512 prints out the active flag bits in
514 preceeded by the text ";; res options:" on
521 lookup up name in the file referred to by the
523 files return a fully qualified hostname if found or NULL if
524 not found or an error occurred.
528 to store the result in,
530 uses a static buffer.
536 are used to get and set the list of server to be queried.
542 take a list of ns_updrec
544 Identifies the containing zone for each record and groups the records
545 according to containing zone maintaining in zone order then sends and update
546 request to the servers for these zones. The number of zones updated is
547 returned or -1 on error. Note that
549 will perform TSIG authenticated dynamic update operations if the key is not
554 discovers the closest enclosing zone cut for a specified domain name,
555 and finds the IP addresses of the zone's master servers.
561 take a linked list of ns_updrec
563 and construct a UPDATE message in
568 return the length of the constructed message on no error or one of the
569 following error values.
570 .Bl -inset -width "-5"
572 An error occurred parsing
579 The first record was not a zone section or there was a section order problem.
580 The section order is S_ZONE, S_PREREQ and S_UPDATE.
582 A number overflow occurred.
584 Unknown operation or no records.
591 close any open files referenced through
600 then frees any memory allocated by
606 compresses the domain name
610 The size of the compressed name is returned or \-1 if there were errors.
611 The size of the array pointed to by
618 to previously-compressed names in the current message.
619 The first pointer points to
620 the beginning of the message and the list ends with
622 The limit to the array is specified by
626 is to update the list of pointers for labels inserted into the message
627 as the name is compressed. If
631 names are not compressed. If
635 the list of labels is not updated.
639 entry expands the compressed domain name
641 to a full domain name.
642 The compressed name is contained in a query or reply message;
644 is a pointer to the beginning of the message.
646 is a pointer to the first location after the message.
647 The uncompressed name is placed in the buffer indicated by
651 The size of compressed name is returned or \-1 if there was an error.
654 .Ft statp->res_h_errno
657 and external variable
659 is set whenever an error occurs during resolver operation. The following
660 definitions are given in
663 #define NETDB_INTERNAL -1
665 #define NETDB_SUCCESS 0
667 #define HOST_NOT_FOUND 1
668 /* Authoritative Answer Host not found */
670 /* Non-Authoritative not found, or SERVFAIL */
671 #define NO_RECOVERY 3
672 /* Non-Recoverable: FORMERR, REFUSED, NOTIMP */
674 /* Valid name, no data for requested type */
679 .\" function writes a message to the diagnostic output consisting of the string
682 .\" the constant string ": ", and a message corresponding to the value of
687 .\" function returns a string which is the message text corresponding to the
692 .Bl -tag -width "/etc/resolv.conf "
695 The configuration file, see
699 .Xr gethostbyname 3 ,
711 .%T "Name Server Operations Guide for BIND"