Documentation ¶
Index ¶
- Constants
- Variables
- func DeriveIPv6AddrFromIPv4AddrMac(ipAddr string, macAddr string, startIp6, endIp6 string, maskLen6 uint8) string
- func ErrMacFormat(macStr string) error
- func FormatMacAddr(macAddr string) string
- func GetFreePort() (int, error)
- func GetHttpRequestIp(r *http.Request) string
- func IP2Number(ipstr string) (uint32, error)
- func IsExitAddress(addr IPV4Addr) bool
- func IsHostLocal(addr IPV4Addr) bool
- func IsLinkLocal(addr IPV4Addr) bool
- func IsMulticast(addr IPV4Addr) bool
- func IsPrivate(addr IPV4Addr) bool
- func MacUnpackHex(mac string) string
- func Mask2Len(mask IPV4Addr) int8
- func Netlen2Mask(netmasklen int) string
- func Number2Bytes(num uint32) []byte
- func Number2IP(num uint32) string
- func SetPrivatePrefixes(pref []string)
- type IPV4Addr
- func (addr IPV4Addr) BroadcastAddr(maskLen int8) IPV4Addr
- func (addr IPV4Addr) CliAddr(maskLen int8) IPV4Addr
- func (addr IPV4Addr) NetAddr(maskLen int8) IPV4Addr
- func (addr IPV4Addr) StepDown() IPV4Addr
- func (addr IPV4Addr) StepUp() IPV4Addr
- func (addr IPV4Addr) String() string
- func (addr IPV4Addr) ToBytes() []byte
- func (addr IPV4Addr) ToIP() net.IP
- func (addr IPV4Addr) ToMac(prefix string) string
- type IPV4AddrRange
- func (ar IPV4AddrRange) AddressCount() int
- func (v4range IPV4AddrRange) Compare(r2 IPV4AddrRange) sortutils.CompareResult
- func (ar IPV4AddrRange) Contains(ip IPV4Addr) bool
- func (ar IPV4AddrRange) ContainsRange(ar2 IPV4AddrRange) bool
- func (ar IPV4AddrRange) EndIp() IPV4Addr
- func (r IPV4AddrRange) IsAll() bool
- func (ar IPV4AddrRange) IsOverlap(ar2 IPV4AddrRange) bool
- func (ar IPV4AddrRange) Merge(ar2 IPV4AddrRange) (IPV4AddrRange, bool)
- func (ar IPV4AddrRange) Random() IPV4Addr
- func (ar *IPV4AddrRange) Set(ip1 IPV4Addr, ip2 IPV4Addr)
- func (ar IPV4AddrRange) StartIp() IPV4Addr
- func (ar IPV4AddrRange) String() string
- func (ar IPV4AddrRange) Substract(ar2 IPV4AddrRange) ([]IPV4AddrRange, *IPV4AddrRange)
- func (ar IPV4AddrRange) Substract2(ar2 IPV4AddrRange) ([]IPV4AddrRange, bool, IPV4AddrRange)
- func (ar IPV4AddrRange) ToIPNets() []*net.IPNet
- func (ar IPV4AddrRange) ToPrefixes() []IPV4Prefix
- type IPV4AddrRangeList
- func (rl IPV4AddrRangeList) Len() int
- func (rl IPV4AddrRangeList) Less(i, j int) bool
- func (rl IPV4AddrRangeList) Merge() []IPV4AddrRange
- func (rl IPV4AddrRangeList) String() string
- func (rl IPV4AddrRangeList) Substract(addrRange IPV4AddrRange) []IPV4AddrRange
- func (rl IPV4AddrRangeList) Swap(i, j int)
- type IPV4Prefix
- type IPV6Addr
- func (addr IPV6Addr) BroadcastAddr(maskLen uint8) IPV6Addr
- func (addr IPV6Addr) Equals(addr2 IPV6Addr) bool
- func (addr IPV6Addr) Ge(addr2 IPV6Addr) bool
- func (addr IPV6Addr) Gt(addr2 IPV6Addr) bool
- func (addr IPV6Addr) HostAddr(hostAddr IPV6Addr, maskLen uint8) IPV6Addr
- func (addr IPV6Addr) Le(addr2 IPV6Addr) bool
- func (addr IPV6Addr) Lt(addr2 IPV6Addr) bool
- func (addr IPV6Addr) NetAddr(maskLen uint8) IPV6Addr
- func (addr IPV6Addr) StepDown() IPV6Addr
- func (addr IPV6Addr) StepUp() IPV6Addr
- func (addr IPV6Addr) String() string
- func (addr IPV6Addr) ToBytes() []byte
- func (addr IPV6Addr) ToIP() net.IP
- type IPV6AddrRange
- func (v6range IPV6AddrRange) Compare(r2 IPV6AddrRange) sortutils.CompareResult
- func (ar IPV6AddrRange) Contains(ip IPV6Addr) bool
- func (ar IPV6AddrRange) ContainsRange(ar2 IPV6AddrRange) bool
- func (ar IPV6AddrRange) EndIp() IPV6Addr
- func (r IPV6AddrRange) IsAll() bool
- func (ar IPV6AddrRange) IsOverlap(ar2 IPV6AddrRange) bool
- func (ar IPV6AddrRange) Merge(ar2 IPV6AddrRange) (IPV6AddrRange, bool)
- func (ar IPV6AddrRange) Random() IPV6Addr
- func (ar *IPV6AddrRange) Set(ip1 IPV6Addr, ip2 IPV6Addr)
- func (ar IPV6AddrRange) StartIp() IPV6Addr
- func (ar IPV6AddrRange) String() string
- func (ar IPV6AddrRange) Substract(ar2 IPV6AddrRange) ([]IPV6AddrRange, *IPV6AddrRange)
- func (ar IPV6AddrRange) Substract2(ar2 IPV6AddrRange) ([]IPV6AddrRange, bool, IPV6AddrRange)
- func (ar IPV6AddrRange) ToIPNets() []*net.IPNet
- func (ar IPV6AddrRange) ToPrefixes() []IPV6Prefix
- type IPV6AddrRangeList
- func (rl IPV6AddrRangeList) Len() int
- func (rl IPV6AddrRangeList) Less(i, j int) bool
- func (rl IPV6AddrRangeList) Merge() []IPV6AddrRange
- func (rl IPV6AddrRangeList) String() string
- func (rl IPV6AddrRangeList) Substract(addrRange IPV6AddrRange) []IPV6AddrRange
- func (rl IPV6AddrRangeList) Swap(i, j int)
- type IPV6Prefix
- type SMacAddr
Constants ¶
View Source
const MaxUint16 = uint16(0xffff)
Variables ¶
View Source
var ( ErrInvalidNumber = errors.Error("invalid number") ErrOutOfRange = errors.Error("ip number out of range [0-255]") ErrInvalidIPAddr = errors.Error("invalid ip address") ErrInvalidMask = errors.Error("invalid mask") ErrOutOfRangeMask = errors.Error("out of range masklen [0-32]") )
View Source
var AllIPV4AddrRange = IPV4AddrRange{ // contains filtered or unexported fields }
View Source
var AllIPV6AddrRange = IPV6AddrRange{ // contains filtered or unexported fields }
View Source
var IPV4Ones = IPV4Addr(0xffffffff)
View Source
var IPV4Zero = IPV4Addr(0)
View Source
var IPV6Ones = IPV6Addr([8]uint16{0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff})
View Source
var IPV6Zero = IPV6Addr([8]uint16{0, 0, 0, 0, 0, 0, 0, 0})
View Source
var MASKS = []string{"0", "128", "192", "224", "240", "248", "252", "254", "255"}
Functions ¶
func DeriveIPv6AddrFromIPv4AddrMac ¶ added in v1.10.0
func ErrMacFormat ¶ added in v1.10.0
func FormatMacAddr ¶
func GetFreePort ¶ added in v1.10.0
func GetHttpRequestIp ¶ added in v1.10.2
func IsExitAddress ¶
func IsHostLocal ¶
func IsLinkLocal ¶
func IsMulticast ¶
func MacUnpackHex ¶
func Netlen2Mask ¶ added in v1.10.0
func Number2Bytes ¶
func SetPrivatePrefixes ¶
func SetPrivatePrefixes(pref []string)
Types ¶
type IPV4Addr ¶
type IPV4Addr uint32
func Masklen2Mask ¶
func NewIPV4Addr ¶
func (IPV4Addr) BroadcastAddr ¶
type IPV4AddrRange ¶
type IPV4AddrRange struct {
// contains filtered or unexported fields
}
func GetPrivateIPRanges ¶
func GetPrivateIPRanges() []IPV4AddrRange
func NewIPV4AddrRange ¶
func NewIPV4AddrRange(ip1 IPV4Addr, ip2 IPV4Addr) IPV4AddrRange
func NewIPV4AddrRangeFromIPNet ¶
func NewIPV4AddrRangeFromIPNet(n *net.IPNet) IPV4AddrRange
n.IP and n.Mask must be ipv4 type. n.Mask must be canonical
func (IPV4AddrRange) AddressCount ¶
func (ar IPV4AddrRange) AddressCount() int
func (IPV4AddrRange) Compare ¶ added in v1.10.2
func (v4range IPV4AddrRange) Compare(r2 IPV4AddrRange) sortutils.CompareResult
func (IPV4AddrRange) Contains ¶
func (ar IPV4AddrRange) Contains(ip IPV4Addr) bool
func (IPV4AddrRange) ContainsRange ¶
func (ar IPV4AddrRange) ContainsRange(ar2 IPV4AddrRange) bool
func (IPV4AddrRange) EndIp ¶
func (ar IPV4AddrRange) EndIp() IPV4Addr
func (IPV4AddrRange) IsAll ¶ added in v1.10.2
func (r IPV4AddrRange) IsAll() bool
func (IPV4AddrRange) IsOverlap ¶
func (ar IPV4AddrRange) IsOverlap(ar2 IPV4AddrRange) bool
func (IPV4AddrRange) Merge ¶
func (ar IPV4AddrRange) Merge(ar2 IPV4AddrRange) (IPV4AddrRange, bool)
func (IPV4AddrRange) Random ¶
func (ar IPV4AddrRange) Random() IPV4Addr
func (*IPV4AddrRange) Set ¶ added in v1.10.0
func (ar *IPV4AddrRange) Set(ip1 IPV4Addr, ip2 IPV4Addr)
func (IPV4AddrRange) StartIp ¶
func (ar IPV4AddrRange) StartIp() IPV4Addr
func (IPV4AddrRange) String ¶
func (ar IPV4AddrRange) String() string
func (IPV4AddrRange) Substract ¶
func (ar IPV4AddrRange) Substract(ar2 IPV4AddrRange) ([]IPV4AddrRange, *IPV4AddrRange)
func (IPV4AddrRange) Substract2 ¶ added in v1.10.2
func (ar IPV4AddrRange) Substract2(ar2 IPV4AddrRange) ([]IPV4AddrRange, bool, IPV4AddrRange)
func (IPV4AddrRange) ToIPNets ¶
func (ar IPV4AddrRange) ToIPNets() []*net.IPNet
func (IPV4AddrRange) ToPrefixes ¶ added in v1.10.2
func (ar IPV4AddrRange) ToPrefixes() []IPV4Prefix
type IPV4AddrRangeList ¶ added in v1.10.2
type IPV4AddrRangeList []IPV4AddrRange
func (IPV4AddrRangeList) Len ¶ added in v1.10.2
func (rl IPV4AddrRangeList) Len() int
func (IPV4AddrRangeList) Less ¶ added in v1.10.2
func (rl IPV4AddrRangeList) Less(i, j int) bool
func (IPV4AddrRangeList) Merge ¶ added in v1.10.2
func (rl IPV4AddrRangeList) Merge() []IPV4AddrRange
func (IPV4AddrRangeList) String ¶ added in v1.10.2
func (rl IPV4AddrRangeList) String() string
func (IPV4AddrRangeList) Substract ¶ added in v1.10.2
func (rl IPV4AddrRangeList) Substract(addrRange IPV4AddrRange) []IPV4AddrRange
func (IPV4AddrRangeList) Swap ¶ added in v1.10.2
func (rl IPV4AddrRangeList) Swap(i, j int)
type IPV4Prefix ¶
func NewIPV4Prefix ¶
func NewIPV4Prefix(prefix string) (IPV4Prefix, error)
func NewIPV4PrefixFromAddr ¶ added in v1.10.2
func NewIPV4PrefixFromAddr(addr IPV4Addr, masklen int8) IPV4Prefix
func (IPV4Prefix) Contains ¶
func (prefix IPV4Prefix) Contains(ip IPV4Addr) bool
func (*IPV4Prefix) Equals ¶
func (pref *IPV4Prefix) Equals(pref1 *IPV4Prefix) bool
func (*IPV4Prefix) String ¶
func (pref *IPV4Prefix) String() string
func (IPV4Prefix) ToIPNet ¶ added in v1.10.2
func (pref IPV4Prefix) ToIPNet() *net.IPNet
func (IPV4Prefix) ToIPRange ¶
func (prefix IPV4Prefix) ToIPRange() IPV4AddrRange
type IPV6Addr ¶ added in v1.10.0
type IPV6Addr [8]uint16
func Mac2LinkLocal ¶ added in v1.10.2
func NewIPV6Addr ¶ added in v1.10.0
func (IPV6Addr) BroadcastAddr ¶ added in v1.10.0
type IPV6AddrRange ¶ added in v1.10.0
type IPV6AddrRange struct {
// contains filtered or unexported fields
}
func NewIPV6AddrRange ¶ added in v1.10.0
func NewIPV6AddrRange(ip1 IPV6Addr, ip2 IPV6Addr) IPV6AddrRange
func NewIPV6AddrRangeFromIPNet ¶ added in v1.10.0
func NewIPV6AddrRangeFromIPNet(n *net.IPNet) IPV6AddrRange
n.IP and n.Mask must be ipv4 type. n.Mask must be canonical
func (IPV6AddrRange) Compare ¶ added in v1.10.2
func (v6range IPV6AddrRange) Compare(r2 IPV6AddrRange) sortutils.CompareResult
func (IPV6AddrRange) Contains ¶ added in v1.10.0
func (ar IPV6AddrRange) Contains(ip IPV6Addr) bool
func (IPV6AddrRange) ContainsRange ¶ added in v1.10.0
func (ar IPV6AddrRange) ContainsRange(ar2 IPV6AddrRange) bool
func (IPV6AddrRange) EndIp ¶ added in v1.10.0
func (ar IPV6AddrRange) EndIp() IPV6Addr
func (IPV6AddrRange) IsAll ¶ added in v1.10.2
func (r IPV6AddrRange) IsAll() bool
func (IPV6AddrRange) IsOverlap ¶ added in v1.10.0
func (ar IPV6AddrRange) IsOverlap(ar2 IPV6AddrRange) bool
func (IPV6AddrRange) Merge ¶ added in v1.10.0
func (ar IPV6AddrRange) Merge(ar2 IPV6AddrRange) (IPV6AddrRange, bool)
func (IPV6AddrRange) Random ¶ added in v1.10.0
func (ar IPV6AddrRange) Random() IPV6Addr
func (*IPV6AddrRange) Set ¶ added in v1.10.0
func (ar *IPV6AddrRange) Set(ip1 IPV6Addr, ip2 IPV6Addr)
func (IPV6AddrRange) StartIp ¶ added in v1.10.0
func (ar IPV6AddrRange) StartIp() IPV6Addr
func (IPV6AddrRange) String ¶ added in v1.10.0
func (ar IPV6AddrRange) String() string
func (IPV6AddrRange) Substract ¶ added in v1.10.2
func (ar IPV6AddrRange) Substract(ar2 IPV6AddrRange) ([]IPV6AddrRange, *IPV6AddrRange)
func (IPV6AddrRange) Substract2 ¶ added in v1.10.2
func (ar IPV6AddrRange) Substract2(ar2 IPV6AddrRange) ([]IPV6AddrRange, bool, IPV6AddrRange)
func (IPV6AddrRange) ToIPNets ¶ added in v1.10.2
func (ar IPV6AddrRange) ToIPNets() []*net.IPNet
func (IPV6AddrRange) ToPrefixes ¶ added in v1.10.2
func (ar IPV6AddrRange) ToPrefixes() []IPV6Prefix
type IPV6AddrRangeList ¶ added in v1.10.2
type IPV6AddrRangeList []IPV6AddrRange
func (IPV6AddrRangeList) Len ¶ added in v1.10.2
func (rl IPV6AddrRangeList) Len() int
func (IPV6AddrRangeList) Less ¶ added in v1.10.2
func (rl IPV6AddrRangeList) Less(i, j int) bool
func (IPV6AddrRangeList) Merge ¶ added in v1.10.2
func (rl IPV6AddrRangeList) Merge() []IPV6AddrRange
func (IPV6AddrRangeList) String ¶ added in v1.10.2
func (rl IPV6AddrRangeList) String() string
func (IPV6AddrRangeList) Substract ¶ added in v1.10.2
func (rl IPV6AddrRangeList) Substract(addrRange IPV6AddrRange) []IPV6AddrRange
func (IPV6AddrRangeList) Swap ¶ added in v1.10.2
func (rl IPV6AddrRangeList) Swap(i, j int)
type IPV6Prefix ¶ added in v1.10.0
func NewIPV6Prefix ¶ added in v1.10.0
func NewIPV6Prefix(prefix string) (IPV6Prefix, error)
func NewIPV6PrefixFromAddr ¶ added in v1.10.2
func NewIPV6PrefixFromAddr(addr IPV6Addr, masklen uint8) IPV6Prefix
func (IPV6Prefix) Contains ¶ added in v1.10.0
func (prefix IPV6Prefix) Contains(ip IPV6Addr) bool
func (*IPV6Prefix) Equals ¶ added in v1.10.0
func (pref *IPV6Prefix) Equals(pref1 *IPV6Prefix) bool
func (*IPV6Prefix) String ¶ added in v1.10.0
func (pref *IPV6Prefix) String() string
func (IPV6Prefix) ToIPNet ¶ added in v1.10.2
func (pref IPV6Prefix) ToIPNet() *net.IPNet
func (IPV6Prefix) ToIPRange ¶ added in v1.10.0
func (prefix IPV6Prefix) ToIPRange() IPV6AddrRange
Click to show internal directories.
Click to hide internal directories.