blob: aeacc00b04d7bd1aa4adbc1e8a3c25e3b50f6eea [file] [log] [blame]
Jian Licb1fca22016-07-19 18:34:25 +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.protocols;
17
18/**
19 * LISP message type enumeration.
20 *
21 * An enumeration of LISP Message type defined in RFC6830
22 * https://tools.ietf.org/html/rfc6830
23 */
24public enum LispType {
Jian Licbc57e32016-09-14 09:06:54 +090025
26 LISP_MAP_REQUEST(1), // LISP Map-Request Message
27 LISP_MAP_REPLY(2), // LISP Map-Reply Message
28 LISP_MAP_REGISTER(3), // LISP Map-Register Message
29 LISP_MAP_NOTIFY(4), // LISP Map-Notify Message
Jian Li27759352016-10-04 20:14:42 +090030 LISP_INFO(7), // LISP Info-Request or Info-Reply Message
Jian Licbc57e32016-09-14 09:06:54 +090031 UNKNOWN(-1); // Other Enums for internal use
32
33 private final short type;
34
35 LispType(int type) {
36 this.type = (short) type;
37 }
38
39 /**
40 * Obtains LISP type code value.
41 *
42 * @return LISP type code value
43 */
44 public short getTypeCode() {
45 return type;
46 }
47
48 /**
49 * Obtains LISP type enum by providing type code value.
50 *
51 * @param typeCode LISP type code value
52 * @return LISP type enum
53 */
54 public static LispType valueOf(short typeCode) {
55 for (LispType val : values()) {
56 if (val.getTypeCode() == typeCode) {
57 return val;
58 }
59 }
60 return UNKNOWN;
61 }
Jian Licb1fca22016-07-19 18:34:25 +090062}