-
Notifications
You must be signed in to change notification settings - Fork 30.9k
/
Copy pathares_dns_record.3
455 lines (410 loc) Β· 13.6 KB
/
ares_dns_record.3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
.\" Copyright (C) 2023 The c-ares project and its contributors.
.\" SPDX-License-Identifier: MIT
.\"
.TH ARES_DNS_RECORD 3 "12 November 2023"
.SH NAME
ares_dns_class_t, ares_dns_flags_t, ares_dns_opcode_t, ares_dns_parse,
ares_dns_rcode_t, ares_dns_record_create, ares_dns_record_destroy,
ares_dns_record_get_flags, ares_dns_record_get_id, ares_dns_record_get_opcode,
ares_dns_record_get_rcode, ares_dns_record_query_add, ares_dns_record_query_cnt,
ares_dns_record_query_get, ares_dns_rec_type_t, ares_dns_write \-
DNS Record parsing, writing, creating and destroying functions.
.SH SYNOPSIS
.nf
#include <ares.h>
void ares_dns_record_destroy(ares_dns_record_t *dnsrec);
ares_status_t ares_dns_parse(const unsigned char *buf,
size_t buf_len, unsigned int flags,
ares_dns_record_t **dnsrec);
ares_status_t ares_dns_write(const ares_dns_record_t *dnsrec,
unsigned char **buf, size_t *buf_len);
ares_status_t ares_dns_record_create(ares_dns_record_t **dnsrec,
unsigned short id,
unsigned short flags,
ares_dns_opcode_t opcode,
ares_dns_rcode_t rcode);
ares_dns_record_t *ares_dns_record_duplicate(const ares_dns_record_t *dnsrec);
unsigned short ares_dns_record_get_id(const ares_dns_record_t *dnsrec);
ares_bool_t ares_dns_record_set_id(ares_dns_record_t *dnsrec,
unsigned short id);
unsigned short ares_dns_record_get_flags(const ares_dns_record_t *dnsrec);
ares_dns_opcode_t ares_dns_record_get_opcode(const ares_dns_record_t *dnsrec);
ares_dns_rcode_t ares_dns_record_get_rcode(const ares_dns_record_t *dnsrec);
ares_status_t ares_dns_record_query_add(ares_dns_record_t *dnsrec,
const char *name,
ares_dns_rec_type_t qtype,
ares_dns_class_t qclass);
ares_status_t ares_dns_record_query_set_name(ares_dns_record_t *dnsrec,
size_t idx,
const char *name);
ares_status_t ares_dns_record_query_set_type(ares_dns_record_t *dnsrec,
size_t idx,
ares_dns_rec_type_t qtype);
size_t ares_dns_record_query_cnt(const ares_dns_record_t *dnsrec);
ares_status_t ares_dns_record_query_get(const ares_dns_record_t *dnsrec,
size_t idx, const char **name,
ares_dns_rec_type_t *qtype,
ares_dns_class_t *qclass);
.fi
.SH ENUMERATIONS
.B ares_dns_rec_type_t -
DNS Record types handled by c-ares. Some record types may only be valid
on requests, and some may only be valid on responses:
.RS 4
.B ARES_REC_TYPE_A
- Host address
.br
.B ARES_REC_TYPE_NS
- Authoritative server
.br
.B ARES_REC_TYPE_CNAME
- Canonical name
.br
.B ARES_REC_TYPE_SOA
- Start of authority zone
.br
.B ARES_REC_TYPE_PTR
- Domain name pointer
.br
.B ARES_REC_TYPE_HINFO
- Host information
.br
.B ARES_REC_TYPE_MX
- Mail routing information
.br
.B ARES_REC_TYPE_TXT
- Text strings
.br
.B ARES_REC_TYPE_SIG
- RFC 2535. RFC 2931. SIG Record
.br
.B ARES_REC_TYPE_AAAA
- RFC 3596. Ip6 Address
.br
.B ARES_REC_TYPE_SRV
- RFC 2782. Server Selection
.br
.B ARES_REC_TYPE_NAPTR
- RFC 3403. Naming Authority Pointer
.br
.B ARES_REC_TYPE_OPT
- RFC 6891. EDNS0 option (meta-RR). Pseudo Record.
.br
.B ARES_REC_TYPE_TLSA
- RFC 6698. DNS-Based Authentication of Named Entities (DANE) Transport Layer Security (TLS) Protocol: TLSA
.br
.B ARES_REC_TYPE_SVCB
- RFC 9460. General Purpose Service Binding
.br
.B ARES_REC_TYPE_HTTPS -
- RFC 9460. Service Binding type for use with HTTPS
.br
.B ARES_REC_TYPE_ANY
- Wildcard match. Not response RR
.br
.B ARES_REC_TYPE_URI
- RFC 7553. Uniform Resource Identifier
.br
.B ARES_REC_TYPE_CAA
- RFC 6844. Certification Authority Authorization
.br
.B ARES_REC_TYPE_RAW_RR
- Used as an indicator that the RR record is not parsed, but provided in wire
format
.br
.RE
.B ares_dns_class_t -
DNS Classes for requests and responses:
.RS 4
.B ARES_CLASS_IN
- Internet
.br
.B ARES_CLASS_CHAOS
- CHAOS
.br
.B ARES_CLASS_HESOID
- Hesoid [Dyer 87]
.br
.B ARES_CLASS_NONE
- RFC 2136
.br
.B ARES_CLASS_ANY
- Any class (requests only)
.br
.RE
.B ares_dns_opcode_t -
DNS Header Opcodes:
.RS 4
.B ARES_OPCODE_QUERY
- Standard query
.br
.B ARES_OPCODE_IQUERY
- Inverse query. Obsolete
.br
.B ARES_OPCODE_STATUS
- Name server status query
.br
.B ARES_OPCODE_NOTIFY
- Zone change notification (RFC 1996)
.br
.B ARES_OPCODE_UPDATE
- Zone update message (RFC 2136)
.br
.RE
.B ares_dns_flags_t -
DNS Header Flags:
.RS 4
.B ARES_FLAG_QR
- QR. If set, is a response
.br
.B ARES_FLAG_AA
- Authoritative Answer. If set, is authoritative
.br
.B ARES_FLAG_TC
- Truncation. If set, is truncated response
.br
.B ARES_FLAG_RD
- Recursion Desired. If set, recursion is desired
.br
.B ARES_FLAG_RA
- Recursion Available. If set, server supports recursion
.br
.B ARES_FLAG_AD
- RFC 2065. Authentic Data bit indicates in a response that the data included
has been verified by the server providing it
.br
.B ARES_FLAG_CD
- RFC 2065. Checking Disabled bit indicates in a query that non-verified data
is acceptable to the resolver sending the query
.br
.RE
.B ares_dns_rcode_t -
DNS Response codes from server:
.RS 4
.B ARES_RCODE_NOERROR
- Success
.br
.B ARES_RCODE_FORMERR
- Format error. The name server was unable to interpret the query
.br
.B ARES_RCODE_SERVFAIL
- Server Failure. The name server was unable to process this query due to a
problem with the nameserver
.br
.B ARES_RCODE_NXDOMAIN
- Name Error. Meaningful only for responses from an authoritative name server,
this code signifies that the domain name referenced in the query does not exist.
.br
.B ARES_RCODE_NOTIMP
- Not implemented. The name server does not support the requested kind of query
.br
.B ARES_RCODE_REFUSED
- Refused. The name server refuses to perform the specified operation for policy
reasons.
.br
.B ARES_RCODE_YXDOMAIN
- RFC 2136. Some name that ought not to exist, does exist
.br
.B ARES_RCODE_YXRRSET
- RFC 2136. Some RRset that ought to not exist, does exist
.br
.B ARES_RCODE_NXRRSET
- RFC 2136. Some RRset that ought to exist, does not exist
.br
.B ARES_RCODE_NOTAUTH
- RFC 2136. The server is not authoritative for the zone named in the Zone section.
.br
.B ARES_RCODE_NOTZONE
- RFC 2136. A name used in the Prerequisite or Update Section is not within the
zone denoted by the Zone Section.
.br
.B ARES_RCODE_DSOTYPEI
- RFC 8409. DSO-TYPE Not implemented
.br
.B ARES_RCODE_BADSIG
- RFC 8945. TSIG Signature Failure
.br
.B ARES_RCODE_BADKEY
- RFC 8945. Key not recognized
.br
.B ARES_RCODE_BADTIME
- RFC 8945. Signature out of time window
.br
.B ARES_RCODE_BADMODE
- RFC 2930. Bad TKEY Mode
.br
.B ARES_RCODE_BADNAME
- RFC 2930. Duplicate Key Name
.br
.B ARES_RCODE_BADALG
- RFC 2930. Algorithm not supported
.br
.B ARES_RCODE_BADTRUNC
- RFC 8945. Bad Truncation
.br
.B ARES_RCODE_BADCOOKIE
- RFC 7973. Bad/missing Server Cookie
.br
.RE
.B ares_dns_parse_flags_t -
Flags for altering \fIares_dns_parse(3)\fP behaviour:
.RS 4
.B ARES_DNS_PARSE_AN_BASE_RAW
- Parse Answer Section from RFC 1035 that allow name compression as RAW RR type
.br
.B ARES_DNS_PARSE_NS_BASE_RAW
- Parse Authority Section from RFC 1035 that allow name compression as RAW RR type
.br
.B ARES_DNS_PARSE_AR_BASE_RAW
- Parse Additional Section from RFC 1035 that allow name compression as RAW RR type
.br
.B ARES_DNS_PARSE_AN_EXT_RAW
- Parse Answer Section from later RFCs (no name compression) as RAW RR type
.br
.B ARES_DNS_PARSE_NS_EXT_RAW
- Parse Authority Section from later RFCs (no name compression) as RAW RR type
.br
.B ARES_DNS_PARSE_AR_EXT_RAW
- Parse Additional Section from later RFCs (no name compression) as RAW RR type
.br
.RE
.SH DESCRIPTION
The \fIares_dns_record_destroy(3)\fP function destroys the memory associated
with the dns record created by either \fIares_dns_record_create(3)\fP or
\fIares_dns_parse(3)\fP passed in via
.IR dnsrec .
The \fIares_dns_parse(3)\fP function parses the buffer provided in
.IR buf
with length provided in
.IR buf_len.
The
.IR flags
parameter can be one or more \fIares_dns_parse_flags_t\fP, or zero if no
flags are needed. The resulting dns record data structure is stored into the
variable pointed to by
.IR dnsrec
and must be destroyed using \fIares_dns_record_destroy(3)\fP.
The \fIares_dns_write(3)\fP function takes a populated DNS record structure in
.IR dnsrec
and writes a wire-format DNS message into the variable pointed to by
.IR buf
and writes the length of the buffer into the variable pointed to by
.IR buf_len.
The buffer must be destroyed using \fIares_free_string(3)\fP.
The \fIares_dns_record_create(3)\fP function creates an empty DNS record structure
in the variable pointed to by
.IR dnsrec.
The
.IR id
parameter is the DNS message id, however if passing to \fIares_send(3)\fP this
identifier will be overwritten, so should typically be 0. The
.IR flags
parameter is one or more \fIares_dns_flags_t\fP. The opcode is passed in the
.IR opcode
parameter and should typically be \fIARES_OPCODE_QUERY\fP. The response code
is meant mostly for responses and is passed in the
.IR rcode
parameter and is typically \fPARES_RCODE_NOERROR\fP.
The \fIares_dns_record_duplicate(3)\fP function duplicates an existing DNS
record structure. This may be useful if needing to save a result as retrieved
from \fIares_send_dnsrec(3)\fP or \fIares_search_dnsrec(3)\fP. The structure
to be duplicated is passed in the
.IR dnsrec
parameter, and the duplicated copy is returned, or NULL on error such as
out of memory.
The \fIares_dns_record_get_id(3)\fP function is used to retrieve the DNS
message id from the DNS record provided in the
.IR dnsrec
parameter.
The \fIares_dns_record_set_id(3)\fP function is used to set the DNS
message id in the
.IR id
parameter from the DNS record provided in the
.IR dnsrec
parameter. This id will be overwritten when passing the record to c-ares,
so mostly exists for external purposes.
The \fIares_dns_record_get_flags(3)\fP function is used to retrieve the DNS
message flags from the DNS record provided in the
.IR dnsrec
parameter.
The \fIares_dns_record_get_opcode(3)\fP function is used to retrieve the DNS
message flags from the DNS record provided in the
.IR dnsrec
parameter.
The \fIares_dns_record_get_rcode(3)\fP function is used to retrieve the DNS
message response code from the DNS record provided in the
.IR dnsrec
parameter.
The \fIares_dns_record_query_add(3)\fP function is used to add a question to
the DNS record provided in the
.IR dnsrec
parameter. The domain name specified for the question is provided in the
.IR name
parameter, along with the question type in the
.IR qtype
parameter and the question class (typically \fIARES_CLASS_IN\fP) in the
.IR qclass
parameter.
The \fIares_dns_record_query_set_name(3)\fP function is used to modify the
question name in the DNS record provided in the
.IR dnsrec
parameter. The index of the query, which must be less than
\fIares_dns_record_query_cnt(3)\fP, is provided in the
.IR idx
parameter. The new domain name is provided in the
.IR name
parameter. Care should be taken as this will cause invalidation of any
\fIname\fP pointer retrieved from \fIares_dns_Record_query_get(3)\fP. This
function is useful if sending multiple similar queries without re-creating
the entire DNS query.
The \fIares_dns_record_query_set_type(3)\fP function is used to modify the
question type in the DNS record provided in the
.IR dnsrec
parameter. The index of the query, which must be less than
\fIares_dns_record_query_cnt(3)\fP, is provided in the
.IR idx
parameter. The new query type is provided in the
.IR qtype
parameter.
The \fIares_dns_record_query_cnt(3)\fP function is used to retrieve the number
of DNS questions in the DNS record provided in the
.IR dnsrec
parameter.
The \fIares_dns_record_query_get(3)\fP function is used to retrieve the details
of a single DNS question in the provided
.IR dnsrec
parameter. The index provided in the
.IR idx
parameter must be less than the value returned from \fIares_dns_record_query_cnt(3)\fP.
The DNS question name will be returned in the variable pointed to by the
.IR name
parameter, this may be provided as NULL if the name is not needed. This pointer
will be invalided by any call to \fIares_dns_record_query_set_name(3)\fP.
The DNS question type will be returned in the variable pointed to by the
.IR qtype
parameter, this may be provided as NULL if the type is not needed.
The DNS question class will be returned in the variable pointed to by the
.IR qclass
parameter, this may be provided as NULL if the class is not needed.
.SH RETURN VALUES
\fIares_dns_parse(3)\fP, \fIares_dns_write(3)\fP, \fIares_dns_record_create(3)\fP,
\fIares_dns_record_query_add(3)\fP, and \fIares_dns_record_query_get(3)\fP all
return an \fIares_status_t\fP error code.
.B ARES_SUCCESS
is returned on success,
.B ARES_ENOMEM
is returned on out of memory,
.B ARES_EFORMERR
is returned on misuse.
\fIares_dns_record_get_id(3)\fP, \fIares_dns_record_set_id(3)\fP,
\fIares_dns_record_get_flags(3)\fP, \fIares_dns_record_get_opcode(3)\fP,
\fIares_dns_record_get_rcode(3)\fP, and \fIares_dns_record_query_cnt(3)\fP
all returned their prescribed datatype values and in general can't fail except
for misuse cases, in which a 0 may be returned, however 0 can also be a valid
return value for most of these functions.
.SH AVAILABILITY
These functions were first introduced in c-ares version 1.22.0.
.SH SEE ALSO
.BR ares_dns_mapping (3),
.BR ares_dns_rr (3),
.BR ares_free_string (3)