Commit d4dabe92 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Simplify flush_route.

parent 2f755b73
...@@ -68,7 +68,7 @@ void ...@@ -68,7 +68,7 @@ void
flush_route(struct route *route) flush_route(struct route *route)
{ {
int n; int n;
unsigned char dest[16]; struct destination *dest;
int install = 0, oldmetric; int install = 0, oldmetric;
n = route - routes; n = route - routes;
...@@ -81,7 +81,7 @@ flush_route(struct route *route) ...@@ -81,7 +81,7 @@ flush_route(struct route *route)
install = 1; install = 1;
} }
memcpy(dest, route->dest->address, 16); dest = route->dest;
if(n != numroutes - 1) if(n != numroutes - 1)
memcpy(routes + n, routes + numroutes - 1, sizeof(struct route)); memcpy(routes + n, routes + numroutes - 1, sizeof(struct route));
...@@ -90,21 +90,14 @@ flush_route(struct route *route) ...@@ -90,21 +90,14 @@ flush_route(struct route *route)
if(install) { if(install) {
struct route *new_route; struct route *new_route;
struct destination *destination = find_destination(dest, 0, 0); new_route = find_best_route(dest);
if(destination == NULL) {
fprintf(stderr,
"Attempted to retract unknown destination "
"(this shouldn't happen).\n");
return;
}
new_route = find_best_route(destination);
if(new_route) { if(new_route) {
install_route(new_route); install_route(new_route);
send_triggered_update(new_route, oldmetric); send_triggered_update(new_route, oldmetric);
} else { } else {
if(destination->metric < INFINITY) { if(dest->metric < INFINITY) {
destination->seqno = ((destination->seqno + 1) & 0xFF); dest->metric = INFINITY;
destination->metric = INFINITY; dest->seqno = (dest->seqno + 1) & 0xFF;
} }
send_update(route->dest, NULL); send_update(route->dest, NULL);
send_request(NULL, route->dest); send_request(NULL, route->dest);
......
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