ndp

package module
v0.0.0-...-4794346 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2017 License: MIT Imports: 7 Imported by: 1

README

NDP - Go library for ICMPv6 Neighbor discovery

goreportcard

Documentation

http://godoc.org/github.com/skoef/ndp

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Checksum

func Checksum(body *[]byte, srcIP, dstIP net.IP) error

Checksum calculates and sets checksum to a given body of bytes based on source and destination IP

Types

type ICMP

type ICMP interface {
	String() string
	Marshal() ([]byte, error)
	Type() ipv6.ICMPType
}

ICMP implements an interface to base various ICMPv6 packets on

func ParseMessage

func ParseMessage(b []byte) (ICMP, error)

ParseMessage returns ICMP and its ICMPOptions for given bytes or error if it couldn't parse it

type ICMPNeighborAdvertisement

type ICMPNeighborAdvertisement struct {
	Router        bool
	Solicited     bool
	Override      bool
	TargetAddress net.IP
	// contains filtered or unexported fields
}

ICMPNeighborAdvertisement implements the Neighbor Advertisement message as described at https://tools.ietf.org/html/rfc4861#section-4.4

func (*ICMPNeighborAdvertisement) AddOption

func (oc *ICMPNeighborAdvertisement) AddOption(o ICMPOption)

AddOption adds given ICMPOption to options of ICMP

func (ICMPNeighborAdvertisement) GetOption

func (oc ICMPNeighborAdvertisement) GetOption(t ICMPOptionType) (*ICMPOption, error)

GetOption returns ICMPOption of type ICMPOptionType or error if ICMP has no such option

func (ICMPNeighborAdvertisement) HasOption

func (oc ICMPNeighborAdvertisement) HasOption(t ICMPOptionType) bool

HasOption returns true if ICMP contains option of type ICMPOptionType

func (ICMPNeighborAdvertisement) Marshal

func (p ICMPNeighborAdvertisement) Marshal() ([]byte, error)

Marshal returns byte slice representing this ICMPNeighborAdvertisement

func (ICMPNeighborAdvertisement) String

func (p ICMPNeighborAdvertisement) String() string

func (ICMPNeighborAdvertisement) Type

Type returns ipv6.ICMPTypeNeighborAdvertisement

type ICMPNeighborSolicitation

type ICMPNeighborSolicitation struct {
	TargetAddress net.IP
	// contains filtered or unexported fields
}

ICMPNeighborSolicitation implements the Neighbor Solicitation message as described at https://tools.ietf.org/html/rfc4861#section-4.3

func (*ICMPNeighborSolicitation) AddOption

func (oc *ICMPNeighborSolicitation) AddOption(o ICMPOption)

AddOption adds given ICMPOption to options of ICMP

func (ICMPNeighborSolicitation) GetOption

func (oc ICMPNeighborSolicitation) GetOption(t ICMPOptionType) (*ICMPOption, error)

GetOption returns ICMPOption of type ICMPOptionType or error if ICMP has no such option

func (ICMPNeighborSolicitation) HasOption

func (oc ICMPNeighborSolicitation) HasOption(t ICMPOptionType) bool

HasOption returns true if ICMP contains option of type ICMPOptionType

func (ICMPNeighborSolicitation) Marshal

func (p ICMPNeighborSolicitation) Marshal() ([]byte, error)

Marshal returns byte slice representing this ICMPNeighborSolicitation

func (ICMPNeighborSolicitation) String

func (p ICMPNeighborSolicitation) String() string

func (ICMPNeighborSolicitation) Type

Type returns ipv6.ICMPTypeNeighborSolicitation

type ICMPOption

type ICMPOption interface {
	String() string
	Len() uint8
	Marshal() ([]byte, error)
	Type() ICMPOptionType
}

ICMPOption implements an interface to base various ICMPv6 options on

type ICMPOptionDNSSearchList

type ICMPOptionDNSSearchList struct {
	Lifetime    uint32
	DomainNames []string
}

ICMPOptionDNSSearchList implements the DNS Search List option as described at https://tools.ietf.org/html/rfc6106#section-5.2

func (ICMPOptionDNSSearchList) Len

Len returns the length in bytes of ICMPOptionDNSSearchList

func (ICMPOptionDNSSearchList) Marshal

func (o ICMPOptionDNSSearchList) Marshal() ([]byte, error)

Marshal returns byte slice representing this ICMPOptionDNSSearchList

func (ICMPOptionDNSSearchList) String

func (o ICMPOptionDNSSearchList) String() string

String implements the String method of ICMPOption interface.

func (ICMPOptionDNSSearchList) Type

Type returns ICMPOptionTypeDNSSearchList

type ICMPOptionMTU

type ICMPOptionMTU struct {
	MTU uint32
}

ICMPOptionMTU implements the MTU option as described at https://tools.ietf.org/html/rfc4861#section-4.6.4

func (ICMPOptionMTU) Len

func (o ICMPOptionMTU) Len() uint8

Len returns the length in bytes of ICMPOptionMTU

func (*ICMPOptionMTU) Marshal

func (o *ICMPOptionMTU) Marshal() ([]byte, error)

Marshal returns byte slice representing this ICMPOptionMTU

func (ICMPOptionMTU) String

func (o ICMPOptionMTU) String() string

String implements the String method of ICMPOption interface.

func (ICMPOptionMTU) Type

func (o ICMPOptionMTU) Type() ICMPOptionType

Type returns ICMPOptionTypeMTU

type ICMPOptionNonce

type ICMPOptionNonce struct {
	Nonce uint64
}

ICMPOptionNonce implements the Nonce option as described at https://tools.ietf.org/html/rfc3971#section-5.3.2

func (ICMPOptionNonce) Len

func (o ICMPOptionNonce) Len() uint8

Len returns the length in bytes of ICMPOptionNonce

func (ICMPOptionNonce) Marshal

func (o ICMPOptionNonce) Marshal() ([]byte, error)

Marshal returns byte slice representing this ICMPOptionNonce

func (ICMPOptionNonce) String

func (o ICMPOptionNonce) String() string

String implements the String method of ICMPOption interface.

func (ICMPOptionNonce) Type

Type returns ICMPOptionTypeNonce

type ICMPOptionPrefixInformation

type ICMPOptionPrefixInformation struct {
	PrefixLength      uint8
	OnLink            bool
	Auto              bool
	ValidLifetime     uint32
	PreferredLifetime uint32
	Prefix            net.IP
}

ICMPOptionPrefixInformation implements the Prefix Information option as described at https://tools.ietf.org/html/rfc4861#section-4.6.2

func (ICMPOptionPrefixInformation) Len

Len returns the length in bytes of ICMPOptionPrefixInformation

func (ICMPOptionPrefixInformation) Marshal

func (o ICMPOptionPrefixInformation) Marshal() ([]byte, error)

Marshal returns byte slice representing this ICMPOptionPrefixInformation

func (ICMPOptionPrefixInformation) String

String implements the String method of ICMPOption interface.

func (ICMPOptionPrefixInformation) Type

Type returns ICMPOptionTypePrefixInformation

type ICMPOptionRecursiveDNSServer

type ICMPOptionRecursiveDNSServer struct {
	Lifetime uint32
	Servers  []net.IP
}

ICMPOptionRecursiveDNSServer implements the Recursive DNS Server option as described at https://tools.ietf.org/html/rfc6106#section-5.1

func (ICMPOptionRecursiveDNSServer) Len

Len returns the length in bytes of ICMPOptionRecursiveDNSServer

func (ICMPOptionRecursiveDNSServer) Marshal

func (o ICMPOptionRecursiveDNSServer) Marshal() ([]byte, error)

Marshal returns byte slice representing this ICMPOptionRecursiveDNSServer

func (ICMPOptionRecursiveDNSServer) String

String implements the String method of ICMPOption interface.

func (ICMPOptionRecursiveDNSServer) Type

Type returns ICMPOptionTypeRecursiveDNSServer

type ICMPOptionSourceLinkLayerAddress

type ICMPOptionSourceLinkLayerAddress struct {
	LinkLayerAddress net.HardwareAddr
}

ICMPOptionSourceLinkLayerAddress implements the Source Linklayer Address option as described at https://tools.ietf.org/html/rfc4861#section-4.6.1

func (ICMPOptionSourceLinkLayerAddress) Len

Len returns the length in bytes of ICMPOptionSourceLinkLayerAddress

func (ICMPOptionSourceLinkLayerAddress) Marshal

func (o ICMPOptionSourceLinkLayerAddress) Marshal() ([]byte, error)

Marshal returns byte slice representing this ICMPOptionSourceLinkLayerAddress

func (ICMPOptionSourceLinkLayerAddress) String

func (ICMPOptionSourceLinkLayerAddress) Type

Type returns ICMPOptionTypeSourceLinkLayerAddress

type ICMPOptionTargetLinkLayerAddress

type ICMPOptionTargetLinkLayerAddress struct {
	LinkLayerAddress net.HardwareAddr
}

ICMPOptionTargetLinkLayerAddress implements the Target Linklayer Address option as described at https://tools.ietf.org/html/rfc4861#section-4.6.1

func (ICMPOptionTargetLinkLayerAddress) Len

Len returns the length in bytes of ICMPOptionTargetLinkLayerAddress

func (ICMPOptionTargetLinkLayerAddress) Marshal

func (o ICMPOptionTargetLinkLayerAddress) Marshal() ([]byte, error)

Marshal returns byte slice representing this ICMPOptionTargetLinkLayerAddress

func (ICMPOptionTargetLinkLayerAddress) String

func (ICMPOptionTargetLinkLayerAddress) Type

Type returns ICMPOptionTypeTargetLinkLayerAddress

type ICMPOptionType

type ICMPOptionType int

ICMPOptionType describes ICMPv6 types

const (
	ICMPOptionTypeUnknown ICMPOptionType = iota
	// RFC4861
	ICMPOptionTypeSourceLinkLayerAddress
	ICMPOptionTypeTargetLinkLayerAddress
	ICMPOptionTypePrefixInformation

	ICMPOptionTypeMTU
	// RFC3971
	ICMPOptionTypeNonce ICMPOptionType = 14
	// RFC6106
	ICMPOptionTypeRecursiveDNSServer ICMPOptionType = 25
	ICMPOptionTypeDNSSearchList      ICMPOptionType = 31
)

ICMPv6 Neighbor discovery types as described in RFC4861, RFC3971, RFC6106

func (ICMPOptionType) String

func (t ICMPOptionType) String() string

type ICMPOptionUnknown

type ICMPOptionUnknown struct {
	// contains filtered or unexported fields
}

ICMPOptionUnknown implements generic type for handling unknown options

func (ICMPOptionUnknown) Len

func (o ICMPOptionUnknown) Len() uint8

Len returns known length for this option

func (ICMPOptionUnknown) Marshal

func (o ICMPOptionUnknown) Marshal() ([]byte, error)

Marshal returns byte slice representing this ICMPOptionUnknown

func (ICMPOptionUnknown) String

func (o ICMPOptionUnknown) String() string

func (ICMPOptionUnknown) Type

Type returns apparent type of this option

type ICMPOptions

type ICMPOptions []ICMPOption

ICMPOptions is a type wrapper for a slice of ICMPOptions

func (ICMPOptions) Marshal

func (opts ICMPOptions) Marshal() ([]byte, error)

Marshal is a helper function of ICMPOptions and returns marshalled results for all ICMPOptions or error when there is one

type ICMPRouterAdvertisement

type ICMPRouterAdvertisement struct {
	HopLimit         uint8
	ManagedAddress   bool
	OtherStateful    bool
	HomeAgent        bool
	RouterPreference RouterPreferenceField
	RouterLifeTime   uint16
	ReachableTime    uint32
	RetransTimer     uint32
	// contains filtered or unexported fields
}

ICMPRouterAdvertisement implements the Router Advertisement message as described at https://tools.ietf.org/html/rfc4861#section-4.2

func (*ICMPRouterAdvertisement) AddOption

func (oc *ICMPRouterAdvertisement) AddOption(o ICMPOption)

AddOption adds given ICMPOption to options of ICMP

func (ICMPRouterAdvertisement) GetOption

func (oc ICMPRouterAdvertisement) GetOption(t ICMPOptionType) (*ICMPOption, error)

GetOption returns ICMPOption of type ICMPOptionType or error if ICMP has no such option

func (ICMPRouterAdvertisement) HasOption

func (oc ICMPRouterAdvertisement) HasOption(t ICMPOptionType) bool

HasOption returns true if ICMP contains option of type ICMPOptionType

func (ICMPRouterAdvertisement) Marshal

func (p ICMPRouterAdvertisement) Marshal() ([]byte, error)

Marshal returns byte slice representing this ICMPRouterAdvertisement

func (ICMPRouterAdvertisement) String

func (p ICMPRouterAdvertisement) String() string

func (ICMPRouterAdvertisement) Type

Type returns ipv6.ICMPTypeRouterAdvertisement

type ICMPRouterSolicitation

type ICMPRouterSolicitation struct {
	// contains filtered or unexported fields
}

ICMPRouterSolicitation implements the Router Solicitation message as described at https://tools.ietf.org/html/rfc4861#section-4.1

func (*ICMPRouterSolicitation) AddOption

func (oc *ICMPRouterSolicitation) AddOption(o ICMPOption)

AddOption adds given ICMPOption to options of ICMP

func (ICMPRouterSolicitation) GetOption

func (oc ICMPRouterSolicitation) GetOption(t ICMPOptionType) (*ICMPOption, error)

GetOption returns ICMPOption of type ICMPOptionType or error if ICMP has no such option

func (ICMPRouterSolicitation) HasOption

func (oc ICMPRouterSolicitation) HasOption(t ICMPOptionType) bool

HasOption returns true if ICMP contains option of type ICMPOptionType

func (ICMPRouterSolicitation) Marshal

func (p ICMPRouterSolicitation) Marshal() ([]byte, error)

Marshal returns byte slice representing this ICMPRouterSolicitation

func (ICMPRouterSolicitation) String

func (p ICMPRouterSolicitation) String() string

func (ICMPRouterSolicitation) Type

Type returns ipv6.ICMPTypeRouterSolicitation

type RouterPreferenceField

type RouterPreferenceField int

RouterPreferenceField implements the Router Preference Values as described at https://tools.ietf.org/html/rfc4191#section-2.1

const (
	RouterPreferenceMedium RouterPreferenceField = iota
	RouterPreferenceHigh

	RouterPreferenceLow
)

types currently defined

func (RouterPreferenceField) String

func (typ RouterPreferenceField) String() string

Jump to

Keyboard shortcuts

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