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.393
1 files changed, 47 insertions, 46 deletions
diff --git a/src/lib/libc/net/resolver.3 b/src/lib/libc/net/resolver.3
index 99abe17f03..4d5402ed2d 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.15 2001/04/03 20:09:08 aaron 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.
@@ -31,11 +31,9 @@
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE. 32.\" SUCH DAMAGE.
33.\" 33.\"
34.\" @(#)resolver.3 8.1 (Berkeley) 6/4/93
35.\"
36.Dd June 4, 1993 34.Dd June 4, 1993
37.Dt RESOLVER 3 35.Dt RESOLVER 3
38.Os BSD 4.3 36.Os
39.Sh NAME 37.Sh NAME
40.Nm res_query , 38.Nm res_query ,
41.Nm res_search , 39.Nm res_search ,
@@ -50,6 +48,7 @@
50.Fd #include <netinet/in.h> 48.Fd #include <netinet/in.h>
51.Fd #include <arpa/nameser.h> 49.Fd #include <arpa/nameser.h>
52.Fd #include <resolv.h> 50.Fd #include <resolv.h>
51.Ft int
53.Fo res_query 52.Fo res_query
54.Fa "char *dname" 53.Fa "char *dname"
55.Fa "int class" 54.Fa "int class"
@@ -57,6 +56,7 @@
57.Fa "u_char *answer" 56.Fa "u_char *answer"
58.Fa "int anslen" 57.Fa "int anslen"
59.Fc 58.Fc
59.Ft int
60.Fo res_search 60.Fo res_search
61.Fa "char *dname" 61.Fa "char *dname"
62.Fa "int class" 62.Fa "int class"
@@ -64,6 +64,7 @@
64.Fa "u_char *answer" 64.Fa "u_char *answer"
65.Fa "int anslen" 65.Fa "int anslen"
66.Fc 66.Fc
67.Ft int
67.Fo res_mkquery 68.Fo res_mkquery
68.Fa "int op" 69.Fa "int op"
69.Fa "char *dname" 70.Fa "char *dname"
@@ -75,13 +76,16 @@
75.Fa "char *buf" 76.Fa "char *buf"
76.Fa "int buflen" 77.Fa "int buflen"
77.Fc 78.Fc
79.Ft int
78.Fo res_send 80.Fo res_send
79.Fa "char *msg" 81.Fa "char *msg"
80.Fa "int msglen" 82.Fa "int msglen"
81.Fa "char *answer" 83.Fa "char *answer"
82.Fa "int anslen" 84.Fa "int anslen"
83.Fc 85.Fc
84.Fn res_init 86.Ft int
87.Fn res_init "void"
88.Ft int
85.Fo dn_comp 89.Fo dn_comp
86.Fa "char *exp_dn" 90.Fa "char *exp_dn"
87.Fa "char *comp_dn" 91.Fa "char *comp_dn"
@@ -89,6 +93,7 @@
89.Fa "char **dnptrs" 93.Fa "char **dnptrs"
90.Fa "char **lastdnptr" 94.Fa "char **lastdnptr"
91.Fc 95.Fc
96.Ft int
92.Fo dn_expand 97.Fo dn_expand
93.Fa "u_char *msg" 98.Fa "u_char *msg"
94.Fa "u_char *eomorig" 99.Fa "u_char *eomorig"
@@ -97,22 +102,22 @@
97.Fa "int length" 102.Fa "int length"
98.Fc 103.Fc
99.Sh DESCRIPTION 104.Sh DESCRIPTION
100These routines are used for making, sending and interpreting 105These routines are used for making, sending, and interpreting
101query and reply messages with Internet domain name servers. 106query and reply messages with Internet domain name servers.
102.Pp 107.Pp
103Global configuration and state information that is used by the 108Global configuration and state information that is used by the
104resolver routines is kept in the structure 109resolver routines is kept in the structure
105.Em _res . 110.Li _res .
106Most of the values have reasonable defaults and can be ignored. 111Most of the values have reasonable defaults and can be ignored.
107Options 112Options stored in
108stored in 113.Li _res.options
109.Em _res.options
110are defined in 114are defined in
111.Pa resolv.h 115.Aq Pa resolv.h
112and are as follows. 116and are as follows.
113Options are stored as a simple bit mask containing the bitwise ``or'' 117Options are stored as a simple bit mask containing the bitwise
118.Tn OR
114of the options enabled. 119of the options enabled.
115.Bl -tag -width RES_DEFNAMES 120.Bl -tag -width RES_USE_INET6
116.It Dv RES_INIT 121.It Dv RES_INIT
117True if the initial name server address and default domain name are 122True if the initial name server address and default domain name are
118initialized (i.e., 123initialized (i.e.,
@@ -137,8 +142,7 @@ Used with
137.Dv RES_USEVC 142.Dv RES_USEVC
138to keep the 143to keep the
139.Tn TCP 144.Tn TCP
140connection open between 145connection open between queries.
141queries.
142This is useful only in programs that regularly do many queries. 146This is useful only in programs that regularly do many queries.
143.Tn UDP 147.Tn UDP
144should be the normal mode used. 148should be the normal mode used.
@@ -165,16 +169,20 @@ will search for host names in the current domain and in parent domains; see
165This is used by the standard host lookup routine 169This is used by the standard host lookup routine
166.Xr gethostbyname 3 . 170.Xr gethostbyname 3 .
167This option is enabled by default. 171This option is enabled by default.
172.It Dv RES_USE_INET6
173Enables support for IPv6-only applications.
174This causes IPv4 addresses to be returned as an IPv4 mapped address.
175For example, 10.1.1.1 will be returned as ::ffff:10.1.1.1.
176The option is not meaningful on
177.Ox .
168.El 178.El
169.Pp 179.Pp
170The 180The
171.Fn res_init 181.Fn res_init
172routine 182routine reads the configuration file (if any; see
173reads the configuration file (if any; see
174.Xr resolv.conf 5 ) 183.Xr resolv.conf 5 )
175to get the default domain name, 184to get the default domain name, search list, and the Internet address
176search list and 185of the local name server(s).
177the Internet address of the local name server(s).
178If no server is configured, the host running 186If no server is configured, the host running
179the resolver is tried. 187the resolver is tried.
180The current domain name is defined by the hostname 188The current domain name is defined by the hostname
@@ -212,7 +220,7 @@ The query requests information of the specified
212.Fa type 220.Fa type
213and 221and
214.Fa class 222.Fa class
215for the specified fully-qualified domain name 223for the specified fully qualified domain name
216.Fa dname . 224.Fa dname .
217The reply message is left in the 225The reply message is left in the
218.Fa answer 226.Fa answer
@@ -224,8 +232,7 @@ The
224.Fn res_search 232.Fn res_search
225routine makes a query and awaits a response like 233routine makes a query and awaits a response like
226.Fn res_query , 234.Fn res_query ,
227but in addition, it implements the default and search rules 235but in addition, it implements the default and search rules controlled by the
228controlled by the
229.Dv RES_DEFNAMES 236.Dv RES_DEFNAMES
230and 237and
231.Dv RES_DNSRCH 238.Dv RES_DNSRCH
@@ -236,11 +243,9 @@ The remaining routines are lower-level routines used by
236.Fn res_query . 243.Fn res_query .
237The 244The
238.Fn res_mkquery 245.Fn res_mkquery
239function 246function constructs a standard query message and places it in
240constructs a standard query message and places it in
241.Fa buf . 247.Fa buf .
242It returns the size of the query, or \-1 if the query is 248It returns the size of the query, or \-1 if the query is larger than
243larger than
244.Fa buflen . 249.Fa buflen .
245The query type 250The query type
246.Fa op 251.Fa op
@@ -250,26 +255,23 @@ but can be any of the query types defined in
250.Aq Pa arpa/nameser.h . 255.Aq Pa arpa/nameser.h .
251The domain name for the query is given by 256The domain name for the query is given by
252.Fa dname . 257.Fa dname .
253.Fa Newrr 258.Fa newrr
254is currently unused but is intended for making update messages. 259is currently unused but is intended for making update messages.
255.Pp 260.Pp
256The 261The
257.Fn res_send 262.Fn res_send
258routine 263routine sends a pre-formatted query and returns an answer.
259sends a pre-formatted query and returns an answer.
260It will call 264It will call
261.Fn res_init 265.Fn res_init
262if 266if
263.Dv RES_INIT 267.Dv RES_INIT
264is not set, send the query to the local name server, and 268is not set, send the query to the local name server, and
265handle timeouts and retries. 269handle timeouts and retries.
266The length of the reply message is returned, or 270The length of the reply message is returned, or \-1 if there were errors.
267\-1 if there were errors.
268.Pp 271.Pp
269The 272The
270.Fn dn_comp 273.Fn dn_comp
271function 274function compresses the domain name
272compresses the domain name
273.Fa exp_dn 275.Fa exp_dn
274and stores it in 276and stores it in
275.Fa comp_dn . 277.Fa comp_dn .
@@ -278,24 +280,23 @@ The size of the array pointed to by
278.Fa comp_dn 280.Fa comp_dn
279is given by 281is given by
280.Fa length . 282.Fa length .
281The compression uses 283The compression uses an array of pointers
282an array of pointers
283.Fa dnptrs 284.Fa dnptrs
284to previously-compressed names in the current message. 285to previously compressed names in the current message.
285The first pointer points to 286The first pointer points
286to the beginning of the message and the list ends with 287to the beginning of the message and the list ends with
287.Dv NULL . 288.Dv NULL .
288The limit to the array is specified by 289The limit to the array is specified by
289.Fa lastdnptr . 290.Fa lastdnptr .
290A side effect of 291A side effect of
291.Fn dn_comp 292.Fn dn_comp
292is to update the list of pointers for 293is to update the list of pointers for labels inserted into the message
293labels inserted into the message
294as the name is compressed. 294as the name is compressed.
295If 295If
296.Em dnptr 296.Em dnptr
297is 297is
298.Dv NULL, names are not compressed. 298.Dv NULL ,
299names are not compressed.
299If 300If
300.Fa lastdnptr 301.Fa lastdnptr
301is 302is
@@ -304,8 +305,7 @@ the list of labels is not updated.
304.Pp 305.Pp
305The 306The
306.Fn dn_expand 307.Fn dn_expand
307entry 308entry expands the compressed domain name
308expands the compressed domain name
309.Fa comp_dn 309.Fa comp_dn
310to a full domain name 310to a full domain name
311The compressed name is contained in a query or reply message; 311The compressed name is contained in a query or reply message;
@@ -319,20 +319,21 @@ The size of compressed name is returned or \-1 if there was an error.
319.Sh FILES 319.Sh FILES
320.Bl -tag -width Pa 320.Bl -tag -width Pa
321/etc/resolv.conf 321/etc/resolv.conf
322The configuration file 322configuration file
323see 323see
324.Xr resolv.conf 5 . 324.Xr resolv.conf 5 .
325.El 325.El
326.Sh SEE ALSO 326.Sh SEE ALSO
327.Xr gethostbyname 3 , 327.Xr gethostbyname 3 ,
328.Xr named 8 ,
329.Xr resolv.conf 5 , 328.Xr resolv.conf 5 ,
330.Xr hostname 7 , 329.Xr hostname 7 ,
330.Xr named 8
331.Pp 331.Pp
332.%T RFC1032 , 332.%T RFC1032 ,
333.%T RFC1033 , 333.%T RFC1033 ,
334.%T RFC1034 , 334.%T RFC1034 ,
335.%T RFC1035 , 335.%T RFC1035 ,
336.%T RFC1535 ,
336.%T RFC974 337.%T RFC974
337.Rs 338.Rs
338.%T "Name Server Operations Guide for BIND" 339.%T "Name Server Operations Guide for BIND"
@@ -340,5 +341,5 @@ see
340.Sh HISTORY 341.Sh HISTORY
341The 342The
342.Nm 343.Nm
343function appeared in 344function appeared in
344.Bx 4.3 . 345.Bx 4.3 .