From 47bd032564a4812a607cbe9f5a44ef2b2f93278d Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 24 Mar 2013 03:45:16 +0100 Subject: Initial nexthop maintenance implementation Mostly taken from the FFD project, and quite incomplete. --- src/neigh.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/neigh.c') 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; } -- cgit v1.2.3