blob: f3690da8b538de039b1bf1354d25467b5f8190c2 [file] [log] [blame]
Jonathan Hart3c259162015-10-21 21:31:19 -07001/*
2 * Copyright 2015 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 */
16
17package org.onosproject.net.flow.instructions;
18
19import com.google.common.annotations.Beta;
20import com.google.common.base.MoreObjects;
21
22import java.util.Objects;
23
24/**
25 * Type of extension instructions.
26 */
27@Beta
alshabib880b6442015-11-23 22:13:04 -080028public final class ExtensionTreatmentType {
Jonathan Hart3c259162015-10-21 21:31:19 -070029
30 /**
31 * A list of well-known named extension instruction type codes.
alshabib880b6442015-11-23 22:13:04 -080032 * These numbers have no impact on the actual OF type id.
Jonathan Hart3c259162015-10-21 21:31:19 -070033 */
alshabib880b6442015-11-23 22:13:04 -080034 public enum ExtensionTreatmentTypes {
Jonathan Hart3c259162015-10-21 21:31:19 -070035 // TODO fix type numbers to include experimenter id
alshabib880b6442015-11-23 22:13:04 -080036 NICIRA_SET_TUNNEL_DST(0),
Phaneendra Mandace66cbc2015-11-26 18:07:48 +053037 NICIRA_RESUBMIT(1),
BitOhenry74dd7e12015-12-01 09:07:19 +080038 NICIRA_SET_NSH_SPI(32),
39 NICIRA_RESUBMIT_TABLE(14);
Jonathan Hart3c259162015-10-21 21:31:19 -070040
alshabib880b6442015-11-23 22:13:04 -080041 private ExtensionTreatmentType type;
Jonathan Hart3c259162015-10-21 21:31:19 -070042
43 /**
44 * Creates a new named extension instruction type.
45 *
46 * @param type type code
47 */
alshabib880b6442015-11-23 22:13:04 -080048 ExtensionTreatmentTypes(int type) {
49 this.type = new ExtensionTreatmentType(type);
Jonathan Hart3c259162015-10-21 21:31:19 -070050 }
51
52 /**
53 * Gets the extension type object for this named type code.
54 *
55 * @return extension type object
56 */
alshabib880b6442015-11-23 22:13:04 -080057 public ExtensionTreatmentType type() {
Jonathan Hart3c259162015-10-21 21:31:19 -070058 return type;
59 }
60 }
61
62 private final int type;
63
64 /**
65 * Creates an extension type with the given int type code.
66 *
67 * @param type type code
68 */
alshabib880b6442015-11-23 22:13:04 -080069 public ExtensionTreatmentType(int type) {
Jonathan Hart3c259162015-10-21 21:31:19 -070070 this.type = type;
71 }
72
73 @Override
74 public int hashCode() {
75 return Objects.hash(type);
76 }
77
78 @Override
79 public boolean equals(Object obj) {
80 if (this == obj) {
81 return true;
82 }
alshabib880b6442015-11-23 22:13:04 -080083 if (obj instanceof ExtensionTreatmentType) {
84 final ExtensionTreatmentType that = (ExtensionTreatmentType) obj;
Jonathan Hart3c259162015-10-21 21:31:19 -070085 return this.type == that.type;
86 }
87 return false;
88 }
89
90 @Override
91 public String toString() {
alshabib880b6442015-11-23 22:13:04 -080092 return MoreObjects.toStringHelper(ExtensionTreatmentType.class)
Jonathan Hart3c259162015-10-21 21:31:19 -070093 .add("type", type)
94 .toString();
95 }
96}