mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-29 16:31:18 +01:00
gnrc_sixlowpan_frag: add arrival time to public type
The arrival time is also needed for the VRB's garbage collection.
This commit is contained in:
parent
b84e496563
commit
8cc5d94956
@ -99,6 +99,8 @@ typedef struct {
|
||||
uint8_t src_len; /**< length of gnrc_sixlowpan_rbuf_t::src */
|
||||
uint8_t dst_len; /**< length of gnrc_sixlowpan_rbuf_t::dst */
|
||||
uint16_t tag; /**< the datagram's tag */
|
||||
uint32_t arrival; /**< time in microseconds of arrival of
|
||||
* last received fragment */
|
||||
/**
|
||||
* @brief The number of bytes currently received of the complete datagram
|
||||
*/
|
||||
|
||||
@ -256,7 +256,7 @@ void rbuf_gc(void)
|
||||
for (i = 0; i < RBUF_SIZE; i++) {
|
||||
/* since pkt occupies pktbuf, aggressivly collect garbage */
|
||||
if ((rbuf[i].super.pkt != NULL) &&
|
||||
((now_usec - rbuf[i].arrival) > RBUF_TIMEOUT)) {
|
||||
((now_usec - rbuf[i].super.arrival) > RBUF_TIMEOUT)) {
|
||||
DEBUG("6lo rfrag: entry (%s, ",
|
||||
gnrc_netif_addr_to_str(rbuf[i].super.src,
|
||||
rbuf[i].super.src_len,
|
||||
@ -301,7 +301,7 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len,
|
||||
rbuf[i].super.dst_len,
|
||||
l2addr_str),
|
||||
(unsigned)rbuf[i].super.pkt->size, rbuf[i].super.tag);
|
||||
rbuf[i].arrival = now_usec;
|
||||
rbuf[i].super.arrival = now_usec;
|
||||
_set_rbuf_timeout();
|
||||
return &(rbuf[i]);
|
||||
}
|
||||
@ -313,7 +313,8 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len,
|
||||
|
||||
/* remember oldest slot */
|
||||
/* note that xtimer_now will overflow in ~1.2 hours */
|
||||
if ((oldest == NULL) || (oldest->arrival - rbuf[i].arrival < UINT32_MAX / 2)) {
|
||||
if ((oldest == NULL) ||
|
||||
(oldest->super.arrival - rbuf[i].super.arrival < UINT32_MAX / 2)) {
|
||||
oldest = &(rbuf[i]);
|
||||
}
|
||||
}
|
||||
@ -358,7 +359,7 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len,
|
||||
|
||||
*((uint64_t *)res->super.pkt->data) = 0; /* clean first few bytes for later
|
||||
* look-ups */
|
||||
res->arrival = now_usec;
|
||||
res->super.arrival = now_usec;
|
||||
memcpy(res->super.src, src, src_len);
|
||||
memcpy(res->super.dst, dst, dst_len);
|
||||
res->super.src_len = src_len;
|
||||
|
||||
@ -51,8 +51,6 @@ extern "C" {
|
||||
*/
|
||||
typedef struct {
|
||||
gnrc_sixlowpan_rbuf_t super; /**< exposed part of the reassembly buffer */
|
||||
uint32_t arrival; /**< time in microseconds of arrival of
|
||||
* last received fragment */
|
||||
} rbuf_t;
|
||||
|
||||
/**
|
||||
|
||||
@ -515,7 +515,7 @@ static void test_rbuf_gc__manually(void)
|
||||
entry = (rbuf_t *)_first_non_empty_rbuf();
|
||||
TEST_ASSERT_NOT_NULL(entry);
|
||||
/* set arrival RBUF_TIMEOUT into the past */
|
||||
entry->arrival -= RBUF_TIMEOUT;
|
||||
entry->super.arrival -= RBUF_TIMEOUT;
|
||||
rbuf_gc();
|
||||
/* reassembly buffer is now empty */
|
||||
TEST_ASSERT_NULL(_first_non_empty_rbuf());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user