Commit 9abe7c66 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Teach send*request to send multihop requests.

parent 77527e09
......@@ -385,7 +385,7 @@ main(int argc, char **argv)
for(i = 0; i < numnets; i++) {
gettimeofday(&now, NULL);
send_hello(&nets[i]);
send_request(&nets[i], NULL, 0);
send_request(&nets[i], NULL, 0, 0, 0, 0);
flushbuf(&nets[i]);
usleep(50000 + random() % 100000);
}
......@@ -394,7 +394,7 @@ main(int argc, char **argv)
gettimeofday(&now, NULL);
send_hello(&nets[i]);
send_self_update(&nets[i], 0);
send_request(&nets[i], NULL, 0);
send_request(&nets[i], NULL, 0, 0, 0, 0);
flushbuf(&nets[i]);
usleep(50000 + random() % 100000);
}
......
......@@ -377,20 +377,23 @@ send_hello(struct network *net)
void
send_request(struct network *net,
const unsigned char *prefix, unsigned char plen)
const unsigned char *prefix, unsigned char plen,
unsigned char hop_count, unsigned short seqno,
unsigned short router_hash)
{
int i;
if(net == NULL) {
for(i = 0; i < numnets; i++)
send_request(&nets[i], prefix, plen);
send_request(&nets[i], prefix, plen, hop_count, seqno, router_hash);
return;
}
debugf("Sending request to %s for %s.\n",
net->ifname, prefix ? format_prefix(prefix, plen) : "any");
debugf("Sending request to %s for %s (%d hops).\n",
net->ifname, prefix ? format_prefix(prefix, plen) : "any",
hop_count);
if(prefix)
send_message(net, 2, plen, 0, 0, 0, prefix);
send_message(net, 2, plen, hop_count, seqno, router_hash, prefix);
else
send_message(net, 2, 0xFF, 0, 0, 0, ones);
}
......@@ -421,23 +424,30 @@ send_unicast_packet(struct neighbour *neigh, unsigned char *buf, int buflen)
void
send_unicast_request(struct neighbour *neigh,
const unsigned char *prefix, unsigned char plen)
const unsigned char *prefix, unsigned char plen,
unsigned char hop_count, unsigned short seqno,
unsigned short router_hash)
{
unsigned char buf[24];
debugf("Sending unicast request to %s (%s) for %s.\n",
debugf("Sending unicast request to %s (%s) for %s (%d hops).\n",
format_address(neigh->id),
format_address(neigh->address),
prefix ? format_prefix(prefix, plen) : "any");
prefix ? format_prefix(prefix, plen) : "any",
hop_count);
memset(buf, 0, 24);
buf[0] = 1;
if(prefix) {
buf[1] = plen;
buf[2] = 0;
buf[3] = hop_count;
*(uint16_t*)(buf + 4) = seqno;
*(uint16_t*)(buf + 6) = router_hash;
memcpy(buf + 8, prefix, 16);
buf[7] = plen;
} else {
buf[1] = 0xFF;
memset(buf + 2, 0, 6);
memcpy(buf + 8, ones, 16);
buf[7] = 0xFF;
}
send_unicast_packet(neigh, buf, 24);
}
......
......@@ -41,9 +41,13 @@ void flushbuf(struct network *net);
void send_hello_noupdate(struct network *net, unsigned interval);
void send_hello(struct network *net);
void send_request(struct network *net,
const unsigned char *prefix, unsigned char plen);
const unsigned char *prefix, unsigned char plen,
unsigned char hop_count, unsigned short seqno,
unsigned short router_hash);
void send_unicast_request(struct neighbour *neigh,
const unsigned char *prefix, unsigned char plen);
const unsigned char *prefix, unsigned char plen,
unsigned char hop_count, unsigned short seqno,
unsigned short router_hash);
void send_update(struct network *net, int urgent,
const unsigned char *prefix, unsigned char plen);
void send_self_update(struct network *net, int force_seqno);
......
......@@ -199,7 +199,7 @@ update_neighbour(struct neighbour *neigh, int hello, int hello_interval)
if(!martian_prefix(neigh->id, 128))
route = find_installed_route(neigh->id, 128);
if(!route || route->metric >= INFINITY || route->nexthop == neigh)
send_unicast_request(neigh, NULL, 0);
send_unicast_request(neigh, NULL, 0, 0, 0, 0);
}
return rc;
}
......
......@@ -460,7 +460,8 @@ send_triggered_update(struct route *route, struct source *oldsrc, int oldmetric)
if(oldmetric < INFINITY) {
if(newmetric >= INFINITY || newmetric >= oldmetric + 384)
send_request(NULL, route->src->prefix, route->src->plen);
send_request(NULL, route->src->prefix, route->src->plen,
0, 0, 0);
}
}
......@@ -503,7 +504,7 @@ route_lost(struct source *src, int oldmetric)
/* Complain loudly. */
send_update(NULL, 1, src->prefix, src->plen);
if(oldmetric < INFINITY)
send_request(NULL, src->prefix, src->plen);
send_request(NULL, src->prefix, src->plen, 0, 0, 0);
}
}
......@@ -528,7 +529,8 @@ expire_routes(void)
if(route->installed && route->refmetric < INFINITY) {
if(route->time < now.tv_sec - MAX(10, route_timeout_delay - 25))
send_unicast_request(route->nexthop,
route->src->prefix, route->src->plen);
route->src->prefix, route->src->plen,
0, 0, 0);
}
i++;
}
......
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