mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-19 05:10:40 +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 */
|
/* clear data structure */
|
||||||
memset(dhcp, 0, sizeof(struct dhcp));
|
memset(dhcp, 0, sizeof(struct dhcp));
|
||||||
|
/* dhcp_set_state(&dhcp, DHCP_OFF); */
|
||||||
/* allocate UDP PCB */
|
/* allocate UDP PCB */
|
||||||
dhcp->pcb = udp_new();
|
dhcp->pcb = udp_new();
|
||||||
if (dhcp->pcb == NULL) {
|
if (dhcp->pcb == NULL) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): could not obtain pcb\n"));
|
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;
|
return ERR_MEM;
|
||||||
}
|
}
|
||||||
#if IP_SOF_BROADCAST
|
#if IP_SOF_BROADCAST
|
||||||
@ -672,7 +671,8 @@ dhcp_inform(struct netif *netif)
|
|||||||
|
|
||||||
LWIP_ERROR("netif != NULL", (netif != NULL), return;);
|
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)) {
|
if ((netif->dhcp != NULL) && (netif->dhcp->pcb != NULL)) {
|
||||||
/* re-use existing pcb */
|
/* re-use existing pcb */
|
||||||
@ -1225,8 +1225,7 @@ dhcp_stop(struct netif *netif)
|
|||||||
dhcp->pcb = NULL;
|
dhcp->pcb = NULL;
|
||||||
}
|
}
|
||||||
LWIP_ASSERT("reply wasn't freed", dhcp->msg_in == NULL);
|
LWIP_ASSERT("reply wasn't freed", dhcp->msg_in == NULL);
|
||||||
mem_free((void *)dhcp);
|
dhcp_set_state(dhcp, DHCP_OFF);
|
||||||
netif->dhcp = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +152,7 @@ void dhcp_fine_tmr(void);
|
|||||||
#define DHCP_SERVER_PORT 67
|
#define DHCP_SERVER_PORT 67
|
||||||
|
|
||||||
/** DHCP client states */
|
/** DHCP client states */
|
||||||
|
#define DHCP_OFF 0
|
||||||
#define DHCP_REQUESTING 1
|
#define DHCP_REQUESTING 1
|
||||||
#define DHCP_INIT 2
|
#define DHCP_INIT 2
|
||||||
#define DHCP_REBOOTING 3
|
#define DHCP_REBOOTING 3
|
||||||
@ -164,7 +165,6 @@ void dhcp_fine_tmr(void);
|
|||||||
#define DHCP_BOUND 10
|
#define DHCP_BOUND 10
|
||||||
/** not yet implemented #define DHCP_RELEASING 11 */
|
/** not yet implemented #define DHCP_RELEASING 11 */
|
||||||
#define DHCP_BACKING_OFF 12
|
#define DHCP_BACKING_OFF 12
|
||||||
#define DHCP_OFF 13
|
|
||||||
|
|
||||||
/** AUTOIP cooperatation flags */
|
/** AUTOIP cooperatation flags */
|
||||||
#define DHCP_AUTOIP_COOP_STATE_OFF 0
|
#define DHCP_AUTOIP_COOP_STATE_OFF 0
|
||||||
|
Loading…
Reference in New Issue
Block a user