svn commit: trunk/busybox: include networking/udhcp

landley at busybox.net landley at busybox.net
Mon Feb 20 23:26:39 UTC 2006


Author: landley
Date: 2006-02-20 15:26:38 -0800 (Mon, 20 Feb 2006)
New Revision: 14152

Log:
Patch from Giuseppe Ciotta to specify retry count.


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


Changeset:
Modified: trunk/busybox/include/usage.h
===================================================================
--- trunk/busybox/include/usage.h	2006-02-20 23:05:06 UTC (rev 14151)
+++ trunk/busybox/include/usage.h	2006-02-20 23:26:38 UTC (rev 14152)
@@ -3239,7 +3239,7 @@
 	"Adjust filesystem options on ext[23] filesystems.\n\n"
 
 #define udhcpc_trivial_usage \
-	"[-Cfbnqv] [-c CID] [-V VCLS] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]"
+	"[-Cfbnqtv] [-c CID] [-V VCLS] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]"
 #define udhcpc_full_usage \
 	"\t-c,\t--clientid=CLIENTID\tSet client identifier\n" \
 	"\t-C,\t--clientid-none\tSuppress default client identifier\n" \
@@ -3254,6 +3254,7 @@
 	"\t-q,\t--quit\tQuit after obtaining lease\n" \
 	"\t-r,\t--request=IP\tIP address to request (default: none)\n" \
 	"\t-s,\t--script=file\tRun file at dhcp events (default: /usr/share/udhcpc/default.script)\n" \
+	"\t-t,\t--retries=NUM\tSend up to NUM request packets\n"\
 	"\t-v,\t--version\tDisplay version"
 
 #define udhcpd_trivial_usage \

Modified: trunk/busybox/networking/udhcp/dhcpc.c
===================================================================
--- trunk/busybox/networking/udhcp/dhcpc.c	2006-02-20 23:05:06 UTC (rev 14151)
+++ trunk/busybox/networking/udhcp/dhcpc.c	2006-02-20 23:26:38 UTC (rev 14152)
@@ -58,6 +58,7 @@
 	.hostname = NULL,
 	.fqdn = NULL,
 	.ifindex = 0,
+	.retries = 3,
 	.arp = "\0\0\0\0\0\0",		/* appease gcc-3.0 */
 };
 
@@ -202,13 +203,14 @@
 		{"request",	required_argument,	0, 'r'},
 		{"script",	required_argument,	0, 's'},
 		{"version",	no_argument,		0, 'v'},
+		{"retries",	required_argument,	0, 't'},		
 		{0, 0, 0, 0}
 	};
 
 	/* get options */
 	while (1) {
 		int option_index = 0;
-		c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qr:s:v", arg_options, &option_index);
+		c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qr:s:t:v", arg_options, &option_index);
 		if (c == -1) break;
 
 		switch (c) {
@@ -284,6 +286,9 @@
 		case 's':
 			client_config.script = optarg;
 			break;
+		case 't':
+			client_config.retries = atoi(optarg);
+			break;
 		case 'v':
 			printf("udhcpcd, version %s\n\n", VERSION);
 			return 0;
@@ -353,7 +358,7 @@
 			/* timeout dropped to zero */
 			switch (state) {
 			case INIT_SELECTING:
-				if (packet_num < 3) {
+				if (packet_num < client_config.retries) {
 					if (packet_num == 0)
 						xid = random_xid();
 
@@ -378,7 +383,7 @@
 				break;
 			case RENEW_REQUESTED:
 			case REQUESTING:
-				if (packet_num < 3) {
+				if (packet_num < client_config.retries) {
 					/* send request packet */
 					if (state == RENEW_REQUESTED)
 						send_renew(xid, server_addr, requested_ip); /* unicast */




More information about the busybox-cvs mailing list