diff --git a/dhcp.c b/dhcp.c index 1a0604f..f716975 100644 --- a/dhcp.c +++ b/dhcp.c @@ -406,9 +406,11 @@ static int currticks(void) } +static int wait_timeout [] = { 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 9, 13, 16, 18, 24 }; + #define BACKOFF_LIMIT 7 #define TICKS_PER_SEC 18 -#define MAX_ARP_RETRIES 4 +#define MAX_ARP_RETRIES (sizeof(wait_timeout)/sizeof(int)) static void rfc951_sleep(int exp) { @@ -472,6 +474,8 @@ static int handle_transaction(int s, struct bootp_request * breq, struct bootp_r } while (retry <= MAX_ARP_RETRIES) { + log_message("DHCP: retry=%d (full timeout %d, wait timeout %d)", retry, breq->secs, timeout); + i = sizeof(*breq); if (sendto(s, breq, i, 0, (struct sockaddr *) server_addr, sizeof(*server_addr)) != i) { @@ -541,10 +545,7 @@ static int handle_transaction(int s, struct bootp_request * breq, struct bootp_r } rfc951_sleep(retry); breq->secs = htons ((currticks () - starttime) / 20); - retry++; - timeout *= 2; - if (timeout > 5) - timeout = 5; + timeout = wait_timeout[retry++]; } return -1;