Documentation ¶
Overview ¶
Package cidr calculates CIDR network
Index ¶
- func AscSortCIDRs(cs []*CIDR)
- func Compare(a, b net.IP) int
- func CompareCIDR(a, b *CIDR) int
- func DecrIP(ip net.IP)
- func DescSortCIDRs(cs []*CIDR)
- func IncrIP(ip net.IP)
- type CIDR
- func (c CIDR) Broadcast() string
- func (c CIDR) CIDR() string
- func (c CIDR) Contains(ip string) bool
- func (c CIDR) Equal(ns string) bool
- func (c CIDR) ForEachIP(iterator func(ip string) error) error
- func (c CIDR) ForEachIPBeginWith(beginIP string, iterator func(ip string) error) error
- func (c CIDR) IP() string
- func (c CIDR) IPCount() *big.Int
- func (c CIDR) IPRange() (begin, end string)
- func (c CIDR) IsIPv4() bool
- func (c CIDR) IsIPv6() bool
- func (c CIDR) Mask() string
- func (c CIDR) MaskSize() (ones, bits int)
- func (c CIDR) Network() string
- func (c CIDR) String() string
- func (c CIDR) SubNetting(method, num int) ([]*CIDR, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
Compare returns an integer comparing two ip The result will be 0 if a==b, -1 if a < b, and +1 if a > b.
func CompareCIDR ¶
CompareCIDR returns an integer comparing two CIDR The result will be 0 if a==b, -1 if a < b, and +1 if a > b.
func DescSortCIDRs ¶
func DescSortCIDRs(cs []*CIDR)
DescSortCIDRs sort cidr slice order by ip,mask desc
Types ¶
type CIDR ¶
type CIDR struct {
// contains filtered or unexported fields
}
CIDR https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
func ParseCIDR ¶
ParseCIDR parses s as a CIDR notation IP address and mask length, like "192.0.2.0/24" or "2001:db8::/32", as defined in RFC 4632 and RFC 4291
func SuperNetting ¶
SuperNetting merge network segments, must be contiguous
func (CIDR) CIDR ¶
CIDR returns the CIDR string. If the IP prefix of the input CIDR string is inaccurate, it returns the string which be corrected by the mask length. For example, "192.0.2.10/24" return "192.0.2.0/24"
func (CIDR) ForEachIPBeginWith ¶
ForEachIPBeginWith begin with specified ip, iterate through each ip in the CIDR