mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-03-12 22:14:25 +00:00
Added 'pbuf_alloc_copy' e.g. as a single function for use with non scatter-gather drivers
This commit is contained in:
parent
42eb98c9fc
commit
dcb2cb99a1
@ -1319,6 +1319,33 @@ pbuf_coalesce(struct pbuf *p, pbuf_layer layer)
|
||||
return q;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup pbuf
|
||||
* Allocates a new pbuf of same length (via @pbuf_alloc) and copies the source
|
||||
* pbuf into this new pbuf (using @pbuf_copy).
|
||||
*
|
||||
* @param layer pbuf_layer of the new pbuf
|
||||
* @param type this parameter decides how and where the pbuf should be allocated
|
||||
* (@see pbuf_alloc)
|
||||
* @param p the source pbuf
|
||||
*
|
||||
* @return a new pbuf or NULL if allocation fails
|
||||
*/
|
||||
struct pbuf *
|
||||
pbuf_alloc_copy(pbuf_layer layer, pbuf_type type, struct pbuf *p)
|
||||
{
|
||||
struct pbuf *q;
|
||||
err_t err;
|
||||
q = pbuf_alloc(layer, p->tot_len, type);
|
||||
if (q == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
err = pbuf_copy(q, p);
|
||||
LWIP_UNUSED_ARG(err); /* in case of LWIP_NOASSERT */
|
||||
LWIP_ASSERT("pbuf_copy failed", err == ERR_OK);
|
||||
return q;
|
||||
}
|
||||
|
||||
#if LWIP_CHECKSUM_ON_COPY
|
||||
/**
|
||||
* Copies data into a single pbuf (*not* into a pbuf queue!) and updates
|
||||
|
@ -262,6 +262,7 @@ err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len);
|
||||
err_t pbuf_take_at(struct pbuf *buf, const void *dataptr, u16_t len, u16_t offset);
|
||||
struct pbuf *pbuf_skip(struct pbuf* in, u16_t in_offset, u16_t* out_offset);
|
||||
struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer);
|
||||
struct pbuf *pbuf_alloc_copy(pbuf_layer l, pbuf_type type, struct pbuf *p);
|
||||
#if LWIP_CHECKSUM_ON_COPY
|
||||
err_t pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr,
|
||||
u16_t len, u16_t *chksum);
|
||||
|
Loading…
x
Reference in New Issue
Block a user