svn commit: trunk/busybox/networking/udhcp

andersen at busybox.net andersen at busybox.net
Mon Mar 20 17:37:02 UTC 2006


Author: andersen
Date: 2006-03-20 09:37:00 -0800 (Mon, 20 Mar 2006)
New Revision: 14581

Log:
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 at gmail.com.



Modified:
   trunk/busybox/networking/udhcp/dhcpc.c
   trunk/busybox/networking/udhcp/dhcpc.h


Changeset:
Modified: trunk/busybox/networking/udhcp/dhcpc.c
===================================================================
--- trunk/busybox/networking/udhcp/dhcpc.c	2006-03-20 09:42:12 UTC (rev 14580)
+++ trunk/busybox/networking/udhcp/dhcpc.c	2006-03-20 17:37:00 UTC (rev 14581)
@@ -59,6 +59,7 @@
 	.fqdn = NULL,
 	.ifindex = 0,
 	.retries = 3,
+	.timeout = 3,
 	.arp = "\0\0\0\0\0\0",		/* appease gcc-3.0 */
 };
 
@@ -84,6 +85,8 @@
 "  -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 @@
 		{"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 @@
 	/* 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 @@
 		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 @@
 					/* 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");

Modified: trunk/busybox/networking/udhcp/dhcpc.h
===================================================================
--- trunk/busybox/networking/udhcp/dhcpc.h	2006-03-20 09:42:12 UTC (rev 14580)
+++ trunk/busybox/networking/udhcp/dhcpc.h	2006-03-20 17:37:00 UTC (rev 14581)
@@ -30,6 +30,7 @@
 	uint8_t *fqdn;			/* Optional fully qualified domain name to use */
 	int ifindex;			/* Index number of the interface to use */
 	int retries;			/* Max number of request packets */        
+	int timeout;			/* Number of seconds to try to get a lease */
 	uint8_t arp[6];			/* Our arp address */
 };
 




More information about the busybox-cvs mailing list