Carmelo Cascone | 00a5996 | 2017-06-16 17:51:49 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present 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 | */ |
| 16 | |
| 17 | package org.onosproject.net.pi.impl; |
| 18 | |
| 19 | import org.onlab.util.ImmutableByteSequence; |
| 20 | import org.onosproject.net.flow.criteria.Criterion; |
| 21 | import org.onosproject.net.flow.criteria.EthCriterion; |
| 22 | import org.onosproject.net.flow.criteria.EthTypeCriterion; |
| 23 | import org.onosproject.net.flow.criteria.IPCriterion; |
| 24 | import org.onosproject.net.flow.criteria.PortCriterion; |
zhiyong ke | f2e6a48 | 2017-07-10 20:32:20 +0800 | [diff] [blame] | 25 | import org.onosproject.net.flow.criteria.VlanIdCriterion; |
| 26 | import org.onosproject.net.flow.criteria.UdpPortCriterion; |
| 27 | import org.onosproject.net.flow.criteria.ExtensionCriterion; |
| 28 | import org.onosproject.net.flow.criteria.IPDscpCriterion; |
| 29 | import org.onosproject.net.flow.criteria.IPProtocolCriterion; |
| 30 | import org.onosproject.net.flow.criteria.IPv6ExthdrFlagsCriterion; |
| 31 | import org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion; |
| 32 | import org.onosproject.net.flow.criteria.IcmpCodeCriterion; |
| 33 | import org.onosproject.net.flow.criteria.IcmpTypeCriterion; |
| 34 | import org.onosproject.net.flow.criteria.Icmpv6CodeCriterion; |
| 35 | import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion; |
| 36 | import org.onosproject.net.flow.criteria.LambdaCriterion; |
| 37 | import org.onosproject.net.flow.criteria.MetadataCriterion; |
| 38 | import org.onosproject.net.flow.criteria.MplsBosCriterion; |
| 39 | import org.onosproject.net.flow.criteria.MplsCriterion; |
| 40 | import org.onosproject.net.flow.criteria.MplsTcCriterion; |
| 41 | import org.onosproject.net.flow.criteria.OchSignalCriterion; |
| 42 | import org.onosproject.net.flow.criteria.OchSignalTypeCriterion; |
| 43 | import org.onosproject.net.flow.criteria.OduSignalIdCriterion; |
| 44 | import org.onosproject.net.flow.criteria.OduSignalTypeCriterion; |
| 45 | import org.onosproject.net.flow.criteria.PbbIsidCriterion; |
| 46 | import org.onosproject.net.flow.criteria.PiCriterion; |
| 47 | import org.onosproject.net.flow.criteria.SctpPortCriterion; |
| 48 | import org.onosproject.net.flow.criteria.TcpFlagsCriterion; |
| 49 | import org.onosproject.net.flow.criteria.TcpPortCriterion; |
| 50 | import org.onosproject.net.flow.criteria.TunnelIdCriterion; |
| 51 | import org.onosproject.net.flow.criteria.VlanPcpCriterion; |
| 52 | import org.onosproject.net.flow.criteria.ArpHaCriterion; |
| 53 | import org.onosproject.net.flow.criteria.ArpOpCriterion; |
| 54 | import org.onosproject.net.flow.criteria.ArpPaCriterion; |
| 55 | import org.onosproject.net.flow.criteria.IPv6NDLinkLayerAddressCriterion; |
| 56 | import org.onosproject.net.flow.criteria.IPv6NDTargetAddressCriterion; |
zhiyong ke | 897fd2d | 2017-07-12 11:41:38 +0800 | [diff] [blame^] | 57 | import org.onosproject.net.flow.criteria.IPEcnCriterion; |
Carmelo Cascone | 00a5996 | 2017-06-16 17:51:49 +0900 | [diff] [blame] | 58 | |
| 59 | import static org.onlab.util.ImmutableByteSequence.ByteSequenceTrimException; |
| 60 | import static org.onlab.util.ImmutableByteSequence.copyFrom; |
| 61 | |
| 62 | /** |
| 63 | * Factory class of criterion translator implementations. |
| 64 | */ |
| 65 | final class CriterionTranslators { |
| 66 | |
| 67 | /** |
| 68 | * Translator of PortCriterion. |
| 69 | */ |
| 70 | static final class PortCriterionTranslator extends AbstractCriterionTranslator { |
| 71 | @Override |
| 72 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 73 | PortCriterion c = (PortCriterion) criterion; |
| 74 | initAsExactMatch(copyFrom(c.port().toLong()), bitWidth); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Translator of EthTypeCriterion. |
| 80 | */ |
| 81 | static final class EthTypeCriterionTranslator extends AbstractCriterionTranslator { |
| 82 | @Override |
| 83 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 84 | EthTypeCriterion c = (EthTypeCriterion) criterion; |
| 85 | initAsExactMatch(copyFrom(c.ethType().toShort()), bitWidth); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Translator of EthCriterion. |
| 91 | */ |
| 92 | static final class EthCriterionTranslator extends AbstractCriterionTranslator { |
| 93 | @Override |
| 94 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 95 | EthCriterion c = (EthCriterion) criterion; |
| 96 | ImmutableByteSequence value = copyFrom(c.mac().toBytes()); |
| 97 | if (c.mask() == null) { |
| 98 | initAsExactMatch(value, bitWidth); |
| 99 | } else { |
| 100 | ImmutableByteSequence mask = copyFrom(c.mask().toBytes()); |
| 101 | initAsTernaryMatch(value, mask, bitWidth); |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Translator of IpCriterion. |
| 108 | */ |
| 109 | static final class IpCriterionTranslator extends AbstractCriterionTranslator { |
zhiyong ke | f2e6a48 | 2017-07-10 20:32:20 +0800 | [diff] [blame] | 110 | @Override |
Carmelo Cascone | 00a5996 | 2017-06-16 17:51:49 +0900 | [diff] [blame] | 111 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 112 | IPCriterion c = (IPCriterion) criterion; |
| 113 | initAsLpm(copyFrom(c.ip().address().toOctets()), c.ip().prefixLength(), bitWidth); |
| 114 | } |
| 115 | } |
zhiyong ke | f2e6a48 | 2017-07-10 20:32:20 +0800 | [diff] [blame] | 116 | |
| 117 | /** |
| 118 | * Translator of VlanIdCriterion. |
| 119 | */ |
| 120 | static final class VlanIdCriterionTranslator extends AbstractCriterionTranslator { |
| 121 | @Override |
| 122 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 123 | VlanIdCriterion c = (VlanIdCriterion) criterion; |
| 124 | initAsExactMatch(copyFrom(c.vlanId().toShort()), bitWidth); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Translator of UdpPortCriterion. |
| 130 | */ |
| 131 | static final class UdpPortCriterionTranslator extends AbstractCriterionTranslator { |
| 132 | @Override |
| 133 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 134 | UdpPortCriterion c = (UdpPortCriterion) criterion; |
| 135 | ImmutableByteSequence value = copyFrom(c.udpPort().toInt()); |
| 136 | if (c.mask() == null) { |
| 137 | initAsExactMatch(value, bitWidth); |
| 138 | } else { |
| 139 | ImmutableByteSequence mask = copyFrom(c.mask().toInt()); |
| 140 | initAsTernaryMatch(value, mask, bitWidth); |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Translator of ExtensionCriterion. |
| 147 | */ |
| 148 | static final class ExtensionCriterionTranslator extends AbstractCriterionTranslator { |
| 149 | @Override |
| 150 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 151 | ExtensionCriterion c = (ExtensionCriterion) criterion; |
| 152 | initAsExactMatch(copyFrom(c.extensionSelector().type().toInt()), bitWidth); |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Translator of IPDscpCriterion. |
| 158 | */ |
| 159 | static final class IPDscpCriterionTranslator extends AbstractCriterionTranslator { |
| 160 | @Override |
| 161 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 162 | IPDscpCriterion c = (IPDscpCriterion) criterion; |
| 163 | ImmutableByteSequence value = copyFrom(c.ipDscp()); |
| 164 | initAsExactMatch(value, bitWidth); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * Translator of IPProtocolCriterion. |
| 170 | */ |
| 171 | static final class IPProtocolCriterionTranslator extends AbstractCriterionTranslator { |
| 172 | @Override |
| 173 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 174 | IPProtocolCriterion c = (IPProtocolCriterion) criterion; |
| 175 | initAsExactMatch(copyFrom(c.protocol()), bitWidth); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Translator of IPv6ExthdrFlagsCriterion. |
| 181 | */ |
| 182 | static final class IPv6ExthdrFlagsCriterionTranslator extends AbstractCriterionTranslator { |
| 183 | @Override |
| 184 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 185 | IPv6ExthdrFlagsCriterion c = (IPv6ExthdrFlagsCriterion) criterion; |
| 186 | initAsExactMatch(copyFrom(c.exthdrFlags()), bitWidth); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * Translator of IPv6FlowLabelCriterion. |
| 192 | */ |
| 193 | static final class IPv6FlowLabelCriterionTranslator extends AbstractCriterionTranslator { |
| 194 | @Override |
| 195 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 196 | IPv6FlowLabelCriterion c = (IPv6FlowLabelCriterion) criterion; |
| 197 | initAsExactMatch(copyFrom(c.flowLabel()), bitWidth); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * Translator of IPv6NDLinkLayerAddressCriterion. |
| 203 | */ |
| 204 | static final class IPv6NDLinkLayerAddressCriterionTranslator extends AbstractCriterionTranslator { |
| 205 | @Override |
| 206 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 207 | IPv6NDLinkLayerAddressCriterion c = (IPv6NDLinkLayerAddressCriterion) criterion; |
| 208 | initAsExactMatch(copyFrom(c.mac().toLong()), bitWidth); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Translator of IPv6NDTargetAddressCriterion. |
| 214 | */ |
| 215 | static final class IPv6NDTargetAddressCriterionTranslator extends AbstractCriterionTranslator { |
| 216 | @Override |
| 217 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 218 | IPv6NDTargetAddressCriterion c = (IPv6NDTargetAddressCriterion) criterion; |
| 219 | initAsExactMatch(copyFrom(c.targetAddress().getIp6Address().toOctets()), bitWidth); |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | /** |
| 224 | * Translator of IcmpCodeCriterion. |
| 225 | */ |
| 226 | static final class IcmpCodeCriterionTranslator extends AbstractCriterionTranslator { |
| 227 | @Override |
| 228 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 229 | IcmpCodeCriterion c = (IcmpCodeCriterion) criterion; |
| 230 | initAsExactMatch(copyFrom(c.icmpCode()), bitWidth); |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * Translator of IcmpTypeCriterion. |
| 236 | */ |
| 237 | static final class IcmpTypeCriterionTranslator extends AbstractCriterionTranslator { |
| 238 | @Override |
| 239 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 240 | IcmpTypeCriterion c = (IcmpTypeCriterion) criterion; |
| 241 | initAsExactMatch(copyFrom(c.icmpType()), bitWidth); |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | /** |
| 246 | * Translator of Icmpv6CodeCriterion. |
| 247 | */ |
| 248 | static final class Icmpv6CodeCriterionTranslator extends AbstractCriterionTranslator { |
| 249 | @Override |
| 250 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 251 | Icmpv6CodeCriterion c = (Icmpv6CodeCriterion) criterion; |
| 252 | initAsExactMatch(copyFrom(c.icmpv6Code()), bitWidth); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * Translator of Icmpv6TypeCriterion. |
| 258 | */ |
| 259 | static final class Icmpv6TypeCriterionTranslator extends AbstractCriterionTranslator { |
| 260 | @Override |
| 261 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 262 | Icmpv6TypeCriterion c = (Icmpv6TypeCriterion) criterion; |
| 263 | initAsExactMatch(copyFrom(c.icmpv6Type()), bitWidth); |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | /** |
| 268 | * Translator of LambdaCriterion. |
| 269 | */ |
| 270 | static final class LambdaCriterionTranslator extends AbstractCriterionTranslator { |
| 271 | @Override |
| 272 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 273 | LambdaCriterion c = (LambdaCriterion) criterion; |
| 274 | initAsExactMatch(copyFrom(c.lambda()), bitWidth); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | /** |
| 279 | * Translator of MetadataCriterion. |
| 280 | */ |
| 281 | static final class MetadataCriterionTranslator extends AbstractCriterionTranslator { |
| 282 | @Override |
| 283 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 284 | MetadataCriterion c = (MetadataCriterion) criterion; |
| 285 | initAsExactMatch(copyFrom(c.metadata()), bitWidth); |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | /** |
| 290 | * Translator of MplsBosCriterion. |
| 291 | */ |
| 292 | static final class MplsBosCriterionTranslator extends AbstractCriterionTranslator { |
| 293 | @Override |
| 294 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 295 | MplsBosCriterion c = (MplsBosCriterion) criterion; |
| 296 | int iMplsBos = c.mplsBos() ? 0 : 1; |
| 297 | initAsExactMatch(copyFrom(iMplsBos), bitWidth); |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | /** |
| 302 | * Translator of MplsCriterion. |
| 303 | */ |
| 304 | static final class MplsCriterionTranslator extends AbstractCriterionTranslator { |
| 305 | @Override |
| 306 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 307 | MplsCriterion c = (MplsCriterion) criterion; |
| 308 | initAsExactMatch(copyFrom(c.label().toInt()), bitWidth); |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | /** |
| 313 | * Translator of MplsTcCriterion. |
| 314 | */ |
| 315 | static final class MplsTcCriterionTranslator extends AbstractCriterionTranslator { |
| 316 | @Override |
| 317 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 318 | MplsTcCriterion c = (MplsTcCriterion) criterion; |
| 319 | initAsExactMatch(copyFrom(c.tc()), bitWidth); |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | /** |
| 324 | * Translator of OchSignalCriterion. |
| 325 | */ |
| 326 | static final class OchSignalCriterionTranslator extends AbstractCriterionTranslator { |
| 327 | @Override |
| 328 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 329 | OchSignalCriterion c = (OchSignalCriterion) criterion; |
| 330 | initAsExactMatch(copyFrom(c.lambda().slotGranularity()), bitWidth); |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | /** |
| 335 | * Translator of OchSignalTypeCriterion. |
| 336 | */ |
| 337 | static final class OchSignalTypeCriterionTranslator extends AbstractCriterionTranslator { |
| 338 | @Override |
| 339 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 340 | OchSignalTypeCriterion c = (OchSignalTypeCriterion) criterion; |
| 341 | initAsExactMatch(copyFrom(c.signalType().ordinal()), bitWidth); |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | /** |
| 346 | * Translator of OduSignalIdCriterion. |
| 347 | */ |
| 348 | static final class OduSignalIdCriterionTranslator extends AbstractCriterionTranslator { |
| 349 | @Override |
| 350 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 351 | OduSignalIdCriterion c = (OduSignalIdCriterion) criterion; |
| 352 | initAsExactMatch(copyFrom(c.oduSignalId().tributaryPortNumber()), bitWidth); |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | |
| 357 | /** |
| 358 | * Translator of OduSignalTypeCriterion. |
| 359 | */ |
| 360 | static final class OduSignalTypeCriterionTranslator extends AbstractCriterionTranslator { |
| 361 | @Override |
| 362 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 363 | OduSignalTypeCriterion c = (OduSignalTypeCriterion) criterion; |
| 364 | initAsExactMatch(copyFrom(c.signalType().bitRate()), bitWidth); |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | /** |
| 369 | * Translator of PbbIsidCriterion. |
| 370 | */ |
| 371 | static final class PbbIsidCriterionTranslator extends AbstractCriterionTranslator { |
| 372 | @Override |
| 373 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 374 | PbbIsidCriterion c = (PbbIsidCriterion) criterion; |
| 375 | initAsExactMatch(copyFrom(c.pbbIsid()), bitWidth); |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | /** |
| 380 | * Translator of PiCriterion. |
| 381 | */ |
| 382 | static final class PiCriterionTranslator extends AbstractCriterionTranslator { |
| 383 | @Override |
| 384 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 385 | PiCriterion c = (PiCriterion) criterion; |
| 386 | initAsExactMatch(copyFrom(c.fieldMatches().size()), bitWidth); |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | /** |
| 391 | * Translator of SctpPortCriterion. |
| 392 | */ |
| 393 | static final class SctpPortCriterionTranslator extends AbstractCriterionTranslator { |
| 394 | @Override |
| 395 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 396 | SctpPortCriterion c = (SctpPortCriterion) criterion; |
| 397 | ImmutableByteSequence value = copyFrom(c.sctpPort().toInt()); |
| 398 | if (c.mask() == null) { |
| 399 | initAsExactMatch(value, bitWidth); |
| 400 | } else { |
| 401 | ImmutableByteSequence mask = copyFrom(c.mask().toInt()); |
| 402 | initAsTernaryMatch(value, mask, bitWidth); |
| 403 | } |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | /** |
| 408 | * Translator of TcpFlagsCriterion. |
| 409 | */ |
| 410 | static final class TcpFlagsCriterionTranslator extends AbstractCriterionTranslator { |
| 411 | @Override |
| 412 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 413 | TcpFlagsCriterion c = (TcpFlagsCriterion) criterion; |
| 414 | initAsExactMatch(copyFrom(c.flags()), bitWidth); |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | /** |
| 419 | * Translator of TcpPortCriterion. |
| 420 | */ |
| 421 | static final class TcpPortCriterionTranslator extends AbstractCriterionTranslator { |
| 422 | @Override |
| 423 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 424 | TcpPortCriterion c = (TcpPortCriterion) criterion; |
| 425 | ImmutableByteSequence value = copyFrom(c.tcpPort().toInt()); |
| 426 | if (c.mask() == null) { |
| 427 | initAsExactMatch(value, bitWidth); |
| 428 | } else { |
| 429 | ImmutableByteSequence mask = copyFrom(c.mask().toInt()); |
| 430 | initAsTernaryMatch(value, mask, bitWidth); |
| 431 | } |
| 432 | |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | /** |
| 437 | * Translator of TunnelIdCriterion. |
| 438 | */ |
| 439 | static final class TunnelIdCriterionTranslator extends AbstractCriterionTranslator { |
| 440 | @Override |
| 441 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 442 | TunnelIdCriterion c = (TunnelIdCriterion) criterion; |
| 443 | initAsExactMatch(copyFrom(c.tunnelId()), bitWidth); |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | /** |
| 448 | * Translator of VlanPcpCriterion. |
| 449 | */ |
| 450 | static final class VlanPcpCriterionTranslator extends AbstractCriterionTranslator { |
| 451 | @Override |
| 452 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 453 | VlanPcpCriterion c = (VlanPcpCriterion) criterion; |
| 454 | initAsExactMatch(copyFrom(c.priority()), bitWidth); |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | /** |
| 459 | * Translator of ArpHaCriterion. |
| 460 | */ |
| 461 | static final class ArpHaCriterionTranslator extends AbstractCriterionTranslator { |
| 462 | @Override |
| 463 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 464 | ArpHaCriterion c = (ArpHaCriterion) criterion; |
| 465 | initAsExactMatch(copyFrom(c.mac().toLong()), bitWidth); |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | /** |
| 470 | * Translator of ArpOpCriterion. |
| 471 | */ |
| 472 | static final class ArpOpCriterionTranslator extends AbstractCriterionTranslator { |
| 473 | @Override |
| 474 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 475 | ArpOpCriterion c = (ArpOpCriterion) criterion; |
| 476 | initAsExactMatch(copyFrom(c.arpOp()), bitWidth); |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | /** |
| 481 | * Translator of ArpPaCriterion. |
| 482 | */ |
| 483 | static final class ArpPaCriterionTranslator extends AbstractCriterionTranslator { |
| 484 | @Override |
| 485 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 486 | ArpPaCriterion c = (ArpPaCriterion) criterion; |
| 487 | initAsExactMatch(copyFrom(c.ip().toInt()), bitWidth); |
| 488 | } |
| 489 | } |
| 490 | |
zhiyong ke | 897fd2d | 2017-07-12 11:41:38 +0800 | [diff] [blame^] | 491 | /** |
| 492 | * Translator of IPEcnCriterion. |
| 493 | */ |
| 494 | static final class IPEcnCriterionTranslator extends AbstractCriterionTranslator { |
| 495 | @Override |
| 496 | public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { |
| 497 | IPEcnCriterion c = (IPEcnCriterion) criterion; |
| 498 | initAsExactMatch(copyFrom(c.ipEcn()), bitWidth); |
| 499 | } |
| 500 | } |
Carmelo Cascone | 00a5996 | 2017-06-16 17:51:49 +0900 | [diff] [blame] | 501 | } |