1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.directory.server.dns.messages;
22
23
24 import java.util.List;
25
26 import org.apache.commons.lang3.builder.EqualsBuilder;
27 import org.apache.commons.lang3.builder.HashCodeBuilder;
28 import org.apache.commons.lang3.builder.ToStringBuilder;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 public class DnsMessage
51 {
52
53
54
55
56
57
58 private int transactionId;
59 private MessageType messageType;
60 private OpCode opCode;
61 private boolean authoritativeAnswer;
62 private boolean truncated;
63 private boolean recursionDesired;
64 private boolean recursionAvailable;
65 private boolean reserved;
66 private boolean acceptNonAuthenticatedData;
67
68 private ResponseCode responseCode;
69
70 private List<QuestionRecord> questionRecords;
71 private List<ResourceRecord> answerRecords;
72 private List<ResourceRecord> authorityRecords;
73 private List<ResourceRecord> additionalRecords;
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94 public DnsMessage( int transactionId, MessageType messageType, OpCode opCode, boolean authoritativeAnswer,
95 boolean truncated, boolean recursionDesired, boolean recursionAvailable, boolean reserved,
96 boolean acceptNonAuthenticatedData, ResponseCode responseCode, List<QuestionRecord> question,
97 List<ResourceRecord> answer, List<ResourceRecord> authority, List<ResourceRecord> additional )
98 {
99 this.transactionId = transactionId;
100 this.messageType = messageType;
101 this.opCode = opCode;
102 this.authoritativeAnswer = authoritativeAnswer;
103 this.truncated = truncated;
104 this.recursionDesired = recursionDesired;
105 this.recursionAvailable = recursionAvailable;
106 this.reserved = reserved;
107 this.acceptNonAuthenticatedData = acceptNonAuthenticatedData;
108 this.responseCode = responseCode;
109 this.questionRecords = question;
110 this.answerRecords = answer;
111 this.authorityRecords = authority;
112 this.additionalRecords = additional;
113 }
114
115
116
117
118
119 public boolean isAcceptNonAuthenticatedData()
120 {
121 return acceptNonAuthenticatedData;
122 }
123
124
125
126
127
128 public List<ResourceRecord> getAdditionalRecords()
129 {
130 return additionalRecords;
131 }
132
133
134
135
136
137 public List<ResourceRecord> getAnswerRecords()
138 {
139 return answerRecords;
140 }
141
142
143
144
145
146 public boolean isAuthoritativeAnswer()
147 {
148 return authoritativeAnswer;
149 }
150
151
152
153
154
155 public List<ResourceRecord> getAuthorityRecords()
156 {
157 return authorityRecords;
158 }
159
160
161
162
163
164 public MessageType getMessageType()
165 {
166 return messageType;
167 }
168
169
170
171
172
173 public OpCode getOpCode()
174 {
175 return opCode;
176 }
177
178
179
180
181
182 public List<QuestionRecord> getQuestionRecords()
183 {
184 return questionRecords;
185 }
186
187
188
189
190
191 public boolean isRecursionAvailable()
192 {
193 return recursionAvailable;
194 }
195
196
197
198
199
200 public boolean isRecursionDesired()
201 {
202 return recursionDesired;
203 }
204
205
206
207
208
209 public boolean isReserved()
210 {
211 return reserved;
212 }
213
214
215
216
217
218 public ResponseCode getResponseCode()
219 {
220 return responseCode;
221 }
222
223
224
225
226
227 public int getTransactionId()
228 {
229 return transactionId;
230 }
231
232
233
234
235
236 public boolean isTruncated()
237 {
238 return truncated;
239 }
240
241
242
243
244
245 @Override
246 public boolean equals( Object object )
247 {
248 if ( object == this )
249 {
250 return true;
251 }
252 if ( !( object instanceof DnsMessage ) )
253 {
254 return false;
255 }
256 DnsMessage/../../../../../org/apache/directory/server/dns/messages/DnsMessage.html#DnsMessage">DnsMessage rhs = ( DnsMessage ) object;
257 return new EqualsBuilder().append( this.transactionId, rhs.transactionId ).append( this.answerRecords,
258 rhs.answerRecords ).append( this.opCode, rhs.opCode ).append( this.recursionAvailable,
259 rhs.recursionAvailable ).append( this.messageType, rhs.messageType ).append( this.additionalRecords,
260 rhs.additionalRecords ).append( this.truncated, rhs.truncated ).append( this.recursionDesired,
261 rhs.recursionDesired ).append( this.responseCode, rhs.responseCode ).append( this.authorityRecords,
262 rhs.authorityRecords ).append( this.authoritativeAnswer, rhs.authoritativeAnswer ).append( this.reserved,
263 rhs.reserved ).append( this.acceptNonAuthenticatedData, rhs.acceptNonAuthenticatedData ).append(
264 this.questionRecords, rhs.questionRecords ).isEquals();
265 }
266
267
268
269
270
271
272 @Override
273 public int hashCode()
274 {
275 return new HashCodeBuilder( -1805208585, -276770303 ).append( this.transactionId ).append( this.answerRecords )
276 .append( this.opCode ).append( this.recursionAvailable ).append( this.messageType ).append(
277 this.additionalRecords ).append( this.truncated ).append( this.recursionDesired ).append(
278 this.responseCode ).append( this.authorityRecords ).append( this.authoritativeAnswer ).append(
279 this.reserved ).append( this.acceptNonAuthenticatedData ).append( this.questionRecords ).toHashCode();
280 }
281
282
283
284
285
286 @Override
287 public String toString()
288 {
289 return new ToStringBuilder( this ).appendSuper( super.toString() ).append( "transactionId", this.transactionId )
290 .append( "opCode", this.opCode ).append( "truncated", this.truncated ).append( "messageType",
291 this.messageType ).append( "recursionDesired", this.recursionDesired ).append( "additionalRecords",
292 this.additionalRecords ).append( "responseCode", this.responseCode ).append( "authorityRecords",
293 this.authorityRecords ).append( "acceptNonAuthenticatedData", this.acceptNonAuthenticatedData ).append(
294 "recursionAvailable", this.recursionAvailable ).append( "answerRecords", this.answerRecords ).append(
295 "questionRecords", this.questionRecords ).append( "authoritativeAnswer", this.authoritativeAnswer )
296 .append( "reserved", this.reserved ).toString();
297 }
298 }