cidr

package
v1.17.0-pre.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: Apache-2.0 Imports: 5 Imported by: 56

Documentation

Index

Constants

View Source
const (
	FAMILY_ALL  = nl.FAMILY_ALL
	FAMILY_V4   = nl.FAMILY_V4
	FAMILY_V6   = nl.FAMILY_V6
	FAMILY_MPLS = nl.FAMILY_MPLS
)

Family type definitions

Variables

This section is empty.

Functions

func CIDRsToIPNets

func CIDRsToIPNets(cidrs []*CIDR) []*net.IPNet

func ContainsAll

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

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

func Equal

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

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

func ZeroNet

func ZeroNet(family int) *net.IPNet

ZeroNet generates a zero net.IPNet object for the given address family

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 NewCIDRSlice

func NewCIDRSlice(ipnets []*net.IPNet) []*CIDR

func ParseCIDR

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

ParseCIDR parses the CIDR string using net.ParseCIDR

func (*CIDR) AvailableIPs

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

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

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

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