1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-27 07:21:18 +01:00

gnrc_netif: add function to check if device requires 6Lo

This commit is contained in:
Jose Alamos 2020-02-07 18:00:10 +01:00
parent 6ace7b5472
commit 4393822b0f
2 changed files with 30 additions and 14 deletions

View File

@ -329,6 +329,17 @@ static inline bool gnrc_netif_is_rtr_adv(const gnrc_netif_t *netif)
#define gnrc_netif_is_rtr_adv(netif) (false)
#endif
/**
* @brief Checks if the device type associated to a @ref gnrc_netif_t
* requires 6Lo to run
*
* @param[in] netif the network interface
*
* @return true if the device requires 6Lo
* @return false otherwise
*/
bool gnrc_netif_dev_is_6lo(const gnrc_netif_t *netif);
/**
* @brief Checks if the interface uses a protocol that requires 6Lo to run
*
@ -351,20 +362,7 @@ static inline bool gnrc_netif_is_6lo(const gnrc_netif_t *netif)
if ((!gnrc_netif_highlander() &&
IS_USED(MODULE_GNRC_SIXLOWPAN)) || \
IS_USED(MODULE_GNRC_SIXLOENC)) {
switch (netif->device_type) {
#ifdef MODULE_GNRC_SIXLOENC
case NETDEV_TYPE_ETHERNET:
return (netif->flags & GNRC_NETIF_FLAGS_6LO);
#endif
case NETDEV_TYPE_IEEE802154:
case NETDEV_TYPE_CC110X:
case NETDEV_TYPE_BLE:
case NETDEV_TYPE_NRFMIN:
case NETDEV_TYPE_ESP_NOW:
return true;
default:
return false;
}
return gnrc_netif_dev_is_6lo(netif);
}
else if (gnrc_netif_highlander() && IS_USED(MODULE_GNRC_SIXLOWPAN)) {
return true;

View File

@ -74,6 +74,24 @@ gnrc_netif_t *gnrc_netif_create(char *stack, int stacksize, char priority,
return netif;
}
bool gnrc_netif_dev_is_6lo(const gnrc_netif_t *netif)
{
switch (netif->device_type) {
#ifdef MODULE_GNRC_SIXLOENC
case NETDEV_TYPE_ETHERNET:
return (netif->flags & GNRC_NETIF_FLAGS_6LO);
#endif
case NETDEV_TYPE_IEEE802154:
case NETDEV_TYPE_CC110X:
case NETDEV_TYPE_BLE:
case NETDEV_TYPE_NRFMIN:
case NETDEV_TYPE_ESP_NOW:
return true;
default:
return false;
}
}
unsigned gnrc_netif_numof(void)
{
gnrc_netif_t *netif = NULL;