summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6
diff options
context:
space:
mode:
authorAndrea Barberio <insomniac@slackware.it>2018-04-17 14:52:26 +0100
committerAndrea Barberio <insomniac@slackware.it>2018-04-17 14:52:26 +0100
commit0aff95a78c91a2983a90e7c964120d480234babf (patch)
tree39aec5c4d750e7253e718ef693c9f943550961e0 /dhcpv6
parent6dcfd842104ff746e0139031540eb84433cb7300 (diff)
dhcpv6: added DHCPv6Message.UpdateOption
Diffstat (limited to 'dhcpv6')
-rw-r--r--dhcpv6/dhcpv6message.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/dhcpv6/dhcpv6message.go b/dhcpv6/dhcpv6message.go
index db29a44..e7e6bda 100644
--- a/dhcpv6/dhcpv6message.go
+++ b/dhcpv6/dhcpv6message.go
@@ -4,10 +4,11 @@ import (
"crypto/rand"
"encoding/binary"
"fmt"
- "github.com/insomniacslk/dhcp/iana"
"log"
"net"
"time"
+
+ "github.com/insomniacslk/dhcp/iana"
)
const MessageHeaderSize = 4
@@ -201,6 +202,16 @@ func (d *DHCPv6Message) AddOption(option Option) {
d.options = append(d.options, option)
}
+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
+ break
+ }
+ }
+}
+
func (d *DHCPv6Message) String() string {
return fmt.Sprintf("DHCPv6Message(messageType=%v transactionID=0x%06x, %d options)",
d.MessageTypeToString(), d.TransactionID(), len(d.options),