Commit d0cd3a24 authored by Matthieu Boutier's avatar Matthieu Boutier

Format TLV for (standard) requests.

parent 4df8ccad
......@@ -540,7 +540,7 @@ main(int argc, char **argv)
send_hello(ifp);
send_wildcard_retraction(ifp);
send_self_update(ifp);
send_request(ifp, NULL, 0);
send_request(ifp, NULL, 0, NULL, 0);
flushupdates(ifp);
flushbuf(ifp);
}
......
......@@ -381,7 +381,7 @@ interface_up(struct interface *ifp, int up)
send_hello(ifp);
if(rc > 0)
send_update(ifp, 0, NULL, 0, NULL, 0);
send_request(ifp, NULL, 0);
send_request(ifp, NULL, 0, NULL, 0);
} else {
flush_interface_routes(ifp, 0);
ifp->buffered = 0;
......@@ -466,7 +466,7 @@ check_interfaces(void)
check_interface_channel(ifp);
rc = check_interface_ipv4(ifp);
if(rc > 0) {
send_request(ifp, NULL, 0);
send_request(ifp, NULL, 0, NULL, 0);
send_update(ifp, 0, NULL, 0, NULL, 0);
}
}
......
......@@ -1670,16 +1670,17 @@ send_marginal_ihu(struct interface *ifp)
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)
{
int v4, pb, len;
int v4, pb, spb, len;
if(ifp == NULL) {
struct interface *ifp_auxn;
FOR_ALL_INTERFACES(ifp_auxn) {
if(if_up(ifp_auxn))
continue;
send_request(ifp_auxn, prefix, plen);
send_request(ifp_auxn, prefix, plen, src_prefix, src_plen);
}
return;
}
......@@ -1690,21 +1691,41 @@ send_request(struct interface *ifp,
if(!if_up(ifp))
return;
debugf("sending request to %s for %s.\n",
ifp->name, prefix ? format_prefix(prefix, plen) : "any");
if(!prefix)
debugf("sending request to %s for any.\n", ifp->name);
else
debugf("sending request to %s for %s from %s.\n", ifp->name,
format_prefix(prefix, plen),
format_prefix(src_prefix, src_plen));
v4 = plen >= 96 && v4mapped(prefix);
pb = v4 ? ((plen - 96) + 7) / 8 : (plen + 7) / 8;
len = !prefix ? 2 : 2 + pb;
start_message(ifp, MESSAGE_REQUEST, len);
if(src_plen != 0) {
spb = v4 ? ((src_plen - 96) + 7) / 8 : (src_plen + 7) / 8;
len += spb + 1;
start_message(ifp, MESSAGE_REQUEST_SRC_SPECIFIC, len);
} else {
start_message(ifp, MESSAGE_REQUEST, len);
}
accumulate_byte(ifp, !prefix ? 0 : v4 ? 1 : 2);
accumulate_byte(ifp, !prefix ? 0 : v4 ? plen - 96 : plen);
if(src_plen != 0)
accumulate_byte(ifp, v4 ? src_plen - 96 : src_plen);
if(prefix) {
if(v4)
accumulate_bytes(ifp, prefix + 12, pb);
else
accumulate_bytes(ifp, prefix, pb);
}
if(src_plen != 0) {
if(v4)
accumulate_bytes(ifp, src_prefix + 12, spb);
else
accumulate_bytes(ifp, src_prefix, spb);
end_message(ifp, MESSAGE_REQUEST_SRC_SPECIFIC, len);
return;
}
end_message(ifp, MESSAGE_REQUEST, len);
}
......
......@@ -41,6 +41,7 @@ THE SOFTWARE.
#define MESSAGE_MH_REQUEST 10
/* 11 and 12 are for authentication */
#define MESSAGE_UPDATE_SRC_SPECIFIC 13
#define MESSAGE_REQUEST_SRC_SPECIFIC 14
/* Protocol extension through sub-TLVs. */
#define SUBTLV_PAD1 0
......@@ -81,7 +82,8 @@ void send_self_update(struct interface *ifp);
void send_ihu(struct neighbour *neigh, struct interface *ifp);
void send_marginal_ihu(struct interface *ifp);
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);
void send_unicast_request(struct neighbour *neigh,
const unsigned char *prefix, unsigned char plen);
void send_multihop_request(struct interface *ifp,
......
......@@ -1115,7 +1115,8 @@ send_triggered_update(struct babel_route *route, struct source *oldsrc,
seqno_plus(route->src->seqno, 1),
route->src->id);
} else if(newmetric >= oldmetric + 288) {
send_request(NULL, route->src->prefix, route->src->plen);
send_request(NULL, route->src->prefix, route->src->plen,
route->src->src_prefix, route->src->src_plen);
}
}
}
......
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