summaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpc.c
diff options
context:
space:
mode:
authorEric Andersen2006-03-20 17:37:00 +0000
committerEric Andersen2006-03-20 17:37:00 +0000
commit28a6afe975c65ee25e5739b1d52eb24b2a8f27c9 (patch)
treec63bdffb45c6d2e1fd1d00b2083a97b38833a7c0 /networking/udhcp/dhcpc.c
parentc30f445b08e811ec7e339e7efad8f7cd47c3ad59 (diff)
downloadbusybox-28a6afe975c65ee25e5739b1d52eb24b2a8f27c9.zip
busybox-28a6afe975c65ee25e5739b1d52eb24b2a8f27c9.tar.gz
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.
Diffstat (limited to 'networking/udhcp/dhcpc.c')
-rw-r--r--networking/udhcp/dhcpc.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 7e7f94a..0c85eca 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -59,6 +59,7 @@ struct client_config_t client_config = {
.fqdn = NULL,
.ifindex = 0,
.retries = 3,
+ .timeout = 3,
.arp = "\0\0\0\0\0\0", /* appease gcc-3.0 */
};
@@ -84,6 +85,8 @@ static void ATTRIBUTE_NORETURN show_usage(void)
" -r, --request=IP IP address to request (default: none)\n"
" -s, --script=file Run file at dhcp events (default:\n"
" " DEFAULT_SCRIPT ")\n"
+" -T, --timeout=seconds Try to get the lease for the amount of\n"
+" seconds (default: 3)\n"
" -v, --version Display version\n"
);
exit(0);
@@ -202,6 +205,7 @@ int main(int argc, char *argv[])
{"quit", no_argument, 0, 'q'},
{"request", required_argument, 0, 'r'},
{"script", required_argument, 0, 's'},
+ {"timeout", required_argument, 0, 'T'},
{"version", no_argument, 0, 'v'},
{"retries", required_argument, 0, 't'},
{0, 0, 0, 0}
@@ -210,7 +214,7 @@ int main(int argc, char *argv[])
/* get options */
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qr:s:t:v", arg_options, &option_index);
+ c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qr:s:T:t:v", arg_options, &option_index);
if (c == -1) break;
switch (c) {
@@ -286,6 +290,9 @@ int main(int argc, char *argv[])
case 's':
client_config.script = optarg;
break;
+ case 'T':
+ client_config.timeout = atoi(optarg);
+ break;
case 't':
client_config.retries = atoi(optarg);
break;
@@ -365,7 +372,7 @@ int main(int argc, char *argv[])
/* send discover packet */
send_discover(xid, requested_ip); /* broadcast */
- timeout = now + ((packet_num == 2) ? 4 : 2);
+ timeout = now + client_config.timeout;
packet_num++;
} else {
run_script(NULL, "leasefail");