> Oh, I assumed that the way TCP and UDP handles pbufs are the same. And since DHCP works fine and it didnt > work with the socket API, your explanation fits in just nicely. But where is this copying supposed to be done ? > Is it supposed to be done in the socket layer, or netconn API layer? Thanks in advance again... TCP sockets copy the data to be sent into an internal buffer as the data might have to be sent again (retransmission). Since there is already a pbuf allocated for this, it is just allocated slightly bigger and the headers are included -> you get one continuous buffer for one packet.
UDP sockets don't copy the data: it doesn't have to be kept for retransmission so it is faster to send them without copying. However, since (for socket API) there is no space for the headers in the buffer pointer you give to udp_sendto, a buffer for the headers has to be allocated in addition to this. These two buffers then form a linked list of pbufs. In your netif->linkoutput() function, UDP socket pbufs have a next pointer != NULL: p->payload will point to the protocol headers p->next->payload will point to the actual data -> p->tot_len will be != p->len for such linked lists while for TCP pbufs, p->len will be == p->tot_len. Have a look at the explanation in pbuf.c: you have to copy all data until you have copying as many bytes as the first p->tot_len says it has (in other words, the last pbuf has p->len == p->tot_len). I assume you always copy the first pbuf in such a linked list only, but tell the driver you have copied p->tot_len bytes and the driver fills in the missing bytes with 0x00? Simon _______________________________________________ lwip-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/lwip-users
