Documentation
¶
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 IsUsingUEFI(msg *Message) bool
- func WithNetboot(d DHCPv6)
- func WithRapidCommit(d DHCPv6)
- type DHCPv6
- type Duid
- type DuidType
- 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) String() string
- func (m *Message) Summary() string
- func (m *Message) ToBytes() []byte
- func (m Message) Type() MessageType
- func (m *Message) UpdateOption(option Option)
- type MessageType
- type Modifier
- func WithArchType(at iana.Arch) Modifier
- func WithClientID(duid Duid) Modifier
- func WithDNS(dnses ...net.IP) Modifier
- func WithDomainSearchList(searchlist ...string) Modifier
- func WithIAID(iaid [4]byte) Modifier
- func WithIANA(addrs ...OptIAAddress) Modifier
- func WithRequestedOptions(optionCodes ...OptionCode) Modifier
- func WithServerID(duid Duid) Modifier
- func WithUserClass(uc []byte) Modifier
- type Opt4RD
- type Opt4RDMapRule
- type Opt4RDNonMapRule
- type OptBootFileURL
- type OptClientArchType
- type OptClientId
- type OptDNSRecursiveNameServer
- type OptDomainSearchList
- type OptElapsedTime
- type OptIAAddress
- type OptIAForPrefixDelegation
- type OptIANA
- type OptIAPrefix
- func (op *OptIAPrefix) Code() OptionCode
- func (op *OptIAPrefix) DelOption(code OptionCode)
- func (op *OptIAPrefix) GetOneOption(code OptionCode) Option
- func (op *OptIAPrefix) IPv6Prefix() net.IP
- func (op *OptIAPrefix) PrefixLength() byte
- func (op *OptIAPrefix) SetIPv6Prefix(p net.IP)
- func (op *OptIAPrefix) SetPrefixLength(pl byte)
- func (op *OptIAPrefix) String() string
- func (op *OptIAPrefix) ToBytes() []byte
- type OptInterfaceId
- type OptNetworkInterfaceId
- func (op *OptNetworkInterfaceId) Code() OptionCode
- func (op *OptNetworkInterfaceId) Major() uint8
- func (op *OptNetworkInterfaceId) Minor() uint8
- func (op *OptNetworkInterfaceId) SetMajor(major uint8)
- func (op *OptNetworkInterfaceId) SetMinor(minor uint8)
- func (op *OptNetworkInterfaceId) SetType(type_ uint8)
- func (op *OptNetworkInterfaceId) String() string
- func (op *OptNetworkInterfaceId) ToBytes() []byte
- func (op *OptNetworkInterfaceId) Type() uint8
- type OptRelayMsg
- type OptRemoteId
- func (op *OptRemoteId) Code() OptionCode
- func (op *OptRemoteId) EnterpriseNumber() uint32
- func (op *OptRemoteId) RemoteID() []byte
- func (op *OptRemoteId) SetEnterpriseNumber(enterpriseNumber uint32)
- func (op *OptRemoteId) SetRemoteID(remoteId []byte)
- func (op *OptRemoteId) String() string
- func (op *OptRemoteId) ToBytes() []byte
- type OptRequestedOption
- func (op *OptRequestedOption) AddRequestedOption(opt OptionCode)
- func (op *OptRequestedOption) Code() OptionCode
- func (op *OptRequestedOption) RequestedOptions() []OptionCode
- func (op *OptRequestedOption) SetRequestedOptions(opts []OptionCode)
- func (op *OptRequestedOption) String() string
- func (op *OptRequestedOption) ToBytes() []byte
- type OptServerId
- type OptStatusCode
- type OptUserClass
- type OptVendorClass
- type OptVendorOpts
- type Option
- type OptionCode
- 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) ToBytes() []byte
- func (o *Options) Update(option Option)
- 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) String() string
- func (r *RelayMessage) Summary() string
- func (r *RelayMessage) ToBytes() []byte
- func (r *RelayMessage) Type() MessageType
- func (r *RelayMessage) UpdateOption(option Option)
- type TransactionID
Constants ¶
const ( DefaultClientPort = 546 DefaultServerPort = 547 )
Default ports
const ( NII_LANDESK_NOPXE = 0 NII_PXE_GEN_I = 1 NII_PXE_GEN_II = 2 NII_UNDI_NOEFI = 3 NII_UNDI_EFI_GEN_I = 4 NII_UNDI_EFI_GEN_II = 5 )
see rfc4578
const MessageHeaderSize = 4
const RelayHeaderSize = 34
Variables ¶
var ( AllDHCPRelayAgentsAndServers = net.ParseIP("ff02::1:2") AllDHCPServers = net.ParseIP("ff05::1:3") )
Default multicast groups
var DuidTypeToString = map[DuidType]string{ DUID_LL: "DUID-LL", DUID_LLT: "DUID-LLT", DUID_EN: "DUID-EN", DUID_UUID: "DUID-UUID", }
DuidTypeToString maps a DuidType to a name.
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 IsUsingUEFI ¶
IsUsingUEFI function takes a DHCPv6 message and returns true if the machine trying to netboot is using UEFI of false if it is not.
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 DHCPv6 ¶
type DHCPv6 interface { Type() MessageType ToBytes() []byte String() string Summary() 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 struct { Type DuidType HwType iana.HWType // for DUID-LLT and DUID-LL. Ignored otherwise. RFC 826 Time uint32 // for DUID-LLT. Ignored otherwise LinkLayerAddr net.HardwareAddr EnterpriseNumber uint32 // for DUID-EN. Ignored otherwise EnterpriseIdentifier []byte // for DUID-EN. Ignored otherwise Uuid []byte // for DUID-UUID. Ignored otherwise Opaque []byte // for unknown DUIDs }
Duid is a DHCP Unique Identifier.
func DuidFromBytes ¶
DuidFromBytes parses a Duid from a byte slice.
type Message ¶
type Message struct { MessageType MessageType TransactionID TransactionID Options Options }
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) 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 MessageType ¶
type MessageType uint8
MessageType represents the kind of DHCPv6 message.
const ( // MessageTypeNone is used internally and is not part of the RFC. MessageTypeNone MessageType = 0 MessageTypeSolicit MessageType = 1 MessageTypeAdvertise MessageType = 2 MessageTypeRequest MessageType = 3 MessageTypeConfirm MessageType = 4 MessageTypeRenew MessageType = 5 MessageTypeRebind MessageType = 6 MessageTypeReply MessageType = 7 MessageTypeRelease MessageType = 8 MessageTypeDecline MessageType = 9 MessageTypeReconfigure MessageType = 10 MessageTypeInformationRequest MessageType = 11 MessageTypeRelayForward MessageType = 12 MessageTypeRelayReply MessageType = 13 MessageTypeLeaseQuery MessageType = 14 MessageTypeLeaseQueryReply MessageType = 15 MessageTypeLeaseQueryDone MessageType = 16 MessageTypeLeaseQueryData MessageType = 17 )
The DHCPv6 message types defined per RFC 3315, Section 5.3.
func (MessageType) String ¶
func (m MessageType) String() string
String prints the message type name.
type Modifier ¶
type Modifier func(d DHCPv6)
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 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 WithRequestedOptions ¶
func WithRequestedOptions(optionCodes ...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 Opt4RD ¶
type Opt4RD Options
Opt4RD represents a 4RD option. It is only a container for 4RD_*_RULE options
func ParseOpt4RD ¶
ParseOpt4RD builds an Opt4RD structure from a sequence of bytes. The input data does not include option code and length bytes
func (*Opt4RD) Code ¶
func (op *Opt4RD) Code() OptionCode
Code returns the Option Code for this option
type Opt4RDMapRule ¶
type Opt4RDMapRule struct { // Prefix4 is the IPv4 prefix mapped by this rule Prefix4 net.IPNet // Prefix6 is the IPv6 prefix mapped by this rule Prefix6 net.IPNet // EABitsLength is the number of bits of an address used in constructing the mapped address EABitsLength uint8 // WKPAuthorized determines if well-known ports are assigned to addresses in an A+P mapping // It can only be set if the length of Prefix4 + EABits > 32 WKPAuthorized bool }
Opt4RDMapRule represents a 4RD Mapping Rule option The option is described in https://tools.ietf.org/html/rfc7600#section-4.9 The 4RD mapping rules are described in https://tools.ietf.org/html/rfc7600#section-4.2
func ParseOpt4RDMapRule ¶
func ParseOpt4RDMapRule(data []byte) (*Opt4RDMapRule, error)
ParseOpt4RDMapRule builds an Opt4RDMapRule structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*Opt4RDMapRule) Code ¶
func (op *Opt4RDMapRule) Code() OptionCode
Code returns the option code representing this option
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 ParseOpt4RDNonMapRule ¶
func ParseOpt4RDNonMapRule(data []byte) (*Opt4RDNonMapRule, error)
ParseOpt4RDNonMapRule builds an Opt4RDNonMapRule structure from a sequence of bytes. The input data does not include option code and length bytes
func (*Opt4RDNonMapRule) Code ¶
func (op *Opt4RDNonMapRule) Code() OptionCode
Code returns the option code for this option
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 OptBootFileURL ¶
type OptBootFileURL string
OptBootFileURL implements the OptionBootfileURL option
This module defines the OptBootFileURL structure. https://www.ietf.org/rfc/rfc5970.txt
func ParseOptBootFileURL ¶
func ParseOptBootFileURL(data []byte) (OptBootFileURL, error)
ParseOptBootFileURL builds an OptBootFileURL structure from a sequence of bytes. The input data does not include option code and length bytes.
func (OptBootFileURL) Code ¶
func (op OptBootFileURL) Code() OptionCode
Code returns the option code
func (OptBootFileURL) String ¶
func (op OptBootFileURL) String() string
func (OptBootFileURL) ToBytes ¶
func (op OptBootFileURL) ToBytes() []byte
ToBytes serializes the option and returns it as a sequence of bytes
type OptClientArchType ¶
OptClientArchType represents an option CLIENT_ARCH_TYPE
This module defines the OptClientArchType structure. https://www.ietf.org/rfc/rfc5970.txt
func ParseOptClientArchType ¶
func ParseOptClientArchType(data []byte) (*OptClientArchType, error)
ParseOptClientArchType builds an OptClientArchType structure from a sequence of bytes The input data does not include option code and length bytes.
func (*OptClientArchType) Code ¶
func (op *OptClientArchType) Code() OptionCode
func (*OptClientArchType) String ¶
func (op *OptClientArchType) String() string
func (*OptClientArchType) ToBytes ¶
func (op *OptClientArchType) ToBytes() []byte
ToBytes marshals the client arch type as defined by RFC 5970.
type OptClientId ¶
type OptClientId struct {
Cid Duid
}
OptClientId represents a Client ID option
This module defines the OptClientId and DUID structures. https://www.ietf.org/rfc/rfc3315.txt
func ParseOptClientId ¶
func ParseOptClientId(data []byte) (*OptClientId, error)
ParseOptClientId builds an OptClientId structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptClientId) Code ¶
func (op *OptClientId) Code() OptionCode
func (*OptClientId) String ¶
func (op *OptClientId) String() string
func (*OptClientId) ToBytes ¶
func (op *OptClientId) ToBytes() []byte
ToBytes marshals the Client ID option as defined by RFC 3315, Section 22.2.
type OptDNSRecursiveNameServer ¶
OptDNSRecursiveNameServer represents a OptionDNSRecursiveNameServer option
This module defines the OptDNSRecursiveNameServer structure. https://www.ietf.org/rfc/rfc3646.txt
func ParseOptDNSRecursiveNameServer ¶
func ParseOptDNSRecursiveNameServer(data []byte) (*OptDNSRecursiveNameServer, error)
ParseOptDNSRecursiveNameServer builds an OptDNSRecursiveNameServer structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptDNSRecursiveNameServer) Code ¶
func (op *OptDNSRecursiveNameServer) Code() OptionCode
Code returns the option code
func (*OptDNSRecursiveNameServer) String ¶
func (op *OptDNSRecursiveNameServer) String() string
func (*OptDNSRecursiveNameServer) ToBytes ¶
func (op *OptDNSRecursiveNameServer) ToBytes() []byte
ToBytes returns the option serialized to bytes.
type OptDomainSearchList ¶
type OptDomainSearchList struct {
DomainSearchList *rfc1035label.Labels
}
OptDomainSearchList list implements a OptionDomainSearchList option
This module defines the OptDomainSearchList structure. https://www.ietf.org/rfc/rfc3646.txt
func ParseOptDomainSearchList ¶
func ParseOptDomainSearchList(data []byte) (*OptDomainSearchList, error)
ParseOptDomainSearchList builds an OptDomainSearchList structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptDomainSearchList) Code ¶
func (op *OptDomainSearchList) Code() OptionCode
func (*OptDomainSearchList) String ¶
func (op *OptDomainSearchList) String() string
func (*OptDomainSearchList) ToBytes ¶
func (op *OptDomainSearchList) ToBytes() []byte
ToBytes marshals this option to bytes.
type OptElapsedTime ¶
type OptElapsedTime struct {
ElapsedTime uint16
}
OptElapsedTime implements the Elapsed Time option.
This module defines the OptElapsedTime structure. https://www.ietf.org/rfc/rfc3315.txt
func ParseOptElapsedTime ¶
func ParseOptElapsedTime(data []byte) (*OptElapsedTime, error)
build an OptElapsedTime structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptElapsedTime) Code ¶
func (op *OptElapsedTime) Code() OptionCode
func (*OptElapsedTime) String ¶
func (op *OptElapsedTime) String() string
func (*OptElapsedTime) ToBytes ¶
func (op *OptElapsedTime) ToBytes() []byte
ToBytes marshals this option to bytes.
type OptIAAddress ¶
type OptIAAddress struct { IPv6Addr net.IP PreferredLifetime uint32 ValidLifetime uint32 Options Options }
OptIAAddress represents an OptionIAAddr.
This module defines the OptIAAddress structure. https://www.ietf.org/rfc/rfc3633.txt
func ParseOptIAAddress ¶
func ParseOptIAAddress(data []byte) (*OptIAAddress, error)
ParseOptIAAddress builds an OptIAAddress structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptIAAddress) Code ¶
func (op *OptIAAddress) Code() OptionCode
Code returns the option's code
func (*OptIAAddress) String ¶
func (op *OptIAAddress) String() string
func (*OptIAAddress) ToBytes ¶
func (op *OptIAAddress) ToBytes() []byte
ToBytes serializes the option and returns it as a sequence of bytes
type OptIAForPrefixDelegation ¶
OptIAForPrefixDelegation implements the identity association for prefix delegation option defined by RFC 3633, Section 9.
func ParseOptIAForPrefixDelegation ¶
func ParseOptIAForPrefixDelegation(data []byte) (*OptIAForPrefixDelegation, error)
build an OptIAForPrefixDelegation structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptIAForPrefixDelegation) Code ¶
func (op *OptIAForPrefixDelegation) Code() OptionCode
Code returns the option code
func (*OptIAForPrefixDelegation) DelOption ¶
func (op *OptIAForPrefixDelegation) DelOption(code OptionCode)
DelOption will remove all the options that match a Option code.
func (*OptIAForPrefixDelegation) GetOneOption ¶
func (op *OptIAForPrefixDelegation) GetOneOption(code OptionCode) Option
GetOneOption will get an option of the give type from the Options field, if it is present. It will return `nil` otherwise
func (*OptIAForPrefixDelegation) String ¶
func (op *OptIAForPrefixDelegation) String() string
String returns a string representation of the OptIAForPrefixDelegation data
func (*OptIAForPrefixDelegation) ToBytes ¶
func (op *OptIAForPrefixDelegation) ToBytes() []byte
ToBytes serializes the option and returns it as a sequence of bytes
type OptIANA ¶
OptIANA implements the identity association for non-temporary addresses option.
This module defines the OptIANA structure. https://www.ietf.org/rfc/rfc3633.txt
func ParseOptIANA ¶
ParseOptIANA builds an OptIANA structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptIANA) Code ¶
func (op *OptIANA) Code() OptionCode
func (*OptIANA) DelOption ¶
func (op *OptIANA) DelOption(code OptionCode)
DelOption will remove all the options that match a Option code.
func (*OptIANA) GetOneOption ¶
func (op *OptIANA) GetOneOption(code OptionCode) Option
GetOneOption will get an option of the give type from the Options field, if it is present. It will return `nil` otherwise
type OptIAPrefix ¶
type OptIAPrefix struct { PreferredLifetime uint32 ValidLifetime uint32 Options Options // contains filtered or unexported fields }
OptIAPrefix implements the IAPrefix option.
This module defines the OptIAPrefix structure. https://www.ietf.org/rfc/rfc3633.txt
func ParseOptIAPrefix ¶
func ParseOptIAPrefix(data []byte) (*OptIAPrefix, error)
ParseOptIAPrefix an OptIAPrefix structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptIAPrefix) Code ¶
func (op *OptIAPrefix) Code() OptionCode
func (*OptIAPrefix) DelOption ¶
func (op *OptIAPrefix) DelOption(code OptionCode)
DelOption will remove all the options that match a Option code.
func (*OptIAPrefix) GetOneOption ¶
func (op *OptIAPrefix) GetOneOption(code OptionCode) Option
GetOneOption will get an option of the give type from the Options field, if it is present. It will return `nil` otherwise
func (*OptIAPrefix) IPv6Prefix ¶
func (op *OptIAPrefix) IPv6Prefix() net.IP
IPv6Prefix returns the ipv6Prefix
func (*OptIAPrefix) PrefixLength ¶
func (op *OptIAPrefix) PrefixLength() byte
func (*OptIAPrefix) SetIPv6Prefix ¶
func (op *OptIAPrefix) SetIPv6Prefix(p net.IP)
SetIPv6Prefix sets the ipv6Prefix
func (*OptIAPrefix) SetPrefixLength ¶
func (op *OptIAPrefix) SetPrefixLength(pl byte)
func (*OptIAPrefix) String ¶
func (op *OptIAPrefix) String() string
func (*OptIAPrefix) ToBytes ¶
func (op *OptIAPrefix) ToBytes() []byte
ToBytes marshals this option according to RFC 3633, Section 10.
type OptInterfaceId ¶
type OptInterfaceId struct {
// contains filtered or unexported fields
}
OptInterfaceId implements the interface-id option as defined by RFC 3315, Section 22.18.
This module defines the OptInterfaceId structure. https://www.ietf.org/rfc/rfc3315.txt
func ParseOptInterfaceId ¶
func ParseOptInterfaceId(data []byte) (*OptInterfaceId, error)
build an OptInterfaceId structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptInterfaceId) Code ¶
func (op *OptInterfaceId) Code() OptionCode
func (*OptInterfaceId) InterfaceID ¶
func (op *OptInterfaceId) InterfaceID() []byte
func (*OptInterfaceId) SetInterfaceID ¶
func (op *OptInterfaceId) SetInterfaceID(interfaceId []byte)
func (*OptInterfaceId) String ¶
func (op *OptInterfaceId) String() string
func (*OptInterfaceId) ToBytes ¶
func (op *OptInterfaceId) ToBytes() []byte
type OptNetworkInterfaceId ¶
type OptNetworkInterfaceId struct {
// contains filtered or unexported fields
}
OptNetworkInterfaceId implements the NIC ID option for network booting as defined by RFC 4578 Section 2.2 and RFC 5970 Section 3.4.
func ParseOptNetworkInterfaceId ¶
func ParseOptNetworkInterfaceId(data []byte) (*OptNetworkInterfaceId, error)
build an OptNetworkInterfaceId structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptNetworkInterfaceId) Code ¶
func (op *OptNetworkInterfaceId) Code() OptionCode
func (*OptNetworkInterfaceId) Major ¶
func (op *OptNetworkInterfaceId) Major() uint8
func (*OptNetworkInterfaceId) Minor ¶
func (op *OptNetworkInterfaceId) Minor() uint8
func (*OptNetworkInterfaceId) SetMajor ¶
func (op *OptNetworkInterfaceId) SetMajor(major uint8)
func (*OptNetworkInterfaceId) SetMinor ¶
func (op *OptNetworkInterfaceId) SetMinor(minor uint8)
func (*OptNetworkInterfaceId) SetType ¶
func (op *OptNetworkInterfaceId) SetType(type_ uint8)
func (*OptNetworkInterfaceId) String ¶
func (op *OptNetworkInterfaceId) String() string
func (*OptNetworkInterfaceId) ToBytes ¶
func (op *OptNetworkInterfaceId) ToBytes() []byte
func (*OptNetworkInterfaceId) Type ¶
func (op *OptNetworkInterfaceId) Type() uint8
type OptRelayMsg ¶
type OptRelayMsg struct {
// contains filtered or unexported fields
}
func ParseOptRelayMsg ¶
func ParseOptRelayMsg(data []byte) (*OptRelayMsg, error)
build an OptRelayMsg structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptRelayMsg) Code ¶
func (op *OptRelayMsg) Code() OptionCode
func (*OptRelayMsg) RelayMessage ¶
func (op *OptRelayMsg) RelayMessage() DHCPv6
func (*OptRelayMsg) SetRelayMessage ¶
func (op *OptRelayMsg) SetRelayMessage(relayMessage DHCPv6)
func (*OptRelayMsg) String ¶
func (op *OptRelayMsg) String() string
func (*OptRelayMsg) ToBytes ¶
func (op *OptRelayMsg) ToBytes() []byte
type OptRemoteId ¶
type OptRemoteId struct {
// contains filtered or unexported fields
}
OptRemoteId implemens the Remote ID option.
https://www.ietf.org/rfc/rfc4649.txt
func ParseOptRemoteId ¶
func ParseOptRemoteId(data []byte) (*OptRemoteId, error)
ParseOptRemoteId builds an OptRemoteId structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptRemoteId) Code ¶
func (op *OptRemoteId) Code() OptionCode
func (*OptRemoteId) EnterpriseNumber ¶
func (op *OptRemoteId) EnterpriseNumber() uint32
func (*OptRemoteId) RemoteID ¶
func (op *OptRemoteId) RemoteID() []byte
func (*OptRemoteId) SetEnterpriseNumber ¶
func (op *OptRemoteId) SetEnterpriseNumber(enterpriseNumber uint32)
func (*OptRemoteId) SetRemoteID ¶
func (op *OptRemoteId) SetRemoteID(remoteId []byte)
func (*OptRemoteId) String ¶
func (op *OptRemoteId) String() string
func (*OptRemoteId) ToBytes ¶
func (op *OptRemoteId) ToBytes() []byte
ToBytes serializes this option to a byte stream.
type OptRequestedOption ¶
type OptRequestedOption struct {
// contains filtered or unexported fields
}
OptRequestedOption implements the requested options option.
This module defines the OptRequestedOption structure. https://www.ietf.org/rfc/rfc3315.txt
func ParseOptRequestedOption ¶
func ParseOptRequestedOption(data []byte) (*OptRequestedOption, error)
build an OptRequestedOption structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptRequestedOption) AddRequestedOption ¶
func (op *OptRequestedOption) AddRequestedOption(opt OptionCode)
func (*OptRequestedOption) Code ¶
func (op *OptRequestedOption) Code() OptionCode
func (*OptRequestedOption) RequestedOptions ¶
func (op *OptRequestedOption) RequestedOptions() []OptionCode
func (*OptRequestedOption) SetRequestedOptions ¶
func (op *OptRequestedOption) SetRequestedOptions(opts []OptionCode)
func (*OptRequestedOption) String ¶
func (op *OptRequestedOption) String() string
func (*OptRequestedOption) ToBytes ¶
func (op *OptRequestedOption) ToBytes() []byte
type OptServerId ¶
type OptServerId struct {
Sid Duid
}
OptServerId represents a Server ID option
This module defines the OptServerId and DUID structures. https://www.ietf.org/rfc/rfc3315.txt
func ParseOptServerId ¶
func ParseOptServerId(data []byte) (*OptServerId, error)
ParseOptServerId builds an OptServerId structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptServerId) Code ¶
func (op *OptServerId) Code() OptionCode
func (*OptServerId) String ¶
func (op *OptServerId) String() string
func (*OptServerId) ToBytes ¶
func (op *OptServerId) ToBytes() []byte
ToBytes serializes this option.
type OptStatusCode ¶
type OptStatusCode struct { StatusCode iana.StatusCode StatusMessage []byte }
OptStatusCode represents a DHCPv6 Status Code option
This module defines the OptStatusCode structure. https://www.ietf.org/rfc/rfc3315.txt
func ParseOptStatusCode ¶
func ParseOptStatusCode(data []byte) (*OptStatusCode, error)
ParseOptStatusCode builds an OptStatusCode structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptStatusCode) Code ¶
func (op *OptStatusCode) Code() OptionCode
Code returns the option code
func (*OptStatusCode) String ¶
func (op *OptStatusCode) String() string
func (*OptStatusCode) ToBytes ¶
func (op *OptStatusCode) ToBytes() []byte
ToBytes serializes the option and returns it as a sequence of bytes
type OptUserClass ¶
type OptUserClass struct {
UserClasses [][]byte
}
OptUserClass represent a DHCPv6 User Class option
This module defines the OptUserClass structure. https://www.ietf.org/rfc/rfc3315.txt
func ParseOptUserClass ¶
func ParseOptUserClass(data []byte) (*OptUserClass, error)
ParseOptUserClass builds an OptUserClass structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptUserClass) 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 ParseOptVendorClass ¶
func ParseOptVendorClass(data []byte) (*OptVendorClass, error)
ParseOptVendorClass builds an OptVendorClass structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptVendorClass) Code ¶
func (op *OptVendorClass) Code() OptionCode
Code returns the option code
func (*OptVendorClass) String ¶
func (op *OptVendorClass) String() string
String returns a string representation of the VendorClass data
func (*OptVendorClass) ToBytes ¶
func (op *OptVendorClass) ToBytes() []byte
ToBytes serializes the option and returns it as a sequence of bytes
type OptVendorOpts ¶
OptVendorOpts represents a DHCPv6 Status Code option
This module defines the OptVendorOpts structure. https://tools.ietf.org/html/rfc3315#section-22.17
func ParseOptVendorOpts ¶
func ParseOptVendorOpts(data []byte) (*OptVendorOpts, error)
ParseOptVendorOpts builds an OptVendorOpts structure from a sequence of bytes. The input data does not include option code and length bytes.
func (*OptVendorOpts) Code ¶
func (op *OptVendorOpts) Code() OptionCode
Code returns the option code
func (*OptVendorOpts) String ¶
func (op *OptVendorOpts) String() string
String returns a string representation of the VendorOpts data
func (*OptVendorOpts) ToBytes ¶
func (op *OptVendorOpts) ToBytes() []byte
ToBytes serializes the option and returns it as a sequence of bytes
type Option ¶
type Option interface { Code() OptionCode ToBytes() []byte String() string }
Option is an interface that all DHCPv6 options adhere to.
func ParseOption ¶
func ParseOption(code OptionCode, optData []byte) (Option, error)
ParseOption parses data according to the given code.
type OptionCode ¶
type OptionCode uint16
OptionCode is a single byte representing the code for a given Option.
const ( OptionClientID OptionCode = 1 OptionServerID OptionCode = 2 OptionIANA OptionCode = 3 OptionIATA OptionCode = 4 OptionIAAddr OptionCode = 5 OptionORO OptionCode = 6 OptionPreference OptionCode = 7 OptionElapsedTime OptionCode = 8 OptionRelayMsg OptionCode = 9 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 OptionGeneric ¶
type OptionGeneric struct { OptionCode OptionCode OptionData []byte }
func (*OptionGeneric) Code ¶
func (og *OptionGeneric) Code() OptionCode
func (*OptionGeneric) String ¶
func (og *OptionGeneric) String() string
func (*OptionGeneric) ToBytes ¶
func (og *OptionGeneric) ToBytes() []byte
type OptionParser ¶
type OptionParser func(code OptionCode, data []byte) (Option, error)
OptionParser is a function signature for option parsing
type Options ¶
type Options []Option
Options is a collection of options.
func (*Options) 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.
type RelayMessage ¶
type RelayMessage struct { MessageType MessageType HopCount uint8 LinkAddr net.IP PeerAddr net.IP Options Options }
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) 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 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_bootfileurl.go
- option_clientid.go
- option_dnsrecursivenameserver.go
- option_domainsearchlist.go
- option_elapsedtime.go
- option_iaaddress.go
- option_iaprefix.go
- option_interfaceid.go
- option_nii.go
- option_nontemporaryaddress.go
- option_prefixdelegation.go
- option_relaymsg.go
- option_remoteid.go
- option_requestedoption.go
- option_serverid.go
- option_statuscode.go
- option_userclass.go
- option_vendor_opts.go
- option_vendorclass.go
- options.go
- types.go