summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/dhcpv4.go
diff options
context:
space:
mode:
authorChris Koch <chrisko@google.com>2021-12-09 14:09:52 -0800
committerinsomniac <insomniacslk@users.noreply.github.com>2021-12-09 22:37:15 +0000
commit7d93572ebe8e3ba39a15bc7b70757c83a5fb8352 (patch)
treeeed2be62c2c6803c8b7ec2a25ea505305ea01c96 /dhcpv4/dhcpv4.go
parentad197bcd36fd5fde44d2eacc50c5aa7aef87a742 (diff)
dhcpv4: remove server IP from REQUEST messages
RFC 2131 Section 4.4.1 specifies that REQUEST messages should set 'siaddr' to 0. Signed-off-by: Chris Koch <chrisko@google.com>
Diffstat (limited to 'dhcpv4/dhcpv4.go')
-rw-r--r--dhcpv4/dhcpv4.go13
1 files changed, 2 insertions, 11 deletions
diff --git a/dhcpv4/dhcpv4.go b/dhcpv4/dhcpv4.go
index 6be9425..fae08fb 100644
--- a/dhcpv4/dhcpv4.go
+++ b/dhcpv4/dhcpv4.go
@@ -232,22 +232,13 @@ func NewInform(hwaddr net.HardwareAddr, localIP net.IP, modifiers ...Modifier) (
// NewRequestFromOffer builds a DHCPv4 request from an offer.
func NewRequestFromOffer(offer *DHCPv4, modifiers ...Modifier) (*DHCPv4, error) {
- // find server IP address
- serverIP := offer.ServerIdentifier()
- if serverIP == nil {
- if offer.ServerIPAddr == nil || offer.ServerIPAddr.IsUnspecified() {
- return nil, fmt.Errorf("missing Server IP Address in DHCP Offer")
- }
- serverIP = offer.ServerIPAddr
- }
-
return New(PrependModifiers(modifiers,
WithReply(offer),
WithMessageType(MessageTypeRequest),
- WithServerIP(serverIP),
WithClientIP(offer.ClientIPAddr),
WithOption(OptRequestedIPAddress(offer.YourIPAddr)),
- WithOption(OptServerIdentifier(serverIP)),
+ // This is usually the server IP.
+ WithOptionCopied(offer, OptionServerIdentifier),
WithRequestedOptions(
OptionSubnetMask,
OptionRouter,