diff --git a/cpu/native/include/netdev_tap.h b/cpu/native/include/netdev_tap.h index e94cd6f861..4e8ff0e287 100644 --- a/cpu/native/include/netdev_tap.h +++ b/cpu/native/include/netdev_tap.h @@ -25,6 +25,7 @@ extern "C" { #endif #include +#include #include "net/netdev.h" #include "net/ethernet/hdr.h" @@ -43,7 +44,8 @@ typedef struct netdev_tap { char tap_name[IFNAMSIZ]; /**< host dev file name */ int tap_fd; /**< host file descriptor for the TAP */ uint8_t addr[ETHERNET_ADDR_LEN]; /**< The MAC address of the TAP */ - uint8_t promiscuous; /**< Flag for promiscuous mode */ + bool promiscuous; /**< Flag for promiscuous mode */ + bool wired; /**< Flag for wired mode */ } netdev_tap_t; /** @@ -52,6 +54,8 @@ typedef struct netdev_tap { typedef struct { char **tap_name; /**< Name of the host system's tap interface to bind to. */ + bool wired; /**< Interface should behave like a + wired interface. */ } netdev_tap_params_t; /** diff --git a/cpu/native/netdev_tap/netdev_tap.c b/cpu/native/netdev_tap/netdev_tap.c index 70755e9176..5c413677cc 100644 --- a/cpu/native/netdev_tap/netdev_tap.c +++ b/cpu/native/netdev_tap/netdev_tap.c @@ -94,6 +94,12 @@ static inline int _set_promiscuous(netdev_t *netdev, int value) return value; } +static inline int _get_wired(netdev_t *netdev) +{ + netdev_tap_t *dev = container_of(netdev, netdev_tap_t, netdev); + return dev->wired; +} + static inline void _isr(netdev_t *netdev) { if (netdev->event_callback) { @@ -124,6 +130,16 @@ static int _get(netdev_t *dev, netopt_t opt, void *value, size_t max_len) *((bool*)value) = (bool)_get_promiscuous(dev); res = sizeof(bool); break; + case NETOPT_IS_WIRED: + if (!_get_wired(dev)) { + res = -ENOTSUP; + } else { + if (value) { + *((bool*)value) = true; + } + res = sizeof(bool); + } + break; default: res = netdev_eth_get(dev, opt, value, max_len); break; @@ -294,6 +310,7 @@ void netdev_tap_setup(netdev_tap_t *dev, const netdev_tap_params_t *params, int dev->netdev.driver = &netdev_driver_tap; strncpy(dev->tap_name, *(params->tap_name), IFNAMSIZ - 1); dev->tap_name[IFNAMSIZ - 1] = '\0'; + dev->wired = params->wired; netdev_register(&dev->netdev, NETDEV_TAP, index); } diff --git a/cpu/native/startup.c b/cpu/native/startup.c index 9009487290..262f706b05 100644 --- a/cpu/native/startup.c +++ b/cpu/native/startup.c @@ -655,6 +655,7 @@ __attribute__((constructor)) static void startup(int argc, char **argv, char **e #ifdef MODULE_NETDEV_TAP for (int i = 0; i < NETDEV_TAP_MAX; i++) { netdev_tap_params[i].tap_name = &argv[optind + i]; + netdev_tap_params[i].wired = true; } #endif