net_lwip_webserver: utilize pbuf_copy_partial()

This commit is contained in:
Peter Lawrence 2021-08-02 20:52:45 -05:00
parent af8e5a90f4
commit b682ce916a
1 changed files with 2 additions and 11 deletions

View File

@ -178,21 +178,12 @@ bool tud_network_recv_cb(const uint8_t *src, uint16_t size)
uint16_t tud_network_xmit_cb(uint8_t *dst, void *ref, uint16_t arg)
{
struct pbuf *p = (struct pbuf *)ref;
struct pbuf *q;
uint16_t len = 0;
(void)arg; /* unused for this example */
/* traverse the "pbuf chain"; see ./lwip/src/core/pbuf.c for more info */
for(q = p; q != NULL; q = q->next)
{
memcpy(dst, (char *)q->payload, q->len);
dst += q->len;
len += q->len;
if (q->len == q->tot_len) break;
}
pbuf_copy_partial(p, dst, p->tot_len, 0);
return len;
return p->tot_len;
}
static void service_traffic(void)