Fandom

lwIP Wiki

Netbuf len

91pages on
this wiki
Add New Page
Talk0 Share

netbuf_lenEdit

u16_t netbuf_len ( struct netbuf * aNetBuf );

Get the total length of the data in a netbuf object, taking into account all chain links.

  • in aNetBuf : the netbuf object in question
  • return : the total number of bytes contained in all chains of the netbuf object

This is actually only a macro defined as " ( ( aNetBuf )->p->tot_len )"

Example:

struct netbuf  * xNetBuf;
struct netconn * xNetConn;
...

{netconn_new, _bind, _listen, _accept}
...
if ( netconn_recv ( xNetConn, &xNetBuf ) == ERR_OK )

{   
   UInt16 xLen = netbuf_len ( xNetBuf );  // total length of data in buffer
   String xBuf = mem_malloc ( xLen );

   if ( xBuf != NULL )
      netbuf_copy ( xNetBuf, xBuf, xLen );

   netbuf_delete ( xNetBuf );
   ...
}

(last changed: Sept. 26, 2011)

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.