mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-12-10 08:46:40 +08:00
update_arp_entry() now accepts multiple packets on the queue to be sent out.
However, code to actually put multiple packets on the queue is a next step.
This commit is contained in:
parent
2c1cf05524
commit
9a2732e9eb
@ -42,6 +42,13 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO:
|
||||||
|
* - pbufs should be sent from the queue once an ARP entry state
|
||||||
|
* goes from PENDING to STABLE.
|
||||||
|
* - Non-PENDING entries MUST NOT have queued packets.
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO:
|
* TODO:
|
||||||
*
|
*
|
||||||
@ -307,6 +314,9 @@ etharp_dequeue(s8_t i)
|
|||||||
/**
|
/**
|
||||||
* Update (or insert) a IP/MAC address pair in the ARP cache.
|
* Update (or insert) a IP/MAC address pair in the ARP cache.
|
||||||
*
|
*
|
||||||
|
* If a pending entry is resolved, any queued packets will be sent
|
||||||
|
* at this point.
|
||||||
|
*
|
||||||
* @param ipaddr IP address of the inserted ARP entry.
|
* @param ipaddr IP address of the inserted ARP entry.
|
||||||
* @param ethaddr Ethernet address of the inserted ARP entry.
|
* @param ethaddr Ethernet address of the inserted ARP entry.
|
||||||
* @param flags Defines behaviour:
|
* @param flags Defines behaviour:
|
||||||
@ -345,7 +355,7 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
|
|||||||
arp_table[i].state = ETHARP_STATE_STABLE;
|
arp_table[i].state = ETHARP_STATE_STABLE;
|
||||||
/* fall-through to next if */
|
/* fall-through to next if */
|
||||||
}
|
}
|
||||||
/* stable entry? (possible just marked to become stable) */
|
/* stable entry? (possibly just marked to become stable) */
|
||||||
if (arp_table[i].state == ETHARP_STATE_STABLE) {
|
if (arp_table[i].state == ETHARP_STATE_STABLE) {
|
||||||
#if ARP_QUEUEING
|
#if ARP_QUEUEING
|
||||||
struct pbuf *p;
|
struct pbuf *p;
|
||||||
@ -358,12 +368,25 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
|
|||||||
}
|
}
|
||||||
/* reset time stamp */
|
/* reset time stamp */
|
||||||
arp_table[i].ctime = 0;
|
arp_table[i].ctime = 0;
|
||||||
|
/* this is where we will send out queued packets! */
|
||||||
#if ARP_QUEUEING
|
#if ARP_QUEUEING
|
||||||
|
/* get the first packet on the queue (if any) */
|
||||||
p = arp_table[i].p;
|
p = arp_table[i].p;
|
||||||
/* queued packet present? */
|
/* queued packet present? */
|
||||||
if (p != NULL) {
|
while (p != NULL) {
|
||||||
/* NULL attached buffer immediately */
|
struct pbuf *q, *n;
|
||||||
arp_table[i].p = NULL;
|
/* search for second packet on queue (n) */
|
||||||
|
q = p;
|
||||||
|
while (q->tot_len > q->len) {
|
||||||
|
/* proceed to next pbuf of this packet */
|
||||||
|
LWIP_ASSERT("q->next ! NULL", q->next != NULL);
|
||||||
|
q = q->next;
|
||||||
|
}
|
||||||
|
/* { q = last pbuf of first packet, q->tot_len = q->len } */
|
||||||
|
n = q->next;
|
||||||
|
/* { n = first pbuf of 2nd packet, or NULL if no 2nd packet } */
|
||||||
|
/* terminate the first packet pbuf chain */
|
||||||
|
q->next = NULL;
|
||||||
/* fill-in Ethernet header */
|
/* fill-in Ethernet header */
|
||||||
ethhdr = p->payload;
|
ethhdr = p->payload;
|
||||||
for (k = 0; k < netif->hwaddr_len; ++k) {
|
for (k = 0; k < netif->hwaddr_len; ++k) {
|
||||||
@ -371,12 +394,16 @@ 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.\n"));
|
LWIP_DEBUGF(ETHARP_DEBUG | 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 */
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
|
/* proceed to next packet on queue */
|
||||||
|
p = n;
|
||||||
}
|
}
|
||||||
|
/* NULL attached buffer*/
|
||||||
|
arp_table[i].p = NULL;
|
||||||
#endif
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -420,7 +447,7 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the ARP table using the given packet.
|
* Updates the ARP table using the given IP packet.
|
||||||
*
|
*
|
||||||
* Uses the incoming IP packet's source address to update the
|
* Uses the incoming IP packet's source address to update the
|
||||||
* ARP cache for the local network. The function does not alter
|
* ARP cache for the local network. The function does not alter
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user