Merge pull request #992 from majbthrd/net_example_pbuf

net_lwip_webserver: utilize pbuf_copy_partial()
This commit is contained in:
Ha Thach 2021-08-17 11:56:54 +07:00 committed by GitHub
commit 7cbb11a86c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 12 deletions

View File

@ -178,21 +178,10 @@ 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;
}
return len;
return pbuf_copy_partial(p, dst, p->tot_len, 0);
}
static void service_traffic(void)