Commit 4d9d1080 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Make metrics unsigned.

parent 702ecb20
...@@ -41,7 +41,7 @@ THE SOFTWARE. ...@@ -41,7 +41,7 @@ THE SOFTWARE.
struct route *routes = NULL; struct route *routes = NULL;
int numroutes = 0, maxroutes = 0; int numroutes = 0, maxroutes = 0;
int kernel_metric = 0; unsigned kernel_metric = 0;
int route_timeout_delay = 160; int route_timeout_delay = 160;
int route_gc_delay = 180; int route_gc_delay = 180;
...@@ -75,7 +75,8 @@ flush_route(struct route *route) ...@@ -75,7 +75,8 @@ flush_route(struct route *route)
{ {
int n; int n;
struct source *src; struct source *src;
int oldmetric, lost = 0; unsigned oldmetric;
int lost = 0;
n = route - routes; n = route - routes;
assert(n >= 0 && n < numroutes); assert(n >= 0 && n < numroutes);
...@@ -129,11 +130,9 @@ flush_neighbour_routes(struct neighbour *neigh) ...@@ -129,11 +130,9 @@ flush_neighbour_routes(struct neighbour *neigh)
} }
} }
unsigned int unsigned
metric_to_kernel(int metric) metric_to_kernel(unsigned metric)
{ {
assert(metric >= 0);
if(metric >= INFINITY) if(metric >= INFINITY)
return KERNEL_INFINITY; return KERNEL_INFINITY;
else else
...@@ -211,7 +210,7 @@ switch_routes(struct route *old, struct route *new) ...@@ -211,7 +210,7 @@ switch_routes(struct route *old, struct route *new)
} }
void void
change_route_metric(struct route *route, int newmetric) change_route_metric(struct route *route, unsigned newmetric)
{ {
int rc; int rc;
...@@ -522,9 +521,11 @@ consider_route(struct route *route) ...@@ -522,9 +521,11 @@ consider_route(struct route *route)
} }
void void
send_triggered_update(struct route *route, struct source *oldsrc, int oldmetric) send_triggered_update(struct route *route, struct source *oldsrc,
unsigned oldmetric)
{ {
int urgent = 0, newmetric, diff; int urgent = 0;
unsigned newmetric, diff;
if(!route->installed) if(!route->installed)
return; return;
...@@ -599,7 +600,7 @@ route_changed(struct route *route, ...@@ -599,7 +600,7 @@ route_changed(struct route *route,
/* We just lost the installed route to a given destination. */ /* We just lost the installed route to a given destination. */
void void
route_lost(struct source *src, int oldmetric) route_lost(struct source *src, unsigned oldmetric)
{ {
struct route *new_route; struct route *new_route;
new_route = find_best_route(src->prefix, src->plen, 1, NULL); new_route = find_best_route(src->prefix, src->plen, 1, NULL);
......
...@@ -33,7 +33,7 @@ struct route { ...@@ -33,7 +33,7 @@ struct route {
extern struct route *routes; extern struct route *routes;
extern int numroutes, maxroutes; extern int numroutes, maxroutes;
extern int kernel_metric; extern unsigned kernel_metric;
extern int route_timeout_delay; extern int route_timeout_delay;
extern int route_gc_delay; extern int route_gc_delay;
...@@ -43,11 +43,11 @@ struct route *find_installed_route(const unsigned char *prefix, ...@@ -43,11 +43,11 @@ struct route *find_installed_route(const unsigned char *prefix,
unsigned char plen); unsigned char plen);
void flush_route(struct route *route); void flush_route(struct route *route);
void flush_neighbour_routes(struct neighbour *neigh); void flush_neighbour_routes(struct neighbour *neigh);
unsigned int metric_to_kernel(int metric); unsigned metric_to_kernel(unsigned metric);
void install_route(struct route *route); void install_route(struct route *route);
void uninstall_route(struct route *route); void uninstall_route(struct route *route);
void switch_route(struct route *old, struct route *new); void switch_route(struct route *old, struct route *new);
void change_route_metric(struct route *route, int newmetric); void change_route_metric(struct route *route, unsigned newmetric);
int route_feasible(struct route *route); int route_feasible(struct route *route);
int update_feasible(const unsigned char *id, int update_feasible(const unsigned char *id,
const unsigned char *p, unsigned char plen, const unsigned char *p, unsigned char plen,
...@@ -70,8 +70,8 @@ void send_unfeasible_request(struct neighbour *neigh, int force, ...@@ -70,8 +70,8 @@ void send_unfeasible_request(struct neighbour *neigh, int force,
const unsigned char *prefix, unsigned char plen); const unsigned char *prefix, unsigned char plen);
void consider_route(struct route *route); void consider_route(struct route *route);
void send_triggered_update(struct route *route, void send_triggered_update(struct route *route,
struct source *oldsrc, int oldmetric); struct source *oldsrc, unsigned oldmetric);
void route_changed(struct route *route, void route_changed(struct route *route,
struct source *oldsrc, unsigned short oldmetric); struct source *oldsrc, unsigned short oldmetric);
void route_lost(struct source *src, int oldmetric); void route_lost(struct source *src, unsigned oldmetric);
void expire_routes(void); void expire_routes(void);
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