From 8c53c74c86470b01677795543d3d6002a693e76c Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 2 Feb 2022 18:43:19 +0000 Subject: [PATCH] lib,rlc_am_nr: fix ptr increment when there is no SO when writting status report without SO. --- lib/src/rlc/rlc_am_nr_packing.cc | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/src/rlc/rlc_am_nr_packing.cc b/lib/src/rlc/rlc_am_nr_packing.cc index 031aaa406..ac6303a91 100644 --- a/lib/src/rlc/rlc_am_nr_packing.cc +++ b/lib/src/rlc/rlc_am_nr_packing.cc @@ -240,23 +240,27 @@ int32_t rlc_am_nr_write_status_pdu(const rlc_am_nr_status_pdu_t& status_pdu, ptr++; // write E1 flag in octet 3 - *ptr = (status_pdu.N_nack > 0) ? 0x80 : 0x00; + if (status_pdu.N_nack > 0) { + *ptr = 0x80; + } else { + *ptr = 0x00; + } ptr++; if (status_pdu.N_nack > 0) { for (uint32_t i = 0; i < status_pdu.N_nack; i++) { - if (status_pdu.nacks[i].has_so) { - // write first 8 bit of NACK_SN - *ptr = (status_pdu.nacks[i].nack_sn >> 4) & 0xff; - ptr++; + // write first 8 bit of NACK_SN + *ptr = (status_pdu.nacks[i].nack_sn >> 4) & 0xff; + ptr++; - // write remaining 4 bits of NACK_SN - *ptr = (status_pdu.nacks[i].nack_sn & 0x0f) << 4; + // write remaining 4 bits of NACK_SN + *ptr = (status_pdu.nacks[i].nack_sn & 0x0f) << 4; + // Set E1 if necessary + if (i < (uint32_t)(status_pdu.N_nack - 1)) { + *ptr |= 0x08; + } - // Set E1 if necessary - if (i < (uint32_t)(status_pdu.N_nack - 1)) { - *ptr |= 0x08; - } + if (status_pdu.nacks[i].has_so) { // Set E2 *ptr |= 0x04; @@ -268,8 +272,8 @@ int32_t rlc_am_nr_write_status_pdu(const rlc_am_nr_status_pdu_t& status_pdu, (*ptr) = status_pdu.nacks[i].so_end >> 8; ptr++; (*ptr) = status_pdu.nacks[i].so_end; - ptr++; } + ptr++; } } } else {