blob: f597a46c0f6b13d50753ddadd83e8b79858e64bd [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/**
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),
Phaneendra Mandaab5a7362015-12-02 01:10:01 +053037 NICIRA_RESUBMIT_TABLE(14),
Jonathan Hart010527b2015-12-02 16:11:53 -080038 NICIRA_SET_NSH_SPI(32),
Phaneendra Mandaab5a7362015-12-02 01:10:01 +053039 NICIRA_SET_NSH_SI(33),
40 NICIRA_SET_NSH_CH1(34),
41 NICIRA_SET_NSH_CH2(35),
42 NICIRA_SET_NSH_CH3(36),
samueljcc4a527ed2015-12-03 13:59:49 +080043 NICIRA_SET_NSH_CH4(37),
44 NICIRA_MOV_ARP_SHA_TO_THA(2),
45 NICIRA_MOV_ARP_SPA_TO_TPA(3),
46 NICIRA_MOV_ETH_SRC_TO_DST(4),
47 NICIRA_MOV_IP_SRC_TO_DST(5);
Jonathan Hart3c259162015-10-21 21:31:19 -070048
alshabib880b6442015-11-23 22:13:04 -080049 private ExtensionTreatmentType type;
Jonathan Hart3c259162015-10-21 21:31:19 -070050
51 /**
Jonathan Hart010527b2015-12-02 16:11:53 -080052 * Creates a new named extension treatment type.
Jonathan Hart3c259162015-10-21 21:31:19 -070053 *
54 * @param type type code
55 */
alshabib880b6442015-11-23 22:13:04 -080056 ExtensionTreatmentTypes(int type) {
57 this.type = new ExtensionTreatmentType(type);
Jonathan Hart3c259162015-10-21 21:31:19 -070058 }
59
60 /**
61 * Gets the extension type object for this named type code.
62 *
63 * @return extension type object
64 */
alshabib880b6442015-11-23 22:13:04 -080065 public ExtensionTreatmentType type() {
Jonathan Hart3c259162015-10-21 21:31:19 -070066 return type;
67 }
68 }
69
70 private final int type;
71
72 /**
73 * Creates an extension type with the given int type code.
74 *
75 * @param type type code
76 */
alshabib880b6442015-11-23 22:13:04 -080077 public ExtensionTreatmentType(int type) {
Jonathan Hart3c259162015-10-21 21:31:19 -070078 this.type = type;
79 }
80
81 @Override
82 public int hashCode() {
83 return Objects.hash(type);
84 }
85
86 @Override
87 public boolean equals(Object obj) {
88 if (this == obj) {
89 return true;
90 }
alshabib880b6442015-11-23 22:13:04 -080091 if (obj instanceof ExtensionTreatmentType) {
92 final ExtensionTreatmentType that = (ExtensionTreatmentType) obj;
Jonathan Hart3c259162015-10-21 21:31:19 -070093 return this.type == that.type;
94 }
95 return false;
96 }
97
98 @Override
99 public String toString() {
alshabib880b6442015-11-23 22:13:04 -0800100 return MoreObjects.toStringHelper(ExtensionTreatmentType.class)
Jonathan Hart3c259162015-10-21 21:31:19 -0700101 .add("type", type)
102 .toString();
103 }
104}