This function updates the internal fragment pointer in the netbuf buf so that it points to the next fragment in the netbuf. The return value is zero if there are more fragments in the netbuf, > 0 if the fragment pointer now points to the last fragment in the netbuf, and < 0 if the fragment pointer already pointed to the last fragment.
Example 4-1. This example shows how to use the netbuf_next() function
We assume that this is in the middle of a function and that the variable buf is a netbuf.
/* [...] */
do {
char *data;
int len;
/* obtain a pointer to the data in the fragment */
netbuf_data(buf, &data, &len);
/* do something with the data */
do_something(data, len);
} while(netbuf_next(buf) >= 0);
/* [...] */
|