From 5b35cdba62662ea5f309788a627869b5a46c8e0e Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 19 Nov 2019 11:40:34 -0600 Subject: Rename function to WithRelayAgentInfo Fix syntax nits Simplified function as suggested by @pmazzini Signed-off-by: kevin --- dhcpv4/modifiers.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/dhcpv4/modifiers.go b/dhcpv4/modifiers.go index 168b178..f076526 100644 --- a/dhcpv4/modifiers.go +++ b/dhcpv4/modifiers.go @@ -43,14 +43,12 @@ func WithGatewayIP(ip net.IP) Modifier { } } -//WithRelayOptions copies the relay options from the request to the reply -func WithRelayOptions(request *DHCPv4) Modifier { +// WithRelayAgentInfo copies the relay options from the request to the reply. +func WithRelayAgentInfo(request *DHCPv4) Modifier { return func(d *DHCPv4) { // If request has Relay Agent Info copy it to the reply - if request.Options.Has(OptionRelayAgentInformation) { - relayopt := request.Options.Get(OptionRelayAgentInformation) - opt := OptGeneric(OptionRelayAgentInformation, relayopt) - d.Options.Update(opt) + if relayOpt := request.RelayAgentInfo(); relayOpt != nil { + d.UpdateOption(dhcpv4.Option{Code: dhcpv4.OptionRelayAgentInformation, Value: relayOpt}) } } } -- cgit v1.2.3