calc

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddrToBits

func AddrToBits(addr netip.Addr) (int, error)

Types

type Prefix

type Prefix struct {
	netip.Prefix
}

network stuct based on netip.Prefix to add custom methods

func (Prefix) BroadcastAddr

func (p Prefix) BroadcastAddr() (netip.Addr, error)

broadcast address of the network ex. 192.168.20.15/23 -> 192.168.21.255

func (Prefix) GetAll

func (p Prefix) GetAll() ([]Prefix, error)

func (Prefix) Hosts

func (p Prefix) Hosts() ([]netip.Addr, error)

list of all hosts in the network (smaller mask bits take exponitially more time)

func (Prefix) HostsCount

func (p Prefix) HostsCount() (int, error)

count hosts in 0(1) time complexity

func (Prefix) Mask

func (p Prefix) Mask() (netip.Addr, error)

network mask of the network

func (Prefix) NetworkAddr

func (p Prefix) NetworkAddr() (netip.Addr, error)

network address of the network ex. 192.168.20.15/23 -> 192.168.20.0

Jump to

Keyboard shortcuts

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