summaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpc.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-11-29 08:17:45 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-11-29 08:17:45 +0000
commitb539c8452f823a377bf629cf0e44ccda4a16c6c4 (patch)
treee131460f8227136ba2a76b1cc57efb491bd2f548 /networking/udhcp/dhcpc.c
parent64309f8669f08f2c3c16a3b5bf82d9cae84ec388 (diff)
downloadbusybox-w32-b539c8452f823a377bf629cf0e44ccda4a16c6c4.tar.gz
busybox-w32-b539c8452f823a377bf629cf0e44ccda4a16c6c4.tar.bz2
busybox-w32-b539c8452f823a377bf629cf0e44ccda4a16c6c4.zip
dhcp: heed TODO item - divorced options from their string descriptions
code shrink while at it. function old new delta dhcp_option_strings - 258 +258 udhcp_run_script 1135 1174 +39 dhcp_option_lengths - 11 +11 udhcp_add_simple_option 93 92 -1 packet_num 4 - -4 read_opt 746 739 -7 udhcp_option_lengths 11 - -11 udhcpc_main 2590 2494 -96 dhcp_options 490 70 -420 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 1/4 up/down: 308/-539) Total: -231 bytes text data bss dec hex filename 775309 929 9100 785338 bfbba busybox_old 775098 929 9084 785111 bfad7 busybox_unstripped
Diffstat (limited to 'networking/udhcp/dhcpc.c')
-rw-r--r--networking/udhcp/dhcpc.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 6ade1ee34..d8077f7e8 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -19,15 +19,9 @@
19#include "options.h" 19#include "options.h"
20 20
21 21
22/* Something is definitely wrong here. IPv4 addresses
23 * in variables of type long?? BTW, we use inet_ntoa()
24 * in the code. Manpage says that struct in_addr has a member of type long (!)
25 * which holds IPv4 address, and the struct is passed by value (!!)
26 */
27static int timeout; /* = 0. Must be signed */ 22static int timeout; /* = 0. Must be signed */
28static uint32_t requested_ip; /* = 0 */ 23static uint32_t requested_ip; /* = 0 */
29static uint32_t server_addr; 24static uint32_t server_addr;
30static int packet_num; /* = 0 */
31static int sockfd = -1; 25static int sockfd = -1;
32 26
33#define LISTEN_NONE 0 27#define LISTEN_NONE 0
@@ -74,12 +68,6 @@ static void perform_renew(void)
74 case INIT_SELECTING: 68 case INIT_SELECTING:
75 break; 69 break;
76 } 70 }
77
78 /* start things over */
79 packet_num = 0;
80
81 /* Kill any timeouts because the user wants this to hurry along */
82 timeout = 0;
83} 71}
84 72
85 73
@@ -153,8 +141,11 @@ int udhcpc_main(int argc, char **argv)
153 int discover_retries = 3; 141 int discover_retries = 3;
154 uint32_t xid = 0; 142 uint32_t xid = 0;
155 uint32_t lease_seconds = 0; /* can be given as 32-bit quantity */ 143 uint32_t lease_seconds = 0; /* can be given as 32-bit quantity */
156 unsigned t1 = 0, t2 = 0; /* what a wonderful names */ 144 int packet_num;
157 unsigned timestamp_got_lease = 0; /* for gcc */ 145 /* t1, t2... what a wonderful names... */
146 unsigned t1 = t1; /* for gcc */
147 unsigned t2 = t2;
148 unsigned timestamp_got_lease = timestamp_got_lease;
158 unsigned opt; 149 unsigned opt;
159 int max_fd; 150 int max_fd;
160 int retval; 151 int retval;
@@ -315,6 +306,7 @@ int udhcpc_main(int argc, char **argv)
315 state = INIT_SELECTING; 306 state = INIT_SELECTING;
316 udhcp_run_script(NULL, "deconfig"); 307 udhcp_run_script(NULL, "deconfig");
317 change_listen_mode(LISTEN_RAW); 308 change_listen_mode(LISTEN_RAW);
309 packet_num = 0;
318 310
319 /* Main event loop. select() waits on signal pipe and possibly 311 /* Main event loop. select() waits on signal pipe and possibly
320 * on sockfd. 312 * on sockfd.
@@ -585,6 +577,10 @@ int udhcpc_main(int argc, char **argv)
585 switch (signo) { 577 switch (signo) {
586 case SIGUSR1: 578 case SIGUSR1:
587 perform_renew(); 579 perform_renew();
580 /* start things over */
581 packet_num = 0;
582 /* Kill any timeouts because the user wants this to hurry along */
583 timeout = 0;
588 break; 584 break;
589 case SIGUSR2: 585 case SIGUSR2:
590 perform_release(); 586 perform_release();