nd

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2023 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultLifeTime      = time.Hour
	DefaultRecvChanDepth = 1024
	DefaultProbeInterval = 5 * time.Second
)

Variables

View Source
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

func GetSolicitedNodeMulticastAddr

func GetSolicitedNodeMulticastAddr(addr netip.Addr) netip.Addr

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) GetList

func (v6nd *IPv6ND) GetList() (rlist []*Neighbor)

GetList returns current list as a slice of *Neighbor

func (*IPv6ND) GetRecvChan

func (v6nd *IPv6ND) GetRecvChan() chan []byte

GetRecvChan returns the channel used to receve ICMPv6 packet, must be an IP packet.

func (*IPv6ND) Register

func (v6nd *IPv6ND) Register(addr netip.Addr, mac net.HardwareAddr)

Register adds a IP addr and MAC pairing to local list

func (*IPv6ND) Resolve

func (v6nd *IPv6ND) Resolve(addr netip.Addr) net.HardwareAddr

Resolve resolve addr to mac based on local list, if not found and activeProbe is true, then send probe

type LoggerFunc

type LoggerFunc func(format string, a ...interface{})

type NeiState

type NeiState uint32
const (
	StateStale NeiState = iota
	StateProbing
)

type Neighbor

type Neighbor struct {
	IPAddr     netip.Addr
	HWAddr     net.HardwareAddr
	Expiration time.Time
	// contains filtered or unexported fields
}

type SendPktFunc

type SendPktFunc func(p []byte, dstmac net.HardwareAddr) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL