Jian Li | 0959600 | 2016-07-15 17:46:49 +0900 | [diff] [blame] | 1 | /* |
| 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 Li | f31019a | 2017-02-05 07:57:46 +0900 | [diff] [blame] | 16 | package org.onosproject.lisp.msg.types.lcaf; |
Jian Li | 0959600 | 2016-07-15 17:46:49 +0900 | [diff] [blame] | 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 Li | 2af9eaa | 2017-02-05 09:15:07 +0900 | [diff] [blame] | 24 | * LCAF is defined in draft-ietf-lisp-lcaf-22 |
| 25 | * https://tools.ietf.org/html/draft-ietf-lisp-lcaf-22 |
Jian Li | 0959600 | 2016-07-15 17:46:49 +0900 | [diff] [blame] | 26 | */ |
| 27 | public enum LispCanonicalAddressFormatEnum { |
Jian Li | c4d0391 | 2017-02-06 00:09:17 +0900 | [diff] [blame^] | 28 | UNKNOWN(-1), // Unknown Type |
| 29 | UNSPECIFIED(0), // Unspecified Type |
Jian Li | 0959600 | 2016-07-15 17:46:49 +0900 | [diff] [blame] | 30 | 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 Li | c4d0391 | 2017-02-06 00:09:17 +0900 | [diff] [blame^] | 34 | GEO_COORDINATE(5), // Geo Coordinate Type |
Jian Li | 0959600 | 2016-07-15 17:46:49 +0900 | [diff] [blame] | 35 | NAT(7), // NAT Traversal Type |
Jian Li | 3ff578d | 2017-02-05 15:34:37 +0900 | [diff] [blame] | 36 | NONCE(8), // Nonce Locator Type |
Jian Li | 0959600 | 2016-07-15 17:46:49 +0900 | [diff] [blame] | 37 | MULTICAST(9), // Multi-cast Info Type |
Jian Li | 2af9eaa | 2017-02-05 09:15:07 +0900 | [diff] [blame] | 38 | TRAFFIC_ENGINEERING(10), // Explicit Locator Path Type |
Jian Li | 0959600 | 2016-07-15 17:46:49 +0900 | [diff] [blame] | 39 | SECURITY(11), // Security Key Type |
Jian Li | c4d0391 | 2017-02-06 00:09:17 +0900 | [diff] [blame^] | 40 | SOURCE_DEST(12); // Source/Dest Key Type |
Jian Li | 0959600 | 2016-07-15 17:46:49 +0900 | [diff] [blame] | 41 | |
| 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 | } |