blob: 7191a2e32611b77490267cae57cb41a6b6a0592c [file] [log] [blame]
Jian Li09596002016-07-15 17:46:49 +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 */
Jian Lif31019a2017-02-05 07:57:46 +090016package org.onosproject.lisp.msg.types.lcaf;
Jian Li09596002016-07-15 17:46:49 +090017
18/**
19 * LISP Canonical Address Format (LCAF) Enumeration class.
20 *
21 * LCAF defines a canonical address format encoding used in LISP control message
22 * and in the encoding of lookup keys for the LISP Mapping Database System.
23 *
Jian Li2af9eaa2017-02-05 09:15:07 +090024 * LCAF is defined in draft-ietf-lisp-lcaf-22
25 * https://tools.ietf.org/html/draft-ietf-lisp-lcaf-22
Jian Li09596002016-07-15 17:46:49 +090026 */
27public enum LispCanonicalAddressFormatEnum {
Jian Lic4d03912017-02-06 00:09:17 +090028 UNKNOWN(-1), // Unknown Type
29 UNSPECIFIED(0), // Unspecified Type
Jian Li09596002016-07-15 17:46:49 +090030 LIST(1), // AFI LIST Type
31 SEGMENT(2), // Instance ID Type
32 AS(3), // AS Number Type
33 APPLICATION_DATA(4), // Application Data Type
Jian Lic4d03912017-02-06 00:09:17 +090034 GEO_COORDINATE(5), // Geo Coordinate Type
Jian Li09596002016-07-15 17:46:49 +090035 NAT(7), // NAT Traversal Type
Jian Li3ff578d2017-02-05 15:34:37 +090036 NONCE(8), // Nonce Locator Type
Jian Li09596002016-07-15 17:46:49 +090037 MULTICAST(9), // Multi-cast Info Type
Jian Li2af9eaa2017-02-05 09:15:07 +090038 TRAFFIC_ENGINEERING(10), // Explicit Locator Path Type
Jian Li09596002016-07-15 17:46:49 +090039 SECURITY(11), // Security Key Type
Jian Lic4d03912017-02-06 00:09:17 +090040 SOURCE_DEST(12); // Source/Dest Key Type
Jian Li09596002016-07-15 17:46:49 +090041
42 private byte lispCode;
43
44 /**
45 * Private constructor which avoid instantiating object externally.
46 *
47 * @param lispCode lisp code value
48 */
49 LispCanonicalAddressFormatEnum(int lispCode) {
50 this.lispCode = (byte) lispCode;
51 }
52
53 /**
54 * Obtains lisp code value.
55 *
56 * @return lisp code value
57 */
58 public byte getLispCode() {
59 return lispCode;
60 }
61
62 /**
63 * Obtains the LCAF enum using given lisp code.
64 *
65 * @param lispCode lisp code
66 * @return LCAP enum
67 */
68 public static LispCanonicalAddressFormatEnum valueOf(int lispCode) {
69 for (LispCanonicalAddressFormatEnum val : values()) {
70 if (val.getLispCode() == lispCode) {
71 return val;
72 }
73 }
74 return UNKNOWN;
75 }
76}