blob: e21c84450978e7a94c2a6ca44cc10c5dbc87ad65 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
Thomas Vachuska83e090e2014-10-22 14:25:35 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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
Thomas Vachuska83e090e2014-10-22 14:25:35 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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.
Thomas Vachuska83e090e2014-10-22 14:25:35 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.flow.criteria;
tom8bb16062014-09-12 14:47:46 -070017
alshabib7b795492014-09-16 14:38:39 -070018
tom8bb16062014-09-12 14:47:46 -070019/**
20 * Representation of a single header field selection.
21 */
22public interface Criterion {
23
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040024 String SEPARATOR = ":";
Jonathan Hartc7840bd2016-01-21 23:26:29 -080025
tom8bb16062014-09-12 14:47:46 -070026 /**
27 * Types of fields to which the selection criterion may apply.
28 */
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080029 // From page 75 of OpenFlow 1.5.0 spec
Sho SHIMIZU3310a342015-05-13 12:14:05 -070030 enum Type {
tom8bb16062014-09-12 14:47:46 -070031 /** Switch input port. */
32 IN_PORT,
Jian Li79bdf3c2015-11-30 14:54:54 -080033
tom8bb16062014-09-12 14:47:46 -070034 /** Switch physical input port. */
35 IN_PHY_PORT,
Jian Li79bdf3c2015-11-30 14:54:54 -080036
tom8bb16062014-09-12 14:47:46 -070037 /** Metadata passed between tables. */
38 METADATA,
Jian Li79bdf3c2015-11-30 14:54:54 -080039
tom8bb16062014-09-12 14:47:46 -070040 /** Ethernet destination address. */
41 ETH_DST,
Jian Li79bdf3c2015-11-30 14:54:54 -080042
Saurav Das9d6c86b2016-02-19 09:01:07 -080043 /** Ethernet destination address with masking. */
44 ETH_DST_MASKED,
45
tom8bb16062014-09-12 14:47:46 -070046 /** Ethernet source address. */
47 ETH_SRC,
Jian Li79bdf3c2015-11-30 14:54:54 -080048
Saurav Das9d6c86b2016-02-19 09:01:07 -080049 /** Ethernet source address with masking. */
50 ETH_SRC_MASKED,
51
tom8bb16062014-09-12 14:47:46 -070052 /** Ethernet frame type. */
53 ETH_TYPE,
Jian Li79bdf3c2015-11-30 14:54:54 -080054
tom8bb16062014-09-12 14:47:46 -070055 /** VLAN id. */
56 VLAN_VID,
Jian Li79bdf3c2015-11-30 14:54:54 -080057
tom8bb16062014-09-12 14:47:46 -070058 /** VLAN priority. */
59 VLAN_PCP,
Jian Li79bdf3c2015-11-30 14:54:54 -080060
alshabibfa0dc662016-01-13 11:23:53 -080061 /**
62 * Inner VLAN id.
63 *
64 * Note: Some drivers may not support this.
65 */
66 INNER_VLAN_VID,
67
68 /**
69 * Inner VLAN pcp.
70 *
71 * Note: Some drivers may not support this.
72 */
73 INNER_VLAN_PCP,
74
tom8bb16062014-09-12 14:47:46 -070075 /** IP DSCP (6 bits in ToS field). */
76 IP_DSCP,
Jian Li79bdf3c2015-11-30 14:54:54 -080077
tom8bb16062014-09-12 14:47:46 -070078 /** IP ECN (2 bits in ToS field). */
79 IP_ECN,
Jian Li79bdf3c2015-11-30 14:54:54 -080080
tom8bb16062014-09-12 14:47:46 -070081 /** IP protocol. */
82 IP_PROTO,
Jian Li79bdf3c2015-11-30 14:54:54 -080083
tom8bb16062014-09-12 14:47:46 -070084 /** IPv4 source address. */
85 IPV4_SRC,
Jian Li79bdf3c2015-11-30 14:54:54 -080086
tom8bb16062014-09-12 14:47:46 -070087 /** IPv4 destination address. */
88 IPV4_DST,
Jian Li79bdf3c2015-11-30 14:54:54 -080089
tom8bb16062014-09-12 14:47:46 -070090 /** TCP source port. */
91 TCP_SRC,
Jian Li79bdf3c2015-11-30 14:54:54 -080092
Andreas Gilbert75b882f72017-02-03 09:58:07 +010093 /** TCP source port with masking. */
94 TCP_SRC_MASKED,
95
tom8bb16062014-09-12 14:47:46 -070096 /** TCP destination port. */
97 TCP_DST,
Jian Li79bdf3c2015-11-30 14:54:54 -080098
Andreas Gilbert75b882f72017-02-03 09:58:07 +010099 /** TCP destination port with masking. */
100 TCP_DST_MASKED,
101
tom8bb16062014-09-12 14:47:46 -0700102 /** UDP source port. */
103 UDP_SRC,
Jian Li79bdf3c2015-11-30 14:54:54 -0800104
Andreas Gilbert75b882f72017-02-03 09:58:07 +0100105 /** UDP source port with masking. */
106 UDP_SRC_MASKED,
107
tom8bb16062014-09-12 14:47:46 -0700108 /** UDP destination port. */
109 UDP_DST,
Jian Li79bdf3c2015-11-30 14:54:54 -0800110
Andreas Gilbert75b882f72017-02-03 09:58:07 +0100111 /** UDP destination port with masking. */
112 UDP_DST_MASKED,
113
tom8bb16062014-09-12 14:47:46 -0700114 /** SCTP source port. */
115 SCTP_SRC,
Jian Li79bdf3c2015-11-30 14:54:54 -0800116
Andreas Gilbert75b882f72017-02-03 09:58:07 +0100117 /** SCTP source port with masking. */
118 SCTP_SRC_MASKED,
119
tom8bb16062014-09-12 14:47:46 -0700120 /** SCTP destination port. */
121 SCTP_DST,
Jian Li79bdf3c2015-11-30 14:54:54 -0800122
Andreas Gilbert75b882f72017-02-03 09:58:07 +0100123 /** SCTP destination port with masking. */
124 SCTP_DST_MASKED,
125
tom8bb16062014-09-12 14:47:46 -0700126 /** ICMP type. */
127 ICMPV4_TYPE,
Jian Li79bdf3c2015-11-30 14:54:54 -0800128
tom8bb16062014-09-12 14:47:46 -0700129 /** ICMP code. */
130 ICMPV4_CODE,
Jian Li79bdf3c2015-11-30 14:54:54 -0800131
tom8bb16062014-09-12 14:47:46 -0700132 /** ARP opcode. */
133 ARP_OP,
Jian Li79bdf3c2015-11-30 14:54:54 -0800134
tom8bb16062014-09-12 14:47:46 -0700135 /** ARP source IPv4 address. */
136 ARP_SPA,
Jian Li79bdf3c2015-11-30 14:54:54 -0800137
tom8bb16062014-09-12 14:47:46 -0700138 /** ARP target IPv4 address. */
139 ARP_TPA,
Jian Li79bdf3c2015-11-30 14:54:54 -0800140
tom8bb16062014-09-12 14:47:46 -0700141 /** ARP source hardware address. */
142 ARP_SHA,
Jian Li79bdf3c2015-11-30 14:54:54 -0800143
tom8bb16062014-09-12 14:47:46 -0700144 /** ARP target hardware address. */
145 ARP_THA,
Jian Li79bdf3c2015-11-30 14:54:54 -0800146
tom8bb16062014-09-12 14:47:46 -0700147 /** IPv6 source address. */
148 IPV6_SRC,
Jian Li79bdf3c2015-11-30 14:54:54 -0800149
tom8bb16062014-09-12 14:47:46 -0700150 /** IPv6 destination address. */
151 IPV6_DST,
Jian Li79bdf3c2015-11-30 14:54:54 -0800152
tom8bb16062014-09-12 14:47:46 -0700153 /** IPv6 Flow Label. */
154 IPV6_FLABEL,
Jian Li79bdf3c2015-11-30 14:54:54 -0800155
tom8bb16062014-09-12 14:47:46 -0700156 /** ICMPv6 type. */
157 ICMPV6_TYPE,
Jian Li79bdf3c2015-11-30 14:54:54 -0800158
tom8bb16062014-09-12 14:47:46 -0700159 /** ICMPv6 code. */
160 ICMPV6_CODE,
Jian Li79bdf3c2015-11-30 14:54:54 -0800161
tom8bb16062014-09-12 14:47:46 -0700162 /** Target address for ND. */
163 IPV6_ND_TARGET,
Jian Li79bdf3c2015-11-30 14:54:54 -0800164
tom8bb16062014-09-12 14:47:46 -0700165 /** Source link-layer for ND. */
166 IPV6_ND_SLL,
Jian Li79bdf3c2015-11-30 14:54:54 -0800167
tom8bb16062014-09-12 14:47:46 -0700168 /** Target link-layer for ND. */
169 IPV6_ND_TLL,
Jian Li79bdf3c2015-11-30 14:54:54 -0800170
tom8bb16062014-09-12 14:47:46 -0700171 /** MPLS label. */
172 MPLS_LABEL,
Jian Li79bdf3c2015-11-30 14:54:54 -0800173
tom8bb16062014-09-12 14:47:46 -0700174 /** MPLS TC. */
175 MPLS_TC,
Jian Li79bdf3c2015-11-30 14:54:54 -0800176
177 /** MPLS BoS bit. */
tom8bb16062014-09-12 14:47:46 -0700178 MPLS_BOS,
Jian Li79bdf3c2015-11-30 14:54:54 -0800179
tom8bb16062014-09-12 14:47:46 -0700180 /** PBB I-SID. */
181 PBB_ISID,
Jian Li79bdf3c2015-11-30 14:54:54 -0800182
tom8bb16062014-09-12 14:47:46 -0700183 /** Logical Port Metadata. */
184 TUNNEL_ID,
Jian Li79bdf3c2015-11-30 14:54:54 -0800185
tom8bb16062014-09-12 14:47:46 -0700186 /** IPv6 Extension Header pseudo-field. */
Marc De Leenheer49087752014-10-23 13:54:09 -0700187 IPV6_EXTHDR,
Jian Li79bdf3c2015-11-30 14:54:54 -0800188
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800189 /** Unassigned value: 40. */
190 UNASSIGNED_40,
Jian Li79bdf3c2015-11-30 14:54:54 -0800191
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800192 /** PBB UCA header field. */
193 PBB_UCA,
Jian Li79bdf3c2015-11-30 14:54:54 -0800194
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800195 /** TCP flags. */
196 TCP_FLAGS,
Jian Li79bdf3c2015-11-30 14:54:54 -0800197
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800198 /** Output port from action set metadata. */
199 ACTSET_OUTPUT,
Jian Li79bdf3c2015-11-30 14:54:54 -0800200
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800201 /** Packet type value. */
202 PACKET_TYPE,
203
204 //
205 // NOTE: Everything below is defined elsewhere: ONOS-specific,
206 // extensions, etc.
207 //
Marc De Leenheer49087752014-10-23 13:54:09 -0700208 /** Optical channel signal ID (lambda). */
209 OCH_SIGID,
Jian Li79bdf3c2015-11-30 14:54:54 -0800210
Marc De Leenheer49087752014-10-23 13:54:09 -0700211 /** Optical channel signal type (fixed or flexible). */
alshabiba3a476d2015-04-10 14:35:38 -0700212 OCH_SIGTYPE,
Jian Li79bdf3c2015-11-30 14:54:54 -0800213
Yafit Hadar52d81552015-10-07 12:26:52 +0300214 /** ODU (Optical channel Data Unit) signal ID. */
215 ODU_SIGID,
Jian Li79bdf3c2015-11-30 14:54:54 -0800216
Yafit Hadar52d81552015-10-07 12:26:52 +0300217 /** ODU (Optical channel Data Unit) signal type. */
218 ODU_SIGTYPE,
alshabiba3a476d2015-04-10 14:35:38 -0700219
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400220 /** Protocol-independent. */
221 PROTOCOL_INDEPENDENT,
222
Jonathan Hart26a8d952015-12-02 15:16:35 -0800223 /** Extension criterion. */
224 EXTENSION,
225
Jian Li79bdf3c2015-11-30 14:54:54 -0800226 /** An empty criterion. */
alshabiba3a476d2015-04-10 14:35:38 -0700227 DUMMY
tom8bb16062014-09-12 14:47:46 -0700228 }
229
alshabib7b795492014-09-16 14:38:39 -0700230 /**
231 * Returns the type of criterion.
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800232 *
alshabib7b795492014-09-16 14:38:39 -0700233 * @return type of criterion
234 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700235 Type type();
alshabib7b795492014-09-16 14:38:39 -0700236
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800237 /**
238 * Bit definitions for IPv6 Extension Header pseudo-field.
239 * From page 79 of OpenFlow 1.5.0 spec.
240 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700241 enum IPv6ExthdrFlags {
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800242 /** "No next header" encountered. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800243 NONEXT((short) (1 << 0)),
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800244 /** Encrypted Sec Payload header present. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800245 ESP((short) (1 << 1)),
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800246 /** Authentication header present. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800247 AUTH((short) (1 << 2)),
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800248 /** 1 or 2 dest headers present. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800249 DEST((short) (1 << 3)),
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800250 /** Fragment header present. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800251 FRAG((short) (1 << 4)),
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800252 /** Router header present. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800253 ROUTER((short) (1 << 5)),
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800254 /** Hop-by-hop header present. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800255 HOP((short) (1 << 6)),
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800256 /** Unexpected repeats encountered. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800257 UNREP((short) (1 << 7)),
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800258 /** Unexpected sequencing encountered. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800259 UNSEQ((short) (1 << 8));
tom8bb16062014-09-12 14:47:46 -0700260
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800261 private short value;
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800262
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800263 IPv6ExthdrFlags(short value) {
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800264 this.value = value;
265 }
266
267 /**
268 * Gets the value as an integer.
269 *
270 * @return the value as an integer
271 */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800272 public short getValue() {
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800273 return this.value;
274 }
275 }
Jian Li79bdf3c2015-11-30 14:54:54 -0800276
Jonathan Hart51539b82015-10-29 09:53:04 -0700277 enum TcpFlags {
Jian Li79bdf3c2015-11-30 14:54:54 -0800278
279 /** ECN-nonce concealment protection. */
280 NS((short) (1 << 0)),
281 /** Congestion Window Reduced. */
282 CWR((short) (1 << 1)),
283 /** ECN-Echo. **/
284 ECE((short) (1 << 2)),
285 /** Urgent pointer field is significant. */
286 URG((short) (1 << 3)),
287 /** Acknowledgment field is significant. */
288 ACK((short) (1 << 4)),
289 /** Push the buffered data to the receiving application. */
290 PSH((short) (1 << 5)),
291 /** Reset the connection. */
292 RST((short) (1 << 6)),
293 /** Synchronize sequence numbers. */
294 SYN((short) (1 << 7)),
295 /** No more data from sender. */
296 FIN((short) (1 << 8));
297
298 private short value;
299
Jonathan Hart51539b82015-10-29 09:53:04 -0700300 TcpFlags(short value) {
Jian Li79bdf3c2015-11-30 14:54:54 -0800301 this.value = value;
302 }
303
304 /**
305 * Gets the value as an integer.
306 *
307 * @return the value as an integer
308 */
309 public short getValue() {
310 return this.value;
311 }
312 }
tom8bb16062014-09-12 14:47:46 -0700313}