forked from Imagelibrary/lwip
Fixed up and made work a PBUF_REF type. Most of the code uses this now
instead of PBUF_ROM. This addition allows support of copy-on-demand where the lower layers can call pbuf_unref() which tests for any PBUF_REF buffers and replaces them with PBUF_POOL buffers. This is now used everywhere. pbuf_unref() is called in ARP queueing and in the coldfire driver, which puts frames on a DMA queue and frees them later. Along with this change pbuf_free() now goes through the entire chain of buffers and tests all the ref counters, not just the first one. Generally now pbuf_ref_chain() should be called and not pbuf_ref(). This change was made because it is possible for the head of the pbuf chain to have a different count than the payload pbuf which might have been passed by the application.
This commit is contained in:
@@ -235,6 +235,7 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
|
||||
{
|
||||
u8_t i, k;
|
||||
#if ARP_QUEUEING
|
||||
struct pbuf *p;
|
||||
struct eth_hdr *ethhdr;
|
||||
#endif
|
||||
DEBUGF(ETHARP_DEBUG, ("update_arp_entry()"));
|
||||
@@ -270,21 +271,20 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
|
||||
arp_table[i].ctime = 0;
|
||||
#if ARP_QUEUEING
|
||||
/* queued packet present? */
|
||||
if(arp_table[i].p != NULL) {
|
||||
|
||||
if((p = arp_table[i].p) != NULL) {
|
||||
/* Null out attached buffer immediately */
|
||||
arp_table[i].p = NULL;
|
||||
/* fill-in Ethernet header */
|
||||
ethhdr = arp_table[i].p->payload;
|
||||
ethhdr = p->payload;
|
||||
for(k = 0; k < 6; ++k) {
|
||||
ethhdr->dest.addr[k] = ethaddr->addr[k];
|
||||
}
|
||||
ethhdr->type = htons(ETHTYPE_IP);
|
||||
DEBUGF(ETHARP_DEBUG, ("update_arp_entry: sending queued IP packet.\n"));
|
||||
/* send the queued IP packet */
|
||||
netif->linkoutput(netif, arp_table[i].p);
|
||||
netif->linkoutput(netif, p);
|
||||
/* free the queued IP packet */
|
||||
pbuf_free(arp_table[i].p);
|
||||
/* remove queued packet from ARP entry (must be freed by the caller) */
|
||||
arp_table[i].p = NULL;
|
||||
pbuf_free(p);
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user