summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/modifiers.go
diff options
context:
space:
mode:
authorChristopher Koch <chrisko@google.com>2019-02-28 14:48:54 -0800
committerinsomniac <insomniacslk@users.noreply.github.com>2019-03-11 21:54:10 -0700
commitafbaa1460f929a04c6e198b387174e70f0f9c903 (patch)
tree6f631e1afc4bd4be5db90cd7d34cb48a82ec6786 /dhcpv6/modifiers.go
parent38f805ad06e71972953004e9472e43c175ba299c (diff)
dhcpv6: remove setters and getters.
- Make members directly accessible.
Diffstat (limited to 'dhcpv6/modifiers.go')
-rw-r--r--dhcpv6/modifiers.go30
1 files changed, 11 insertions, 19 deletions
diff --git a/dhcpv6/modifiers.go b/dhcpv6/modifiers.go
index f1be702..8c75ea5 100644
--- a/dhcpv6/modifiers.go
+++ b/dhcpv6/modifiers.go
@@ -10,28 +10,26 @@ import (
// WithClientID adds a client ID option to a DHCPv6 packet
func WithClientID(duid Duid) Modifier {
- return func(d DHCPv6) DHCPv6 {
+ return func(d DHCPv6) {
cid := OptClientId{Cid: duid}
d.UpdateOption(&cid)
- return d
}
}
// WithServerID adds a client ID option to a DHCPv6 packet
func WithServerID(duid Duid) Modifier {
- return func(d DHCPv6) DHCPv6 {
+ return func(d DHCPv6) {
sid := OptServerId{Sid: duid}
d.UpdateOption(&sid)
- return d
}
}
// WithNetboot adds bootfile URL and bootfile param options to a DHCPv6 packet.
-func WithNetboot(d DHCPv6) DHCPv6 {
+func WithNetboot(d DHCPv6) {
msg, ok := d.(*Message)
if !ok {
log.Printf("WithNetboot: not a Message")
- return d
+ return
}
// add OptionBootfileURL and OptionBootfileParam
opt := msg.GetOneOption(OptionORO)
@@ -43,32 +41,30 @@ func WithNetboot(d DHCPv6) DHCPv6 {
oro.AddRequestedOption(OptionBootfileURL)
oro.AddRequestedOption(OptionBootfileParam)
msg.UpdateOption(oro)
- return d
+ return
}
// WithUserClass adds a user class option to the packet
func WithUserClass(uc []byte) Modifier {
// TODO let the user specify multiple user classes
- return func(d DHCPv6) DHCPv6 {
+ return func(d DHCPv6) {
ouc := OptUserClass{UserClasses: [][]byte{uc}}
d.AddOption(&ouc)
- return d
}
}
// WithArchType adds an arch type option to the packet
func WithArchType(at iana.Arch) Modifier {
- return func(d DHCPv6) DHCPv6 {
+ return func(d DHCPv6) {
ao := OptClientArchType{ArchTypes: []iana.Arch{at}}
d.AddOption(&ao)
- return d
}
}
// WithIANA adds or updates an OptIANA option with the provided IAAddress
// options
func WithIANA(addrs ...OptIAAddress) Modifier {
- return func(d DHCPv6) DHCPv6 {
+ return func(d DHCPv6) {
opt := d.GetOneOption(OptionIANA)
if opt == nil {
opt = &OptIANA{}
@@ -78,37 +74,34 @@ func WithIANA(addrs ...OptIAAddress) Modifier {
iaNa.AddOption(&addr)
}
d.UpdateOption(iaNa)
- return d
}
}
// WithDNS adds or updates an OptDNSRecursiveNameServer
func WithDNS(dnses ...net.IP) Modifier {
- return func(d DHCPv6) DHCPv6 {
+ return func(d DHCPv6) {
odns := OptDNSRecursiveNameServer{
NameServers: append([]net.IP{}, dnses[:]...),
}
d.UpdateOption(&odns)
- return d
}
}
// WithDomainSearchList adds or updates an OptDomainSearchList
func WithDomainSearchList(searchlist ...string) Modifier {
- return func(d DHCPv6) DHCPv6 {
+ return func(d DHCPv6) {
osl := OptDomainSearchList{
DomainSearchList: &rfc1035label.Labels{
Labels: searchlist,
},
}
d.UpdateOption(&osl)
- return d
}
}
// WithRequestedOptions adds requested options to the packet
func WithRequestedOptions(optionCodes ...OptionCode) Modifier {
- return func(d DHCPv6) DHCPv6 {
+ return func(d DHCPv6) {
opt := d.GetOneOption(OptionORO)
if opt == nil {
opt = &OptRequestedOption{}
@@ -118,6 +111,5 @@ func WithRequestedOptions(optionCodes ...OptionCode) Modifier {
oro.AddRequestedOption(optionCode)
}
d.UpdateOption(oro)
- return d
}
}