Skip to content

Commit

Permalink
net/netif: add netif_unregister()
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed May 3, 2022
1 parent a6c5eae commit 87f0c6f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sys/include/net/netif.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,17 @@ int netif_set_opt(netif_t *netif, netopt_t opt, uint16_t context,
*/
int netif_register(netif_t *netif);

/**
* @brief Removes a network interface in the global interface list.
*
* @param[in] netif Interface to be removed
*
* @return 0 on success
* @return -EINVAL if @p netif is NULL
* or not part of the global interface list
*/
int netif_unregister(netif_t *netif);

#ifdef __cplusplus
}
#endif
Expand Down
15 changes: 15 additions & 0 deletions sys/net/netif/netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ int netif_register(netif_t *netif)
return 0;
}

int netif_unregister(netif_t *netif)
{
void *found;

if (netif == NULL) {
return -EINVAL;
}

unsigned state = irq_disable();
found = list_remove(&netif_list, &netif->node);
irq_restore(state);

return found ? 0 : -EINVAL;
}

netif_t *netif_iter(const netif_t *last)
{
if (last == NULL) {
Expand Down

0 comments on commit 87f0c6f

Please sign in to comment.