summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/option_domain_search.go
blob: 6d2f7b21c8ed2bccf1e55b9a90d17b1cdf123982 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package dhcpv4

import (
	"github.com/insomniacslk/dhcp/rfc1035label"
)

// OptDomainSearch returns a new domain search option.
//
// The domain search option is described by RFC 3397, Section 2.
func OptDomainSearch(labels *rfc1035label.Labels) Option {
	return Option{Code: OptionDNSDomainSearchList, Value: labels}
}

// GetDomainSearch returns the domain search list in o, if present.
//
// The domain search option is described by RFC 3397, Section 2.
func GetDomainSearch(o Options) *rfc1035label.Labels {
	v := o.Get(OptionDNSDomainSearchList)
	if v == nil {
		return nil
	}
	labels, err := rfc1035label.FromBytes(v)
	if err != nil {
		return nil
	}
	return labels
}