diff --git a/sys/include/net/gnrc/ipv6/nib.h b/sys/include/net/gnrc/ipv6/nib.h index 9e89d7f67d..2fbcf9ee67 100644 --- a/sys/include/net/gnrc/ipv6/nib.h +++ b/sys/include/net/gnrc/ipv6/nib.h @@ -233,6 +233,16 @@ extern "C" { * @note Only handled with @ref CONFIG_GNRC_IPV6_NIB_DNS != 0 */ #define GNRC_IPV6_NIB_RDNSS_TIMEOUT (0x4fd3U) + +/** + * @brief Interface up event + */ +#define GNRC_IPV6_NIB_IFACE_UP (0x4fd4U) + +/** + * @brief Interface down event + */ +#define GNRC_IPV6_NIB_IFACE_DOWN (0x4fd5U) /** @} */ /** diff --git a/sys/net/gnrc/netif/gnrc_netif.c b/sys/net/gnrc/netif/gnrc_netif.c index 648ac7670e..bf8df2d664 100644 --- a/sys/net/gnrc/netif/gnrc_netif.c +++ b/sys/net/gnrc/netif/gnrc_netif.c @@ -25,10 +25,8 @@ #include "net/ethernet.h" #include "net/ipv6.h" #include "net/gnrc.h" -#if IS_USED(MODULE_GNRC_IPV6_NIB) #include "net/gnrc/ipv6/nib.h" #include "net/gnrc/ipv6.h" -#endif /* IS_USED(MODULE_GNRC_IPV6_NIB) */ #if IS_USED(MODULE_GNRC_NETIF_PKTQ) #include "net/gnrc/netif/pktq.h" #endif /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */ @@ -2052,14 +2050,20 @@ static void _event_cb(netdev_t *dev, netdev_event_t event) DEBUG("gnrc_netif: event triggered -> %i\n", event); gnrc_pktsnip_t *pkt = NULL; switch (event) { -#if IS_USED(MODULE_GNRC_IPV6_NIB) case NETDEV_EVENT_LINK_UP: - gnrc_ipv6_nib_iface_up(netif); + if (IS_USED(MODULE_GNRC_IPV6)) { + msg_t msg = { .type = GNRC_IPV6_NIB_IFACE_UP, .content = { .ptr = netif } }; + + msg_send(&msg, gnrc_ipv6_pid); + } break; case NETDEV_EVENT_LINK_DOWN: - gnrc_ipv6_nib_iface_down(netif, false); + if (IS_USED(MODULE_GNRC_IPV6)) { + msg_t msg = { .type = GNRC_IPV6_NIB_IFACE_DOWN, .content = { .ptr = netif } }; + + msg_send(&msg, gnrc_ipv6_pid); + } break; -#endif case NETDEV_EVENT_RX_COMPLETE: pkt = netif->ops->recv(netif); /* send packet previously queued within netif due to the lower diff --git a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c index 89b03d98b0..a70f2e0783 100644 --- a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c +++ b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c @@ -244,6 +244,12 @@ static void *_event_loop(void *args) DEBUG("ipv6: NIB timer event received\n"); gnrc_ipv6_nib_handle_timer_event(msg.content.ptr, msg.type); break; + case GNRC_IPV6_NIB_IFACE_UP: + gnrc_ipv6_nib_iface_up(msg.content.ptr); + break; + case GNRC_IPV6_NIB_IFACE_DOWN: + gnrc_ipv6_nib_iface_down(msg.content.ptr, false); + break; default: break; }