Commit 3cde1704 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Add feasible parameter to find_best_route.

parent 14eb3454
...@@ -242,7 +242,7 @@ update_feasible(const unsigned char *a, ...@@ -242,7 +242,7 @@ update_feasible(const unsigned char *a,
/* This returns the feasible route with the smallest metric. */ /* This returns the feasible route with the smallest metric. */
struct route * struct route *
find_best_route(const unsigned char *prefix, unsigned char plen) find_best_route(const unsigned char *prefix, unsigned char plen, int feasible)
{ {
struct route *route = NULL; struct route *route = NULL;
int i; int i;
...@@ -252,7 +252,7 @@ find_best_route(const unsigned char *prefix, unsigned char plen) ...@@ -252,7 +252,7 @@ find_best_route(const unsigned char *prefix, unsigned char plen)
continue; continue;
if(routes[i].time < now.tv_sec - route_timeout_delay) if(routes[i].time < now.tv_sec - route_timeout_delay)
continue; continue;
if(!route_feasible(&routes[i])) if(feasible && !route_feasible(&routes[i]))
continue; continue;
if(route && route->metric <= routes[i].metric) if(route && route->metric <= routes[i].metric)
continue; continue;
...@@ -575,7 +575,7 @@ trigger_route_change(struct route *route, ...@@ -575,7 +575,7 @@ trigger_route_change(struct route *route,
if(route->metric > oldmetric) { if(route->metric > oldmetric) {
struct route *better_route; struct route *better_route;
better_route = better_route =
find_best_route(route->src->prefix, route->src->plen); find_best_route(route->src->prefix, route->src->plen, 1);
if(better_route && better_route->metric <= route->metric - 96) if(better_route && better_route->metric <= route->metric - 96)
consider_route(better_route); consider_route(better_route);
} }
...@@ -593,7 +593,7 @@ void ...@@ -593,7 +593,7 @@ void
route_lost(struct source *src, int oldmetric) route_lost(struct source *src, int oldmetric)
{ {
struct route *new_route; struct route *new_route;
new_route = find_best_route(src->prefix, src->plen); new_route = find_best_route(src->prefix, src->plen, 1);
if(new_route) { if(new_route) {
consider_route(new_route); consider_route(new_route);
} else { } else {
......
...@@ -53,7 +53,8 @@ int route_feasible(struct route *route); ...@@ -53,7 +53,8 @@ int route_feasible(struct route *route);
int update_feasible(const unsigned char *a, int update_feasible(const unsigned char *a,
const unsigned char *p, unsigned char plen, const unsigned char *p, unsigned char plen,
unsigned short seqno, unsigned short refmetric); unsigned short seqno, unsigned short refmetric);
struct route *find_best_route(const unsigned char *prefix, unsigned char plen); struct route *find_best_route(const unsigned char *prefix, unsigned char plen,
int feasible);
struct route *install_best_route(const unsigned char prefix[16], struct route *install_best_route(const unsigned char prefix[16],
unsigned char plen); unsigned char plen);
void update_neighbour_metric(struct neighbour *neigh); void update_neighbour_metric(struct neighbour *neigh);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment