Fix bug #52704: DHCP and bad OFFER

Stop timeout only if offer is accepted
This commit is contained in:
Dirk Ziegelmeier 2017-12-30 12:17:24 +01:00
parent b536fd9767
commit 6c7e7153bc

View File

@ -337,6 +337,8 @@ dhcp_handle_offer(struct netif *netif, struct dhcp_msg *msg_in)
(void *)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); (void *)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
/* obtain the server address */ /* obtain the server address */
if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_SERVER_ID)) { if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_SERVER_ID)) {
dhcp->request_timeout = 0; /* stop timer */
ip_addr_set_ip4_u32(&dhcp->server_ip_addr, lwip_htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_SERVER_ID))); ip_addr_set_ip4_u32(&dhcp->server_ip_addr, lwip_htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_SERVER_ID)));
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_handle_offer(): server 0x%08"X32_F"\n", LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_handle_offer(): server 0x%08"X32_F"\n",
ip4_addr_get_u32(ip_2_ip4(&dhcp->server_ip_addr)))); ip4_addr_get_u32(ip_2_ip4(&dhcp->server_ip_addr))));
@ -1835,7 +1837,6 @@ dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
/* received a DHCP_OFFER in DHCP_STATE_SELECTING state? */ /* received a DHCP_OFFER in DHCP_STATE_SELECTING state? */
else if ((msg_type == DHCP_OFFER) && (dhcp->state == DHCP_STATE_SELECTING)) { else if ((msg_type == DHCP_OFFER) && (dhcp->state == DHCP_STATE_SELECTING)) {
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("DHCP_OFFER received in DHCP_STATE_SELECTING state\n")); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("DHCP_OFFER received in DHCP_STATE_SELECTING state\n"));
dhcp->request_timeout = 0;
/* remember offered lease */ /* remember offered lease */
dhcp_handle_offer(netif, msg_in); dhcp_handle_offer(netif, msg_in);
} }