netiputil

package
v27.3.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddrPortFromNet

func AddrPortFromNet(addr net.Addr) netip.AddrPort

AddrPortFromNet converts a net.Addr into a netip.AddrPort.

func HostID

func HostID(addr netip.Addr, bits uint) uint64

HostID masks out the 'bits' most-significant bits of addr. The result is undefined if bits > addr.BitLen().

func LastAddr

func LastAddr(p netip.Prefix) netip.Addr

LastAddr returns the last address of prefix 'p'.

func PrefixAfter

func PrefixAfter(prev netip.Prefix, sz int) netip.Prefix

PrefixAfter returns the prefix of size 'sz' right after 'prev'.

func PrefixCompare

func PrefixCompare(a, b netip.Prefix) int

PrefixCompare two prefixes and return a negative, 0, or a positive integer as required by slices.SortFunc. When two prefixes with the same address is provided, the shortest one will be sorted first.

func SubnetRange

func SubnetRange(network, subnet netip.Prefix) (start, end uint64)

SubnetRange returns the amount to add to network.Addr() in order to yield the first and last addresses in subnet, respectively.

func ToIPNet

func ToIPNet(p netip.Prefix) *net.IPNet

ToIPNet converts p into a *net.IPNet, returning nil if p is not valid.

func ToPrefix

func ToPrefix(n *net.IPNet) (netip.Prefix, bool)

ToPrefix converts n into a netip.Prefix. If n is not a valid IPv4 or IPV6 address, ToPrefix returns netip.Prefix{}, false.

Types

This section is empty.

Jump to

Keyboard shortcuts

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