Skip to content

Commit cbd8a15

Browse files
author
Mika Leppänen
committed
Corrected frame counter storing threshold check
Corrected frame counter storing check clause to take frame counter exhaust into account. If stored frame counter is at maximum do not initiate storing again.
1 parent 37f7ae9 commit cbd8a15

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

source/6LoWPAN/ws/ws_pae_controller.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,9 +1760,12 @@ static void ws_pae_controller_frame_counter_store(pae_controller_t *entry, bool
17601760
}
17611761
uint32_t frame_counter = entry->frame_counters.counter[i].frame_counter;
17621762

1763-
// If threshold check is disabled or frame counter has advanced for the threshold value, stores the new value
1764-
if (!use_threshold ||
1765-
frame_counter > entry->frame_counters.counter[i].stored_frame_counter + FRAME_COUNTER_STORE_THRESHOLD) {
1763+
/* If threshold check is disabled or frame counter has advanced for the threshold value, stores the new value.
1764+
If frame counter is at maximum at storage, do not initiate storing */
1765+
if (!use_threshold || (
1766+
(frame_counter > entry->frame_counters.counter[i].stored_frame_counter + FRAME_COUNTER_STORE_THRESHOLD) &&
1767+
!(entry->frame_counters.counter[i].stored_frame_counter == UINT32_MAX &&
1768+
frame_counter >= UINT32_MAX - FRAME_COUNTER_STORE_THRESHOLD))) {
17661769
entry->frame_counters.counter[i].stored_frame_counter = frame_counter;
17671770
update_needed = true;
17681771
tr_debug("Stored updated frame counter: index %i value %"PRIu32"", i, frame_counter);

0 commit comments

Comments
 (0)