public IPv6Address getFirst() { return underlyingRange.getFirst(); }
public IPv6Address getFirst() { return underlyingRange.getFirst(); }
/** * Allocate the first available subnet from the pool. * * @return resulting pool */ public IPv6AddressPool allocate() { if (!isExhausted()) { // get the first range of free subnets, and take the first subnet of that range final IPv6AddressRange firstFreeRange = freeRanges.first(); final IPv6Network allocated = IPv6Network.fromAddressAndMask(firstFreeRange.getFirst(), allocationSubnetSize); return doAllocate(allocated, firstFreeRange); } else { // exhausted return null; } }
/** * Allocate the first available subnet from the pool. * * @return resulting pool */ public IPv6AddressPool allocate() { if (!isExhausted()) { // get the first range of free subnets, and take the first subnet of that range final IPv6AddressRange firstFreeRange = freeRanges.first(); final IPv6Network allocated = IPv6Network.fromAddressAndMask(firstFreeRange.getFirst(), allocationSubnetSize); return doAllocate(allocated, firstFreeRange); } else { // exhausted return null; } }
/** * Private helper method to find the free range just after the given address. */ private IPv6AddressRange findFreeRangeAfter(IPv6Network network) { for (IPv6AddressRange freeRange : freeRanges) { if (freeRange.getFirst().subtract(1).equals(network.getLast())) { return freeRange; } } // not found return null; }
/** * Private helper method to find the free range just after the given address. */ private IPv6AddressRange findFreeRangeAfter(IPv6Network network) { for (IPv6AddressRange freeRange : freeRanges) { if (freeRange.getFirst().subtract(1).equals(network.getLast())) { return freeRange; } } // not found return null; }
private void validateRangeIsMultipleOfSubnetsOfGivenSize(IPv6AddressRange range, IPv6NetworkMask allocationSubnetSize) { final int allocatableBits = 128 - allocationSubnetSize.asPrefixLength(); if (range.getFirst().numberOfTrailingZeroes() < allocatableBits) throw new IllegalArgumentException( "range [" + this + "] is not aligned with prefix length [" + allocationSubnetSize.asPrefixLength() + "], " + "first address should end with " + allocatableBits + " zero bits"); if (range.getLast().numberOfTrailingOnes() < allocatableBits) throw new IllegalArgumentException( "range [" + this + "] is not aligned with prefix length [" + allocationSubnetSize.asPrefixLength() + "], last address should end with " + allocatableBits + " one bits"); }
private void validateRangeIsMultipleOfSubnetsOfGivenSize(IPv6AddressRange range, IPv6NetworkMask allocationSubnetSize) { final int allocatableBits = 128 - allocationSubnetSize.asPrefixLength(); if (range.getFirst().numberOfTrailingZeroes() < allocatableBits) throw new IllegalArgumentException( "range [" + this + "] is not aligned with prefix length [" + allocationSubnetSize.asPrefixLength() + "], " + "first address should end with " + allocatableBits + " zero bits"); if (range.getLast().numberOfTrailingOnes() < allocatableBits) throw new IllegalArgumentException( "range [" + this + "] is not aligned with prefix length [" + allocationSubnetSize.asPrefixLength() + "], last address should end with " + allocatableBits + " one bits"); }