[PATCH] udhcpc: add option to specify number of request packets
Giuseppe Ciotta
giuseppe at telvia.it
Mon Feb 20 11:38:43 UTC 2006
http://bugs.busybox.net/view.php?id=746
My dhcpd is very slow and udhcpc sends by default only 3 requests,
failing to get a valid address, this patch adds -t option to specify
number of requests. Defaults are unchanged.
--
Giuseppe Ciotta
(string 99 105 97 111)
-------------- next part --------------
diff -Nru busybox-1.1.0-orig/networking/udhcp/dhcpc.c busybox-1.1.0/networking/udhcp/dhcpc.c
--- busybox-1.1.0-orig/networking/udhcp/dhcpc.c 2006-01-11 06:43:50.000000000 +0100
+++ busybox-1.1.0/networking/udhcp/dhcpc.c 2006-02-20 11:44:29.000000000 +0100
@@ -70,6 +70,7 @@
.hostname = NULL,
.fqdn = NULL,
.ifindex = 0,
+ .retries = 3,
.arp = "\0\0\0\0\0\0", /* appease gcc-3.0 */
};
@@ -95,6 +96,7 @@
" -r, --request=IP IP address to request (default: none)\n"
" -s, --script=file Run file at dhcp events (default:\n"
" " DEFAULT_SCRIPT ")\n"
+" -t, --retries=NUM Send up to NUM request packets\n"
" -v, --version Display version\n"
);
exit(0);
@@ -214,13 +216,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) {
@@ -296,6 +299,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;
@@ -365,7 +371,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();
@@ -390,7 +396,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 */
diff -Nru busybox-1.1.0-orig/networking/udhcp/dhcpc.h busybox-1.1.0/networking/udhcp/dhcpc.h
--- busybox-1.1.0-orig/networking/udhcp/dhcpc.h 2006-01-11 06:43:50.000000000 +0100
+++ busybox-1.1.0/networking/udhcp/dhcpc.h 2006-02-20 11:42:49.000000000 +0100
@@ -29,6 +29,7 @@
uint8_t *hostname; /* Optional hostname to use */
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 */
uint8_t arp[6]; /* Our arp address */
};
More information about the busybox
mailing list