Skip to content
Snippets Groups Projects
Commit 3b825c25 authored by Cenk Gündoğan's avatar Cenk Gündoğan
Browse files

sixlowpan: use xtimer_now() instead of vtimer_now()

parent 023c0984
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "mutex.h" #include "mutex.h"
#include "net/gnrc/sixlowpan/ctx.h" #include "net/gnrc/sixlowpan/ctx.h"
#include "vtimer.h" #include "vtimer.h"
#include "xtimer.h"
#define ENABLE_DEBUG (0) #define ENABLE_DEBUG (0)
#include "debug.h" #include "debug.h"
...@@ -132,9 +133,7 @@ gnrc_sixlowpan_ctx_t *gnrc_sixlowpan_ctx_update(uint8_t id, const ipv6_addr_t *p ...@@ -132,9 +133,7 @@ gnrc_sixlowpan_ctx_t *gnrc_sixlowpan_ctx_update(uint8_t id, const ipv6_addr_t *p
static uint32_t _current_minute(void) static uint32_t _current_minute(void)
{ {
timex_t now; return xtimer_now() / (SEC_IN_USEC * 60);
vtimer_now(&now);
return now.seconds / 60;
} }
static void _update_lifetime(uint8_t id) static void _update_lifetime(uint8_t id)
......
...@@ -231,17 +231,15 @@ static bool _rbuf_update_ints(rbuf_t *entry, uint16_t offset, size_t frag_size) ...@@ -231,17 +231,15 @@ static bool _rbuf_update_ints(rbuf_t *entry, uint16_t offset, size_t frag_size)
static void _rbuf_gc(void) static void _rbuf_gc(void)
{ {
rbuf_t *oldest = NULL; rbuf_t *oldest = NULL;
timex_t now; uint32_t now_sec = xtimer_now() / SEC_IN_USEC;
unsigned int i; unsigned int i;
vtimer_now(&now);
for (i = 0; i < RBUF_SIZE; i++) { for (i = 0; i < RBUF_SIZE; i++) {
if (rbuf[i].pkt == NULL) { /* leave GC early if there is still room */ if (rbuf[i].pkt == NULL) { /* leave GC early if there is still room */
return; return;
} }
else if ((rbuf[i].pkt != NULL) && else if ((rbuf[i].pkt != NULL) &&
((now.seconds - rbuf[i].arrival) > RBUF_TIMEOUT)) { ((now_sec - rbuf[i].arrival) > RBUF_TIMEOUT)) {
DEBUG("6lo rfrag: entry (%s, ", gnrc_netif_addr_to_str(l2addr_str, DEBUG("6lo rfrag: entry (%s, ", gnrc_netif_addr_to_str(l2addr_str,
sizeof(l2addr_str), rbuf[i].src, rbuf[i].src_len)); sizeof(l2addr_str), rbuf[i].src, rbuf[i].src_len));
DEBUG("%s, %u, %u) timed out\n", DEBUG("%s, %u, %u) timed out\n",
...@@ -269,9 +267,7 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len, ...@@ -269,9 +267,7 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len,
size_t size, uint16_t tag) size_t size, uint16_t tag)
{ {
rbuf_t *res = NULL; rbuf_t *res = NULL;
timex_t now; uint32_t now_sec = xtimer_now() / SEC_IN_USEC;
vtimer_now(&now);
for (unsigned int i = 0; i < RBUF_SIZE; i++) { for (unsigned int i = 0; i < RBUF_SIZE; i++) {
/* check first if entry already available */ /* check first if entry already available */
...@@ -287,7 +283,7 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len, ...@@ -287,7 +283,7 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len,
gnrc_netif_addr_to_str(l2addr_str, sizeof(l2addr_str), gnrc_netif_addr_to_str(l2addr_str, sizeof(l2addr_str),
rbuf[i].dst, rbuf[i].dst_len), rbuf[i].dst, rbuf[i].dst_len),
(unsigned)rbuf[i].pkt->size, rbuf[i].tag); (unsigned)rbuf[i].pkt->size, rbuf[i].tag);
rbuf[i].arrival = now.seconds; rbuf[i].arrival = now_sec;
return &(rbuf[i]); return &(rbuf[i]);
} }
...@@ -306,7 +302,7 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len, ...@@ -306,7 +302,7 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len,
*((uint64_t *)res->pkt->data) = 0; /* clean first few bytes for later *((uint64_t *)res->pkt->data) = 0; /* clean first few bytes for later
* look-ups */ * look-ups */
res->arrival = now.seconds; res->arrival = now_sec;
memcpy(res->src, src, src_len); memcpy(res->src, src, src_len);
memcpy(res->dst, dst, dst_len); memcpy(res->dst, dst, dst_len);
res->src_len = src_len; res->src_len = src_len;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment