diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-10-07 18:19:41 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-10-07 18:19:41 +0200 |
commit | ec6a57a218b4bf4bf6d2e6ae1a6a4db59aa79f64 (patch) | |
tree | a87cab79bfe783cd4893c564aa64171586ab3ba4 /ffd/neigh.c | |
parent | 650a9e882705c993b401ab2545bc166b3d88028c (diff) | |
download | ffd-ec6a57a218b4bf4bf6d2e6ae1a6a4db59aa79f64.tar ffd-ec6a57a218b4bf4bf6d2e6ae1a6a4db59aa79f64.zip |
Fix rxcost computation
Diffstat (limited to 'ffd/neigh.c')
-rw-r--r-- | ffd/neigh.c | 6 |
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; |