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/09/18 21:48:12 UTC

svn commit: r289962 [1/3] - in /directory/protocol-providers/dns/trunk/src: java/org/apache/dns/io/ java/org/apache/dns/io/decoder/ java/org/apache/dns/io/encoder/ java/org/apache/dns/messages/ java/org/apache/dns/protocol/ java/org/apache/dns/service/...

Author: erodriguez
Date: Sun Sep 18 12:47:47 2005
New Revision: 289962

URL: http://svn.apache.org/viewcvs?rev=289962&view=rev
Log:
Completed basic directory-backed record serving (DIRDNS-1):
o  Replaced hard-coded A-record serving with hashed adapter mapping record types to their respective encoders.
o  Added encoders for SOA, A, NS, MX, PTR, and CNAME resource records.

Added:
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/decoder/
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/decoder/Decoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/decoder/ResourceRecordDecoder.java
      - copied, changed from r265797, directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/ResourceRecordDecoder.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/A6RecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/AddressRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/CanonicalNameRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/CertificateRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/DnameRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/HostInformationRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/Inet6AddressRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/KeyExchangeRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/KeyRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/LocationRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/MailExchangeRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/MailInformationRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NameAuthorityPointerEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NameServerRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NextNameRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/PointerRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/QuestionRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/RecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/ResourceRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/ServerSelectionRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/SignatureRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/StartOfAuthorityRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/TextRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/WellKnownServicesRecordEncoder.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/QuestionRecords.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/ResourceRecordImpl.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/ResourceRecordModifier.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/ResourceRecords.java   (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/GetResourceRecords.java
      - copied, changed from r289702, directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/GetRecordEntry.java
    directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/
    directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/DNS-QUERY.pdu
      - copied, changed from r289702, directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DNS-QUERY.pdu
    directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/DNS-RESPONSE.pdu
      - copied, changed from r289702, directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DNS-RESPONSE.pdu
    directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/DNS-TRAFFIC.libpcap
      - copied, changed from r289702, directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DNS-TRAFFIC.libpcap
    directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/DnsMessageDecoderTest.java
      - copied, changed from r289702, directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DnsMessageDecoderTest.java
Removed:
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/DnsMessageDecoder.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/DnsMessageEncoder.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/ResourceRecordDecoder.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/GetRecordEntry.java
    directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DNS-QUERY.pdu
    directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DNS-RESPONSE.pdu
    directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DNS-TRAFFIC.libpcap
    directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DnsMessageDecoderTest.java
Modified:
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/DnsMessage.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/DnsMessageModifier.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/ResourceRecord.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsDecoder.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsEncoder.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolHandler.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/BuildReply.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsContext.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsExceptionHandler.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DomainNameServiceChain.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorContext.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorMessage.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/DnsAttribute.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/JndiRecordStoreImpl.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/RecordStore.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/operations/GetRecord.java
    directory/protocol-providers/dns/trunk/src/test/org/apache/dns/AbstractDnsTestCase.java

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/decoder/Decoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/decoder/Decoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/decoder/Decoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/decoder/Decoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,26 @@
+/*
+ *   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.io.decoder;
+
+import java.io.IOException;
+import java.util.Map;
+
+public interface Decoder
+{
+    public Map decode( byte[] resourceData ) throws IOException;
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/decoder/Decoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/decoder/ResourceRecordDecoder.java (from r265797, directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/ResourceRecordDecoder.java)
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/decoder/ResourceRecordDecoder.java?p2=directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/decoder/ResourceRecordDecoder.java&p1=directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/ResourceRecordDecoder.java&r1=265797&r2=289962&rev=289962&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/ResourceRecordDecoder.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/decoder/ResourceRecordDecoder.java Sun Sep 18 12:47:47 2005
@@ -15,67 +15,39 @@
  *
  */
 
-package org.apache.dns.io;
+package org.apache.dns.io.decoder;
 
-import org.apache.dns.DnsException;
-import org.apache.dns.messages.ResponseCode;
-import org.apache.dns.records.RecordClass;
-import org.apache.dns.records.RecordType;
-import org.apache.dns.records.ResourceRecord;
-import org.apache.dns.records.internet.AddressRecord;
-import org.apache.dns.records.internet.WellKnownServicesRecord;
-import org.apache.dns.records.standard.CanonicalNameRecord;
-import org.apache.dns.records.standard.HostInformationRecord;
-import org.apache.dns.records.standard.MailExchangeRecord;
-import org.apache.dns.records.standard.MailInformationRecord;
-import org.apache.dns.records.standard.NameServerRecord;
-import org.apache.dns.records.standard.PointerRecord;
-import org.apache.dns.records.standard.StartOfAuthorityRecord;
-import org.apache.dns.records.standard.TextRecord;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.nio.ByteBuffer;
 
 public class ResourceRecordDecoder
 {
-    /** the log for this class */
-    private static final Logger log = LoggerFactory.getLogger( ResourceRecordDecoder.class );
+    protected short getUnsignedByte( ByteBuffer byteBuffer )
+    {
+        return ( (short) ( byteBuffer.get() & 0xff ) );
+    }
+
+    protected short getUnsignedByte( ByteBuffer byteBuffer, int position )
+    {
+        return ( (short) ( byteBuffer.get( position ) & (short) 0xff ) );
+    }
+
+    protected int getUnsignedShort( ByteBuffer byteBuffer )
+    {
+        return ( byteBuffer.getShort() & 0xffff );
+    }
+
+    protected int getUnsignedShort( ByteBuffer byteBuffer, int position )
+    {
+        return ( byteBuffer.getShort( position ) & 0xffff );
+    }
+
+    protected long getUnsignedInt( ByteBuffer byteBuffer )
+    {
+        return ( byteBuffer.getInt() & 0xffffffffL );
+    }
 
-    public static ResourceRecord getInstance( String domainName, RecordType recordType, RecordClass recordClass,
-            int timeToLive, byte[] resourceData ) throws DnsException
+    protected long getUnsignedInt( ByteBuffer byteBuffer, int position )
     {
-        if ( recordClass != RecordClass.IN )
-        {
-            log.info( "Unsupported record class:  " + recordClass );
-            throw new DnsException( ResponseCode.NOT_IMPLEMENTED );
-        }
-
-        int tag = recordType.getOrdinal();
-
-        switch ( tag )
-        {
-            case 1:
-                return new AddressRecord( domainName, timeToLive, resourceData );
-            case 2:
-                return new NameServerRecord( domainName, timeToLive, resourceData );
-            case 5:
-                return new CanonicalNameRecord( domainName, timeToLive, resourceData );
-            case 6:
-                return new StartOfAuthorityRecord( domainName, timeToLive, resourceData );
-            case 11:
-                return new WellKnownServicesRecord( domainName, timeToLive, resourceData );
-            case 12:
-                return new PointerRecord( domainName, timeToLive, resourceData );
-            case 13:
-                return new HostInformationRecord( domainName, timeToLive, resourceData );
-            case 14:
-                return new MailInformationRecord( domainName, timeToLive, resourceData );
-            case 15:
-                return new MailExchangeRecord( domainName, timeToLive, resourceData );
-            case 16:
-                return new TextRecord( domainName, timeToLive, resourceData );
-            default:
-                log.info( "Unsupported option code:  " + tag );
-                throw new DnsException( ResponseCode.NOT_IMPLEMENTED );
-        }
+        return ( byteBuffer.getInt( position ) & 0xffffffffL );
     }
 }

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/A6RecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/A6RecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/A6RecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/A6RecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,54 @@
+/*
+ *   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.io.encoder;
+
+/**
+ * 3.1.1.  Format
+ * 
+ *    The RDATA portion of the A6 record contains two or three fields.
+ * 
+ *            +-----------+------------------+-------------------+
+ *            |Prefix len.|  Address suffix  |    Prefix name    |
+ *            | (1 octet) |  (0..16 octets)  |  (0..255 octets)  |
+ *            +-----------+------------------+-------------------+
+ * 
+ *    o  A prefix length, encoded as an eight-bit unsigned integer with
+ *       value between 0 and 128 inclusive.
+ * 
+ *    o  An IPv6 address suffix, encoded in network order (high-order octet
+ *       first).  There MUST be exactly enough octets in this field to
+ *       contain a number of bits equal to 128 minus prefix length, with 0
+ *       to 7 leading pad bits to make this field an integral number of
+ *       octets.  Pad bits, if present, MUST be set to zero when loading a
+ *       zone file and ignored (other than for SIG [DNSSEC] verification)
+ *       on reception.
+ * 
+ *    o  The name of the prefix, encoded as a domain name.  By the rules of
+ *       [DNSIS], this name MUST NOT be compressed.
+ * 
+ *    The domain name component SHALL NOT be present if the prefix length
+ *    is zero.  The address suffix component SHALL NOT be present if the
+ *    prefix length is 128.
+ * 
+ *    It is SUGGESTED that an A6 record intended for use as a prefix for
+ *    other A6 records have all the insignificant trailing bits in its
+ *    address suffix field set to zero.
+ */
+public class A6RecordEncoder
+{
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/A6RecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/A6RecordEncoder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/AddressRecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/AddressRecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/AddressRecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/AddressRecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,60 @@
+/*
+ *   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.io.encoder;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import org.apache.dns.messages.ResourceRecord;
+import org.apache.dns.store.DnsAttribute;
+
+/**
+ * 3.4.1. A RDATA format
+ * 
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                    ADDRESS                    |
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * 
+ * where:
+ * 
+ * ADDRESS         A 32 bit Internet address.
+ * 
+ * Hosts that have multiple Internet addresses will have multiple A
+ * records.
+ * 
+ * A records cause no additional section processing.  The RDATA section of
+ * an A line in a master file is an Internet address expressed as four
+ * decimal numbers separated by dots without any imbedded spaces (e.g.,
+ * "10.2.0.52" or "192.0.5.6").
+ */
+public class AddressRecordEncoder extends ResourceRecordEncoder
+{
+    protected byte[] encodeResourceData( ResourceRecord record )
+    {
+        String ipAddress = record.get( DnsAttribute.IP_ADDRESS );
+
+        try
+        {
+            return InetAddress.getByName( ipAddress ).getAddress();
+        }
+        catch ( UnknownHostException uhe )
+        {
+            return null;
+        }
+    }
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/AddressRecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/AddressRecordEncoder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/CanonicalNameRecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/CanonicalNameRecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/CanonicalNameRecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/CanonicalNameRecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,48 @@
+/*
+ *   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.io.encoder;
+
+import org.apache.dns.messages.ResourceRecord;
+import org.apache.dns.store.DnsAttribute;
+
+/**
+ * 3.3.1. CNAME RDATA format
+ * 
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *     /                     CNAME                     /
+ *     /                                               /
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * 
+ * where:
+ * 
+ * CNAME           A <domain-name> which specifies the canonical or primary
+ *                 name for the owner.  The owner name is an alias.
+ * 
+ * CNAME RRs cause no additional section processing, but name servers may
+ * choose to restart the query at the canonical name in certain cases.  See
+ * the description of name server logic in [RFC-1034] for details.
+ */
+public class CanonicalNameRecordEncoder extends ResourceRecordEncoder
+{
+    protected byte[] encodeResourceData( ResourceRecord record )
+    {
+        String domainName = record.get( DnsAttribute.DOMAIN_NAME );
+
+        return encodeDomainName( domainName );
+    }
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/CanonicalNameRecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/CertificateRecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/CertificateRecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/CertificateRecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/CertificateRecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,59 @@
+/*
+ *   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.io.encoder;
+
+/**
+ * 2. The CERT Resource Record
+ * 
+ *    The CERT resource record (RR) has the structure given below.  Its RR
+ *    type code is 37.
+ * 
+ *                          1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
+ *      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |             type              |             key tag           |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |   algorithm   |                                               /
+ *     +---------------+            certificate or CRL                 /
+ *     /                                                               /
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
+ * 
+ *    The type field is the certificate type as define in section 2.1
+ *    below.
+ * 
+ *    The algorithm field has the same meaning as the algorithm field in
+ *    KEY and SIG RRs [RFC 2535] except that a zero algorithm field
+ *    indicates the algorithm is unknown to a secure DNS, which may simply
+ *    be the result of the algorithm not having been standardized for
+ *    secure DNS.
+ * 
+ *    The key tag field is the 16 bit value computed for the key embedded
+ *    in the certificate as specified in the DNSSEC Standard [RFC 2535].
+ *    This field is used as an efficiency measure to pick which CERT RRs
+ *    may be applicable to a particular key.  The key tag can be calculated
+ *    for the key in question and then only CERT RRs with the same key tag
+ *    need be examined. However, the key must always be transformed to the
+ *    format it would have as the public key portion of a KEY RR before the
+ *    key tag is computed.  This is only possible if the key is applicable
+ *    to an algorithm (and limits such as key size limits) defined for DNS
+ *    security.  If it is not, the algorithm field MUST BE zero and the tag
+ *    field is meaningless and SHOULD BE zero.
+ */
+public class CertificateRecordEncoder
+{
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/CertificateRecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/CertificateRecordEncoder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/DnameRecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/DnameRecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/DnameRecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/DnameRecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,64 @@
+/*
+ *   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.io.encoder;
+
+/**
+ * 3. The DNAME Resource Record
+ * 
+ *    The DNAME RR has mnemonic DNAME and type code 39 (decimal).
+ * 
+ *    DNAME has the following format:
+ * 
+ *       <owner> <ttl> <class> DNAME <target>
+ * 
+ *    The format is not class-sensitive.  All fields are required.  The
+ *    RDATA field <target> is a <domain-name> [DNSIS].
+ * 
+ *    The DNAME RR causes type NS additional section processing.
+ * 
+ *    The effect of the DNAME record is the substitution of the record's
+ *    <target> for its <owner> as a suffix of a domain name.  A "no-
+ *    descendants" limitation governs the use of DNAMEs in a zone file:
+ * 
+ *       If a DNAME RR is present at a node N, there may be other data at N
+ *       (except a CNAME or another DNAME), but there MUST be no data at
+ *       any descendant of N.  This restriction applies only to records of
+ *       the same class as the DNAME record.
+ * 
+ *    This rule assures predictable results when a DNAME record is cached
+ *    by a server which is not authoritative for the record's zone.  It
+ *    MUST be enforced when authoritative zone data is loaded.  Together
+ *    with the rules for DNS zone authority [DNSCLR] it implies that DNAME
+ *    and NS records can only coexist at the top of a zone which has only
+ *    one node.
+ * 
+ *    The compression scheme of [DNSIS] MUST NOT be applied to the RDATA
+ *    portion of a DNAME record unless the sending server has some way of
+ *    knowing that the receiver understands the DNAME record format.
+ *    Signalling such understanding is expected to be the subject of future
+ *    DNS Extensions.
+ * 
+ *    Naming loops can be created with DNAME records or a combination of
+ *    DNAME and CNAME records, just as they can with CNAME records alone.
+ *    Resolvers, including resolvers embedded in DNS servers, MUST limit
+ *    the resources they devote to any query.  Implementors should note,
+ *    however, that fairly lengthy chains of DNAME records may be valid.
+ */
+public class DnameRecordEncoder
+{
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/DnameRecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/DnameRecordEncoder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/HostInformationRecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/HostInformationRecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/HostInformationRecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/HostInformationRecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,44 @@
+/*
+ *   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.io.encoder;
+
+/**
+ * 3.3.2. HINFO RDATA format
+ * 
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *     /                      CPU                      /
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *     /                       OS                      /
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * 
+ * where:
+ * 
+ * CPU             A <character-string> which specifies the CPU type.
+ * 
+ * OS              A <character-string> which specifies the operating
+ *                 system type.
+ * 
+ * Standard values for CPU and OS can be found in [RFC-1010].
+ * 
+ * HINFO records are used to acquire general information about a host.  The
+ * main use is for protocols such as FTP that can use special procedures
+ * when talking between machines or operating systems of the same type.
+ */
+public class HostInformationRecordEncoder
+{
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/HostInformationRecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/Inet6AddressRecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/Inet6AddressRecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/Inet6AddressRecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/Inet6AddressRecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,76 @@
+/*
+ *   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.io.encoder;
+
+/**
+ * 2. New resource record definition and domain
+ * 
+ *    A record type is defined to store a host's IPv6 address.  A host that
+ *    has more than one IPv6 address must have more than one such record.
+ * 
+ * 2.1 AAAA record type
+ * 
+ *    The AAAA resource record type is a record specific to the Internet
+ *    class that stores a single IPv6 address.
+ * 
+ *    The IANA assigned value of the type is 28 (decimal).
+ * 
+ * 2.2 AAAA data format
+ * 
+ *    A 128 bit IPv6 address is encoded in the data portion of an AAAA
+ *    resource record in network byte order (high-order byte first).
+ * 
+ * 2.3 AAAA query
+ * 
+ *    An AAAA query for a specified domain name in the Internet class
+ *    returns all associated AAAA resource records in the answer section of
+ *    a response.
+ * 
+ *    A type AAAA query does not trigger additional section processing.
+ * 
+ * 2.4 Textual format of AAAA records
+ * 
+ *    The textual representation of the data portion of the AAAA resource
+ *    record used in a master database file is the textual representation
+ *    of an IPv6 address as defined in [3].
+ * 
+ * 2.5 IP6.ARPA Domain
+ * 
+ *    A special domain is defined to look up a record given an IPv6
+ *    address.  The intent of this domain is to provide a way of mapping an
+ *    IPv6 address to a host name, although it may be used for other
+ *    purposes as well.  The domain is rooted at IP6.ARPA.
+ * 
+ *    An IPv6 address is represented as a name in the IP6.ARPA domain by a
+ *    sequence of nibbles separated by dots with the suffix ".IP6.ARPA".
+ *    The sequence of nibbles is encoded in reverse order, i.e., the
+ *    low-order nibble is encoded first, followed by the next low-order
+ *    nibble and so on.  Each nibble is represented by a hexadecimal digit.
+ *    For example, the reverse lookup domain name corresponding to the
+ *    address
+ * 
+ *        4321:0:1:2:3:4:567:89ab
+ * 
+ *    would be
+ * 
+ *    b.a.9.8.7.6.5.0.4.0.0.0.3.0.0.0.2.0.0.0.1.0.0.0.0.0.0.0.1.2.3.4.IP6.
+ *                                                                   ARPA.
+ */
+public class Inet6AddressRecordEncoder
+{
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/Inet6AddressRecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/Inet6AddressRecordEncoder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/KeyExchangeRecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/KeyExchangeRecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/KeyExchangeRecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/KeyExchangeRecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,50 @@
+/*
+ *   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.io.encoder;
+
+/**
+ * 3.1 KX RDATA format
+ * 
+ *    The KX DNS record has the following RDATA format:
+ * 
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *     |                  PREFERENCE                   |
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *     /                   EXCHANGER                   /
+ *     /                                               /
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * 
+ *    where:
+ * 
+ *    PREFERENCE      A 16 bit non-negative integer which specifies the
+ *                    preference given to this RR among other KX records
+ *                    at the same owner.  Lower values are preferred.
+ * 
+ *    EXCHANGER       A <domain-name> which specifies a host willing to
+ *                    act as a mail exchange for the owner name.
+ * 
+ *    KX records MUST cause type A additional section processing for the
+ *    host specified by EXCHANGER.  In the event that the host processing
+ *    the DNS transaction supports IPv6, KX records MUST also cause type
+ *    AAAA additional section processing.
+ * 
+ *    The KX RDATA field MUST NOT be compressed.
+ */
+public class KeyExchangeRecordEncoder
+{
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/KeyExchangeRecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/KeyExchangeRecordEncoder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/KeyRecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/KeyRecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/KeyRecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/KeyRecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,57 @@
+/*
+ *   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.io.encoder;
+
+/**
+ * 3. The KEY Resource Record
+ * 
+ *    The KEY resource record (RR) is used to store a public key that is
+ *    associated with a Domain Name System (DNS) name.  This can be the
+ *    public key of a zone, a user, or a host or other end entity. Security
+ *    aware DNS implementations MUST be designed to handle at least two
+ *    simultaneously valid keys of the same type associated with the same
+ *    name.
+ * 
+ *    The type number for the KEY RR is 25.
+ * 
+ *    A KEY RR is, like any other RR, authenticated by a SIG RR.  KEY RRs
+ *    must be signed by a zone level key.
+ * 
+ * 3.1 KEY RDATA format
+ * 
+ *    The RDATA for a KEY RR consists of flags, a protocol octet, the
+ *    algorithm number octet, and the public key itself.  The format is as
+ *    follows:
+ * 
+ *                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
+ *     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *    |             flags             |    protocol   |   algorithm   |
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *    |                                                               /
+ *    /                          public key                           /
+ *    /                                                               /
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
+ * 
+ *    The KEY RR is not intended for storage of certificates and a separate
+ *    certificate RR has been developed for that purpose, defined in [RFC
+ *    2538].
+ */
+public class KeyRecordEncoder
+{
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/KeyRecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/KeyRecordEncoder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/LocationRecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/LocationRecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/LocationRecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/LocationRecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,114 @@
+/*
+ *   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.io.encoder;
+
+/**
+ * 2. RDATA Format
+ * 
+ *        MSB                                           LSB
+ *        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *       0|        VERSION        |         SIZE          |
+ *        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *       2|       HORIZ PRE       |       VERT PRE        |
+ *        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *       4|                   LATITUDE                    |
+ *        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *       6|                   LATITUDE                    |
+ *        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *       8|                   LONGITUDE                   |
+ *        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *      10|                   LONGITUDE                   |
+ *        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *      12|                   ALTITUDE                    |
+ *        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *      14|                   ALTITUDE                    |
+ *        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *    (octet)
+ * 
+ * where:
+ * 
+ * VERSION      Version number of the representation.  This must be zero.
+ *              Implementations are required to check this field and make
+ *              no assumptions about the format of unrecognized versions.
+ * 
+ * SIZE         The diameter of a sphere enclosing the described entity, in
+ *              centimeters, expressed as a pair of four-bit unsigned
+ *              integers, each ranging from zero to nine, with the most
+ *              significant four bits representing the base and the second
+ *              number representing the power of ten by which to multiply
+ *              the base.  This allows sizes from 0e0 (<1cm) to 9e9
+ *              (90,000km) to be expressed.  This representation was chosen
+ *              such that the hexadecimal representation can be read by
+ *              eye; 0x15 = 1e5.  Four-bit values greater than 9 are
+ *              undefined, as are values with a base of zero and a non-zero
+ *              exponent.
+ * 
+ *              Since 20000000m (represented by the value 0x29) is greater
+ *              than the equatorial diameter of the WGS 84 ellipsoid
+ *              (12756274m), it is therefore suitable for use as a
+ *              "worldwide" size.
+ * 
+ * HORIZ PRE    The horizontal precision of the data, in centimeters,
+ *              expressed using the same representation as SIZE.  This is
+ *              the diameter of the horizontal "circle of error", rather
+ *              than a "plus or minus" value.  (This was chosen to match
+ *              the interpretation of SIZE; to get a "plus or minus" value,
+ *              divide by 2.)
+ * 
+ * VERT PRE     The vertical precision of the data, in centimeters,
+ *              expressed using the sane representation as for SIZE.  This
+ *              is the total potential vertical error, rather than a "plus
+ *              or minus" value.  (This was chosen to match the
+ *              interpretation of SIZE; to get a "plus or minus" value,
+ *              divide by 2.)  Note that if altitude above or below sea
+ *              level is used as an approximation for altitude relative to
+ *              the [WGS 84] ellipsoid, the precision value should be
+ *              adjusted.
+ * 
+ * LATITUDE     The latitude of the center of the sphere described by the
+ *              SIZE field, expressed as a 32-bit integer, most significant
+ *              octet first (network standard byte order), in thousandths
+ *              of a second of arc.  2^31 represents the equator; numbers
+ *              above that are north latitude.
+ * 
+ * LONGITUDE    The longitude of the center of the sphere described by the
+ *              SIZE field, expressed as a 32-bit integer, most significant
+ *              octet first (network standard byte order), in thousandths
+ *              of a second of arc, rounded away from the prime meridian.
+ *              2^31 represents the prime meridian; numbers above that are
+ *              east longitude.
+ * 
+ * ALTITUDE     The altitude of the center of the sphere described by the
+ *              SIZE field, expressed as a 32-bit integer, most significant
+ *              octet first (network standard byte order), in centimeters,
+ *              from a base of 100,000m below the [WGS 84] reference
+ *              spheroid used by GPS (semimajor axis a=6378137.0,
+ *              reciprocal flattening rf=298.257223563).  Altitude above
+ *              (or below) sea level may be used as an approximation of
+ *              altitude relative to the the [WGS 84] spheroid, though due
+ *              to the Earth's surface not being a perfect spheroid, there
+ *              will be differences.  (For example, the geoid (which sea
+ *              level approximates) for the continental US ranges from 10
+ *              meters to 50 meters below the [WGS 84] spheroid.
+ *              Adjustments to ALTITUDE and/or VERT PRE will be necessary
+ *              in most cases.  The Defense Mapping Agency publishes geoid
+ *              height values relative to the [WGS 84] ellipsoid.
+ */
+public class LocationRecordEncoder
+{
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/LocationRecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/LocationRecordEncoder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/MailExchangeRecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/MailExchangeRecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/MailExchangeRecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/MailExchangeRecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,62 @@
+/*
+ *   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.io.encoder;
+
+import java.nio.ByteBuffer;
+
+import org.apache.dns.messages.ResourceRecord;
+import org.apache.dns.store.DnsAttribute;
+
+/**
+ * 3.3.9. MX RDATA format
+ * 
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *     |                  PREFERENCE                   |
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *     /                   EXCHANGE                    /
+ *     /                                               /
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * 
+ * where:
+ * 
+ * PREFERENCE      A 16 bit integer which specifies the preference given to
+ *                 this RR among others at the same owner.  Lower values
+ *                 are preferred.
+ * 
+ * EXCHANGE        A <domain-name> which specifies a host willing to act as
+ *                 a mail exchange for the owner name.
+ * 
+ * MX records cause type A additional section processing for the host
+ * specified by EXCHANGE.  The use of MX RRs is explained in detail in
+ * [RFC-974].
+ */
+public class MailExchangeRecordEncoder extends ResourceRecordEncoder
+{
+    protected byte[] encodeResourceData( ResourceRecord record )
+    {
+        ByteBuffer byteBuffer = ByteBuffer.allocate( 256 );
+        byteBuffer.putShort( Short.parseShort( record.get( DnsAttribute.MX_PREFERENCE ) ) );
+        byteBuffer.put( encodeDomainName( record.get( DnsAttribute.DOMAIN_NAME ) ) );
+
+        byteBuffer.flip();
+        byte[] bytes = new byte[ byteBuffer.remaining() ];
+        byteBuffer.get( bytes, 0, bytes.length );
+
+        return bytes;
+    }
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/MailExchangeRecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/MailInformationRecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/MailInformationRecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/MailInformationRecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/MailInformationRecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,52 @@
+/*
+ *   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.io.encoder;
+
+/**
+ * 3.3.7. MINFO RDATA format (EXPERIMENTAL)
+ * 
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *     /                    RMAILBX                    /
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *     /                    EMAILBX                    /
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * 
+ * where:
+ * 
+ * RMAILBX         A <domain-name> which specifies a mailbox which is
+ *                 responsible for the mailing list or mailbox.  If this
+ *                 domain name names the root, the owner of the MINFO RR is
+ *                 responsible for itself.  Note that many existing mailing
+ *                 lists use a mailbox X-request for the RMAILBX field of
+ *                 mailing list X, e.g., Msgroup-request for Msgroup.  This
+ *                 field provides a more general mechanism.
+ * 
+ * EMAILBX         A <domain-name> which specifies a mailbox which is to
+ *                 receive error messages related to the mailing list or
+ *                 mailbox specified by the owner of the MINFO RR (similar
+ *                 to the ERRORS-TO: field which has been proposed).  If
+ *                 this domain name names the root, errors should be
+ *                 returned to the sender of the message.
+ * 
+ * MINFO records cause no additional section processing.  Although these
+ * records can be associated with a simple mailbox, they are usually used
+ * with a mailing list.
+ */
+public class MailInformationRecordEncoder
+{
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/MailInformationRecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NameAuthorityPointerEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NameAuthorityPointerEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NameAuthorityPointerEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NameAuthorityPointerEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,131 @@
+/*
+ *   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.io.encoder;
+
+/**
+ * 4. NAPTR RR Format
+ * 
+ * 4.1 Packet Format
+ * 
+ *    The packet format of the NAPTR RR is given below.  The DNS type code
+ *    for NAPTR is 35.
+ * 
+ *       The packet format for the NAPTR record is as follows
+ *                                        1  1  1  1  1  1
+ *          0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
+ *        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *        |                     ORDER                     |
+ *        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *        |                   PREFERENCE                  |
+ *        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *        /                     FLAGS                     /
+ *        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *        /                   SERVICES                    /
+ *        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *        /                    REGEXP                     /
+ *        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *        /                  REPLACEMENT                  /
+ *        /                                               /
+ *        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * 
+ *    <character-string> and <domain-name> as used here are defined in RFC
+ *    1035 [7].
+ * 
+ *    ORDER
+ *       A 16-bit unsigned integer specifying the order in which the NAPTR
+ *       records MUST be processed in order to accurately represent the
+ *       ordered list of Rules.  The ordering is from lowest to highest.
+ *       If two records have the same order value then they are considered
+ *       to be the same rule and should be selected based on the
+ *       combination of the Preference values and Services offered.
+ * 
+ *    PREFERENCE
+ *       Although it is called "preference" in deference to DNS
+ *       terminology, this field is equivalent to the Priority value in the
+ *       DDDS Algorithm.  It is a 16-bit unsigned integer that specifies
+ *       the order in which NAPTR records with equal Order values SHOULD be
+ *       processed, low numbers being processed before high numbers.  This
+ *       is similar to the preference field in an MX record, and is used so
+ *       domain administrators can direct clients towards more capable
+ *       hosts or lighter weight protocols.  A client MAY look at records
+ *       with higher preference values if it has a good reason to do so
+ *       such as not supporting some protocol or service very well.
+ * 
+ *       The important difference between Order and Preference is that once
+ *       a match is found the client MUST NOT consider records with a
+ *       different Order but they MAY process records with the same Order
+ *       but different Preferences.  The only exception to this is noted in
+ *       the second important Note in the DDDS algorithm specification
+ *       concerning allowing clients to use more complex Service
+ *       determination between steps 3 and 4 in the algorithm.  Preference
+ *       is used to give communicate a higher quality of service to rules
+ *       that are considered the same from an authority standpoint but not
+ *       from a simple load balancing standpoint.
+ * 
+ *       It is important to note that DNS contains several load balancing
+ *       mechanisms and if load balancing among otherwise equal services
+ *       should be needed then methods such as SRV records or multiple A
+ *       records should be utilized to accomplish load balancing.
+ * 
+ *    FLAGS
+ *       A <character-string> containing flags to control aspects of the
+ *       rewriting and interpretation of the fields in the record.  Flags
+ *       are single characters from the set A-Z and 0-9.  The case of the
+ *       alphabetic characters is not significant.  The field can be empty.
+ * 
+ *       It is up to the Application specifying how it is using this
+ *       Database to define the Flags in this field.  It must define which
+ *       ones are terminal and which ones are not.
+ * 
+ *    SERVICES
+ *       A <character-string> that specifies the Service Parameters
+ *       applicable to this this delegation path.  It is up to the
+ *       Application Specification to specify the values found in this
+ *       field.
+ * 
+ *    REGEXP
+ *       A <character-string> containing a substitution expression that is
+ *       applied to the original string held by the client in order to
+ *       construct the next domain name to lookup.  See the DDDS Algorithm
+ *       specification for the syntax of this field.
+ * 
+ *       As stated in the DDDS algorithm, The regular expressions MUST NOT
+ *       be used in a cumulative fashion, that is, they should only be
+ *       applied to the original string held by the client, never to the
+ *       domain name produced by a previous NAPTR rewrite.  The latter is
+ *       tempting in some applications but experience has shown such use to
+ *       be extremely fault sensitive, very error prone, and extremely
+ *       difficult to debug.
+ * 
+ *    REPLACEMENT
+ *       A <domain-name> which is the next domain-name to query for
+ *       depending on the potential values found in the flags field.  This
+ *       field is used when the regular expression is a simple replacement
+ *       operation.  Any value in this field MUST be a fully qualified
+ *       domain-name.  Name compression is not to be used for this field.
+ * 
+ *       This field and the REGEXP field together make up the Substitution
+ *       Expression in the DDDS Algorithm.  It is simply a historical
+ *       optimization specifically for DNS compression that this field
+ *       exists.  The fields are also mutually exclusive.  If a record is
+ *       returned that has values for both fields then it is considered to
+ *       be in error and SHOULD be either ignored or an error returned.
+ */
+public class NameAuthorityPointerEncoder
+{
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NameAuthorityPointerEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NameAuthorityPointerEncoder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NameServerRecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NameServerRecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NameServerRecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NameServerRecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,55 @@
+/*
+ *   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.io.encoder;
+
+import org.apache.dns.messages.ResourceRecord;
+import org.apache.dns.store.DnsAttribute;
+
+/**
+ * 3.3.11. NS RDATA format
+ * 
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *     /                   NSDNAME                     /
+ *     /                                               /
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * 
+ * where:
+ * 
+ * NSDNAME         A <domain-name> which specifies a host which should be
+ *                 authoritative for the specified class and domain.
+ * 
+ * NS records cause both the usual additional section processing to locate
+ * a type A record, and, when used in a referral, a special search of the
+ * zone in which they reside for glue information.
+ * 
+ * The NS RR states that the named host should be expected to have a zone
+ * starting at owner name of the specified class.  Note that the class may
+ * not indicate the protocol family which should be used to communicate
+ * with the host, although it is typically a strong hint.  For example,
+ * hosts which are name servers for either Internet (IN) or Hesiod (HS)
+ * class information are normally queried using IN class protocols.
+ */
+public class NameServerRecordEncoder extends ResourceRecordEncoder
+{
+    protected byte[] encodeResourceData( ResourceRecord record )
+    {
+        String domainName = record.get( DnsAttribute.DOMAIN_NAME );
+
+        return encodeDomainName( domainName );
+    }
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NameServerRecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NextNameRecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NextNameRecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NextNameRecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NextNameRecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,53 @@
+/*
+ *   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.io.encoder;
+
+/**
+ * 5.2 NXT RDATA Format
+ * 
+ *    The RDATA for an NXT RR consists simply of a domain name followed by
+ *    a bit map.
+ * 
+ *    The type number for the NXT RR is 30.
+ * 
+ *                            1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
+ *        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *       |         next domain name                                      /
+ *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *       |                    type bit map                               /
+ *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * 
+ *    The NXT RR type bit map is one bit per RR type present for the owner
+ *    name similar to the WKS socket bit map.  The first bit represents RR
+ *    type zero (an illegal type which should not be present.) A one bit
+ *    indicates that at least one RR of that type is present for the owner
+ *    name.  A zero indicates that no such RR is present.  All bits not
+ *    specified because they are beyond the end of the bit map are assumed
+ *    to be zero.  Note that bit 30, for NXT, will always be on so the
+ *    minimum bit map length is actually four octets.  The NXT bit map
+ *    should be printed as a list of RR type mnemonics or decimal numbers
+ *    similar to the WKS RR.
+ * 
+ *    The domain name may be compressed with standard DNS name compression
+ *    when being transmitted over the network.  The size of the bit map can
+ *    be inferred from the RDLENGTH and the length of the next domain name.
+ */
+public class NextNameRecordEncoder
+{
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NextNameRecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/NextNameRecordEncoder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/PointerRecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/PointerRecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/PointerRecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/PointerRecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,49 @@
+/*
+ *   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.io.encoder;
+
+import org.apache.dns.messages.ResourceRecord;
+import org.apache.dns.store.DnsAttribute;
+
+/**
+ * 3.3.12. PTR RDATA format
+ * 
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *     /                   PTRDNAME                    /
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * 
+ * where:
+ * 
+ * PTRDNAME        A <domain-name> which points to some location in the
+ *                 domain name space.
+ * 
+ * PTR records cause no additional section processing.  These RRs are used
+ * in special domains to point to some other location in the domain space.
+ * These records are simple data, and don't imply any special processing
+ * similar to that performed by CNAME, which identifies aliases.  See the
+ * description of the IN-ADDR.ARPA domain for an example.
+ */
+public class PointerRecordEncoder extends ResourceRecordEncoder
+{
+    protected byte[] encodeResourceData( ResourceRecord record )
+    {
+        String domainName = record.get( DnsAttribute.DOMAIN_NAME );
+
+        return encodeDomainName( domainName );
+    }
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/PointerRecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/QuestionRecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/QuestionRecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/QuestionRecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/QuestionRecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,61 @@
+/*
+ *   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.io.encoder;
+
+import org.apache.dns.messages.QuestionRecord;
+import org.apache.dns.messages.RecordClass;
+import org.apache.dns.messages.RecordType;
+import org.apache.mina.common.ByteBuffer;
+
+public class QuestionRecordEncoder
+{
+    public void encode( ByteBuffer out, QuestionRecord question )
+    {
+        encodeDomainName( out, question.getDomainName() );
+        encodeRecordType( out, question.getRecordType() );
+        encodeRecordClass( out, question.getRecordClass() );
+    }
+
+    private void encodeDomainName( ByteBuffer byteBuffer, String domainName )
+    {
+        String[] labels = domainName.split( "\\." );
+
+        for ( int ii = 0; ii < labels.length; ii++ )
+        {
+            byteBuffer.put( (byte) labels[ ii ].length() );
+
+            char[] characters = labels[ ii ].toCharArray();
+            for ( int jj = 0; jj < characters.length; jj++ )
+            {
+                byteBuffer.put( (byte) characters[ jj ] );
+            }
+        }
+
+        byteBuffer.put( (byte) 0x00 );
+    }
+
+    private void encodeRecordType( ByteBuffer byteBuffer, RecordType recordType )
+    {
+        byteBuffer.putShort( (short) recordType.getOrdinal() );
+    }
+
+    private void encodeRecordClass( ByteBuffer byteBuffer, RecordClass recordClass )
+    {
+        byteBuffer.putShort( (short) recordClass.getOrdinal() );
+    }
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/QuestionRecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/RecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/RecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/RecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/RecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,28 @@
+/*
+ *   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.io.encoder;
+
+import java.io.IOException;
+
+import org.apache.dns.messages.ResourceRecord;
+import org.apache.mina.common.ByteBuffer;
+
+public interface RecordEncoder
+{
+    public void encode( ByteBuffer buffer, ResourceRecord record ) throws IOException;
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/RecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/ResourceRecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/ResourceRecordEncoder.java?rev=289962&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/ResourceRecordEncoder.java (added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/ResourceRecordEncoder.java Sun Sep 18 12:47:47 2005
@@ -0,0 +1,154 @@
+/*
+ *   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.io.encoder;
+
+import java.io.IOException;
+
+import org.apache.dns.messages.RecordClass;
+import org.apache.dns.messages.RecordType;
+import org.apache.dns.messages.ResourceRecord;
+import org.apache.mina.common.ByteBuffer;
+
+public abstract class ResourceRecordEncoder implements RecordEncoder
+{
+    protected abstract byte[] encodeResourceData( ResourceRecord record );
+
+    public void encode( ByteBuffer out, ResourceRecord record ) throws IOException
+    {
+        encodeDomainName( out, record.getDomainName() );
+        encodeRecordType( out, record.getRecordType() );
+        encodeRecordClass( out, record.getRecordClass() );
+
+        out.putInt( record.getTimeToLive() );
+
+        byte[] resourceData = encodeResourceData( record );
+
+        out.putShort( (short) resourceData.length );
+        out.put( resourceData );
+    }
+
+    /**
+     * <domain-name> is a domain name represented as a series of labels, and
+     * terminated by a label with zero length.
+     * @param domainName the domain name to encode
+     * @return byte array of the encoded domain name
+     */
+    protected byte[] encodeDomainName( String domainName )
+    {
+        ByteBuffer byteBuffer = ByteBuffer.allocate( 256 );
+
+        encodeDomainName( byteBuffer, domainName );
+
+        byteBuffer.flip();
+        byte[] bytes = new byte[ byteBuffer.remaining() ];
+        byteBuffer.get( bytes, 0, bytes.length );
+
+        return bytes;
+    }
+
+    /**
+     * <domain-name> is a domain name represented as a series of labels, and
+     * terminated by a label with zero length.
+     * @param byteBuffer the ByteBuffer to encode the domain name into
+     * @param domainName the domain name to encode
+     */
+    protected void encodeDomainName( ByteBuffer byteBuffer, String domainName )
+    {
+        String[] labels = domainName.split( "\\." );
+
+        for ( int ii = 0; ii < labels.length; ii++ )
+        {
+            byteBuffer.put( (byte) labels[ ii ].length() );
+
+            char[] characters = labels[ ii ].toCharArray();
+            for ( int jj = 0; jj < characters.length; jj++ )
+            {
+                byteBuffer.put( (byte) characters[ jj ] );
+            }
+        }
+
+        byteBuffer.put( (byte) 0x00 );
+    }
+
+    protected void encodeRecordType( ByteBuffer byteBuffer, RecordType recordType )
+    {
+        byteBuffer.putShort( (short) recordType.getOrdinal() );
+    }
+
+    protected void encodeRecordClass( ByteBuffer byteBuffer, RecordClass recordClass )
+    {
+        byteBuffer.putShort( (short) recordClass.getOrdinal() );
+    }
+
+    /**
+     * <character-string> is a single length octet followed by that number
+     * of characters.  <character-string> is treated as binary information,
+     * and can be up to 256 characters in length (including the length octet).
+     * @param characterString the character string to encode
+     * @return byte array of the encoded character string
+     */
+    protected byte[] encodeCharacterString( String characterString )
+    {
+        ByteBuffer byteBuffer = ByteBuffer.allocate( 256 );
+
+        byteBuffer.put( (byte) characterString.length() );
+
+        char[] characters = characterString.toCharArray();
+
+        for ( int ii = 0; ii < characters.length; ii++ )
+        {
+            byteBuffer.put( (byte) characters[ ii ] );
+        }
+
+        byteBuffer.flip();
+        byte[] bytes = new byte[ byteBuffer.remaining() ];
+        byteBuffer.get( bytes, 0, bytes.length );
+
+        return bytes;
+    }
+
+    protected void putUnsignedByte( ByteBuffer byteBuffer, int value )
+    {
+        byteBuffer.put( (byte) ( value & 0xff ) );
+    }
+
+    protected void putUnsignedByte( ByteBuffer byteBuffer, int position, int value )
+    {
+        byteBuffer.put( position, (byte) ( value & 0xff ) );
+    }
+
+    protected void putUnsignedShort( ByteBuffer byteBuffer, int value )
+    {
+        byteBuffer.putShort( (short) ( value & 0xffff ) );
+    }
+
+    protected void putUnsignedShort( ByteBuffer byteBuffer, int position, int value )
+    {
+        byteBuffer.putShort( position, (short) ( value & 0xffff ) );
+    }
+
+    protected void putUnsignedInt( ByteBuffer byteBuffer, long value )
+    {
+        byteBuffer.putInt( (int) ( value & 0xffffffffL ) );
+    }
+
+    protected void putUnsignedInt( ByteBuffer byteBuffer, int position, long value )
+    {
+        byteBuffer.putInt( position, (int) ( value & 0xffffffffL ) );
+    }
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/ResourceRecordEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native