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