[Top][All Lists]

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

Re: [lwip-users] pbuf->payload question

From: Toshiyasu Morita
Subject: Re: [lwip-users] pbuf->payload question
Date: Thu, 5 Dec 2019 13:51:07 -0800

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.


On Thu, Dec 5, 2019 at 1:23 PM Toshiyasu Morita <address@hidden> 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()?


reply via email to

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