From 08a6a496134a077cb868adb516c602fa12bb9b1e Mon Sep 17 00:00:00 2001 From: insomniac Date: Wed, 2 May 2018 00:57:57 +0200 Subject: UpdateOption now adds the option if missing (#55) --- dhcpv6/dhcpv6message.go | 4 +++- dhcpv6/dhcpv6relay.go | 4 +++- 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 { -- cgit v1.2.3