blob: b6cfa7195c3045d010d20d9ac75157e73557e9d8 [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 {
28 LIST(1), // AFI LIST Type
29 SEGMENT(2), // Instance ID Type
30 AS(3), // AS Number Type
31 APPLICATION_DATA(4), // Application Data Type
32 NAT(7), // NAT Traversal Type
Jian Li3ff578d2017-02-05 15:34:37 +090033 NONCE(8), // Nonce Locator Type
Jian Li09596002016-07-15 17:46:49 +090034 MULTICAST(9), // Multi-cast Info Type
Jian Li2af9eaa2017-02-05 09:15:07 +090035 TRAFFIC_ENGINEERING(10), // Explicit Locator Path Type
Jian Li09596002016-07-15 17:46:49 +090036 SECURITY(11), // Security Key Type
37 SOURCE_DEST(12), // Source/Dest Key Type
Jian Li52015762016-10-04 17:51:16 +090038 UNSPECIFIED(0), // Unspecified Type
Jian Li09596002016-07-15 17:46:49 +090039 UNKNOWN(-1); // Unknown Type
40
41 private byte lispCode;
42
43 /**
44 * Private constructor which avoid instantiating object externally.
45 *
46 * @param lispCode lisp code value
47 */
48 LispCanonicalAddressFormatEnum(int lispCode) {
49 this.lispCode = (byte) lispCode;
50 }
51
52 /**
53 * Obtains lisp code value.
54 *
55 * @return lisp code value
56 */
57 public byte getLispCode() {
58 return lispCode;
59 }
60
61 /**
62 * Obtains the LCAF enum using given lisp code.
63 *
64 * @param lispCode lisp code
65 * @return LCAP enum
66 */
67 public static LispCanonicalAddressFormatEnum valueOf(int lispCode) {
68 for (LispCanonicalAddressFormatEnum val : values()) {
69 if (val.getLispCode() == lispCode) {
70 return val;
71 }
72 }
73 return UNKNOWN;
74 }
75}