]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/resolver.3
strip trailing white space
[thirdparty/man-pages.git] / man3 / resolver.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
3.\" Permission is granted to make and distribute verbatim copies of this
4.\" manual provided the copyright notice and this permission notice are
5.\" preserved on all copies.
6.\"
7.\" Permission is granted to copy and distribute modified versions of this
8.\" manual under the conditions for verbatim copying, provided that the
9.\" entire resulting derived work is distributed under the terms of a
10.\" permission notice identical to this one.
c13182ef 11.\"
fea681da
MK
12.\" Since the Linux kernel and libraries are constantly changing, this
13.\" manual page may be incorrect or out-of-date. The author(s) assume no
14.\" responsibility for errors or omissions, or for damages resulting from
15.\" the use of the information contained herein. The author(s) may not
16.\" have taken the same level of care in the production of this manual,
17.\" which is licensed free of charge, as they might when working
18.\" professionally.
c13182ef 19.\"
fea681da
MK
20.\" Formatted or processed versions of this manual, if unaccompanied by
21.\" the source, must acknowledge the copyright and authors of this work.
22.\"
23.\" References consulted:
24.\" Linux libc source code
25.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26.\" 386BSD man pages
27.\" Modified 1993-07-25 by Rik Faith (faith@cs.unc.edu)
28.\" Modified 2004-10-31 by aeb
29.\"
69962544 30.TH RESOLVER 3 2004-10-31 "GNU" "Linux Programmer's Manual"
fea681da 31.SH NAME
c13182ef 32res_init, res_query, res_search, res_querydomain, res_mkquery, res_send,
fea681da
MK
33dn_comp, dn_expand \- resolver routines
34.SH SYNOPSIS
35.nf
36.B #include <netinet/in.h>
37.B #include <arpa/nameser.h>
38.B #include <resolv.h>
39.B extern struct state _res;
40.sp
41.B int res_init(void);
42.sp
43.BI "int res_query(const char *" dname ", int " class ", int " type ,
44.RS
45.BI "unsigned char *" answer ", int " anslen );
46.RE
47.sp
48.BI "int res_search(const char *" dname ", int " class ", int " type ,
49.RS
50.BI "unsigned char *" answer ", int " anslen );
51.RE
52.sp
53.BI "int res_querydomain(const char *" name ", const char *" domain ,
54.RS
55.BI "int " class ", int " type ", unsigned char *" answer ,
56.BI "int " anslen );
57.RE
58.sp
59.BI "int res_mkquery(int " op ", const char *" dname ", int " class ,
60.RS
61.BI "int " type ", char *" data ", int " datalen ", struct rrec *" newrr ,
62.BI "char *" buf ", int " buflen );
63.RE
64.sp
c13182ef 65.BI "int res_send(const char *" msg ", int " msglen ", char *" answer ,
fea681da
MK
66.RS
67.BI "int " anslen );
68.RE
69.sp
70.BI "int dn_comp(unsigned char *" exp_dn ", unsigned char *" comp_dn ,
71.RS
72.BI "int " length ", unsigned char **" dnptrs ", unsigned char *" exp_dn ,
73.BI "unsigned char **" lastdnptr );
74.RE
75.sp
76.BI "int dn_expand(unsigned char *" msg ", unsigned char *" eomorig ,
77.RS
78.BI "unsigned char *" comp_dn ", unsigned char *" exp_dn ,
79.BI "int " length );
80.RE
81.fi
82.sp
e9329f6d 83Link with \fI\-lresolv\fP.
fea681da
MK
84.SH DESCRIPTION
85These functions make queries to and interpret the responses from Internet
86domain name servers.
87.PP
60a90ecd
MK
88The
89.BR res_init ()
90function reads the configuration files (see
ac1056b5 91resolv.conf(5)) to get the default domain name, search order and name
c13182ef
MK
92server address(es).
93If no server is given, the local host is tried.
fea681da
MK
94If no domain is given, that associated with the local host is used.
95It can be overridden with the environment variable LOCALDOMAIN.
60a90ecd
MK
96.BR res_init ()
97is normally executed by the first call to one of the
fea681da
MK
98other functions.
99.PP
60a90ecd
MK
100The
101.BR res_query ()
102function queries the name server for the
fea681da 103fully-qualified domain name \fIname\fP of specified \fItype\fP and
c13182ef
MK
104\fIclass\fP.
105The reply is left in the buffer \fIanswer\fP of length
fea681da
MK
106\fIanslen\fP supplied by the caller.
107.PP
60a90ecd
MK
108The
109.BR res_search ()
110function makes a query and waits for the response
111like
112.BR res_query (),
113but in addition implements the default and search
fea681da
MK
114rules controlled by RES_DEFNAMES and RES_DNSRCH (see description of
115\fI_res\fP options below).
116.PP
60a90ecd
MK
117The
118.BR res_querydomain ()
119function makes a query using
120.BR res_query ()
fea681da
MK
121on the concatenation of \fIname\fP and \fIdomain\fP.
122.PP
60a90ecd
MK
123The following functions are lower-level routines used by
124.BR res_query ().
fea681da 125.PP
60a90ecd
MK
126The
127.BR res_mkquery ()
128function constructs a query message in \fIbuf\fP
c13182ef
MK
129of length \fIbuflen\fP for the domain name \fIdname\fP.
130The query type
fea681da 131\fIop\fP is usually QUERY, but can be any of the types defined in
be7fff26
MK
132\fI<arpa/nameser.h>\fP.
133\fInewrr\fP is currently unused.
fea681da 134.PP
60a90ecd
MK
135The
136.BR res_send ()
137function sends a pre-formatted query given in
fea681da 138\fImsg\fP of length \fImsglen\fP and returns the answer in \fIanswer\fP
c13182ef 139which is of length \fIanslen\fP.
60a90ecd
MK
140It will call
141.BR res_init (),
142if it
fea681da
MK
143has not already been called.
144.PP
60a90ecd
MK
145The
146.BR dn_comp ()
147function compresses the domain name \fIexp_dn\fP
fea681da
MK
148and stores it in the buffer \fIcomp_dn\fP of length \fIlength\fP.
149The compression uses an array of pointers \fIdnptrs\fP to previously
c13182ef
MK
150compressed names in the current message.
151The first pointer points
152to the beginning of the message and the list ends with NULL.
153The limit of the array is specified by \fIlastdnptr\fP.
154If \fIdnptr\fP is NULL, domain names are not compressed.
155If \fIlastdnptr\fP is NULL, the list
fea681da
MK
156of labels is not updated.
157.PP
63aa9df0 158The \fPdn_expand\fP() function expands the compressed domain name
fea681da 159\fIcomp_dn\fP to a full domain name, which is placed in the buffer
c13182ef
MK
160\fIexp_dn\fP of size \fIlength\fP.
161The compressed name is contained
fea681da
MK
162in a query or reply message, and \fImsg\fP points to the beginning of
163the message.
164.PP
165The resolver routines use global configuration and state information
c13182ef
MK
166contained in the structure \fI_res\fP, which is defined in
167\fI<resolv.h>\fP.
168The only field that is normally manipulated by the
169user is \fI_res.options\fP.
170This field can contain the bitwise ``or''
fea681da 171of the following options:
fea681da
MK
172.TP
173.B RES_INIT
60a90ecd
MK
174True if
175.BR res_init ()
176has been called.
fea681da
MK
177.TP
178.B RES_DEBUG
179Print debugging messages.
180.TP
181.B RES_AAONLY
988db661 182Accept authoritative answers only.
60a90ecd
MK
183.BR res_send ()
184continues until
fea681da
MK
185it fins an authoritative answer or returns an error. [Not currently
186implemented].
187.TP
188.B RES_USEVC
189Use TCP connections for queries rather than UDP datagrams.
190.TP
191.B RES_PRIMARY
192Query primary domain name server only.
193.TP
194.B RES_IGNTC
c13182ef
MK
195Ignore truncation errors.
196Don't retry with TCP. [Not currently
fea681da
MK
197implemented].
198.TP
199.B RES_RECURSE
c13182ef
MK
200Set the recursion desired bit in queries.
201Recursion is carried out
60a90ecd
MK
202by the domain name server, not by
203.BR res_send ().
c13182ef 204[Enabled by default].
fea681da
MK
205.TP
206.B RES_DEFNAMES
60a90ecd
MK
207If set,
208.BR res_search ()
209will append the default domain name to
fea681da
MK
210single component names, ie. those that do not contain a dot.
211[Enabled by default].
212.TP
213.B RES_STAYOPEN
214Used with RES_USEVC to keep the TCP connection open between queries.
215.TP
216.B RES_DNSRCH
60a90ecd
MK
217If set,
218.BR res_search ()
219will search for host names in the current
c13182ef
MK
220domain and in parent domains.
221This option is used by
fea681da
MK
222.BR gethostbyname (3).
223[Enabled by default].
224.SH "RETURN VALUE"
60a90ecd
MK
225The
226.BR res_init ()
227function returns 0 on success, or \-1 if an error
fea681da
MK
228occurs.
229.PP
60a90ecd
MK
230The
231.BR res_query (),
232.BR res_search (),
233.BR res_querydomain (),
234.BR res_mkquery ()
235and
236.BR res_send ()
237functions return the length
fea681da
MK
238of the response, or \-1 if an error occurs.
239.PP
60a90ecd
MK
240The
241.BR dn_comp ()
242and
243.BR dn_expand ()
244functions return the length
fea681da
MK
245of the compressed name, or \-1 if an error occurs.
246.SH FILES
247.nf
248/etc/resolv.conf resolver configuration file
249/etc/host.conf resolver configuration file
250.fi
251.SH "CONFORMING TO"
b14d4aa5 2524.3BSD
fea681da
MK
253.SH "SEE ALSO"
254.BR gethostbyname (3),
aca92158 255.BR resolver (5),
fea681da 256.BR hostname (7),
b95582c7
MK
257.BR resolv.conf (5),
258.BR named (8)