From 28b8536063f4f45d9e5d24e699fb1c1a093235ab Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Mon, 11 Oct 2021 22:44:05 +0200 Subject: [PATCH 1/7] sys/shell/gnrc_netif: print v6 addresses based on ipv6 module To support lwIP better (dont require gnrc_ipv6) Also don't require IPv6 for printing link type With this sc_gnrc_netif can compile and work when using lwIP (with l2util module added): ``` > ifconfig Iface ET1 HWaddr: 24:0A:C4:E6:0E:9C Channel: 6 Link: up L2-PDU:1500 Source address length: 6 Link type: wireless inet6 addr: fe80::260a:c4ff:fee6:e9c scope: link inet6 addr: 2001:db8::260a:c4ff:fee6:e9c scope: global Iface ET0 HWaddr: 24:0A:C4:E6:0E:9F Link: up L2-PDU:1500 Source address length: 6 Link type: wired inet6 addr: fe80::260a:c4ff:fee6:e9f scope: link inet6 addr: 2001:db8::260a:c4ff:fee6:e9f scope: global > ``` Still works in gnrc_networking example: ``` > ifconfig Iface 8 HWaddr: 24:0A:C4:E6:0E:9F Link: up L2-PDU:1500 MTU:1500 HL:64 RTR RTR_ADV Source address length: 6 Link type: wired inet6 addr: fe80::260a:c4ff:fee6:e9f scope: link VAL inet6 group: ff02::2 inet6 group: ff02::1 inet6 group: ff02::1:ffe6:e9f inet6 group: ff02::1a ``` --- sys/shell/cmds/gnrc_netif.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/shell/cmds/gnrc_netif.c b/sys/shell/cmds/gnrc_netif.c index 938480e89f7d..0da36652fb4a 100644 --- a/sys/shell/cmds/gnrc_netif.c +++ b/sys/shell/cmds/gnrc_netif.c @@ -580,7 +580,7 @@ static unsigned _netif_list_flag(netif_t *iface, netopt_t opt, char *str, return line_thresh; } -#ifdef MODULE_GNRC_IPV6 +#ifdef MODULE_IPV6 static void _netif_list_ipv6(ipv6_addr_t *addr, uint8_t flags) { char addr_str[IPV6_ADDR_MAX_STR_LEN]; @@ -600,6 +600,7 @@ static void _netif_list_ipv6(ipv6_addr_t *addr, uint8_t flags) else { printf("unknown"); } +#if MODULE_GNRC_IPV6 if (flags & GNRC_NETIF_IPV6_ADDRS_FLAGS_ANYCAST) { printf(" [anycast]"); } @@ -620,6 +621,7 @@ static void _netif_list_ipv6(ipv6_addr_t *addr, uint8_t flags) break; } } +#endif _newline(0U, _LINE_THRESHOLD); } @@ -636,7 +638,7 @@ static void _netif_list_groups(ipv6_addr_t *addr) static void _netif_list(netif_t *iface) { -#ifdef MODULE_GNRC_IPV6 +#ifdef MODULE_IPV6 ipv6_addr_t ipv6_addrs[CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF]; ipv6_addr_t ipv6_groups[GNRC_NETIF_IPV6_GROUPS_NUMOF]; #endif @@ -892,11 +894,11 @@ static void _netif_list(netif_t *iface) line_thresh++; } line_thresh = _newline(0U, line_thresh); -#ifdef MODULE_GNRC_IPV6 printf("Link type: %s", (netif_get_opt(iface, NETOPT_IS_WIRED, 0, &u16, sizeof(u16)) > 0) ? "wired" : "wireless"); _newline(0U, ++line_thresh); +#ifdef MODULE_IPV6 res = netif_get_opt(iface, NETOPT_IPV6_ADDR, 0, ipv6_addrs, sizeof(ipv6_addrs)); if (res >= 0) { From 7a66f1cc4260474b69e5e6b8e6eacb145d950791 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Wed, 4 Oct 2023 13:21:05 +0200 Subject: [PATCH 2/7] sys/event/timeout: add event_timeout_is_pending() --- sys/include/event/timeout.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/include/event/timeout.h b/sys/include/event/timeout.h index eee2b881cfbb..3f7b9b7f4695 100644 --- a/sys/include/event/timeout.h +++ b/sys/include/event/timeout.h @@ -107,6 +107,18 @@ void event_timeout_set(event_timeout_t *event_timeout, uint32_t timeout); */ void event_timeout_clear(event_timeout_t *event_timeout); +/** + * @brief Check if a timeout event is scheduled to be executed in the future + * + * @param[in] event_timeout event_timout context object to use + * @return true if the event is scheduled, false otherwise + */ +static inline bool event_timeout_is_pending(const event_timeout_t *event_timeout) +{ + return ztimer_is_set(event_timeout->clock, &event_timeout->timer) + || event_is_queued(event_timeout->queue, event_timeout->event); +} + #ifdef __cplusplus } #endif From 2dc44124713620a5655aae82e555a66a826e8d5d Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Wed, 4 Oct 2023 13:24:41 +0200 Subject: [PATCH 3/7] tests/sys/events: add event_timeout_is_pending() to test --- tests/sys/events/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/sys/events/main.c b/tests/sys/events/main.c index 0741f4f9bc96..ee5c038f7ebf 100644 --- a/tests/sys/events/main.c +++ b/tests/sys/events/main.c @@ -197,6 +197,7 @@ int main(void) before = xtimer_now_usec(); #endif event_timeout_set(&event_timeout, (1 * US_PER_SEC)); + expect(event_timeout_is_pending(&event_timeout)); event_timeout_t event_timeout_canceled; @@ -205,6 +206,7 @@ int main(void) (event_t *)&noevent_callback); event_timeout_set(&event_timeout_canceled, 500 * US_PER_MS); event_timeout_clear(&event_timeout_canceled); + expect(!event_timeout_is_pending(&event_timeout_canceled)); puts("launching event queue"); event_loop(&queue); From ee6ca2b6ce012284e898ee16044466226e09dfe6 Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Mon, 9 May 2022 00:36:08 +0200 Subject: [PATCH 4/7] sys/shell/gnrc_netif: Use l2util versions of link addr helpers To avoid dependency on gnrc files. As suggested in #16965 --- sys/shell/Makefile.dep | 3 +++ sys/shell/cmds/gnrc_netif.c | 13 +++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sys/shell/Makefile.dep b/sys/shell/Makefile.dep index 862ada7b9301..02b64a08061c 100644 --- a/sys/shell/Makefile.dep +++ b/sys/shell/Makefile.dep @@ -3,6 +3,9 @@ USEMODULE += stdin ifneq (,$(filter shell_cmds_default,$(USEMODULE))) USEMODULE += shell_cmd_sys + ifneq (,$(filter netif,$(USEMODULE))) + USEMODULE += l2util + endif ifneq (,$(filter app_metadata,$(USEMODULE))) USEMODULE += shell_cmd_app_metadata endif diff --git a/sys/shell/cmds/gnrc_netif.c b/sys/shell/cmds/gnrc_netif.c index 0da36652fb4a..d7dc05d7c461 100644 --- a/sys/shell/cmds/gnrc_netif.c +++ b/sys/shell/cmds/gnrc_netif.c @@ -29,6 +29,7 @@ #include "net/gnrc/netif.h" #include "net/gnrc/netif/hdr.h" #include "net/ipv6/addr.h" +#include "net/l2util.h" #include "net/lora.h" #include "net/loramac.h" #include "net/netif.h" @@ -660,7 +661,7 @@ static void _netif_list(netif_t *iface) if (res >= 0) { char hwaddr_str[res * 3]; printf(" HWaddr: %s ", - gnrc_netif_addr_to_str(hwaddr, res, hwaddr_str)); + l2util_addr_to_str(hwaddr, res, hwaddr_str)); } res = netif_get_opt(iface, NETOPT_CHANNEL, 0, &u16, sizeof(u16)); if (res >= 0) { @@ -788,7 +789,7 @@ static void _netif_list(netif_t *iface) if (res >= 0) { char hwaddr_str[res * 3]; printf("Long HWaddr: "); - printf("%s ", gnrc_netif_addr_to_str(hwaddr, res, hwaddr_str)); + printf("%s ", l2util_addr_to_str(hwaddr, res, hwaddr_str)); line_thresh++; } line_thresh = _newline(0U, line_thresh); @@ -935,8 +936,8 @@ static void _netif_list(netif_t *iface) for (unsigned i = 0; i < CONFIG_L2FILTER_LISTSIZE; i++) { if (filter[i].addr_len > 0) { char hwaddr_str[filter[i].addr_len * 3]; - gnrc_netif_addr_to_str(filter[i].addr, filter[i].addr_len, - hwaddr_str); + l2util_addr_to_str(filter[i].addr, filter[i].addr_len, + hwaddr_str); printf(" %2i: %s\n", count++, hwaddr_str); } } @@ -1300,7 +1301,7 @@ static int _netif_set_lw_key(netif_t *iface, netopt_t opt, char *key_str) static int _netif_set_addr(netif_t *iface, netopt_t opt, char *addr_str) { uint8_t addr[GNRC_NETIF_L2ADDR_MAXLEN]; - size_t addr_len = gnrc_netif_addr_from_str(addr_str, addr); + size_t addr_len = l2util_addr_from_str(addr_str, addr); if (addr_len == 0) { printf("error: unable to parse address.\n" @@ -1449,7 +1450,7 @@ static int _netif_set_encrypt_key(netif_t *iface, netopt_t opt, char *key_str) static int _netif_addrm_l2filter(netif_t *iface, char *val, bool add) { uint8_t addr[GNRC_NETIF_L2ADDR_MAXLEN]; - size_t addr_len = gnrc_netif_addr_from_str(val, addr); + size_t addr_len = l2util_addr_from_str(val, addr); if ((addr_len == 0) || (addr_len > CONFIG_L2FILTER_ADDR_MAXLEN)) { printf("error: given address is invalid\n"); From 988db6923d65dc183819c1a6f9436245b4a5c898 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Thu, 12 Oct 2023 16:23:53 +0200 Subject: [PATCH 5/7] gnrc_ipv6_ext_frag: _completed: Add comment why list head is not checked ... for NULL pointer dereference. --- sys/net/gnrc/network_layer/ipv6/ext/frag/gnrc_ipv6_ext_frag.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/net/gnrc/network_layer/ipv6/ext/frag/gnrc_ipv6_ext_frag.c b/sys/net/gnrc/network_layer/ipv6/ext/frag/gnrc_ipv6_ext_frag.c index 2f5124363cfa..c57407729e23 100644 --- a/sys/net/gnrc/network_layer/ipv6/ext/frag/gnrc_ipv6_ext_frag.c +++ b/sys/net/gnrc/network_layer/ipv6/ext/frag/gnrc_ipv6_ext_frag.c @@ -711,6 +711,7 @@ static gnrc_pktsnip_t *_completed(gnrc_ipv6_ext_frag_rbuf_t *rbuf) /* clist: first element is second element ;-) (from next of head) */ gnrc_ipv6_ext_frag_limits_t *ptr = (gnrc_ipv6_ext_frag_limits_t *)rbuf->limits.next->next; + /* ptr should not be NULL at this point so it is safe to dereference with ptr->start here */ if (rbuf->last && (ptr->start == 0)) { gnrc_pktsnip_t *res = NULL; From a250dfeef032a06da1307f1cc3266d83e6ea6d19 Mon Sep 17 00:00:00 2001 From: Koen Zandberg Date: Fri, 13 Oct 2023 15:25:23 +0200 Subject: [PATCH 6/7] pkg/nanocbor: Bump to latest commit Important changes: - Add stream-like interface for encoder - Separate functions for number of items left in arrays and maps --- pkg/nanocbor/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/nanocbor/Makefile b/pkg/nanocbor/Makefile index f7eacb56ccd4..61a019daadb0 100644 --- a/pkg/nanocbor/Makefile +++ b/pkg/nanocbor/Makefile @@ -1,6 +1,6 @@ PKG_NAME = nanocbor PKG_URL = https://github.com/bergzand/nanocbor -PKG_VERSION = 1bc789705057c42be32aea17aeec97763aece3c7 +PKG_VERSION = ae01e393f152b8294028986256f8451c93f75cfc PKG_LICENSE = CC-0 include $(RIOTBASE)/pkg/pkg.mk From d778e2eb5f0576f72ac6718ac76cc67d584e6a5c Mon Sep 17 00:00:00 2001 From: SimonIT Date: Fri, 13 Oct 2023 16:11:20 +0200 Subject: [PATCH 7/7] core: Express -1 as ~0 in thread_status_t cast --- core/include/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/include/sched.h b/core/include/sched.h index 49b4c35eef05..f7384236ffcf 100644 --- a/core/include/sched.h +++ b/core/include/sched.h @@ -184,7 +184,7 @@ typedef enum { */ #define STATUS_ON_RUNQUEUE STATUS_RUNNING /**< to check if on run queue: `st >= STATUS_ON_RUNQUEUE` */ -#define STATUS_NOT_FOUND ((thread_status_t)-1) /**< Describes an illegal thread status */ +#define STATUS_NOT_FOUND ((thread_status_t)~0) /**< Describes an illegal thread status */ /** @} */ /** * @def SCHED_PRIO_LEVELS