Commit dd29d40c authored by Matthieu Boutier's avatar Matthieu Boutier Committed by Juliusz Chroboczek

Add some guarded code to handle requests in a near future.

parent 196977c3
......@@ -38,10 +38,13 @@ struct resend *to_resend = NULL;
static int
resend_match(struct resend *resend,
int kind, const unsigned char *prefix, unsigned char plen)
int kind, const unsigned char *prefix, unsigned char plen,
const unsigned char *src_prefix, unsigned char src_plen)
{
return (resend->kind == kind &&
resend->plen == plen && memcmp(resend->prefix, prefix, 16) == 0);
resend->plen == plen && memcmp(resend->prefix, prefix, 16) == 0 &&
resend->src_plen == src_plen &&
memcmp(resend->src_prefix, src_prefix, 16));
}
/* This is called by neigh.c when a neighbour is flushed */
......@@ -54,14 +57,15 @@ flush_resends(struct neighbour *neigh)
static struct resend *
find_resend(int kind, const unsigned char *prefix, unsigned char plen,
struct resend **previous_return)
const unsigned char *src_prefix, unsigned char src_plen,
struct resend **previous_return)
{
struct resend *current, *previous;
previous = NULL;
current = to_resend;
while(current) {
if(resend_match(current, kind, prefix, plen)) {
if(resend_match(current, kind, prefix, plen, src_prefix, src_plen)) {
if(previous_return)
*previous_return = previous;
return current;
......@@ -78,7 +82,10 @@ find_request(const unsigned char *prefix, unsigned char plen,
const unsigned char *src_prefix, unsigned char src_plen,
struct resend **previous_return)
{
return find_resend(RESEND_REQUEST, prefix, plen, previous_return);
if(src_plen != 0)
return NULL;
return find_resend(RESEND_REQUEST, prefix, plen, src_prefix, src_plen,
previous_return);
}
int
......@@ -90,6 +97,9 @@ record_resend(int kind, const unsigned char *prefix, unsigned char plen,
struct resend *resend;
unsigned int ifindex = ifp ? ifp->ifindex : 0;
if(src_plen != 0)
return 0;
if((kind == RESEND_REQUEST &&
input_filter(NULL, prefix, plen, NULL, 0, NULL, ifindex) >=
INFINITY) ||
......@@ -101,7 +111,7 @@ record_resend(int kind, const unsigned char *prefix, unsigned char plen,
if(delay >= 0xFFFF)
delay = 0xFFFF;
resend = find_resend(kind, prefix, plen, NULL);
resend = find_resend(kind, prefix, plen, src_prefix, src_plen, NULL);
if(resend) {
if(resend->delay && delay)
resend->delay = MIN(resend->delay, delay);
......@@ -129,6 +139,8 @@ record_resend(int kind, const unsigned char *prefix, unsigned char plen,
resend->delay = delay;
memcpy(resend->prefix, prefix, 16);
resend->plen = plen;
memcpy(resend->src_prefix, src_prefix, 16);
resend->src_plen = src_plen;
resend->seqno = seqno;
if(id)
memcpy(resend->id, id, 8);
......@@ -215,6 +227,10 @@ satisfy_request(const unsigned char *prefix, unsigned char plen,
{
struct resend *request, *previous;
/* TODO */
if(src_plen != 0)
return 0;
request = find_request(prefix, plen, zeroes, 0, &previous);
if(request == NULL)
return 0;
......@@ -303,7 +319,7 @@ do_resend()
case RESEND_UPDATE:
send_update(resend->ifp, 1,
resend->prefix, resend->plen,
zeroes, 0);
resend->src_prefix, resend->src_plen);
break;
default: abort();
}
......
......@@ -33,6 +33,8 @@ struct resend {
struct timeval time;
unsigned char prefix[16];
unsigned char plen;
unsigned char src_prefix[16];
unsigned char src_plen;
unsigned short seqno;
unsigned char id[8];
struct interface *ifp;
......
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