diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-10-07 18:11:07 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-10-07 18:11:07 +0200 |
commit | 650a9e882705c993b401ab2545bc166b3d88028c (patch) | |
tree | 4f1a3d117a8ad2517f68f55a497d4a9d0a4622ea /ffd/neigh.c | |
parent | 4334011653c004f8f8925342bc81e109452cbcae (diff) | |
download | ffd-650a9e882705c993b401ab2545bc166b3d88028c.tar ffd-650a9e882705c993b401ab2545bc166b3d88028c.zip |
Add code for periodic maintenance
Diffstat (limited to 'ffd/neigh.c')
-rw-r--r-- | ffd/neigh.c | 11 |
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; |