mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-30 12:32:37 +00:00
most of files: prefix all debug.h define with "LWIP_" to avoid any conflict with others environment defines (these were too "generic").
This commit is contained in:
parent
9ec08fa76a
commit
5368a760cf
@ -98,6 +98,10 @@ HISTORY
|
|||||||
|
|
||||||
++ Bug fixes:
|
++ Bug fixes:
|
||||||
|
|
||||||
|
2007-03-30 Frédéric Bernon
|
||||||
|
* most of files: prefix all debug.h define with "LWIP_" to avoid any conflict with
|
||||||
|
others environment defines (these were too "generic").
|
||||||
|
|
||||||
2007-03-28 Frédéric Bernon
|
2007-03-28 Frédéric Bernon
|
||||||
* api.h, api_lib.c, sockets.c: netbuf_ref doesn't check its internal pbuf_alloc call
|
* api.h, api_lib.c, sockets.c: netbuf_ref doesn't check its internal pbuf_alloc call
|
||||||
result and can cause a crash. lwip_send now check netbuf_ref result.
|
result and can cause a crash. lwip_send now check netbuf_ref result.
|
||||||
|
204
src/core/dhcp.c
204
src/core/dhcp.c
@ -146,10 +146,10 @@ static void dhcp_option_trailer(struct dhcp *dhcp);
|
|||||||
static void dhcp_handle_nak(struct netif *netif) {
|
static void dhcp_handle_nak(struct netif *netif) {
|
||||||
struct dhcp *dhcp = netif->dhcp;
|
struct dhcp *dhcp = netif->dhcp;
|
||||||
u16_t msecs = 10 * 1000;
|
u16_t msecs = 10 * 1000;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_handle_nak(netif=%p) %c%c%"U16_F"\n",
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 3, ("dhcp_handle_nak(netif=%p) %c%c%"U16_F"\n",
|
||||||
(void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
|
(void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
|
||||||
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
|
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_handle_nak(): set request timeout %"U16_F" msecs\n", msecs));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_handle_nak(): set request timeout %"U16_F" msecs\n", msecs));
|
||||||
dhcp_set_state(dhcp, DHCP_BACKING_OFF);
|
dhcp_set_state(dhcp, DHCP_BACKING_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,18 +165,18 @@ static void dhcp_check(struct netif *netif)
|
|||||||
struct dhcp *dhcp = netif->dhcp;
|
struct dhcp *dhcp = netif->dhcp;
|
||||||
err_t result;
|
err_t result;
|
||||||
u16_t msecs;
|
u16_t msecs;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_check(netif=%p) %c%c\n", (void *)netif, (s16_t)netif->name[0],
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 3, ("dhcp_check(netif=%p) %c%c\n", (void *)netif, (s16_t)netif->name[0],
|
||||||
(s16_t)netif->name[1]));
|
(s16_t)netif->name[1]));
|
||||||
/* 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);
|
||||||
if (result != ERR_OK) {
|
if (result != ERR_OK) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_check: could not perform ARP query\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("dhcp_check: could not perform ARP query\n"));
|
||||||
}
|
}
|
||||||
dhcp->tries++;
|
dhcp->tries++;
|
||||||
msecs = 500;
|
msecs = 500;
|
||||||
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
|
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_check(): set request timeout %"U16_F" msecs\n", msecs));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_check(): set request timeout %"U16_F" msecs\n", msecs));
|
||||||
dhcp_set_state(dhcp, DHCP_CHECKING);
|
dhcp_set_state(dhcp, DHCP_CHECKING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,15 +190,15 @@ static void dhcp_handle_offer(struct netif *netif)
|
|||||||
struct dhcp *dhcp = netif->dhcp;
|
struct dhcp *dhcp = netif->dhcp;
|
||||||
/* obtain the server address */
|
/* obtain the server address */
|
||||||
u8_t *option_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_SERVER_ID);
|
u8_t *option_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_SERVER_ID);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_handle_offer(netif=%p) %c%c%"U16_F"\n",
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 3, ("dhcp_handle_offer(netif=%p) %c%c%"U16_F"\n",
|
||||||
(void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
|
(void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
|
||||||
if (option_ptr != NULL)
|
if (option_ptr != NULL)
|
||||||
{
|
{
|
||||||
dhcp->server_ip_addr.addr = htonl(dhcp_get_option_long(&option_ptr[2]));
|
dhcp->server_ip_addr.addr = htonl(dhcp_get_option_long(&option_ptr[2]));
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): server 0x%08"X32_F"\n", dhcp->server_ip_addr.addr));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_handle_offer(): server 0x%08"X32_F"\n", dhcp->server_ip_addr.addr));
|
||||||
/* remember offered address */
|
/* remember offered address */
|
||||||
ip_addr_set(&dhcp->offered_ip_addr, (struct ip_addr *)&dhcp->msg_in->yiaddr);
|
ip_addr_set(&dhcp->offered_ip_addr, (struct ip_addr *)&dhcp->msg_in->yiaddr);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): offer for 0x%08"X32_F"\n", dhcp->offered_ip_addr.addr));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_handle_offer(): offer for 0x%08"X32_F"\n", dhcp->offered_ip_addr.addr));
|
||||||
|
|
||||||
dhcp_select(netif);
|
dhcp_select(netif);
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ static err_t dhcp_select(struct netif *netif)
|
|||||||
const char *p;
|
const char *p;
|
||||||
#endif /* LWIP_NETIF_HOSTNAME */
|
#endif /* LWIP_NETIF_HOSTNAME */
|
||||||
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("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 | 3, ("dhcp_select(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
|
||||||
|
|
||||||
/* create and initialize the DHCP message header */
|
/* create and initialize the DHCP message header */
|
||||||
result = dhcp_create_request(netif);
|
result = dhcp_create_request(netif);
|
||||||
@ -269,15 +269,15 @@ static err_t dhcp_select(struct netif *netif)
|
|||||||
/* reconnect to any (or to server here?!) */
|
/* reconnect to any (or to server here?!) */
|
||||||
udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT);
|
udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT);
|
||||||
dhcp_delete_request(netif);
|
dhcp_delete_request(netif);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_select: REQUESTING\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_select: REQUESTING\n"));
|
||||||
dhcp_set_state(dhcp, DHCP_REQUESTING);
|
dhcp_set_state(dhcp, DHCP_REQUESTING);
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_select: could not allocate DHCP request\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("dhcp_select: could not allocate DHCP request\n"));
|
||||||
}
|
}
|
||||||
dhcp->tries++;
|
dhcp->tries++;
|
||||||
msecs = dhcp->tries < 4 ? dhcp->tries * 1000 : 4 * 1000;
|
msecs = dhcp->tries < 4 ? dhcp->tries * 1000 : 4 * 1000;
|
||||||
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
|
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_select(): set request timeout %"U32_F" msecs\n", msecs));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_select(): set request timeout %"U32_F" msecs\n", msecs));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,19 +288,19 @@ static err_t dhcp_select(struct netif *netif)
|
|||||||
void dhcp_coarse_tmr()
|
void dhcp_coarse_tmr()
|
||||||
{
|
{
|
||||||
struct netif *netif = netif_list;
|
struct netif *netif = netif_list;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_coarse_tmr()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_coarse_tmr()\n"));
|
||||||
/* iterate through all network interfaces */
|
/* iterate through all network interfaces */
|
||||||
while (netif != NULL) {
|
while (netif != NULL) {
|
||||||
/* only act on DHCP configured interfaces */
|
/* only act on DHCP configured interfaces */
|
||||||
if (netif->dhcp != NULL) {
|
if (netif->dhcp != NULL) {
|
||||||
/* timer is active (non zero), and triggers (zeroes) now? */
|
/* timer is active (non zero), and triggers (zeroes) now? */
|
||||||
if (netif->dhcp->t2_timeout-- == 1) {
|
if (netif->dhcp->t2_timeout-- == 1) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_coarse_tmr(): t2 timeout\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_coarse_tmr(): t2 timeout\n"));
|
||||||
/* this clients' rebind timeout triggered */
|
/* this clients' rebind timeout triggered */
|
||||||
dhcp_t2_timeout(netif);
|
dhcp_t2_timeout(netif);
|
||||||
/* timer is active (non zero), and triggers (zeroes) now */
|
/* timer is active (non zero), and triggers (zeroes) now */
|
||||||
} else if (netif->dhcp->t1_timeout-- == 1) {
|
} else if (netif->dhcp->t1_timeout-- == 1) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_coarse_tmr(): t1 timeout\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_coarse_tmr(): t1 timeout\n"));
|
||||||
/* this clients' renewal timeout triggered */
|
/* this clients' renewal timeout triggered */
|
||||||
dhcp_t1_timeout(netif);
|
dhcp_t1_timeout(netif);
|
||||||
}
|
}
|
||||||
@ -331,7 +331,7 @@ void dhcp_fine_tmr()
|
|||||||
else if (netif->dhcp->request_timeout == 1) {
|
else if (netif->dhcp->request_timeout == 1) {
|
||||||
netif->dhcp->request_timeout--;
|
netif->dhcp->request_timeout--;
|
||||||
/* { netif->dhcp->request_timeout == 0 } */
|
/* { netif->dhcp->request_timeout == 0 } */
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_fine_tmr(): request timeout\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_fine_tmr(): request timeout\n"));
|
||||||
/* this clients' request timeout triggered */
|
/* this clients' request timeout triggered */
|
||||||
dhcp_timeout(netif);
|
dhcp_timeout(netif);
|
||||||
}
|
}
|
||||||
@ -353,24 +353,24 @@ void dhcp_fine_tmr()
|
|||||||
static void dhcp_timeout(struct netif *netif)
|
static void dhcp_timeout(struct netif *netif)
|
||||||
{
|
{
|
||||||
struct dhcp *dhcp = netif->dhcp;
|
struct dhcp *dhcp = netif->dhcp;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_timeout()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 3, ("dhcp_timeout()\n"));
|
||||||
/* back-off period has passed, or server selection timed out */
|
/* back-off period has passed, or server selection timed out */
|
||||||
if ((dhcp->state == DHCP_BACKING_OFF) || (dhcp->state == DHCP_SELECTING)) {
|
if ((dhcp->state == DHCP_BACKING_OFF) || (dhcp->state == DHCP_SELECTING)) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_timeout(): restarting discovery\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_timeout(): restarting discovery\n"));
|
||||||
dhcp_discover(netif);
|
dhcp_discover(netif);
|
||||||
/* receiving the requested lease timed out */
|
/* receiving the requested lease timed out */
|
||||||
} else if (dhcp->state == DHCP_REQUESTING) {
|
} else if (dhcp->state == DHCP_REQUESTING) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REQUESTING, DHCP request timed out\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): REQUESTING, DHCP request timed out\n"));
|
||||||
if (dhcp->tries <= 5) {
|
if (dhcp->tries <= 5) {
|
||||||
dhcp_select(netif);
|
dhcp_select(netif);
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REQUESTING, releasing, restarting\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): REQUESTING, releasing, restarting\n"));
|
||||||
dhcp_release(netif);
|
dhcp_release(netif);
|
||||||
dhcp_discover(netif);
|
dhcp_discover(netif);
|
||||||
}
|
}
|
||||||
/* received no ARP reply for the offered address (which is good) */
|
/* received no ARP reply for the offered address (which is good) */
|
||||||
} else if (dhcp->state == DHCP_CHECKING) {
|
} else if (dhcp->state == DHCP_CHECKING) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): CHECKING, ARP request timed out\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): CHECKING, ARP request timed out\n"));
|
||||||
if (dhcp->tries <= 1) {
|
if (dhcp->tries <= 1) {
|
||||||
dhcp_check(netif);
|
dhcp_check(netif);
|
||||||
/* no ARP replies on the offered address,
|
/* no ARP replies on the offered address,
|
||||||
@ -382,17 +382,17 @@ static void dhcp_timeout(struct netif *netif)
|
|||||||
}
|
}
|
||||||
/* did not get response to renew request? */
|
/* did not get response to renew request? */
|
||||||
else if (dhcp->state == DHCP_RENEWING) {
|
else if (dhcp->state == DHCP_RENEWING) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): RENEWING, DHCP request timed out\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): RENEWING, DHCP request timed out\n"));
|
||||||
/* just retry renewal */
|
/* just retry renewal */
|
||||||
/* note that the rebind timer will eventually time-out if renew does not work */
|
/* note that the rebind timer will eventually time-out if renew does not work */
|
||||||
dhcp_renew(netif);
|
dhcp_renew(netif);
|
||||||
/* did not get response to rebind request? */
|
/* did not get response to rebind request? */
|
||||||
} else if (dhcp->state == DHCP_REBINDING) {
|
} else if (dhcp->state == DHCP_REBINDING) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REBINDING, DHCP request timed out\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): REBINDING, DHCP request timed out\n"));
|
||||||
if (dhcp->tries <= 8) {
|
if (dhcp->tries <= 8) {
|
||||||
dhcp_rebind(netif);
|
dhcp_rebind(netif);
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): RELEASING, DISCOVERING\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): RELEASING, DISCOVERING\n"));
|
||||||
dhcp_release(netif);
|
dhcp_release(netif);
|
||||||
dhcp_discover(netif);
|
dhcp_discover(netif);
|
||||||
}
|
}
|
||||||
@ -407,11 +407,11 @@ static void dhcp_timeout(struct netif *netif)
|
|||||||
static void dhcp_t1_timeout(struct netif *netif)
|
static void dhcp_t1_timeout(struct netif *netif)
|
||||||
{
|
{
|
||||||
struct dhcp *dhcp = netif->dhcp;
|
struct dhcp *dhcp = netif->dhcp;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_t1_timeout()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_t1_timeout()\n"));
|
||||||
if ((dhcp->state == DHCP_REQUESTING) || (dhcp->state == DHCP_BOUND) || (dhcp->state == DHCP_RENEWING)) {
|
if ((dhcp->state == DHCP_REQUESTING) || (dhcp->state == DHCP_BOUND) || (dhcp->state == DHCP_RENEWING)) {
|
||||||
/* just retry to renew - note that the rebind timer (t2) will
|
/* just retry to renew - note that the rebind timer (t2) will
|
||||||
* eventually time-out if renew tries fail. */
|
* eventually time-out if renew tries fail. */
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t1_timeout(): must renew\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_t1_timeout(): must renew\n"));
|
||||||
dhcp_renew(netif);
|
dhcp_renew(netif);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -423,10 +423,10 @@ static void dhcp_t1_timeout(struct netif *netif)
|
|||||||
static void dhcp_t2_timeout(struct netif *netif)
|
static void dhcp_t2_timeout(struct netif *netif)
|
||||||
{
|
{
|
||||||
struct dhcp *dhcp = netif->dhcp;
|
struct dhcp *dhcp = netif->dhcp;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t2_timeout()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_t2_timeout()\n"));
|
||||||
if ((dhcp->state == DHCP_REQUESTING) || (dhcp->state == DHCP_BOUND) || (dhcp->state == DHCP_RENEWING)) {
|
if ((dhcp->state == DHCP_REQUESTING) || (dhcp->state == DHCP_BOUND) || (dhcp->state == DHCP_RENEWING)) {
|
||||||
/* just retry to rebind */
|
/* just retry to rebind */
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t2_timeout(): must rebind\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_t2_timeout(): must rebind\n"));
|
||||||
dhcp_rebind(netif);
|
dhcp_rebind(netif);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -539,23 +539,23 @@ err_t dhcp_start(struct netif *netif)
|
|||||||
err_t result = ERR_OK;
|
err_t result = ERR_OK;
|
||||||
|
|
||||||
LWIP_ASSERT("netif != NULL", netif != NULL);
|
LWIP_ASSERT("netif != NULL", netif != NULL);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_start(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 | LWIP_DBG_STATE, ("dhcp_start(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
|
||||||
netif->flags &= ~NETIF_FLAG_DHCP;
|
netif->flags &= ~NETIF_FLAG_DHCP;
|
||||||
|
|
||||||
/* no DHCP client attached yet? */
|
/* no DHCP client attached yet? */
|
||||||
if (dhcp == NULL) {
|
if (dhcp == NULL) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): starting new DHCP client\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): starting new DHCP client\n"));
|
||||||
dhcp = mem_malloc(sizeof(struct dhcp));
|
dhcp = mem_malloc(sizeof(struct dhcp));
|
||||||
if (dhcp == NULL) {
|
if (dhcp == NULL) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): could not allocate dhcp\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): could not allocate dhcp\n"));
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
}
|
}
|
||||||
/* store this dhcp client in the netif */
|
/* store this dhcp client in the netif */
|
||||||
netif->dhcp = dhcp;
|
netif->dhcp = dhcp;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): allocated dhcp"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): allocated dhcp"));
|
||||||
/* already has DHCP client attached */
|
/* already has DHCP client attached */
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE | 3, ("dhcp_start(): restarting DHCP configuration\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | 3, ("dhcp_start(): restarting DHCP configuration\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clear data structure */
|
/* clear data structure */
|
||||||
@ -563,12 +563,12 @@ err_t dhcp_start(struct netif *netif)
|
|||||||
/* 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 | 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);
|
mem_free((void *)dhcp);
|
||||||
netif->dhcp = dhcp = NULL;
|
netif->dhcp = dhcp = NULL;
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
}
|
}
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): starting DHCP configuration\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): starting DHCP configuration\n"));
|
||||||
/* (re)start the DHCP negotiation */
|
/* (re)start the DHCP negotiation */
|
||||||
result = dhcp_discover(netif);
|
result = dhcp_discover(netif);
|
||||||
if (result != ERR_OK) {
|
if (result != ERR_OK) {
|
||||||
@ -596,20 +596,20 @@ void dhcp_inform(struct netif *netif)
|
|||||||
err_t result = ERR_OK;
|
err_t result = ERR_OK;
|
||||||
dhcp = mem_malloc(sizeof(struct dhcp));
|
dhcp = mem_malloc(sizeof(struct dhcp));
|
||||||
if (dhcp == NULL) {
|
if (dhcp == NULL) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_inform(): could not allocate dhcp\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("dhcp_inform(): could not allocate dhcp\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
netif->dhcp = dhcp;
|
netif->dhcp = dhcp;
|
||||||
memset(dhcp, 0, sizeof(struct dhcp));
|
memset(dhcp, 0, sizeof(struct dhcp));
|
||||||
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_inform(): allocated dhcp\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_inform(): allocated dhcp\n"));
|
||||||
dhcp->pcb = udp_new();
|
dhcp->pcb = udp_new();
|
||||||
if (dhcp->pcb == NULL) {
|
if (dhcp->pcb == NULL) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_inform(): could not obtain pcb"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("dhcp_inform(): could not obtain pcb"));
|
||||||
mem_free((void *)dhcp);
|
mem_free((void *)dhcp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_inform(): created new udp pcb\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_inform(): created new udp pcb\n"));
|
||||||
/* create and initialize the DHCP message header */
|
/* create and initialize the DHCP message header */
|
||||||
result = dhcp_create_request(netif);
|
result = dhcp_create_request(netif);
|
||||||
if (result == ERR_OK) {
|
if (result == ERR_OK) {
|
||||||
@ -627,12 +627,12 @@ void dhcp_inform(struct netif *netif)
|
|||||||
|
|
||||||
udp_bind(dhcp->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT);
|
udp_bind(dhcp->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT);
|
||||||
udp_connect(dhcp->pcb, IP_ADDR_BROADCAST, DHCP_SERVER_PORT);
|
udp_connect(dhcp->pcb, IP_ADDR_BROADCAST, DHCP_SERVER_PORT);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_inform: INFORMING\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_inform: INFORMING\n"));
|
||||||
udp_send(dhcp->pcb, dhcp->p_out);
|
udp_send(dhcp->pcb, dhcp->p_out);
|
||||||
udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT);
|
udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT);
|
||||||
dhcp_delete_request(netif);
|
dhcp_delete_request(netif);
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_inform: could not allocate DHCP request\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("dhcp_inform: could not allocate DHCP request\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dhcp != NULL)
|
if (dhcp != NULL)
|
||||||
@ -655,15 +655,15 @@ void dhcp_inform(struct netif *netif)
|
|||||||
void dhcp_arp_reply(struct netif *netif, struct ip_addr *addr)
|
void dhcp_arp_reply(struct netif *netif, struct ip_addr *addr)
|
||||||
{
|
{
|
||||||
LWIP_ASSERT("netif != NULL", netif != NULL);
|
LWIP_ASSERT("netif != NULL", netif != NULL);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_arp_reply()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 3, ("dhcp_arp_reply()\n"));
|
||||||
/* is a DHCP client doing an ARP check? */
|
/* is a DHCP client doing an ARP check? */
|
||||||
if ((netif->dhcp != NULL) && (netif->dhcp->state == DHCP_CHECKING)) {
|
if ((netif->dhcp != NULL) && (netif->dhcp->state == DHCP_CHECKING)) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_arp_reply(): CHECKING, arp reply for 0x%08"X32_F"\n", addr->addr));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_arp_reply(): CHECKING, arp reply for 0x%08"X32_F"\n", addr->addr));
|
||||||
/* did a host respond with the address we
|
/* did a host respond with the address we
|
||||||
were offered by the DHCP server? */
|
were offered by the DHCP server? */
|
||||||
if (ip_addr_cmp(addr, &netif->dhcp->offered_ip_addr)) {
|
if (ip_addr_cmp(addr, &netif->dhcp->offered_ip_addr)) {
|
||||||
/* we will not accept the offered address */
|
/* we will not accept the offered address */
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE | 1, ("dhcp_arp_reply(): arp reply matched with offered address, declining\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | 1, ("dhcp_arp_reply(): arp reply matched with offered address, declining\n"));
|
||||||
dhcp_decline(netif);
|
dhcp_decline(netif);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -681,7 +681,7 @@ static err_t dhcp_decline(struct netif *netif)
|
|||||||
struct dhcp *dhcp = netif->dhcp;
|
struct dhcp *dhcp = netif->dhcp;
|
||||||
err_t result = ERR_OK;
|
err_t result = ERR_OK;
|
||||||
u16_t msecs;
|
u16_t msecs;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_decline()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 3, ("dhcp_decline()\n"));
|
||||||
dhcp_set_state(dhcp, DHCP_BACKING_OFF);
|
dhcp_set_state(dhcp, DHCP_BACKING_OFF);
|
||||||
/* create and initialize the DHCP message header */
|
/* create and initialize the DHCP message header */
|
||||||
result = dhcp_create_request(netif);
|
result = dhcp_create_request(netif);
|
||||||
@ -706,14 +706,14 @@ static err_t dhcp_decline(struct netif *netif)
|
|||||||
/* per section 4.4.4, broadcast DECLINE messages */
|
/* per section 4.4.4, broadcast DECLINE messages */
|
||||||
udp_sendto(dhcp->pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT);
|
udp_sendto(dhcp->pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT);
|
||||||
dhcp_delete_request(netif);
|
dhcp_delete_request(netif);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_decline: BACKING OFF\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_decline: BACKING OFF\n"));
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_decline: could not allocate DHCP request\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("dhcp_decline: could not allocate DHCP request\n"));
|
||||||
}
|
}
|
||||||
dhcp->tries++;
|
dhcp->tries++;
|
||||||
msecs = 10*1000;
|
msecs = 10*1000;
|
||||||
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
|
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_decline(): set request timeout %"U16_F" msecs\n", msecs));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_decline(): set request timeout %"U16_F" msecs\n", msecs));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -728,13 +728,13 @@ static err_t dhcp_discover(struct netif *netif)
|
|||||||
struct dhcp *dhcp = netif->dhcp;
|
struct dhcp *dhcp = netif->dhcp;
|
||||||
err_t result = ERR_OK;
|
err_t result = ERR_OK;
|
||||||
u16_t msecs;
|
u16_t msecs;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_discover()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 3, ("dhcp_discover()\n"));
|
||||||
ip_addr_set(&dhcp->offered_ip_addr, IP_ADDR_ANY);
|
ip_addr_set(&dhcp->offered_ip_addr, IP_ADDR_ANY);
|
||||||
/* create and initialize the DHCP message header */
|
/* create and initialize the DHCP message header */
|
||||||
result = dhcp_create_request(netif);
|
result = dhcp_create_request(netif);
|
||||||
if (result == ERR_OK)
|
if (result == ERR_OK)
|
||||||
{
|
{
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: making request\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: making request\n"));
|
||||||
dhcp_option(dhcp, DHCP_OPTION_MESSAGE_TYPE, DHCP_OPTION_MESSAGE_TYPE_LEN);
|
dhcp_option(dhcp, DHCP_OPTION_MESSAGE_TYPE, DHCP_OPTION_MESSAGE_TYPE_LEN);
|
||||||
dhcp_option_byte(dhcp, DHCP_DISCOVER);
|
dhcp_option_byte(dhcp, DHCP_DISCOVER);
|
||||||
|
|
||||||
@ -749,26 +749,26 @@ static err_t dhcp_discover(struct netif *netif)
|
|||||||
|
|
||||||
dhcp_option_trailer(dhcp);
|
dhcp_option_trailer(dhcp);
|
||||||
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: realloc()ing\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: realloc()ing\n"));
|
||||||
pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len);
|
pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len);
|
||||||
|
|
||||||
/* set receive callback function with netif as user data */
|
/* set receive callback function with netif as user data */
|
||||||
udp_recv(dhcp->pcb, dhcp_recv, netif);
|
udp_recv(dhcp->pcb, dhcp_recv, netif);
|
||||||
udp_bind(dhcp->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT);
|
udp_bind(dhcp->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT);
|
||||||
udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT);
|
udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)\n"));
|
||||||
udp_sendto(dhcp->pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT);
|
udp_sendto(dhcp->pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: deleting()ing\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: deleting()ing\n"));
|
||||||
dhcp_delete_request(netif);
|
dhcp_delete_request(netif);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_discover: SELECTING\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_discover: SELECTING\n"));
|
||||||
dhcp_set_state(dhcp, DHCP_SELECTING);
|
dhcp_set_state(dhcp, DHCP_SELECTING);
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_discover: could not allocate DHCP request\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("dhcp_discover: could not allocate DHCP request\n"));
|
||||||
}
|
}
|
||||||
dhcp->tries++;
|
dhcp->tries++;
|
||||||
msecs = dhcp->tries < 4 ? (dhcp->tries + 1) * 1000 : 10 * 1000;
|
msecs = dhcp->tries < 4 ? (dhcp->tries + 1) * 1000 : 10 * 1000;
|
||||||
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
|
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_discover(): set request timeout %"U16_F" msecs\n", msecs));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_discover(): set request timeout %"U16_F" msecs\n", msecs));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -785,30 +785,30 @@ static void dhcp_bind(struct netif *netif)
|
|||||||
struct ip_addr sn_mask, gw_addr;
|
struct ip_addr sn_mask, gw_addr;
|
||||||
LWIP_ASSERT("dhcp_bind: netif != NULL", netif != NULL);
|
LWIP_ASSERT("dhcp_bind: netif != NULL", netif != NULL);
|
||||||
LWIP_ASSERT("dhcp_bind: dhcp != NULL", dhcp != NULL);
|
LWIP_ASSERT("dhcp_bind: dhcp != NULL", dhcp != NULL);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_bind(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 | 3, ("dhcp_bind(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
|
||||||
|
|
||||||
/* temporary DHCP lease? */
|
/* temporary DHCP lease? */
|
||||||
if (dhcp->offered_t1_renew != 0xffffffffUL) {
|
if (dhcp->offered_t1_renew != 0xffffffffUL) {
|
||||||
/* set renewal period timer */
|
/* set renewal period timer */
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_bind(): t1 renewal timer %"U32_F" secs\n", dhcp->offered_t1_renew));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_bind(): t1 renewal timer %"U32_F" secs\n", dhcp->offered_t1_renew));
|
||||||
timeout = (dhcp->offered_t1_renew + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS;
|
timeout = (dhcp->offered_t1_renew + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS;
|
||||||
if(timeout > 0xffff)
|
if(timeout > 0xffff)
|
||||||
timeout = 0xffff;
|
timeout = 0xffff;
|
||||||
dhcp->t1_timeout = (u16_t)timeout;
|
dhcp->t1_timeout = (u16_t)timeout;
|
||||||
if (dhcp->t1_timeout == 0)
|
if (dhcp->t1_timeout == 0)
|
||||||
dhcp->t1_timeout = 1;
|
dhcp->t1_timeout = 1;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t1_renew*1000));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t1_renew*1000));
|
||||||
}
|
}
|
||||||
/* set renewal period timer */
|
/* set renewal period timer */
|
||||||
if (dhcp->offered_t2_rebind != 0xffffffffUL) {
|
if (dhcp->offered_t2_rebind != 0xffffffffUL) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_bind(): t2 rebind timer %"U32_F" secs\n", dhcp->offered_t2_rebind));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_bind(): t2 rebind timer %"U32_F" secs\n", dhcp->offered_t2_rebind));
|
||||||
timeout = (dhcp->offered_t2_rebind + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS;
|
timeout = (dhcp->offered_t2_rebind + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS;
|
||||||
if(timeout > 0xffff)
|
if(timeout > 0xffff)
|
||||||
timeout = 0xffff;
|
timeout = 0xffff;
|
||||||
dhcp->t2_timeout = (u16_t)timeout;
|
dhcp->t2_timeout = (u16_t)timeout;
|
||||||
if (dhcp->t2_timeout == 0)
|
if (dhcp->t2_timeout == 0)
|
||||||
dhcp->t2_timeout = 1;
|
dhcp->t2_timeout = 1;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t2_rebind*1000));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t2_rebind*1000));
|
||||||
}
|
}
|
||||||
/* copy offered network mask */
|
/* copy offered network mask */
|
||||||
ip_addr_set(&sn_mask, &dhcp->offered_sn_mask);
|
ip_addr_set(&sn_mask, &dhcp->offered_sn_mask);
|
||||||
@ -835,11 +835,11 @@ static void dhcp_bind(struct netif *netif)
|
|||||||
gw_addr.addr |= htonl(0x00000001);
|
gw_addr.addr |= htonl(0x00000001);
|
||||||
}
|
}
|
||||||
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): IP: 0x%08"X32_F"\n", dhcp->offered_ip_addr.addr));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_bind(): IP: 0x%08"X32_F"\n", dhcp->offered_ip_addr.addr));
|
||||||
netif_set_ipaddr(netif, &dhcp->offered_ip_addr);
|
netif_set_ipaddr(netif, &dhcp->offered_ip_addr);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): SN: 0x%08"X32_F"\n", sn_mask.addr));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_bind(): SN: 0x%08"X32_F"\n", sn_mask.addr));
|
||||||
netif_set_netmask(netif, &sn_mask);
|
netif_set_netmask(netif, &sn_mask);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): GW: 0x%08"X32_F"\n", gw_addr.addr));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_bind(): GW: 0x%08"X32_F"\n", gw_addr.addr));
|
||||||
netif_set_gw(netif, &gw_addr);
|
netif_set_gw(netif, &gw_addr);
|
||||||
/* bring the interface up */
|
/* bring the interface up */
|
||||||
netif_set_up(netif);
|
netif_set_up(netif);
|
||||||
@ -857,7 +857,7 @@ err_t dhcp_renew(struct netif *netif)
|
|||||||
struct dhcp *dhcp = netif->dhcp;
|
struct dhcp *dhcp = netif->dhcp;
|
||||||
err_t result;
|
err_t result;
|
||||||
u16_t msecs;
|
u16_t msecs;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_renew()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 3, ("dhcp_renew()\n"));
|
||||||
dhcp_set_state(dhcp, DHCP_RENEWING);
|
dhcp_set_state(dhcp, DHCP_RENEWING);
|
||||||
|
|
||||||
/* create and initialize the DHCP message header */
|
/* create and initialize the DHCP message header */
|
||||||
@ -890,15 +890,15 @@ err_t dhcp_renew(struct netif *netif)
|
|||||||
udp_send(dhcp->pcb, dhcp->p_out);
|
udp_send(dhcp->pcb, dhcp->p_out);
|
||||||
dhcp_delete_request(netif);
|
dhcp_delete_request(netif);
|
||||||
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_renew: RENEWING\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_renew: RENEWING\n"));
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_renew: could not allocate DHCP request\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("dhcp_renew: could not allocate DHCP request\n"));
|
||||||
}
|
}
|
||||||
dhcp->tries++;
|
dhcp->tries++;
|
||||||
/* back-off on retries, but to a maximum of 20 seconds */
|
/* back-off on retries, but to a maximum of 20 seconds */
|
||||||
msecs = dhcp->tries < 10 ? dhcp->tries * 2000 : 20 * 1000;
|
msecs = dhcp->tries < 10 ? dhcp->tries * 2000 : 20 * 1000;
|
||||||
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
|
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_renew(): set request timeout %"U16_F" msecs\n", msecs));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_renew(): set request timeout %"U16_F" msecs\n", msecs));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -912,7 +912,7 @@ static err_t dhcp_rebind(struct netif *netif)
|
|||||||
struct dhcp *dhcp = netif->dhcp;
|
struct dhcp *dhcp = netif->dhcp;
|
||||||
err_t result;
|
err_t result;
|
||||||
u16_t msecs;
|
u16_t msecs;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_rebind()\n"));
|
||||||
dhcp_set_state(dhcp, DHCP_REBINDING);
|
dhcp_set_state(dhcp, DHCP_REBINDING);
|
||||||
|
|
||||||
/* create and initialize the DHCP message header */
|
/* create and initialize the DHCP message header */
|
||||||
@ -944,14 +944,14 @@ static err_t dhcp_rebind(struct netif *netif)
|
|||||||
/* broadcast to server */
|
/* broadcast to server */
|
||||||
udp_sendto(dhcp->pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT);
|
udp_sendto(dhcp->pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT);
|
||||||
dhcp_delete_request(netif);
|
dhcp_delete_request(netif);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind: REBINDING\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_rebind: REBINDING\n"));
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_rebind: could not allocate DHCP request\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("dhcp_rebind: could not allocate DHCP request\n"));
|
||||||
}
|
}
|
||||||
dhcp->tries++;
|
dhcp->tries++;
|
||||||
msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000;
|
msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000;
|
||||||
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
|
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind(): set request timeout %"U16_F" msecs\n", msecs));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_rebind(): set request timeout %"U16_F" msecs\n", msecs));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -965,7 +965,7 @@ err_t dhcp_release(struct netif *netif)
|
|||||||
struct dhcp *dhcp = netif->dhcp;
|
struct dhcp *dhcp = netif->dhcp;
|
||||||
err_t result;
|
err_t result;
|
||||||
u16_t msecs;
|
u16_t msecs;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_release()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 3, ("dhcp_release()\n"));
|
||||||
|
|
||||||
/* idle DHCP client */
|
/* idle DHCP client */
|
||||||
dhcp_set_state(dhcp, DHCP_OFF);
|
dhcp_set_state(dhcp, DHCP_OFF);
|
||||||
@ -990,14 +990,14 @@ err_t dhcp_release(struct netif *netif)
|
|||||||
udp_connect(dhcp->pcb, &dhcp->server_ip_addr, DHCP_SERVER_PORT);
|
udp_connect(dhcp->pcb, &dhcp->server_ip_addr, DHCP_SERVER_PORT);
|
||||||
udp_send(dhcp->pcb, dhcp->p_out);
|
udp_send(dhcp->pcb, dhcp->p_out);
|
||||||
dhcp_delete_request(netif);
|
dhcp_delete_request(netif);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_release: RELEASED, DHCP_OFF\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_release: RELEASED, DHCP_OFF\n"));
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_release: could not allocate DHCP request\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("dhcp_release: could not allocate DHCP request\n"));
|
||||||
}
|
}
|
||||||
dhcp->tries++;
|
dhcp->tries++;
|
||||||
msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000;
|
msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000;
|
||||||
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
|
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_release(): set request timeout %"U16_F" msecs\n", msecs));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_release(): set request timeout %"U16_F" msecs\n", msecs));
|
||||||
/* bring the interface down */
|
/* bring the interface down */
|
||||||
netif_set_down(netif);
|
netif_set_down(netif);
|
||||||
/* remove IP address from interface */
|
/* remove IP address from interface */
|
||||||
@ -1018,7 +1018,7 @@ void dhcp_stop(struct netif *netif)
|
|||||||
struct dhcp *dhcp = netif->dhcp;
|
struct dhcp *dhcp = netif->dhcp;
|
||||||
LWIP_ASSERT("dhcp_stop: netif != NULL", netif != NULL);
|
LWIP_ASSERT("dhcp_stop: netif != NULL", netif != NULL);
|
||||||
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_stop()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 3, ("dhcp_stop()\n"));
|
||||||
/* netif is DHCP configured? */
|
/* netif is DHCP configured? */
|
||||||
if (dhcp != NULL)
|
if (dhcp != NULL)
|
||||||
{
|
{
|
||||||
@ -1116,14 +1116,14 @@ static err_t dhcp_unfold_reply(struct dhcp *dhcp)
|
|||||||
dhcp->options_in = mem_malloc(dhcp->options_in_len);
|
dhcp->options_in = mem_malloc(dhcp->options_in_len);
|
||||||
if (dhcp->options_in == NULL)
|
if (dhcp->options_in == NULL)
|
||||||
{
|
{
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_unfold_reply(): could not allocate dhcp->options\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("dhcp_unfold_reply(): could not allocate dhcp->options\n"));
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dhcp->msg_in = mem_malloc(sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN);
|
dhcp->msg_in = mem_malloc(sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN);
|
||||||
if (dhcp->msg_in == NULL)
|
if (dhcp->msg_in == NULL)
|
||||||
{
|
{
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_unfold_reply(): could not allocate dhcp->msg_in\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("dhcp_unfold_reply(): could not allocate dhcp->msg_in\n"));
|
||||||
mem_free((void *)dhcp->options_in);
|
mem_free((void *)dhcp->options_in);
|
||||||
dhcp->options_in = NULL;
|
dhcp->options_in = NULL;
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
@ -1142,7 +1142,7 @@ static err_t dhcp_unfold_reply(struct dhcp *dhcp)
|
|||||||
j = 0;
|
j = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_unfold_reply(): copied %"U16_F" bytes into dhcp->msg_in[]\n", i));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_unfold_reply(): copied %"U16_F" bytes into dhcp->msg_in[]\n", i));
|
||||||
if (dhcp->options_in != NULL) {
|
if (dhcp->options_in != NULL) {
|
||||||
ptr = (u8_t *)dhcp->options_in;
|
ptr = (u8_t *)dhcp->options_in;
|
||||||
/* proceed through options */
|
/* proceed through options */
|
||||||
@ -1155,7 +1155,7 @@ static err_t dhcp_unfold_reply(struct dhcp *dhcp)
|
|||||||
j = 0;
|
j = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_unfold_reply(): copied %"U16_F" bytes to dhcp->options_in[]\n", i));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_unfold_reply(): copied %"U16_F" bytes to dhcp->options_in[]\n", i));
|
||||||
}
|
}
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
@ -1191,17 +1191,17 @@ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_
|
|||||||
u8_t *options_ptr;
|
u8_t *options_ptr;
|
||||||
u8_t msg_type;
|
u8_t msg_type;
|
||||||
u8_t i;
|
u8_t i;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_recv(pbuf = %p) from DHCP server %"U16_F".%"U16_F".%"U16_F".%"U16_F" port %"U16_F"\n", (void*)p,
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 3, ("dhcp_recv(pbuf = %p) from DHCP server %"U16_F".%"U16_F".%"U16_F".%"U16_F" port %"U16_F"\n", (void*)p,
|
||||||
(u16_t)(ntohl(addr->addr) >> 24 & 0xff), (u16_t)(ntohl(addr->addr) >> 16 & 0xff),
|
(u16_t)(ntohl(addr->addr) >> 24 & 0xff), (u16_t)(ntohl(addr->addr) >> 16 & 0xff),
|
||||||
(u16_t)(ntohl(addr->addr) >> 8 & 0xff), (u16_t)(ntohl(addr->addr) & 0xff), port));
|
(u16_t)(ntohl(addr->addr) >> 8 & 0xff), (u16_t)(ntohl(addr->addr) & 0xff), port));
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->len = %"U16_F"\n", p->len));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("pbuf->len = %"U16_F"\n", p->len));
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->tot_len = %"U16_F"\n", p->tot_len));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("pbuf->tot_len = %"U16_F"\n", p->tot_len));
|
||||||
/* prevent warnings about unused arguments */
|
/* prevent warnings about unused arguments */
|
||||||
(void)pcb; (void)addr; (void)port;
|
(void)pcb; (void)addr; (void)port;
|
||||||
dhcp->p = p;
|
dhcp->p = p;
|
||||||
/* TODO: check packet length before reading them */
|
/* TODO: check packet length before reading them */
|
||||||
if (reply_msg->op != DHCP_BOOTREPLY) {
|
if (reply_msg->op != DHCP_BOOTREPLY) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("not a DHCP reply message, but type %"U16_F"\n", (u16_t)reply_msg->op));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 1, ("not a DHCP reply message, but type %"U16_F"\n", (u16_t)reply_msg->op));
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
dhcp->p = NULL;
|
dhcp->p = NULL;
|
||||||
return;
|
return;
|
||||||
@ -1209,7 +1209,7 @@ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_
|
|||||||
/* iterate through hardware address and match against DHCP message */
|
/* iterate through hardware address and match against DHCP message */
|
||||||
for (i = 0; i < netif->hwaddr_len; i++) {
|
for (i = 0; i < netif->hwaddr_len; i++) {
|
||||||
if (netif->hwaddr[i] != reply_msg->chaddr[i]) {
|
if (netif->hwaddr[i] != reply_msg->chaddr[i]) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("netif->hwaddr[%"U16_F"]==%02"X16_F" != reply_msg->chaddr[%"U16_F"]==%02"X16_F"\n",
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("netif->hwaddr[%"U16_F"]==%02"X16_F" != reply_msg->chaddr[%"U16_F"]==%02"X16_F"\n",
|
||||||
(u16_t)i, (u16_t)netif->hwaddr[i], (u16_t)i, (u16_t)reply_msg->chaddr[i]));
|
(u16_t)i, (u16_t)netif->hwaddr[i], (u16_t)i, (u16_t)reply_msg->chaddr[i]));
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
dhcp->p = NULL;
|
dhcp->p = NULL;
|
||||||
@ -1218,24 +1218,24 @@ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_
|
|||||||
}
|
}
|
||||||
/* match transaction ID against what we expected */
|
/* match transaction ID against what we expected */
|
||||||
if (ntohl(reply_msg->xid) != dhcp->xid) {
|
if (ntohl(reply_msg->xid) != dhcp->xid) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("transaction id mismatch reply_msg->xid(%"X32_F")!=dhcp->xid(%"X32_F")\n",ntohl(reply_msg->xid),dhcp->xid));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("transaction id mismatch reply_msg->xid(%"X32_F")!=dhcp->xid(%"X32_F")\n",ntohl(reply_msg->xid),dhcp->xid));
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
dhcp->p = NULL;
|
dhcp->p = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* option fields could be unfold? */
|
/* option fields could be unfold? */
|
||||||
if (dhcp_unfold_reply(dhcp) != ERR_OK) {
|
if (dhcp_unfold_reply(dhcp) != ERR_OK) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("problem unfolding DHCP message - too short on memory?\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("problem unfolding DHCP message - too short on memory?\n"));
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
dhcp->p = NULL;
|
dhcp->p = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("searching DHCP_OPTION_MESSAGE_TYPE\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("searching DHCP_OPTION_MESSAGE_TYPE\n"));
|
||||||
/* obtain pointer to DHCP message type */
|
/* obtain pointer to DHCP message type */
|
||||||
options_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_MESSAGE_TYPE);
|
options_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_MESSAGE_TYPE);
|
||||||
if (options_ptr == NULL) {
|
if (options_ptr == NULL) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_OPTION_MESSAGE_TYPE option not found\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 1, ("DHCP_OPTION_MESSAGE_TYPE option not found\n"));
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
dhcp->p = NULL;
|
dhcp->p = NULL;
|
||||||
return;
|
return;
|
||||||
@ -1245,7 +1245,7 @@ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_
|
|||||||
msg_type = dhcp_get_option_byte(options_ptr + 2);
|
msg_type = dhcp_get_option_byte(options_ptr + 2);
|
||||||
/* message type is DHCP ACK? */
|
/* message type is DHCP ACK? */
|
||||||
if (msg_type == DHCP_ACK) {
|
if (msg_type == DHCP_ACK) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_ACK received\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 1, ("DHCP_ACK received\n"));
|
||||||
/* in requesting state? */
|
/* in requesting state? */
|
||||||
if (dhcp->state == DHCP_REQUESTING) {
|
if (dhcp->state == DHCP_REQUESTING) {
|
||||||
dhcp_handle_ack(netif);
|
dhcp_handle_ack(netif);
|
||||||
@ -1268,13 +1268,13 @@ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_
|
|||||||
else if ((msg_type == DHCP_NAK) &&
|
else if ((msg_type == DHCP_NAK) &&
|
||||||
((dhcp->state == DHCP_REBOOTING) || (dhcp->state == DHCP_REQUESTING) ||
|
((dhcp->state == DHCP_REBOOTING) || (dhcp->state == DHCP_REQUESTING) ||
|
||||||
(dhcp->state == DHCP_REBINDING) || (dhcp->state == DHCP_RENEWING ))) {
|
(dhcp->state == DHCP_REBINDING) || (dhcp->state == DHCP_RENEWING ))) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_NAK received\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 1, ("DHCP_NAK received\n"));
|
||||||
dhcp->request_timeout = 0;
|
dhcp->request_timeout = 0;
|
||||||
dhcp_handle_nak(netif);
|
dhcp_handle_nak(netif);
|
||||||
}
|
}
|
||||||
/* received a DHCP_OFFER in DHCP_SELECTING state? */
|
/* received a DHCP_OFFER in DHCP_SELECTING state? */
|
||||||
else if ((msg_type == DHCP_OFFER) && (dhcp->state == DHCP_SELECTING)) {
|
else if ((msg_type == DHCP_OFFER) && (dhcp->state == DHCP_SELECTING)) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_OFFER received in DHCP_SELECTING state\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 1, ("DHCP_OFFER received in DHCP_SELECTING state\n"));
|
||||||
dhcp->request_timeout = 0;
|
dhcp->request_timeout = 0;
|
||||||
/* remember offered lease */
|
/* remember offered lease */
|
||||||
dhcp_handle_offer(netif);
|
dhcp_handle_offer(netif);
|
||||||
@ -1292,12 +1292,12 @@ static err_t dhcp_create_request(struct netif *netif)
|
|||||||
LWIP_ASSERT("dhcp_create_request: dhcp->msg_out == NULL", dhcp->msg_out == NULL);
|
LWIP_ASSERT("dhcp_create_request: dhcp->msg_out == NULL", dhcp->msg_out == NULL);
|
||||||
dhcp->p_out = pbuf_alloc(PBUF_TRANSPORT, sizeof(struct dhcp_msg), PBUF_RAM);
|
dhcp->p_out = pbuf_alloc(PBUF_TRANSPORT, sizeof(struct dhcp_msg), PBUF_RAM);
|
||||||
if (dhcp->p_out == NULL) {
|
if (dhcp->p_out == NULL) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_create_request(): could not allocate pbuf\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("dhcp_create_request(): could not allocate pbuf\n"));
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
}
|
}
|
||||||
/* give unique transaction identifier to this request */
|
/* give unique transaction identifier to this request */
|
||||||
dhcp->xid = xid++;
|
dhcp->xid = xid++;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("transaction id xid++(%"X32_F") dhcp->xid(%"U32_F")\n",xid,dhcp->xid));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("transaction id xid++(%"X32_F") dhcp->xid(%"U32_F")\n",xid,dhcp->xid));
|
||||||
|
|
||||||
dhcp->msg_out = (struct dhcp_msg *)dhcp->p_out->payload;
|
dhcp->msg_out = (struct dhcp_msg *)dhcp->p_out->payload;
|
||||||
|
|
||||||
@ -1382,14 +1382,14 @@ static u8_t *dhcp_get_option_ptr(struct dhcp *dhcp, u8_t option_type)
|
|||||||
/* LWIP_DEBUGF(DHCP_DEBUG, ("msg_offset=%"U16_F", q->len=%"U16_F, msg_offset, q->len)); */
|
/* LWIP_DEBUGF(DHCP_DEBUG, ("msg_offset=%"U16_F", q->len=%"U16_F, msg_offset, q->len)); */
|
||||||
/* are the sname and/or file field overloaded with options? */
|
/* are the sname and/or file field overloaded with options? */
|
||||||
if (options[offset] == DHCP_OPTION_OVERLOAD) {
|
if (options[offset] == DHCP_OPTION_OVERLOAD) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("overloaded message detected\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 2, ("overloaded message detected\n"));
|
||||||
/* skip option type and length */
|
/* skip option type and length */
|
||||||
offset += 2;
|
offset += 2;
|
||||||
overload = options[offset++];
|
overload = options[offset++];
|
||||||
}
|
}
|
||||||
/* requested option found */
|
/* requested option found */
|
||||||
else if (options[offset] == option_type) {
|
else if (options[offset] == option_type) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("option found at offset %"U16_F" in options\n", offset));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("option found at offset %"U16_F" in options\n", offset));
|
||||||
return &options[offset];
|
return &options[offset];
|
||||||
/* skip option */
|
/* skip option */
|
||||||
} else {
|
} else {
|
||||||
@ -1404,16 +1404,16 @@ static u8_t *dhcp_get_option_ptr(struct dhcp *dhcp, u8_t option_type)
|
|||||||
if (overload != DHCP_OVERLOAD_NONE) {
|
if (overload != DHCP_OVERLOAD_NONE) {
|
||||||
u16_t field_len;
|
u16_t field_len;
|
||||||
if (overload == DHCP_OVERLOAD_FILE) {
|
if (overload == DHCP_OVERLOAD_FILE) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded file field\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 1, ("overloaded file field\n"));
|
||||||
options = (u8_t *)&dhcp->msg_in->file;
|
options = (u8_t *)&dhcp->msg_in->file;
|
||||||
field_len = DHCP_FILE_LEN;
|
field_len = DHCP_FILE_LEN;
|
||||||
} else if (overload == DHCP_OVERLOAD_SNAME) {
|
} else if (overload == DHCP_OVERLOAD_SNAME) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded sname field\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 1, ("overloaded sname field\n"));
|
||||||
options = (u8_t *)&dhcp->msg_in->sname;
|
options = (u8_t *)&dhcp->msg_in->sname;
|
||||||
field_len = DHCP_SNAME_LEN;
|
field_len = DHCP_SNAME_LEN;
|
||||||
/* TODO: check if else if () is necessary */
|
/* TODO: check if else if () is necessary */
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded sname and file field\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 1, ("overloaded sname and file field\n"));
|
||||||
options = (u8_t *)&dhcp->msg_in->sname;
|
options = (u8_t *)&dhcp->msg_in->sname;
|
||||||
field_len = DHCP_FILE_LEN + DHCP_SNAME_LEN;
|
field_len = DHCP_FILE_LEN + DHCP_SNAME_LEN;
|
||||||
}
|
}
|
||||||
@ -1422,11 +1422,11 @@ static u8_t *dhcp_get_option_ptr(struct dhcp *dhcp, u8_t option_type)
|
|||||||
/* at least 1 byte to read and no end marker */
|
/* at least 1 byte to read and no end marker */
|
||||||
while ((offset < field_len) && (options[offset] != DHCP_OPTION_END)) {
|
while ((offset < field_len) && (options[offset] != DHCP_OPTION_END)) {
|
||||||
if (options[offset] == option_type) {
|
if (options[offset] == option_type) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("option found at offset=%"U16_F"\n", offset));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("option found at offset=%"U16_F"\n", offset));
|
||||||
return &options[offset];
|
return &options[offset];
|
||||||
/* skip option */
|
/* skip option */
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("skipping option %"U16_F"\n", options[offset]));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("skipping option %"U16_F"\n", options[offset]));
|
||||||
/* skip option type */
|
/* skip option type */
|
||||||
offset++;
|
offset++;
|
||||||
offset += 1 + options[offset];
|
offset += 1 + options[offset];
|
||||||
|
@ -276,10 +276,10 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
|||||||
if (netif == NULL) {
|
if (netif == NULL) {
|
||||||
/* remote port is DHCP server? */
|
/* remote port is DHCP server? */
|
||||||
if (IPH_PROTO(iphdr) == IP_PROTO_UDP) {
|
if (IPH_PROTO(iphdr) == IP_PROTO_UDP) {
|
||||||
LWIP_DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: UDP packet to DHCP client port %"U16_F"\n",
|
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE | 1, ("ip_input: UDP packet to DHCP client port %"U16_F"\n",
|
||||||
ntohs(((struct udp_hdr *)((u8_t *)iphdr + iphdrlen))->dest)));
|
ntohs(((struct udp_hdr *)((u8_t *)iphdr + iphdrlen))->dest)));
|
||||||
if (ntohs(((struct udp_hdr *)((u8_t *)iphdr + iphdrlen))->dest) == DHCP_CLIENT_PORT) {
|
if (ntohs(((struct udp_hdr *)((u8_t *)iphdr + iphdrlen))->dest) == DHCP_CLIENT_PORT) {
|
||||||
LWIP_DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: DHCP packet accepted.\n"));
|
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE | 1, ("ip_input: DHCP packet accepted.\n"));
|
||||||
netif = inp;
|
netif = inp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -288,7 +288,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
|||||||
/* packet not for us? */
|
/* packet not for us? */
|
||||||
if (netif == NULL) {
|
if (netif == NULL) {
|
||||||
/* packet not for us, route or discard */
|
/* packet not for us, route or discard */
|
||||||
LWIP_DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: packet not for us.\n"));
|
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE | 1, ("ip_input: packet not for us.\n"));
|
||||||
#if IP_FORWARD
|
#if IP_FORWARD
|
||||||
/* non-broadcast packet? */
|
/* non-broadcast packet? */
|
||||||
if (!ip_addr_isbroadcast(&(iphdr->dest), inp)) {
|
if (!ip_addr_isbroadcast(&(iphdr->dest), inp)) {
|
||||||
|
@ -157,7 +157,7 @@ mem_free(void *rmem)
|
|||||||
struct mem *mem;
|
struct mem *mem;
|
||||||
|
|
||||||
if (rmem == NULL) {
|
if (rmem == NULL) {
|
||||||
LWIP_DEBUGF(MEM_DEBUG | DBG_TRACE | 2, ("mem_free(p == NULL) was called.\n"));
|
LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_TRACE | 2, ("mem_free(p == NULL) was called.\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr)
|
|||||||
snmp_insert_ipaddridx_tree(netif);
|
snmp_insert_ipaddridx_tree(netif);
|
||||||
snmp_insert_iprteidx_tree(0,netif);
|
snmp_insert_iprteidx_tree(0,netif);
|
||||||
|
|
||||||
LWIP_DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: IP address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | 3, ("netif: IP address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
||||||
netif->name[0], netif->name[1],
|
netif->name[0], netif->name[1],
|
||||||
ip4_addr1(&netif->ip_addr),
|
ip4_addr1(&netif->ip_addr),
|
||||||
ip4_addr2(&netif->ip_addr),
|
ip4_addr2(&netif->ip_addr),
|
||||||
@ -236,7 +236,7 @@ void
|
|||||||
netif_set_gw(struct netif *netif, struct ip_addr *gw)
|
netif_set_gw(struct netif *netif, struct ip_addr *gw)
|
||||||
{
|
{
|
||||||
ip_addr_set(&(netif->gw), gw);
|
ip_addr_set(&(netif->gw), gw);
|
||||||
LWIP_DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: GW address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | 3, ("netif: GW address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
||||||
netif->name[0], netif->name[1],
|
netif->name[0], netif->name[1],
|
||||||
ip4_addr1(&netif->gw),
|
ip4_addr1(&netif->gw),
|
||||||
ip4_addr2(&netif->gw),
|
ip4_addr2(&netif->gw),
|
||||||
@ -251,7 +251,7 @@ netif_set_netmask(struct netif *netif, struct ip_addr *netmask)
|
|||||||
/* set new netmask to netif */
|
/* set new netmask to netif */
|
||||||
ip_addr_set(&(netif->netmask), netmask);
|
ip_addr_set(&(netif->netmask), netmask);
|
||||||
snmp_insert_iprteidx_tree(0, netif);
|
snmp_insert_iprteidx_tree(0, netif);
|
||||||
LWIP_DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: netmask of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | 3, ("netif: netmask of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
||||||
netif->name[0], netif->name[1],
|
netif->name[0], netif->name[1],
|
||||||
ip4_addr1(&netif->netmask),
|
ip4_addr1(&netif->netmask),
|
||||||
ip4_addr2(&netif->netmask),
|
ip4_addr2(&netif->netmask),
|
||||||
|
@ -219,7 +219,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
|
|||||||
struct pbuf *p, *q, *r;
|
struct pbuf *p, *q, *r;
|
||||||
u16_t offset;
|
u16_t offset;
|
||||||
s32_t rem_len; /* remaining length */
|
s32_t rem_len; /* remaining length */
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc(length=%"U16_F")\n", length));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 3, ("pbuf_alloc(length=%"U16_F")\n", length));
|
||||||
|
|
||||||
/* determine header offset */
|
/* determine header offset */
|
||||||
offset = 0;
|
offset = 0;
|
||||||
@ -247,7 +247,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
|
|||||||
case PBUF_POOL:
|
case PBUF_POOL:
|
||||||
/* allocate head of pbuf chain into p */
|
/* allocate head of pbuf chain into p */
|
||||||
p = pbuf_pool_alloc();
|
p = pbuf_pool_alloc();
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc: allocated pbuf %p\n", (void *)p));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 3, ("pbuf_alloc: allocated pbuf %p\n", (void *)p));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
#if PBUF_STATS
|
#if PBUF_STATS
|
||||||
++lwip_stats.pbuf.err;
|
++lwip_stats.pbuf.err;
|
||||||
@ -328,7 +328,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
|
|||||||
/* only allocate memory for the pbuf structure */
|
/* only allocate memory for the pbuf structure */
|
||||||
p = memp_malloc(MEMP_PBUF);
|
p = memp_malloc(MEMP_PBUF);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_alloc: Could not allocate MEMP_PBUF for PBUF_%s.\n", flag == PBUF_ROM?"ROM":"REF"));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 2, ("pbuf_alloc: Could not allocate MEMP_PBUF for PBUF_%s.\n", flag == PBUF_ROM?"ROM":"REF"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* caller must set this field properly, afterwards */
|
/* caller must set this field properly, afterwards */
|
||||||
@ -343,7 +343,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
|
|||||||
}
|
}
|
||||||
/* set reference count */
|
/* set reference count */
|
||||||
p->ref = 1;
|
p->ref = 1;
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc(length=%"U16_F") == %p\n", length, (void *)p));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 3, ("pbuf_alloc(length=%"U16_F") == %p\n", length, (void *)p));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -581,10 +581,10 @@ pbuf_free(struct pbuf *p)
|
|||||||
LWIP_ASSERT("p != NULL", p != NULL);
|
LWIP_ASSERT("p != NULL", p != NULL);
|
||||||
/* if assertions are disabled, proceed with debug output */
|
/* if assertions are disabled, proceed with debug output */
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_free(p == NULL) was called.\n"));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 2, ("pbuf_free(p == NULL) was called.\n"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_free(%p)\n", (void *)p));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 3, ("pbuf_free(%p)\n", (void *)p));
|
||||||
|
|
||||||
PERF_START;
|
PERF_START;
|
||||||
|
|
||||||
@ -737,7 +737,7 @@ pbuf_chain(struct pbuf *h, struct pbuf *t)
|
|||||||
pbuf_cat(h, t);
|
pbuf_cat(h, t);
|
||||||
/* t is now referenced by h */
|
/* t is now referenced by h */
|
||||||
pbuf_ref(t);
|
pbuf_ref(t);
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_chain: %p references %p\n", (void *)h, (void *)t));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_FRESH | 2, ("pbuf_chain: %p references %p\n", (void *)h, (void *)t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For packet queueing. Note that queued packets MUST be dequeued first
|
/* For packet queueing. Note that queued packets MUST be dequeued first
|
||||||
@ -762,7 +762,7 @@ pbuf_queue(struct pbuf *p, struct pbuf *n)
|
|||||||
LWIP_ASSERT("n == NULL in pbuf_queue: this indicates a programmer error\n", n != NULL);
|
LWIP_ASSERT("n == NULL in pbuf_queue: this indicates a programmer error\n", n != NULL);
|
||||||
LWIP_ASSERT("p == n in pbuf_queue: this indicates a programmer error\n", p != n);
|
LWIP_ASSERT("p == n in pbuf_queue: this indicates a programmer error\n", p != n);
|
||||||
if ((p == NULL) || (n == NULL) || (p == n)){
|
if ((p == NULL) || (n == NULL) || (p == n)){
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_HALT | 3, ("pbuf_queue: programmer argument error\n"));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_HALT | 3, ("pbuf_queue: programmer argument error\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -792,7 +792,7 @@ pbuf_queue(struct pbuf *p, struct pbuf *n)
|
|||||||
/* n is now referenced to by the (packet p in the) queue */
|
/* n is now referenced to by the (packet p in the) queue */
|
||||||
pbuf_ref(n);
|
pbuf_ref(n);
|
||||||
#if PBUF_DEBUG
|
#if PBUF_DEBUG
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2,
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_FRESH | 2,
|
||||||
("pbuf_queue: newly queued packet %p sits after packet %p in queue %p\n",
|
("pbuf_queue: newly queued packet %p sits after packet %p in queue %p\n",
|
||||||
(void *)n, (void *)p, (void *)q));
|
(void *)n, (void *)p, (void *)q));
|
||||||
#endif
|
#endif
|
||||||
@ -833,9 +833,9 @@ pbuf_dequeue(struct pbuf *p)
|
|||||||
/* although q is no longer referenced by p, it MUST be referenced by
|
/* although q is no longer referenced by p, it MUST be referenced by
|
||||||
* the caller, who is maintaining this packet queue. So, we do not call
|
* the caller, who is maintaining this packet queue. So, we do not call
|
||||||
* pbuf_free(q) here, resulting in an implicit pbuf_ref(q) for the caller. */
|
* pbuf_free(q) here, resulting in an implicit pbuf_ref(q) for the caller. */
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_dequeue: first remaining packet on queue is %p\n", (void *)q));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_FRESH | 2, ("pbuf_dequeue: first remaining packet on queue is %p\n", (void *)q));
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_dequeue: no further packets on queue\n"));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_FRESH | 2, ("pbuf_dequeue: no further packets on queue\n"));
|
||||||
}
|
}
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
@ -868,7 +868,7 @@ pbuf_take(struct pbuf *p)
|
|||||||
{
|
{
|
||||||
struct pbuf *q , *prev, *head;
|
struct pbuf *q , *prev, *head;
|
||||||
LWIP_ASSERT("pbuf_take: p != NULL\n", p != NULL);
|
LWIP_ASSERT("pbuf_take: p != NULL\n", p != NULL);
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_take(%p)\n", (void*)p));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 3, ("pbuf_take(%p)\n", (void*)p));
|
||||||
|
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
head = p;
|
head = p;
|
||||||
@ -877,24 +877,24 @@ pbuf_take(struct pbuf *p)
|
|||||||
{
|
{
|
||||||
/* pbuf is of type PBUF_REF? */
|
/* pbuf is of type PBUF_REF? */
|
||||||
if (p->flags == PBUF_FLAG_REF) {
|
if (p->flags == PBUF_FLAG_REF) {
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE, ("pbuf_take: encountered PBUF_REF %p\n", (void *)p));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_take: encountered PBUF_REF %p\n", (void *)p));
|
||||||
/* allocate a pbuf (w/ payload) fully in RAM */
|
/* allocate a pbuf (w/ payload) fully in RAM */
|
||||||
/* PBUF_POOL buffers are faster if we can use them */
|
/* PBUF_POOL buffers are faster if we can use them */
|
||||||
if (p->len <= PBUF_POOL_BUFSIZE) {
|
if (p->len <= PBUF_POOL_BUFSIZE) {
|
||||||
q = pbuf_alloc(PBUF_RAW, p->len, PBUF_POOL);
|
q = pbuf_alloc(PBUF_RAW, p->len, PBUF_POOL);
|
||||||
if (q == NULL) {
|
if (q == NULL) {
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: Could not allocate PBUF_POOL\n"));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 2, ("pbuf_take: Could not allocate PBUF_POOL\n"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* no replacement pbuf yet */
|
/* no replacement pbuf yet */
|
||||||
q = NULL;
|
q = NULL;
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: PBUF_POOL too small to replace PBUF_REF\n"));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 2, ("pbuf_take: PBUF_POOL too small to replace PBUF_REF\n"));
|
||||||
}
|
}
|
||||||
/* no (large enough) PBUF_POOL was available? retry with PBUF_RAM */
|
/* no (large enough) PBUF_POOL was available? retry with PBUF_RAM */
|
||||||
if (q == NULL) {
|
if (q == NULL) {
|
||||||
q = pbuf_alloc(PBUF_RAW, p->len, PBUF_RAM);
|
q = pbuf_alloc(PBUF_RAW, p->len, PBUF_RAM);
|
||||||
if (q == NULL) {
|
if (q == NULL) {
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: Could not allocate PBUF_RAM\n"));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 2, ("pbuf_take: Could not allocate PBUF_RAM\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* replacement pbuf could be allocated? */
|
/* replacement pbuf could be allocated? */
|
||||||
@ -938,14 +938,14 @@ pbuf_take(struct pbuf *p)
|
|||||||
}
|
}
|
||||||
/* p->flags != PBUF_FLAG_REF */
|
/* p->flags != PBUF_FLAG_REF */
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 1, ("pbuf_take: skipping pbuf not of type PBUF_REF\n"));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 1, ("pbuf_take: skipping pbuf not of type PBUF_REF\n"));
|
||||||
}
|
}
|
||||||
/* remember this pbuf */
|
/* remember this pbuf */
|
||||||
prev = p;
|
prev = p;
|
||||||
/* proceed to next pbuf in original chain */
|
/* proceed to next pbuf in original chain */
|
||||||
p = p->next;
|
p = p->next;
|
||||||
} while (p);
|
} while (p);
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 1, ("pbuf_take: end of chain reached.\n"));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 1, ("pbuf_take: end of chain reached.\n"));
|
||||||
|
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
@ -976,10 +976,10 @@ pbuf_dechain(struct pbuf *p)
|
|||||||
/* total length of pbuf p is its own length only */
|
/* total length of pbuf p is its own length only */
|
||||||
p->tot_len = p->len;
|
p->tot_len = p->len;
|
||||||
/* q is no longer referenced by p, free it */
|
/* q is no longer referenced by p, free it */
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_STATE, ("pbuf_dechain: unreferencing %p\n", (void *)q));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_STATE, ("pbuf_dechain: unreferencing %p\n", (void *)q));
|
||||||
tail_gone = pbuf_free(q);
|
tail_gone = pbuf_free(q);
|
||||||
if (tail_gone > 0) {
|
if (tail_gone > 0) {
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | DBG_STATE,
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_STATE,
|
||||||
("pbuf_dechain: deallocated %p (as it is no longer referenced)\n", (void *)q));
|
("pbuf_dechain: deallocated %p (as it is no longer referenced)\n", (void *)q));
|
||||||
}
|
}
|
||||||
/* return remaining tail or NULL if deallocated */
|
/* return remaining tail or NULL if deallocated */
|
||||||
|
@ -202,7 +202,7 @@ raw_sendto(struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *ipaddr)
|
|||||||
struct ip_addr *src_ip;
|
struct ip_addr *src_ip;
|
||||||
struct pbuf *q; /* q will be sent down the stack */
|
struct pbuf *q; /* q will be sent down the stack */
|
||||||
|
|
||||||
LWIP_DEBUGF(RAW_DEBUG | DBG_TRACE | 3, ("raw_sendto\n"));
|
LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE | 3, ("raw_sendto\n"));
|
||||||
|
|
||||||
/* not enough space to add an IP header to first pbuf in given p chain? */
|
/* not enough space to add an IP header to first pbuf in given p chain? */
|
||||||
if (pbuf_header(p, IP_HLEN)) {
|
if (pbuf_header(p, IP_HLEN)) {
|
||||||
@ -210,7 +210,7 @@ raw_sendto(struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *ipaddr)
|
|||||||
q = pbuf_alloc(PBUF_IP, 0, PBUF_RAM);
|
q = pbuf_alloc(PBUF_IP, 0, PBUF_RAM);
|
||||||
/* new header pbuf could not be allocated? */
|
/* new header pbuf could not be allocated? */
|
||||||
if (q == NULL) {
|
if (q == NULL) {
|
||||||
LWIP_DEBUGF(RAW_DEBUG | DBG_TRACE | 2, ("raw_sendto: could not allocate header\n"));
|
LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE | 2, ("raw_sendto: could not allocate header\n"));
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
}
|
}
|
||||||
/* chain header q in front of given pbuf p */
|
/* chain header q in front of given pbuf p */
|
||||||
@ -311,7 +311,7 @@ struct raw_pcb *
|
|||||||
raw_new(u16_t proto) {
|
raw_new(u16_t proto) {
|
||||||
struct raw_pcb *pcb;
|
struct raw_pcb *pcb;
|
||||||
|
|
||||||
LWIP_DEBUGF(RAW_DEBUG | DBG_TRACE | 3, ("raw_new\n"));
|
LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE | 3, ("raw_new\n"));
|
||||||
|
|
||||||
pcb = memp_malloc(MEMP_RAW_PCB);
|
pcb = memp_malloc(MEMP_RAW_PCB);
|
||||||
/* could allocate RAW PCB? */
|
/* could allocate RAW PCB? */
|
||||||
|
@ -93,7 +93,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t copy)
|
|||||||
}
|
}
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(TCP_OUTPUT_DEBUG | DBG_STATE | 3, ("tcp_write() called in invalid state\n"));
|
LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_STATE | 3, ("tcp_write() called in invalid state\n"));
|
||||||
return ERR_CONN;
|
return ERR_CONN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,7 +282,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
|
|||||||
segments such as SYN|ACK. */
|
segments such as SYN|ACK. */
|
||||||
memcpy(seg->dataptr, optdata, optlen);
|
memcpy(seg->dataptr, optdata, optlen);
|
||||||
}
|
}
|
||||||
LWIP_DEBUGF(TCP_OUTPUT_DEBUG | DBG_TRACE, ("tcp_enqueue: queueing %"U32_F":%"U32_F" (0x%"X16_F")\n",
|
LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_TRACE, ("tcp_enqueue: queueing %"U32_F":%"U32_F" (0x%"X16_F")\n",
|
||||||
ntohl(seg->tcphdr->seqno),
|
ntohl(seg->tcphdr->seqno),
|
||||||
ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg),
|
ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg),
|
||||||
(u16_t)flags));
|
(u16_t)flags));
|
||||||
@ -322,7 +322,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
|
|||||||
useg->len += queue->len;
|
useg->len += queue->len;
|
||||||
useg->next = queue->next;
|
useg->next = queue->next;
|
||||||
|
|
||||||
LWIP_DEBUGF(TCP_OUTPUT_DEBUG | DBG_TRACE | DBG_STATE, ("tcp_enqueue: chaining segments, new len %"U16_F"\n", useg->len));
|
LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("tcp_enqueue: chaining segments, new len %"U16_F"\n", useg->len));
|
||||||
if (seg == queue) {
|
if (seg == queue) {
|
||||||
seg = NULL;
|
seg = NULL;
|
||||||
}
|
}
|
||||||
@ -371,7 +371,7 @@ memerr:
|
|||||||
LWIP_ASSERT("tcp_enqueue: valid queue length", pcb->unacked != NULL ||
|
LWIP_ASSERT("tcp_enqueue: valid queue length", pcb->unacked != NULL ||
|
||||||
pcb->unsent != NULL);
|
pcb->unsent != NULL);
|
||||||
}
|
}
|
||||||
LWIP_DEBUGF(TCP_QLEN_DEBUG | DBG_STATE, ("tcp_enqueue: %"S16_F" (with mem err)\n", pcb->snd_queuelen));
|
LWIP_DEBUGF(TCP_QLEN_DEBUG | LWIP_DBG_STATE, ("tcp_enqueue: %"S16_F" (with mem err)\n", pcb->snd_queuelen));
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ udp_input(struct pbuf *p, struct netif *inp)
|
|||||||
|
|
||||||
/* Check checksum if this is a match or if it was directed at us. */
|
/* Check checksum if this is a match or if it was directed at us. */
|
||||||
if (pcb != NULL || ip_addr_cmp(&inp->ip_addr, &iphdr->dest)) {
|
if (pcb != NULL || ip_addr_cmp(&inp->ip_addr, &iphdr->dest)) {
|
||||||
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE, ("udp_input: calculating checksum\n"));
|
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_input: calculating checksum\n"));
|
||||||
#ifdef IPv6
|
#ifdef IPv6
|
||||||
if (iphdr->nexthdr == IP_PROTO_UDPLITE) {
|
if (iphdr->nexthdr == IP_PROTO_UDPLITE) {
|
||||||
#else
|
#else
|
||||||
@ -217,7 +217,7 @@ udp_input(struct pbuf *p, struct netif *inp)
|
|||||||
if (pcb->recv != NULL)
|
if (pcb->recv != NULL)
|
||||||
pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src);
|
pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src);
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE, ("udp_input: not for us.\n"));
|
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_input: not for us.\n"));
|
||||||
|
|
||||||
/* No match was found, send ICMP destination port unreachable unless
|
/* No match was found, send ICMP destination port unreachable unless
|
||||||
destination address was broadcast/multicast. */
|
destination address was broadcast/multicast. */
|
||||||
@ -303,14 +303,14 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
|
|||||||
err_t err;
|
err_t err;
|
||||||
struct pbuf *q; /* q will be sent down the stack */
|
struct pbuf *q; /* q will be sent down the stack */
|
||||||
|
|
||||||
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_send\n"));
|
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | 3, ("udp_send\n"));
|
||||||
|
|
||||||
/* if the PCB is not yet bound to a port, bind it here */
|
/* if the PCB is not yet bound to a port, bind it here */
|
||||||
if (pcb->local_port == 0) {
|
if (pcb->local_port == 0) {
|
||||||
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: not yet bound to a port, binding now\n"));
|
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | 2, ("udp_send: not yet bound to a port, binding now\n"));
|
||||||
err = udp_bind(pcb, &pcb->local_ip, pcb->local_port);
|
err = udp_bind(pcb, &pcb->local_ip, pcb->local_port);
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: forced port bind failed\n"));
|
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | 2, ("udp_send: forced port bind failed\n"));
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -329,7 +329,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
|
|||||||
q = pbuf_alloc(PBUF_IP, UDP_HLEN, PBUF_RAM);
|
q = pbuf_alloc(PBUF_IP, UDP_HLEN, PBUF_RAM);
|
||||||
/* new header pbuf could not be allocated? */
|
/* new header pbuf could not be allocated? */
|
||||||
if (q == NULL) {
|
if (q == NULL) {
|
||||||
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: could not allocate header\n"));
|
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | 2, ("udp_send: could not allocate header\n"));
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
}
|
}
|
||||||
/* chain header q in front of given pbuf p */
|
/* chain header q in front of given pbuf p */
|
||||||
@ -433,9 +433,9 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
|||||||
struct udp_pcb *ipcb;
|
struct udp_pcb *ipcb;
|
||||||
u8_t rebind;
|
u8_t rebind;
|
||||||
|
|
||||||
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_bind(ipaddr = "));
|
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | 3, ("udp_bind(ipaddr = "));
|
||||||
ip_addr_debug_print(UDP_DEBUG, ipaddr);
|
ip_addr_debug_print(UDP_DEBUG, ipaddr);
|
||||||
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, (", port = %"U16_F")\n", port));
|
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | 3, (", port = %"U16_F")\n", port));
|
||||||
|
|
||||||
rebind = 0;
|
rebind = 0;
|
||||||
/* Check for double bind and rebind of the same pcb */
|
/* Check for double bind and rebind of the same pcb */
|
||||||
@ -499,7 +499,7 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
|||||||
pcb->next = udp_pcbs;
|
pcb->next = udp_pcbs;
|
||||||
udp_pcbs = pcb;
|
udp_pcbs = pcb;
|
||||||
}
|
}
|
||||||
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | DBG_STATE,
|
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
|
||||||
("udp_bind: bound to %"U16_F".%"U16_F".%"U16_F".%"U16_F", port %"U16_F"\n",
|
("udp_bind: bound to %"U16_F".%"U16_F".%"U16_F".%"U16_F", port %"U16_F"\n",
|
||||||
(u16_t)(ntohl(pcb->local_ip.addr) >> 24 & 0xff),
|
(u16_t)(ntohl(pcb->local_ip.addr) >> 24 & 0xff),
|
||||||
(u16_t)(ntohl(pcb->local_ip.addr) >> 16 & 0xff),
|
(u16_t)(ntohl(pcb->local_ip.addr) >> 16 & 0xff),
|
||||||
@ -553,7 +553,7 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
|||||||
pcb->local_ip.addr = 0;
|
pcb->local_ip.addr = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | DBG_STATE,
|
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
|
||||||
("udp_connect: connected to %"U16_F".%"U16_F".%"U16_F".%"U16_F",port %"U16_F"\n",
|
("udp_connect: connected to %"U16_F".%"U16_F".%"U16_F".%"U16_F",port %"U16_F"\n",
|
||||||
(u16_t)(ntohl(pcb->remote_ip.addr) >> 24 & 0xff),
|
(u16_t)(ntohl(pcb->remote_ip.addr) >> 24 & 0xff),
|
||||||
(u16_t)(ntohl(pcb->remote_ip.addr) >> 16 & 0xff),
|
(u16_t)(ntohl(pcb->remote_ip.addr) >> 16 & 0xff),
|
||||||
|
@ -41,25 +41,25 @@
|
|||||||
* - 3 severe
|
* - 3 severe
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DBG_LEVEL_OFF 0
|
#define LWIP_DBG_LEVEL_OFF 0
|
||||||
#define DBG_LEVEL_WARNING 1 /* bad checksums, dropped packets, ... */
|
#define LWIP_DBG_LEVEL_WARNING 1 /* bad checksums, dropped packets, ... */
|
||||||
#define DBG_LEVEL_SERIOUS 2 /* memory allocation failures, ... */
|
#define LWIP_DBG_LEVEL_SERIOUS 2 /* memory allocation failures, ... */
|
||||||
#define DBG_LEVEL_SEVERE 3 /* */
|
#define LWIP_DBG_LEVEL_SEVERE 3 /* */
|
||||||
#define DBG_MASK_LEVEL 3
|
#define LWIP_DBG_MASK_LEVEL 3
|
||||||
|
|
||||||
/** flag for LWIP_DEBUGF to enable that debug message */
|
/** flag for LWIP_DEBUGF to enable that debug message */
|
||||||
#define DBG_ON 0x80U
|
#define LWIP_DBG_ON 0x80U
|
||||||
/** flag for LWIP_DEBUGF to disable that debug message */
|
/** flag for LWIP_DEBUGF to disable that debug message */
|
||||||
#define DBG_OFF 0x00U
|
#define LWIP_DBG_OFF 0x00U
|
||||||
|
|
||||||
/** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */
|
/** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */
|
||||||
#define DBG_TRACE 0x40U
|
#define LWIP_DBG_TRACE 0x40U
|
||||||
/** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */
|
/** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */
|
||||||
#define DBG_STATE 0x20U
|
#define LWIP_DBG_STATE 0x20U
|
||||||
/** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */
|
/** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */
|
||||||
#define DBG_FRESH 0x10U
|
#define LWIP_DBG_FRESH 0x10U
|
||||||
/** flag for LWIP_DEBUGF to halt after printing this debug message */
|
/** flag for LWIP_DEBUGF to halt after printing this debug message */
|
||||||
#define DBG_HALT 0x08U
|
#define LWIP_DBG_HALT 0x08U
|
||||||
|
|
||||||
#ifndef LWIP_NOASSERT
|
#ifndef LWIP_NOASSERT
|
||||||
# define LWIP_ASSERT(x,y) do { if(!(y)) LWIP_PLATFORM_ASSERT(x); } while(0)
|
# define LWIP_ASSERT(x,y) do { if(!(y)) LWIP_PLATFORM_ASSERT(x); } while(0)
|
||||||
@ -69,9 +69,9 @@
|
|||||||
|
|
||||||
#ifdef LWIP_DEBUG
|
#ifdef LWIP_DEBUG
|
||||||
/** print debug message only if debug message type is enabled...
|
/** print debug message only if debug message type is enabled...
|
||||||
* AND is of correct type AND is at least DBG_LEVEL
|
* AND is of correct type AND is at least LWIP_DBG_LEVEL
|
||||||
*/
|
*/
|
||||||
# define LWIP_DEBUGF(debug,x) do { if (((debug) & DBG_ON) && ((debug) & DBG_TYPES_ON) && ((s16_t)((debug) & DBG_MASK_LEVEL) >= DBG_MIN_LEVEL)) { LWIP_PLATFORM_DIAG(x); if ((debug) & DBG_HALT) while(1); } } while(0)
|
# define LWIP_DEBUGF(debug,x) do { if (((debug) & LWIP_DBG_ON) && ((debug) & LWIP_DBG_TYPES_ON) && ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { LWIP_PLATFORM_DIAG(x); if ((debug) & LWIP_DBG_HALT) while(1); } } while(0)
|
||||||
# define LWIP_ERROR(x) do { LWIP_PLATFORM_DIAG(x); } while(0)
|
# define LWIP_ERROR(x) do { LWIP_PLATFORM_DIAG(x); } while(0)
|
||||||
#else /* LWIP_DEBUG */
|
#else /* LWIP_DEBUG */
|
||||||
# define LWIP_DEBUGF(debug,x)
|
# define LWIP_DEBUGF(debug,x)
|
||||||
@ -80,8 +80,3 @@
|
|||||||
|
|
||||||
#endif /* __LWIP_DEBUG_H__ */
|
#endif /* __LWIP_DEBUG_H__ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -656,131 +656,131 @@ a lot of data that needs to be copied, this should be set high. */
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ETHARP_DEBUG
|
#ifndef ETHARP_DEBUG
|
||||||
#define ETHARP_DEBUG DBG_OFF
|
#define ETHARP_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NETIF_DEBUG
|
#ifndef NETIF_DEBUG
|
||||||
#define NETIF_DEBUG DBG_OFF
|
#define NETIF_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PBUF_DEBUG
|
#ifndef PBUF_DEBUG
|
||||||
#define PBUF_DEBUG DBG_OFF
|
#define PBUF_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef API_LIB_DEBUG
|
#ifndef API_LIB_DEBUG
|
||||||
#define API_LIB_DEBUG DBG_OFF
|
#define API_LIB_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef API_MSG_DEBUG
|
#ifndef API_MSG_DEBUG
|
||||||
#define API_MSG_DEBUG DBG_OFF
|
#define API_MSG_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SOCKETS_DEBUG
|
#ifndef SOCKETS_DEBUG
|
||||||
#define SOCKETS_DEBUG DBG_OFF
|
#define SOCKETS_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ICMP_DEBUG
|
#ifndef ICMP_DEBUG
|
||||||
#define ICMP_DEBUG DBG_OFF
|
#define ICMP_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef INET_DEBUG
|
#ifndef INET_DEBUG
|
||||||
#define INET_DEBUG DBG_OFF
|
#define INET_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef IP_DEBUG
|
#ifndef IP_DEBUG
|
||||||
#define IP_DEBUG DBG_OFF
|
#define IP_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef IP_REASS_DEBUG
|
#ifndef IP_REASS_DEBUG
|
||||||
#define IP_REASS_DEBUG DBG_OFF
|
#define IP_REASS_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef RAW_DEBUG
|
#ifndef RAW_DEBUG
|
||||||
#define RAW_DEBUG DBG_OFF
|
#define RAW_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MEM_DEBUG
|
#ifndef MEM_DEBUG
|
||||||
#define MEM_DEBUG DBG_OFF
|
#define MEM_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MEMP_DEBUG
|
#ifndef MEMP_DEBUG
|
||||||
#define MEMP_DEBUG DBG_OFF
|
#define MEMP_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SYS_DEBUG
|
#ifndef SYS_DEBUG
|
||||||
#define SYS_DEBUG DBG_OFF
|
#define SYS_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TCP_DEBUG
|
#ifndef TCP_DEBUG
|
||||||
#define TCP_DEBUG DBG_OFF
|
#define TCP_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TCP_INPUT_DEBUG
|
#ifndef TCP_INPUT_DEBUG
|
||||||
#define TCP_INPUT_DEBUG DBG_OFF
|
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TCP_FR_DEBUG
|
#ifndef TCP_FR_DEBUG
|
||||||
#define TCP_FR_DEBUG DBG_OFF
|
#define TCP_FR_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TCP_RTO_DEBUG
|
#ifndef TCP_RTO_DEBUG
|
||||||
#define TCP_RTO_DEBUG DBG_OFF
|
#define TCP_RTO_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TCP_REXMIT_DEBUG
|
#ifndef TCP_REXMIT_DEBUG
|
||||||
#define TCP_REXMIT_DEBUG DBG_OFF
|
#define TCP_REXMIT_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TCP_CWND_DEBUG
|
#ifndef TCP_CWND_DEBUG
|
||||||
#define TCP_CWND_DEBUG DBG_OFF
|
#define TCP_CWND_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TCP_WND_DEBUG
|
#ifndef TCP_WND_DEBUG
|
||||||
#define TCP_WND_DEBUG DBG_OFF
|
#define TCP_WND_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TCP_OUTPUT_DEBUG
|
#ifndef TCP_OUTPUT_DEBUG
|
||||||
#define TCP_OUTPUT_DEBUG DBG_OFF
|
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TCP_RST_DEBUG
|
#ifndef TCP_RST_DEBUG
|
||||||
#define TCP_RST_DEBUG DBG_OFF
|
#define TCP_RST_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TCP_QLEN_DEBUG
|
#ifndef TCP_QLEN_DEBUG
|
||||||
#define TCP_QLEN_DEBUG DBG_OFF
|
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef UDP_DEBUG
|
#ifndef UDP_DEBUG
|
||||||
#define UDP_DEBUG DBG_OFF
|
#define UDP_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TCPIP_DEBUG
|
#ifndef TCPIP_DEBUG
|
||||||
#define TCPIP_DEBUG DBG_OFF
|
#define TCPIP_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PPP_DEBUG
|
#ifndef PPP_DEBUG
|
||||||
#define PPP_DEBUG DBG_OFF
|
#define PPP_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SLIP_DEBUG
|
#ifndef SLIP_DEBUG
|
||||||
#define SLIP_DEBUG DBG_OFF
|
#define SLIP_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DHCP_DEBUG
|
#ifndef DHCP_DEBUG
|
||||||
#define DHCP_DEBUG DBG_OFF
|
#define DHCP_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SNMP_MSG_DEBUG
|
#ifndef SNMP_MSG_DEBUG
|
||||||
#define SNMP_MSG_DEBUG DBG_OFF
|
#define SNMP_MSG_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SNMP_MIB_DEBUG
|
#ifndef SNMP_MIB_DEBUG
|
||||||
#define SNMP_MIB_DEBUG DBG_OFF
|
#define SNMP_MIB_DEBUG LWIP_DBG_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DBG_MIN_LEVEL
|
#ifndef DBG_MIN_LEVEL
|
||||||
#define DBG_MIN_LEVEL DBG_LEVEL_OFF
|
#define DBG_MIN_LEVEL LWIP_DBG_LEVEL_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __LWIP_OPT_H__ */
|
#endif /* __LWIP_OPT_H__ */
|
||||||
|
@ -258,7 +258,7 @@ static s8_t find_entry(struct ip_addr *ipaddr, u8_t flags)
|
|||||||
else if (arp_table[i].state == ETHARP_STATE_PENDING) {
|
else if (arp_table[i].state == ETHARP_STATE_PENDING) {
|
||||||
/* if given, does IP address match IP address in ARP entry? */
|
/* if given, does IP address match IP address in ARP entry? */
|
||||||
if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) {
|
if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) {
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: found matching pending entry %"U16_F"\n", (u16_t)i));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("find_entry: found matching pending entry %"U16_F"\n", (u16_t)i));
|
||||||
/* found exact IP address match, simply bail out */
|
/* found exact IP address match, simply bail out */
|
||||||
return i;
|
return i;
|
||||||
#if ARP_QUEUEING
|
#if ARP_QUEUEING
|
||||||
@ -281,7 +281,7 @@ static s8_t find_entry(struct ip_addr *ipaddr, u8_t flags)
|
|||||||
else if (arp_table[i].state == ETHARP_STATE_STABLE) {
|
else if (arp_table[i].state == ETHARP_STATE_STABLE) {
|
||||||
/* if given, does IP address match IP address in ARP entry? */
|
/* if given, does IP address match IP address in ARP entry? */
|
||||||
if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) {
|
if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) {
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: found matching stable entry %"U16_F"\n", (u16_t)i));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("find_entry: found matching stable entry %"U16_F"\n", (u16_t)i));
|
||||||
/* found exact IP address match, simply bail out */
|
/* found exact IP address match, simply bail out */
|
||||||
return i;
|
return i;
|
||||||
/* remember entry with oldest stable entry in oldest, its age in maxtime */
|
/* remember entry with oldest stable entry in oldest, its age in maxtime */
|
||||||
@ -311,13 +311,13 @@ static s8_t find_entry(struct ip_addr *ipaddr, u8_t flags)
|
|||||||
/* 1) empty entry available? */
|
/* 1) empty entry available? */
|
||||||
if (empty < ARP_TABLE_SIZE) {
|
if (empty < ARP_TABLE_SIZE) {
|
||||||
i = empty;
|
i = empty;
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting empty entry %"U16_F"\n", (u16_t)i));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("find_entry: selecting empty entry %"U16_F"\n", (u16_t)i));
|
||||||
}
|
}
|
||||||
/* 2) found recyclable stable entry? */
|
/* 2) found recyclable stable entry? */
|
||||||
else if (old_stable < ARP_TABLE_SIZE) {
|
else if (old_stable < ARP_TABLE_SIZE) {
|
||||||
/* recycle oldest stable*/
|
/* recycle oldest stable*/
|
||||||
i = old_stable;
|
i = old_stable;
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest stable entry %"U16_F"\n", (u16_t)i));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("find_entry: selecting oldest stable entry %"U16_F"\n", (u16_t)i));
|
||||||
#if ARP_QUEUEING
|
#if ARP_QUEUEING
|
||||||
/* no queued packets should exist on stable entries */
|
/* no queued packets should exist on stable entries */
|
||||||
LWIP_ASSERT("arp_table[i].q == NULL", arp_table[i].q == NULL);
|
LWIP_ASSERT("arp_table[i].q == NULL", arp_table[i].q == NULL);
|
||||||
@ -326,13 +326,13 @@ static s8_t find_entry(struct ip_addr *ipaddr, u8_t flags)
|
|||||||
} else if (old_pending < ARP_TABLE_SIZE) {
|
} else if (old_pending < ARP_TABLE_SIZE) {
|
||||||
/* recycle oldest pending */
|
/* recycle oldest pending */
|
||||||
i = old_pending;
|
i = old_pending;
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest pending entry %"U16_F" (without queue)\n", (u16_t)i));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("find_entry: selecting oldest pending entry %"U16_F" (without queue)\n", (u16_t)i));
|
||||||
#if ARP_QUEUEING
|
#if ARP_QUEUEING
|
||||||
/* 4) found recyclable pending entry with queued packets? */
|
/* 4) found recyclable pending entry with queued packets? */
|
||||||
} else if (old_queue < ARP_TABLE_SIZE) {
|
} else if (old_queue < ARP_TABLE_SIZE) {
|
||||||
/* recycle oldest pending */
|
/* recycle oldest pending */
|
||||||
i = old_queue;
|
i = old_queue;
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest pending entry %"U16_F", freeing packet queue %p\n", (u16_t)i, (void *)(arp_table[i].q)));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("find_entry: selecting oldest pending entry %"U16_F", freeing packet queue %p\n", (u16_t)i, (void *)(arp_table[i].q)));
|
||||||
free_etharp_q(arp_table[i].q);
|
free_etharp_q(arp_table[i].q);
|
||||||
arp_table[i].q = NULL;
|
arp_table[i].q = NULL;
|
||||||
#endif
|
#endif
|
||||||
@ -384,9 +384,9 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
|
|||||||
{
|
{
|
||||||
s8_t i;
|
s8_t i;
|
||||||
u8_t k;
|
u8_t k;
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 3, ("update_arp_entry()\n"));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | 3, ("update_arp_entry()\n"));
|
||||||
LWIP_ASSERT("netif->hwaddr_len != 0", netif->hwaddr_len != 0);
|
LWIP_ASSERT("netif->hwaddr_len != 0", netif->hwaddr_len != 0);
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: %"U16_F".%"U16_F".%"U16_F".%"U16_F" - %02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F"\n",
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("update_arp_entry: %"U16_F".%"U16_F".%"U16_F".%"U16_F" - %02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F"\n",
|
||||||
ip4_addr1(ipaddr), ip4_addr2(ipaddr), ip4_addr3(ipaddr), ip4_addr4(ipaddr),
|
ip4_addr1(ipaddr), ip4_addr2(ipaddr), ip4_addr3(ipaddr), ip4_addr4(ipaddr),
|
||||||
ethaddr->addr[0], ethaddr->addr[1], ethaddr->addr[2],
|
ethaddr->addr[0], ethaddr->addr[1], ethaddr->addr[2],
|
||||||
ethaddr->addr[3], ethaddr->addr[4], ethaddr->addr[5]));
|
ethaddr->addr[3], ethaddr->addr[4], ethaddr->addr[5]));
|
||||||
@ -394,7 +394,7 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
|
|||||||
if (ip_addr_isany(ipaddr) ||
|
if (ip_addr_isany(ipaddr) ||
|
||||||
ip_addr_isbroadcast(ipaddr, netif) ||
|
ip_addr_isbroadcast(ipaddr, netif) ||
|
||||||
ip_addr_ismulticast(ipaddr)) {
|
ip_addr_ismulticast(ipaddr)) {
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: will not add non-unicast IP address to ARP cache\n"));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("update_arp_entry: will not add non-unicast IP address to ARP cache\n"));
|
||||||
return ERR_ARG;
|
return ERR_ARG;
|
||||||
}
|
}
|
||||||
/* find or create ARP entry */
|
/* find or create ARP entry */
|
||||||
@ -410,7 +410,7 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
|
|||||||
/* insert in SNMP ARP index tree */
|
/* insert in SNMP ARP index tree */
|
||||||
snmp_insert_arpidx_tree(netif, &arp_table[i].ipaddr);
|
snmp_insert_arpidx_tree(netif, &arp_table[i].ipaddr);
|
||||||
|
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: updating stable entry %"S16_F"\n", (s16_t)i));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("update_arp_entry: updating stable entry %"S16_F"\n", (s16_t)i));
|
||||||
/* update address */
|
/* update address */
|
||||||
k = netif->hwaddr_len;
|
k = netif->hwaddr_len;
|
||||||
while (k > 0) {
|
while (k > 0) {
|
||||||
@ -442,7 +442,7 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
|
|||||||
ethhdr->src.addr[k] = netif->hwaddr[k];
|
ethhdr->src.addr[k] = netif->hwaddr[k];
|
||||||
}
|
}
|
||||||
ethhdr->type = htons(ETHTYPE_IP);
|
ethhdr->type = htons(ETHTYPE_IP);
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: sending queued IP packet %p.\n", (void *)p));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("update_arp_entry: sending queued IP packet %p.\n", (void *)p));
|
||||||
/* send the queued IP packet */
|
/* send the queued IP packet */
|
||||||
netif->linkoutput(netif, p);
|
netif->linkoutput(netif, p);
|
||||||
/* free the queued IP packet */
|
/* free the queued IP packet */
|
||||||
@ -514,7 +514,7 @@ etharp_ip_input(struct netif *netif, struct pbuf *p)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_ip_input: updating ETHARP table.\n"));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_ip_input: updating ETHARP table.\n"));
|
||||||
/* update ARP table */
|
/* update ARP table */
|
||||||
/* @todo We could use ETHARP_TRY_HARD if we think we are going to talk
|
/* @todo We could use ETHARP_TRY_HARD if we think we are going to talk
|
||||||
* back soon (for example, if the destination IP address is ours. */
|
* back soon (for example, if the destination IP address is ours. */
|
||||||
@ -550,7 +550,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
|
|||||||
|
|
||||||
/* drop short ARP packets */
|
/* drop short ARP packets */
|
||||||
if (p->tot_len < sizeof(struct etharp_hdr)) {
|
if (p->tot_len < sizeof(struct etharp_hdr)) {
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 1, ("etharp_arp_input: packet dropped, too short (%"S16_F"/%"S16_F")\n", p->tot_len, (s16_t)sizeof(struct etharp_hdr)));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | 1, ("etharp_arp_input: packet dropped, too short (%"S16_F"/%"S16_F")\n", p->tot_len, (s16_t)sizeof(struct etharp_hdr)));
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -589,11 +589,11 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
|
|||||||
* reply. In any case, we time-stamp any existing ARP entry,
|
* reply. In any case, we time-stamp any existing ARP entry,
|
||||||
* and possiby send out an IP packet that was queued on it. */
|
* and possiby send out an IP packet that was queued on it. */
|
||||||
|
|
||||||
LWIP_DEBUGF (ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP request\n"));
|
LWIP_DEBUGF (ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: incoming ARP request\n"));
|
||||||
/* ARP request for our address? */
|
/* ARP request for our address? */
|
||||||
if (for_us) {
|
if (for_us) {
|
||||||
|
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: replying to ARP request for our IP address\n"));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: replying to ARP request for our IP address\n"));
|
||||||
/* re-use pbuf to send ARP reply */
|
/* re-use pbuf to send ARP reply */
|
||||||
hdr->opcode = htons(ARP_REPLY);
|
hdr->opcode = htons(ARP_REPLY);
|
||||||
|
|
||||||
@ -621,16 +621,16 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
|
|||||||
/* we are not configured? */
|
/* we are not configured? */
|
||||||
} else if (netif->ip_addr.addr == 0) {
|
} else if (netif->ip_addr.addr == 0) {
|
||||||
/* { for_us == 0 and netif->ip_addr.addr == 0 } */
|
/* { for_us == 0 and netif->ip_addr.addr == 0 } */
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: we are unconfigured, ARP request ignored.\n"));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: we are unconfigured, ARP request ignored.\n"));
|
||||||
/* request was not directed to us */
|
/* request was not directed to us */
|
||||||
} else {
|
} else {
|
||||||
/* { for_us == 0 and netif->ip_addr.addr != 0 } */
|
/* { for_us == 0 and netif->ip_addr.addr != 0 } */
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: ARP request was not for us.\n"));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: ARP request was not for us.\n"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ARP_REPLY:
|
case ARP_REPLY:
|
||||||
/* ARP reply. We already updated the ARP cache earlier. */
|
/* ARP reply. We already updated the ARP cache earlier. */
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP reply\n"));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: incoming ARP reply\n"));
|
||||||
#if (LWIP_DHCP && DHCP_DOES_ARP_CHECK)
|
#if (LWIP_DHCP && DHCP_DOES_ARP_CHECK)
|
||||||
/* DHCP wants to know about ARP replies from any host with an
|
/* DHCP wants to know about ARP replies from any host with an
|
||||||
* IP address also offered to us by the DHCP server. We do not
|
* IP address also offered to us by the DHCP server. We do not
|
||||||
@ -641,7 +641,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: ARP unknown opcode type %"S16_F"\n", htons(hdr->opcode)));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: ARP unknown opcode type %"S16_F"\n", htons(hdr->opcode)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* free ARP packet */
|
/* free ARP packet */
|
||||||
@ -676,7 +676,7 @@ etharp_output(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
|
|||||||
/* make room for Ethernet header - should not fail */
|
/* make room for Ethernet header - should not fail */
|
||||||
if (pbuf_header(q, sizeof(struct eth_hdr)) != 0) {
|
if (pbuf_header(q, sizeof(struct eth_hdr)) != 0) {
|
||||||
/* bail out */
|
/* bail out */
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 2, ("etharp_output: could not allocate room for header.\n"));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | 2, ("etharp_output: could not allocate room for header.\n"));
|
||||||
LINK_STATS_INC(link.lenerr);
|
LINK_STATS_INC(link.lenerr);
|
||||||
return ERR_BUF;
|
return ERR_BUF;
|
||||||
}
|
}
|
||||||
@ -776,7 +776,7 @@ err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
|
|||||||
if (ip_addr_isbroadcast(ipaddr, netif) ||
|
if (ip_addr_isbroadcast(ipaddr, netif) ||
|
||||||
ip_addr_ismulticast(ipaddr) ||
|
ip_addr_ismulticast(ipaddr) ||
|
||||||
ip_addr_isany(ipaddr)) {
|
ip_addr_isany(ipaddr)) {
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: will not add non-unicast IP address to ARP cache\n"));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: will not add non-unicast IP address to ARP cache\n"));
|
||||||
return ERR_ARG;
|
return ERR_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -786,8 +786,8 @@ err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
|
|||||||
/* could not find or create entry? */
|
/* could not find or create entry? */
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
{
|
{
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: could not create ARP entry\n"));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: could not create ARP entry\n"));
|
||||||
if (q) LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: packet dropped\n"));
|
if (q) LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: packet dropped\n"));
|
||||||
return (err_t)i;
|
return (err_t)i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -821,7 +821,7 @@ err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
|
|||||||
ethhdr->src.addr[k] = srcaddr->addr[k];
|
ethhdr->src.addr[k] = srcaddr->addr[k];
|
||||||
}
|
}
|
||||||
ethhdr->type = htons(ETHTYPE_IP);
|
ethhdr->type = htons(ETHTYPE_IP);
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: sending packet %p\n", (void *)q));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: sending packet %p\n", (void *)q));
|
||||||
/* send the packet */
|
/* send the packet */
|
||||||
result = netif->linkoutput(netif, q);
|
result = netif->linkoutput(netif, q);
|
||||||
/* pending entry? (either just created or already pending */
|
/* pending entry? (either just created or already pending */
|
||||||
@ -855,16 +855,16 @@ err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
|
|||||||
/* queue did not exist, first item in queue */
|
/* queue did not exist, first item in queue */
|
||||||
arp_table[i].q = newEntry;
|
arp_table[i].q = newEntry;
|
||||||
}
|
}
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: queued packet %p on ARP entry %"S16_F"\n", (void *)q, (s16_t)i));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: queued packet %p on ARP entry %"S16_F"\n", (void *)q, (s16_t)i));
|
||||||
result = ERR_OK;
|
result = ERR_OK;
|
||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: could not queue a copy of PBUF_REF packet %p (out of memory)\n", (void *)q));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: could not queue a copy of PBUF_REF packet %p (out of memory)\n", (void *)q));
|
||||||
/* { result == ERR_MEM } through initialization */
|
/* { result == ERR_MEM } through initialization */
|
||||||
}
|
}
|
||||||
#else /* ARP_QUEUEING == 0 */
|
#else /* ARP_QUEUEING == 0 */
|
||||||
/* q && state == PENDING && ARP_QUEUEING == 0 => result = ERR_MEM */
|
/* q && state == PENDING && ARP_QUEUEING == 0 => result = ERR_MEM */
|
||||||
/* { result == ERR_MEM } through initialization */
|
/* { result == ERR_MEM } through initialization */
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: Ethernet destination address unknown, queueing disabled, packet %p dropped\n", (void *)q));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: Ethernet destination address unknown, queueing disabled, packet %p dropped\n", (void *)q));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -883,7 +883,7 @@ err_t etharp_request(struct netif *netif, struct ip_addr *ipaddr)
|
|||||||
/* could allocate a pbuf for an ARP request? */
|
/* could allocate a pbuf for an ARP request? */
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
struct etharp_hdr *hdr = p->payload;
|
struct etharp_hdr *hdr = p->payload;
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_request: sending ARP request.\n"));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_request: sending ARP request.\n"));
|
||||||
hdr->opcode = htons(ARP_REQUEST);
|
hdr->opcode = htons(ARP_REQUEST);
|
||||||
k = netif->hwaddr_len;
|
k = netif->hwaddr_len;
|
||||||
while(k > 0) {
|
while(k > 0) {
|
||||||
@ -917,7 +917,7 @@ err_t etharp_request(struct netif *netif, struct ip_addr *ipaddr)
|
|||||||
/* could not allocate pbuf for ARP request */
|
/* could not allocate pbuf for ARP request */
|
||||||
} else {
|
} else {
|
||||||
result = ERR_MEM;
|
result = ERR_MEM;
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 2, ("etharp_request: could not allocate pbuf for ARP request.\n"));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | 2, ("etharp_request: could not allocate pbuf for ARP request.\n"));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user