diff options
author | Chris Koch <chrisko@google.com> | 2023-02-18 20:31:32 -0800 |
---|---|---|
committer | Chris K <c@chrisko.ch> | 2023-02-19 22:39:16 -0800 |
commit | 336d4b9bd652b2bf0bc1bd0feae3f2f51009c13f (patch) | |
tree | 9c99ebb8f3067a39981d8bea07109fd7e7ba0d17 /dhcpv6/option_iapd.go | |
parent | 1e0fe5ce427973ca92a0dfb1a06a252ddb0dd4be (diff) |
dhcpv6: convert every Parse function to FromBytes
Signed-off-by: Chris Koch <chrisko@google.com>
Diffstat (limited to 'dhcpv6/option_iapd.go')
-rw-r--r-- | dhcpv6/option_iapd.go | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/dhcpv6/option_iapd.go b/dhcpv6/option_iapd.go index 6296103..d853cea 100644 --- a/dhcpv6/option_iapd.go +++ b/dhcpv6/option_iapd.go @@ -79,21 +79,20 @@ func (op *OptIAPD) LongString(indentSpace int) string { return fmt.Sprintf("%s: IAID=%#x T1=%v T2=%v Options=%v", op.Code(), op.IaId, op.T1, op.T2, op.Options.LongString(indentSpace)) } -// ParseOptIAPD builds an OptIAPD structure from a sequence of bytes. -// The input data does not include option code and length bytes. -func ParseOptIAPD(data []byte) (*OptIAPD, error) { - var opt OptIAPD +// FromBytes builds an OptIAPD structure from a sequence of bytes. The input +// data does not include option code and length bytes. +func (op *OptIAPD) FromBytes(data []byte) error { buf := uio.NewBigEndianBuffer(data) - buf.ReadBytes(opt.IaId[:]) + buf.ReadBytes(op.IaId[:]) var t1, t2 Duration t1.Unmarshal(buf) t2.Unmarshal(buf) - opt.T1 = t1.Duration - opt.T2 = t2.Duration + op.T1 = t1.Duration + op.T2 = t2.Duration - if err := opt.Options.FromBytes(buf.ReadAll()); err != nil { - return nil, err + if err := op.Options.FromBytes(buf.ReadAll()); err != nil { + return err } - return &opt, buf.FinError() + return buf.FinError() } |