diff options
author | Chris Koch <chrisko@google.com> | 2019-12-28 05:55:41 -0800 |
---|---|---|
committer | Chris K <c@chrisko.ch> | 2020-03-11 13:52:51 -0700 |
commit | eed709df9494fb0c994e41d7b8360a2f1b137b6e (patch) | |
tree | edccc9faea9f1a18b73167edf39932714f8e2096 /dhcpv6/modifiers.go | |
parent | 4d26b5e0b42f27fa41d872b15a7d2bc867787975 (diff) |
v6: introduce Prefix options
IAPD has PDOptions which allows IAPrefix and StatusCode.
IAPrefix has PrefixOptions which allow StatusCode.
Signed-off-by: Chris Koch <chrisko@google.com>
Diffstat (limited to 'dhcpv6/modifiers.go')
-rw-r--r-- | dhcpv6/modifiers.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/dhcpv6/modifiers.go b/dhcpv6/modifiers.go index 95f49d1..96fbf4b 100644 --- a/dhcpv6/modifiers.go +++ b/dhcpv6/modifiers.go @@ -33,7 +33,7 @@ func WithNetboot(d DHCPv6) { func WithFQDN(flags uint8, domainname string) Modifier { return func(d DHCPv6) { d.UpdateOption(&OptFQDN{ - Flags: flags, + Flags: flags, DomainName: &rfc1035label.Labels{ Labels: []string{domainname}, }, @@ -136,19 +136,19 @@ func WithDHCP4oDHCP6Server(addrs ...net.IP) Modifier { // WithIAPD adds or updates an IAPD option with the provided IAID and // prefix options to a DHCPv6 packet. -func WithIAPD(iaid [4]byte, prefixes ...OptIAPrefix) Modifier { +func WithIAPD(iaid [4]byte, prefixes ...*OptIAPrefix) Modifier { return func(d DHCPv6) { - opt := d.GetOneOption(OptionIAPD) - if opt == nil { - opt = &OptIAForPrefixDelegation{} - } - iaPd := opt.(*OptIAForPrefixDelegation) - - copy(iaPd.IaId[:], iaid[:]) + if msg, ok := d.(*Message); ok { + opt := msg.Options.OneIAPD() + if opt == nil { + opt = &OptIAPD{} + } + copy(opt.IaId[:], iaid[:]) - for _, prefix := range prefixes { - iaPd.Options.Add(&prefix) + for _, prefix := range prefixes { + opt.Options.Add(prefix) + } + d.UpdateOption(opt) } - d.UpdateOption(iaPd) } } |