mirror of
https://github.com/espressif/esp-lwip.git
synced 2026-10-26 01:04:03 +00:00
dhcp: Add dhcp state debug info
Picked from espressif/esp-lwip@9c62fd4e Ref IDF-4817
This commit is contained in:
+13
-5
@@ -318,6 +318,7 @@ dhcp_handle_nak(struct netif *netif)
|
|||||||
/* Change to a defined state - set this before assigning the address
|
/* Change to a defined state - set this before assigning the address
|
||||||
to ensure the callback can use dhcp_supplied_address() */
|
to ensure the callback can use dhcp_supplied_address() */
|
||||||
dhcp_set_state(dhcp, DHCP_STATE_BACKING_OFF);
|
dhcp_set_state(dhcp, DHCP_STATE_BACKING_OFF);
|
||||||
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_handle_nak(): dhcp state is BACKING_OFF\n"));
|
||||||
/* remove IP address from interface (must no longer be used, as per RFC2131) */
|
/* remove IP address from interface (must no longer be used, as per RFC2131) */
|
||||||
netif_set_addr(netif, IP4_ADDR_ANY4, IP4_ADDR_ANY4, IP4_ADDR_ANY4);
|
netif_set_addr(netif, IP4_ADDR_ANY4, IP4_ADDR_ANY4, IP4_ADDR_ANY4);
|
||||||
/* We can immediately restart discovery */
|
/* We can immediately restart discovery */
|
||||||
@@ -343,6 +344,7 @@ dhcp_check(struct netif *netif)
|
|||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_check(netif=%p) %c%c\n", (void *)netif, (s16_t)netif->name[0],
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_check(netif=%p) %c%c\n", (void *)netif, (s16_t)netif->name[0],
|
||||||
(s16_t)netif->name[1]));
|
(s16_t)netif->name[1]));
|
||||||
dhcp_set_state(dhcp, DHCP_STATE_CHECKING);
|
dhcp_set_state(dhcp, DHCP_STATE_CHECKING);
|
||||||
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_check(): dhcp state is CHECKING\n"));
|
||||||
/* create an ARP query for the offered IP address, expecting that no host
|
/* create an ARP query for the offered IP address, expecting that no host
|
||||||
responds, as the IP address should not be in use. */
|
responds, as the IP address should not be in use. */
|
||||||
result = etharp_query(netif, &dhcp->offered_ip_addr, NULL);
|
result = etharp_query(netif, &dhcp->offered_ip_addr, NULL);
|
||||||
@@ -413,6 +415,7 @@ dhcp_select(struct netif *netif)
|
|||||||
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_select(netif=%p) %c%c%"U16_F"\n", (void *)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_select(netif=%p) %c%c%"U16_F"\n", (void *)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
|
||||||
dhcp_set_state(dhcp, DHCP_STATE_REQUESTING);
|
dhcp_set_state(dhcp, DHCP_STATE_REQUESTING);
|
||||||
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_select(): dhcp state is REQUESTING\n"));
|
||||||
|
|
||||||
/* create and initialize the DHCP message header */
|
/* create and initialize the DHCP message header */
|
||||||
p_out = dhcp_create_msg(netif, dhcp, DHCP_REQUEST, &options_out_len);
|
p_out = dhcp_create_msg(netif, dhcp, DHCP_REQUEST, &options_out_len);
|
||||||
@@ -832,6 +835,7 @@ dhcp_start(struct netif *netif)
|
|||||||
if (!netif_is_link_up(netif)) {
|
if (!netif_is_link_up(netif)) {
|
||||||
/* set state INIT and wait for dhcp_network_changed() to call dhcp_discover() */
|
/* set state INIT and wait for dhcp_network_changed() to call dhcp_discover() */
|
||||||
dhcp_set_state(dhcp, DHCP_STATE_INIT);
|
dhcp_set_state(dhcp, DHCP_STATE_INIT);
|
||||||
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_start(): dhcp state is INIT\n"));
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -877,7 +881,7 @@ dhcp_inform(struct netif *netif)
|
|||||||
|
|
||||||
memset(&dhcp, 0, sizeof(struct dhcp));
|
memset(&dhcp, 0, sizeof(struct dhcp));
|
||||||
dhcp_set_state(&dhcp, DHCP_STATE_INFORMING);
|
dhcp_set_state(&dhcp, DHCP_STATE_INFORMING);
|
||||||
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_inform(): dhcp state is INFORMING\n"));
|
||||||
/* create and initialize the DHCP message header */
|
/* create and initialize the DHCP message header */
|
||||||
p_out = dhcp_create_msg(netif, &dhcp, DHCP_INFORM, &options_out_len);
|
p_out = dhcp_create_msg(netif, &dhcp, DHCP_INFORM, &options_out_len);
|
||||||
if (p_out != NULL) {
|
if (p_out != NULL) {
|
||||||
@@ -993,6 +997,7 @@ dhcp_decline(struct netif *netif)
|
|||||||
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_decline()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_decline()\n"));
|
||||||
dhcp_set_state(dhcp, DHCP_STATE_BACKING_OFF);
|
dhcp_set_state(dhcp, DHCP_STATE_BACKING_OFF);
|
||||||
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_decline(): dhcp state is BACKING_OFF\n"));
|
||||||
/* create and initialize the DHCP message header */
|
/* create and initialize the DHCP message header */
|
||||||
p_out = dhcp_create_msg(netif, dhcp, DHCP_DECLINE, &options_out_len);
|
p_out = dhcp_create_msg(netif, dhcp, DHCP_DECLINE, &options_out_len);
|
||||||
if (p_out != NULL) {
|
if (p_out != NULL) {
|
||||||
@@ -1042,6 +1047,8 @@ dhcp_discover(struct netif *netif)
|
|||||||
|
|
||||||
ip4_addr_set_any(&dhcp->offered_ip_addr);
|
ip4_addr_set_any(&dhcp->offered_ip_addr);
|
||||||
dhcp_set_state(dhcp, DHCP_STATE_SELECTING);
|
dhcp_set_state(dhcp, DHCP_STATE_SELECTING);
|
||||||
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_discover(): dhcp state is DISCOVER\n"));
|
||||||
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, ("dhcp_select: could not allocate DHCP request\n"));
|
||||||
/* create and initialize the DHCP message header */
|
/* create and initialize the DHCP message header */
|
||||||
p_out = dhcp_create_msg(netif, dhcp, DHCP_DISCOVER, &options_out_len);
|
p_out = dhcp_create_msg(netif, dhcp, DHCP_DISCOVER, &options_out_len);
|
||||||
if (p_out != NULL) {
|
if (p_out != NULL) {
|
||||||
@@ -1161,7 +1168,7 @@ dhcp_bind(struct netif *netif)
|
|||||||
/* netif is now bound to DHCP leased address - set this before assigning the address
|
/* netif is now bound to DHCP leased address - set this before assigning the address
|
||||||
to ensure the callback can use dhcp_supplied_address() */
|
to ensure the callback can use dhcp_supplied_address() */
|
||||||
dhcp_set_state(dhcp, DHCP_STATE_BOUND);
|
dhcp_set_state(dhcp, DHCP_STATE_BOUND);
|
||||||
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_bind(): dhcp state is BOUND\n"));
|
||||||
netif_set_addr(netif, &dhcp->offered_ip_addr, &sn_mask, &gw_addr);
|
netif_set_addr(netif, &dhcp->offered_ip_addr, &sn_mask, &gw_addr);
|
||||||
/* interface is used by routing now that an address is set */
|
/* interface is used by routing now that an address is set */
|
||||||
}
|
}
|
||||||
@@ -1185,7 +1192,7 @@ dhcp_renew(struct netif *netif)
|
|||||||
LWIP_ASSERT_CORE_LOCKED();
|
LWIP_ASSERT_CORE_LOCKED();
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_renew()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_renew()\n"));
|
||||||
dhcp_set_state(dhcp, DHCP_STATE_RENEWING);
|
dhcp_set_state(dhcp, DHCP_STATE_RENEWING);
|
||||||
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_renew(): dhcp state is RENEWING\n"));
|
||||||
/* create and initialize the DHCP message header */
|
/* create and initialize the DHCP message header */
|
||||||
p_out = dhcp_create_msg(netif, dhcp, DHCP_REQUEST, &options_out_len);
|
p_out = dhcp_create_msg(netif, dhcp, DHCP_REQUEST, &options_out_len);
|
||||||
if (p_out != NULL) {
|
if (p_out != NULL) {
|
||||||
@@ -1240,7 +1247,7 @@ dhcp_rebind(struct netif *netif)
|
|||||||
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_rebind()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_rebind()\n"));
|
||||||
dhcp_set_state(dhcp, DHCP_STATE_REBINDING);
|
dhcp_set_state(dhcp, DHCP_STATE_REBINDING);
|
||||||
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_rebind(): dhcp state is REBINDING\n"));
|
||||||
/* create and initialize the DHCP message header */
|
/* create and initialize the DHCP message header */
|
||||||
p_out = dhcp_create_msg(netif, dhcp, DHCP_REQUEST, &options_out_len);
|
p_out = dhcp_create_msg(netif, dhcp, DHCP_REQUEST, &options_out_len);
|
||||||
if (p_out != NULL) {
|
if (p_out != NULL) {
|
||||||
@@ -1294,7 +1301,7 @@ dhcp_reboot(struct netif *netif)
|
|||||||
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_reboot()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_reboot()\n"));
|
||||||
dhcp_set_state(dhcp, DHCP_STATE_REBOOTING);
|
dhcp_set_state(dhcp, DHCP_STATE_REBOOTING);
|
||||||
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_reboot(): dhcp state is REBOOTING\n"));
|
||||||
/* create and initialize the DHCP message header */
|
/* create and initialize the DHCP message header */
|
||||||
p_out = dhcp_create_msg(netif, dhcp, DHCP_REQUEST, &options_out_len);
|
p_out = dhcp_create_msg(netif, dhcp, DHCP_REQUEST, &options_out_len);
|
||||||
if (p_out != NULL) {
|
if (p_out != NULL) {
|
||||||
@@ -1406,6 +1413,7 @@ dhcp_release_and_stop(struct netif *netif)
|
|||||||
}
|
}
|
||||||
#endif /* LWIP_DHCP_AUTOIP_COOP */
|
#endif /* LWIP_DHCP_AUTOIP_COOP */
|
||||||
|
|
||||||
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_release_and_stop(): dhcp state is OFF\n"));
|
||||||
if (dhcp->pcb_allocated != 0) {
|
if (dhcp->pcb_allocated != 0) {
|
||||||
dhcp_dec_pcb_refcount(); /* free DHCP PCB if not needed any more */
|
dhcp_dec_pcb_refcount(); /* free DHCP PCB if not needed any more */
|
||||||
dhcp->pcb_allocated = 0;
|
dhcp->pcb_allocated = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user