blob: dad75cbff49c93c50fbb47efffb74a682ac5326f [file] [log] [blame]
Jonathan Hart26a8d952015-12-02 15:16:35 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Jonathan Hart26a8d952015-12-02 15:16:35 -08003 *
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.criteria;
18
19import com.google.common.annotations.Beta;
20import com.google.common.base.MoreObjects;
21
22import java.util.Objects;
23
24/**
25 * Type of selector extensions.
26 */
27@Beta
28public 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 Mandaefb38752015-12-04 00:43:38 +053035 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 Chan14967c22015-12-07 11:11:50 -080040 NICIRA_MATCH_NSH_CH4(5),
Phaneendra Manda8db7d092016-06-04 00:17:24 +053041 NICIRA_MATCH_ENCAP_ETH_TYPE(6),
Carmelo Cascone2ea177b2016-02-25 18:38:42 -080042 OFDPA_MATCH_VLAN_VID(16),
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070043 BMV2_MATCH_PARAMS(128);
Jonathan Hart26a8d952015-12-02 15:16:35 -080044
45 private ExtensionSelectorType type;
46
47 /**
48 * Creates a new named extension selector type.
49 *
50 * @param type type code
51 */
52 ExtensionSelectorTypes(int type) {
53 this.type = new ExtensionSelectorType(type);
54 }
55
56 /**
57 * Gets the extension type object for this named type code.
58 *
59 * @return extension type object
60 */
61 public ExtensionSelectorType type() {
62 return type;
63 }
64 }
65
66 private final int type;
67
68 /**
69 * Creates an extension type with the given int type code.
70 *
71 * @param type type code
72 */
73 public ExtensionSelectorType(int type) {
74 this.type = type;
75 }
76
Carmelo Cascone17972822016-05-11 17:48:56 -070077 /**
78 * Returns the integer value associated with this type.
79 *
80 * @return an integer value
81 */
82 public int toInt() {
83 return this.type;
84 }
85
Jonathan Hart26a8d952015-12-02 15:16:35 -080086 @Override
87 public int hashCode() {
88 return Objects.hash(type);
89 }
90
91 @Override
92 public boolean equals(Object obj) {
93 if (this == obj) {
94 return true;
95 }
96 if (obj instanceof ExtensionSelectorType) {
97 final ExtensionSelectorType that = (ExtensionSelectorType) obj;
98 return this.type == that.type;
99 }
100 return false;
101 }
102
103 @Override
104 public String toString() {
105 return MoreObjects.toStringHelper(ExtensionSelectorType.class)
106 .add("type", type)
107 .toString();
108 }
109}