summaryrefslogtreecommitdiffstats
path: root/ffd/neigh.c
diff options
context:
space:
mode:
Diffstat (limited to 'ffd/neigh.c')
-rw-r--r--ffd/neigh.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/ffd/neigh.c b/ffd/neigh.c
index 02a3318..74ff1b5 100644
--- a/ffd/neigh.c
+++ b/ffd/neigh.c
@@ -53,7 +53,7 @@ uint16_t ffd_neigh_get_rxcost(const ffd_neigh_t *neigh) {
if (!neigh->hello_log || !neigh->hello_interval)
return 0xffff;
- int timediff = timespec_diff(&now, &neigh->last_hello)/10;
+ int timediff = timespec_diff(&now, &neigh->last_hello);
int shift = (timediff - neigh->hello_interval/2)/neigh->hello_interval;
int received = __builtin_popcount(neigh->hello_log << shift);
@@ -63,11 +63,18 @@ uint16_t ffd_neigh_get_rxcost(const ffd_neigh_t *neigh) {
return (0x1000/received);
}
+uint16_t ffd_neigh_get_txcost(const ffd_neigh_t *neigh) {
+ if (timespec_diff(&now, &neigh->last_ihu) > FFD_IHU_TIMEOUT(neigh->ihu_interval))
+ return 0xffff;
+ else
+ return neigh->txcost;
+}
+
uint16_t ffd_neigh_get_cost(const ffd_neigh_t *neigh) {
if (!neigh) /* self */
return 0;
- uint16_t txcost = neigh->txcost;
+ uint16_t txcost = ffd_neigh_get_txcost(neigh);
if (txcost < 256)
txcost = 256;