blob: 6db66e426a4916984a9ca0963050979a4f0022e1 [file] [log] [blame]
Ray Milkeydb358082015-01-13 16:34:38 -08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * 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
7 *
8 * 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.
15 */
16package org.onosproject.codec.impl;
17
18import org.hamcrest.Description;
19import org.hamcrest.TypeSafeDiagnosingMatcher;
Ray Milkeydb358082015-01-13 16:34:38 -080020import org.onosproject.net.flow.criteria.Criterion;
21
22import com.fasterxml.jackson.databind.JsonNode;
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -070023import org.onosproject.net.flow.criteria.EthCriterion;
24import org.onosproject.net.flow.criteria.EthTypeCriterion;
25import org.onosproject.net.flow.criteria.IPCriterion;
26import org.onosproject.net.flow.criteria.IPDscpCriterion;
27import org.onosproject.net.flow.criteria.IPEcnCriterion;
28import org.onosproject.net.flow.criteria.IPProtocolCriterion;
29import org.onosproject.net.flow.criteria.IPv6ExthdrFlagsCriterion;
30import org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion;
31import org.onosproject.net.flow.criteria.IPv6NDLinkLayerAddressCriterion;
32import org.onosproject.net.flow.criteria.IPv6NDTargetAddressCriterion;
33import org.onosproject.net.flow.criteria.IcmpCodeCriterion;
34import org.onosproject.net.flow.criteria.IcmpTypeCriterion;
35import org.onosproject.net.flow.criteria.Icmpv6CodeCriterion;
36import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion;
37import org.onosproject.net.flow.criteria.LambdaCriterion;
38import org.onosproject.net.flow.criteria.MetadataCriterion;
39import org.onosproject.net.flow.criteria.MplsCriterion;
40import org.onosproject.net.flow.criteria.OpticalSignalTypeCriterion;
41import org.onosproject.net.flow.criteria.PortCriterion;
42import org.onosproject.net.flow.criteria.SctpPortCriterion;
43import org.onosproject.net.flow.criteria.TcpPortCriterion;
44import org.onosproject.net.flow.criteria.UdpPortCriterion;
45import org.onosproject.net.flow.criteria.VlanIdCriterion;
46import org.onosproject.net.flow.criteria.VlanPcpCriterion;
Ray Milkeydb358082015-01-13 16:34:38 -080047
48/**
49 * Hamcrest matcher for criterion objects.
50 */
Ray Milkey46670a82015-02-08 17:57:17 -080051public final class CriterionJsonMatcher extends
52 TypeSafeDiagnosingMatcher<JsonNode> {
Ray Milkeydb358082015-01-13 16:34:38 -080053
54 final Criterion criterion;
Ray Milkey46670a82015-02-08 17:57:17 -080055 Description description;
56 JsonNode jsonCriterion;
Ray Milkeydb358082015-01-13 16:34:38 -080057
Ray Milkey46670a82015-02-08 17:57:17 -080058 /**
59 * Constructs a matcher object.
60 *
61 * @param criterionValue criterion to match
62 */
Ray Milkeydb358082015-01-13 16:34:38 -080063 private CriterionJsonMatcher(Criterion criterionValue) {
64 criterion = criterionValue;
65 }
66
Ray Milkey46670a82015-02-08 17:57:17 -080067 /**
68 * Factory to allocate an criterion matcher.
69 *
70 * @param criterion criterion object we are looking for
71 * @return matcher
72 */
73 public static CriterionJsonMatcher matchesCriterion(Criterion criterion) {
74 return new CriterionJsonMatcher(criterion);
75 }
76
77 /**
78 * Matches a port criterion object.
79 *
80 * @param criterion criterion to match
81 * @return true if the JSON matches the criterion, false otherwise.
82 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -070083 private boolean matchCriterion(PortCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -080084 final long port = criterion.port().toLong();
85 final long jsonPort = jsonCriterion.get("port").asLong();
86 if (port != jsonPort) {
87 description.appendText("port was " + Long.toString(jsonPort));
88 return false;
89 }
90 return true;
91 }
92
93 /**
94 * Matches a metadata criterion object.
95 *
96 * @param criterion criterion to match
97 * @return true if the JSON matches the criterion, false otherwise.
98 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -070099 private boolean matchCriterion(MetadataCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800100 final long metadata = criterion.metadata();
101 final long jsonMetadata = jsonCriterion.get("metadata").asLong();
102 if (metadata != jsonMetadata) {
103 description.appendText("metadata was "
104 + Long.toString(jsonMetadata));
105 return false;
106 }
107 return true;
108 }
109
110 /**
111 * Matches an eth criterion object.
112 *
113 * @param criterion criterion to match
114 * @return true if the JSON matches the criterion, false otherwise.
115 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700116 private boolean matchCriterion(EthCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800117 final String mac = criterion.mac().toString();
118 final String jsonMac = jsonCriterion.get("mac").textValue();
119 if (!mac.equals(jsonMac)) {
120 description.appendText("mac was " + jsonMac);
121 return false;
122 }
123 return true;
124 }
125
126 /**
127 * Matches an eth type criterion object.
128 *
129 * @param criterion criterion to match
130 * @return true if the JSON matches the criterion, false otherwise.
131 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700132 private boolean matchCriterion(EthTypeCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800133 final int ethType = criterion.ethType();
134 final int jsonEthType = jsonCriterion.get("ethType").intValue();
135 if (ethType != jsonEthType) {
136 description.appendText("ethType was "
137 + Integer.toString(jsonEthType));
138 return false;
139 }
140 return true;
141 }
142
143 /**
144 * Matches a VLAN ID criterion object.
145 *
146 * @param criterion criterion to match
147 * @return true if the JSON matches the criterion, false otherwise.
148 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700149 private boolean matchCriterion(VlanIdCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800150 final short vlanId = criterion.vlanId().toShort();
151 final short jsonVlanId = jsonCriterion.get("vlanId").shortValue();
152 if (vlanId != jsonVlanId) {
153 description.appendText("vlanId was " + Short.toString(jsonVlanId));
154 return false;
155 }
156 return true;
157 }
158
159 /**
160 * Matches a VLAN PCP criterion object.
161 *
162 * @param criterion criterion to match
163 * @return true if the JSON matches the criterion, false otherwise.
164 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700165 private boolean matchCriterion(VlanPcpCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800166 final byte priority = criterion.priority();
167 final byte jsonPriority =
168 (byte) jsonCriterion.get("priority").shortValue();
169 if (priority != jsonPriority) {
170 description.appendText("priority was " + Byte.toString(jsonPriority));
171 return false;
172 }
173 return true;
174 }
175
176 /**
177 * Matches an IP DSCP criterion object.
178 *
179 * @param criterion criterion to match
180 * @return true if the JSON matches the criterion, false otherwise.
181 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700182 private boolean matchCriterion(IPDscpCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800183 final byte ipDscp = criterion.ipDscp();
184 final byte jsonIpDscp = (byte) jsonCriterion.get("ipDscp").shortValue();
185 if (ipDscp != jsonIpDscp) {
186 description.appendText("IP DSCP was " + Byte.toString(jsonIpDscp));
187 return false;
188 }
189 return true;
190 }
191
192 /**
193 * Matches an IP ECN criterion object.
194 *
195 * @param criterion criterion to match
196 * @return true if the JSON matches the criterion, false otherwise.
197 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700198 private boolean matchCriterion(IPEcnCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800199 final byte ipEcn = criterion.ipEcn();
200 final byte jsonIpEcn = (byte) jsonCriterion.get("ipEcn").shortValue();
201 if (ipEcn != jsonIpEcn) {
202 description.appendText("IP ECN was " + Byte.toString(jsonIpEcn));
203 return false;
204 }
205 return true;
206 }
207
208 /**
209 * Matches an IP protocol criterion object.
210 *
211 * @param criterion criterion to match
212 * @return true if the JSON matches the criterion, false otherwise.
213 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700214 private boolean matchCriterion(IPProtocolCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800215 final short protocol = criterion.protocol();
216 final short jsonProtocol = jsonCriterion.get("protocol").shortValue();
217 if (protocol != jsonProtocol) {
218 description.appendText("protocol was "
219 + Short.toString(jsonProtocol));
220 return false;
221 }
222 return true;
223 }
224
225 /**
226 * Matches an IP address criterion object.
227 *
228 * @param criterion criterion to match
229 * @return true if the JSON matches the criterion, false otherwise.
230 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700231 private boolean matchCriterion(IPCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800232 final String ip = criterion.ip().toString();
233 final String jsonIp = jsonCriterion.get("ip").textValue();
234 if (!ip.equals(jsonIp)) {
235 description.appendText("ip was " + jsonIp);
236 return false;
237 }
238 return true;
239 }
240
241 /**
242 * Matches a TCP port criterion object.
243 *
244 * @param criterion criterion to match
245 * @return true if the JSON matches the criterion, false otherwise.
246 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700247 private boolean matchCriterion(TcpPortCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800248 final int tcpPort = criterion.tcpPort();
249 final int jsonTcpPort = jsonCriterion.get("tcpPort").intValue();
250 if (tcpPort != jsonTcpPort) {
251 description.appendText("tcp port was "
252 + Integer.toString(jsonTcpPort));
253 return false;
254 }
255 return true;
256 }
257
258 /**
259 * Matches a UDP port criterion object.
260 *
261 * @param criterion criterion to match
262 * @return true if the JSON matches the criterion, false otherwise.
263 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700264 private boolean matchCriterion(UdpPortCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800265 final int udpPort = criterion.udpPort();
266 final int jsonUdpPort = jsonCriterion.get("udpPort").intValue();
267 if (udpPort != jsonUdpPort) {
268 description.appendText("udp port was "
269 + Integer.toString(jsonUdpPort));
270 return false;
271 }
272 return true;
273 }
274
275 /**
276 * Matches an SCTP port criterion object.
277 *
278 * @param criterion criterion to match
279 * @return true if the JSON matches the criterion, false otherwise.
280 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700281 private boolean matchCriterion(SctpPortCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800282 final int sctpPort = criterion.sctpPort();
283 final int jsonSctpPort = jsonCriterion.get("sctpPort").intValue();
284 if (sctpPort != jsonSctpPort) {
285 description.appendText("sctp port was "
286 + Integer.toString(jsonSctpPort));
287 return false;
288 }
289 return true;
290 }
291
292 /**
293 * Matches an ICMP type criterion object.
294 *
295 * @param criterion criterion to match
296 * @return true if the JSON matches the criterion, false otherwise.
297 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700298 private boolean matchCriterion(IcmpTypeCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800299 final short icmpType = criterion.icmpType();
300 final short jsonIcmpType = jsonCriterion.get("icmpType").shortValue();
301 if (icmpType != jsonIcmpType) {
302 description.appendText("icmp type was "
303 + Short.toString(jsonIcmpType));
304 return false;
305 }
306 return true;
307 }
308
309 /**
310 * Matches an ICMP code criterion object.
311 *
312 * @param criterion criterion to match
313 * @return true if the JSON matches the criterion, false otherwise.
314 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700315 private boolean matchCriterion(IcmpCodeCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800316 final short icmpCode = criterion.icmpCode();
317 final short jsonIcmpCode = jsonCriterion.get("icmpCode").shortValue();
318 if (icmpCode != jsonIcmpCode) {
319 description.appendText("icmp code was "
320 + Short.toString(jsonIcmpCode));
321 return false;
322 }
323 return true;
324 }
325
326 /**
327 * Matches an IPV6 flow label criterion object.
328 *
329 * @param criterion criterion to match
330 * @return true if the JSON matches the criterion, false otherwise.
331 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700332 private boolean matchCriterion(IPv6FlowLabelCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800333 final int flowLabel = criterion.flowLabel();
334 final int jsonFlowLabel = jsonCriterion.get("flowLabel").intValue();
335 if (flowLabel != jsonFlowLabel) {
336 description.appendText("IPv6 flow label was "
337 + Integer.toString(jsonFlowLabel));
338 return false;
339 }
340 return true;
341 }
342
343 /**
344 * Matches an ICMP V6 type criterion object.
345 *
346 * @param criterion criterion to match
347 * @return true if the JSON matches the criterion, false otherwise.
348 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700349 private boolean matchCriterion(Icmpv6TypeCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800350 final short icmpv6Type = criterion.icmpv6Type();
351 final short jsonIcmpv6Type =
352 jsonCriterion.get("icmpv6Type").shortValue();
353 if (icmpv6Type != jsonIcmpv6Type) {
354 description.appendText("icmpv6 type was "
355 + Short.toString(jsonIcmpv6Type));
356 return false;
357 }
358 return true;
359 }
360
361 /**
362 * Matches an IPV6 code criterion object.
363 *
364 * @param criterion criterion to match
365 * @return true if the JSON matches the criterion, false otherwise.
366 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700367 private boolean matchCriterion(Icmpv6CodeCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800368 final short icmpv6Code = criterion.icmpv6Code();
369 final short jsonIcmpv6Code =
370 jsonCriterion.get("icmpv6Code").shortValue();
371 if (icmpv6Code != jsonIcmpv6Code) {
372 description.appendText("icmpv6 code was "
373 + Short.toString(jsonIcmpv6Code));
374 return false;
375 }
376 return true;
377 }
378
379 /**
380 * Matches an IPV6 ND target criterion object.
381 *
382 * @param criterion criterion to match
383 * @return true if the JSON matches the criterion, false otherwise.
384 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700385 private boolean matchCriterion(IPv6NDTargetAddressCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800386 final String targetAddress =
387 criterion.targetAddress().toString();
388 final String jsonTargetAddress =
389 jsonCriterion.get("targetAddress").textValue();
390 if (!targetAddress.equals(jsonTargetAddress)) {
391 description.appendText("target address was " +
392 jsonTargetAddress);
393 return false;
394 }
395 return true;
396 }
397
398 /**
399 * Matches an IPV6 ND link layer criterion object.
400 *
401 * @param criterion criterion to match
402 * @return true if the JSON matches the criterion, false otherwise.
403 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700404 private boolean matchCriterion(IPv6NDLinkLayerAddressCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800405 final String llAddress =
406 criterion.mac().toString();
407 final String jsonLlAddress =
408 jsonCriterion.get("mac").textValue();
409 if (!llAddress.equals(jsonLlAddress)) {
410 description.appendText("mac was " + jsonLlAddress);
411 return false;
412 }
413 return true;
414 }
415
416 /**
417 * Matches an MPLS label criterion object.
418 *
419 * @param criterion criterion to match
420 * @return true if the JSON matches the criterion, false otherwise.
421 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700422 private boolean matchCriterion(MplsCriterion criterion) {
Michele Santuari4b6019e2014-12-19 11:31:45 +0100423 final int label = criterion.label().toInt();
Ray Milkey46670a82015-02-08 17:57:17 -0800424 final int jsonLabel = jsonCriterion.get("label").intValue();
425 if (label != jsonLabel) {
426 description.appendText("label was " + Integer.toString(jsonLabel));
427 return false;
428 }
429 return true;
430 }
431
432 /**
433 * Matches an IPV6 exthdr criterion object.
434 *
435 * @param criterion criterion to match
436 * @return true if the JSON matches the criterion, false otherwise.
437 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700438 private boolean matchCriterion(IPv6ExthdrFlagsCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800439 final int exthdrFlags = criterion.exthdrFlags();
440 final int jsonExthdrFlags =
441 jsonCriterion.get("exthdrFlags").intValue();
442 if (exthdrFlags != jsonExthdrFlags) {
443 description.appendText("exthdrFlags was "
444 + Long.toHexString(jsonExthdrFlags));
445 return false;
446 }
447 return true;
448 }
449
450 /**
451 * Matches a lambda criterion object.
452 *
453 * @param criterion criterion to match
454 * @return true if the JSON matches the criterion, false otherwise.
455 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700456 private boolean matchCriterion(LambdaCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800457 final int lambda = criterion.lambda();
458 final int jsonLambda = jsonCriterion.get("lambda").intValue();
459 if (lambda != jsonLambda) {
460 description.appendText("lambda was " + Integer.toString(lambda));
461 return false;
462 }
463 return true;
464 }
465
466 /**
467 * Matches an optical signal type criterion object.
468 *
469 * @param criterion criterion to match
470 * @return true if the JSON matches the criterion, false otherwise.
471 */
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700472 private boolean matchCriterion(OpticalSignalTypeCriterion criterion) {
Ray Milkey46670a82015-02-08 17:57:17 -0800473 final short signalType = criterion.signalType();
474 final short jsonSignalType = jsonCriterion.get("signalType").shortValue();
475 if (signalType != jsonSignalType) {
476 description.appendText("signal type was " + Short.toString(signalType));
477 return false;
478 }
479 return true;
480 }
481
Ray Milkeydb358082015-01-13 16:34:38 -0800482 @Override
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800483 public boolean matchesSafely(JsonNode jsonCriterion,
484 Description description) {
Ray Milkey46670a82015-02-08 17:57:17 -0800485 this.description = description;
486 this.jsonCriterion = jsonCriterion;
Ray Milkeydb358082015-01-13 16:34:38 -0800487 final String type = criterion.type().name();
488 final String jsonType = jsonCriterion.get("type").asText();
489 if (!type.equals(jsonType)) {
490 description.appendText("type was " + type);
491 return false;
492 }
493
494 switch (criterion.type()) {
495
496 case IN_PORT:
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800497 case IN_PHY_PORT:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700498 return matchCriterion((PortCriterion) criterion);
Ray Milkeydb358082015-01-13 16:34:38 -0800499
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800500 case METADATA:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700501 return matchCriterion((MetadataCriterion) criterion);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800502
Ray Milkeydb358082015-01-13 16:34:38 -0800503 case ETH_DST:
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800504 case ETH_SRC:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700505 return matchCriterion((EthCriterion) criterion);
Ray Milkeydb358082015-01-13 16:34:38 -0800506
507 case ETH_TYPE:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700508 return matchCriterion((EthTypeCriterion) criterion);
Ray Milkeydb358082015-01-13 16:34:38 -0800509
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800510 case VLAN_VID:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700511 return matchCriterion((VlanIdCriterion) criterion);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800512
513 case VLAN_PCP:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700514 return matchCriterion((VlanPcpCriterion) criterion);
Ray Milkeydb358082015-01-13 16:34:38 -0800515
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800516 case IP_DSCP:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700517 return matchCriterion((IPDscpCriterion) criterion);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800518
519 case IP_ECN:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700520 return matchCriterion((IPEcnCriterion) criterion);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800521
Ray Milkeydb358082015-01-13 16:34:38 -0800522 case IP_PROTO:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700523 return matchCriterion((IPProtocolCriterion) criterion);
Ray Milkeydb358082015-01-13 16:34:38 -0800524
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800525 case IPV4_SRC:
526 case IPV4_DST:
527 case IPV6_SRC:
528 case IPV6_DST:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700529 return matchCriterion((IPCriterion) criterion);
Ray Milkeydb358082015-01-13 16:34:38 -0800530
531 case TCP_SRC:
532 case TCP_DST:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700533 return matchCriterion((TcpPortCriterion) criterion);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800534
535 case UDP_SRC:
536 case UDP_DST:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700537 return matchCriterion((UdpPortCriterion) criterion);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800538
539 case SCTP_SRC:
540 case SCTP_DST:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700541 return matchCriterion((SctpPortCriterion) criterion);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800542
543 case ICMPV4_TYPE:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700544 return matchCriterion((IcmpTypeCriterion) criterion);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800545
546 case ICMPV4_CODE:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700547 return matchCriterion((IcmpCodeCriterion) criterion);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800548
549 case IPV6_FLABEL:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700550 return matchCriterion((IPv6FlowLabelCriterion) criterion);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800551
552 case ICMPV6_TYPE:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700553 return matchCriterion((Icmpv6TypeCriterion) criterion);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800554
555 case ICMPV6_CODE:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700556 return matchCriterion((Icmpv6CodeCriterion) criterion);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800557
558 case IPV6_ND_TARGET:
Ray Milkey46670a82015-02-08 17:57:17 -0800559 return matchCriterion(
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700560 (IPv6NDTargetAddressCriterion) criterion);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800561
562 case IPV6_ND_SLL:
563 case IPV6_ND_TLL:
Ray Milkey46670a82015-02-08 17:57:17 -0800564 return matchCriterion(
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700565 (IPv6NDLinkLayerAddressCriterion) criterion);
Ray Milkeydb358082015-01-13 16:34:38 -0800566
567 case MPLS_LABEL:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700568 return matchCriterion((MplsCriterion) criterion);
Ray Milkeydb358082015-01-13 16:34:38 -0800569
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800570 case IPV6_EXTHDR:
Ray Milkey46670a82015-02-08 17:57:17 -0800571 return matchCriterion(
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700572 (IPv6ExthdrFlagsCriterion) criterion);
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800573
Ray Milkeydb358082015-01-13 16:34:38 -0800574 case OCH_SIGID:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700575 return matchCriterion((LambdaCriterion) criterion);
Ray Milkeydb358082015-01-13 16:34:38 -0800576
577 case OCH_SIGTYPE:
Ray Milkey46670a82015-02-08 17:57:17 -0800578 return matchCriterion(
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700579 (OpticalSignalTypeCriterion) criterion);
Ray Milkeydb358082015-01-13 16:34:38 -0800580
581 default:
582 // Don't know how to format this type
583 description.appendText("unknown criterion type " +
584 criterion.type());
585 return false;
586 }
Ray Milkeydb358082015-01-13 16:34:38 -0800587 }
588
589 @Override
590 public void describeTo(Description description) {
591 description.appendText(criterion.toString());
592 }
Ray Milkeydb358082015-01-13 16:34:38 -0800593}