dhcpv6

package module
v0.0.0-...-79aba89 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: MIT Imports: 8 Imported by: 0

README

DHCPv6 - Go library for DHCPv6

Documentation

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArchitectureType

type ArchitectureType uint16
const (
	ArchitectureTypeIntelx86PC ArchitectureType = iota
	ArchitectureTypeNECPC98
	ArchitectureTypeEFIItanium
	ArchitectureTypeDECAlpha
	ArchitectureTypeArcx86
	ArchitectureTypeIntelLeanClient
	ArchitectureTypeEFIIA32
	ArchitectureTypeEFIBC
	ArchitectureTypeEFIXscale
	ArchitectureTypeEFIx8664
)

Architecture types as described at https://tools.ietf.org/html/rfc4578#section-2.1

func (ArchitectureType) String

func (s ArchitectureType) String() string

type DUID

type DUID interface {
	String() string
	Len() uint16
	Type() DUIDType
	Marshal() ([]byte, error)
}

DUID acts as an interface of other DUIDs

func DecodeDUID

func DecodeDUID(data []byte) (DUID, error)

DecodeDUID tries to decode given byte slice to one of the defined DUIDTypes

type DUIDEN

type DUIDEN struct {
	EnterpriseNumber uint32
	ID               []byte
}

DUIDEN - as described in https://tools.ietf.org/html/rfc3315#section-9.3 NOTE: currently not implemented

type DUIDLL

type DUIDLL struct {
	HardwareType     uint16
	LinkLayerAddress net.HardwareAddr
}

DUIDLL - as described in https://tools.ietf.org/html/rfc3315#section-9.4

func (DUIDLL) Len

func (d DUIDLL) Len() uint16

Len returns length in bytes for entire DUIDLL

func (DUIDLL) Marshal

func (d DUIDLL) Marshal() ([]byte, error)

Marshal returns byte slice representing this DUIDLL

func (DUIDLL) String

func (d DUIDLL) String() string

func (DUIDLL) Type

func (d DUIDLL) Type() DUIDType

Type returns DUIDTypeLL

type DUIDLLT

type DUIDLLT struct {
	HardwareType     uint16
	Time             time.Time
	LinkLayerAddress net.HardwareAddr
}

DUIDLLT - as described in https://tools.ietf.org/html/rfc3315#section-9.2

func (DUIDLLT) Len

func (d DUIDLLT) Len() uint16

Len returns length in bytes for entire DUIDLLT

func (DUIDLLT) Marshal

func (d DUIDLLT) Marshal() ([]byte, error)

Marshal returns byte slice representing this DUIDLLT

func (DUIDLLT) String

func (d DUIDLLT) String() string

func (DUIDLLT) Type

func (d DUIDLLT) Type() DUIDType

Type returns DUIDTypeLLT

type DUIDType

type DUIDType uint8

DUIDType represents the type of DUID

const (

	// RFC3315
	DUIDTypeLLT DUIDType
	DUIDTypeEN
	DUIDTypeLL
	// RFC6355
	DUIDTypeUUID
)

DUID types as described in https://tools.ietf.org/html/rfc3315#section-9.1 and https://tools.ietf.org/html/rfc6355#section-4

func (DUIDType) String

func (d DUIDType) String() string

type DUIDUUID

type DUIDUUID struct {
	UUID uuid.UUID
}

DUIDUUID as described in https://tools.ietf.org/html/rfc6355#section-4

func (DUIDUUID) Len

func (d DUIDUUID) Len() uint16

Len returns length in bytes for the entire DUIDUUID

func (DUIDUUID) Marshal

func (d DUIDUUID) Marshal() ([]byte, error)

Marshal returns byte slice representing this DUIDLL

func (DUIDUUID) String

func (d DUIDUUID) String() string

func (DUIDUUID) Type

func (d DUIDUUID) Type() DUIDType

Type returns DUIDTypeUUID

type InterfaceType

type InterfaceType uint8
const (
	InterfaceTypeUNDI InterfaceType
)

Interface types as described at https://tools.ietf.org/html/rfc4578#section-2.2

func (InterfaceType) String

func (s InterfaceType) String() string

type Message

type Message struct {
	MessageType MessageType
	Xid         uint32
	Options     Options
}

Message represents a DHCPv6 message

func DecodeMessage

func DecodeMessage(data []byte) (*Message, error)

DecodeMessage takes DHCPv6 message bytes and tries to decode the message and optionally its options and returns decoded Message or error if any occurs

func (*Message) AddOption

func (m *Message) AddOption(o Option)

AddOption adds given Option to slice of Options of Message

func (Message) HasOption

func (m Message) HasOption(t OptionType) Option

HasOption returns Option if this Message has OptionType t as option or nil otherwise

func (Message) Marshal

func (m Message) Marshal() ([]byte, error)

Marshal returns byte slice representing this Message or error

type MessageType

type MessageType uint8

MessageType describes DHCPv6 message types

const (
	MessageTypeSolicit MessageType
	MessageTypeAdvertise
	MessageTypeRequest
	MessageTypeConfirm
	MessageTypeRenew
	MessageTypeRebind
	MessageTypeReply
	MessageTypeRelease
	MessageTypeDecline
	MessageTypeReconfigure
	MessageTypeInformationRequest
	MessageTypeRelayForward
	MessageTypeRelayReply
)

add constants for all DHCPv6 message types from RFC3315

func (MessageType) String

func (t MessageType) String() string

type Option

type Option interface {
	String() string
	Len() uint16
	Type() OptionType
	Marshal() ([]byte, error)
}

Option -- interface to build various DHCPv6 options on

type OptionBootFileParameters

type OptionBootFileParameters struct {
	Parameters []string
}

OptionBootFileParameters implements the Boot File URL option described in https://tools.ietf.org/html/rfc5970#section-3.2

func (OptionBootFileParameters) Len

Len returns the length in bytes of OptionBootFileParameters's body

func (OptionBootFileParameters) Marshal

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

Marshal returns byte slice representing this OptionBootFileParameters

func (OptionBootFileParameters) String

func (o OptionBootFileParameters) String() string

func (OptionBootFileParameters) Type

Type returns OptionTypeBootFileParameters

type OptionBootFileURL

type OptionBootFileURL struct {
	URL string
}

OptionBootFileURL implements the Boot File URL option described in https://tools.ietf.org/html/rfc5970#section-3.1

func (OptionBootFileURL) Len

func (o OptionBootFileURL) Len() uint16

Len returns the length in bytes of OptionBootFileURL's body

func (OptionBootFileURL) Marshal

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

Marshal returns byte slice representing this OptionBootFileURL

func (OptionBootFileURL) String

func (o OptionBootFileURL) String() string

func (OptionBootFileURL) Type

func (o OptionBootFileURL) Type() OptionType

Type returns OptionTypeBootFileURL

type OptionClientID

type OptionClientID struct {
	DUID DUID
}

OptionClientID implements the Client Identifier option as described at https://tools.ietf.org/html/rfc3315#section-22.2

func (OptionClientID) Len

func (o OptionClientID) Len() uint16

Len returns the length in bytes of OptionClientID's body

func (OptionClientID) Marshal

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

Marshal returns byte slice representing this OptionClientID

func (OptionClientID) String

func (o OptionClientID) String() string

func (OptionClientID) Type

func (o OptionClientID) Type() OptionType

Type returns OptionTypeClientID

type OptionClientNetworkInterfaceIdentifier

type OptionClientNetworkInterfaceIdentifier struct {
	InterfaceType InterfaceType
	RevisionMajor uint8
	RevisionMinor uint8
}

OptionClientNetworkInterfaceIdentifier implements the Client Network Interface Identifier option as described in https://tools.ietf.org/html/rfc5970#section-3.4

func (OptionClientNetworkInterfaceIdentifier) Len

Len returns the length in bytes of OptionClientNetworkInterfaceIdentifier's body

func (OptionClientNetworkInterfaceIdentifier) Marshal

Marshal returns byte slice representing this OptionTypeClientNetworkInterfaceIdentifier

func (OptionClientNetworkInterfaceIdentifier) String

func (OptionClientNetworkInterfaceIdentifier) Type

Type returns OptionTypeClientNetworkInterfaceIdentifier

type OptionClientSystemArchitectureType

type OptionClientSystemArchitectureType struct {
	Types []ArchitectureType
}

OptionClientSystemArchitectureType implements the Client System Architecture Type option as described in https://tools.ietf.org/html/rfc5970#section-3.3

func (OptionClientSystemArchitectureType) Len

Len returns the length in bytes of OptionClientSystemArchitectureType's body

func (OptionClientSystemArchitectureType) Marshal

Marshal returns byte slice representing this OptionClientSystemArchitectureType

func (OptionClientSystemArchitectureType) String

func (OptionClientSystemArchitectureType) Type

Type returns OptionTypeClientSystemArchitectureType

type OptionDNSServer

type OptionDNSServer struct {
	Servers []net.IP
}

OptionDNSServer implements the DNS Server option described in https://tools.ietf.org/html/rfc3646#section-3

func (OptionDNSServer) Len

func (o OptionDNSServer) Len() uint16

Len returns the length in bytes of OptionDNSServer's body

func (OptionDNSServer) Marshal

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

Marshal returns byte slice representing this OptionDNSServer

func (OptionDNSServer) String

func (o OptionDNSServer) String() string

func (OptionDNSServer) Type

func (o OptionDNSServer) Type() OptionType

Type returns OptionTypeDNSServer

type OptionElapsedTime

type OptionElapsedTime struct {
	ElapsedTime time.Duration
}

OptionElapsedTime implements the Elapsed Time option as described at https://tools.ietf.org/html/rfc3315#section-22.9

func (OptionElapsedTime) Len

func (o OptionElapsedTime) Len() uint16

Len returns the length in bytes of OptionElapsedTime's body

func (OptionElapsedTime) Marshal

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

Marshal returns byte slice representing this OptionElapsedTime

func (OptionElapsedTime) String

func (o OptionElapsedTime) String() string

func (OptionElapsedTime) Type

func (o OptionElapsedTime) Type() OptionType

Type returns OptionTypeElapsedTime

type OptionIAAddress

type OptionIAAddress struct {
	Address           net.IP
	PreferredLifetime time.Duration
	ValidLifetime     time.Duration
	// contains filtered or unexported fields
}

OptionIAAddress implements the IA Address option as described at https://tools.ietf.org/html/rfc3315#section-22.6

func (*OptionIAAddress) AddOption

func (o *OptionIAAddress) AddOption(opt Option)

AddOption adds given Option to slice of Options, even if this type occurs in the list already. To prevent duplicate option types in the list, you will probably want to use SetOption instead

func (OptionIAAddress) HasOption

func (o OptionIAAddress) HasOption(t OptionType) Option

HasOption returns first occurance of option with type t or nil if no options with that type are in Options

func (OptionIAAddress) Len

func (o OptionIAAddress) Len() uint16

Len returns the length in bytes of OptionIAAddress's body

func (OptionIAAddress) Marshal

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

Marshal returns byte slice representing this OptionIAAddress

func (*OptionIAAddress) SetOption

func (o *OptionIAAddress) SetOption(newopt Option)

SetOption sets given Option to slice of Options, replacing first potential duplicate option of the same type

func (OptionIAAddress) String

func (o OptionIAAddress) String() string

func (OptionIAAddress) Type

func (o OptionIAAddress) Type() OptionType

Type returns OptionTypeIAAddress

type OptionIANA

type OptionIANA struct {
	IAID uint32
	T1   time.Duration // delay before Renew
	T2   time.Duration // delay before Rebind
	// contains filtered or unexported fields
}

OptionIANA implements the Identity Association for Non-temporary Addresses option as described at https://tools.ietf.org/html/rfc3315#section-22.4

func (*OptionIANA) AddOption

func (o *OptionIANA) AddOption(opt Option)

AddOption adds given Option to slice of Options, even if this type occurs in the list already. To prevent duplicate option types in the list, you will probably want to use SetOption instead

func (OptionIANA) HasOption

func (o OptionIANA) HasOption(t OptionType) Option

HasOption returns first occurance of option with type t or nil if no options with that type are in Options

func (OptionIANA) Len

func (o OptionIANA) Len() uint16

Len returns the length in bytes of OptionIANA's body

func (*OptionIANA) Marshal

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

Marshal returns byte slice representing this OptionIANA

func (*OptionIANA) SetOption

func (o *OptionIANA) SetOption(newopt Option)

SetOption sets given Option to slice of Options, replacing first potential duplicate option of the same type

func (OptionIANA) String

func (o OptionIANA) String() string

func (OptionIANA) Type

func (o OptionIANA) Type() OptionType

Type returns OptionIANA

type OptionNextHop

type OptionNextHop struct {
	Address net.IP
	// contains filtered or unexported fields
}

OptionNextHop implements the Next Hop option proposed in https://tools.ietf.org/html/draft-ietf-mif-dhcpv6-route-option-05#section-5.1

func (*OptionNextHop) AddOption

func (o *OptionNextHop) AddOption(opt Option)

AddOption adds given Option to slice of Options, even if this type occurs in the list already. To prevent duplicate option types in the list, you will probably want to use SetOption instead

func (OptionNextHop) HasOption

func (o OptionNextHop) HasOption(t OptionType) Option

HasOption returns first occurance of option with type t or nil if no options with that type are in Options

func (OptionNextHop) Len

func (o OptionNextHop) Len() uint16

Len returns the length in bytes of OptionNextHop's body

func (OptionNextHop) Marshal

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

Marshal returns byte slice representing this OptionNextHop

func (*OptionNextHop) SetOption

func (o *OptionNextHop) SetOption(newopt Option)

SetOption sets given Option to slice of Options, replacing first potential duplicate option of the same type

func (OptionNextHop) String

func (o OptionNextHop) String() string

func (OptionNextHop) Type

func (o OptionNextHop) Type() OptionType

Type returns OptionTypeNextHop

type OptionOptionRequest

type OptionOptionRequest struct {
	Options []OptionType
}

OptionOptionRequest implements the Option Request option as described at https://tools.ietf.org/html/rfc3315#section-22.7

func (OptionOptionRequest) HasOption

func (o OptionOptionRequest) HasOption(t OptionType) bool

HasOption returns Option if this IA_NA option has OptionType t as option or nil otherwise

func (OptionOptionRequest) Len

func (o OptionOptionRequest) Len() uint16

Len returns the length in bytes of OptionOptionRequest's body

func (OptionOptionRequest) Marshal

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

Marshal returns byte slice representing this OptionOptionRequest

func (OptionOptionRequest) String

func (o OptionOptionRequest) String() string

func (OptionOptionRequest) Type

Type returns OptionTypeOptionRequest

type OptionRapidCommit

type OptionRapidCommit struct{}

OptionRapidCommit implements the Rapid Commit option as described at https://tools.ietf.org/html/rfc3315#section-22.14 this option acts basically as a flag for the message carrying it and has no further contents

func (OptionRapidCommit) Len

func (o OptionRapidCommit) Len() uint16

Len returns the length in bytes of OptionRapidCommit's body

func (OptionRapidCommit) Marshal

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

Marshal returns byte slice representing this OptionRapidCommit

func (OptionRapidCommit) String

func (o OptionRapidCommit) String() string

func (OptionRapidCommit) Type

func (o OptionRapidCommit) Type() OptionType

Type returns OptionTypeRapidCommit

type OptionRoutePrefix

type OptionRoutePrefix struct {
	RouteLifetime uint32
	PrefixLength  uint8
	Preference    RoutePreference
	Metric        uint8
	Prefix        net.IP
	// contains filtered or unexported fields
}

OptionRoutePrefix implements the Next Hop option proposed in https://tools.ietf.org/html/draft-ietf-mif-dhcpv6-route-option-05#section-5.2

func (*OptionRoutePrefix) AddOption

func (o *OptionRoutePrefix) AddOption(opt Option)

AddOption adds given Option to slice of Options, even if this type occurs in the list already. To prevent duplicate option types in the list, you will probably want to use SetOption instead

func (OptionRoutePrefix) HasOption

func (o OptionRoutePrefix) HasOption(t OptionType) Option

HasOption returns first occurance of option with type t or nil if no options with that type are in Options

func (OptionRoutePrefix) Len

func (o OptionRoutePrefix) Len() uint16

Len returns the length in bytes of OptionNextHop's body

func (OptionRoutePrefix) Marshal

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

Marshal returns byte slice representing this OptionRoutePrefix

func (*OptionRoutePrefix) SetOption

func (o *OptionRoutePrefix) SetOption(newopt Option)

SetOption sets given Option to slice of Options, replacing first potential duplicate option of the same type

func (OptionRoutePrefix) String

func (o OptionRoutePrefix) String() string

func (OptionRoutePrefix) Type

func (o OptionRoutePrefix) Type() OptionType

Type returns OptionTypeNextHop

type OptionServerID

type OptionServerID struct {
	DUID DUID
}

OptionServerID implements the Server Identifier option as described at https://tools.ietf.org/html/rfc3315#section-22.3

func (OptionServerID) Equal

func (o OptionServerID) Equal(opt Option) bool

Equal returns true if given ServerID option is byte-wise identical or false otherwise

func (OptionServerID) Len

func (o OptionServerID) Len() uint16

Len returns the length in bytes of OptionServerID's body

func (OptionServerID) Marshal

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

Marshal returns byte slice representing this OptionServerID

func (OptionServerID) String

func (o OptionServerID) String() string

func (OptionServerID) Type

func (o OptionServerID) Type() OptionType

Type returns OptionTypeServerID

type OptionStatusCode

type OptionStatusCode struct {
	Code    StatusCode
	Message string
}

OptionStatusCode implements the Status Code option as described at https://tools.ietf.org/html/rfc3315#section-22.13

func (OptionStatusCode) Len

func (o OptionStatusCode) Len() uint16

Len returns the length in bytes of OptionStatusCode's body

func (OptionStatusCode) Marshal

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

Marshal returns byte slice representing this OptionStatusCode

func (OptionStatusCode) String

func (o OptionStatusCode) String() string

func (OptionStatusCode) Type

func (o OptionStatusCode) Type() OptionType

Type returns OptionTypeStatusCode

type OptionType

type OptionType uint8

OptionType describes DHCPv6 option types

const (

	// RFC3315
	OptionTypeClientID OptionType
	OptionTypeServerID
	OptionTypeIANA
	OptionTypeIATA
	OptionTypeIAAddress
	OptionTypeOptionRequest
	OptionTypePreference
	OptionTypeElapsedTime
	OptionTypeRelayMessage

	OptionTypeAuthentication
	OptionTypeServerUnicast
	OptionTypeStatusCode
	OptionTypeRapidCommit
	OptionTypeUserClass
	OptionTypeVendorClass
	OptionTypeVendorOption
	OptionTypeInterfaceID
	OptionTypeReconfigureMessage
	OptionTypeReconfigureAccept

	// RFC3646
	OptionTypeDNSServer
	OptionTypeDNSSearchList
	// RFC5970
	OptionTypeBootFileURL                      OptionType = 59
	OptionTypeBootFileParameters               OptionType = 60
	OptionTypeClientSystemArchitectureType     OptionType = 61
	OptionTypeClientNetworkInterfaceIdentifier OptionType = 62
	// draft-ietf-mif-dhcpv6-route-option
	OptionTypeNextHop     OptionType = 242
	OptionTypeRoutePrefix OptionType = 243
)

DHCPv6 option types as described in RFC's 3315, 3646, 5970 and a draft for Route Options

func (OptionType) String

func (t OptionType) String() string

type OptionUserClass

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

OptionUserClass implements the User Class option described in https://tools.ietf.org/html/rfc3315#section-22.15

func (OptionUserClass) Len

func (o OptionUserClass) Len() uint16

Len returns the length in bytes of OptionUserClass's body

func (OptionUserClass) Marshal

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

Marshal returns byte slice representing this OptionUserClass

func (OptionUserClass) String

func (o OptionUserClass) String() string

func (OptionUserClass) Type

func (o OptionUserClass) Type() OptionType

Type returns OptionTypeUserClass

type OptionVendorClass

type OptionVendorClass struct {
	EnterpriseNumber uint32
	// contains filtered or unexported fields
}

OptionVendorClass implements the Vendor Class option described in https://tools.ietf.org/html/rfc3315#section-22.16

func (OptionVendorClass) Len

func (o OptionVendorClass) Len() uint16

Len returns the length in bytes of OptionVendorClass's body

func (OptionVendorClass) Marshal

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

Marshal returns byte slice representing this OptionVendorClass

func (OptionVendorClass) String

func (o OptionVendorClass) String() string

func (OptionVendorClass) Type

func (o OptionVendorClass) Type() OptionType

Type returns OptionTypeVendorClass

type Options

type Options []Option

Options is a type wrapper for a slice of Options

func DecodeOptions

func DecodeOptions(data []byte) (Options, error)

DecodeOptions takes DHCPv6 option bytes and tries to decode every handled option, looking at its type and the given length, and returns a slice containing all decoded structs

func (Options) Len

func (o Options) Len() uint16

Len returns combined length in bytes for all Options in slice this includes the option header (containing type and length)

func (Options) Marshal

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

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

type RoutePreference

type RoutePreference uint8
const (
	RoutePreferenceMedium RoutePreference = iota
	RoutePreferenceHigh

	RoutePreferenceLow
)

Route preferences as described at https://tools.ietf.org/html/draft-ietf-mif-dhcpv6-route-option-05#section-5.2

func (RoutePreference) String

func (s RoutePreference) String() string

type StatusCode

type StatusCode uint16
const (
	StatusCodeSuccess StatusCode = iota
	StatusCodeUnspecFail
	StatusCodeNoAddrsAvail
	StatusCodeNoBinding
	StatusCodeNotOnLink
	StatusCodeUseMulticast
)

Status codes as described at https://tools.ietf.org/html/rfc3315#section-24.4

func (StatusCode) String

func (s StatusCode) String() string

Jump to

Keyboard shortcuts

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