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.lang.builder.EqualsBuilder;
27 import org.apache.commons.lang.builder.HashCodeBuilder;
28 import org.apache.commons.lang.builder.ToStringBuilder;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 public class DnsMessage
52 {
53
54
55
56
57
58
59 private int transactionId;
60 private MessageType messageType;
61 private OpCode opCode;
62 private boolean authoritativeAnswer;
63 private boolean truncated;
64 private boolean recursionDesired;
65 private boolean recursionAvailable;
66 private boolean reserved;
67 private boolean acceptNonAuthenticatedData;
68
69 private ResponseCode responseCode;
70
71 private List<QuestionRecord> questionRecords;
72 private List<ResourceRecord> answerRecords;
73 private List<ResourceRecord> authorityRecords;
74 private List<ResourceRecord> additionalRecords;
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95 public DnsMessage( int transactionId, MessageType messageType, OpCode opCode, boolean authoritativeAnswer,
96 boolean truncated, boolean recursionDesired, boolean recursionAvailable, boolean reserved,
97 boolean acceptNonAuthenticatedData, ResponseCode responseCode, List<QuestionRecord> question,
98 List<ResourceRecord> answer, List<ResourceRecord> authority, List<ResourceRecord> additional )
99 {
100 this.transactionId = transactionId;
101 this.messageType = messageType;
102 this.opCode = opCode;
103 this.authoritativeAnswer = authoritativeAnswer;
104 this.truncated = truncated;
105 this.recursionDesired = recursionDesired;
106 this.recursionAvailable = recursionAvailable;
107 this.reserved = reserved;
108 this.acceptNonAuthenticatedData = acceptNonAuthenticatedData;
109 this.responseCode = responseCode;
110 this.questionRecords = question;
111 this.answerRecords = answer;
112 this.authorityRecords = authority;
113 this.additionalRecords = additional;
114 }
115
116
117
118
119
120 public boolean isAcceptNonAuthenticatedData()
121 {
122 return acceptNonAuthenticatedData;
123 }
124
125
126
127
128
129 public List<ResourceRecord> getAdditionalRecords()
130 {
131 return additionalRecords;
132 }
133
134
135
136
137
138 public List<ResourceRecord> getAnswerRecords()
139 {
140 return answerRecords;
141 }
142
143
144
145
146
147 public boolean isAuthoritativeAnswer()
148 {
149 return authoritativeAnswer;
150 }
151
152
153
154
155
156 public List<ResourceRecord> getAuthorityRecords()
157 {
158 return authorityRecords;
159 }
160
161
162
163
164
165 public MessageType getMessageType()
166 {
167 return messageType;
168 }
169
170
171
172
173
174 public OpCode getOpCode()
175 {
176 return opCode;
177 }
178
179
180
181
182
183 public List<QuestionRecord> getQuestionRecords()
184 {
185 return questionRecords;
186 }
187
188
189
190
191
192 public boolean isRecursionAvailable()
193 {
194 return recursionAvailable;
195 }
196
197
198
199
200
201 public boolean isRecursionDesired()
202 {
203 return recursionDesired;
204 }
205
206
207
208
209
210 public boolean isReserved()
211 {
212 return reserved;
213 }
214
215
216
217
218
219 public ResponseCode getResponseCode()
220 {
221 return responseCode;
222 }
223
224
225
226
227
228 public int getTransactionId()
229 {
230 return transactionId;
231 }
232
233
234
235
236
237 public boolean isTruncated()
238 {
239 return truncated;
240 }
241
242
243
244
245
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 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 public int hashCode()
273 {
274 return new HashCodeBuilder( -1805208585, -276770303 ).append( this.transactionId ).append( this.answerRecords )
275 .append( this.opCode ).append( this.recursionAvailable ).append( this.messageType ).append(
276 this.additionalRecords ).append( this.truncated ).append( this.recursionDesired ).append(
277 this.responseCode ).append( this.authorityRecords ).append( this.authoritativeAnswer ).append(
278 this.reserved ).append( this.acceptNonAuthenticatedData ).append( this.questionRecords ).toHashCode();
279 }
280
281
282
283
284
285 public String toString()
286 {
287 return new ToStringBuilder( this ).appendSuper( super.toString() ).append( "transactionId", this.transactionId )
288 .append( "opCode", this.opCode ).append( "truncated", this.truncated ).append( "messageType",
289 this.messageType ).append( "recursionDesired", this.recursionDesired ).append( "additionalRecords",
290 this.additionalRecords ).append( "responseCode", this.responseCode ).append( "authorityRecords",
291 this.authorityRecords ).append( "acceptNonAuthenticatedData", this.acceptNonAuthenticatedData ).append(
292 "recursionAvailable", this.recursionAvailable ).append( "answerRecords", this.answerRecords ).append(
293 "questionRecords", this.questionRecords ).append( "authoritativeAnswer", this.authoritativeAnswer )
294 .append( "reserved", this.reserved ).toString();
295 }
296 }