summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/option_vendorclass.go
diff options
context:
space:
mode:
authorChris Koch <chrisko@google.com>2023-02-18 20:31:32 -0800
committerChris K <c@chrisko.ch>2023-02-19 22:39:16 -0800
commit336d4b9bd652b2bf0bc1bd0feae3f2f51009c13f (patch)
tree9c99ebb8f3067a39981d8bea07109fd7e7ba0d17 /dhcpv6/option_vendorclass.go
parent1e0fe5ce427973ca92a0dfb1a06a252ddb0dd4be (diff)
dhcpv6: convert every Parse function to FromBytes
Signed-off-by: Chris Koch <chrisko@google.com>
Diffstat (limited to 'dhcpv6/option_vendorclass.go')
-rw-r--r--dhcpv6/option_vendorclass.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/dhcpv6/option_vendorclass.go b/dhcpv6/option_vendorclass.go
index 33297dc..954dbd0 100644
--- a/dhcpv6/option_vendorclass.go
+++ b/dhcpv6/option_vendorclass.go
@@ -39,18 +39,18 @@ func (op *OptVendorClass) String() string {
return fmt.Sprintf("%s: {EnterpriseNumber=%d Data=[%s]}", op.Code(), op.EnterpriseNumber, strings.Join(vcStrings, ", "))
}
-// ParseOptVendorClass builds an OptVendorClass structure from a sequence of
-// bytes. The input data does not include option code and length bytes.
-func ParseOptVendorClass(data []byte) (*OptVendorClass, error) {
- var opt OptVendorClass
+// FromBytes builds an OptVendorClass structure from a sequence of bytes. The
+// input data does not include option code and length bytes.
+func (op *OptVendorClass) FromBytes(data []byte) error {
buf := uio.NewBigEndianBuffer(data)
- opt.EnterpriseNumber = buf.Read32()
+ *op = OptVendorClass{}
+ op.EnterpriseNumber = buf.Read32()
for buf.Has(2) {
len := buf.Read16()
- opt.Data = append(opt.Data, buf.CopyN(int(len)))
+ op.Data = append(op.Data, buf.CopyN(int(len)))
}
- if len(opt.Data) < 1 {
- return nil, errors.New("ParseOptVendorClass: at least one vendor class data is required")
+ if len(op.Data) < 1 {
+ return errors.New("ParseOptVendorClass: at least one vendor class data is required")
}
- return &opt, buf.FinError()
+ return buf.FinError()
}