lwIP - A Minimal TCP/IP implementation - Wikia
lwIP - A Minimal TCP/IP implementation - Wikia
lwIP - A Minimal TCP/IP implementation - Wikia
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
15 API REFERENCE 15.2 Buffer functions<br />
/* obtain a pointer to the data in the fragment */<br />
netbuf_data(buf, &data, &len);<br />
/* do something with the data */<br />
do_something(data, len);<br />
} while(netbuf_next(buf) >= 0);<br />
/* [...] */<br />
15.2.9 netbuf first()<br />
Synopsis<br />
void netbuf first(struct netbuf *buf)<br />
Description<br />
Resets the fragment pointer in the netbuf buf so that it points to the first fragment.<br />
15.2.10 netbuf copy()<br />
Synopsis<br />
void netbuf copy(struct netbuf *buf, void *data, int len)<br />
Description<br />
Copies all of the data from the netbuf buf into the memory pointed to by data even if the netbuf<br />
buf is fragmented. The len parameter is an upper bound of how much data that will be copied<br />
into the memory pointed to by data.<br />
Example This example shows a simple use of netbuf_copy(). Here, 200 bytes of memory is<br />
allocated on the stack to hold data. Even if the netbuf buf has more data that 200 bytes, only<br />
200 bytes are copied into data.<br />
void<br />
example_function(struct netbuf *buf)<br />
{<br />
char data[200];<br />
netbuf_copy(buf, data, 200);<br />
}<br />
/* do something with the data */<br />
15.2.11 netbuf chain()<br />
Synopsis<br />
void netbuf chain(struct netbuf *head, struct netbuf *tail)<br />
Description<br />
Chains the two netbufs head and tail together so that the data in tail will become the last<br />
fragment(s) in head. The netbuf tail is deallocated and should not be used after the call to this<br />
function.<br />
15.2.12 netbuf fromaddr()<br />
Synopsis<br />
struct ip addr * netbuf fromaddr(struct netbuf *buf)<br />
24