blob: c45f160bf6cacedc4ba932f18c22871d852f2b4f [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;
Sho SHIMIZUefc2e282015-05-04 15:26:23 -070026import org.onosproject.net.IndexedLambda;
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -070027import org.onosproject.net.Lambda;
28import org.onosproject.net.OchSignal;
lishuaia72d44d2015-10-19 17:27:38 +080029import org.onosproject.net.OchSignalType;
Yafit Hadar52d81552015-10-07 12:26:52 +030030import org.onosproject.net.OduSignalId;
31import org.onosproject.net.OduSignalType;
Brian O'Connorabafb502014-12-02 22:26:20 -080032import org.onosproject.net.PortNumber;
33import org.onosproject.net.flow.criteria.Criterion.Type;
alshabib7b795492014-09-16 14:38:39 -070034
tom8bb16062014-09-12 14:47:46 -070035/**
36 * Factory class to create various traffic selection criteria.
37 */
38public final class Criteria {
39
alshabib7b795492014-09-16 14:38:39 -070040 //TODO: incomplete type implementation. Need to implement complete list from Criterion
41
tom8bb16062014-09-12 14:47:46 -070042 // Ban construction
43 private Criteria() {
44 }
45
46 /**
alshabib7b795492014-09-16 14:38:39 -070047 * Creates a match on IN_PORT field using the specified value.
48 *
49 * @param port inport value
50 * @return match criterion
51 */
52 public static Criterion matchInPort(PortNumber port) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080053 return new PortCriterion(port, Type.IN_PORT);
54 }
55
56 /**
57 * Creates a match on IN_PHY_PORT field using the specified value.
58 *
59 * @param port inport value
60 * @return match criterion
61 */
62 public static Criterion matchInPhyPort(PortNumber port) {
63 return new PortCriterion(port, Type.IN_PHY_PORT);
64 }
65
66 /**
67 * Creates a match on METADATA field using the specified value.
68 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -080069 * @param metadata metadata value (64 bits data)
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080070 * @return match criterion
71 */
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -080072 public static Criterion matchMetadata(long metadata) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080073 return new MetadataCriterion(metadata);
alshabib7b795492014-09-16 14:38:39 -070074 }
75
76 /**
alshabib369d2942014-09-12 17:59:35 -070077 * Creates a match on ETH_DST field using the specified value. This value
78 * may be a wildcard mask.
79 *
tomc104d282014-09-19 10:57:55 -070080 * @param mac MAC address value or wildcard mask
alshabib369d2942014-09-12 17:59:35 -070081 * @return match criterion
82 */
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070083 public static Criterion matchEthDst(MacAddress mac) {
alshabib7b795492014-09-16 14:38:39 -070084 return new EthCriterion(mac, Type.ETH_DST);
85 }
86
87 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080088 * Creates a match on ETH_SRC field using the specified value. This value
89 * may be a wildcard mask.
90 *
91 * @param mac MAC address value or wildcard mask
92 * @return match criterion
93 */
94 public static Criterion matchEthSrc(MacAddress mac) {
95 return new EthCriterion(mac, Type.ETH_SRC);
96 }
97
98 /**
alshabib7b795492014-09-16 14:38:39 -070099 * Creates a match on ETH_TYPE field using the specified value.
100 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800101 * @param ethType eth type value (16 bits unsigned integer)
alshabib7b795492014-09-16 14:38:39 -0700102 * @return match criterion
103 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800104 public static Criterion matchEthType(int ethType) {
alshabib7b795492014-09-16 14:38:39 -0700105 return new EthTypeCriterion(ethType);
106 }
107
108 /**
alshabibcaf1ca22015-06-25 15:18:16 -0700109 * Creates a match on ETH_TYPE field using the specified value.
110 *
111 * @param ethType eth type value
112 * @return match criterion
113 */
114 public static Criterion matchEthType(EthType ethType) {
115 return new EthTypeCriterion(ethType);
116 }
117
118 /**
alshabib7b795492014-09-16 14:38:39 -0700119 * Creates a match on VLAN ID field using the specified value.
120 *
121 * @param vlanId vlan id value
122 * @return match criterion
123 */
Ayaka Koshibea9c199f2014-09-16 16:21:40 -0700124 public static Criterion matchVlanId(VlanId vlanId) {
alshabib7b795492014-09-16 14:38:39 -0700125 return new VlanIdCriterion(vlanId);
126 }
127
128 /**
129 * Creates a match on VLAN PCP field using the specified value.
130 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800131 * @param vlanPcp vlan pcp value (3 bits)
alshabib7b795492014-09-16 14:38:39 -0700132 * @return match criterion
133 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800134 public static Criterion matchVlanPcp(byte vlanPcp) {
alshabib7b795492014-09-16 14:38:39 -0700135 return new VlanPcpCriterion(vlanPcp);
136 }
137
138 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800139 * Creates a match on IP DSCP field using the specified value.
140 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800141 * @param ipDscp ip dscp value (6 bits)
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800142 * @return match criterion
143 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800144 public static Criterion matchIPDscp(byte ipDscp) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800145 return new IPDscpCriterion(ipDscp);
146 }
147
148 /**
149 * Creates a match on IP ECN field using the specified value.
150 *
Pavlin Radoslavovab8553a2015-02-20 14:13:50 -0800151 * @param ipEcn ip ecn value (2 bits)
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800152 * @return match criterion
153 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800154 public static Criterion matchIPEcn(byte ipEcn) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800155 return new IPEcnCriterion(ipEcn);
156 }
157
158 /**
alshabib7b795492014-09-16 14:38:39 -0700159 * Creates a match on IP proto field using the specified value.
160 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800161 * @param proto ip protocol value (8 bits unsigned integer)
alshabib7b795492014-09-16 14:38:39 -0700162 * @return match criterion
163 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800164 public static Criterion matchIPProtocol(short proto) {
alshabib7b795492014-09-16 14:38:39 -0700165 return new IPProtocolCriterion(proto);
166 }
167
168 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800169 * Creates a match on IPv4 source field using the specified value.
alshabib7b795492014-09-16 14:38:39 -0700170 *
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800171 * @param ip ipv4 source value
alshabib7b795492014-09-16 14:38:39 -0700172 * @return match criterion
173 */
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700174 public static Criterion matchIPSrc(IpPrefix ip) {
alshabib7b795492014-09-16 14:38:39 -0700175 return new IPCriterion(ip, Type.IPV4_SRC);
176 }
177
178 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800179 * Creates a match on IPv4 destination field using the specified value.
alshabib7b795492014-09-16 14:38:39 -0700180 *
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800181 * @param ip ipv4 source value
alshabib7b795492014-09-16 14:38:39 -0700182 * @return match criterion
183 */
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700184 public static Criterion matchIPDst(IpPrefix ip) {
alshabib7b795492014-09-16 14:38:39 -0700185 return new IPCriterion(ip, Type.IPV4_DST);
alshabib369d2942014-09-12 17:59:35 -0700186 }
187
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700188 /**
189 * Creates a match on TCP source port field using the specified value.
190 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700191 * @param tcpPort TCP source port
192 * @return match criterion
193 * @deprecated in Drake release
194 */
195 @Deprecated
196 public static Criterion matchTcpSrc(short tcpPort) {
197 return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_SRC);
198 }
199
200 /**
201 * Creates a match on TCP source port field using the specified value.
202 *
203 * @param tcpPort TCP source port
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700204 * @return match criterion
205 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700206 public static Criterion matchTcpSrc(TpPort tcpPort) {
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700207 return new TcpPortCriterion(tcpPort, Type.TCP_SRC);
208 }
209
210 /**
211 * Creates a match on TCP destination port field using the specified value.
212 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700213 * @param tcpPort TCP destination port
214 * @return match criterion
215 * @deprecated in Drake release
216 */
217 @Deprecated
218 public static Criterion matchTcpDst(short tcpPort) {
219 return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_DST);
220 }
221
222 /**
223 * Creates a match on TCP destination port field using the specified value.
224 *
225 * @param tcpPort TCP destination port
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700226 * @return match criterion
227 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700228 public static Criterion matchTcpDst(TpPort tcpPort) {
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700229 return new TcpPortCriterion(tcpPort, Type.TCP_DST);
230 }
alshabib369d2942014-09-12 17:59:35 -0700231
Marc De Leenheer49087752014-10-23 13:54:09 -0700232 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800233 * Creates a match on UDP source port field using the specified value.
234 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700235 * @param udpPort UDP source port
236 * @return match criterion
237 * @deprecated in Drake release
238 */
239 @Deprecated
240 public static Criterion matchUdpSrc(short udpPort) {
241 return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_SRC);
242 }
243
244 /**
245 * Creates a match on UDP source port field using the specified value.
246 *
247 * @param udpPort UDP source port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800248 * @return match criterion
249 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700250 public static Criterion matchUdpSrc(TpPort udpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800251 return new UdpPortCriterion(udpPort, Type.UDP_SRC);
252 }
253
254 /**
255 * Creates a match on UDP destination port field using the specified value.
256 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700257 * @param udpPort UDP destination port
258 * @return match criterion
259 * @deprecated in Drake release
260 */
261 @Deprecated
262 public static Criterion matchUdpDst(short udpPort) {
263 return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_DST);
264 }
265
266 /**
267 * Creates a match on UDP destination port field using the specified value.
268 *
269 * @param udpPort UDP destination port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800270 * @return match criterion
271 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700272 public static Criterion matchUdpDst(TpPort udpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800273 return new UdpPortCriterion(udpPort, Type.UDP_DST);
274 }
275
276 /**
277 * Creates a match on SCTP source port field using the specified value.
278 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700279 * @param sctpPort SCTP source port
280 * @return match criterion
281 * @deprecated in Drake release
282 */
283 @Deprecated
284 public static Criterion matchSctpSrc(short sctpPort) {
285 return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_SRC);
286 }
287
288 /**
289 * Creates a match on SCTP source port field using the specified value.
290 *
291 * @param sctpPort SCTP source port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800292 * @return match criterion
293 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700294 public static Criterion matchSctpSrc(TpPort sctpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800295 return new SctpPortCriterion(sctpPort, Type.SCTP_SRC);
296 }
297
298 /**
299 * Creates a match on SCTP destination port field using the specified
300 * value.
301 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700302 * @param sctpPort SCTP destination port
303 * @return match criterion
304 * @deprecated in Drake release
305 */
306 @Deprecated
307 public static Criterion matchSctpDst(short sctpPort) {
308 return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_DST);
309 }
310
311 /**
312 * Creates a match on SCTP destination port field using the specified
313 * value.
314 *
315 * @param sctpPort SCTP destination port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800316 * @return match criterion
317 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700318 public static Criterion matchSctpDst(TpPort sctpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800319 return new SctpPortCriterion(sctpPort, Type.SCTP_DST);
320 }
321
322 /**
323 * Creates a match on ICMP type field using the specified value.
324 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800325 * @param icmpType ICMP type (8 bits unsigned integer)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800326 * @return match criterion
327 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800328 public static Criterion matchIcmpType(short icmpType) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800329 return new IcmpTypeCriterion(icmpType);
330 }
331
332 /**
333 * Creates a match on ICMP code field using the specified value.
334 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800335 * @param icmpCode ICMP code (8 bits unsigned integer)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800336 * @return match criterion
337 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800338 public static Criterion matchIcmpCode(short icmpCode) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800339 return new IcmpCodeCriterion(icmpCode);
340 }
341
342 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800343 * Creates a match on IPv6 source field using the specified value.
344 *
345 * @param ip ipv6 source value
346 * @return match criterion
347 */
348 public static Criterion matchIPv6Src(IpPrefix ip) {
349 return new IPCriterion(ip, Type.IPV6_SRC);
350 }
351
352 /**
353 * Creates a match on IPv6 destination field using the specified value.
354 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800355 * @param ip ipv6 destination value
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800356 * @return match criterion
357 */
358 public static Criterion matchIPv6Dst(IpPrefix ip) {
359 return new IPCriterion(ip, Type.IPV6_DST);
360 }
361
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800362 /**
363 * Creates a match on IPv6 flow label field using the specified value.
364 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800365 * @param flowLabel IPv6 flow label (20 bits)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800366 * @return match criterion
367 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800368 public static Criterion matchIPv6FlowLabel(int flowLabel) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800369 return new IPv6FlowLabelCriterion(flowLabel);
370 }
371
372 /**
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800373 * Creates a match on ICMPv6 type field using the specified value.
374 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800375 * @param icmpv6Type ICMPv6 type (8 bits unsigned integer)
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800376 * @return match criterion
377 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800378 public static Criterion matchIcmpv6Type(short icmpv6Type) {
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800379 return new Icmpv6TypeCriterion(icmpv6Type);
380 }
381
382 /**
383 * Creates a match on ICMPv6 code field using the specified value.
384 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800385 * @param icmpv6Code ICMPv6 code (8 bits unsigned integer)
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800386 * @return match criterion
387 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800388 public static Criterion matchIcmpv6Code(short icmpv6Code) {
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800389 return new Icmpv6CodeCriterion(icmpv6Code);
390 }
391
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800392 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800393 * Creates a match on IPv6 Neighbor Discovery target address using the
394 * specified value.
395 *
396 * @param targetAddress IPv6 Neighbor Discovery target address
397 * @return match criterion
398 */
399 public static Criterion matchIPv6NDTargetAddress(Ip6Address targetAddress) {
400 return new IPv6NDTargetAddressCriterion(targetAddress);
401 }
402
403 /**
404 * Creates a match on IPv6 Neighbor Discovery source link-layer address
405 * using the specified value.
406 *
407 * @param mac IPv6 Neighbor Discovery source link-layer address
408 * @return match criterion
409 */
410 public static Criterion matchIPv6NDSourceLinkLayerAddress(MacAddress mac) {
411 return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_SLL);
412 }
413
414 /**
415 * Creates a match on IPv6 Neighbor Discovery target link-layer address
416 * using the specified value.
417 *
418 * @param mac IPv6 Neighbor Discovery target link-layer address
419 * @return match criterion
420 */
421 public static Criterion matchIPv6NDTargetLinkLayerAddress(MacAddress mac) {
422 return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_TLL);
423 }
424
425 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800426 * Creates a match on MPLS label.
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800427 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800428 * @param mplsLabel MPLS label (20 bits)
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800429 * @return match criterion
430 */
Michele Santuari4b6019e2014-12-19 11:31:45 +0100431 public static Criterion matchMplsLabel(MplsLabel mplsLabel) {
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800432 return new MplsCriterion(mplsLabel);
433 }
434
435 /**
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700436 * Creates a match on MPLS Bottom-of-Stack indicator bit.
437 *
438 * @param mplsBos boolean value indicating true (BOS=1) or false (BOS=0)
439 * @return match criterion
440 */
441 public static Criterion matchMplsLabel(boolean mplsBos) {
442 return new MplsBosCriterion(mplsBos);
443 }
444
445 /**
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700446 * Creates a match on Tunnel ID.
447 *
448 * @param tunnelId Tunnel ID (64 bits)
449 * @return match criterion
450 */
451 public static Criterion matchTunnelId(long tunnelId) {
452 return new TunnelIdCriterion(tunnelId);
453 }
454
455 /**
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800456 * Creates a match on IPv6 Extension Header pseudo-field fiags.
457 * Those are defined in Criterion.IPv6ExthdrFlags.
458 *
459 * @param exthdrFlags IPv6 Extension Header pseudo-field flags (16 bits)
460 * @return match criterion
461 */
462 public static Criterion matchIPv6ExthdrFlags(int exthdrFlags) {
463 return new IPv6ExthdrFlagsCriterion(exthdrFlags);
464 }
465
466 /**
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -0700467 * Creates a match on lambda using the specified value.
468 *
469 * @param lambda lambda
470 * @return match criterion
471 */
472 public static Criterion matchLambda(Lambda lambda) {
Sho SHIMIZUefc2e282015-05-04 15:26:23 -0700473 if (lambda instanceof IndexedLambda) {
474 return new IndexedLambdaCriterion((IndexedLambda) lambda);
475 } else if (lambda instanceof OchSignal) {
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -0700476 return new OchSignalCriterion((OchSignal) lambda);
477 } else {
478 throw new UnsupportedOperationException(String.format("Unsupported type of Lambda: %s", lambda));
479 }
480 }
481
482 /**
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -0700483 * Create a match on OCh (Optical Channel) signal type.
484 *
485 * @param signalType OCh signal type
486 * @return match criterion
487 */
488 public static Criterion matchOchSignalType(OchSignalType signalType) {
489 return new OchSignalTypeCriterion(signalType);
490 }
491
Yafit Hadar52d81552015-10-07 12:26:52 +0300492 /**
493 * Creates a match on ODU (Optical channel Data Unit) signal ID using the specified value.
494 *
495 * @param oduSignalId ODU Signal Id
496 * @return match criterion
497 */
498 public static Criterion matchOduSignalId(OduSignalId oduSignalId) {
499 return new OduSignalIdCriterion(oduSignalId);
500 }
501
502 /**
503 * Creates a match on ODU (Optical channel Data Unit) signal Type using the specified value.
504 *
505 * @param signalType ODU Signal Type
506 * @return match criterion
507 */
508 public static Criterion matchOduSignalType(OduSignalType signalType) {
509 return new OduSignalTypeCriterion(signalType);
510 }
511
lishuaia72d44d2015-10-19 17:27:38 +0800512 /**
BitOhenrye330cf02015-11-17 18:59:33 +0800513 * Creates a match on IPv4 destination field using the specified value.
lishuaia72d44d2015-10-19 17:27:38 +0800514 *
BitOhenrye330cf02015-11-17 18:59:33 +0800515 * @param ip ipv4 destination value
lishuaia72d44d2015-10-19 17:27:38 +0800516 * @return match criterion
517 */
518 public static Criterion matchArpTpa(Ip4Address ip) {
519 return new ArpPaCriterion(ip, Type.ARP_TPA);
520 }
521
BitOhenrycc024eb2015-11-10 17:17:36 +0800522 /**
BitOhenrye330cf02015-11-17 18:59:33 +0800523 * Creates a match on MAC destination field using the specified value.
524 *
525 * @param mac MAC destination value
526 * @return match criterion
527 */
528 public static Criterion matchArpTha(MacAddress mac) {
529 return new ArpHaCriterion(mac, Type.ARP_THA);
530 }
531
532 /**
BitOhenrycc024eb2015-11-10 17:17:36 +0800533 * Creates a match on MAC source field using the specified value.
534 *
535 * @param mac MAC source value
536 * @return match criterion
537 */
BitOhenrye330cf02015-11-17 18:59:33 +0800538 public static Criterion matchArpSha(MacAddress mac) {
539 return new ArpHaCriterion(mac, Type.ARP_SHA);
BitOhenrycc024eb2015-11-10 17:17:36 +0800540 }
541
alshabiba3a476d2015-04-10 14:35:38 -0700542 public static Criterion dummy() {
543 return new DummyCriterion();
544 }
545
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700546 /**
alshabiba3a476d2015-04-10 14:35:38 -0700547 * Dummy Criterion used with @see{FilteringObjective}.
548 */
549 private static class DummyCriterion implements Criterion {
550
551 @Override
552 public Type type() {
553 return Type.DUMMY;
554 }
555 }
tom8bb16062014-09-12 14:47:46 -0700556}