ipv4subnet

package
v0.1.42 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Range

type Range struct {
	// contains filtered or unexported fields
}

Range added because ranges were removed when netaddr joined core Go

func NewRange

func NewRange(first, last netip.Addr) Range

NewRange make a new range

func (*Range) First

func (r *Range) First() netip.Addr

First get first address in range

func (*Range) Last

func (r *Range) Last() netip.Addr

Last get last address in range

func (*Range) String

func (r *Range) String() string

String return string version of range

type Subnet

type Subnet struct {
	// contains filtered or unexported fields
}

Subnet an IP subnet

func NewFromAddrAndBits

func NewFromAddrAndBits(addr string, bits int) (subnet *Subnet, err error)

NewFromAddrAndBits new using incoming prefix ip and network bits

func NewFromPrefix

func NewFromPrefix(prefix string) (subnet *Subnet, err error)

NewFromPrefix new using incoming prefix

func NewNamedFromAddrAndBits

func NewNamedFromAddrAndBits(addr string, bits int, name string) (subnet *Subnet, err error)

NewNamedFromAddrAndBits new with name using incoming prefix ip and network bits

func NewNamedFromPrefix

func NewNamedFromPrefix(prefix string, name string) (subnet *Subnet, err error)

NewNamedFromPrefix new with name using incoming prefix

func (*Subnet) BinaryID

func (s *Subnet) BinaryID() (mask string)

BinaryID get the starting IP for subnet as binary

func (*Subnet) BinaryMask

func (s *Subnet) BinaryMask() (mask string)

BinaryMask get dot delimited subnet mask in binary

func (*Subnet) BroadcastAddr

func (s *Subnet) BroadcastAddr() (ip netip.Addr)

BroadcastAddr get broadcast address for subnet, i.e. the max IP

func (*Subnet) CIDR

func (s *Subnet) CIDR() (cidr string)

CIDR get CIDR notation for subnet

func (*Subnet) Class

func (s *Subnet) Class() (class rune)

Class get network class, a, b, or c

func (*Subnet) ClassHostBits

func (s *Subnet) ClassHostBits() int

ClassHostBits bits used for network in class block

func (*Subnet) ClassNetworkBits

func (s *Subnet) ClassNetworkBits() int

ClassNetworkBits bits not used for hosts in class block

func (*Subnet) EffectiveNetworks

func (s *Subnet) EffectiveNetworks(secondarySubnet *Subnet) int64

EffectiveNetworks number of networks

func (*Subnet) First

func (s *Subnet) First() (ip netip.Addr, err error)

First get first IP for subnet

func (*Subnet) Hosts

func (s *Subnet) Hosts() int64

Hosts bits remaining in mask block

func (*Subnet) IP

func (s *Subnet) IP() netip.Addr

IP get IP for subnet

func (*Subnet) IPRange

func (s *Subnet) IPRange() (r Range, err error)

IPRange get subnet range

func (*Subnet) IPRanges

func (s *Subnet) IPRanges() (ranges []Range, err error)

IPRanges the set of equally sized ranges for subnet

func (*Subnet) IPs

func (s *Subnet) IPs() (ips []netip.Addr, err error)

IPs get ips for subnet

func (*Subnet) JSON

func (s *Subnet) JSON() (bytes []byte, err error)

JSON get JSON for subnet

func (*Subnet) Last

func (s *Subnet) Last() (ip netip.Addr)

Last get last IP for subnet

func (*Subnet) Name

func (s *Subnet) Name() string

Name subnet name

func (*Subnet) NetworkAddr

func (s *Subnet) NetworkAddr() (ip netip.Addr)

NetworkAddr get last IP for subnet

func (*Subnet) Networks

func (s *Subnet) Networks() int64

Networks number of subnets

func (*Subnet) Prefix

func (s *Subnet) Prefix() netip.Prefix

Prefix get prefix for subnet

func (*Subnet) SecondaryIPRanges

func (s *Subnet) SecondaryIPRanges(secondarySubnet *Subnet) (ranges []Range, err error)

SecondaryIPRanges set of ranges in the context of parent subnet

func (*Subnet) SecondarySubnets

func (s *Subnet) SecondarySubnets(secondarySubnet *Subnet) (subnets []*Subnet, err error)

SecondarySubnets set of subnets in the context of parent subnet

func (*Subnet) SetName

func (s *Subnet) SetName(name string)

SetName set subnet name

func (*Subnet) String

func (s *Subnet) String() string

String get string representing subnet (cidr notation)

func (*Subnet) SubnetMask

func (s *Subnet) SubnetMask() netip.Addr

SubnetMask get subnet mask for subnet

func (*Subnet) Subnets

func (s *Subnet) Subnets() (subnets []*Subnet, err error)

Subnets the set of equally sized subnets for subnet

func (*Subnet) TotalHosts

func (s *Subnet) TotalHosts() int64

TotalHosts total hosts in subnet

func (*Subnet) UsableHosts

func (s *Subnet) UsableHosts() int64

UsableHosts number of usable hosts

func (*Subnet) UsableIPRange

func (s *Subnet) UsableIPRange() (r Range, err error)

UsableIPRange get range of IPs usable for hosts

func (*Subnet) UsableIPs

func (s *Subnet) UsableIPs() (ips []netip.Addr, err error)

UsableIPs get usable ips for subnet

func (*Subnet) WildcardMask

func (s *Subnet) WildcardMask() netip.Addr

WildcardMask get wildcard mask for subnet

func (*Subnet) YAML

func (s *Subnet) YAML() (bytes []byte, err error)

YAML get YAML for subnet

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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