mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-04 14:29:39 +00:00
This commit is contained in:
parent
050d233e10
commit
de83c3e9e0
@ -245,6 +245,10 @@ HISTORY
|
||||
|
||||
++ Bugfixes:
|
||||
|
||||
2015-05-19: Simon Goldschmidt
|
||||
* dhcp.h/.c: fixed bugs #45140 and #45141 (dhcp was not stopped correctly after
|
||||
fixing bug #38204)
|
||||
|
||||
2015-03-21: Simon Goldschmidt (patch by Homyak)
|
||||
* tcp_in.c: fixed bug #44766 (LWIP_WND_SCALE: tcphdr->wnd was not scaled in
|
||||
two places)
|
||||
|
@ -356,20 +356,21 @@ dhcp_coarse_tmr(void)
|
||||
/* iterate through all network interfaces */
|
||||
while (netif != NULL) {
|
||||
/* only act on DHCP configured interfaces */
|
||||
if (netif->dhcp != NULL) {
|
||||
struct dhcp* dhcp = netif->dhcp;
|
||||
if ((dhcp != NULL) && (dhcp->state != DHCP_STATE_OFF)) {
|
||||
/* compare lease time to expire timeout */
|
||||
if (++netif->dhcp->lease_used == netif->dhcp->t0_timeout) {
|
||||
if (dhcp->t0_timeout && (++dhcp->lease_used == dhcp->t0_timeout)) {
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_coarse_tmr(): t0 timeout\n"));
|
||||
/* this clients' lease time has expired */
|
||||
dhcp_release(netif);
|
||||
dhcp_discover(netif);
|
||||
/* timer is active (non zero), and triggers (zeroes) now? */
|
||||
} else if (netif->dhcp->t2_rebind_time-- == 1) {
|
||||
} else if (dhcp->t2_rebind_time && (dhcp->t2_rebind_time-- == 1)) {
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_coarse_tmr(): t2 timeout\n"));
|
||||
/* this clients' rebind timeout triggered */
|
||||
dhcp_t2_timeout(netif);
|
||||
/* timer is active (non zero), and triggers (zeroes) now */
|
||||
} else if (netif->dhcp->t1_renew_time-- == 1) {
|
||||
} else if (dhcp->t1_renew_time && (dhcp->t1_renew_time-- == 1)) {
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_coarse_tmr(): t1 timeout\n"));
|
||||
/* this clients' renewal timeout triggered */
|
||||
dhcp_t1_timeout(netif);
|
||||
@ -1204,7 +1205,6 @@ dhcp_release(struct netif *netif)
|
||||
{
|
||||
struct dhcp *dhcp = netif->dhcp;
|
||||
err_t result;
|
||||
u16_t msecs;
|
||||
ip_addr_t server_ip_addr;
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_release()\n"));
|
||||
if (dhcp == NULL) {
|
||||
@ -1223,7 +1223,13 @@ dhcp_release(struct netif *netif)
|
||||
ip4_addr_set_zero(&dhcp->offered_si_addr);
|
||||
#endif /* LWIP_DHCP_BOOTP_FILE */
|
||||
dhcp->offered_t0_lease = dhcp->offered_t1_renew = dhcp->offered_t2_rebind = 0;
|
||||
|
||||
dhcp->t1_renew_time = dhcp->t2_rebind_time = dhcp->lease_used = dhcp->t0_timeout = 0;
|
||||
|
||||
if (!dhcp_supplied_address(netif)) {
|
||||
/* don't issue release message when address is not dhcp-assigned */
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/* create and initialize the DHCP message header */
|
||||
result = dhcp_create_msg(netif, dhcp, DHCP_RELEASE);
|
||||
if (result == ERR_OK) {
|
||||
@ -1238,14 +1244,9 @@ dhcp_release(struct netif *netif)
|
||||
dhcp_delete_msg(dhcp);
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_release: RELEASED, DHCP_STATE_OFF\n"));
|
||||
} else {
|
||||
/* sending release failed, but that's not a problem since the correct behaviour of dhcp does not rely on release */
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("dhcp_release: could not allocate DHCP request\n"));
|
||||
}
|
||||
if (dhcp->tries < 255) {
|
||||
dhcp->tries++;
|
||||
}
|
||||
msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000;
|
||||
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_release(): set request timeout %"U16_F" msecs\n", msecs));
|
||||
/* remove IP address from interface (prevents routing from selecting this interface) */
|
||||
netif_set_addr(netif, IP4_ADDR_ANY, IP4_ADDR_ANY, IP4_ADDR_ANY);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user