1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" References consulted:
26 .\" Linux libc source code
27 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
29 .\" Modified 1993-07-25 by Rik Faith (faith@cs.unc.edu)
30 .\" Modified 2004-10-31 by aeb
32 .TH RESOLVER 3 2014-05-28 "GNU" "Linux Programmer's Manual"
34 res_init, res_query, res_search, res_querydomain, res_mkquery, res_send,
35 dn_comp, dn_expand \- resolver routines
38 .B #include <netinet/in.h>
39 .B #include <arpa/nameser.h>
40 .B #include <resolv.h>
41 .B extern struct __res_state _res;
43 .B int res_init(void);
45 .BI "int res_query(const char *" dname ", int " class ", int " type ,
47 .BI "unsigned char *" answer ", int " anslen );
50 .BI "int res_search(const char *" dname ", int " class ", int " type ,
52 .BI "unsigned char *" answer ", int " anslen );
55 .BI "int res_querydomain(const char *" name ", const char *" domain ,
57 .BI "int " class ", int " type ", unsigned char *" answer ,
61 .BI "int res_mkquery(int " op ", const char *" dname ", int " class ,
63 .BI "int " type ", const unsigned char *" data ", int " datalen ,
64 .BI "const unsigned char *" newrr ", unsigned char *" buf ", int " buflen );
67 .BI "int res_send(const unsigned char *" msg ", int " msglen ,
69 .BI "unsigned char *" answer ", int " anslen );
72 .BI "int dn_comp(const char *" exp_dn ", unsigned char *" comp_dn ,
74 .BI "int " length ", unsigned char **" dnptrs ", unsigned char **" lastdnptr );
77 .BI "int dn_expand(const unsigned char *" msg ", const unsigned char *" eomorig ,
79 .BI "const unsigned char *" comp_dn ", char *" exp_dn ,
84 Link with \fI\-lresolv\fP.
86 These functions make queries to and interpret the responses from Internet
91 function reads the configuration files (see
93 to get the default domain name, search order and name
95 If no server is given, the local host is tried.
96 If no domain is given, that associated with the local host is used.
97 It can be overridden with the environment variable
100 is normally executed by the first call to one of the
105 function queries the name server for the
106 fully qualified domain name \fIname\fP of specified \fItype\fP and
108 The reply is left in the buffer \fIanswer\fP of length
109 \fIanslen\fP supplied by the caller.
113 function makes a query and waits for the response
116 but in addition implements the default and search
122 \fI_res\fP options below).
125 .BR res_querydomain ()
126 function makes a query using
128 on the concatenation of \fIname\fP and \fIdomain\fP.
130 The following functions are lower-level routines used by
135 function constructs a query message in \fIbuf\fP
136 of length \fIbuflen\fP for the domain name \fIdname\fP.
140 but can be any of the types defined in
141 \fI<arpa/nameser.h>\fP.
142 \fInewrr\fP is currently unused.
146 function sends a preformatted query given in
147 \fImsg\fP of length \fImsglen\fP and returns the answer in \fIanswer\fP
148 which is of length \fIanslen\fP.
152 has not already been called.
156 function compresses the domain name \fIexp_dn\fP
157 and stores it in the buffer \fIcomp_dn\fP of length \fIlength\fP.
158 The compression uses an array of pointers \fIdnptrs\fP to previously
159 compressed names in the current message.
160 The first pointer points
161 to the beginning of the message and the list ends with NULL.
162 The limit of the array is specified by \fIlastdnptr\fP.
163 If \fIdnptr\fP is NULL, domain names are not compressed.
164 If \fIlastdnptr\fP is NULL, the list
165 of labels is not updated.
169 function expands the compressed domain name
170 \fIcomp_dn\fP to a full domain name, which is placed in the buffer
171 \fIexp_dn\fP of size \fIlength\fP.
172 The compressed name is contained
173 in a query or reply message, and \fImsg\fP points to the beginning of
176 The resolver routines use global configuration and state information
177 contained in the structure \fI_res\fP, which is defined in
179 The only field that is normally manipulated by the
180 user is \fI_res.options\fP.
181 This field can contain the bitwise "OR"
182 of the following options:
190 Print debugging messages.
191 This option is available only if glibc was built with debugging enabled,
192 .\" See resolv/README.
193 .\" Support for RES_DEBUG was made conditional in glibc 2.2.
194 which is not the default.
197 Accept authoritative answers only.
200 it finds an authoritative answer or returns an error. [Not currently
204 Use TCP connections for queries rather than UDP datagrams.
207 Query primary domain name server only.
210 Ignore truncation errors.
211 Don't retry with TCP. [Not currently
215 Set the recursion desired bit in queries.
216 Recursion is carried out
217 by the domain name server, not by
219 [Enabled by default].
224 will append the default domain name to
225 single component names\(emthat is, those that do not contain a dot.
226 [Enabled by default].
231 to keep the TCP connection open between queries.
236 will search for hostnames in the current
237 domain and in parent domains.
238 This option is used by
239 .BR gethostbyname (3).
240 [Enabled by default].
242 This list is not complete.
243 You can find some other flags described in
248 function returns 0 on success, or \-1 if an error
254 .BR res_querydomain (),
258 functions return the length
259 of the response, or \-1 if an error occurs.
265 functions return the length
266 of the compressed name, or \-1 if an error occurs.
269 /etc/resolv.conf resolver configuration file
270 /etc/host.conf resolver configuration file
275 .BR gethostbyname (3),