cidr

package
v1.14.2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains added in v1.14.0

func Contains(ipNets []*net.IPNet, ipNet *net.IPNet) bool

Contains returns true if 'ipNets' contains ipNet.

func ContainsAll added in v1.14.0

func ContainsAll(ipNets1, ipNets2 []*net.IPNet) bool

ContainsAll returns true if 'ipNets1' contains all net.IPNet of 'ipNets2'

func Equal added in v1.14.0

func Equal(n, o *net.IPNet) bool

Equal returns true if the n and o net.IPNet CIDRs arr Equal.

func RemoveAll added in v1.14.0

func RemoveAll(ipNets, toRemove []*net.IPNet) []*net.IPNet

RemoveAll removes all cidrs specified in 'toRemove' from 'ipNets'. ipNets is clobbered (to ensure removed CIDRs can be garbage collected) and must not be used after this function has been called. Example usage:

cidrs = cidr.RemoveAll(cidrs, toRemove)

Types

type CIDR

type CIDR struct {
	*net.IPNet
}

CIDR is a network CIDR representation based on net.IPNet

func DiffCIDRLists

func DiffCIDRLists(old, new []*CIDR) (add, remove []*CIDR)

DiffCIDRLists compares an old and new list of CIDRs and returns the list of removed and added CIDRs

func MustParseCIDR

func MustParseCIDR(str string) *CIDR

MustParseCIDR parses the CIDR string using net.ParseCIDR and panics if the CIDR cannot be parsed

func NewCIDR

func NewCIDR(ipnet *net.IPNet) *CIDR

NewCIDR returns a new CIDR using a net.IPNet

func ParseCIDR

func ParseCIDR(str string) (*CIDR, error)

ParseCIDR parses the CIDR string using net.ParseCIDR

func (*CIDR) AvailableIPs added in v1.14.0

func (n *CIDR) AvailableIPs() int

AvailableIPs returns the number of IPs available in a CIDR

func (*CIDR) DeepCopy

func (n *CIDR) DeepCopy() *CIDR

DeepCopy creates a deep copy of a CIDR

func (*CIDR) DeepCopyInto added in v1.14.0

func (in *CIDR) DeepCopyInto(out *CIDR)

DeepCopyInto is a deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*CIDR) DeepEqual added in v1.14.0

func (in *CIDR) DeepEqual(other *CIDR) bool

DeepEqual is an deepequal function, deeply comparing the receiver with other. in must be non-nil.

func (*CIDR) Equal added in v1.14.0

func (n *CIDR) Equal(o *CIDR) bool

Equal returns true if the receiver's CIDR equals the other CIDR.

Jump to

Keyboard shortcuts

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