-/* $OpenBSD: dhclient.c,v 1.709 2021/03/04 02:00:42 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.710 2021/03/09 14:32:24 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
break;
}
- if (cur_time < ifi->startup_time + config->link_interval)
- interval = 1;
-
ifi->interval = interval ? interval : 1;
}
void
send_discover(struct interface_info *ifi)
{
- time_t cur_time;
+ struct timespec now;
ssize_t rslt;
+ time_t cur_time;
- time(&cur_time);
+ clock_gettime(CLOCK_REALTIME, &now);
+ cur_time = now.tv_sec;
if (cur_time > ifi->first_sending + config->offer_interval) {
state_panic(ifi);
return;
}
- set_interval(ifi, cur_time);
+ if (timespeccmp(&now, &ifi->link_timeout, <))
+ ifi->interval = 1;
+ else
+ set_interval(ifi, cur_time);
set_secs(ifi, cur_time);
rslt = send_packet(ifi, inaddr_any, inaddr_broadcast, "DHCPDISCOVER");
return;
}
- set_interval(ifi, cur_time);
+ if (timespeccmp(&now, &ifi->link_timeout, <))
+ ifi->interval = 1;
+ else
+ set_interval(ifi, cur_time);
set_secs(ifi, cur_time);
rslt = send_packet(ifi, from, destination.sin_addr, "DHCPREQUEST");
-/* $OpenBSD: dhcpd.h,v 1.295 2021/02/24 16:18:59 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.296 2021/03/09 14:32:24 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
void (*timeout_func)(struct interface_info *);
uint16_t secs;
time_t first_sending;
- time_t startup_time;
+ struct timespec link_timeout;
enum dhcp_state state;
struct in_addr destination;
time_t interval;
-/* $OpenBSD: dispatch.c,v 1.170 2021/03/02 16:17:26 krw Exp $ */
+/* $OpenBSD: dispatch.c,v 1.171 2021/03/09 14:32:24 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
void
dispatch(struct interface_info *ifi, int routefd)
{
+ const struct timespec link_intvl = {config->link_interval, 0};
struct pollfd fds[3];
struct timespec timeout;
struct timespec *ts;
while (quit == 0 || quit == RESTART) {
if (quit == RESTART) {
quit = 0;
- time(&ifi->startup_time);
+ clock_gettime(CLOCK_REALTIME, &ifi->link_timeout);
+ timespecadd(&ifi->link_timeout, &link_intvl, &ifi->link_timeout);
free(ifi->configured);
ifi->configured = NULL;
free(ifi->unwind_info);