blob: e3068719f2b8116fb927c3da89ec0d9dbd4a5820 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 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
alshabibcaf1ca22015-06-25 15:18:16 -070018import org.onlab.packet.EthType;
lishuaia72d44d2015-10-19 17:27:38 +080019import org.onlab.packet.Ip4Address;
Hyunsun Mooncf732fb2015-08-22 21:04:23 -070020import org.onlab.packet.Ip6Address;
21import org.onlab.packet.IpPrefix;
22import org.onlab.packet.MacAddress;
23import org.onlab.packet.MplsLabel;
24import org.onlab.packet.TpPort;
25import org.onlab.packet.VlanId;
Jonathan Hart26a8d952015-12-02 15:16:35 -080026import org.onosproject.net.DeviceId;
Sho SHIMIZUefc2e282015-05-04 15:26:23 -070027import org.onosproject.net.IndexedLambda;
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -070028import org.onosproject.net.Lambda;
29import org.onosproject.net.OchSignal;
lishuaia72d44d2015-10-19 17:27:38 +080030import org.onosproject.net.OchSignalType;
Yafit Hadar52d81552015-10-07 12:26:52 +030031import org.onosproject.net.OduSignalId;
32import org.onosproject.net.OduSignalType;
Brian O'Connorabafb502014-12-02 22:26:20 -080033import org.onosproject.net.PortNumber;
34import org.onosproject.net.flow.criteria.Criterion.Type;
alshabib7b795492014-09-16 14:38:39 -070035
tom8bb16062014-09-12 14:47:46 -070036/**
37 * Factory class to create various traffic selection criteria.
38 */
39public final class Criteria {
40
alshabib7b795492014-09-16 14:38:39 -070041 //TODO: incomplete type implementation. Need to implement complete list from Criterion
42
tom8bb16062014-09-12 14:47:46 -070043 // Ban construction
44 private Criteria() {
45 }
46
47 /**
alshabib7b795492014-09-16 14:38:39 -070048 * Creates a match on IN_PORT field using the specified value.
49 *
50 * @param port inport value
51 * @return match criterion
52 */
53 public static Criterion matchInPort(PortNumber port) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080054 return new PortCriterion(port, Type.IN_PORT);
55 }
56
57 /**
58 * Creates a match on IN_PHY_PORT field using the specified value.
59 *
60 * @param port inport value
61 * @return match criterion
62 */
63 public static Criterion matchInPhyPort(PortNumber port) {
64 return new PortCriterion(port, Type.IN_PHY_PORT);
65 }
66
67 /**
68 * Creates a match on METADATA field using the specified value.
69 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -080070 * @param metadata metadata value (64 bits data)
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080071 * @return match criterion
72 */
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -080073 public static Criterion matchMetadata(long metadata) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080074 return new MetadataCriterion(metadata);
alshabib7b795492014-09-16 14:38:39 -070075 }
76
77 /**
alshabib369d2942014-09-12 17:59:35 -070078 * Creates a match on ETH_DST field using the specified value. This value
79 * may be a wildcard mask.
80 *
tomc104d282014-09-19 10:57:55 -070081 * @param mac MAC address value or wildcard mask
alshabib369d2942014-09-12 17:59:35 -070082 * @return match criterion
83 */
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070084 public static Criterion matchEthDst(MacAddress mac) {
alshabib7b795492014-09-16 14:38:39 -070085 return new EthCriterion(mac, Type.ETH_DST);
86 }
87
88 /**
Saurav Das9d6c86b2016-02-19 09:01:07 -080089 * Creates a masked match on ETH_DST field using the specified value and mask.
90 *
91 * @param mac MAC address value
92 * @param mask MAC address masking
93 * @return match criterion
94 */
95 public static Criterion matchEthDstMasked(MacAddress mac, MacAddress mask) {
96 return new EthCriterion(mac, mask, Type.ETH_DST_MASKED);
97 }
98
99 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800100 * Creates a match on ETH_SRC field using the specified value. This value
101 * may be a wildcard mask.
102 *
103 * @param mac MAC address value or wildcard mask
104 * @return match criterion
105 */
106 public static Criterion matchEthSrc(MacAddress mac) {
107 return new EthCriterion(mac, Type.ETH_SRC);
108 }
109
110 /**
Saurav Das9d6c86b2016-02-19 09:01:07 -0800111 * Creates a masked match on ETH_SRC field using the specified value and mask.
112 *
113 * @param mac MAC address value
114 * @param mask MAC address masking
115 * @return match criterion
116 */
117 public static Criterion matchEthSrcMasked(MacAddress mac, MacAddress mask) {
118 return new EthCriterion(mac, mask, Type.ETH_SRC_MASKED);
119 }
120
121 /**
alshabib7b795492014-09-16 14:38:39 -0700122 * Creates a match on ETH_TYPE field using the specified value.
123 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800124 * @param ethType eth type value (16 bits unsigned integer)
alshabib7b795492014-09-16 14:38:39 -0700125 * @return match criterion
126 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800127 public static Criterion matchEthType(int ethType) {
alshabib7b795492014-09-16 14:38:39 -0700128 return new EthTypeCriterion(ethType);
129 }
130
131 /**
alshabibcaf1ca22015-06-25 15:18:16 -0700132 * Creates a match on ETH_TYPE field using the specified value.
133 *
134 * @param ethType eth type value
135 * @return match criterion
136 */
137 public static Criterion matchEthType(EthType ethType) {
138 return new EthTypeCriterion(ethType);
139 }
140
141 /**
alshabib7b795492014-09-16 14:38:39 -0700142 * Creates a match on VLAN ID field using the specified value.
143 *
144 * @param vlanId vlan id value
145 * @return match criterion
146 */
Ayaka Koshibea9c199f2014-09-16 16:21:40 -0700147 public static Criterion matchVlanId(VlanId vlanId) {
alshabib7b795492014-09-16 14:38:39 -0700148 return new VlanIdCriterion(vlanId);
149 }
150
151 /**
alshabibfa0dc662016-01-13 11:23:53 -0800152 * Creates a match on the inner VLAN ID field using the specified value.
153 *
154 * @param vlanId vlan id value
155 * @return match criterion
156 */
157 public static Criterion matchInnerVlanId(VlanId vlanId) {
158 return new VlanIdCriterion(vlanId, Type.INNER_VLAN_VID);
159 }
160
161 /**
alshabib7b795492014-09-16 14:38:39 -0700162 * Creates a match on VLAN PCP field using the specified value.
163 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800164 * @param vlanPcp vlan pcp value (3 bits)
alshabib7b795492014-09-16 14:38:39 -0700165 * @return match criterion
166 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800167 public static Criterion matchVlanPcp(byte vlanPcp) {
alshabib7b795492014-09-16 14:38:39 -0700168 return new VlanPcpCriterion(vlanPcp);
169 }
170
171 /**
alshabibfa0dc662016-01-13 11:23:53 -0800172 * Creates a match on the inner VLAN PCP field using the specified value.
173 *
174 * @param vlanPcp vlan pcp value (3 bits)
175 * @return match criterion
176 */
177 public static Criterion matchInnerVlanPcp(byte vlanPcp) {
178 return new VlanPcpCriterion(vlanPcp, Type.INNER_VLAN_PCP);
179 }
180
181 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800182 * Creates a match on IP DSCP field using the specified value.
183 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800184 * @param ipDscp ip dscp value (6 bits)
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800185 * @return match criterion
186 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800187 public static Criterion matchIPDscp(byte ipDscp) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800188 return new IPDscpCriterion(ipDscp);
189 }
190
191 /**
192 * Creates a match on IP ECN field using the specified value.
193 *
Pavlin Radoslavovab8553a2015-02-20 14:13:50 -0800194 * @param ipEcn ip ecn value (2 bits)
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800195 * @return match criterion
196 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800197 public static Criterion matchIPEcn(byte ipEcn) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800198 return new IPEcnCriterion(ipEcn);
199 }
200
201 /**
alshabib7b795492014-09-16 14:38:39 -0700202 * Creates a match on IP proto field using the specified value.
203 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800204 * @param proto ip protocol value (8 bits unsigned integer)
alshabib7b795492014-09-16 14:38:39 -0700205 * @return match criterion
206 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800207 public static Criterion matchIPProtocol(short proto) {
alshabib7b795492014-09-16 14:38:39 -0700208 return new IPProtocolCriterion(proto);
209 }
210
211 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800212 * Creates a match on IPv4 source field using the specified value.
alshabib7b795492014-09-16 14:38:39 -0700213 *
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800214 * @param ip ipv4 source value
alshabib7b795492014-09-16 14:38:39 -0700215 * @return match criterion
216 */
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700217 public static Criterion matchIPSrc(IpPrefix ip) {
alshabib7b795492014-09-16 14:38:39 -0700218 return new IPCriterion(ip, Type.IPV4_SRC);
219 }
220
221 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800222 * Creates a match on IPv4 destination field using the specified value.
alshabib7b795492014-09-16 14:38:39 -0700223 *
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800224 * @param ip ipv4 source value
alshabib7b795492014-09-16 14:38:39 -0700225 * @return match criterion
226 */
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700227 public static Criterion matchIPDst(IpPrefix ip) {
alshabib7b795492014-09-16 14:38:39 -0700228 return new IPCriterion(ip, Type.IPV4_DST);
alshabib369d2942014-09-12 17:59:35 -0700229 }
230
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700231 /**
232 * Creates a match on TCP source port field using the specified value.
233 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700234 * @param tcpPort TCP source port
235 * @return match criterion
236 * @deprecated in Drake release
237 */
238 @Deprecated
239 public static Criterion matchTcpSrc(short tcpPort) {
240 return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_SRC);
241 }
242
243 /**
244 * Creates a match on TCP source port field using the specified value.
245 *
246 * @param tcpPort TCP source port
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700247 * @return match criterion
248 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700249 public static Criterion matchTcpSrc(TpPort tcpPort) {
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700250 return new TcpPortCriterion(tcpPort, Type.TCP_SRC);
251 }
252
253 /**
254 * Creates a match on TCP destination port field using the specified value.
255 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700256 * @param tcpPort TCP destination port
257 * @return match criterion
258 * @deprecated in Drake release
259 */
260 @Deprecated
261 public static Criterion matchTcpDst(short tcpPort) {
262 return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_DST);
263 }
264
265 /**
266 * Creates a match on TCP destination port field using the specified value.
267 *
268 * @param tcpPort TCP destination port
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700269 * @return match criterion
270 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700271 public static Criterion matchTcpDst(TpPort tcpPort) {
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700272 return new TcpPortCriterion(tcpPort, Type.TCP_DST);
273 }
alshabib369d2942014-09-12 17:59:35 -0700274
Marc De Leenheer49087752014-10-23 13:54:09 -0700275 /**
Jian Li2748b2c2015-11-30 11:43:09 -0800276 * Creates a match on TCP flags using the specified value.
277 *
278 * @param flags TCP flags
279 * @return match criterion
280 */
281 public static Criterion matchTcpFlags(int flags) {
282 return new TcpFlagsCriterion(flags);
283 }
284
285 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800286 * Creates a match on UDP source port field using the specified value.
287 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700288 * @param udpPort UDP source port
289 * @return match criterion
290 * @deprecated in Drake release
291 */
292 @Deprecated
293 public static Criterion matchUdpSrc(short udpPort) {
294 return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_SRC);
295 }
296
297 /**
298 * Creates a match on UDP source port field using the specified value.
299 *
300 * @param udpPort UDP source port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800301 * @return match criterion
302 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700303 public static Criterion matchUdpSrc(TpPort udpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800304 return new UdpPortCriterion(udpPort, Type.UDP_SRC);
305 }
306
307 /**
308 * Creates a match on UDP destination port field using the specified value.
309 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700310 * @param udpPort UDP destination port
311 * @return match criterion
312 * @deprecated in Drake release
313 */
314 @Deprecated
315 public static Criterion matchUdpDst(short udpPort) {
316 return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_DST);
317 }
318
319 /**
320 * Creates a match on UDP destination port field using the specified value.
321 *
322 * @param udpPort UDP destination port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800323 * @return match criterion
324 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700325 public static Criterion matchUdpDst(TpPort udpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800326 return new UdpPortCriterion(udpPort, Type.UDP_DST);
327 }
328
329 /**
330 * Creates a match on SCTP source port field using the specified value.
331 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700332 * @param sctpPort SCTP source port
333 * @return match criterion
334 * @deprecated in Drake release
335 */
336 @Deprecated
337 public static Criterion matchSctpSrc(short sctpPort) {
338 return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_SRC);
339 }
340
341 /**
342 * Creates a match on SCTP source port field using the specified value.
343 *
344 * @param sctpPort SCTP source port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800345 * @return match criterion
346 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700347 public static Criterion matchSctpSrc(TpPort sctpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800348 return new SctpPortCriterion(sctpPort, Type.SCTP_SRC);
349 }
350
351 /**
352 * Creates a match on SCTP destination port field using the specified
353 * value.
354 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700355 * @param sctpPort SCTP destination port
356 * @return match criterion
357 * @deprecated in Drake release
358 */
359 @Deprecated
360 public static Criterion matchSctpDst(short sctpPort) {
361 return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_DST);
362 }
363
364 /**
365 * Creates a match on SCTP destination port field using the specified
366 * value.
367 *
368 * @param sctpPort SCTP destination port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800369 * @return match criterion
370 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700371 public static Criterion matchSctpDst(TpPort sctpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800372 return new SctpPortCriterion(sctpPort, Type.SCTP_DST);
373 }
374
375 /**
376 * Creates a match on ICMP type field using the specified value.
377 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800378 * @param icmpType ICMP type (8 bits unsigned integer)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800379 * @return match criterion
380 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800381 public static Criterion matchIcmpType(short icmpType) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800382 return new IcmpTypeCriterion(icmpType);
383 }
384
385 /**
386 * Creates a match on ICMP code field using the specified value.
387 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800388 * @param icmpCode ICMP code (8 bits unsigned integer)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800389 * @return match criterion
390 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800391 public static Criterion matchIcmpCode(short icmpCode) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800392 return new IcmpCodeCriterion(icmpCode);
393 }
394
395 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800396 * Creates a match on IPv6 source field using the specified value.
397 *
398 * @param ip ipv6 source value
399 * @return match criterion
400 */
401 public static Criterion matchIPv6Src(IpPrefix ip) {
402 return new IPCriterion(ip, Type.IPV6_SRC);
403 }
404
405 /**
406 * Creates a match on IPv6 destination field using the specified value.
407 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800408 * @param ip ipv6 destination value
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800409 * @return match criterion
410 */
411 public static Criterion matchIPv6Dst(IpPrefix ip) {
412 return new IPCriterion(ip, Type.IPV6_DST);
413 }
414
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800415 /**
416 * Creates a match on IPv6 flow label field using the specified value.
417 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800418 * @param flowLabel IPv6 flow label (20 bits)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800419 * @return match criterion
420 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800421 public static Criterion matchIPv6FlowLabel(int flowLabel) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800422 return new IPv6FlowLabelCriterion(flowLabel);
423 }
424
425 /**
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800426 * Creates a match on ICMPv6 type field using the specified value.
427 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800428 * @param icmpv6Type ICMPv6 type (8 bits unsigned integer)
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800429 * @return match criterion
430 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800431 public static Criterion matchIcmpv6Type(short icmpv6Type) {
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800432 return new Icmpv6TypeCriterion(icmpv6Type);
433 }
434
435 /**
436 * Creates a match on ICMPv6 code field using the specified value.
437 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800438 * @param icmpv6Code ICMPv6 code (8 bits unsigned integer)
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800439 * @return match criterion
440 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800441 public static Criterion matchIcmpv6Code(short icmpv6Code) {
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800442 return new Icmpv6CodeCriterion(icmpv6Code);
443 }
444
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800445 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800446 * Creates a match on IPv6 Neighbor Discovery target address using the
447 * specified value.
448 *
449 * @param targetAddress IPv6 Neighbor Discovery target address
450 * @return match criterion
451 */
452 public static Criterion matchIPv6NDTargetAddress(Ip6Address targetAddress) {
453 return new IPv6NDTargetAddressCriterion(targetAddress);
454 }
455
456 /**
457 * Creates a match on IPv6 Neighbor Discovery source link-layer address
458 * using the specified value.
459 *
460 * @param mac IPv6 Neighbor Discovery source link-layer address
461 * @return match criterion
462 */
463 public static Criterion matchIPv6NDSourceLinkLayerAddress(MacAddress mac) {
464 return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_SLL);
465 }
466
467 /**
468 * Creates a match on IPv6 Neighbor Discovery target link-layer address
469 * using the specified value.
470 *
471 * @param mac IPv6 Neighbor Discovery target link-layer address
472 * @return match criterion
473 */
474 public static Criterion matchIPv6NDTargetLinkLayerAddress(MacAddress mac) {
475 return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_TLL);
476 }
477
478 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800479 * Creates a match on MPLS label.
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800480 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800481 * @param mplsLabel MPLS label (20 bits)
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800482 * @return match criterion
483 */
Michele Santuari4b6019e2014-12-19 11:31:45 +0100484 public static Criterion matchMplsLabel(MplsLabel mplsLabel) {
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800485 return new MplsCriterion(mplsLabel);
486 }
487
488 /**
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700489 * Creates a match on MPLS Bottom-of-Stack indicator bit.
490 *
491 * @param mplsBos boolean value indicating true (BOS=1) or false (BOS=0)
492 * @return match criterion
493 */
Jian Li5c4cf1e2015-11-30 13:10:46 -0800494 public static Criterion matchMplsBos(boolean mplsBos) {
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700495 return new MplsBosCriterion(mplsBos);
496 }
497
498 /**
Jian Lifd44dc92015-11-26 16:32:32 -0800499 * Creates a match on MPLS TC.
500 *
501 * @param mplsTc MPLS TC (3 bits)
502 * @return match criterion
503 */
504 public static Criterion matchMplsTc(byte mplsTc) {
505 return new MplsTcCriterion(mplsTc);
506 }
507
508 /**
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700509 * Creates a match on Tunnel ID.
510 *
511 * @param tunnelId Tunnel ID (64 bits)
512 * @return match criterion
513 */
514 public static Criterion matchTunnelId(long tunnelId) {
515 return new TunnelIdCriterion(tunnelId);
516 }
517
518 /**
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800519 * Creates a match on IPv6 Extension Header pseudo-field fiags.
520 * Those are defined in Criterion.IPv6ExthdrFlags.
521 *
522 * @param exthdrFlags IPv6 Extension Header pseudo-field flags (16 bits)
523 * @return match criterion
524 */
525 public static Criterion matchIPv6ExthdrFlags(int exthdrFlags) {
526 return new IPv6ExthdrFlagsCriterion(exthdrFlags);
527 }
528
529 /**
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -0700530 * Creates a match on lambda using the specified value.
531 *
532 * @param lambda lambda
533 * @return match criterion
534 */
535 public static Criterion matchLambda(Lambda lambda) {
Sho SHIMIZUefc2e282015-05-04 15:26:23 -0700536 if (lambda instanceof IndexedLambda) {
537 return new IndexedLambdaCriterion((IndexedLambda) lambda);
538 } else if (lambda instanceof OchSignal) {
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -0700539 return new OchSignalCriterion((OchSignal) lambda);
540 } else {
541 throw new UnsupportedOperationException(String.format("Unsupported type of Lambda: %s", lambda));
542 }
543 }
544
545 /**
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -0700546 * Create a match on OCh (Optical Channel) signal type.
547 *
548 * @param signalType OCh signal type
549 * @return match criterion
550 */
551 public static Criterion matchOchSignalType(OchSignalType signalType) {
552 return new OchSignalTypeCriterion(signalType);
553 }
554
Yafit Hadar52d81552015-10-07 12:26:52 +0300555 /**
556 * Creates a match on ODU (Optical channel Data Unit) signal ID using the specified value.
557 *
558 * @param oduSignalId ODU Signal Id
559 * @return match criterion
560 */
561 public static Criterion matchOduSignalId(OduSignalId oduSignalId) {
562 return new OduSignalIdCriterion(oduSignalId);
563 }
564
565 /**
566 * Creates a match on ODU (Optical channel Data Unit) signal Type using the specified value.
567 *
568 * @param signalType ODU Signal Type
569 * @return match criterion
570 */
571 public static Criterion matchOduSignalType(OduSignalType signalType) {
572 return new OduSignalTypeCriterion(signalType);
573 }
574
lishuaia72d44d2015-10-19 17:27:38 +0800575 /**
BitOhenrye330cf02015-11-17 18:59:33 +0800576 * Creates a match on IPv4 destination field using the specified value.
lishuaia72d44d2015-10-19 17:27:38 +0800577 *
BitOhenrye330cf02015-11-17 18:59:33 +0800578 * @param ip ipv4 destination value
lishuaia72d44d2015-10-19 17:27:38 +0800579 * @return match criterion
580 */
581 public static Criterion matchArpTpa(Ip4Address ip) {
582 return new ArpPaCriterion(ip, Type.ARP_TPA);
583 }
584
BitOhenrycc024eb2015-11-10 17:17:36 +0800585 /**
BitOhenry08c72942015-11-18 14:44:29 +0800586 * Creates a match on IPv4 source field using the specified value.
587 *
588 * @param ip ipv4 source value
589 * @return match criterion
590 */
591 public static Criterion matchArpSpa(Ip4Address ip) {
592 return new ArpPaCriterion(ip, Type.ARP_SPA);
593 }
594
595 /**
BitOhenrye330cf02015-11-17 18:59:33 +0800596 * Creates a match on MAC destination field using the specified value.
597 *
598 * @param mac MAC destination value
599 * @return match criterion
600 */
601 public static Criterion matchArpTha(MacAddress mac) {
602 return new ArpHaCriterion(mac, Type.ARP_THA);
603 }
604
605 /**
BitOhenrycc024eb2015-11-10 17:17:36 +0800606 * Creates a match on MAC source field using the specified value.
607 *
608 * @param mac MAC source value
609 * @return match criterion
610 */
BitOhenrye330cf02015-11-17 18:59:33 +0800611 public static Criterion matchArpSha(MacAddress mac) {
612 return new ArpHaCriterion(mac, Type.ARP_SHA);
BitOhenrycc024eb2015-11-10 17:17:36 +0800613 }
614
BitOhenry11620c92015-11-27 08:42:36 +0800615 /**
616 * Creates a match on arp operation type field using the specified value.
617 *
618 * @param arpOp arp operation type value
619 * @return match criterion
620 */
621 public static Criterion matchArpOp(int arpOp) {
622 return new ArpOpCriterion(arpOp, Type.ARP_OP);
623 }
624
Jonathan Hart26a8d952015-12-02 15:16:35 -0800625 /**
Jian Lif1ecf992015-12-02 17:48:54 -0800626 * Creates a match on PBB I-SID field using the specific value.
627 *
628 * @param pbbIsid PBB I-SID
629 * @return match criterion
630 */
631 public static Criterion matchPbbIsid(int pbbIsid) {
632 return new PbbIsidCriterion(pbbIsid);
633 }
634
635 /**
Jonathan Hart26a8d952015-12-02 15:16:35 -0800636 * Creates an extension criterion for the specified extension selector.
637 *
638 * @param extensionSelector extension selector
639 * @param deviceId device ID
Charles Chan14967c22015-12-07 11:11:50 -0800640 * @return match extension criterion
Jonathan Hart26a8d952015-12-02 15:16:35 -0800641 */
Charles Chan14967c22015-12-07 11:11:50 -0800642 public static ExtensionCriterion extension(ExtensionSelector extensionSelector,
Jonathan Hart26a8d952015-12-02 15:16:35 -0800643 DeviceId deviceId) {
644 return new ExtensionCriterion(extensionSelector, deviceId);
645 }
646
647 /**
648 * Creates a dummy criterion.
649 *
650 * @return match criterion
651 */
alshabiba3a476d2015-04-10 14:35:38 -0700652 public static Criterion dummy() {
653 return new DummyCriterion();
654 }
655
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700656 /**
alshabiba3a476d2015-04-10 14:35:38 -0700657 * Dummy Criterion used with @see{FilteringObjective}.
658 */
659 private static class DummyCriterion implements Criterion {
660
661 @Override
662 public Type type() {
663 return Type.DUMMY;
664 }
665 }
tom8bb16062014-09-12 14:47:46 -0700666}