dhcp6opts

package
v0.0.0-...-2a67805 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2019 License: MIT Imports: 10 Imported by: 77

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHardwareTypeNotImplemented is returned when HardwareType is not
	// implemented on the current platform.
	ErrHardwareTypeNotImplemented = errors.New("hardware type detection not implemented on this platform")

	// ErrInvalidDUIDLLTTime is returned when a time before midnight (UTC),
	// January 1, 2000 is used in NewDUIDLLT.
	ErrInvalidDUIDLLTTime = errors.New("DUID-LLT time must be after midnight (UTC), January 1, 2000")

	// ErrInvalidIP is returned when an input net.IP value is not recognized as a
	// valid IPv6 address.
	ErrInvalidIP = errors.New("IP must be an IPv6 address")

	// ErrInvalidLifetimes is returned when an input preferred lifetime is shorter
	// than a valid lifetime parameter.
	ErrInvalidLifetimes = errors.New("preferred lifetime must be less than valid lifetime")

	// ErrParseHardwareType is returned when a valid hardware type could
	// not be found for a given interface.
	ErrParseHardwareType = errors.New("could not parse hardware type for interface")
)

Functions

func GetRapidCommit

func GetRapidCommit(o dhcp6.Options) error

GetRapidCommit returns the Rapid Commit Option value, described in RFC 3315, Section 22.14.

Nil is returned if OptionRapidCommit was present in the Options map.

Types

type ArchType

type ArchType uint16

An ArchType is a client system architecture type, as defined in RFC 4578, Section 2.1. Though this RFC indicates these constants are for DHCPv4, they are carried over for use in DHCPv6 in RFC 5970, Section 3.3.

const (
	// RFC 4578
	ArchTypeIntelx86PC      ArchType = 0
	ArchTypeNECPC98         ArchType = 1
	ArchTypeEFIItanium      ArchType = 2
	ArchTypeDECAlpha        ArchType = 3
	ArchtypeArcx86          ArchType = 4
	ArchTypeIntelLeanClient ArchType = 5
	ArchTypeEFIIA32         ArchType = 6
	ArchTypeEFIBC           ArchType = 7
	ArchTypeEFIXscale       ArchType = 8
	ArchTypeEFIx8664        ArchType = 9
)

ArchType constants which indicate the client system architecture types described in RFC 4578, Section 2.1.

func (ArchType) String

func (i ArchType) String() string

type ArchTypes

type ArchTypes []ArchType

ArchTypes is a slice of ArchType values. It is provided for convenient marshaling and unmarshaling of a slice of ArchType values from an Options map.

func GetClientArchType

func GetClientArchType(o dhcp6.Options) (ArchTypes, error)

GetClientArchType returns the Client System Architecture Type Option value, described in RFC 5970, Section 3.3.

The ArchTypes slice returned contains a list of one or more ArchType values. The first ArchType listed is the client's most preferable value.

func (ArchTypes) MarshalBinary

func (a ArchTypes) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from ArchTypes.

func (*ArchTypes) UnmarshalBinary

func (a *ArchTypes) UnmarshalBinary(p []byte) error

UnmarshalBinary unmarshals a raw byte slice into an ArchTypes slice.

If the byte slice is less than 2 bytes in length, or is not a length that is divisible by 2, io.ErrUnexpectedEOF is returned.

type Authentication

type Authentication struct {
	// The authentication protocol used in this authentication option
	Protocol byte

	// The algorithm used in the authentication protocol
	Algorithm byte

	// The replay detection method used in this authentication option
	RDM byte

	// The replay detection information for the RDM
	ReplayDetection uint64

	// The authentication information, as specified by the protocol and
	// algorithm used in this authentication option.
	AuthenticationInformation []byte
}

The Authentication option carries authentication information to authenticate the identity and contents of DHCP messages. The use of the Authentication option is described in section 21.

func GetAuthentication

func GetAuthentication(o dhcp6.Options) (*Authentication, error)

GetAuthentication returns the Authentication Option value, as described in RFC 3315, Section 22.11.

The Authentication option carries authentication information to authenticate the identity and contents of DHCP messages.

func (*Authentication) MarshalBinary

func (a *Authentication) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a Authentication.

func (*Authentication) UnmarshalBinary

func (a *Authentication) UnmarshalBinary(p []byte) error

UnmarshalBinary unmarshals a raw byte slice into a Authentication. If the byte slice does not contain enough data to form a valid Authentication, io.ErrUnexpectedEOF is returned.

type BootFileParam

type BootFileParam []string

A BootFileParam are boot file parameters.

func GetBootFileParam

func GetBootFileParam(o dhcp6.Options) (BootFileParam, error)

GetBootFileParam returns the Boot File Parameters Option value, described in RFC 5970, Section 3.2.

The Data structure returned contains any parameters needed for a boot file, such as a root filesystem label or a path to a configuration file for further chainloading.

func (BootFileParam) MarshalBinary

func (bfp BootFileParam) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a BootFileParam.

func (*BootFileParam) UnmarshalBinary

func (bfp *BootFileParam) UnmarshalBinary(b []byte) error

UnmarshalBinary unmarshals a raw byte slice into a BootFileParam.

type DUID

DUID represents a DHCP Unique Identifier, as defined in RFC 3315, Section 9. A DUID is used by a DHCP server to identify unique clients. A DUID can also be used by a DHCP client to identify a unique server, when needed.

The DUID interface represents a generic DUID, but DUIDs can be type-asserted to one of four specific types outlined in RFC 3315 and RFC 6355:

  • DUIDLLT - DUID Based on Link-layer Address Plus Time
  • DUIDEN - DUID Assigned by Vendor Based on Enterprise Number
  • DUIDLL - DUID Based on Link-layer Address
  • DUIDUUID - DUID Based on Universally Unique Identifier

If further introspection of the DUID is needed, a type switch is recommended:

switch d := duid.(type) {
case *dhcp6.DUIDLLT:
	fmt.Println(d.Time)
case *dhcp6.DUIDEN:
	fmt.Println(d.EnterpriseNumber)
case *dhcp6.DUIDLL:
	fmt.Println(d.HardwareAddr)
case *dhcp6.DUIDUUID:
	fmt.Println(d.UUID)
}

func GetClientID

func GetClientID(o dhcp6.Options) (DUID, error)

GetClientID returns the Client Identifier Option value, as described in RFC 3315, Section 22.2.

The DUID returned allows unique identification of a client to a server.

func GetServerID

func GetServerID(o dhcp6.Options) (DUID, error)

GetServerID returns the Server Identifier Option value, as described in RFC 3315, Section 22.3.

The DUID returned allows unique identification of a server to a client.

type DUIDEN

type DUIDEN struct {
	// Type specifies the DUID type.  For a DUIDEN, this should always be
	// DUIDTypeEN.
	Type DUIDType

	// EnterpriseNumber specifies an IANA-assigned vendor Private Enterprise
	// Number.
	EnterpriseNumber uint32

	// Identifier specifies a unique identifier of arbitrary length.  This
	// value is typically assigned when a device is manufactured.
	Identifier []byte
}

DUIDEN represents a DUID Assigned by Vendor Based on Enterprise Number [DUID-EN], as defined in RFC 3315, Section 9.3. This DUID type uses an IANA-assigned Private Enterprise Number for a given vendor.

func NewDUIDEN

func NewDUIDEN(enterpriseNumber uint32, identifier []byte) *DUIDEN

NewDUIDEN generates a new DUIDEN from an input IANA-assigned Private Enterprise Number and a variable length unique identifier byte slice.

func (*DUIDEN) MarshalBinary

func (d *DUIDEN) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a DUIDEN.

func (*DUIDEN) UnmarshalBinary

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

UnmarshalBinary unmarshals a raw byte slice into a DUIDEN. If the byte slice does not contain enough data to form a valid DUIDEN, or another DUID type is indicated, errInvalidDUIDEN is returned.

type DUIDLL

type DUIDLL struct {
	// Type specifies the DUID type.  For a DUIDLL, this should always be
	// DUIDTypeLL.
	Type DUIDType

	// HardwareType specifies an IANA-assigned hardware type, as described
	// in RFC 826.
	HardwareType uint16

	// HardwareAddr specifies the hardware address for an arbitrary link-layer
	// interface on a device, used in generating the DUIDLL.  This value
	// could represent any arbitrary interface on a system, and should not be
	// treated as a client or server's communicating hardware address.
	HardwareAddr net.HardwareAddr
}

DUIDLL represents a DUID Based on Link-layer Address [DUID-LL], as defined in RFC 3315, Section 9.4.

This DUID type is recommended for devices with a permanently-connected network interface, but without stable, persistent storage.

DUIDLL values are generated automatically for Servers which are not created with a ServerID, using the hardware type found by HardwareType and the hardware address of the listening network interface.

func NewDUIDLL

func NewDUIDLL(hardwareType uint16, hardwareAddr net.HardwareAddr) *DUIDLL

NewDUIDLL generates a new DUIDLL from an input IANA-assigned hardware type and a hardware address.

func (*DUIDLL) MarshalBinary

func (d *DUIDLL) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a DUIDLL.

func (*DUIDLL) UnmarshalBinary

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

UnmarshalBinary unmarshals a raw byte slice into a DUIDLL. If the byte slice does not contain enough data to form a valid DUIDLL, or another DUID type is indicated, errInvalidDUIDLL is returned.

type DUIDLLT

type DUIDLLT struct {
	// Type specifies the DUID type.  For a DUIDLLT, this should always be
	// DUIDTypeLLT.
	Type DUIDType

	// HardwareType specifies an IANA-assigned hardware type, as described
	// in RFC 826.
	HardwareType uint16

	// Time specifies the duration of the time this DUID was generated, minus
	// midnight (UTC), January 1, 2000.
	Time time.Duration

	// HardwareAddr specifies the hardware address for an arbitrary link-layer
	// interface on a device, used in generating the DUIDLLT.  This value
	// could represent any arbitrary interface on a system, and should not be
	// treated as a client or server's communicating hardware address.
	HardwareAddr net.HardwareAddr
}

DUIDLLT represents a DUID Based on Link-layer Address Plus Time [DUID-LLT], as defined in RFC 3315, Section 9.2.

This DUID type must only be used with clients and servers with stable, persistent storage. It is the recommended DUID type for all general purpose computing devices.

func NewDUIDLLT

func NewDUIDLLT(hardwareType uint16, time time.Time, hardwareAddr net.HardwareAddr) (*DUIDLLT, error)

NewDUIDLLT generates a new DUIDLLT from an input IANA-assigned hardware type, time value, and a hardware address.

The time value must be greater than midnight (UTC), January 1, 2000.

func (*DUIDLLT) MarshalBinary

func (d *DUIDLLT) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a DUIDLLT.

func (*DUIDLLT) UnmarshalBinary

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

UnmarshalBinary unmarshals a raw byte slice into a DUIDLLT. If the byte slice does not contain enough data to form a valid DUIDLLT, or another DUID type is indicated, errInvalidDUIDLLT is returned.

type DUIDType

type DUIDType uint16

DUIDType is a type of DHCP Unique Identifier, as defined in RFC 3315, Section 9. DUIDs are used to uniquely identify a client to a server, or vice-versa.

const (
	// RFC 3315
	DUIDTypeLLT DUIDType = 1
	DUIDTypeEN  DUIDType = 2
	DUIDTypeLL  DUIDType = 3

	// RFC 6355
	DUIDTypeUUID DUIDType = 4
)

DUIDType constants which indicate DUID types described in RFCs 3315 and 6355.

These DUID types are taken from IANA's DHCPv6 parameters registry: http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xhtml.

func (DUIDType) String

func (i DUIDType) String() string

type DUIDUUID

type DUIDUUID struct {
	// Type specifies the DUID type.  For a DUIDUUID, this should always be
	// DUIDTypeUUID.
	Type DUIDType

	// UUID specifies a Universally Unique Identifier, as described in RFC 4578.
	UUID [16]byte
}

DUIDUUID represents a DUID based on Universally Unique Identifier [DUID-UUID], as defined in RFC 6355. This DUID type uses a UUID to identify clients or servers.

func NewDUIDUUID

func NewDUIDUUID(uuid [16]byte) *DUIDUUID

NewDUIDUUID generates a new DUIDUUID using an input UUID.

func (*DUIDUUID) MarshalBinary

func (d *DUIDUUID) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a DUIDUUID.

func (*DUIDUUID) UnmarshalBinary

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

UnmarshalBinary unmarshals a raw byte slice into a DUIDUUID. If the byte slice does not contain the exact number of bytes needed to form a valid DUIDUUID, or another DUID type is indicated, errInvalidDUIDUUID is returned.

type Data

type Data [][]byte

Data is a raw collection of byte slices, typically carrying user class data, vendor class data, or PXE boot file parameters.

func GetUserClass

func GetUserClass(o dhcp6.Options) (Data, error)

GetUserClass returns the User Class Option value, described in RFC 3315, Section 22.15.

The Data structure returned contains any raw class data present in the option.

func (Data) Marshal

func (d Data) Marshal(b *buffer.Buffer)

Marshal marshals to a given buffer from a Data structure.

func (Data) MarshalBinary

func (d Data) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a Data structure.

func (*Data) Unmarshal

func (d *Data) Unmarshal(b *buffer.Buffer) error

Unmarshal marshals from a given buffer into a Data structure. Data is packed in the form:

  • 2 bytes: data length
  • N bytes: raw data

func (*Data) UnmarshalBinary

func (d *Data) UnmarshalBinary(p []byte) error

UnmarshalBinary unmarshals a raw byte slice into a Data structure.

type ElapsedTime

type ElapsedTime time.Duration

An ElapsedTime is a client's elapsed request time value, as defined in RFC 3315, Section 22.9.

The duration returned reports the time elapsed during a DHCP transaction, as reported by a client.

func GetElapsedTime

func GetElapsedTime(o dhcp6.Options) (ElapsedTime, error)

GetElapsedTime returns the Elapsed Time Option value, as described in RFC 3315, Section 22.9.

The time.Duration returned reports the time elapsed during a DHCP transaction, as reported by a client.

func (ElapsedTime) MarshalBinary

func (t ElapsedTime) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from an ElapsedTime.

func (*ElapsedTime) UnmarshalBinary

func (t *ElapsedTime) UnmarshalBinary(p []byte) error

UnmarshalBinary unmarshals a raw byte slice into a ElapsedTime.

If the byte slice is not exactly 2 bytes in length, io.ErrUnexpectedEOF is returned.

type IAAddr

type IAAddr struct {
	// IP specifies the IPv6 address to offer to a client.  The validity of the
	// address is controlled by the PreferredLifetime and ValidLifetime fields.
	IP net.IP

	// PreferredLifetime specifies the preferred lifetime of an IPv6 address.
	// When the preferred lifetime of an address expires, the address becomes
	// deprecated, and should not be used in new communications.
	//
	// The preferred lifetime of an address must not be greater than its
	// valid lifetime.
	PreferredLifetime time.Duration

	// ValidLifetime specifies the valid lifetime of an IPv6 address.  When the
	// valid lifetime of an address expires, the address should not be used for
	// any further communication.
	//
	// The valid lifetime of an address must be greater than its preferred
	// lifetime.
	ValidLifetime time.Duration

	// Options specifies a map of DHCP options specific to this IAAddr.
	// Its methods can be used to retrieve data from an incoming IAAddr, or
	// send data with an outgoing IAAddr.
	Options dhcp6.Options
}

IAAddr represents an Identity Association Address, as defined in RFC 3315, Section 22.6.

DHCP clients use identity association addresses (IAAddrs) to request IPv6 addresses from a DHCP server, using the lifetimes specified in the preferred lifetime and valid lifetime fields. Multiple IAAddrs may be present in a single DHCP request, but only enscapsulated within an IANA or IATA options field.

func GetIAAddr

func GetIAAddr(o dhcp6.Options) ([]*IAAddr, error)

GetIAAddr returns the Identity Association Address Option value, as described in RFC 3315, Section 22.6.

The IAAddr option must always appear encapsulated in the Options map of a IANA or IATA option. Multiple IAAddr values may be present in a single DHCP request.

func NewIAAddr

func NewIAAddr(ip net.IP, preferred time.Duration, valid time.Duration, options dhcp6.Options) (*IAAddr, error)

NewIAAddr creates a new IAAddr from an IPv6 address, preferred and valid lifetime durations, and an optional Options map.

The IP must be exactly 16 bytes, the correct length for an IPv6 address. The preferred lifetime duration must be less than the valid lifetime duration. Failure to meet either of these conditions will result in an error. If an Options map is not specified, a new one will be allocated.

func (*IAAddr) MarshalBinary

func (i *IAAddr) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a IAAddr.

func (*IAAddr) UnmarshalBinary

func (i *IAAddr) UnmarshalBinary(p []byte) error

UnmarshalBinary unmarshals a raw byte slice into a IAAddr.

If the byte slice does not contain enough data to form a valid IAAddr, io.ErrUnexpectedEOF is returned. If the preferred lifetime value in the byte slice is less than the valid lifetime, ErrInvalidLifetimes is returned.

type IANA

type IANA struct {
	// IAID specifies a DHCP identity association identifier.  The IAID
	// is a unique, client-generated identifier.
	IAID [4]byte

	// T1 specifies how long a DHCP client will wait to contact this server,
	// to extend the lifetimes of the addresses assigned to this IANA
	// by this server.
	T1 time.Duration

	// T2 specifies how long a DHCP client will wait to contact any server,
	// to extend the lifetimes of the addresses assigned to this IANA
	// by this server.
	T2 time.Duration

	// Options specifies a map of DHCP options specific to this IANA.
	// Its methods can be used to retrieve data from an incoming IANA, or send
	// data with an outgoing IANA.
	Options dhcp6.Options
}

IANA represents an Identity Association for Non-temporary Addresses, as defined in RFC 3315, Section 22.4.

Multiple IANAs may be present in a single DHCP request.

func GetIANA

func GetIANA(o dhcp6.Options) ([]*IANA, error)

GetIANA returns the Identity Association for Non-temporary Addresses Option value, as described in RFC 3315, Section 22.4.

Multiple IANA values may be present in a single DHCP request.

func NewIANA

func NewIANA(iaid [4]byte, t1 time.Duration, t2 time.Duration, options dhcp6.Options) *IANA

NewIANA creates a new IANA from an IAID, T1 and T2 durations, and an Options map. If an Options map is not specified, a new one will be allocated.

func (IANA) MarshalBinary

func (i IANA) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a IANA.

func (*IANA) UnmarshalBinary

func (i *IANA) UnmarshalBinary(p []byte) error

UnmarshalBinary unmarshals a raw byte slice into a IANA.

If the byte slice does not contain enough data to form a valid IANA, io.ErrUnexpectedEOF is returned.

type IAPD

type IAPD struct {
	// IAID specifies a DHCP identity association identifier.  The IAID
	// is a unique, client-generated identifier.
	IAID [4]byte

	// T1 specifies how long a requesting router will wait to contact a
	// delegating router, to extend the lifetimes of the prefixes delegated
	// to this IAPD, by the delegating router.
	T1 time.Duration

	// T2 specifies how long a requesting router will wait to contact any
	// available delegating router, to extend the lifetimes of the prefixes
	// delegated to this IAPD.
	T2 time.Duration

	// Options specifies a map of DHCP options specific to this IAPD.
	// Its methods can be used to retrieve data from an incoming IAPD, or send
	// data with an outgoing IAPD.
	Options dhcp6.Options
}

IAPD represents an Identity Association for Prefix Delegation, as defined in RFC 3633, Section 9.

Multiple IAPDs may be present in a single DHCP request.

func GetIAPD

func GetIAPD(o dhcp6.Options) ([]*IAPD, error)

GetIAPD returns the Identity Association for Prefix Delegation Option value, described in RFC 3633, Section 9.

Multiple IAPD values may be present in a a single DHCP request.

func NewIAPD

func NewIAPD(iaid [4]byte, t1 time.Duration, t2 time.Duration, options dhcp6.Options) *IAPD

NewIAPD creates a new IAPD from an IAID, T1 and T2 durations, and an Options map. If an Options map is not specified, a new one will be allocated.

func (*IAPD) MarshalBinary

func (i *IAPD) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a IAPD.

func (*IAPD) UnmarshalBinary

func (i *IAPD) UnmarshalBinary(b []byte) error

UnmarshalBinary unmarshals a raw byte slice into a IAPD.

If the byte slice does not contain enough data to form a valid IAPD, io.ErrUnexpectedEOF is returned.

type IAPrefix

type IAPrefix struct {
	// PreferredLifetime specifies the preferred lifetime of an IPv6 prefix.
	// When the preferred lifetime of a prefix expires, the prefix becomes
	// deprecated, and addresses from the prefix should not be used in new
	// communications.
	//
	// The preferred lifetime of a prefix must not be greater than its valid
	// lifetime.
	PreferredLifetime time.Duration

	// ValidLifetime specifies the valid lifetime of an IPv6 prefix.  When the
	// valid lifetime of a prefix expires, addresses from the prefix the address
	// should not be used for any further communication.
	//
	// The valid lifetime of a prefix must be greater than its preferred
	// lifetime.
	ValidLifetime time.Duration

	// PrefixLength specifies the length in bits of an IPv6 address prefix, such
	// as 32, 64, etc.
	PrefixLength uint8

	// Prefix specifies the IPv6 address prefix from which IPv6 addresses can
	// be allocated.
	Prefix net.IP

	// Options specifies a map of DHCP options specific to this IAPrefix.
	// Its methods can be used to retrieve data from an incoming IAPrefix, or
	// send data with an outgoing IAPrefix.
	Options dhcp6.Options
}

IAPrefix represents an Identity Association Prefix, as defined in RFC 3633, Section 10.

Routers may use identity association prefixes (IAPrefixes) to request IPv6 prefixes to assign individual address to IPv6 clients, using the lifetimes specified in the preferred lifetime and valid lifetime fields. Multiple IAPrefixes may be present in a single DHCP request, but only enscapsulated within an IAPD's options.

func GetIAPrefix

func GetIAPrefix(o dhcp6.Options) ([]*IAPrefix, error)

GetIAPrefix returns the Identity Association Prefix Option value, as described in RFC 3633, Section 10.

Multiple IAPrefix values may be present in a a single DHCP request.

func NewIAPrefix

func NewIAPrefix(preferred time.Duration, valid time.Duration, prefixLength uint8, prefix net.IP, options dhcp6.Options) (*IAPrefix, error)

NewIAPrefix creates a new IAPrefix from preferred and valid lifetime durations, an IPv6 prefix length, an IPv6 prefix, and an optional Options map.

The preferred lifetime duration must be less than the valid lifetime duration. The IPv6 prefix must be exactly 16 bytes, the correct length for an IPv6 address. Failure to meet either of these conditions will result in an error. If an Options map is not specified, a new one will be allocated.

func (*IAPrefix) MarshalBinary

func (i *IAPrefix) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a IAPrefix.

func (*IAPrefix) UnmarshalBinary

func (i *IAPrefix) UnmarshalBinary(p []byte) error

UnmarshalBinary unmarshals a raw byte slice into a IAPrefix.

If the byte slice does not contain enough data to form a valid IAPrefix, io.ErrUnexpectedEOF is returned. If the preferred lifetime value in the byte slice is less than the valid lifetime, ErrInvalidLifetimes is returned.

type IATA

type IATA struct {
	// IAID specifies a DHCP identity association identifier.  The IAID
	// is a unique, client-generated identifier.
	IAID [4]byte

	// Options specifies a map of DHCP options specific to this IATA.
	// Its methods can be used to retrieve data from an incoming IATA, or send
	// data with an outgoing IATA.
	Options dhcp6.Options
}

IATA represents an Identity Association for Temporary Addresses, as defined in RFC 3315, Section 22.5.

Multiple IATAs may be present in a single DHCP request.

func GetIATA

func GetIATA(o dhcp6.Options) ([]*IATA, error)

GetIATA returns the Identity Association for Temporary Addresses Option value, as described in RFC 3315, Section 22.5.

Multiple IATA values may be present in a single DHCP request.

func NewIATA

func NewIATA(iaid [4]byte, options dhcp6.Options) *IATA

NewIATA creates a new IATA from an IAID and an Options map. If an Options map is not specified, a new one will be allocated.

func (*IATA) MarshalBinary

func (i *IATA) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a IATA.

func (*IATA) UnmarshalBinary

func (i *IATA) UnmarshalBinary(p []byte) error

UnmarshalBinary unmarshals a raw byte slice into a IATA.

If the byte slice does not contain enough data to form a valid IATA, io.ErrUnexpectedEOF is returned.

type IP

type IP net.IP

An IP is an IPv6 address. The IP type is provided for convenience. It can be used to easily add IPv6 addresses to an Options map.

func GetUnicast

func GetUnicast(o dhcp6.Options) (IP, error)

GetUnicast returns the IP from a Unicast Option value, described in RFC 3315, Section 22.12.

The IP return value indicates a server's IPv6 address, which a client may use to contact the server via unicast.

func (IP) MarshalBinary

func (i IP) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a IP.

func (*IP) UnmarshalBinary

func (i *IP) UnmarshalBinary(b []byte) error

UnmarshalBinary unmarshals a raw byte slice into an IP.

If the byte slice is not an IPv6 address, io.ErrUnexpectedEOF is returned.

type IPs

type IPs []net.IP

IPs represents a list of IPv6 addresses.

func GetDNSServers

func GetDNSServers(o dhcp6.Options) (IPs, error)

GetDNSServers returns the DNS Recursive Name Servers Option value, as described in RFC 3646, Section 3.

The DNS servers are listed in the order of preference for use by the client resolver.

func (IPs) MarshalBinary

func (i IPs) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the consecutive data of all IPs.

func (*IPs) UnmarshalBinary

func (i *IPs) UnmarshalBinary(p []byte) error

UnmarshalBinary unmarshals a raw byte slice into a list of IPs.

If the byte slice contains any non-IPv6 addresses, io.ErrUnexpectedEOF is returned.

type InterfaceID

type InterfaceID []byte

An InterfaceID is an opaque value of arbitrary length generated by the relay agent to identify one of the relay agent's interfaces.

func GetInterfaceID

func GetInterfaceID(o dhcp6.Options) (InterfaceID, error)

GetInterfaceID returns the Interface-Id Option value, described in RFC 3315, Section 22.18.

The InterfaceID structure returned contains any raw class data present in the option.

func (*InterfaceID) MarshalBinary

func (i *InterfaceID) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a InterfaceID.

func (*InterfaceID) UnmarshalBinary

func (i *InterfaceID) UnmarshalBinary(b []byte) error

UnmarshalBinary unmarshals a raw byte slice into a InterfaceID.

type NII

type NII struct {
	// Type specifies a network interface type.
	Type uint8

	// Major specifies the UNDI major revisision which this client supports.
	Major uint8

	// Minor specifies the UNDI minor revision which this client supports.
	Minor uint8
}

A NII is a Client Network Interface Identifier, as defined in RFC 5970, Section 3.4.

A NII is used to indicate a client's level of Universal Network Device Interface (UNDI) support.

func GetNII

func GetNII(o dhcp6.Options) (*NII, error)

GetNII returns the Client Network Interface Identifier Option value, described in RFC 5970, Section 3.4.

The NII value returned indicates a client's level of Universal Network Device Interface (UNDI) support.

func (*NII) MarshalBinary

func (n *NII) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a NII.

func (*NII) UnmarshalBinary

func (n *NII) UnmarshalBinary(b []byte) error

UnmarshalBinary unmarshals a raw byte slice into a NII.

If the byte slice is not exactly 3 bytes in length, io.ErrUnexpectedEOF is returned.

type OptionRequestOption

type OptionRequestOption []dhcp6.OptionCode

A OptionRequestOption is a list OptionCode, as defined in RFC 3315, Section 22.7.

The Option Request option is used to identify a list of options in a message between a client and a server.

func GetOptionRequest

func GetOptionRequest(o dhcp6.Options) (OptionRequestOption, error)

GetOptionRequest returns the Option Request Option value, as described in RFC 3315, Section 22.7.

The slice of OptionCode values indicates the options a DHCP client is interested in receiving from a server.

func (OptionRequestOption) MarshalBinary

func (oro OptionRequestOption) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a OptionRequestOption.

func (*OptionRequestOption) UnmarshalBinary

func (oro *OptionRequestOption) UnmarshalBinary(p []byte) error

UnmarshalBinary unmarshals a raw byte slice into a OptionRequestOption.

If the length of byte slice is not be be divisible by 2, errInvalidOptionRequest is returned.

type Preference

type Preference uint8

A Preference is a preference value, as defined in RFC 3315, Section 22.8.

A preference value is sent by a server to a client to affect the selection of a server by the client.

func GetPreference

func GetPreference(o dhcp6.Options) (Preference, error)

GetPreference returns the Preference Option value, as described in RFC 3315, Section 22.8.

The integer preference value is sent by a server to a client to affect the selection of a server by the client.

func (Preference) MarshalBinary

func (p Preference) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a Preference.

func (*Preference) UnmarshalBinary

func (p *Preference) UnmarshalBinary(b []byte) error

UnmarshalBinary unmarshals a raw byte slice into a Preference.

If the byte slice is not exactly 1 byte in length, io.ErrUnexpectedEOF is returned.

type RelayMessage

type RelayMessage struct {
	// RELAY-FORW or RELAY-REPL only
	MessageType dhcp6.MessageType

	// Number of relay agents that have relayed this
	// message.
	HopCount uint8

	// A global or site-local address that will be used by
	// the server to identify the link on which the client
	// is located.
	LinkAddress net.IP

	// The address of the client or relay agent from which
	// the message to be relayed was received.
	PeerAddress net.IP

	// Options specifies a map of DHCP options.  Its methods can be used to
	// retrieve data from an incoming RelayMessage, or send data with an outgoing
	// RelayMessage.
	// MUST include a "Relay Message option" (see
	// section 22.10); MAY include other options added by
	// the relay agent.
	Options dhcp6.Options
}

RelayMessage represents a raw RelayMessage generated by DHCPv6 relay agent, using RFC 3315, Section 7.

func (*RelayMessage) MarshalBinary

func (rm *RelayMessage) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a RelayMessage.

func (*RelayMessage) UnmarshalBinary

func (rm *RelayMessage) UnmarshalBinary(p []byte) error

UnmarshalBinary unmarshals a raw byte slice into a RelayMessage.

If the byte slice does not contain enough data to form a valid RelayMessage, ErrInvalidPacket is returned.

type RelayMessageOption

type RelayMessageOption []byte

A RelayMessageOption is used by a DHCPv6 Relay Agent to relay messages between clients and servers or other relay agents through Relay-Forward and Relay-Reply message types. The original client DHCP message (i.e., the packet payload, excluding UDP and IP headers) is encapsulated in a Relay Message option.

func GetRelayMessageOption

func GetRelayMessageOption(o dhcp6.Options) (RelayMessageOption, error)

GetRelayMessageOption returns the Relay Message Option value, as described in RFC 3315, Section 22.10.

The RelayMessage option carries a DHCP message in a Relay-forward or Relay-reply message.

func (*RelayMessageOption) ClientServerMessage

func (r *RelayMessageOption) ClientServerMessage() (*dhcp6.Packet, error)

ClientServerMessage gets the client server message (e.g. Solicit, Advertise ...) into this option (when hopcount = 0 of outer RelayMessage).

func (*RelayMessageOption) MarshalBinary

func (r *RelayMessageOption) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a RelayMessageOption.

func (*RelayMessageOption) RelayMessage

func (r *RelayMessageOption) RelayMessage() (*RelayMessage, error)

RelayMessage gets the relay message (e.g. Relay Forward, Relay Reply) into this option (when hopcount > 0 of outer RelayMessage).

func (*RelayMessageOption) SetClientServerMessage

func (r *RelayMessageOption) SetClientServerMessage(p *dhcp6.Packet) error

SetClientServerMessage sets a Packet (e.g. Solicit, Advertise ...) into this option.

func (*RelayMessageOption) SetRelayMessage

func (r *RelayMessageOption) SetRelayMessage(p *RelayMessage) error

SetRelayMessage sets a RelayMessage (e.g. Relay Forward, Relay Reply) into this option.

func (*RelayMessageOption) UnmarshalBinary

func (r *RelayMessageOption) UnmarshalBinary(b []byte) error

UnmarshalBinary unmarshals a raw byte slice into a RelayMessageOption.

type RemoteIdentifier

type RemoteIdentifier struct {
	// EnterpriseNumber specifies an IANA-assigned vendor Private Enterprise
	// Number.
	EnterpriseNumber uint32

	// The opaque value for the remote-id.
	RemoteID []byte
}

A RemoteIdentifier carries vendor-specific options.

The vendor is indicated in the enterprise-number field. The remote-id field may be used to encode, for instance: - a "caller ID" telephone number for dial-up connection - a "user name" prompted for by a Remote Access Server - a remote caller ATM address - a "modem ID" of a cable data modem - the remote IP address of a point-to-point link - a remote X.25 address for X.25 connections - an interface or port identifier

func GetRemoteIdentifier

func GetRemoteIdentifier(o dhcp6.Options) (*RemoteIdentifier, error)

GetRemoteIdentifier returns the Remote Identifier, described in RFC 4649.

This option may be added by DHCPv6 relay agents that terminate switched or permanent circuits and have mechanisms to identify the remote host end of the circuit.

func (*RemoteIdentifier) MarshalBinary

func (r *RemoteIdentifier) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a RemoteIdentifier.

func (*RemoteIdentifier) UnmarshalBinary

func (r *RemoteIdentifier) UnmarshalBinary(p []byte) error

UnmarshalBinary unmarshals a raw byte slice into a RemoteIdentifier. If the byte slice does not contain enough data to form a valid RemoteIdentifier, io.ErrUnexpectedEOF is returned.

type StatusCode

type StatusCode struct {
	// Code specifies the Status value stored within this StatusCode, such as
	// StatusSuccess, StatusUnspecFail, etc.
	Code dhcp6.Status

	// Message specifies a human-readable message within this StatusCode, useful
	// for providing information about successes or failures.
	Message string
}

StatusCode represents a Status Code, as defined in RFC 3315, Section 5.4. DHCP clients and servers can use status codes to communicate successes or failures, and provide additional information using a message to describe specific failures.

func GetStatusCode

func GetStatusCode(o dhcp6.Options) (*StatusCode, error)

GetStatusCode returns the Status Code Option value, described in RFC 3315, Section 22.13.

The StatusCode return value may be used to determine a code and an explanation for the status.

func NewStatusCode

func NewStatusCode(code dhcp6.Status, message string) *StatusCode

NewStatusCode creates a new StatusCode from an input Status value and a string message.

func (*StatusCode) MarshalBinary

func (s *StatusCode) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a StatusCode.

func (*StatusCode) UnmarshalBinary

func (s *StatusCode) UnmarshalBinary(p []byte) error

UnmarshalBinary unmarshals a raw byte slice into a StatusCode.

If the byte slice does not contain enough data to form a valid StatusCode, errInvalidStatusCode is returned.

type URL

type URL url.URL

A URL is a uniform resource locater. The URL type is provided for convenience. It can be used to easily add URLs to an Options map.

func GetBootFileURL

func GetBootFileURL(o dhcp6.Options) (*URL, error)

GetBootFileURL returns the Boot File URL Option value, described in RFC 5970, Section 3.1.

The URL return value contains a URL which may be used by clients to obtain a boot file for PXE.

func (URL) MarshalBinary

func (u URL) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a URL.

func (*URL) UnmarshalBinary

func (u *URL) UnmarshalBinary(b []byte) error

UnmarshalBinary unmarshals a raw byte slice into an URL.

If the byte slice is not an URLv6 address, io.ErrUnexpectedEOF is returned.

type VendorClass

type VendorClass struct {
	// EnterpriseNumber specifies an IANA-assigned vendor Private Enterprise
	// Number.
	EnterpriseNumber uint32

	// The vendor-class-data is composed of a series of separate items, each
	// of which describes some characteristic of the client's hardware
	// configuration.  Examples of vendor-class-data instances might include
	// the version of the operating system the client is running or the
	// amount of memory installed on the client.
	VendorClassData Data
}

VendorClass is used by a client to identify the vendor that manufactured the hardware on which the client is running. The information contained in the data area of this option is contained in one or more opaque fields that identify details of the hardware configuration.

func GetVendorClass

func GetVendorClass(o dhcp6.Options) (*VendorClass, error)

GetVendorClass returns the Vendor Class Option value, described in RFC 3315, Section 22.16.

The VendorClass structure returned contains VendorClass in the option.

func (*VendorClass) MarshalBinary

func (vc *VendorClass) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a VendorClass.

func (*VendorClass) UnmarshalBinary

func (vc *VendorClass) UnmarshalBinary(p []byte) error

UnmarshalBinary unmarshals a raw byte slice into a VendorClass.

If the byte slice is less than 4 bytes in length, or if VendorClassData is malformed, io.ErrUnexpectedEOF is returned.

type VendorOpts

type VendorOpts struct {
	// EnterpriseNumber specifies an IANA-assigned vendor Private Enterprise
	// Number.
	EnterpriseNumber uint32

	// An opaque object of option-len octets,
	// interpreted by vendor-specific code on the
	// clients and servers
	Options dhcp6.Options
}

A VendorOpts is used by clients and servers to exchange VendorOpts information.

func GetVendorOpts

func GetVendorOpts(o dhcp6.Options) (*VendorOpts, error)

GetVendorOpts returns the Vendor-specific Information Option value, described in RFC 3315, Section 22.17.

The VendorOpts structure returned contains Vendor-specific Information data present in the option.

func (*VendorOpts) MarshalBinary

func (v *VendorOpts) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice containing the data from a VendorOpts.

func (*VendorOpts) UnmarshalBinary

func (v *VendorOpts) UnmarshalBinary(p []byte) error

UnmarshalBinary unmarshals a raw byte slice into a VendorOpts. If the byte slice does not contain enough data to form a valid VendorOpts, io.ErrUnexpectedEOF is returned. If option-data are invalid, then ErrInvalidPacket is returned.

Jump to

Keyboard shortcuts

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