diff --git a/sys/include/net/netopt.h b/sys/include/net/netopt.h index 563e3e8be4..73dcbbd900 100644 --- a/sys/include/net/netopt.h +++ b/sys/include/net/netopt.h @@ -37,6 +37,15 @@ extern "C" { */ #define NETOPT_MAX_PACKET_SIZE NETOPT_MAX_PDU_SIZE +/** + * @brief A deprecated alias for @ref NETOPT_LINK + * + * @deprecated Please use @ref NETOPT_LINK instead of + * `NETOPT_LINK_CONNECTED`. It will be removed after the + * 2020.07 release at the latest. + */ +#define NETOPT_LINK_CONNECTED NETOPT_LINK + /** * @brief Global list of configuration options available throughout the * network stack, e.g. by netdev and netapi @@ -286,16 +295,13 @@ typedef enum { NETOPT_AUTOCCA, /** - * @brief (@ref netopt_enable_t) Phy link status. + * @brief (@ref netopt_enable_t) network interface link status. * - * Returns NETOPT_ENABLE when the the link of the interface is up, - * NETOPT_DISABLE when the link is down. If the interface is wireless or - * doesn't support link status detection this function will return - * -ENOTSUP. + * This option is used to set or check the link status (up or down). * - * @note Setting this option will always return -ENOTSUP. + * @note On error this option should return a negative number. */ - NETOPT_LINK_CONNECTED, + NETOPT_LINK, /** * @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 ab26c1e7e2..db0a75bca9 100644 --- a/sys/net/crosslayer/netopt/netopt.c +++ b/sys/net/crosslayer/netopt/netopt.c @@ -62,7 +62,7 @@ static const char *_netopt_strmap[] = { [NETOPT_CSMA_MINBE] = "NETOPT_CSMA_MINBE", [NETOPT_MAC_NO_SLEEP] = "NETOPT_MAC_NO_SLEEP", [NETOPT_IS_WIRED] = "NETOPT_IS_WIRED", - [NETOPT_LINK_CONNECTED] = "NETOPT_LINK_CONNECTED", + [NETOPT_LINK] = "NETOPT_LINK", [NETOPT_DEVICE_TYPE] = "NETOPT_DEVICE_TYPE", [NETOPT_CHANNEL_PAGE] = "NETOPT_CHANNEL_PAGE", [NETOPT_CCA_THRESHOLD] = "NETOPT_CCA_THRESHOLD", diff --git a/sys/shell/commands/sc_gnrc_netif.c b/sys/shell/commands/sc_gnrc_netif.c index 02d0e87fbf..691a92b438 100644 --- a/sys/shell/commands/sc_gnrc_netif.c +++ b/sys/shell/commands/sc_gnrc_netif.c @@ -136,6 +136,11 @@ static int _netif_stats(kernel_pid_t iface, unsigned module, bool reset) } #endif /* MODULE_NETSTATS */ +static void _link_usage(char *cmd_name) +{ + printf("usage: %s [up|down]\n", cmd_name); +} + static void _set_usage(char *cmd_name) { printf("usage: %s set \n", cmd_name); @@ -450,7 +455,7 @@ static void _netif_list(kernel_pid_t iface) printf(" CR: %s ", _netopt_coding_rate_str[u8]); } #endif - res = gnrc_netapi_get(iface, NETOPT_LINK_CONNECTED, 0, &u8, sizeof(u8)); + res = gnrc_netapi_get(iface, NETOPT_LINK, 0, &u8, sizeof(u8)); if (res >= 0) { printf(" Link: %s ", (netopt_enable_t)u8 ? "up" : "down" ); } @@ -998,6 +1003,7 @@ static void _l2filter_usage(const char *cmd) static void _usage(char *cmd) { printf("usage: %s\n", cmd); + _link_usage(cmd); _set_usage(cmd); _flag_usage(cmd); _add_usage(cmd); @@ -1107,6 +1113,15 @@ static uint8_t _get_prefix_len(char *addr) } #endif +static int _netif_link(kernel_pid_t iface, netopt_enable_t en) +{ + if(gnrc_netapi_set(iface, NETOPT_LINK, 0, &en, sizeof(en)) < 0) { + printf("error: unable to set link %s\n", en == NETOPT_ENABLE ? "up" : "down"); + return 1; + } + return 0; +} + static int _netif_add(char *cmd_name, kernel_pid_t iface, int argc, char **argv) { #ifdef MODULE_GNRC_IPV6 @@ -1302,6 +1317,12 @@ int _gnrc_netif_config(int argc, char **argv) return _netif_set(argv[0], iface, argv[3], argv[4]); } + else if (strcmp(argv[2], "up") == 0) { + return _netif_link((kernel_pid_t)iface, NETOPT_ENABLE); + } + else if (strcmp(argv[2], "down") == 0) { + return _netif_link((kernel_pid_t)iface, NETOPT_DISABLE); + } else if (strcmp(argv[2], "add") == 0) { if (argc < 4) { _add_usage(argv[0]); diff --git a/tests/gnrc_ipv6_ext_frag/Makefile.ci b/tests/gnrc_ipv6_ext_frag/Makefile.ci index 96a80b1307..41ea57e6f2 100644 --- a/tests/gnrc_ipv6_ext_frag/Makefile.ci +++ b/tests/gnrc_ipv6_ext_frag/Makefile.ci @@ -17,6 +17,7 @@ BOARD_INSUFFICIENT_MEMORY := \ nucleo-f042k6 \ nucleo-f070rb \ nucleo-f072rb \ + nucleo-f302r8 \ nucleo-f303k8 \ nucleo-f334r8 \ nucleo-l031k6 \