diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-07-03 15:47:50 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-07-03 15:47:50 +0000 |
commit | 42b3dea9bfb8ac595c71089ee23012f44dd43eb2 (patch) | |
tree | b7b86d06a574d2af72bc79536d399905b5619959 /networking/udhcp/dhcpd.c | |
parent | 54e19da86d5496ec5f5787b85a2b6342be1d63d4 (diff) | |
download | busybox-w32-42b3dea9bfb8ac595c71089ee23012f44dd43eb2.tar.gz busybox-w32-42b3dea9bfb8ac595c71089ee23012f44dd43eb2.tar.bz2 busybox-w32-42b3dea9bfb8ac595c71089ee23012f44dd43eb2.zip |
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.c | 20 |
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 | } |