lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] PPP - TCP


From: Norberto R. de Goes Jr.
Subject: Re: [lwip-users] PPP - TCP
Date: Mon, 18 Jan 2016 13:01:12 -0200

Hi Sylvain:

I had already used the pppos_input_tcpip with no success. Now, after your last email, I tried again and the problem is the same:
"...
  while(1) {
      sizeRead = sio_read(ppp->ppp_sio, buffer, 1000);
      if (sizeRead > 0) {
          pppos_input_tcpip(ppp->ppp, buffer, sizeRead);
      }
  }
..."

Please, about your comment:
 "... you failed to understand how PBUF_POOL buffers are working, what you are doing here is a buffer overflow. PBUF_POOL are
*chained* buffers, that's explained in the very first basic lwIP documentation. I have serious doubt about how you are using the stack,
which might explain why you seem to have packet corruption. ..."

I would like remember you the code used to reproduce the PPP/TCP error is practically the same of the lwip git-repos (lwip e contrib), last Friday (jan/15/2016) version, only the "simhost.c" and "lwipopts.h" files with little modifications (attached again), or better, I am not using my code to show you the reported problem, but the behavior is the same. 

Thanks.
Norberto




2016-01-18 12:09 GMT-02:00 Sylvain Rochet <address@hidden>:
Hi Norberto,

On Mon, Jan 18, 2016 at 08:14:17AM -0200, Norberto R. de Goes Jr. wrote:
> Hi Sylvain.
>
> I changed the "simhost.c" file to use the pppos_input_sys function
> (attached full file) conforming your orientation.

Well, I mislead you, sorry, you have to use pppos_input_tcpip, not
pppos_input_sys. I don't even understand how you managed to follow that,
it's pretty clear in the header documentation that pppos_input_sys is
an internal only function which must not be used in user application.


> "...
>   while(1) {
>       sizeRead = sio_read(ppp->ppp_sio, buffer, 1000);
>       if (sizeRead > 0) {
>          /* struct pbuf *pBuffer = pbuf_alloc(PBUF_LINK, sizeRead,
> PBUF_RAM); */
>          struct pbuf *pBuffer = pbuf_alloc(PBUF_RAW, sizeRead, PBUF_POOL);
>
>           if (pBuffer == NULL) {
>               printf("Allocate memory fail.\n");
>               return;
>           }
>           MEMCPY(pBuffer->payload, buffer, sizeRead);

Added to that, you failed to understand how PBUF_POOL buffers are
working, what you are doing here is a buffer overflow. PBUF_POOL are
*chained* buffers, that's explained in the very first basic lwIP
documentation. I have serious doubt about how you are using the stack,
which might explain why you seem to have packet corruption.

What you need to use here is pbuf_take(), which basically do the
following:

struct pbuf *p;
u8_t *b;
for (p = pBuffer, b = buffer; p != NULL; p = p->next) {
  MEMCPY(p->payload, b, p->len);
  b += p->len;
  if (p->tot_len == p->len) {
    break;
  }
}

Of course that's not necessary for pppos_input_tcpip, which take
buffer+buffer_len as arguments.


>           pppos_input_sys(pBuffer, &pppos_netif);
>       }
>   }
> ..."


Sylvain

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



--
Norberto R. de Goes Jr.
CPqD - DRC
Tel.: +55 19 3705-4241 / Fax: +55 19 3705-6125
address@hidden
www.cpqd.com.br


Attachment: lwipopts.h
Description: Text Data

Attachment: simhost.c
Description: Text Data


reply via email to

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