From 4f6b2759be9583a2efec56da38e06d5573d462b4 Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Wed, 11 Oct 2023 20:37:34 +0200 Subject: [PATCH] sys/net: Add NETOPT_ACTIVE for netif on/off state Similar to forcing interface up/down on Linux. In lwIP this is separate to link state. --- sys/include/net/netopt.h | 10 ++++++++++ sys/net/crosslayer/netopt/netopt.c | 1 + 2 files changed, 11 insertions(+) diff --git a/sys/include/net/netopt.h b/sys/include/net/netopt.h index 6385e68145..e94842dd90 100644 --- a/sys/include/net/netopt.h +++ b/sys/include/net/netopt.h @@ -299,6 +299,16 @@ typedef enum { */ NETOPT_LINK, + /** + * @brief (@ref netopt_enable_t) network interface status. + * + * This option is used check state or to enable/disable the interface, + * regardless of link status. + * + * @note On error this option should return a negative number. + */ + NETOPT_ACTIVE, + /** * @brief (@ref netopt_enable_t) CSMA/CA support * diff --git a/sys/net/crosslayer/netopt/netopt.c b/sys/net/crosslayer/netopt/netopt.c index 9c66cbc0b4..bfadebe8b6 100644 --- a/sys/net/crosslayer/netopt/netopt.c +++ b/sys/net/crosslayer/netopt/netopt.c @@ -63,6 +63,7 @@ static const char *_netopt_strmap[] = { [NETOPT_MAC_NO_SLEEP] = "NETOPT_MAC_NO_SLEEP", [NETOPT_IS_WIRED] = "NETOPT_IS_WIRED", [NETOPT_LINK] = "NETOPT_LINK", + [NETOPT_ACTIVE] = "NETOPT_ACTIVE", [NETOPT_DEVICE_TYPE] = "NETOPT_DEVICE_TYPE", [NETOPT_CHANNEL_PAGE] = "NETOPT_CHANNEL_PAGE", [NETOPT_CCA_THRESHOLD] = "NETOPT_CCA_THRESHOLD",