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 b54778a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion sys/net/gnrc/netif/gnrc_netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1464,11 +1464,28 @@ bool gnrc_netif_ipv6_wait_for_global_address(gnrc_netif_t *netif,
static int _change_state_and_wait(gnrc_netif_t *netif, netopt_state_t state, unsigned timeout_ms)
{
int res = 0;

netopt_state_t state_prev;
while (gnrc_netapi_get(netif->pid, NETOPT_STATE, 0, &state_prev, sizeof(state_prev)) == -EBUSY) {}

if (state == state_prev) {
return 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 b54778a

Please sign in to comment.