directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r547508 - in /directory/apacheds/trunk/protocol-dns/src: main/java/org/apache/directory/server/dns/io/encoder/ test/java/org/apache/directory/server/dns/io/encoder/
Date Fri, 15 Jun 2007 03:28:20 GMT
Author: erodriguez
Date: Thu Jun 14 20:28:19 2007
New Revision: 547508

URL: http://svn.apache.org/viewvc?view=rev&rev=547508
Log:
Corrected invalid encoding by removing pre-pended domain name length.
o  Collateral updates to unit tests.

Modified:
    directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/io/encoder/ResourceRecordEncoder.java
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/CanonicalNameRecordEncoderTest.java
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/MailExchangeRecordEncoderTest.java
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/NameServerRecordEncoderTest.java
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/PointerRecordEncoderTest.java
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java

Modified: directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/io/encoder/ResourceRecordEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/io/encoder/ResourceRecordEncoder.java?view=diff&rev=547508&r1=547507&r2=547508
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/io/encoder/ResourceRecordEncoder.java
(original)
+++ directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/io/encoder/ResourceRecordEncoder.java
Thu Jun 14 20:28:19 2007
@@ -52,7 +52,8 @@
 
     protected void putResourceRecord( ByteBuffer byteBuffer, ResourceRecord record )
     {
-        int startPosition = prepareForSizedData( byteBuffer );
+        int startPosition = byteBuffer.position();
+        byteBuffer.position( startPosition + 2 );
 
         putResourceRecordData( byteBuffer, record );
 
@@ -60,41 +61,26 @@
     }
 
 
-    protected int prepareForSizedData( ByteBuffer byteBuffer )
-    {
-        int startPosition = byteBuffer.position();
-        byteBuffer.position( startPosition + 1 );
-        return startPosition;
-    }
-
-
     protected void putDataSize( ByteBuffer byteBuffer, int startPosition )
     {
-        byte length = ( byte ) ( byteBuffer.position() - startPosition + 1 );
+        int endPosition = byteBuffer.position();
+        short length = ( short ) ( endPosition - startPosition - 2 );
+
         byteBuffer.position( startPosition );
-        byteBuffer.put( length );
-        byteBuffer.position( startPosition + length - 1 );
+        byteBuffer.putShort( length );
+        byteBuffer.position( endPosition );
     }
 
 
     /**
      * <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 putDomainName( ByteBuffer byteBuffer, String domainName )
     {
-        int startPosition = prepareForSizedData( byteBuffer );
-
-        putDomainNameData( byteBuffer, domainName );
-
-        putDataSize( byteBuffer, startPosition );
-    }
-
-
-    protected void putDomainNameData( ByteBuffer byteBuffer, String domainName )
-    {
         String[] labels = domainName.split( "\\." );
 
         for ( int ii = 0; ii < labels.length; ii++ )
@@ -128,8 +114,9 @@
      * <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 byteBuffer The byte buffer to encode the character string into.
      * @param characterString the character string to encode
-     * @return byte array of the encoded character string
      */
     protected void putCharacterString( ByteBuffer byteBuffer, String characterString )
     {
@@ -142,5 +129,4 @@
             byteBuffer.put( ( byte ) characters[ii] );
         }
     }
-
 }

Modified: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/CanonicalNameRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/CanonicalNameRecordEncoderTest.java?view=diff&rev=547508&r1=547507&r2=547508
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/CanonicalNameRecordEncoderTest.java
(original)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/CanonicalNameRecordEncoderTest.java
Thu Jun 14 20:28:19 2007
@@ -76,7 +76,6 @@
 
     protected void putExpectedResourceData( ByteBuffer expectedData )
     {
-        expectedData.put( ( byte ) 19 );
         expectedData.put( ( byte ) 18 );
         expectedData.put( ( byte ) cnameParts[0].length() );    // 1
         expectedData.put( cnameParts[0].getBytes() );           // + 5

Modified: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/MailExchangeRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/MailExchangeRecordEncoderTest.java?view=diff&rev=547508&r1=547507&r2=547508
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/MailExchangeRecordEncoderTest.java
(original)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/MailExchangeRecordEncoderTest.java
Thu Jun 14 20:28:19 2007
@@ -61,7 +61,6 @@
     {
         expectedData.put( ( byte ) 20 );
         expectedData.putShort( Short.parseShort( mxPreference ) );
-        expectedData.put( ( byte ) 17 );
         expectedData.put( ( byte ) mxParts[0].length() );    // 1
         expectedData.put( mxParts[0].getBytes() );           // + 4
         expectedData.put( ( byte ) mxParts[1].length() );    // + 1

Modified: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/NameServerRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/NameServerRecordEncoderTest.java?view=diff&rev=547508&r1=547507&r2=547508
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/NameServerRecordEncoderTest.java
(original)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/NameServerRecordEncoderTest.java
Thu Jun 14 20:28:19 2007
@@ -53,7 +53,6 @@
 
     protected void putExpectedResourceData( ByteBuffer expectedData )
     {
-        expectedData.put( (byte ) 20 );
         expectedData.put( ( byte ) 19 );
         expectedData.put( ( byte ) nsParts[0].length() );    // 1
         expectedData.put( nsParts[0].getBytes() );           // + 3

Modified: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/PointerRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/PointerRecordEncoderTest.java?view=diff&rev=547508&r1=547507&r2=547508
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/PointerRecordEncoderTest.java
(original)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/PointerRecordEncoderTest.java
Thu Jun 14 20:28:19 2007
@@ -53,7 +53,6 @@
 
     protected void putExpectedResourceData( ByteBuffer expectedData )
     {
-        expectedData.put( ( byte ) 16 );
         expectedData.put( ( byte ) 15 );
         expectedData.put( ( byte ) ptrParts[0].length() );    // 1
         expectedData.put( ptrParts[0].getBytes() );           // + 3

Modified: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java?view=diff&rev=547508&r1=547507&r2=547508
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java
(original)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java
Thu Jun 14 20:28:19 2007
@@ -66,7 +66,6 @@
         expectedData.putShort( Short.parseShort( priority ) );
         expectedData.putShort( Short.parseShort( weight ) );
         expectedData.putShort( Short.parseShort( port ) );
-        expectedData.put( ( byte ) 16 );
         expectedData.put( ( byte ) srvParts[0].length() );  // 1
         expectedData.put( srvParts[0].getBytes() );         // + 3
         expectedData.put( ( byte ) srvParts[1].length() );  // + 1

Modified: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java?view=diff&rev=547508&r1=547507&r2=547508
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java
(original)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java
Thu Jun 14 20:28:19 2007
@@ -69,7 +69,6 @@
     protected void putExpectedResourceData( ByteBuffer expectedData )
     {
         expectedData.put( ( byte ) 60 );   // 1 + 18 + 1 + 20 + 4 + 4 + 4 + 4 + 4
-        expectedData.put( ( byte ) 18 );
         expectedData.put( ( byte ) mNameParts[0].length() );    // 1
         expectedData.put( mNameParts[0].getBytes() );           // + 2
         expectedData.put( ( byte ) mNameParts[1].length() );    // + 1
@@ -77,7 +76,6 @@
         expectedData.put( ( byte ) mNameParts[2].length() );    // + 1
         expectedData.put( mNameParts[2].getBytes() );           // + 3
         expectedData.put( ( byte  ) 0x00 );                     // + 1 = 18
-        expectedData.put( ( byte ) 20 );
         expectedData.put( ( byte ) rNameParts[0].length() );    // 1
         expectedData.put( rNameParts[0].getBytes() );           // + 4
         expectedData.put( ( byte ) rNameParts[1].length() );    // + 1



Mime
View raw message