diff --git a/ndhc/arp.c b/ndhc/arp.c index 6523681..69d9f64 100644 --- a/ndhc/arp.c +++ b/ndhc/arp.c @@ -218,6 +218,7 @@ void arp_success(struct client_state_t *cs) inet_ntoa(temp_addr), cs->lease); cs->requestedIP = arp_dhcp_packet.yiaddr; cs->dhcpState = DS_BOUND; + cs->init = 0; ifchange(&arp_dhcp_packet, ((cs->arpPrevState == DS_RENEWING || cs->arpPrevState == DS_REBINDING) diff --git a/ndhc/config.h b/ndhc/config.h index 0a664f1..cc19d2b 100644 --- a/ndhc/config.h +++ b/ndhc/config.h @@ -65,6 +65,7 @@ struct client_state_t { uint32_t requestedIP, serverAddr, routerAddr; uint32_t lease, t1, t2, xid; uint8_t routerArp[6]; + uint8_t init; }; struct client_config_t { diff --git a/ndhc/ndhc.c b/ndhc/ndhc.c index b6a55fd..f9485bb 100644 --- a/ndhc/ndhc.c +++ b/ndhc/ndhc.c @@ -67,6 +67,7 @@ struct client_state_t cs = { .packetNum = 0, .xid = 0, .timeout = 0, + .init = 1, .oldTimeout = 0, .leaseStartTime = 0, .requestedIP = 0, diff --git a/ndhc/timeout.c b/ndhc/timeout.c index 401f039..00785ae 100644 --- a/ndhc/timeout.c +++ b/ndhc/timeout.c @@ -39,12 +39,14 @@ static void init_selecting_timeout(struct client_state_t *cs) cs->timeout = DELAY_SEC * (cs->packetNum + 1) * 1000; cs->packetNum++; } else { - if (client_config.background_if_no_lease) { - log_line("No lease, going to background."); - background(cs); - } else if (client_config.abort_if_no_lease) { - log_line("No lease, failing."); - exit(EXIT_FAILURE); + if (cs->init) { + if (client_config.background_if_no_lease) { + log_line("No lease, going to background."); + background(cs); + } else if (client_config.abort_if_no_lease) { + log_line("No lease, failing."); + exit(EXIT_FAILURE); + } } /* wait to try again */ cs->packetNum = 0;