Skip to content

Commit

Permalink
netdev_tap: port to netdev_new_api
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Nov 21, 2024
1 parent 7832253 commit 3ba131c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cpu/native/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ifneq (,$(filter socket_zep,$(USEMODULE)))
endif

ifneq (,$(filter netdev_tap,$(USEMODULE)))
USEMODULE += netdev_legacy_api
USEMODULE += netdev_new_api
endif

ifneq (,$(filter libc_gettimeofday,$(USEMODULE)))
Expand Down
19 changes: 13 additions & 6 deletions cpu/native/netdev_tap/netdev_tap.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,25 @@ static int _set(netdev_t *dev, netopt_t opt, const void *value, size_t value_len
return res;
}

static int _confirm_send(netdev_t *netdev, void *info)
{
(void)netdev;
(void)info;

/* confirm_send should not be called with synchronos send */
assert(0);

return -EOPNOTSUPP;
}

static const netdev_driver_t netdev_driver_tap = {
.send = _send,
.recv = _recv,
.init = _init,
.isr = _isr,
.get = _get,
.set = _set,
.confirm_send = _confirm_send,
};

/* driver implementation */
Expand Down Expand Up @@ -293,12 +305,7 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
unsigned n;
iolist_to_iovec(iolist, iov, &n);

int res = _native_writev(dev->tap_fd, iov, n);

if (netdev->event_callback) {
netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE);
}
return res;
return _native_writev(dev->tap_fd, iov, n);
}

void netdev_tap_setup(netdev_tap_t *dev, const netdev_tap_params_t *params, int index) {
Expand Down

0 comments on commit 3ba131c

Please sign in to comment.