summaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpd.c
diff options
context:
space:
mode:
authorDenis Vlasenko2007-07-03 15:47:50 +0000
committerDenis Vlasenko2007-07-03 15:47:50 +0000
commit42b3dea9bfb8ac595c71089ee23012f44dd43eb2 (patch)
treeb7b86d06a574d2af72bc79536d399905b5619959 /networking/udhcp/dhcpd.c
parent54e19da86d5496ec5f5787b85a2b6342be1d63d4 (diff)
downloadbusybox-42b3dea9bfb8ac595c71089ee23012f44dd43eb2.zip
busybox-42b3dea9bfb8ac595c71089ee23012f44dd43eb2.tar.gz
udhcp: many small fixes:
* arpping(): smaller and even probably fixed * lots of variables/params converted: ulong -> uint32_t * uptime() nuked in favor of monotonic_sec() * udhcp_get_packet(): only one "bad vendor", simplify function old new delta reservedIp 36 35 -1 udhcpc_main 2462 2460 -2 addStaticLease 64 62 -2 static.broken_vendors 16 - -16 uptime 19 - -19 udhcpd_main 1273 1238 -35 udhcp_get_packet 223 184 -39 .rodata 144162 144106 -56 arpping 690 609 -81 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 0/7 up/down: 0/-251) Total: -251 bytes text data bss dec hex filename 734241 3028 14400 751669 b7835 busybox_old 734005 3028 14400 751433 b7749 busybox_unstripped
Diffstat (limited to 'networking/udhcp/dhcpd.c')
-rw-r--r--networking/udhcp/dhcpd.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 9dbd35d..8cac681 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -30,7 +30,8 @@ int udhcpd_main(int argc, char **argv)
struct dhcpMessage packet;
uint8_t *state, *server_id, *requested;
uint32_t server_id_align, requested_align, static_lease_ip;
- unsigned long timeout_end, num_ips;
+ unsigned timeout_end;
+ unsigned num_ips;
struct option_set *option;
struct dhcpOfferedAddr *lease, static_lease;
@@ -48,7 +49,7 @@ int udhcpd_main(int argc, char **argv)
/* Would rather not do read_config before daemonization -
* otherwise NOMMU machines will parse config twice */
- read_config(argc < 2 ? DHCPD_CONF_FILE : argv[1]);
+ read_config(argv[1] ? argv[1] : DHCPD_CONF_FILE);
udhcp_make_pidfile(server_config.pidfile);
@@ -62,9 +63,8 @@ int udhcpd_main(int argc, char **argv)
/* Sanity check */
num_ips = server_config.end_ip - server_config.start_ip + 1;
if (server_config.max_leases > num_ips) {
- bb_error_msg("max_leases=%lu is too big, "
- "setting to %lu",
- server_config.max_leases, num_ips);
+ bb_error_msg("max_leases=%u is too big, setting to %u",
+ (unsigned)server_config.max_leases, num_ips);
server_config.max_leases = num_ips;
}
@@ -80,7 +80,7 @@ int udhcpd_main(int argc, char **argv)
/* Setup the signal pipe */
udhcp_sp_setup();
- timeout_end = time(0) + server_config.auto_time;
+ timeout_end = monotonic_sec() + server_config.auto_time;
while (1) { /* loop until universe collapses */
if (server_socket < 0) {
@@ -90,7 +90,7 @@ int udhcpd_main(int argc, char **argv)
max_sock = udhcp_sp_fd_set(&rfds, server_socket);
if (server_config.auto_time) {
- tv.tv_sec = timeout_end - time(0);
+ tv.tv_sec = timeout_end - monotonic_sec();
tv.tv_usec = 0;
}
retval = 0;
@@ -100,7 +100,7 @@ int udhcpd_main(int argc, char **argv)
}
if (retval == 0) {
write_leases();
- timeout_end = time(0) + server_config.auto_time;
+ timeout_end = monotonic_sec() + server_config.auto_time;
continue;
}
if (retval < 0 && errno != EINTR) {
@@ -113,7 +113,7 @@ int udhcpd_main(int argc, char **argv)
bb_info_msg("Received a SIGUSR1");
write_leases();
/* why not just reset the timeout, eh */
- timeout_end = time(0) + server_config.auto_time;
+ timeout_end = monotonic_sec() + server_config.auto_time;
continue;
case SIGTERM:
bb_info_msg("Received a SIGTERM");
@@ -244,7 +244,7 @@ int udhcpd_main(int argc, char **argv)
ret0:
retval = 0;
ret:
- if (server_config.pidfile)
+ /*if (server_config.pidfile) - server_config.pidfile is never NULL */
remove_pidfile(server_config.pidfile);
return retval;
}