Commit 7aee11a7 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Clean-up request handling code.

parent 7107cd5d
...@@ -102,13 +102,15 @@ parse_packet(const unsigned char *from, struct network *net, ...@@ -102,13 +102,15 @@ parse_packet(const unsigned char *from, struct network *net,
continue; continue;
net->activity_time = now.tv_sec; net->activity_time = now.tv_sec;
if(message[0] == 1) { if(message[0] == 1) {
int hopcount = message[2];
int theirseqno = message[1];
debugf("Received request on %s from %s (%s) for %s " debugf("Received request on %s from %s (%s) for %s "
"(%d hops for seqno %d).\n", "(%d hops for seqno %d).\n",
net->ifname, net->ifname,
format_address(neigh->id), format_address(neigh->id),
format_address(from), format_address(from),
format_address(message + 4), format_address(message + 4),
message[2], message[1]); hopcount, theirseqno);
if(memcmp(message + 4, zeroes, 16) == 0) { if(memcmp(message + 4, zeroes, 16) == 0) {
/* If a neighbour is requesting a full route dump from us, /* If a neighbour is requesting a full route dump from us,
we might as well send its txcost. */ we might as well send its txcost. */
...@@ -116,7 +118,7 @@ parse_packet(const unsigned char *from, struct network *net, ...@@ -116,7 +118,7 @@ parse_packet(const unsigned char *from, struct network *net,
send_update(NULL, neigh->network); send_update(NULL, neigh->network);
} else if(memcmp(message + 4, myid, 16) == 0) { } else if(memcmp(message + 4, myid, 16) == 0) {
int new_seqno; int new_seqno;
if(message[2] > 0 && seqno_compare(message[1], seqno) <= 0) if(hopcount > 0 && seqno_compare(theirseqno, seqno) <= 0)
/* Somebody's requesting an old seqno. */ /* Somebody's requesting an old seqno. */
new_seqno = 0; new_seqno = 0;
else else
...@@ -126,12 +128,10 @@ parse_packet(const unsigned char *from, struct network *net, ...@@ -126,12 +128,10 @@ parse_packet(const unsigned char *from, struct network *net,
struct destination *dest; struct destination *dest;
dest = find_destination(message + 4, 0, 0); dest = find_destination(message + 4, 0, 0);
if(dest) { if(dest) {
if(message[2] == 0) { if(hopcount == 0) {
send_update(dest, neigh->network); send_update(dest, neigh->network);
} else { } else {
/* Request for a new seqno */ /* Request for a new seqno */
int hopcount = message[2];
int theirseqno = message[1];
struct route *installed; struct route *installed;
installed = find_installed_route(dest); installed = find_installed_route(dest);
if(installed && installed->nexthop != neigh) { if(installed && installed->nexthop != 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