bitmap

package
v0.0.0-...-fda5957 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allocator

type Allocator struct {
	// contains filtered or unexported fields
}

Allocator is a prefix allocator allocating in chunks of a fixed size regardless of the size requested by the client. It consumes an amount of memory proportional to the total amount of available prefixes

func NewBitmapAllocator

func NewBitmapAllocator(pool net.IPNet, size int) (*Allocator, error)

NewBitmapAllocator creates a new allocator, allocating /`size` prefixes carved out of the given `pool` prefix

func (*Allocator) Allocate

func (a *Allocator) Allocate(hint net.IPNet) (ret net.IPNet, err error)

Allocate reserves a maxsize-sized block and returns a block of size min(maxsize, hint.size)

func (*Allocator) Free

func (a *Allocator) Free(prefix net.IPNet) error

Free returns the given prefix to the available pool if it was taken.

type IPv4Allocator

type IPv4Allocator struct {
	// contains filtered or unexported fields
}

IPv4Allocator allocates IPv4 addresses, tracking utilization with a bitmap

func NewIPv4Allocator

func NewIPv4Allocator(start, end net.IP) (*IPv4Allocator, error)

NewIPv4Allocator creates a new allocator suitable for giving out IPv4 addresses

func (*IPv4Allocator) Allocate

func (a *IPv4Allocator) Allocate(hint net.IPNet) (n net.IPNet, err error)

Allocate reserves an IP for a client

func (*IPv4Allocator) Free

func (a *IPv4Allocator) Free(n net.IPNet) error

Free releases the given IP

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL