diff options
author | Eric Andersen <andersen@codepoet.org> | 2006-03-20 17:37:00 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2006-03-20 17:37:00 +0000 |
commit | 28a6afe975c65ee25e5739b1d52eb24b2a8f27c9 (patch) | |
tree | c63bdffb45c6d2e1fd1d00b2083a97b38833a7c0 | |
parent | c30f445b08e811ec7e339e7efad8f7cd47c3ad59 (diff) | |
download | busybox-w32-28a6afe975c65ee25e5739b1d52eb24b2a8f27c9.tar.gz busybox-w32-28a6afe975c65ee25e5739b1d52eb24b2a8f27c9.tar.bz2 busybox-w32-28a6afe975c65ee25e5739b1d52eb24b2a8f27c9.zip |
Roy Walker writes:
Here is a patch against the current subversion repository, that makes
udhcpc have an adjustable timeout. Works for both foreground and before
it drops to the background. This brings it more in-line with ISC dhcpc.
Use like so:
udhcpc --timeout=10 ...
or
udhcpc -T 10 ...
Still shooting for 1.1.1 this month? Would really be great if you could
get this in that release.
Please give credit to Paul Pacheco - ppacheco@gmail.com.
-rw-r--r-- | networking/udhcp/dhcpc.c | 11 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.h | 1 |
2 files changed, 10 insertions, 2 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 7e7f94a5a..0c85eca83 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -59,6 +59,7 @@ struct client_config_t client_config = { | |||
59 | .fqdn = NULL, | 59 | .fqdn = NULL, |
60 | .ifindex = 0, | 60 | .ifindex = 0, |
61 | .retries = 3, | 61 | .retries = 3, |
62 | .timeout = 3, | ||
62 | .arp = "\0\0\0\0\0\0", /* appease gcc-3.0 */ | 63 | .arp = "\0\0\0\0\0\0", /* appease gcc-3.0 */ |
63 | }; | 64 | }; |
64 | 65 | ||
@@ -84,6 +85,8 @@ static void ATTRIBUTE_NORETURN show_usage(void) | |||
84 | " -r, --request=IP IP address to request (default: none)\n" | 85 | " -r, --request=IP IP address to request (default: none)\n" |
85 | " -s, --script=file Run file at dhcp events (default:\n" | 86 | " -s, --script=file Run file at dhcp events (default:\n" |
86 | " " DEFAULT_SCRIPT ")\n" | 87 | " " DEFAULT_SCRIPT ")\n" |
88 | " -T, --timeout=seconds Try to get the lease for the amount of\n" | ||
89 | " seconds (default: 3)\n" | ||
87 | " -v, --version Display version\n" | 90 | " -v, --version Display version\n" |
88 | ); | 91 | ); |
89 | exit(0); | 92 | exit(0); |
@@ -202,6 +205,7 @@ int main(int argc, char *argv[]) | |||
202 | {"quit", no_argument, 0, 'q'}, | 205 | {"quit", no_argument, 0, 'q'}, |
203 | {"request", required_argument, 0, 'r'}, | 206 | {"request", required_argument, 0, 'r'}, |
204 | {"script", required_argument, 0, 's'}, | 207 | {"script", required_argument, 0, 's'}, |
208 | {"timeout", required_argument, 0, 'T'}, | ||
205 | {"version", no_argument, 0, 'v'}, | 209 | {"version", no_argument, 0, 'v'}, |
206 | {"retries", required_argument, 0, 't'}, | 210 | {"retries", required_argument, 0, 't'}, |
207 | {0, 0, 0, 0} | 211 | {0, 0, 0, 0} |
@@ -210,7 +214,7 @@ int main(int argc, char *argv[]) | |||
210 | /* get options */ | 214 | /* get options */ |
211 | while (1) { | 215 | while (1) { |
212 | int option_index = 0; | 216 | int option_index = 0; |
213 | c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qr:s:t:v", arg_options, &option_index); | 217 | c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qr:s:T:t:v", arg_options, &option_index); |
214 | if (c == -1) break; | 218 | if (c == -1) break; |
215 | 219 | ||
216 | switch (c) { | 220 | switch (c) { |
@@ -286,6 +290,9 @@ int main(int argc, char *argv[]) | |||
286 | case 's': | 290 | case 's': |
287 | client_config.script = optarg; | 291 | client_config.script = optarg; |
288 | break; | 292 | break; |
293 | case 'T': | ||
294 | client_config.timeout = atoi(optarg); | ||
295 | break; | ||
289 | case 't': | 296 | case 't': |
290 | client_config.retries = atoi(optarg); | 297 | client_config.retries = atoi(optarg); |
291 | break; | 298 | break; |
@@ -365,7 +372,7 @@ int main(int argc, char *argv[]) | |||
365 | /* send discover packet */ | 372 | /* send discover packet */ |
366 | send_discover(xid, requested_ip); /* broadcast */ | 373 | send_discover(xid, requested_ip); /* broadcast */ |
367 | 374 | ||
368 | timeout = now + ((packet_num == 2) ? 4 : 2); | 375 | timeout = now + client_config.timeout; |
369 | packet_num++; | 376 | packet_num++; |
370 | } else { | 377 | } else { |
371 | run_script(NULL, "leasefail"); | 378 | run_script(NULL, "leasefail"); |
diff --git a/networking/udhcp/dhcpc.h b/networking/udhcp/dhcpc.h index 808e91924..80c3fc2f8 100644 --- a/networking/udhcp/dhcpc.h +++ b/networking/udhcp/dhcpc.h | |||
@@ -30,6 +30,7 @@ struct client_config_t { | |||
30 | uint8_t *fqdn; /* Optional fully qualified domain name to use */ | 30 | uint8_t *fqdn; /* Optional fully qualified domain name to use */ |
31 | int ifindex; /* Index number of the interface to use */ | 31 | int ifindex; /* Index number of the interface to use */ |
32 | int retries; /* Max number of request packets */ | 32 | int retries; /* Max number of request packets */ |
33 | int timeout; /* Number of seconds to try to get a lease */ | ||
33 | uint8_t arp[6]; /* Our arp address */ | 34 | uint8_t arp[6]; /* Our arp address */ |
34 | }; | 35 | }; |
35 | 36 | ||