#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
+#include <poll.h>
#include <alloca.h>
#include <resolv.h>
#include <limits.h>
md5_hash(c->hostname, strlen(c->hostname), &md5);
}
- l += snprintf(leasebuf + l, sizeof(leasebuf) - l, "%s/%hhu ", ipbuf,
+ l += snprintf(leasebuf + l, sizeof(leasebuf) - l, "%s/%d ", ipbuf,
(c->managed_size) ? addrs[i].prefix : c->length);
}
leasebuf[l - 1] = '\n';
if (first && c->managed_size == 0)
free_dhcpv6_assignment(c);
+ else if (first)
+ c->valid_until = now + 150;
}
iaidbuf, assign->iaid, assign->length);
ustream_write_pending(&assign->managed_sock.stream);
assign->managed_size = -1;
+ assign->valid_until = odhcpd_time() + 15;
list_add(&assign->head, &iface->ia_assignments);
+
+ // Wait initial period of up to 250ms for immediate assignment
+ struct pollfd pfd = { .fd = fd, .events = POLLIN };
+ poll(&pfd, 1, 250);
+ managed_handle_pd_data(&assign->managed_sock.stream, 0);
+
+ if (fcntl(fd, F_GETFL) >= 0 && assign->managed_size > 0)
+ return true;
}
return false;
// Was only a solicitation: mark binding for removal
if (assigned && hdr->msg_type == DHCPV6_MSG_SOLICIT) {
- a->valid_until = now + 15;
+ a->valid_until = 0;
} else if (assigned && hdr->msg_type == DHCPV6_MSG_REQUEST) {
if (hostname_len > 0) {
a->hostname = realloc(a->hostname, hostname_len + 1);