diff --git a/pkg/lwip/contrib/netdev/lwip_netdev.c b/pkg/lwip/contrib/netdev/lwip_netdev.c index ffc86384419623d8814968e2fbddf66ec375aec1..cb9246aa8aa13a1558ecdda65a5fdf3a87fa0f55 100644 --- a/pkg/lwip/contrib/netdev/lwip_netdev.c +++ b/pkg/lwip/contrib/netdev/lwip_netdev.c @@ -185,15 +185,24 @@ static err_t _eth_link_output(struct netif *netif, struct pbuf *p) pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */ #endif LL_COUNT(p, q, count); - struct iovec pkt[count]; + iolist_t iolist[count]; + + /* make last point to the last entry of iolist[] */ + iolist_t *last = &iolist[count]; + last--; + for (q = p, count = 0; q != NULL; q = q->next, count++) { - pkt[count].iov_base = q->payload; - pkt[count].iov_len = (size_t)q->len; + iolist_t *iol = &iolist[count]; + + iol->iol_next = (iol == last) ? NULL : &iolist[count + 1]; + + iol->iol_base = q->payload; + iol->iol_len = (size_t)q->len; } #if ETH_PAD_SIZE pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */ #endif - return (netdev->driver->send(netdev, pkt, count) > 0) ? ERR_OK : ERR_BUF; + return (netdev->driver->send(netdev, iolist) > 0) ? ERR_OK : ERR_BUF; } #endif @@ -202,12 +211,12 @@ static err_t _ieee802154_link_output(struct netif *netif, struct pbuf *p) { LWIP_ASSERT("p->next == NULL", p->next == NULL); netdev_t *netdev = (netdev_t *)netif->state; - struct iovec pkt = { - .iov_base = p->payload, - .iov_len = (p->len - IEEE802154_FCS_LEN), /* FCS is written by driver */ + iolist_t pkt = { + .iol_base = p->payload, + .iol_len = (p->len - IEEE802154_FCS_LEN), /* FCS is written by driver */ }; - return (netdev->driver->send(netdev, &pkt, 1) > 0) ? ERR_OK : ERR_BUF; + return (netdev->driver->send(netdev, &pkt) > 0) ? ERR_OK : ERR_BUF; } #endif diff --git a/tests/lwip_sock_ip/stack.c b/tests/lwip_sock_ip/stack.c index 52e58a3f526db4c7aee55018e55940d27810d592..23ee9cabf99ac891c059f85de1ae4fb9b3568eed 100644 --- a/tests/lwip_sock_ip/stack.c +++ b/tests/lwip_sock_ip/stack.c @@ -141,16 +141,16 @@ static int _netdev_recv(netdev_t *dev, char *buf, int len, void *info) return res; } -static int _netdev_send(netdev_t *dev, const struct iovec *vector, int count) +static int _netdev_send(netdev_t *dev, const iolist_t *iolist) { msg_t done = { .type = _SEND_DONE }; unsigned offset = 0; (void)dev; mutex_lock(&_netdev_buffer_mutex); - for (int i = 0; i < count; i++) { - memcpy(&_netdev_buffer[offset], vector[i].iov_base, vector[i].iov_len); - offset += vector[i].iov_len; + for (; iolist; iolist = iolist->iol_next) { + memcpy(&_netdev_buffer[offset], iolist->iol_base, iolist->iol_len); + offset += iolist->iol_len; if (offset > sizeof(_netdev_buffer)) { mutex_unlock(&_netdev_buffer_mutex); return -ENOBUFS; diff --git a/tests/lwip_sock_udp/stack.c b/tests/lwip_sock_udp/stack.c index 45539cb478e7a10c45c764231e6a0c94167f656c..cdde693b293c0b09bb378892d66256684aaa2687 100644 --- a/tests/lwip_sock_udp/stack.c +++ b/tests/lwip_sock_udp/stack.c @@ -143,16 +143,16 @@ static int _netdev_recv(netdev_t *dev, char *buf, int len, void *info) return res; } -static int _netdev_send(netdev_t *dev, const struct iovec *vector, int count) +static int _netdev_send(netdev_t *dev, const iolist_t *iolist) { msg_t done = { .type = _SEND_DONE }; unsigned offset = 0; (void)dev; mutex_lock(&_netdev_buffer_mutex); - for (int i = 0; i < count; i++) { - memcpy(&_netdev_buffer[offset], vector[i].iov_base, vector[i].iov_len); - offset += vector[i].iov_len; + for (; iolist; iolist = iolist->iol_next) { + memcpy(&_netdev_buffer[offset], iolist->iol_base, iolist->iol_len); + offset += iolist->iol_len; if (offset > sizeof(_netdev_buffer)) { mutex_unlock(&_netdev_buffer_mutex); return -ENOBUFS;