dhcpv6

package
v0.0.0-...-b105c29 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: BSD-3-Clause Imports: 11 Imported by: 224

Documentation

Overview

Package dhcpv6 provides encoding and decoding of DHCPv6 messages and options.

Index

Constants

View Source
const (
	DefaultClientPort = 546
	DefaultServerPort = 547
)

Default ports

View Source
const (
	NTPSuboptionSrvAddrCode = OptionCode(1)
	NTPSuboptionMCAddrCode  = OptionCode(2)
	NTPSuboptionSrvFQDNCode = OptionCode(3)
)

NTPSuboptionSrvAddr is the value of NTP_SUBOPTION_SRV_ADDR according to RFC 5908.

View Source
const MessageHeaderSize = 4
View Source
const RelayHeaderSize = 34

Variables

View Source
var (
	AllDHCPRelayAgentsAndServers = net.ParseIP("ff02::1:2")
	AllDHCPServers               = net.ParseIP("ff05::1:3")
)

Default multicast groups

View Source
var InterfaceAddresses func(string) ([]net.Addr, error) = interfaceAddresses

InterfaceAddresses is used to fetch addresses of an interface with given name

Functions

func ExtractMAC

func ExtractMAC(packet DHCPv6) (net.HardwareAddr, error)

ExtractMAC looks into the inner most PeerAddr field in the RelayInfo header which contains the EUI-64 address of the client making the request, populated by the dhcp relay, it is possible to extract the mac address from that IP. If that fails, it looks for the MAC addressed embededded in the DUID. Note that this only works with type DuidLL and DuidLLT. If a mac address cannot be found an error will be returned.

func GetGlobalAddr

func GetGlobalAddr(ifname string) (net.IP, error)

GetGlobalAddr returns a global address for the interface

func GetLinkLocalAddr

func GetLinkLocalAddr(ifname string) (net.IP, error)

GetLinkLocalAddr returns a link-local address for the interface

func GetMacAddressFromEUI64

func GetMacAddressFromEUI64(ip net.IP) (net.HardwareAddr, error)

GetMacAddressFromEUI64 will return a valid MAC address ONLY if it's a EUI-48

func GetTime

func GetTime() uint32

GetTime returns a time integer suitable for DUID-LLT, i.e. the current time counted in seconds since January 1st, 2000, midnight UTC, modulo 2^32

func OptClientLinkLayerAddress

func OptClientLinkLayerAddress(ht iana.HWType, lla net.HardwareAddr) *optClientLinkLayerAddress

OptClientLinkLayerAddress implements OptionClientLinkLayerAddr option. https://tools.ietf.org/html/rfc6939

func OptInformationRefreshTime

func OptInformationRefreshTime(irt time.Duration) *optInformationRefreshTime

OptInformationRefreshTime implements OptionInformationRefreshTime option. https://tools.ietf.org/html/rfc8415#section-21.23

func WithNetboot

func WithNetboot(d DHCPv6)

WithNetboot adds bootfile URL and bootfile param options to a DHCPv6 packet.

func WithRapidCommit

func WithRapidCommit(d DHCPv6)

WithRapidCommit adds the rapid commit option to a message.

Types

type AddressOptions

type AddressOptions struct {
	Options
}

AddressOptions are options valid for the IAAddress option field.

RFC 8415 Appendix C lists only the Status Code option as valid.

func (AddressOptions) Status

func (ao AddressOptions) Status() *OptStatusCode

Status returns the status code associated with this option.

type DHCPv6

type DHCPv6 interface {
	Type() MessageType
	ToBytes() []byte
	String() string
	Summary() string
	LongString(indent int) string
	IsRelay() bool

	// GetInnerMessage returns the innermost encapsulated DHCPv6 message.
	//
	// If it is already a message, it will be returned. If it is a relay
	// message, the encapsulated message will be recursively extracted.
	GetInnerMessage() (*Message, error)

	GetOption(code OptionCode) []Option
	GetOneOption(code OptionCode) Option
	AddOption(Option)
	UpdateOption(Option)
}

func DecapsulateRelay

func DecapsulateRelay(l DHCPv6) (DHCPv6, error)

DecapsulateRelay extracts the content of a relay message. It does not recurse if there are nested relay messages. Returns the original packet if is not not a relay message

func DecapsulateRelayIndex

func DecapsulateRelayIndex(l DHCPv6, index int) (DHCPv6, error)

DecapsulateRelayIndex extracts the content of a relay message. It takes an integer as index (e.g. if 0 return the outermost relay, 1 returns the second, etc, and -1 returns the last). Returns the original packet if it is not not a relay message.

func FromBytes

func FromBytes(data []byte) (DHCPv6, error)

FromBytes reads a DHCPv6 message from a byte stream.

func NewRelayReplFromRelayForw

func NewRelayReplFromRelayForw(relay *RelayMessage, msg *Message) (DHCPv6, error)

NewRelayReplFromRelayForw creates a MessageTypeRelayReply based on a MessageTypeRelayForward and replaces the inner message with the passed DHCPv6 message. It copies the OptionInterfaceID and OptionRemoteID if the options are present in the Relay packet.

type DUID

type DUID interface {
	fmt.Stringer

	ToBytes() []byte
	FromBytes(p []byte) error
	DUIDType() DUIDType
	Equal(d DUID) bool
}

DUID is the interface that all DUIDs adhere to.

func DUIDFromBytes

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

DUIDFromBytes parses a DUID from a byte slice.

type DUIDEN

type DUIDEN struct {
	EnterpriseNumber     uint32
	EnterpriseIdentifier []byte
}

DUIDEN is a DUID based on enterprise number (RFC 8415 Section 11.3).

func (DUIDEN) DUIDType

func (d DUIDEN) DUIDType() DUIDType

DUIDType returns the DUID_EN type.

func (*DUIDEN) Equal

func (d *DUIDEN) Equal(e DUID) bool

Equal returns true if e is a DUID-EN with the same values as d.

func (*DUIDEN) FromBytes

func (d *DUIDEN) FromBytes(p []byte) error

FromBytes reads the option.

func (DUIDEN) String

func (d DUIDEN) String() string

String pretty-prints DUIDEN information.

func (DUIDEN) ToBytes

func (d DUIDEN) ToBytes() []byte

ToBytes serializes the option out to bytes.

type DUIDLL

type DUIDLL struct {
	HWType        iana.HWType
	LinkLayerAddr net.HardwareAddr
}

DUIDLL is a DUID based on link-layer (RFC 8415 Section 11.4).

func (DUIDLL) DUIDType

func (d DUIDLL) DUIDType() DUIDType

DUIDType returns the DUID_LL type.

func (*DUIDLL) Equal

func (d *DUIDLL) Equal(e DUID) bool

Equal returns true if e is a DUID-LL with the same values as d.

func (*DUIDLL) FromBytes

func (d *DUIDLL) FromBytes(p []byte) error

FromBytes reads the option.

func (DUIDLL) String

func (d DUIDLL) String() string

String pretty-prints DUIDLL information.

func (DUIDLL) ToBytes

func (d DUIDLL) ToBytes() []byte

ToBytes serializes the option out to bytes.

type DUIDLLT

type DUIDLLT struct {
	HWType        iana.HWType
	Time          uint32
	LinkLayerAddr net.HardwareAddr
}

DUIDLLT is a DUID based on link-layer address plus time (RFC 8415 Section 11.2).

func (DUIDLLT) DUIDType

func (d DUIDLLT) DUIDType() DUIDType

DUIDType returns the DUID_LLT type.

func (*DUIDLLT) Equal

func (d *DUIDLLT) Equal(e DUID) bool

Equal returns true if e is a DUID-LLT with the same values as d.

func (*DUIDLLT) FromBytes

func (d *DUIDLLT) FromBytes(p []byte) error

FromBytes reads the option.

func (DUIDLLT) String

func (d DUIDLLT) String() string

String pretty-prints DUIDLLT information.

func (DUIDLLT) ToBytes

func (d DUIDLLT) ToBytes() []byte

ToBytes serializes the option out to bytes.

type DUIDOpaque

type DUIDOpaque struct {
	Type DUIDType
	Data []byte
}

DUIDOpaque is a DUID of unknown type.

func (DUIDOpaque) DUIDType

func (d DUIDOpaque) DUIDType() DUIDType

DUIDType returns the opaque DUID type.

func (*DUIDOpaque) Equal

func (d *DUIDOpaque) Equal(e DUID) bool

Equal returns true if e is an opaque DUID with the same values as d.

func (*DUIDOpaque) FromBytes

func (d *DUIDOpaque) FromBytes(p []byte) error

FromBytes reads the option.

func (DUIDOpaque) String

func (d DUIDOpaque) String() string

String pretty-prints opaque DUID information.

func (DUIDOpaque) ToBytes

func (d DUIDOpaque) ToBytes() []byte

ToBytes serializes the option out to bytes.

type DUIDType

type DUIDType uint16

DUIDType is the DUID type as defined in RFC 3315.

const (
	DUID_LLT  DUIDType = 1
	DUID_EN   DUIDType = 2
	DUID_LL   DUIDType = 3
	DUID_UUID DUIDType = 4
)

DUID types

func (DUIDType) String

func (d DUIDType) String() string

type DUIDUUID

type DUIDUUID struct {
	// Defined by RFC 6355.
	UUID [16]byte
}

DUIDUUID is a DUID based on UUID (RFC 8415 Section 11.5).

func (DUIDUUID) DUIDType

func (d DUIDUUID) DUIDType() DUIDType

DUIDType returns the DUID_UUID type.

func (*DUIDUUID) Equal

func (d *DUIDUUID) Equal(e DUID) bool

Equal returns true if e is a DUID-UUID with the same values as d.

func (*DUIDUUID) FromBytes

func (d *DUIDUUID) FromBytes(p []byte) error

FromBytes reads the option.

func (DUIDUUID) String

func (d DUIDUUID) String() string

String pretty-prints DUIDUUID information.

func (DUIDUUID) ToBytes

func (d DUIDUUID) ToBytes() []byte

ToBytes serializes the option out to bytes.

type Duration

type Duration struct {
	time.Duration
}

Duration is a duration as embedded in IA messages (IAPD, IANA, IATA).

func (Duration) Marshal

func (d Duration) Marshal(buf *uio.Lexer)

Marshal encodes the time in uint32 seconds as defined by RFC 3315 for IANA messages.

func (*Duration) Unmarshal

func (d *Duration) Unmarshal(buf *uio.Lexer)

Unmarshal decodes time from uint32 seconds as defined by RFC 3315 for IANA messages.

type FourRDOptions

type FourRDOptions struct {
	Options
}

FourRDOptions are options that can be encapsulated with the 4RD option.

func (FourRDOptions) MapRules

func (frdo FourRDOptions) MapRules() []*Opt4RDMapRule

MapRules returns the map rules associated with the 4RD option.

"The OPTION_4RD DHCPv6 option contains at least one encapsulated
OPTION_4RD_MAP_RULE option." (RFC 7600 Section 4.9)

func (FourRDOptions) NonMapRule

func (frdo FourRDOptions) NonMapRule() *Opt4RDNonMapRule

NonMapRule returns the non-map-rule associated with this option.

"The OPTION_4RD DHCPv6 option contains ... a maximum of one
encapsulated OPTION_4RD_NON_MAP_RULE option." (RFC 7600 Section 4.9)

type IdentityOptions

type IdentityOptions struct {
	Options
}

IdentityOptions implement the options allowed for IA_NA and IA_TA messages.

The allowed options are identified in RFC 3315 Appendix B.

func (IdentityOptions) Addresses

func (io IdentityOptions) Addresses() []*OptIAAddress

Addresses returns the addresses assigned to the identity.

func (IdentityOptions) OneAddress

func (io IdentityOptions) OneAddress() *OptIAAddress

OneAddress returns one address (of potentially many) assigned to the identity.

func (IdentityOptions) Status

func (io IdentityOptions) Status() *OptStatusCode

Status returns the status code associated with this option.

type Message

type Message struct {
	MessageType   MessageType
	TransactionID TransactionID
	Options       MessageOptions
}

Message represents a DHCPv6 Message as defined by RFC 3315 Section 6.

func MessageFromBytes

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

MessageFromBytes parses a DHCPv6 message from a byte stream.

func NewAdvertiseFromSolicit

func NewAdvertiseFromSolicit(sol *Message, modifiers ...Modifier) (*Message, error)

NewAdvertiseFromSolicit creates a new ADVERTISE packet based on an SOLICIT packet.

func NewMessage

func NewMessage(modifiers ...Modifier) (*Message, error)

NewMessage creates a new DHCPv6 message with default options

func NewReplyFromMessage

func NewReplyFromMessage(msg *Message, modifiers ...Modifier) (*Message, error)

NewReplyFromMessage creates a new REPLY packet based on a Message. The function is to be used when generating a reply to a SOLICIT with rapid-commit, REQUEST, CONFIRM, RENEW, REBIND, RELEASE and INFORMATION-REQUEST packets.

func NewRequestFromAdvertise

func NewRequestFromAdvertise(adv *Message, modifiers ...Modifier) (*Message, error)

NewRequestFromAdvertise creates a new REQUEST packet based on an ADVERTISE packet options.

func NewSolicit

func NewSolicit(hwaddr net.HardwareAddr, modifiers ...Modifier) (*Message, error)

NewSolicit creates a new SOLICIT message, using the given hardware address to derive the IAID in the IA_NA option.

func (*Message) AddOption

func (m *Message) AddOption(option Option)

AddOption adds an option to this message.

func (*Message) GetInnerMessage

func (m *Message) GetInnerMessage() (*Message, error)

GetInnerMessage returns the message itself.

func (*Message) GetOneOption

func (m *Message) GetOneOption(code OptionCode) Option

GetOneOption returns the first associated option with the code from this message.

func (*Message) GetOption

func (m *Message) GetOption(code OptionCode) []Option

GetOption returns the options associated with the code.

func (*Message) IsNetboot

func (m *Message) IsNetboot() bool

IsNetboot returns true if the machine is trying to netboot. It checks if "boot file" is one of the requested options, which is useful for SOLICIT/REQUEST packet types, it also checks if the "boot file" option is included in the packet, which is useful for ADVERTISE/REPLY packet.

func (*Message) IsOptionRequested

func (m *Message) IsOptionRequested(requested OptionCode) bool

IsOptionRequested takes an OptionCode and returns true if that option is within the requested options of the DHCPv6 message.

func (*Message) IsRelay

func (m *Message) IsRelay() bool

IsRelay returns whether this is a relay message or not.

func (*Message) LongString

func (m *Message) LongString(spaceIndent int) string

LongString prints all options associated with this message.

func (*Message) String

func (m *Message) String() string

String returns a short human-readable string for this message.

func (*Message) Summary

func (m *Message) Summary() string

Summary prints all options associated with this message.

func (*Message) ToBytes

func (m *Message) ToBytes() []byte

ToBytes returns the serialized version of this message as defined by RFC 3315, Section 5.

func (Message) Type

func (m Message) Type() MessageType

Type returns this message's message type.

func (*Message) UpdateOption

func (m *Message) UpdateOption(option Option)

UpdateOption updates the existing options with the passed option, adding it at the end if not present already

type MessageOptions

type MessageOptions struct {
	Options
}

MessageOptions are the options that may appear in a normal DHCPv6 message.

RFC 3315 Appendix B lists the valid options that can be used.

func (MessageOptions) ArchTypes

func (mo MessageOptions) ArchTypes() iana.Archs

ArchTypes returns the architecture type option.

func (MessageOptions) BootFileParam

func (mo MessageOptions) BootFileParam() []string

BootFileParam returns the Boot File Param option as defined by RFC 5970.

func (MessageOptions) BootFileURL

func (mo MessageOptions) BootFileURL() string

BootFileURL returns the Boot File URL option as defined by RFC 5970.

func (MessageOptions) ClientID

func (mo MessageOptions) ClientID() DUID

ClientID returns the client identifier option.

func (MessageOptions) DHCP4oDHCP6Server

func (mo MessageOptions) DHCP4oDHCP6Server() *OptDHCP4oDHCP6Server

DHCP4oDHCP6Server returns the DHCP 4o6 Server Address option as defined by RFC 7341.

func (MessageOptions) DNS

func (mo MessageOptions) DNS() []net.IP

DNS returns the DNS Recursive Name Server option as defined by RFC 3646.

func (MessageOptions) DomainSearchList

func (mo MessageOptions) DomainSearchList() *rfc1035label.Labels

DomainSearchList returns the Domain List option as defined by RFC 3646.

func (MessageOptions) ElapsedTime

func (mo MessageOptions) ElapsedTime() time.Duration

ElapsedTime returns the Elapsed Time option as defined by RFC 3315 Section 22.9.

ElapsedTime returns a duration of 0 if the option is not present.

func (MessageOptions) FQDN

func (mo MessageOptions) FQDN() *OptFQDN

FQDN returns the FQDN option as defined by RFC 4704.

func (MessageOptions) FourRD

func (mo MessageOptions) FourRD() []*Opt4RD

FourRD returns all 4RD options.

func (MessageOptions) IANA

func (mo MessageOptions) IANA() []*OptIANA

IANA returns all Identity Association for Non-temporary Address options.

func (MessageOptions) IAPD

func (mo MessageOptions) IAPD() []*OptIAPD

IAPD returns all Identity Association for Prefix Delegation options.

func (MessageOptions) IATA

func (mo MessageOptions) IATA() []*OptIATA

IATA returns all Identity Association for Temporary Address options.

func (MessageOptions) InformationRefreshTime

func (mo MessageOptions) InformationRefreshTime(def time.Duration) time.Duration

InformationRefreshTime returns the Information Refresh Time option as defined by RFC 815 Section 21.23.

InformationRefreshTime returns the provided default if no option is present.

func (MessageOptions) NTPServers

func (mo MessageOptions) NTPServers() []net.IP

NTPServers returns the NTP server addresses contained in the NTP_SUBOPTION_SRV_ADDR of an OPTION_NTP_SERVER. If multiple NTP server options exist, the function will return all the NTP server addresses it finds, as defined by RFC 5908.

func (MessageOptions) OneIANA

func (mo MessageOptions) OneIANA() *OptIANA

OneIANA returns the first IANA option.

func (MessageOptions) OneIAPD

func (mo MessageOptions) OneIAPD() *OptIAPD

OneIAPD returns the first IAPD option.

func (MessageOptions) OneIATA

func (mo MessageOptions) OneIATA() *OptIATA

OneIATA returns the first IATA option.

func (MessageOptions) RequestedOptions

func (mo MessageOptions) RequestedOptions() OptionCodes

RequestedOptions returns the Options Requested Option.

func (MessageOptions) ServerID

func (mo MessageOptions) ServerID() DUID

ServerID returns the server identifier option.

func (MessageOptions) Status

func (mo MessageOptions) Status() *OptStatusCode

Status returns the status code associated with this option.

func (MessageOptions) UserClasses

func (mo MessageOptions) UserClasses() [][]byte

UserClasses returns a list of user classes.

func (MessageOptions) VendorClass

func (mo MessageOptions) VendorClass(enterpriseNumber uint32) [][]byte

VendorClass returns the vendor class options matching the given enterprise number.

func (MessageOptions) VendorClasses

func (mo MessageOptions) VendorClasses() []*OptVendorClass

VendorClasses returns the all vendor class options.

func (MessageOptions) VendorOpt

func (mo MessageOptions) VendorOpt(enterpriseNumber uint32) Options

VendorOpt returns the vendor options matching the given enterprise number.

RFC 8415 Section 21.17:

Servers and clients MUST NOT send more than one instance of the
Vendor-specific Information option with the same Enterprise Number.

func (MessageOptions) VendorOpts

func (mo MessageOptions) VendorOpts() []*OptVendorOpts

VendorOpts returns the all vendor-specific options.

RFC 8415 Section 21.17:

Multiple instances of the Vendor-specific Information option may appear in
a DHCP message.

type MessageType

type MessageType uint8

MessageType represents the kind of DHCPv6 message.

const (
	// MessageTypeNone is used internally and is not part of the RFC.
	MessageTypeNone               MessageType = 0
	MessageTypeSolicit            MessageType = 1
	MessageTypeAdvertise          MessageType = 2
	MessageTypeRequest            MessageType = 3
	MessageTypeConfirm            MessageType = 4
	MessageTypeRenew              MessageType = 5
	MessageTypeRebind             MessageType = 6
	MessageTypeReply              MessageType = 7
	MessageTypeRelease            MessageType = 8
	MessageTypeDecline            MessageType = 9
	MessageTypeReconfigure        MessageType = 10
	MessageTypeInformationRequest MessageType = 11
	MessageTypeRelayForward       MessageType = 12
	MessageTypeRelayReply         MessageType = 13
	MessageTypeLeaseQuery         MessageType = 14
	MessageTypeLeaseQueryReply    MessageType = 15
	MessageTypeLeaseQueryDone     MessageType = 16
	MessageTypeLeaseQueryData     MessageType = 17

	MessageTypeDHCPv4Query    MessageType = 20
	MessageTypeDHCPv4Response MessageType = 21
)

The DHCPv6 message types defined per RFC 3315, Section 5.3.

func (MessageType) String

func (m MessageType) String() string

String prints the message type name.

type Modifier

type Modifier func(d DHCPv6)

Modifier defines the signature for functions that can modify DHCPv6 structures. This is used to simplify packet manipulation

func WithArchType

func WithArchType(at iana.Arch) Modifier

WithArchType adds an arch type option to the packet

func WithClientID

func WithClientID(duid DUID) Modifier

WithClientID adds a client ID option to a DHCPv6 packet

func WithClientLinkLayerAddress

func WithClientLinkLayerAddress(ht iana.HWType, lla net.HardwareAddr) Modifier

WithClientLinkLayerAddress adds or updates the ClientLinkLayerAddress option with provided HWType and HWAddress on a DHCPv6 packet

func WithDHCP4oDHCP6Server

func WithDHCP4oDHCP6Server(addrs ...net.IP) Modifier

WithDHCP4oDHCP6Server adds or updates an OptDHCP4oDHCP6Server

func WithDNS

func WithDNS(dnses ...net.IP) Modifier

WithDNS adds or updates an OptDNSRecursiveNameServer

func WithDomainSearchList

func WithDomainSearchList(searchlist ...string) Modifier

WithDomainSearchList adds or updates an OptDomainSearchList

func WithFQDN

func WithFQDN(flags uint8, domainname string) Modifier

WithFQDN adds a fully qualified domain name option to the packet

func WithIAID

func WithIAID(iaid [4]byte) Modifier

WithIAID updates an OptIANA option with the provided IAID

func WithIANA

func WithIANA(addrs ...OptIAAddress) Modifier

WithIANA adds or updates an OptIANA option with the provided IAAddress options

func WithIAPD

func WithIAPD(iaid [4]byte, prefixes ...*OptIAPrefix) Modifier

WithIAPD adds or updates an IAPD option with the provided IAID and prefix options to a DHCPv6 packet.

func WithIATA

func WithIATA(iaid [4]byte, addrs ...OptIAAddress) Modifier

WithIATA adds or updates an OptIATA option with the provided IAID, and IAAddress options

func WithInformationRefreshTime

func WithInformationRefreshTime(irt time.Duration) Modifier

WithInformationRefreshTime adds an optInformationRefreshTime to the DHCPv6 packet using the provided duration

func WithOption

func WithOption(o Option) Modifier

WithOption adds the specific option to the DHCPv6 message.

func WithRequestedOptions

func WithRequestedOptions(codes ...OptionCode) Modifier

WithRequestedOptions adds requested options to the packet

func WithServerID

func WithServerID(duid DUID) Modifier

WithServerID adds a client ID option to a DHCPv6 packet

func WithUserClass

func WithUserClass(uc []byte) Modifier

WithUserClass adds a user class option to the packet

type NTPSuboptionMCAddr

type NTPSuboptionMCAddr net.IP

NTPSuboptionMCAddr is NTP_SUBOPTION_MC_ADDR according to RFC 5908.

func (*NTPSuboptionMCAddr) Code

func (n *NTPSuboptionMCAddr) Code() OptionCode

Code returns the suboption code.

func (*NTPSuboptionMCAddr) FromBytes

func (n *NTPSuboptionMCAddr) FromBytes(p []byte) error

FromBytes parses NTP multicast address from a byte slice p.

func (*NTPSuboptionMCAddr) String

func (n *NTPSuboptionMCAddr) String() string

func (*NTPSuboptionMCAddr) ToBytes

func (n *NTPSuboptionMCAddr) ToBytes() []byte

ToBytes returns the byte serialization of the suboption.

type NTPSuboptionSrvAddr

type NTPSuboptionSrvAddr net.IP

NTPSuboptionSrvAddr is NTP_SUBOPTION_SRV_ADDR according to RFC 5908.

func (*NTPSuboptionSrvAddr) Code

func (n *NTPSuboptionSrvAddr) Code() OptionCode

Code returns the suboption code.

func (*NTPSuboptionSrvAddr) FromBytes

func (n *NTPSuboptionSrvAddr) FromBytes(p []byte) error

FromBytes parses NTP server address from a byte slice p.

func (*NTPSuboptionSrvAddr) String

func (n *NTPSuboptionSrvAddr) String() string

func (*NTPSuboptionSrvAddr) ToBytes

func (n *NTPSuboptionSrvAddr) ToBytes() []byte

ToBytes returns the byte serialization of the suboption.

type NTPSuboptionSrvFQDN

type NTPSuboptionSrvFQDN struct {
	rfc1035label.Labels
}

NTPSuboptionSrvFQDN is NTP_SUBOPTION_SRV_FQDN according to RFC 5908.

func (*NTPSuboptionSrvFQDN) Code

func (n *NTPSuboptionSrvFQDN) Code() OptionCode

Code returns the suboption code.

func (*NTPSuboptionSrvFQDN) FromBytes

func (n *NTPSuboptionSrvFQDN) FromBytes(p []byte) error

FromBytes parses an NTP server FQDN from a byte slice p.

func (*NTPSuboptionSrvFQDN) String

func (n *NTPSuboptionSrvFQDN) String() string

func (*NTPSuboptionSrvFQDN) ToBytes

func (n *NTPSuboptionSrvFQDN) ToBytes() []byte

ToBytes returns the byte serialization of the suboption.

type NetworkInterfaceType

type NetworkInterfaceType uint8

NetworkInterfaceType is the NIC type as defined by RFC 4578 Section 2.2

const (
	NII_LANDESK_NOPXE   NetworkInterfaceType = 0
	NII_PXE_GEN_I       NetworkInterfaceType = 1
	NII_PXE_GEN_II      NetworkInterfaceType = 2
	NII_UNDI_NOEFI      NetworkInterfaceType = 3
	NII_UNDI_EFI_GEN_I  NetworkInterfaceType = 4
	NII_UNDI_EFI_GEN_II NetworkInterfaceType = 5
)

see rfc4578

func (NetworkInterfaceType) String

func (nit NetworkInterfaceType) String() string

type Opt4RD

type Opt4RD struct {
	FourRDOptions
}

Opt4RD represents a 4RD option. It is only a container for 4RD_*_RULE options

func (*Opt4RD) Code

func (op *Opt4RD) Code() OptionCode

Code returns the Option Code for this option

func (*Opt4RD) FromBytes

func (op *Opt4RD) FromBytes(data []byte) error

FromBytes builds an Opt4RD structure from a sequence of bytes. The input data does not include option code and length bytes

func (*Opt4RD) LongString

func (op *Opt4RD) LongString(indentSpace int) string

LongString returns a multi-line human-readable representation of the option

func (*Opt4RD) String

func (op *Opt4RD) String() string

String returns a human-readable representation of the option

func (*Opt4RD) ToBytes

func (op *Opt4RD) ToBytes() []byte

ToBytes serializes this option

type Opt4RDMapRule

type Opt4RDMapRule struct {
	// Prefix4 is the IPv4 prefix mapped by this rule
	Prefix4 net.IPNet

	// Prefix6 is the IPv6 prefix mapped by this rule
	Prefix6 net.IPNet

	// EABitsLength is the number of bits of an address used in constructing the mapped address
	EABitsLength uint8

	// WKPAuthorized determines if well-known ports are assigned to addresses in an A+P mapping
	// It can only be set if the length of Prefix4 + EABits > 32
	WKPAuthorized bool
}

Opt4RDMapRule represents a 4RD Mapping Rule option.

The option is described in RFC 7600 Section 4.9. The 4RD mapping rules are described in RFC 7600 Section 4.2.

func (*Opt4RDMapRule) Code

func (op *Opt4RDMapRule) Code() OptionCode

Code returns the option code representing this option

func (*Opt4RDMapRule) FromBytes

func (op *Opt4RDMapRule) FromBytes(data []byte) error

FromBytes builds an Opt4RDMapRule structure from a sequence of bytes. The input data does not include option code and length bytes.

func (*Opt4RDMapRule) String

func (op *Opt4RDMapRule) String() string

String returns a human-readable description of this option

func (*Opt4RDMapRule) ToBytes

func (op *Opt4RDMapRule) ToBytes() []byte

ToBytes serializes this option

type Opt4RDNonMapRule

type Opt4RDNonMapRule struct {
	// HubAndSpoke is whether the network topology is hub-and-spoke or meshed
	HubAndSpoke bool

	// TrafficClass is an optional 8-bit tunnel traffic class identifier
	TrafficClass *uint8

	// DomainPMTU is the Path MTU for this 4RD domain
	DomainPMTU uint16
}

Opt4RDNonMapRule represents 4RD parameters other than mapping rules

func (*Opt4RDNonMapRule) Code

func (op *Opt4RDNonMapRule) Code() OptionCode

Code returns the option code for this option

func (*Opt4RDNonMapRule) FromBytes

func (op *Opt4RDNonMapRule) FromBytes(data []byte) error

FromBytes builds an Opt4RDNonMapRule structure from a sequence of bytes. The input data does not include option code and length bytes

func (*Opt4RDNonMapRule) String

func (op *Opt4RDNonMapRule) String() string

String returns a human-readable description of this option

func (*Opt4RDNonMapRule) ToBytes

func (op *Opt4RDNonMapRule) ToBytes() []byte

ToBytes serializes this option

type OptDHCP4oDHCP6Server

type OptDHCP4oDHCP6Server struct {
	DHCP4oDHCP6Servers []net.IP
}

OptDHCP4oDHCP6Server represents a OptionDHCP4oDHCP6Server option

This module defines the OptDHCP4oDHCP6Server structure. https://www.ietf.org/rfc/rfc7341.txt

func (*OptDHCP4oDHCP6Server) Code

func (op *OptDHCP4oDHCP6Server) Code() OptionCode

Code returns the option code

func (*OptDHCP4oDHCP6Server) FromBytes

func (op *OptDHCP4oDHCP6Server) FromBytes(data []byte) error

FromBytes builds an OptDHCP4oDHCP6Server structure from a sequence of bytes. The input data does not include option code and length bytes.

func (*OptDHCP4oDHCP6Server) String

func (op *OptDHCP4oDHCP6Server) String() string

func (*OptDHCP4oDHCP6Server) ToBytes

func (op *OptDHCP4oDHCP6Server) ToBytes() []byte

ToBytes returns the option serialized to bytes.

type OptDHCPv4Msg

type OptDHCPv4Msg struct {
	Msg *dhcpv4.DHCPv4
}

OptDHCPv4Msg represents a OptionDHCPv4Msg option

This module defines the OptDHCPv4Msg structure. https://www.ietf.org/rfc/rfc7341.txt

func (*OptDHCPv4Msg) Code

func (op *OptDHCPv4Msg) Code() OptionCode

Code returns the option code

func (*OptDHCPv4Msg) FromBytes

func (op *OptDHCPv4Msg) FromBytes(data []byte) error

FromBytes builds an OptDHCPv4Msg structure from a sequence of bytes. The input data does not include option code and length bytes.

func (*OptDHCPv4Msg) LongString

func (op *OptDHCPv4Msg) LongString(indent int) string

LongString returns a multi-line string representation of DHCPv4 data.

func (*OptDHCPv4Msg) String

func (op *OptDHCPv4Msg) String() string

func (*OptDHCPv4Msg) ToBytes

func (op *OptDHCPv4Msg) ToBytes() []byte

ToBytes returns the option serialized to bytes.

type OptFQDN

type OptFQDN struct {
	Flags      uint8
	DomainName *rfc1035label.Labels
}

OptFQDN implements OptionFQDN option.

https://tools.ietf.org/html/rfc4704

func (*OptFQDN) Code

func (op *OptFQDN) Code() OptionCode

Code returns the option code.

func (*OptFQDN) FromBytes

func (op *OptFQDN) FromBytes(data []byte) error

FromBytes deserializes from bytes to build a OptFQDN structure.

func (*OptFQDN) String

func (op *OptFQDN) String() string

func (*OptFQDN) ToBytes

func (op *OptFQDN) ToBytes() []byte

ToBytes serializes the option and returns it as a sequence of bytes

type OptIAAddress

type OptIAAddress struct {
	IPv6Addr          net.IP
	PreferredLifetime time.Duration
	ValidLifetime     time.Duration
	Options           AddressOptions
}

OptIAAddress represents an OptionIAAddr.

This module defines the OptIAAddress structure. https://www.ietf.org/rfc/rfc3633.txt

func (*OptIAAddress) Code

func (op *OptIAAddress) Code() OptionCode

Code returns the option's code

func (*OptIAAddress) FromBytes

func (op *OptIAAddress) FromBytes(data []byte) error

FromBytes builds an OptIAAddress structure from a sequence of bytes. The input data does not include option code and length bytes.

func (*OptIAAddress) LongString

func (op *OptIAAddress) LongString(indent int) string

LongString returns a multi-line string representation of the OptIAAddress data.

func (*OptIAAddress) String

func (op *OptIAAddress) String() string

func (*OptIAAddress) ToBytes

func (op *OptIAAddress) ToBytes() []byte

ToBytes serializes the option and returns it as a sequence of bytes

type OptIANA

type OptIANA struct {
	IaId    [4]byte
	T1      time.Duration
	T2      time.Duration
	Options IdentityOptions
}

OptIANA implements the identity association for non-temporary addresses option.

This module defines the OptIANA structure. https://www.ietf.org/rfc/rfc3633.txt

func (*OptIANA) Code

func (op *OptIANA) Code() OptionCode

func (*OptIANA) FromBytes

func (op *OptIANA) FromBytes(data []byte) error

FromBytes builds an OptIANA structure from a sequence of bytes. The input data does not include option code and length bytes.

func (*OptIANA) LongString

func (op *OptIANA) LongString(indentSpace int) string

LongString returns a multi-line string representation of IANA data.

func (*OptIANA) String

func (op *OptIANA) String() string

func (*OptIANA) ToBytes

func (op *OptIANA) ToBytes() []byte

ToBytes serializes IANA to DHCPv6 bytes.

type OptIAPD

type OptIAPD struct {
	IaId    [4]byte
	T1      time.Duration
	T2      time.Duration
	Options PDOptions
}

OptIAPD implements the identity association for prefix delegation option defined by RFC 3633, Section 9.

func (*OptIAPD) Code

func (op *OptIAPD) Code() OptionCode

Code returns the option code

func (*OptIAPD) FromBytes

func (op *OptIAPD) FromBytes(data []byte) error

FromBytes builds an OptIAPD structure from a sequence of bytes. The input data does not include option code and length bytes.

func (*OptIAPD) LongString

func (op *OptIAPD) LongString(indentSpace int) string

LongString returns a multi-line string representation of the OptIAPD data

func (*OptIAPD) String

func (op *OptIAPD) String() string

String returns a string representation of the OptIAPD data

func (*OptIAPD) ToBytes

func (op *OptIAPD) ToBytes() []byte

ToBytes serializes the option and returns it as a sequence of bytes

type OptIAPrefix

type OptIAPrefix struct {
	PreferredLifetime time.Duration
	ValidLifetime     time.Duration
	Prefix            *net.IPNet
	Options           PrefixOptions
}

OptIAPrefix implements the IAPrefix option.

This module defines the OptIAPrefix structure. https://www.ietf.org/rfc/rfc3633.txt

func (*OptIAPrefix) Code

func (op *OptIAPrefix) Code() OptionCode

func (*OptIAPrefix) FromBytes

func (op *OptIAPrefix) FromBytes(data []byte) error

FromBytes an OptIAPrefix structure from a sequence of bytes. The input data does not include option code and length bytes.

func (*OptIAPrefix) String

func (op *OptIAPrefix) String() string

func (*OptIAPrefix) ToBytes

func (op *OptIAPrefix) ToBytes() []byte

ToBytes marshals this option according to RFC 3633, Section 10.

type OptIATA

type OptIATA struct {
	IaId    [4]byte
	Options IdentityOptions
}

OptIATA implements the identity association for non-temporary addresses option.

This module defines the OptIATA structure, as defined by RFC 8415 Section 21.5.

func (*OptIATA) Code

func (op *OptIATA) Code() OptionCode

Code returns the option code for an IA_TA

func (*OptIATA) FromBytes

func (op *OptIATA) FromBytes(data []byte) error

FromBytes builds an OptIATA structure from a sequence of bytes. The input data does not include option code and length bytes.

func (*OptIATA) LongString

func (op *OptIATA) LongString(indentSpace int) string

LongString returns a multi-line string representation of IATA data.

func (*OptIATA) String

func (op *OptIATA) String() string

func (*OptIATA) ToBytes

func (op *OptIATA) ToBytes() []byte

ToBytes serializes IATA to DHCPv6 bytes.

type OptNTPServer

type OptNTPServer struct {
	Suboptions Options
}

OptNTPServer is an option NTP server as defined by RFC 5908.

func (*OptNTPServer) Code

func (op *OptNTPServer) Code() OptionCode

Code returns the option code

func (*OptNTPServer) FromBytes

func (op *OptNTPServer) FromBytes(data []byte) error

FromBytes parses a sequence of bytes into an OptNTPServer object.

func (*OptNTPServer) String

func (op *OptNTPServer) String() string

func (*OptNTPServer) ToBytes

func (op *OptNTPServer) ToBytes() []byte

ToBytes returns the option serialized to bytes.

type OptNetworkInterfaceID

type OptNetworkInterfaceID struct {
	Typ NetworkInterfaceType

	// Revision number
	Major, Minor uint8
}

OptNetworkInterfaceID implements the NIC ID option for network booting as defined by RFC 4578 Section 2.2 and RFC 5970 Section 3.4.

func (*OptNetworkInterfaceID) Code

Code implements Option.Code.

func (*OptNetworkInterfaceID) FromBytes

func (op *OptNetworkInterfaceID) FromBytes(data []byte) error

FromBytes builds an OptNetworkInterfaceID structure from a sequence of bytes. The input data does not include option code and length bytes.

func (*OptNetworkInterfaceID) String

func (op *OptNetworkInterfaceID) String() string

func (*OptNetworkInterfaceID) ToBytes

func (op *OptNetworkInterfaceID) ToBytes() []byte

ToBytes implements Option.ToBytes.

type OptRemoteID

type OptRemoteID struct {
	EnterpriseNumber uint32
	RemoteID         []byte
}

OptRemoteID implemens the Remote ID option as defined by RFC 4649.

func (*OptRemoteID) Code

func (*OptRemoteID) Code() OptionCode

Code implements Option.Code.

func (*OptRemoteID) FromBytes

func (op *OptRemoteID) FromBytes(data []byte) error

FromBytes builds an OptRemoteID structure from a sequence of bytes. The input data does not include option code and length bytes.

func (*OptRemoteID) String

func (op *OptRemoteID) String() string

func (*OptRemoteID) ToBytes

func (op *OptRemoteID) ToBytes() []byte

ToBytes serializes this option to a byte stream.

type OptStatusCode

type OptStatusCode struct {
	StatusCode    iana.StatusCode
	StatusMessage string
}

OptStatusCode represents a DHCPv6 Status Code option

This module defines the OptStatusCode structure. https://www.ietf.org/rfc/rfc3315.txt

func (*OptStatusCode) Code

func (op *OptStatusCode) Code() OptionCode

Code returns the option code.

func (*OptStatusCode) FromBytes

func (op *OptStatusCode) FromBytes(data []byte) error

FromBytes builds an OptStatusCode structure from a sequence of bytes. The input data does not include option code and length bytes.

func (*OptStatusCode) String

func (op *OptStatusCode) String() string

String returns a human-readable option.

func (*OptStatusCode) ToBytes

func (op *OptStatusCode) ToBytes() []byte

ToBytes serializes the option and returns it as a sequence of bytes.

type OptUserClass

type OptUserClass struct {
	UserClasses [][]byte
}

OptUserClass represent a DHCPv6 User Class option

This module defines the OptUserClass structure. https://www.ietf.org/rfc/rfc3315.txt

func (*OptUserClass) Code

func (op *OptUserClass) Code() OptionCode

Code returns the option code

func (*OptUserClass) FromBytes

func (op *OptUserClass) FromBytes(data []byte) error

FromBytes builds an OptUserClass structure from a sequence of bytes. The input data does not include option code and length bytes.

func (*OptUserClass) String

func (op *OptUserClass) String() string

func (*OptUserClass) ToBytes

func (op *OptUserClass) ToBytes() []byte

ToBytes serializes the option and returns it as a sequence of bytes

type OptVendorClass

type OptVendorClass struct {
	EnterpriseNumber uint32
	Data             [][]byte
}

OptVendorClass represents a DHCPv6 Vendor Class option

func (*OptVendorClass) Code

func (op *OptVendorClass) Code() OptionCode

Code returns the option code

func (*OptVendorClass) FromBytes

func (op *OptVendorClass) FromBytes(data []byte) error

FromBytes builds an OptVendorClass structure from a sequence of bytes. The input data does not include option code and length bytes.

func (*OptVendorClass) String

func (op *OptVendorClass) String() string

String returns a string representation of the VendorClass data

func (*OptVendorClass) ToBytes

func (op *OptVendorClass) ToBytes() []byte

ToBytes serializes the option and returns it as a sequence of bytes

type OptVendorOpts

type OptVendorOpts struct {
	EnterpriseNumber uint32
	VendorOpts       Options
}

OptVendorOpts represents a DHCPv6 Status Code option

This module defines the OptVendorOpts structure. https://tools.ietf.org/html/rfc3315#section-22.17

func (*OptVendorOpts) Code

func (op *OptVendorOpts) Code() OptionCode

Code returns the option code

func (*OptVendorOpts) FromBytes

func (op *OptVendorOpts) FromBytes(data []byte) error

FromBytes builds an OptVendorOpts structure from a sequence of bytes. The input data does not include option code and length bytes.

func (*OptVendorOpts) LongString

func (op *OptVendorOpts) LongString(indent int) string

LongString returns a string representation of the VendorOpts data

func (*OptVendorOpts) String

func (op *OptVendorOpts) String() string

String returns a string representation of the VendorOpts data

func (*OptVendorOpts) ToBytes

func (op *OptVendorOpts) ToBytes() []byte

ToBytes serializes the option and returns it as a sequence of bytes

type Option

type Option interface {
	Code() OptionCode
	ToBytes() []byte
	String() string
	FromBytes([]byte) error
}

Option is an interface that all DHCPv6 options adhere to.

func OptBootFileParam

func OptBootFileParam(args ...string) Option

OptBootFileParam returns a BootfileParam option as defined in RFC 5970 Section 3.2.

func OptBootFileURL

func OptBootFileURL(url string) Option

OptBootFileURL returns a OptionBootfileURL as defined by RFC 5970.

func OptClientArchType

func OptClientArchType(a ...iana.Arch) Option

OptClientArchType represents an option CLIENT_ARCH_TYPE.

This module defines the OptClientArchType structure. https://www.ietf.org/rfc/rfc5970.txt

func OptClientID

func OptClientID(d DUID) Option

OptClientID represents a Client Identifier option as defined by RFC 3315 Section 22.2.

func OptDNS

func OptDNS(ip ...net.IP) Option

OptDNS returns a DNS Recursive Name Server option as defined by RFC 3646.

func OptDomainSearchList

func OptDomainSearchList(labels *rfc1035label.Labels) Option

OptDomainSearchList returns a DomainSearchList option as defined by RFC 3646.

func OptElapsedTime

func OptElapsedTime(dur time.Duration) Option

OptElapsedTime returns an Elapsed Time option as defined by RFC 3315 Section 22.9.

func OptInterfaceID

func OptInterfaceID(id []byte) Option

OptInterfaceID returns an interface id option as defined by RFC 3315, Section 22.18.

func OptRelayMessage

func OptRelayMessage(msg DHCPv6) Option

OptRelayMessage embeds a message in a relay option.

func OptRelayPort

func OptRelayPort(port uint16) Option

OptRelayPort specifies an UDP port to use for the downstream relay

func OptRequestedOption

func OptRequestedOption(o ...OptionCode) Option

OptRequestedOption implements the requested options option as defined by RFC 3315 Section 22.7.

func OptServerID

func OptServerID(d DUID) Option

OptServerID represents a Server Identifier option as defined by RFC 3315 Section 22.1.

func ParseOption

func ParseOption(code OptionCode, optData []byte) (Option, error)

ParseOption parses data according to the given code.

Parse a sequence of bytes as a single DHCPv6 option. Returns the option structure, or an error if any.

type OptionCode

type OptionCode uint16

OptionCode is a single byte representing the code for a given Option.

const (
	OptionClientID    OptionCode = 1
	OptionServerID    OptionCode = 2
	OptionIANA        OptionCode = 3
	OptionIATA        OptionCode = 4
	OptionIAAddr      OptionCode = 5
	OptionORO         OptionCode = 6
	OptionPreference  OptionCode = 7
	OptionElapsedTime OptionCode = 8
	OptionRelayMsg    OptionCode = 9

	OptionAuth                           OptionCode = 11
	OptionUnicast                        OptionCode = 12
	OptionStatusCode                     OptionCode = 13
	OptionRapidCommit                    OptionCode = 14
	OptionUserClass                      OptionCode = 15
	OptionVendorClass                    OptionCode = 16
	OptionVendorOpts                     OptionCode = 17
	OptionInterfaceID                    OptionCode = 18
	OptionReconfMessage                  OptionCode = 19
	OptionReconfAccept                   OptionCode = 20
	OptionSIPServersDomainNameList       OptionCode = 21
	OptionSIPServersIPv6AddressList      OptionCode = 22
	OptionDNSRecursiveNameServer         OptionCode = 23
	OptionDomainSearchList               OptionCode = 24
	OptionIAPD                           OptionCode = 25
	OptionIAPrefix                       OptionCode = 26
	OptionNISServers                     OptionCode = 27
	OptionNISPServers                    OptionCode = 28
	OptionNISDomainName                  OptionCode = 29
	OptionNISPDomainName                 OptionCode = 30
	OptionSNTPServerList                 OptionCode = 31
	OptionInformationRefreshTime         OptionCode = 32
	OptionBCMCSControllerDomainNameList  OptionCode = 33
	OptionBCMCSControllerIPv6AddressList OptionCode = 34

	OptionGeoConfCivic                            OptionCode = 36
	OptionRemoteID                                OptionCode = 37
	OptionRelayAgentSubscriberID                  OptionCode = 38
	OptionFQDN                                    OptionCode = 39
	OptionPANAAuthenticationAgent                 OptionCode = 40
	OptionNewPOSIXTimezone                        OptionCode = 41
	OptionNewTZDBTimezone                         OptionCode = 42
	OptionEchoRequest                             OptionCode = 43
	OptionLQQuery                                 OptionCode = 44
	OptionClientData                              OptionCode = 45
	OptionCLTTime                                 OptionCode = 46
	OptionLQRelayData                             OptionCode = 47
	OptionLQClientLink                            OptionCode = 48
	OptionMIPv6HomeNetworkIDFQDN                  OptionCode = 49
	OptionMIPv6VisitedHomeNetworkInformation      OptionCode = 50
	OptionLoSTServer                              OptionCode = 51
	OptionCAPWAPAccessControllerAddresses         OptionCode = 52
	OptionRelayID                                 OptionCode = 53
	OptionIPv6AddressMOS                          OptionCode = 54
	OptionIPv6FQDNMOS                             OptionCode = 55
	OptionNTPServer                               OptionCode = 56
	OptionV6AccessDomain                          OptionCode = 57
	OptionSIPUACSList                             OptionCode = 58
	OptionBootfileURL                             OptionCode = 59
	OptionBootfileParam                           OptionCode = 60
	OptionClientArchType                          OptionCode = 61
	OptionNII                                     OptionCode = 62
	OptionGeolocation                             OptionCode = 63
	OptionAFTRName                                OptionCode = 64
	OptionERPLocalDomainName                      OptionCode = 65
	OptionRSOO                                    OptionCode = 66
	OptionPDExclude                               OptionCode = 67
	OptionVirtualSubnetSelection                  OptionCode = 68
	OptionMIPv6IdentifiedHomeNetworkInformation   OptionCode = 69
	OptionMIPv6UnrestrictedHomeNetworkInformation OptionCode = 70
	OptionMIPv6HomeNetworkPrefix                  OptionCode = 71
	OptionMIPv6HomeAgentAddress                   OptionCode = 72
	OptionMIPv6HomeAgentFQDN                      OptionCode = 73
	OptionRDNSSSelection                          OptionCode = 74
	OptionKRBPrincipalName                        OptionCode = 75
	OptionKRBRealmName                            OptionCode = 76
	OptionKRBDefaultRealmName                     OptionCode = 77
	OptionKRBKDC                                  OptionCode = 78
	OptionClientLinkLayerAddr                     OptionCode = 79
	OptionLinkAddress                             OptionCode = 80
	OptionRadius                                  OptionCode = 81
	OptionSolMaxRT                                OptionCode = 82
	OptionInfMaxRT                                OptionCode = 83
	OptionAddrSel                                 OptionCode = 84
	OptionAddrSelTable                            OptionCode = 85
	OptionV6PCPServer                             OptionCode = 86
	OptionDHCPv4Msg                               OptionCode = 87
	OptionDHCP4oDHCP6Server                       OptionCode = 88
	OptionS46Rule                                 OptionCode = 89
	OptionS46BR                                   OptionCode = 90
	OptionS46DMR                                  OptionCode = 91
	OptionS46V4V6Bind                             OptionCode = 92
	OptionS46PortParams                           OptionCode = 93
	OptionS46ContMapE                             OptionCode = 94
	OptionS46ContMapT                             OptionCode = 95
	OptionS46ContLW                               OptionCode = 96
	Option4RD                                     OptionCode = 97
	Option4RDMapRule                              OptionCode = 98
	Option4RDNonMapRule                           OptionCode = 99
	OptionLQBaseTime                              OptionCode = 100
	OptionLQStartTime                             OptionCode = 101
	OptionLQEndTime                               OptionCode = 102
	OptionCaptivePortal                           OptionCode = 103
	OptionMPLParameters                           OptionCode = 104
	OptionANIAccessTechType                       OptionCode = 105
	OptionANINetworkName                          OptionCode = 106
	OptionANIAccessPointName                      OptionCode = 107
	OptionANIAccessPointBSSID                     OptionCode = 108
	OptionANIOperatorID                           OptionCode = 109
	OptionANIOperatorRealm                        OptionCode = 110
	OptionS46Priority                             OptionCode = 111
	OptionMUDUrlV6                                OptionCode = 112
	OptionV6Prefix64                              OptionCode = 113
	OptionFailoverBindingStatus                   OptionCode = 114
	OptionFailoverConnectFlags                    OptionCode = 115
	OptionFailoverDNSRemovalInfo                  OptionCode = 116
	OptionFailoverDNSHostName                     OptionCode = 117
	OptionFailoverDNSZoneName                     OptionCode = 118
	OptionFailoverDNSFlags                        OptionCode = 119
	OptionFailoverExpirationTime                  OptionCode = 120
	OptionFailoverMaxUnackedBNDUPD                OptionCode = 121
	OptionFailoverMCLT                            OptionCode = 122
	OptionFailoverPartnerLifetime                 OptionCode = 123
	OptionFailoverPartnerLifetimeSent             OptionCode = 124
	OptionFailoverPartnerDownTime                 OptionCode = 125
	OptionFailoverPartnerRawCLTTime               OptionCode = 126
	OptionFailoverProtocolVersion                 OptionCode = 127
	OptionFailoverKeepaliveTime                   OptionCode = 128
	OptionFailoverReconfigureData                 OptionCode = 129
	OptionFailoverRelationshipName                OptionCode = 130
	OptionFailoverServerFlags                     OptionCode = 131
	OptionFailoverServerState                     OptionCode = 132
	OptionFailoverStartTimeOfState                OptionCode = 133
	OptionFailoverStateExpirationTime             OptionCode = 134
	OptionRelayPort                               OptionCode = 135
	OptionV6SZTPRedirect                          OptionCode = 136
	OptionS46BindIPv6Prefix                       OptionCode = 137

	OptionIPv6AddressANDSF OptionCode = 143
)

All DHCPv6 options.

func (OptionCode) String

func (o OptionCode) String() string

String returns the option code name.

type OptionCodes

type OptionCodes []OptionCode

OptionCodes are a collection of option codes.

func (*OptionCodes) Add

func (o *OptionCodes) Add(c OptionCode)

Add adds an option to the list, ignoring duplicates.

func (OptionCodes) Contains

func (o OptionCodes) Contains(c OptionCode) bool

Contains returns whether the option codes contain c.

func (*OptionCodes) FromBytes

func (o *OptionCodes) FromBytes(data []byte) error

FromBytes populates o from binary-encoded data.

func (OptionCodes) String

func (o OptionCodes) String() string

func (OptionCodes) ToBytes

func (o OptionCodes) ToBytes() []byte

ToBytes implements Option.ToBytes.

type OptionGeneric

type OptionGeneric struct {
	OptionCode OptionCode
	OptionData []byte
}

func (*OptionGeneric) Code

func (og *OptionGeneric) Code() OptionCode

func (*OptionGeneric) FromBytes

func (og *OptionGeneric) FromBytes(p []byte) error

FromBytes resets OptionData to p.

func (*OptionGeneric) String

func (og *OptionGeneric) String() string

func (*OptionGeneric) ToBytes

func (og *OptionGeneric) ToBytes() []byte

type OptionParser

type OptionParser func(code OptionCode, data []byte) (Option, error)

OptionParser is a function signature for option parsing

type Options

type Options []Option

Options is a collection of options.

func (*Options) Add

func (o *Options) Add(option Option)

Add appends one option.

func (*Options) Del

func (o *Options) Del(code OptionCode)

Del deletes all options matching the option code.

func (*Options) FromBytes

func (o *Options) FromBytes(data []byte) error

FromBytes reads data into o and returns an error if the options are not a valid serialized representation of DHCPv6 options per RFC 3315.

func (*Options) FromBytesWithParser

func (o *Options) FromBytesWithParser(data []byte, parser OptionParser) error

FromBytesWithParser parses Options from byte sequences using the parsing function that is passed in as a paremeter

func (Options) Get

func (o Options) Get(code OptionCode) []Option

Get returns all options matching the option code.

func (Options) GetOne

func (o Options) GetOne(code OptionCode) Option

GetOne returns the first option matching the option code.

func (Options) LongString

func (o Options) LongString(spaceIndent int) string

LongString prints options with indentation of at least spaceIndent spaces.

func (Options) ToBytes

func (o Options) ToBytes() []byte

ToBytes marshals all options to bytes.

func (*Options) Update

func (o *Options) Update(option Option)

Update replaces the first option of the same type as the specified one.

type PDOptions

type PDOptions struct {
	Options
}

PDOptions are options used with the IAPD (prefix delegation) option.

RFC 3633 describes that IA_PD-options may contain the IAPrefix option and the StatusCode option.

func (PDOptions) Prefixes

func (po PDOptions) Prefixes() []*OptIAPrefix

Prefixes are the prefixes associated with this delegation.

func (PDOptions) Status

func (po PDOptions) Status() *OptStatusCode

Status returns the status code associated with this option.

type PrefixOptions

type PrefixOptions struct {
	Options
}

PrefixOptions are the options valid for use with IAPrefix option field.

RFC 3633 states that it's just the StatusCode option.

RFC 8415 Appendix C does not list the Status Code option as valid, but it does say that the previous text in RFC 8415 Section 21.22 supersedes that table. Section 21.22 does mention the Status Code option.

func (PrefixOptions) Status

func (po PrefixOptions) Status() *OptStatusCode

Status returns the status code associated with this option.

type RelayMessage

type RelayMessage struct {
	MessageType MessageType
	HopCount    uint8
	LinkAddr    net.IP
	PeerAddr    net.IP
	Options     RelayOptions
}

RelayMessage is a DHCPv6 relay agent message as defined by RFC 3315 Section 7.

func EncapsulateRelay

func EncapsulateRelay(d DHCPv6, mType MessageType, linkAddr, peerAddr net.IP) (*RelayMessage, error)

EncapsulateRelay creates a RelayMessage message containing the passed DHCPv6 message as payload. The passed message type must be either RELAY_FORW or RELAY_REPL

func RelayMessageFromBytes

func RelayMessageFromBytes(data []byte) (*RelayMessage, error)

RelayMessageFromBytes parses a relay message from a byte stream.

func (*RelayMessage) AddOption

func (r *RelayMessage) AddOption(option Option)

AddOption adds an option to this message.

func (*RelayMessage) GetInnerMessage

func (r *RelayMessage) GetInnerMessage() (*Message, error)

GetInnerMessage recurses into a relay message and extract and return the inner Message. Return nil if none found (e.g. not a relay message).

func (*RelayMessage) GetOneOption

func (r *RelayMessage) GetOneOption(code OptionCode) Option

GetOneOption returns the first associated option with the code from this message.

func (*RelayMessage) GetOption

func (r *RelayMessage) GetOption(code OptionCode) []Option

GetOption returns the options associated with the code.

func (*RelayMessage) IsRelay

func (r *RelayMessage) IsRelay() bool

IsRelay returns whether this is a relay message or not.

func (*RelayMessage) LongString

func (r *RelayMessage) LongString(spaceIndent int) string

LongString prints all options associated with this message.

func (*RelayMessage) String

func (r *RelayMessage) String() string

String prints a short human-readable relay message.

func (*RelayMessage) Summary

func (r *RelayMessage) Summary() string

Summary prints all options associated with this relay message.

func (*RelayMessage) ToBytes

func (r *RelayMessage) ToBytes() []byte

ToBytes returns the serialized version of this relay message as defined by RFC 3315, Section 7.

func (*RelayMessage) Type

func (r *RelayMessage) Type() MessageType

Type is this relay message's types.

func (*RelayMessage) UpdateOption

func (r *RelayMessage) UpdateOption(option Option)

UpdateOption replaces the first option of the same type as the specified one.

type RelayOptions

type RelayOptions struct {
	Options
}

RelayOptions are the options valid for RelayForw and RelayRepl messages.

RFC 3315 Appendix B defines them to be InterfaceID and RelayMsg options; RFC 4649 also adds the RemoteID option.

func (RelayOptions) ClientLinkLayerAddress

func (ro RelayOptions) ClientLinkLayerAddress() (iana.HWType, net.HardwareAddr)

ClientLinkLayerAddress returns the Hardware Type and Link Layer Address of the requesting client in this relay message.

func (RelayOptions) InterfaceID

func (ro RelayOptions) InterfaceID() []byte

InterfaceID returns the interface ID of this relay message.

func (RelayOptions) RelayMessage

func (ro RelayOptions) RelayMessage() DHCPv6

RelayMessage returns the message embedded.

func (RelayOptions) RemoteID

func (ro RelayOptions) RemoteID() *OptRemoteID

RemoteID returns the remote ID in this relay message.

type TransactionID

type TransactionID [3]byte

TransactionID is a DHCPv6 Transaction ID defined by RFC 3315, Section 6.

func GenerateTransactionID

func GenerateTransactionID() (TransactionID, error)

GenerateTransactionID generates a random 3-byte transaction ID.

func GetTransactionID

func GetTransactionID(packet DHCPv6) (TransactionID, error)

GetTransactionID returns a transactionID of a message or its inner message in case of relay

func (TransactionID) String

func (xid TransactionID) String() string

String prints the transaction ID as a hex value.

Directories

Path Synopsis
Package nclient6 is a minimum-functionality client for DHCPv6.
Package nclient6 is a minimum-functionality client for DHCPv6.
Package server6 is a basic, extensible DHCPv6 server.
Package server6 is a basic, extensible DHCPv6 server.

Jump to

Keyboard shortcuts

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