Skip to content

Commit

Permalink
pkg/lwip: Allow setting netif active state
Browse files Browse the repository at this point in the history
  • Loading branch information
yarrick committed Oct 11, 2023
1 parent 0fc7898 commit c49cd44
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions pkg/lwip/contrib/_netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "fmt.h"
#include "lwip/netif/compat.h"
#include "lwip/netifapi.h"
#include "net/netif.h"

int netif_get_name(netif_t *iface, char *name)
Expand Down Expand Up @@ -85,13 +86,28 @@ int netif_get_opt(netif_t *iface, netopt_t opt, uint16_t context,
int netif_set_opt(netif_t *iface, netopt_t opt, uint16_t context,
void *value, size_t value_len)
{
(void)iface;
(void)opt;
(void)context;
(void)value;
(void)value_len;
int res = -ENOTSUP;
lwip_netif_t *lwip_netif = (lwip_netif_t*) iface;
struct netif *netif = &lwip_netif->lwip_netif;

return -ENOTSUP;
switch (opt) {
case NETOPT_ACTIVE: {
assert(value_len >= sizeof(netopt_enable_t));
netopt_enable_t *state = value;
if (*state == NETOPT_ENABLE) {
netifapi_netif_set_up(netif);
} else {
netifapi_netif_set_down(netif);
}
res = 0;
}
break;
default:
break;
}

return res;
}

/** @} */

0 comments on commit c49cd44

Please sign in to comment.