blob: 6ad3cdbf1c04712b5d3a09367918b8b0c7bde2e4 [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 *
24 * LCAF is defined in draft-ietf-lisp-lcaf-13
25 * https://tools.ietf.org/html/draft-ietf-lisp-lcaf-13
26 */
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
37 UNKNOWN(-1); // Unknown Type
38
39 private byte lispCode;
40
41 /**
42 * Private constructor which avoid instantiating object externally.
43 *
44 * @param lispCode lisp code value
45 */
46 LispCanonicalAddressFormatEnum(int lispCode) {
47 this.lispCode = (byte) lispCode;
48 }
49
50 /**
51 * Obtains lisp code value.
52 *
53 * @return lisp code value
54 */
55 public byte getLispCode() {
56 return lispCode;
57 }
58
59 /**
60 * Obtains the LCAF enum using given lisp code.
61 *
62 * @param lispCode lisp code
63 * @return LCAP enum
64 */
65 public static LispCanonicalAddressFormatEnum valueOf(int lispCode) {
66 for (LispCanonicalAddressFormatEnum val : values()) {
67 if (val.getLispCode() == lispCode) {
68 return val;
69 }
70 }
71 return UNKNOWN;
72 }
73}