blob: c94b1e02d4b36d9a8896647494ef8b863c4d79fe [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 /**
130 * Creates a match on VLAN PCP field using the specified value.
131 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800132 * @param vlanPcp vlan pcp value (3 bits)
alshabib7b795492014-09-16 14:38:39 -0700133 * @return match criterion
134 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800135 public static Criterion matchVlanPcp(byte vlanPcp) {
alshabib7b795492014-09-16 14:38:39 -0700136 return new VlanPcpCriterion(vlanPcp);
137 }
138
139 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800140 * Creates a match on IP DSCP field using the specified value.
141 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800142 * @param ipDscp ip dscp value (6 bits)
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800143 * @return match criterion
144 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800145 public static Criterion matchIPDscp(byte ipDscp) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800146 return new IPDscpCriterion(ipDscp);
147 }
148
149 /**
150 * Creates a match on IP ECN field using the specified value.
151 *
Pavlin Radoslavovab8553a2015-02-20 14:13:50 -0800152 * @param ipEcn ip ecn value (2 bits)
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800153 * @return match criterion
154 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800155 public static Criterion matchIPEcn(byte ipEcn) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800156 return new IPEcnCriterion(ipEcn);
157 }
158
159 /**
alshabib7b795492014-09-16 14:38:39 -0700160 * Creates a match on IP proto field using the specified value.
161 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800162 * @param proto ip protocol value (8 bits unsigned integer)
alshabib7b795492014-09-16 14:38:39 -0700163 * @return match criterion
164 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800165 public static Criterion matchIPProtocol(short proto) {
alshabib7b795492014-09-16 14:38:39 -0700166 return new IPProtocolCriterion(proto);
167 }
168
169 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800170 * Creates a match on IPv4 source field using the specified value.
alshabib7b795492014-09-16 14:38:39 -0700171 *
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800172 * @param ip ipv4 source value
alshabib7b795492014-09-16 14:38:39 -0700173 * @return match criterion
174 */
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700175 public static Criterion matchIPSrc(IpPrefix ip) {
alshabib7b795492014-09-16 14:38:39 -0700176 return new IPCriterion(ip, Type.IPV4_SRC);
177 }
178
179 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800180 * Creates a match on IPv4 destination field using the specified value.
alshabib7b795492014-09-16 14:38:39 -0700181 *
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800182 * @param ip ipv4 source value
alshabib7b795492014-09-16 14:38:39 -0700183 * @return match criterion
184 */
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700185 public static Criterion matchIPDst(IpPrefix ip) {
alshabib7b795492014-09-16 14:38:39 -0700186 return new IPCriterion(ip, Type.IPV4_DST);
alshabib369d2942014-09-12 17:59:35 -0700187 }
188
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700189 /**
190 * Creates a match on TCP source port field using the specified value.
191 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700192 * @param tcpPort TCP source port
193 * @return match criterion
194 * @deprecated in Drake release
195 */
196 @Deprecated
197 public static Criterion matchTcpSrc(short tcpPort) {
198 return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_SRC);
199 }
200
201 /**
202 * Creates a match on TCP source port field using the specified value.
203 *
204 * @param tcpPort TCP source port
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700205 * @return match criterion
206 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700207 public static Criterion matchTcpSrc(TpPort tcpPort) {
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700208 return new TcpPortCriterion(tcpPort, Type.TCP_SRC);
209 }
210
211 /**
212 * Creates a match on TCP destination port field using the specified value.
213 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700214 * @param tcpPort TCP destination port
215 * @return match criterion
216 * @deprecated in Drake release
217 */
218 @Deprecated
219 public static Criterion matchTcpDst(short tcpPort) {
220 return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_DST);
221 }
222
223 /**
224 * Creates a match on TCP destination port field using the specified value.
225 *
226 * @param tcpPort TCP destination port
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700227 * @return match criterion
228 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700229 public static Criterion matchTcpDst(TpPort tcpPort) {
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700230 return new TcpPortCriterion(tcpPort, Type.TCP_DST);
231 }
alshabib369d2942014-09-12 17:59:35 -0700232
Marc De Leenheer49087752014-10-23 13:54:09 -0700233 /**
Jian Li2748b2c2015-11-30 11:43:09 -0800234 * Creates a match on TCP flags using the specified value.
235 *
236 * @param flags TCP flags
237 * @return match criterion
238 */
239 public static Criterion matchTcpFlags(int flags) {
240 return new TcpFlagsCriterion(flags);
241 }
242
243 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800244 * Creates a match on UDP source port field using the specified value.
245 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700246 * @param udpPort UDP source port
247 * @return match criterion
248 * @deprecated in Drake release
249 */
250 @Deprecated
251 public static Criterion matchUdpSrc(short udpPort) {
252 return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_SRC);
253 }
254
255 /**
256 * Creates a match on UDP source port field using the specified value.
257 *
258 * @param udpPort UDP source port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800259 * @return match criterion
260 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700261 public static Criterion matchUdpSrc(TpPort udpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800262 return new UdpPortCriterion(udpPort, Type.UDP_SRC);
263 }
264
265 /**
266 * Creates a match on UDP destination port field using the specified value.
267 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700268 * @param udpPort UDP destination port
269 * @return match criterion
270 * @deprecated in Drake release
271 */
272 @Deprecated
273 public static Criterion matchUdpDst(short udpPort) {
274 return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_DST);
275 }
276
277 /**
278 * Creates a match on UDP destination port field using the specified value.
279 *
280 * @param udpPort UDP destination port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800281 * @return match criterion
282 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700283 public static Criterion matchUdpDst(TpPort udpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800284 return new UdpPortCriterion(udpPort, Type.UDP_DST);
285 }
286
287 /**
288 * Creates a match on SCTP source port field using the specified value.
289 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700290 * @param sctpPort SCTP source port
291 * @return match criterion
292 * @deprecated in Drake release
293 */
294 @Deprecated
295 public static Criterion matchSctpSrc(short sctpPort) {
296 return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_SRC);
297 }
298
299 /**
300 * Creates a match on SCTP source port field using the specified value.
301 *
302 * @param sctpPort SCTP source port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800303 * @return match criterion
304 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700305 public static Criterion matchSctpSrc(TpPort sctpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800306 return new SctpPortCriterion(sctpPort, Type.SCTP_SRC);
307 }
308
309 /**
310 * Creates a match on SCTP destination port field using the specified
311 * value.
312 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700313 * @param sctpPort SCTP destination port
314 * @return match criterion
315 * @deprecated in Drake release
316 */
317 @Deprecated
318 public static Criterion matchSctpDst(short sctpPort) {
319 return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_DST);
320 }
321
322 /**
323 * Creates a match on SCTP destination port field using the specified
324 * value.
325 *
326 * @param sctpPort SCTP destination port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800327 * @return match criterion
328 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700329 public static Criterion matchSctpDst(TpPort sctpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800330 return new SctpPortCriterion(sctpPort, Type.SCTP_DST);
331 }
332
333 /**
334 * Creates a match on ICMP type field using the specified value.
335 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800336 * @param icmpType ICMP type (8 bits unsigned integer)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800337 * @return match criterion
338 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800339 public static Criterion matchIcmpType(short icmpType) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800340 return new IcmpTypeCriterion(icmpType);
341 }
342
343 /**
344 * Creates a match on ICMP code field using the specified value.
345 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800346 * @param icmpCode ICMP code (8 bits unsigned integer)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800347 * @return match criterion
348 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800349 public static Criterion matchIcmpCode(short icmpCode) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800350 return new IcmpCodeCriterion(icmpCode);
351 }
352
353 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800354 * Creates a match on IPv6 source field using the specified value.
355 *
356 * @param ip ipv6 source value
357 * @return match criterion
358 */
359 public static Criterion matchIPv6Src(IpPrefix ip) {
360 return new IPCriterion(ip, Type.IPV6_SRC);
361 }
362
363 /**
364 * Creates a match on IPv6 destination field using the specified value.
365 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800366 * @param ip ipv6 destination value
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800367 * @return match criterion
368 */
369 public static Criterion matchIPv6Dst(IpPrefix ip) {
370 return new IPCriterion(ip, Type.IPV6_DST);
371 }
372
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800373 /**
374 * Creates a match on IPv6 flow label field using the specified value.
375 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800376 * @param flowLabel IPv6 flow label (20 bits)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800377 * @return match criterion
378 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800379 public static Criterion matchIPv6FlowLabel(int flowLabel) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800380 return new IPv6FlowLabelCriterion(flowLabel);
381 }
382
383 /**
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800384 * Creates a match on ICMPv6 type field using the specified value.
385 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800386 * @param icmpv6Type ICMPv6 type (8 bits unsigned integer)
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800387 * @return match criterion
388 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800389 public static Criterion matchIcmpv6Type(short icmpv6Type) {
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800390 return new Icmpv6TypeCriterion(icmpv6Type);
391 }
392
393 /**
394 * Creates a match on ICMPv6 code field using the specified value.
395 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800396 * @param icmpv6Code ICMPv6 code (8 bits unsigned integer)
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800397 * @return match criterion
398 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800399 public static Criterion matchIcmpv6Code(short icmpv6Code) {
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800400 return new Icmpv6CodeCriterion(icmpv6Code);
401 }
402
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800403 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800404 * Creates a match on IPv6 Neighbor Discovery target address using the
405 * specified value.
406 *
407 * @param targetAddress IPv6 Neighbor Discovery target address
408 * @return match criterion
409 */
410 public static Criterion matchIPv6NDTargetAddress(Ip6Address targetAddress) {
411 return new IPv6NDTargetAddressCriterion(targetAddress);
412 }
413
414 /**
415 * Creates a match on IPv6 Neighbor Discovery source link-layer address
416 * using the specified value.
417 *
418 * @param mac IPv6 Neighbor Discovery source link-layer address
419 * @return match criterion
420 */
421 public static Criterion matchIPv6NDSourceLinkLayerAddress(MacAddress mac) {
422 return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_SLL);
423 }
424
425 /**
426 * Creates a match on IPv6 Neighbor Discovery target link-layer address
427 * using the specified value.
428 *
429 * @param mac IPv6 Neighbor Discovery target link-layer address
430 * @return match criterion
431 */
432 public static Criterion matchIPv6NDTargetLinkLayerAddress(MacAddress mac) {
433 return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_TLL);
434 }
435
436 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800437 * Creates a match on MPLS label.
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800438 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800439 * @param mplsLabel MPLS label (20 bits)
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800440 * @return match criterion
441 */
Michele Santuari4b6019e2014-12-19 11:31:45 +0100442 public static Criterion matchMplsLabel(MplsLabel mplsLabel) {
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800443 return new MplsCriterion(mplsLabel);
444 }
445
446 /**
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700447 * Creates a match on MPLS Bottom-of-Stack indicator bit.
448 *
449 * @param mplsBos boolean value indicating true (BOS=1) or false (BOS=0)
450 * @return match criterion
451 */
Jian Li5c4cf1e2015-11-30 13:10:46 -0800452 public static Criterion matchMplsBos(boolean mplsBos) {
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700453 return new MplsBosCriterion(mplsBos);
454 }
455
456 /**
Jian Lifd44dc92015-11-26 16:32:32 -0800457 * Creates a match on MPLS TC.
458 *
459 * @param mplsTc MPLS TC (3 bits)
460 * @return match criterion
461 */
462 public static Criterion matchMplsTc(byte mplsTc) {
463 return new MplsTcCriterion(mplsTc);
464 }
465
466 /**
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700467 * Creates a match on Tunnel ID.
468 *
469 * @param tunnelId Tunnel ID (64 bits)
470 * @return match criterion
471 */
472 public static Criterion matchTunnelId(long tunnelId) {
473 return new TunnelIdCriterion(tunnelId);
474 }
475
476 /**
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800477 * Creates a match on IPv6 Extension Header pseudo-field fiags.
478 * Those are defined in Criterion.IPv6ExthdrFlags.
479 *
480 * @param exthdrFlags IPv6 Extension Header pseudo-field flags (16 bits)
481 * @return match criterion
482 */
483 public static Criterion matchIPv6ExthdrFlags(int exthdrFlags) {
484 return new IPv6ExthdrFlagsCriterion(exthdrFlags);
485 }
486
487 /**
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -0700488 * Creates a match on lambda using the specified value.
489 *
490 * @param lambda lambda
491 * @return match criterion
492 */
493 public static Criterion matchLambda(Lambda lambda) {
Sho SHIMIZUefc2e282015-05-04 15:26:23 -0700494 if (lambda instanceof IndexedLambda) {
495 return new IndexedLambdaCriterion((IndexedLambda) lambda);
496 } else if (lambda instanceof OchSignal) {
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -0700497 return new OchSignalCriterion((OchSignal) lambda);
498 } else {
499 throw new UnsupportedOperationException(String.format("Unsupported type of Lambda: %s", lambda));
500 }
501 }
502
503 /**
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -0700504 * Create a match on OCh (Optical Channel) signal type.
505 *
506 * @param signalType OCh signal type
507 * @return match criterion
508 */
509 public static Criterion matchOchSignalType(OchSignalType signalType) {
510 return new OchSignalTypeCriterion(signalType);
511 }
512
Yafit Hadar52d81552015-10-07 12:26:52 +0300513 /**
514 * Creates a match on ODU (Optical channel Data Unit) signal ID using the specified value.
515 *
516 * @param oduSignalId ODU Signal Id
517 * @return match criterion
518 */
519 public static Criterion matchOduSignalId(OduSignalId oduSignalId) {
520 return new OduSignalIdCriterion(oduSignalId);
521 }
522
523 /**
524 * Creates a match on ODU (Optical channel Data Unit) signal Type using the specified value.
525 *
526 * @param signalType ODU Signal Type
527 * @return match criterion
528 */
529 public static Criterion matchOduSignalType(OduSignalType signalType) {
530 return new OduSignalTypeCriterion(signalType);
531 }
532
lishuaia72d44d2015-10-19 17:27:38 +0800533 /**
BitOhenrye330cf02015-11-17 18:59:33 +0800534 * Creates a match on IPv4 destination field using the specified value.
lishuaia72d44d2015-10-19 17:27:38 +0800535 *
BitOhenrye330cf02015-11-17 18:59:33 +0800536 * @param ip ipv4 destination value
lishuaia72d44d2015-10-19 17:27:38 +0800537 * @return match criterion
538 */
539 public static Criterion matchArpTpa(Ip4Address ip) {
540 return new ArpPaCriterion(ip, Type.ARP_TPA);
541 }
542
BitOhenrycc024eb2015-11-10 17:17:36 +0800543 /**
BitOhenry08c72942015-11-18 14:44:29 +0800544 * Creates a match on IPv4 source field using the specified value.
545 *
546 * @param ip ipv4 source value
547 * @return match criterion
548 */
549 public static Criterion matchArpSpa(Ip4Address ip) {
550 return new ArpPaCriterion(ip, Type.ARP_SPA);
551 }
552
553 /**
BitOhenrye330cf02015-11-17 18:59:33 +0800554 * Creates a match on MAC destination field using the specified value.
555 *
556 * @param mac MAC destination value
557 * @return match criterion
558 */
559 public static Criterion matchArpTha(MacAddress mac) {
560 return new ArpHaCriterion(mac, Type.ARP_THA);
561 }
562
563 /**
BitOhenrycc024eb2015-11-10 17:17:36 +0800564 * Creates a match on MAC source field using the specified value.
565 *
566 * @param mac MAC source value
567 * @return match criterion
568 */
BitOhenrye330cf02015-11-17 18:59:33 +0800569 public static Criterion matchArpSha(MacAddress mac) {
570 return new ArpHaCriterion(mac, Type.ARP_SHA);
BitOhenrycc024eb2015-11-10 17:17:36 +0800571 }
572
BitOhenry11620c92015-11-27 08:42:36 +0800573 /**
574 * Creates a match on arp operation type field using the specified value.
575 *
576 * @param arpOp arp operation type value
577 * @return match criterion
578 */
579 public static Criterion matchArpOp(int arpOp) {
580 return new ArpOpCriterion(arpOp, Type.ARP_OP);
581 }
582
Jonathan Hart26a8d952015-12-02 15:16:35 -0800583 /**
Jian Lif1ecf992015-12-02 17:48:54 -0800584 * Creates a match on PBB I-SID field using the specific value.
585 *
586 * @param pbbIsid PBB I-SID
587 * @return match criterion
588 */
589 public static Criterion matchPbbIsid(int pbbIsid) {
590 return new PbbIsidCriterion(pbbIsid);
591 }
592
593 /**
Jonathan Hart26a8d952015-12-02 15:16:35 -0800594 * Creates an extension criterion for the specified extension selector.
595 *
596 * @param extensionSelector extension selector
597 * @param deviceId device ID
598 * @return match criterion
599 */
600 public static Criterion extension(ExtensionSelector extensionSelector,
601 DeviceId deviceId) {
602 return new ExtensionCriterion(extensionSelector, deviceId);
603 }
604
605 /**
606 * Creates a dummy criterion.
607 *
608 * @return match criterion
609 */
alshabiba3a476d2015-04-10 14:35:38 -0700610 public static Criterion dummy() {
611 return new DummyCriterion();
612 }
613
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700614 /**
alshabiba3a476d2015-04-10 14:35:38 -0700615 * Dummy Criterion used with @see{FilteringObjective}.
616 */
617 private static class DummyCriterion implements Criterion {
618
619 @Override
620 public Type type() {
621 return Type.DUMMY;
622 }
623 }
tom8bb16062014-09-12 14:47:46 -0700624}