From 2cae71e89ba01aa8d210bcb4e903116673ddf84b Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Wed, 22 Sep 2010 22:04:55 +0000 Subject: [PATCH] Added a function for obtaining the link estimate and rtmetric for a neighbor --- core/net/rime/collect-neighbor.c | 14 ++++++++++---- core/net/rime/collect-neighbor.h | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/core/net/rime/collect-neighbor.c b/core/net/rime/collect-neighbor.c index 03fca74cf..7cb5ce4ad 100644 --- a/core/net/rime/collect-neighbor.c +++ b/core/net/rime/collect-neighbor.c @@ -33,7 +33,7 @@ * * This file is part of the Contiki operating system. * - * $Id: collect-neighbor.c,v 1.5 2010/09/13 13:28:14 adamdunkels Exp $ + * $Id: collect-neighbor.c,v 1.6 2010/09/22 22:04:55 adamdunkels Exp $ */ /** @@ -251,8 +251,8 @@ collect_neighbor_list_best(struct collect_neighbor_list *neighbors_list) n->rtmetric, collect_neighbor_link_estimate(n), collect_neighbor_rtmetric(n)); if(!rimeaddr_cmp(&n->addr, &rimeaddr_null) && - rtmetric > collect_neighbor_rtmetric(n)) { - rtmetric = collect_neighbor_rtmetric(n); + rtmetric > collect_neighbor_rtmetric_link_estimate(n)) { + rtmetric = collect_neighbor_rtmetric_link_estimate(n); best = n; } } @@ -335,11 +335,17 @@ collect_neighbor_link_estimate(struct collect_neighbor *n) } /*---------------------------------------------------------------------------*/ int -collect_neighbor_rtmetric(struct collect_neighbor *n) +collect_neighbor_rtmetric_link_estimate(struct collect_neighbor *n) { return n->rtmetric + collect_link_estimate(&n->le); } /*---------------------------------------------------------------------------*/ +int +collect_neighbor_rtmetric(struct collect_neighbor *n) +{ + return n->rtmetric; +} +/*---------------------------------------------------------------------------*/ void collect_neighbor_set_lifetime(int seconds) { diff --git a/core/net/rime/collect-neighbor.h b/core/net/rime/collect-neighbor.h index 19f3ce3ab..28abace89 100644 --- a/core/net/rime/collect-neighbor.h +++ b/core/net/rime/collect-neighbor.h @@ -39,7 +39,7 @@ * * This file is part of the Contiki operating system. * - * $Id: collect-neighbor.h,v 1.3 2010/09/13 13:28:14 adamdunkels Exp $ + * $Id: collect-neighbor.h,v 1.4 2010/09/22 22:04:55 adamdunkels Exp $ */ /** @@ -91,6 +91,7 @@ void collect_neighbor_tx(struct collect_neighbor *n, uint8_t num_tx); void collect_neighbor_rx(struct collect_neighbor *n); void collect_neighbor_tx_fail(struct collect_neighbor *n, uint8_t num_tx); int collect_neighbor_link_estimate(struct collect_neighbor *n); +int collect_neighbor_rtmetric_link_estimate(struct collect_neighbor *n); int collect_neighbor_rtmetric(struct collect_neighbor *n);