summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/modifiers.go
diff options
context:
space:
mode:
authorChris Koch <chrisko@google.com>2019-11-20 15:41:45 -0800
committerChris K <c@chrisko.ch>2019-12-03 16:02:05 -0700
commit3997b8a58c66233275ad9b26612ef733a63bd9d3 (patch)
treeeb6e50a7cdb43b7a638be799dea969ded1a9ca6e /dhcpv4/modifiers.go
parent23cb9c9804a6fcab99e1843729a1f561e424716e (diff)
dhcpv4: add Client Identifier option; respect RFC 6842
Signed-off-by: Chris Koch <chrisko@google.com>
Diffstat (limited to 'dhcpv4/modifiers.go')
-rw-r--r--dhcpv4/modifiers.go12
1 files changed, 5 insertions, 7 deletions
diff --git a/dhcpv4/modifiers.go b/dhcpv4/modifiers.go
index 2bf79b8..0ab35bc 100644
--- a/dhcpv4/modifiers.go
+++ b/dhcpv4/modifiers.go
@@ -43,18 +43,16 @@ func WithGatewayIP(ip net.IP) Modifier {
}
}
-// WithRelayAgentInfo copies the relay options from the request to the reply.
-func WithRelayAgentInfo(request *DHCPv4) Modifier {
+// WithOptionCopied copies the value of option opt from request.
+func WithOptionCopied(request *DHCPv4, opt OptionCode) Modifier {
return func(d *DHCPv4) {
- // If request has Relay Agent Info copy it to the reply
- if relayOpt := request.RelayAgentInfo(); relayOpt != nil {
- d.UpdateOption(Option{Code: OptionRelayAgentInformation, Value: relayOpt})
+ if val := request.Options.Get(opt); val != nil {
+ d.UpdateOption(OptGeneric(opt, val))
}
}
}
-// WithReply fills in opcode, hwtype, xid, clienthwaddr, flags, and gateway ip
-// addr from the given packet.
+// WithReply fills in opcode, hwtype, xid, clienthwaddr, and flags from the given packet.
func WithReply(request *DHCPv4) Modifier {
return func(d *DHCPv4) {
if request.OpCode == OpcodeBootRequest {