dhcpv6

package
v0.0.0-...-cedea85 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultClientPort = 546
	DefaultServerPort = 547
)
View Source
const (
	NII_LANDESK_NOPXE   = 0
	NII_PXE_GEN_I       = 1
	NII_PXE_GEN_II      = 2
	NII_UNDI_NOEFI      = 3
	NII_UNDI_EFI_GEN_I  = 4
	NII_UNDI_EFI_GEN_II = 5
)

see rfc4578

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

Variables

View Source
var DuidTypeToString = map[DuidType]string{
	DUID_LL:   "DUID-LL",
	DUID_LLT:  "DUID-LLT",
	DUID_EN:   "DUID-EN",
	DUID_UUID: "DUID-UUID",
}

DuidTypeToString maps a DuidType to a name.

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 IsUsingUEFI

func IsUsingUEFI(msg DHCPv6) bool

IsUsingUEFI function takes a DHCPv6 message and returns true if the machine trying to netboot is using UEFI of false if it is not.

Types

type DHCPv6

type DHCPv6 interface {
	Type() MessageType
	ToBytes() []byte
	Options() []Option
	String() string
	Summary() string
	IsRelay() bool
	GetOption(code OptionCode) []Option
	GetOneOption(code OptionCode) Option
	SetOptions(options []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 EncapsulateRelay

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

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

func FromBytes

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

func NewAdvertiseFromSolicit

func NewAdvertiseFromSolicit(solicit DHCPv6, modifiers ...Modifier) (DHCPv6, error)

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

func NewMessage

func NewMessage(modifiers ...Modifier) (DHCPv6, error)

NewMessage creates a new DHCPv6 message with default options

func NewRelayReplFromRelayForw

func NewRelayReplFromRelayForw(relayForw, msg DHCPv6) (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.

func NewReplyFromDHCPv6Message

func NewReplyFromDHCPv6Message(message DHCPv6, modifiers ...Modifier) (DHCPv6, error)

NewReplyFromDHCPv6Message creates a new REPLY packet based on a DHCPv6Message. The function is to be used when generating a reply to REQUEST, CONFIRM, RENEW, REBIND, RELEASE and INFORMATION-REQUEST packets.

func NewRequestFromAdvertise

func NewRequestFromAdvertise(advertise DHCPv6, modifiers ...Modifier) (DHCPv6, error)

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

func NewSolicitForInterface

func NewSolicitForInterface(ifname string, modifiers ...Modifier) (DHCPv6, error)

NewSolicitForInterface creates a new SOLICIT message with DUID-LLT, using the given network interface's hardware address and current time

func NewSolicitWithCID

func NewSolicitWithCID(duid Duid, modifiers ...Modifier) (DHCPv6, error)

NewSolicitWithCID creates a new SOLICIT message with CID.

func WithNetboot

func WithNetboot(d DHCPv6) DHCPv6

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

type DHCPv6Message

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

func (*DHCPv6Message) AddOption

func (d *DHCPv6Message) AddOption(option Option)

func (*DHCPv6Message) GetOneOption

func (d *DHCPv6Message) GetOneOption(code OptionCode) Option

func (*DHCPv6Message) GetOption

func (d *DHCPv6Message) GetOption(code OptionCode) []Option

func (*DHCPv6Message) IsNetboot

func (d *DHCPv6Message) 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 (*DHCPv6Message) IsOptionRequested

func (d *DHCPv6Message) IsOptionRequested(requested OptionCode) bool

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

func (*DHCPv6Message) IsRelay

func (d *DHCPv6Message) IsRelay() bool

func (*DHCPv6Message) MessageTypeToString

func (d *DHCPv6Message) MessageTypeToString() string

func (*DHCPv6Message) Options

func (d *DHCPv6Message) Options() []Option

func (*DHCPv6Message) SetMessage

func (d *DHCPv6Message) SetMessage(messageType MessageType)

func (*DHCPv6Message) SetOptions

func (d *DHCPv6Message) SetOptions(options []Option)

func (*DHCPv6Message) SetTransactionID

func (d *DHCPv6Message) SetTransactionID(tid TransactionID)

SetTransactionID sets this message's transaction id.

func (*DHCPv6Message) String

func (d *DHCPv6Message) String() string

func (*DHCPv6Message) Summary

func (d *DHCPv6Message) Summary() string

func (*DHCPv6Message) ToBytes

func (d *DHCPv6Message) ToBytes() []byte

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

func (*DHCPv6Message) TransactionID

func (d *DHCPv6Message) TransactionID() TransactionID

TransactionID returns this message's transaction id.

func (*DHCPv6Message) Type

func (d *DHCPv6Message) Type() MessageType

func (*DHCPv6Message) UpdateOption

func (d *DHCPv6Message) UpdateOption(option Option)

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

type DHCPv6Relay

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

func (*DHCPv6Relay) AddOption

func (r *DHCPv6Relay) AddOption(option Option)

func (*DHCPv6Relay) GetInnerMessage

func (d *DHCPv6Relay) GetInnerMessage() (DHCPv6, error)

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

func (*DHCPv6Relay) GetOneOption

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

func (*DHCPv6Relay) GetOption

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

func (*DHCPv6Relay) HopCount

func (r *DHCPv6Relay) HopCount() uint8

func (*DHCPv6Relay) IsRelay

func (r *DHCPv6Relay) IsRelay() bool

func (*DHCPv6Relay) LinkAddr

func (r *DHCPv6Relay) LinkAddr() net.IP

func (*DHCPv6Relay) MessageTypeToString

func (r *DHCPv6Relay) MessageTypeToString() string

func (*DHCPv6Relay) Options

func (r *DHCPv6Relay) Options() []Option

func (*DHCPv6Relay) PeerAddr

func (r *DHCPv6Relay) PeerAddr() net.IP

func (*DHCPv6Relay) SetHopCount

func (r *DHCPv6Relay) SetHopCount(hopCount uint8)

func (*DHCPv6Relay) SetLinkAddr

func (r *DHCPv6Relay) SetLinkAddr(linkAddr net.IP)

func (*DHCPv6Relay) SetMessageType

func (r *DHCPv6Relay) SetMessageType(messageType MessageType)

func (*DHCPv6Relay) SetOptions

func (r *DHCPv6Relay) SetOptions(options []Option)

func (*DHCPv6Relay) SetPeerAddr

func (r *DHCPv6Relay) SetPeerAddr(peerAddr net.IP)

func (*DHCPv6Relay) String

func (r *DHCPv6Relay) String() string

func (*DHCPv6Relay) Summary

func (r *DHCPv6Relay) Summary() string

func (*DHCPv6Relay) ToBytes

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

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

func (*DHCPv6Relay) Type

func (r *DHCPv6Relay) Type() MessageType

func (*DHCPv6Relay) UpdateOption

func (r *DHCPv6Relay) UpdateOption(option Option)

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

type Duid

type Duid struct {
	Type                 DuidType
	HwType               iana.HWType // for DUID-LLT and DUID-LL. Ignored otherwise. RFC 826
	Time                 uint32      // for DUID-LLT. Ignored otherwise
	LinkLayerAddr        net.HardwareAddr
	EnterpriseNumber     uint32 // for DUID-EN. Ignored otherwise
	EnterpriseIdentifier []byte // for DUID-EN. Ignored otherwise
	Uuid                 []byte // for DUID-UUID. Ignored otherwise
	Opaque               []byte // for unknown DUIDs
}

Duid is a DHCP Unique Identifier.

func DuidFromBytes

func DuidFromBytes(data []byte) (*Duid, error)

DuidFromBytes parses a Duid from a byte slice.

func (Duid) Equal

func (d Duid) Equal(o Duid) bool

Equal compares two Duid objects.

func (*Duid) Length

func (d *Duid) Length() int

Length returns the DUID length in bytes.

func (*Duid) String

func (d *Duid) String() string

func (*Duid) ToBytes

func (d *Duid) ToBytes() []byte

ToBytes serializes a Duid object.

type DuidType

type DuidType uint16

DuidType is the DUID type as defined in rfc3315.

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

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

func WithIANA(addrs ...OptIAAddress) Modifier

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

func WithRequestedOptions

func WithRequestedOptions(optionCodes ...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 OptBootFileURL

type OptBootFileURL struct {
	BootFileURL []byte
}

OptBootFileURL implements the OptionBootfileURL option

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

func ParseOptBootFileURL

func ParseOptBootFileURL(data []byte) (*OptBootFileURL, error)

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

func (*OptBootFileURL) Code

func (op *OptBootFileURL) Code() OptionCode

Code returns the option code

func (*OptBootFileURL) String

func (op *OptBootFileURL) String() string

func (*OptBootFileURL) ToBytes

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

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

type OptClientArchType

type OptClientArchType struct {
	ArchTypes []iana.Arch
}

OptClientArchType represents an option CLIENT_ARCH_TYPE

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

func ParseOptClientArchType

func ParseOptClientArchType(data []byte) (*OptClientArchType, error)

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

func (*OptClientArchType) Code

func (op *OptClientArchType) Code() OptionCode

func (*OptClientArchType) String

func (op *OptClientArchType) String() string

func (*OptClientArchType) ToBytes

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

ToBytes marshals the client arch type as defined by RFC 5970.

type OptClientId

type OptClientId struct {
	Cid Duid
}

OptClientId represents a Client ID option

This module defines the OptClientId and DUID structures. https://www.ietf.org/rfc/rfc3315.txt

func ParseOptClientId

func ParseOptClientId(data []byte) (*OptClientId, error)

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

func (*OptClientId) Code

func (op *OptClientId) Code() OptionCode

func (*OptClientId) String

func (op *OptClientId) String() string

func (*OptClientId) ToBytes

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

ToBytes marshals the Client ID option as defined by RFC 3315, Section 22.2.

type OptDNSRecursiveNameServer

type OptDNSRecursiveNameServer struct {
	NameServers []net.IP
}

OptDNSRecursiveNameServer represents a OptionDNSRecursiveNameServer option

This module defines the OptDNSRecursiveNameServer structure. https://www.ietf.org/rfc/rfc3646.txt

func ParseOptDNSRecursiveNameServer

func ParseOptDNSRecursiveNameServer(data []byte) (*OptDNSRecursiveNameServer, error)

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

func (*OptDNSRecursiveNameServer) Code

Code returns the option code

func (*OptDNSRecursiveNameServer) String

func (op *OptDNSRecursiveNameServer) String() string

func (*OptDNSRecursiveNameServer) ToBytes

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

ToBytes returns the option serialized to bytes.

type OptDomainSearchList

type OptDomainSearchList struct {
	DomainSearchList *rfc1035label.Labels
}

OptDomainSearchList list implements a OptionDomainSearchList option

This module defines the OptDomainSearchList structure. https://www.ietf.org/rfc/rfc3646.txt

func ParseOptDomainSearchList

func ParseOptDomainSearchList(data []byte) (*OptDomainSearchList, error)

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

func (*OptDomainSearchList) Code

func (op *OptDomainSearchList) Code() OptionCode

func (*OptDomainSearchList) String

func (op *OptDomainSearchList) String() string

func (*OptDomainSearchList) ToBytes

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

ToBytes marshals this option to bytes.

type OptElapsedTime

type OptElapsedTime struct {
	ElapsedTime uint16
}

OptElapsedTime implements the Elapsed Time option.

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

func ParseOptElapsedTime

func ParseOptElapsedTime(data []byte) (*OptElapsedTime, error)

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

func (*OptElapsedTime) Code

func (op *OptElapsedTime) Code() OptionCode

func (*OptElapsedTime) String

func (op *OptElapsedTime) String() string

func (*OptElapsedTime) ToBytes

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

ToBytes marshals this option to bytes.

type OptIAAddress

type OptIAAddress struct {
	IPv6Addr          net.IP
	PreferredLifetime uint32
	ValidLifetime     uint32
	Options           Options
}

OptIAAddress represents an OptionIAAddr.

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

func ParseOptIAAddress

func ParseOptIAAddress(data []byte) (*OptIAAddress, error)

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

func (*OptIAAddress) Code

func (op *OptIAAddress) Code() OptionCode

Code returns the option's code

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 OptIAForPrefixDelegation

type OptIAForPrefixDelegation struct {
	IaId    [4]byte
	T1      uint32
	T2      uint32
	Options Options
}

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

func ParseOptIAForPrefixDelegation

func ParseOptIAForPrefixDelegation(data []byte) (*OptIAForPrefixDelegation, error)

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

func (*OptIAForPrefixDelegation) Code

Code returns the option code

func (*OptIAForPrefixDelegation) DelOption

func (op *OptIAForPrefixDelegation) DelOption(code OptionCode)

DelOption will remove all the options that match a Option code.

func (*OptIAForPrefixDelegation) GetOneOption

func (op *OptIAForPrefixDelegation) GetOneOption(code OptionCode) Option

GetOneOption will get an option of the give type from the Options field, if it is present. It will return `nil` otherwise

func (*OptIAForPrefixDelegation) String

func (op *OptIAForPrefixDelegation) String() string

String returns a string representation of the OptIAForPrefixDelegation data

func (*OptIAForPrefixDelegation) ToBytes

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

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

type OptIANA

type OptIANA struct {
	IaId    [4]byte
	T1      uint32
	T2      uint32
	Options Options
}

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

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

func ParseOptIANA

func ParseOptIANA(data []byte) (*OptIANA, error)

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

func (*OptIANA) AddOption

func (op *OptIANA) AddOption(opt Option)

AddOption adds an option at the end of the IA_NA options

func (*OptIANA) Code

func (op *OptIANA) Code() OptionCode

func (*OptIANA) DelOption

func (op *OptIANA) DelOption(code OptionCode)

DelOption will remove all the options that match a Option code.

func (*OptIANA) GetOneOption

func (op *OptIANA) GetOneOption(code OptionCode) Option

GetOneOption will get an option of the give type from the Options field, if it is present. It will return `nil` otherwise

func (*OptIANA) String

func (op *OptIANA) String() string

func (*OptIANA) ToBytes

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

ToBytes serializes IANA to DHCPv6 bytes.

type OptIAPrefix

type OptIAPrefix struct {
	PreferredLifetime uint32
	ValidLifetime     uint32

	Options Options
	// contains filtered or unexported fields
}

OptIAPrefix implements the IAPrefix option.

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

func ParseOptIAPrefix

func ParseOptIAPrefix(data []byte) (*OptIAPrefix, error)

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

func (*OptIAPrefix) Code

func (op *OptIAPrefix) Code() OptionCode

func (*OptIAPrefix) DelOption

func (op *OptIAPrefix) DelOption(code OptionCode)

DelOption will remove all the options that match a Option code.

func (*OptIAPrefix) GetOneOption

func (op *OptIAPrefix) GetOneOption(code OptionCode) Option

GetOneOption will get an option of the give type from the Options field, if it is present. It will return `nil` otherwise

func (*OptIAPrefix) IPv6Prefix

func (op *OptIAPrefix) IPv6Prefix() net.IP

IPv6Prefix returns the ipv6Prefix

func (*OptIAPrefix) PrefixLength

func (op *OptIAPrefix) PrefixLength() byte

func (*OptIAPrefix) SetIPv6Prefix

func (op *OptIAPrefix) SetIPv6Prefix(p net.IP)

SetIPv6Prefix sets the ipv6Prefix

func (*OptIAPrefix) SetPrefixLength

func (op *OptIAPrefix) SetPrefixLength(pl byte)

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 OptInterfaceId

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

OptInterfaceId implements the interface-id option as defined by RFC 3315, Section 22.18.

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

func ParseOptInterfaceId

func ParseOptInterfaceId(data []byte) (*OptInterfaceId, error)

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

func (*OptInterfaceId) Code

func (op *OptInterfaceId) Code() OptionCode

func (*OptInterfaceId) InterfaceID

func (op *OptInterfaceId) InterfaceID() []byte

func (*OptInterfaceId) SetInterfaceID

func (op *OptInterfaceId) SetInterfaceID(interfaceId []byte)

func (*OptInterfaceId) String

func (op *OptInterfaceId) String() string

func (*OptInterfaceId) ToBytes

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

type OptNetworkInterfaceId

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

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

func ParseOptNetworkInterfaceId

func ParseOptNetworkInterfaceId(data []byte) (*OptNetworkInterfaceId, error)

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

func (*OptNetworkInterfaceId) Code

func (op *OptNetworkInterfaceId) Code() OptionCode

func (*OptNetworkInterfaceId) Major

func (op *OptNetworkInterfaceId) Major() uint8

func (*OptNetworkInterfaceId) Minor

func (op *OptNetworkInterfaceId) Minor() uint8

func (*OptNetworkInterfaceId) SetMajor

func (op *OptNetworkInterfaceId) SetMajor(major uint8)

func (*OptNetworkInterfaceId) SetMinor

func (op *OptNetworkInterfaceId) SetMinor(minor uint8)

func (*OptNetworkInterfaceId) SetType

func (op *OptNetworkInterfaceId) SetType(type_ uint8)

func (*OptNetworkInterfaceId) String

func (op *OptNetworkInterfaceId) String() string

func (*OptNetworkInterfaceId) ToBytes

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

func (*OptNetworkInterfaceId) Type

func (op *OptNetworkInterfaceId) Type() uint8

type OptRelayMsg

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

func ParseOptRelayMsg

func ParseOptRelayMsg(data []byte) (*OptRelayMsg, error)

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

func (*OptRelayMsg) Code

func (op *OptRelayMsg) Code() OptionCode

func (*OptRelayMsg) RelayMessage

func (op *OptRelayMsg) RelayMessage() DHCPv6

func (*OptRelayMsg) SetRelayMessage

func (op *OptRelayMsg) SetRelayMessage(relayMessage DHCPv6)

func (*OptRelayMsg) String

func (op *OptRelayMsg) String() string

func (*OptRelayMsg) ToBytes

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

type OptRemoteId

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

OptRemoteId implemens the Remote ID option.

https://www.ietf.org/rfc/rfc4649.txt

func ParseOptRemoteId

func ParseOptRemoteId(data []byte) (*OptRemoteId, error)

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

func (*OptRemoteId) Code

func (op *OptRemoteId) Code() OptionCode

func (*OptRemoteId) EnterpriseNumber

func (op *OptRemoteId) EnterpriseNumber() uint32

func (*OptRemoteId) RemoteID

func (op *OptRemoteId) RemoteID() []byte

func (*OptRemoteId) SetEnterpriseNumber

func (op *OptRemoteId) SetEnterpriseNumber(enterpriseNumber uint32)

func (*OptRemoteId) SetRemoteID

func (op *OptRemoteId) SetRemoteID(remoteId []byte)

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 OptRequestedOption

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

OptRequestedOption implements the requested options option.

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

func ParseOptRequestedOption

func ParseOptRequestedOption(data []byte) (*OptRequestedOption, error)

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

func (*OptRequestedOption) AddRequestedOption

func (op *OptRequestedOption) AddRequestedOption(opt OptionCode)

func (*OptRequestedOption) Code

func (op *OptRequestedOption) Code() OptionCode

func (*OptRequestedOption) RequestedOptions

func (op *OptRequestedOption) RequestedOptions() []OptionCode

func (*OptRequestedOption) SetRequestedOptions

func (op *OptRequestedOption) SetRequestedOptions(opts []OptionCode)

func (*OptRequestedOption) String

func (op *OptRequestedOption) String() string

func (*OptRequestedOption) ToBytes

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

type OptServerId

type OptServerId struct {
	Sid Duid
}

OptServerId represents a Server ID option

This module defines the OptServerId and DUID structures. https://www.ietf.org/rfc/rfc3315.txt

func ParseOptServerId

func ParseOptServerId(data []byte) (*OptServerId, error)

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

func (*OptServerId) Code

func (op *OptServerId) Code() OptionCode

func (*OptServerId) String

func (op *OptServerId) String() string

func (*OptServerId) ToBytes

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

ToBytes serializes this option.

type OptStatusCode

type OptStatusCode struct {
	StatusCode    iana.StatusCode
	StatusMessage []byte
}

OptStatusCode represents a DHCPv6 Status Code option

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

func ParseOptStatusCode

func ParseOptStatusCode(data []byte) (*OptStatusCode, error)

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

func (*OptStatusCode) Code

func (op *OptStatusCode) Code() OptionCode

Code returns the option code

func (*OptStatusCode) String

func (op *OptStatusCode) String() string

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 ParseOptUserClass

func ParseOptUserClass(data []byte) (*OptUserClass, error)

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

func (*OptUserClass) Code

func (op *OptUserClass) Code() OptionCode

Code returns the option code

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 ParseOptVendorClass

func ParseOptVendorClass(data []byte) (*OptVendorClass, error)

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

func (*OptVendorClass) Code

func (op *OptVendorClass) Code() OptionCode

Code returns the option code

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 ParseOptVendorOpts

func ParseOptVendorOpts(data []byte) (*OptVendorOpts, error)

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

func (*OptVendorOpts) Code

func (op *OptVendorOpts) Code() OptionCode

Code returns the option code

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
}

Option is an interface that all DHCPv6 options adhere to.

func ParseOption

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

ParseOption parses data according to the given code.

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
	// skip 10
	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
	// skip 35
	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
)

All DHCPv6 options.

func (OptionCode) String

func (o OptionCode) String() string

String returns the option code name.

type OptionGeneric

type OptionGeneric struct {
	OptionCode OptionCode
	OptionData []byte
}

func (*OptionGeneric) Code

func (og *OptionGeneric) Code() OptionCode

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

Jump to

Keyboard shortcuts

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