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 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) ToMac(prefix string) string
- type IPV4AddrRange
- func (ar IPV4AddrRange) AddressCount() int
- func (ar IPV4AddrRange) Contains(ip IPV4Addr) bool
- func (ar IPV4AddrRange) ContainsRange(ar2 IPV4AddrRange) bool
- func (ar IPV4AddrRange) EndIp() IPV4Addr
- 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) (lefts []IPV4AddrRange, sub *IPV4AddrRange)
- func (ar IPV4AddrRange) ToIPNets() []*net.IPNet
- func (ar IPV4AddrRange) ToMaskMatches() [][2]uint32
- 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
- type IPV6AddrRange
- func (ar IPV6AddrRange) Contains(ip IPV6Addr) bool
- func (ar IPV6AddrRange) ContainsRange(ar2 IPV6AddrRange) bool
- func (ar IPV6AddrRange) EndIp() IPV6Addr
- 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
- 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 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 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) 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) 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) (lefts []IPV4AddrRange, sub *IPV4AddrRange)
func (IPV4AddrRange) ToIPNets ¶
func (ar IPV4AddrRange) ToIPNets() []*net.IPNet
func (IPV4AddrRange) ToMaskMatches ¶
func (ar IPV4AddrRange) ToMaskMatches() [][2]uint32
type IPV4Prefix ¶
func NewIPV4Prefix ¶
func NewIPV4Prefix(prefix string) (IPV4Prefix, error)
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) ToIPRange ¶
func (prefix IPV4Prefix) ToIPRange() IPV4AddrRange
type IPV6Addr ¶ added in v1.10.0
type IPV6Addr [8]uint16
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) 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) 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
type IPV6Prefix ¶ added in v1.10.0
func NewIPV6Prefix ¶ added in v1.10.0
func NewIPV6Prefix(prefix string) (IPV6Prefix, error)
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) ToIPRange ¶ added in v1.10.0
func (prefix IPV6Prefix) ToIPRange() IPV6AddrRange
Click to show internal directories.
Click to hide internal directories.