/[lwip]/lwip/src/core/pbuf.c
ViewVC logotype

Diff of /lwip/src/core/pbuf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.50 by jani, Tue May 6 12:15:08 2003 UTC revision 1.51 by likewise, Sun May 18 22:29:10 2003 UTC
# Line 10  Line 10 
10   * A packet may span over multiple pbufs, chained as a singly linked   * A packet may span over multiple pbufs, chained as a singly linked
11   * list. This is called a "pbuf chain".   * list. This is called a "pbuf chain".
12   *   *
13   * Multiple packets may be queued using this singly linked list. This   * Multiple packets may be queued, also using this singly linked list.
14   * is called a "pbuf queue". So, a pbuf queue consists of one or more   * This is called a "packet queue". So, a packet queue consists of one
15   * pbuf chains, each of which consist of one or more pbufs.   * or more pbuf chains, each of which consist of one or more pbufs.
16   *   *
17   * In order to find the last pbuf of a packet, traverse the linked list   * The last pbuf of a packet has a ->tot_len field that equals the
18   * until the ->tot_len field equals the ->len field. If the ->next field   * ->len field. It can be found by traversing the list. If the last
19   * of this packet is not NULL, more packets are on the queue.   * pbuf of a packet has a ->next field other than NULL, more packets
20     * are on the queue.
21   */   */
22    
23  /*  /*
# Line 366  pbuf_alloc(pbuf_layer l, u16_t length, p Line 367  pbuf_alloc(pbuf_layer l, u16_t length, p
367   * resized, and any remaining pbufs will be freed.   * resized, and any remaining pbufs will be freed.
368   *   *
369   * @note If the pbuf is ROM/REF, only the ->tot_len and ->len fields are adjusted.   * @note If the pbuf is ROM/REF, only the ->tot_len and ->len fields are adjusted.
370     * @note May not be called on a packet queue.
371   *   *
372   * @bug Cannot grow the size of a pbuf (chain) (yet).   * @bug Cannot grow the size of a pbuf (chain) (yet).
373   */   */
# Line 442  pbuf_realloc(struct pbuf *p, u16_t new_l Line 444  pbuf_realloc(struct pbuf *p, u16_t new_l
444   * the call will fail. A check is made that the increase in header size does   * the call will fail. A check is made that the increase in header size does
445   * not move the payload pointer in front of the start of the buffer.   * not move the payload pointer in front of the start of the buffer.
446   * @return 1 on failure, 0 on success.   * @return 1 on failure, 0 on success.
447     *
448     * @note May not be called on a packet queue.
449   */   */
450  u8_t  u8_t
451  pbuf_header(struct pbuf *p, s16_t header_size)  pbuf_header(struct pbuf *p, s16_t header_size)
# Line 500  pbuf_header(struct pbuf *p, s16_t header Line 504  pbuf_header(struct pbuf *p, s16_t header
504   * @return the number of unreferenced pbufs that were de-allocated   * @return the number of unreferenced pbufs that were de-allocated
505   * from the head of the chain.   * from the head of the chain.
506   *   *
507     * @note May not be called on a packet queue.
508   * @note the reference counter of a pbuf equals the number of pointers   * @note the reference counter of a pbuf equals the number of pointers
509   * that refer to the pbuf (or into the pbuf).   * that refer to the pbuf (or into the pbuf).
510   *   *
# Line 593  pbuf_clen(struct pbuf *p) Line 598  pbuf_clen(struct pbuf *p)
598    }    }
599    return len;    return len;
600  }  }
601    
602  /**  /**
603   *   *
604   * Increment the reference count of the pbuf.   * Increment the reference count of the pbuf.
# Line 618  pbuf_ref(struct pbuf *p) Line 624  pbuf_ref(struct pbuf *p)
624   *   *
625   * @param h head pbuf (chain)   * @param h head pbuf (chain)
626   * @param t tail pbuf (chain)   * @param t tail pbuf (chain)
627     * @note May not be called on a packet queue.
628   *   *
629   * The ->tot_len fields of all pbufs of the head chain are adjusted.   * The ->tot_len fields of all pbufs of the head chain are adjusted.
630   * The ->next field of the last pbuf of the head chain is adjusted.   * The ->next field of the last pbuf of the head chain is adjusted.
# Line 651  pbuf_chain(struct pbuf *h, struct pbuf * Line 658  pbuf_chain(struct pbuf *h, struct pbuf *
658    DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_chain: referencing tail %p\n", (void *) t));    DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_chain: referencing tail %p\n", (void *) t));
659  }  }
660    
661  /* TODO: Will be enabled soon. Please review code. */  /* For packet queueing. Note that queued packets must be dequeued first
662  #if 1   * before calling any pbuf functions. */
663    #if ARP_QUEUEING
664  /**  /**
665   * Add a packet to the end of a queue.   * Add a packet to the end of a queue.
666   *   *
# Line 680  pbuf_queue(struct pbuf *p, struct pbuf * Line 688  pbuf_queue(struct pbuf *p, struct pbuf *
688        p = p->next;        p = p->next;
689      }      }
690  #endif  #endif
691        /* now p->tot_len == p->len */
692        /* proceed to next packet on queue */
693      p = p->next;      p = p->next;
694    }      }  
695    /* chain last pbuf of h chain (p) with first of tail (t) */    /* chain last pbuf of h chain (p) with first of tail (t) */
# Line 714  pbuf_dequeue(struct pbuf *p) Line 724  pbuf_dequeue(struct pbuf *p)
724    p->next = NULL;    p->next = NULL;
725    /* q is now referenced to one less time */    /* q is now referenced to one less time */
726    pbuf_free(q);    pbuf_free(q);
727    DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_dequeue: dereferencing remaining queue%p\n", (void *)q));    DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_dequeue: dereferencing remaining queue %p\n", (void *)q));
728    return q;    return q;
729  }  }
730  #endif  #endif
# Line 831  pbuf_take(struct pbuf *p) Line 841  pbuf_take(struct pbuf *p)
841   * Makes p->tot_len field equal to p->len.   * Makes p->tot_len field equal to p->len.
842   * @param p pbuf to dechain   * @param p pbuf to dechain
843   * @return remainder of the pbuf chain, or NULL if it was de-allocated.   * @return remainder of the pbuf chain, or NULL if it was de-allocated.
844     * @note May not be called on a packet queue.
845   */   */
846  struct pbuf *  struct pbuf *
847  pbuf_dechain(struct pbuf *p)  pbuf_dechain(struct pbuf *p)

Legend:
Removed from v.1.50  
changed lines
  Added in v.1.51

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26