From 2091f168d1582a63c33ee6012ac12e22c6feff02 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Wed, 17 Apr 2019 21:26:27 +0200 Subject: [PATCH 1/4] gnrc_sixlowpan: expose configuration via config group --- sys/include/net/gnrc/sixlowpan.h | 22 +------- sys/include/net/gnrc/sixlowpan/config.h | 72 +++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 21 deletions(-) create mode 100644 sys/include/net/gnrc/sixlowpan/config.h diff --git a/sys/include/net/gnrc/sixlowpan.h b/sys/include/net/gnrc/sixlowpan.h index e0592f8246..665e79b426 100644 --- a/sys/include/net/gnrc/sixlowpan.h +++ b/sys/include/net/gnrc/sixlowpan.h @@ -138,6 +138,7 @@ #include "kernel_types.h" +#include "net/gnrc/sixlowpan/config.h" #include "net/gnrc/sixlowpan/frag.h" #include "net/gnrc/sixlowpan/internal.h" #include "net/gnrc/sixlowpan/iphc.h" @@ -147,27 +148,6 @@ extern "C" { #endif -/** - * @brief Default stack size to use for the 6LoWPAN thread. - */ -#ifndef GNRC_SIXLOWPAN_STACK_SIZE -#define GNRC_SIXLOWPAN_STACK_SIZE (THREAD_STACKSIZE_DEFAULT) -#endif - -/** - * @brief Default priority for the 6LoWPAN thread. - */ -#ifndef GNRC_SIXLOWPAN_PRIO -#define GNRC_SIXLOWPAN_PRIO (THREAD_PRIORITY_MAIN - 4) -#endif - -/** - * @brief Default message queue size to use for the 6LoWPAN thread. - */ -#ifndef GNRC_SIXLOWPAN_MSG_QUEUE_SIZE -#define GNRC_SIXLOWPAN_MSG_QUEUE_SIZE (8U) -#endif - /** * @brief Initialization of the 6LoWPAN thread. * diff --git a/sys/include/net/gnrc/sixlowpan/config.h b/sys/include/net/gnrc/sixlowpan/config.h new file mode 100644 index 0000000000..8099bb0c32 --- /dev/null +++ b/sys/include/net/gnrc/sixlowpan/config.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2019 Freie Universität Berlin + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @defgroup net_gnrc_sixlowpan_config GNRC 6LoWPAN compile configurations + * @ingroup net_gnrc_sixlowpan + * @ingroup config + * @brief + * @{ + * + * @file + * @brief Configuration macros for @ref net_gnrc_sixlowpan + * + * @author Martine Lenders + */ +#ifndef NET_GNRC_SIXLOWPAN_CONFIG_H +#define NET_GNRC_SIXLOWPAN_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Default stack size to use for the 6LoWPAN thread. + */ +#ifndef GNRC_SIXLOWPAN_STACK_SIZE +#define GNRC_SIXLOWPAN_STACK_SIZE (THREAD_STACKSIZE_DEFAULT) +#endif + +/** + * @brief Default priority for the 6LoWPAN thread. + */ +#ifndef GNRC_SIXLOWPAN_PRIO +#define GNRC_SIXLOWPAN_PRIO (THREAD_PRIORITY_MAIN - 4) +#endif + +/** + * @brief Default message queue size to use for the 6LoWPAN thread. + */ +#ifndef GNRC_SIXLOWPAN_MSG_QUEUE_SIZE +#define GNRC_SIXLOWPAN_MSG_QUEUE_SIZE (8U) +#endif + +/** + * @brief Registration lifetime in minutes for the address registration option + * + * This value should be adapted to the devices power-lifecycle so that it is + * greater than the time the device spends sleeping. + * + * @see [RFC 6775, section 5.8.1](https://tools.ietf.org/html/rfc6775#section-5.8.1) + * + * @note Only applicable with [gnrc_ipv6_nib](@ref net_gnrc_ipv6_nib) and + * [gnrc_sixlowpan_nd](@ref net_gnrc_sixlowpan_nd) modules. The first + * provides automatic sending of neighbor solicitations, the latter + * provides capabilities to build the address registration option as a + * @ref gnrc_pktsnip_t + */ +#ifndef GNRC_SIXLOWPAN_ND_AR_LTIME +#define GNRC_SIXLOWPAN_ND_AR_LTIME (15U) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* NET_GNRC_SIXLOWPAN_CONFIG_H */ +/** @} */ From ba3c099f16af9d746ce3370173c9c6b617f9be25 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Wed, 17 Apr 2019 21:26:59 +0200 Subject: [PATCH 2/4] gnrc_sixlowpan_nd: remove unused config variable (and its header) --- .../net/gnrc/sixlowpan/nd/border_router.h | 43 ------------------- 1 file changed, 43 deletions(-) delete mode 100644 sys/include/net/gnrc/sixlowpan/nd/border_router.h diff --git a/sys/include/net/gnrc/sixlowpan/nd/border_router.h b/sys/include/net/gnrc/sixlowpan/nd/border_router.h deleted file mode 100644 index 7d61d36f87..0000000000 --- a/sys/include/net/gnrc/sixlowpan/nd/border_router.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2015 Martine Lenders - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @defgroup net_gnrc_sixlowpan_nd_border_router Border router part of 6LoWPAN-ND - * @ingroup net_gnrc_sixlowpan_nd - * @brief Border router part of 6LoWPAN-ND - * @{ - * - * @file - * @brief Border router definitions for 6LoWPAN. - * - * @author Martine Lenders - */ -#ifndef NET_GNRC_SIXLOWPAN_ND_BORDER_ROUTER_H -#define NET_GNRC_SIXLOWPAN_ND_BORDER_ROUTER_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Default lifetime in minutes for 6LoWPAN border router information. - * - * @see - * RFC 6775, section 4.3 - * - */ -#ifndef GNRC_SIXLOWPAN_ND_BORDER_ROUTER_DEFAULT_LTIME -#define GNRC_SIXLOWPAN_ND_BORDER_ROUTER_DEFAULT_LTIME (10000U) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* NET_GNRC_SIXLOWPAN_ND_BORDER_ROUTER_H */ -/** @} */ From 1550390adb2216ac06d821eaaac9480a77690e1b Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Wed, 17 Apr 2019 21:39:17 +0200 Subject: [PATCH 3/4] gnrc_sixlowpan_frag: expose reassembly buffer configuration Both values are not standardized so there is no sense keeping these values not configurable --- sys/include/net/gnrc/sixlowpan/config.h | 22 +++++++++++++++++++ .../gnrc/network_layer/sixlowpan/frag/rbuf.h | 10 +++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/sys/include/net/gnrc/sixlowpan/config.h b/sys/include/net/gnrc/sixlowpan/config.h index 8099bb0c32..8cfebbcf67 100644 --- a/sys/include/net/gnrc/sixlowpan/config.h +++ b/sys/include/net/gnrc/sixlowpan/config.h @@ -21,6 +21,8 @@ #ifndef NET_GNRC_SIXLOWPAN_CONFIG_H #define NET_GNRC_SIXLOWPAN_CONFIG_H +#include "timex.h" + #ifdef __cplusplus extern "C" { #endif @@ -46,6 +48,26 @@ extern "C" { #define GNRC_SIXLOWPAN_MSG_QUEUE_SIZE (8U) #endif +/** + * @brief Size of the reassembly buffer + * + * @note Only applicable with + * [gnrc_sixlowpan_frag](@ref net_gnrc_sixlowpan_frag) module + */ +#ifndef GNRC_SIXLOWPAN_FRAG_RBUF_SIZE +#define GNRC_SIXLOWPAN_FRAG_RBUF_SIZE (4U) +#endif + +/** + * @brief Timeout for reassembly buffer entries in microseconds + * + * @note Only applicable with + * [gnrc_sixlowpan_frag](@ref net_gnrc_sixlowpan_frag) module + */ +#ifndef GNRC_SIXLOWPAN_FRAG_RBUF_TIMEOUT_MS +#define GNRC_SIXLOWPAN_FRAG_RBUF_TIMEOUT_MS (3U * US_PER_SEC) +#endif + /** * @brief Registration lifetime in minutes for the address registration option * diff --git a/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.h b/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.h index 0f7947897a..957e2573d9 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.h +++ b/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.h @@ -25,14 +25,20 @@ #include "net/gnrc/netif/hdr.h" #include "net/gnrc/pkt.h" +#include "net/gnrc/sixlowpan/config.h" #include "net/gnrc/sixlowpan/frag.h" #ifdef __cplusplus extern "C" { #endif -#define RBUF_SIZE (4U) /**< size of the reassembly buffer */ -#define RBUF_TIMEOUT (3U * US_PER_SEC) /**< timeout for reassembly in microseconds */ +/** + * @name Legacy defines + * @{ + */ +#define RBUF_SIZE (GNRC_SIXLOWPAN_FRAG_RBUF_SIZE) +#define RBUF_TIMEOUT (GNRC_SIXLOWPAN_FRAG_RBUF_TIMEOUT_MS) +/** @} */ /** * @brief Fragment intervals to identify limits of fragments. From 43dedfcd2c52c15fb083e0d984c23c6f6e550cb6 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Thu, 18 Apr 2019 12:21:47 +0200 Subject: [PATCH 4/4] gnrc_sixlowpan_frag/rbuf: document undocumented functions This adds documentation for the following undocumented functions: - rbuf_rm() - rbuf_entry_empty() --- .../gnrc/network_layer/sixlowpan/frag/rbuf.h | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.h b/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.h index 957e2573d9..8e067490ad 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.h +++ b/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.h @@ -96,8 +96,28 @@ void rbuf_add(gnrc_netif_hdr_t *netif_hdr, gnrc_pktsnip_t *frag, */ void rbuf_gc(void); +/** + * @brief Unsets a reassembly buffer entry (but does not free + * rbuf_t::super::pkt) + * + * This functions sets rbuf_t::super::pkt to NULL and removes all rbuf::ints. + * + * @param[in] rbuf A reassembly buffer entry + * + * @internal + */ void rbuf_rm(rbuf_t *rbuf); +/** + * @brief Checks if a reassembly buffer entry is unset + * + * @param[in] rbuf A reassembly buffer entry + * + * @return true, if @p rbuf is empty (i.e. rbuf->super.pkt is NULL). + * @return false, if @p rbuf is in use. + * + * @internal + */ static inline bool rbuf_entry_empty(const rbuf_t *rbuf) { return (rbuf->super.pkt == NULL); }