You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by er...@apache.org on 2005/01/11 08:19:57 UTC
svn commit: r124896 - incubator/directory/dns/trunk/core/src/java/org/apache/dns/records
Author: erodriguez
Date: Mon Jan 10 23:19:53 2005
New Revision: 124896
URL: http://svn.apache.org/viewcvs?view=rev&rev=124896
Log:
DNS resource record classes.
Added:
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/InternetResource.java
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/QuestionRecord.java
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/ResourceRecord.java (contents, props changed)
Added: incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/InternetResource.java
Url: http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/InternetResource.java?view=auto&rev=124896
==============================================================================
--- (empty file)
+++ incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/InternetResource.java Mon Jan 10 23:19:53 2005
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.dns.records;
+
+import java.nio.ByteBuffer;
+
+
+public abstract class InternetResource extends ResourceRecord
+{
+ private byte[] resourceData;
+
+ public InternetResource( String domainName, RecordType recordType,
+ int timeToLive, byte[] resourceData )
+ {
+ super( domainName, recordType, RecordClass.IN, timeToLive, resourceData );
+
+ this.resourceData = resourceData;
+ }
+
+ protected void dataToByteBuffer( ByteBuffer out )
+ {
+ out.put( resourceData );
+ }
+}
+
Added: incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/QuestionRecord.java
Url: http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/QuestionRecord.java?view=auto&rev=124896
==============================================================================
--- (empty file)
+++ incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/QuestionRecord.java Mon Jan 10 23:19:53 2005
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.dns.records;
+
+
+/**
+ * The question section is used to carry the "question" in most queries,
+ * i.e., the parameters that define what is being asked. The section
+ * contains QDCOUNT (usually 1) entries, each of the following format:
+ *
+ * 1 1 1 1 1 1
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * | |
+ * / QNAME /
+ * / /
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * | QTYPE |
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * | QCLASS |
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ */
+public class QuestionRecord
+{
+ private String domainName;
+ private RecordType recordType;
+ private RecordClass recordClass;
+
+
+ public QuestionRecord( String domainName, RecordType recordType, RecordClass recordClass )
+ {
+ this.domainName = domainName;
+ this.recordType = recordType;
+ this.recordClass = recordClass;
+ }
+
+
+ /**
+ * A two octet code that specifies the class of the query.
+ * For example, the QCLASS field is IN for the Internet.
+ *
+ * @return Returns the questionClass.
+ */
+ public RecordClass getRecordClass()
+ {
+ return recordClass;
+ }
+
+ /**
+ * A domain name represented as a sequence of labels, where
+ * each label consists of a length octet followed by that
+ * number of octets. The domain name terminates with the
+ * zero length octet for the null label of the root. Note
+ * that this field may be an odd number of octets; no
+ * padding is used.
+ *
+ * @return Returns the questionName.
+ */
+ public String getDomainName()
+ {
+ return domainName;
+ }
+
+ /**
+ * A two octet code which specifies the type of the query.
+ * The values for this field include all codes valid for a
+ * TYPE field, together with some more general codes which
+ * can match more than one type of RR.
+ *
+ * @return Returns the questionType.
+ */
+ public RecordType getRecordType()
+ {
+ return recordType;
+ }
+
+ public String toString()
+ {
+ return "org.apache.dns.records.QuestionRecord[ " + domainName + " ( " +
+ recordClass + " " + recordType + " ) ]";
+ }
+}
+
Added: incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/ResourceRecord.java
Url: http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/ResourceRecord.java?view=auto&rev=124896
==============================================================================
--- (empty file)
+++ incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/ResourceRecord.java Mon Jan 10 23:19:53 2005
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.dns.records;
+
+import java.nio.ByteBuffer;
+
+/**
+ * The answer, authority, and additional sections all share the same
+ * format: a variable number of resource records, where the number of
+ * records is specified in the corresponding count field in the header.
+ * Each resource record has the following format:
+ * 1 1 1 1 1 1
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * | |
+ * / /
+ * / NAME /
+ * | |
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * | TYPE |
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * | CLASS |
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * | TTL |
+ * | |
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * | RDLENGTH |
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
+ * / RDATA /
+ * / /
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ */
+public abstract class ResourceRecord
+{
+ private String domainName;
+ private RecordType recordType;
+ private RecordClass recordClass;
+
+ private int timeToLive;
+ private byte[] resourceData;
+
+ public ResourceRecord( String domainName, RecordType recordType, RecordClass recordClass,
+ int timeToLive, byte[] resourceData )
+ {
+ this.domainName = domainName;
+ this.recordType = recordType;
+ this.recordClass = recordClass;
+ this.timeToLive = timeToLive;
+ this.resourceData = resourceData;
+ }
+
+ abstract protected void dataToByteBuffer( ByteBuffer out );
+
+ public void writeTo( ByteBuffer out )
+ {
+ dataToByteBuffer( out );
+ }
+
+ public String toString()
+ {
+ return "org.apache.dns.records.ResourceRecord[ " + domainName + " ( " +
+ recordClass + " " + recordType + " " + timeToLive + " " +
+ resourceData.length + " ) ]";
+ }
+}
+