From 336d4b9bd652b2bf0bc1bd0feae3f2f51009c13f Mon Sep 17 00:00:00 2001 From: Chris Koch Date: Sat, 18 Feb 2023 20:31:32 -0800 Subject: dhcpv6: convert every Parse function to FromBytes Signed-off-by: Chris Koch --- dhcpv6/option_userclass.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'dhcpv6/option_userclass.go') diff --git a/dhcpv6/option_userclass.go b/dhcpv6/option_userclass.go index 00abcbd..643fdd1 100644 --- a/dhcpv6/option_userclass.go +++ b/dhcpv6/option_userclass.go @@ -38,17 +38,16 @@ func (op *OptUserClass) String() string { return fmt.Sprintf("%s: [%s]", op.Code(), strings.Join(ucStrings, ", ")) } -// ParseOptUserClass builds an OptUserClass structure from a sequence of -// bytes. The input data does not include option code and length bytes. -func ParseOptUserClass(data []byte) (*OptUserClass, error) { - var opt OptUserClass +// FromBytes builds an OptUserClass structure from a sequence of bytes. The +// input data does not include option code and length bytes. +func (op *OptUserClass) FromBytes(data []byte) error { if len(data) == 0 { - return nil, fmt.Errorf("user class option must not be empty") + return fmt.Errorf("user class option must not be empty") } buf := uio.NewBigEndianBuffer(data) for buf.Has(2) { len := buf.Read16() - opt.UserClasses = append(opt.UserClasses, buf.CopyN(int(len))) + op.UserClasses = append(op.UserClasses, buf.CopyN(int(len))) } - return &opt, buf.FinError() + return buf.FinError() } -- cgit v1.2.3