blob: 466469396af4c9cc6d5244e9ded10d9433338a32 [file] [log] [blame]
Jonathan Hart26a8d952015-12-02 15:16:35 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
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),
Frank Wang5733c382017-03-28 10:15:18 +080042 NICIRA_MATCH_CONNTRACK_STATE(7),
43 NICIRA_MATCH_CONNTRACK_ZONE(8),
44 NICIRA_MATCH_CONNTRACK_MARK(9),
45 NICIRA_MATCH_CONNTRACK_LABEL(10),
Carmelo Cascone2ea177b2016-02-25 18:38:42 -080046 OFDPA_MATCH_VLAN_VID(16),
Pier Ventre6f630052016-10-18 09:58:41 -070047 OFDPA_MATCH_OVID(17),
Pier Ventre9cf536b2016-10-21 13:30:18 -070048 OFDPA_MATCH_MPLS_L2_PORT(18),
Shashikanth VH8b1a5ef2016-12-26 14:37:43 +053049 EXT_MATCH_FLOW_TYPE(20),
Frank Wang72c5e432016-09-23 17:20:49 +080050
51 UNRESOLVED_TYPE(200);
Jonathan Hart26a8d952015-12-02 15:16:35 -080052
53 private ExtensionSelectorType type;
54
55 /**
56 * Creates a new named extension selector type.
57 *
58 * @param type type code
59 */
60 ExtensionSelectorTypes(int type) {
61 this.type = new ExtensionSelectorType(type);
62 }
63
64 /**
65 * Gets the extension type object for this named type code.
66 *
67 * @return extension type object
68 */
69 public ExtensionSelectorType type() {
70 return type;
71 }
72 }
73
74 private final int type;
75
76 /**
77 * Creates an extension type with the given int type code.
78 *
79 * @param type type code
80 */
81 public ExtensionSelectorType(int type) {
82 this.type = type;
83 }
84
Carmelo Cascone17972822016-05-11 17:48:56 -070085 /**
86 * Returns the integer value associated with this type.
87 *
88 * @return an integer value
89 */
90 public int toInt() {
91 return this.type;
92 }
93
Jonathan Hart26a8d952015-12-02 15:16:35 -080094 @Override
95 public int hashCode() {
96 return Objects.hash(type);
97 }
98
99 @Override
100 public boolean equals(Object obj) {
101 if (this == obj) {
102 return true;
103 }
104 if (obj instanceof ExtensionSelectorType) {
105 final ExtensionSelectorType that = (ExtensionSelectorType) obj;
106 return this.type == that.type;
107 }
108 return false;
109 }
110
111 @Override
112 public String toString() {
113 return MoreObjects.toStringHelper(ExtensionSelectorType.class)
114 .add("type", type)
115 .toString();
116 }
117}