subnet

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Calculator

type Calculator struct {
	IPv4Pools             *iradix.Tree
	AllocatedIPv4Prefixes *iradix.Tree
	IPv6Pools             *iradix.Tree
	AllocatedIPv6Prefixes *iradix.Tree
}

Calculator stores radix trees of supernets and subnets.

func NewCalculator

func NewCalculator() *Calculator

NewCalculator creates a new Calculator from a list of supernets and subnets.

func (*Calculator) AddAllocatedPrefix

func (c *Calculator) AddAllocatedPrefix(prefix netip.Prefix)

func (*Calculator) AddPool

func (c *Calculator) AddPool(prefix netip.Prefix)

func (*Calculator) DeleteAllocatedPrefix

func (c *Calculator) DeleteAllocatedPrefix(prefix netip.Prefix)

func (*Calculator) DeletePool

func (c *Calculator) DeletePool(prefix netip.Prefix)

func (*Calculator) NextAvailableIPv4Subnet added in v0.3.0

func (c *Calculator) NextAvailableIPv4Subnet(numBits int) (netip.Prefix, error)

NextAvailableIPv4Subnet finds the first available IPv4 subnet of a given mask length from a list of subnets and supernets, and fails if none are available.

func (*Calculator) NextAvailableIPv6Subnet added in v0.3.0

func (c *Calculator) NextAvailableIPv6Subnet(numBits int) (netip.Prefix, error)

NextAvailableIPv6Subnet finds the first available IPv6 subnet of a given mask length from a list of subnets and supernets, and fails if none are available.

func (*Calculator) PrefixInPools

func (c *Calculator) PrefixInPools(prefix netip.Prefix) bool

PrefixInPools tests to see if a prefix is a part of any pools that have been added to the calculator.

Jump to

Keyboard shortcuts

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