summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/option_clientid.go
diff options
context:
space:
mode:
authorChris Koch <chrisko@google.com>2019-12-28 00:57:21 -0800
committerinsomniac <insomniacslk@users.noreply.github.com>2020-03-05 15:51:55 +0000
commitc483f8beb41f894c3d9c5adf0781c73ca1fbd7ac (patch)
tree73f0afcf6f50af83220f4f2d67e7edbc2cb71326 /dhcpv6/option_clientid.go
parent8d3e32a40580e3e227f64d9068f84b321e7921b2 (diff)
v6: add ClientID getter
Signed-off-by: Chris Koch <chrisko@google.com>
Diffstat (limited to 'dhcpv6/option_clientid.go')
-rw-r--r--dhcpv6/option_clientid.go31
1 files changed, 13 insertions, 18 deletions
diff --git a/dhcpv6/option_clientid.go b/dhcpv6/option_clientid.go
index 200d1a6..0941bcc 100644
--- a/dhcpv6/option_clientid.go
+++ b/dhcpv6/option_clientid.go
@@ -4,36 +4,31 @@ import (
"fmt"
)
-// OptClientId represents a Client ID option
-//
-// This module defines the OptClientId and DUID structures.
-// https://www.ietf.org/rfc/rfc3315.txt
-type OptClientId struct {
- Cid Duid
+// OptClientID represents a Client Identifier option as defined by RFC 3315
+// Section 22.2.
+func OptClientID(d Duid) Option {
+ return &optClientID{d}
}
-func (op *OptClientId) Code() OptionCode {
- return OptionClientID
+type optClientID struct {
+ Duid
}
-// ToBytes marshals the Client ID option as defined by RFC 3315, Section 22.2.
-func (op *OptClientId) ToBytes() []byte {
- return op.Cid.ToBytes()
+func (*optClientID) Code() OptionCode {
+ return OptionClientID
}
-func (op *OptClientId) String() string {
- return fmt.Sprintf("OptClientId{cid=%v}", op.Cid.String())
+func (op *optClientID) String() string {
+ return fmt.Sprintf("ClientID: %v", op.Duid.String())
}
-// ParseOptClientId builds an OptClientId structure from a sequence
+// parseOptClientID builds an OptClientId structure from a sequence
// of bytes. The input data does not include option code and length
// bytes.
-func ParseOptClientId(data []byte) (*OptClientId, error) {
- var opt OptClientId
+func parseOptClientID(data []byte) (*optClientID, error) {
cid, err := DuidFromBytes(data)
if err != nil {
return nil, err
}
- opt.Cid = *cid
- return &opt, nil
+ return &optClientID{*cid}, nil
}