summaryrefslogtreecommitdiff
path: root/src/class/net/net_device.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/class/net/net_device.c')
-rw-r--r--src/class/net/net_device.c34
1 files changed, 6 insertions, 28 deletions
diff --git a/src/class/net/net_device.c b/src/class/net/net_device.c
index 1d7f9ce3a..3a45a9b99 100644
--- a/src/class/net/net_device.c
+++ b/src/class/net/net_device.c
@@ -141,9 +141,9 @@ uint16_t netd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint1
TUD_RNDIS_ITF_SUBCLASS == itf_desc->bInterfaceSubClass &&
TUD_RNDIS_ITF_PROTOCOL == itf_desc->bInterfaceProtocol);
- bool const is_ecm = (TUSB_CLASS_CDC == itf_desc->bInterfaceClass &&
- CDC_COMM_SUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL == itf_desc->bInterfaceSubClass &&
- 0x00 == itf_desc->bInterfaceProtocol);
+ bool const is_ecm = (TUSB_CLASS_CDC == itf_desc->bInterfaceClass &&
+ CDC_COMM_SUBCLASS_ETHERNET_CONTROL_MODEL == itf_desc->bInterfaceSubClass &&
+ 0x00 == itf_desc->bInterfaceProtocol);
TU_VERIFY(is_rndis || is_ecm, 0);
@@ -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)
- {
- memcpy(p->payload, pnt, size);
- p->len = 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,12 +424,7 @@ void tud_network_xmit(struct pbuf *p)
len = (_netd_itf.ecm_mode) ? 0 : CFG_TUD_NET_PACKET_PREFIX_LEN;
data = transmitted + len;
- for(q = p; q != NULL; q = q->next)
- {
- memcpy(data, (char *)q->payload, q->len);
- data += q->len;
- len += q->len;
- }
+ len += tud_network_xmit_cb(data, ref, arg);
if (!_netd_itf.ecm_mode)
{