cidr

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoAvailableCidr    = errors.New("unable to find available CIDR range")
	ErrInvalidInputRanges = errors.New("input ranges invalid")
)

Functions

func ChildCIDRs

func ChildCIDRs(parent *net.IPNet) (*net.IPNet, *net.IPNet, error)

ChildCIDRs will return the two child CIDRs from extending the mask 1 bit

func ContainsCIDR

func ContainsCIDR(parentCIDR *net.IPNet, childCIDR *net.IPNet) bool

ContainsCIDR returns true if the childCIDR is contained within parentCIDR, and false otherwise. Comparison checking is inclusive, so identical CIDRs will return true.

func ContainsExistingCIDR

func ContainsExistingCIDR(currentCIDR *net.IPNet, usedCIDRs []*net.IPNet) bool

ContainsExistingCIDR returns true if any of the usedCIDRs are contained within the currentCIDR, and false otherwise.

func EqualCIDRs

func EqualCIDRs(x *net.IPNet, y *net.IPNet) bool

func EqualMask

func EqualMask(x *net.IPMask, y *net.IPMask) bool

func FindAvailableCIDR

func FindAvailableCIDR(rootCIDR *net.IPNet, desiredMask *net.IPMask, usedCIDRs []*net.IPNet) (*net.IPNet, error)

FindAvailableCIDR will find a CIDR range of specified desiredMask size within the rootCIDR given a list of already existing usedCIDRs.

func MatchesExistingCIDR

func MatchesExistingCIDR(currentCIDR *net.IPNet, usedCIDRs []*net.IPNet) bool

func SmallerMask

func SmallerMask(smaller *net.IPMask, larger *net.IPMask) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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