183 |
|
|
184 |
|
|
185 |
/** |
/** |
186 |
* Allocates a pbuf. |
* Allocates a pbuf of the given type (possibly a chain for PBUF_POOL type). |
187 |
* |
* |
188 |
* The actual memory allocated for the pbuf is determined by the |
* The actual memory allocated for the pbuf is determined by the |
189 |
* layer at which the pbuf is allocated and the requested size |
* layer at which the pbuf is allocated and the requested size |
319 |
LWIP_ASSERT("pbuf_alloc: pbuf->payload properly aligned", |
LWIP_ASSERT("pbuf_alloc: pbuf->payload properly aligned", |
320 |
((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0); |
((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0); |
321 |
break; |
break; |
322 |
/* pbuf references existing (static constant) ROM payload? */ |
/* pbuf references existing (non-volatile static constant) ROM payload? */ |
323 |
case PBUF_ROM: |
case PBUF_ROM: |
324 |
/* pbuf references existing (externally allocated) RAM payload? */ |
/* pbuf references existing (externally allocated) RAM payload? */ |
325 |
case PBUF_REF: |
case PBUF_REF: |
664 |
{ |
{ |
665 |
struct pbuf *p; |
struct pbuf *p; |
666 |
|
|
667 |
LWIP_ASSERT("h != NULL", h != NULL); |
LWIP_ASSERT("h != NULL (programmer violates API)", h != NULL); |
668 |
LWIP_ASSERT("t != NULL", t != NULL); |
LWIP_ASSERT("t != NULL (programmer violates API)", t != NULL); |
669 |
if ((h == NULL) || (t == NULL)) return; |
if ((h == NULL) || (t == NULL)) return; |
670 |
|
|
671 |
/* proceed to last pbuf of chain */ |
/* proceed to last pbuf of chain */ |
675 |
} |
} |
676 |
/* { p is last pbuf of first h chain, p->next == NULL } */ |
/* { p is last pbuf of first h chain, p->next == NULL } */ |
677 |
LWIP_ASSERT("p->tot_len == p->len (of last pbuf in chain)", p->tot_len == p->len); |
LWIP_ASSERT("p->tot_len == p->len (of last pbuf in chain)", p->tot_len == p->len); |
678 |
|
LWIP_ASSERT("p->next == NULL", p->next == NULL); |
679 |
/* add total length of second chain to last pbuf total of first chain */ |
/* add total length of second chain to last pbuf total of first chain */ |
680 |
p->tot_len += t->tot_len; |
p->tot_len += t->tot_len; |
681 |
/* chain last pbuf of head (p) with first of tail (t) */ |
/* chain last pbuf of head (p) with first of tail (t) */ |
682 |
p->next = t; |
p->next = t; |
683 |
|
/* p->next now references t, but the caller will drop its reference to t, |
684 |
|
* so netto there is no change to the reference count of t. |
685 |
|
*/ |
686 |
} |
} |
687 |
|
|
688 |
/** |
/** |
796 |
/* { p->tot_len == p->len } => p is the last pbuf of the first packet */ |
/* { p->tot_len == p->len } => p is the last pbuf of the first packet */ |
797 |
/* remember next packet on queue in q */ |
/* remember next packet on queue in q */ |
798 |
q = p->next; |
q = p->next; |
799 |
/* dequeue p from queue */ |
/* dequeue packet p from queue */ |
800 |
p->next = NULL; |
p->next = NULL; |
801 |
/* any next packet on queue? */ |
/* any next packet on queue? */ |
802 |
if (q != NULL) { |
if (q != NULL) { |