ipam

package
v0.81.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalIP

func CanonicalIP(value string) string

CanonicalIP normalizes an address with or without a prefix while preserving invalid input.

func CanonicalPrefix

func CanonicalPrefix(value string) string

CanonicalPrefix normalizes a prefix while preserving invalid input.

Types

type DADClient

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

DADClient checks address availability on a macvlan parent segment.

func NewDADClient

func NewDADClient(parentName string) (*DADClient, error)

NewDADClient snapshots host and neighbour addresses for the parent segment.

func (*DADClient) Close

func (d *DADClient) Close() error

Close releases the temporary probe interface and packet socket. It must not run concurrently with Probe.

func (*DADClient) Probe

func (d *DADClient) Probe(ctx context.Context, ip netip.Addr) (bool, error)

Probe reports whether ip is available.

func (*DADClient) ProbeBatch

func (d *DADClient) ProbeBatch(ctx context.Context, addresses []netip.Addr) ([]bool, error)

ProbeBatch reports address availability while probing concurrently.

type IPAllocator

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

IPAllocator assigns addresses from one subnet. It is not safe for concurrent use.

func NewIPAllocator

func NewIPAllocator(subnet, pool netip.Prefix, reserved []netip.Addr) (*IPAllocator, error)

NewIPAllocator creates an allocator, excluding subnet boundary addresses. Reserved addresses (for example gateways) may be outside the allocation pool.

func (*IPAllocator) Next

func (a *IPAllocator) Next(ctx context.Context, clients ...*DADClient) (netip.Addr, error)

Next reserves and returns the first free address accepted by duplicate detection.

func (*IPAllocator) NextPreferredBatch

func (a *IPAllocator) NextPreferredBatch(
	ctx context.Context,
	preferred []netip.Addr,
	clients ...*DADClient,
) ([]netip.Addr, error)

NextPreferredBatch reserves available preferred addresses and replaces unavailable preferences from the pool.

func (*IPAllocator) Reserve

func (a *IPAllocator) Reserve(ip netip.Addr) error

Reserve excludes an explicit address.

Jump to

Keyboard shortcuts

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