summaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpd.c
diff options
context:
space:
mode:
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 9dbd35d4e..8cac68195 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -30,7 +30,8 @@ int udhcpd_main(int argc, char **argv)
30 struct dhcpMessage packet; 30 struct dhcpMessage packet;
31 uint8_t *state, *server_id, *requested; 31 uint8_t *state, *server_id, *requested;
32 uint32_t server_id_align, requested_align, static_lease_ip; 32 uint32_t server_id_align, requested_align, static_lease_ip;
33 unsigned long timeout_end, num_ips; 33 unsigned timeout_end;
34 unsigned num_ips;
34 struct option_set *option; 35 struct option_set *option;
35 struct dhcpOfferedAddr *lease, static_lease; 36 struct dhcpOfferedAddr *lease, static_lease;
36 37
@@ -48,7 +49,7 @@ int udhcpd_main(int argc, char **argv)
48 49
49 /* Would rather not do read_config before daemonization - 50 /* Would rather not do read_config before daemonization -
50 * otherwise NOMMU machines will parse config twice */ 51 * otherwise NOMMU machines will parse config twice */
51 read_config(argc < 2 ? DHCPD_CONF_FILE : argv[1]); 52 read_config(argv[1] ? argv[1] : DHCPD_CONF_FILE);
52 53
53 udhcp_make_pidfile(server_config.pidfile); 54 udhcp_make_pidfile(server_config.pidfile);
54 55
@@ -62,9 +63,8 @@ int udhcpd_main(int argc, char **argv)
62 /* Sanity check */ 63 /* Sanity check */
63 num_ips = server_config.end_ip - server_config.start_ip + 1; 64 num_ips = server_config.end_ip - server_config.start_ip + 1;
64 if (server_config.max_leases > num_ips) { 65 if (server_config.max_leases > num_ips) {
65 bb_error_msg("max_leases=%lu is too big, " 66 bb_error_msg("max_leases=%u is too big, setting to %u",
66 "setting to %lu", 67 (unsigned)server_config.max_leases, num_ips);
67 server_config.max_leases, num_ips);
68 server_config.max_leases = num_ips; 68 server_config.max_leases = num_ips;
69 } 69 }
70 70
@@ -80,7 +80,7 @@ int udhcpd_main(int argc, char **argv)
80 /* Setup the signal pipe */ 80 /* Setup the signal pipe */
81 udhcp_sp_setup(); 81 udhcp_sp_setup();
82 82
83 timeout_end = time(0) + server_config.auto_time; 83 timeout_end = monotonic_sec() + server_config.auto_time;
84 while (1) { /* loop until universe collapses */ 84 while (1) { /* loop until universe collapses */
85 85
86 if (server_socket < 0) { 86 if (server_socket < 0) {
@@ -90,7 +90,7 @@ int udhcpd_main(int argc, char **argv)
90 90
91 max_sock = udhcp_sp_fd_set(&rfds, server_socket); 91 max_sock = udhcp_sp_fd_set(&rfds, server_socket);
92 if (server_config.auto_time) { 92 if (server_config.auto_time) {
93 tv.tv_sec = timeout_end - time(0); 93 tv.tv_sec = timeout_end - monotonic_sec();
94 tv.tv_usec = 0; 94 tv.tv_usec = 0;
95 } 95 }
96 retval = 0; 96 retval = 0;
@@ -100,7 +100,7 @@ int udhcpd_main(int argc, char **argv)
100 } 100 }
101 if (retval == 0) { 101 if (retval == 0) {
102 write_leases(); 102 write_leases();
103 timeout_end = time(0) + server_config.auto_time; 103 timeout_end = monotonic_sec() + server_config.auto_time;
104 continue; 104 continue;
105 } 105 }
106 if (retval < 0 && errno != EINTR) { 106 if (retval < 0 && errno != EINTR) {
@@ -113,7 +113,7 @@ int udhcpd_main(int argc, char **argv)
113 bb_info_msg("Received a SIGUSR1"); 113 bb_info_msg("Received a SIGUSR1");
114 write_leases(); 114 write_leases();
115 /* why not just reset the timeout, eh */ 115 /* why not just reset the timeout, eh */
116 timeout_end = time(0) + server_config.auto_time; 116 timeout_end = monotonic_sec() + server_config.auto_time;
117 continue; 117 continue;
118 case SIGTERM: 118 case SIGTERM:
119 bb_info_msg("Received a SIGTERM"); 119 bb_info_msg("Received a SIGTERM");
@@ -244,7 +244,7 @@ int udhcpd_main(int argc, char **argv)
244 ret0: 244 ret0:
245 retval = 0; 245 retval = 0;
246 ret: 246 ret:
247 if (server_config.pidfile) 247 /*if (server_config.pidfile) - server_config.pidfile is never NULL */
248 remove_pidfile(server_config.pidfile); 248 remove_pidfile(server_config.pidfile);
249 return retval; 249 return retval;
250} 250}