Author: erodriguez
Date: Fri Jan 21 13:47:20 2005
New Revision: 125966

URL: http://svn.apache.org/viewcvs?view=rev&rev=125966
Log:
Refactoring of base DNS Resource Record types, based on experience with DER 
encoding.
Added:
   
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/internet/AddressRecord.java
   (contents, props changed)
   
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/internet/ProtocolType.java
   
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/internet/ServiceType.java
   
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/internet/WellKnownServicesRecord.java
   (contents, props changed)
Modified:
   
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/QuestionRecord.java
   
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/Record.java
   
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/ResourceRecord.java

Modified: 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/QuestionRecord.java
Url: 
http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/QuestionRecord.java?view=diff&rev=125966&p1=incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/QuestionRecord.java&r1=125965&p2=incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/QuestionRecord.java&r2=125966
==============================================================================
--- 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/QuestionRecord.java
      (original)
+++ 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/QuestionRecord.java
      Fri Jan 21 13:47:20 2005
@@ -44,7 +44,7 @@
        
        public String toString()
        {
-               return getClass().getName() + "[ " + domainName + " ( " +
+               return getClass().getName() + " [ " + domainName + " ( " +
                                recordClass + " " + recordType + " ) ]";
        }
 }

Modified: 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/Record.java
Url: 
http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/Record.java?view=diff&rev=125966&p1=incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/Record.java&r1=125965&p2=incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/Record.java&r2=125966
==============================================================================
--- 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/Record.java  
    (original)
+++ 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/Record.java  
    Fri Jan 21 13:47:20 2005
@@ -77,7 +77,7 @@
                encodeRecordClass( byteBuffer, recordClass );
        }
        
-       protected void encodeDomainName( ByteBuffer byteBuffer, String 
domainName )
+       protected static void encodeDomainName( ByteBuffer byteBuffer, String 
domainName )
        {
                String[] labels = domainName.split("\\.");
                
@@ -105,7 +105,12 @@
                byteBuffer.putShort( (short)recordClass.getOrdinal() );
        }
        
-       protected byte[] domainNameToByteArray( String domainName )
+       protected static String byteArrayToDomainName( byte[] bytes )
+       {
+               return new String( bytes );
+       }
+       
+       protected static byte[] domainNameToByteArray( String domainName )
        {
                ByteBuffer byteBuffer = ByteBuffer.allocate( 256 );
                encodeDomainName( byteBuffer, domainName );

Modified: 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/ResourceRecord.java
Url: 
http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/ResourceRecord.java?view=diff&rev=125966&p1=incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/ResourceRecord.java&r1=125965&p2=incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/ResourceRecord.java&r2=125966
==============================================================================
--- 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/ResourceRecord.java
      (original)
+++ 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/ResourceRecord.java
      Fri Jan 21 13:47:20 2005
@@ -57,27 +57,20 @@
                
                this.timeToLive   = timeToLive;
                this.resourceData = resourceData;
-               
-               decodeResourceData( resourceData );
        }
        
-       abstract protected void decodeResourceData( byte[] resourceData );      
-       abstract protected byte[] encodeResourceData();
-       
        protected void dataToByteBuffer( ByteBuffer byteBuffer )
        {
                super.dataToByteBuffer( byteBuffer );
                
                byteBuffer.putInt( timeToLive );
-               
-               byte[] resourceData = encodeResourceData();
                byteBuffer.putShort( (short)resourceData.length );
                byteBuffer.put( resourceData );
        }
        
        public String toString()
        {
-               return getClass().getName() + "[ " + domainName + " ( " +
+               return getClass().getName() + " [ " + domainName + " ( " +
                                recordClass + " " + recordType + " " + 
timeToLive + " " +
                                resourceData.length + " ) ]";
        }

Added: 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/internet/AddressRecord.java
Url: 
http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/internet/AddressRecord.java?view=auto&rev=125966
==============================================================================
--- (empty file)
+++ 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/internet/AddressRecord.java
      Fri Jan 21 13:47:20 2005
@@ -0,0 +1,81 @@
+/*
+ *   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.records.internet;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import org.apache.dns.records.InternetResource;
+import org.apache.dns.records.RecordType;
+import org.apache.dns.records.ResourceRecord;
+
+/**
+ * 3.4.1. A RDATA format
+ * 
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                    ADDRESS                    |
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * 
+ * where:
+ * 
+ * ADDRESS         A 32 bit Internet address.
+ * 
+ * Hosts that have multiple Internet addresses will have multiple A
+ * records.
+ * 
+ * A records cause no additional section processing.  The RDATA section of
+ * an A line in a master file is an Internet address expressed as four
+ * decimal numbers separated by dots without any imbedded spaces (e.g.,
+ * "10.2.0.52" or "192.0.5.6").
+ */
+public class AddressRecord extends InternetResource
+{
+       /**
+        * Basic ResourceRecord constructor.
+        */
+       public AddressRecord( String domainName, int timeToLive, byte[] 
resourceData )
+       {
+               super( domainName, RecordType.A, timeToLive, resourceData );
+       }
+       
+    /**
+     * Static factory method, type-conversion operator.
+     */
+       public static ResourceRecord valueOf( String domainName, int 
timeToLive, InetAddress internetAddress )
+       {
+               return new AddressRecord( domainName, timeToLive, 
internetAddress.getAddress() );
+       }
+       
+       /**
+        * Lazy accessor.
+        */
+       public InetAddress getAddress()
+       {
+               try
+               {
+                       return InetAddress.getByAddress( resourceData );
+               }
+               catch (UnknownHostException uhe)
+               {
+                       uhe.printStackTrace();
+               }
+               
+               return null;
+       }
+}
+

Added: 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/internet/ProtocolType.java
Url: 
http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/internet/ProtocolType.java?view=auto&rev=125966
==============================================================================
--- (empty file)
+++ 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/internet/ProtocolType.java
       Fri Jan 21 13:47:20 2005
@@ -0,0 +1,122 @@
+/*
+ *   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.records.internet;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+
+public final class ProtocolType implements Comparable
+{
+       /**
+        * Enumeration elements are constructed once upon class loading.
+        * Order of appearance here determines the order of compareTo.
+        */
+       public static final ProtocolType NULL        = new ProtocolType( 0,  
"Null" );
+       public static final ProtocolType ICMP        = new ProtocolType( 1,  
"Internet Control Message" );
+       public static final ProtocolType IGMP        = new ProtocolType( 2,  
"Internet Group Management" );
+       public static final ProtocolType GGP         = new ProtocolType( 3,  
"Gateway-to-Gateway" );
+       public static final ProtocolType ST          = new ProtocolType( 5,  
"Stream" );
+       public static final ProtocolType TCP         = new ProtocolType( 6,  
"Transmission Control" );
+       public static final ProtocolType UCL         = new ProtocolType( 7,  
"UCL" );
+       public static final ProtocolType EGP         = new ProtocolType( 8,  
"Exterior Gateway Protocol" );
+       public static final ProtocolType IGP         = new ProtocolType( 9,  
"any private interior gateway" );
+       public static final ProtocolType BBN_RCC_MON = new ProtocolType( 10, 
"BBN RCC Monitoring" );
+       public static final ProtocolType NVP_II      = new ProtocolType( 11, 
"Network Voice Protocol" );
+       public static final ProtocolType PUP         = new ProtocolType( 12, 
"PUP" );
+       public static final ProtocolType ARGUS       = new ProtocolType( 13, 
"ARGUS" );
+       public static final ProtocolType EMCON       = new ProtocolType( 14, 
"EMCON" );
+       public static final ProtocolType XNET        = new ProtocolType( 15, 
"Cross Net Debugger" );
+       public static final ProtocolType CHAOS       = new ProtocolType( 16, 
"Chaos" );
+       public static final ProtocolType UDP         = new ProtocolType( 17, 
"User Datagram" );
+       public static final ProtocolType MUX         = new ProtocolType( 18, 
"Multiplexing" );
+       public static final ProtocolType DCN_MEAS    = new ProtocolType( 19, 
"DCN Measurement Subsystems" );
+       public static final ProtocolType HMP         = new ProtocolType( 20, 
"Host Monitoring" );
+       public static final ProtocolType PRM         = new ProtocolType( 21, 
"Packet Radio Measurement" );
+       public static final ProtocolType XNS_IDP     = new ProtocolType( 22, 
"XEROX NS IDP" );
+       public static final ProtocolType TRUNK_1     = new ProtocolType( 23, 
"Trunk-1" );
+       public static final ProtocolType TRUNK_2     = new ProtocolType( 24, 
"Trunk-2" );
+       public static final ProtocolType LEAF_1      = new ProtocolType( 25, 
"Leaf-1" );
+       public static final ProtocolType LEAF_2      = new ProtocolType( 26, 
"Leaf-2" );
+       public static final ProtocolType RDP         = new ProtocolType( 27, 
"Reliable Data Protocol" );
+       public static final ProtocolType IRTP        = new ProtocolType( 28, 
"Internet Reliable Transaction" );
+       public static final ProtocolType ISO_TP4     = new ProtocolType( 29, 
"ISO Transport Protocol Class 4" );
+       public static final ProtocolType NETBLT      = new ProtocolType( 30, 
"Bulk Data Transfer Protocol" );
+       public static final ProtocolType MFE_NSP     = new ProtocolType( 31, 
"MFE Network Services Protocol" );
+       public static final ProtocolType MERIT_INP   = new ProtocolType( 32, 
"MERIT Internodal Protocol" );
+       public static final ProtocolType SEP         = new ProtocolType( 33, 
"Sequential Exchange Protocol" );
+       public static final ProtocolType CFTP        = new ProtocolType( 62, 
"CFTP" );
+       public static final ProtocolType SAT_EXPAK   = new ProtocolType( 64, 
"SATNET and Backroom EXPAK" );
+       public static final ProtocolType MIT_SUBNET  = new ProtocolType( 65, 
"MIT Subnet Support" );
+       public static final ProtocolType RVD         = new ProtocolType( 66, 
"MIT Remote Virtual Disk Protocol" );
+       public static final ProtocolType IPPC        = new ProtocolType( 67, 
"Internet Pluribus Packet Core" );
+       public static final ProtocolType SAT_MON     = new ProtocolType( 69, 
"SATNET Monitoring" );
+       public static final ProtocolType IPCV        = new ProtocolType( 71, 
"Internet Packet Core Utility" );
+       public static final ProtocolType BR_SAT_MON  = new ProtocolType( 76, 
"Backroom SATNET Monitoring" );
+       public static final ProtocolType WB_MON      = new ProtocolType( 78, 
"WIDEBAND Monitoring" );
+       public static final ProtocolType WB_EXPAK    = new ProtocolType( 79, 
"WIDEBAND EXPAK" );
+       
+       public String toString()
+    {
+               return name;
+       }
+
+       public int compareTo( Object that )
+    {
+               return ordinal - ( (ProtocolType) that ).ordinal;
+       }
+
+       public static ProtocolType getTypeByOrdinal( int type )
+    {
+               for ( int ii = 0; ii < values.length; ii++ )
+                       if ( values[ ii ].ordinal == type )
+                               return values[ ii ];
+               return NULL;
+       }
+       
+       public int getOrdinal()
+    {
+               return ordinal;
+       }
+
+       /// PRIVATE /////
+       private final String name;
+       private final int    ordinal;
+
+       /**
+        * Private constructor prevents construction outside of this class.
+        */
+       private ProtocolType( int ordinal, String name )
+    {
+        this.ordinal = ordinal;
+               this.name    = name;
+       }
+
+       /**
+        * These two lines are all that's necessary to export a List of VALUES.
+        */
+       private static final ProtocolType[] values = { NULL, ICMP, IGMP, GGP, 
ST, TCP, UCL,
+                       EGP, IGP, BBN_RCC_MON, NVP_II, PUP, ARGUS, EMCON, XNET, 
CHAOS, UDP, MUX,
+                       DCN_MEAS, HMP, PRM, XNS_IDP, TRUNK_1, TRUNK_2, LEAF_1, 
LEAF_2, RDP, IRTP,
+                       ISO_TP4, NETBLT, MFE_NSP, MERIT_INP, SEP, CFTP, 
SAT_EXPAK, MIT_SUBNET, RVD,
+                       IPPC, SAT_MON, IPCV, BR_SAT_MON, WB_MON, WB_EXPAK };
+       // VALUES needs to be located here, otherwise illegal forward reference
+       public static final List VALUES = Collections.unmodifiableList( 
Arrays.asList( values ) );
+}
+

Added: 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/internet/ServiceType.java
Url: 
http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/internet/ServiceType.java?view=auto&rev=125966
==============================================================================
--- (empty file)
+++ 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/internet/ServiceType.java
        Fri Jan 21 13:47:20 2005
@@ -0,0 +1,164 @@
+/*
+ *   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.records.internet;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+
+public final class ServiceType implements Comparable
+{
+       /**
+        * Enumeration elements are constructed once upon class loading.
+        * Order of appearance here determines the order of compareTo.
+        */
+       public static final ServiceType NULL        = new ServiceType( 0, 
"Null" );
+       public static final ServiceType RJE         = new ServiceType( 5, 
"Remote job entry." );
+       public static final ServiceType ECHO        = new ServiceType( 7, 
"Echo" );
+       public static final ServiceType DISCARD     = new ServiceType( 9, 
"Discard" );
+       public static final ServiceType USERS       = new ServiceType( 11, 
"Active users." );
+       public static final ServiceType DAYTIME     = new ServiceType( 13, 
"Daytime" );
+       public static final ServiceType QUOTE       = new ServiceType( 17, 
"Quote of the day." );
+       public static final ServiceType CHARGEN     = new ServiceType( 19, 
"Character generator." );
+       public static final ServiceType FTP_DATA    = new ServiceType( 20, 
"File Transfer [Default Data]" );
+       public static final ServiceType FTP         = new ServiceType( 21, 
"File Transfer [Control]" );
+       public static final ServiceType TELNET      = new ServiceType( 23, 
"Telnet" );
+       public static final ServiceType SMTP        = new ServiceType( 25, 
"Simple Mail Transfer" );
+       public static final ServiceType NSW_FE      = new ServiceType( 27, "NSW 
User System FE" );
+       public static final ServiceType MSG_ICP     = new ServiceType( 29, "MSG 
ICP" );
+       public static final ServiceType MSG_AUTH    = new ServiceType( 31, "MSG 
Authentication" );
+       public static final ServiceType DSP         = new ServiceType( 33, 
"Display Support Protocol" );
+       public static final ServiceType TIME        = new ServiceType( 37, 
"Time" );
+       public static final ServiceType RLP         = new ServiceType( 39, 
"Resource Location Protocol" );
+       public static final ServiceType GRAPHICS    = new ServiceType( 41, 
"Graphics" );
+       public static final ServiceType NAMESERVER  = new ServiceType( 42, 
"Host Name Server" );
+       public static final ServiceType NICKNAME    = new ServiceType( 43, "Who 
Is" );
+       public static final ServiceType MPM_FLAGS   = new ServiceType( 44, "MPM 
FLAGS Protocol" );
+       public static final ServiceType MPM         = new ServiceType( 45, 
"Message Processing Module [recv]" );
+       public static final ServiceType MPM_SND     = new ServiceType( 46, "MPM 
[default send]" );
+       public static final ServiceType NI_FTP      = new ServiceType( 47, "NI 
FTP" );
+       public static final ServiceType LOGIN       = new ServiceType( 49, 
"Login Host Protocol" );
+       public static final ServiceType LA_MAINT    = new ServiceType( 51, "IMP 
Logical Address Maintenance" );
+       public static final ServiceType DOMAIN      = new ServiceType( 53, 
"Domain Name Server" );
+       public static final ServiceType ISI_GL      = new ServiceType( 55, "ISI 
Graphics Language" );
+       public static final ServiceType NI_MAIL     = new ServiceType( 61, "NI 
MAIL" );
+       public static final ServiceType VIA_FTP     = new ServiceType( 63, "VIA 
Systems - FTP" );
+       public static final ServiceType TACACS_DS   = new ServiceType( 65, 
"TACACS-Database Service" );
+       public static final ServiceType BOOTPS      = new ServiceType( 67, 
"Bootstrap Protocol Server" );
+       public static final ServiceType BOOTPC      = new ServiceType( 68, 
"Bootstrap Protocol Client" );
+       public static final ServiceType TFTP        = new ServiceType( 69, 
"Trivial File Transfer" );
+       public static final ServiceType NETRJS_1    = new ServiceType( 71, 
"Remote Job Service" );
+       public static final ServiceType NETRJS_2    = new ServiceType( 72, 
"Remote Job Service" );
+       public static final ServiceType NETRJS_3    = new ServiceType( 73, 
"Remote Job Service" );
+       public static final ServiceType NETRJS_4    = new ServiceType( 74, 
"Remote Job Service" );
+       public static final ServiceType FINGER      = new ServiceType( 79, 
"Finger" );
+       public static final ServiceType HOSTS2_NS   = new ServiceType( 81, 
"HOSTS2 Name Server" );
+       public static final ServiceType SU_MIT_TG   = new ServiceType( 89, 
"SU/MIT Telnet Gateway" );
+       public static final ServiceType MIT_DOV     = new ServiceType( 91, "MIT 
Dover Spooler" );
+       public static final ServiceType DCP         = new ServiceType( 93, 
"Device Control Protocol" );
+       public static final ServiceType SUPDUP      = new ServiceType( 95, 
"SUPDUP" );
+       public static final ServiceType SWIFT_RVF   = new ServiceType( 97, 
"Swift Remote Virtual File Protocol" );
+       public static final ServiceType TACNEWS     = new ServiceType( 98, "TAC 
News" );
+       public static final ServiceType METAGRAM    = new ServiceType( 99, 
"Metagram Relay" );
+       public static final ServiceType HOSTNAME    = new ServiceType( 101, 
"NIC Host Name Server" );
+       public static final ServiceType ISO_TSAP    = new ServiceType( 102, 
"ISO-TSAP" );
+       public static final ServiceType X400        = new ServiceType( 103, 
"X400" );
+       public static final ServiceType X400_SND    = new ServiceType( 104, 
"X400-SND" );
+       public static final ServiceType CSNET_NS    = new ServiceType( 105, 
"Mailbox Name Nameserver" );
+       public static final ServiceType RTELNET     = new ServiceType( 107, 
"Remote Telnet Service" );
+       public static final ServiceType POP_2       = new ServiceType( 109, 
"Post Office Protocol - Version 2" );
+       public static final ServiceType SUNRPC      = new ServiceType( 111, 
"SUN Remote Procedure Call" );
+       public static final ServiceType AUTH        = new ServiceType( 113, 
"Authentication Service" );
+       public static final ServiceType SFTP        = new ServiceType( 115, 
"Simple File Transfer Protocol" );
+       public static final ServiceType UUCP_PATH   = new ServiceType( 117, 
"UUCP Path Service" );
+       public static final ServiceType NNTP        = new ServiceType( 119, 
"Network News Transfer Protocol" );
+       public static final ServiceType ERPC        = new ServiceType( 121, 
"HYDRA Expedited Remote Procedure" );       
+       public static final ServiceType NTP         = new ServiceType( 123, 
"Network Time Protocol" );
+       public static final ServiceType LOCUS_MAP   = new ServiceType( 125, 
"Locus PC-Interface Net Map Server" );
+       public static final ServiceType LOCUS_CON   = new ServiceType( 127, 
"Locus PC-Interface Conn Server" );
+       public static final ServiceType PWDGEN      = new ServiceType( 129, 
"Password Generator Protocol" );
+       public static final ServiceType CISCO_FNA   = new ServiceType( 130, 
"CISCO FNATIVE" );
+       public static final ServiceType CISCO_TNA   = new ServiceType( 131, 
"CISCO TNATIVE" );
+       public static final ServiceType CISCO_SYS   = new ServiceType( 132, 
"CISCO SYSMAINT" );
+       public static final ServiceType STATSRV     = new ServiceType( 133, 
"Statistics Service" );
+       public static final ServiceType INGRES_NET  = new ServiceType( 134, 
"INGRES-NET Service" );
+       public static final ServiceType LOC_SRV     = new ServiceType( 135, 
"Location Service" );
+       public static final ServiceType PROFILE     = new ServiceType( 136, 
"PROFILE Naming System" );
+       public static final ServiceType NETBIOS_NS  = new ServiceType( 137, 
"NETBIOS Name Service" );
+       public static final ServiceType NETBIOS_DGM = new ServiceType( 138, 
"NETBIOS Datagram Service" );
+       public static final ServiceType NETBIOS_SSN = new ServiceType( 139, 
"NETBIOS Session Service" );
+       public static final ServiceType EMFIS_DATA  = new ServiceType( 140, 
"EMFIS Data Service" );
+       public static final ServiceType EMFIS_CNTL  = new ServiceType( 141, 
"EMFIS Control Service" );
+       public static final ServiceType BL_IDM      = new ServiceType( 142, 
"Britton-Lee IDM" );
+       public static final ServiceType SUR_MEAS    = new ServiceType( 243, 
"Survey Measurement" );
+       public static final ServiceType LINK        = new ServiceType( 245, 
"LINK" );
+       
+       public String toString()
+    {
+               return name;
+       }
+
+       public int compareTo( Object that )
+    {
+               return ordinal - ( (ServiceType) that ).ordinal;
+       }
+
+       public static ServiceType getTypeByOrdinal( int type )
+    {
+               for ( int ii = 0; ii < values.length; ii++ )
+                       if ( values[ ii ].ordinal == type )
+                               return values[ ii ];
+               return NULL;
+       }
+       
+       public int getOrdinal()
+    {
+               return ordinal;
+       }
+
+       /// PRIVATE /////
+       private final String name;
+       private final int    ordinal;
+
+       /**
+        * Private constructor prevents construction outside of this class.
+        */
+       private ServiceType( int ordinal, String name )
+    {
+        this.ordinal = ordinal;
+               this.name    = name;
+       }
+
+       /**
+        * These two lines are all that's necessary to export a List of VALUES.
+        */
+       private static final ServiceType[] values = { NULL, RJE, ECHO, DISCARD, 
USERS, DAYTIME,
+                       QUOTE, CHARGEN, FTP_DATA, FTP, TELNET, SMTP, NSW_FE, 
MSG_ICP, MSG_AUTH, DSP,
+                       TIME, RLP, GRAPHICS, NAMESERVER, NICKNAME, MPM_FLAGS, 
MPM, MPM_SND, NI_FTP,
+                       LOGIN, LA_MAINT, DOMAIN, ISI_GL,NI_MAIL, VIA_FTP, 
TACACS_DS, BOOTPS, BOOTPC,
+                       TFTP, NETRJS_1, NETRJS_2, NETRJS_3, NETRJS_4, FINGER, 
HOSTS2_NS, SU_MIT_TG,
+                       MIT_DOV, DCP, SUPDUP, SWIFT_RVF, TACNEWS, METAGRAM, 
HOSTNAME, ISO_TSAP, X400,
+                       X400_SND, CSNET_NS, RTELNET, POP_2, SUNRPC, AUTH, SFTP, 
UUCP_PATH, NNTP, ERPC,
+                       NTP, LOCUS_MAP, LOCUS_CON, PWDGEN, CISCO_FNA, 
CISCO_TNA, CISCO_SYS, STATSRV,
+                       INGRES_NET, LOC_SRV, PROFILE, NETBIOS_NS, NETBIOS_DGM, 
NETBIOS_SSN, EMFIS_DATA,
+                       EMFIS_CNTL, BL_IDM, SUR_MEAS, LINK };
+       // VALUES needs to be located here, otherwise illegal forward reference
+       public static final List VALUES = Collections.unmodifiableList( 
Arrays.asList( values ) );
+}
+

Added: 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/internet/WellKnownServicesRecord.java
Url: 
http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/internet/WellKnownServicesRecord.java?view=auto&rev=125966
==============================================================================
--- (empty file)
+++ 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/records/internet/WellKnownServicesRecord.java
    Fri Jan 21 13:47:20 2005
@@ -0,0 +1,95 @@
+/*
+ *   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.records.internet;
+
+import org.apache.dns.records.InternetResource;
+import org.apache.dns.records.RecordType;
+import org.apache.dns.records.ResourceRecord;
+
+/**
+ * 3.4.2. WKS RDATA format
+ * 
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *     |                    ADDRESS                    |
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *     |       PROTOCOL        |                       |
+ *     +--+--+--+--+--+--+--+--+                       |
+ *     |                                               |
+ *     /                   <BIT MAP>                   /
+ *     /                                               /
+ *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * 
+ * where:
+ * 
+ * ADDRESS         An 32 bit Internet address
+ * 
+ * PROTOCOL        An 8 bit IP protocol number
+ * 
+ * <BIT MAP>       A variable length bit map.  The bit map must be a
+ *                 multiple of 8 bits long.
+ * 
+ * The WKS record is used to describe the well known services supported by
+ * a particular protocol on a particular internet address.  The PROTOCOL
+ * field specifies an IP protocol number, and the bit map has one bit per
+ * port of the specified protocol.  The first bit corresponds to port 0,
+ * the second to port 1, etc.  If the bit map does not include a bit for a
+ * protocol of interest, that bit is assumed zero.  The appropriate values
+ * and mnemonics for ports and protocols are specified in [RFC-1010].
+ * 
+ * For example, if PROTOCOL=TCP (6), the 26th bit corresponds to TCP port
+ * 25 (SMTP).  If this bit is set, a SMTP server should be listening on TCP
+ * port 25; if zero, SMTP service is not supported on the specified
+ * address.
+ * 
+ * The purpose of WKS RRs is to provide availability information for
+ * servers for TCP and UDP.  If a server supports both TCP and UDP, or has
+ * multiple Internet addresses, then multiple WKS RRs are used.
+ * 
+ * WKS RRs cause no additional section processing.
+ * 
+ * In master files, both ports and protocols are expressed using mnemonics
+ * or decimal numbers.
+ */
+public class WellKnownServicesRecord extends InternetResource
+{
+       /**
+        * Basic ResourceRecord constructor.
+        */
+       public WellKnownServicesRecord( String domainName, int timeToLive, 
byte[] resourceData )
+       {
+               super( domainName, RecordType.WKS, timeToLive, resourceData );
+       }
+       
+    /**
+     * Static factory method, type-conversion operator.
+     */
+       public static ResourceRecord valueOf( String domainName, int 
timeToLive, int protocol, byte[] bitMap )
+       {
+               byte[] resourceData = new byte[ 1 + bitMap.length ];
+               
+               resourceData[0] = (byte)( protocol & 0xFF );
+               
+               for ( int ii = 0; ii < bitMap.length; ii++ )
+               {
+                       resourceData[ ii + 1 ] = bitMap[ ii ];
+               }
+               
+               return new WellKnownServicesRecord( domainName, timeToLive, 
resourceData );
+       }
+}
+

Reply via email to