If the admin set "ipaddr = *", and no "src_ipaddr = ...", then
we used to send packets from 0.0.0.0. That's wrong.
We now look for server identifier or server IP address.
If one of those is found, we use that as the source IP
request->reply->src_ipaddr.af = AF_INET;
request->reply->src_ipaddr.ipaddr.ip4addr.s_addr = sock->src_ipaddr.ipaddr.ip4addr.s_addr;
+ /*
+ * They didn't set a proper src_ipaddr, but we want to
+ * send the packet with a source IP. If there's a server
+ * identifier, use it.
+ */
+ if (request->reply->src_ipaddr.ipaddr.ip4addr.s_addr == INADDR_ANY) {
+ vp = pairfind(request->reply->vps, DHCP2ATTR(265)); /* DHCP-Server-IP-Address */
+ if (!vp) vp = pairfind(request->reply->vps, DHCP2ATTR(54)); /* DHCP-DHCP-Server-Identifier */
+ if (vp) {
+ request->reply->src_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr;
+ }
+ }
+
request->reply->dst_port = request->packet->src_port;
request->reply->src_port = request->packet->dst_port;