diff options
author | Chris Koch <chrisko@google.com> | 2019-12-28 03:31:44 -0800 |
---|---|---|
committer | Chris K <c@chrisko.ch> | 2020-03-09 15:38:59 -0700 |
commit | a3af88f6782eba884ef5216b987bf4e2a96ff033 (patch) | |
tree | ae4402ecfd66c1fdcbbf8f3175cb90718de3dc29 /dhcpv6/option_interfaceid.go | |
parent | 817408d8cc264703a709f21d90ebe62c10a9b87c (diff) |
v6: getter for InterfaceID on RelayOptions
Signed-off-by: Chris Koch <chrisko@google.com>
Diffstat (limited to 'dhcpv6/option_interfaceid.go')
-rw-r--r-- | dhcpv6/option_interfaceid.go | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/dhcpv6/option_interfaceid.go b/dhcpv6/option_interfaceid.go index 5ed2fba..ce85714 100644 --- a/dhcpv6/option_interfaceid.go +++ b/dhcpv6/option_interfaceid.go @@ -4,39 +4,32 @@ import ( "fmt" ) -// OptInterfaceId implements the interface-id option as defined by RFC 3315, +// OptInterfaceID returns an interface id option as defined by RFC 3315, // Section 22.18. -// -// This module defines the OptInterfaceId structure. -// https://www.ietf.org/rfc/rfc3315.txt -type OptInterfaceId struct { - interfaceId []byte +func OptInterfaceID(id []byte) Option { + return &optInterfaceID{ID: id} } -func (op *OptInterfaceId) Code() OptionCode { - return OptionInterfaceID -} - -func (op *OptInterfaceId) ToBytes() []byte { - return op.interfaceId +type optInterfaceID struct { + ID []byte } -func (op *OptInterfaceId) InterfaceID() []byte { - return op.interfaceId +func (*optInterfaceID) Code() OptionCode { + return OptionInterfaceID } -func (op *OptInterfaceId) SetInterfaceID(interfaceId []byte) { - op.interfaceId = append([]byte(nil), interfaceId...) +func (op *optInterfaceID) ToBytes() []byte { + return op.ID } -func (op *OptInterfaceId) String() string { - return fmt.Sprintf("OptInterfaceId{interfaceid=%v}", op.interfaceId) +func (op *optInterfaceID) String() string { + return fmt.Sprintf("InterfaceID: %v", op.ID) } -// build an OptInterfaceId structure from a sequence of bytes. +// build an optInterfaceID structure from a sequence of bytes. // The input data does not include option code and length bytes. -func ParseOptInterfaceId(data []byte) (*OptInterfaceId, error) { - var opt OptInterfaceId - opt.interfaceId = append([]byte(nil), data...) +func parseOptInterfaceID(data []byte) (*optInterfaceID, error) { + var opt optInterfaceID + opt.ID = append([]byte(nil), data...) return &opt, nil } |