Documentation
¶
Overview ¶
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- type IPBlock
- func DisjointIPBlocks(set1, set2 []*IPBlock) []*IPBlock
- func FromCidr(cidr string) (*IPBlock, error)
- func FromCidrList(cidrsList []string) (*IPBlock, error)
- func FromCidrOrAddress(s string) (*IPBlock, error)
- func FromIPAddress(ipAddress string) (*IPBlock, error)
- func FromIPRangeStr(ipRangeStr string) (*IPBlock, error)
- func GetCidrAll() *IPBlock
- func New() *IPBlock
- func PairCIDRsToIPBlocks(cidr1, cidr2 string) (ipb1, ipb2 *IPBlock, err error)
- func (b *IPBlock) ContainedIn(other *IPBlock) bool
- func (b *IPBlock) Copy() *IPBlock
- func (b *IPBlock) Equal(c *IPBlock) bool
- func (b *IPBlock) ExceptCidrs(exceptions ...string) (*IPBlock, error)
- func (b *IPBlock) FirstIPAddress() string
- func (b *IPBlock) Intersect(c *IPBlock) *IPBlock
- func (b *IPBlock) IsEmpty() bool
- func (b *IPBlock) ListToPrint() []string
- func (b *IPBlock) Overlap(c *IPBlock) bool
- func (b *IPBlock) PrefixLength() (int64, error)
- func (b *IPBlock) Split() []*IPBlock
- func (b *IPBlock) String() string
- func (b *IPBlock) Subtract(c *IPBlock) *IPBlock
- func (b *IPBlock) ToCidrList() []string
- func (b *IPBlock) ToCidrListString() string
- func (b *IPBlock) ToIPAddressString() string
- func (b *IPBlock) ToIPRanges() string
- func (b *IPBlock) Union(c *IPBlock) *IPBlock
Constants ¶
const (
// CidrAll represents the CIDR for all addresses "0.0.0.0/0"
CidrAll = "0.0.0.0/0"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IPBlock ¶
type IPBlock struct {
// contains filtered or unexported fields
}
IPBlock captures a set of IP ranges
func DisjointIPBlocks ¶
DisjointIPBlocks returns an IPBlock of disjoint ip ranges from 2 input IPBlock objects
func FromCidrList ¶
FromCidrList returns IPBlock object from multiple CIDRs given as list of strings
func FromCidrOrAddress ¶
FromCidrOrAddress returns a new IPBlock object from input string of CIDR or IP address
func FromIPAddress ¶
FromIPAddress returns an IPBlock object from input IP address string
func FromIPRangeStr ¶
FromIPRangeStr returns IPBlock object from input IP range string (example: "169.255.0.0-172.15.255.255")
func GetCidrAll ¶
func GetCidrAll() *IPBlock
GetCidrAll returns IPBlock object of the entire range 0.0.0.0/0
func PairCIDRsToIPBlocks ¶
PairCIDRsToIPBlocks returns two IPBlock objects from two input CIDR strings
func (*IPBlock) ContainedIn ¶
ContainedIn checks if this IP block is contained within another IP block.
func (*IPBlock) ExceptCidrs ¶ added in v0.3.0
ExceptCidrs returns a new IPBlock with all cidr ranges removed
func (*IPBlock) FirstIPAddress ¶ added in v0.3.2
FirstIPAddress() returns the first IP Address string for this IPBlock
func (*IPBlock) Intersect ¶
Intersect returns a new IPBlock from intersection of this IPBlock with input IPBlock
func (*IPBlock) ListToPrint ¶
ListToPrint: returns a uniform to print list s.t. each element contains either a single cidr or an ip range
func (*IPBlock) Overlap ¶ added in v0.3.4
Overlap returns whether the two IPBlocks have at least one IP address in common
func (*IPBlock) PrefixLength ¶
PrefixLength returns the cidr's prefix length, assuming the ipBlock is exactly one cidr. Prefix length specifies the number of bits in the IP address that are to be used as the subnet mask.
func (*IPBlock) String ¶ added in v0.3.1
String returns an IPBlock's string -- either single IP address, or list of CIDR strings
func (*IPBlock) Subtract ¶
Subtract returns a new IPBlock from subtraction of input IPBlock from this IPBlock
func (*IPBlock) ToCidrList ¶
ToCidrList returns a list of CIDR strings for this IPBlock object
func (*IPBlock) ToCidrListString ¶
ToCidrListString returns a string with all CIDRs within the IPBlock object
func (*IPBlock) ToIPAddressString ¶
ToIPAdressString returns the IP Address string for this IPBlock
func (*IPBlock) ToIPRanges ¶
ToIPRanges returns a string of the ip ranges in the current IPBlock object