public void addDstIp(IpSpace dstIp) { _dstIps = AclIpSpace.union(_dstIps, dstIp); }
public void addSrcIp(IpSpace srcIp) { _srcIps = AclIpSpace.union(_srcIps, srcIp); }
public void addSrcOrDstIp(IpSpace srcOrDstIp) { _srcOrDstIps = AclIpSpace.union(_srcOrDstIps, srcOrDstIp); }
public void addNotDstIp(IpSpace notDstIp) { _notDstIps = AclIpSpace.union(_notDstIps, notDstIp); }
public void addNotSrcIp(IpSpace notSrcIp) { _notSrcIps = AclIpSpace.union(_notSrcIps, notSrcIp); }
/** * Set-theoretic union of multiple {@link IpSpace IP spaces}.<br> * {@code null} ipSpaces are ignored. If all arguments are {@code null}, returns {@code null}. */ public static @Nullable IpSpace union(IpSpace... ipSpaces) { return union(Arrays.asList(ipSpaces)); }
static IpSpace toIpSpace(NetworkObjectGroup networkObjectGroup) { return firstNonNull(AclIpSpace.union(networkObjectGroup.getLines()), EmptyIpSpace.INSTANCE); }
private @Nullable static IpSpace specializeIpSpace( @Nullable IpSpace ipSpace, BDDIpSpaceSpecializer... specializers) { if (ipSpace == null) { return null; } // union the subspaces relevant to each specializer List<IpSpace> specializedIpSpaces = Arrays.stream(specializers) .map(specializer -> specializer.specialize(ipSpace)) .collect(Collectors.toList()); return specializedIpSpaces.contains(UniverseIpSpace.INSTANCE) ? UniverseIpSpace.INSTANCE : AclIpSpace.union(specializedIpSpaces); }
@VisibleForTesting static IpSpace computeRouteMatchConditions( Set<AbstractRoute> routes, Map<Prefix, IpSpace> matchingIps) { // get the union of IpSpace that match one of the routes return firstNonNull( AclIpSpace.union( routes.stream() .map(AbstractRoute::getNetwork) .collect(ImmutableSet.toImmutableSet()) .stream() .map(matchingIps::get) .toArray(IpSpace[]::new)), EmptyIpSpace.INSTANCE); }
private IpSpace computeInternalIps() { try (ActiveSpan span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeInternalIps").startActive()) { assert span != null; // avoid unused warning return firstNonNull( AclIpSpace.union( _interfaceHostSubnetIps.values().stream() .flatMap(vrfSubnetIps -> vrfSubnetIps.values().stream()) .flatMap(ifaceSubnetIps -> ifaceSubnetIps.values().stream()) .collect(Collectors.toList())), EmptyIpSpace.INSTANCE); } }
@Nonnull private static IpSpace resolveIpSpaceSpecifier(IpSpaceSpecifier specifier, SpecifierContext ctx) { return firstNonNull( AclIpSpace.union( specifier.resolve(ImmutableSet.of(), ctx).getEntries().stream() .map(Entry::getIpSpace) .collect(ImmutableList.toImmutableList())), EmptyIpSpace.INSTANCE); }
/** * Returns the union of IpSpace of all members. Returns {@link EmptyIpSpace} if there are no * members */ public IpSpace getIpSpace( Map<String, AddressObject> addressObjects, Map<String, AddressGroup> addressGroups) { Set<String> descendantObjects = getDescendantObjects(addressObjects, addressGroups, new HashSet<>()); IpSpace space = AclIpSpace.union( descendantObjects.stream() .map(m -> addressObjects.get(m).getIpSpace()) .collect(Collectors.toSet())); return space == null ? EmptyIpSpace.INSTANCE : space; }
@Override public IpSpaceAssignment resolve(Set<Location> key, SpecifierContext ctxt) { Set<Location> locations = _locationSpecifier.resolve(ctxt); checkArgument(!locations.isEmpty(), "No such locations"); IpSpace ipSpace = AclIpSpace.union( InferFromLocationIpSpaceSpecifier.INSTANCE.resolve(locations, ctxt).getEntries() .stream() .map(Entry::getIpSpace) .collect(Collectors.toList())); return IpSpaceAssignment.builder() .assign(key, firstNonNull(ipSpace, EmptyIpSpace.INSTANCE)) .build(); } }
@VisibleForTesting IpSpace resolveDestinationIpSpace() throws InvalidReachabilityParametersException { IpSpace destinationIpSpace = AclIpSpace.union( _params.getDestinationIpSpaceSpecifier().resolve(ImmutableSet.of(), _context) .getEntries().stream() .map(Entry::getIpSpace) .collect(ImmutableList.toImmutableList())); /* * Make sure the destinationIpSpace is non-empty. Otherwise, we'll get no results and no * explanation why. */ if (!_ipSpaceRepresentative.getRepresentative(destinationIpSpace).isPresent()) { throw new InvalidReachabilityParametersException("Empty destination IpSpace"); } return destinationIpSpace; }
@Override public void applyTo( HeaderSpace.Builder headerSpaceBuilder, JuniperConfiguration jc, Warnings w, Configuration c) { headerSpaceBuilder.setNotSrcIps( AclIpSpace.union(headerSpaceBuilder.getNotSrcIps(), _ipWildcard.toIpSpace())); }
@Override public void applyTo( HeaderSpace.Builder headerSpaceBuilder, JuniperConfiguration jc, Warnings w, Configuration c) { headerSpaceBuilder.setSrcIps( AclIpSpace.union(headerSpaceBuilder.getSrcIps(), _ipWildcard.toIpSpace())); }
@Override public void applyTo( HeaderSpace.Builder headerSpaceBuilder, JuniperConfiguration jc, Warnings w, Configuration c) { headerSpaceBuilder.setDstIps( AclIpSpace.union(headerSpaceBuilder.getDstIps(), _ipWildcard.toIpSpace())); }
@Override public void applyTo( HeaderSpace.Builder headerSpaceBuilder, JuniperConfiguration jc, Warnings w, Configuration c) { headerSpaceBuilder.setNotDstIps( AclIpSpace.union(headerSpaceBuilder.getNotDstIps(), _ipWildcard.toIpSpace())); }
@Override public IpSpace visitInterfaceLinkLocation(InterfaceLinkLocation interfaceLinkLocation) { String node = interfaceLinkLocation.getNodeName(); String iface = interfaceLinkLocation.getInterfaceName(); @Nullable IpSpace linkIpSpace = AclIpSpace.union( interfaceAddresses(node, iface).stream() /* * Only include addresses on networks that might have hosts. */ .filter(address -> address.getNetworkBits() <= HOST_SUBNET_MAX_PREFIX_LENGTH) .map(address -> address.getPrefix().toHostIpSpace()) .collect(Collectors.toList())); return linkIpSpace == null ? EmptyIpSpace.INSTANCE : AclIpSpace.difference(linkIpSpace, _specifierContext.getSnapshotDeviceOwnedIps()); }