jpayne@68
|
1 .\"
|
jpayne@68
|
2 .\" Copyright 1998 by the Massachusetts Institute of Technology.
|
jpayne@68
|
3 .\" SPDX-License-Identifier: MIT
|
jpayne@68
|
4 .\"
|
jpayne@68
|
5 .TH ARES_SEND 3 "25 July 1998"
|
jpayne@68
|
6 .SH NAME
|
jpayne@68
|
7 ares_send \- Initiate a DNS query
|
jpayne@68
|
8 .SH SYNOPSIS
|
jpayne@68
|
9 .nf
|
jpayne@68
|
10 #include <ares.h>
|
jpayne@68
|
11
|
jpayne@68
|
12 typedef void (*ares_callback_dnsrec)(void *arg, ares_status_t status,
|
jpayne@68
|
13 size_t timeouts,
|
jpayne@68
|
14 const ares_dns_record_t *dnsrec);
|
jpayne@68
|
15
|
jpayne@68
|
16 ares_status_t ares_send_dnsrec(ares_channel_t *channel,
|
jpayne@68
|
17 const ares_dns_record_t *dnsrec,
|
jpayne@68
|
18 ares_callback_dnsrec callback,
|
jpayne@68
|
19 void *arg, unsigned short *qid);
|
jpayne@68
|
20
|
jpayne@68
|
21 typedef void (*ares_callback)(void *arg, int status,
|
jpayne@68
|
22 int timeouts, unsigned char *abuf,
|
jpayne@68
|
23 int alen);
|
jpayne@68
|
24
|
jpayne@68
|
25 void ares_send(ares_channel_t *channel, const unsigned char *qbuf,
|
jpayne@68
|
26 int qlen, ares_callback callback, void *arg);
|
jpayne@68
|
27
|
jpayne@68
|
28 .fi
|
jpayne@68
|
29 .SH DESCRIPTION
|
jpayne@68
|
30 The \fIares_send_dnsrec(3)\fP function initiates a DNS query formatted using the
|
jpayne@68
|
31 \fIares_dns_record_t *\fP data structure created via
|
jpayne@68
|
32 \fIares_dns_record_create(3)\fP in the
|
jpayne@68
|
33 .IR dnsrec
|
jpayne@68
|
34 parameter. The supplied callback in the
|
jpayne@68
|
35 .IR callback
|
jpayne@68
|
36 parameter also returns the response using a
|
jpayne@68
|
37 \fIares_dns_record_t *\fP data structure.
|
jpayne@68
|
38
|
jpayne@68
|
39 The \fIares_send(3)\fP function similarly initiates a DNS query, but instead uses
|
jpayne@68
|
40 raw binary buffers with fully formatted DNS messages passed in the request via the
|
jpayne@68
|
41 .IR qbuf
|
jpayne@68
|
42 and
|
jpayne@68
|
43 .IR qlen
|
jpayne@68
|
44 parameters. The supplied callback in the
|
jpayne@68
|
45 .IR callback
|
jpayne@68
|
46 parameter also returns the raw binary DNS response in the
|
jpayne@68
|
47 .IR abuf
|
jpayne@68
|
48 and
|
jpayne@68
|
49 .IR alen
|
jpayne@68
|
50 parameters. This method should be considered deprecated in favor of
|
jpayne@68
|
51 \fIares_send_dnsrec(3)\fP.
|
jpayne@68
|
52
|
jpayne@68
|
53 Both functions take an initialized ares channel identified by
|
jpayne@68
|
54 .IR channel .
|
jpayne@68
|
55
|
jpayne@68
|
56 The \fIares_send_dnsrec(3)\fP also can be supplied an optional output parameter of
|
jpayne@68
|
57 .IR qid
|
jpayne@68
|
58 to populate the query id as it was placed on the wire.
|
jpayne@68
|
59
|
jpayne@68
|
60 The \fIares_send_dnsrec(3)\fP function returns an \fIares_status_t\fP response
|
jpayne@68
|
61 code. This may be useful to know that the query was enqueued properly. The
|
jpayne@68
|
62 response code does not reflect the result of the query, just the result of the
|
jpayne@68
|
63 enqueuing of the query.
|
jpayne@68
|
64
|
jpayne@68
|
65 Completion or failure of the query may happen immediately (even before the
|
jpayne@68
|
66 function returning), or may happen later as network events are processed.
|
jpayne@68
|
67
|
jpayne@68
|
68 When the associated callback is called, it is called with a channel lock so care
|
jpayne@68
|
69 must be taken to ensure any processing is minimal to prevent DNS channel stalls.
|
jpayne@68
|
70
|
jpayne@68
|
71 The callback may be triggered from a different thread than the one which
|
jpayne@68
|
72 called \fIares_send_dnsrec(3)\fP or \fIares_send(3)\fP.
|
jpayne@68
|
73
|
jpayne@68
|
74 For integrators running their own event loops and not using \fBARES_OPT_EVENT_THREAD\fP,
|
jpayne@68
|
75 care needs to be taken to ensure any file descriptor lists are updated immediately
|
jpayne@68
|
76 within the eventloop when notified.
|
jpayne@68
|
77
|
jpayne@68
|
78 The callback argument
|
jpayne@68
|
79 .IR arg
|
jpayne@68
|
80 is copied from the \fIares_send_dnsrec(3)\fP or \fIares_send(3)\fP
|
jpayne@68
|
81 .IR arg
|
jpayne@68
|
82 parameter.
|
jpayne@68
|
83
|
jpayne@68
|
84 The callback argument
|
jpayne@68
|
85 .I status
|
jpayne@68
|
86 indicates whether the query succeeded and, if not, how it failed. It
|
jpayne@68
|
87 may have any of the following values:
|
jpayne@68
|
88 .TP 19
|
jpayne@68
|
89 .B ARES_SUCCESS
|
jpayne@68
|
90 The query completed.
|
jpayne@68
|
91 .TP 19
|
jpayne@68
|
92 .B ARES_EBADQUERY
|
jpayne@68
|
93 The query buffer was poorly formed (was not long enough for a DNS
|
jpayne@68
|
94 header or was too long for TCP transmission).
|
jpayne@68
|
95 .TP 19
|
jpayne@68
|
96 .B ARES_ETIMEOUT
|
jpayne@68
|
97 No name servers responded within the timeout period.
|
jpayne@68
|
98 .TP 19
|
jpayne@68
|
99 .B ARES_ECONNREFUSED
|
jpayne@68
|
100 No name servers could be contacted.
|
jpayne@68
|
101 .TP 19
|
jpayne@68
|
102 .B ARES_ENOMEM
|
jpayne@68
|
103 Memory was exhausted.
|
jpayne@68
|
104 .TP 19
|
jpayne@68
|
105 .B ARES_ECANCELLED
|
jpayne@68
|
106 The query was cancelled.
|
jpayne@68
|
107 .TP 19
|
jpayne@68
|
108 .B ARES_EDESTRUCTION
|
jpayne@68
|
109 The name service channel
|
jpayne@68
|
110 .I channel
|
jpayne@68
|
111 is being destroyed; the query will not be completed.
|
jpayne@68
|
112 .TP 19
|
jpayne@68
|
113 .B ARES_ENOSERVER
|
jpayne@68
|
114 The query will not be completed because no DNS servers were configured on the
|
jpayne@68
|
115 channel.
|
jpayne@68
|
116 .TP 19
|
jpayne@68
|
117 .B ARES_EBADQUERY
|
jpayne@68
|
118 Misformatted DNS query.
|
jpayne@68
|
119 .PP
|
jpayne@68
|
120
|
jpayne@68
|
121 The callback argument
|
jpayne@68
|
122 .I timeouts
|
jpayne@68
|
123 reports how many times a query timed out during the execution of the
|
jpayne@68
|
124 given request.
|
jpayne@68
|
125
|
jpayne@68
|
126 If the query completed, the callback argument
|
jpayne@68
|
127 .IR dnsrec
|
jpayne@68
|
128 for \fIares_send_dnsrec(3)\fP or
|
jpayne@68
|
129 .IR abuf
|
jpayne@68
|
130 and
|
jpayne@68
|
131 .IR alen
|
jpayne@68
|
132 for \fIares_send(3)\fP will be non-NULL.
|
jpayne@68
|
133
|
jpayne@68
|
134 Unless the flag
|
jpayne@68
|
135 .B ARES_FLAG_NOCHECKRESP
|
jpayne@68
|
136 was set at channel initialization time, \fIares_send_dnsrec(3)\fP and
|
jpayne@68
|
137 \fIares_send(3)\fP will normally ignore responses whose questions do not match
|
jpayne@68
|
138 the supplied questions, as well as responses with reply codes of
|
jpayne@68
|
139 .BR SERVFAIL ,
|
jpayne@68
|
140 .BR NOTIMP ,
|
jpayne@68
|
141 and
|
jpayne@68
|
142 .BR REFUSED .
|
jpayne@68
|
143 Unlike other query functions in the ares library, however,
|
jpayne@68
|
144 \fIares_send_dnsrec(3)\fP and \fIares_send(3)\fP do not inspect the header of
|
jpayne@68
|
145 the reply packet to determine the error status, so a callback status of
|
jpayne@68
|
146 .B ARES_SUCCESS
|
jpayne@68
|
147 does not reflect as much about the response as for other query functions.
|
jpayne@68
|
148
|
jpayne@68
|
149 .SH AVAILABILITY
|
jpayne@68
|
150 \fBares_send_dnsrec(3)\fP was introduced in c-ares 1.28.0.
|
jpayne@68
|
151
|
jpayne@68
|
152 .SH SEE ALSO
|
jpayne@68
|
153 .BR ares_dns_record_create (3),
|
jpayne@68
|
154 .BR ares_process (3),
|
jpayne@68
|
155 .BR ares_search (3),
|
jpayne@68
|
156 .BR ares_dns_record (3)
|