directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r124894 - /incubator/directory/dns/trunk/core/src/java/org/apache/dns/io/DnsMessageDecoder.java /incubator/directory/dns/trunk/core/src/java/org/apache/dns/io/ResourceRecordDecoder.java
Date Tue, 11 Jan 2005 07:14:54 GMT
Author: erodriguez
Date: Mon Jan 10 23:14:50 2005
New Revision: 124894

URL: http://svn.apache.org/viewcvs?view=rev&rev=124894
Log:
DNS Resource Record decoding.
Added:
   incubator/directory/dns/trunk/core/src/java/org/apache/dns/io/ResourceRecordDecoder.java
Modified:
   incubator/directory/dns/trunk/core/src/java/org/apache/dns/io/DnsMessageDecoder.java

Modified: incubator/directory/dns/trunk/core/src/java/org/apache/dns/io/DnsMessageDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/io/DnsMessageDecoder.java?view=diff&rev=124894&p1=incubator/directory/dns/trunk/core/src/java/org/apache/dns/io/DnsMessageDecoder.java&r1=124893&p2=incubator/directory/dns/trunk/core/src/java/org/apache/dns/io/DnsMessageDecoder.java&r2=124894
==============================================================================
--- incubator/directory/dns/trunk/core/src/java/org/apache/dns/io/DnsMessageDecoder.java	(original)
+++ incubator/directory/dns/trunk/core/src/java/org/apache/dns/io/DnsMessageDecoder.java	Mon
Jan 10 23:14:50 2005
@@ -79,8 +79,15 @@
 			byte[] data = new byte[ dataLength ];
 			byteBuffer.get( data );
 			
-			records[ ii ] = new ResourceRecord( domainName, recordType,
+			try
+			{
+				records[ ii ] = ResourceRecordDecoder.getInstance( domainName, recordType,
 					recordClass, timeToLive, data );
+			}
+			catch (Exception e)
+			{
+				e.printStackTrace();
+			}
 		}
 		
 		return records;

Added: incubator/directory/dns/trunk/core/src/java/org/apache/dns/io/ResourceRecordDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/io/ResourceRecordDecoder.java?view=auto&rev=124894
==============================================================================
--- (empty file)
+++ incubator/directory/dns/trunk/core/src/java/org/apache/dns/io/ResourceRecordDecoder.java
Mon Jan 10 23:14:50 2005
@@ -0,0 +1,75 @@
+/*
+ *   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;
+
+import org.apache.dns.DnsException;
+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;
+
+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 );
+		}
+	}
+}
+

Mime
View raw message