diff options
Diffstat (limited to 'dhcpv6/modifiers.go')
-rw-r--r-- | dhcpv6/modifiers.go | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/dhcpv6/modifiers.go b/dhcpv6/modifiers.go index be4c367..af5e6a8 100644 --- a/dhcpv6/modifiers.go +++ b/dhcpv6/modifiers.go @@ -72,30 +72,32 @@ func WithArchType(at iana.Arch) Modifier { // options func WithIANA(addrs ...OptIAAddress) Modifier { return func(d DHCPv6) { - opt := d.GetOneOption(OptionIANA) - if opt == nil { - opt = &OptIANA{} - } - iaNa := opt.(*OptIANA) - for _, addr := range addrs { - iaNa.AddOption(&addr) + if msg, ok := d.(*Message); ok { + iana := msg.Options.OneIANA() + if iana == nil { + iana = &OptIANA{} + } + for _, addr := range addrs { + iana.AddOption(&addr) + } + msg.UpdateOption(iana) } - d.UpdateOption(iaNa) } } // WithIAID updates an OptIANA option with the provided IAID func WithIAID(iaid [4]byte) Modifier { return func(d DHCPv6) { - opt := d.GetOneOption(OptionIANA) - if opt == nil { - opt = &OptIANA{ - Options: Options{}, + if msg, ok := d.(*Message); ok { + iana := msg.Options.OneIANA() + if iana == nil { + iana = &OptIANA{ + Options: Options{}, + } } + copy(iana.IaId[:], iaid[:]) + d.UpdateOption(iana) } - iaNa := opt.(*OptIANA) - copy(iaNa.IaId[:], iaid[:]) - d.UpdateOption(iaNa) } } |