summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/option_iaprefix.go
diff options
context:
space:
mode:
authorChristopher Koch <c@chrisko.ch>2019-01-20 04:05:36 +0000
committerinsomniac <insomniacslk@users.noreply.github.com>2019-01-26 23:34:26 +0000
commit8936b6e4e714e0b682e37fa81fde29606e58e7c2 (patch)
tree25aa6c19674258c391654e52af3dc7db1ba12f7b /dhcpv6/option_iaprefix.go
parent6a9ec900f656439652b2f20e34b2452d561eb0a6 (diff)
dhcpv6: introduce options type.
Diffstat (limited to 'dhcpv6/option_iaprefix.go')
-rw-r--r--dhcpv6/option_iaprefix.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/dhcpv6/option_iaprefix.go b/dhcpv6/option_iaprefix.go
index 8a39531..2f71fb0 100644
--- a/dhcpv6/option_iaprefix.go
+++ b/dhcpv6/option_iaprefix.go
@@ -14,7 +14,7 @@ type OptIAPrefix struct {
ValidLifetime uint32
prefixLength byte
ipv6Prefix net.IP
- Options []Option
+ Options Options
}
func (op *OptIAPrefix) Code() OptionCode {
@@ -70,18 +70,17 @@ func (op *OptIAPrefix) String() string {
// GetOneOption will get an option of the give type from the Options field, if
// it is present. It will return `nil` otherwise
func (op *OptIAPrefix) GetOneOption(code OptionCode) Option {
- return getOption(op.Options, code)
+ return op.Options.GetOne(code)
}
// DelOption will remove all the options that match a Option code.
func (op *OptIAPrefix) DelOption(code OptionCode) {
- op.Options = delOption(op.Options, code)
+ op.Options.Del(code)
}
// build 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) {
- var err error
opt := OptIAPrefix{}
if len(data) < 25 {
return nil, fmt.Errorf("Invalid IA for Prefix Delegation data length. Expected at least 25 bytes, got %v", len(data))
@@ -90,8 +89,7 @@ func ParseOptIAPrefix(data []byte) (*OptIAPrefix, error) {
opt.ValidLifetime = binary.BigEndian.Uint32(data[4:8])
opt.prefixLength = data[8]
opt.ipv6Prefix = net.IP(data[9:25])
- opt.Options, err = OptionsFromBytes(data[25:])
- if err != nil {
+ if err := opt.Options.FromBytes(data[25:]); err != nil {
return nil, err
}
return &opt, nil