diff --git a/sys/include/net/gnrc/sixlowpan/frag/rb.h b/sys/include/net/gnrc/sixlowpan/frag/rb.h index ff5dfb8259..8bfa78c84d 100644 --- a/sys/include/net/gnrc/sixlowpan/frag/rb.h +++ b/sys/include/net/gnrc/sixlowpan/frag/rb.h @@ -251,6 +251,27 @@ static inline void gnrc_sixlowpan_frag_rb_remove(gnrc_sixlowpan_frag_rb_t *rbuf) } #endif +#if defined(TEST_SUITES) || defined(DOXYGEN) +/** + * @brief Check if pool of fragment intervals is empty + * + * @see @ref gnrc_sixlowpan_frag_rb_int_t + * @note Returns only non-true values if @ref TEST_SUITES is defined. + * + * @return true, if pool of fragment intervals is empty + * @return false, if pool of fragment intervals is not empty + */ +bool gnrc_sixlowpan_frag_rb_ints_empty(void); +#else /* defined(TEST_SUITES) || defined(DOXYGEN) */ +/* always true without TEST_SUITES defined to optimize out when not testing, + * as checking the status of the fragment interval pool is unnecessary in + * production */ +static inline bool gnrc_sixlowpan_frag_rb_ints_empty(void) +{ + return true; +} +#endif /* defined(TEST_SUITES) || defined(DOXYGEN) */ + #ifdef __cplusplus } #endif diff --git a/sys/net/gnrc/network_layer/sixlowpan/frag/rb/gnrc_sixlowpan_frag_rb.c b/sys/net/gnrc/network_layer/sixlowpan/frag/rb/gnrc_sixlowpan_frag_rb.c index fee17cc9e3..dedd6cec6a 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/frag/rb/gnrc_sixlowpan_frag_rb.c +++ b/sys/net/gnrc/network_layer/sixlowpan/frag/rb/gnrc_sixlowpan_frag_rb.c @@ -423,6 +423,18 @@ static gnrc_sixlowpan_frag_rb_int_t *_rbuf_int_get_free(void) return NULL; } +#ifdef TEST_SUITES +bool gnrc_sixlowpan_frag_rb_ints_empty(void) +{ + for (unsigned int i = 0; i < RBUF_INT_SIZE; i++) { + if (rbuf_int[i].end > 0) { + return false; + } + } + return true; +} +#endif /* TEST_SUITES */ + static bool _rbuf_update_ints(gnrc_sixlowpan_frag_rb_base_t *entry, uint16_t offset, size_t frag_size) {