From 26ec6ccc1813d21a91bc0227ce36dee3531c5c96 Mon Sep 17 00:00:00 2001 From: Chris Koch Date: Sat, 28 Dec 2019 07:12:19 -0800 Subject: v6: add DNS getter (and rename DNSRecursiveNameServer to DNS) Signed-off-by: Chris Koch --- dhcpv6/dhcpv6message.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'dhcpv6/dhcpv6message.go') diff --git a/dhcpv6/dhcpv6message.go b/dhcpv6/dhcpv6message.go index 28853f1..400c46a 100644 --- a/dhcpv6/dhcpv6message.go +++ b/dhcpv6/dhcpv6message.go @@ -92,6 +92,18 @@ func (mo MessageOptions) RequestedOptions() OptionCodes { return oro.OptionCodes } +// DNS returns the DNS Recursive Name Server option as defined by RFC 3646. +func (mo MessageOptions) DNS() []net.IP { + opt := mo.Options.GetOne(OptionDNSRecursiveNameServer) + if opt == nil { + return nil + } + if dns, ok := opt.(*optDNS); ok { + return dns.NameServers + } + return nil +} + // Message represents a DHCPv6 Message as defined by RFC 3315 Section 6. type Message struct { MessageType MessageType -- cgit v1.2.3