blob: ea303f5f94f797cb5cab85a60c1a712de0238b84 [file] [log] [blame]
Jian Li10a09062016-07-26 23:58:50 +09001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Jian Li10a09062016-07-26 23:58:50 +09003 *
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 * An enumeration class that represents Map-Reply action.
20 *
21 * The current assigned values are:
22 *
23 * (0) No-Action: The map-cache is kept alive, and no packet
24 * encapsulation occurs.
25 *
26 * (1) Natively-Forward: The packet is not encapsulated or dropped
27 * but natively forwarded.
28 *
29 * (2) Send-Map-Request: The packet invokes sending a Map-Request.
30 *
31 * (3) Drop: A packet that matches this map-cache entry is dropped.
32 * An ICMP Destination Unreachable message SHOULD be sent.
33 */
34public enum LispMapReplyAction {
35
36 NoAction(0), // No-Action
37 NativelyForward(1), // Natively-Forward
38 SendMapRequest(2), // Send-Map-Request
39 Drop(3); // Drop
40
41 private int action;
42
43 LispMapReplyAction(int action) {
44 this.action = action;
45 }
46
47 /**
48 * Obtains MapReplyAction code.
49 *
50 * @return map reply action code
51 */
52 public int getAction() {
53 return action;
54 }
55
56 /**
57 * Obtains the LispMapReplyAction enum with given action code.
58 *
59 * @param action action code
60 * @return an enumeration of LispMapReplyAction
61 */
62 public static LispMapReplyAction valueOf(int action) {
63 for (LispMapReplyAction act : values()) {
64 if (act.getAction() == action) {
65 return act;
66 }
67 }
68 return null;
69 }
70}