diff --git a/lib/include/srslte/common/string_helpers.h b/lib/include/srslte/common/string_helpers.h index 190ba2a12..ca514380a 100644 --- a/lib/include/srslte/common/string_helpers.h +++ b/lib/include/srslte/common/string_helpers.h @@ -115,7 +115,7 @@ static inline void string_parse_list(const std::string& input, char delimiter, I template const char* to_c_str(fmt::basic_memory_buffer& mem_buffer) { - fmt::format_to(mem_buffer, "{}", '\0'); + mem_buffer.push_back('\0'); return mem_buffer.data(); } diff --git a/lib/include/srslte/upper/rlc_am_lte.h b/lib/include/srslte/upper/rlc_am_lte.h index 95d76c6e9..8e7dbef0e 100644 --- a/lib/include/srslte/upper/rlc_am_lte.h +++ b/lib/include/srslte/upper/rlc_am_lte.h @@ -468,16 +468,11 @@ uint32_t rlc_am_packed_length(rlc_amd_retx_t retx); bool rlc_am_is_valid_status_pdu(const rlc_status_pdu_t& status); bool rlc_am_is_pdu_segment(uint8_t* payload); std::string rlc_am_undelivered_sdu_info_to_string(const std::map& info_queue); -template -void log_rlc_am_status_pdu_to_string(srslog::log_channel& log_ch, - rlc_status_pdu_t* status, - const char* fmt = "%s", - Args&&... args); -void log_rlc_amd_pdu_header_to_string(srslog::log_channel& log_ch, const rlc_amd_pdu_header_t& header); -bool rlc_am_start_aligned(const uint8_t fi); -bool rlc_am_end_aligned(const uint8_t fi); -bool rlc_am_is_unaligned(const uint8_t fi); -bool rlc_am_not_start_aligned(const uint8_t fi); +void log_rlc_amd_pdu_header_to_string(srslog::log_channel& log_ch, const rlc_amd_pdu_header_t& header); +bool rlc_am_start_aligned(const uint8_t fi); +bool rlc_am_end_aligned(const uint8_t fi); +bool rlc_am_is_unaligned(const uint8_t fi); +bool rlc_am_not_start_aligned(const uint8_t fi); } // namespace srslte diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index 6cf4e7093..5e73b420c 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -25,6 +25,42 @@ namespace srslte { +/******************************* + * Helper methods + ******************************/ + +/** + * Logs Status PDU into provided log channel, using fmt_str as format string + */ +template +void log_rlc_am_status_pdu_to_string(srslog::log_channel& log_ch, + const char* fmt_str, + rlc_status_pdu_t* status, + Args&&... args) +{ + if (not log_ch.enabled()) { + return; + } + fmt::memory_buffer buffer; + fmt::format_to(buffer, "ACK_SN = {}, N_nack = {}", status->ack_sn, status->N_nack); + if (status->N_nack > 0) { + fmt::format_to(buffer, ", NACK_SN = "); + for (uint32_t i = 0; i < status->N_nack; ++i) { + if (status->nacks[i].has_so) { + fmt::format_to( + buffer, "[{} {}:{}]", status->nacks[i].nack_sn, status->nacks[i].so_start, status->nacks[i].so_end); + } else { + fmt::format_to(buffer, "[{}]", status->nacks[i].nack_sn); + } + } + } + log_ch(fmt_str, std::forward(args)..., to_c_str(buffer)); +} + +/******************************* + * rlc_am_lte class + ******************************/ + rlc_am_lte::rlc_am_lte(srslog::basic_logger& logger, uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, @@ -563,9 +599,9 @@ bool rlc_am_lte::rlc_am_lte_tx::poll_required() int rlc_am_lte::rlc_am_lte_tx::build_status_pdu(uint8_t* payload, uint32_t nof_bytes) { int pdu_len = parent->rx.get_status_pdu(&tx_status, nof_bytes); - log_rlc_am_status_pdu_to_string(logger.debug, &tx_status); + log_rlc_am_status_pdu_to_string(logger.debug, "%s", &tx_status); if (pdu_len > 0 && nof_bytes >= static_cast(pdu_len)) { - log_rlc_am_status_pdu_to_string(logger.info, &tx_status, "%s Tx status PDU - %s", RB_NAME); + log_rlc_am_status_pdu_to_string(logger.info, "%s Tx status PDU - %s", &tx_status, RB_NAME); parent->rx.reset_status(); @@ -1046,7 +1082,7 @@ void rlc_am_lte::rlc_am_lte_tx::handle_control_pdu(uint8_t* payload, uint32_t no rlc_status_pdu_t status; rlc_am_read_status_pdu(payload, nof_bytes, &status); - log_rlc_am_status_pdu_to_string(logger.info, &status, "%s Rx Status PDU: %s", RB_NAME); + log_rlc_am_status_pdu_to_string(logger.info, "%s Rx Status PDU: %s", &status, RB_NAME); // Sec 5.2.2.2, stop poll reTx timer if status PDU comprises a positive _or_ negative acknowledgement // for the RLC data PDU with sequence number poll_sn @@ -2339,31 +2375,6 @@ bool rlc_am_is_pdu_segment(uint8_t* payload) return ((*(payload) >> 6) & 0x01) == 1; } -template -void log_rlc_am_status_pdu_to_string(srslog::log_channel& log_ch, - rlc_status_pdu_t* status, - const char* fmt, - Args&&... args) -{ - if (not log_ch.enabled()) { - return; - } - fmt::memory_buffer buffer; - fmt::format_to(buffer, "ACK_SN = {}, N_nack = {}", status->ack_sn, status->N_nack); - if (status->N_nack > 0) { - fmt::format_to(buffer, ", NACK_SN = "); - for (uint32_t i = 0; i < status->N_nack; ++i) { - if (status->nacks[i].has_so) { - fmt::format_to( - buffer, "[{} {}:{}]", status->nacks[i].nack_sn, status->nacks[i].so_start, status->nacks[i].so_end); - } else { - fmt::format_to(buffer, "[{}]", status->nacks[i].nack_sn); - } - } - } - log_ch(fmt, std::forward(args)..., to_c_str(buffer)); -} - std::string rlc_am_undelivered_sdu_info_to_string(const std::map& info_queue) { std::string str = "\n";