diff --git a/srsenb/hdr/stack/rrc/rrc_nr.h b/srsenb/hdr/stack/rrc/rrc_nr.h index d286dc79d..75fe397fa 100644 --- a/srsenb/hdr/stack/rrc/rrc_nr.h +++ b/srsenb/hdr/stack/rrc/rrc_nr.h @@ -101,6 +101,21 @@ public: int set_aggregate_max_bitrate(uint16_t rnti, const asn1::ngap_nr::ue_aggregate_maximum_bit_rate_s& rates); int allocate_lcid(uint16_t rnti); + // logging + typedef enum { Rx = 0, Tx } direction_t; + template + void log_rrc_message(const std::string& source, + const direction_t dir, + const asn1::dyn_octstring& oct, + const T& msg, + const std::string& msg_type); + + template + void log_rrc_message(const std::string& source, + const direction_t dir, + const srsran::byte_buffer_t& pdu, + const T& msg, + const std::string& msg_type); class ue { public: @@ -186,6 +201,10 @@ public: int add_drb(); + // logging helpers + template + void log_rrc_message(const direction_t dir, const M& pdu, const T& msg, const std::string& msg_type); + // state rrc_nr_state_t state = rrc_nr_state_t::RRC_IDLE; uint8_t transaction_id = 0; @@ -241,22 +260,6 @@ private: // Helper to create PDU from RRC message template srsran::unique_byte_buffer_t pack_into_pdu(const T& msg); - - // logging - typedef enum { Rx = 0, Tx } direction_t; - template - void log_rrc_message(const std::string& source, - const direction_t dir, - const asn1::dyn_octstring& oct, - const T& msg, - const std::string& msg_type); - - template - void log_rrc_message(const std::string& source, - const direction_t dir, - const srsran::byte_buffer_t& pdu, - const T& msg, - const std::string& msg_type); }; } // namespace srsenb diff --git a/srsenb/src/stack/rrc/rrc_nr.cc b/srsenb/src/stack/rrc/rrc_nr.cc index 12346264d..b4fc56957 100644 --- a/srsenb/src/stack/rrc/rrc_nr.cc +++ b/srsenb/src/stack/rrc/rrc_nr.cc @@ -694,9 +694,7 @@ void rrc_nr::ue::send_dl_ccch(dl_ccch_msg_s* dl_ccch_msg) parent->logger.error("Failed to send DL-CCCH"); return; } - fmt::memory_buffer strbuf; - fmt::format_to(strbuf, "rnti=0x{:x}", rnti); - parent->log_rrc_message(fmt::to_string(strbuf), Tx, *pdu.get(), *dl_ccch_msg, "DL-CCCH"); + log_rrc_message(Tx, *pdu.get(), *dl_ccch_msg, "DL-CCCH"); parent->rlc->write_sdu(rnti, (uint32_t)srsran::nr_srb::srb0, std::move(pdu)); } @@ -1247,10 +1245,7 @@ int rrc_nr::ue::pack_secondary_cell_group_cfg(asn1::dyn_octstring& packed_second } packed_secondary_cell_config.resize(bref_pack.distance_bytes()); - fmt::memory_buffer strbuf; - fmt::format_to(strbuf, "rnti=0x{:x}", rnti); - parent->log_rrc_message( - fmt::to_string(strbuf), Tx, packed_secondary_cell_config, cell_group_cfg_pack, "nr-SecondaryCellGroupConfig-r15"); + log_rrc_message(Tx, packed_secondary_cell_config, cell_group_cfg_pack, "nr-SecondaryCellGroupConfig-r15"); return SRSRAN_SUCCESS; } @@ -1307,10 +1302,7 @@ int rrc_nr::ue::pack_nr_radio_bearer_config(asn1::dyn_octstring& packed_nr_beare // resize to packed length packed_nr_bearer_config.resize(bref_pack.distance_bytes()); - fmt::memory_buffer strbuf; - fmt::format_to(strbuf, "rnti=0x{:x}", rnti); - parent->log_rrc_message( - fmt::to_string(strbuf), Tx, packed_nr_bearer_config, radio_bearer_cfg_pack, "nr-RadioBearerConfig1-r15"); + log_rrc_message(Tx, packed_nr_bearer_config, radio_bearer_cfg_pack, "nr-RadioBearerConfig1-r15"); return SRSRAN_SUCCESS; } @@ -1478,4 +1470,12 @@ void rrc_nr::ue::deactivate_bearers() parent->mac->ue_cfg(rnti, uecfg); } +template +void rrc_nr::ue::log_rrc_message(const direction_t dir, const M& pdu, const T& msg, const std::string& msg_type) +{ + fmt::memory_buffer strbuf; + fmt::format_to(strbuf, "rnti=0x{:x}", rnti); + parent->log_rrc_message(fmt::to_string(strbuf), Tx, pdu, msg, msg_type); +} + } // namespace srsenb