blob: 136534e6ec5d79f83a403aaba32f0c3a95a583a4 [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
28 NO_ADDRESS(0), IP(1), IP6(2), DNS(16), DISTINGUISHED_NAME(17), AS(18), LCAF(16387),
29 MAC(16389), OUI(16391), UNKNOWN(-1);
30
31 private short ianaCode;
32
33 AddressFamilyIdentifierEnum(int ianaCode) {
34 this.ianaCode = (short) ianaCode;
35 }
36
37 /**
38 * Obtains iana code value.
39 *
40 * @return iana code value
41 */
42 public short getIanaCode() {
43 return ianaCode;
44 }
45
46 /**
47 * Obtains AFI enum by providing iana code value.
48 *
49 * @param ianaCode iana code value
50 * @return AFI enum
51 */
52 public static AddressFamilyIdentifierEnum valueOf(short ianaCode) {
53 for (AddressFamilyIdentifierEnum val : values()) {
54 if (val.getIanaCode() == ianaCode) {
55 return val;
56 }
57 }
58 return UNKNOWN;
59 }
60}