summaryrefslogtreecommitdiffstats
path: root/src/neigh.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-03-24 03:45:16 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-03-24 03:45:16 +0100
commit47bd032564a4812a607cbe9f5a44ef2b2f93278d (patch)
tree3069f48157989175a51584897ed338c01b58d2bc /src/neigh.c
parent0af36311e10c0dd480bcfca5774db738e165066d (diff)
downloadbabel-47bd032564a4812a607cbe9f5a44ef2b2f93278d.tar
babel-47bd032564a4812a607cbe9f5a44ef2b2f93278d.zip
Initial nexthop maintenance implementation
Mostly taken from the FFD project, and quite incomplete.
Diffstat (limited to 'src/neigh.c')
-rw-r--r--src/neigh.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/neigh.c b/src/neigh.c
index bbef746..b89e284 100644
--- a/src/neigh.c
+++ b/src/neigh.c
@@ -40,7 +40,7 @@ gp_babel_neigh_t* gp_babel_neigh_get(gp_babel_iface_t *iface, const gmrf_addr_t
neigh->last_ihu = gmrf_time_unspec;
neigh->addr = *addr;
- neigh->txcost = 0xffff;
+ neigh->txcost = GP_BABEL_INFINITY;
}
return neigh;
@@ -66,25 +66,25 @@ void gp_babel_neigh_unref(gp_babel_neigh_t *neigh) {
uint16_t gp_babel_neigh_get_rxcost(gmrf_t *gmrf, const gp_babel_neigh_t *neigh) {
if (!neigh->hello_log || !neigh->hello_interval || !neigh->iface)
- return 0xffff;
+ return GP_BABEL_INFINITY;
int timediff = (gmrf_now(gmrf) - neigh->last_hello)/10;
int shift = (timediff - neigh->hello_interval/2)/neigh->hello_interval;
if (shift >= 16)
- return 0xffff;
+ return GP_BABEL_INFINITY;
int received = __builtin_popcount((neigh->hello_log << shift) & 0xffff);
if (received == 0)
- return 0xffff;
+ return GP_BABEL_INFINITY;
else
return (0x1000/received);
}
uint16_t gp_babel_neigh_get_txcost(gmrf_t *gmrf, const gp_babel_neigh_t *neigh) {
if ((gmrf_now(gmrf) - neigh->last_ihu)/10 > GP_BABEL_IHU_TIMEOUT(neigh->ihu_interval) || !neigh->iface)
- return 0xffff;
+ return GP_BABEL_INFINITY;
else
return neigh->txcost;
}
@@ -99,8 +99,8 @@ uint16_t gp_babel_neigh_get_cost(gmrf_t *gmrf, const gp_babel_neigh_t *neigh) {
uint32_t cost = (txcost * gp_babel_neigh_get_rxcost(gmrf, neigh)) >> 8;
- if (cost > 0xffff)
- return 0xffff;
+ if (cost > GP_BABEL_INFINITY)
+ return GP_BABEL_INFINITY;
else
return cost;
}