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..8cfebbcf67 --- /dev/null +++ b/sys/include/net/gnrc/sixlowpan/config.h @@ -0,0 +1,94 @@ +/* + * 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 + +#include "timex.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 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 + * + * 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 */ +/** @} */ 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 */ -/** @} */ diff --git a/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.h b/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.h index 0f7947897a..8e067490ad 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. @@ -90,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); }