blob: b942132d3234a8b7fda5317239b6707a428bd480 [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 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 /**
241 * Creates a match on TCP destination port field using the specified value.
242 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700243 * @param tcpPort TCP destination port
244 * @return match criterion
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700245 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700246 public static Criterion matchTcpDst(TpPort tcpPort) {
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700247 return new TcpPortCriterion(tcpPort, Type.TCP_DST);
248 }
alshabib369d2942014-09-12 17:59:35 -0700249
Marc De Leenheer49087752014-10-23 13:54:09 -0700250 /**
Jian Li2748b2c2015-11-30 11:43:09 -0800251 * Creates a match on TCP flags using the specified value.
252 *
253 * @param flags TCP flags
254 * @return match criterion
255 */
256 public static Criterion matchTcpFlags(int flags) {
257 return new TcpFlagsCriterion(flags);
258 }
259
260 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800261 * Creates a match on UDP source port field using the specified value.
262 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700263 * @param udpPort UDP source port
264 * @return match criterion
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800265 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700266 public static Criterion matchUdpSrc(TpPort udpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800267 return new UdpPortCriterion(udpPort, Type.UDP_SRC);
268 }
269
270 /**
271 * Creates a match on UDP destination port field using the specified value.
272 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700273 * @param udpPort UDP destination port
274 * @return match criterion
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800275 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700276 public static Criterion matchUdpDst(TpPort udpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800277 return new UdpPortCriterion(udpPort, Type.UDP_DST);
278 }
279
280 /**
281 * Creates a match on SCTP source port field using the specified value.
282 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700283 * @param sctpPort SCTP source port
284 * @return match criterion
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800285 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700286 public static Criterion matchSctpSrc(TpPort sctpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800287 return new SctpPortCriterion(sctpPort, Type.SCTP_SRC);
288 }
289
290 /**
291 * Creates a match on SCTP destination port field using the specified
292 * value.
293 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700294 * @param sctpPort SCTP destination port
295 * @return match criterion
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800296 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700297 public static Criterion matchSctpDst(TpPort sctpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800298 return new SctpPortCriterion(sctpPort, Type.SCTP_DST);
299 }
300
301 /**
302 * Creates a match on ICMP type field using the specified value.
303 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800304 * @param icmpType ICMP type (8 bits unsigned integer)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800305 * @return match criterion
306 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800307 public static Criterion matchIcmpType(short icmpType) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800308 return new IcmpTypeCriterion(icmpType);
309 }
310
311 /**
312 * Creates a match on ICMP code field using the specified value.
313 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800314 * @param icmpCode ICMP code (8 bits unsigned integer)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800315 * @return match criterion
316 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800317 public static Criterion matchIcmpCode(short icmpCode) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800318 return new IcmpCodeCriterion(icmpCode);
319 }
320
321 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800322 * Creates a match on IPv6 source field using the specified value.
323 *
324 * @param ip ipv6 source value
325 * @return match criterion
326 */
327 public static Criterion matchIPv6Src(IpPrefix ip) {
328 return new IPCriterion(ip, Type.IPV6_SRC);
329 }
330
331 /**
332 * Creates a match on IPv6 destination field using the specified value.
333 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800334 * @param ip ipv6 destination value
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800335 * @return match criterion
336 */
337 public static Criterion matchIPv6Dst(IpPrefix ip) {
338 return new IPCriterion(ip, Type.IPV6_DST);
339 }
340
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800341 /**
342 * Creates a match on IPv6 flow label field using the specified value.
343 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800344 * @param flowLabel IPv6 flow label (20 bits)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800345 * @return match criterion
346 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800347 public static Criterion matchIPv6FlowLabel(int flowLabel) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800348 return new IPv6FlowLabelCriterion(flowLabel);
349 }
350
351 /**
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800352 * Creates a match on ICMPv6 type field using the specified value.
353 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800354 * @param icmpv6Type ICMPv6 type (8 bits unsigned integer)
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800355 * @return match criterion
356 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800357 public static Criterion matchIcmpv6Type(short icmpv6Type) {
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800358 return new Icmpv6TypeCriterion(icmpv6Type);
359 }
360
361 /**
362 * Creates a match on ICMPv6 code field using the specified value.
363 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800364 * @param icmpv6Code ICMPv6 code (8 bits unsigned integer)
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800365 * @return match criterion
366 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800367 public static Criterion matchIcmpv6Code(short icmpv6Code) {
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800368 return new Icmpv6CodeCriterion(icmpv6Code);
369 }
370
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800371 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800372 * Creates a match on IPv6 Neighbor Discovery target address using the
373 * specified value.
374 *
375 * @param targetAddress IPv6 Neighbor Discovery target address
376 * @return match criterion
377 */
378 public static Criterion matchIPv6NDTargetAddress(Ip6Address targetAddress) {
379 return new IPv6NDTargetAddressCriterion(targetAddress);
380 }
381
382 /**
383 * Creates a match on IPv6 Neighbor Discovery source link-layer address
384 * using the specified value.
385 *
386 * @param mac IPv6 Neighbor Discovery source link-layer address
387 * @return match criterion
388 */
389 public static Criterion matchIPv6NDSourceLinkLayerAddress(MacAddress mac) {
390 return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_SLL);
391 }
392
393 /**
394 * Creates a match on IPv6 Neighbor Discovery target link-layer address
395 * using the specified value.
396 *
397 * @param mac IPv6 Neighbor Discovery target link-layer address
398 * @return match criterion
399 */
400 public static Criterion matchIPv6NDTargetLinkLayerAddress(MacAddress mac) {
401 return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_TLL);
402 }
403
404 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800405 * Creates a match on MPLS label.
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800406 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800407 * @param mplsLabel MPLS label (20 bits)
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800408 * @return match criterion
409 */
Michele Santuari4b6019e2014-12-19 11:31:45 +0100410 public static Criterion matchMplsLabel(MplsLabel mplsLabel) {
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800411 return new MplsCriterion(mplsLabel);
412 }
413
414 /**
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700415 * Creates a match on MPLS Bottom-of-Stack indicator bit.
416 *
417 * @param mplsBos boolean value indicating true (BOS=1) or false (BOS=0)
418 * @return match criterion
419 */
Jian Li5c4cf1e2015-11-30 13:10:46 -0800420 public static Criterion matchMplsBos(boolean mplsBos) {
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700421 return new MplsBosCriterion(mplsBos);
422 }
423
424 /**
Jian Lifd44dc92015-11-26 16:32:32 -0800425 * Creates a match on MPLS TC.
426 *
427 * @param mplsTc MPLS TC (3 bits)
428 * @return match criterion
429 */
430 public static Criterion matchMplsTc(byte mplsTc) {
431 return new MplsTcCriterion(mplsTc);
432 }
433
434 /**
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700435 * Creates a match on Tunnel ID.
436 *
437 * @param tunnelId Tunnel ID (64 bits)
438 * @return match criterion
439 */
440 public static Criterion matchTunnelId(long tunnelId) {
441 return new TunnelIdCriterion(tunnelId);
442 }
443
444 /**
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800445 * Creates a match on IPv6 Extension Header pseudo-field fiags.
446 * Those are defined in Criterion.IPv6ExthdrFlags.
447 *
448 * @param exthdrFlags IPv6 Extension Header pseudo-field flags (16 bits)
449 * @return match criterion
450 */
451 public static Criterion matchIPv6ExthdrFlags(int exthdrFlags) {
452 return new IPv6ExthdrFlagsCriterion(exthdrFlags);
453 }
454
455 /**
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -0700456 * Creates a match on lambda using the specified value.
457 *
458 * @param lambda lambda
459 * @return match criterion
460 */
461 public static Criterion matchLambda(Lambda lambda) {
Sho SHIMIZU06810162016-02-24 12:52:32 -0800462 if (lambda instanceof OchSignal) {
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -0700463 return new OchSignalCriterion((OchSignal) lambda);
464 } else {
465 throw new UnsupportedOperationException(String.format("Unsupported type of Lambda: %s", lambda));
466 }
467 }
468
469 /**
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -0700470 * Create a match on OCh (Optical Channel) signal type.
471 *
472 * @param signalType OCh signal type
473 * @return match criterion
474 */
475 public static Criterion matchOchSignalType(OchSignalType signalType) {
476 return new OchSignalTypeCriterion(signalType);
477 }
478
Yafit Hadar52d81552015-10-07 12:26:52 +0300479 /**
480 * Creates a match on ODU (Optical channel Data Unit) signal ID using the specified value.
481 *
482 * @param oduSignalId ODU Signal Id
483 * @return match criterion
484 */
485 public static Criterion matchOduSignalId(OduSignalId oduSignalId) {
486 return new OduSignalIdCriterion(oduSignalId);
487 }
488
489 /**
490 * Creates a match on ODU (Optical channel Data Unit) signal Type using the specified value.
491 *
492 * @param signalType ODU Signal Type
493 * @return match criterion
494 */
495 public static Criterion matchOduSignalType(OduSignalType signalType) {
496 return new OduSignalTypeCriterion(signalType);
497 }
498
lishuaia72d44d2015-10-19 17:27:38 +0800499 /**
BitOhenrye330cf02015-11-17 18:59:33 +0800500 * Creates a match on IPv4 destination field using the specified value.
lishuaia72d44d2015-10-19 17:27:38 +0800501 *
BitOhenrye330cf02015-11-17 18:59:33 +0800502 * @param ip ipv4 destination value
lishuaia72d44d2015-10-19 17:27:38 +0800503 * @return match criterion
504 */
505 public static Criterion matchArpTpa(Ip4Address ip) {
506 return new ArpPaCriterion(ip, Type.ARP_TPA);
507 }
508
BitOhenrycc024eb2015-11-10 17:17:36 +0800509 /**
BitOhenry08c72942015-11-18 14:44:29 +0800510 * Creates a match on IPv4 source field using the specified value.
511 *
512 * @param ip ipv4 source value
513 * @return match criterion
514 */
515 public static Criterion matchArpSpa(Ip4Address ip) {
516 return new ArpPaCriterion(ip, Type.ARP_SPA);
517 }
518
519 /**
BitOhenrye330cf02015-11-17 18:59:33 +0800520 * Creates a match on MAC destination field using the specified value.
521 *
522 * @param mac MAC destination value
523 * @return match criterion
524 */
525 public static Criterion matchArpTha(MacAddress mac) {
526 return new ArpHaCriterion(mac, Type.ARP_THA);
527 }
528
529 /**
BitOhenrycc024eb2015-11-10 17:17:36 +0800530 * Creates a match on MAC source field using the specified value.
531 *
532 * @param mac MAC source value
533 * @return match criterion
534 */
BitOhenrye330cf02015-11-17 18:59:33 +0800535 public static Criterion matchArpSha(MacAddress mac) {
536 return new ArpHaCriterion(mac, Type.ARP_SHA);
BitOhenrycc024eb2015-11-10 17:17:36 +0800537 }
538
BitOhenry11620c92015-11-27 08:42:36 +0800539 /**
540 * Creates a match on arp operation type field using the specified value.
541 *
542 * @param arpOp arp operation type value
543 * @return match criterion
544 */
545 public static Criterion matchArpOp(int arpOp) {
546 return new ArpOpCriterion(arpOp, Type.ARP_OP);
547 }
548
Jonathan Hart26a8d952015-12-02 15:16:35 -0800549 /**
Jian Lif1ecf992015-12-02 17:48:54 -0800550 * Creates a match on PBB I-SID field using the specific value.
551 *
552 * @param pbbIsid PBB I-SID
553 * @return match criterion
554 */
555 public static Criterion matchPbbIsid(int pbbIsid) {
556 return new PbbIsidCriterion(pbbIsid);
557 }
558
559 /**
Jonathan Hart26a8d952015-12-02 15:16:35 -0800560 * Creates an extension criterion for the specified extension selector.
561 *
562 * @param extensionSelector extension selector
563 * @param deviceId device ID
Charles Chan14967c22015-12-07 11:11:50 -0800564 * @return match extension criterion
Jonathan Hart26a8d952015-12-02 15:16:35 -0800565 */
Charles Chan14967c22015-12-07 11:11:50 -0800566 public static ExtensionCriterion extension(ExtensionSelector extensionSelector,
Jonathan Hart26a8d952015-12-02 15:16:35 -0800567 DeviceId deviceId) {
568 return new ExtensionCriterion(extensionSelector, deviceId);
569 }
570
571 /**
572 * Creates a dummy criterion.
573 *
574 * @return match criterion
575 */
alshabiba3a476d2015-04-10 14:35:38 -0700576 public static Criterion dummy() {
577 return new DummyCriterion();
578 }
579
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700580 /**
alshabiba3a476d2015-04-10 14:35:38 -0700581 * Dummy Criterion used with @see{FilteringObjective}.
582 */
583 private static class DummyCriterion implements Criterion {
584
585 @Override
586 public Type type() {
587 return Type.DUMMY;
588 }
589 }
tom8bb16062014-09-12 14:47:46 -0700590}