diff --git a/Makefile.dep b/Makefile.dep index 3cb560f094cbf091d63aec0663cab8377e79b798..6a66add076efdc48877e26886424cf842b158e46 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -8,7 +8,7 @@ endif ifneq (,$(filter nhdp,$(USEMODULE))) USEMODULE += conn_udp - USEMODULE += vtimer + USEMODULE += xtimer USEMODULE += oonf_rfc5444 endif diff --git a/sys/net/routing/nhdp/iib_table.c b/sys/net/routing/nhdp/iib_table.c index 22769eace938b2205a61358c7fdc25f6f996f724..d65c69e2749aa31587bb1260a6b78577b70c7cf6 100644 --- a/sys/net/routing/nhdp/iib_table.c +++ b/sys/net/routing/nhdp/iib_table.c @@ -20,7 +20,7 @@ #include "mutex.h" #include "timex.h" -#include "vtimer.h" +#include "xtimer.h" #include "utlist.h" #include "kernel_types.h" @@ -118,7 +118,7 @@ iib_link_set_entry_t *iib_process_hello(kernel_pid_t if_pid, nib_entry_t *nb_elt } if (base_elt) { - vtimer_now(&now); + xtimer_now_timex(&now); /* Create a new link tuple for the neighbor that originated the hello */ ls_entry = update_link_set(base_elt, nb_elt, &now, validity_time, is_sym_nb, is_lost); @@ -143,7 +143,7 @@ void iib_fill_wr_addresses(kernel_pid_t if_pid, struct rfc5444_writer *wr) mutex_lock(&mtx_iib_access); - vtimer_now(&now); + xtimer_now_timex(&now); /* Before adding addresses first update the status of all link tuples */ iib_update_lt_status(&now); @@ -251,7 +251,7 @@ void iib_process_metric_msg(iib_link_set_entry_t *ls_entry, uint64_t int_time) ls_entry->hello_interval = rfc5444_timetlv_encode(int_time); if (ls_entry->last_seq_no == 0) { timex_t now, i_time; - vtimer_now(&now); + xtimer_now_timex(&now); i_time = timex_from_uint64(int_time * MS_IN_USEC * DAT_HELLO_TIMEOUT_FACTOR); ls_entry->dat_received[0]++; ls_entry->dat_total[0]++; @@ -297,7 +297,7 @@ void iib_process_metric_pckt(iib_link_set_entry_t *ls_entry, uint32_t metric_out if (ls_entry->hello_interval != 0) { timex_t now, i_time; - vtimer_now(&now); + xtimer_now_timex(&now); i_time = timex_from_uint64(rfc5444_timetlv_decode(ls_entry->hello_interval) * MS_IN_USEC * DAT_HELLO_TIMEOUT_FACTOR); ls_entry->dat_time = timex_add(now, i_time); diff --git a/sys/net/routing/nhdp/nhdp.c b/sys/net/routing/nhdp/nhdp.c index b5f00aec77fec66cada163b5eeee34bf0baf5066..a545ea383099ee413e372127df41a6dd2d51f901 100644 --- a/sys/net/routing/nhdp/nhdp.c +++ b/sys/net/routing/nhdp/nhdp.c @@ -42,6 +42,8 @@ #error "nhdp needs a conn_udp implementation to work" #endif +#define HELLO_TIMER (12345) + char nhdp_stack[NHDP_STACK_SIZE]; char nhdp_rcv_stack[NHDP_STACK_SIZE]; @@ -54,8 +56,9 @@ static mutex_t send_rcv_mutex = MUTEX_INIT; static conn_udp_t conn; #if (NHDP_METRIC_NEEDS_TIMER) -static vtimer_t metric_timer; +static xtimer_t metric_timer; static timex_t metric_interval; +static msg_t metric_msg; #endif /* Internal function prototypes */ @@ -100,7 +103,10 @@ kernel_pid_t nhdp_start(void) /* Configure periodic timer message to refresh metric values */ if (nhdp_pid != KERNEL_PID_UNDEF) { metric_interval = timex_from_uint64(DAT_REFRESH_INTERVAL * SEC_IN_USEC); - vtimer_set_msg(&metric_timer, metric_interval, nhdp_pid, NHDP_METRIC_TIMER, NULL); + metric_msg.type = NHDP_METRIC_TIMER; + metric_msg.content.ptr = NULL; + xtimer_set_msg64(&metric_timer, timex_uint64(metric_interval), + metric_msg, nhdp_pid); } #endif } @@ -196,7 +202,7 @@ int nhdp_register_if(kernel_pid_t if_pid, uint8_t *addr, size_t addr_size, uint8 THREAD_CREATE_STACKTEST, _nhdp_receiver, NULL, "nhdp_rcv_thread"); /* Start sending periodic HELLO */ - signal_msg.type = MSG_TIMER; + signal_msg.type = HELLO_TIMER; signal_msg.content.ptr = (char *) if_entry; /* TODO: msg_send or msg_try_send? */ msg_try_send(&signal_msg, nhdp_pid); @@ -247,7 +253,7 @@ static void *_nhdp_runner(void *arg) msg_receive(&msg_rcvd); switch (msg_rcvd.type) { - case MSG_TIMER: + case HELLO_TIMER: mutex_lock(&send_rcv_mutex); if_entry = (nhdp_if_entry_t *) msg_rcvd.content.ptr; @@ -256,8 +262,9 @@ static void *_nhdp_runner(void *arg) /* TODO: Add jitter */ /* Schedule next sending */ - vtimer_set_msg(&if_entry->if_timer, if_entry->hello_interval, - thread_getpid(), MSG_TIMER, (void *) if_entry); + xtimer_set_msg64(&if_entry->if_timer, + timex_uint64(if_entry->hello_interval), + &msg_rcvd, thread_getpid()); mutex_unlock(&send_rcv_mutex); break; @@ -268,8 +275,10 @@ static void *_nhdp_runner(void *arg) iib_process_metric_refresh(); /* Schedule next sending */ - vtimer_set_msg(&metric_timer, metric_interval, - thread_getpid(), NHDP_METRIC_TIMER, NULL); + metric_msg.type = NHDP_METRIC_TIMER; + metric_msg.content.ptr = NULL; + xtimer_set_msg64(&metric_timer, timex_uint64(metric_interval), + metric_msg, thread_getpid()); mutex_unlock(&send_rcv_mutex); break; #endif diff --git a/sys/net/routing/nhdp/nhdp.h b/sys/net/routing/nhdp/nhdp.h index bbd828f8db88812cccd7cb85645104fcaa0f6992..bca7482170be2a9bc1b85dc17b7cc65388f79ac0 100644 --- a/sys/net/routing/nhdp/nhdp.h +++ b/sys/net/routing/nhdp/nhdp.h @@ -22,7 +22,7 @@ #define NHDP_H_ #include "timex.h" -#include "vtimer.h" +#include "xtimer.h" #include "kernel_types.h" #include "nhdp_metric.h" @@ -90,7 +90,7 @@ extern "C" { */ typedef struct nhdp_if_entry_t { kernel_pid_t if_pid; /**< PID of the interface's handling thread */ - vtimer_t if_timer; /**< Vtimer used for the periodic signaling */ + xtimer_t if_timer; /**< xtimer used for the periodic signaling */ timex_t hello_interval; /**< Interval time for periodic HELLOs */ timex_t validity_time; /**< Validity time for propagated information */ uint16_t seq_no; /**< Sequence number of last send RFC5444 packet */ diff --git a/sys/net/routing/nhdp/nhdp_reader.c b/sys/net/routing/nhdp/nhdp_reader.c index c19ab0e84812773d22e81a638584ae9473c458f1..f29d6e2f32c6a873b333580b29714332caa73c04 100644 --- a/sys/net/routing/nhdp/nhdp_reader.c +++ b/sys/net/routing/nhdp/nhdp_reader.c @@ -456,7 +456,7 @@ static void process_temp_tables(void) nib_entry_t *nib_elt; timex_t now; - vtimer_now(&now); + xtimer_now_timex(&now); iib_update_lt_status(&now); nib_elt = nib_process_hello(); diff --git a/sys/net/routing/nhdp/nib_table.c b/sys/net/routing/nhdp/nib_table.c index 8e922eb552520cdc55c2b7932432ba860022d6da..ab6357bf232cd0bd1b2c5fd75746e750546c0d9e 100644 --- a/sys/net/routing/nhdp/nib_table.c +++ b/sys/net/routing/nhdp/nib_table.c @@ -20,7 +20,7 @@ #include "timex.h" #include "mutex.h" -#include "vtimer.h" +#include "xtimer.h" #include "utlist.h" #include "rfc5444/rfc5444_iana.h" @@ -57,7 +57,7 @@ nib_entry_t *nib_process_hello(void) mutex_lock(&mtx_nib_access); - vtimer_now(&now); + xtimer_now_timex(&now); LL_FOREACH_SAFE(nib_entry_head, nib_elt, nib_tmp) { nhdp_addr_entry_t *list_elt; @@ -113,7 +113,7 @@ void nib_fill_wr_addresses(struct rfc5444_writer *wr) mutex_lock(&mtx_nib_access); - vtimer_now(&now); + xtimer_now_timex(&now); /* Add addresses of symmetric neighbors to HELLO msg */ LL_FOREACH(nib_entry_head, nib_elt) {