Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.codec.impl; |
| 17 | |
Frank Wang | 74ce2c1 | 2018-04-11 20:26:45 +0800 | [diff] [blame] | 18 | import java.util.Collection; |
Yafit Hadar | 5796d97 | 2015-10-15 13:16:11 +0300 | [diff] [blame] | 19 | import java.util.Objects; |
| 20 | |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 21 | import org.hamcrest.Description; |
| 22 | import org.hamcrest.TypeSafeDiagnosingMatcher; |
Yafit Hadar | 5796d97 | 2015-10-15 13:16:11 +0300 | [diff] [blame] | 23 | import org.onlab.util.HexString; |
Sho SHIMIZU | c44c0c3 | 2015-06-01 11:40:48 -0700 | [diff] [blame] | 24 | import org.onosproject.net.OchSignal; |
Yafit Hadar | 5796d97 | 2015-10-15 13:16:11 +0300 | [diff] [blame] | 25 | import org.onosproject.net.OduSignalId; |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 26 | import org.onosproject.net.flow.criteria.Criterion; |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 27 | import org.onosproject.net.flow.criteria.EthCriterion; |
| 28 | import org.onosproject.net.flow.criteria.EthTypeCriterion; |
| 29 | import org.onosproject.net.flow.criteria.IPCriterion; |
| 30 | import org.onosproject.net.flow.criteria.IPDscpCriterion; |
| 31 | import org.onosproject.net.flow.criteria.IPEcnCriterion; |
| 32 | import org.onosproject.net.flow.criteria.IPProtocolCriterion; |
| 33 | import org.onosproject.net.flow.criteria.IPv6ExthdrFlagsCriterion; |
| 34 | import org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion; |
| 35 | import org.onosproject.net.flow.criteria.IPv6NDLinkLayerAddressCriterion; |
| 36 | import org.onosproject.net.flow.criteria.IPv6NDTargetAddressCriterion; |
| 37 | import org.onosproject.net.flow.criteria.IcmpCodeCriterion; |
| 38 | import org.onosproject.net.flow.criteria.IcmpTypeCriterion; |
| 39 | import org.onosproject.net.flow.criteria.Icmpv6CodeCriterion; |
| 40 | import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion; |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 41 | import org.onosproject.net.flow.criteria.MetadataCriterion; |
| 42 | import org.onosproject.net.flow.criteria.MplsCriterion; |
Sho SHIMIZU | c44c0c3 | 2015-06-01 11:40:48 -0700 | [diff] [blame] | 43 | import org.onosproject.net.flow.criteria.OchSignalCriterion; |
Sho SHIMIZU | 6c70f64 | 2015-05-29 17:27:22 -0700 | [diff] [blame] | 44 | import org.onosproject.net.flow.criteria.OchSignalTypeCriterion; |
Yafit Hadar | 5796d97 | 2015-10-15 13:16:11 +0300 | [diff] [blame] | 45 | import org.onosproject.net.flow.criteria.OduSignalIdCriterion; |
| 46 | import org.onosproject.net.flow.criteria.OduSignalTypeCriterion; |
Frank Wang | 74ce2c1 | 2018-04-11 20:26:45 +0800 | [diff] [blame] | 47 | import org.onosproject.net.flow.criteria.PiCriterion; |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 48 | import org.onosproject.net.flow.criteria.PortCriterion; |
| 49 | import org.onosproject.net.flow.criteria.SctpPortCriterion; |
| 50 | import org.onosproject.net.flow.criteria.TcpPortCriterion; |
| 51 | import org.onosproject.net.flow.criteria.UdpPortCriterion; |
| 52 | import org.onosproject.net.flow.criteria.VlanIdCriterion; |
| 53 | import org.onosproject.net.flow.criteria.VlanPcpCriterion; |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 54 | |
Yafit Hadar | 5796d97 | 2015-10-15 13:16:11 +0300 | [diff] [blame] | 55 | import com.fasterxml.jackson.databind.JsonNode; |
| 56 | import com.google.common.base.Joiner; |
Frank Wang | 74ce2c1 | 2018-04-11 20:26:45 +0800 | [diff] [blame] | 57 | import org.onosproject.net.pi.runtime.PiExactFieldMatch; |
| 58 | import org.onosproject.net.pi.runtime.PiFieldMatch; |
| 59 | import org.onosproject.net.pi.runtime.PiLpmFieldMatch; |
| 60 | import org.onosproject.net.pi.runtime.PiRangeFieldMatch; |
| 61 | import org.onosproject.net.pi.runtime.PiTernaryFieldMatch; |
Frank Wang | 74ce2c1 | 2018-04-11 20:26:45 +0800 | [diff] [blame] | 62 | |
| 63 | import static org.onlab.util.ImmutableByteSequence.copyFrom; |
Sho SHIMIZU | c44c0c3 | 2015-06-01 11:40:48 -0700 | [diff] [blame] | 64 | |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 65 | /** |
| 66 | * Hamcrest matcher for criterion objects. |
| 67 | */ |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 68 | public final class CriterionJsonMatcher extends |
| 69 | TypeSafeDiagnosingMatcher<JsonNode> { |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 70 | |
| 71 | final Criterion criterion; |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 72 | Description description; |
| 73 | JsonNode jsonCriterion; |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 74 | |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 75 | /** |
| 76 | * Constructs a matcher object. |
| 77 | * |
| 78 | * @param criterionValue criterion to match |
| 79 | */ |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 80 | private CriterionJsonMatcher(Criterion criterionValue) { |
| 81 | criterion = criterionValue; |
| 82 | } |
| 83 | |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 84 | /** |
| 85 | * Factory to allocate an criterion matcher. |
| 86 | * |
| 87 | * @param criterion criterion object we are looking for |
| 88 | * @return matcher |
| 89 | */ |
| 90 | public static CriterionJsonMatcher matchesCriterion(Criterion criterion) { |
| 91 | return new CriterionJsonMatcher(criterion); |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Matches a port criterion object. |
| 96 | * |
| 97 | * @param criterion criterion to match |
| 98 | * @return true if the JSON matches the criterion, false otherwise. |
| 99 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 100 | private boolean matchCriterion(PortCriterion criterion) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 101 | final long port = criterion.port().toLong(); |
| 102 | final long jsonPort = jsonCriterion.get("port").asLong(); |
| 103 | if (port != jsonPort) { |
| 104 | description.appendText("port was " + Long.toString(jsonPort)); |
| 105 | return false; |
| 106 | } |
| 107 | return true; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Matches a metadata criterion object. |
| 112 | * |
| 113 | * @param criterion criterion to match |
| 114 | * @return true if the JSON matches the criterion, false otherwise. |
| 115 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 116 | private boolean matchCriterion(MetadataCriterion criterion) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 117 | final long metadata = criterion.metadata(); |
| 118 | final long jsonMetadata = jsonCriterion.get("metadata").asLong(); |
| 119 | if (metadata != jsonMetadata) { |
| 120 | description.appendText("metadata was " |
| 121 | + Long.toString(jsonMetadata)); |
| 122 | return false; |
| 123 | } |
| 124 | return true; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Matches an eth criterion object. |
| 129 | * |
| 130 | * @param criterion criterion to match |
| 131 | * @return true if the JSON matches the criterion, false otherwise. |
| 132 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 133 | private boolean matchCriterion(EthCriterion criterion) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 134 | final String mac = criterion.mac().toString(); |
| 135 | final String jsonMac = jsonCriterion.get("mac").textValue(); |
| 136 | if (!mac.equals(jsonMac)) { |
| 137 | description.appendText("mac was " + jsonMac); |
| 138 | return false; |
| 139 | } |
| 140 | return true; |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * Matches an eth type criterion object. |
| 145 | * |
| 146 | * @param criterion criterion to match |
| 147 | * @return true if the JSON matches the criterion, false otherwise. |
| 148 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 149 | private boolean matchCriterion(EthTypeCriterion criterion) { |
andrea | d35f89c | 2015-11-23 10:02:07 -0800 | [diff] [blame] | 150 | final int ethType = criterion.ethType().toShort() & 0xffff; |
| 151 | final int jsonEthType = Integer.decode(jsonCriterion.get("ethType").textValue()) & 0xffff; |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 152 | if (ethType != jsonEthType) { |
| 153 | description.appendText("ethType was " |
| 154 | + Integer.toString(jsonEthType)); |
| 155 | return false; |
| 156 | } |
| 157 | return true; |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Matches a VLAN ID criterion object. |
| 162 | * |
| 163 | * @param criterion criterion to match |
| 164 | * @return true if the JSON matches the criterion, false otherwise. |
| 165 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 166 | private boolean matchCriterion(VlanIdCriterion criterion) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 167 | final short vlanId = criterion.vlanId().toShort(); |
| 168 | final short jsonVlanId = jsonCriterion.get("vlanId").shortValue(); |
| 169 | if (vlanId != jsonVlanId) { |
| 170 | description.appendText("vlanId was " + Short.toString(jsonVlanId)); |
| 171 | return false; |
| 172 | } |
| 173 | return true; |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * Matches a VLAN PCP criterion object. |
| 178 | * |
| 179 | * @param criterion criterion to match |
| 180 | * @return true if the JSON matches the criterion, false otherwise. |
| 181 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 182 | private boolean matchCriterion(VlanPcpCriterion criterion) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 183 | final byte priority = criterion.priority(); |
| 184 | final byte jsonPriority = |
| 185 | (byte) jsonCriterion.get("priority").shortValue(); |
| 186 | if (priority != jsonPriority) { |
| 187 | description.appendText("priority was " + Byte.toString(jsonPriority)); |
| 188 | return false; |
| 189 | } |
| 190 | return true; |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * Matches an IP DSCP criterion object. |
| 195 | * |
| 196 | * @param criterion criterion to match |
| 197 | * @return true if the JSON matches the criterion, false otherwise. |
| 198 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 199 | private boolean matchCriterion(IPDscpCriterion criterion) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 200 | final byte ipDscp = criterion.ipDscp(); |
| 201 | final byte jsonIpDscp = (byte) jsonCriterion.get("ipDscp").shortValue(); |
| 202 | if (ipDscp != jsonIpDscp) { |
| 203 | description.appendText("IP DSCP was " + Byte.toString(jsonIpDscp)); |
| 204 | return false; |
| 205 | } |
| 206 | return true; |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * Matches an IP ECN criterion object. |
| 211 | * |
| 212 | * @param criterion criterion to match |
| 213 | * @return true if the JSON matches the criterion, false otherwise. |
| 214 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 215 | private boolean matchCriterion(IPEcnCriterion criterion) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 216 | final byte ipEcn = criterion.ipEcn(); |
| 217 | final byte jsonIpEcn = (byte) jsonCriterion.get("ipEcn").shortValue(); |
| 218 | if (ipEcn != jsonIpEcn) { |
| 219 | description.appendText("IP ECN was " + Byte.toString(jsonIpEcn)); |
| 220 | return false; |
| 221 | } |
| 222 | return true; |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * Matches an IP protocol criterion object. |
| 227 | * |
| 228 | * @param criterion criterion to match |
| 229 | * @return true if the JSON matches the criterion, false otherwise. |
| 230 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 231 | private boolean matchCriterion(IPProtocolCriterion criterion) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 232 | final short protocol = criterion.protocol(); |
| 233 | final short jsonProtocol = jsonCriterion.get("protocol").shortValue(); |
| 234 | if (protocol != jsonProtocol) { |
| 235 | description.appendText("protocol was " |
| 236 | + Short.toString(jsonProtocol)); |
| 237 | return false; |
| 238 | } |
| 239 | return true; |
| 240 | } |
| 241 | |
| 242 | /** |
| 243 | * Matches an IP address criterion object. |
| 244 | * |
| 245 | * @param criterion criterion to match |
| 246 | * @return true if the JSON matches the criterion, false otherwise. |
| 247 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 248 | private boolean matchCriterion(IPCriterion criterion) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 249 | final String ip = criterion.ip().toString(); |
| 250 | final String jsonIp = jsonCriterion.get("ip").textValue(); |
| 251 | if (!ip.equals(jsonIp)) { |
| 252 | description.appendText("ip was " + jsonIp); |
| 253 | return false; |
| 254 | } |
| 255 | return true; |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * Matches a TCP port criterion object. |
| 260 | * |
| 261 | * @param criterion criterion to match |
| 262 | * @return true if the JSON matches the criterion, false otherwise. |
| 263 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 264 | private boolean matchCriterion(TcpPortCriterion criterion) { |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 265 | final int tcpPort = criterion.tcpPort().toInt(); |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 266 | final int jsonTcpPort = jsonCriterion.get("tcpPort").intValue(); |
| 267 | if (tcpPort != jsonTcpPort) { |
| 268 | description.appendText("tcp port was " |
| 269 | + Integer.toString(jsonTcpPort)); |
| 270 | return false; |
| 271 | } |
| 272 | return true; |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * Matches a UDP port criterion object. |
| 277 | * |
| 278 | * @param criterion criterion to match |
| 279 | * @return true if the JSON matches the criterion, false otherwise. |
| 280 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 281 | private boolean matchCriterion(UdpPortCriterion criterion) { |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 282 | final int udpPort = criterion.udpPort().toInt(); |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 283 | final int jsonUdpPort = jsonCriterion.get("udpPort").intValue(); |
| 284 | if (udpPort != jsonUdpPort) { |
| 285 | description.appendText("udp port was " |
| 286 | + Integer.toString(jsonUdpPort)); |
| 287 | return false; |
| 288 | } |
| 289 | return true; |
| 290 | } |
| 291 | |
| 292 | /** |
| 293 | * Matches an SCTP port criterion object. |
| 294 | * |
| 295 | * @param criterion criterion to match |
| 296 | * @return true if the JSON matches the criterion, false otherwise. |
| 297 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 298 | private boolean matchCriterion(SctpPortCriterion criterion) { |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 299 | final int sctpPort = criterion.sctpPort().toInt(); |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 300 | final int jsonSctpPort = jsonCriterion.get("sctpPort").intValue(); |
| 301 | if (sctpPort != jsonSctpPort) { |
| 302 | description.appendText("sctp port was " |
| 303 | + Integer.toString(jsonSctpPort)); |
| 304 | return false; |
| 305 | } |
| 306 | return true; |
| 307 | } |
| 308 | |
| 309 | /** |
| 310 | * Matches an ICMP type criterion object. |
| 311 | * |
| 312 | * @param criterion criterion to match |
| 313 | * @return true if the JSON matches the criterion, false otherwise. |
| 314 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 315 | private boolean matchCriterion(IcmpTypeCriterion criterion) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 316 | final short icmpType = criterion.icmpType(); |
| 317 | final short jsonIcmpType = jsonCriterion.get("icmpType").shortValue(); |
| 318 | if (icmpType != jsonIcmpType) { |
| 319 | description.appendText("icmp type was " |
| 320 | + Short.toString(jsonIcmpType)); |
| 321 | return false; |
| 322 | } |
| 323 | return true; |
| 324 | } |
| 325 | |
| 326 | /** |
| 327 | * Matches an ICMP code criterion object. |
| 328 | * |
| 329 | * @param criterion criterion to match |
| 330 | * @return true if the JSON matches the criterion, false otherwise. |
| 331 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 332 | private boolean matchCriterion(IcmpCodeCriterion criterion) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 333 | final short icmpCode = criterion.icmpCode(); |
| 334 | final short jsonIcmpCode = jsonCriterion.get("icmpCode").shortValue(); |
| 335 | if (icmpCode != jsonIcmpCode) { |
| 336 | description.appendText("icmp code was " |
| 337 | + Short.toString(jsonIcmpCode)); |
| 338 | return false; |
| 339 | } |
| 340 | return true; |
| 341 | } |
| 342 | |
| 343 | /** |
| 344 | * Matches an IPV6 flow label criterion object. |
| 345 | * |
| 346 | * @param criterion criterion to match |
| 347 | * @return true if the JSON matches the criterion, false otherwise. |
| 348 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 349 | private boolean matchCriterion(IPv6FlowLabelCriterion criterion) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 350 | final int flowLabel = criterion.flowLabel(); |
| 351 | final int jsonFlowLabel = jsonCriterion.get("flowLabel").intValue(); |
| 352 | if (flowLabel != jsonFlowLabel) { |
| 353 | description.appendText("IPv6 flow label was " |
| 354 | + Integer.toString(jsonFlowLabel)); |
| 355 | return false; |
| 356 | } |
| 357 | return true; |
| 358 | } |
| 359 | |
| 360 | /** |
| 361 | * Matches an ICMP V6 type criterion object. |
| 362 | * |
| 363 | * @param criterion criterion to match |
| 364 | * @return true if the JSON matches the criterion, false otherwise. |
| 365 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 366 | private boolean matchCriterion(Icmpv6TypeCriterion criterion) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 367 | final short icmpv6Type = criterion.icmpv6Type(); |
| 368 | final short jsonIcmpv6Type = |
| 369 | jsonCriterion.get("icmpv6Type").shortValue(); |
| 370 | if (icmpv6Type != jsonIcmpv6Type) { |
| 371 | description.appendText("icmpv6 type was " |
| 372 | + Short.toString(jsonIcmpv6Type)); |
| 373 | return false; |
| 374 | } |
| 375 | return true; |
| 376 | } |
| 377 | |
| 378 | /** |
| 379 | * Matches an IPV6 code criterion object. |
| 380 | * |
| 381 | * @param criterion criterion to match |
| 382 | * @return true if the JSON matches the criterion, false otherwise. |
| 383 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 384 | private boolean matchCriterion(Icmpv6CodeCriterion criterion) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 385 | final short icmpv6Code = criterion.icmpv6Code(); |
| 386 | final short jsonIcmpv6Code = |
| 387 | jsonCriterion.get("icmpv6Code").shortValue(); |
| 388 | if (icmpv6Code != jsonIcmpv6Code) { |
| 389 | description.appendText("icmpv6 code was " |
| 390 | + Short.toString(jsonIcmpv6Code)); |
| 391 | return false; |
| 392 | } |
| 393 | return true; |
| 394 | } |
| 395 | |
| 396 | /** |
| 397 | * Matches an IPV6 ND target criterion object. |
| 398 | * |
| 399 | * @param criterion criterion to match |
| 400 | * @return true if the JSON matches the criterion, false otherwise. |
| 401 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 402 | private boolean matchCriterion(IPv6NDTargetAddressCriterion criterion) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 403 | final String targetAddress = |
| 404 | criterion.targetAddress().toString(); |
| 405 | final String jsonTargetAddress = |
| 406 | jsonCriterion.get("targetAddress").textValue(); |
| 407 | if (!targetAddress.equals(jsonTargetAddress)) { |
| 408 | description.appendText("target address was " + |
| 409 | jsonTargetAddress); |
| 410 | return false; |
| 411 | } |
| 412 | return true; |
| 413 | } |
| 414 | |
| 415 | /** |
| 416 | * Matches an IPV6 ND link layer criterion object. |
| 417 | * |
| 418 | * @param criterion criterion to match |
| 419 | * @return true if the JSON matches the criterion, false otherwise. |
| 420 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 421 | private boolean matchCriterion(IPv6NDLinkLayerAddressCriterion criterion) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 422 | final String llAddress = |
| 423 | criterion.mac().toString(); |
| 424 | final String jsonLlAddress = |
| 425 | jsonCriterion.get("mac").textValue(); |
| 426 | if (!llAddress.equals(jsonLlAddress)) { |
| 427 | description.appendText("mac was " + jsonLlAddress); |
| 428 | return false; |
| 429 | } |
| 430 | return true; |
| 431 | } |
| 432 | |
| 433 | /** |
| 434 | * Matches an MPLS label criterion object. |
| 435 | * |
| 436 | * @param criterion criterion to match |
| 437 | * @return true if the JSON matches the criterion, false otherwise. |
| 438 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 439 | private boolean matchCriterion(MplsCriterion criterion) { |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 440 | final int label = criterion.label().toInt(); |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 441 | final int jsonLabel = jsonCriterion.get("label").intValue(); |
| 442 | if (label != jsonLabel) { |
| 443 | description.appendText("label was " + Integer.toString(jsonLabel)); |
| 444 | return false; |
| 445 | } |
| 446 | return true; |
| 447 | } |
| 448 | |
| 449 | /** |
| 450 | * Matches an IPV6 exthdr criterion object. |
| 451 | * |
| 452 | * @param criterion criterion to match |
| 453 | * @return true if the JSON matches the criterion, false otherwise. |
| 454 | */ |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 455 | private boolean matchCriterion(IPv6ExthdrFlagsCriterion criterion) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 456 | final int exthdrFlags = criterion.exthdrFlags(); |
| 457 | final int jsonExthdrFlags = |
| 458 | jsonCriterion.get("exthdrFlags").intValue(); |
| 459 | if (exthdrFlags != jsonExthdrFlags) { |
| 460 | description.appendText("exthdrFlags was " |
| 461 | + Long.toHexString(jsonExthdrFlags)); |
| 462 | return false; |
| 463 | } |
| 464 | return true; |
| 465 | } |
| 466 | |
| 467 | /** |
Sho SHIMIZU | c44c0c3 | 2015-06-01 11:40:48 -0700 | [diff] [blame] | 468 | * Matches an Och signal criterion object. |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 469 | * |
| 470 | * @param criterion criterion to match |
| 471 | * @return true if the JSON matches the criterion, false otherwise. |
| 472 | */ |
Sho SHIMIZU | c44c0c3 | 2015-06-01 11:40:48 -0700 | [diff] [blame] | 473 | private boolean matchCriterion(OchSignalCriterion criterion) { |
| 474 | final OchSignal ochSignal = criterion.lambda(); |
| 475 | final JsonNode jsonOchSignal = jsonCriterion.get("ochSignalId"); |
| 476 | String jsonGridType = jsonOchSignal.get("gridType").textValue(); |
| 477 | String jsonChannelSpacing = jsonOchSignal.get("channelSpacing").textValue(); |
| 478 | int jsonSpacingMultiplier = jsonOchSignal.get("spacingMultiplier").intValue(); |
| 479 | int jsonSlotGranularity = jsonOchSignal.get("slotGranularity").intValue(); |
| 480 | |
| 481 | boolean equality = Objects.equals(ochSignal.gridType().name(), jsonGridType) |
| 482 | && Objects.equals(ochSignal.channelSpacing().name(), jsonChannelSpacing) |
| 483 | && Objects.equals(ochSignal.spacingMultiplier(), jsonSpacingMultiplier) |
| 484 | && Objects.equals(ochSignal.slotGranularity(), jsonSlotGranularity); |
| 485 | |
| 486 | if (!equality) { |
| 487 | String joined = Joiner.on(", ") |
| 488 | .join(jsonGridType, jsonChannelSpacing, jsonSpacingMultiplier, jsonSlotGranularity); |
| 489 | |
| 490 | description.appendText("och signal id was " + joined); |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 491 | return false; |
| 492 | } |
| 493 | return true; |
| 494 | } |
| 495 | |
| 496 | /** |
Sho SHIMIZU | 68b8c1f | 2015-05-29 18:42:26 -0700 | [diff] [blame] | 497 | * Matches an Och signal type criterion object. |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 498 | * |
| 499 | * @param criterion criterion to match |
| 500 | * @return true if the JSON matches the criterion, false otherwise. |
| 501 | */ |
Sho SHIMIZU | 6c70f64 | 2015-05-29 17:27:22 -0700 | [diff] [blame] | 502 | private boolean matchCriterion(OchSignalTypeCriterion criterion) { |
| 503 | final String signalType = criterion.signalType().name(); |
| 504 | final String jsonSignalType = jsonCriterion.get("ochSignalType").textValue(); |
| 505 | if (!signalType.equals(jsonSignalType)) { |
Sho SHIMIZU | c06966e | 2015-06-01 12:14:37 -0700 | [diff] [blame] | 506 | description.appendText("signal type was " + jsonSignalType); |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 507 | return false; |
| 508 | } |
| 509 | return true; |
| 510 | } |
| 511 | |
Yafit Hadar | 5796d97 | 2015-10-15 13:16:11 +0300 | [diff] [blame] | 512 | /** |
| 513 | * Matches an ODU signal ID criterion object. |
| 514 | * |
| 515 | * @param criterion criterion to match |
| 516 | * @return true if the JSON matches the criterion, false otherwise. |
| 517 | */ |
| 518 | private boolean matchCriterion(OduSignalIdCriterion criterion) { |
| 519 | final OduSignalId oduSignal = criterion.oduSignalId(); |
| 520 | final JsonNode jsonOduSignal = jsonCriterion.get(CriterionCodec.ODU_SIGNAL_ID); |
| 521 | int jsonTpn = jsonOduSignal.get(CriterionCodec.TRIBUTARY_PORT_NUMBER).intValue(); |
| 522 | int jsonTsLen = jsonOduSignal.get(CriterionCodec.TRIBUTARY_SLOT_LEN).intValue(); |
| 523 | byte[] jsonTributaryBitMap = HexString.fromHexString( |
| 524 | jsonOduSignal.get(CriterionCodec.TRIBUTARY_SLOT_BITMAP).asText()); |
| 525 | OduSignalId jsonOduSignalId = OduSignalId.oduSignalId(jsonTpn, jsonTsLen, jsonTributaryBitMap); |
| 526 | if (!oduSignal.equals(jsonOduSignalId)) { |
| 527 | description.appendText("oduSignalId was " + criterion); |
| 528 | return false; |
| 529 | } |
| 530 | return true; |
| 531 | } |
| 532 | |
| 533 | /** |
| 534 | * Matches an ODU signal Type criterion object. |
| 535 | * |
| 536 | * @param criterion criterion to match |
| 537 | * @return true if the JSON matches the criterion, false otherwise. |
| 538 | */ |
| 539 | private boolean matchCriterion(OduSignalTypeCriterion criterion) { |
| 540 | final String signalType = criterion.signalType().name(); |
| 541 | final String jsonOduSignalType = jsonCriterion.get("oduSignalType").textValue(); |
| 542 | if (!signalType.equals(jsonOduSignalType)) { |
| 543 | description.appendText("signalType was " + signalType); |
| 544 | return false; |
| 545 | } |
| 546 | return true; |
| 547 | } |
| 548 | |
Frank Wang | 74ce2c1 | 2018-04-11 20:26:45 +0800 | [diff] [blame] | 549 | /** |
| 550 | * Matches a protocol-independent Type criterion object. |
| 551 | * |
| 552 | * @param criterion criterion to match |
| 553 | * @return true if the JSON matches the criterion, false otherwise. |
| 554 | */ |
| 555 | private boolean matchCriterion(PiCriterion criterion) { |
| 556 | Collection<PiFieldMatch> piFieldMatches = criterion.fieldMatches(); |
| 557 | JsonNode jsonMathes = jsonCriterion.get("matches"); |
| 558 | if (!jsonMathes.isArray()) { |
| 559 | return false; |
| 560 | } |
| 561 | for (JsonNode matchNode : jsonMathes) { |
| 562 | for (PiFieldMatch fieldMatch : piFieldMatches) { |
| 563 | |
| 564 | if (!Objects.equals(matchNode.get("field").textValue(), fieldMatch.fieldId().id())) { |
| 565 | description.appendText("match field was " + fieldMatch.fieldId().id()); |
| 566 | return false; |
| 567 | } |
| 568 | |
| 569 | if (!Objects.equals(matchNode.get("match").textValue(), |
| 570 | fieldMatch.type().name().toLowerCase())) { |
| 571 | description.appendText("match type was " + fieldMatch.type().name().toLowerCase()); |
| 572 | return false; |
| 573 | } |
| 574 | |
| 575 | switch (fieldMatch.type()) { |
| 576 | case EXACT: |
| 577 | if (!Objects.equals(copyFrom(HexString.fromHexString(matchNode.get("value") |
| 578 | .textValue(), null)), |
| 579 | ((PiExactFieldMatch) fieldMatch).value())) { |
| 580 | description.appendText("match value was " + ((PiExactFieldMatch) fieldMatch).value()); |
| 581 | return false; |
| 582 | } |
| 583 | break; |
| 584 | case LPM: |
| 585 | if (!Objects.equals(copyFrom(HexString.fromHexString(matchNode.get("value") |
| 586 | .textValue(), null)), |
| 587 | ((PiLpmFieldMatch) fieldMatch).value())) { |
| 588 | description.appendText("match value was " + ((PiLpmFieldMatch) fieldMatch).value()); |
| 589 | return false; |
| 590 | } |
| 591 | if (!Objects.equals(matchNode.get("prefixLength").intValue(), |
| 592 | ((PiLpmFieldMatch) fieldMatch).prefixLength())) { |
| 593 | description.appendText("match prefix was " + |
| 594 | ((PiLpmFieldMatch) fieldMatch).prefixLength()); |
| 595 | return false; |
| 596 | } |
| 597 | break; |
| 598 | case TERNARY: |
| 599 | if (!Objects.equals(copyFrom(HexString.fromHexString(matchNode.get("value") |
| 600 | .textValue(), null)), |
| 601 | ((PiTernaryFieldMatch) fieldMatch).value())) { |
| 602 | description.appendText("match value was " + ((PiTernaryFieldMatch) fieldMatch).value()); |
| 603 | return false; |
| 604 | } |
| 605 | if (!Objects.equals(copyFrom(HexString.fromHexString(matchNode.get("mask") |
| 606 | .textValue(), null)), |
| 607 | ((PiTernaryFieldMatch) fieldMatch).mask())) { |
| 608 | description.appendText("match mask was " + ((PiTernaryFieldMatch) fieldMatch).mask()); |
| 609 | return false; |
| 610 | } |
| 611 | break; |
| 612 | case RANGE: |
| 613 | if (!Objects.equals(copyFrom(HexString.fromHexString(matchNode.get("highValue") |
| 614 | .textValue(), null)), |
| 615 | ((PiRangeFieldMatch) fieldMatch).highValue())) { |
| 616 | description.appendText("match high value was " + |
| 617 | ((PiRangeFieldMatch) fieldMatch).highValue()); |
| 618 | return false; |
| 619 | } |
| 620 | if (!Objects.equals(copyFrom(HexString.fromHexString(matchNode.get("lowValue") |
| 621 | .textValue(), null)), |
| 622 | ((PiRangeFieldMatch) fieldMatch).lowValue())) { |
| 623 | description.appendText("match low value was " + |
| 624 | ((PiRangeFieldMatch) fieldMatch).lowValue()); |
| 625 | return false; |
| 626 | } |
| 627 | break; |
Frank Wang | 74ce2c1 | 2018-04-11 20:26:45 +0800 | [diff] [blame] | 628 | default: |
| 629 | description.appendText("match type was " + fieldMatch.type().name().toLowerCase()); |
| 630 | return false; |
| 631 | } |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | return true; |
| 636 | } |
Yafit Hadar | 5796d97 | 2015-10-15 13:16:11 +0300 | [diff] [blame] | 637 | |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 638 | @Override |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 639 | public boolean matchesSafely(JsonNode jsonCriterion, |
| 640 | Description description) { |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 641 | this.description = description; |
| 642 | this.jsonCriterion = jsonCriterion; |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 643 | final String type = criterion.type().name(); |
| 644 | final String jsonType = jsonCriterion.get("type").asText(); |
| 645 | if (!type.equals(jsonType)) { |
| 646 | description.appendText("type was " + type); |
| 647 | return false; |
| 648 | } |
| 649 | |
| 650 | switch (criterion.type()) { |
| 651 | |
| 652 | case IN_PORT: |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 653 | case IN_PHY_PORT: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 654 | return matchCriterion((PortCriterion) criterion); |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 655 | |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 656 | case METADATA: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 657 | return matchCriterion((MetadataCriterion) criterion); |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 658 | |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 659 | case ETH_DST: |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 660 | case ETH_SRC: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 661 | return matchCriterion((EthCriterion) criterion); |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 662 | |
| 663 | case ETH_TYPE: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 664 | return matchCriterion((EthTypeCriterion) criterion); |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 665 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 666 | case VLAN_VID: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 667 | return matchCriterion((VlanIdCriterion) criterion); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 668 | |
| 669 | case VLAN_PCP: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 670 | return matchCriterion((VlanPcpCriterion) criterion); |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 671 | |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 672 | case IP_DSCP: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 673 | return matchCriterion((IPDscpCriterion) criterion); |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 674 | |
| 675 | case IP_ECN: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 676 | return matchCriterion((IPEcnCriterion) criterion); |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 677 | |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 678 | case IP_PROTO: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 679 | return matchCriterion((IPProtocolCriterion) criterion); |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 680 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 681 | case IPV4_SRC: |
| 682 | case IPV4_DST: |
| 683 | case IPV6_SRC: |
| 684 | case IPV6_DST: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 685 | return matchCriterion((IPCriterion) criterion); |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 686 | |
| 687 | case TCP_SRC: |
| 688 | case TCP_DST: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 689 | return matchCriterion((TcpPortCriterion) criterion); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 690 | |
| 691 | case UDP_SRC: |
| 692 | case UDP_DST: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 693 | return matchCriterion((UdpPortCriterion) criterion); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 694 | |
| 695 | case SCTP_SRC: |
| 696 | case SCTP_DST: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 697 | return matchCriterion((SctpPortCriterion) criterion); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 698 | |
| 699 | case ICMPV4_TYPE: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 700 | return matchCriterion((IcmpTypeCriterion) criterion); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 701 | |
| 702 | case ICMPV4_CODE: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 703 | return matchCriterion((IcmpCodeCriterion) criterion); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 704 | |
| 705 | case IPV6_FLABEL: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 706 | return matchCriterion((IPv6FlowLabelCriterion) criterion); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 707 | |
| 708 | case ICMPV6_TYPE: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 709 | return matchCriterion((Icmpv6TypeCriterion) criterion); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 710 | |
| 711 | case ICMPV6_CODE: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 712 | return matchCriterion((Icmpv6CodeCriterion) criterion); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 713 | |
| 714 | case IPV6_ND_TARGET: |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 715 | return matchCriterion( |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 716 | (IPv6NDTargetAddressCriterion) criterion); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 717 | |
| 718 | case IPV6_ND_SLL: |
| 719 | case IPV6_ND_TLL: |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 720 | return matchCriterion( |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 721 | (IPv6NDLinkLayerAddressCriterion) criterion); |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 722 | |
| 723 | case MPLS_LABEL: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 724 | return matchCriterion((MplsCriterion) criterion); |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 725 | |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 726 | case IPV6_EXTHDR: |
Ray Milkey | 46670a8 | 2015-02-08 17:57:17 -0800 | [diff] [blame] | 727 | return matchCriterion( |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 728 | (IPv6ExthdrFlagsCriterion) criterion); |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 729 | |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 730 | case OCH_SIGID: |
Sho SHIMIZU | c44c0c3 | 2015-06-01 11:40:48 -0700 | [diff] [blame] | 731 | return matchCriterion((OchSignalCriterion) criterion); |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 732 | |
| 733 | case OCH_SIGTYPE: |
Sho SHIMIZU | 6c70f64 | 2015-05-29 17:27:22 -0700 | [diff] [blame] | 734 | return matchCriterion((OchSignalTypeCriterion) criterion); |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 735 | |
Yafit Hadar | 5796d97 | 2015-10-15 13:16:11 +0300 | [diff] [blame] | 736 | case ODU_SIGID: |
| 737 | return matchCriterion((OduSignalIdCriterion) criterion); |
| 738 | |
| 739 | case ODU_SIGTYPE: |
| 740 | return matchCriterion((OduSignalTypeCriterion) criterion); |
Frank Wang | 74ce2c1 | 2018-04-11 20:26:45 +0800 | [diff] [blame] | 741 | case PROTOCOL_INDEPENDENT: |
| 742 | return matchCriterion((PiCriterion) criterion); |
Yafit Hadar | 5796d97 | 2015-10-15 13:16:11 +0300 | [diff] [blame] | 743 | |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 744 | default: |
| 745 | // Don't know how to format this type |
| 746 | description.appendText("unknown criterion type " + |
| 747 | criterion.type()); |
| 748 | return false; |
| 749 | } |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 750 | } |
| 751 | |
| 752 | @Override |
| 753 | public void describeTo(Description description) { |
| 754 | description.appendText(criterion.toString()); |
| 755 | } |
Ray Milkey | db35808 | 2015-01-13 16:34:38 -0800 | [diff] [blame] | 756 | } |