diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2017-06-14 20:27:09 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2017-06-14 20:27:09 +0000 |
commit | 1498e0654b7bf3976f9170174b8521f243d4d1fe (patch) | |
tree | e244fb3ccce98076e1d843f1bbf5ecbf7a869248 | |
parent | 8a17ba6805f280b144fae94dc77afdb82937f077 (diff) |
No need to be coy - call a "struct interface_info *" a
"struct interface_info *" and not a "void *".
No intentional functional change.
-rw-r--r-- | sbin/dhclient/dhclient.c | 49 | ||||
-rw-r--r-- | sbin/dhclient/dhcpd.h | 14 | ||||
-rw-r--r-- | sbin/dhclient/dispatch.c | 22 |
3 files changed, 39 insertions, 46 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 8160ff6f4e6..17833796aeb 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $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> @@ -130,16 +130,16 @@ void apply_ignore_list(char *); 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 *); @@ -705,9 +705,8 @@ usage(void) } 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; @@ -749,9 +748,8 @@ state_preboot(void *xifi) * 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; @@ -791,10 +789,8 @@ state_reboot(void *xifi) * 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); @@ -811,9 +807,8 @@ state_init(void *xifi) * 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(); @@ -1092,9 +1087,8 @@ newlease: * 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; @@ -1378,9 +1372,8 @@ dhcpnak(struct interface_info *ifi, struct in_addr client_addr, * 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; @@ -1443,9 +1436,8 @@ send_discover(void *xifi) * 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."); @@ -1468,9 +1460,8 @@ state_panic(void *xifi) } 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; @@ -1574,10 +1565,8 @@ send_request(void *xifi) } 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); diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index 8d885676530..7baa7db0696 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $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> @@ -160,9 +160,9 @@ struct interface_info { }; 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" @@ -216,8 +216,10 @@ ssize_t receive_packet(struct interface_info *, struct sockaddr_in *, /* 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 *); diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index 0891ea8fc99..4138f703f92 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -1,4 +1,4 @@ -/* $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> @@ -123,15 +123,15 @@ dispatch(struct interface_info *ifi) 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; @@ -155,7 +155,7 @@ dispatch(struct interface_info *ifi) * 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; @@ -280,19 +280,21 @@ interface_status(struct interface_info *ifi) } 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 @@ -300,7 +302,7 @@ cancel_timeout(void) { timeout.when = 0; timeout.func = NULL; - timeout.arg = NULL; + timeout.ifi = NULL; } int |