summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/resolver.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/net/resolver.3')
-rw-r--r--src/lib/libc/net/resolver.3172
1 files changed, 91 insertions, 81 deletions
diff --git a/src/lib/libc/net/resolver.3 b/src/lib/libc/net/resolver.3
index 99abe17f03..e820ea25ed 100644
--- a/src/lib/libc/net/resolver.3
+++ b/src/lib/libc/net/resolver.3
@@ -1,4 +1,4 @@
1.\" $NetBSD: resolver.3,v 1.5 1995/02/25 06:21:02 cgd Exp $ 1.\" $OpenBSD: resolver.3,v 1.21 2007/05/31 19:19:30 jmc Exp $
2.\" 2.\"
3.\" Copyright (c) 1985, 1991, 1993 3.\" Copyright (c) 1985, 1991, 1993
4.\" The Regents of the University of California. All rights reserved. 4.\" The Regents of the University of California. All rights reserved.
@@ -11,11 +11,7 @@
11.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the 12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution. 13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software 14.\" 3. Neither the name of the University nor the names of its contributors
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software 15.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission. 16.\" without specific prior written permission.
21.\" 17.\"
@@ -31,11 +27,9 @@
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE. 28.\" SUCH DAMAGE.
33.\" 29.\"
34.\" @(#)resolver.3 8.1 (Berkeley) 6/4/93 30.Dd $Mdocdate: May 31 2007 $
35.\"
36.Dd June 4, 1993
37.Dt RESOLVER 3 31.Dt RESOLVER 3
38.Os BSD 4.3 32.Os
39.Sh NAME 33.Sh NAME
40.Nm res_query , 34.Nm res_query ,
41.Nm res_search , 35.Nm res_search ,
@@ -50,69 +44,76 @@
50.Fd #include <netinet/in.h> 44.Fd #include <netinet/in.h>
51.Fd #include <arpa/nameser.h> 45.Fd #include <arpa/nameser.h>
52.Fd #include <resolv.h> 46.Fd #include <resolv.h>
47.Ft int
53.Fo res_query 48.Fo res_query
54.Fa "char *dname" 49.Fa "const char *dname"
55.Fa "int class" 50.Fa "int class"
56.Fa "int type" 51.Fa "int type"
57.Fa "u_char *answer" 52.Fa "unsigned char *answer"
58.Fa "int anslen" 53.Fa "int anslen"
59.Fc 54.Fc
55.Ft int
60.Fo res_search 56.Fo res_search
61.Fa "char *dname" 57.Fa "const char *dname"
62.Fa "int class" 58.Fa "int class"
63.Fa "int type" 59.Fa "int type"
64.Fa "u_char *answer" 60.Fa "unsigned char *answer"
65.Fa "int anslen" 61.Fa "int anslen"
66.Fc 62.Fc
63.Ft int
67.Fo res_mkquery 64.Fo res_mkquery
68.Fa "int op" 65.Fa "int op"
69.Fa "char *dname" 66.Fa "const char *dname"
70.Fa "int class" 67.Fa "int class"
71.Fa "int type" 68.Fa "int type"
72.Fa "char *data" 69.Fa "const unsigned char *data"
73.Fa "int datalen" 70.Fa "int datalen"
74.Fa "struct rrec *newrr" 71.Fa "const unsigned char *newrr"
75.Fa "char *buf" 72.Fa "unsigned char *buf"
76.Fa "int buflen" 73.Fa "int buflen"
77.Fc 74.Fc
75.Ft int
78.Fo res_send 76.Fo res_send
79.Fa "char *msg" 77.Fa "const unsigned char *msg"
80.Fa "int msglen" 78.Fa "int msglen"
81.Fa "char *answer" 79.Fa "unsigned char *answer"
82.Fa "int anslen" 80.Fa "int anslen"
83.Fc 81.Fc
84.Fn res_init 82.Ft int
83.Fn res_init "void"
84.Ft int
85.Fo dn_comp 85.Fo dn_comp
86.Fa "char *exp_dn" 86.Fa "const char *exp_dn"
87.Fa "char *comp_dn" 87.Fa "unsigned char *comp_dn"
88.Fa "int length" 88.Fa "int length"
89.Fa "char **dnptrs" 89.Fa "unsigned char **dnptrs"
90.Fa "char **lastdnptr" 90.Fa "unsigned char **lastdnptr"
91.Fc 91.Fc
92.Ft int
92.Fo dn_expand 93.Fo dn_expand
93.Fa "u_char *msg" 94.Fa "const unsigned char *msg"
94.Fa "u_char *eomorig" 95.Fa "const unsigned char *eomorig"
95.Fa "u_char *comp_dn" 96.Fa "const unsigned char *comp_dn"
96.Fa "u_char *exp_dn" 97.Fa "char *exp_dn"
97.Fa "int length" 98.Fa "int length"
98.Fc 99.Fc
99.Sh DESCRIPTION 100.Sh DESCRIPTION
100These routines are used for making, sending and interpreting 101These routines are used for making, sending, and interpreting
101query and reply messages with Internet domain name servers. 102query and reply messages with Internet domain name servers.
102.Pp 103.Pp
103Global configuration and state information that is used by the 104Global configuration and state information that is used by the
104resolver routines is kept in the structure 105resolver routines is kept in the structure
105.Em _res . 106.Li _res .
106Most of the values have reasonable defaults and can be ignored. 107Most of the values have reasonable defaults and can be ignored.
107Options 108Options stored in
108stored in 109.Li _res.options
109.Em _res.options
110are defined in 110are defined in
111.Pa resolv.h 111.Aq Pa resolv.h
112and are as follows. 112and are as follows.
113Options are stored as a simple bit mask containing the bitwise ``or'' 113Options are stored as a simple bit mask containing the bitwise
114.Tn OR
114of the options enabled. 115of the options enabled.
115.Bl -tag -width RES_DEFNAMES 116.Bl -tag -width RES_USE_INET6
116.It Dv RES_INIT 117.It Dv RES_INIT
117True if the initial name server address and default domain name are 118True if the initial name server address and default domain name are
118initialized (i.e., 119initialized (i.e.,
@@ -137,8 +138,7 @@ Used with
137.Dv RES_USEVC 138.Dv RES_USEVC
138to keep the 139to keep the
139.Tn TCP 140.Tn TCP
140connection open between 141connection open between queries.
141queries.
142This is useful only in programs that regularly do many queries. 142This is useful only in programs that regularly do many queries.
143.Tn UDP 143.Tn UDP
144should be the normal mode used. 144should be the normal mode used.
@@ -165,16 +165,28 @@ will search for host names in the current domain and in parent domains; see
165This is used by the standard host lookup routine 165This is used by the standard host lookup routine
166.Xr gethostbyname 3 . 166.Xr gethostbyname 3 .
167This option is enabled by default. 167This option is enabled by default.
168.It Dv RES_USE_INET6
169Enables support for IPv6-only applications.
170This causes IPv4 addresses to be returned as an IPv4 mapped address.
171For example, 10.1.1.1 will be returned as ::ffff:10.1.1.1.
172The option is not meaningful on
173.Ox .
174.It Dv RES_USE_EDNS0
175Enables support for OPT pseudo-RR for EDNS0 extension.
176With this option, resolver code will attach OPT pseudo-RR into DNS queries,
177to inform of our receive buffer size.
178The option will allow DNS servers to take advantage of non-default receive
179buffer size, and to send larger replies.
180DNS query packets with EDNS0 extension is not compatible with
181non-EDNS0 DNS servers.
168.El 182.El
169.Pp 183.Pp
170The 184The
171.Fn res_init 185.Fn res_init
172routine 186routine reads the configuration file (if any; see
173reads the configuration file (if any; see
174.Xr resolv.conf 5 ) 187.Xr resolv.conf 5 )
175to get the default domain name, 188to get the default domain name, search list, and the Internet address
176search list and 189of the local name server(s).
177the Internet address of the local name server(s).
178If no server is configured, the host running 190If no server is configured, the host running
179the resolver is tried. 191the resolver is tried.
180The current domain name is defined by the hostname 192The current domain name is defined by the hostname
@@ -212,20 +224,26 @@ The query requests information of the specified
212.Fa type 224.Fa type
213and 225and
214.Fa class 226.Fa class
215for the specified fully-qualified domain name 227for the specified fully qualified domain name
216.Fa dname . 228.Fa dname .
217The reply message is left in the 229The reply message is left in the
218.Fa answer 230.Fa answer
219buffer with length 231buffer with length
220.Fa anslen 232.Fa anslen
221supplied by the caller. 233supplied by the caller.
234Values for the
235.Fa class
236and
237.Fa type
238fields
239are defined in
240.Aq Pa arpa/nameser.h .
222.Pp 241.Pp
223The 242The
224.Fn res_search 243.Fn res_search
225routine makes a query and awaits a response like 244routine makes a query and awaits a response like
226.Fn res_query , 245.Fn res_query ,
227but in addition, it implements the default and search rules 246but in addition, it implements the default and search rules controlled by the
228controlled by the
229.Dv RES_DEFNAMES 247.Dv RES_DEFNAMES
230and 248and
231.Dv RES_DNSRCH 249.Dv RES_DNSRCH
@@ -236,11 +254,9 @@ The remaining routines are lower-level routines used by
236.Fn res_query . 254.Fn res_query .
237The 255The
238.Fn res_mkquery 256.Fn res_mkquery
239function 257function constructs a standard query message and places it in
240constructs a standard query message and places it in
241.Fa buf . 258.Fa buf .
242It returns the size of the query, or \-1 if the query is 259It returns the size of the query, or \-1 if the query is larger than
243larger than
244.Fa buflen . 260.Fa buflen .
245The query type 261The query type
246.Fa op 262.Fa op
@@ -250,26 +266,23 @@ but can be any of the query types defined in
250.Aq Pa arpa/nameser.h . 266.Aq Pa arpa/nameser.h .
251The domain name for the query is given by 267The domain name for the query is given by
252.Fa dname . 268.Fa dname .
253.Fa Newrr 269.Fa newrr
254is currently unused but is intended for making update messages. 270is currently unused but is intended for making update messages.
255.Pp 271.Pp
256The 272The
257.Fn res_send 273.Fn res_send
258routine 274routine sends a pre-formatted query and returns an answer.
259sends a pre-formatted query and returns an answer.
260It will call 275It will call
261.Fn res_init 276.Fn res_init
262if 277if
263.Dv RES_INIT 278.Dv RES_INIT
264is not set, send the query to the local name server, and 279is not set, send the query to the local name server, and
265handle timeouts and retries. 280handle timeouts and retries.
266The length of the reply message is returned, or 281The length of the reply message is returned, or \-1 if there were errors.
267\-1 if there were errors.
268.Pp 282.Pp
269The 283The
270.Fn dn_comp 284.Fn dn_comp
271function 285function compresses the domain name
272compresses the domain name
273.Fa exp_dn 286.Fa exp_dn
274and stores it in 287and stores it in
275.Fa comp_dn . 288.Fa comp_dn .
@@ -278,24 +291,23 @@ The size of the array pointed to by
278.Fa comp_dn 291.Fa comp_dn
279is given by 292is given by
280.Fa length . 293.Fa length .
281The compression uses 294The compression uses an array of pointers
282an array of pointers
283.Fa dnptrs 295.Fa dnptrs
284to previously-compressed names in the current message. 296to previously compressed names in the current message.
285The first pointer points to 297The first pointer points
286to the beginning of the message and the list ends with 298to the beginning of the message and the list ends with
287.Dv NULL . 299.Dv NULL .
288The limit to the array is specified by 300The limit to the array is specified by
289.Fa lastdnptr . 301.Fa lastdnptr .
290A side effect of 302A side effect of
291.Fn dn_comp 303.Fn dn_comp
292is to update the list of pointers for 304is to update the list of pointers for labels inserted into the message
293labels inserted into the message
294as the name is compressed. 305as the name is compressed.
295If 306If
296.Em dnptr 307.Fa dnptrs
297is 308is
298.Dv NULL, names are not compressed. 309.Dv NULL ,
310names are not compressed.
299If 311If
300.Fa lastdnptr 312.Fa lastdnptr
301is 313is
@@ -304,10 +316,9 @@ the list of labels is not updated.
304.Pp 316.Pp
305The 317The
306.Fn dn_expand 318.Fn dn_expand
307entry 319entry expands the compressed domain name
308expands the compressed domain name
309.Fa comp_dn 320.Fa comp_dn
310to a full domain name 321to a full domain name.
311The compressed name is contained in a query or reply message; 322The compressed name is contained in a query or reply message;
312.Fa msg 323.Fa msg
313is a pointer to the beginning of the message. 324is a pointer to the beginning of the message.
@@ -317,28 +328,27 @@ which is of size
317.Fa length . 328.Fa length .
318The size of compressed name is returned or \-1 if there was an error. 329The size of compressed name is returned or \-1 if there was an error.
319.Sh FILES 330.Sh FILES
320.Bl -tag -width Pa 331.Bl -tag -width "/etc/resolv.confXX"
321/etc/resolv.conf 332.It Pa /etc/resolv.conf
322The configuration file 333The configuration file.
323see
324.Xr resolv.conf 5 .
325.El 334.El
326.Sh SEE ALSO 335.Sh SEE ALSO
327.Xr gethostbyname 3 , 336.Xr gethostbyname 3 ,
328.Xr named 8 ,
329.Xr resolv.conf 5 , 337.Xr resolv.conf 5 ,
330.Xr hostname 7 , 338.Xr hostname 7 ,
339.Xr named 8
331.Pp 340.Pp
332.%T RFC1032 , 341.%T RFC 974 ,
333.%T RFC1033 , 342.%T RFC 1032 ,
334.%T RFC1034 , 343.%T RFC 1033 ,
335.%T RFC1035 , 344.%T RFC 1034 ,
336.%T RFC974 345.%T RFC 1035 ,
346.%T RFC 1535
337.Rs 347.Rs
338.%T "Name Server Operations Guide for BIND" 348.%T "Name Server Operations Guide for BIND"
339.Re 349.Re
340.Sh HISTORY 350.Sh HISTORY
341The 351The
342.Nm 352.Nm
343function appeared in 353function appeared in
344.Bx 4.3 . 354.Bx 4.3 .