View Javadoc

1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  
21  package org.apache.directory.server.dns.messages;
22  
23  
24  import org.apache.directory.server.dns.util.EnumConverter;
25  import org.apache.directory.server.dns.util.ReverseEnumMap;
26  
27  
28  /**
29   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
30   */
31  public enum RecordType implements EnumConverter<Short>
32  {
33      /** Host address */
34      A(1),
35  
36      /** Authoritative name server */
37      NS(2),
38  
39      /** Mail destination */
40      MD(3),
41  
42      /** Mail forwarder */
43      MF(4),
44  
45      /** Canonical name for an alias */
46      CNAME(5),
47  
48      /** Start of a zone of authority */
49      SOA(6),
50  
51      /** Mailbox domain name */
52      MB(7),
53  
54      /** Mail group member */
55      MG(8),
56  
57      /** Mail rename domain name */
58      MR(9),
59  
60      /** Null resource record */
61      NULL(10),
62  
63      /** Well know service description */
64      WKS(11),
65  
66      /** Domain name pointer */
67      PTR(12),
68  
69      /** Host information */
70      HINFO(13),
71  
72      /** Mailbox or mail list information */
73      MINFO(14),
74  
75      /** Mail exchange */
76      MX(15),
77  
78      /** Text strings */
79      TXT(16),
80  
81      /** Responsible person */
82      RP(17),
83  
84      /** AFS cell database */
85      AFSDB(18),
86  
87      /** X.25 calling address */
88      X25(19),
89  
90      /** ISDN calling address */
91      ISDN(20),
92  
93      /** Router */
94      RT(21),
95  
96      /** NSAP address */
97      NSAP(22),
98  
99      /** Reverse NSAP address (deprecated) */
100     NSAP_PTR(23),
101 
102     /** Signature */
103     SIG(24),
104 
105     /** Key */
106     KEY(25),
107 
108     /** X.400 mail mapping */
109     PX(26),
110 
111     /** Geographical position (withdrawn) */
112     GPOS(27),
113 
114     /** IPv6 address */
115     AAAA(28),
116 
117     /** Location */
118     LOC(29),
119 
120     /** Next valid name in zone */
121     NXT(30),
122 
123     /** Endpoint identifier */
124     EID(31),
125 
126     /** Nimrod locator */
127     NIMLOC(32),
128 
129     /** Server selection */
130     SRV(33),
131 
132     /** ATM address */
133     ATMA(34),
134 
135     /** Naming authority pointer */
136     NAPTR(35),
137 
138     /** Key exchange */
139     KX(36),
140 
141     /** Certificate */
142     CERT(34),
143 
144     /** IPv6 address (experimental) */
145     A6(38),
146 
147     /** Non-terminal name redirection */
148     DNAME(39),
149 
150     /** Options - contains EDNS metadata */
151     OPT(41),
152 
153     /** Address Prefix List */
154     APL(42),
155 
156     /** Delegation Signer */
157     DS(43),
158 
159     /** SSH Key Fingerprint */
160     SSHFP(44),
161 
162     /** Resource Record Signature */
163     RRSIG(46),
164 
165     /** Next Secure Name */
166     NSEC(47),
167 
168     /** DNSSEC Key */
169     DNSKEY(48),
170 
171     /** Transaction key - used to compute a shared secret or exchange a key */
172     TKEY(249),
173 
174     /** Transaction signature */
175     TSIG(250),
176 
177     /** Incremental zone transfer */
178     IXFR(251),
179 
180     /** Request for transfer of an entire zone */
181     AXFR(252),
182 
183     /** Request for mailbox-related records */
184     MAILB(253),
185 
186     /** Request for mail agent resource records */
187     MAILA(254),
188 
189     /** Request for all records */
190     ANY(255);
191 
192     private static ReverseEnumMap<Short, RecordType> map = new ReverseEnumMap<Short, RecordType>( RecordType.class );
193 
194     private final short value;
195 
196 
197     private RecordType( int value )
198     {
199         this.value = ( short ) value;
200     }
201 
202 
203     public Short convert()
204     {
205         return this.value;
206     }
207 
208 
209     /**
210      * Converts an ordinal value into a {@link RecordType}.
211      *
212      * @param value
213      * @return The {@link RecordType}.
214      */
215     public static RecordType convert( short value )
216     {
217         return map.get( value );
218     }
219 
220 
221     /**
222      * Returns whether a given {@link RecordType} is a {@link ResourceRecord}.
223      *
224      * @param resourceType
225      * @return true of the {@link RecordType} is a {@link ResourceRecord}.
226      */
227     public static boolean isResourceRecord( RecordType resourceType )
228     {
229         switch ( resourceType )
230         {
231             case OPT:
232             case TKEY:
233             case TSIG:
234             case IXFR:
235             case AXFR:
236             case MAILB:
237             case MAILA:
238             case ANY:
239                 return false;
240             default:
241                 return true;
242         }
243     }
244 }