diff options
author | Chris Koch <chrisko@google.com> | 2019-12-28 01:35:02 -0800 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2020-03-09 11:20:54 +0000 |
commit | 9f507afe0e85d11469f610304e001eb825c1c61e (patch) | |
tree | 2c046a7a4e852dbfaced220b3184bfb8495e0063 | |
parent | a3ce4ba6230eaf0fceb9c67321bd1a3aa6d2e983 (diff) |
netconf: use new IANA and IAAddress getters
Signed-off-by: Chris Koch <chrisko@google.com>
-rw-r--r-- | dhcpv6/option_nontemporaryaddress.go | 6 | ||||
-rw-r--r-- | netboot/netconf.go | 13 |
2 files changed, 5 insertions, 14 deletions
diff --git a/dhcpv6/option_nontemporaryaddress.go b/dhcpv6/option_nontemporaryaddress.go index 01971f8..0b6012e 100644 --- a/dhcpv6/option_nontemporaryaddress.go +++ b/dhcpv6/option_nontemporaryaddress.go @@ -32,8 +32,8 @@ type IdentityOptions struct { Options } -// Address returns the addresses assigned to the identity. -func (io IdentityOptions) Address() []*OptIAAddress { +// Addresses returns the addresses assigned to the identity. +func (io IdentityOptions) Addresses() []*OptIAAddress { opts := io.Options.Get(OptionIAAddr) var iaAddrs []*OptIAAddress for _, o := range opts { @@ -44,7 +44,7 @@ func (io IdentityOptions) Address() []*OptIAAddress { // OneAddress returns one address (of potentially many) assigned to the identity. func (io IdentityOptions) OneAddress() *OptIAAddress { - a := io.Address() + a := io.Addresses() if len(a) == 0 { return nil } diff --git a/netboot/netconf.go b/netboot/netconf.go index 78ddff8..60468a7 100644 --- a/netboot/netconf.go +++ b/netboot/netconf.go @@ -41,19 +41,11 @@ func GetNetConfFromPacketv6(d *dhcpv6.Message) (*NetConf, error) { } netconf := NetConf{} - // get IP configuration - iaaddrs := make([]*dhcpv6.OptIAAddress, 0) - for _, o := range iana.Options { - if o.Code() == dhcpv6.OptionIAAddr { - iaaddrs = append(iaaddrs, o.(*dhcpv6.OptIAAddress)) - } - } - netmask := net.IPMask(net.ParseIP("ffff:ffff:ffff:ffff::")) - for _, iaaddr := range iaaddrs { + for _, iaaddr := range iana.Options.Addresses() { netconf.Addresses = append(netconf.Addresses, AddrConf{ IPNet: net.IPNet{ IP: iaaddr.IPv6Addr, - Mask: netmask, + Mask: net.CIDRMask(64, 128), }, PreferredLifetime: iaaddr.PreferredLifetime, ValidLifetime: iaaddr.ValidLifetime, @@ -70,7 +62,6 @@ func GetNetConfFromPacketv6(d *dhcpv6.Message) (*NetConf, error) { if domains != nil { netconf.DNSSearchList = domains.Labels } - return &netconf, nil } |