Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 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 | |
| 17 | package org.onosproject.net.flow.instructions; |
| 18 | |
| 19 | import com.google.common.annotations.Beta; |
| 20 | import com.google.common.base.MoreObjects; |
| 21 | |
| 22 | import java.util.Objects; |
| 23 | |
| 24 | /** |
Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 25 | * Type of treatment extensions. |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 26 | */ |
| 27 | @Beta |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 28 | public final class ExtensionTreatmentType { |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 29 | |
| 30 | /** |
| 31 | * A list of well-known named extension instruction type codes. |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 32 | * These numbers have no impact on the actual OF type id. |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 33 | */ |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 34 | public enum ExtensionTreatmentTypes { |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 35 | NICIRA_SET_TUNNEL_DST(0), |
Phaneendra Manda | ce66cbc | 2015-11-26 18:07:48 +0530 | [diff] [blame] | 36 | NICIRA_RESUBMIT(1), |
Charles Chan | 14967c2 | 2015-12-07 11:11:50 -0800 | [diff] [blame] | 37 | 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 Manda | 8db7d09 | 2016-06-04 00:17:24 +0530 | [diff] [blame] | 41 | 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 Manda | ab5a736 | 2015-12-02 01:10:01 +0530 | [diff] [blame] | 48 | NICIRA_RESUBMIT_TABLE(14), |
Phaneendra Manda | 8db7d09 | 2016-06-04 00:17:24 +0530 | [diff] [blame] | 49 | NICIRA_PUSH_NSH(38), |
| 50 | NICIRA_POP_NSH(39), |
Carmelo Cascone | 2ea177b | 2016-02-25 18:38:42 -0800 | [diff] [blame] | 51 | OFDPA_SET_VLAN_ID(64), |
Phaneendra Manda | 8db7d09 | 2016-06-04 00:17:24 +0530 | [diff] [blame] | 52 | NICIRA_TUN_GPE_NP(111), |
| 53 | NICIRA_SET_NSH_SPI(113), |
| 54 | NICIRA_SET_NSH_SI(114), |
| 55 | NICIRA_SET_NSH_CH1(115), |
| 56 | NICIRA_SET_NSH_CH2(116), |
| 57 | NICIRA_SET_NSH_CH3(117), |
| 58 | NICIRA_SET_NSH_CH4(118), |
| 59 | NICIRA_NSH_MDTYPE(119), |
| 60 | NICIRA_NSH_NP(120), |
| 61 | NICIRA_ENCAP_ETH_SRC(121), |
| 62 | NICIRA_ENCAP_ETH_DST(122), |
| 63 | NICIRA_ENCAP_ETH_TYPE(123), |
yjimmyy | cfcb053 | 2016-07-11 16:03:48 -0700 | [diff] [blame] | 64 | BMV2_ACTION(128), |
| 65 | OPLINK_ATTENUATION(130); |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 66 | |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 67 | private ExtensionTreatmentType type; |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 68 | |
| 69 | /** |
Jonathan Hart | 010527b | 2015-12-02 16:11:53 -0800 | [diff] [blame] | 70 | * Creates a new named extension treatment type. |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 71 | * |
| 72 | * @param type type code |
| 73 | */ |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 74 | ExtensionTreatmentTypes(int type) { |
| 75 | this.type = new ExtensionTreatmentType(type); |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Gets the extension type object for this named type code. |
| 80 | * |
| 81 | * @return extension type object |
| 82 | */ |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 83 | public ExtensionTreatmentType type() { |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 84 | return type; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | private final int type; |
| 89 | |
| 90 | /** |
| 91 | * Creates an extension type with the given int type code. |
| 92 | * |
| 93 | * @param type type code |
| 94 | */ |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 95 | public ExtensionTreatmentType(int type) { |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 96 | this.type = type; |
| 97 | } |
| 98 | |
Jian Li | dab7256 | 2016-04-12 14:10:32 -0700 | [diff] [blame] | 99 | /** |
| 100 | * Returns extension treatment type. |
| 101 | * |
| 102 | * @return extension treatment type |
| 103 | */ |
| 104 | public int type() { |
| 105 | return type; |
| 106 | } |
| 107 | |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 108 | @Override |
| 109 | public int hashCode() { |
| 110 | return Objects.hash(type); |
| 111 | } |
| 112 | |
| 113 | @Override |
| 114 | public boolean equals(Object obj) { |
| 115 | if (this == obj) { |
| 116 | return true; |
| 117 | } |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 118 | if (obj instanceof ExtensionTreatmentType) { |
| 119 | final ExtensionTreatmentType that = (ExtensionTreatmentType) obj; |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 120 | return this.type == that.type; |
| 121 | } |
| 122 | return false; |
| 123 | } |
| 124 | |
| 125 | @Override |
| 126 | public String toString() { |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 127 | return MoreObjects.toStringHelper(ExtensionTreatmentType.class) |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 128 | .add("type", type) |
| 129 | .toString(); |
| 130 | } |
| 131 | } |