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