Skip to content

Commit

Permalink
gnrc_sixlowpan_frag_sfr: make ARQ timer mockable
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed May 4, 2021
1 parent fcaad8b commit 89c0b8e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
11 changes: 11 additions & 0 deletions sys/include/net/gnrc/sixlowpan/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,17 @@ extern "C" {
#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_DG_RETRIES
#define CONFIG_GNRC_SIXLOWPAN_SFR_DG_RETRIES 0U
#endif

/**
* @brief Deactivate automatic handling of ARQ timer
*
* This requires an external source (e.g. a test application) to call
* @ref gnrc_sixlowpan_frag_sfr_arq_timeout() for
* @ref net_gnrc_sixlowpan_frag_sfr to still work properly.
*/
#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_MOCK_ARQ_TIMER
#define CONFIG_GNRC_SIXLOWPAN_SFR_MOCK_ARQ_TIMER 0U
#endif
/** @} */

/**
Expand Down
8 changes: 8 additions & 0 deletions sys/net/gnrc/network_layer/sixlowpan/frag/sfr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,12 @@ config GNRC_SIXLOWPAN_SFR_DG_RETRIES
int "The maximum number of retries from scratch for a particular datagram (MaxDatagramRetries)"
default 0

config GNRC_SIXLOWPAN_SFR_MOCK_ARQ_TIMER
bool "Deactivate automatic handling of ARQ timer"
default n
help
This requires an external source (e.g. a test application) to call
@ref gnrc_sixlowpan_frag_sfr_arq_timeout() for
@ref net_gnrc_sixlowpan_frag_sfr to still work properly.

endif
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,10 @@ void gnrc_sixlowpan_frag_sfr_arq_timeout(gnrc_sixlowpan_frag_fb_t *fbuf)

DEBUG("6lo sfr: ARQ timeout for datagram %u\n", fbuf->tag);
fbuf->sfr.arq_timeout_event.msg.content.ptr = NULL;
if (IS_ACTIVE(CONFIG_GNRC_SIXLOWPAN_SFR_MOCK_ARQ_TIMER)) {
/* time goes by ;-) */
now -= (fbuf->sfr.arq_timeout * US_PER_MS) + 1;
}
if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE) && frag_desc) {
gnrc_sixlowpan_frag_sfr_congure_snd_report_frags_timeout(fbuf);
_shrink_window(fbuf);
Expand Down Expand Up @@ -1608,18 +1612,20 @@ static void _sched_next_frame(gnrc_sixlowpan_frag_fb_t *fbuf)

static void _sched_arq_timeout(gnrc_sixlowpan_frag_fb_t *fbuf, uint32_t offset)
{
if (fbuf->sfr.arq_timeout_event.msg.content.ptr != NULL) {
DEBUG("6lo sfr: ARQ timeout for datagram %u already scheduled\n",
(uint8_t)fbuf->tag);
return;
if (!IS_ACTIVE(CONFIG_GNRC_SIXLOWPAN_SFR_MOCK_ARQ_TIMER)) {
if (fbuf->sfr.arq_timeout_event.msg.content.ptr != NULL) {
DEBUG("6lo sfr: ARQ timeout for datagram %u already scheduled\n",
(uint8_t)fbuf->tag);
return;
}
DEBUG("6lo sfr: arming ACK timeout in %lums for datagram %u\n",
(long unsigned)offset, fbuf->tag);
fbuf->sfr.arq_timeout_event.event.offset = offset;
fbuf->sfr.arq_timeout_event.msg.content.ptr = fbuf;
fbuf->sfr.arq_timeout_event.msg.type = GNRC_SIXLOWPAN_FRAG_SFR_ARQ_TIMEOUT_MSG;
evtimer_add_msg(&_arq_timer, &fbuf->sfr.arq_timeout_event,
_getpid());
}
DEBUG("6lo sfr: arming ACK timeout in %lums for datagram %u\n",
(long unsigned)offset, fbuf->tag);
fbuf->sfr.arq_timeout_event.event.offset = offset;
fbuf->sfr.arq_timeout_event.msg.content.ptr = fbuf;
fbuf->sfr.arq_timeout_event.msg.type = GNRC_SIXLOWPAN_FRAG_SFR_ARQ_TIMEOUT_MSG;
evtimer_add_msg(&_arq_timer, &fbuf->sfr.arq_timeout_event,
_getpid());
}

static void _sched_abort_timeout(gnrc_sixlowpan_frag_fb_t *fbuf)
Expand Down

0 comments on commit 89c0b8e

Please sign in to comment.