@Test public void testDestinationIpSpace() throws InvalidReachabilityParametersException { Builder reachabilityParametersBuilder = ReachabilityParameters.builder() .setActions(ImmutableSortedSet.of(ACCEPTED)) .setSourceIpSpaceSpecifier(new ConstantIpSpaceSpecifier(UniverseIpSpace.INSTANCE)) .setFinalNodesSpecifier(AllNodesNodeSpecifier.INSTANCE); ReachabilityParameters reachabilityParameters = reachabilityParametersBuilder.build(); ResolvedReachabilityParameters resolvedReachabilityParameters = resolveReachabilityParameters(_batfish, reachabilityParameters, _snapshot); assertThat( resolvedReachabilityParameters.getHeaderSpace(), equalTo( AclLineMatchExprs.and( AclLineMatchExprs.TRUE, AclLineMatchExprs.matchDst(UniverseIpSpace.INSTANCE)))); IpIpSpace dstIpSpace = Ip.parse("1.1.1.1").toIpSpace(); reachabilityParameters = reachabilityParametersBuilder .setDestinationIpSpaceSpecifier(new ConstantIpSpaceSpecifier(dstIpSpace)) .build(); resolvedReachabilityParameters = resolveReachabilityParameters(_batfish, reachabilityParameters, _snapshot); assertThat( resolvedReachabilityParameters.getHeaderSpace(), equalTo( AclLineMatchExprs.and(AclLineMatchExprs.TRUE, AclLineMatchExprs.matchDst(dstIpSpace)))); }
public static ResolvedReachabilityParameters resolveReachabilityParameters( IBatfish batfish, ReachabilityParameters params, NetworkSnapshot snapshot) throws InvalidReachabilityParametersException { ReachabilityParametersResolver resolver = new ReachabilityParametersResolver(batfish, params, snapshot); SpecifierContext context = resolver._context; SortedSet<FlowDisposition> actions = params.getActions(); if (actions.isEmpty()) { throw new InvalidReachabilityParametersException("No actions"); } Set<String> finalNodes = params.getFinalNodesSpecifier().resolve(context); if (finalNodes.isEmpty()) { throw new InvalidReachabilityParametersException("No final nodes"); } Set<String> forbiddenTransitNodes = params.getForbiddenTransitNodesSpecifier().resolve(context); Set<String> requiredTransitNodes = params.getRequiredTransitNodesSpecifier().resolve(context); if (!requiredTransitNodes.isEmpty() && forbiddenTransitNodes.containsAll(requiredTransitNodes)) { throw new InvalidReachabilityParametersException( "All required transit nodes are also forbidden"); } return ResolvedReachabilityParameters.builder() .setActions(actions) .setFinalNodes(finalNodes) .setForbiddenTransitNodes(forbiddenTransitNodes) .setHeaderSpace(resolver.resolveHeaderSpace()) .setIgnoreFilters(params.getIgnoreFilters()) .setMaxChunkSize(params.getMaxChunkSize()) .setSourceIpSpaceAssignment(resolver.resolveSourceIpSpaceAssignment()) .setSrcNatted(params.getSrcNatted()) .setSpecialize(params.getSpecialize()) .setRequiredTransitNodes(requiredTransitNodes) .build(); }
ReachabilityParametersResolver { public static ResolvedReachabilityParameters resolveReachabilityParameters( IBatfish batfish, ReachabilityParameters params, NetworkSnapshot snapshot) throws InvalidReachabilityParametersException { ReachabilityParametersResolver resolver = new ReachabilityParametersResolver(batfish, params, snapshot); SpecifierContext context = resolver._context; SortedSet<FlowDisposition> actions = params.getActions(); if (actions.isEmpty()) { throw new InvalidReachabilityParametersException("No actions"); } Set<String> finalNodes = params.getFinalNodesSpecifier().resolve(context); if (finalNodes.isEmpty()) { throw new InvalidReachabilityParametersException("No final nodes"); } Set<String> forbiddenTransitNodes = params.getForbiddenTransitNodesSpecifier().resolve(context); Set<String> requiredTransitNodes = params.getRequiredTransitNodesSpecifier().resolve(context); if (!requiredTransitNodes.isEmpty() && forbiddenTransitNodes.containsAll(requiredTransitNodes)) { throw new InvalidReachabilityParametersException( "All required transit nodes are also forbidden"); } return ResolvedReachabilityParameters.builder() .setActions(actions) .setFinalNodes(finalNodes) .setForbiddenTransitNodes(forbiddenTransitNodes) .setHeaderSpace(resolver.resolveHeaderSpace()) .setIgnoreFilters(params.getIgnoreFilters()) .setMaxChunkSize(params.getMaxChunkSize()) .setSourceIpSpaceAssignment(resolver.resolveSourceIpSpaceAssignment()) .setSrcNatted(params.getSrcNatted()) .setSpecialize(params.getSpecialize()) .setRequiredTransitNodes(requiredTransitNodes) .build(); } }
ReachabilityParametersResolver { public static ResolvedReachabilityParameters resolveReachabilityParameters( IBatfish batfish, ReachabilityParameters params, NetworkSnapshot snapshot) throws InvalidReachabilityParametersException { ReachabilityParametersResolver resolver = new ReachabilityParametersResolver(batfish, params, snapshot); SpecifierContext context = resolver._context; SortedSet<FlowDisposition> actions = params.getActions(); if (actions.isEmpty()) { throw new InvalidReachabilityParametersException("No actions"); } Set<String> finalNodes = params.getFinalNodesSpecifier().resolve(context); if (finalNodes.isEmpty()) { throw new InvalidReachabilityParametersException("No final nodes"); } Set<String> forbiddenTransitNodes = params.getForbiddenTransitNodesSpecifier().resolve(context); Set<String> requiredTransitNodes = params.getRequiredTransitNodesSpecifier().resolve(context); if (!requiredTransitNodes.isEmpty() && forbiddenTransitNodes.containsAll(requiredTransitNodes)) { throw new InvalidReachabilityParametersException( "All required transit nodes are also forbidden"); } return ResolvedReachabilityParameters.builder() .setActions(actions) .setFinalNodes(finalNodes) .setForbiddenTransitNodes(forbiddenTransitNodes) .setHeaderSpace(resolver.resolveHeaderSpace()) .setIgnoreFilters(params.getIgnoreFilters()) .setMaxChunkSize(params.getMaxChunkSize()) .setSourceIpSpaceAssignment(resolver.resolveSourceIpSpaceAssignment()) .setSrcNatted(params.getSrcNatted()) .setSpecialize(params.getSpecialize()) .setRequiredTransitNodes(requiredTransitNodes) .build(); } @VisibleForTesting  ReachabilityParametersResolver(
      IBatfish batfish, ReachabilityParameters params, NetworkSnapshot snapshot); }
ReachabilityParametersResolver { public static ResolvedReachabilityParameters resolveReachabilityParameters( IBatfish batfish, ReachabilityParameters params, NetworkSnapshot snapshot) throws InvalidReachabilityParametersException { ReachabilityParametersResolver resolver = new ReachabilityParametersResolver(batfish, params, snapshot); SpecifierContext context = resolver._context; SortedSet<FlowDisposition> actions = params.getActions(); if (actions.isEmpty()) { throw new InvalidReachabilityParametersException("No actions"); } Set<String> finalNodes = params.getFinalNodesSpecifier().resolve(context); if (finalNodes.isEmpty()) { throw new InvalidReachabilityParametersException("No final nodes"); } Set<String> forbiddenTransitNodes = params.getForbiddenTransitNodesSpecifier().resolve(context); Set<String> requiredTransitNodes = params.getRequiredTransitNodesSpecifier().resolve(context); if (!requiredTransitNodes.isEmpty() && forbiddenTransitNodes.containsAll(requiredTransitNodes)) { throw new InvalidReachabilityParametersException( "All required transit nodes are also forbidden"); } return ResolvedReachabilityParameters.builder() .setActions(actions) .setFinalNodes(finalNodes) .setForbiddenTransitNodes(forbiddenTransitNodes) .setHeaderSpace(resolver.resolveHeaderSpace()) .setIgnoreFilters(params.getIgnoreFilters()) .setMaxChunkSize(params.getMaxChunkSize()) .setSourceIpSpaceAssignment(resolver.resolveSourceIpSpaceAssignment()) .setSrcNatted(params.getSrcNatted()) .setSpecialize(params.getSpecialize()) .setRequiredTransitNodes(requiredTransitNodes) .build(); } @VisibleForTesting  ReachabilityParametersResolver(
      IBatfish batfish, ReachabilityParameters params, NetworkSnapshot snapshot); static ResolvedReachabilityParameters resolveReachabilityParameters(
      IBatfish batfish, ReachabilityParameters params, NetworkSnapshot snapshot); }
ReachabilityParametersResolver { public static ResolvedReachabilityParameters resolveReachabilityParameters( IBatfish batfish, ReachabilityParameters params, NetworkSnapshot snapshot) throws InvalidReachabilityParametersException { ReachabilityParametersResolver resolver = new ReachabilityParametersResolver(batfish, params, snapshot); SpecifierContext context = resolver._context; SortedSet<FlowDisposition> actions = params.getActions(); if (actions.isEmpty()) { throw new InvalidReachabilityParametersException("No actions"); } Set<String> finalNodes = params.getFinalNodesSpecifier().resolve(context); if (finalNodes.isEmpty()) { throw new InvalidReachabilityParametersException("No final nodes"); } Set<String> forbiddenTransitNodes = params.getForbiddenTransitNodesSpecifier().resolve(context); Set<String> requiredTransitNodes = params.getRequiredTransitNodesSpecifier().resolve(context); if (!requiredTransitNodes.isEmpty() && forbiddenTransitNodes.containsAll(requiredTransitNodes)) { throw new InvalidReachabilityParametersException( "All required transit nodes are also forbidden"); } return ResolvedReachabilityParameters.builder() .setActions(actions) .setFinalNodes(finalNodes) .setForbiddenTransitNodes(forbiddenTransitNodes) .setHeaderSpace(resolver.resolveHeaderSpace()) .setIgnoreFilters(params.getIgnoreFilters()) .setMaxChunkSize(params.getMaxChunkSize()) .setSourceIpSpaceAssignment(resolver.resolveSourceIpSpaceAssignment()) .setSrcNatted(params.getSrcNatted()) .setSpecialize(params.getSpecialize()) .setRequiredTransitNodes(requiredTransitNodes) .build(); } @VisibleForTesting  ReachabilityParametersResolver(
      IBatfish batfish, ReachabilityParameters params, NetworkSnapshot snapshot); static ResolvedReachabilityParameters resolveReachabilityParameters(
      IBatfish batfish, ReachabilityParameters params, NetworkSnapshot snapshot);  }