diff --git a/lib/include/srslte/mac/pdu.h b/lib/include/srslte/mac/pdu.h index d90fb16c7..a40d3edf1 100644 --- a/lib/include/srslte/mac/pdu.h +++ b/lib/include/srslte/mac/pdu.h @@ -133,13 +133,12 @@ public: {} virtual ~pdu() = default; - std::string to_string() + void to_string(fmt::memory_buffer& buffer) { - std::stringstream ss; for (int i = 0; i < nof_subheaders; i++) { - ss << subheaders[i].to_string() << " "; + subheaders[i].to_string(buffer); + fmt::format_to(buffer, " "); } - return ss.str(); } /* Resets the Read/Write position and remaining PDU length */ @@ -289,11 +288,11 @@ class subh public: virtual ~subh() {} - virtual bool read_subheader(uint8_t** ptr) = 0; - virtual void read_payload(uint8_t** ptr) = 0; - virtual void write_subheader(uint8_t** ptr, bool is_last) = 0; - virtual void write_payload(uint8_t** ptr) = 0; - virtual std::string to_string() = 0; + virtual bool read_subheader(uint8_t** ptr) = 0; + virtual void read_payload(uint8_t** ptr) = 0; + virtual void write_subheader(uint8_t** ptr, bool is_last) = 0; + virtual void write_payload(uint8_t** ptr) = 0; + virtual void to_string(fmt::memory_buffer& buffer) = 0; pdu* parent = nullptr; @@ -357,8 +356,8 @@ public: void set_padding(uint32_t padding_len); void set_type(subh_type type_); - void init(); - std::string to_string(); + void init(); + void to_string(fmt::memory_buffer& buffer); bool set_next_mch_sched_info(uint8_t lcid, uint16_t mtch_stop); @@ -396,7 +395,7 @@ public: static uint32_t size_header_sdu(uint32_t nbytes); bool update_space_ce(uint32_t nbytes, bool var_len = false); bool update_space_sdu(uint32_t nbytes); - std::string to_string(); + void to_string(fmt::memory_buffer& buffer); }; class rar_subh : public subh @@ -433,8 +432,8 @@ public: void set_temp_crnti(uint16_t temp_rnti); void set_sched_grant(uint8_t grant[RAR_GRANT_LEN]); - void init(); - std::string to_string(); + void init(); + void to_string(fmt::memory_buffer& buffer); private: uint8_t grant[RAR_GRANT_LEN]; @@ -453,8 +452,8 @@ public: bool has_backoff(); uint8_t get_backoff(); - bool write_packet(uint8_t* ptr); - std::string to_string(); + bool write_packet(uint8_t* ptr); + void to_string(fmt::memory_buffer& buffer); private: bool has_backoff_indicator; diff --git a/lib/include/srslte/upper/gtpu.h b/lib/include/srslte/upper/gtpu.h index 324893c35..502984e51 100644 --- a/lib/include/srslte/upper/gtpu.h +++ b/lib/include/srslte/upper/gtpu.h @@ -70,9 +70,9 @@ struct gtpu_header_t { std::vector ext_buffer; }; -bool gtpu_read_header(srslte::byte_buffer_t* pdu, gtpu_header_t* header, srslog::basic_logger& logger); -bool gtpu_write_header(gtpu_header_t* header, srslte::byte_buffer_t* pdu, srslog::basic_logger& logger); -std::string gtpu_ntoa(uint32_t addr); +bool gtpu_read_header(srslte::byte_buffer_t* pdu, gtpu_header_t* header, srslog::basic_logger& logger); +bool gtpu_write_header(gtpu_header_t* header, srslte::byte_buffer_t* pdu, srslog::basic_logger& logger); +void gtpu_ntoa(fmt::memory_buffer& buffer, uint32_t addr); inline bool gtpu_supported_flags_check(gtpu_header_t* header, srslog::basic_logger& logger) { diff --git a/lib/src/mac/pdu.cc b/lib/src/mac/pdu.cc index 82e4f000c..71ae9470f 100644 --- a/lib/src/mac/pdu.cc +++ b/lib/src/mac/pdu.cc @@ -199,11 +199,10 @@ bool lcid_t::is_sdu() const * SCH PDU *************************/ -std::string sch_pdu::to_string() +void sch_pdu::to_string(fmt::memory_buffer& buffer) { - std::stringstream ss; - ss << (is_ul() ? "UL " : "DL ") << pdu::to_string(); - return ss.str(); + fmt::format_to(buffer, "{}", is_ul() ? "UL" : "DL"); + pdu::to_string(buffer); } void sch_pdu::parse_packet(uint8_t* ptr) @@ -897,19 +896,18 @@ void sch_subh::read_payload(uint8_t** ptr) *ptr += nof_bytes; } -std::string sch_subh::to_string() +void sch_subh::to_string(fmt::memory_buffer& buffer) { - std::stringstream ss; if (is_sdu()) { - ss << "LCID=" << lcid << " len=" << nof_bytes; + fmt::format_to(buffer, "LCID={} len={}", lcid, nof_bytes); } else if (type == SCH_SUBH_TYPE) { if (parent->is_ul()) { switch ((ul_sch_lcid)lcid) { case ul_sch_lcid::CRNTI: - ss << "CRNTI: rnti=0x" << std::hex << get_c_rnti() << std::dec; + fmt::format_to(buffer, "CRNTI: rnti=0x{:x}", get_c_rnti()); break; case ul_sch_lcid::PHR_REPORT: - ss << "PHR: ph=" << get_phr(); + fmt::format_to(buffer, "PHR: ph={}", get_phr()); break; case ul_sch_lcid::TRUNC_BSR: case ul_sch_lcid::SHORT_BSR: @@ -918,18 +916,18 @@ std::string sch_subh::to_string() uint32_t buff_size_bytes[4] = {}; uint32_t lcg = get_bsr(buff_size_idx, buff_size_bytes); if (ul_sch_ce_type() == ul_sch_lcid::LONG_BSR) { - ss << "LBSR: b="; + fmt::format_to(buffer, "LBSR: b="); for (uint32_t i = 0; i < 4; i++) { - ss << buff_size_idx[i] << " "; + fmt::format_to(buffer, "{} ", buff_size_idx[i]); } } else if (ul_sch_ce_type() == ul_sch_lcid::SHORT_BSR) { - ss << "SBSR: lcg=" << lcg << " b=" << buff_size_idx[lcg]; + fmt::format_to(buffer, "SBSR: lcg={} b={}", lcg, buff_size_idx[lcg]); } else { - ss << "TBSR: lcg=" << lcg << " b=" << buff_size_idx[lcg]; + fmt::format_to(buffer, "TBSR: lcg={} b={}", lcg, buff_size_idx[lcg]); } } break; case ul_sch_lcid::PADDING: - ss << "PAD: len=" << get_payload_size(); + fmt::format_to(buffer, "PAD: len={}", get_payload_size()); break; default: // do nothing @@ -938,20 +936,20 @@ std::string sch_subh::to_string() } else { switch ((dl_sch_lcid)lcid) { case dl_sch_lcid::CON_RES_ID: - ss << "CON_RES: id=0x" << std::hex << get_con_res_id() << std::dec; + fmt::format_to(buffer, "CON_RES: id=0x{:x}", get_con_res_id()); break; case dl_sch_lcid::TA_CMD: - ss << "TA: ta=" << std::to_string(get_ta_cmd()); + fmt::format_to(buffer, "TA: ta={}", get_ta_cmd()); break; case dl_sch_lcid::SCELL_ACTIVATION_4_OCTET: case dl_sch_lcid::SCELL_ACTIVATION: - ss << "SCELL_ACT"; + fmt::format_to(buffer, "SCELL_ACT"); break; case dl_sch_lcid::DRX_CMD: - ss << "DRX"; + fmt::format_to(buffer, "DRX"); break; case dl_sch_lcid::PADDING: - ss << "PAD: len=" << get_payload_size(); + fmt::format_to(buffer, "PAD: len={}", get_payload_size()); break; default: break; @@ -960,16 +958,15 @@ std::string sch_subh::to_string() } else if (type == MCH_SUBH_TYPE) { switch ((mch_lcid)lcid) { case mch_lcid::MCH_SCHED_INFO: - ss << "MCH_SCHED_INFO"; + fmt::format_to(buffer, "MCH_SCHED_INFO"); break; case mch_lcid::PADDING: - ss << "PAD: len=" << get_payload_size(); + fmt::format_to(buffer, "PAD: len={}", get_payload_size()); break; default: break; } } - return ss.str(); } uint8_t sch_subh::buff_size_table(uint32_t buffer_size) @@ -1000,11 +997,11 @@ uint8_t sch_subh::phr_report_table(float phr_value) return (uint8_t)floor(phr_value + 23); } -std::string rar_pdu::to_string() +void rar_pdu::to_string(fmt::memory_buffer& buffer) { std::string msg("MAC PDU for RAR: "); - msg += pdu::to_string(); - return msg; + fmt::format_to(buffer, "MAC PDU for RAR: "); + pdu::to_string(buffer); } rar_pdu::rar_pdu(uint32_t max_rars_, srslog::basic_logger& logger) : pdu(max_rars_, logger) @@ -1065,20 +1062,17 @@ bool rar_pdu::write_packet(uint8_t* ptr) return true; } -std::string rar_subh::to_string() +void rar_subh::to_string(fmt::memory_buffer& buffer) { - std::stringstream ss; if (type == RAPID) { - ss << "RAPID: " << preamble << ", Temp C-RNTI: " << temp_rnti << ", TA: " << ta << ", UL Grant: "; + fmt::format_to(buffer, "RAPID: {}, Temp C-RNTI: {}, TA: {}, UL Grant: ", preamble, temp_rnti, ta); } else { - ss << "Backoff Indicator: " << int32_t(((rar_pdu*)parent)->get_backoff()) << " "; + fmt::format_to(buffer, "Backoff Indicator: {} ", int32_t(((rar_pdu*)parent)->get_backoff())); } char tmp[16]; srslte_vec_sprint_hex(tmp, sizeof(tmp), grant, RAR_GRANT_LEN); - ss << tmp; - - return ss.str(); + fmt::format_to(buffer, "{}", tmp); } void rar_subh::init() diff --git a/lib/src/upper/gtpu.cc b/lib/src/upper/gtpu.cc index 3f7bfbd4a..2b22923ea 100644 --- a/lib/src/upper/gtpu.cc +++ b/lib/src/upper/gtpu.cc @@ -178,7 +178,7 @@ bool gtpu_read_header(srslte::byte_buffer_t* pdu, gtpu_header_t* header, srslog: } // Helper function to return a string from IPv4 address for easy printing -std::string gtpu_ntoa(uint32_t addr) +void gtpu_ntoa(fmt::memory_buffer& buffer, uint32_t addr) { char tmp_str[INET_ADDRSTRLEN + 1] = {}; struct in_addr tmp_addr = {}; @@ -186,9 +186,10 @@ std::string gtpu_ntoa(uint32_t addr) tmp_addr.s_addr = addr; const char* tmp_ptr = inet_ntop(AF_INET, &tmp_addr, tmp_str, INET_ADDRSTRLEN); if (tmp_ptr == NULL) { - return std::string("Invalid IPv4 address"); + fmt::format_to(buffer, "Invalid IPv4 address"); + } else { + fmt::format_to(buffer, "{}", tmp_str); } - return std::string(tmp_str); } } // namespace srslte diff --git a/lib/test/mac/pdu_test.cc b/lib/test/mac/pdu_test.cc index 1c21b5afd..2cdd536da 100644 --- a/lib/test/mac/pdu_test.cc +++ b/lib/test/mac/pdu_test.cc @@ -54,7 +54,9 @@ int mac_rar_pdu_unpack_test1() srslte::rar_pdu rar_pdu_msg; rar_pdu_msg.init_rx(sizeof(rar_pdu_tv1)); rar_pdu_msg.parse_packet(rar_pdu_tv1); - std::cout << rar_pdu_msg.to_string() << std::endl; + fmt::memory_buffer buffer; + rar_pdu_msg.to_string(buffer); + std::cout << fmt::to_string(buffer) << std::endl; TESTASSERT(not rar_pdu_msg.has_backoff()); TESTASSERT(rar_pdu_msg.nof_subh() == 1); @@ -72,7 +74,9 @@ int mac_rar_pdu_unpack_test2() srslte::rar_pdu rar_pdu_msg; rar_pdu_msg.init_rx(sizeof(rar_pdu_tv2)); rar_pdu_msg.parse_packet(rar_pdu_tv2); - std::cout << rar_pdu_msg.to_string() << std::endl; + fmt::memory_buffer buffer; + rar_pdu_msg.to_string(buffer); + std::cout << fmt::to_string(buffer) << std::endl; TESTASSERT(rar_pdu_msg.nof_subh() == 2); TESTASSERT(rar_pdu_msg.has_backoff()); @@ -101,7 +105,9 @@ int mac_rar_pdu_unpack_test3() TESTASSERT(rar_pdu_msg.parse_packet(rar_pdu) != SRSLTE_SUCCESS); TESTASSERT(rar_pdu_msg.nof_subh() == 0); - std::cout << rar_pdu_msg.to_string() << std::endl; + fmt::memory_buffer buffer; + rar_pdu_msg.to_string(buffer); + std::cout << fmt::to_string(buffer) << std::endl; return SRSLTE_SUCCESS; } @@ -500,8 +506,9 @@ int mac_sch_pdu_pack_test6() for (uint32_t i = 0; i < 4; i++) { TESTASSERT(buff_size_rx[i] == buff_size_tx[i]); } - - mac_logger.info("%s", pdu.to_string().c_str()); + fmt::memory_buffer str_buffer; + pdu.to_string(str_buffer); + mac_logger.info("%s", str_buffer.data()); // log mac_logger.info(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):", buffer.N_bytes); @@ -530,7 +537,9 @@ int mac_sch_pdu_pack_test6() // write PDU pdu.write_packet(mac_logger); - mac_logger.info("%s", pdu.to_string().c_str()); + str_buffer.clear(); + pdu.to_string(str_buffer); + mac_logger.info("%s", str_buffer.data()); TESTASSERT(memcmp(buffer.msg, tv2, buffer.N_bytes) == 0); @@ -583,7 +592,9 @@ int mac_sch_pdu_pack_test6() // write PDU pdu.write_packet(mac_logger); - mac_logger.info("%s", pdu.to_string().c_str()); + str_buffer.clear(); + pdu.to_string(str_buffer); + mac_logger.info("%s", str_buffer.data()); TESTASSERT(memcmp(buffer.msg, tv3, buffer.N_bytes) == 0); @@ -999,7 +1010,9 @@ int mac_sch_pdu_unpack_test3() } } - std::cout << pdu.to_string() << std::endl; + fmt::memory_buffer buffer; + pdu.to_string(buffer); + std::cout << fmt::to_string(buffer) << std::endl; #if HAVE_PCAP pcap_handle->write_dl_crnti(tv, sizeof(tv), 0x1001, true, 1, 0); diff --git a/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_harq.h b/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_harq.h index c2147410f..6ecfb50f4 100644 --- a/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_harq.h +++ b/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_harq.h @@ -24,6 +24,7 @@ namespace srsenb { class harq_proc { public: + harq_proc(); void init(uint32_t id); void reset(uint32_t tb_idx); uint32_t get_id() const; @@ -45,6 +46,7 @@ protected: enum ack_t { NACK, ACK }; + srslog::basic_logger* logger; bool ack_state[SRSLTE_MAX_TB]; bool active[SRSLTE_MAX_TB]; std::array ndi = {}; diff --git a/srsenb/src/stack/mac/sched_ue_ctrl/sched_harq.cc b/srsenb/src/stack/mac/sched_ue_ctrl/sched_harq.cc index 5ced31492..cde622989 100644 --- a/srsenb/src/stack/mac/sched_ue_ctrl/sched_harq.cc +++ b/srsenb/src/stack/mac/sched_ue_ctrl/sched_harq.cc @@ -27,6 +27,8 @@ namespace srsenb { * ******************************************************/ +harq_proc::harq_proc() : logger(&srslog::fetch_basic_logger("MAC")) {} + void harq_proc::init(uint32_t id_) { id = id_; @@ -76,19 +78,17 @@ tti_point harq_proc::get_tti() const int harq_proc::set_ack_common(uint32_t tb_idx, bool ack_) { if (is_empty(tb_idx)) { - srslog::fetch_basic_logger("MAC").warning("Received ACK for inactive harq"); + logger->warning("Received ACK for inactive harq"); return SRSLTE_ERROR; } ack_state[tb_idx] = ack_; - srslog::fetch_basic_logger("MAC").debug( - "ACK=%d received pid=%d, tb_idx=%d, n_rtx=%d, max_retx=%d", ack_, id, tb_idx, n_rtx[tb_idx], max_retx); + logger->debug("ACK=%d received pid=%d, tb_idx=%d, n_rtx=%d, max_retx=%d", ack_, id, tb_idx, n_rtx[tb_idx], max_retx); if (!ack_ && (n_rtx[tb_idx] + 1 >= max_retx)) { - srslog::fetch_basic_logger("MAC").info( - "SCHED: discarding TB=%d pid=%d, tti=%d, maximum number of retx exceeded (%d)", - tb_idx, - id, - tti.to_uint(), - max_retx); + logger->info("SCHED: discarding TB=%d pid=%d, tti=%d, maximum number of retx exceeded (%d)", + tb_idx, + id, + tti.to_uint(), + max_retx); active[tb_idx] = false; } else if (ack_) { active[tb_idx] = false; diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index 8ae03fa68..09bbedc8f 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -255,7 +255,9 @@ void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channe mac_msg_ul.init_rx(nof_bytes, true); mac_msg_ul.parse_packet(pdu); - logger.info("0x%x %s", rnti, mac_msg_ul.to_string().c_str()); + fmt::memory_buffer buffer; + mac_msg_ul.to_string(buffer); + logger.info("0x%x %s", rnti, buffer.data()); if (pcap) { pcap->write_ul_crnti(pdu, nof_bytes, rnti, true, last_tti, UL_CC_IDX); @@ -529,7 +531,9 @@ uint8_t* ue::generate_pdu(uint32_t ue_cc_idx, } } ret = mac_msg_dl.write_packet(logger); - logger.info("0x%x %s", rnti, mac_msg_dl.to_string().c_str()); + fmt::memory_buffer str_buffer; + mac_msg_dl.to_string(str_buffer); + logger.info("0x%x %s", rnti, str_buffer.data()); } else { logger.error( "Invalid parameters calling generate_pdu: cc_idx=%d, harq_pid=%d, tb_idx=%d", ue_cc_idx, harq_pid, tb_idx); diff --git a/srsenb/src/stack/upper/gtpu.cc b/srsenb/src/stack/upper/gtpu.cc index e90778662..e6fe14b8b 100644 --- a/srsenb/src/stack/upper/gtpu.cc +++ b/srsenb/src/stack/upper/gtpu.cc @@ -153,12 +153,14 @@ uint32_t gtpu::add_bearer(uint16_t rnti, uint32_t lcid, uint32_t addr, uint32_t ue_teidin_db[rnti][lcid].push_back(teid_in); + fmt::memory_buffer buffer; + srslte::gtpu_ntoa(buffer, htonl(addr)); logger.info("New tunnel teid_in=0x%x, teid_out=0x%x, rnti=0x%x, lcid=%d, addr=%s", teid_in, teid_out, rnti, lcid, - srslte::gtpu_ntoa(htonl(addr)).c_str()); + buffer.data()); if (props != nullptr) { if (props->flush_before_teidin_present) { @@ -517,23 +519,29 @@ srslte::span gtpu::get_lcid_teids(uint16_t rnti, uint32_t lcid) void gtpu::log_message(tunnel& tun, bool is_rx, srslte::span pdu, int pdcp_sn) { - fmt::basic_memory_buffer strbuf; - struct iphdr* ip_pkt = (struct iphdr*)pdu.data(); + struct iphdr* ip_pkt = (struct iphdr*)pdu.data(); if (ip_pkt->version != 4 && ip_pkt->version != 6) { logger.error("%s SDU with invalid IP version %s SPGW", is_rx ? "Received" : "Sending", is_rx ? "from" : "to"); return; } + if (not logger.info.enabled()) { + return; + } - const char* dir = "Tx"; - fmt::memory_buffer strbuf2; + fmt::basic_memory_buffer strbuf; + const char* dir = "Tx"; + fmt::memory_buffer strbuf2, addrbuf; + srslte::gtpu_ntoa(addrbuf, htonl(tun.spgw_addr)); if (is_rx) { dir = "Rx"; - fmt::format_to(strbuf2, "{}:0x{:0x} > ", srslte::gtpu_ntoa(htonl(tun.spgw_addr)), tun.teid_in); + fmt::format_to(strbuf2, "{}:0x{:0x} > ", addrbuf.data(), tun.teid_in); if (not tun.dl_enabled) { fmt::format_to(strbuf2, "DL (buffered), "); } else if (tun.fwd_teid_in_present) { tunnel& tx_tun = tunnels.at(tun.fwd_teid_in); - fmt::format_to(strbuf2, "{}:0x{:0x} (forwarded), ", srslte::gtpu_ntoa(htonl(tx_tun.spgw_addr)), tx_tun.teid_in); + addrbuf.clear(); + srslte::gtpu_ntoa(addrbuf, htonl(tx_tun.spgw_addr)); + fmt::format_to(strbuf2, "{}:0x{:0x} (forwarded), ", addrbuf.data(), tx_tun.teid_in); } else { fmt::format_to(strbuf2, "DL, "); } @@ -543,7 +551,7 @@ void gtpu::log_message(tunnel& tun, bool is_rx, srslte::span pdu, int p } else { fmt::format_to(strbuf2, "UL "); } - fmt::format_to(strbuf2, "> {}:0x{:0x}, ", srslte::gtpu_ntoa(htonl(tun.spgw_addr)), tun.teid_in); + fmt::format_to(strbuf2, "> {}:0x{:0x}, ", addrbuf.data(), tun.teid_in); } fmt::format_to(strbuf, "{} S1-U SDU, {}rnti=0x{:0x}, lcid={}, n_bytes={}, IPv{}", @@ -554,12 +562,16 @@ void gtpu::log_message(tunnel& tun, bool is_rx, srslte::span pdu, int p pdu.size(), (int)ip_pkt->version); if (ip_pkt->version == 4) { - fmt::format_to(strbuf, " {} > {}", srslte::gtpu_ntoa(ip_pkt->saddr), srslte::gtpu_ntoa(ip_pkt->daddr)); + addrbuf.clear(); + strbuf2.clear(); + srslte::gtpu_ntoa(addrbuf, ip_pkt->saddr); + srslte::gtpu_ntoa(strbuf2, ip_pkt->daddr); + fmt::format_to(strbuf, " {} > {}", addrbuf.data(), strbuf2.data()); if (ntohs(ip_pkt->tot_len) != pdu.size()) { logger.error("IP Len and PDU N_bytes mismatch"); } } - logger.info(pdu.data(), pdu.size(), fmt::to_string(strbuf)); + logger.info(pdu.data(), pdu.size(), "%s", strbuf.data()); } /**************************************************************************** diff --git a/srsepc/src/spgw/gtpu.cc b/srsepc/src/spgw/gtpu.cc index cf749272c..5a2366f5e 100644 --- a/srsepc/src/spgw/gtpu.cc +++ b/srsepc/src/spgw/gtpu.cc @@ -206,8 +206,12 @@ void spgw::gtpu::handle_sgi_pdu(srslte::unique_byte_buffer_t msg) // Logging PDU info m_logger.debug("SGi PDU -- IP version %d, Total length %d", int(iph->version), ntohs(iph->tot_len)); - m_logger.debug("SGi PDU -- IP src addr %s", srslte::gtpu_ntoa(iph->saddr).c_str()); - m_logger.debug("SGi PDU -- IP dst addr %s", srslte::gtpu_ntoa(iph->daddr).c_str()); + fmt::memory_buffer buffer; + srslte::gtpu_ntoa(buffer, iph->saddr); + m_logger.debug("SGi PDU -- IP src addr %s", buffer.data()); + buffer.clear(); + srslte::gtpu_ntoa(buffer, iph->daddr); + m_logger.debug("SGi PDU -- IP dst addr %s", buffer.data()); // Find user and control tunnel gtpu_fteid_it = m_ip_to_usr_teid.find(iph->daddr); @@ -309,8 +313,12 @@ void spgw::gtpu::send_all_queued_packets(srslte::gtp_fteid_t bool spgw::gtpu::modify_gtpu_tunnel(in_addr_t ue_ipv4, srslte::gtpc_f_teid_ie dw_user_fteid, uint32_t up_ctrl_teid) { m_logger.info("Modifying GTP-U Tunnel."); - m_logger.info("UE IP %s", srslte::gtpu_ntoa(ue_ipv4).c_str()); - m_logger.info("Downlink eNB addr %s, U-TEID 0x%x", srslte::gtpu_ntoa(dw_user_fteid.ipv4).c_str(), dw_user_fteid.teid); + fmt::memory_buffer buffer; + srslte::gtpu_ntoa(buffer, ue_ipv4); + m_logger.info("UE IP %s", buffer.data()); + buffer.clear(); + srslte::gtpu_ntoa(buffer, dw_user_fteid.ipv4); + m_logger.info("Downlink eNB addr %s, U-TEID 0x%x", buffer.data(), dw_user_fteid.teid); m_logger.info("Uplink C-TEID: 0x%x", up_ctrl_teid); m_ip_to_usr_teid[ue_ipv4] = dw_user_fteid; m_ip_to_ctr_teid[ue_ipv4] = up_ctrl_teid; diff --git a/srsue/src/stack/mac/demux.cc b/srsue/src/stack/mac/demux.cc index 546508f1a..995a487f7 100644 --- a/srsue/src/stack/mac/demux.cc +++ b/srsue/src/stack/mac/demux.cc @@ -153,7 +153,11 @@ void demux::process_pdu(uint8_t* mac_pdu, uint32_t nof_bytes, srslte::pdu_queue: // Unpack DLSCH MAC PDU mac_msg.init_rx(nof_bytes); mac_msg.parse_packet(mac_pdu); - Info("%s", mac_msg.to_string().c_str()); + { + fmt::memory_buffer buffer; + mac_msg.to_string(buffer); + Info("%s", buffer.data()); + } process_sch_pdu(&mac_msg); pdus.deallocate(mac_pdu); break; diff --git a/srsue/src/stack/mac/mux.cc b/srsue/src/stack/mac/mux.cc index 0c7aa06ad..3e8d0f592 100644 --- a/srsue/src/stack/mac/mux.cc +++ b/srsue/src/stack/mac/mux.cc @@ -285,8 +285,10 @@ uint8_t* mux::pdu_get(srslte::byte_buffer_t* payload, uint32_t pdu_sz) bsr_procedure->update_bsr_tti_end(&bsr); // Generate MAC PDU and save to buffer - uint8_t* ret = pdu_msg.write_packet(logger); - Info("%s", pdu_msg.to_string().c_str()); + uint8_t* ret = pdu_msg.write_packet(logger); + fmt::memory_buffer buffer; + pdu_msg.to_string(buffer); + Info("%s", buffer.data()); Debug("Assembled MAC PDU msg size %d/%d bytes", pdu_msg.get_pdu_len() - pdu_msg.rem_size(), pdu_sz); return ret;