blob: cb153a8b09e4a4825490c925ae12f00812d8af15 [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 /**
Saurav Das9d6c86b2016-02-19 09:01:07 -080089 * Creates a masked match on ETH_DST field using the specified value and mask.
90 *
91 * @param mac MAC address value
92 * @param mask MAC address masking
93 * @return match criterion
94 */
95 public static Criterion matchEthDstMasked(MacAddress mac, MacAddress mask) {
96 return new EthCriterion(mac, mask, Type.ETH_DST_MASKED);
97 }
98
99 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800100 * Creates a match on ETH_SRC field using the specified value. This value
101 * may be a wildcard mask.
102 *
103 * @param mac MAC address value or wildcard mask
104 * @return match criterion
105 */
106 public static Criterion matchEthSrc(MacAddress mac) {
107 return new EthCriterion(mac, Type.ETH_SRC);
108 }
109
110 /**
Saurav Das9d6c86b2016-02-19 09:01:07 -0800111 * Creates a masked match on ETH_SRC field using the specified value and mask.
112 *
113 * @param mac MAC address value
114 * @param mask MAC address masking
115 * @return match criterion
116 */
117 public static Criterion matchEthSrcMasked(MacAddress mac, MacAddress mask) {
118 return new EthCriterion(mac, mask, Type.ETH_SRC_MASKED);
119 }
120
121 /**
alshabib7b795492014-09-16 14:38:39 -0700122 * Creates a match on ETH_TYPE field using the specified value.
123 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800124 * @param ethType eth type value (16 bits unsigned integer)
alshabib7b795492014-09-16 14:38:39 -0700125 * @return match criterion
126 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800127 public static Criterion matchEthType(int ethType) {
alshabib7b795492014-09-16 14:38:39 -0700128 return new EthTypeCriterion(ethType);
129 }
130
131 /**
alshabibcaf1ca22015-06-25 15:18:16 -0700132 * Creates a match on ETH_TYPE field using the specified value.
133 *
134 * @param ethType eth type value
135 * @return match criterion
136 */
137 public static Criterion matchEthType(EthType ethType) {
138 return new EthTypeCriterion(ethType);
139 }
140
141 /**
alshabib7b795492014-09-16 14:38:39 -0700142 * Creates a match on VLAN ID field using the specified value.
143 *
144 * @param vlanId vlan id value
145 * @return match criterion
146 */
Ayaka Koshibea9c199f2014-09-16 16:21:40 -0700147 public static Criterion matchVlanId(VlanId vlanId) {
alshabib7b795492014-09-16 14:38:39 -0700148 return new VlanIdCriterion(vlanId);
149 }
150
151 /**
alshabibfa0dc662016-01-13 11:23:53 -0800152 * Creates a match on the inner VLAN ID field using the specified value.
153 *
154 * @param vlanId vlan id value
155 * @return match criterion
156 */
157 public static Criterion matchInnerVlanId(VlanId vlanId) {
158 return new VlanIdCriterion(vlanId, Type.INNER_VLAN_VID);
159 }
160
161 /**
alshabib7b795492014-09-16 14:38:39 -0700162 * Creates a match on VLAN PCP field using the specified value.
163 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800164 * @param vlanPcp vlan pcp value (3 bits)
alshabib7b795492014-09-16 14:38:39 -0700165 * @return match criterion
166 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800167 public static Criterion matchVlanPcp(byte vlanPcp) {
alshabib7b795492014-09-16 14:38:39 -0700168 return new VlanPcpCriterion(vlanPcp);
169 }
170
171 /**
alshabibfa0dc662016-01-13 11:23:53 -0800172 * Creates a match on the inner VLAN PCP field using the specified value.
173 *
174 * @param vlanPcp vlan pcp value (3 bits)
175 * @return match criterion
176 */
177 public static Criterion matchInnerVlanPcp(byte vlanPcp) {
178 return new VlanPcpCriterion(vlanPcp, Type.INNER_VLAN_PCP);
179 }
180
181 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800182 * Creates a match on IP DSCP field using the specified value.
183 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800184 * @param ipDscp ip dscp value (6 bits)
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800185 * @return match criterion
186 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800187 public static Criterion matchIPDscp(byte ipDscp) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800188 return new IPDscpCriterion(ipDscp);
189 }
190
191 /**
192 * Creates a match on IP ECN field using the specified value.
193 *
Pavlin Radoslavovab8553a2015-02-20 14:13:50 -0800194 * @param ipEcn ip ecn value (2 bits)
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800195 * @return match criterion
196 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800197 public static Criterion matchIPEcn(byte ipEcn) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800198 return new IPEcnCriterion(ipEcn);
199 }
200
201 /**
alshabib7b795492014-09-16 14:38:39 -0700202 * Creates a match on IP proto field using the specified value.
203 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800204 * @param proto ip protocol value (8 bits unsigned integer)
alshabib7b795492014-09-16 14:38:39 -0700205 * @return match criterion
206 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800207 public static Criterion matchIPProtocol(short proto) {
alshabib7b795492014-09-16 14:38:39 -0700208 return new IPProtocolCriterion(proto);
209 }
210
211 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800212 * Creates a match on IPv4 source field using the specified value.
alshabib7b795492014-09-16 14:38:39 -0700213 *
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800214 * @param ip ipv4 source value
alshabib7b795492014-09-16 14:38:39 -0700215 * @return match criterion
216 */
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700217 public static Criterion matchIPSrc(IpPrefix ip) {
alshabib7b795492014-09-16 14:38:39 -0700218 return new IPCriterion(ip, Type.IPV4_SRC);
219 }
220
221 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800222 * Creates a match on IPv4 destination field using the specified value.
alshabib7b795492014-09-16 14:38:39 -0700223 *
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800224 * @param ip ipv4 source value
alshabib7b795492014-09-16 14:38:39 -0700225 * @return match criterion
226 */
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700227 public static Criterion matchIPDst(IpPrefix ip) {
alshabib7b795492014-09-16 14:38:39 -0700228 return new IPCriterion(ip, Type.IPV4_DST);
alshabib369d2942014-09-12 17:59:35 -0700229 }
230
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700231 /**
232 * Creates a match on TCP source port field using the specified value.
233 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700234 * @param tcpPort TCP source port
235 * @return match criterion
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700236 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700237 public static Criterion matchTcpSrc(TpPort tcpPort) {
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700238 return new TcpPortCriterion(tcpPort, Type.TCP_SRC);
239 }
240
241 /**
242 * Creates a match on TCP destination port field using the specified value.
243 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700244 * @param tcpPort TCP destination port
245 * @return match criterion
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700246 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700247 public static Criterion matchTcpDst(TpPort tcpPort) {
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700248 return new TcpPortCriterion(tcpPort, Type.TCP_DST);
249 }
alshabib369d2942014-09-12 17:59:35 -0700250
Marc De Leenheer49087752014-10-23 13:54:09 -0700251 /**
Jian Li2748b2c2015-11-30 11:43:09 -0800252 * Creates a match on TCP flags using the specified value.
253 *
254 * @param flags TCP flags
255 * @return match criterion
256 */
257 public static Criterion matchTcpFlags(int flags) {
258 return new TcpFlagsCriterion(flags);
259 }
260
261 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800262 * Creates a match on UDP source port field using the specified value.
263 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700264 * @param udpPort UDP source port
265 * @return match criterion
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800266 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700267 public static Criterion matchUdpSrc(TpPort udpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800268 return new UdpPortCriterion(udpPort, Type.UDP_SRC);
269 }
270
271 /**
272 * Creates a match on UDP destination port field using the specified value.
273 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700274 * @param udpPort UDP destination port
275 * @return match criterion
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800276 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700277 public static Criterion matchUdpDst(TpPort udpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800278 return new UdpPortCriterion(udpPort, Type.UDP_DST);
279 }
280
281 /**
282 * Creates a match on SCTP source port field using the specified value.
283 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700284 * @param sctpPort SCTP source port
285 * @return match criterion
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800286 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700287 public static Criterion matchSctpSrc(TpPort sctpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800288 return new SctpPortCriterion(sctpPort, Type.SCTP_SRC);
289 }
290
291 /**
292 * Creates a match on SCTP destination port field using the specified
293 * value.
294 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700295 * @param sctpPort SCTP destination port
296 * @return match criterion
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800297 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700298 public static Criterion matchSctpDst(TpPort sctpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800299 return new SctpPortCriterion(sctpPort, Type.SCTP_DST);
300 }
301
302 /**
303 * Creates a match on ICMP type field using the specified value.
304 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800305 * @param icmpType ICMP type (8 bits unsigned integer)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800306 * @return match criterion
307 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800308 public static Criterion matchIcmpType(short icmpType) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800309 return new IcmpTypeCriterion(icmpType);
310 }
311
312 /**
313 * Creates a match on ICMP code field using the specified value.
314 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800315 * @param icmpCode ICMP code (8 bits unsigned integer)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800316 * @return match criterion
317 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800318 public static Criterion matchIcmpCode(short icmpCode) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800319 return new IcmpCodeCriterion(icmpCode);
320 }
321
322 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800323 * Creates a match on IPv6 source field using the specified value.
324 *
325 * @param ip ipv6 source value
326 * @return match criterion
327 */
328 public static Criterion matchIPv6Src(IpPrefix ip) {
329 return new IPCriterion(ip, Type.IPV6_SRC);
330 }
331
332 /**
333 * Creates a match on IPv6 destination field using the specified value.
334 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800335 * @param ip ipv6 destination value
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800336 * @return match criterion
337 */
338 public static Criterion matchIPv6Dst(IpPrefix ip) {
339 return new IPCriterion(ip, Type.IPV6_DST);
340 }
341
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800342 /**
343 * Creates a match on IPv6 flow label field using the specified value.
344 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800345 * @param flowLabel IPv6 flow label (20 bits)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800346 * @return match criterion
347 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800348 public static Criterion matchIPv6FlowLabel(int flowLabel) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800349 return new IPv6FlowLabelCriterion(flowLabel);
350 }
351
352 /**
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800353 * Creates a match on ICMPv6 type field using the specified value.
354 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800355 * @param icmpv6Type ICMPv6 type (8 bits unsigned integer)
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800356 * @return match criterion
357 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800358 public static Criterion matchIcmpv6Type(short icmpv6Type) {
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800359 return new Icmpv6TypeCriterion(icmpv6Type);
360 }
361
362 /**
363 * Creates a match on ICMPv6 code field using the specified value.
364 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800365 * @param icmpv6Code ICMPv6 code (8 bits unsigned integer)
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800366 * @return match criterion
367 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800368 public static Criterion matchIcmpv6Code(short icmpv6Code) {
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800369 return new Icmpv6CodeCriterion(icmpv6Code);
370 }
371
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800372 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800373 * Creates a match on IPv6 Neighbor Discovery target address using the
374 * specified value.
375 *
376 * @param targetAddress IPv6 Neighbor Discovery target address
377 * @return match criterion
378 */
379 public static Criterion matchIPv6NDTargetAddress(Ip6Address targetAddress) {
380 return new IPv6NDTargetAddressCriterion(targetAddress);
381 }
382
383 /**
384 * Creates a match on IPv6 Neighbor Discovery source link-layer address
385 * using the specified value.
386 *
387 * @param mac IPv6 Neighbor Discovery source link-layer address
388 * @return match criterion
389 */
390 public static Criterion matchIPv6NDSourceLinkLayerAddress(MacAddress mac) {
391 return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_SLL);
392 }
393
394 /**
395 * Creates a match on IPv6 Neighbor Discovery target link-layer address
396 * using the specified value.
397 *
398 * @param mac IPv6 Neighbor Discovery target link-layer address
399 * @return match criterion
400 */
401 public static Criterion matchIPv6NDTargetLinkLayerAddress(MacAddress mac) {
402 return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_TLL);
403 }
404
405 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800406 * Creates a match on MPLS label.
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800407 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800408 * @param mplsLabel MPLS label (20 bits)
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800409 * @return match criterion
410 */
Michele Santuari4b6019e2014-12-19 11:31:45 +0100411 public static Criterion matchMplsLabel(MplsLabel mplsLabel) {
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800412 return new MplsCriterion(mplsLabel);
413 }
414
415 /**
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700416 * Creates a match on MPLS Bottom-of-Stack indicator bit.
417 *
418 * @param mplsBos boolean value indicating true (BOS=1) or false (BOS=0)
419 * @return match criterion
420 */
Jian Li5c4cf1e2015-11-30 13:10:46 -0800421 public static Criterion matchMplsBos(boolean mplsBos) {
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700422 return new MplsBosCriterion(mplsBos);
423 }
424
425 /**
Jian Lifd44dc92015-11-26 16:32:32 -0800426 * Creates a match on MPLS TC.
427 *
428 * @param mplsTc MPLS TC (3 bits)
429 * @return match criterion
430 */
431 public static Criterion matchMplsTc(byte mplsTc) {
432 return new MplsTcCriterion(mplsTc);
433 }
434
435 /**
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700436 * Creates a match on Tunnel ID.
437 *
438 * @param tunnelId Tunnel ID (64 bits)
439 * @return match criterion
440 */
441 public static Criterion matchTunnelId(long tunnelId) {
442 return new TunnelIdCriterion(tunnelId);
443 }
444
445 /**
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800446 * Creates a match on IPv6 Extension Header pseudo-field fiags.
447 * Those are defined in Criterion.IPv6ExthdrFlags.
448 *
449 * @param exthdrFlags IPv6 Extension Header pseudo-field flags (16 bits)
450 * @return match criterion
451 */
452 public static Criterion matchIPv6ExthdrFlags(int exthdrFlags) {
453 return new IPv6ExthdrFlagsCriterion(exthdrFlags);
454 }
455
456 /**
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -0700457 * Creates a match on lambda using the specified value.
458 *
459 * @param lambda lambda
460 * @return match criterion
461 */
462 public static Criterion matchLambda(Lambda lambda) {
Sho SHIMIZUefc2e282015-05-04 15:26:23 -0700463 if (lambda instanceof IndexedLambda) {
464 return new IndexedLambdaCriterion((IndexedLambda) lambda);
465 } else if (lambda instanceof OchSignal) {
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -0700466 return new OchSignalCriterion((OchSignal) lambda);
467 } else {
468 throw new UnsupportedOperationException(String.format("Unsupported type of Lambda: %s", lambda));
469 }
470 }
471
472 /**
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -0700473 * Create a match on OCh (Optical Channel) signal type.
474 *
475 * @param signalType OCh signal type
476 * @return match criterion
477 */
478 public static Criterion matchOchSignalType(OchSignalType signalType) {
479 return new OchSignalTypeCriterion(signalType);
480 }
481
Yafit Hadar52d81552015-10-07 12:26:52 +0300482 /**
483 * Creates a match on ODU (Optical channel Data Unit) signal ID using the specified value.
484 *
485 * @param oduSignalId ODU Signal Id
486 * @return match criterion
487 */
488 public static Criterion matchOduSignalId(OduSignalId oduSignalId) {
489 return new OduSignalIdCriterion(oduSignalId);
490 }
491
492 /**
493 * Creates a match on ODU (Optical channel Data Unit) signal Type using the specified value.
494 *
495 * @param signalType ODU Signal Type
496 * @return match criterion
497 */
498 public static Criterion matchOduSignalType(OduSignalType signalType) {
499 return new OduSignalTypeCriterion(signalType);
500 }
501
lishuaia72d44d2015-10-19 17:27:38 +0800502 /**
BitOhenrye330cf02015-11-17 18:59:33 +0800503 * Creates a match on IPv4 destination field using the specified value.
lishuaia72d44d2015-10-19 17:27:38 +0800504 *
BitOhenrye330cf02015-11-17 18:59:33 +0800505 * @param ip ipv4 destination value
lishuaia72d44d2015-10-19 17:27:38 +0800506 * @return match criterion
507 */
508 public static Criterion matchArpTpa(Ip4Address ip) {
509 return new ArpPaCriterion(ip, Type.ARP_TPA);
510 }
511
BitOhenrycc024eb2015-11-10 17:17:36 +0800512 /**
BitOhenry08c72942015-11-18 14:44:29 +0800513 * Creates a match on IPv4 source field using the specified value.
514 *
515 * @param ip ipv4 source value
516 * @return match criterion
517 */
518 public static Criterion matchArpSpa(Ip4Address ip) {
519 return new ArpPaCriterion(ip, Type.ARP_SPA);
520 }
521
522 /**
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
BitOhenry11620c92015-11-27 08:42:36 +0800542 /**
543 * Creates a match on arp operation type field using the specified value.
544 *
545 * @param arpOp arp operation type value
546 * @return match criterion
547 */
548 public static Criterion matchArpOp(int arpOp) {
549 return new ArpOpCriterion(arpOp, Type.ARP_OP);
550 }
551
Jonathan Hart26a8d952015-12-02 15:16:35 -0800552 /**
Jian Lif1ecf992015-12-02 17:48:54 -0800553 * Creates a match on PBB I-SID field using the specific value.
554 *
555 * @param pbbIsid PBB I-SID
556 * @return match criterion
557 */
558 public static Criterion matchPbbIsid(int pbbIsid) {
559 return new PbbIsidCriterion(pbbIsid);
560 }
561
562 /**
Jonathan Hart26a8d952015-12-02 15:16:35 -0800563 * Creates an extension criterion for the specified extension selector.
564 *
565 * @param extensionSelector extension selector
566 * @param deviceId device ID
Charles Chan14967c22015-12-07 11:11:50 -0800567 * @return match extension criterion
Jonathan Hart26a8d952015-12-02 15:16:35 -0800568 */
Charles Chan14967c22015-12-07 11:11:50 -0800569 public static ExtensionCriterion extension(ExtensionSelector extensionSelector,
Jonathan Hart26a8d952015-12-02 15:16:35 -0800570 DeviceId deviceId) {
571 return new ExtensionCriterion(extensionSelector, deviceId);
572 }
573
574 /**
575 * Creates a dummy criterion.
576 *
577 * @return match criterion
578 */
alshabiba3a476d2015-04-10 14:35:38 -0700579 public static Criterion dummy() {
580 return new DummyCriterion();
581 }
582
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700583 /**
alshabiba3a476d2015-04-10 14:35:38 -0700584 * Dummy Criterion used with @see{FilteringObjective}.
585 */
586 private static class DummyCriterion implements Criterion {
587
588 @Override
589 public Type type() {
590 return Type.DUMMY;
591 }
592 }
tom8bb16062014-09-12 14:47:46 -0700593}