The destination IP address should be INADDR_BROADCAST, but was
accidentally left as INADDR_ANY.
r = setsockopt(s, IPPROTO_IP, IP_PKTINFO, &on, sizeof(on));
if (r < 0)
return -errno;
r = setsockopt(s, IPPROTO_IP, IP_PKTINFO, &on, sizeof(on));
if (r < 0)
return -errno;
+
+ r = setsockopt(s, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on));
+ if (r < 0)
+ return -errno;
}
r = bind(s, &src.sa, sizeof(src.in));
}
r = bind(s, &src.sa, sizeof(src.in));
} else if (req->message->ciaddr && type != DHCP_NAK)
destination = req->message->ciaddr;
} else if (req->message->ciaddr && type != DHCP_NAK)
destination = req->message->ciaddr;
- if (destination || requested_broadcast(req) || type == DHCP_NAK)
+ if (destination != INADDR_ANY)
return dhcp_server_send_udp(server, destination, &packet->dhcp,
sizeof(DHCPMessage) + optoffset);
return dhcp_server_send_udp(server, destination, &packet->dhcp,
sizeof(DHCPMessage) + optoffset);
+ else if (requested_broadcast(req) || type == DHCP_NAK)
+ return dhcp_server_send_udp(server, INADDR_BROADCAST, &packet->dhcp,
+ sizeof(DHCPMessage) + optoffset);
else
/* we cannot send UDP packet to specific MAC address when the address is
not yet configured, so must fall back to raw packets */
else
/* we cannot send UDP packet to specific MAC address when the address is
not yet configured, so must fall back to raw packets */