Commit 061d6822 authored by Baptiste Jonglez's avatar Baptiste Jonglez Committed by Juliusz Chroboczek

Don't directly modify a neighbour in parse_hello_subtlv()

parent 916fc9e5
...@@ -167,7 +167,8 @@ parse_update_subtlv(const unsigned char *a, int alen, ...@@ -167,7 +167,8 @@ parse_update_subtlv(const unsigned char *a, int alen,
} }
static int static int
parse_hello_subtlv(const unsigned char *a, int alen, struct neighbour *neigh) parse_hello_subtlv(const unsigned char *a, int alen,
unsigned int *hello_send_us)
{ {
int type, len, i = 0, ret = 0; int type, len, i = 0, ret = 0;
...@@ -192,8 +193,7 @@ parse_hello_subtlv(const unsigned char *a, int alen, struct neighbour *neigh) ...@@ -192,8 +193,7 @@ parse_hello_subtlv(const unsigned char *a, int alen, struct neighbour *neigh)
/* Nothing to do. */ /* Nothing to do. */
} else if(type == SUBTLV_TIMESTAMP) { } else if(type == SUBTLV_TIMESTAMP) {
if(len >= 4) { if(len >= 4) {
DO_NTOHL(neigh->hello_send_us, a + i + 2); DO_NTOHL(*hello_send_us, a + i + 2);
neigh->hello_rtt_receive_time = now;
ret = 1; ret = 1;
} else { } else {
fprintf(stderr, fprintf(stderr,
...@@ -360,6 +360,7 @@ parse_packet(const unsigned char *from, struct interface *ifp, ...@@ -360,6 +360,7 @@ parse_packet(const unsigned char *from, struct interface *ifp,
} else if(type == MESSAGE_HELLO) { } else if(type == MESSAGE_HELLO) {
unsigned short seqno, interval; unsigned short seqno, interval;
int changed; int changed;
unsigned int timestamp;
if(len < 6) goto fail; if(len < 6) goto fail;
DO_NTOHS(seqno, message + 4); DO_NTOHS(seqno, message + 4);
DO_NTOHS(interval, message + 6); DO_NTOHS(interval, message + 6);
...@@ -373,8 +374,11 @@ parse_packet(const unsigned char *from, struct interface *ifp, ...@@ -373,8 +374,11 @@ parse_packet(const unsigned char *from, struct interface *ifp,
schedule_neighbours_check(interval * 15, 0); schedule_neighbours_check(interval * 15, 0);
/* Sub-TLV handling. */ /* Sub-TLV handling. */
if(len > 8) { if(len > 8) {
if(parse_hello_subtlv(message + 8, len - 6, neigh) > 0) if(parse_hello_subtlv(message + 8, len - 6, &timestamp) > 0) {
neigh->hello_send_us = timestamp;
neigh->hello_rtt_receive_time = now;
have_hello_rtt = 1; have_hello_rtt = 1;
}
} }
} else if(type == MESSAGE_IHU) { } else if(type == MESSAGE_IHU) {
unsigned short txcost, interval; unsigned short txcost, interval;
......
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