Documentation changes. Added missing trailing newlines to debug messages.

This commit is contained in:
likewise 2003-03-31 10:32:35 +00:00
parent 8636ac26cf
commit 6c147709b6
8 changed files with 202 additions and 186 deletions

View File

@ -138,9 +138,9 @@ static void dhcp_option_trailer(struct dhcp *dhcp);
static void dhcp_handle_nak(struct netif *netif) {
struct dhcp *dhcp = netif->dhcp;
u16_t msecs = 10 * 1000;
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_handle_nak()"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_handle_nak()\n"));
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_handle_nak(): set request timeout %u msecs", msecs));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_handle_nak(): set request timeout %u msecs\n", msecs));
dhcp_set_state(dhcp, DHCP_BACKING_OFF);
}
@ -157,12 +157,12 @@ static void dhcp_check(struct netif *netif)
struct pbuf *p;
err_t result;
u16_t msecs;
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_check()"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_check()\n"));
/* create an ARP query for the offered IP address, expecting that no host
responds, as the IP address should not be in use. */
p = etharp_query(netif, &dhcp->offered_ip_addr, NULL);
if (p != NULL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_check(): sending ARP request len %u", p->tot_len));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_check(): sending ARP request len %u\n", p->tot_len));
result = netif->linkoutput(netif, p);
pbuf_free(p);
p = NULL;
@ -172,7 +172,7 @@ static void dhcp_check(struct netif *netif)
dhcp->tries++;
msecs = 500;
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_check(): set request timeout %u msecs", msecs));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_check(): set request timeout %u msecs\n", msecs));
dhcp_set_state(dhcp, DHCP_CHECKING);
}
@ -189,10 +189,10 @@ static void dhcp_handle_offer(struct netif *netif)
if (option_ptr != NULL)
{
dhcp->server_ip_addr.addr = htonl(dhcp_get_option_long(&option_ptr[2]));
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): server 0x%08lx", dhcp->server_ip_addr.addr));
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): server 0x%08lx\n", dhcp->server_ip_addr.addr));
/* remember offered address */
ip_addr_set(&dhcp->offered_ip_addr, (struct ip_addr *)&dhcp->msg_in->yiaddr);
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): offer for 0x%08lx", dhcp->offered_ip_addr.addr));
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): offer for 0x%08lx\n", dhcp->offered_ip_addr.addr));
dhcp_select(netif);
}
}
@ -210,7 +210,7 @@ static err_t dhcp_select(struct netif *netif)
struct dhcp *dhcp = netif->dhcp;
err_t result;
u32_t msecs;
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_select()"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_select()\n"));
/* create and initialize the DHCP message header */
result = dhcp_create_request(netif);
@ -255,7 +255,7 @@ static err_t dhcp_select(struct netif *netif)
dhcp->tries++;
msecs = dhcp->tries < 4 ? dhcp->tries * 1000 : 4 * 1000;
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_select(): set request timeout %u msecs", msecs));
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_select(): set request timeout %u msecs\n", msecs));
return result;
}
@ -266,19 +266,19 @@ static err_t dhcp_select(struct netif *netif)
void dhcp_coarse_tmr()
{
struct netif *netif = netif_list;
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_coarse_tmr():"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_coarse_tmr()\n"));
/* iterate through all network interfaces */
while (netif != NULL) {
/* only act on DHCP configured interfaces */
if (netif->dhcp != NULL) {
/* timer is active (non zero), and triggers (zeroes) now? */
if (netif->dhcp->t2_timeout-- == 1) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_coarse_tmr(): t2 timeout"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_coarse_tmr(): t2 timeout\n"));
/* this clients' rebind timeout triggered */
dhcp_t2_timeout(netif);
/* timer is active (non zero), and triggers (zeroes) now */
} else if (netif->dhcp->t1_timeout-- == 1) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_coarse_tmr(): t1 timeout"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_coarse_tmr(): t1 timeout\n"));
/* this clients' renewal timeout triggered */
dhcp_t1_timeout(netif);
}
@ -303,7 +303,7 @@ void dhcp_fine_tmr()
if (netif->dhcp != NULL) {
/* timer is active (non zero), and triggers (zeroes) now */
if (netif->dhcp->request_timeout-- == 1) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_fine_tmr(): request timeout"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_fine_tmr(): request timeout\n"));
/* this clients' request timeout triggered */
dhcp_timeout(netif);
}
@ -325,24 +325,24 @@ void dhcp_fine_tmr()
static void dhcp_timeout(struct netif *netif)
{
struct dhcp *dhcp = netif->dhcp;
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_timeout()"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_timeout()\n"));
/* back-off period has passed, or server selection timed out */
if ((dhcp->state == DHCP_BACKING_OFF) || (dhcp->state == DHCP_SELECTING)) {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_timeout(): restarting discovery"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_timeout(): restarting discovery\n"));
dhcp_discover(netif);
/* receiving the requested lease timed out */
} else if (dhcp->state == DHCP_REQUESTING) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REQUESTING, DHCP request timed out"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REQUESTING, DHCP request timed out\n"));
if (dhcp->tries <= 5) {
dhcp_select(netif);
} else {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REQUESTING, releasing, restarting"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REQUESTING, releasing, restarting\n"));
dhcp_release(netif);
dhcp_discover(netif);
}
/* received no ARP reply for the offered address (which is good) */
} else if (dhcp->state == DHCP_CHECKING) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): CHECKING, ARP request timed out"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): CHECKING, ARP request timed out\n"));
if (dhcp->tries <= 1) {
dhcp_check(netif);
/* no ARP replies on the offered address,
@ -354,17 +354,17 @@ static void dhcp_timeout(struct netif *netif)
}
/* did not get response to renew request? */
else if (dhcp->state == DHCP_RENEWING) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): RENEWING, DHCP request timed out"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): RENEWING, DHCP request timed out\n"));
/* just retry renewal */
/* note that the rebind timer will eventually time-out if renew does not work */
dhcp_renew(netif);
/* did not get response to rebind request? */
} else if (dhcp->state == DHCP_REBINDING) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REBINDING, DHCP request timed out"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REBINDING, DHCP request timed out\n"));
if (dhcp->tries <= 8) {
dhcp_rebind(netif);
} else {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): RELEASING, DISCOVERING"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): RELEASING, DISCOVERING\n"));
dhcp_release(netif);
dhcp_discover(netif);
}
@ -379,11 +379,11 @@ static void dhcp_timeout(struct netif *netif)
static void dhcp_t1_timeout(struct netif *netif)
{
struct dhcp *dhcp = netif->dhcp;
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_t1_timeout()"));
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_t1_timeout()\n"));
if ((dhcp->state == DHCP_REQUESTING) || (dhcp->state == DHCP_BOUND) || (dhcp->state == DHCP_RENEWING)) {
/* just retry to renew */
/* note that the rebind timer will eventually time-out if renew does not work */
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t1_timeout(): must renew"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t1_timeout(): must renew\n"));
dhcp_renew(netif);
}
}
@ -395,10 +395,10 @@ static void dhcp_t1_timeout(struct netif *netif)
static void dhcp_t2_timeout(struct netif *netif)
{
struct dhcp *dhcp = netif->dhcp;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t2_timeout()"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t2_timeout()\n"));
if ((dhcp->state == DHCP_REQUESTING) || (dhcp->state == DHCP_BOUND) || (dhcp->state == DHCP_RENEWING)) {
/* just retry to rebind */
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t2_timeout(): must rebind"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t2_timeout(): must rebind\n"));
dhcp_rebind(netif);
}
}
@ -485,13 +485,13 @@ err_t dhcp_start(struct netif *netif)
err_t result = ERR_OK;
LWIP_ASSERT("netif != NULL", netif != NULL);
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_start(netif=%p) %c%c%u", netif, netif->name[0], netif->name[1], netif->num));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_start(netif=%p) %c%c%u\n", netif, netif->name[0], netif->name[1], netif->num));
if (dhcp == NULL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): starting new DHCP client"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): starting new DHCP client\n"));
dhcp = mem_malloc(sizeof(struct dhcp));
if (dhcp == NULL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): could not allocate dhcp"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): could not allocate dhcp\n"));
netif->flags &= ~NETIF_FLAG_DHCP;
return ERR_MEM;
}
@ -500,7 +500,7 @@ err_t dhcp_start(struct netif *netif)
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): allocated dhcp"));
dhcp->pcb = udp_new();
if (dhcp->pcb == NULL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): could not obtain pcb"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): could not obtain pcb\n"));
mem_free((void *)dhcp);
dhcp = NULL;
netif->flags &= ~NETIF_FLAG_DHCP;
@ -508,8 +508,8 @@ err_t dhcp_start(struct netif *netif)
}
/* store this dhcp client in the netif */
netif->dhcp = dhcp;
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): created new udp pcb"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): starting DHCP configuration"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): created new udp pcb\n"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): starting DHCP configuration\n"));
} else {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE | 3, ("dhcp_start(): restarting DHCP configuration\n"));
}
@ -538,19 +538,19 @@ void dhcp_inform(struct netif *netif)
err_t result = ERR_OK;
dhcp = mem_malloc(sizeof(struct dhcp));
if (dhcp == NULL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_inform(): could not allocate dhcp"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_inform(): could not allocate dhcp\n"));
return;
}
memset(dhcp, 0, sizeof(struct dhcp));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_inform(): allocated dhcp"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_inform(): allocated dhcp\n"));
dhcp->pcb = udp_new();
if (dhcp->pcb == NULL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_inform(): could not obtain pcb"));
mem_free((void *)dhcp);
return;
}
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_inform(): created new udp pcb"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_inform(): created new udp pcb\n"));
/* create and initialize the DHCP message header */
result = dhcp_create_request(netif);
if (result == ERR_OK) {
@ -593,15 +593,15 @@ void dhcp_inform(struct netif *netif)
*/
void dhcp_arp_reply(struct netif *netif, struct ip_addr *addr)
{
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_arp_reply()"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_arp_reply()\n"));
/* is this DHCP client doing an ARP check? */
if ((netif->dhcp != NULL) && (netif->dhcp->state == DHCP_CHECKING)) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_arp_reply(): CHECKING, arp reply for 0x%08lx", addr->addr));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_arp_reply(): CHECKING, arp reply for 0x%08lx\n", addr->addr));
/* did a host respond with the address we
were offered by the DHCP server? */
if (ip_addr_cmp(addr, &netif->dhcp->offered_ip_addr)) {
/* we will not accept the offered address */
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE | 1, ("dhcp_arp_reply(): arp reply matched with offered address, declining"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE | 1, ("dhcp_arp_reply(): arp reply matched with offered address, declining\n"));
dhcp_decline(netif);
}
}
@ -619,7 +619,7 @@ static err_t dhcp_decline(struct netif *netif)
struct dhcp *dhcp = netif->dhcp;
err_t result = ERR_OK;
u16_t msecs;
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_decline()"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_decline()\n"));
dhcp_set_state(dhcp, DHCP_BACKING_OFF);
/* create and initialize the DHCP message header */
result = dhcp_create_request(netif);
@ -646,7 +646,7 @@ static err_t dhcp_decline(struct netif *netif)
dhcp->tries++;
msecs = 10*1000;
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_decline(): set request timeout %u msecs", msecs));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_decline(): set request timeout %u msecs\n", msecs));
return result;
}
#endif
@ -661,13 +661,13 @@ static err_t dhcp_discover(struct netif *netif)
struct dhcp *dhcp = netif->dhcp;
err_t result = ERR_OK;
u16_t msecs;
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_discover()"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_discover()\n"));
ip_addr_set(&dhcp->offered_ip_addr, IP_ADDR_ANY);
/* create and initialize the DHCP message header */
result = dhcp_create_request(netif);
if (result == ERR_OK)
{
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: making request"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: making request\n"));
dhcp_option(dhcp, DHCP_OPTION_MESSAGE_TYPE, DHCP_OPTION_MESSAGE_TYPE_LEN);
dhcp_option_byte(dhcp, DHCP_DISCOVER);
@ -681,7 +681,7 @@ static err_t dhcp_discover(struct netif *netif)
dhcp_option_trailer(dhcp);
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: realloc()ing"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: realloc()ing\n"));
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 */
@ -706,7 +706,7 @@ static err_t dhcp_discover(struct netif *netif)
dhcp->tries++;
msecs = dhcp->tries < 4 ? (dhcp->tries + 1) * 1000 : 10 * 1000;
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_discover(): set request timeout %u msecs", msecs));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_discover(): set request timeout %u msecs\n", msecs));
return result;
}
@ -724,17 +724,17 @@ static void dhcp_bind(struct netif *netif)
/* temporary DHCP lease? */
if (dhcp->offered_t1_renew != 0xffffffffUL) {
/* set renewal period timer */
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_bind(): t1 renewal timer %lu secs", dhcp->offered_t1_renew));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_bind(): t1 renewal timer %lu secs\n", dhcp->offered_t1_renew));
dhcp->t1_timeout = (dhcp->offered_t1_renew + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS;
if (dhcp->t1_timeout == 0) dhcp->t1_timeout = 1;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_bind(): set request timeout %u msecs", dhcp->offered_t1_renew*1000));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_bind(): set request timeout %u msecs\n", dhcp->offered_t1_renew*1000));
}
/* set renewal period timer */
if (dhcp->offered_t2_rebind != 0xffffffffUL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_bind(): t2 rebind timer %lu secs", dhcp->offered_t2_rebind));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_bind(): t2 rebind timer %lu secs\n", dhcp->offered_t2_rebind));
dhcp->t2_timeout = (dhcp->offered_t2_rebind + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS;
if (dhcp->t2_timeout == 0) dhcp->t2_timeout = 1;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_bind(): set request timeout %u msecs", dhcp->offered_t2_rebind*1000));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_bind(): set request timeout %u msecs\n", dhcp->offered_t2_rebind*1000));
}
/* copy offered network mask */
ip_addr_set(&sn_mask, &dhcp->offered_sn_mask);
@ -758,11 +758,11 @@ static void dhcp_bind(struct netif *netif)
gw_addr.addr |= htonl(0x00000001);
}
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): IP: 0x%08lx", dhcp->offered_ip_addr.addr));
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): IP: 0x%08lx\n", dhcp->offered_ip_addr.addr));
netif_set_ipaddr(netif, &dhcp->offered_ip_addr);
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): SN: 0x%08lx", sn_mask.addr));
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): SN: 0x%08lx\n", sn_mask.addr));
netif_set_netmask(netif, &sn_mask);
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): GW: 0x%08lx", gw_addr.addr));
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): GW: 0x%08lx\n", gw_addr.addr));
netif_set_gw(netif, &gw_addr);
/* netif is now bound to DHCP leased address */
dhcp_set_state(dhcp, DHCP_BOUND);
@ -778,7 +778,7 @@ err_t dhcp_renew(struct netif *netif)
struct dhcp *dhcp = netif->dhcp;
err_t result;
u16_t msecs;
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_renew()"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_renew()\n"));
dhcp_set_state(dhcp, DHCP_RENEWING);
/* create and initialize the DHCP message header */
@ -819,7 +819,7 @@ err_t dhcp_renew(struct netif *netif)
/* back-off on retries, but to a maximum of 20 seconds */
msecs = dhcp->tries < 10 ? dhcp->tries * 2000 : 20 * 1000;
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_renew(): set request timeout %u msecs", msecs));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_renew(): set request timeout %u msecs\n", msecs));
return result;
}
@ -833,7 +833,7 @@ static err_t dhcp_rebind(struct netif *netif)
struct dhcp *dhcp = netif->dhcp;
err_t result;
u16_t msecs;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind()"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind()\n"));
dhcp_set_state(dhcp, DHCP_REBINDING);
/* create and initialize the DHCP message header */
@ -871,7 +871,7 @@ static err_t dhcp_rebind(struct netif *netif)
dhcp->tries++;
msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000;
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind(): set request timeout %u msecs", msecs));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind(): set request timeout %u msecs\n", msecs));
return result;
}
@ -885,7 +885,7 @@ static err_t dhcp_release(struct netif *netif)
struct dhcp *dhcp = netif->dhcp;
err_t result;
u16_t msecs;
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_release()"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_release()\n"));
/* idle DHCP client */
dhcp_set_state(dhcp, DHCP_OFF);
@ -912,7 +912,7 @@ static err_t dhcp_release(struct netif *netif)
dhcp->tries++;
msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000;
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_release(): set request timeout %u msecs", msecs));
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_release(): set request timeout %u msecs\n", msecs));
/* remove IP address from interface */
netif_set_ipaddr(netif, IP_ADDR_ANY);
netif_set_gw(netif, IP_ADDR_ANY);
@ -928,7 +928,7 @@ static err_t dhcp_release(struct netif *netif)
void dhcp_stop(struct netif *netif)
{
struct dhcp *dhcp = netif->dhcp;
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_stop()"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_stop()\n"));
/* netif is DHCP configured? */
if (dhcp != NULL)
{
@ -1027,14 +1027,14 @@ static err_t dhcp_unfold_reply(struct dhcp *dhcp)
dhcp->options_in = mem_malloc(dhcp->options_in_len);
if (dhcp->options_in == NULL)
{
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_unfold_reply(): could not allocate dhcp->options"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_unfold_reply(): could not allocate dhcp->options\n"));
return ERR_MEM;
}
}
dhcp->msg_in = mem_malloc(sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN);
if (dhcp->msg_in == NULL)
{
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_unfold_reply(): could not allocate dhcp->msg_in"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_unfold_reply(): could not allocate dhcp->msg_in\n"));
mem_free((void *)dhcp->options_in);
dhcp->options_in = NULL;
return ERR_MEM;
@ -1053,7 +1053,7 @@ static err_t dhcp_unfold_reply(struct dhcp *dhcp)
j = 0;
}
}
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_unfold_reply(): copied %u bytes into dhcp->msg_in[]", i));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_unfold_reply(): copied %u bytes into dhcp->msg_in[]\n", i));
if (dhcp->options_in != NULL) {
ptr = (u8_t *)dhcp->options_in;
/* proceed through options */
@ -1066,7 +1066,7 @@ static err_t dhcp_unfold_reply(struct dhcp *dhcp)
j = 0;
}
}
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_unfold_reply(): copied %u bytes to dhcp->options_in[]", i));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_unfold_reply(): copied %u bytes to dhcp->options_in[]\n", i));
}
return ERR_OK;
}
@ -1087,7 +1087,7 @@ static void dhcp_free_reply(struct dhcp *dhcp)
dhcp->options_in = NULL;
dhcp->options_in_len = 0;
}
DEBUGF(DHCP_DEBUG, ("dhcp_free_reply(): freed"));
DEBUGF(DHCP_DEBUG, ("dhcp_free_reply(): free'd\n"));
}
@ -1102,18 +1102,18 @@ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_
u8_t *options_ptr;
u8_t msg_type;
u8_t i;
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_recv()"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->len = %u", p->len));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->tot_len = %u", p->tot_len));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_recv()\n"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->len = %u\n", p->len));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->tot_len = %u\n", p->tot_len));
dhcp->p = p;
if (reply_msg->op != DHCP_BOOTREPLY) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("not a DHCP reply message, but type %u", reply_msg->op));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("not a DHCP reply message, but type %u\n", reply_msg->op));
pbuf_free(p);
}
/* iterate through hardware address and match against DHCP message */
for (i = 0; i < netif->hwaddr_len; i++) {
if (netif->hwaddr[i] != reply_msg->chaddr[i]) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("netif->hwaddr[%u]==%02x != reply_msg->chaddr[%u]==%02x",
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("netif->hwaddr[%u]==%02x != reply_msg->chaddr[%u]==%02x\n",
i, netif->hwaddr[i], i, reply_msg->chaddr[i]));
pbuf_free(p);
return;
@ -1121,22 +1121,22 @@ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_
}
/* match transaction ID against what we expected */
if (ntohl(reply_msg->xid) != dhcp->xid) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("transaction id mismatch"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("transaction id mismatch\n"));
pbuf_free(p);
return;
}
/* option fields could be unfold? */
if (dhcp_unfold_reply(dhcp) != ERR_OK) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("problem unfolding DHCP message - too short on memory?"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("problem unfolding DHCP message - too short on memory?\n"));
pbuf_free(p);
return;
}
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("searching DHCP_OPTION_MESSAGE_TYPE"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("searching DHCP_OPTION_MESSAGE_TYPE\n"));
/* obtain pointer to DHCP message type */
options_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_MESSAGE_TYPE);
if (options_ptr == NULL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_OPTION_MESSAGE_TYPE option not found"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_OPTION_MESSAGE_TYPE option not found\n"));
pbuf_free(p);
return;
}
@ -1145,7 +1145,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);
/* message type is DHCP ACK? */
if (msg_type == DHCP_ACK) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_ACK received"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_ACK received\n"));
/* in requesting state? */
if (dhcp->state == DHCP_REQUESTING) {
dhcp_handle_ack(netif);
@ -1168,13 +1168,13 @@ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_
else if ((msg_type == DHCP_NAK) &&
((dhcp->state == DHCP_REBOOTING) || (dhcp->state == DHCP_REQUESTING) ||
(dhcp->state == DHCP_REBINDING) || (dhcp->state == DHCP_RENEWING ))) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_NAK received"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_NAK received\n"));
dhcp->request_timeout = 0;
dhcp_handle_nak(netif);
}
/* received a DHCP_OFFER in DHCP_SELECTING state? */
else if ((msg_type == DHCP_OFFER) && (dhcp->state == DHCP_SELECTING)) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_OFFER received in DHCP_SELECTING state"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_OFFER received in DHCP_SELECTING state\n"));
dhcp->request_timeout = 0;
/* remember offered lease */
dhcp_handle_offer(netif);
@ -1191,7 +1191,7 @@ static err_t dhcp_create_request(struct netif *netif)
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);
if (dhcp->p_out == NULL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_create_request(): could not allocate pbuf"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_create_request(): could not allocate pbuf\n"));
return ERR_MEM;
}
/* give unique transaction identifier to this request */
@ -1244,13 +1244,13 @@ static void dhcp_delete_request(struct netif *netif)
static void dhcp_option_trailer(struct dhcp *dhcp)
{
LWIP_ASSERT("dhcp_option_trailer: dhcp->msg_out != NULL", dhcp->msg_out != NULL);
LWIP_ASSERT("dhcp_option_trailer: dhcp->options_out_len < DHCP_OPTIONS_LEN", dhcp->options_out_len < DHCP_OPTIONS_LEN);
LWIP_ASSERT("dhcp_option_trailer: dhcp->msg_out != NULL\n", dhcp->msg_out != NULL);
LWIP_ASSERT("dhcp_option_trailer: dhcp->options_out_len < DHCP_OPTIONS_LEN\n", dhcp->options_out_len < DHCP_OPTIONS_LEN);
dhcp->msg_out->options[dhcp->options_out_len++] = DHCP_OPTION_END;
/* packet is too small, or not 4 byte aligned? */
while ((dhcp->options_out_len < DHCP_MIN_OPTIONS_LEN) || (dhcp->options_out_len & 3)) {
/* DEBUGF(DHCP_DEBUG, ("dhcp_option_trailer: dhcp->options_out_len=%u, DHCP_OPTIONS_LEN=%u", dhcp->options_out_len, DHCP_OPTIONS_LEN)); */
LWIP_ASSERT("dhcp_option_trailer: dhcp->options_out_len < DHCP_OPTIONS_LEN", dhcp->options_out_len < DHCP_OPTIONS_LEN);
LWIP_ASSERT("dhcp_option_trailer: dhcp->options_out_len < DHCP_OPTIONS_LEN\n", dhcp->options_out_len < DHCP_OPTIONS_LEN);
/* add a fill/padding byte */
dhcp->msg_out->options[dhcp->options_out_len++] = 0;
}
@ -1279,18 +1279,18 @@ static u8_t *dhcp_get_option_ptr(struct dhcp *dhcp, u8_t option_type)
/* DEBUGF(DHCP_DEBUG, ("msg_offset=%u, q->len=%u", msg_offset, q->len)); */
/* are the sname and/or file field overloaded with options? */
if (options[offset] == DHCP_OPTION_OVERLOAD) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("overloaded message detected"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("overloaded message detected\n"));
/* skip option type and length */
offset += 2;
overload = options[offset++];
}
/* requested option found */
else if (options[offset] == option_type) {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("option found at offset %u in options", offset));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("option found at offset %u in options\n", offset));
return &options[offset];
/* skip option */
} else {
DEBUGF(DHCP_DEBUG, ("skipping option %u in options", options[offset]));
DEBUGF(DHCP_DEBUG, ("skipping option %u in options\n", options[offset]));
/* skip option type */
offset++;
/* skip option length, and then length bytes */
@ -1301,16 +1301,16 @@ static u8_t *dhcp_get_option_ptr(struct dhcp *dhcp, u8_t option_type)
if (overload != DHCP_OVERLOAD_NONE) {
u16_t field_len;
if (overload == DHCP_OVERLOAD_FILE) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded file field"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded file field\n"));
options = (u8_t *)&dhcp->msg_in->file;
field_len = DHCP_FILE_LEN;
} else if (overload == DHCP_OVERLOAD_SNAME) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded sname field"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded sname field\n"));
options = (u8_t *)&dhcp->msg_in->sname;
field_len = DHCP_SNAME_LEN;
/* TODO: check if else if () is necessary */
} else {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded sname and file field"));
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded sname and file field\n"));
options = (u8_t *)&dhcp->msg_in->sname;
field_len = DHCP_FILE_LEN + DHCP_SNAME_LEN;
}
@ -1319,11 +1319,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 */
while ((offset < field_len) && (options[offset] != DHCP_OPTION_END)) {
if (options[offset] == option_type) {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("option found at offset=%u", offset));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("option found at offset=%u\n", offset));
return &options[offset];
/* skip option */
} else {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("skipping option %u", options[offset]));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("skipping option %u\n", options[offset]));
/* skip option type */
offset++;
offset += 1 + options[offset];
@ -1344,7 +1344,7 @@ static u8_t *dhcp_get_option_ptr(struct dhcp *dhcp, u8_t option_type)
*/
static u8_t dhcp_get_option_byte(u8_t *ptr)
{
DEBUGF(DHCP_DEBUG, ("option byte value=%u", *ptr));
DEBUGF(DHCP_DEBUG, ("option byte value=%u\n", *ptr));
return *ptr;
}
@ -1361,7 +1361,7 @@ static u16_t dhcp_get_option_short(u8_t *ptr)
u16_t value;
value = *ptr++ << 8;
value |= *ptr;
DEBUGF(DHCP_DEBUG, ("option short value=%u", value));
DEBUGF(DHCP_DEBUG, ("option short value=%u\n", value));
return value;
}
@ -1380,6 +1380,6 @@ static u32_t dhcp_get_option_long(u8_t *ptr)
value |= (u32_t)(*ptr++) << 16;
value |= (u32_t)(*ptr++) << 8;
value |= (u32_t)(*ptr++);
DEBUGF(DHCP_DEBUG, ("option long value=%lu", value));
DEBUGF(DHCP_DEBUG, ("option long value=%lu\n", value));
return value;
}

View File

@ -321,7 +321,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
/* remote port is DHCP server? */
if(IPH_PROTO(iphdr) == IP_PROTO_UDP) {
DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: UDP packet to DHCP client port %u\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) {
DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: DHCP packet accepted.\n"));
netif = inp;

View File

@ -143,7 +143,7 @@ void netif_remove(struct netif * netif)
/* reset default netif */
netif_default = NULL;
DEBUGF(NETIF_DEBUG, ("netif_remove: removed netif"));
DEBUGF(NETIF_DEBUG, ("netif_remove: removed netif\n"));
mem_free( netif );
}

View File

@ -1,6 +1,15 @@
/**
* @file
* Packet buffers/chains management module
* Packet buffer management
*
* Packets are represented by the pbuf data structure. It supports dynamic
* memory allocation for packet contents or can reference externally
* managed packet contents both in RAM and ROM. Quick allocation for
* incoming packets is provided through pools with fixed sized pbufs.
*
* Pbufs can be chained as a singly linked list, called a pbuf chain, so
* that a packet may span over several pbufs.
*
*/
/*
@ -60,7 +69,6 @@ static struct pbuf *pbuf_pool_alloc_cache = NULL;
static struct pbuf *pbuf_pool_free_cache = NULL;
/**
*
* Initializes the pbuf module.
*
* A large part of memory is allocated for holding the pool of pbufs.
@ -189,12 +197,14 @@ pbuf_pool_free(struct pbuf *p)
}
/**
* Allocates a pbuf.
*
* Allocates a pbuf at protocol layer l.
* The actual memory allocated for the pbuf is determined by the
* layer at which the pbuf is allocated and the requested size
* (from the size parameter). The flag parameter decides how and
* where the pbuf should be allocated as follows:
* (from the size parameter).
*
* @param flag this parameter decides how and where the pbuf
* should be allocated as follows:
*
* - PBUF_RAM: buffer memory for pbuf is allocated as one large
* chunk. This includes protocol headers as well.
@ -211,13 +221,16 @@ pbuf_pool_free(struct pbuf *p)
* then pbuf_take should be called to copy the buffer.
* - PBUF_POOL: the pbuf is allocated as a pbuf chain, with pbufs from
* the pbuf pool that is allocated during pbuf_init().
*
* @return the allocated pbuf. If multiple pbufs where allocated, this
* is the first pbuf of a pbuf chain.
*/
struct pbuf *
pbuf_alloc(pbuf_layer l, u16_t size, pbuf_flag flag)
pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
{
struct pbuf *p, *q, *r;
u16_t offset;
s32_t rem_len;
s32_t rem_len; /* remaining length */
/* determine header offset */
offset = 0;
@ -250,17 +263,19 @@ pbuf_alloc(pbuf_layer l, u16_t size, pbuf_flag flag)
}
p->next = NULL;
/* make the payload pointer points offset bytes into pbuf data memory */
/* make the payload pointer point offset bytes into pbuf data memory */
p->payload = MEM_ALIGN((void *)((u8_t *)p + (sizeof(struct pbuf) + offset)));
/* the total length of the pbuf is the requested size */
p->tot_len = size;
/* set the length of the first pbuf is the chain */
p->len = size > PBUF_POOL_BUFSIZE - offset? PBUF_POOL_BUFSIZE - offset: size;
p->tot_len = length;
/* set the length of the first pbuf in the chain */
p->len = length > PBUF_POOL_BUFSIZE - offset? PBUF_POOL_BUFSIZE - offset: length;
p->flags = PBUF_FLAG_POOL;
/* allocate the tail of the pbuf chain. */
r = p;
rem_len = size - p->len;
/* remaining length to be allocated */
rem_len = length - p->len;
/* any remaining pbufs to be allocated? */
while(rem_len > 0) {
q = pbuf_pool_alloc();
if (q == NULL) {
@ -279,7 +294,7 @@ pbuf_alloc(pbuf_layer l, u16_t size, pbuf_flag flag)
q->payload = (void *)((u8_t *)q + sizeof(struct pbuf));
r = q;
q->ref = 1;
rem_len -= PBUF_POOL_BUFSIZE;
rem_len -= q->len;
}
/* end of chain */
r->next = NULL;
@ -289,13 +304,13 @@ pbuf_alloc(pbuf_layer l, u16_t size, pbuf_flag flag)
break;
case PBUF_RAM:
/* If pbuf is to be allocated in RAM, allocate memory for it. */
p = mem_malloc(MEM_ALIGN_SIZE(sizeof(struct pbuf) + size + offset));
p = mem_malloc(MEM_ALIGN_SIZE(sizeof(struct pbuf) + length + offset));
if (p == NULL) {
return NULL;
}
/* Set up internal structure of the pbuf. */
p->payload = MEM_ALIGN((void *)((u8_t *)p + sizeof(struct pbuf) + offset));
p->len = p->tot_len = size;
p->len = p->tot_len = length;
p->next = NULL;
p->flags = PBUF_FLAG_RAM;
@ -314,7 +329,7 @@ pbuf_alloc(pbuf_layer l, u16_t size, pbuf_flag flag)
}
/* caller must set this field properly, afterwards */
p->payload = NULL;
p->len = p->tot_len = size;
p->len = p->tot_len = length;
p->next = NULL;
p->flags = (flag == PBUF_ROM? PBUF_FLAG_ROM: PBUF_FLAG_REF);
break;
@ -471,7 +486,7 @@ pbuf_realloc(struct pbuf *p, u16_t new_len)
}
/**
* Tries to decrease the payload pointer by the given header size.
* Tries to add a header to the payload.
*
* Adjusts the ->payload pointer so that space for a header appears in
* the pbuf. Also, the ->tot_len and ->len fields are adjusted.
@ -485,31 +500,32 @@ u8_t
pbuf_header(struct pbuf *p, s16_t header_size)
{
void *payload;
/* referencing pbufs cannot be realloc()ed */
/* TODO: WHY NOT? just adjust payload, tot_len and len? */
if (p->flags == PBUF_FLAG_ROM ||
p->flags == PBUF_FLAG_REF) {
/* failure */
return 1;
}
/* remember current payload pointer */
payload = p->payload;
/* set new payload pointer */
p->payload = (u8_t *)p->payload - header_size;
DEBUGF(PBUF_DEBUG, ("pbuf_header: old %p new %p (%d)\n", payload, p->payload, header_size));
/* */
if((u8_t *)p->payload < (u8_t *)p + sizeof(struct pbuf)) {
DEBUGF(PBUF_DEBUG | 2, ("pbuf_header: failed as %p < %p\n",
(u8_t *)p->payload,
(u8_t *)p + sizeof(struct pbuf)));\
/* restore old payload pointer */
p->payload = payload;
return 1;
/* pbuf types containing payloads? */
if (p->flags == PBUF_FLAG_RAM ||
p->flags == PBUF_FLAG_POOL) {
/* boundary check fails? */
if ((u8_t *)p->payload < (u8_t *)p + sizeof(struct pbuf)) {
DEBUGF( PBUF_DEBUG | 2, ("pbuf_header: failed as %p < %p\n",
(u8_t *)p->payload,
(u8_t *)p + sizeof(struct pbuf)) );\
/* restore old payload pointer */
p->payload = payload;/
/* bail out unsuccesfully */
return 1;
}
}
DEBUGF( PBUF_DEBUG, ("pbuf_header: old %p new %p (%d)\n", payload, p->payload, header_size) );
/* modify pbuf length fields */
p->len += header_size;
p->tot_len += header_size;
return 0;
}
@ -547,7 +563,7 @@ pbuf_free(struct pbuf *p)
SYS_ARCH_DECL_PROTECT(old_level);
if (p == NULL) {
DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_free(p==NULL) was called.\n"));
DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_free(p == NULL) was called.\n"));
return 0;
}
@ -575,7 +591,6 @@ pbuf_free(struct pbuf *p)
{
/* remember next pbuf in chain for next iteration */
q = p->next;
/* is this a pbuf from the pool? */
if (p->flags == PBUF_FLAG_POOL) {
p->len = p->tot_len = PBUF_POOL_BUFSIZE;
@ -680,7 +695,7 @@ pbuf_chain(struct pbuf *h, struct pbuf *t)
/* proceed to last pbuf of chain */
for (p = h; p->next != NULL; p = p->next) {
/* add length of second chain to totals of first chain */
/* add total length of second chain to each total of first chain */
p->tot_len += t->tot_len;
}
/* chain last pbuf of h chain (p) with first of tail (t) */
@ -747,7 +762,7 @@ pbuf_take(struct pbuf *f)
{
struct pbuf *p, *prev, *top;
LWIP_ASSERT("pbuf_take: f != NULL", f != NULL);
DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_take(%p)", (void*)f));
DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_take(%p)\n", (void*)f));
prev = NULL;
p = f;
@ -760,21 +775,21 @@ pbuf_take(struct pbuf *f)
{
/* the replacement pbuf */
struct pbuf *q;
DEBUGF(PBUF_DEBUG | DBG_TRACE, ("pbuf_take: encountered PBUF_REF %p", (void *)p));
DEBUGF(PBUF_DEBUG | DBG_TRACE, ("pbuf_take: encountered PBUF_REF %p\n", (void *)p));
/* allocate a pbuf (w/ payload) fully in RAM */
/* PBUF_POOL buffers are faster if we can use them */
if (p->len <= PBUF_POOL_BUFSIZE) {
q = pbuf_alloc(PBUF_RAW, p->len, PBUF_POOL);
if (q == NULL) DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: Could not allocate PBUF_POOL"));
if (q == NULL) DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: Could not allocate PBUF_POOL\n"));
} else {
/* no replacement pbuf yet */
q = NULL;
DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: PBUF_POOL too small to replace PBUF_REF"));
DEBUGF(PBUF_DEBUG | 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 */
if (q == NULL) {
q = pbuf_alloc(PBUF_RAW, p->len, PBUF_RAM);
if (q == NULL) DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: Could not allocate PBUF_RAM"));
if (q == NULL) DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: Could not allocate PBUF_RAM\n"));
}
/* replacement pbuf could be allocated? */
if (q != NULL)
@ -816,13 +831,13 @@ pbuf_take(struct pbuf *f)
}
}
else {
DEBUGF(PBUF_DEBUG | DBG_TRACE | 1, ("pbuf_take: not PBUF_REF"));
DEBUGF(PBUF_DEBUG | DBG_TRACE | 1, ("pbuf_take: not PBUF_REF\n"));
}
prev = p;
p = p->next;
} while (p);
DEBUGF(PBUF_DEBUG | DBG_TRACE | 1, ("pbuf_take: end of chain reached."));
DEBUGF(PBUF_DEBUG | DBG_TRACE | 1, ("pbuf_take: end of chain reached.\n"));
return top;
}

View File

@ -470,22 +470,22 @@ tcp_slowtmr(void)
/* Steps through all of the active PCBs. */
prev = NULL;
pcb = tcp_active_pcbs;
if (pcb == NULL) DEBUGF(TCP_DEBUG, ("tcp_slowtmr: no active pcbs"));
if (pcb == NULL) DEBUGF(TCP_DEBUG, ("tcp_slowtmr: no active pcbs\n"));
while(pcb != NULL) {
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: processing active pcb"));
LWIP_ASSERT("tcp_slowtmr: active pcb->state != CLOSED", pcb->state != CLOSED);
LWIP_ASSERT("tcp_slowtmr: active pcb->state != LISTEN", pcb->state != LISTEN);
LWIP_ASSERT("tcp_slowtmr: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT);
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: processing active pcb\n"));
LWIP_ASSERT("tcp_slowtmr: active pcb->state != CLOSED\n", pcb->state != CLOSED);
LWIP_ASSERT("tcp_slowtmr: active pcb->state != LISTEN\n", pcb->state != LISTEN);
LWIP_ASSERT("tcp_slowtmr: active pcb->state != TIME-WAIT\n", pcb->state != TIME_WAIT);
pcb_remove = 0;
if(pcb->state == SYN_SENT && pcb->nrtx == TCP_SYNMAXRTX) {
++pcb_remove;
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max SYN retries reached"));
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max SYN retries reached\n"));
}
else if(pcb->nrtx == TCP_MAXRTX) {
++pcb_remove;
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max DATA retries reached"));
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max DATA retries reached\n"));
} else {
++pcb->rtime;
if(pcb->unacked != NULL && pcb->rtime >= pcb->rto) {
@ -520,7 +520,7 @@ tcp_slowtmr(void)
if((u32_t)(tcp_ticks - pcb->tmr) >
TCP_FIN_WAIT_TIMEOUT / TCP_SLOW_INTERVAL) {
++pcb_remove;
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2"));
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2\n"));
}
}

View File

@ -66,11 +66,11 @@
/** print debug message only if debug message type is enabled...
* AND is of correct type AND is at least DBG_LEVEL
*/
# define DEBUGF(debug, x) do { if (((debug) & DBG_ON) && ((debug) & DBG_TYPES_ON) && (((debug) & DBG_MASK_LEVEL) >= DBG_MIN_LEVEL)) { LWIP_PLATFORM_DIAG(x); if ((debug) & DBG_HALT) while(1); } } while(0)
# define DEBUGF(debug,x) do { if (((debug) & DBG_ON) && ((debug) & DBG_TYPES_ON) && (((debug) & DBG_MASK_LEVEL) >= DBG_MIN_LEVEL)) { LWIP_PLATFORM_DIAG(x); if ((debug) & DBG_HALT) while(1); } } while(0)
# define LWIP_ERROR(x) do { LWIP_PLATFORM_DIAG(x); } while(0)
#else /* LWIP_DEBUG */
# define LWIP_ASSERT(x, y)
# define DEBUGF(debug, x)
# define LWIP_ASSERT(x,y)
# define DEBUGF(debug,x)
# define LWIP_ERROR(x)
#endif /* LWIP_DEBUG */

View File

@ -141,8 +141,9 @@ void dhcp_fine_tmr(void);
#define DHCP_CHECKING 8
#define DHCP_PERMANENT 9
#define DHCP_BOUND 10
#define DHCP_BACKING_OFF 11
#define DHCP_OFF 12
/** not yet implemented #define DHCP_RELEASING 11 */
#define DHCP_BACKING_OFF 12
#define DHCP_OFF 13
#define DHCP_BOOTREQUEST 1
#define DHCP_BOOTREPLY 2

View File

@ -238,12 +238,12 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
struct pbuf *p;
struct eth_hdr *ethhdr;
#endif
DEBUGF(ETHARP_DEBUG, ("update_arp_entry()"));
DEBUGF(ETHARP_DEBUG, ("update_arp_entry: %u.%u.%u.%u - %02x:%02x:%02x:%02x:%02x:%02x\n", ip4_addr1(ipaddr), ip4_addr2(ipaddr), ip4_addr3(ipaddr), ip4_addr4(ipaddr),
DEBUGF(ETHARP_DEBUG | DBG_TRACE | 3, ("update_arp_entry()\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: %u.%u.%u.%u - %02x:%02x:%02x:%02x:%02x:%02x\n", ip4_addr1(ipaddr), ip4_addr2(ipaddr), ip4_addr3(ipaddr), ip4_addr4(ipaddr),
ethaddr->addr[0], ethaddr->addr[1], ethaddr->addr[2], ethaddr->addr[3], ethaddr->addr[4], ethaddr->addr[5]));
/* do not update for 0.0.0.0 addresses */
if (ipaddr->addr == 0) {
DEBUGF(ETHARP_DEBUG, ("update_arp_entry: will not add 0.0.0.0 to ARP cache\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: will not add 0.0.0.0 to ARP cache\n"));
return NULL;
}
/* Walk through the ARP mapping table and try to find an entry to
@ -255,16 +255,16 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
if(ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) {
/* pending entry? */
if(arp_table[i].state == ETHARP_STATE_PENDING) {
DEBUGF(ETHARP_DEBUG, ("update_arp_entry: pending entry %u goes stable\n", i));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: pending entry %u goes stable\n", i));
/* A pending entry was found, mark it stable */
arp_table[i].state = ETHARP_STATE_STABLE;
/* fall-through to next if */
}
/* stable entry? (possible just marked to become stable) */
if(arp_table[i].state == ETHARP_STATE_STABLE) {
DEBUGF(ETHARP_DEBUG, ("update_arp_entry: updating stable entry %u\n", i));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: updating stable entry %u\n", i));
/* An old entry found, update this and return. */
for(k = 0; k < 6; ++k) {
for(k = 0; k < netif->hwaddr_len; ++k) {
arp_table[i].ethaddr.addr[k] = ethaddr->addr[k];
}
/* reset time stamp */
@ -276,11 +276,11 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
arp_table[i].p = NULL;
/* fill-in Ethernet header */
ethhdr = p->payload;
for(k = 0; k < 6; ++k) {
for(k = 0; k < netif->hwaddr_len; ++k) {
ethhdr->dest.addr[k] = ethaddr->addr[k];
}
ethhdr->type = htons(ETHTYPE_IP);
DEBUGF(ETHARP_DEBUG, ("update_arp_entry: sending queued IP packet.\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: sending queued IP packet.\n"));
/* send the queued IP packet */
netif->linkoutput(netif, p);
/* free the queued IP packet */
@ -295,32 +295,32 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
/* no matching ARP entry was found */
LWIP_ASSERT("update_arp_entry: i == ARP_TABLE_SIZE", i == ARP_TABLE_SIZE);
DEBUGF(ETHARP_DEBUG, ("update_arp_entry: IP address not yet in table\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: IP address not yet in table\n"));
/* allowed to insert an entry? */
if ((ETHARP_ALWAYS_INSERT) || (flags & ARP_INSERT_FLAG))
{
DEBUGF(ETHARP_DEBUG, ("update_arp_entry: adding entry to table\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: adding entry to table\n"));
/* find an empty or old entry. */
i = find_arp_entry();
if(i == ARP_TABLE_SIZE) {
DEBUGF(ETHARP_DEBUG, ("update_arp_entry: no available entry found\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: no available entry found\n"));
return NULL;
}
/* see if find_arp_entry() gave us an old stable, or empty entry to re-use */
if (arp_table[i].state == ETHARP_STATE_STABLE) {
DEBUGF(ETHARP_DEBUG, ("update_arp_entry: overwriting old stable entry %u\n", i));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: overwriting old stable entry %u\n", i));
/* stable entries should have no queued packets (TODO: allow later) */
#if ARP_QUEUEING
LWIP_ASSERT("update_arp_entry: arp_table[i].p == NULL", arp_table[i].p == NULL);
#endif
} else {
DEBUGF(ETHARP_DEBUG, ("update_arp_entry: filling empty entry %u with state %u\n", i, arp_table[i].state));
DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("update_arp_entry: filling empty entry %u with state %u\n", i, arp_table[i].state));
LWIP_ASSERT("update_arp_entry: arp_table[i].state == ETHARP_STATE_EMPTY", arp_table[i].state == ETHARP_STATE_EMPTY);
}
/* set IP address */
ip_addr_set(&arp_table[i].ipaddr, ipaddr);
/* set Ethernet hardware address */
for(k = 0; k < 6; ++k) {
for(k = 0; k < netif->hwaddr_len; ++k) {
arp_table[i].ethaddr.addr[k] = ethaddr->addr[k];
}
/* reset time-stamp */
@ -334,7 +334,7 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
}
else
{
DEBUGF(ETHARP_DEBUG, ("update_arp_entry: no matching stable entry to update\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: no matching stable entry to update\n"));
}
return NULL;
}
@ -368,7 +368,7 @@ etharp_ip_input(struct netif *netif, struct pbuf *p)
return NULL;
}
DEBUGF(ETHARP_DEBUG, ("etharp_ip_input: updating ETHARP table.\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_ip_input: updating ETHARP table.\n"));
/* update ARP table, ask to insert entry */
update_arp_entry(netif, &(hdr->ip.src), &(hdr->eth.src), ARP_INSERT_FLAG);
return NULL;
@ -397,7 +397,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
/* drop short ARP packets */
if(p->tot_len < sizeof(struct etharp_hdr)) {
DEBUGF(ETHARP_DEBUG, ("etharp_arp_input: packet too short (%d/%d)\n", p->tot_len, sizeof(struct etharp_hdr)));
DEBUGF(ETHARP_DEBUG | DBG_TRACE | 1, ("etharp_arp_input: packet too short (%d/%d)\n", p->tot_len, sizeof(struct etharp_hdr)));
pbuf_free(p);
return NULL;
}
@ -411,10 +411,10 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
reply. In any case, we time-stamp any existing ARP entry,
and possiby send out an IP packet that was queued on it. */
DEBUGF(ETHARP_DEBUG, ("etharp_arp_input: incoming ARP request\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP request\n"));
/* we are not configured? */
if(netif->ip_addr.addr == 0) {
DEBUGF(ETHARP_DEBUG, ("etharp_arp_input: we are unconfigured, ARP request ignored.\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: we are unconfigured, ARP request ignored.\n"));
pbuf_free(p);
return NULL;
}
@ -423,14 +423,14 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
/* ARP request for our address? */
if(ip_addr_cmp(&(hdr->dipaddr), &(netif->ip_addr))) {
DEBUGF(ETHARP_DEBUG, ("etharp_arp_input: replying to ARP request for our IP address\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: replying to ARP request for our IP address\n"));
/* re-use pbuf to send ARP reply */
hdr->opcode = htons(ARP_REPLY);
ip_addr_set(&(hdr->dipaddr), &(hdr->sipaddr));
ip_addr_set(&(hdr->sipaddr), &(netif->ip_addr));
for(i = 0; i < 6; ++i) {
for(i = 0; i < netif->hwaddr_len; ++i) {
hdr->dhwaddr.addr[i] = hdr->shwaddr.addr[i];
hdr->shwaddr.addr[i] = ethaddr->addr[i];
hdr->ethhdr.dest.addr[i] = hdr->dhwaddr.addr[i];
@ -438,7 +438,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
}
hdr->hwtype = htons(HWTYPE_ETHERNET);
ARPH_HWLEN_SET(hdr, 6);
ARPH_HWLEN_SET(hdr, netif->hwaddr_len);
hdr->proto = htons(ETHTYPE_IP);
ARPH_PROTOLEN_SET(hdr, sizeof(struct ip_addr));
@ -447,24 +447,24 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
/* return ARP reply */
netif->linkoutput(netif, p);
} else {
DEBUGF(ETHARP_DEBUG, ("etharp_arp_input: incoming ARP request was not for us.\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP request was not for us.\n"));
}
break;
case ARP_REPLY:
/* ARP reply. We insert or update the ARP table. */
DEBUGF(ETHARP_DEBUG, ("etharp_arp_input: incoming ARP reply\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP reply\n"));
#if (LWIP_DHCP && DHCP_DOES_ARP_CHECK)
/* DHCP needs to know about ARP replies */
dhcp_arp_reply(netif, &hdr->sipaddr);
#endif
/* ARP reply directed to us? */
if(ip_addr_cmp(&(hdr->dipaddr), &(netif->ip_addr))) {
DEBUGF(ETHARP_DEBUG, ("etharp_arp_input: incoming ARP reply is for us\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP reply is for us\n"));
/* update_the ARP cache, ask to insert */
update_arp_entry(netif, &(hdr->sipaddr), &(hdr->shwaddr), ARP_INSERT_FLAG);
/* ARP reply not directed to us */
} else {
DEBUGF(ETHARP_DEBUG, ("etharp_arp_input: incoming ARP reply is not for us\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP reply is not for us\n"));
/* update the destination address pair */
update_arp_entry(netif, &(hdr->sipaddr), &(hdr->shwaddr), 0);
/* update the destination address pair */
@ -472,7 +472,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
}
break;
default:
DEBUGF(ETHARP_DEBUG, ("etharp_arp_input: ARP unknown opcode type %d\n", htons(hdr->opcode)));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: ARP unknown opcode type %d\n", htons(hdr->opcode)));
break;
}
/* free ARP packet */
@ -517,7 +517,7 @@ etharp_output(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
if(pbuf_header(q, sizeof(struct eth_hdr)) != 0) {
/* The pbuf_header() call shouldn't fail, and we'll just bail
out if it does.. */
DEBUGF(ETHARP_DEBUG, ("etharp_output: could not allocate room for header.\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE | 2, ("etharp_output: could not allocate room for header.\n"));
#ifdef LINK_STATS
++lwip_stats.link.lenerr;
#endif /* LINK_STATS */
@ -600,7 +600,7 @@ etharp_output(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
Ethernet header for the outgoing packet. */
ethhdr = q->payload;
for(i = 0; i < 6; i++) {
for(i = 0; i < netif->hwaddr_len; i++) {
ethhdr->dest.addr[i] = dest->addr[i];
ethhdr->src.addr[i] = srcaddr->addr[i];
}
@ -672,7 +672,7 @@ struct pbuf *etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pb
DEBUGF(ETHARP_DEBUG | 2, ("etharp_query: no more ARP entries available.\n"));
return NULL;
}
DEBUGF(ETHARP_DEBUG, ("etharp_query: created ARP table entry %u.\n", i));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: created ARP table entry %u.\n", i));
/* i is available, create ARP entry */
ip_addr_set(&arp_table[i].ipaddr, ipaddr);
arp_table[i].ctime = 0;
@ -690,7 +690,7 @@ struct pbuf *etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pb
pbuf_ref_chain(q);
/* remember pbuf to queue, if any */
arp_table[i].p = q;
DEBUGF(ETHARP_DEBUG, ("etharp_query: queued packet %p on ARP entry %u.\n", (void *)q, i));
DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("etharp_query: queued packet %p on ARP entry %u.\n", (void *)q, i));
}
#endif
/* allocate a pbuf for the outgoing ARP request packet */
@ -698,10 +698,10 @@ struct pbuf *etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pb
/* could allocate pbuf? */
if (p != NULL) {
u8_t j;
DEBUGF(ETHARP_DEBUG, ("etharp_query: sending ARP request.\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: sending ARP request.\n"));
hdr = p->payload;
hdr->opcode = htons(ARP_REQUEST);
for(j = 0; j < 6; ++j)
for(j = 0; j < netif->hwaddr_len; ++j)
{
hdr->dhwaddr.addr[j] = 0x00;
hdr->shwaddr.addr[j] = srcaddr->addr[j];
@ -710,11 +710,11 @@ struct pbuf *etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pb
ip_addr_set(&(hdr->sipaddr), &(netif->ip_addr));
hdr->hwtype = htons(HWTYPE_ETHERNET);
ARPH_HWLEN_SET(hdr, 6);
ARPH_HWLEN_SET(hdr, netif->hwaddr_len);
hdr->proto = htons(ETHTYPE_IP);
ARPH_PROTOLEN_SET(hdr, sizeof(struct ip_addr));
for(j = 0; j < 6; ++j)
for(j = 0; j < netif->hwaddr_len; ++j)
{
hdr->ethhdr.dest.addr[j] = 0xff;
hdr->ethhdr.src.addr[j] = srcaddr->addr[j];
@ -726,7 +726,7 @@ struct pbuf *etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pb
pbuf_free(p);
p = NULL;
} else {
DEBUGF(ETHARP_DEBUG, ("etharp_query: could not allocate pbuf for ARP request.\n"));
DEBUGF(ETHARP_DEBUG | DBG_TRACE | 2, ("etharp_query: could not allocate pbuf for ARP request.\n"));
}
return NULL;
}