Browse Source

sys/net/routing/nhdp: get rid of vtimer

sys/net/routing/nhdp/nhdp.c: fix identation

sys/net/routing/nhdp/nhdp.h: fix typo
pr/gpio
kYc0o 7 years ago
parent
commit
6e8d574534
  1. 2
      Makefile.dep
  2. 10
      sys/net/routing/nhdp/iib_table.c
  3. 25
      sys/net/routing/nhdp/nhdp.c
  4. 4
      sys/net/routing/nhdp/nhdp.h
  5. 2
      sys/net/routing/nhdp/nhdp_reader.c
  6. 6
      sys/net/routing/nhdp/nib_table.c

2
Makefile.dep

@ -8,7 +8,7 @@ endif
ifneq (,$(filter nhdp,$(USEMODULE)))
USEMODULE += conn_udp
USEMODULE += vtimer
USEMODULE += xtimer
USEMODULE += oonf_rfc5444
endif

10
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);

25
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

4
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 */

2
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();

6
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) {

Loading…
Cancel
Save