001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020 021 package org.apache.directory.server.dns.messages; 022 023 024 import java.util.List; 025 026 027 /** 028 * All communications inside of the domain protocol are carried in a single 029 * format called a message. The top level format of message is divided 030 * into 5 sections (some of which are empty in certain cases) shown below: 031 * 032 * +---------------------+ 033 * | Header | 034 * +---------------------+ 035 * | Question | the question for the name server 036 * +---------------------+ 037 * | Answer | ResourceRecords answering the question 038 * +---------------------+ 039 * | Authority | ResourceRecords pointing toward an authority 040 * +---------------------+ 041 * | Additional | ResourceRecords holding additional information 042 * +---------------------+ 043 * 044 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 045 * @version $Rev: 547514 $, $Date: 2007-06-15 05:50:50 +0200 (Fri, 15 Jun 2007) $ 046 */ 047 public class DnsMessageModifier 048 { 049 /** 050 * The header section is always present. The header includes fields that 051 * specify which of the remaining sections are present, and also specify 052 * whether the message is a query or a response, a standard query or some 053 * other opcode, etc. 054 */ 055 private int transactionId; 056 private MessageType messageType; 057 private OpCode opCode; 058 private boolean authoritativeAnswer; 059 private boolean truncated; 060 private boolean recursionDesired; 061 private boolean recursionAvailable; 062 private boolean reserved; 063 private boolean acceptNonAuthenticatedData; 064 065 private ResponseCode responseCode; 066 067 private List<QuestionRecord> questionRecords; 068 private List<ResourceRecord> answerRecords; 069 private List<ResourceRecord> authorityRecords; 070 private List<ResourceRecord> additionalRecords; 071 072 073 /** 074 * Returns the {@link DnsMessage}. 075 * 076 * @return The {@link DnsMessage}. 077 */ 078 public DnsMessage getDnsMessage() 079 { 080 return new DnsMessage( transactionId, messageType, opCode, authoritativeAnswer, truncated, recursionDesired, 081 recursionAvailable, reserved, acceptNonAuthenticatedData, responseCode, questionRecords, answerRecords, 082 authorityRecords, additionalRecords ); 083 } 084 085 086 /** 087 * @param acceptNonAuthenticatedData The acceptNonAuthenticatedData to set. 088 */ 089 public void setAcceptNonAuthenticatedData( boolean acceptNonAuthenticatedData ) 090 { 091 this.acceptNonAuthenticatedData = acceptNonAuthenticatedData; 092 } 093 094 095 /** 096 * @param additionalRecords The additional to set. 097 */ 098 public void setAdditionalRecords( List<ResourceRecord> additionalRecords ) 099 { 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 }