1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/native/netdev_tap: Add to netdev_register

This commit is contained in:
Jens Wetterich 2022-02-10 18:16:43 +01:00
parent c423148bbc
commit 4dfeafcabd
5 changed files with 8 additions and 4 deletions

View File

@ -59,8 +59,10 @@ typedef struct {
*
* @param dev the preallocated netdev_tap device handle to setup
* @param params initialization parameters
* @param index Index of @p params in a global parameter struct array.
* If initialized manually, pass a unique identifier instead.
*/
void netdev_tap_setup(netdev_tap_t *dev, const netdev_tap_params_t *params);
void netdev_tap_setup(netdev_tap_t *dev, const netdev_tap_params_t *params, int index);
#ifdef __cplusplus
}

View File

@ -290,10 +290,11 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
return res;
}
void netdev_tap_setup(netdev_tap_t *dev, const netdev_tap_params_t *params) {
void netdev_tap_setup(netdev_tap_t *dev, const netdev_tap_params_t *params, int index) {
dev->netdev.driver = &netdev_driver_tap;
strncpy(dev->tap_name, *(params->tap_name), IFNAMSIZ - 1);
dev->tap_name[IFNAMSIZ - 1] = '\0';
netdev_register(&dev->netdev, NETDEV_TAP, index);
}
static void _tap_isr(int fd, void *arg) {

View File

@ -323,6 +323,7 @@ typedef enum {
NETDEV_CC2420,
NETDEV_ETHOS,
NETDEV_SLIPDEV,
NETDEV_TAP,
/* add more if needed */
} netdev_type_t;
/** @} */

View File

@ -33,7 +33,7 @@ static netdev_tap_t netdev_taps[NETIF_TAP_NUMOF];
static void auto_init_netdev_tap(void)
{
for (unsigned i = 0; i < NETIF_TAP_NUMOF; i++) {
netdev_tap_setup(&netdev_taps[i], &netdev_tap_params[i]);
netdev_tap_setup(&netdev_taps[i], &netdev_tap_params[i], i);
if (lwip_add_ethernet(&netif[i], &netdev_taps[i].netdev) == NULL) {
DEBUG("Could not add netdev_tap device\n");
return;

View File

@ -38,7 +38,7 @@ void auto_init_netdev_tap(void)
LOG_DEBUG("[auto_init_netif] initializing netdev_tap #%u on TAP %s\n",
i, *(p->tap_name));
netdev_tap_setup(&netdev_tap[i], p);
netdev_tap_setup(&netdev_tap[i], p, i);
gnrc_netif_ethernet_create(&_netif[i], _netdev_eth_stack[i], TAP_MAC_STACKSIZE,
TAP_MAC_PRIO, "gnrc_netdev_tap",
&netdev_tap[i].netdev);