Ok, just realized I need to copy data to the pbuf->payload.
However, when I do this, the packet comes out with the entire payload as
zeroes.
So the problem is elsewhere, apparently.

Toshi

On Thu, Dec 5, 2019 at 1:23 PM Toshiyasu Morita <tmor...@autox.ai> wrote:

> I have lwIP mostly up and running on my target.
> I can see the following:
>
> o gratuitous ARP
> o ARP request
> o ARP reply
> o UDP test packet sent
>
> However, the UDP test packet has a garbage payload.
>
> My test code looks something like this:
>
>
> uint8_t test_data[10] = {0, 1, 2, 4, 5, 6, 7, 8, 9};
> ..
> p = pbuf_alloc(PBUF_RAW, 10, PBUF_POOL);
> p->payload = test_data;
>
> udp_send(pcb, p);
>
> I have traced through lwIP, and it seems to do subtraction on the payload
> pointer to add the UDP header:
>
> static u8_t
> pbuf_add_header_impl(struct pbuf *p, size_t header_size_increment, u8_t
> force)
> {
> ...
>     /* hide a header in the payload? */
>     if (force) {
>       payload = (u8_t *)p->payload - header_size_increment;
> ...
>
> So it seems like the p->payload needs to be a special buffer that has
> space reserved for a packet header. This doesn't seem to be documented in
> the header file for pbuf.
>
> What is the proper procedure to allocate a buffer for the payload which is
> compatible with pbuf_add_header_impl()?
>
> Toshi
>
>
>
>
>
>
>
>
_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to