Documentation ¶
Overview ¶
Package dhcpv6 provides encoding and decoding of DHCPv6 messages and options.
Index ¶
- Constants
- Variables
- func ExtractMAC(packet DHCPv6) (net.HardwareAddr, error)
- func GetGlobalAddr(ifname string) (net.IP, error)
- func GetLinkLocalAddr(ifname string) (net.IP, error)
- func GetMacAddressFromEUI64(ip net.IP) (net.HardwareAddr, error)
- func GetTime() uint32
- func OptClientLinkLayerAddress(ht iana.HWType, lla net.HardwareAddr) *optClientLinkLayerAddress
- func OptInformationRefreshTime(irt time.Duration) *optInformationRefreshTime
- func WithNetboot(d DHCPv6)
- func WithRapidCommit(d DHCPv6)
- type AddressOptions
- type DHCPv6
- type DUID
- type DUIDEN
- type DUIDLL
- type DUIDLLT
- type DUIDOpaque
- type DUIDType
- type DUIDUUID
- type Duration
- type FourRDOptions
- type IdentityOptions
- type Message
- func MessageFromBytes(data []byte) (*Message, error)
- func NewAdvertiseFromSolicit(sol *Message, modifiers ...Modifier) (*Message, error)
- func NewMessage(modifiers ...Modifier) (*Message, error)
- func NewReplyFromMessage(msg *Message, modifiers ...Modifier) (*Message, error)
- func NewRequestFromAdvertise(adv *Message, modifiers ...Modifier) (*Message, error)
- func NewSolicit(hwaddr net.HardwareAddr, modifiers ...Modifier) (*Message, error)
- func (m *Message) AddOption(option Option)
- func (m *Message) GetInnerMessage() (*Message, error)
- func (m *Message) GetOneOption(code OptionCode) Option
- func (m *Message) GetOption(code OptionCode) []Option
- func (m *Message) IsNetboot() bool
- func (m *Message) IsOptionRequested(requested OptionCode) bool
- func (m *Message) IsRelay() bool
- func (m *Message) LongString(spaceIndent int) string
- func (m *Message) String() string
- func (m *Message) Summary() string
- func (m *Message) ToBytes() []byte
- func (m Message) Type() MessageType
- func (m *Message) UpdateOption(option Option)
- type MessageOptions
- func (mo MessageOptions) ArchTypes() iana.Archs
- func (mo MessageOptions) BootFileParam() []string
- func (mo MessageOptions) BootFileURL() string
- func (mo MessageOptions) ClientID() DUID
- func (mo MessageOptions) DHCP4oDHCP6Server() *OptDHCP4oDHCP6Server
- func (mo MessageOptions) DNS() []net.IP
- func (mo MessageOptions) DomainSearchList() *rfc1035label.Labels
- func (mo MessageOptions) ElapsedTime() time.Duration
- func (mo MessageOptions) FQDN() *OptFQDN
- func (mo MessageOptions) FourRD() []*Opt4RD
- func (mo MessageOptions) IANA() []*OptIANA
- func (mo MessageOptions) IAPD() []*OptIAPD
- func (mo MessageOptions) IATA() []*OptIATA
- func (mo MessageOptions) InformationRefreshTime(def time.Duration) time.Duration
- func (mo MessageOptions) NTPServers() []net.IP
- func (mo MessageOptions) OneIANA() *OptIANA
- func (mo MessageOptions) OneIAPD() *OptIAPD
- func (mo MessageOptions) OneIATA() *OptIATA
- func (mo MessageOptions) RequestedOptions() OptionCodes
- func (mo MessageOptions) ServerID() DUID
- func (mo MessageOptions) Status() *OptStatusCode
- func (mo MessageOptions) UserClasses() [][]byte
- func (mo MessageOptions) VendorClass(enterpriseNumber uint32) [][]byte
- func (mo MessageOptions) VendorClasses() []*OptVendorClass
- func (mo MessageOptions) VendorOpt(enterpriseNumber uint32) Options
- func (mo MessageOptions) VendorOpts() []*OptVendorOpts
- type MessageType
- type Modifier
- func WithArchType(at iana.Arch) Modifier
- func WithClientID(duid DUID) Modifier
- func WithClientLinkLayerAddress(ht iana.HWType, lla net.HardwareAddr) Modifier
- func WithDHCP4oDHCP6Server(addrs ...net.IP) Modifier
- func WithDNS(dnses ...net.IP) Modifier
- func WithDomainSearchList(searchlist ...string) Modifier
- func WithFQDN(flags uint8, domainname string) Modifier
- func WithIAID(iaid [4]byte) Modifier
- func WithIANA(addrs ...OptIAAddress) Modifier
- func WithIAPD(iaid [4]byte, prefixes ...*OptIAPrefix) Modifier
- func WithIATA(iaid [4]byte, addrs ...OptIAAddress) Modifier
- func WithInformationRefreshTime(irt time.Duration) Modifier
- func WithOption(o Option) Modifier
- func WithRequestedOptions(codes ...OptionCode) Modifier
- func WithServerID(duid DUID) Modifier
- func WithUserClass(uc []byte) Modifier
- type NTPSuboptionMCAddr
- type NTPSuboptionSrvAddr
- type NTPSuboptionSrvFQDN
- type NetworkInterfaceType
- type Opt4RD
- type Opt4RDMapRule
- type Opt4RDNonMapRule
- type OptDHCP4oDHCP6Server
- type OptDHCPv4Msg
- type OptFQDN
- type OptIAAddress
- type OptIANA
- type OptIAPD
- type OptIAPrefix
- type OptIATA
- type OptNTPServer
- type OptNetworkInterfaceID
- type OptRemoteID
- type OptStatusCode
- type OptUserClass
- type OptVendorClass
- type OptVendorOpts
- type Option
- func OptBootFileParam(args ...string) Option
- func OptBootFileURL(url string) Option
- func OptClientArchType(a ...iana.Arch) Option
- func OptClientID(d DUID) Option
- func OptDNS(ip ...net.IP) Option
- func OptDomainSearchList(labels *rfc1035label.Labels) Option
- func OptElapsedTime(dur time.Duration) Option
- func OptInterfaceID(id []byte) Option
- func OptRelayMessage(msg DHCPv6) Option
- func OptRelayPort(port uint16) Option
- func OptRequestedOption(o ...OptionCode) Option
- func OptServerID(d DUID) Option
- func ParseOption(code OptionCode, optData []byte) (Option, error)
- type OptionCode
- type OptionCodes
- type OptionGeneric
- type OptionParser
- type Options
- func (o *Options) Add(option Option)
- func (o *Options) Del(code OptionCode)
- func (o *Options) FromBytes(data []byte) error
- func (o *Options) FromBytesWithParser(data []byte, parser OptionParser) error
- func (o Options) Get(code OptionCode) []Option
- func (o Options) GetOne(code OptionCode) Option
- func (o Options) LongString(spaceIndent int) string
- func (o Options) ToBytes() []byte
- func (o *Options) Update(option Option)
- type PDOptions
- type PrefixOptions
- type RelayMessage
- func (r *RelayMessage) AddOption(option Option)
- func (r *RelayMessage) GetInnerMessage() (*Message, error)
- func (r *RelayMessage) GetOneOption(code OptionCode) Option
- func (r *RelayMessage) GetOption(code OptionCode) []Option
- func (r *RelayMessage) IsRelay() bool
- func (r *RelayMessage) LongString(spaceIndent int) string
- func (r *RelayMessage) String() string
- func (r *RelayMessage) Summary() string
- func (r *RelayMessage) ToBytes() []byte
- func (r *RelayMessage) Type() MessageType
- func (r *RelayMessage) UpdateOption(option Option)
- type RelayOptions
- type TransactionID
Constants ¶
const ( DefaultClientPort = 546 DefaultServerPort = 547 )
Default ports
const ( NTPSuboptionSrvAddrCode = OptionCode(1) NTPSuboptionMCAddrCode = OptionCode(2) NTPSuboptionSrvFQDNCode = OptionCode(3) )
NTPSuboptionSrvAddr is the value of NTP_SUBOPTION_SRV_ADDR according to RFC 5908.
const MessageHeaderSize = 4
const RelayHeaderSize = 34
Variables ¶
var ( AllDHCPRelayAgentsAndServers = net.ParseIP("ff02::1:2") AllDHCPServers = net.ParseIP("ff05::1:3") )
Default multicast groups
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 ¶
GetGlobalAddr returns a global address for the interface
func GetLinkLocalAddr ¶
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 ¶
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 ¶
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 ¶
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 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 ¶
DUIDFromBytes parses a DUID from a byte slice.
type DUIDEN ¶
DUIDEN is a DUID based on enterprise number (RFC 8415 Section 11.3).
type DUIDLL ¶
type DUIDLL struct { HWType iana.HWType LinkLayerAddr net.HardwareAddr }
DUIDLL is a DUID based on link-layer (RFC 8415 Section 11.4).
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).
type DUIDOpaque ¶
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 DUIDUUID ¶
DUIDUUID is a DUID based on UUID (RFC 8415 Section 11.5).
type Duration ¶
Duration is a duration as embedded in IA messages (IAPD, IANA, IATA).
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 ¶
MessageFromBytes parses a DHCPv6 message from a byte stream.
func NewAdvertiseFromSolicit ¶
NewAdvertiseFromSolicit creates a new ADVERTISE packet based on an SOLICIT packet.
func NewMessage ¶
NewMessage creates a new DHCPv6 message with default options
func NewReplyFromMessage ¶
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 ¶
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) GetInnerMessage ¶
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 ¶
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) LongString ¶
LongString prints all options associated with this message.
func (*Message) ToBytes ¶
ToBytes returns the serialized version of this message as defined by RFC 3315, Section 5.
func (*Message) UpdateOption ¶
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.
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.
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 ¶
WithArchType adds an arch type option to the packet
func WithClientID ¶
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 ¶
WithDHCP4oDHCP6Server adds or updates an OptDHCP4oDHCP6Server
func WithDomainSearchList ¶
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 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 ¶
WithInformationRefreshTime adds an optInformationRefreshTime to the DHCPv6 packet using the provided duration
func WithOption ¶
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 ¶
WithServerID adds a client ID option to a DHCPv6 packet
func WithUserClass ¶
WithUserClass adds a user class option to the packet
type NTPSuboptionMCAddr ¶
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 ¶
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 ¶
FromBytes builds an Opt4RD structure from a sequence of bytes. The input data does not include option code and length bytes
func (*Opt4RD) LongString ¶
LongString returns a multi-line human-readable representation of the 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 ¶
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 ¶
OptDHCPv4Msg represents a OptionDHCPv4Msg option
This module defines the OptDHCPv4Msg structure. https://www.ietf.org/rfc/rfc7341.txt
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.
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 ¶
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 ¶
FromBytes builds an OptIANA structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptIANA) LongString ¶
LongString returns a multi-line string representation of IANA data.
type OptIAPD ¶
OptIAPD implements the identity association for prefix delegation option defined by RFC 3633, Section 9.
func (*OptIAPD) FromBytes ¶
FromBytes builds an OptIAPD structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptIAPD) LongString ¶
LongString returns a multi-line string representation of the OptIAPD data
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 ¶
FromBytes builds an OptIATA structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptIATA) LongString ¶
LongString returns a multi-line string representation of IATA data.
type OptNTPServer ¶
type OptNTPServer struct {
Suboptions Options
}
OptNTPServer is an option NTP server as defined by RFC 5908.
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 ¶
func (*OptNetworkInterfaceID) Code() OptionCode
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 ¶
OptRemoteID implemens the Remote ID option as defined by RFC 4649.
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) 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 ¶
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 ¶
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 ¶
OptBootFileParam returns a BootfileParam option as defined in RFC 5970 Section 3.2.
func OptBootFileURL ¶
OptBootFileURL returns a OptionBootfileURL as defined by RFC 5970.
func OptClientArchType ¶
OptClientArchType represents an option CLIENT_ARCH_TYPE.
This module defines the OptClientArchType structure. https://www.ietf.org/rfc/rfc5970.txt
func OptClientID ¶
OptClientID represents a Client Identifier option as defined by RFC 3315 Section 22.2.
func OptDomainSearchList ¶
func OptDomainSearchList(labels *rfc1035label.Labels) Option
OptDomainSearchList returns a DomainSearchList option as defined by RFC 3646.
func OptElapsedTime ¶
OptElapsedTime returns an Elapsed Time option as defined by RFC 3315 Section 22.9.
func OptInterfaceID ¶
OptInterfaceID returns an interface id option as defined by RFC 3315, Section 22.18.
func OptRelayMessage ¶
OptRelayMessage embeds a message in a relay option.
func OptRelayPort ¶
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 ¶
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.
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) Del ¶
func (o *Options) Del(code OptionCode)
Del deletes all options matching the option code.
func (*Options) FromBytes ¶
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 ¶
LongString prints options with indentation of at least spaceIndent spaces.
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.
Source Files ¶
- defaults.go
- dhcpv6.go
- dhcpv6message.go
- dhcpv6relay.go
- duid.go
- iputils.go
- modifiers.go
- option_4rd.go
- option_archtype.go
- option_bootfileparam.go
- option_bootfileurl.go
- option_clientid.go
- option_clientlinklayeraddress.go
- option_dhcpv4_msg.go
- option_dhcpv4_o_dhcpv6_server.go
- option_dns.go
- option_domainsearchlist.go
- option_elapsedtime.go
- option_fqdn.go
- option_iaaddress.go
- option_iapd.go
- option_iaprefix.go
- option_informationrefreshtime.go
- option_interfaceid.go
- option_nii.go
- option_nontemporaryaddress.go
- option_ntp_server.go
- option_relaymsg.go
- option_relayport.go
- option_remoteid.go
- option_requestedoption.go
- option_serverid.go
- option_statuscode.go
- option_temporaryaddress.go
- option_userclass.go
- option_vendor_opts.go
- option_vendorclass.go
- options.go
- types.go