blob: 0c26b89e93c87e5b01ba1a49a1ee015127653c62 [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 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080089 * Creates a match on ETH_SRC field using the specified value. This value
90 * may be a wildcard mask.
91 *
92 * @param mac MAC address value or wildcard mask
93 * @return match criterion
94 */
95 public static Criterion matchEthSrc(MacAddress mac) {
96 return new EthCriterion(mac, Type.ETH_SRC);
97 }
98
99 /**
alshabib7b795492014-09-16 14:38:39 -0700100 * Creates a match on ETH_TYPE field using the specified value.
101 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800102 * @param ethType eth type value (16 bits unsigned integer)
alshabib7b795492014-09-16 14:38:39 -0700103 * @return match criterion
104 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800105 public static Criterion matchEthType(int ethType) {
alshabib7b795492014-09-16 14:38:39 -0700106 return new EthTypeCriterion(ethType);
107 }
108
109 /**
alshabibcaf1ca22015-06-25 15:18:16 -0700110 * Creates a match on ETH_TYPE field using the specified value.
111 *
112 * @param ethType eth type value
113 * @return match criterion
114 */
115 public static Criterion matchEthType(EthType ethType) {
116 return new EthTypeCriterion(ethType);
117 }
118
119 /**
alshabib7b795492014-09-16 14:38:39 -0700120 * Creates a match on VLAN ID field using the specified value.
121 *
122 * @param vlanId vlan id value
123 * @return match criterion
124 */
Ayaka Koshibea9c199f2014-09-16 16:21:40 -0700125 public static Criterion matchVlanId(VlanId vlanId) {
alshabib7b795492014-09-16 14:38:39 -0700126 return new VlanIdCriterion(vlanId);
127 }
128
129 /**
alshabibfa0dc662016-01-13 11:23:53 -0800130 * Creates a match on the inner VLAN ID field using the specified value.
131 *
132 * @param vlanId vlan id value
133 * @return match criterion
134 */
135 public static Criterion matchInnerVlanId(VlanId vlanId) {
136 return new VlanIdCriterion(vlanId, Type.INNER_VLAN_VID);
137 }
138
139 /**
alshabib7b795492014-09-16 14:38:39 -0700140 * Creates a match on VLAN PCP field using the specified value.
141 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800142 * @param vlanPcp vlan pcp value (3 bits)
alshabib7b795492014-09-16 14:38:39 -0700143 * @return match criterion
144 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800145 public static Criterion matchVlanPcp(byte vlanPcp) {
alshabib7b795492014-09-16 14:38:39 -0700146 return new VlanPcpCriterion(vlanPcp);
147 }
148
149 /**
alshabibfa0dc662016-01-13 11:23:53 -0800150 * Creates a match on the inner VLAN PCP field using the specified value.
151 *
152 * @param vlanPcp vlan pcp value (3 bits)
153 * @return match criterion
154 */
155 public static Criterion matchInnerVlanPcp(byte vlanPcp) {
156 return new VlanPcpCriterion(vlanPcp, Type.INNER_VLAN_PCP);
157 }
158
159 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800160 * Creates a match on IP DSCP field using the specified value.
161 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800162 * @param ipDscp ip dscp value (6 bits)
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800163 * @return match criterion
164 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800165 public static Criterion matchIPDscp(byte ipDscp) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800166 return new IPDscpCriterion(ipDscp);
167 }
168
169 /**
170 * Creates a match on IP ECN field using the specified value.
171 *
Pavlin Radoslavovab8553a2015-02-20 14:13:50 -0800172 * @param ipEcn ip ecn value (2 bits)
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800173 * @return match criterion
174 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800175 public static Criterion matchIPEcn(byte ipEcn) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800176 return new IPEcnCriterion(ipEcn);
177 }
178
179 /**
alshabib7b795492014-09-16 14:38:39 -0700180 * Creates a match on IP proto field using the specified value.
181 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800182 * @param proto ip protocol value (8 bits unsigned integer)
alshabib7b795492014-09-16 14:38:39 -0700183 * @return match criterion
184 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800185 public static Criterion matchIPProtocol(short proto) {
alshabib7b795492014-09-16 14:38:39 -0700186 return new IPProtocolCriterion(proto);
187 }
188
189 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800190 * Creates a match on IPv4 source field using the specified value.
alshabib7b795492014-09-16 14:38:39 -0700191 *
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800192 * @param ip ipv4 source value
alshabib7b795492014-09-16 14:38:39 -0700193 * @return match criterion
194 */
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700195 public static Criterion matchIPSrc(IpPrefix ip) {
alshabib7b795492014-09-16 14:38:39 -0700196 return new IPCriterion(ip, Type.IPV4_SRC);
197 }
198
199 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800200 * Creates a match on IPv4 destination field using the specified value.
alshabib7b795492014-09-16 14:38:39 -0700201 *
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800202 * @param ip ipv4 source value
alshabib7b795492014-09-16 14:38:39 -0700203 * @return match criterion
204 */
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700205 public static Criterion matchIPDst(IpPrefix ip) {
alshabib7b795492014-09-16 14:38:39 -0700206 return new IPCriterion(ip, Type.IPV4_DST);
alshabib369d2942014-09-12 17:59:35 -0700207 }
208
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700209 /**
210 * Creates a match on TCP source port field using the specified value.
211 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700212 * @param tcpPort TCP source port
213 * @return match criterion
214 * @deprecated in Drake release
215 */
216 @Deprecated
217 public static Criterion matchTcpSrc(short tcpPort) {
218 return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_SRC);
219 }
220
221 /**
222 * Creates a match on TCP source port field using the specified value.
223 *
224 * @param tcpPort TCP source port
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700225 * @return match criterion
226 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700227 public static Criterion matchTcpSrc(TpPort tcpPort) {
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700228 return new TcpPortCriterion(tcpPort, Type.TCP_SRC);
229 }
230
231 /**
232 * Creates a match on TCP destination port field using the specified value.
233 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700234 * @param tcpPort TCP destination port
235 * @return match criterion
236 * @deprecated in Drake release
237 */
238 @Deprecated
239 public static Criterion matchTcpDst(short tcpPort) {
240 return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_DST);
241 }
242
243 /**
244 * Creates a match on TCP destination port field using the specified value.
245 *
246 * @param tcpPort TCP destination port
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700247 * @return match criterion
248 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700249 public static Criterion matchTcpDst(TpPort tcpPort) {
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700250 return new TcpPortCriterion(tcpPort, Type.TCP_DST);
251 }
alshabib369d2942014-09-12 17:59:35 -0700252
Marc De Leenheer49087752014-10-23 13:54:09 -0700253 /**
Jian Li2748b2c2015-11-30 11:43:09 -0800254 * Creates a match on TCP flags using the specified value.
255 *
256 * @param flags TCP flags
257 * @return match criterion
258 */
259 public static Criterion matchTcpFlags(int flags) {
260 return new TcpFlagsCriterion(flags);
261 }
262
263 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800264 * Creates a match on UDP source port field using the specified value.
265 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700266 * @param udpPort UDP source port
267 * @return match criterion
268 * @deprecated in Drake release
269 */
270 @Deprecated
271 public static Criterion matchUdpSrc(short udpPort) {
272 return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_SRC);
273 }
274
275 /**
276 * Creates a match on UDP source port field using the specified value.
277 *
278 * @param udpPort UDP source port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800279 * @return match criterion
280 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700281 public static Criterion matchUdpSrc(TpPort udpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800282 return new UdpPortCriterion(udpPort, Type.UDP_SRC);
283 }
284
285 /**
286 * Creates a match on UDP destination port field using the specified value.
287 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700288 * @param udpPort UDP destination port
289 * @return match criterion
290 * @deprecated in Drake release
291 */
292 @Deprecated
293 public static Criterion matchUdpDst(short udpPort) {
294 return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_DST);
295 }
296
297 /**
298 * Creates a match on UDP destination port field using the specified value.
299 *
300 * @param udpPort UDP destination port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800301 * @return match criterion
302 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700303 public static Criterion matchUdpDst(TpPort udpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800304 return new UdpPortCriterion(udpPort, Type.UDP_DST);
305 }
306
307 /**
308 * Creates a match on SCTP source port field using the specified value.
309 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700310 * @param sctpPort SCTP source port
311 * @return match criterion
312 * @deprecated in Drake release
313 */
314 @Deprecated
315 public static Criterion matchSctpSrc(short sctpPort) {
316 return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_SRC);
317 }
318
319 /**
320 * Creates a match on SCTP source port field using the specified value.
321 *
322 * @param sctpPort SCTP source port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800323 * @return match criterion
324 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700325 public static Criterion matchSctpSrc(TpPort sctpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800326 return new SctpPortCriterion(sctpPort, Type.SCTP_SRC);
327 }
328
329 /**
330 * Creates a match on SCTP destination port field using the specified
331 * value.
332 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700333 * @param sctpPort SCTP destination port
334 * @return match criterion
335 * @deprecated in Drake release
336 */
337 @Deprecated
338 public static Criterion matchSctpDst(short sctpPort) {
339 return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_DST);
340 }
341
342 /**
343 * Creates a match on SCTP destination port field using the specified
344 * value.
345 *
346 * @param sctpPort SCTP destination port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800347 * @return match criterion
348 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700349 public static Criterion matchSctpDst(TpPort sctpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800350 return new SctpPortCriterion(sctpPort, Type.SCTP_DST);
351 }
352
353 /**
354 * Creates a match on ICMP type field using the specified value.
355 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800356 * @param icmpType ICMP type (8 bits unsigned integer)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800357 * @return match criterion
358 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800359 public static Criterion matchIcmpType(short icmpType) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800360 return new IcmpTypeCriterion(icmpType);
361 }
362
363 /**
364 * Creates a match on ICMP code field using the specified value.
365 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800366 * @param icmpCode ICMP code (8 bits unsigned integer)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800367 * @return match criterion
368 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800369 public static Criterion matchIcmpCode(short icmpCode) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800370 return new IcmpCodeCriterion(icmpCode);
371 }
372
373 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800374 * Creates a match on IPv6 source field using the specified value.
375 *
376 * @param ip ipv6 source value
377 * @return match criterion
378 */
379 public static Criterion matchIPv6Src(IpPrefix ip) {
380 return new IPCriterion(ip, Type.IPV6_SRC);
381 }
382
383 /**
384 * Creates a match on IPv6 destination field using the specified value.
385 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800386 * @param ip ipv6 destination value
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800387 * @return match criterion
388 */
389 public static Criterion matchIPv6Dst(IpPrefix ip) {
390 return new IPCriterion(ip, Type.IPV6_DST);
391 }
392
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800393 /**
394 * Creates a match on IPv6 flow label field using the specified value.
395 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800396 * @param flowLabel IPv6 flow label (20 bits)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800397 * @return match criterion
398 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800399 public static Criterion matchIPv6FlowLabel(int flowLabel) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800400 return new IPv6FlowLabelCriterion(flowLabel);
401 }
402
403 /**
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800404 * Creates a match on ICMPv6 type field using the specified value.
405 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800406 * @param icmpv6Type ICMPv6 type (8 bits unsigned integer)
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800407 * @return match criterion
408 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800409 public static Criterion matchIcmpv6Type(short icmpv6Type) {
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800410 return new Icmpv6TypeCriterion(icmpv6Type);
411 }
412
413 /**
414 * Creates a match on ICMPv6 code field using the specified value.
415 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800416 * @param icmpv6Code ICMPv6 code (8 bits unsigned integer)
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800417 * @return match criterion
418 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800419 public static Criterion matchIcmpv6Code(short icmpv6Code) {
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800420 return new Icmpv6CodeCriterion(icmpv6Code);
421 }
422
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800423 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800424 * Creates a match on IPv6 Neighbor Discovery target address using the
425 * specified value.
426 *
427 * @param targetAddress IPv6 Neighbor Discovery target address
428 * @return match criterion
429 */
430 public static Criterion matchIPv6NDTargetAddress(Ip6Address targetAddress) {
431 return new IPv6NDTargetAddressCriterion(targetAddress);
432 }
433
434 /**
435 * Creates a match on IPv6 Neighbor Discovery source link-layer address
436 * using the specified value.
437 *
438 * @param mac IPv6 Neighbor Discovery source link-layer address
439 * @return match criterion
440 */
441 public static Criterion matchIPv6NDSourceLinkLayerAddress(MacAddress mac) {
442 return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_SLL);
443 }
444
445 /**
446 * Creates a match on IPv6 Neighbor Discovery target link-layer address
447 * using the specified value.
448 *
449 * @param mac IPv6 Neighbor Discovery target link-layer address
450 * @return match criterion
451 */
452 public static Criterion matchIPv6NDTargetLinkLayerAddress(MacAddress mac) {
453 return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_TLL);
454 }
455
456 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800457 * Creates a match on MPLS label.
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800458 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800459 * @param mplsLabel MPLS label (20 bits)
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800460 * @return match criterion
461 */
Michele Santuari4b6019e2014-12-19 11:31:45 +0100462 public static Criterion matchMplsLabel(MplsLabel mplsLabel) {
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800463 return new MplsCriterion(mplsLabel);
464 }
465
466 /**
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700467 * Creates a match on MPLS Bottom-of-Stack indicator bit.
468 *
469 * @param mplsBos boolean value indicating true (BOS=1) or false (BOS=0)
470 * @return match criterion
471 */
Jian Li5c4cf1e2015-11-30 13:10:46 -0800472 public static Criterion matchMplsBos(boolean mplsBos) {
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700473 return new MplsBosCriterion(mplsBos);
474 }
475
476 /**
Jian Lifd44dc92015-11-26 16:32:32 -0800477 * Creates a match on MPLS TC.
478 *
479 * @param mplsTc MPLS TC (3 bits)
480 * @return match criterion
481 */
482 public static Criterion matchMplsTc(byte mplsTc) {
483 return new MplsTcCriterion(mplsTc);
484 }
485
486 /**
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700487 * Creates a match on Tunnel ID.
488 *
489 * @param tunnelId Tunnel ID (64 bits)
490 * @return match criterion
491 */
492 public static Criterion matchTunnelId(long tunnelId) {
493 return new TunnelIdCriterion(tunnelId);
494 }
495
496 /**
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800497 * Creates a match on IPv6 Extension Header pseudo-field fiags.
498 * Those are defined in Criterion.IPv6ExthdrFlags.
499 *
500 * @param exthdrFlags IPv6 Extension Header pseudo-field flags (16 bits)
501 * @return match criterion
502 */
503 public static Criterion matchIPv6ExthdrFlags(int exthdrFlags) {
504 return new IPv6ExthdrFlagsCriterion(exthdrFlags);
505 }
506
507 /**
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -0700508 * Creates a match on lambda using the specified value.
509 *
510 * @param lambda lambda
511 * @return match criterion
512 */
513 public static Criterion matchLambda(Lambda lambda) {
Sho SHIMIZUefc2e282015-05-04 15:26:23 -0700514 if (lambda instanceof IndexedLambda) {
515 return new IndexedLambdaCriterion((IndexedLambda) lambda);
516 } else if (lambda instanceof OchSignal) {
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -0700517 return new OchSignalCriterion((OchSignal) lambda);
518 } else {
519 throw new UnsupportedOperationException(String.format("Unsupported type of Lambda: %s", lambda));
520 }
521 }
522
523 /**
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -0700524 * Create a match on OCh (Optical Channel) signal type.
525 *
526 * @param signalType OCh signal type
527 * @return match criterion
528 */
529 public static Criterion matchOchSignalType(OchSignalType signalType) {
530 return new OchSignalTypeCriterion(signalType);
531 }
532
Yafit Hadar52d81552015-10-07 12:26:52 +0300533 /**
534 * Creates a match on ODU (Optical channel Data Unit) signal ID using the specified value.
535 *
536 * @param oduSignalId ODU Signal Id
537 * @return match criterion
538 */
539 public static Criterion matchOduSignalId(OduSignalId oduSignalId) {
540 return new OduSignalIdCriterion(oduSignalId);
541 }
542
543 /**
544 * Creates a match on ODU (Optical channel Data Unit) signal Type using the specified value.
545 *
546 * @param signalType ODU Signal Type
547 * @return match criterion
548 */
549 public static Criterion matchOduSignalType(OduSignalType signalType) {
550 return new OduSignalTypeCriterion(signalType);
551 }
552
lishuaia72d44d2015-10-19 17:27:38 +0800553 /**
BitOhenrye330cf02015-11-17 18:59:33 +0800554 * Creates a match on IPv4 destination field using the specified value.
lishuaia72d44d2015-10-19 17:27:38 +0800555 *
BitOhenrye330cf02015-11-17 18:59:33 +0800556 * @param ip ipv4 destination value
lishuaia72d44d2015-10-19 17:27:38 +0800557 * @return match criterion
558 */
559 public static Criterion matchArpTpa(Ip4Address ip) {
560 return new ArpPaCriterion(ip, Type.ARP_TPA);
561 }
562
BitOhenrycc024eb2015-11-10 17:17:36 +0800563 /**
BitOhenry08c72942015-11-18 14:44:29 +0800564 * Creates a match on IPv4 source field using the specified value.
565 *
566 * @param ip ipv4 source value
567 * @return match criterion
568 */
569 public static Criterion matchArpSpa(Ip4Address ip) {
570 return new ArpPaCriterion(ip, Type.ARP_SPA);
571 }
572
573 /**
BitOhenrye330cf02015-11-17 18:59:33 +0800574 * Creates a match on MAC destination field using the specified value.
575 *
576 * @param mac MAC destination value
577 * @return match criterion
578 */
579 public static Criterion matchArpTha(MacAddress mac) {
580 return new ArpHaCriterion(mac, Type.ARP_THA);
581 }
582
583 /**
BitOhenrycc024eb2015-11-10 17:17:36 +0800584 * Creates a match on MAC source field using the specified value.
585 *
586 * @param mac MAC source value
587 * @return match criterion
588 */
BitOhenrye330cf02015-11-17 18:59:33 +0800589 public static Criterion matchArpSha(MacAddress mac) {
590 return new ArpHaCriterion(mac, Type.ARP_SHA);
BitOhenrycc024eb2015-11-10 17:17:36 +0800591 }
592
BitOhenry11620c92015-11-27 08:42:36 +0800593 /**
594 * Creates a match on arp operation type field using the specified value.
595 *
596 * @param arpOp arp operation type value
597 * @return match criterion
598 */
599 public static Criterion matchArpOp(int arpOp) {
600 return new ArpOpCriterion(arpOp, Type.ARP_OP);
601 }
602
Jonathan Hart26a8d952015-12-02 15:16:35 -0800603 /**
Jian Lif1ecf992015-12-02 17:48:54 -0800604 * Creates a match on PBB I-SID field using the specific value.
605 *
606 * @param pbbIsid PBB I-SID
607 * @return match criterion
608 */
609 public static Criterion matchPbbIsid(int pbbIsid) {
610 return new PbbIsidCriterion(pbbIsid);
611 }
612
613 /**
Jonathan Hart26a8d952015-12-02 15:16:35 -0800614 * Creates an extension criterion for the specified extension selector.
615 *
616 * @param extensionSelector extension selector
617 * @param deviceId device ID
618 * @return match criterion
619 */
620 public static Criterion extension(ExtensionSelector extensionSelector,
621 DeviceId deviceId) {
622 return new ExtensionCriterion(extensionSelector, deviceId);
623 }
624
625 /**
626 * Creates a dummy criterion.
627 *
628 * @return match criterion
629 */
alshabiba3a476d2015-04-10 14:35:38 -0700630 public static Criterion dummy() {
631 return new DummyCriterion();
632 }
633
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700634 /**
alshabiba3a476d2015-04-10 14:35:38 -0700635 * Dummy Criterion used with @see{FilteringObjective}.
636 */
637 private static class DummyCriterion implements Criterion {
638
639 @Override
640 public Type type() {
641 return Type.DUMMY;
642 }
643 }
tom8bb16062014-09-12 14:47:46 -0700644}