From 2e2dada5614524b777e440ae7bd97cf40689f349 Mon Sep 17 00:00:00 2001 From: likewise Date: Wed, 14 Apr 2004 19:12:10 +0000 Subject: [PATCH] etharp_query(): Fixed the case where the packet that initiates the ARP request is not queued, and gets lost. etharp_query(): Fixed the case where the packets destination address is already known. As a result, we now always queue the packet and perform an ARP request, unless the entry is stable and no packet is submitted for transmission. --- src/netif/etharp.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/netif/etharp.c b/src/netif/etharp.c index 2c17a942..a0e145e7 100644 --- a/src/netif/etharp.c +++ b/src/netif/etharp.c @@ -772,9 +772,14 @@ err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q) } else if (arp_table[i].state == ETHARP_STATE_STABLE) { LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("etharp_query: requested IP already stable as entry %u\n", i)); - /* user may wish to queue a packet on a stable entry, so we proceed without ARP requesting */ - /* TODO: even if the ARP entry is stable, we might do an ARP request anyway */ - perform_arp_request = 0; + /* User wishes to queue a packet on a stable entry (or does she want to send + * out the packet immediately, we will not know), so we force an ARP request. + * Upon response we will send out the queued packet in etharp_update(). + * + * Alternatively, we could accept the stable entry, and just send out the packet + * immediately. I chose to implement the former approach. + */ + perform_arp_request = (q?1:0); break; } } @@ -786,18 +791,17 @@ err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q) i = find_arp_entry(); /* bail out if no ARP entries are available */ if (i == ERR_MEM) { - LWIP_DEBUGF(ETHARP_DEBUG | 2, ("etharp_query: no more ARP entries available. Should seldom occur.\n")); + LWIP_DEBUGF(ETHARP_DEBUG | 2, ("etharp_query: no more ARP entries available. Should seldomly occur.\n")); return ERR_MEM; } /* i is available, create ARP entry */ arp_table[i].state = ETHARP_STATE_PENDING; ip_addr_set(&arp_table[i].ipaddr, ipaddr); - /* queried address was already in ARP table */ - } else { -#if ARP_QUEUEING - etharp_enqueue(i, q); -#endif } + /* { i is now valid } */ +#if ARP_QUEUEING /* queue packet (even on a stable entry, see above) */ + etharp_enqueue(i, q); +#endif /* ARP request? */ if (perform_arp_request) {