com.googlecode.ipv6
Class IPv6AddressPool

java.lang.Object
  extended by com.googlecode.ipv6.IPv6AddressPool

public final class IPv6AddressPool
extends Object

Immutable representation of an IPv6 address pool.

An IPv6 address pool is like an IPv6 address range in which some addresses are "free" and some are "allocated". Think "dhcp server". Addresses are allocated in whole subnet blocks at once. These subnet blocks have a predefined prefix length for the whole allocatable range.

Author:
Jan Van Besien

Method Summary
 IPv6AddressPool allocate()
          Allocate the first available subnet from the pool.
 IPv6AddressPool allocate(IPv6Network toAllocate)
          Allocate the given subnet from the pool.
 boolean contains(IPv6Address address)
           
 boolean contains(IPv6AddressRange range)
           
 IPv6AddressPool deAllocate(IPv6Network toDeAllocate)
          Give a network back to the pool (de-allocate).
 boolean equals(Object o)
           
 Iterable<IPv6Network> freeNetworks()
           
static IPv6AddressPool fromRangeAndSubnet(IPv6AddressRange range, IPv6NetworkMask allocationSubnetSize)
          Create a pool of the given range (boundaries inclusive) which is completely free.
 IPv6Address getFirst()
           
 IPv6Address getLast()
           
 IPv6Network getLastAllocated()
           
 int hashCode()
           
 boolean isExhausted()
           
 boolean isFree(IPv6Network network)
           
 boolean overlaps(IPv6AddressRange range)
           
 String toLongString()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

fromRangeAndSubnet

public static IPv6AddressPool fromRangeAndSubnet(IPv6AddressRange range,
                                                 IPv6NetworkMask allocationSubnetSize)
Create a pool of the given range (boundaries inclusive) which is completely free. The given subnet size is the network mask (thus size) of the allocated subnets in this range. This constructor verifies that the whole range is "aligned" with subnets of this size (i.e. there should not be a waste of space in the beginning or end which is smaller than one subnet of the given subnet size).

Parameters:
range - range from within to allocate
allocationSubnetSize - size of the subnets that will be allocated

getLastAllocated

public IPv6Network getLastAllocated()
Returns:
the last IPv6Network which was allocated or null if none was allocated yet

allocate

public IPv6AddressPool allocate()
Allocate the first available subnet from the pool.

Returns:
resulting pool

allocate

public IPv6AddressPool allocate(IPv6Network toAllocate)
Allocate the given subnet from the pool.

Parameters:
toAllocate - subnet to allocate from the pool
Returns:
resulting pool

deAllocate

public IPv6AddressPool deAllocate(IPv6Network toDeAllocate)
Give a network back to the pool (de-allocate).

Parameters:
toDeAllocate - network to de-allocate

isExhausted

public boolean isExhausted()
Returns:
true if no subnets are free in this pool, false otherwize

isFree

public boolean isFree(IPv6Network network)

freeNetworks

public Iterable<IPv6Network> freeNetworks()
Returns:
all networks (all with the same fixed prefix length) which are free in this pool

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

contains

public boolean contains(IPv6Address address)

contains

public boolean contains(IPv6AddressRange range)

overlaps

public boolean overlaps(IPv6AddressRange range)

getFirst

public IPv6Address getFirst()

getLast

public IPv6Address getLast()

toString

public String toString()
Overrides:
toString in class Object

toLongString

public String toLongString()
Returns:
like toString but without using shorthand notations for addresses


Copyright © 2012. All Rights Reserved.