Commit 68da3363 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Split handling of directed requests into its own function.

parent 6b9f349b
...@@ -58,6 +58,11 @@ struct buffered_update buffered_updates[MAX_BUFFERED_UPDATES]; ...@@ -58,6 +58,11 @@ struct buffered_update buffered_updates[MAX_BUFFERED_UPDATES];
struct network *update_net = NULL; struct network *update_net = NULL;
int updates = 0; int updates = 0;
static void
handle_request(struct neighbour *neigh, const unsigned char *prefix,
unsigned char plen, unsigned char hop_count,
unsigned short seqno, unsigned short router_hash);
unsigned short unsigned short
hash_id(const unsigned char *id) hash_id(const unsigned char *id)
{ {
...@@ -74,9 +79,8 @@ parse_packet(const unsigned char *from, struct network *net, ...@@ -74,9 +79,8 @@ parse_packet(const unsigned char *from, struct network *net,
{ {
int i, j; int i, j;
const unsigned char *message; const unsigned char *message;
unsigned char type, plen; unsigned char type, plen, hop_count;
unsigned short seqno; unsigned short seqno, metric;
unsigned short metric;
const unsigned char *address; const unsigned char *address;
struct neighbour *neigh; struct neighbour *neigh;
int have_current_source = 0; int have_current_source = 0;
...@@ -112,6 +116,7 @@ parse_packet(const unsigned char *from, struct network *net, ...@@ -112,6 +116,7 @@ parse_packet(const unsigned char *from, struct network *net,
message = packet + 8 + 24 * i; message = packet + 8 + 24 * i;
type = message[0]; type = message[0];
plen = message[1]; plen = message[1];
hop_count = message[3];
seqno = ntohs(*(uint16_t*)(message + 4)); seqno = ntohs(*(uint16_t*)(message + 4));
metric = ntohs(*(uint16_t*)(message + 6)); metric = ntohs(*(uint16_t*)(message + 6));
address = message + 8; address = message + 8;
...@@ -162,7 +167,8 @@ parse_packet(const unsigned char *from, struct network *net, ...@@ -162,7 +167,8 @@ parse_packet(const unsigned char *from, struct network *net,
send_ihu(neigh, NULL); send_ihu(neigh, NULL);
send_update(neigh->network, 0, NULL, 0); send_update(neigh->network, 0, NULL, 0);
} else { } else {
send_update(neigh->network, 1, address, plen); handle_request(neigh, address, plen,
hop_count, seqno, metric);
} }
} else if(type == 3) { } else if(type == 3) {
if(plen == 0xFF) if(plen == 0xFF)
...@@ -214,6 +220,15 @@ parse_packet(const unsigned char *from, struct network *net, ...@@ -214,6 +220,15 @@ parse_packet(const unsigned char *from, struct network *net,
return; return;
} }
static void
handle_request(struct neighbour *neigh, const unsigned char *prefix,
unsigned char plen, unsigned char hop_count,
unsigned short seqno, unsigned short router_hash)
{
send_update(neigh->network, 1, prefix, plen);
}
/* Under normal circumstances, there are enough moderation mechanisms /* Under normal circumstances, there are enough moderation mechanisms
elsewhere in the protocol to make sure that this last-ditch check elsewhere in the protocol to make sure that this last-ditch check
should never trigger. But I'm supersticious. */ should never trigger. But I'm supersticious. */
......
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