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.shared.kerberos.codec.types; 21 22 23 /** 24 * Host Address type. They are 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 */ 49 public enum HostAddrType 50 { 51 /** 52 * Constant for the "null" host address type. 53 */ 54 NULL(0), 55 56 /** 57 * Constant for the "Unix" host address type. 58 * 59 * Not in RFC 60 */ 61 // ADDRTYPE_UNIX( 1 ), 62 63 /** 64 * Constant for the "Internet" host address type. 65 */ 66 ADDRTYPE_INET(2), 67 68 /** 69 * Constant for the "Arpanet" host address type. 70 */ 71 ADDRTYPE_IMPLINK(3), 72 73 /** 74 * Constant for the "PUP" host address type. 75 * 76 * Not in RFC 77 */ 78 //ADDRTYPE_PUP( 4 ), 79 80 /** 81 * Constant for the "CHAOS" host address type. 82 */ 83 ADDRTYPE_CHAOS(5), 84 85 /** 86 * Constant for the "XEROX Network Services" host address type. 87 */ 88 ADDRTYPE_XNS(6), 89 90 /** 91 * Constant for the "IPX" host address type. 92 * 93 * Not in RFC 94 */ 95 // ADDRTYPE_IPX( 6 ), 96 97 /** 98 * Constant for the "OSI" host address type. 99 */ 100 ADDRTYPE_OSI(7), 101 102 /** 103 * Constant for the "European Computer Manufacturers" host address type. 104 * 105 * Not in RFC 106 */ 107 //ADDRTYPE_ECMA( 8 ), 108 109 /** 110 * Constant for the "Datakit" host address type. 111 * 112 * Not in RFC 113 */ 114 //ADDRTYPE_DATAKIT( 9 ), 115 116 /** 117 * Constant for the "CCITT" host address type. 118 * 119 * Not in RFC 120 */ 121 //pADDRTYPE_CCITT( 10 ), 122 123 /** 124 * Constant for the "SNA" host address type. 125 * 126 * Not in RFC 127 */ 128 //ADDRTYPE_SNA( 11 ), 129 130 /** 131 * Constant for the "DECnet" host address type. 132 */ 133 ADDRTYPE_DECNET(12), 134 135 /** 136 * Constant for the "Direct Data Link Interface" host address type. 137 * 138 * Not in RFC 139 */ 140 //ADDRTYPE_DLI( 13 ), 141 142 /** 143 * Constant for the "LAT" host address type. 144 * 145 * Not in RFC 146 */ 147 //ADDRTYPE_LAT( 14 ), 148 149 /** 150 * Constant for the "NSC Hyperchannel" host address type. 151 * 152 * Not in RFC 153 */ 154 //ADDRTYPE_HYLINK( 15 ), 155 156 /** 157 * Constant for the "AppleTalk" host address type. 158 */ 159 ADDRTYPE_APPLETALK(16), 160 161 /** 162 * Constant for the "VoiceView" host address type. 163 * 164 * Not in RFC 165 */ 166 //ADDRTYPE_VOICEVIEW( 18 ), 167 168 /** 169 * Constant for the "Firefox" host address type. 170 * 171 * Not in RFC 172 */ 173 //ADDRTYPE_FIREFOX( 19 ), 174 175 /** 176 * Constant for the "NetBios" host address type. 177 * 178 * Not in RFC 179 */ 180 ADDRTYPE_NETBIOS(20), 181 182 /** 183 * Constant for the "Banyan" host address type. 184 * 185 * Not in RFC 186 */ 187 //ADDRTYPE_BAN( 21 ), 188 189 /** 190 * Constant for the "ATM" host address type. 191 * 192 * Not in RFC 193 */ 194 //ADDRTYPE_ATM( 22 ), 195 196 /** 197 * Constant for the "Internet Protocol V6" host address type. 198 */ 199 ADDRTYPE_INET6(24); 200 201 /** 202 * The value/code for the host address type. 203 */ 204 private final int value; 205 206 207 /** 208 * Private constructor prevents construction outside of this class. 209 */ 210 private HostAddrType( int value ) 211 { 212 this.value = value; 213 } 214 215 216 /** 217 * Returns the host address type when specified by its ordinal. 218 * 219 * @param type 220 * @return The host address type. 221 */ 222 public static HostAddrType getTypeByOrdinal( int type ) 223 { 224 switch ( type ) 225 { 226 case 0: 227 return NULL; 228 //case 1 : return ADDRTYPE_UNIX; 229 case 2: 230 return ADDRTYPE_INET; 231 case 3: 232 return ADDRTYPE_IMPLINK; 233 //case 4 : return ADDRTYPE_PUP; 234 case 5: 235 return ADDRTYPE_CHAOS; 236 case 6: 237 return ADDRTYPE_XNS; 238 case 7: 239 return ADDRTYPE_OSI; 240 //case 8 : return ADDRTYPE_ECMA; 241 //case 9 : return ADDRTYPE_DATAKIT; 242 //case 10 : return pADDRTYPE_CCITT; 243 //case 11 : return ADDRTYPE_SNA; 244 case 12: 245 return ADDRTYPE_DECNET; 246 //case 13 : return ADDRTYPE_DLI; 247 //case 14 : return ADDRTYPE_LAT; 248 //case 15 : return ADDRTYPE_HYLINK; 249 case 16: 250 return ADDRTYPE_APPLETALK; 251 //case 18 : return ADDRTYPE_VOICEVIEW; 252 //case 19 : return ADDRTYPE_FIREFOX; 253 case 20: 254 return ADDRTYPE_NETBIOS; 255 //case 21 : return ADDRTYPE_BAN; 256 //case 22 : return ADDRTYPE_ATM; 257 case 24: 258 return ADDRTYPE_INET6; 259 default: 260 return NULL; 261 } 262 } 263 264 265 /** 266 * Returns the number associated with this host address type. 267 * 268 * @return The host address type ordinal. 269 */ 270 public int getValue() 271 { 272 return value; 273 } 274 275 276 /** 277 * {@inheritDoc} 278 */ 279 @Override 280 public String toString() 281 { 282 switch ( value ) 283 { 284 //case 1 : return "Unix" + "(" + value + ")" ; 285 case 2: 286 return "Internet" + "(" + value + ")"; 287 case 3: 288 return "Arpanet" + "(" + value + ")"; 289 //case 4 : return "PUP" + "(" + value + ")" ; 290 case 5: 291 return "CHAOS" + "(" + value + ")"; 292 case 6: 293 return "XEROX Network Services" + "(" + value + ")"; 294 case 7: 295 return "OSI" + "(" + value + ")"; 296 //case 8 : return "European Computer Manufacturers" + "(" + value + ")" ; 297 //case 9 : return "Datakit" + "(" + value + ")" ; 298 //case 10 : return "CCITT" + "(" + value + ")" ; 299 //case 11 : return "SNA" + "(" + value + ")" ; 300 case 12: 301 return "DECnet" + "(" + value + ")"; 302 //case 13 : return "Direct Data Link Interface" + "(" + value + ")" ; 303 //case 14 : return "LAT" + "(" + value + ")" ; 304 //case 15 : return "NSC Hyperchannel" + "(" + value + ")" ; 305 //case 16 : return "AppleTalk" + "(" + value + ")" ; 306 //case 18 : return "VoiceView" + "(" + value + ")" ; 307 //case 19 : return "Firefox" + "(" + value + ")" ; 308 case 20: 309 return "NetBios" + "(" + value + ")"; 310 //case 21 : return "Banyan" + "(" + value + ")" ; 311 //case 22 : return "ATM" + "(" + value + ")" ; 312 case 24: 313 return "Internet Protocol V6" + "(" + value + ")"; 314 default: 315 return "null" + "(" + value + ")"; 316 } 317 } 318 }