summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-10-07 18:19:41 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-10-07 18:19:41 +0200
commitec6a57a218b4bf4bf6d2e6ae1a6a4db59aa79f64 (patch)
treea87cab79bfe783cd4893c564aa64171586ab3ba4
parent650a9e882705c993b401ab2545bc166b3d88028c (diff)
downloadffd-ec6a57a218b4bf4bf6d2e6ae1a6a4db59aa79f64.tar
ffd-ec6a57a218b4bf4bf6d2e6ae1a6a4db59aa79f64.zip
Fix rxcost computation
-rw-r--r--ffd/neigh.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ffd/neigh.c b/ffd/neigh.c
index 74ff1b5..ca72ccc 100644
--- a/ffd/neigh.c
+++ b/ffd/neigh.c
@@ -55,7 +55,11 @@ uint16_t ffd_neigh_get_rxcost(const ffd_neigh_t *neigh) {
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);
+
+ if (shift >= 16)
+ return 0xffff;
+
+ int received = __builtin_popcount((neigh->hello_log << shift) & 0xffff);
if (received == 0)
return 0xffff;