Name

netbuf_copy() — Copy all netbuf data to memory pointer

Synopsis

void netbuf_copy (struct netbuf *buf , void *data , u16_t len );

Description

Copies all of the data from the netbuf buf into the memory pointed to by data even if the netbuf buf is fragmented. The len parameter is an upper bound of how much data that will be copied into the memory pointed to by data.

Example

Example 164.4. This example shows a simple use of netbuf_copy()

Here, 200 bytes of memory is allocated on the stack to hold data. Even if the netbuf buf has more data that 200 bytes, only 200 bytes are copied into data.

void
example_function(struct netbuf *buf)
{
    char data[200];
    netbuf_copy(buf, data, 200);

    /* do something with the data */
}