Documentation
¶
Overview ¶
Package myaddr is Go module that provides varies functions to processing address, include IP address, MAC address and VLAN ID.
Index ¶
- Constants
- func AddrtoBig(addr net.IP) *big.Int
- func BigtoAddr(n *big.Int, ipv4 bool) (net.IP, error)
- func BigtoHWAddr(n *big.Int, alen int) (net.HardwareAddr, error)
- func BigtoMACAddr(n *big.Int) (net.HardwareAddr, error)
- func GenAddrWithIPNet(prefix *net.IPNet, hostn *big.Int) (net.IP, error)
- func GenConnectionAddrStr(prefix string, ip net.IP, port int) string
- func GenPrefixWithPrefix(prefix netip.Prefix, hostn *big.Int) (netip.Prefix, error)
- func GetLLAFromMac(mac net.HardwareAddr) net.IP
- func HWAddrtoBig(addr net.HardwareAddr) *big.Int
- func IncAddr(addr net.IP, step *big.Int) (net.IP, error)
- func IncMACAddr(macaddr net.HardwareAddr, step *big.Int) (net.HardwareAddr, error)
- func IncreaseVLANIDs(ids []uint16, step int) ([]uint16, error)
Constants ¶
const ( MaxIPv4AddrN = 4294967295 MaxMACAddrN = 281474976710655 MaxIPv6AddrStr = "340282366920938463463374607431768211455" )
MAX Values
Variables ¶
This section is empty.
Functions ¶
func BigtoHWAddr ¶
BigtoHWAddr convert n to a hardware address, with specified alen
func BigtoMACAddr ¶
func BigtoMACAddr(n *big.Int) (net.HardwareAddr, error)
BigtoMACAddr convert n to a MAC address
func GenAddrWithIPNet ¶ added in v0.1.2
GenAddrWithIPNet geneate an address = prefix + hostn. hostn must>=0
func GenConnectionAddrStr ¶
GenConnectionAddrStr return a string with following format: IPv4: <prefix><ip>:<port> IPv6: <prefix>[<ip>]:<port>
func GenPrefixWithPrefix ¶ added in v0.1.3
GenPrefixWithPrefix geneate an prefix = prefix + hostn. hostn must>=0
func GetLLAFromMac ¶ added in v0.1.1
func GetLLAFromMac(mac net.HardwareAddr) net.IP
GetLLAFromMac return an IPv6 link local address from mac, based on Appendix A of RFC4291
func HWAddrtoBig ¶
func HWAddrtoBig(addr net.HardwareAddr) *big.Int
HWAddrtoBig convert hardware address to *big.Int
func IncMACAddr ¶
func IncMACAddr(macaddr net.HardwareAddr, step *big.Int) (net.HardwareAddr, error)
IncMACAddr increase macaddr by step (could be negative), return the result
Types ¶
This section is empty.