DHCP: fixed timeout for DISCOVER request
This commit is contained in:
parent
41bb05e67e
commit
8c1beeb584
11
dhcp.c
11
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 BACKOFF_LIMIT 7
|
||||||
#define TICKS_PER_SEC 18
|
#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)
|
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) {
|
while (retry <= MAX_ARP_RETRIES) {
|
||||||
|
log_message("DHCP: retry=%d (full timeout %d, wait timeout %d)", retry, breq->secs, timeout);
|
||||||
|
|
||||||
i = sizeof(*breq);
|
i = sizeof(*breq);
|
||||||
|
|
||||||
if (sendto(s, breq, i, 0, (struct sockaddr *) server_addr, sizeof(*server_addr)) != i) {
|
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);
|
rfc951_sleep(retry);
|
||||||
breq->secs = htons ((currticks () - starttime) / 20);
|
breq->secs = htons ((currticks () - starttime) / 20);
|
||||||
retry++;
|
timeout = wait_timeout[retry++];
|
||||||
timeout *= 2;
|
|
||||||
if (timeout > 5)
|
|
||||||
timeout = 5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user