Documentation
¶
Overview ¶
Package ndp implements the Neighbor Discovery Protocol, as described in RFC 4861.
Index ¶
- Constants
- func MarshalMessage(m Message) ([]byte, error)
- func MarshalMessageChecksum(m Message, source, destination netip.Addr) ([]byte, error)
- func SolicitedNodeMulticast(ip netip.Addr) (netip.Addr, error)
- type Addr
- type CaptivePortal
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) JoinGroup(group netip.Addr) error
- func (c *Conn) LeaveGroup(group netip.Addr) error
- func (c *Conn) ReadFrom() (Message, *ipv6.ControlMessage, netip.Addr, error)
- func (c *Conn) ReadRaw(b []byte) (int, *ipv6.ControlMessage, netip.Addr, error)
- func (c *Conn) SetControlMessage(cf ipv6.ControlFlags, on bool) error
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetICMPFilter(f *ipv6.ICMPFilter) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) WriteTo(m Message, cm *ipv6.ControlMessage, dst netip.Addr) error
- type DNSSearchList
- type Direction
- type LinkLayerAddress
- type MTU
- type Message
- type NeighborAdvertisement
- type NeighborSolicitation
- type Nonce
- type Option
- type PREF64
- type Preference
- type PrefixInformation
- type RAFlags
- type RAFlagsExtension
- type RawOption
- type RecursiveDNSServer
- type RouteInformation
- type RouterAdvertisement
- type RouterSolicitation
Constants ¶
const HopLimit = 255
HopLimit is the expected IPv6 hop limit for all NDP messages.
const Infinity = time.Duration(0xffffffff) * time.Second
Infinity indicates that a prefix is valid for an infinite amount of time, unless a new, finite, value is received in a subsequent router advertisement.
const Unrestricted = "urn:ietf:params:capport:unrestricted"
Unrestricted is the IANA-assigned URI for a network with no captive portal restrictions, as specified in RFC 8910, Section 2.
Variables ¶
This section is empty.
Functions ¶
func MarshalMessage ¶
MarshalMessage marshals a Message into its binary form and prepends an ICMPv6 message with the correct type.
It is assumed that the operating system or caller will calculate and place the ICMPv6 checksum in the result.
func MarshalMessageChecksum ¶
MarshalMessageChecksum marshals a Message into its binary form and prepends an ICMPv6 message with the correct type.
The source and destination IP addresses are used to compute an IPv6 pseudo header for checksum calculation.
Types ¶
type CaptivePortal ¶
type CaptivePortal struct {
URI string
}
A CaptivePortal is a Captive-Portal option, as described in RFC 8910, Section 2.3.
func NewCaptivePortal ¶
func NewCaptivePortal(uri string) (*CaptivePortal, error)
NewCaptivePortal produces a CaptivePortal Option for the input URI string. As a special case, if uri is empty, Unrestricted is used as the CaptivePortal OptionURI.
If uri is an IP address literal, an error is returned. Per RFC 8910, uri "SHOULD NOT" be an IP address, but there are circumstances where this behavior may be useful. In that case, the caller can bypass NewCaptivePortal and construct a CaptivePortal Option directly.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
A Conn is a Neighbor Discovery Protocol connection.
func Listen ¶
Listen creates a NDP connection using the specified interface and address type.
As a special case, literal IPv6 addresses may be specified to bind to a specific address for an interface. If the IPv6 address does not exist on the interface, an error will be returned.
Listen returns a Conn and the chosen IPv6 address of the interface.
func (*Conn) JoinGroup ¶
JoinGroup joins the specified multicast group. If group contains an IPv6 zone, it is overwritten by the zone of the network interface which backs Conn.
func (*Conn) LeaveGroup ¶
LeaveGroup leaves the specified multicast group. If group contains an IPv6 zone, it is overwritten by the zone of the network interface which backs Conn.
func (*Conn) ReadFrom ¶
ReadFrom reads a Message from the Conn and returns its control message and source network address. Messages sourced from this machine and malformed or unrecognized ICMPv6 messages are filtered.
If more control and/or a more efficient low-level API are required, see ReadRaw.
func (*Conn) ReadRaw ¶
ReadRaw reads ICMPv6 message bytes into b from the Conn and returns the number of bytes read, the control message, and the source network address.
Most callers should use ReadFrom instead, which parses bytes into Messages and also handles malformed and unrecognized ICMPv6 messages.
func (*Conn) SetControlMessage ¶
func (c *Conn) SetControlMessage(cf ipv6.ControlFlags, on bool) error
SetControlMessage enables the reception of *ipv6.ControlMessages based on the specified flags.
func (*Conn) SetDeadline ¶
SetDeadline sets the read and write deadlines for Conn. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.
func (*Conn) SetICMPFilter ¶
func (c *Conn) SetICMPFilter(f *ipv6.ICMPFilter) error
SetICMPFilter applies the specified ICMP filter. This option can be used to ensure a Conn only accepts certain kinds of NDP messages.
func (*Conn) SetReadDeadline ¶
SetReadDeadline sets a deadline for the next NDP message to arrive.
func (*Conn) SetWriteDeadline ¶
SetWriteDeadline sets a deadline for the next NDP message to be written.
type DNSSearchList ¶
A DNSSearchList is a DNS search list option, as described in RFC 8106, Section 5.2.
type Direction ¶
type Direction int
A Direction specifies the direction of a LinkLayerAddress Option as a source or target.
type LinkLayerAddress ¶
type LinkLayerAddress struct { Direction Direction Addr net.HardwareAddr }
A LinkLayerAddress is a Source or Target Link-Layer Address option, as described in RFC 4861, Section 4.6.1.
type MTU ¶
type MTU struct {
MTU uint32
}
An MTU is an MTU option, as described in RFC 4861, Section 4.6.1.
type Message ¶
type Message interface { // Type specifies the ICMPv6 type for a Message. Type() ipv6.ICMPType // contains filtered or unexported methods }
A Message is a Neighbor Discovery Protocol message.
func ParseMessage ¶
ParseMessage parses a Message from its binary form after determining its type from a leading ICMPv6 message.
type NeighborAdvertisement ¶
type NeighborAdvertisement struct { Router bool Solicited bool Override bool TargetAddress netip.Addr Options []Option }
A NeighborAdvertisement is a Neighbor Advertisement message as described in RFC 4861, Section 4.4.
func (*NeighborAdvertisement) Type ¶
func (na *NeighborAdvertisement) Type() ipv6.ICMPType
Type implements Message.
type NeighborSolicitation ¶
A NeighborSolicitation is a Neighbor Solicitation message as described in RFC 4861, Section 4.3.
func (*NeighborSolicitation) Type ¶
func (ns *NeighborSolicitation) Type() ipv6.ICMPType
Type implements Message.
type Nonce ¶ added in v0.10.0
type Nonce struct {
// contains filtered or unexported fields
}
A Nonce is a Nonce option, as described in RFC 3971, Section 5.3.2.
func NewNonce ¶ added in v0.10.0
func NewNonce() *Nonce
NewNonce creates a Nonce option with an opaque random value.
type Option ¶
type Option interface { // Code specifies the NDP option code for an Option. Code() uint8 // contains filtered or unexported methods }
An Option is a Neighbor Discovery Protocol option.
type PREF64 ¶ added in v1.1.0
PREF64 is a PREF64 option, as described in RFC 8781, Section 4. The prefix must have a prefix length of 96, 64, 56, 40, or 32. The lifetime is used to indicate to clients how long the PREF64 prefix is valid for. A lifetime of 0 indicates the prefix is no longer valid. If unsure, refer to RFC 8781 Section 4.1 for how to calculate an appropriate lifetime.
type Preference ¶
type Preference int
A Preference is a NDP router selection or route preference value as described in RFC 4191, Section 2.1.
const ( Medium Preference = 0 High Preference = 1 Low Preference = 3 )
Possible Preference values.
func (Preference) String ¶
func (i Preference) String() string
type PrefixInformation ¶
type PrefixInformation struct { PrefixLength uint8 OnLink bool AutonomousAddressConfiguration bool ValidLifetime time.Duration PreferredLifetime time.Duration Prefix netip.Addr }
A PrefixInformation is a a Prefix Information option, as described in RFC 4861, Section 4.6.1.
type RAFlags ¶ added in v1.1.0
type RAFlags []byte
RAFlags is a bitmask of Router Advertisement flags contained within an RAFlagsExtension.
type RAFlagsExtension ¶ added in v1.1.0
type RAFlagsExtension struct {
Flags RAFlags
}
A RAFlagsExtension is a Router Advertisement Flags Extension (or Expansion) option, as described in RFC 5175, Section 4.
func (*RAFlagsExtension) Code ¶ added in v1.1.0
func (*RAFlagsExtension) Code() byte
Code implements Option.
type RawOption ¶
A RawOption is an Option in its raw and unprocessed format. Options which are not recognized by this package can be represented using a RawOption.
type RecursiveDNSServer ¶
A RecursiveDNSServer is a Recursive DNS Server option, as described in RFC 8106, Section 5.1.
type RouteInformation ¶
type RouteInformation struct { PrefixLength uint8 Preference Preference RouteLifetime time.Duration Prefix netip.Addr }
A RouteInformation is a Route Information option, as described in RFC 4191, Section 2.3.
type RouterAdvertisement ¶
type RouterAdvertisement struct { CurrentHopLimit uint8 ManagedConfiguration bool OtherConfiguration bool MobileIPv6HomeAgent bool RouterSelectionPreference Preference NeighborDiscoveryProxy bool RouterLifetime time.Duration ReachableTime time.Duration RetransmitTimer time.Duration Options []Option }
A RouterAdvertisement is a Router Advertisement message as described in RFC 4861, Section 4.1.
func (*RouterAdvertisement) Type ¶
func (ra *RouterAdvertisement) Type() ipv6.ICMPType
Type implements Message.
type RouterSolicitation ¶
type RouterSolicitation struct {
Options []Option
}
A RouterSolicitation is a Router Solicitation message as described in RFC 4861, Section 4.1.
func (*RouterSolicitation) Type ¶
func (rs *RouterSolicitation) Type() ipv6.ICMPType
Type implements Message.
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
ndp
Command ndp is a utility for working with the Neighbor Discovery Protocol.
|
Command ndp is a utility for working with the Neighbor Discovery Protocol. |
internal
|
|
ndpcmd
Package ndpcmd provides the commands for the ndp utility.
|
Package ndpcmd provides the commands for the ndp utility. |
ndptest
Package ndptest provides test functions and types for package ndp.
|
Package ndptest provides test functions and types for package ndp. |