refuse to issue an DHCP lease if 'secs' is set to zero */
packet->dhcp.secs = htobe16(client->secs);
+ /* RFC2132 section 4.1
+ A client that cannot receive unicast IP datagrams until its protocol
+ software has been configured with an IP address SHOULD set the
+ BROADCAST bit in the 'flags' field to 1 in any DHCPDISCOVER or
+ DHCPREQUEST messages that client sends. The BROADCAST bit will
+ provide a hint to the DHCP server and BOOTP relay agent to broadcast
+ any messages to the client on the client's subnet. */
+ packet->dhcp.flags = htobe16(0x8000);
+
/* RFC2132 section 4.1.1:
The client MUST include its hardware address in the ’chaddr’ field, if
necessary for delivery of DHCP reply messages.
len = read(fd, message, buflen);
if (len < 0) {
log_dhcp_client(client, "could not receive message from UDP "
- "socket: %s", strerror(errno));
+ "socket: %m");
return 0;
} else if ((size_t)len < sizeof(DHCPMessage))
return 0;
len = recvmsg(fd, &msg, 0);
if (len < 0) {
log_dhcp_client(client, "could not receive message from raw "
- "socket: %s", strerror(errno));
+ "socket: %m");
return 0;
} else if ((size_t)len < sizeof(DHCPPacket))
return 0;