diff options
| author | Peter Lawrence <[email protected]> | 2020-10-24 20:27:57 -0500 |
|---|---|---|
| committer | Peter Lawrence <[email protected]> | 2020-10-24 20:27:57 -0500 |
| commit | a097b7e51aac7fc92708e1bc536e84a9ec2af3ec (patch) | |
| tree | ce49f6b51b2c2f169e9e5def66eb2eab10075d3b /src/class/net/net_device.c | |
| parent | f5b72f5796554910e14040cf747d6eea9505ee1a (diff) | |
net_device: re-factor code so as to not be specific to lwIP
Diffstat (limited to 'src/class/net/net_device.c')
| -rw-r--r-- | src/class/net/net_device.c | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/src/class/net/net_device.c b/src/class/net/net_device.c index 238d64d81..65fd1ab53 100644 --- a/src/class/net/net_device.c +++ b/src/class/net/net_device.c @@ -366,23 +366,7 @@ static void handle_incoming_packet(uint32_t len) } } - bool accepted = false; - - if (size) - { - struct pbuf *p = pbuf_alloc(PBUF_RAW, size, PBUF_POOL); - - if (p) - { - /* pbuf_alloc() has already initialized struct; all we need to do is copy the data */ - memcpy(p->payload, pnt, size); - accepted = tud_network_recv_cb(p); - - if (!accepted) pbuf_free(p); - } - } - - if (!accepted) + if (!tud_network_recv_cb(pnt, size)) { /* if a buffer was never handled by user code, we must renew on the user's behalf */ tud_network_recv_renew(); @@ -429,9 +413,8 @@ bool tud_network_can_xmit(void) return can_xmit; } -void tud_network_xmit(struct pbuf *p) +void tud_network_xmit(void *ref, uint16_t arg) { - struct pbuf *q; uint8_t *data; uint16_t len; @@ -441,14 +424,7 @@ void tud_network_xmit(struct pbuf *p) len = (_netd_itf.ecm_mode) ? 0 : CFG_TUD_NET_PACKET_PREFIX_LEN; data = transmitted + len; - /* traverse the "pbuf chain"; see ./lwip/src/core/pbuf.c for more info */ - for(q = p; q != NULL; q = q->next) - { - memcpy(data, (char *)q->payload, q->len); - data += q->len; - len += q->len; - if (q->len == q->tot_len) break; - } + len += tud_network_xmit_cb(data, ref, arg); if (!_netd_itf.ecm_mode) { |
