lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] udp_sendto and header restoring


From: chrysn
Subject: [lwip-users] udp_sendto and header restoring
Date: Mon, 3 Jun 2013 17:11:19 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

hello lwip users,

i'm pushing the lwip port of libcoap (discussion[1], source[2]) to be
more zero-copy:

* i use pbufs with some reserve for future udp sending for allocating
  libcoap's internal protocol data unit structure (effectively removing
  all the library's malloc calls and using either pbuf_alloc or
  memp_alloc)
* on sending, i trim the non-data part of the internal structure away,
  pass the resulting pure-data pbuf to udp_sendto
* for the cases when retransmissions could be needed, i restore the
  previous headers (in future, i might implement retransmissions as
  keeping the complete sent package and handing it to the appropriate
  netif->linkoutput, but for that i have to enhance my understanding of
  whether the resulting packages are guaranteed to be identical or not).

my problem is that after pbuf_send, the pbuf's head is shifted around,
and i have to call pbuf_header(p, -42) to restore it.

while i could just calculate the offset and be done with it, i'm not
sure it's the cleanest solution, so:

* is there a rule about whether functions may or may not push around the
  headers of pbufs,
* is there a way to call udp_sendto so it will restore the header, or
* should it revert all changes to the pbuf anyway?

best regards
chrysn

ps: comments on my general approach of libcoap adaption are appreciated
as well!

[1] http://lists.gnu.org/archive/html/lwip-users/2013-01/msg00050.html
[2] https://gitorious.org/coap-lwip

-- 
To use raw power is to make yourself infinitely vulnerable to greater powers.
  -- Bene Gesserit axiom

Attachment: signature.asc
Description: Digital signature


reply via email to

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