mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-16 07:09:58 +00:00
Prevent mem_free (leave struct dhcp allocated on dhcp_stop) to prevent calling mem_malloc when restarting dhcp later
This commit is contained in:
parent
c6f7a34abe
commit
81c5d9e983
@ -625,12 +625,11 @@ dhcp_start(struct netif *netif)
|
||||
|
||||
/* clear data structure */
|
||||
memset(dhcp, 0, sizeof(struct dhcp));
|
||||
/* dhcp_set_state(&dhcp, DHCP_OFF); */
|
||||
/* allocate UDP PCB */
|
||||
dhcp->pcb = udp_new();
|
||||
if (dhcp->pcb == NULL) {
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): could not obtain pcb\n"));
|
||||
mem_free((void *)dhcp);
|
||||
netif->dhcp = dhcp = NULL;
|
||||
return ERR_MEM;
|
||||
}
|
||||
#if IP_SOF_BROADCAST
|
||||
@ -672,7 +671,8 @@ dhcp_inform(struct netif *netif)
|
||||
|
||||
LWIP_ERROR("netif != NULL", (netif != NULL), return;);
|
||||
|
||||
memset(&dhcp, 0, sizeof(dhcp));
|
||||
memset(&dhcp, 0, sizeof(struct dhcp));
|
||||
dhcp_set_state(&dhcp, DHCP_INFORM);
|
||||
|
||||
if ((netif->dhcp != NULL) && (netif->dhcp->pcb != NULL)) {
|
||||
/* re-use existing pcb */
|
||||
@ -1214,10 +1214,10 @@ dhcp_stop(struct netif *netif)
|
||||
/* netif is DHCP configured? */
|
||||
if (dhcp != NULL) {
|
||||
#if LWIP_DHCP_AUTOIP_COOP
|
||||
if(dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_ON) {
|
||||
autoip_stop(netif);
|
||||
dhcp->autoip_coop_state = DHCP_AUTOIP_COOP_STATE_OFF;
|
||||
}
|
||||
if(dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_ON) {
|
||||
autoip_stop(netif);
|
||||
dhcp->autoip_coop_state = DHCP_AUTOIP_COOP_STATE_OFF;
|
||||
}
|
||||
#endif /* LWIP_DHCP_AUTOIP_COOP */
|
||||
|
||||
if (dhcp->pcb != NULL) {
|
||||
@ -1225,8 +1225,7 @@ dhcp_stop(struct netif *netif)
|
||||
dhcp->pcb = NULL;
|
||||
}
|
||||
LWIP_ASSERT("reply wasn't freed", dhcp->msg_in == NULL);
|
||||
mem_free((void *)dhcp);
|
||||
netif->dhcp = NULL;
|
||||
dhcp_set_state(dhcp, DHCP_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,6 +152,7 @@ void dhcp_fine_tmr(void);
|
||||
#define DHCP_SERVER_PORT 67
|
||||
|
||||
/** DHCP client states */
|
||||
#define DHCP_OFF 0
|
||||
#define DHCP_REQUESTING 1
|
||||
#define DHCP_INIT 2
|
||||
#define DHCP_REBOOTING 3
|
||||
@ -164,7 +165,6 @@ void dhcp_fine_tmr(void);
|
||||
#define DHCP_BOUND 10
|
||||
/** not yet implemented #define DHCP_RELEASING 11 */
|
||||
#define DHCP_BACKING_OFF 12
|
||||
#define DHCP_OFF 13
|
||||
|
||||
/** AUTOIP cooperatation flags */
|
||||
#define DHCP_AUTOIP_COOP_STATE_OFF 0
|
||||
|
Loading…
Reference in New Issue
Block a user