This repository has been archived by the owner on Mar 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathares_parse_message.3
162 lines (162 loc) · 4.46 KB
/
ares_parse_message.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
.\" $Id: ares_parse_message.3,v 1.2 2003-08-05 13:12:58 mwhitson Exp $
.\"
.\" Copyright 2002 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_PARSE_MESSAGE 3 "26 August 2002"
.SH NAME
ares_parse_message \- Parse a DNS message into a struct ares_dns_message
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B
int ares_parse_message(const unsigned char *\fIabuf\fB, int \fIalen\fB,
.B struct ares_dns_message **\fImessage\fB);
.fi
.SH DESCRIPTION
The
.B ares_parse_message
function parses a DNS message into a
.BR "struct ares_dns_message" .
Resource record data is returned as an unparsed sequence of bytes;
however, if a record of well-known type contains compressed domain
names, the domain names will be uncompressed. The parameters
.I abuf
and
.I alen
give the contents of the message. The result is stored in allocated
memory and a pointer to it stored into the variable pointed to by
.IR message .
It is the caller's responsibility to free the resulting host structure
using
.BR ares_free_dns_message (3)
when it is no longer needed.
.SH RETURN VALUES
.B ares_parse_message can return any of the following values:
.TP 15
.B ARES_SUCCESS
The response was successfully parsed.
.TP 15
.B ARES_EBADRESP
The response was malformatted.
.TP 15
.B ARES_ENOMEM
Memory was exhausted.
.PP
The
.B ares_dns_message
structure contains the following fields:
.TP 15
.B int \fIid\fP;
The identifier of this message.
.TP 15
.B int \fIis_response\fP;
1 if this message is a response, 0 if it is a request.
.TP 15
.B int \fIopcode\fP;
The opcode of this message.
.B ares.h
defines values of the form
.B ARES_DNS_OPCODE_QUERY
corresponding to the possible opcode values.
.TP 15
.B int \fIauthoritative_answer\fP;
1 if this message is an authoritative answer, 0 if not. Only
meaningful for responses.
.TP 15
.B int \fItruncated\fP;
1 if this message was truncated (because it did not fit in a UDP
packet), 0 if not. Only meaningful for responses.
.TP 15
.B int \fIrecursion_desired\fP;
1 if recursion is requested for this query, 0 if not. Only meaningful
for requests.
.TP 15
.B int \fIrecursion_available\fP;
1 if recursion is allowed by this server, 0 if not. Only meaningful
for responses.
.TP 15
.B int \fIzero\fP;
Reserved bits in the message format, generally set to 0.
.TP 15
.B int \fIresponse_code\fP;
The status of this response.
.TP 15
.B int \fIqcount\fP;
The number of questions in this message.
.TP 15
.B struct ares_dns_question *\fIquestions\fP;
This message's queries.
.TP 15
.B struct ares_dns_section \fIanswers\fP;
This message's answers.
.TP 15
.B struct ares_dns_section \fIauthority\fP;
This message's authority records.
.TP 15
.B struct ares_dns_section \fIadditional\fP;
This message's additional records.
.PP
The
.B ares_dns_question
structure contains the following fields:
.TP 15
.B char *\fIname\fP;
The name this question is asking about.
.TP 15
.B int \fItype\fP;
The DNS type of the record set this question is asking about.
.TP 15
.B int \fIdnsclass\fP;
The DNS class of the record set this question is asking about.
.PP
The
.B ares_dns_section
structure contains the following fields:
.TP 15
.B int \fIcount\fP;
The number of resource records in this section.
.TP 15
.B struct ares_dns_rr *\fIrecords\fP;
This section's resource records.
.PP
The
.B ares_dns_rr
structure contains the following fields:
.TP 15
.B char *\fIname\fP;
The name of this resource record.
.TP 15
.B int \fItype\fP;
The DNS type of this resource record.
.TP 15
.B int \fIdnsclass\fP;
The DNS class of this resource record.
.TP 15
.B int \fIttl\fP;
The time-to-live of this resource record, in seconds.
.TP 15
.B int \fIlen\fP;
The length of this resource record's data.
.TP 15
.B unsigned char *\fIdata\fP;
This resource record's data.
.SH SEE ALSO
.BR ares_expand_name (3),
.BR ares_free_dns_message (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 2002 by the Massachusetts Institute of Technology.