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