diff options
author | Andrea Barberio <insomniac@slackware.it> | 2020-03-06 20:50:34 +0000 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2020-03-06 23:01:18 +0000 |
commit | 99cbb09fb7b9ed72366e4c3e7def412d8e461539 (patch) | |
tree | 24dfd645fe4316df206dccd0fd5e46e84d014c10 /dhcpv6 | |
parent | 7ea59fc95373dc2c34b2a81c0917618402affe0f (diff) |
[dhcpv6] More getters for MessageOptions
Added IAAddress, OneIAAddress, UserClasses, VendorOpts, and changed
Options to MessageOptions in IA_NA and IA_Address options.
Signed-off-by: Andrea Barberio <insomniac@slackware.it>
Diffstat (limited to 'dhcpv6')
-rw-r--r-- | dhcpv6/dhcpv6message.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/dhcpv6/dhcpv6message.go b/dhcpv6/dhcpv6message.go index 56f8627..76404f2 100644 --- a/dhcpv6/dhcpv6message.go +++ b/dhcpv6/dhcpv6message.go @@ -167,6 +167,30 @@ func (mo MessageOptions) BootFileParam() []string { return nil } +// UserClasses returns a list of user classes. +func (mo MessageOptions) UserClasses() [][]byte { + opt := mo.Options.GetOne(OptionUserClass) + if opt == nil { + return nil + } + if t, ok := opt.(*OptUserClass); ok { + return t.UserClasses + } + return nil +} + +// VendorOpts returns the enterprise number and a list of vendor options. +func (mo MessageOptions) VendorOpts() (uint32, Options) { + opt := mo.Options.GetOne(OptionVendorOpts) + if opt == nil { + return 0, nil + } + if t, ok := opt.(*OptVendorOpts); ok { + return t.EnterpriseNumber, t.VendorOpts + } + return 0, nil +} + // ElapsedTime returns the Elapsed Time option as defined by RFC 3315 Section 22.9. // // ElapsedTime returns a duration of 0 if the option is not present. |