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 package org.apache.directory.server.kerberos.shared.messages.value.types; 21 22 23 /** 24 * Host Address type. Theyare described in RFC 4120, chap. 7.5.3. 25 * 26 * Only a few of them are declared : 27 * 28 * Address Type Value 29 * 30 * IPv4 2 31 * Directional 3 32 * ChaosNet 5 33 * XNS 6 34 * ISO 7 35 * DECNET Phase IV 12 36 * AppleTalk DDP 16 37 * NetBios 20 38 * IPv6 24 39 * 40 * The other address types are simply ignored. They are part of a Unix 41 * include file. 42 * 43 * @todo find the original include where those ignored values come from 44 * 45 * To be realistic, we may encounter IPv4, IPv6 and NetBios addresses in the real world... 46 * 47 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 48 * @version $Rev: 540371 $, $Date: 2007-05-22 02:00:43 +0200 (Tue, 22 May 2007) $ 49 */ 50 public enum HostAddrType 51 { 52 /** 53 * Constant for the "null" host address type. 54 */ 55 NULL( 0 ), 56 57 /** 58 * Constant for the "Unix" host address type. 59 * 60 * Not in RFC 61 */ 62 // ADDRTYPE_UNIX( 1 ), 63 64 /** 65 * Constant for the "Internet" host address type. 66 */ 67 ADDRTYPE_INET( 2 ), 68 69 /** 70 * Constant for the "Arpanet" host address type. 71 */ 72 ADDRTYPE_IMPLINK( 3 ), 73 74 /** 75 * Constant for the "PUP" host address type. 76 * 77 * Not in RFC 78 */ 79 //ADDRTYPE_PUP( 4 ), 80 81 /** 82 * Constant for the "CHAOS" host address type. 83 */ 84 ADDRTYPE_CHAOS( 5 ), 85 86 /** 87 * Constant for the "XEROX Network Services" host address type. 88 */ 89 ADDRTYPE_XNS( 6 ), 90 91 /** 92 * Constant for the "IPX" host address type. 93 * 94 * Not in RFC 95 */ 96 // ADDRTYPE_IPX( 6 ), 97 98 /** 99 * 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 }