blob: f21bb7fc9757ef24bf138f6ebc77f9fc9a2b354f [file] [log] [blame]
Jonathan Hart3c259162015-10-21 21:31:19 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Jonathan Hart3c259162015-10-21 21:31:19 -07003 *
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/**
Jonathan Hart26a8d952015-12-02 15:16:35 -080025 * Type of treatment extensions.
Jonathan Hart3c259162015-10-21 21:31:19 -070026 */
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 {
alshabib880b6442015-11-23 22:13:04 -080035 NICIRA_SET_TUNNEL_DST(0),
Phaneendra Mandace66cbc2015-11-26 18:07:48 +053036 NICIRA_RESUBMIT(1),
Charles Chan14967c22015-12-07 11:11:50 -080037 NICIRA_MOV_ARP_SHA_TO_THA(2),
38 NICIRA_MOV_ARP_SPA_TO_TPA(3),
39 NICIRA_MOV_ETH_SRC_TO_DST(4),
40 NICIRA_MOV_IP_SRC_TO_DST(5),
Phaneendra Manda8db7d092016-06-04 00:17:24 +053041 NICIRA_MOV_NSH_C1_TO_C1(6),
42 NICIRA_MOV_NSH_C2_TO_C2(7),
43 NICIRA_MOV_NSH_C3_TO_C3(8),
44 NICIRA_MOV_NSH_C4_TO_C4(9),
45 NICIRA_MOV_TUN_IPV4_DST_TO_TUN_IPV4_DST(10),
46 NICIRA_MOV_TUN_ID_TO_TUN_ID(11),
47 NICIRA_MOV_NSH_C2_TO_TUN_ID(12),
Phaneendra Mandaab5a7362015-12-02 01:10:01 +053048 NICIRA_RESUBMIT_TABLE(14),
Phaneendra Manda8db7d092016-06-04 00:17:24 +053049 NICIRA_PUSH_NSH(38),
50 NICIRA_POP_NSH(39),
Carmelo Cascone2ea177b2016-02-25 18:38:42 -080051 OFDPA_SET_VLAN_ID(64),
Charles Chancad338a2016-09-16 18:03:11 -070052 OFDPA_SET_MPLS_TYPE(65),
Pier Ventre6f630052016-10-18 09:58:41 -070053 OFDPA_SET_OVID(66),
Pier Ventre9cf536b2016-10-21 13:30:18 -070054 OFDPA_SET_MPLS_L2_PORT(67),
Phaneendra Manda8db7d092016-06-04 00:17:24 +053055 NICIRA_TUN_GPE_NP(111),
56 NICIRA_SET_NSH_SPI(113),
57 NICIRA_SET_NSH_SI(114),
58 NICIRA_SET_NSH_CH1(115),
59 NICIRA_SET_NSH_CH2(116),
60 NICIRA_SET_NSH_CH3(117),
61 NICIRA_SET_NSH_CH4(118),
62 NICIRA_NSH_MDTYPE(119),
63 NICIRA_NSH_NP(120),
64 NICIRA_ENCAP_ETH_SRC(121),
65 NICIRA_ENCAP_ETH_DST(122),
66 NICIRA_ENCAP_ETH_TYPE(123),
yjimmyycfcb0532016-07-11 16:03:48 -070067 BMV2_ACTION(128),
Frank Wang72c5e432016-09-23 17:20:49 +080068 OPLINK_ATTENUATION(130),
69
70 UNRESOLVED_TYPE(200);
Jonathan Hart3c259162015-10-21 21:31:19 -070071
alshabib880b6442015-11-23 22:13:04 -080072 private ExtensionTreatmentType type;
Jonathan Hart3c259162015-10-21 21:31:19 -070073
74 /**
Jonathan Hart010527b2015-12-02 16:11:53 -080075 * Creates a new named extension treatment type.
Jonathan Hart3c259162015-10-21 21:31:19 -070076 *
77 * @param type type code
78 */
alshabib880b6442015-11-23 22:13:04 -080079 ExtensionTreatmentTypes(int type) {
80 this.type = new ExtensionTreatmentType(type);
Jonathan Hart3c259162015-10-21 21:31:19 -070081 }
82
83 /**
84 * Gets the extension type object for this named type code.
85 *
86 * @return extension type object
87 */
alshabib880b6442015-11-23 22:13:04 -080088 public ExtensionTreatmentType type() {
Jonathan Hart3c259162015-10-21 21:31:19 -070089 return type;
90 }
91 }
92
93 private final int type;
94
95 /**
96 * Creates an extension type with the given int type code.
97 *
98 * @param type type code
99 */
alshabib880b6442015-11-23 22:13:04 -0800100 public ExtensionTreatmentType(int type) {
Jonathan Hart3c259162015-10-21 21:31:19 -0700101 this.type = type;
102 }
103
Jian Lidab72562016-04-12 14:10:32 -0700104 /**
105 * Returns extension treatment type.
106 *
107 * @return extension treatment type
108 */
109 public int type() {
110 return type;
111 }
112
Jonathan Hart3c259162015-10-21 21:31:19 -0700113 @Override
114 public int hashCode() {
115 return Objects.hash(type);
116 }
117
118 @Override
119 public boolean equals(Object obj) {
120 if (this == obj) {
121 return true;
122 }
alshabib880b6442015-11-23 22:13:04 -0800123 if (obj instanceof ExtensionTreatmentType) {
124 final ExtensionTreatmentType that = (ExtensionTreatmentType) obj;
Jonathan Hart3c259162015-10-21 21:31:19 -0700125 return this.type == that.type;
126 }
127 return false;
128 }
129
130 @Override
131 public String toString() {
alshabib880b6442015-11-23 22:13:04 -0800132 return MoreObjects.toStringHelper(ExtensionTreatmentType.class)
Jonathan Hart3c259162015-10-21 21:31:19 -0700133 .add("type", type)
134 .toString();
135 }
136}