blob: e40b74250d992769105acd8ea3e4bdb75e208024 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
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 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 /**
Saurav Das9d6c86b2016-02-19 09:01:07 -080088 * Creates a masked match on ETH_DST field using the specified value and mask.
89 *
90 * @param mac MAC address value
91 * @param mask MAC address masking
92 * @return match criterion
93 */
94 public static Criterion matchEthDstMasked(MacAddress mac, MacAddress mask) {
95 return new EthCriterion(mac, mask, Type.ETH_DST_MASKED);
96 }
97
98 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080099 * Creates a match on ETH_SRC field using the specified value. This value
100 * may be a wildcard mask.
101 *
102 * @param mac MAC address value or wildcard mask
103 * @return match criterion
104 */
105 public static Criterion matchEthSrc(MacAddress mac) {
106 return new EthCriterion(mac, Type.ETH_SRC);
107 }
108
109 /**
Saurav Das9d6c86b2016-02-19 09:01:07 -0800110 * Creates a masked match on ETH_SRC field using the specified value and mask.
111 *
112 * @param mac MAC address value
113 * @param mask MAC address masking
114 * @return match criterion
115 */
116 public static Criterion matchEthSrcMasked(MacAddress mac, MacAddress mask) {
117 return new EthCriterion(mac, mask, Type.ETH_SRC_MASKED);
118 }
119
120 /**
alshabib7b795492014-09-16 14:38:39 -0700121 * Creates a match on ETH_TYPE field using the specified value.
122 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800123 * @param ethType eth type value (16 bits unsigned integer)
alshabib7b795492014-09-16 14:38:39 -0700124 * @return match criterion
125 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800126 public static Criterion matchEthType(int ethType) {
alshabib7b795492014-09-16 14:38:39 -0700127 return new EthTypeCriterion(ethType);
128 }
129
130 /**
alshabibcaf1ca22015-06-25 15:18:16 -0700131 * Creates a match on ETH_TYPE field using the specified value.
132 *
133 * @param ethType eth type value
134 * @return match criterion
135 */
136 public static Criterion matchEthType(EthType ethType) {
137 return new EthTypeCriterion(ethType);
138 }
139
140 /**
alshabib7b795492014-09-16 14:38:39 -0700141 * Creates a match on VLAN ID field using the specified value.
142 *
143 * @param vlanId vlan id value
144 * @return match criterion
145 */
Ayaka Koshibea9c199f2014-09-16 16:21:40 -0700146 public static Criterion matchVlanId(VlanId vlanId) {
alshabib7b795492014-09-16 14:38:39 -0700147 return new VlanIdCriterion(vlanId);
148 }
149
150 /**
alshabibfa0dc662016-01-13 11:23:53 -0800151 * Creates a match on the inner VLAN ID field using the specified value.
152 *
153 * @param vlanId vlan id value
154 * @return match criterion
155 */
156 public static Criterion matchInnerVlanId(VlanId vlanId) {
157 return new VlanIdCriterion(vlanId, Type.INNER_VLAN_VID);
158 }
159
160 /**
alshabib7b795492014-09-16 14:38:39 -0700161 * Creates a match on VLAN PCP field using the specified value.
162 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800163 * @param vlanPcp vlan pcp value (3 bits)
alshabib7b795492014-09-16 14:38:39 -0700164 * @return match criterion
165 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800166 public static Criterion matchVlanPcp(byte vlanPcp) {
alshabib7b795492014-09-16 14:38:39 -0700167 return new VlanPcpCriterion(vlanPcp);
168 }
169
170 /**
alshabibfa0dc662016-01-13 11:23:53 -0800171 * Creates a match on the inner VLAN PCP field using the specified value.
172 *
173 * @param vlanPcp vlan pcp value (3 bits)
174 * @return match criterion
175 */
176 public static Criterion matchInnerVlanPcp(byte vlanPcp) {
177 return new VlanPcpCriterion(vlanPcp, Type.INNER_VLAN_PCP);
178 }
179
180 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800181 * Creates a match on IP DSCP field using the specified value.
182 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800183 * @param ipDscp ip dscp value (6 bits)
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800184 * @return match criterion
185 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800186 public static Criterion matchIPDscp(byte ipDscp) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800187 return new IPDscpCriterion(ipDscp);
188 }
189
190 /**
191 * Creates a match on IP ECN field using the specified value.
192 *
Pavlin Radoslavovab8553a2015-02-20 14:13:50 -0800193 * @param ipEcn ip ecn value (2 bits)
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800194 * @return match criterion
195 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800196 public static Criterion matchIPEcn(byte ipEcn) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800197 return new IPEcnCriterion(ipEcn);
198 }
199
200 /**
alshabib7b795492014-09-16 14:38:39 -0700201 * Creates a match on IP proto field using the specified value.
202 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800203 * @param proto ip protocol value (8 bits unsigned integer)
alshabib7b795492014-09-16 14:38:39 -0700204 * @return match criterion
205 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800206 public static Criterion matchIPProtocol(short proto) {
alshabib7b795492014-09-16 14:38:39 -0700207 return new IPProtocolCriterion(proto);
208 }
209
210 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800211 * Creates a match on IPv4 source field using the specified value.
alshabib7b795492014-09-16 14:38:39 -0700212 *
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800213 * @param ip ipv4 source value
alshabib7b795492014-09-16 14:38:39 -0700214 * @return match criterion
215 */
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700216 public static Criterion matchIPSrc(IpPrefix ip) {
alshabib7b795492014-09-16 14:38:39 -0700217 return new IPCriterion(ip, Type.IPV4_SRC);
218 }
219
220 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800221 * Creates a match on IPv4 destination field using the specified value.
alshabib7b795492014-09-16 14:38:39 -0700222 *
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800223 * @param ip ipv4 source value
alshabib7b795492014-09-16 14:38:39 -0700224 * @return match criterion
225 */
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700226 public static Criterion matchIPDst(IpPrefix ip) {
alshabib7b795492014-09-16 14:38:39 -0700227 return new IPCriterion(ip, Type.IPV4_DST);
alshabib369d2942014-09-12 17:59:35 -0700228 }
229
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700230 /**
231 * Creates a match on TCP source port field using the specified value.
232 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700233 * @param tcpPort TCP source port
234 * @return match criterion
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700235 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700236 public static Criterion matchTcpSrc(TpPort tcpPort) {
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700237 return new TcpPortCriterion(tcpPort, Type.TCP_SRC);
238 }
239
240 /**
Andreas Gilbert75b882f72017-02-03 09:58:07 +0100241 * Creates a masked match on TCP source port field using the specified value and mask.
242 *
243 * @param tcpPort TCP source port
244 * @param mask TCP source port masking
245 * @return match criterion
246 */
247 public static Criterion matchTcpSrcMasked(TpPort tcpPort, TpPort mask) {
248 return new TcpPortCriterion(tcpPort, mask, Type.TCP_SRC_MASKED);
249 }
250
251 /**
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700252 * Creates a match on TCP destination port field using the specified value.
253 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700254 * @param tcpPort TCP destination port
255 * @return match criterion
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700256 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700257 public static Criterion matchTcpDst(TpPort tcpPort) {
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700258 return new TcpPortCriterion(tcpPort, Type.TCP_DST);
259 }
alshabib369d2942014-09-12 17:59:35 -0700260
Marc De Leenheer49087752014-10-23 13:54:09 -0700261 /**
Andreas Gilbert75b882f72017-02-03 09:58:07 +0100262 * Creates a masked match on TCP destination port field using the specified value and mask.
263 *
264 * @param tcpPort TCP destination port
265 * @param mask TCP destination port masking
266 * @return match criterion
267 */
268 public static Criterion matchTcpDstMasked(TpPort tcpPort, TpPort mask) {
269 return new TcpPortCriterion(tcpPort, mask, Type.TCP_DST_MASKED);
270 }
271
272 /**
Jian Li2748b2c2015-11-30 11:43:09 -0800273 * Creates a match on TCP flags using the specified value.
274 *
275 * @param flags TCP flags
276 * @return match criterion
277 */
278 public static Criterion matchTcpFlags(int flags) {
279 return new TcpFlagsCriterion(flags);
280 }
281
282 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800283 * Creates a match on UDP source port field using the specified value.
284 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700285 * @param udpPort UDP source port
286 * @return match criterion
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800287 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700288 public static Criterion matchUdpSrc(TpPort udpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800289 return new UdpPortCriterion(udpPort, Type.UDP_SRC);
290 }
291
292 /**
Andreas Gilbert75b882f72017-02-03 09:58:07 +0100293 * Creates a masked match on UDP source port field using the specified value and mask.
294 *
295 * @param udpPort UDP source port
296 * @param mask UDP source port masking
297 * @return match criterion
298 */
299 public static Criterion matchUdpSrcMasked(TpPort udpPort, TpPort mask) {
300 return new UdpPortCriterion(udpPort, mask, Type.UDP_SRC_MASKED);
301 }
302
303 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800304 * Creates a match on UDP destination port field using the specified value.
305 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700306 * @param udpPort UDP destination port
307 * @return match criterion
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800308 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700309 public static Criterion matchUdpDst(TpPort udpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800310 return new UdpPortCriterion(udpPort, Type.UDP_DST);
311 }
312
313 /**
Andreas Gilbert75b882f72017-02-03 09:58:07 +0100314 * Creates a masked match on UDP destination port field using the specified value and mask.
315 *
316 * @param udpPort UDP destination port
317 * @param mask UDP destination port masking
318 * @return match criterion
319 */
320 public static Criterion matchUdpDstMasked(TpPort udpPort, TpPort mask) {
321 return new UdpPortCriterion(udpPort, mask, Type.UDP_DST_MASKED);
322 }
323
324 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800325 * Creates a match on SCTP source port field using the specified value.
326 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700327 * @param sctpPort SCTP source port
328 * @return match criterion
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800329 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700330 public static Criterion matchSctpSrc(TpPort sctpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800331 return new SctpPortCriterion(sctpPort, Type.SCTP_SRC);
332 }
333
334 /**
Andreas Gilbert75b882f72017-02-03 09:58:07 +0100335 * Creates a masked match on SCTP source port field using the specified value and mask.
336 *
337 * @param sctpPort SCTP source port
338 * @param mask SCTP source port masking
339 * @return match criterion
340 */
341 public static Criterion matchSctpSrcMasked(TpPort sctpPort, TpPort mask) {
342 return new SctpPortCriterion(sctpPort, mask, Type.SCTP_SRC_MASKED);
343 }
344
345 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800346 * Creates a match on SCTP destination port field using the specified
347 * value.
348 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700349 * @param sctpPort SCTP destination port
350 * @return match criterion
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800351 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700352 public static Criterion matchSctpDst(TpPort sctpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800353 return new SctpPortCriterion(sctpPort, Type.SCTP_DST);
354 }
355
356 /**
Andreas Gilbert75b882f72017-02-03 09:58:07 +0100357 * Creates a masked match on SCTP destination port field using the specified value and mask.
358 *
359 * @param sctpPort SCTP destination port
360 * @param mask SCTP destination port masking
361 * @return match criterion
362 */
363 public static Criterion matchSctpDstMasked(TpPort sctpPort, TpPort mask) {
364 return new SctpPortCriterion(sctpPort, mask, Type.SCTP_DST_MASKED);
365 }
366
367 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800368 * Creates a match on ICMP type field using the specified value.
369 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800370 * @param icmpType ICMP type (8 bits unsigned integer)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800371 * @return match criterion
372 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800373 public static Criterion matchIcmpType(short icmpType) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800374 return new IcmpTypeCriterion(icmpType);
375 }
376
377 /**
378 * Creates a match on ICMP code field using the specified value.
379 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800380 * @param icmpCode ICMP code (8 bits unsigned integer)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800381 * @return match criterion
382 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800383 public static Criterion matchIcmpCode(short icmpCode) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800384 return new IcmpCodeCriterion(icmpCode);
385 }
386
387 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800388 * Creates a match on IPv6 source field using the specified value.
389 *
390 * @param ip ipv6 source value
391 * @return match criterion
392 */
393 public static Criterion matchIPv6Src(IpPrefix ip) {
394 return new IPCriterion(ip, Type.IPV6_SRC);
395 }
396
397 /**
398 * Creates a match on IPv6 destination field using the specified value.
399 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800400 * @param ip ipv6 destination value
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800401 * @return match criterion
402 */
403 public static Criterion matchIPv6Dst(IpPrefix ip) {
404 return new IPCriterion(ip, Type.IPV6_DST);
405 }
406
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800407 /**
408 * Creates a match on IPv6 flow label field using the specified value.
409 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800410 * @param flowLabel IPv6 flow label (20 bits)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800411 * @return match criterion
412 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800413 public static Criterion matchIPv6FlowLabel(int flowLabel) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800414 return new IPv6FlowLabelCriterion(flowLabel);
415 }
416
417 /**
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800418 * Creates a match on ICMPv6 type field using the specified value.
419 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800420 * @param icmpv6Type ICMPv6 type (8 bits unsigned integer)
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800421 * @return match criterion
422 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800423 public static Criterion matchIcmpv6Type(short icmpv6Type) {
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800424 return new Icmpv6TypeCriterion(icmpv6Type);
425 }
426
427 /**
428 * Creates a match on ICMPv6 code field using the specified value.
429 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800430 * @param icmpv6Code ICMPv6 code (8 bits unsigned integer)
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800431 * @return match criterion
432 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800433 public static Criterion matchIcmpv6Code(short icmpv6Code) {
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800434 return new Icmpv6CodeCriterion(icmpv6Code);
435 }
436
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800437 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800438 * Creates a match on IPv6 Neighbor Discovery target address using the
439 * specified value.
440 *
441 * @param targetAddress IPv6 Neighbor Discovery target address
442 * @return match criterion
443 */
444 public static Criterion matchIPv6NDTargetAddress(Ip6Address targetAddress) {
445 return new IPv6NDTargetAddressCriterion(targetAddress);
446 }
447
448 /**
449 * Creates a match on IPv6 Neighbor Discovery source link-layer address
450 * using the specified value.
451 *
452 * @param mac IPv6 Neighbor Discovery source link-layer address
453 * @return match criterion
454 */
455 public static Criterion matchIPv6NDSourceLinkLayerAddress(MacAddress mac) {
456 return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_SLL);
457 }
458
459 /**
460 * Creates a match on IPv6 Neighbor Discovery target link-layer address
461 * using the specified value.
462 *
463 * @param mac IPv6 Neighbor Discovery target link-layer address
464 * @return match criterion
465 */
466 public static Criterion matchIPv6NDTargetLinkLayerAddress(MacAddress mac) {
467 return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_TLL);
468 }
469
470 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800471 * Creates a match on MPLS label.
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800472 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800473 * @param mplsLabel MPLS label (20 bits)
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800474 * @return match criterion
475 */
Michele Santuari4b6019e2014-12-19 11:31:45 +0100476 public static Criterion matchMplsLabel(MplsLabel mplsLabel) {
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800477 return new MplsCriterion(mplsLabel);
478 }
479
480 /**
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700481 * Creates a match on MPLS Bottom-of-Stack indicator bit.
482 *
483 * @param mplsBos boolean value indicating true (BOS=1) or false (BOS=0)
484 * @return match criterion
485 */
Jian Li5c4cf1e2015-11-30 13:10:46 -0800486 public static Criterion matchMplsBos(boolean mplsBos) {
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700487 return new MplsBosCriterion(mplsBos);
488 }
489
490 /**
Jian Lifd44dc92015-11-26 16:32:32 -0800491 * Creates a match on MPLS TC.
492 *
493 * @param mplsTc MPLS TC (3 bits)
494 * @return match criterion
495 */
496 public static Criterion matchMplsTc(byte mplsTc) {
497 return new MplsTcCriterion(mplsTc);
498 }
499
500 /**
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700501 * Creates a match on Tunnel ID.
502 *
503 * @param tunnelId Tunnel ID (64 bits)
504 * @return match criterion
505 */
506 public static Criterion matchTunnelId(long tunnelId) {
507 return new TunnelIdCriterion(tunnelId);
508 }
509
510 /**
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800511 * Creates a match on IPv6 Extension Header pseudo-field fiags.
512 * Those are defined in Criterion.IPv6ExthdrFlags.
513 *
514 * @param exthdrFlags IPv6 Extension Header pseudo-field flags (16 bits)
515 * @return match criterion
516 */
517 public static Criterion matchIPv6ExthdrFlags(int exthdrFlags) {
518 return new IPv6ExthdrFlagsCriterion(exthdrFlags);
519 }
520
521 /**
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -0700522 * Creates a match on lambda using the specified value.
523 *
524 * @param lambda lambda
525 * @return match criterion
526 */
527 public static Criterion matchLambda(Lambda lambda) {
Sho SHIMIZU06810162016-02-24 12:52:32 -0800528 if (lambda instanceof OchSignal) {
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -0700529 return new OchSignalCriterion((OchSignal) lambda);
530 } else {
531 throw new UnsupportedOperationException(String.format("Unsupported type of Lambda: %s", lambda));
532 }
533 }
534
535 /**
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -0700536 * Create a match on OCh (Optical Channel) signal type.
537 *
538 * @param signalType OCh signal type
539 * @return match criterion
540 */
541 public static Criterion matchOchSignalType(OchSignalType signalType) {
542 return new OchSignalTypeCriterion(signalType);
543 }
544
Yafit Hadar52d81552015-10-07 12:26:52 +0300545 /**
546 * Creates a match on ODU (Optical channel Data Unit) signal ID using the specified value.
547 *
548 * @param oduSignalId ODU Signal Id
549 * @return match criterion
550 */
551 public static Criterion matchOduSignalId(OduSignalId oduSignalId) {
552 return new OduSignalIdCriterion(oduSignalId);
553 }
554
555 /**
556 * Creates a match on ODU (Optical channel Data Unit) signal Type using the specified value.
557 *
558 * @param signalType ODU Signal Type
559 * @return match criterion
560 */
561 public static Criterion matchOduSignalType(OduSignalType signalType) {
562 return new OduSignalTypeCriterion(signalType);
563 }
564
lishuaia72d44d2015-10-19 17:27:38 +0800565 /**
BitOhenrye330cf02015-11-17 18:59:33 +0800566 * Creates a match on IPv4 destination field using the specified value.
lishuaia72d44d2015-10-19 17:27:38 +0800567 *
BitOhenrye330cf02015-11-17 18:59:33 +0800568 * @param ip ipv4 destination value
lishuaia72d44d2015-10-19 17:27:38 +0800569 * @return match criterion
570 */
571 public static Criterion matchArpTpa(Ip4Address ip) {
572 return new ArpPaCriterion(ip, Type.ARP_TPA);
573 }
574
BitOhenrycc024eb2015-11-10 17:17:36 +0800575 /**
BitOhenry08c72942015-11-18 14:44:29 +0800576 * Creates a match on IPv4 source field using the specified value.
577 *
578 * @param ip ipv4 source value
579 * @return match criterion
580 */
581 public static Criterion matchArpSpa(Ip4Address ip) {
582 return new ArpPaCriterion(ip, Type.ARP_SPA);
583 }
584
585 /**
BitOhenrye330cf02015-11-17 18:59:33 +0800586 * Creates a match on MAC destination field using the specified value.
587 *
588 * @param mac MAC destination value
589 * @return match criterion
590 */
591 public static Criterion matchArpTha(MacAddress mac) {
592 return new ArpHaCriterion(mac, Type.ARP_THA);
593 }
594
595 /**
BitOhenrycc024eb2015-11-10 17:17:36 +0800596 * Creates a match on MAC source field using the specified value.
597 *
598 * @param mac MAC source value
599 * @return match criterion
600 */
BitOhenrye330cf02015-11-17 18:59:33 +0800601 public static Criterion matchArpSha(MacAddress mac) {
602 return new ArpHaCriterion(mac, Type.ARP_SHA);
BitOhenrycc024eb2015-11-10 17:17:36 +0800603 }
604
BitOhenry11620c92015-11-27 08:42:36 +0800605 /**
606 * Creates a match on arp operation type field using the specified value.
607 *
608 * @param arpOp arp operation type value
609 * @return match criterion
610 */
611 public static Criterion matchArpOp(int arpOp) {
612 return new ArpOpCriterion(arpOp, Type.ARP_OP);
613 }
614
Jonathan Hart26a8d952015-12-02 15:16:35 -0800615 /**
Jian Lif1ecf992015-12-02 17:48:54 -0800616 * Creates a match on PBB I-SID field using the specific value.
617 *
618 * @param pbbIsid PBB I-SID
619 * @return match criterion
620 */
621 public static Criterion matchPbbIsid(int pbbIsid) {
622 return new PbbIsidCriterion(pbbIsid);
623 }
624
625 /**
Jonathan Hart26a8d952015-12-02 15:16:35 -0800626 * Creates an extension criterion for the specified extension selector.
627 *
628 * @param extensionSelector extension selector
629 * @param deviceId device ID
Charles Chan14967c22015-12-07 11:11:50 -0800630 * @return match extension criterion
Jonathan Hart26a8d952015-12-02 15:16:35 -0800631 */
Charles Chan14967c22015-12-07 11:11:50 -0800632 public static ExtensionCriterion extension(ExtensionSelector extensionSelector,
Jonathan Hart26a8d952015-12-02 15:16:35 -0800633 DeviceId deviceId) {
634 return new ExtensionCriterion(extensionSelector, deviceId);
635 }
636
637 /**
638 * Creates a dummy criterion.
639 *
640 * @return match criterion
641 */
alshabiba3a476d2015-04-10 14:35:38 -0700642 public static Criterion dummy() {
643 return new DummyCriterion();
644 }
645
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700646 /**
alshabiba3a476d2015-04-10 14:35:38 -0700647 * Dummy Criterion used with @see{FilteringObjective}.
648 */
649 private static class DummyCriterion implements Criterion {
650
651 @Override
652 public Type type() {
653 return Type.DUMMY;
654 }
655 }
tom8bb16062014-09-12 14:47:46 -0700656}