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/01 09:55:52 UTC
svn commit: r265668 [1/3] - in /directory/protocol-providers/dns/trunk/src:
java/org/apache/dns/ java/org/apache/dns/io/ java/org/apache/dns/messages/
java/org/apache/dns/protocol/ java/org/apache/dns/records/
java/org/apache/dns/records/internet/ java...
Author: erodriguez
Date: Thu Sep 1 00:55:12 2005
New Revision: 265668
URL: http://svn.apache.org/viewcvs?rev=265668&view=rev
Log:
Formatting: imports, line breaks, whitespace, or other code convention.
Modified:
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DnsException.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DomainNameService.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/ByteBufferCodec.java
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/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/MessageType.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/OpCode.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/ResponseCode.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/protocol/DnsProtocolProvider.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/InternetResource.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/QuestionRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/Record.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/RecordClass.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/RecordType.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/ResourceRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/internet/AddressRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/internet/ProtocolType.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/internet/ServiceType.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/internet/WellKnownServicesRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/standard/CanonicalNameRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/standard/HostInformationRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/standard/MailExchangeRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/standard/MailInformationRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/standard/NameServerRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/standard/PointerRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/standard/StartOfAuthorityRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/standard/TextRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/zone/A6Record.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/zone/CertificateRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/zone/DnameRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/zone/Inet6AddressRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/zone/KeyExchangeRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/zone/KeyRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/zone/LocationRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/zone/NameAuthorityPointer.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/zone/NextNameRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/zone/ServerSelectionRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/zone/SignatureRecord.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DomainNameServiceImpl.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/DnsRecordStateFactory.java
directory/protocol-providers/dns/trunk/src/test/org/apache/dns/AbstractDnsTestCase.java
directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DnsMessageDecoderTest.java
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DnsException.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DnsException.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DnsException.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DnsException.java Thu Sep 1 00:55:12 2005
@@ -17,7 +17,6 @@
package org.apache.dns;
-
public class DnsException extends Exception
{
/**
@@ -40,4 +39,3 @@
super( description );
}
}
-
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DomainNameService.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DomainNameService.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DomainNameService.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DomainNameService.java Thu Sep 1 00:55:12 2005
@@ -19,12 +19,10 @@
import org.apache.dns.messages.DnsMessage;
-
/**
* DNS Protocol (RFC 1034, RFC 1035)
*/
public interface DomainNameService
{
- public DnsMessage getReplyFor( DnsMessage request );
+ public DnsMessage getReplyFor( DnsMessage request );
}
-
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/ByteBufferCodec.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/ByteBufferCodec.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/ByteBufferCodec.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/ByteBufferCodec.java Thu Sep 1 00:55:12 2005
@@ -19,67 +19,65 @@
import java.nio.ByteBuffer;
-
public class ByteBufferCodec
{
- public static short getUnsignedByte( ByteBuffer byteBuffer )
- {
- return ( (short)( byteBuffer.get() & 0xff ) );
- }
-
- public static void putUnsignedByte( ByteBuffer byteBuffer, int value )
- {
- byteBuffer.put( (byte)( value & 0xff ) );
- }
-
- public static short getUnsignedByte( ByteBuffer byteBuffer, int position )
- {
- return ( (short)( byteBuffer.get( position ) & (short)0xff ) );
- }
-
- public static void putUnsignedByte( ByteBuffer byteBuffer, int position, int value )
- {
- byteBuffer.put( position, (byte)( value & 0xff ) );
- }
-
- public static int getUnsignedShort( ByteBuffer byteBuffer )
- {
- return ( byteBuffer.getShort() & 0xffff );
- }
-
- public static void putUnsignedShort( ByteBuffer byteBuffer, int value )
- {
- byteBuffer.putShort( (short)( value & 0xffff ) );
- }
-
- public static int getUnsignedShort( ByteBuffer byteBuffer, int position )
- {
- return ( byteBuffer.getShort( position ) & 0xffff );
- }
-
- public static void putUnsignedShort( ByteBuffer byteBuffer, int position, int value )
- {
- byteBuffer.putShort( position, (short)( value & 0xffff ) );
- }
-
- public static long getUnsignedInt( ByteBuffer byteBuffer )
- {
- return ( byteBuffer.getInt() & 0xffffffffL );
- }
-
- public static void putUnsignedInt( ByteBuffer byteBuffer, long value )
- {
- byteBuffer.putInt( (int)( value & 0xffffffffL ) );
- }
-
- public static long getUnsignedInt( ByteBuffer byteBuffer, int position )
- {
- return ( byteBuffer.getInt( position ) & 0xffffffffL );
- }
-
- public static void putUnsignedInt( ByteBuffer byteBuffer, int position, long value )
- {
- byteBuffer.putInt( position, (int)( value & 0xffffffffL ) );
- }
+ public static short getUnsignedByte( ByteBuffer byteBuffer )
+ {
+ return ( (short) ( byteBuffer.get() & 0xff ) );
+ }
+
+ public static void putUnsignedByte( ByteBuffer byteBuffer, int value )
+ {
+ byteBuffer.put( (byte) ( value & 0xff ) );
+ }
+
+ public static short getUnsignedByte( ByteBuffer byteBuffer, int position )
+ {
+ return ( (short) ( byteBuffer.get( position ) & (short) 0xff ) );
+ }
+
+ public static void putUnsignedByte( ByteBuffer byteBuffer, int position, int value )
+ {
+ byteBuffer.put( position, (byte) ( value & 0xff ) );
+ }
+
+ public static int getUnsignedShort( ByteBuffer byteBuffer )
+ {
+ return ( byteBuffer.getShort() & 0xffff );
+ }
+
+ public static void putUnsignedShort( ByteBuffer byteBuffer, int value )
+ {
+ byteBuffer.putShort( (short) ( value & 0xffff ) );
+ }
+
+ public static int getUnsignedShort( ByteBuffer byteBuffer, int position )
+ {
+ return ( byteBuffer.getShort( position ) & 0xffff );
+ }
+
+ public static void putUnsignedShort( ByteBuffer byteBuffer, int position, int value )
+ {
+ byteBuffer.putShort( position, (short) ( value & 0xffff ) );
+ }
+
+ public static long getUnsignedInt( ByteBuffer byteBuffer )
+ {
+ return ( byteBuffer.getInt() & 0xffffffffL );
+ }
+
+ public static void putUnsignedInt( ByteBuffer byteBuffer, long value )
+ {
+ byteBuffer.putInt( (int) ( value & 0xffffffffL ) );
+ }
+
+ public static long getUnsignedInt( ByteBuffer byteBuffer, int position )
+ {
+ return ( byteBuffer.getInt( position ) & 0xffffffffL );
+ }
+
+ public static void putUnsignedInt( ByteBuffer byteBuffer, int position, long value )
+ {
+ byteBuffer.putInt( position, (int) ( value & 0xffffffffL ) );
+ }
}
-
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/DnsMessageDecoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/DnsMessageDecoder.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/DnsMessageDecoder.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/DnsMessageDecoder.java Thu Sep 1 00:55:12 2005
@@ -29,170 +29,168 @@
import org.apache.dns.records.RecordType;
import org.apache.dns.records.ResourceRecord;
-
public class DnsMessageDecoder
{
- public DnsMessage decode( ByteBuffer byteBuffer )
- {
- DnsMessageModifier modifier = new DnsMessageModifier();
-
- modifier.setTransactionId( byteBuffer.getShort() );
-
- byte header = byteBuffer.get();
- modifier.setMessageType( parseMessageType( header ) );
- modifier.setOpCode( parseOpCode( header ) );
- modifier.setAuthoritativeAnswer( parseAuthoritativeAnswer( header ) );
- modifier.setTruncated( parseTruncated( header ) );
- modifier.setRecursionDesired( parseRecursionDesired( header ) );
-
- header = byteBuffer.get();
- modifier.setRecursionAvailable( parseRecursionAvailable( header ) );
- modifier.setResponseCode( parseResponseCode( header ) );
-
- short questionCount = byteBuffer.getShort();
- short answerCount = byteBuffer.getShort();
- short authorityCount = byteBuffer.getShort();
- short additionalCount = byteBuffer.getShort();
-
- modifier.setQuestionRecords( parseQuestions( questionCount, byteBuffer ) );
- modifier.setAnswerRecords( parseRecords( answerCount, byteBuffer ) );
- modifier.setAuthorityRecords( parseRecords( authorityCount, byteBuffer ) );
- modifier.setAdditionalRecords( parseRecords( additionalCount, byteBuffer ) );
-
- return modifier.getDnsMessage();
- }
-
- private ResourceRecord[] parseRecords( short recordCount, ByteBuffer byteBuffer )
- {
- ResourceRecord[] records = new ResourceRecord[ recordCount ];
-
- for ( int ii = 0; ii < recordCount; ii++ )
- {
- String domainName = parseDomainName( byteBuffer );
-
- RecordType recordType = RecordType.getTypeByOrdinal( byteBuffer.getShort() );
- RecordClass recordClass = RecordClass.getTypeByOrdinal( byteBuffer.getShort() );
-
- int timeToLive = byteBuffer.getInt();
- short dataLength = byteBuffer.getShort();
-
- byte[] data = new byte[ dataLength ];
- byteBuffer.get( data );
-
- try
- {
- records[ ii ] = ResourceRecordDecoder.getInstance( domainName, recordType,
- recordClass, timeToLive, data );
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- return records;
- }
-
- private QuestionRecord[] parseQuestions( short questionCount, ByteBuffer byteBuffer )
- {
- QuestionRecord[] questions = new QuestionRecord[ questionCount ];
-
- for ( int ii = 0; ii < questionCount; ii++ )
- {
- String domainName = parseDomainName( byteBuffer );
-
- RecordType recordType = RecordType.getTypeByOrdinal( byteBuffer.getShort() );
- RecordClass recordClass = RecordClass.getTypeByOrdinal( byteBuffer.getShort() );
-
- questions[ ii ] = new QuestionRecord( domainName, recordType, recordClass );
- }
-
- return questions;
- }
-
- private String parseDomainName( ByteBuffer byteBuffer )
- {
- StringBuffer domainName = new StringBuffer();
- recurseDomainName( domainName, byteBuffer );
-
- return domainName.toString();
- }
-
- private void recurseDomainName( StringBuffer domainName, ByteBuffer byteBuffer )
- {
- byte currentByte = byteBuffer.get();
-
- boolean isCompressed = ( ( currentByte & (byte)0xc0 ) == (byte)0xc0 );
- boolean isLabelLength = ( ( currentByte != 0 ) && !isCompressed );
-
- if ( isCompressed )
- {
- int position = byteBuffer.get();
- int originalPosition = byteBuffer.position();
- byteBuffer.position( position );
-
- int labelLength = byteBuffer.get();
- getLabel( labelLength, byteBuffer, domainName );
- recurseDomainName( domainName, byteBuffer );
-
- byteBuffer.position( originalPosition );
- }
-
- if ( isLabelLength )
- {
- int labelLength = currentByte;
- getLabel( labelLength, byteBuffer, domainName );
- recurseDomainName( domainName, byteBuffer );
- }
- }
-
- private void getLabel( int labelLength, ByteBuffer byteBuffer, StringBuffer domainName )
- {
- for ( int jj = 0; jj < labelLength; jj++ )
- {
- char character = (char)byteBuffer.get();
- domainName.append( character );
- }
-
- if ( byteBuffer.get( byteBuffer.position() ) != 0 )
- {
- domainName.append( "." );
- }
- }
-
- private MessageType parseMessageType( byte header )
- {
- return MessageType.getTypeByOrdinal( ( header & 0x80 ) >>> 7 );
- }
-
- private OpCode parseOpCode( byte header )
- {
- return OpCode.getTypeByOrdinal( ( header & 0x78 ) >>> 3 );
- }
-
- private boolean parseAuthoritativeAnswer( byte header )
- {
- return ( ( header & 0x04 ) >>> 2 ) == 1;
- }
-
- private boolean parseTruncated( byte header )
- {
- return ( ( header & 0x02 ) >>> 1 ) == 1;
- }
-
- private boolean parseRecursionDesired( byte header )
- {
- return ( ( header & 0x01 ) ) == 1;
- }
-
- private boolean parseRecursionAvailable( byte header )
- {
- return ( ( header & 0x80 ) >>> 7 ) == 1;
- }
-
- private ResponseCode parseResponseCode( byte header )
- {
- return ResponseCode.getTypeByOrdinal( header & 0x0F );
- }
-}
+ public DnsMessage decode( ByteBuffer byteBuffer )
+ {
+ DnsMessageModifier modifier = new DnsMessageModifier();
+
+ modifier.setTransactionId( byteBuffer.getShort() );
+
+ byte header = byteBuffer.get();
+ modifier.setMessageType( parseMessageType( header ) );
+ modifier.setOpCode( parseOpCode( header ) );
+ modifier.setAuthoritativeAnswer( parseAuthoritativeAnswer( header ) );
+ modifier.setTruncated( parseTruncated( header ) );
+ modifier.setRecursionDesired( parseRecursionDesired( header ) );
+
+ header = byteBuffer.get();
+ modifier.setRecursionAvailable( parseRecursionAvailable( header ) );
+ modifier.setResponseCode( parseResponseCode( header ) );
+
+ short questionCount = byteBuffer.getShort();
+ short answerCount = byteBuffer.getShort();
+ short authorityCount = byteBuffer.getShort();
+ short additionalCount = byteBuffer.getShort();
+
+ modifier.setQuestionRecords( parseQuestions( questionCount, byteBuffer ) );
+ modifier.setAnswerRecords( parseRecords( answerCount, byteBuffer ) );
+ modifier.setAuthorityRecords( parseRecords( authorityCount, byteBuffer ) );
+ modifier.setAdditionalRecords( parseRecords( additionalCount, byteBuffer ) );
+
+ return modifier.getDnsMessage();
+ }
+
+ private ResourceRecord[] parseRecords( short recordCount, ByteBuffer byteBuffer )
+ {
+ ResourceRecord[] records = new ResourceRecord[ recordCount ];
+
+ for ( int ii = 0; ii < recordCount; ii++ )
+ {
+ String domainName = parseDomainName( byteBuffer );
+
+ RecordType recordType = RecordType.getTypeByOrdinal( byteBuffer.getShort() );
+ RecordClass recordClass = RecordClass.getTypeByOrdinal( byteBuffer.getShort() );
+
+ int timeToLive = byteBuffer.getInt();
+ short dataLength = byteBuffer.getShort();
+
+ byte[] data = new byte[ dataLength ];
+ byteBuffer.get( data );
+
+ try
+ {
+ records[ ii ] = ResourceRecordDecoder.getInstance( domainName, recordType, recordClass, timeToLive,
+ data );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ return records;
+ }
+
+ private QuestionRecord[] parseQuestions( short questionCount, ByteBuffer byteBuffer )
+ {
+ QuestionRecord[] questions = new QuestionRecord[ questionCount ];
+
+ for ( int ii = 0; ii < questionCount; ii++ )
+ {
+ String domainName = parseDomainName( byteBuffer );
+
+ RecordType recordType = RecordType.getTypeByOrdinal( byteBuffer.getShort() );
+ RecordClass recordClass = RecordClass.getTypeByOrdinal( byteBuffer.getShort() );
+
+ questions[ ii ] = new QuestionRecord( domainName, recordType, recordClass );
+ }
+ return questions;
+ }
+
+ private String parseDomainName( ByteBuffer byteBuffer )
+ {
+ StringBuffer domainName = new StringBuffer();
+ recurseDomainName( domainName, byteBuffer );
+
+ return domainName.toString();
+ }
+
+ private void recurseDomainName( StringBuffer domainName, ByteBuffer byteBuffer )
+ {
+ byte currentByte = byteBuffer.get();
+
+ boolean isCompressed = ( ( currentByte & (byte) 0xc0 ) == (byte) 0xc0 );
+ boolean isLabelLength = ( ( currentByte != 0 ) && !isCompressed );
+
+ if ( isCompressed )
+ {
+ int position = byteBuffer.get();
+ int originalPosition = byteBuffer.position();
+ byteBuffer.position( position );
+
+ int labelLength = byteBuffer.get();
+ getLabel( labelLength, byteBuffer, domainName );
+ recurseDomainName( domainName, byteBuffer );
+
+ byteBuffer.position( originalPosition );
+ }
+
+ if ( isLabelLength )
+ {
+ int labelLength = currentByte;
+ getLabel( labelLength, byteBuffer, domainName );
+ recurseDomainName( domainName, byteBuffer );
+ }
+ }
+
+ private void getLabel( int labelLength, ByteBuffer byteBuffer, StringBuffer domainName )
+ {
+ for ( int jj = 0; jj < labelLength; jj++ )
+ {
+ char character = (char) byteBuffer.get();
+ domainName.append( character );
+ }
+
+ if ( byteBuffer.get( byteBuffer.position() ) != 0 )
+ {
+ domainName.append( "." );
+ }
+ }
+
+ private MessageType parseMessageType( byte header )
+ {
+ return MessageType.getTypeByOrdinal( ( header & 0x80 ) >>> 7 );
+ }
+
+ private OpCode parseOpCode( byte header )
+ {
+ return OpCode.getTypeByOrdinal( ( header & 0x78 ) >>> 3 );
+ }
+
+ private boolean parseAuthoritativeAnswer( byte header )
+ {
+ return ( ( header & 0x04 ) >>> 2 ) == 1;
+ }
+
+ private boolean parseTruncated( byte header )
+ {
+ return ( ( header & 0x02 ) >>> 1 ) == 1;
+ }
+
+ private boolean parseRecursionDesired( byte header )
+ {
+ return ( ( header & 0x01 ) ) == 1;
+ }
+
+ private boolean parseRecursionAvailable( byte header )
+ {
+ return ( ( header & 0x80 ) >>> 7 ) == 1;
+ }
+
+ private ResponseCode parseResponseCode( byte header )
+ {
+ return ResponseCode.getTypeByOrdinal( header & 0x0F );
+ }
+}
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/DnsMessageEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/DnsMessageEncoder.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/DnsMessageEncoder.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/DnsMessageEncoder.java Thu Sep 1 00:55:12 2005
@@ -27,94 +27,93 @@
public class DnsMessageEncoder
{
- public void encode( ByteBuffer byteBuffer, DnsMessage message )
- {
- byteBuffer.putShort( message.getTransactionId() );
-
- byte header = (byte)0x00;
- header = encodeMessageType( message.getMessageType(), header );
- header = encodeOpCode( message.getOpCode(), header );
- header = encodeAuthoritativeAnswer( message.isAuthoritativeAnswer(), header );
- header = encodeTruncated( message.isTruncated(), header );
- header = encodeRecursionDesired( message.isRecursionDesired(), header );
- byteBuffer.put( header );
-
- header = (byte)0x00;
- header = encodeRecursionAvailable( message.isRecursionAvailable(), header );
- header = encodeResponseCode( message.getResponseCode(), header );
- byteBuffer.put( header );
-
- byteBuffer.putShort( (short)message.getQuestionRecords().length );
- byteBuffer.putShort( (short)message.getAnswerRecords().length );
- byteBuffer.putShort( (short)message.getAuthorityRecords().length );
- byteBuffer.putShort( (short)message.getAdditionalRecords().length );
-
- encodeRecords( message.getQuestionRecords(), byteBuffer );
- encodeRecords( message.getAnswerRecords(), byteBuffer );
- encodeRecords( message.getAuthorityRecords(), byteBuffer );
- encodeRecords( message.getAdditionalRecords(), byteBuffer );
- }
-
- private byte encodeMessageType( MessageType messageType, byte header )
- {
- byte oneBit = (byte)( messageType.getOrdinal() & 0x01 );
- return (byte)( ( oneBit << 7 ) | header );
- }
-
- private byte encodeOpCode( OpCode opCode, byte header )
- {
- byte fourBits = (byte)( opCode.getOrdinal() & 0x0F );
- return (byte)( ( fourBits << 3 ) | header );
- }
-
- private byte encodeAuthoritativeAnswer( boolean authoritative, byte header )
- {
- if ( authoritative )
- {
- header = (byte)( ( (byte)0x01 << 2 ) | header );
- }
- return header;
- }
-
- private byte encodeTruncated( boolean truncated, byte header )
- {
- if ( truncated )
- {
- header = (byte)( ( (byte)0x01 << 1 ) | header );
- }
- return header;
- }
-
- private byte encodeRecursionDesired( boolean recursionDesired, byte header )
- {
- if ( recursionDesired )
- {
- header = (byte)( ( (byte)0x01 ) | header );
- }
- return header;
- }
-
- private byte encodeRecursionAvailable( boolean recursionAvailable, byte header )
- {
- if ( recursionAvailable )
- {
- header = (byte)( ( (byte)0x01 << 7 ) | header );
- }
- return header;
- }
-
- private byte encodeResponseCode( ResponseCode responseCode, byte header )
- {
- byte fourBits = (byte)( responseCode.getOrdinal() & 0x0F );
- return (byte)( fourBits | header );
- }
-
- private void encodeRecords( Record[] records, ByteBuffer byteBuffer )
- {
- for ( int ii = 0; ii < records.length; ii++ )
- {
- records[ ii ].writeTo( byteBuffer );
- }
- }
-}
+ public void encode( ByteBuffer byteBuffer, DnsMessage message )
+ {
+ byteBuffer.putShort( message.getTransactionId() );
+
+ byte header = (byte) 0x00;
+ header = encodeMessageType( message.getMessageType(), header );
+ header = encodeOpCode( message.getOpCode(), header );
+ header = encodeAuthoritativeAnswer( message.isAuthoritativeAnswer(), header );
+ header = encodeTruncated( message.isTruncated(), header );
+ header = encodeRecursionDesired( message.isRecursionDesired(), header );
+ byteBuffer.put( header );
+
+ header = (byte) 0x00;
+ header = encodeRecursionAvailable( message.isRecursionAvailable(), header );
+ header = encodeResponseCode( message.getResponseCode(), header );
+ byteBuffer.put( header );
+
+ byteBuffer.putShort( (short) message.getQuestionRecords().length );
+ byteBuffer.putShort( (short) message.getAnswerRecords().length );
+ byteBuffer.putShort( (short) message.getAuthorityRecords().length );
+ byteBuffer.putShort( (short) message.getAdditionalRecords().length );
+
+ encodeRecords( message.getQuestionRecords(), byteBuffer );
+ encodeRecords( message.getAnswerRecords(), byteBuffer );
+ encodeRecords( message.getAuthorityRecords(), byteBuffer );
+ encodeRecords( message.getAdditionalRecords(), byteBuffer );
+ }
+
+ private byte encodeMessageType( MessageType messageType, byte header )
+ {
+ byte oneBit = (byte) ( messageType.getOrdinal() & 0x01 );
+ return (byte) ( ( oneBit << 7 ) | header );
+ }
+
+ private byte encodeOpCode( OpCode opCode, byte header )
+ {
+ byte fourBits = (byte) ( opCode.getOrdinal() & 0x0F );
+ return (byte) ( ( fourBits << 3 ) | header );
+ }
+ private byte encodeAuthoritativeAnswer( boolean authoritative, byte header )
+ {
+ if ( authoritative )
+ {
+ header = (byte) ( ( (byte) 0x01 << 2 ) | header );
+ }
+ return header;
+ }
+
+ private byte encodeTruncated( boolean truncated, byte header )
+ {
+ if ( truncated )
+ {
+ header = (byte) ( ( (byte) 0x01 << 1 ) | header );
+ }
+ return header;
+ }
+
+ private byte encodeRecursionDesired( boolean recursionDesired, byte header )
+ {
+ if ( recursionDesired )
+ {
+ header = (byte) ( ( (byte) 0x01 ) | header );
+ }
+ return header;
+ }
+
+ private byte encodeRecursionAvailable( boolean recursionAvailable, byte header )
+ {
+ if ( recursionAvailable )
+ {
+ header = (byte) ( ( (byte) 0x01 << 7 ) | header );
+ }
+ return header;
+ }
+
+ private byte encodeResponseCode( ResponseCode responseCode, byte header )
+ {
+ byte fourBits = (byte) ( responseCode.getOrdinal() & 0x0F );
+ return (byte) ( fourBits | header );
+ }
+
+ private void encodeRecords( Record[] records, ByteBuffer byteBuffer )
+ {
+ for ( int ii = 0; ii < records.length; ii++ )
+ {
+ records[ ii ].writeTo( byteBuffer );
+ }
+ }
+}
Modified: 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/ResourceRecordDecoder.java?rev=265668&r1=265667&r2=265668&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/ResourceRecordDecoder.java Thu Sep 1 00:55:12 2005
@@ -34,42 +34,40 @@
public class ResourceRecordDecoder
{
- public static ResourceRecord getInstance( String domainName, RecordType recordType,
- RecordClass recordClass, int timeToLive, byte[] resourceData )
- throws DnsException
- {
- if ( recordClass != RecordClass.IN )
- {
- throw new DnsException( "Unsupported record class: " + recordClass );
- }
-
- 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:
- throw new DnsException( "Unsupported or bad option code: " + tag );
- }
- }
-}
+ public static ResourceRecord getInstance( String domainName, RecordType recordType, RecordClass recordClass,
+ int timeToLive, byte[] resourceData ) throws DnsException
+ {
+ if ( recordClass != RecordClass.IN )
+ {
+ throw new DnsException( "Unsupported record class: " + recordClass );
+ }
+
+ 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:
+ throw new DnsException( "Unsupported or bad option code: " + tag );
+ }
+ }
+}
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/DnsMessage.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/DnsMessage.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/DnsMessage.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/DnsMessage.java Thu Sep 1 00:55:12 2005
@@ -39,167 +39,164 @@
*/
public class DnsMessage
{
- /**
- * The header section is always present. The header includes fields that
- * specify which of the remaining sections are present, and also specify
- * whether the message is a query or a response, a standard query or some
- * other opcode, etc.
- */
- private short transactionId;
- private MessageType messageType;
- private OpCode opCode;
- private boolean authoritativeAnswer;
- private boolean truncated;
- private boolean recursionDesired;
- private boolean recursionAvailable;
- private boolean reserved;
- private boolean acceptNonAuthenticatedData;
-
- private ResponseCode responseCode;
-
- private QuestionRecord[] questionRecords;
- private ResourceRecord[] answerRecords;
- private ResourceRecord[] authorityRecords;
- private ResourceRecord[] additionalRecords;
-
- public DnsMessage( short transactionId, MessageType messageType,
- OpCode opCode, boolean authoritativeAnswer, boolean truncated,
- boolean recursionDesired, boolean recursionAvailable,
- boolean reserved, boolean acceptNonAuthenticatedData,
- ResponseCode responseCode, QuestionRecord[] question,
- ResourceRecord[] answer, ResourceRecord[] authority, ResourceRecord[] additional )
- {
- this.transactionId = transactionId;
- this.messageType = messageType;
- this.opCode = opCode;
- this.authoritativeAnswer = authoritativeAnswer;
- this.truncated = truncated;
- this.recursionDesired = recursionDesired;
- this.recursionAvailable = recursionAvailable;
- this.reserved = reserved;
- this.acceptNonAuthenticatedData = acceptNonAuthenticatedData;
- this.responseCode = responseCode;
- this.questionRecords = question;
- this.answerRecords = answer;
- this.authorityRecords = authority;
- this.additionalRecords = additional;
- }
-
- /**
- * @return Returns the acceptNonAuthenticatedData.
- */
- public boolean isAcceptNonAuthenticatedData()
- {
- return acceptNonAuthenticatedData;
- }
-
- /**
- * @return Returns the additional.
- */
- public ResourceRecord[] getAdditionalRecords()
- {
- return additionalRecords;
- }
-
- /**
- * @return Returns the answer.
- */
- public ResourceRecord[] getAnswerRecords()
- {
- return answerRecords;
- }
-
- /**
- * @return Returns the authoritativeAnswer.
- */
- public boolean isAuthoritativeAnswer()
- {
- return authoritativeAnswer;
- }
-
- /**
- * @return Returns the authority.
- */
- public ResourceRecord[] getAuthorityRecords()
- {
- return authorityRecords;
- }
-
- /**
- * @return Returns the messageType.
- */
- public MessageType getMessageType()
- {
- return messageType;
- }
-
- /**
- * @return Returns the opCode.
- */
- public OpCode getOpCode()
- {
- return opCode;
- }
-
- /**
- * @return Returns the question.
- */
- public QuestionRecord[] getQuestionRecords()
- {
- return questionRecords;
- }
-
- /**
- * @return Returns the recursionAvailable.
- */
- public boolean isRecursionAvailable()
- {
- return recursionAvailable;
- }
-
- /**
- * @return Returns the recursionDesired.
- */
- public boolean isRecursionDesired()
- {
- return recursionDesired;
- }
-
- /**
- * @return Returns the reserved.
- */
- public boolean isReserved()
- {
- return reserved;
- }
-
- /**
- * @return Returns the responseCode.
- */
- public ResponseCode getResponseCode()
- {
- return responseCode;
- }
-
- /**
- * @return Returns the transactionId.
- */
- public short getTransactionId()
- {
- return transactionId;
- }
-
- /**
- * @return Returns the truncated.
- */
- public boolean isTruncated()
- {
- return truncated;
- }
-
- public String toString()
- {
- return getClass().getName() + "[ transactionId = " + transactionId + " ]";
- }
-}
+ /**
+ * The header section is always present. The header includes fields that
+ * specify which of the remaining sections are present, and also specify
+ * whether the message is a query or a response, a standard query or some
+ * other opcode, etc.
+ */
+ private short transactionId;
+ private MessageType messageType;
+ private OpCode opCode;
+ private boolean authoritativeAnswer;
+ private boolean truncated;
+ private boolean recursionDesired;
+ private boolean recursionAvailable;
+ private boolean reserved;
+ private boolean acceptNonAuthenticatedData;
+
+ private ResponseCode responseCode;
+
+ private QuestionRecord[] questionRecords;
+ private ResourceRecord[] answerRecords;
+ private ResourceRecord[] authorityRecords;
+ private ResourceRecord[] additionalRecords;
+
+ public DnsMessage( short transactionId, MessageType messageType, OpCode opCode, boolean authoritativeAnswer,
+ boolean truncated, boolean recursionDesired, boolean recursionAvailable, boolean reserved,
+ boolean acceptNonAuthenticatedData, ResponseCode responseCode, QuestionRecord[] question,
+ ResourceRecord[] answer, ResourceRecord[] authority, ResourceRecord[] additional )
+ {
+ this.transactionId = transactionId;
+ this.messageType = messageType;
+ this.opCode = opCode;
+ this.authoritativeAnswer = authoritativeAnswer;
+ this.truncated = truncated;
+ this.recursionDesired = recursionDesired;
+ this.recursionAvailable = recursionAvailable;
+ this.reserved = reserved;
+ this.acceptNonAuthenticatedData = acceptNonAuthenticatedData;
+ this.responseCode = responseCode;
+ this.questionRecords = question;
+ this.answerRecords = answer;
+ this.authorityRecords = authority;
+ this.additionalRecords = additional;
+ }
+
+ /**
+ * @return Returns the acceptNonAuthenticatedData.
+ */
+ public boolean isAcceptNonAuthenticatedData()
+ {
+ return acceptNonAuthenticatedData;
+ }
+
+ /**
+ * @return Returns the additional.
+ */
+ public ResourceRecord[] getAdditionalRecords()
+ {
+ return additionalRecords;
+ }
+
+ /**
+ * @return Returns the answer.
+ */
+ public ResourceRecord[] getAnswerRecords()
+ {
+ return answerRecords;
+ }
+
+ /**
+ * @return Returns the authoritativeAnswer.
+ */
+ public boolean isAuthoritativeAnswer()
+ {
+ return authoritativeAnswer;
+ }
+
+ /**
+ * @return Returns the authority.
+ */
+ public ResourceRecord[] getAuthorityRecords()
+ {
+ return authorityRecords;
+ }
+
+ /**
+ * @return Returns the messageType.
+ */
+ public MessageType getMessageType()
+ {
+ return messageType;
+ }
+ /**
+ * @return Returns the opCode.
+ */
+ public OpCode getOpCode()
+ {
+ return opCode;
+ }
+
+ /**
+ * @return Returns the question.
+ */
+ public QuestionRecord[] getQuestionRecords()
+ {
+ return questionRecords;
+ }
+
+ /**
+ * @return Returns the recursionAvailable.
+ */
+ public boolean isRecursionAvailable()
+ {
+ return recursionAvailable;
+ }
+
+ /**
+ * @return Returns the recursionDesired.
+ */
+ public boolean isRecursionDesired()
+ {
+ return recursionDesired;
+ }
+
+ /**
+ * @return Returns the reserved.
+ */
+ public boolean isReserved()
+ {
+ return reserved;
+ }
+
+ /**
+ * @return Returns the responseCode.
+ */
+ public ResponseCode getResponseCode()
+ {
+ return responseCode;
+ }
+
+ /**
+ * @return Returns the transactionId.
+ */
+ public short getTransactionId()
+ {
+ return transactionId;
+ }
+
+ /**
+ * @return Returns the truncated.
+ */
+ public boolean isTruncated()
+ {
+ return truncated;
+ }
+
+ public String toString()
+ {
+ return getClass().getName() + "[ transactionId = " + transactionId + " ]";
+ }
+}
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/DnsMessageModifier.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/DnsMessageModifier.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/DnsMessageModifier.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/DnsMessageModifier.java Thu Sep 1 00:55:12 2005
@@ -39,149 +39,145 @@
*/
public class DnsMessageModifier
{
- /**
- * The header section is always present. The header includes fields that
- * specify which of the remaining sections are present, and also specify
- * whether the message is a query or a response, a standard query or some
- * other opcode, etc.
- */
- private short transactionId;
- private MessageType messageType;
- private OpCode opCode;
- private boolean authoritativeAnswer;
- private boolean truncated;
- private boolean recursionDesired;
- private boolean recursionAvailable;
- private boolean reserved;
- private boolean acceptNonAuthenticatedData;
-
- private ResponseCode responseCode;
-
- private QuestionRecord[] questionRecords;
- private ResourceRecord[] answerRecords;
- private ResourceRecord[] authorityRecords;
- private ResourceRecord[] additionalRecords;
-
-
- public DnsMessage getDnsMessage()
- {
- return new DnsMessage( transactionId, messageType, opCode,
- authoritativeAnswer, truncated, recursionDesired,
- recursionAvailable, reserved, acceptNonAuthenticatedData,
- responseCode, questionRecords, answerRecords, authorityRecords,
- additionalRecords );
- }
-
- /**
- * @param acceptNonAuthenticatedData The acceptNonAuthenticatedData to set.
- */
- public void setAcceptNonAuthenticatedData( boolean acceptNonAuthenticatedData )
- {
- this.acceptNonAuthenticatedData = acceptNonAuthenticatedData;
- }
-
- /**
- * @param additional The additional to set.
- */
- public void setAdditionalRecords( ResourceRecord[] additionalRecords )
- {
- this.additionalRecords = additionalRecords;
- }
-
- /**
- * @param answer The answer to set.
- */
- public void setAnswerRecords( ResourceRecord[] answerRecords )
- {
- this.answerRecords = answerRecords;
- }
-
- /**
- * @param authoritativeAnswer The authoritativeAnswer to set.
- */
- public void setAuthoritativeAnswer( boolean authoritativeAnswer )
- {
- this.authoritativeAnswer = authoritativeAnswer;
- }
-
- /**
- * @param authority The authority to set.
- */
- public void setAuthorityRecords( ResourceRecord[] authorityRecords )
- {
- this.authorityRecords = authorityRecords;
- }
-
- /**
- * @param messageType The messageType to set.
- */
- public void setMessageType( MessageType messageType )
- {
- this.messageType = messageType;
- }
-
- /**
- * @param opCode The opCode to set.
- */
- public void setOpCode( OpCode opCode )
- {
- this.opCode = opCode;
- }
-
- /**
- * @param question The question to set.
- */
- public void setQuestionRecords( QuestionRecord[] questionRecords )
- {
- this.questionRecords = questionRecords;
- }
-
- /**
- * @param recursionAvailable The recursionAvailable to set.
- */
- public void setRecursionAvailable( boolean recursionAvailable )
- {
- this.recursionAvailable = recursionAvailable;
- }
-
- /**
- * @param recursionDesired The recursionDesired to set.
- */
- public void setRecursionDesired( boolean recursionDesired )
- {
- this.recursionDesired = recursionDesired;
- }
-
- /**
- * @param reserved The reserved to set.
- */
- public void setReserved( boolean reserved )
- {
- this.reserved = reserved;
- }
-
- /**
- * @param responseCode The responseCode to set.
- */
- public void setResponseCode( ResponseCode responseCode )
- {
- this.responseCode = responseCode;
- }
-
- /**
- * @param transactionId The transactionId to set.
- */
- public void setTransactionId( short transactionId )
- {
- this.transactionId = transactionId;
- }
-
- /**
- * @param truncated The truncated to set.
- */
- public void setTruncated( boolean truncated )
- {
- this.truncated = truncated;
- }
-}
+ /**
+ * The header section is always present. The header includes fields that
+ * specify which of the remaining sections are present, and also specify
+ * whether the message is a query or a response, a standard query or some
+ * other opcode, etc.
+ */
+ private short transactionId;
+ private MessageType messageType;
+ private OpCode opCode;
+ private boolean authoritativeAnswer;
+ private boolean truncated;
+ private boolean recursionDesired;
+ private boolean recursionAvailable;
+ private boolean reserved;
+ private boolean acceptNonAuthenticatedData;
+
+ private ResponseCode responseCode;
+
+ private QuestionRecord[] questionRecords;
+ private ResourceRecord[] answerRecords;
+ private ResourceRecord[] authorityRecords;
+ private ResourceRecord[] additionalRecords;
+
+ public DnsMessage getDnsMessage()
+ {
+ return new DnsMessage( transactionId, messageType, opCode, authoritativeAnswer, truncated, recursionDesired,
+ recursionAvailable, reserved, acceptNonAuthenticatedData, responseCode, questionRecords, answerRecords,
+ authorityRecords, additionalRecords );
+ }
+
+ /**
+ * @param acceptNonAuthenticatedData The acceptNonAuthenticatedData to set.
+ */
+ public void setAcceptNonAuthenticatedData( boolean acceptNonAuthenticatedData )
+ {
+ this.acceptNonAuthenticatedData = acceptNonAuthenticatedData;
+ }
+
+ /**
+ * @param additional The additional to set.
+ */
+ public void setAdditionalRecords( ResourceRecord[] additionalRecords )
+ {
+ this.additionalRecords = additionalRecords;
+ }
+
+ /**
+ * @param answer The answer to set.
+ */
+ public void setAnswerRecords( ResourceRecord[] answerRecords )
+ {
+ this.answerRecords = answerRecords;
+ }
+
+ /**
+ * @param authoritativeAnswer The authoritativeAnswer to set.
+ */
+ public void setAuthoritativeAnswer( boolean authoritativeAnswer )
+ {
+ this.authoritativeAnswer = authoritativeAnswer;
+ }
+
+ /**
+ * @param authority The authority to set.
+ */
+ public void setAuthorityRecords( ResourceRecord[] authorityRecords )
+ {
+ this.authorityRecords = authorityRecords;
+ }
+ /**
+ * @param messageType The messageType to set.
+ */
+ public void setMessageType( MessageType messageType )
+ {
+ this.messageType = messageType;
+ }
+
+ /**
+ * @param opCode The opCode to set.
+ */
+ public void setOpCode( OpCode opCode )
+ {
+ this.opCode = opCode;
+ }
+
+ /**
+ * @param question The question to set.
+ */
+ public void setQuestionRecords( QuestionRecord[] questionRecords )
+ {
+ this.questionRecords = questionRecords;
+ }
+
+ /**
+ * @param recursionAvailable The recursionAvailable to set.
+ */
+ public void setRecursionAvailable( boolean recursionAvailable )
+ {
+ this.recursionAvailable = recursionAvailable;
+ }
+
+ /**
+ * @param recursionDesired The recursionDesired to set.
+ */
+ public void setRecursionDesired( boolean recursionDesired )
+ {
+ this.recursionDesired = recursionDesired;
+ }
+
+ /**
+ * @param reserved The reserved to set.
+ */
+ public void setReserved( boolean reserved )
+ {
+ this.reserved = reserved;
+ }
+
+ /**
+ * @param responseCode The responseCode to set.
+ */
+ public void setResponseCode( ResponseCode responseCode )
+ {
+ this.responseCode = responseCode;
+ }
+
+ /**
+ * @param transactionId The transactionId to set.
+ */
+ public void setTransactionId( short transactionId )
+ {
+ this.transactionId = transactionId;
+ }
+
+ /**
+ * @param truncated The truncated to set.
+ */
+ public void setTruncated( boolean truncated )
+ {
+ this.truncated = truncated;
+ }
+}
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/MessageType.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/MessageType.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/MessageType.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/MessageType.java Thu Sep 1 00:55:12 2005
@@ -21,57 +21,54 @@
import java.util.Collections;
import java.util.List;
-
public final class MessageType implements Comparable
{
- /**
- * Enumeration elements are constructed once upon class loading.
- * Order of appearance here determines the order of compareTo.
- */
- public static final MessageType QUERY = new MessageType( 0, "Query" );
- public static final MessageType RESPONSE = new MessageType( 1, "Response" );
+ /**
+ * Enumeration elements are constructed once upon class loading.
+ * Order of appearance here determines the order of compareTo.
+ */
+ public static final MessageType QUERY = new MessageType( 0, "Query" );
+ public static final MessageType RESPONSE = new MessageType( 1, "Response" );
- public String toString()
+ public String toString()
{
- return name;
- }
+ return name;
+ }
- public int compareTo( Object that )
+ public int compareTo( Object that )
{
- return ordinal - ( (MessageType) that ).ordinal;
- }
+ return ordinal - ( (MessageType) that ).ordinal;
+ }
- public static MessageType getTypeByOrdinal( int type )
+ public static MessageType getTypeByOrdinal( int type )
{
- for ( int ii = 0; ii < values.length; ii++ )
- if ( values[ ii ].ordinal == type )
- return values[ ii ];
- return QUERY;
- }
-
- public int getOrdinal()
+ for ( int ii = 0; ii < values.length; ii++ )
+ if ( values[ ii ].ordinal == type ) return values[ ii ];
+ return QUERY;
+ }
+
+ public int getOrdinal()
{
- return ordinal;
- }
+ return ordinal;
+ }
- /// PRIVATE /////
- private final String name;
- private final int ordinal;
-
- /**
- * Private constructor prevents construction outside of this class.
- */
- private MessageType( int ordinal, String name )
+ /// PRIVATE /////
+ private final String name;
+ private final int ordinal;
+
+ /**
+ * Private constructor prevents construction outside of this class.
+ */
+ private MessageType( int ordinal, String name )
{
this.ordinal = ordinal;
- this.name = name;
- }
+ this.name = name;
+ }
- /**
- * These two lines are all that's necessary to export a List of VALUES.
- */
- private static final MessageType[] values = { QUERY, RESPONSE };
- // VALUES needs to be located here, otherwise illegal forward reference
- public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
+ /**
+ * These two lines are all that's necessary to export a List of VALUES.
+ */
+ private static final MessageType[] values = { QUERY, RESPONSE };
+ // VALUES needs to be located here, otherwise illegal forward reference
+ public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
}
-
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/OpCode.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/OpCode.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/OpCode.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/OpCode.java Thu Sep 1 00:55:12 2005
@@ -21,60 +21,57 @@
import java.util.Collections;
import java.util.List;
-
public final class OpCode implements Comparable
{
- /**
- * Enumeration elements are constructed once upon class loading.
- * Order of appearance here determines the order of compareTo.
- */
- public static final OpCode QUERY = new OpCode( 0, "Standard query" );
- public static final OpCode IQUERY = new OpCode( 1, "Inverse query" );
- public static final OpCode STATUS = new OpCode( 2, "Server status request" );
- public static final OpCode NOTIFY = new OpCode( 4, "Zone transfer notification" );
- public static final OpCode UPDATE = new OpCode( 5, "Dynamic update message" );
+ /**
+ * Enumeration elements are constructed once upon class loading.
+ * Order of appearance here determines the order of compareTo.
+ */
+ public static final OpCode QUERY = new OpCode( 0, "Standard query" );
+ public static final OpCode IQUERY = new OpCode( 1, "Inverse query" );
+ public static final OpCode STATUS = new OpCode( 2, "Server status request" );
+ public static final OpCode NOTIFY = new OpCode( 4, "Zone transfer notification" );
+ public static final OpCode UPDATE = new OpCode( 5, "Dynamic update message" );
- public String toString()
+ public String toString()
{
- return name;
- }
+ return name;
+ }
- public int compareTo( Object that )
+ public int compareTo( Object that )
{
- return ordinal - ( (OpCode) that ).ordinal;
- }
+ return ordinal - ( (OpCode) that ).ordinal;
+ }
- public static OpCode getTypeByOrdinal( int type )
+ public static OpCode getTypeByOrdinal( int type )
{
- for ( int ii = 0; ii < values.length; ii++ )
- if ( values[ ii ].ordinal == type )
- return values[ ii ];
- return QUERY;
- }
-
- public int getOrdinal()
+ for ( int ii = 0; ii < values.length; ii++ )
+ if ( values[ ii ].ordinal == type ) return values[ ii ];
+ return QUERY;
+ }
+
+ public int getOrdinal()
{
- return ordinal;
- }
+ return ordinal;
+ }
- /// PRIVATE /////
- private final String name;
- private final int ordinal;
-
- /**
- * Private constructor prevents construction outside of this class.
- */
- private OpCode( int ordinal, String name )
+ /// PRIVATE /////
+ private final String name;
+ private final int ordinal;
+
+ /**
+ * Private constructor prevents construction outside of this class.
+ */
+ private OpCode( int ordinal, String name )
{
this.ordinal = ordinal;
- this.name = name;
- }
+ this.name = name;
+ }
- /**
- * These two lines are all that's necessary to export a List of VALUES.
- */
- private static final OpCode[] values = { QUERY, IQUERY, STATUS, NOTIFY, UPDATE };
- // VALUES needs to be located here, otherwise illegal forward reference
- public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
+ /**
+ * These two lines are all that's necessary to export a List of VALUES.
+ */
+ private static final OpCode[] values = { QUERY, IQUERY, STATUS, NOTIFY, UPDATE };
+ // VALUES needs to be located here, otherwise illegal forward reference
+ public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
}
-
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/ResponseCode.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/ResponseCode.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/ResponseCode.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/ResponseCode.java Thu Sep 1 00:55:12 2005
@@ -21,62 +21,64 @@
import java.util.Collections;
import java.util.List;
-
public final class ResponseCode implements Comparable
{
- /**
- * Enumeration elements are constructed once upon class loading.
- * Order of appearance here determines the order of compareTo.
- */
- public static final ResponseCode NO_ERROR = new ResponseCode( 0, "No error condition." );
- public static final ResponseCode FORMAT_ERROR = new ResponseCode( 1, "The name server was unable to interpret the query." );
- public static final ResponseCode SERVER_FAILURE = new ResponseCode( 2, "The name server was unable to process this query due to a problem with the name server." );
- public static final ResponseCode NAME_ERROR = new ResponseCode( 3, "The domain name referenced in the query does not exist." );
- public static final ResponseCode NOT_IMPLEMENTED = new ResponseCode( 4, "The name server does not support the requested kind of query." );
- public static final ResponseCode REFUSED = new ResponseCode( 5, "The name server refuses to perform the specified operation for policy reasons." );
+ /**
+ * Enumeration elements are constructed once upon class loading.
+ * Order of appearance here determines the order of compareTo.
+ */
+ public static final ResponseCode NO_ERROR = new ResponseCode( 0, "No error condition." );
+ public static final ResponseCode FORMAT_ERROR = new ResponseCode( 1,
+ "The name server was unable to interpret the query." );
+ public static final ResponseCode SERVER_FAILURE = new ResponseCode( 2,
+ "The name server was unable to process this query due to a problem with the name server." );
+ public static final ResponseCode NAME_ERROR = new ResponseCode( 3,
+ "The domain name referenced in the query does not exist." );
+ public static final ResponseCode NOT_IMPLEMENTED = new ResponseCode( 4,
+ "The name server does not support the requested kind of query." );
+ public static final ResponseCode REFUSED = new ResponseCode( 5,
+ "The name server refuses to perform the specified operation for policy reasons." );
- public String toString()
+ public String toString()
{
- return name;
- }
+ return name;
+ }
- public int compareTo( Object that )
+ public int compareTo( Object that )
{
- return ordinal - ( (ResponseCode) that ).ordinal;
- }
+ return ordinal - ( (ResponseCode) that ).ordinal;
+ }
- public static ResponseCode getTypeByOrdinal( int type )
+ public static ResponseCode getTypeByOrdinal( int type )
{
- for ( int ii = 0; ii < values.length; ii++ )
- if ( values[ ii ].ordinal == type )
- return values[ ii ];
- return NO_ERROR;
- }
-
- public int getOrdinal()
+ for ( int ii = 0; ii < values.length; ii++ )
+ if ( values[ ii ].ordinal == type ) return values[ ii ];
+ return NO_ERROR;
+ }
+
+ public int getOrdinal()
{
- return ordinal;
- }
+ return ordinal;
+ }
- /// PRIVATE /////
- private final String name;
- private final int ordinal;
-
- /**
- * Private constructor prevents construction outside of this class.
- */
- private ResponseCode( int ordinal, String name )
+ /// PRIVATE /////
+ private final String name;
+ private final int ordinal;
+
+ /**
+ * Private constructor prevents construction outside of this class.
+ */
+ private ResponseCode( int ordinal, String name )
{
this.ordinal = ordinal;
- this.name = name;
- }
+ this.name = name;
+ }
- /**
- * These two lines are all that's necessary to export a List of VALUES.
- */
- private static final ResponseCode[] values = { NO_ERROR, FORMAT_ERROR, SERVER_FAILURE,
- NAME_ERROR, NOT_IMPLEMENTED, REFUSED };
- // VALUES needs to be located here, otherwise illegal forward reference
- public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
+ /**
+ * These two lines are all that's necessary to export a List of VALUES.
+ */
+ private static final ResponseCode[] values = { NO_ERROR, FORMAT_ERROR, SERVER_FAILURE, NAME_ERROR, NOT_IMPLEMENTED,
+ REFUSED };
+ // VALUES needs to be located here, otherwise illegal forward reference
+ public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
}
-
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsDecoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsDecoder.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsDecoder.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsDecoder.java Thu Sep 1 00:55:12 2005
@@ -24,14 +24,12 @@
import org.apache.mina.protocol.ProtocolSession;
import org.apache.mina.protocol.ProtocolViolationException;
-
public class DnsDecoder implements ProtocolDecoder
{
public void decode( ProtocolSession session, ByteBuffer in, ProtocolDecoderOutput out )
throws ProtocolViolationException
{
- DnsMessageDecoder decoder = new DnsMessageDecoder();
- out.write( decoder.decode( in.buf() ) );
+ DnsMessageDecoder decoder = new DnsMessageDecoder();
+ out.write( decoder.decode( in.buf() ) );
}
}
-
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsEncoder.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsEncoder.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsEncoder.java Thu Sep 1 00:55:12 2005
@@ -25,20 +25,18 @@
import org.apache.mina.protocol.ProtocolSession;
import org.apache.mina.protocol.ProtocolViolationException;
-
public class DnsEncoder implements ProtocolEncoder
{
public void encode( ProtocolSession session, Object message, ProtocolEncoderOutput out )
throws ProtocolViolationException
{
DnsMessageEncoder encoder = new DnsMessageEncoder();
-
+
ByteBuffer buf = ByteBuffer.allocate( 1024 );
- encoder.encode( buf.buf(), (DnsMessage)message );
-
+ encoder.encode( buf.buf(), (DnsMessage) message );
+
buf.flip();
-
+
out.write( buf );
}
}
-
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolHandler.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolHandler.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolHandler.java Thu Sep 1 00:55:12 2005
@@ -24,7 +24,6 @@
import org.apache.mina.protocol.ProtocolHandler;
import org.apache.mina.protocol.ProtocolSession;
-
public class DnsProtocolHandler implements ProtocolHandler
{
public void sessionCreated( ProtocolSession session )
@@ -58,10 +57,10 @@
public void messageReceived( ProtocolSession session, Object message )
{
System.out.println( session.getRemoteAddress() + " RCVD: " + message );
-
+
DomainNameService dnsService = new DomainNameServiceImpl();
- DnsMessage reply = dnsService.getReplyFor( (DnsMessage)message );
-
+ DnsMessage reply = dnsService.getReplyFor( (DnsMessage) message );
+
session.write( reply );
}
@@ -70,4 +69,3 @@
System.out.println( session.getRemoteAddress() + " SENT: " + message );
}
}
-
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolProvider.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolProvider.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolProvider.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolProvider.java Thu Sep 1 00:55:12 2005
@@ -23,7 +23,6 @@
import org.apache.mina.protocol.ProtocolHandler;
import org.apache.mina.protocol.ProtocolProvider;
-
public class DnsProtocolProvider implements ProtocolProvider
{
// Protocol handler is usually a singleton.
@@ -55,4 +54,3 @@
return HANDLER;
}
}
-
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/InternetResource.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/InternetResource.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/InternetResource.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/InternetResource.java Thu Sep 1 00:55:12 2005
@@ -17,13 +17,10 @@
package org.apache.dns.records;
-
public abstract class InternetResource extends ResourceRecord
{
- public InternetResource( String domainName, RecordType recordType,
- int timeToLive, byte[] resourceData )
- {
- super( domainName, recordType, RecordClass.IN, timeToLive, resourceData );
- }
+ public InternetResource( String domainName, RecordType recordType, int timeToLive, byte[] resourceData )
+ {
+ super( domainName, recordType, RecordClass.IN, timeToLive, resourceData );
+ }
}
-
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/QuestionRecord.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/QuestionRecord.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/QuestionRecord.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/QuestionRecord.java Thu Sep 1 00:55:12 2005
@@ -17,7 +17,6 @@
package org.apache.dns.records;
-
/**
* The question section is used to carry the "question" in most queries,
* i.e., the parameters that define what is being asked. The section
@@ -37,15 +36,13 @@
*/
public class QuestionRecord extends Record
{
- public QuestionRecord( String domainName, RecordType recordType, RecordClass recordClass )
- {
- super( domainName, recordType, recordClass );
- }
-
- public String toString()
- {
- return getClass().getName() + " [ " + domainName + " ( " +
- recordClass + " " + recordType + " ) ]";
- }
-}
+ public QuestionRecord( String domainName, RecordType recordType, RecordClass recordClass )
+ {
+ super( domainName, recordType, recordClass );
+ }
+ public String toString()
+ {
+ return getClass().getName() + " [ " + domainName + " ( " + recordClass + " " + recordType + " ) ]";
+ }
+}
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/Record.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/Record.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/Record.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/Record.java Thu Sep 1 00:55:12 2005
@@ -35,90 +35,87 @@
*/
public abstract class Record
{
- /**
- * A domain name represented as a sequence of labels, where
- * each label consists of a length octet followed by that
- * number of octets. The domain name terminates with the
- * zero length octet for the null label of the root. Note
- * that this field may be an odd number of octets; no
- * padding is used.
- */
- protected String domainName;
-
- /**
- * A two octet code which specifies the type.
- */
- protected RecordType recordType;
-
- /**
- * A two octet code that specifies the class.
+ /**
+ * A domain name represented as a sequence of labels, where
+ * each label consists of a length octet followed by that
+ * number of octets. The domain name terminates with the
+ * zero length octet for the null label of the root. Note
+ * that this field may be an odd number of octets; no
+ * padding is used.
+ */
+ protected String domainName;
+
+ /**
+ * A two octet code which specifies the type.
+ */
+ protected RecordType recordType;
+
+ /**
+ * A two octet code that specifies the class.
* For example, the CLASS field is IN for the Internet.
- */
- protected RecordClass recordClass;
-
-
- public Record( String domainName, RecordType recordType, RecordClass recordClass )
- {
- this.domainName = domainName;
- this.recordType = recordType;
- this.recordClass = recordClass;
- }
-
-
- public void writeTo( ByteBuffer out )
- {
- dataToByteBuffer( out );
- }
-
- protected void dataToByteBuffer( ByteBuffer byteBuffer )
- {
- encodeDomainName( byteBuffer, domainName );
- encodeRecordType( byteBuffer, recordType );
- encodeRecordClass( byteBuffer, recordClass );
- }
-
- protected static 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() );
- }
-
- protected static String byteArrayToDomainName( byte[] bytes )
- {
- return new String( bytes );
- }
-
- protected static byte[] domainNameToByteArray( String domainName )
- {
- ByteBuffer byteBuffer = ByteBuffer.allocate( 256 );
- encodeDomainName( byteBuffer, domainName );
- byte[] bytes = new byte[ byteBuffer.position() ];
- byteBuffer.rewind();
- byteBuffer.get( bytes );
-
- return bytes;
- }
-}
+ */
+ protected RecordClass recordClass;
+
+ public Record( String domainName, RecordType recordType, RecordClass recordClass )
+ {
+ this.domainName = domainName;
+ this.recordType = recordType;
+ this.recordClass = recordClass;
+ }
+
+ public void writeTo( ByteBuffer out )
+ {
+ dataToByteBuffer( out );
+ }
+
+ protected void dataToByteBuffer( ByteBuffer byteBuffer )
+ {
+ encodeDomainName( byteBuffer, domainName );
+ encodeRecordType( byteBuffer, recordType );
+ encodeRecordClass( byteBuffer, recordClass );
+ }
+
+ protected static 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() );
+ }
+
+ protected static String byteArrayToDomainName( byte[] bytes )
+ {
+ return new String( bytes );
+ }
+
+ protected static byte[] domainNameToByteArray( String domainName )
+ {
+ ByteBuffer byteBuffer = ByteBuffer.allocate( 256 );
+ encodeDomainName( byteBuffer, domainName );
+ byte[] bytes = new byte[ byteBuffer.position() ];
+ byteBuffer.rewind();
+ byteBuffer.get( bytes );
+
+ return bytes;
+ }
+}
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/RecordClass.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/RecordClass.java?rev=265668&r1=265667&r2=265668&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/RecordClass.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/RecordClass.java Thu Sep 1 00:55:12 2005
@@ -21,61 +21,58 @@
import java.util.Collections;
import java.util.List;
-
public final class RecordClass implements Comparable
{
- /**
- * Enumeration elements are constructed once upon class loading.
- * Order of appearance here determines the order of compareTo.
- */
- public static final RecordClass IN = new RecordClass( 1, "Internet" );
- public static final RecordClass CS = new RecordClass( 2, "CSNET class" );
- public static final RecordClass CH = new RecordClass( 3, "CHAOS class" );
- public static final RecordClass HS = new RecordClass( 4, "Hesiod [Dyer 87]" );
- public static final RecordClass NONE = new RecordClass( 254, "Special value used in dynamic update messages" );
- public static final RecordClass ANY = new RecordClass( 255, "Any class" );
-
- public String toString()
+ /**
+ * Enumeration elements are constructed once upon class loading.
+ * Order of appearance here determines the order of compareTo.
+ */
+ public static final RecordClass IN = new RecordClass( 1, "Internet" );
+ public static final RecordClass CS = new RecordClass( 2, "CSNET class" );
+ public static final RecordClass CH = new RecordClass( 3, "CHAOS class" );
+ public static final RecordClass HS = new RecordClass( 4, "Hesiod [Dyer 87]" );
+ public static final RecordClass NONE = new RecordClass( 254, "Special value used in dynamic update messages" );
+ public static final RecordClass ANY = new RecordClass( 255, "Any class" );
+
+ public String toString()
{
- return name;
- }
+ return name;
+ }
- public int compareTo( Object that )
+ public int compareTo( Object that )
{
- return ordinal - ( (RecordClass) that ).ordinal;
- }
+ return ordinal - ( (RecordClass) that ).ordinal;
+ }
- public static RecordClass getTypeByOrdinal( int type )
+ public static RecordClass getTypeByOrdinal( int type )
{
- for ( int i = 0; i < values.length; i++ )
- if ( values[ i ].ordinal == type )
- return values[ i ];
- return IN;
- }
-
- public int getOrdinal()
+ for ( int i = 0; i < values.length; i++ )
+ if ( values[ i ].ordinal == type ) return values[ i ];
+ return IN;
+ }
+
+ public int getOrdinal()
{
- return ordinal;
- }
+ return ordinal;
+ }
- /// PRIVATE /////
- private final String name;
- private final int ordinal;
-
- /**
- * Private constructor prevents construction outside of this class.
- */
- private RecordClass( int ordinal, String name )
+ /// PRIVATE /////
+ private final String name;
+ private final int ordinal;
+
+ /**
+ * Private constructor prevents construction outside of this class.
+ */
+ private RecordClass( int ordinal, String name )
{
this.ordinal = ordinal;
- this.name = name;
- }
+ this.name = name;
+ }
- /**
- * These two lines are all that's necessary to export a List of VALUES.
- */
- private static final RecordClass[] values = { IN, CS, CH, HS, NONE, ANY };
- // VALUES needs to be located here, otherwise illegal forward reference
- public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
+ /**
+ * These two lines are all that's necessary to export a List of VALUES.
+ */
+ private static final RecordClass[] values = { IN, CS, CH, HS, NONE, ANY };
+ // VALUES needs to be located here, otherwise illegal forward reference
+ public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
}
-