lwIP Wiki
Advertisement

netbuf_copy[]

u16_t netbuf_copy ( struct netbuf * aNetBuf, void * aData, u16_t aLen ); 


u16_t netbuf_copy_partial ( struct netbuf * aNetBuf, void * aData, 
                                            u16_t aLen, u16_t aOffset );

Copy at most "aLen" bytes from the netbuf object to the destination location. The second alternative can start at an offset instead of 0.

  • in aNetBuf : netbuf object the data is copied from
  • out aData : address of the memory where the data is copied to
  • in aLen : the size of the buffer, or the length of data to copy
  • in aOffset : an offset to start the with copy operation. In "netbuf_copy" this value is 0
  • return : total number of copied bytes, might be 0

Contray to using "netbuf_data" you don't have to fumble around with chained buffers. You get all the data out of the buffer. As a drawback you have an extra overhead of memory usage.

If you need to know the length of the data beforehand (in order to allocate memory), you could use "netbuf_len()".

The "function" is actually only a macro to "pbuf_copy_partial ( ( aNetBuf )->p, ( aDdata ), ( aLen ), ( aOffset )".


(last changed: Sept. 26, 2011)

Advertisement