Skip to content

Commit cfd1a4d

Browse files
author
Mika Tervonen
committed
Fixed Route cost calculation
If route cost was larger than 0xffff it was calculated incorrectly and wrapped
1 parent 5094614 commit cfd1a4d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2645,6 +2645,10 @@ static uint16_t ws_bootstrap_routing_cost_calculate(protocol_interface_info_entr
26452645
//Scale to 128 based ETX (local read retur 0x100 - 0xffff
26462646
etx = etx >> 1;
26472647
}
2648+
// Make the 0xffff as maximum value
2649+
if (ws_neighbor->routing_cost + etx > 0xffff) {
2650+
return 0xffff;
2651+
}
26482652

26492653
return ws_neighbor->routing_cost + etx;
26502654
}

0 commit comments

Comments
 (0)