[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] udp_send: space for IP header is not being allocated?
From: |
David Baird |
Subject: |
Re: [lwip-users] udp_send: space for IP header is not being allocated? |
Date: |
Fri, 13 Jul 2007 14:22:56 -0600 |
On 7/13/07, Robin Iddon <address@hidden> wrote:
I might be barking up the wrong tree here, but when you allocate the
pbuf for your user data you pass in a flag that says "TRANSPORT" and
this means that when the pbuf is allocated the transport header space
is pre-allocated. Now, if you're using UDP raw interface, I am not sure
in what way that is different from the normal udp_send().
Many thanks Robin. But now I have another question: why does
``udp_send`` bother to allocate more pbufs. It seems like that should
not be required since the space is already supposed to be
pre-allocated?
Sorry for stepping on anyone's toes by calling this a bug.
In order to figure this out I was looking at doc/rawapi.txt, reading
the lwIP source code, and looking at examples on the web. Somehow I
missed PBUF_TRANSPORT detail. I think that the doc/rawapi.txt file
could be improved by mentioning the proper way to allocate memory.
With that said, I've attached a patch :-)
-David
Index: doc/rawapi.txt
===================================================================
RCS file: /sources/lwip/lwip/doc/rawapi.txt,v
retrieving revision 1.7
diff -u -r1.7 rawapi.txt
--- doc/rawapi.txt 2 Mar 2007 19:35:15 -0000 1.7
+++ doc/rawapi.txt 13 Jul 2007 20:17:15 -0000
@@ -279,7 +279,11 @@
- err_t udp_send(struct udp_pcb *pcb, struct pbuf *p)
- Sends the pbuf p. The pbuf is not deallocated.
+ Sends the pbuf p. The pbuf is not deallocated. To allocate pbufs,
+ make sure to use the PBUF_TRANSPORT flag to ensure that enough space
+ is allocated for UDP and IP headers, e.g.:
+
+ p = pbuf_alloc(PBUF_TRANSPORT, num_bytes, PBUF_POOL);
- void udp_recv(struct udp_pcb *pcb,
void (* recv)(void *arg, struct udp_pcb *upcb,
- [lwip-users] udp_send: space for IP header is not being allocated?, David Baird, 2007/07/13
- Re: [lwip-users] udp_send: space for IP header is not being allocated?, Robin Iddon, 2007/07/13
- Re: [lwip-users] udp_send: space for IP header is not being allocated?,
David Baird <=
- RE: [lwip-users] udp_send: space for IP header is not being allocated?, Grubb, Jared, 2007/07/13
- Re: [lwip-users] udp_send: space for IP header is not being allocated?, David Baird, 2007/07/13
- RE: [lwip-users] udp_send: space for IP header is not being allocated?, Grubb, Jared, 2007/07/13
- Re: [lwip-users] udp_send: space for IP header is not being allocated?, David Baird, 2007/07/14
- RE: [lwip-users] udp_send: space for IP header is not being allocated?, Grubb, Jared, 2007/07/15
- RE: [lwip-users] udp_send: space for IP header is not being allocated?, Kieran Mansley, 2007/07/16
- RE: [lwip-users] udp_send: space for IP header is not being allocated?, Grubb, Jared, 2007/07/16