@Test public void testSrcNatNullPool() 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 preNatAclHeaderSpace = HeaderSpace.builder().setDstIps(Prefix.parse("2.0.0.0/24").toIpSpace()).build(); HeaderSpace nat1MatchHeaderSpace = HeaderSpace.builder().setSrcPorts(ImmutableList.of(SubRange.singleton(105))).build(); HeaderSpace nat2MatchHeaderSpace = HeaderSpace.builder().setSrcPorts(ImmutableList.of(new SubRange(100, 110))).build(); Interface iface = nf.interfaceBuilder() .setOwner(config) .setVrf(vrf) .setActive(true) .setAddress(ConcreteInterfaceAddress.parse("1.0.0.1/24")) .setPreTransformationOutgoingFilter( nf.aclBuilder() .setOwner(config) .setLines(ImmutableList.of(acceptingHeaderSpace(preNatAclHeaderSpace))) .build()) .setOutgoingTransformation( when(match(nat1MatchHeaderSpace)) .apply(NOOP_SOURCE_NAT) .setOrElse( when(match(nat2MatchHeaderSpace)) .apply(assignSourceIp(poolIp, poolIp)) .build()) .build()) .build(); String ifaceName = iface.getName(); SortedMap<String, Configuration> configs = ImmutableSortedMap.of(config.getHostname(), config); BDDReachabilityAnalysisFactory factory = makeBddReachabilityAnalysisFactory(configs); BDDReachabilityAnalysis analysis = factory.bddReachabilityAnalysis( IpSpaceAssignment.builder() .assign( new InterfaceLinkLocation(config.getHostname(), ifaceName), UniverseIpSpace.INSTANCE) .build()); Transition transition = analysis .getForwardEdgeMap() .get(new PreOutInterfaceDeliveredToSubnet(config.getHostname(), ifaceName)) .get(new NodeInterfaceDeliveredToSubnet(config.getHostname(), ifaceName)); HeaderSpaceToBDD toBDD = new HeaderSpaceToBDD(PKT, ImmutableMap.of()); BDD preNatAclBdd = toBDD.toBDD(preNatAclHeaderSpace); BDD nat1MatchBdd = toBDD.toBDD(nat1MatchHeaderSpace); BDD nat2MatchBdd = toBDD.toBDD(nat2MatchHeaderSpace); BDD origSrcIpBdd = toBDD.getSrcIpSpaceToBdd().toBDD(Ip.parse("6.6.6.6")); BDD poolIpBdd = toBDD.getSrcIpSpaceToBdd().toBDD(poolIp); assertThat( transition.transitForward(origSrcIpBdd), equalTo( preNatAclBdd.and(nat1MatchBdd.not().and(nat2MatchBdd).ite(poolIpBdd, origSrcIpBdd)))); }
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();  }