Skip to main content
Graduate
May 11, 2023
Question

Should be avoided using p->payload in LwIP examples?

  • May 11, 2023
  • 1 reply
  • 1187 views

I was looking at example HTTP IAP server provided in STM32F2xx package.

\STM32Cube\Repository\STM32Cube_FW_F2_V1.9.3\Projects\STM322xG_EVAL\Applications\LwIP\LwIP_IAP\Src\httpserver.c

In http_recv, received data is extracted on every chunk of data from p->payload assuming len = p->tot_len == p->len. If I'm not wrong, p->tot_len might be more than one pbuff (i.e. more than one p->payload).

Shouldn't routine pbuf_copy_partial used instead of accessing directly to payload field?

I mean, something like:

received_bytes = pbuf_copy_partial(p, getCmdBuffer, p->tot_len, 0);

    This topic has been closed for replies.

    1 reply

    ST Employee
    July 12, 2023

    Hi,

    This issue has been confirmed and fixed with STM32F4 and not yet maintained in STM32F2.

    You can use the patch attached to this post to fix the issue.

    The maintenance for STM32F2 is not planned yet, but you can use the patch meanwhile.

    I hope it helps.

    Graduate II
    July 12, 2023
    if(len)
    IAP_HTTP_writedata(ptr,len);

    There are several such places in that file and your fix keeps that beginner level incompetent formatting. And then on another topic you are telling this:

    the rationale is keeping the code easily readable and understandable

    Couldn't be more hypocritical...