[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] netconn/netbuf API
From: |
Hans-Erik Floryd |
Subject: |
[lwip-users] netconn/netbuf API |
Date: |
Wed, 25 Mar 2009 12:19:00 +0100 |
User-agent: |
Thunderbird 2.0.0.21 (Windows/20090302) |
Hello,
I am trying to use the netconn API to send UDP messages. Each message
consists of two sections, an identifer and the payload. Since I will be
using netconn_sendto I need to construct a netbuf containing the two
data sections.
At first glance something like this seems like it would work:
identifier = netbuf_new();
payload = netbuf_new();
netbuf_ref (identifier, pId, pIdSize);
netbuf_ref (payload, pData, pDataSize);
netbuf_chain (identifier, payload);
netconn_sendto (conn, identifier, &addr, port);
netbuf_delete (payload);
netbuf_delete (identifier);
But netbuf_chain calls memp_free on the tail (i.e. payload), so when
netbuf_delete(payload) is called, payload is no longer valid. On the
other hand, if netbuf_delete(payload) is not called, a pbuf is lost
because the reference count on the payload data is two, so
netbuf_delete(identifier) will not free the data.
Is it correct for netbuf_chain to free the tail netbuf? If that one line
is removed the code above works fine.
If it is correct behaviour, any ideas how to best use the netconn API to
send the message? I have read what documentation I could find on the
wiki but there doesn't seem to be much information regarding
netconn/netbuf there.
Thanks for any help!
- [lwip-users] netconn/netbuf API,
Hans-Erik Floryd <=