Documentation
¶
Index ¶
Constants ¶
const ( DefaultLifeTime = time.Hour DefaultRecvChanDepth = 1024 DefaultProbeInterval = 5 * time.Second )
Variables ¶
var (
BroadCastMAC = net.HardwareAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
)
Functions ¶
func GetLLAFromMAC ¶
func GetLLAFromMAC(mac net.HardwareAddr) netip.Addr
GetLLAFromMAC returns an IPv6 LLA from mac, according to the alg described in Appendix A of RFC4291
func GetMulticastMACfromIPv6Addr ¶
func GetMulticastMACfromIPv6Addr(addr netip.Addr) net.HardwareAddr
Types ¶
type IPv6ND ¶
type IPv6ND struct {
// contains filtered or unexported fields
}
IPv6ND does two jobs: 1. respond to NS for local address; 2. resolve IPv6 to MAC
func NewDefaultIPv6ND ¶
func NewDefaultIPv6ND(ctx context.Context, ownmac net.HardwareAddr, ownip netip.Addr, recvc chan []byte, sendf SendPktFunc) *IPv6ND
NewDefaultIPv6ND creats a new IPv6ND with default settings
func NewIPv6ND ¶
func NewIPv6ND(ctx context.Context, ownmac net.HardwareAddr, ownip netip.Addr, recvc chan []byte, sendf SendPktFunc, life time.Duration, recvchandepth int, logf LoggerFunc, probe bool, probeinterval time.Duration) *IPv6ND
NewIPv6ND creates a new IPv6ND, with following parameters: ownmac, ownip is used as source MAC/IP for egress NS; life specifies how long an existing entry need to be re-probed; recvchandepth is the depth of receives msg channel; logf is the logging function; if probe is true, then system will send probe for unresolved IP, probeinterval is the retry interval for probe;
func (*IPv6ND) GetRecvChan ¶
GetRecvChan returns the channel used to receve ICMPv6 packet, must be an IP packet.
type LoggerFunc ¶
type LoggerFunc func(format string, a ...interface{})
type SendPktFunc ¶
type SendPktFunc func(p []byte, dstmac net.HardwareAddr) (int, error)