blob: b552e08096953940df07eb67d96c0daad42b65d0 [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 */
16package org.onosproject.lisp.msg.types;
17
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 Li89c9ca92016-11-11 04:09:02 +090024 * LCAF is defined in draft-ietf-lisp-lcaf-20
25 * https://tools.ietf.org/html/draft-ietf-lisp-lcaf-20
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
33 MULTICAST(9), // Multi-cast Info Type
34 SECURITY(11), // Security Key Type
35 SOURCE_DEST(12), // Source/Dest Key Type
36 TRAFFIC_ENGINEERING(10), // Explicit Locator Path Type
Jian Li52015762016-10-04 17:51:16 +090037 UNSPECIFIED(0), // Unspecified Type
Jian Li09596002016-07-15 17:46:49 +090038 UNKNOWN(-1); // Unknown Type
39
40 private byte lispCode;
41
42 /**
43 * Private constructor which avoid instantiating object externally.
44 *
45 * @param lispCode lisp code value
46 */
47 LispCanonicalAddressFormatEnum(int lispCode) {
48 this.lispCode = (byte) lispCode;
49 }
50
51 /**
52 * Obtains lisp code value.
53 *
54 * @return lisp code value
55 */
56 public byte getLispCode() {
57 return lispCode;
58 }
59
60 /**
61 * Obtains the LCAF enum using given lisp code.
62 *
63 * @param lispCode lisp code
64 * @return LCAP enum
65 */
66 public static LispCanonicalAddressFormatEnum valueOf(int lispCode) {
67 for (LispCanonicalAddressFormatEnum val : values()) {
68 if (val.getLispCode() == lispCode) {
69 return val;
70 }
71 }
72 return UNKNOWN;
73 }
74}