-/* $OpenBSD: dhclient.c,v 1.424 2017/06/14 16:52:35 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.425 2017/06/14 20:27:08 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
int compare_lease(struct client_lease *, struct client_lease *);
void set_lease_times(struct client_lease *);
-void state_preboot(void *);
-void state_reboot(void *);
-void state_init(void *);
-void state_selecting(void *);
-void state_bound(void *);
-void state_panic(void *);
+void state_preboot(struct interface_info *);
+void state_reboot(struct interface_info *);
+void state_init(struct interface_info *);
+void state_selecting(struct interface_info *);
+void state_bound(struct interface_info *);
+void state_panic(struct interface_info *);
-void send_discover(void *);
-void send_request(void *);
-void send_decline(void *);
+void send_discover(struct interface_info *);
+void send_request(struct interface_info *);
+void send_decline(struct interface_info *);
void bind_lease(struct interface_info *);
}
void
-state_preboot(void *xifi)
+state_preboot(struct interface_info *ifi)
{
- struct interface_info *ifi = xifi;
static int preamble;
time_t cur_time;
int interval;
* Called when the interface link becomes active.
*/
void
-state_reboot(void *xifi)
+state_reboot(struct interface_info *ifi)
{
- struct interface_info *ifi = xifi;
char ifname[IF_NAMESIZE];
time_t cur_time;
* renew it.
*/
void
-state_init(void *xifi)
+state_init(struct interface_info *ifi)
{
- struct interface_info *ifi = xifi;
-
ifi->xid = arc4random();
make_discover(ifi, ifi->active);
* configurable period of time has passed.
*/
void
-state_selecting(void *xifi)
+state_selecting(struct interface_info *ifi)
{
- struct interface_info *ifi = xifi;
struct client_lease *lease, *picked;
cancel_timeout();
* the server that gave us our original lease.
*/
void
-state_bound(void *xifi)
+state_bound(struct interface_info *ifi)
{
- struct interface_info *ifi = xifi;
struct option_data *opt;
struct in_addr *dest;
* the time we reach the panic interval, call the panic function.
*/
void
-send_discover(void *xifi)
+send_discover(struct interface_info *ifi)
{
- struct interface_info *ifi = xifi;
struct dhcp_packet *packet = &ifi->sent_packet;
time_t cur_time;
ssize_t rslt;
* this happens, we try to use existing leases that haven't yet expired.
*/
void
-state_panic(void *xifi)
+state_panic(struct interface_info *ifi)
{
- struct interface_info *ifi = xifi;
struct client_lease *lp;
log_info("No acceptable DHCPOFFERS received.");
}
void
-send_request(void *xifi)
+send_request(struct interface_info *ifi)
{
- struct interface_info *ifi = xifi;
struct dhcp_packet *packet = &ifi->sent_packet;
struct sockaddr_in destination;
struct in_addr from;
}
void
-send_decline(void *xifi)
+send_decline(struct interface_info *ifi)
{
- struct interface_info *ifi = xifi;
-
log_info("DHCPDECLINE on %s", ifi->name);
send_packet(ifi, inaddr_any, inaddr_broadcast);
-/* $OpenBSD: dhcpd.h,v 1.180 2017/06/14 16:52:35 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.181 2017/06/14 20:27:08 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
};
struct dhcp_timeout {
- time_t when;
- void (*func)(void *);
- void *arg;
+ time_t when;
+ void (*func)(struct interface_info *);
+ struct interface_info *ifi;
};
#define _PATH_RESOLV_CONF "/etc/resolv.conf"
/* dispatch.c */
void dispatch(struct interface_info *);
-void set_timeout(time_t, void (*)(void *), void *);
-void set_timeout_interval(time_t, void (*)(void *), void *);
+void set_timeout(time_t, void (*)(struct interface_info *),
+ struct interface_info *);
+void set_timeout_interval(time_t, void (*)(struct interface_info *),
+ struct interface_info *);
void cancel_timeout(void);
void interface_link_forceup(char *);
int interface_status(struct interface_info *);
-/* $OpenBSD: dispatch.c,v 1.121 2017/06/14 16:52:35 krw Exp $ */
+/* $OpenBSD: dispatch.c,v 1.122 2017/06/14 20:27:08 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
int count, to_msec;
struct pollfd fds[3];
time_t cur_time, howlong;
- void (*func)(void *);
- void *arg;
+ void (*func)(struct interface_info *);
+ struct interface_info *arg;
while (quit == 0) {
if (timeout.func) {
time(&cur_time);
if (timeout.when <= cur_time) {
func = timeout.func;
- arg = timeout.arg;
+ arg = timeout.ifi;
cancel_timeout();
(*(func))(arg);
continue;
* fds[0] == bpf socket for incoming packets
* fds[1] == routing socket for incoming RTM messages
* fds[2] == imsg socket to privileged process
- */
+ */
fds[0].fd = ifi->bfdesc;
fds[1].fd = routefd;
fds[2].fd = unpriv_ibuf->fd;
}
void
-set_timeout(time_t when, void (*where)(void *), void *arg)
+set_timeout(time_t when, void (*where)(struct interface_info *),
+ struct interface_info *ifi)
{
timeout.when = when;
timeout.func = where;
- timeout.arg = arg;
+ timeout.ifi = ifi;
}
void
-set_timeout_interval(time_t secs, void (*where)(void *), void *arg)
+set_timeout_interval(time_t secs, void (*where)(struct interface_info *),
+ struct interface_info *ifi)
{
timeout.when = time(NULL) + secs;
timeout.func = where;
- timeout.arg = arg;
+ timeout.ifi = ifi;
}
void
{
timeout.when = 0;
timeout.func = NULL;
- timeout.arg = NULL;
+ timeout.ifi = NULL;
}
int