summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6
diff options
context:
space:
mode:
Diffstat (limited to 'dhcpv6')
-rw-r--r--dhcpv6/dhcpv6message.go38
1 files changed, 31 insertions, 7 deletions
diff --git a/dhcpv6/dhcpv6message.go b/dhcpv6/dhcpv6message.go
index 3b850fb..2067fcc 100644
--- a/dhcpv6/dhcpv6message.go
+++ b/dhcpv6/dhcpv6message.go
@@ -179,16 +179,40 @@ func (mo MessageOptions) UserClasses() [][]byte {
return nil
}
-// VendorOpts returns the enterprise number and a list of vendor options.
-func (mo MessageOptions) VendorOpts() (uint32, Options) {
- opt := mo.Options.GetOne(OptionVendorOpts)
+// VendorOpts returns the all vendor-specific options.
+//
+// RFC 8415 Section 21.17:
+//
+// Multiple instances of the Vendor-specific Information option may appear in
+// a DHCP message.
+func (mo MessageOptions) VendorOpts() []*OptVendorOpts {
+ opt := mo.Options.Get(OptionVendorOpts)
if opt == nil {
- return 0, nil
+ return nil
+ }
+ var vo []*OptVendorOpts
+ for _, o := range opt {
+ if t, ok := o.(*OptVendorOpts); ok {
+ vo = append(vo, t)
+ }
}
- if t, ok := opt.(*OptVendorOpts); ok {
- return t.EnterpriseNumber, t.VendorOpts
+ return vo
+}
+
+// VendorOpt returns the vendor options matching the given enterprise number.
+//
+// RFC 8415 Section 21.17:
+//
+// Servers and clients MUST NOT send more than one instance of the
+// Vendor-specific Information option with the same Enterprise Number.
+func (mo MessageOptions) VendorOpt(enterpriseNumber uint32) Options {
+ vo := mo.VendorOpts()
+ for _, v := range vo {
+ if v.EnterpriseNumber == enterpriseNumber {
+ return v.VendorOpts
+ }
}
- return 0, nil
+ return nil
}
// ElapsedTime returns the Elapsed Time option as defined by RFC 3315 Section 22.9.