chiark / gitweb /
sd-dhcp: message_init - only set secs in the client
[elogind.git] / src / libsystemd-dhcp / sd-dhcp-client.c
index 63b7b24..01397cf 100644 (file)
@@ -206,11 +206,17 @@ static int client_message_init(sd_dhcp_client *client, DHCPMessage *message,
                                size_t *optlen) {
         int r;
 
-        r = dhcp_message_init(message, BOOTREQUEST, client->xid, type,
-                              secs, opt, optlen);
+        assert(secs);
+
+        r = dhcp_message_init(message, BOOTREQUEST, client->xid, type, opt,
+                              optlen);
         if (r < 0)
                 return r;
 
+        /* Although 'secs' field is a SHOULD in RFC 2131, certain DHCP servers
+           refuse to issue an DHCP lease if 'secs' is set to zero */
+        message->secs = htobe16(secs);
+
         memcpy(&message->chaddr, &client->mac_addr, ETH_ALEN);
 
         if (client->state == DHCP_STATE_RENEWING ||