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 */ 020package org.apache.directory.shared.kerberos.codec.types; 021 022 023/** 024 * Host Address type. They are 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 */ 049public enum HostAddrType 050{ 051 /** 052 * Constant for the "null" host address type. 053 */ 054 NULL(0), 055 056 /** 057 * Constant for the "Unix" host address type. 058 * 059 * Not in RFC 060 */ 061 // ADDRTYPE_UNIX( 1 ), 062 063 /** 064 * Constant for the "Internet" host address type. 065 */ 066 ADDRTYPE_INET(2), 067 068 /** 069 * Constant for the "Arpanet" host address type. 070 */ 071 ADDRTYPE_IMPLINK(3), 072 073 /** 074 * Constant for the "PUP" host address type. 075 * 076 * Not in RFC 077 */ 078 //ADDRTYPE_PUP( 4 ), 079 080 /** 081 * Constant for the "CHAOS" host address type. 082 */ 083 ADDRTYPE_CHAOS(5), 084 085 /** 086 * Constant for the "XEROX Network Services" host address type. 087 */ 088 ADDRTYPE_XNS(6), 089 090 /** 091 * Constant for the "IPX" host address type. 092 * 093 * Not in RFC 094 */ 095 // ADDRTYPE_IPX( 6 ), 096 097 /** 098 * Constant for the "OSI" host address type. 099 */ 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}