1 <!-- 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. -->
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="TCP/IP Library Reference"
23 HREF="tcpip-library-reference.html"><LINK
26 HREF="net-common-tcpip-manpages-ns.html"><LINK
29 HREF="net-common-tcpip-manpages-accept.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="net-common-tcpip-manpages-ns.html"
65 >Chapter 38. TCP/IP Library Reference</TD
71 HREF="net-common-tcpip-manpages-accept.html"
85 NAME="NET-COMMON-TCPIP-MANPAGES-RESOLVER">resolver</H1
94 >RESOLVER(3) System Library Functions Manual RESOLVER(3)
97 res_query, res_search, res_mkquery, res_send, res_init, dn_comp,
98 dn_expand - resolver routines
101 #include <sys/types.h>
102 #include <netinet/in.h>
103 #include <arpa/nameser.h>
104 #include <resolv.h>
107 res_query(char *dname, int class, int type, u_char *answer, int anslen);
110 res_search(char *dname, int class, int type, u_char *answer, int anslen);
113 res_mkquery(int op, char *dname, int class, int type, char *data,
114 int datalen, struct rrec *newrr, char *buf, int buflen);
117 res_send(char *msg, int msglen, char *answer, int anslen);
123 dn_comp(char *exp_dn, char *comp_dn, int length, char **dnptrs,
127 dn_expand(u_char *msg, u_char *eomorig, u_char *comp_dn, u_char *exp_dn,
131 These routines are used for making, sending, and interpreting query and
132 reply messages with Internet domain name servers.
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.
140 RES_INIT True if the initial name server address and default domain
141 name are initialized (i.e., res_init() has been called).
143 RES_DEBUG Print debugging messages.
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-
150 RES_USEVC Use TCP connections for queries instead of UDP datagrams.
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
157 RES_IGNTC Unused currently (ignore truncation errors, i.e., don't
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.)
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.
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
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.
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
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.
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.
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
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.
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.
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
239 /etc/resolv.conf configuration file see resolv.conf(5).
242 gethostbyname(3), resolv.conf(5), hostname(7), named(8)
244 RFC1032, RFC1033, RFC1034, RFC1035, RFC1535, RFC974
246 Name Server Operations Guide for BIND.
249 The res_query function appeared in 4.3BSD.
262 SUMMARY="Footer navigation table"
273 HREF="net-common-tcpip-manpages-ns.html"
291 HREF="net-common-tcpip-manpages-accept.html"
307 HREF="tcpip-library-reference.html"