@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; IPv6Network that = (IPv6Network) o; if (address != null ? !address.equals(that.address) : that.address != null) return false; if (networkMask != null ? !networkMask.equals(that.networkMask) : that.networkMask != null) return false; return true; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; IPv6AddressPool that = (IPv6AddressPool) o; if (allocationSubnetSize != null ? !allocationSubnetSize.equals(that.allocationSubnetSize) : that.allocationSubnetSize != null) return false; if (freeRanges != null ? !freeRanges.equals(that.freeRanges) : that.freeRanges != null) return false; if (lastAllocated != null ? !lastAllocated.equals(that.lastAllocated) : that.lastAllocated != null) return false; if (underlyingRange != null ? !underlyingRange.equals(that.underlyingRange) : that.underlyingRange != null) return false; return true; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; IPv6AddressPool that = (IPv6AddressPool) o; if (allocationSubnetSize != null ? !allocationSubnetSize.equals(that.allocationSubnetSize) : that.allocationSubnetSize != null) return false; if (freeRanges != null ? !freeRanges.equals(that.freeRanges) : that.freeRanges != null) return false; if (lastAllocated != null ? !lastAllocated.equals(that.lastAllocated) : that.lastAllocated != null) return false; if (underlyingRange != null ? !underlyingRange.equals(that.underlyingRange) : that.underlyingRange != null) return false; return true; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; IPv6Network that = (IPv6Network) o; if (address != null ? !address.equals(that.address) : that.address != null) return false; if (networkMask != null ? !networkMask.equals(that.networkMask) : that.networkMask != null) return false; return true; }
public boolean isFree(final IPv6Network network) { if (network == null) throw new IllegalArgumentException("network invalid [null]"); if (!this.allocationSubnetSize.equals(network.getNetmask())) throw new IllegalArgumentException( "network of prefix length [" + network.getNetmask().asPrefixLength() + "] can not be free in a pool which uses prefix length [" + allocationSubnetSize + "]"); // find a free range that contains the network for (IPv6AddressRange freeRange : freeRanges) { if (freeRange.contains(network)) { return true; } } // nothing found return false; }
public boolean isFree(final IPv6Network network) { if (network == null) throw new IllegalArgumentException("network invalid [null]"); if (!this.allocationSubnetSize.equals(network.getNetmask())) throw new IllegalArgumentException( "network of prefix length [" + network.getNetmask().asPrefixLength() + "] can not be free in a pool which uses prefix length [" + allocationSubnetSize + "]"); // find a free range that contains the network for (IPv6AddressRange freeRange : freeRanges) { if (freeRange.contains(network)) { return true; } } // nothing found return false; }
/** * Allocate the given subnet from the pool. * * @param toAllocate subnet to allocate from the pool * @return resulting pool */ public IPv6AddressPool allocate(IPv6Network toAllocate) { if (!contains(toAllocate)) throw new IllegalArgumentException( "can not allocate network which is not contained in the pool to allocate from [" + toAllocate + "]"); if (!this.allocationSubnetSize.equals(toAllocate.getNetmask())) throw new IllegalArgumentException( "can not allocate network with prefix length /" + toAllocate.getNetmask().asPrefixLength() + " from a pool configured to hand out subnets with prefix length /" + allocationSubnetSize); // go find the range that contains the requested subnet final IPv6AddressRange rangeToAllocateFrom = findFreeRangeContaining(toAllocate); if (rangeToAllocateFrom != null) { // found a range in which this subnet is free, allocate it return doAllocate(toAllocate, rangeToAllocateFrom); } else { // requested subnet not free return null; } }
/** * Allocate the given subnet from the pool. * * @param toAllocate subnet to allocate from the pool * @return resulting pool */ public IPv6AddressPool allocate(IPv6Network toAllocate) { if (!contains(toAllocate)) throw new IllegalArgumentException( "can not allocate network which is not contained in the pool to allocate from [" + toAllocate + "]"); if (!this.allocationSubnetSize.equals(toAllocate.getNetmask())) throw new IllegalArgumentException( "can not allocate network with prefix length /" + toAllocate.getNetmask().asPrefixLength() + " from a pool configured to hand out subnets with prefix length /" + allocationSubnetSize); // go find the range that contains the requested subnet final IPv6AddressRange rangeToAllocateFrom = findFreeRangeContaining(toAllocate); if (rangeToAllocateFrom != null) { // found a range in which this subnet is free, allocate it return doAllocate(toAllocate, rangeToAllocateFrom); } else { // requested subnet not free return null; } }