@Test public void testGenerateRootEdges_OriginateInterface_PostInVrf() throws IOException { NetworkFactory nf = new NetworkFactory(); Configuration c = nf.configurationBuilder().setConfigurationFormat(ConfigurationFormat.CISCO_IOS).build(); Vrf vrf = nf.vrfBuilder().setOwner(c).build(); Interface.Builder ib = nf.interfaceBuilder().setOwner(c).setVrf(vrf).setActive(true); Interface iface1 = ib.setAddress(ConcreteInterfaceAddress.parse("1.1.1.1/24")).build(); ib.setAddress(ConcreteInterfaceAddress.parse("2.2.2.2/24")).build(); SortedMap<String, Configuration> configs = ImmutableSortedMap.of(c.getHostname(), c); BDDReachabilityAnalysisFactory factory = makeBddReachabilityAnalysisFactory(configs); OriginateInterface originateIface1 = new OriginateInterface(c.getHostname(), iface1.getName()); BDD rootBdd = PKT.getDstIp().value(Ip.parse("3.3.3.3").asLong()); List<Edge> rootEdges = factory .generateRootEdges_OriginateInterface_PostInVrf( ImmutableMap.of(originateIface1, rootBdd)) .collect(ImmutableList.toImmutableList()); assertThat( rootEdges, contains( new Edge( originateIface1, new PostInVrf(c.getHostname(), vrf.getName()), compose( addOriginatingFromDeviceConstraint( factory.getBDDSourceManagers().get(c.getHostname())), constraint(rootBdd))))); }
@VisibleForTesting Stream<Edge> generateRootEdges_OriginateInterface_PostInVrf(Map<StateExpr, BDD> rootBdds) { return rootBdds.entrySet().stream() .filter(e -> e.getKey() instanceof OriginateInterface) .map( e -> { OriginateInterface state = (OriginateInterface) e.getKey(); String vrf = _interfacesToVrfsMap.get(state.getHostname()).get(state.getInterface()); PostInVrf postInVrf = new PostInVrf(state.getHostname(), vrf); String hostname = state.getHostname(); return new Edge( state, postInVrf, compose( addOriginatingFromDeviceConstraint(_bddSourceManagers.get(hostname)), addOutgoingOriginalFlowFiltersConstraint( _bddOutgoingOriginalFlowFilterManagers.get(hostname)), constraint(e.getValue()))); }); }
BDDReachabilityAnalysisFactory { @VisibleForTesting Stream<Edge> generateRootEdges_OriginateInterface_PostInVrf(Map<StateExpr, BDD> rootBdds) { return rootBdds.entrySet().stream() .filter(e -> e.getKey() instanceof OriginateInterface) .map( e -> { OriginateInterface state = (OriginateInterface) e.getKey(); String vrf = _interfacesToVrfsMap.get(state.getHostname()).get(state.getInterface()); PostInVrf postInVrf = new PostInVrf(state.getHostname(), vrf); String hostname = state.getHostname(); return new Edge( state, postInVrf, compose( addOriginatingFromDeviceConstraint(_bddSourceManagers.get(hostname)), addOutgoingOriginalFlowFiltersConstraint( _bddOutgoingOriginalFlowFilterManagers.get(hostname)), constraint(e.getValue()))); }); } }
BDDReachabilityAnalysisFactory { @VisibleForTesting Stream<Edge> generateRootEdges_OriginateInterface_PostInVrf(Map<StateExpr, BDD> rootBdds) { return rootBdds.entrySet().stream() .filter(e -> e.getKey() instanceof OriginateInterface) .map( e -> { OriginateInterface state = (OriginateInterface) e.getKey(); String vrf = _interfacesToVrfsMap.get(state.getHostname()).get(state.getInterface()); PostInVrf postInVrf = new PostInVrf(state.getHostname(), vrf); String hostname = state.getHostname(); return new Edge( state, postInVrf, compose( addOriginatingFromDeviceConstraint(_bddSourceManagers.get(hostname)), addOutgoingOriginalFlowFiltersConstraint( _bddOutgoingOriginalFlowFilterManagers.get(hostname)), constraint(e.getValue()))); }); } BDDReachabilityAnalysisFactory(
      BDDPacket packet,
      Map<String, Configuration> configs,
      ForwardingAnalysis forwardingAnalysis,
      IpsRoutedOutInterfacesFactory ipsRoutedOutInterfacesFactory,
      boolean ignoreFilters,
      boolean initializeSessions); }
BDDReachabilityAnalysisFactory { @VisibleForTesting Stream<Edge> generateRootEdges_OriginateInterface_PostInVrf(Map<StateExpr, BDD> rootBdds) { return rootBdds.entrySet().stream() .filter(e -> e.getKey() instanceof OriginateInterface) .map( e -> { OriginateInterface state = (OriginateInterface) e.getKey(); String vrf = _interfacesToVrfsMap.get(state.getHostname()).get(state.getInterface()); PostInVrf postInVrf = new PostInVrf(state.getHostname(), vrf); String hostname = state.getHostname(); return new Edge( state, postInVrf, compose( addOriginatingFromDeviceConstraint(_bddSourceManagers.get(hostname)), addOutgoingOriginalFlowFiltersConstraint( _bddOutgoingOriginalFlowFilterManagers.get(hostname)), constraint(e.getValue()))); }); } 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 { @VisibleForTesting Stream<Edge> generateRootEdges_OriginateInterface_PostInVrf(Map<StateExpr, BDD> rootBdds) { return rootBdds.entrySet().stream() .filter(e -> e.getKey() instanceof OriginateInterface) .map( e -> { OriginateInterface state = (OriginateInterface) e.getKey(); String vrf = _interfacesToVrfsMap.get(state.getHostname()).get(state.getInterface()); PostInVrf postInVrf = new PostInVrf(state.getHostname(), vrf); String hostname = state.getHostname(); return new Edge( state, postInVrf, compose( addOriginatingFromDeviceConstraint(_bddSourceManagers.get(hostname)), addOutgoingOriginalFlowFiltersConstraint( _bddOutgoingOriginalFlowFilterManagers.get(hostname)), constraint(e.getValue()))); }); } 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();  }