summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/dhcpv6message.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/dhcpv6message.go
parent6a9ec900f656439652b2f20e34b2452d561eb0a6 (diff)
dhcpv6: introduce options type.
Diffstat (limited to 'dhcpv6/dhcpv6message.go')
-rw-r--r--dhcpv6/dhcpv6message.go18
1 files changed, 5 insertions, 13 deletions
diff --git a/dhcpv6/dhcpv6message.go b/dhcpv6/dhcpv6message.go
index a95d9ce..abccf43 100644
--- a/dhcpv6/dhcpv6message.go
+++ b/dhcpv6/dhcpv6message.go
@@ -17,7 +17,7 @@ const MessageHeaderSize = 4
type DHCPv6Message struct {
messageType MessageType
transactionID uint32 // only 24 bits are used though
- options []Option
+ options Options
}
func BytesToTransactionID(data []byte) (*uint32, error) {
@@ -277,21 +277,13 @@ func (d *DHCPv6Message) SetOptions(options []Option) {
}
func (d *DHCPv6Message) AddOption(option Option) {
- d.options = append(d.options, option)
+ d.options.Add(option)
}
// UpdateOption updates the existing options with the passed option, adding it
// at the end if not present already
func (d *DHCPv6Message) UpdateOption(option Option) {
- for idx, opt := range d.options {
- if opt.Code() == option.Code() {
- d.options[idx] = option
- // don't look further
- return
- }
- }
- // if not found, add it
- d.AddOption(option)
+ d.options.Update(option)
}
// IsNetboot returns true if the machine is trying to netboot. It checks if
@@ -373,11 +365,11 @@ func (d *DHCPv6Message) Options() []Option {
}
func (d *DHCPv6Message) GetOption(code OptionCode) []Option {
- return getOptions(d.options, code, false)
+ return d.options.Get(code)
}
func (d *DHCPv6Message) GetOneOption(code OptionCode) Option {
- return getOption(d.options, code)
+ return d.options.GetOne(code)
}
func (d *DHCPv6Message) IsRelay() bool {