View Javadoc

1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  
21  package org.apache.directory.server.dns.messages;
22  
23  
24  import java.util.List;
25  
26  
27  /**
28   * All communications inside of the domain protocol are carried in a single
29   * format called a message.  The top level format of message is divided
30   * into 5 sections (some of which are empty in certain cases) shown below:
31   *
32   *     +---------------------+
33   *     |        Header       |
34   *     +---------------------+
35   *     |       Question      | the question for the name server
36   *     +---------------------+
37   *     |        Answer       | ResourceRecords answering the question
38   *     +---------------------+
39   *     |      Authority      | ResourceRecords pointing toward an authority
40   *     +---------------------+
41   *     |      Additional     | ResourceRecords holding additional information
42   *     +---------------------+
43   * 
44   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
45   * @version $Rev: 547514 $, $Date: 2007-06-15 05:50:50 +0200 (Fr, 15 Jun 2007) $
46   */
47  public class DnsMessageModifier
48  {
49      /**
50       * The header section is always present.  The header includes fields that
51       * specify which of the remaining sections are present, and also specify
52       * whether the message is a query or a response, a standard query or some
53       * other opcode, etc.
54       */
55      private int transactionId;
56      private MessageType messageType;
57      private OpCode opCode;
58      private boolean authoritativeAnswer;
59      private boolean truncated;
60      private boolean recursionDesired;
61      private boolean recursionAvailable;
62      private boolean reserved;
63      private boolean acceptNonAuthenticatedData;
64  
65      private ResponseCode responseCode;
66  
67      private List<QuestionRecord> questionRecords;
68      private List<ResourceRecord> answerRecords;
69      private List<ResourceRecord> authorityRecords;
70      private List<ResourceRecord> additionalRecords;
71  
72  
73      /**
74       * Returns the {@link DnsMessage}.
75       *
76       * @return The {@link DnsMessage}.
77       */
78      public DnsMessage getDnsMessage()
79      {
80          return new DnsMessage( transactionId, messageType, opCode, authoritativeAnswer, truncated, recursionDesired,
81              recursionAvailable, reserved, acceptNonAuthenticatedData, responseCode, questionRecords, answerRecords,
82              authorityRecords, additionalRecords );
83      }
84  
85  
86      /**
87       * @param acceptNonAuthenticatedData The acceptNonAuthenticatedData to set.
88       */
89      public void setAcceptNonAuthenticatedData( boolean acceptNonAuthenticatedData )
90      {
91          this.acceptNonAuthenticatedData = acceptNonAuthenticatedData;
92      }
93  
94  
95      /**
96       * @param additionalRecords The additional to set.
97       */
98      public void setAdditionalRecords( List<ResourceRecord> additionalRecords )
99      {
100         this.additionalRecords = additionalRecords;
101     }
102 
103 
104     /**
105      * @param answerRecords The answer to set.
106      */
107     public void setAnswerRecords( List<ResourceRecord> answerRecords )
108     {
109         this.answerRecords = answerRecords;
110     }
111 
112 
113     /**
114      * @param authoritativeAnswer The authoritativeAnswer to set.
115      */
116     public void setAuthoritativeAnswer( boolean authoritativeAnswer )
117     {
118         this.authoritativeAnswer = authoritativeAnswer;
119     }
120 
121 
122     /**
123      * @param authorityRecords The authority to set.
124      */
125     public void setAuthorityRecords( List<ResourceRecord> authorityRecords )
126     {
127         this.authorityRecords = authorityRecords;
128     }
129 
130 
131     /**
132      * @param messageType The messageType to set.
133      */
134     public void setMessageType( MessageType messageType )
135     {
136         this.messageType = messageType;
137     }
138 
139 
140     /**
141      * @param opCode The opCode to set.
142      */
143     public void setOpCode( OpCode opCode )
144     {
145         this.opCode = opCode;
146     }
147 
148 
149     /**
150      * @param questionRecords The question to set.
151      */
152     public void setQuestionRecords( List<QuestionRecord> questionRecords )
153     {
154         this.questionRecords = questionRecords;
155     }
156 
157 
158     /**
159      * @param recursionAvailable The recursionAvailable to set.
160      */
161     public void setRecursionAvailable( boolean recursionAvailable )
162     {
163         this.recursionAvailable = recursionAvailable;
164     }
165 
166 
167     /**
168      * @param recursionDesired The recursionDesired to set.
169      */
170     public void setRecursionDesired( boolean recursionDesired )
171     {
172         this.recursionDesired = recursionDesired;
173     }
174 
175 
176     /**
177      * @param reserved The reserved to set.
178      */
179     public void setReserved( boolean reserved )
180     {
181         this.reserved = reserved;
182     }
183 
184 
185     /**
186      * @param responseCode The responseCode to set.
187      */
188     public void setResponseCode( ResponseCode responseCode )
189     {
190         this.responseCode = responseCode;
191     }
192 
193 
194     /**
195      * @param transactionId The transactionId to set.
196      */
197     public void setTransactionId( int transactionId )
198     {
199         this.transactionId = transactionId;
200     }
201 
202 
203     /**
204      * @param truncated The truncated to set.
205      */
206     public void setTruncated( boolean truncated )
207     {
208         this.truncated = truncated;
209     }
210 }