diff options
Diffstat (limited to 'dhcpv6/option_iaprefix.go')
-rw-r--r-- | dhcpv6/option_iaprefix.go | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/dhcpv6/option_iaprefix.go b/dhcpv6/option_iaprefix.go index fc41e0a..f7d3e76 100644 --- a/dhcpv6/option_iaprefix.go +++ b/dhcpv6/option_iaprefix.go @@ -74,31 +74,30 @@ func (op *OptIAPrefix) String() string { op.Code(), op.PreferredLifetime, op.ValidLifetime, op.Prefix, op.Options) } -// ParseOptIAPrefix an OptIAPrefix structure from a sequence of bytes. The -// input data does not include option code and length bytes. -func ParseOptIAPrefix(data []byte) (*OptIAPrefix, error) { +// FromBytes an OptIAPrefix structure from a sequence of bytes. The input data +// does not include option code and length bytes. +func (op *OptIAPrefix) FromBytes(data []byte) error { buf := uio.NewBigEndianBuffer(data) - var opt OptIAPrefix var t1, t2 Duration t1.Unmarshal(buf) t2.Unmarshal(buf) - opt.PreferredLifetime = t1.Duration - opt.ValidLifetime = t2.Duration + op.PreferredLifetime = t1.Duration + op.ValidLifetime = t2.Duration length := buf.Read8() ip := net.IP(buf.CopyN(net.IPv6len)) if length == 0 { - opt.Prefix = nil + op.Prefix = nil } else { - opt.Prefix = &net.IPNet{ + op.Prefix = &net.IPNet{ Mask: net.CIDRMask(int(length), 128), IP: ip, } } - 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() } |