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/29 00:08:55 UTC
svn commit: r292331 - in
/directory/protocol-providers/dns/trunk/src/java/org/apache/dns:
io/encoder/ServerSelectionRecordEncoder.java protocol/DnsEncoder.java
store/DnsAttribute.java
Author: erodriguez
Date: Wed Sep 28 15:08:51 2005
New Revision: 292331
URL: http://svn.apache.org/viewcvs?rev=292331&view=rev
Log:
Updates to DNS protocol-provider to support DIRDNS-4 (Add support for service location SRV records)
o Added constants for the SRV attributeTypes.
o Implemented the SRV encoder.
o Added the SRV type-to-encoder mapping.
http://issues.apache.org/jira/browse/DIRDNS-4
Modified:
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/ServerSelectionRecordEncoder.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsEncoder.java
directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/DnsAttribute.java
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/ServerSelectionRecordEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/ServerSelectionRecordEncoder.java?rev=292331&r1=292330&r2=292331&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/ServerSelectionRecordEncoder.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/encoder/ServerSelectionRecordEncoder.java Wed Sep 28 15:08:51 2005
@@ -17,6 +17,11 @@
package org.apache.dns.io.encoder;
+import java.nio.ByteBuffer;
+
+import org.apache.dns.messages.ResourceRecord;
+import org.apache.dns.store.DnsAttribute;
+
/**
* The format of the SRV RR
*
@@ -116,6 +121,20 @@
* A Target of "." means that the service is decidedly not
* available at this domain.
*/
-public class ServerSelectionRecordEncoder
+public class ServerSelectionRecordEncoder extends ResourceRecordEncoder
{
+ protected byte[] encodeResourceData( ResourceRecord record )
+ {
+ ByteBuffer byteBuffer = ByteBuffer.allocate( 256 );
+ byteBuffer.putShort( Short.parseShort( record.get( DnsAttribute.SERVICE_PRIORITY ) ) );
+ byteBuffer.putShort( Short.parseShort( record.get( DnsAttribute.SERVICE_WEIGHT ) ) );
+ byteBuffer.putShort( Short.parseShort( record.get( DnsAttribute.SERVICE_PORT ) ) );
+ byteBuffer.put( encodeDomainName( record.get( DnsAttribute.DOMAIN_NAME ) ) );
+
+ byteBuffer.flip();
+ byte[] bytes = new byte[ byteBuffer.remaining() ];
+ byteBuffer.get( bytes, 0, bytes.length );
+
+ return bytes;
+ }
}
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=292331&r1=292330&r2=292331&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 Wed Sep 28 15:08:51 2005
@@ -30,6 +30,7 @@
import org.apache.dns.io.encoder.PointerRecordEncoder;
import org.apache.dns.io.encoder.QuestionRecordEncoder;
import org.apache.dns.io.encoder.RecordEncoder;
+import org.apache.dns.io.encoder.ServerSelectionRecordEncoder;
import org.apache.dns.io.encoder.StartOfAuthorityRecordEncoder;
import org.apache.dns.messages.DnsMessage;
import org.apache.dns.messages.MessageType;
@@ -68,6 +69,7 @@
map.put( RecordType.CNAME, new CanonicalNameRecordEncoder() );
map.put( RecordType.PTR, new PointerRecordEncoder() );
map.put( RecordType.MX, new MailExchangeRecordEncoder() );
+ map.put( RecordType.SRV, new ServerSelectionRecordEncoder() );
DEFAULT_ENCODERS = Collections.unmodifiableMap( map );
}
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/DnsAttribute.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/DnsAttribute.java?rev=292331&r1=292330&r2=292331&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/DnsAttribute.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/DnsAttribute.java Wed Sep 28 15:08:51 2005
@@ -79,4 +79,13 @@
/** the apachedns schema apacheDnsCharacterString */
public static final String CHARACTER_STRING = "apacheDnsCharacterString";
+
+ /** the apachedns schema apacheDnsServicePriority */
+ public static final String SERVICE_PRIORITY = "apacheDnsServicePriority";
+
+ /** the apachedns schema apacheDnsServiceWeight */
+ public static final String SERVICE_WEIGHT = "apacheDnsServiceWeight";
+
+ /** the apachedns schema apacheDnsServicePort */
+ public static final String SERVICE_PORT = "apacheDnsServicePort";
}