Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 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 | ab5a736 | 2015-12-02 01:10:01 +0530 | [diff] [blame] | 41 | NICIRA_RESUBMIT_TABLE(14), |
Jonathan Hart | 010527b | 2015-12-02 16:11:53 -0800 | [diff] [blame] | 42 | NICIRA_SET_NSH_SPI(32), |
Phaneendra Manda | ab5a736 | 2015-12-02 01:10:01 +0530 | [diff] [blame] | 43 | NICIRA_SET_NSH_SI(33), |
| 44 | NICIRA_SET_NSH_CH1(34), |
| 45 | NICIRA_SET_NSH_CH2(35), |
| 46 | NICIRA_SET_NSH_CH3(36), |
samueljcc | 4a527ed | 2015-12-03 13:59:49 +0800 | [diff] [blame] | 47 | NICIRA_SET_NSH_CH4(37), |
Charles Chan | 14967c2 | 2015-12-07 11:11:50 -0800 | [diff] [blame] | 48 | OFDPA_SET_VLAN_ID(64); |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 49 | |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 50 | private ExtensionTreatmentType type; |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 51 | |
| 52 | /** |
Jonathan Hart | 010527b | 2015-12-02 16:11:53 -0800 | [diff] [blame] | 53 | * Creates a new named extension treatment type. |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 54 | * |
| 55 | * @param type type code |
| 56 | */ |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 57 | ExtensionTreatmentTypes(int type) { |
| 58 | this.type = new ExtensionTreatmentType(type); |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Gets the extension type object for this named type code. |
| 63 | * |
| 64 | * @return extension type object |
| 65 | */ |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 66 | public ExtensionTreatmentType type() { |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 67 | return type; |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | private final int type; |
| 72 | |
| 73 | /** |
| 74 | * Creates an extension type with the given int type code. |
| 75 | * |
| 76 | * @param type type code |
| 77 | */ |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 78 | public ExtensionTreatmentType(int type) { |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 79 | this.type = type; |
| 80 | } |
| 81 | |
| 82 | @Override |
| 83 | public int hashCode() { |
| 84 | return Objects.hash(type); |
| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public boolean equals(Object obj) { |
| 89 | if (this == obj) { |
| 90 | return true; |
| 91 | } |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 92 | if (obj instanceof ExtensionTreatmentType) { |
| 93 | final ExtensionTreatmentType that = (ExtensionTreatmentType) obj; |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 94 | return this.type == that.type; |
| 95 | } |
| 96 | return false; |
| 97 | } |
| 98 | |
| 99 | @Override |
| 100 | public String toString() { |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 101 | return MoreObjects.toStringHelper(ExtensionTreatmentType.class) |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 102 | .add("type", type) |
| 103 | .toString(); |
| 104 | } |
| 105 | } |