@Test public void testReturnFlowTransition() { IpAccessListToBddImpl aclToBdd = new IpAccessListToBddImpl( _pkt, BDDSourceManager.empty(_pkt), ImmutableMap.of(), ImmutableMap.of()); TransformationToTransition toTransition = new TransformationToTransition(_pkt, aclToBdd); IpSpaceToBDD dstToBdd = aclToBdd.getHeaderSpaceToBDD().getDstIpSpaceToBdd(); { Prefix shiftPrefix = Prefix.parse("6.6.0.0/16"); Transition transition = toTransition.toReturnFlowTransition(always().apply(shiftSourceIp(shiftPrefix)).build()); assertThat(transition.transitForward(dstToBdd.toBDD(shiftPrefix)), equalTo(_one)); assertThat(transition.transitForward(dstToBdd.toBDD(shiftPrefix).not()), equalTo(_zero)); assertThat( transition.transitForward(dstToBdd.toBDD(Ip.parse("6.6.6.6"))), equalTo( dstToBdd.toBDD( IpWildcard.ipWithWildcardMask(Ip.parse("0.0.6.6"), Ip.parse("255.255.0.0"))))); assertEquals( transition.transitBackward(dstToBdd.toBDD(Ip.parse("5.5.6.6"))), dstToBdd.toBDD(Ip.parse("6.6.6.6"))); } { Ip poolStart = Ip.parse("6.6.6.3"); Ip poolEnd = Ip.parse("6.6.6.9"); Transition transition = toTransition.toReturnFlowTransition( always().apply(assignSourceIp(poolStart, poolEnd)).build()); BDDInteger dstIp = dstToBdd.getBDDInteger(); BDD poolBdd = dstIp.geq(poolStart.asLong()).and(dstIp.leq(poolEnd.asLong())); assertThat(transition.transitForward(poolBdd), equalTo(_one)); assertThat(transition.transitForward(poolBdd.not()), equalTo(_zero)); assertEquals(transition.transitBackward(dstToBdd.toBDD(Ip.parse("5.5.6.6"))), poolBdd); } }
public Transition toReturnFlowTransition(@Nullable Transformation transformation) { return transformation == null ? IDENTITY : reverse(toTransition(returnFlowTransformation(transformation))); }
TransformationToTransition { public Transition toReturnFlowTransition(@Nullable Transformation transformation) { return transformation == null ? IDENTITY : reverse(toTransition(returnFlowTransformation(transformation))); } }
TransformationToTransition { public Transition toReturnFlowTransition(@Nullable Transformation transformation) { return transformation == null ? IDENTITY : reverse(toTransition(returnFlowTransformation(transformation))); } TransformationToTransition(BDDPacket bddPacket, IpAccessListToBdd ipAccessListToBdd); }
TransformationToTransition { public Transition toReturnFlowTransition(@Nullable Transformation transformation) { return transformation == null ? IDENTITY : reverse(toTransition(returnFlowTransformation(transformation))); } TransformationToTransition(BDDPacket bddPacket, IpAccessListToBdd ipAccessListToBdd); Transition toTransition(@Nullable Transformation transformation); Transition toReturnFlowTransition(@Nullable Transformation transformation); }
TransformationToTransition { public Transition toReturnFlowTransition(@Nullable Transformation transformation) { return transformation == null ? IDENTITY : reverse(toTransition(returnFlowTransformation(transformation))); } TransformationToTransition(BDDPacket bddPacket, IpAccessListToBdd ipAccessListToBdd); Transition toTransition(@Nullable Transformation transformation); Transition toReturnFlowTransition(@Nullable Transformation transformation);  }