blob: e1a4d97b863a53e3cc117343ab4a771130b9e4b6 [file] [log] [blame]
Jian Li6b77dc02016-07-14 16:04:25 +09001/*
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 */
16package 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 */
26public enum AddressFamilyIdentifierEnum {
27
Jian Lid56f97e2016-07-19 15:48:15 +090028 NO_ADDRESS(0), // Reserved
Jian Lid4e63702016-08-30 18:29:20 +090029 IP4(1), // IP4 (IP version 4)
Jian Lid56f97e2016-07-19 15:48:15 +090030 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 Li6b77dc02016-07-14 16:04:25 +090038
Jian Lid56f97e2016-07-19 15:48:15 +090039 private final short ianaCode;
Jian Li6b77dc02016-07-14 16:04:25 +090040
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}