Commit ceda3a02 authored by Antonin Décimo's avatar Antonin Décimo Committed by Juliusz Chroboczek

Expire Index and challenge timer.

parent d66a4d2b
......@@ -508,10 +508,16 @@ preparse_packet(const unsigned char *from, struct interface *ifp,
goto done;
gettime(&now);
if(timeval_compare(&now, &neigh->challenge_deadline) > 0) {
debugf("No pending challenge.\n");
goto done;
}
if(len == sizeof(neigh->nonce) &&
memcmp(neigh->nonce, message + 2, len) == 0 &&
timeval_compare(&now, &neigh->challenge_deadline) <= 0) {
memcmp(neigh->nonce, message + 2, len) == 0) {
const struct timeval zero = {0, 0};
challenge_success = 1;
neigh->challenge_deadline = zero;
} else {
debugf("Challenge failed.\n");
}
......@@ -529,12 +535,11 @@ preparse_packet(const unsigned char *from, struct interface *ifp,
neigh->index_len = index_len;
memcpy(neigh->index, index, index_len);
memcpy(neigh->pc, pc, 4);
neigh->have_index = 1;
accept_packet = 1;
goto maybe_send_challenge_reply;
}
if(neigh == NULL || !neigh->have_index || neigh->index_len != index_len ||
if(neigh == NULL || neigh->index_len != index_len ||
memcmp(index, neigh->index, index_len) != 0) {
neigh = neigh != NULL ? neigh : find_neighbour(from, ifp);
if(neigh == NULL)
......
......@@ -108,7 +108,8 @@ find_neighbour(const unsigned char *address, struct interface *ifp)
neigh->hello_rtt_receive_time = zero;
neigh->echo_receive_time = zero;
neigh->rtt_time = zero;
neigh->challenge_deadline = now;
neigh->index_len = -1;
neigh->challenge_deadline = zero;
neigh->ifp = ifp;
neigh->buf.buf = buf;
neigh->buf.size = ifp->buf.size;
......
......@@ -47,9 +47,8 @@ struct neighbour {
struct timeval echo_receive_time;
unsigned int rtt;
struct timeval rtt_time;
int have_index;
int index_len;
unsigned char pc[4];
int index_len; /* This is -1 when index is undefined */
unsigned char index[32];
unsigned char nonce[NONCE_LEN];
struct timeval challenge_deadline;
......
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