diff options
author | Chris Koch <chrisko@google.com> | 2020-02-06 14:54:44 -0800 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2020-03-05 15:51:55 +0000 |
commit | 05d8a93081707e4eccd5893799c998a384d3652e (patch) | |
tree | fce98c1ce2d75ad459c2f1205ff9e9aa84fbc64d /dhcpv6/dhcpv6message.go | |
parent | 3bf2e89230d11ddbee88ae5146016c175fbdf0ae (diff) |
v6: add IAPD getter
Signed-off-by: Chris Koch <chrisko@google.com>
Diffstat (limited to 'dhcpv6/dhcpv6message.go')
-rw-r--r-- | dhcpv6/dhcpv6message.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/dhcpv6/dhcpv6message.go b/dhcpv6/dhcpv6message.go index 3963f39..ced5f9e 100644 --- a/dhcpv6/dhcpv6message.go +++ b/dhcpv6/dhcpv6message.go @@ -66,6 +66,25 @@ func (mo MessageOptions) OneIANA() *OptIANA { return ianas[0] } +// IAPD returns all Identity Association for Prefix Delegation options. +func (mo MessageOptions) IAPD() []*OptIAForPrefixDelegation { + opts := mo.Get(OptionIAPD) + var ianas []*OptIAForPrefixDelegation + for _, o := range opts { + ianas = append(ianas, o.(*OptIAForPrefixDelegation)) + } + return ianas +} + +// OneIAPD returns the first IAPD option. +func (mo MessageOptions) OneIAPD() *OptIAForPrefixDelegation { + iapds := mo.IAPD() + if len(iapds) == 0 { + return nil + } + return iapds[0] +} + // Status returns the status code associated with this option. func (mo MessageOptions) Status() *OptStatusCode { opt := mo.Options.GetOne(OptionStatusCode) |