summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorinsomniac <insomniacslk@users.noreply.github.com>2018-05-02 00:57:57 +0200
committerGitHub <noreply@github.com>2018-05-02 00:57:57 +0200
commit08a6a496134a077cb868adb516c602fa12bb9b1e (patch)
treeb8ddabacacd29bf3523e770973785577fd4890d5
parent18dae087d822c843c2a2252f915f45577ba21df8 (diff)
UpdateOption now adds the option if missing (#55)
-rw-r--r--dhcpv6/dhcpv6message.go4
-rw-r--r--dhcpv6/dhcpv6relay.go4
2 files changed, 6 insertions, 2 deletions
diff --git a/dhcpv6/dhcpv6message.go b/dhcpv6/dhcpv6message.go
index 1ea73f7..0cd34f0 100644
--- a/dhcpv6/dhcpv6message.go
+++ b/dhcpv6/dhcpv6message.go
@@ -280,9 +280,11 @@ func (d *DHCPv6Message) UpdateOption(option Option) {
if opt.Code() == option.Code() {
d.options[idx] = option
// don't look further
- break
+ return
}
}
+ // if not found, add it
+ d.AddOption(option)
}
func (d *DHCPv6Message) String() string {
diff --git a/dhcpv6/dhcpv6relay.go b/dhcpv6/dhcpv6relay.go
index 0ccdf72..68f3cf0 100644
--- a/dhcpv6/dhcpv6relay.go
+++ b/dhcpv6/dhcpv6relay.go
@@ -127,9 +127,11 @@ func (r *DHCPv6Relay) UpdateOption(option Option) {
if opt.Code() == option.Code() {
r.options[idx] = option
// don't look further
- break
+ return
}
}
+ // if not found, add it
+ r.AddOption(option)
}
func (r *DHCPv6Relay) IsRelay() bool {