Documentation ¶
Overview ¶
Provides tools and data structures for managing IP address pools
Provides tools and data structures for caching IP address pools and managing them
Provides tools for handling IP address ranges
Index ¶
- func HasIp(list *IpAlloc, ip net.IP) bool
- func Range2Cidr(start, end net.IP) (r []*net.IPNet)
- type IpAlloc
- func (ipa *IpAlloc) AddAll(other *IpAlloc) error
- func (ipa *IpAlloc) AddIp(ip net.IP)
- func (ipa *IpAlloc) AddRange(start net.IP, end net.IP)
- func (ipa *IpAlloc) AddRanges(ranges []IpRange) error
- func (ipa *IpAlloc) AddSubnet(subnet *net.IPNet)
- func (ipa *IpAlloc) Empty() bool
- func (ipa *IpAlloc) GetIp() (net.IP, error)
- func (ipa *IpAlloc) GetIpChunk(chunkSize int64) ([]IpRange, error)
- func (ipa *IpAlloc) GetSize() int64
- func (ipa *IpAlloc) Intersect(other *IpAlloc) *IpAlloc
- func (ipa *IpAlloc) RemoveAll(other *IpAlloc) error
- func (ipa *IpAlloc) RemoveIp(ip net.IP) bool
- func (ipa *IpAlloc) RemoveRange(start net.IP, end net.IP) bool
- func (ipa *IpAlloc) RemoveRanges(ranges []IpRange) error
- func (ipa *IpAlloc) RemoveSubnet(subnet *net.IPNet) bool
- type IpCache
- func (iplists *IpCache) AllocateIp(ipv4 bool) (net.IP, error)
- func (iplists *IpCache) CombineV4() []IpRange
- func (iplists *IpCache) CombineV6() []IpRange
- func (iplists *IpCache) DeallocateIp(ip net.IP)
- func (iplists *IpCache) GetV4IpCache() []*IpAlloc
- func (iplists *IpCache) GetV6IpCache() []*IpAlloc
- func (iplists *IpCache) LoadRanges(ipranges []IpRange)
- func (iplists *IpCache) RemoveIp(ip net.IP) bool
- type IpRange
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type IpAlloc ¶
type IpAlloc struct {
FreeList []IpRange
}
A IP pool containing a list of free IP address ranges. IP addresses can be either v4 or v6, but not both
func NewFromRanges ¶
Create a new IpAlloc from an existing freelist
func (*IpAlloc) AddRange ¶
Add the range of IP addresses provides to the free list example: start:10.2.1.1 and end 10.2.1.1 example: ipa.FreeList = [{10.2.1.2 10.2.1.129}] After the following function the ipa.Freelist = [{10.2.1.1 10.2.1.129}]
func (*IpAlloc) AddSubnet ¶
Add the given subnet to the free list. Note that this will include the network address ip|mask in the range.
func (*IpAlloc) GetIpChunk ¶
Return a set of ranges containing at chunkSize IP addresses and remove them from the free list.
func (*IpAlloc) Intersect ¶
Create a new IpAlloc that is the intersection of the ranges in the ipa and other
func (*IpAlloc) RemoveRange ¶
Remove all the IP addresses in the range from the free list
func (*IpAlloc) RemoveRanges ¶
Remove all IP ranges from a slice of ranges
type IpCache ¶
type IpCache struct {
// contains filtered or unexported fields
}
The data structure to cache the IpV4 and IpV6 lists
func NewIpCache ¶
func NewIpCache() *IpCache
Create a new IpCache which will have 2 lists, the List-0 is for the available IPs and List-1 is for the used Ips.
func (*IpCache) AllocateIp ¶
allocates Ip from the pool and updates the Lists also removes the Ip from the available Ips list
func (*IpCache) DeallocateIp ¶
Adds the Ip to the used list of Ips
func (*IpCache) GetV4IpCache ¶
func (*IpCache) GetV6IpCache ¶
func (*IpCache) LoadRanges ¶
loads the Iplists from the given IpRange, this function is invoked at the init or the update