cidr

package
v4.0.0-pre-2 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HostBig

func HostBig(base netip.Prefix, num *big.Int) (netip.Addr, error)

HostBig takes a parent CIDR range and turns it into a host IP address with the given host number. It differs from Host in that it takes a *big.Int for the num, instead of an int.

For example, 10.3.0.0/16 with a host number of 2 gives 10.3.0.2.

func NextSubnet

func NextSubnet(network netip.Prefix, prefixLen int) (netip.Prefix, bool)

NextSubnet returns the next available subnet of the desired mask size starting for the maximum IP of the offset subnet If the IP exceeds the maxium IP then the second return value is true

func PreviousSubnet

func PreviousSubnet(network netip.Prefix, prefixLen int) (netip.Prefix, bool)

PreviousSubnet returns the subnet of the desired mask in the IP space just lower than the start of Prefix provided. If the IP space rolls over then the second return value is true

func SubnetBig

func SubnetBig(base netip.Prefix, newBits int, num *big.Int) (netip.Prefix, error)

SubnetBig takes a parent CIDR range and creates a subnet within it with the given number of additional prefix bits and the given network number. It differs from Subnet in that it takes a *big.Int for the num, instead of an int.

For example, 10.3.0.0/16, extended by 8 bits, with a network number of 5, becomes 10.3.5.0/24 .

Types

This section is empty.

Jump to

Keyboard shortcuts

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