blob: 2c85d20f645b08cb07a2282d1798925d51fef11b [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001.\"
2.\" Copyright 1998 by the Massachusetts Institute of Technology.
3.\"
4.\" Permission to use, copy, modify, and distribute this
5.\" software and its documentation for any purpose and without
6.\" fee is hereby granted, provided that the above copyright
7.\" notice appear in all copies and that both that copyright
8.\" notice and this permission notice appear in supporting
9.\" documentation, and that the name of M.I.T. not be used in
10.\" advertising or publicity pertaining to distribution of the
11.\" software without specific, written prior permission.
12.\" M.I.T. makes no representations about the suitability of
13.\" this software for any purpose. It is provided "as is"
14.\" without express or implied warranty.
15.\"
16.TH ARES_SEARCH 3 "24 July 1998"
17.SH NAME
18ares_search \- Initiate a DNS query with domain search
19.SH SYNOPSIS
20.nf
21.B #include <ares.h>
22.PP
23.B typedef void (*ares_callback)(void *\fIarg\fP, int \fIstatus\fP,
24.B int \fItimeouts\fP, unsigned char *\fIabuf\fP, int \fIalen\fP)
25.PP
26.B void ares_search(ares_channel \fIchannel\fP, const char *\fIname\fP,
27.B int \fIdnsclass\fP, int \fItype\fP, ares_callback \fIcallback\fP,
28.B void *\fIarg\fP)
29.fi
30.SH DESCRIPTION
31The
32.B ares_search
33function initiates a series of single-question DNS queries on the name
34service channel identified by
35.IR channel ,
36using the channel's search domains as well as a host alias file given
37by the HOSTALIAS environment variable. The parameter
38.I name
39gives the alias name or the base of the query name as a NUL-terminated
40C string of period-separated labels; if it ends with a period, the
41channel's search domains will not be used. Periods and backslashes
42within a label must be escaped with a backslash. The parameters
43.I dnsclass
44and
45.I type
46give the class and type of the query using the values defined in
47.BR <arpa/nameser.h> .
48When the query sequence is complete or has failed, the ares library
49will invoke
50.IR callback .
51Completion or failure of the query sequence may happen immediately, or
52may happen during a later call to
53.BR ares_process (3)
54or
55.BR ares_destroy (3).
56.PP
57The callback argument
58.I arg
59is copied from the
60.B ares_search
61argument
62.IR arg .
63The callback argument
64.I status
65indicates whether the query sequence ended with a successful query
66and, if not, how the query sequence failed. It may have any of the
67following values:
68.TP 19
69.B ARES_SUCCESS
70A query completed successfully.
71.TP 19
72.B ARES_ENODATA
73No query completed successfully; when the query was tried without a
74search domain appended, a response was returned with no answers.
75.TP 19
76.B ARES_EFORMERR
77A query completed but the server claimed that the query was
78malformatted.
79.TP 19
80.B ARES_ESERVFAIL
81No query completed successfully; when the query was tried without a
82search domain appended, the server claimed to have experienced a
83failure. (This code can only occur if the
84.B ARES_FLAG_NOCHECKRESP
85flag was specified at channel initialization time; otherwise, such
86responses are ignored at the
87.BR ares_send (3)
88level.)
89.TP 19
90.B ARES_ENOTFOUND
91No query completed successfully; when the query was tried without a
92search domain appended, the server reported that the queried-for
93domain name was not found.
94.TP 19
95.B ARES_ENOTIMP
96A query completed but the server does not implement the operation
97requested by the query. (This code can only occur if the
98.B ARES_FLAG_NOCHECKRESP
99flag was specified at channel initialization time; otherwise, such
100responses are ignored at the
101.BR ares_send (3)
102level.)
103.TP 19
104.B ARES_EREFUSED
105A query completed but the server refused the query. (This code can
106only occur returned if the
107.B ARES_FLAG_NOCHECKRESP
108flag was specified at channel initialization time; otherwise, such
109responses are ignored at the
110.BR ares_send (3)
111level.)
112.TP 19
113.B ARES_TIMEOUT
114No name servers responded to a query within the timeout period.
115.TP 19
116.B ARES_ECONNREFUSED
117No name servers could be contacted.
118.TP 19
119.B ARES_ENOMEM
120Memory was exhausted.
121.TP 19
122.B ARES_ECANCELLED
123The query was cancelled.
124.TP 19
125.B ARES_EDESTRUCTION
126The name service channel
127.I channel
128is being destroyed; the query will not be completed.
129.PP
130The callback argument
131.I timeouts
132reports how many times a query timed out during the execution of the
133given request.
134.PP
135If a query completed successfully, the callback argument
136.I abuf
137points to a result buffer of length
138.IR alen .
139If the query did not complete successfully,
140.I abuf
141will usually be NULL and
142.I alen
143will usually be 0, but in some cases an unsuccessful query result may
144be placed in
145.IR abuf .
146.SH SEE ALSO
147.BR ares_process (3)
148.SH AUTHOR
149Greg Hudson, MIT Information Systems
150.br
151Copyright 1998 by the Massachusetts Institute of Technology.