If a lease is negotiated, then expires after renewal attempts, don't time out

and exit the daemon as would be desirable at startup.  Just keep trying.
This commit is contained in:
Nicholas J. Kain 2011-06-26 18:21:40 -04:00
parent 057211d5f5
commit 1e2698b402
4 changed files with 11 additions and 6 deletions

View File

@ -218,6 +218,7 @@ void arp_success(struct client_state_t *cs)
inet_ntoa(temp_addr), cs->lease); inet_ntoa(temp_addr), cs->lease);
cs->requestedIP = arp_dhcp_packet.yiaddr; cs->requestedIP = arp_dhcp_packet.yiaddr;
cs->dhcpState = DS_BOUND; cs->dhcpState = DS_BOUND;
cs->init = 0;
ifchange(&arp_dhcp_packet, ifchange(&arp_dhcp_packet,
((cs->arpPrevState == DS_RENEWING || ((cs->arpPrevState == DS_RENEWING ||
cs->arpPrevState == DS_REBINDING) cs->arpPrevState == DS_REBINDING)

View File

@ -65,6 +65,7 @@ struct client_state_t {
uint32_t requestedIP, serverAddr, routerAddr; uint32_t requestedIP, serverAddr, routerAddr;
uint32_t lease, t1, t2, xid; uint32_t lease, t1, t2, xid;
uint8_t routerArp[6]; uint8_t routerArp[6];
uint8_t init;
}; };
struct client_config_t { struct client_config_t {

View File

@ -67,6 +67,7 @@ struct client_state_t cs = {
.packetNum = 0, .packetNum = 0,
.xid = 0, .xid = 0,
.timeout = 0, .timeout = 0,
.init = 1,
.oldTimeout = 0, .oldTimeout = 0,
.leaseStartTime = 0, .leaseStartTime = 0,
.requestedIP = 0, .requestedIP = 0,

View File

@ -39,12 +39,14 @@ static void init_selecting_timeout(struct client_state_t *cs)
cs->timeout = DELAY_SEC * (cs->packetNum + 1) * 1000; cs->timeout = DELAY_SEC * (cs->packetNum + 1) * 1000;
cs->packetNum++; cs->packetNum++;
} else { } else {
if (client_config.background_if_no_lease) { if (cs->init) {
log_line("No lease, going to background."); if (client_config.background_if_no_lease) {
background(cs); log_line("No lease, going to background.");
} else if (client_config.abort_if_no_lease) { background(cs);
log_line("No lease, failing."); } else if (client_config.abort_if_no_lease) {
exit(EXIT_FAILURE); log_line("No lease, failing.");
exit(EXIT_FAILURE);
}
} }
/* wait to try again */ /* wait to try again */
cs->packetNum = 0; cs->packetNum = 0;