[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] PPP - TCP
From: |
Sylvain Rochet |
Subject: |
Re: [lwip-users] PPP - TCP |
Date: |
Mon, 18 Jan 2016 15:09:13 +0100 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
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
signature.asc
Description: Digital signature
- [lwip-users] PPP - TCP, Norberto R. de Goes Jr., 2016/01/05
- Re: [lwip-users] PPP - TCP, Sylvain Rochet, 2016/01/05
- Re: [lwip-users] PPP - TCP, Norberto R. de Goes Jr., 2016/01/06
- Re: [lwip-users] PPP - TCP, Norberto R. de Goes Jr., 2016/01/08
- Re: [lwip-users] PPP - TCP, Norberto R. de Goes Jr., 2016/01/13
- Re: [lwip-users] PPP - TCP, Norberto R. de Goes Jr., 2016/01/15
- Re: [lwip-users] PPP - TCP, Sylvain Rochet, 2016/01/16
- Re: [lwip-users] PPP - TCP, Norberto R. de Goes Jr., 2016/01/18
- Re: [lwip-users] PPP - TCP,
Sylvain Rochet <=
- Re: [lwip-users] PPP - TCP, Norberto R. de Goes Jr., 2016/01/18
- Re: [lwip-users] PPP - TCP, Sylvain Rochet, 2016/01/20
- Re: [lwip-users] PPP - TCP, Norberto R. de Goes Jr., 2016/01/21
- Re: [lwip-users] PPP - TCP, Sylvain Rochet, 2016/01/21
- Re: [lwip-users] PPP - TCP, Norberto R. de Goes Jr., 2016/01/22
- Re: [lwip-users] PPP - TCP, Sylvain Rochet, 2016/01/22
- Re: [lwip-users] PPP - TCP, Norberto R. de Goes Jr., 2016/01/22
- Re: [lwip-users] PPP - TCP, Sylvain Rochet, 2016/01/22
- Re: [lwip-users] PPP - TCP, Sylvain Rochet, 2016/01/23
- Re: [lwip-users] PPP - TCP, Norberto R. de Goes Jr., 2016/01/25