@Test public void testDifferentSourceInterfaces() { Prefix routePrefix1 = Prefix.parse("1.0.0.0/8"); Prefix routePrefix2 = Prefix.parse("2.0.0.0/8"); Prefix routePrefix3 = Prefix.parse("3.0.0.0/8"); BDD fwdRouteBdd1 = dstBdd(routePrefix1); BDD fwdRouteBdd2 = dstBdd(routePrefix2); BDD fwdRouteBdd3 = dstBdd(routePrefix3); BDD r1I1Flows = _lastHopMgr .getLastHopOutgoingInterfaceBdd(R1, R1I1, FW, FWI1) .and(fwdRouteBdd1.or(fwdRouteBdd2)); BDD r3I1Flows = _lastHopMgr .getLastHopOutgoingInterfaceBdd(R3, R3I1, FW, FWI2) .and(fwdRouteBdd2.or(fwdRouteBdd3)); BDD inBdd1 = _fwSrcMgr.getSourceInterfaceBDD(FWI1).and(r1I1Flows); BDD inBdd2 = _fwSrcMgr.getSourceInterfaceBDD(FWI2).and(r3I1Flows); BDD tcp = PKT.getIpProtocol().value(IpProtocol.TCP); BDD outBdd = tcp.and(inBdd1.or(inBdd2)); BDD r1I1SessionFlows = tcp.and(srcBdd(routePrefix1).or(srcBdd(routePrefix2))); BDD r3I1SessionFlows = tcp.and(srcBdd(routePrefix2).or(srcBdd(routePrefix3))); Map<StateExpr, BDD> forwardReachableSets = ImmutableMap.of( new PreInInterface(FW, FWI1), inBdd1, new PreInInterface(FW, FWI2), inBdd2, new PreOutEdgePostNat(FW, FWI3, BORDER, BORDER_IFACE), outBdd); Map<String, List<BDDFirewallSessionTraceInfo>> sessions = computeInitializedSessions(forwardReachableSets, TRIVIAL_REVERSE_TRANSFORMATION_RANGES); assertThat(sessions.keySet(), contains(FW)); List<BDDFirewallSessionTraceInfo> fwSessions = sessions.get(FW); assertThat( fwSessions, containsInAnyOrder( allOf( hasHostname(FW), hasIncomingInterfaces(contains(FWI3)), hasAction(new ForwardOutInterface(FWI1, NodeInterfacePair.of(R1, R1I1))), hasSessionFlows(r1I1SessionFlows), hasTransformation(_fwI3ToI1ReverseTransformation)), allOf( hasHostname(FW), hasIncomingInterfaces(contains(FWI3)), hasAction(new ForwardOutInterface(FWI2, NodeInterfacePair.of(R3, R3I1))), hasSessionFlows(r3I1SessionFlows), hasTransformation(_fwI3ToI2ReverseTransformation)))); }
private Map<String, List<BDDFirewallSessionTraceInfo>> computeInitializedSessions() { return _configs.values().stream() .flatMap( config -> { List<BDDFirewallSessionTraceInfo> sessions = computeInitializedSessions(config); return sessions.isEmpty() ? Stream.of() : Stream.of(Maps.immutableEntry(config.getHostname(), sessions)); }) .collect(ImmutableMap.toImmutableMap(Entry::getKey, Entry::getValue)); }
BDDReachabilityAnalysisSessionFactory { private Map<String, List<BDDFirewallSessionTraceInfo>> computeInitializedSessions() { return _configs.values().stream() .flatMap( config -> { List<BDDFirewallSessionTraceInfo> sessions = computeInitializedSessions(config); return sessions.isEmpty() ? Stream.of() : Stream.of(Maps.immutableEntry(config.getHostname(), sessions)); }) .collect(ImmutableMap.toImmutableMap(Entry::getKey, Entry::getValue)); } }
BDDReachabilityAnalysisSessionFactory { private Map<String, List<BDDFirewallSessionTraceInfo>> computeInitializedSessions() { return _configs.values().stream() .flatMap( config -> { List<BDDFirewallSessionTraceInfo> sessions = computeInitializedSessions(config); return sessions.isEmpty() ? Stream.of() : Stream.of(Maps.immutableEntry(config.getHostname(), sessions)); }) .collect(ImmutableMap.toImmutableMap(Entry::getKey, Entry::getValue)); } BDDReachabilityAnalysisSessionFactory(
      BDDPacket bddPacket,
      Map<String, Configuration> configs,
      Map<String, BDDSourceManager> srcManagers,
      LastHopOutgoingInterfaceManager lastHopManager,
      Map<StateExpr, BDD> forwardReachableBdds,
      BDDReverseFlowTransformationFactory transformationFactory,
      BDDReverseTransformationRanges reverseTransformationRanges); }
BDDReachabilityAnalysisSessionFactory { private Map<String, List<BDDFirewallSessionTraceInfo>> computeInitializedSessions() { return _configs.values().stream() .flatMap( config -> { List<BDDFirewallSessionTraceInfo> sessions = computeInitializedSessions(config); return sessions.isEmpty() ? Stream.of() : Stream.of(Maps.immutableEntry(config.getHostname(), sessions)); }) .collect(ImmutableMap.toImmutableMap(Entry::getKey, Entry::getValue)); } BDDReachabilityAnalysisSessionFactory(
      BDDPacket bddPacket,
      Map<String, Configuration> configs,
      Map<String, BDDSourceManager> srcManagers,
      LastHopOutgoingInterfaceManager lastHopManager,
      Map<StateExpr, BDD> forwardReachableBdds,
      BDDReverseFlowTransformationFactory transformationFactory,
      BDDReverseTransformationRanges reverseTransformationRanges);  }
BDDReachabilityAnalysisSessionFactory { private Map<String, List<BDDFirewallSessionTraceInfo>> computeInitializedSessions() { return _configs.values().stream() .flatMap( config -> { List<BDDFirewallSessionTraceInfo> sessions = computeInitializedSessions(config); return sessions.isEmpty() ? Stream.of() : Stream.of(Maps.immutableEntry(config.getHostname(), sessions)); }) .collect(ImmutableMap.toImmutableMap(Entry::getKey, Entry::getValue)); } BDDReachabilityAnalysisSessionFactory(
      BDDPacket bddPacket,
      Map<String, Configuration> configs,
      Map<String, BDDSourceManager> srcManagers,
      LastHopOutgoingInterfaceManager lastHopManager,
      Map<StateExpr, BDD> forwardReachableBdds,
      BDDReverseFlowTransformationFactory transformationFactory,
      BDDReverseTransformationRanges reverseTransformationRanges);   }