lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] [lwip] pbuf payload length


From: Wurmsdobler, Peter
Subject: [lwip-users] [lwip] pbuf payload length
Date: Wed, 08 Jan 2003 23:38:17 -0000

Hello,

Since I like the pbuf concept vey much and I would like to use it throughout
my application, I encountered a problem. What I wanted to do is to allocate
a pbuf with a given length: 

  p = pbuf_alloc (PBUF_TRANSPORT, length, PBUF_POOL);

or convert a static flat buffer[SIZE] into a pbuf by

  p = convert_buffer2pbuf (buffer, SIZE, PBUF_TRANSPORT);

The latter function just casts the buffer to be a pbuf and fills in the
structure. The problem, however, becomes obvious when I want to fill the
payload up with data at length len:

  copy_data2pbuf (p, data, len);

How does the pbuf know that there is still room in the pbuf. With one
variable he can either know the payload length or the length of the buffer
in memory. Or a variable is kept externally keeping track of the payload.

For this reason I would need a "pay_len" entry in the structure which will
be updated at such a call. Alternatively, the structure could contain a
"limit" entry and I keep the len (and tot_len) for the payload length, but
this limit variable to the amount data can be copied into the pbuf.

Or could I do what I want with the current implementation?
(a tricky solution would be to play with the redundancy of the next pointer
and the difference of len and tot_len, which would work for a unchained
pbuf).

peter

Peter Wurmsdober
Eurotherm Drives Ltd.
Littlehampton, BN17 7RZ, UK
TEL: +44 19 03 73 73 58
FAX: +44 19 03 73 71 07
[This message was sent through the lwip discussion list.]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]