summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/dhcpv4.go
diff options
context:
space:
mode:
authorAndrea Barberio <insomniac@slackware.it>2018-12-08 22:17:28 +0000
committerAndrea Barberio <insomniac@slackware.it>2018-12-08 22:17:28 +0000
commit08c8b272d33662a5448d4b789466a3de79050ed8 (patch)
tree19ba7036e1e57a3f8505a9eb2d7cacbcf9843889 /dhcpv4/dhcpv4.go
parent4dabb19b0ae8c2c0287807d4454eedee46d39a2d (diff)
Added netconf v4 tests and required modifiers
Diffstat (limited to 'dhcpv4/dhcpv4.go')
-rw-r--r--dhcpv4/dhcpv4.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/dhcpv4/dhcpv4.go b/dhcpv4/dhcpv4.go
index 94b8351..2931565 100644
--- a/dhcpv4/dhcpv4.go
+++ b/dhcpv4/dhcpv4.go
@@ -612,6 +612,20 @@ func (d *DHCPv4) AddOption(option Option) {
}
}
+// UpdateOption updates the existing options with the passed option, adding it
+// at the end if not present already
+func (d *DHCPv4) 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)
+}
+
// MessageType returns the message type, trying to extract it from the
// OptMessageType option. It returns nil if the message type cannot be extracted
func (d *DHCPv4) MessageType() *MessageType {