The netbuf_grab function reads sz number of bytes from the network buffer’s (buf) socket into the network buffer. If the buffer is not large enough, it is resized. The data can be retrieved from buf->inbuf on success.
This function is used by the function netbuf_buf2sd.
int netbuf_grab(netbuf *buf, int sz);
The number of bytes actually read (between 1 and sz) if the operation was successful, or the constant IO_EOF or IO_ERROR for end of file or error.
netbuf *buf is the buffer to read into.
int sz is the number of bytes to read.