-/* $OpenBSD: dhclient.c,v 1.436 2017/06/18 17:01:46 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.437 2017/06/18 21:08:15 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
ftruncate(fileno(optionDB), 0);
}
/* No need to wait for anything but link. */
- cancel_timeout();
+ cancel_timeout(ifi);
}
}
break;
char ifname[IF_NAMESIZE];
time_t cur_time;
- cancel_timeout();
+ cancel_timeout(ifi);
deleting.s_addr = INADDR_ANY;
adding.s_addr = INADDR_ANY;
{
struct option_data *option;
- cancel_timeout();
+ cancel_timeout(ifi);
if (ifi->offer == NULL) {
state_panic(ifi);
ifi->offer->ssid_len = ifi->ssid_len;
/* Stop resending DHCPREQUEST. */
- cancel_timeout();
+ cancel_timeout(ifi);
bind_lease(ifi);
}
ifi->active = NULL;
/* Stop sending DHCPREQUEST packets. */
- cancel_timeout();
+ cancel_timeout(ifi);
ifi->state = S_INIT;
state_init(ifi);
if (ifi->state == S_REBOOTING && interval >
config->reboot_timeout) {
ifi->state = S_INIT;
- cancel_timeout();
+ cancel_timeout(ifi);
state_init(ifi);
return;
}
-/* $OpenBSD: dhcpd.h,v 1.188 2017/06/18 17:01:46 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.189 2017/06/18 21:08:15 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
char *server_name;
};
+
struct interface_info {
struct ether_addr hw_address;
char name[IFNAMSIZ];
struct dhcp_packet sent_packet;
int sent_packet_length;
u_int32_t xid;
+ time_t timeout;
+ void (*timeout_func)(struct interface_info *);
u_int16_t secs;
time_t first_sending;
time_t startup_time;
TAILQ_HEAD(_leases, client_lease) leases;
};
-struct dhcp_timeout {
- time_t when;
- void (*func)(struct interface_info *);
- struct interface_info *ifi;
-};
-
#define _PATH_RESOLV_CONF "/etc/resolv.conf"
#define _PATH_DHCLIENT_CONF "/etc/dhclient.conf"
#define _PATH_DHCLIENT_DB "/var/db/dhclient.leases"
void dispatch(struct interface_info *);
void set_timeout(time_t, void (*)(struct interface_info *),
struct interface_info *);
-void cancel_timeout(void);
+void cancel_timeout(struct interface_info *);
void interface_link_forceup(char *);
int interface_status(struct interface_info *);
int get_rdomain(char *);
-/* $OpenBSD: dispatch.c,v 1.123 2017/06/18 17:01:46 krw Exp $ */
+/* $OpenBSD: dispatch.c,v 1.124 2017/06/18 21:08:15 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
#include "privsep.h"
-struct dhcp_timeout timeout;
-
void packethandler(struct interface_info *ifi);
void sendhup(struct client_lease *);
struct pollfd fds[3];
time_t cur_time, howlong;
void (*func)(struct interface_info *);
- struct interface_info *arg;
while (quit == 0) {
- if (timeout.func) {
+ if (ifi->timeout_func) {
time(&cur_time);
- if (timeout.when <= cur_time) {
- func = timeout.func;
- arg = timeout.ifi;
- cancel_timeout();
- (*(func))(arg);
+ if (ifi->timeout <= cur_time) {
+ func = ifi->timeout_func;
+ cancel_timeout(ifi);
+ (*(func))(ifi);
continue;
}
/*
* int for poll, while not polling with a
* negative timeout and blocking indefinitely.
*/
- howlong = timeout.when - cur_time;
+ howlong = ifi->timeout - cur_time;
if (howlong > INT_MAX / 1000)
howlong = INT_MAX / 1000;
to_msec = howlong * 1000;
set_timeout(time_t secs, void (*where)(struct interface_info *),
struct interface_info *ifi)
{
- timeout.when = time(NULL) + secs;
- timeout.func = where;
- timeout.ifi = ifi;
+ ifi->timeout = time(NULL) + secs;
+ ifi->timeout_func = where;
}
void
-cancel_timeout(void)
+cancel_timeout(struct interface_info *ifi)
{
- timeout.when = 0;
- timeout.func = NULL;
- timeout.ifi = NULL;
+ ifi->timeout = 0;
+ ifi->timeout_func = NULL;
}
int