Jian Li | 6b77dc0 | 2016-07-14 16:04:25 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.lisp.msg.types; |
| 17 | |
| 18 | /** |
| 19 | * Address Family Identifier (AFI) Enumeration class. |
| 20 | * |
| 21 | * An enumeration of AFIs defined by iana. |
| 22 | * Now, we only declare 10 enums, more enums will be declared later on. |
| 23 | * |
| 24 | * http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml |
| 25 | */ |
| 26 | public enum AddressFamilyIdentifierEnum { |
| 27 | |
Jian Li | d56f97e | 2016-07-19 15:48:15 +0900 | [diff] [blame] | 28 | NO_ADDRESS(0), // Reserved |
Jian Li | d4e6370 | 2016-08-30 18:29:20 +0900 | [diff] [blame] | 29 | IP4(1), // IP4 (IP version 4) |
Jian Li | d56f97e | 2016-07-19 15:48:15 +0900 | [diff] [blame] | 30 | IP6(2), // IP6 (IP version 6) |
| 31 | DNS(16), // Domain Name System |
| 32 | DISTINGUISHED_NAME(17), // Distinguished Name |
| 33 | AS(18), // AS Number |
| 34 | LCAF(16387), // LISP Canonical Address Format (LCAF) |
| 35 | MAC(16389), // 48-bit MAC |
| 36 | OUI(16391), // 24-bit Organizationally Unique Identifier |
| 37 | UNKNOWN(-1); // Other Enums for internal use |
Jian Li | 6b77dc0 | 2016-07-14 16:04:25 +0900 | [diff] [blame] | 38 | |
Jian Li | d56f97e | 2016-07-19 15:48:15 +0900 | [diff] [blame] | 39 | private final short ianaCode; |
Jian Li | 6b77dc0 | 2016-07-14 16:04:25 +0900 | [diff] [blame] | 40 | |
| 41 | AddressFamilyIdentifierEnum(int ianaCode) { |
| 42 | this.ianaCode = (short) ianaCode; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Obtains iana code value. |
| 47 | * |
| 48 | * @return iana code value |
| 49 | */ |
| 50 | public short getIanaCode() { |
| 51 | return ianaCode; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Obtains AFI enum by providing iana code value. |
| 56 | * |
| 57 | * @param ianaCode iana code value |
| 58 | * @return AFI enum |
| 59 | */ |
| 60 | public static AddressFamilyIdentifierEnum valueOf(short ianaCode) { |
| 61 | for (AddressFamilyIdentifierEnum val : values()) { |
| 62 | if (val.getIanaCode() == ianaCode) { |
| 63 | return val; |
| 64 | } |
| 65 | } |
| 66 | return UNKNOWN; |
| 67 | } |
| 68 | } |