Skip to content

Commit

Permalink
fixup! net/gnrc_netif: add gnrc_netif_up()/gnrc_netif_down()
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Sep 21, 2022
1 parent 8882777 commit 5a25d0c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion sys/net/gnrc/netif/gnrc_netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1465,10 +1465,19 @@ static int _change_state_and_wait(gnrc_netif_t *netif, netopt_state_t state, uns
{
int res = 0;
#if IS_USED(MODULE_GNRC_NETIF_BUS)
gnrc_netif_event_t event;

if ((state == NETOPT_STATE_SLEEP) || (state == NETOPT_STATE_OFF) ||
(state == NETOPT_STATE_STANDBY)) {
event = GNRC_NETIF_EVENT_LINK_STATE_CHANGED_DOWN;
} else {
event = GNRC_NETIF_EVENT_LINK_STATE_CHANGED_UP;
}

msg_bus_entry_t sub;
msg_bus_t *bus = gnrc_netif_get_bus(netif, GNRC_NETIF_BUS_IFACE);
msg_bus_attach(bus, &sub);
msg_bus_subscribe(&sub, GNRC_IPV6_EVENT_ADDR_VALID);
msg_bus_subscribe(&sub, event);
#endif

while (gnrc_netapi_set(netif->pid, NETOPT_STATE, 0, &state, sizeof(state)) == -EBUSY) {}
Expand Down

0 comments on commit 5a25d0c

Please sign in to comment.