1 |
28 |
unneback |
<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
2 |
|
|
<!-- This material may be distributed only subject to the terms -->
|
3 |
|
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
4 |
|
|
<!-- or later (the latest version is presently available at -->
|
5 |
|
|
<!-- http://www.opencontent.org/openpub/). -->
|
6 |
|
|
<!-- Distribution of the work or derivative of the work in any -->
|
7 |
|
|
<!-- standard (paper) book form is prohibited unless prior -->
|
8 |
|
|
<!-- permission is obtained from the copyright holder. -->
|
9 |
|
|
<HTML
|
10 |
|
|
><HEAD
|
11 |
|
|
><TITLE
|
12 |
|
|
>resolver</TITLE
|
13 |
|
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
14 |
|
|
<META
|
15 |
|
|
NAME="GENERATOR"
|
16 |
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
17 |
|
|
"><LINK
|
18 |
|
|
REL="HOME"
|
19 |
|
|
TITLE="eCos Reference Manual"
|
20 |
|
|
HREF="ecos-ref.html"><LINK
|
21 |
|
|
REL="UP"
|
22 |
|
|
TITLE="TCP/IP Library Reference"
|
23 |
|
|
HREF="tcpip-library-reference.html"><LINK
|
24 |
|
|
REL="PREVIOUS"
|
25 |
|
|
TITLE="ns"
|
26 |
|
|
HREF="net-common-tcpip-manpages-ns.html"><LINK
|
27 |
|
|
REL="NEXT"
|
28 |
|
|
TITLE="accept"
|
29 |
|
|
HREF="net-common-tcpip-manpages-accept.html"></HEAD
|
30 |
|
|
><BODY
|
31 |
|
|
CLASS="SECT1"
|
32 |
|
|
BGCOLOR="#FFFFFF"
|
33 |
|
|
TEXT="#000000"
|
34 |
|
|
LINK="#0000FF"
|
35 |
|
|
VLINK="#840084"
|
36 |
|
|
ALINK="#0000FF"
|
37 |
|
|
><DIV
|
38 |
|
|
CLASS="NAVHEADER"
|
39 |
|
|
><TABLE
|
40 |
|
|
SUMMARY="Header navigation table"
|
41 |
|
|
WIDTH="100%"
|
42 |
|
|
BORDER="0"
|
43 |
|
|
CELLPADDING="0"
|
44 |
|
|
CELLSPACING="0"
|
45 |
|
|
><TR
|
46 |
|
|
><TH
|
47 |
|
|
COLSPAN="3"
|
48 |
|
|
ALIGN="center"
|
49 |
|
|
>eCos Reference Manual</TH
|
50 |
|
|
></TR
|
51 |
|
|
><TR
|
52 |
|
|
><TD
|
53 |
|
|
WIDTH="10%"
|
54 |
|
|
ALIGN="left"
|
55 |
|
|
VALIGN="bottom"
|
56 |
|
|
><A
|
57 |
|
|
HREF="net-common-tcpip-manpages-ns.html"
|
58 |
|
|
ACCESSKEY="P"
|
59 |
|
|
>Prev</A
|
60 |
|
|
></TD
|
61 |
|
|
><TD
|
62 |
|
|
WIDTH="80%"
|
63 |
|
|
ALIGN="center"
|
64 |
|
|
VALIGN="bottom"
|
65 |
|
|
>Chapter 38. TCP/IP Library Reference</TD
|
66 |
|
|
><TD
|
67 |
|
|
WIDTH="10%"
|
68 |
|
|
ALIGN="right"
|
69 |
|
|
VALIGN="bottom"
|
70 |
|
|
><A
|
71 |
|
|
HREF="net-common-tcpip-manpages-accept.html"
|
72 |
|
|
ACCESSKEY="N"
|
73 |
|
|
>Next</A
|
74 |
|
|
></TD
|
75 |
|
|
></TR
|
76 |
|
|
></TABLE
|
77 |
|
|
><HR
|
78 |
|
|
ALIGN="LEFT"
|
79 |
|
|
WIDTH="100%"></DIV
|
80 |
|
|
><DIV
|
81 |
|
|
CLASS="SECT1"
|
82 |
|
|
><H1
|
83 |
|
|
CLASS="SECT1"
|
84 |
|
|
><A
|
85 |
|
|
NAME="NET-COMMON-TCPIP-MANPAGES-RESOLVER">resolver</H1
|
86 |
|
|
><TABLE
|
87 |
|
|
BORDER="5"
|
88 |
|
|
BGCOLOR="#E0E0F0"
|
89 |
|
|
WIDTH="70%"
|
90 |
|
|
><TR
|
91 |
|
|
><TD
|
92 |
|
|
><PRE
|
93 |
|
|
CLASS="SCREEN"
|
94 |
|
|
>RESOLVER(3) System Library Functions Manual RESOLVER(3)
|
95 |
|
|
|
96 |
|
|
NAME
|
97 |
|
|
res_query, res_search, res_mkquery, res_send, res_init, dn_comp,
|
98 |
|
|
dn_expand - resolver routines
|
99 |
|
|
|
100 |
|
|
SYNOPSIS
|
101 |
|
|
#include <sys/types.h>
|
102 |
|
|
#include <netinet/in.h>
|
103 |
|
|
#include <arpa/nameser.h>
|
104 |
|
|
#include <resolv.h>
|
105 |
|
|
|
106 |
|
|
int
|
107 |
|
|
res_query(char *dname, int class, int type, u_char *answer, int anslen);
|
108 |
|
|
|
109 |
|
|
int
|
110 |
|
|
res_search(char *dname, int class, int type, u_char *answer, int anslen);
|
111 |
|
|
|
112 |
|
|
int
|
113 |
|
|
res_mkquery(int op, char *dname, int class, int type, char *data,
|
114 |
|
|
int datalen, struct rrec *newrr, char *buf, int buflen);
|
115 |
|
|
|
116 |
|
|
int
|
117 |
|
|
res_send(char *msg, int msglen, char *answer, int anslen);
|
118 |
|
|
|
119 |
|
|
int
|
120 |
|
|
res_init(void);
|
121 |
|
|
|
122 |
|
|
int
|
123 |
|
|
dn_comp(char *exp_dn, char *comp_dn, int length, char **dnptrs,
|
124 |
|
|
char **lastdnptr);
|
125 |
|
|
|
126 |
|
|
int
|
127 |
|
|
dn_expand(u_char *msg, u_char *eomorig, u_char *comp_dn, u_char *exp_dn,
|
128 |
|
|
int length);
|
129 |
|
|
|
130 |
|
|
DESCRIPTION
|
131 |
|
|
These routines are used for making, sending, and interpreting query and
|
132 |
|
|
reply messages with Internet domain name servers.
|
133 |
|
|
|
134 |
|
|
Global configuration and state information that is used by the resolver
|
135 |
|
|
routines is kept in the structure _res. Most of the values have reason-
|
136 |
|
|
able defaults and can be ignored. Options stored in _res.options are
|
137 |
|
|
defined in <resolv.h> and are as follows. Options are stored as a simple
|
138 |
|
|
bit mask containing the bitwise OR of the options enabled.
|
139 |
|
|
|
140 |
|
|
RES_INIT True if the initial name server address and default domain
|
141 |
|
|
name are initialized (i.e., res_init() has been called).
|
142 |
|
|
|
143 |
|
|
RES_DEBUG Print debugging messages.
|
144 |
|
|
|
145 |
|
|
RES_AAONLY Accept authoritative answers only. With this option,
|
146 |
|
|
res_send() should continue until it finds an authoritative
|
147 |
|
|
answer or finds an error. Currently this is not imple-
|
148 |
|
|
mented.
|
149 |
|
|
|
150 |
|
|
RES_USEVC Use TCP connections for queries instead of UDP datagrams.
|
151 |
|
|
|
152 |
|
|
RES_STAYOPEN Used with RES_USEVC to keep the TCP connection open
|
153 |
|
|
between queries. This is useful only in programs that
|
154 |
|
|
regularly do many queries. UDP should be the normal mode
|
155 |
|
|
used.
|
156 |
|
|
|
157 |
|
|
RES_IGNTC Unused currently (ignore truncation errors, i.e., don't
|
158 |
|
|
retry with TCP).
|
159 |
|
|
|
160 |
|
|
RES_RECURSE Set the recursion-desired bit in queries. This is the
|
161 |
|
|
default. (res_send() does not do iterative queries and
|
162 |
|
|
expects the name server to handle recursion.)
|
163 |
|
|
|
164 |
|
|
RES_DEFNAMES If set, res_search() will append the default domain name
|
165 |
|
|
to single-component names (those that do not contain a
|
166 |
|
|
dot). This option is enabled by default.
|
167 |
|
|
|
168 |
|
|
RES_DNSRCH If this option is set, res_search() will search for host
|
169 |
|
|
names in the current domain and in parent domains; see
|
170 |
|
|
hostname(7). This is used by the standard host lookup
|
171 |
|
|
routine gethostbyname(3). This option is enabled by
|
172 |
|
|
default.
|
173 |
|
|
|
174 |
|
|
RES_USE_INET6 Enables support for IPv6-only applications. This causes
|
175 |
|
|
IPv4 addresses to be returned as an IPv4 mapped address.
|
176 |
|
|
For example, 10.1.1.1 will be returned as ::ffff:10.1.1.1.
|
177 |
|
|
The option is not meaningful on OpenBSD.
|
178 |
|
|
|
179 |
|
|
The res_init() routine reads the configuration file (if any; see
|
180 |
|
|
resolv.conf(5)) to get the default domain name, search list, and the
|
181 |
|
|
Internet address of the local name server(s). If no server is config-
|
182 |
|
|
ured, the host running the resolver is tried. The current domain name is
|
183 |
|
|
defined by the hostname if not specified in the configuration file; it
|
184 |
|
|
can be overridden by the environment variable LOCALDOMAIN. This environ-
|
185 |
|
|
ment variable may contain several blank-separated tokens if you wish to
|
186 |
|
|
override the search list on a per-process basis. This is similar to the
|
187 |
|
|
search command in the configuration file. Another environment variable
|
188 |
|
|
RES_OPTIONS can be set to override certain internal resolver options
|
189 |
|
|
which are otherwise set by changing fields in the _res structure or are
|
190 |
|
|
inherited from the configuration file's options command. The syntax of
|
191 |
|
|
the RES_OPTIONS environment variable is explained in resolv.conf(5).
|
192 |
|
|
Initialization normally occurs on the first call to one of the following
|
193 |
|
|
routines.
|
194 |
|
|
|
195 |
|
|
The res_query() function provides an interface to the server query mecha-
|
196 |
|
|
nism. It constructs a query, sends it to the local server, awaits a
|
197 |
|
|
response, and makes preliminary checks on the reply. The query requests
|
198 |
|
|
information of the specified type and class for the specified fully qual-
|
199 |
|
|
ified domain name dname. The reply message is left in the answer buffer
|
200 |
|
|
with length anslen supplied by the caller.
|
201 |
|
|
|
202 |
|
|
The res_search() routine makes a query and awaits a response like
|
203 |
|
|
res_query(), but in addition, it implements the default and search rules
|
204 |
|
|
controlled by the RES_DEFNAMES and RES_DNSRCH options. It returns the
|
205 |
|
|
first successful reply.
|
206 |
|
|
|
207 |
|
|
The remaining routines are lower-level routines used by res_query(). The
|
208 |
|
|
res_mkquery() function constructs a standard query message and places it
|
209 |
|
|
in buf. It returns the size of the query, or -1 if the query is larger
|
210 |
|
|
than buflen. The query type op is usually QUERY, but can be any of the
|
211 |
|
|
query types defined in <arpa/nameser.h>. The domain name for the query
|
212 |
|
|
is given by dname. newrr is currently unused but is intended for making
|
213 |
|
|
update messages.
|
214 |
|
|
|
215 |
|
|
The res_send() routine sends a pre-formatted query and returns an answer.
|
216 |
|
|
It will call res_init() if RES_INIT is not set, send the query to the
|
217 |
|
|
local name server, and handle timeouts and retries. The length of the
|
218 |
|
|
reply message is returned, or -1 if there were errors.
|
219 |
|
|
|
220 |
|
|
The dn_comp() function compresses the domain name exp_dn and stores it in
|
221 |
|
|
comp_dn. The size of the compressed name is returned or -1 if there were
|
222 |
|
|
errors. The size of the array pointed to by comp_dn is given by length.
|
223 |
|
|
The compression uses an array of pointers dnptrs to previously compressed
|
224 |
|
|
names in the current message. The first pointer points to the beginning
|
225 |
|
|
of the message and the list ends with NULL. The limit to the array is
|
226 |
|
|
specified by lastdnptr. A side effect of dn_comp() is to update the list
|
227 |
|
|
of pointers for labels inserted into the message as the name is com-
|
228 |
|
|
pressed. If dnptr is NULL, names are not compressed. If lastdnptr is
|
229 |
|
|
NULL, the list of labels is not updated.
|
230 |
|
|
|
231 |
|
|
The dn_expand() entry expands the compressed domain name comp_dn to a
|
232 |
|
|
full domain name The compressed name is contained in a query or reply
|
233 |
|
|
message; msg is a pointer to the beginning of the message. The uncom-
|
234 |
|
|
pressed name is placed in the buffer indicated by exp_dn which is of size
|
235 |
|
|
length. The size of compressed name is returned or -1 if there was an
|
236 |
|
|
error.
|
237 |
|
|
|
238 |
|
|
FILES
|
239 |
|
|
/etc/resolv.conf configuration file see resolv.conf(5).
|
240 |
|
|
|
241 |
|
|
SEE ALSO
|
242 |
|
|
gethostbyname(3), resolv.conf(5), hostname(7), named(8)
|
243 |
|
|
|
244 |
|
|
RFC1032, RFC1033, RFC1034, RFC1035, RFC1535, RFC974
|
245 |
|
|
|
246 |
|
|
Name Server Operations Guide for BIND.
|
247 |
|
|
|
248 |
|
|
HISTORY
|
249 |
|
|
The res_query function appeared in 4.3BSD.
|
250 |
|
|
|
251 |
|
|
BSD June 4, 1993 BSD
|
252 |
|
|
</PRE
|
253 |
|
|
></TD
|
254 |
|
|
></TR
|
255 |
|
|
></TABLE
|
256 |
|
|
></DIV
|
257 |
|
|
><DIV
|
258 |
|
|
CLASS="NAVFOOTER"
|
259 |
|
|
><HR
|
260 |
|
|
ALIGN="LEFT"
|
261 |
|
|
WIDTH="100%"><TABLE
|
262 |
|
|
SUMMARY="Footer navigation table"
|
263 |
|
|
WIDTH="100%"
|
264 |
|
|
BORDER="0"
|
265 |
|
|
CELLPADDING="0"
|
266 |
|
|
CELLSPACING="0"
|
267 |
|
|
><TR
|
268 |
|
|
><TD
|
269 |
|
|
WIDTH="33%"
|
270 |
|
|
ALIGN="left"
|
271 |
|
|
VALIGN="top"
|
272 |
|
|
><A
|
273 |
|
|
HREF="net-common-tcpip-manpages-ns.html"
|
274 |
|
|
ACCESSKEY="P"
|
275 |
|
|
>Prev</A
|
276 |
|
|
></TD
|
277 |
|
|
><TD
|
278 |
|
|
WIDTH="34%"
|
279 |
|
|
ALIGN="center"
|
280 |
|
|
VALIGN="top"
|
281 |
|
|
><A
|
282 |
|
|
HREF="ecos-ref.html"
|
283 |
|
|
ACCESSKEY="H"
|
284 |
|
|
>Home</A
|
285 |
|
|
></TD
|
286 |
|
|
><TD
|
287 |
|
|
WIDTH="33%"
|
288 |
|
|
ALIGN="right"
|
289 |
|
|
VALIGN="top"
|
290 |
|
|
><A
|
291 |
|
|
HREF="net-common-tcpip-manpages-accept.html"
|
292 |
|
|
ACCESSKEY="N"
|
293 |
|
|
>Next</A
|
294 |
|
|
></TD
|
295 |
|
|
></TR
|
296 |
|
|
><TR
|
297 |
|
|
><TD
|
298 |
|
|
WIDTH="33%"
|
299 |
|
|
ALIGN="left"
|
300 |
|
|
VALIGN="top"
|
301 |
|
|
>ns</TD
|
302 |
|
|
><TD
|
303 |
|
|
WIDTH="34%"
|
304 |
|
|
ALIGN="center"
|
305 |
|
|
VALIGN="top"
|
306 |
|
|
><A
|
307 |
|
|
HREF="tcpip-library-reference.html"
|
308 |
|
|
ACCESSKEY="U"
|
309 |
|
|
>Up</A
|
310 |
|
|
></TD
|
311 |
|
|
><TD
|
312 |
|
|
WIDTH="33%"
|
313 |
|
|
ALIGN="right"
|
314 |
|
|
VALIGN="top"
|
315 |
|
|
>accept</TD
|
316 |
|
|
></TR
|
317 |
|
|
></TABLE
|
318 |
|
|
></DIV
|
319 |
|
|
></BODY
|
320 |
|
|
></HTML
|
321 |
|
|
>
|