Skip to content

Commit

Permalink
Corrected frame counter storing threshold check
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Mika Leppänen committed Aug 18, 2021
1 parent 37f7ae9 commit cbd8a15
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions source/6LoWPAN/ws/ws_pae_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -1760,9 +1760,12 @@ static void ws_pae_controller_frame_counter_store(pae_controller_t *entry, bool
}
uint32_t frame_counter = entry->frame_counters.counter[i].frame_counter;

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

0 comments on commit cbd8a15

Please sign in to comment.