Commit 57d9928c authored by Matthieu Boutier's avatar Matthieu Boutier

Format TLV for unicast requests.

parent d0cd3a24
...@@ -1731,30 +1731,52 @@ send_request(struct interface *ifp, ...@@ -1731,30 +1731,52 @@ send_request(struct interface *ifp,
void void
send_unicast_request(struct neighbour *neigh, send_unicast_request(struct neighbour *neigh,
const unsigned char *prefix, unsigned char plen) const unsigned char *prefix, unsigned char plen,
const unsigned char *src_prefix, unsigned char src_plen)
{ {
int rc, v4, pb, len; int rc, v4, pb, spb, len;
/* make sure any buffered updates go out before this request. */ /* make sure any buffered updates go out before this request. */
flushupdates(neigh->ifp); flushupdates(neigh->ifp);
debugf("sending unicast request to %s for %s.\n", if(!prefix)
format_address(neigh->address), debugf("sending unicast request to %s for any.\n",
prefix ? format_prefix(prefix, plen) : "any"); format_address(neigh->address));
else
debugf("sending unicast request to %s for %s from %s.\n",
format_address(neigh->address),
format_prefix(prefix, plen),
format_prefix(src_prefix, src_plen));
v4 = plen >= 96 && v4mapped(prefix); v4 = plen >= 96 && v4mapped(prefix);
pb = v4 ? ((plen - 96) + 7) / 8 : (plen + 7) / 8; pb = v4 ? ((plen - 96) + 7) / 8 : (plen + 7) / 8;
len = !prefix ? 2 : 2 + pb; len = !prefix ? 2 : 2 + pb;
rc = start_unicast_message(neigh, MESSAGE_REQUEST, len); if(src_plen != 0) {
spb = v4 ? ((src_plen - 96) + 7) / 8 : (src_plen + 7) / 8;
len += spb + 1;
rc = start_unicast_message(neigh, MESSAGE_REQUEST_SRC_SPECIFIC, len);
} else {
rc = start_unicast_message(neigh, MESSAGE_REQUEST, len);
}
if(rc < 0) return; if(rc < 0) return;
accumulate_unicast_byte(neigh, !prefix ? 0 : v4 ? 1 : 2); accumulate_unicast_byte(neigh, !prefix ? 0 : v4 ? 1 : 2);
accumulate_unicast_byte(neigh, !prefix ? 0 : v4 ? plen - 96 : plen); accumulate_unicast_byte(neigh, !prefix ? 0 : v4 ? plen - 96 : plen);
if(src_plen != 0)
accumulate_unicast_byte(neigh, v4 ? src_plen - 96 : src_plen);
if(prefix) { if(prefix) {
if(v4) if(v4)
accumulate_unicast_bytes(neigh, prefix + 12, pb); accumulate_unicast_bytes(neigh, prefix + 12, pb);
else else
accumulate_unicast_bytes(neigh, prefix, pb); accumulate_unicast_bytes(neigh, prefix, pb);
} }
if(src_plen != 0) {
if(v4)
accumulate_unicast_bytes(neigh, src_prefix + 12, spb);
else
accumulate_unicast_bytes(neigh, src_prefix, spb);
end_unicast_message(neigh, MESSAGE_REQUEST_SRC_SPECIFIC, len);
return;
}
end_unicast_message(neigh, MESSAGE_REQUEST, len); end_unicast_message(neigh, MESSAGE_REQUEST, len);
} }
......
...@@ -85,7 +85,9 @@ void send_request(struct interface *ifp, ...@@ -85,7 +85,9 @@ void send_request(struct interface *ifp,
const unsigned char *prefix, unsigned char plen, const unsigned char *prefix, unsigned char plen,
const unsigned char *src_prefix, unsigned char src_plen); const unsigned char *src_prefix, unsigned char src_plen);
void send_unicast_request(struct neighbour *neigh, void send_unicast_request(struct neighbour *neigh,
const unsigned char *prefix, unsigned char plen); const unsigned char *prefix, unsigned char plen,
const unsigned char *src_prefix,
unsigned char src_plen);
void send_multihop_request(struct interface *ifp, void send_multihop_request(struct interface *ifp,
const unsigned char *prefix, unsigned char plen, const unsigned char *prefix, unsigned char plen,
unsigned short seqno, const unsigned char *id, unsigned short seqno, const unsigned char *id,
......
...@@ -193,7 +193,7 @@ update_neighbour(struct neighbour *neigh, int hello, int hello_interval) ...@@ -193,7 +193,7 @@ update_neighbour(struct neighbour *neigh, int hello, int hello_interval)
if((neigh->reach & 0xFC00) == 0xC000) { if((neigh->reach & 0xFC00) == 0xC000) {
/* This is a newish neighbour, let's request a full route dump. /* This is a newish neighbour, let's request a full route dump.
We ought to avoid this when the network is dense */ We ought to avoid this when the network is dense */
send_unicast_request(neigh, NULL, 0); send_unicast_request(neigh, NULL, 0, NULL, 0);
send_ihu(neigh, NULL); send_ihu(neigh, NULL);
} }
return rc; return rc;
......
...@@ -1198,7 +1198,8 @@ expire_routes(void) ...@@ -1198,7 +1198,8 @@ expire_routes(void)
if(route_old(r)) if(route_old(r))
/* Route about to expire, send a request. */ /* Route about to expire, send a request. */
send_unicast_request(r->neigh, send_unicast_request(r->neigh,
r->src->prefix, r->src->plen); r->src->prefix, r->src->plen,
r->src->src_prefix, r->src->src_plen);
} }
r = r->next; r = r->next;
} }
......
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