Commit a5ef363d authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Add valid field to struct source.

parent c2704e82
...@@ -37,6 +37,8 @@ find_source(const unsigned char *a, const unsigned char *p, unsigned char plen, ...@@ -37,6 +37,8 @@ find_source(const unsigned char *a, const unsigned char *p, unsigned char plen,
{ {
int i; int i;
for(i = 0; i < numsrcs; i++) { for(i = 0; i < numsrcs; i++) {
if(!srcs[i].valid)
continue;
/* This should really be a hash table. For now, check the /* This should really be a hash table. For now, check the
last byte first. */ last byte first. */
if(srcs[i].address[15] != a[15]) if(srcs[i].address[15] != a[15])
...@@ -54,6 +56,7 @@ find_source(const unsigned char *a, const unsigned char *p, unsigned char plen, ...@@ -54,6 +56,7 @@ find_source(const unsigned char *a, const unsigned char *p, unsigned char plen,
fprintf(stderr, "Too many sources.\n"); fprintf(stderr, "Too many sources.\n");
return NULL; return NULL;
} }
srcs[numsrcs].valid = 1;
memcpy(srcs[numsrcs].address, a, 16); memcpy(srcs[numsrcs].address, a, 16);
memcpy(srcs[numsrcs].prefix, p, 16); memcpy(srcs[numsrcs].prefix, p, 16);
srcs[numsrcs].plen = plen; srcs[numsrcs].plen = plen;
...@@ -70,6 +73,8 @@ find_recent_source(const unsigned char *p, unsigned char plen) ...@@ -70,6 +73,8 @@ find_recent_source(const unsigned char *p, unsigned char plen)
struct source *src = NULL; struct source *src = NULL;
for(i = 0; i < numsrcs; i++) { for(i = 0; i < numsrcs; i++) {
if(!srcs[i].valid)
continue;
if(!source_match(&srcs[i], p, plen)) if(!source_match(&srcs[i], p, plen))
continue; continue;
if(!src || src->time < srcs[i].time) if(!src || src->time < srcs[i].time)
......
...@@ -26,6 +26,7 @@ struct source { ...@@ -26,6 +26,7 @@ struct source {
unsigned char address[16]; unsigned char address[16];
unsigned char prefix[16]; unsigned char prefix[16];
unsigned char plen; unsigned char plen;
unsigned char valid;
unsigned short seqno; unsigned short seqno;
unsigned short metric; unsigned short metric;
time_t time; time_t time;
......
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