blob: a8aba57252f3257cfa5b2b5a9d793b3220bb46a6 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
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
Jonathan Hartc7840bd2016-01-21 23:26:29 -080024 static final String SEPARATOR = ":";
25
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
Jonathan Hart26a8d952015-12-02 15:16:35 -0800220 /** Extension criterion. */
221 EXTENSION,
222
Jian Li79bdf3c2015-11-30 14:54:54 -0800223 /** An empty criterion. */
alshabiba3a476d2015-04-10 14:35:38 -0700224 DUMMY
tom8bb16062014-09-12 14:47:46 -0700225 }
226
alshabib7b795492014-09-16 14:38:39 -0700227 /**
228 * Returns the type of criterion.
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800229 *
alshabib7b795492014-09-16 14:38:39 -0700230 * @return type of criterion
231 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700232 Type type();
alshabib7b795492014-09-16 14:38:39 -0700233
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800234 /**
235 * Bit definitions for IPv6 Extension Header pseudo-field.
236 * From page 79 of OpenFlow 1.5.0 spec.
237 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700238 enum IPv6ExthdrFlags {
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800239 /** "No next header" encountered. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800240 NONEXT((short) (1 << 0)),
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800241 /** Encrypted Sec Payload header present. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800242 ESP((short) (1 << 1)),
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800243 /** Authentication header present. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800244 AUTH((short) (1 << 2)),
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800245 /** 1 or 2 dest headers present. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800246 DEST((short) (1 << 3)),
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800247 /** Fragment header present. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800248 FRAG((short) (1 << 4)),
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800249 /** Router header present. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800250 ROUTER((short) (1 << 5)),
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800251 /** Hop-by-hop header present. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800252 HOP((short) (1 << 6)),
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800253 /** Unexpected repeats encountered. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800254 UNREP((short) (1 << 7)),
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800255 /** Unexpected sequencing encountered. */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800256 UNSEQ((short) (1 << 8));
tom8bb16062014-09-12 14:47:46 -0700257
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800258 private short value;
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800259
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800260 IPv6ExthdrFlags(short value) {
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800261 this.value = value;
262 }
263
264 /**
265 * Gets the value as an integer.
266 *
267 * @return the value as an integer
268 */
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800269 public short getValue() {
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800270 return this.value;
271 }
272 }
Jian Li79bdf3c2015-11-30 14:54:54 -0800273
Jonathan Hart51539b82015-10-29 09:53:04 -0700274 enum TcpFlags {
Jian Li79bdf3c2015-11-30 14:54:54 -0800275
276 /** ECN-nonce concealment protection. */
277 NS((short) (1 << 0)),
278 /** Congestion Window Reduced. */
279 CWR((short) (1 << 1)),
280 /** ECN-Echo. **/
281 ECE((short) (1 << 2)),
282 /** Urgent pointer field is significant. */
283 URG((short) (1 << 3)),
284 /** Acknowledgment field is significant. */
285 ACK((short) (1 << 4)),
286 /** Push the buffered data to the receiving application. */
287 PSH((short) (1 << 5)),
288 /** Reset the connection. */
289 RST((short) (1 << 6)),
290 /** Synchronize sequence numbers. */
291 SYN((short) (1 << 7)),
292 /** No more data from sender. */
293 FIN((short) (1 << 8));
294
295 private short value;
296
Jonathan Hart51539b82015-10-29 09:53:04 -0700297 TcpFlags(short value) {
Jian Li79bdf3c2015-11-30 14:54:54 -0800298 this.value = value;
299 }
300
301 /**
302 * Gets the value as an integer.
303 *
304 * @return the value as an integer
305 */
306 public short getValue() {
307 return this.value;
308 }
309 }
tom8bb16062014-09-12 14:47:46 -0700310}