ipam

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package ipam contains types to implement IP address management on IPv4 and IPv6 networks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPv4

type IPv4 [4]byte

func (IPv4) Addr

func (ip IPv4) Addr() netip.Addr

func (IPv4) String

func (ip IPv4) String() string

type IPv4Pool

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

func NewIPv4Pool

func NewIPv4Pool(ip IPv4, nbits int) *IPv4Pool

func (*IPv4Pool) Get

func (p *IPv4Pool) Get() (IPv4, bool)

func (*IPv4Pool) GetAddr

func (p *IPv4Pool) GetAddr() (netip.Addr, bool)

func (*IPv4Pool) Put

func (p *IPv4Pool) Put(ip IPv4)

func (*IPv4Pool) PutAddr

func (p *IPv4Pool) PutAddr(ip netip.Addr)

func (*IPv4Pool) Reset

func (p *IPv4Pool) Reset(ip IPv4, nbits int)

func (*IPv4Pool) String

func (p *IPv4Pool) String() string

type IPv6

type IPv6 [16]byte

func (IPv6) Addr

func (ip IPv6) Addr() netip.Addr

func (IPv6) String

func (ip IPv6) String() string

type IPv6Pool

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

func NewIPv6Pool

func NewIPv6Pool(ip IPv6, nbits int) *IPv6Pool

func (*IPv6Pool) Get

func (p *IPv6Pool) Get() (IPv6, bool)

func (*IPv6Pool) GetAddr

func (p *IPv6Pool) GetAddr() (netip.Addr, bool)

func (*IPv6Pool) Put

func (p *IPv6Pool) Put(ip IPv6)

func (*IPv6Pool) PutAddr

func (p *IPv6Pool) PutAddr(ip netip.Addr)

func (*IPv6Pool) Reset

func (p *IPv6Pool) Reset(ip IPv6, nbits int)

func (*IPv6Pool) String

func (p *IPv6Pool) String() string

type Pool

type Pool interface {
	// Obtains the next IP address, or returns nil if the pool was exhausted.
	GetAddr() (netip.Addr, bool)
	// Returns an IP address to the pool. The ip address must have been obtained
	// by a previous call to GetIP or the method panics.
	PutAddr(netip.Addr)
}

Pool is an interface implemented by the IPv4Pool and IPv6Pool types to abstract the type of IP addresses that are managed by the pool.

func NewPool

func NewPool(prefix netip.Prefix) Pool

NewPool constructs a pool of IP addresses for the network passed as argument.

Jump to

Keyboard shortcuts

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