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

Ignore a Challenge Request received on multicast.

parent 024c17ae
...@@ -448,8 +448,9 @@ network_address(int ae, const unsigned char *a, unsigned int len, ...@@ -448,8 +448,9 @@ network_address(int ae, const unsigned char *a, unsigned int len,
} }
static struct neighbour * static struct neighbour *
preparse_packet(const unsigned char *body, int bodylen, preparse_packet(const unsigned char *from, struct interface *ifp,
const unsigned char *address, struct interface *ifp) const unsigned char *body, int bodylen,
const unsigned char *to)
{ {
int rc, i; int rc, i;
struct neighbour *neigh = NULL; struct neighbour *neigh = NULL;
...@@ -485,20 +486,24 @@ preparse_packet(const unsigned char *body, int bodylen, ...@@ -485,20 +486,24 @@ preparse_packet(const unsigned char *body, int bodylen,
} }
if(index != NULL) if(index != NULL)
goto done; goto done;
debugf("Received PC from %s.\n", format_address(address)); debugf("Received PC from %s.\n", format_address(from));
pc = message + 2; pc = message + 2;
index = message + 6; index = message + 6;
index_len = len - 4; index_len = len - 4;
} else if(type == MESSAGE_CHALLENGE_REQUEST) { } else if(type == MESSAGE_CHALLENGE_REQUEST) {
debugf("Received challenge request from %s.\n", debugf("Received challenge request from %s.\n",
format_address(address)); format_address(from));
if(IN6_IS_ADDR_MULTICAST(to))
goto done;
nonce = message + 2; nonce = message + 2;
nonce_len = len; nonce_len = len;
} else if(type == MESSAGE_CHALLENGE_REPLY) { } else if(type == MESSAGE_CHALLENGE_REPLY) {
debugf("Received challenge reply from %s.\n", debugf("Received challenge reply from %s.\n",
format_address(address)); format_address(from));
neigh = neigh != NULL ? neigh : find_neighbour(address, ifp); neigh = neigh != NULL ? neigh : find_neighbour(from, ifp);
if(neigh == NULL) if(neigh == NULL)
goto done; goto done;
...@@ -531,7 +536,7 @@ preparse_packet(const unsigned char *body, int bodylen, ...@@ -531,7 +536,7 @@ preparse_packet(const unsigned char *body, int bodylen,
if(neigh == NULL || !neigh->have_index || neigh->index_len != index_len || if(neigh == NULL || !neigh->have_index || 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(address, ifp); neigh = neigh != NULL ? neigh : find_neighbour(from, ifp);
if(neigh == NULL) if(neigh == NULL)
return NULL; return NULL;
rc = send_challenge_request(neigh); rc = send_challenge_request(neigh);
...@@ -550,7 +555,7 @@ preparse_packet(const unsigned char *body, int bodylen, ...@@ -550,7 +555,7 @@ preparse_packet(const unsigned char *body, int bodylen,
maybe_send_challenge_reply: maybe_send_challenge_reply:
if(nonce != NULL) { /* a challenge request was received */ if(nonce != NULL) { /* a challenge request was received */
neigh = neigh != NULL ? neigh : find_neighbour(address, ifp); neigh = neigh != NULL ? neigh : find_neighbour(from, ifp);
if(neigh == NULL) if(neigh == NULL)
return NULL; return NULL;
send_challenge_reply(neigh, nonce, nonce_len); send_challenge_reply(neigh, nonce, nonce_len);
...@@ -618,7 +623,7 @@ parse_packet(const unsigned char *from, struct interface *ifp, ...@@ -618,7 +623,7 @@ parse_packet(const unsigned char *from, struct interface *ifp,
fputs("Received wrong hmac.\n", stderr); fputs("Received wrong hmac.\n", stderr);
return; return;
case 1: case 1:
neigh = preparse_packet(packet, bodylen, from, ifp); neigh = preparse_packet(from, ifp, packet, bodylen, to);
if(neigh == NULL) { if(neigh == NULL) {
fputs("Received wrong PC or failed the challenge.\n", stderr); fputs("Received wrong PC or failed the challenge.\n", stderr);
return; return;
......
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