001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 *
019 */
020 package org.apache.directory.server.kerberos.shared.messages.value.types;
021
022
023 /**
024 * Host Address type. Theyare described in RFC 4120, chap. 7.5.3.
025 *
026 * Only a few of them are declared :
027 *
028 * Address Type Value
029 *
030 * IPv4 2
031 * Directional 3
032 * ChaosNet 5
033 * XNS 6
034 * ISO 7
035 * DECNET Phase IV 12
036 * AppleTalk DDP 16
037 * NetBios 20
038 * IPv6 24
039 *
040 * The other address types are simply ignored. They are part of a Unix
041 * include file.
042 *
043 * @todo find the original include where those ignored values come from
044 *
045 * To be realistic, we may encounter IPv4, IPv6 and NetBios addresses in the real world...
046 *
047 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
048 * @version $Rev: 540371 $, $Date: 2007-05-22 02:00:43 +0200 (Tue, 22 May 2007) $
049 */
050 public enum HostAddrType
051 {
052 /**
053 * Constant for the "null" host address type.
054 */
055 NULL( 0 ),
056
057 /**
058 * Constant for the "Unix" host address type.
059 *
060 * Not in RFC
061 */
062 // ADDRTYPE_UNIX( 1 ),
063
064 /**
065 * Constant for the "Internet" host address type.
066 */
067 ADDRTYPE_INET( 2 ),
068
069 /**
070 * Constant for the "Arpanet" host address type.
071 */
072 ADDRTYPE_IMPLINK( 3 ),
073
074 /**
075 * Constant for the "PUP" host address type.
076 *
077 * Not in RFC
078 */
079 //ADDRTYPE_PUP( 4 ),
080
081 /**
082 * Constant for the "CHAOS" host address type.
083 */
084 ADDRTYPE_CHAOS( 5 ),
085
086 /**
087 * Constant for the "XEROX Network Services" host address type.
088 */
089 ADDRTYPE_XNS( 6 ),
090
091 /**
092 * Constant for the "IPX" host address type.
093 *
094 * Not in RFC
095 */
096 // ADDRTYPE_IPX( 6 ),
097
098 /**
099 * Constant for the "OSI" host address type.
100 */
101 ADDRTYPE_OSI( 7 ),
102
103 /**
104 * Constant for the "European Computer Manufacturers" host address type.
105 *
106 * Not in RFC
107 */
108 //ADDRTYPE_ECMA( 8 ),
109
110 /**
111 * Constant for the "Datakit" host address type.
112 *
113 * Not in RFC
114 */
115 //ADDRTYPE_DATAKIT( 9 ),
116
117 /**
118 * Constant for the "CCITT" host address type.
119 *
120 * Not in RFC
121 */
122 //pADDRTYPE_CCITT( 10 ),
123
124 /**
125 * Constant for the "SNA" host address type.
126 *
127 * Not in RFC
128 */
129 //ADDRTYPE_SNA( 11 ),
130
131 /**
132 * Constant for the "DECnet" host address type.
133 */
134 ADDRTYPE_DECNET( 12 ),
135
136 /**
137 * Constant for the "Direct Data Link Interface" host address type.
138 *
139 * Not in RFC
140 */
141 //ADDRTYPE_DLI( 13 ),
142
143 /**
144 * Constant for the "LAT" host address type.
145 *
146 * Not in RFC
147 */
148 //ADDRTYPE_LAT( 14 ),
149
150 /**
151 * Constant for the "NSC Hyperchannel" host address type.
152 *
153 * Not in RFC
154 */
155 //ADDRTYPE_HYLINK( 15 ),
156
157 /**
158 * Constant for the "AppleTalk" host address type.
159 */
160 ADDRTYPE_APPLETALK( 16 ),
161
162 /**
163 * Constant for the "VoiceView" host address type.
164 *
165 * Not in RFC
166 */
167 //ADDRTYPE_VOICEVIEW( 18 ),
168
169 /**
170 * Constant for the "Firefox" host address type.
171 *
172 * Not in RFC
173 */
174 //ADDRTYPE_FIREFOX( 19 ),
175
176 /**
177 * Constant for the "NetBios" host address type.
178 *
179 * Not in RFC
180 */
181 ADDRTYPE_NETBIOS( 20 ),
182
183 /**
184 * Constant for the "Banyan" host address type.
185 *
186 * Not in RFC
187 */
188 //ADDRTYPE_BAN( 21 ),
189
190 /**
191 * Constant for the "ATM" host address type.
192 *
193 * Not in RFC
194 */
195 //ADDRTYPE_ATM( 22 ),
196
197 /**
198 * Constant for the "Internet Protocol V6" host address type.
199 */
200 ADDRTYPE_INET6( 24 );
201
202 /**
203 * The value/code for the host address type.
204 */
205 private final int ordinal;
206
207
208 /**
209 * Private constructor prevents construction outside of this class.
210 */
211 private HostAddrType( int ordinal )
212 {
213 this.ordinal = ordinal;
214 }
215
216
217 /**
218 * Returns the host address type when specified by its ordinal.
219 *
220 * @param type
221 * @return The host address type.
222 */
223 public static HostAddrType getTypeByOrdinal( int type )
224 {
225 switch ( type )
226 {
227 case 0 : return NULL;
228 //case 1 : return ADDRTYPE_UNIX;
229 case 2 : return ADDRTYPE_INET;
230 case 3 : return ADDRTYPE_IMPLINK;
231 //case 4 : return ADDRTYPE_PUP;
232 case 5 : return ADDRTYPE_CHAOS;
233 case 6 : return ADDRTYPE_XNS;
234 case 7 : return ADDRTYPE_OSI;
235 //case 8 : return ADDRTYPE_ECMA;
236 //case 9 : return ADDRTYPE_DATAKIT;
237 //case 10 : return pADDRTYPE_CCITT;
238 //case 11 : return ADDRTYPE_SNA;
239 case 12 : return ADDRTYPE_DECNET;
240 //case 13 : return ADDRTYPE_DLI;
241 //case 14 : return ADDRTYPE_LAT;
242 //case 15 : return ADDRTYPE_HYLINK;
243 case 16 : return ADDRTYPE_APPLETALK;
244 //case 18 : return ADDRTYPE_VOICEVIEW;
245 //case 19 : return ADDRTYPE_FIREFOX;
246 case 20 : return ADDRTYPE_NETBIOS;
247 //case 21 : return ADDRTYPE_BAN;
248 //case 22 : return ADDRTYPE_ATM;
249 case 24 : return ADDRTYPE_INET6;
250 default : return NULL;
251 }
252 }
253
254
255 /**
256 * Returns the number associated with this host address type.
257 *
258 * @return The host address type ordinal.
259 */
260 public int getOrdinal()
261 {
262 return ordinal;
263 }
264
265 public String toString()
266 {
267 switch ( ordinal )
268 {
269 //case 1 : return "Unix" + "(" + ordinal + ")" ;
270 case 2 : return "Internet" + "(" + ordinal + ")" ;
271 case 3 : return "Arpanet" + "(" + ordinal + ")" ;
272 //case 4 : return "PUP" + "(" + ordinal + ")" ;
273 case 5 : return "CHAOS" + "(" + ordinal + ")" ;
274 case 6 : return "XEROX Network Services" + "(" + ordinal + ")" ;
275 case 7 : return "OSI" + "(" + ordinal + ")" ;
276 //case 8 : return "European Computer Manufacturers" + "(" + ordinal + ")" ;
277 //case 9 : return "Datakit" + "(" + ordinal + ")" ;
278 //case 10 : return "CCITT" + "(" + ordinal + ")" ;
279 //case 11 : return "SNA" + "(" + ordinal + ")" ;
280 case 12 : return "DECnet" + "(" + ordinal + ")" ;
281 //case 13 : return "Direct Data Link Interface" + "(" + ordinal + ")" ;
282 //case 14 : return "LAT" + "(" + ordinal + ")" ;
283 //case 15 : return "NSC Hyperchannel" + "(" + ordinal + ")" ;
284 //case 16 : return "AppleTalk" + "(" + ordinal + ")" ;
285 //case 18 : return "VoiceView" + "(" + ordinal + ")" ;
286 //case 19 : return "Firefox" + "(" + ordinal + ")" ;
287 case 20 : return "NetBios" + "(" + ordinal + ")" ;
288 //case 21 : return "Banyan" + "(" + ordinal + ")" ;
289 //case 22 : return "ATM" + "(" + ordinal + ")" ;
290 case 24 : return "Internet Protocol V6" + "(" + ordinal + ")" ;
291 default : return "null" + "(" + ordinal + ")" ;
292 }
293 }
294 }