summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dhcpv6/dhcpv6message.go12
-rw-r--r--dhcpv6/modifiers_test.go4
2 files changed, 14 insertions, 2 deletions
diff --git a/dhcpv6/dhcpv6message.go b/dhcpv6/dhcpv6message.go
index ced5f9e..8ba7943 100644
--- a/dhcpv6/dhcpv6message.go
+++ b/dhcpv6/dhcpv6message.go
@@ -168,6 +168,18 @@ func (mo MessageOptions) ElapsedTime() time.Duration {
return 0
}
+// FQDN returns the FQDN option as defined by RFC 4704.
+func (mo MessageOptions) FQDN() *OptFQDN {
+ opt := mo.Options.GetOne(OptionFQDN)
+ if opt == nil {
+ return nil
+ }
+ if fqdn, ok := opt.(*OptFQDN); ok {
+ return fqdn
+ }
+ return nil
+}
+
// Message represents a DHCPv6 Message as defined by RFC 3315 Section 6.
type Message struct {
MessageType MessageType
diff --git a/dhcpv6/modifiers_test.go b/dhcpv6/modifiers_test.go
index ff8022c..e31cd29 100644
--- a/dhcpv6/modifiers_test.go
+++ b/dhcpv6/modifiers_test.go
@@ -90,8 +90,8 @@ func TestWithDomainSearchList(t *testing.T) {
func TestWithFQDN(t *testing.T) {
var d Message
WithFQDN(4, "cnos.localhost")(&d)
- require.Equal(t, 1, len(d.Options))
- ofqdn := d.Options[0].(*OptFQDN)
+ require.Equal(t, 1, len(d.Options.Options))
+ ofqdn := d.Options.FQDN()
require.Equal(t, OptionFQDN, ofqdn.Code())
require.Equal(t, uint8(4), ofqdn.Flags)
require.Equal(t, "cnos.localhost", ofqdn.DomainName)