lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] file upload


From: Heike Lepke
Subject: Re: [lwip-users] file upload
Date: Thu, 08 Mar 2007 16:18:10 +0100
User-agent: Thunderbird 1.5.0.10 (Windows/20070221)

sadly not,

the p->tot_len is the same as the p->len and p->next is NULL...
even if I call tcp_recved(pcb, p->tot_len); after I worked on my data.

Heike

Kieran Mansley schrieb:
On Thu, 2007-03-08 at 15:55 +0100, Heike Lepke wrote:
err_t
http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
   int i;
   struct http_state *hs;
   T_CHAR *pc_rq;
   hs = reinterpret_cast<http_state*>(arg);
   hs->file = hs->mem;

   if(err == ERR_OK && p != NULL)
   {

     /* Inform TCP that we have taken the data. */
     tcp_recved(pcb, p->tot_len);
     /* Send the data to the http-Server. */
hs->left = reinterpret_cast<http_state*>(arg)->myServer->HandleRequest(static_cast<T_CHAR*>(p->payload),p->len,hs->file,BUFFER_SIZE);
...
###############################################################################################################################

In this function I get the pbuf p, with the p->len e.g. 600, but the real length of the data is 1400, whereby the data after the first 600 bytes is the part of the file to upload.
The upload-file I can see in the p->payload+600 following.

Ahh, could it be that this pbuf is part of a pbuf chain?  p->len tells
you the length of each individual pbuf, p->tot_len (for the first one in
the chain) tells you the total length of all the pbufs in the chain.  p-
next lets you access the next pbuf in the chain.

Also, you should only be calling tcp_recved() after you have finished
accessing the data - i.e. copied it to your own memory or have no
further use for it.  If you don't, it's possible that the stack will
overwrite the packet data with a new packet.  Putting it at the end of
your http_recv() function should probably be sufficient.
Kieran



_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users





reply via email to

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