Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [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.criteria; |
| 18 | |
| 19 | import com.google.common.annotations.Beta; |
| 20 | import com.google.common.base.MoreObjects; |
| 21 | |
| 22 | import java.util.Objects; |
| 23 | |
| 24 | /** |
| 25 | * Type of selector extensions. |
| 26 | */ |
| 27 | @Beta |
| 28 | public class ExtensionSelectorType { |
| 29 | |
| 30 | /** |
| 31 | * A list of well-known named extension selector type codes. |
| 32 | * These numbers have no impact on the actual OF type id. |
| 33 | */ |
| 34 | public enum ExtensionSelectorTypes { |
Phaneendra Manda | efb3875 | 2015-12-04 00:43:38 +0530 | [diff] [blame] | 35 | NICIRA_MATCH_NSH_SPI(0), |
| 36 | NICIRA_MATCH_NSH_SI(1), |
| 37 | NICIRA_MATCH_NSH_CH1(2), |
| 38 | NICIRA_MATCH_NSH_CH2(3), |
| 39 | NICIRA_MATCH_NSH_CH3(4), |
Charles Chan | 14967c2 | 2015-12-07 11:11:50 -0800 | [diff] [blame] | 40 | NICIRA_MATCH_NSH_CH4(5), |
Phaneendra Manda | 8db7d09 | 2016-06-04 00:17:24 +0530 | [diff] [blame] | 41 | NICIRA_MATCH_ENCAP_ETH_TYPE(6), |
Frank Wang | 5733c38 | 2017-03-28 10:15:18 +0800 | [diff] [blame] | 42 | NICIRA_MATCH_CONNTRACK_STATE(7), |
| 43 | NICIRA_MATCH_CONNTRACK_ZONE(8), |
| 44 | NICIRA_MATCH_CONNTRACK_MARK(9), |
| 45 | NICIRA_MATCH_CONNTRACK_LABEL(10), |
Carmelo Cascone | 2ea177b | 2016-02-25 18:38:42 -0800 | [diff] [blame] | 46 | OFDPA_MATCH_VLAN_VID(16), |
Pier Ventre | 6f63005 | 2016-10-18 09:58:41 -0700 | [diff] [blame] | 47 | OFDPA_MATCH_OVID(17), |
Pier Ventre | 9cf536b | 2016-10-21 13:30:18 -0700 | [diff] [blame] | 48 | OFDPA_MATCH_MPLS_L2_PORT(18), |
Shashikanth VH | 8b1a5ef | 2016-12-26 14:37:43 +0530 | [diff] [blame] | 49 | EXT_MATCH_FLOW_TYPE(20), |
Andreas Pantelopoulos | fdcfe53 | 2018-04-02 10:59:23 -0700 | [diff] [blame] | 50 | OFDPA_MATCH_ACTSET_OUTPUT(19), |
| 51 | OFDPA_MATCH_ALLOW_VLAN_TRANSLATION(21), |
Frank Wang | 72c5e43 | 2016-09-23 17:20:49 +0800 | [diff] [blame] | 52 | |
| 53 | UNRESOLVED_TYPE(200); |
Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 54 | |
| 55 | private ExtensionSelectorType type; |
| 56 | |
| 57 | /** |
| 58 | * Creates a new named extension selector type. |
| 59 | * |
| 60 | * @param type type code |
| 61 | */ |
| 62 | ExtensionSelectorTypes(int type) { |
| 63 | this.type = new ExtensionSelectorType(type); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Gets the extension type object for this named type code. |
| 68 | * |
| 69 | * @return extension type object |
| 70 | */ |
| 71 | public ExtensionSelectorType type() { |
| 72 | return type; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | private final int type; |
| 77 | |
| 78 | /** |
| 79 | * Creates an extension type with the given int type code. |
| 80 | * |
| 81 | * @param type type code |
| 82 | */ |
| 83 | public ExtensionSelectorType(int type) { |
| 84 | this.type = type; |
| 85 | } |
| 86 | |
Carmelo Cascone | 1797282 | 2016-05-11 17:48:56 -0700 | [diff] [blame] | 87 | /** |
| 88 | * Returns the integer value associated with this type. |
| 89 | * |
| 90 | * @return an integer value |
| 91 | */ |
| 92 | public int toInt() { |
| 93 | return this.type; |
| 94 | } |
| 95 | |
Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 96 | @Override |
| 97 | public int hashCode() { |
| 98 | return Objects.hash(type); |
| 99 | } |
| 100 | |
| 101 | @Override |
| 102 | public boolean equals(Object obj) { |
| 103 | if (this == obj) { |
| 104 | return true; |
| 105 | } |
| 106 | if (obj instanceof ExtensionSelectorType) { |
| 107 | final ExtensionSelectorType that = (ExtensionSelectorType) obj; |
| 108 | return this.type == that.type; |
| 109 | } |
| 110 | return false; |
| 111 | } |
| 112 | |
| 113 | @Override |
| 114 | public String toString() { |
| 115 | return MoreObjects.toStringHelper(ExtensionSelectorType.class) |
| 116 | .add("type", type) |
| 117 | .toString(); |
| 118 | } |
| 119 | } |