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