@Test public void testDestNat() throws IOException { NetworkFactory nf = new NetworkFactory(); Configuration config = nf.configurationBuilder().setConfigurationFormat(ConfigurationFormat.CISCO_IOS).build(); Vrf vrf = nf.vrfBuilder().setOwner(config).build(); Ip poolIp = Ip.parse("5.5.5.5"); HeaderSpace ingressAclHeaderSpace = HeaderSpace.builder().setSrcIps(Prefix.parse("2.0.0.0/8").toIpSpace()).build(); HeaderSpace natMatchHeaderSpace = HeaderSpace.builder().setSrcPorts(ImmutableList.of(SubRange.singleton(100))).build(); Interface iface = nf.interfaceBuilder() .setOwner(config) .setVrf(vrf) .setActive(true) .setAddress(ConcreteInterfaceAddress.parse("1.0.0.0/8")) .setIncomingFilter( nf.aclBuilder() .setOwner(config) .setLines(ImmutableList.of(acceptingHeaderSpace(ingressAclHeaderSpace))) .build()) .setIncomingTransformation( when(match(natMatchHeaderSpace)) .apply(TransformationStep.assignDestinationIp(poolIp, poolIp)) .build()) .build(); SortedMap<String, Configuration> configs = ImmutableSortedMap.of(config.getHostname(), config); BDDReachabilityAnalysisFactory factory = makeBddReachabilityAnalysisFactory(configs); BDDReachabilityAnalysis analysis = factory.bddReachabilityAnalysis( IpSpaceAssignment.builder() .assign( new InterfaceLinkLocation(config.getHostname(), iface.getName()), UniverseIpSpace.INSTANCE) .build()); Transition transition = analysis .getForwardEdgeMap() .get(new PreInInterface(config.getHostname(), iface.getName())) .get(new PostInInterface(config.getHostname(), iface.getName())); HeaderSpaceToBDD toBDD = new HeaderSpaceToBDD(PKT, ImmutableMap.of()); BDD ingressAclBdd = toBDD.toBDD(ingressAclHeaderSpace); BDD natMatchBdd = toBDD.toBDD(natMatchHeaderSpace); BDD origDstIpBdd = toBDD.getDstIpSpaceToBdd().toBDD(Ip.parse("6.6.6.6")); BDD poolIpBdd = toBDD.getDstIpSpaceToBdd().toBDD(poolIp); assertThat( transition.transitForward(origDstIpBdd), equalTo(ingressAclBdd.and(natMatchBdd.ite(poolIpBdd, origDstIpBdd)))); }
public BDDReachabilityAnalysis bddReachabilityAnalysis(IpSpaceAssignment srcIpSpaceAssignment) { return bddReachabilityAnalysis(srcIpSpaceAssignment, false); }
BDDReachabilityAnalysisFactory { public BDDReachabilityAnalysis bddReachabilityAnalysis(IpSpaceAssignment srcIpSpaceAssignment) { return bddReachabilityAnalysis(srcIpSpaceAssignment, false); } }
BDDReachabilityAnalysisFactory { public BDDReachabilityAnalysis bddReachabilityAnalysis(IpSpaceAssignment srcIpSpaceAssignment) { return bddReachabilityAnalysis(srcIpSpaceAssignment, false); } BDDReachabilityAnalysisFactory(
      BDDPacket packet,
      Map<String, Configuration> configs,
      ForwardingAnalysis forwardingAnalysis,
      IpsRoutedOutInterfacesFactory ipsRoutedOutInterfacesFactory,
      boolean ignoreFilters,
      boolean initializeSessions); }
BDDReachabilityAnalysisFactory { public BDDReachabilityAnalysis bddReachabilityAnalysis(IpSpaceAssignment srcIpSpaceAssignment) { return bddReachabilityAnalysis(srcIpSpaceAssignment, false); } BDDReachabilityAnalysisFactory(
      BDDPacket packet,
      Map<String, Configuration> configs,
      ForwardingAnalysis forwardingAnalysis,
      IpsRoutedOutInterfacesFactory ipsRoutedOutInterfacesFactory,
      boolean ignoreFilters,
      boolean initializeSessions); BDDReachabilityAnalysis bddReachabilityAnalysis(IpSpaceAssignment srcIpSpaceAssignment); BDDReachabilityAnalysis bddReachabilityAnalysis(
      IpSpaceAssignment srcIpSpaceAssignment, boolean useInterfaceRoots); BDDLoopDetectionAnalysis bddLoopDetectionAnalysis(IpSpaceAssignment srcIpSpaceAssignment); Map<IngressLocation, BDD> getAllBDDs(
      IpSpaceAssignment srcIpSpaceAssignment,
      AclLineMatchExpr initialHeaderSpace,
      Set<String> forbiddenTransitNodes,
      Set<String> requiredTransitNodes,
      Set<String> finalNodes,
      Set<FlowDisposition> actions); @VisibleForTesting BDDReachabilityAnalysis bddReachabilityAnalysis(
      IpSpaceAssignment srcIpSpaceAssignment,
      AclLineMatchExpr initialHeaderSpace,
      Set<String> forbiddenTransitNodes,
      Set<String> requiredTransitNodes,
      Set<String> finalNodes,
      Set<FlowDisposition> actions); @VisibleForTesting BDDReachabilityAnalysis bddReachabilityAnalysis(
      IpSpaceAssignment srcIpSpaceAssignment,
      AclLineMatchExpr initialHeaderSpace,
      Set<String> forbiddenTransitNodes,
      Set<String> requiredTransitNodes,
      Set<String> finalNodes,
      Set<FlowDisposition> actions,
      boolean useInterfaceRoots); Map<String, BDDOutgoingOriginalFlowFilterManager> getBddOutgoingOriginalFlowFilterManagers(); Map<String, BDDSourceManager> getBDDSourceManagers(); @Nullable LastHopOutgoingInterfaceManager getLastHopManager(); }
BDDReachabilityAnalysisFactory { public BDDReachabilityAnalysis bddReachabilityAnalysis(IpSpaceAssignment srcIpSpaceAssignment) { return bddReachabilityAnalysis(srcIpSpaceAssignment, false); } BDDReachabilityAnalysisFactory(
      BDDPacket packet,
      Map<String, Configuration> configs,
      ForwardingAnalysis forwardingAnalysis,
      IpsRoutedOutInterfacesFactory ipsRoutedOutInterfacesFactory,
      boolean ignoreFilters,
      boolean initializeSessions); BDDReachabilityAnalysis bddReachabilityAnalysis(IpSpaceAssignment srcIpSpaceAssignment); BDDReachabilityAnalysis bddReachabilityAnalysis(
      IpSpaceAssignment srcIpSpaceAssignment, boolean useInterfaceRoots); BDDLoopDetectionAnalysis bddLoopDetectionAnalysis(IpSpaceAssignment srcIpSpaceAssignment); Map<IngressLocation, BDD> getAllBDDs(
      IpSpaceAssignment srcIpSpaceAssignment,
      AclLineMatchExpr initialHeaderSpace,
      Set<String> forbiddenTransitNodes,
      Set<String> requiredTransitNodes,
      Set<String> finalNodes,
      Set<FlowDisposition> actions); @VisibleForTesting BDDReachabilityAnalysis bddReachabilityAnalysis(
      IpSpaceAssignment srcIpSpaceAssignment,
      AclLineMatchExpr initialHeaderSpace,
      Set<String> forbiddenTransitNodes,
      Set<String> requiredTransitNodes,
      Set<String> finalNodes,
      Set<FlowDisposition> actions); @VisibleForTesting BDDReachabilityAnalysis bddReachabilityAnalysis(
      IpSpaceAssignment srcIpSpaceAssignment,
      AclLineMatchExpr initialHeaderSpace,
      Set<String> forbiddenTransitNodes,
      Set<String> requiredTransitNodes,
      Set<String> finalNodes,
      Set<FlowDisposition> actions,
      boolean useInterfaceRoots); Map<String, BDDOutgoingOriginalFlowFilterManager> getBddOutgoingOriginalFlowFilterManagers(); Map<String, BDDSourceManager> getBDDSourceManagers(); @Nullable LastHopOutgoingInterfaceManager getLastHopManager();  }